27 #include <QVTKOpenGLWidget.h>
30 #include <vtkAssemblyPath.h>
32 #include <vtkCommand.h>
33 #include <vtkGlyph3D.h>
34 #include <vtkInteractorStyleSwitch.h>
36 #include <vtkLightCollection.h>
37 #include <vtkLineWidget.h>
38 #include <vtkObjectFactory.h>
39 #include <vtkPoints.h>
40 #include <vtkPolyData.h>
41 #include <vtkPolyDataMapper.h>
42 #include <vtkProperty.h>
43 #include <vtkRenderer.h>
44 #include <vtkRendererCollection.h>
45 #include <vtkRenderWindow.h>
46 #include <vtkRenderWindowInteractor.h>
47 #include <vtkSmartPointer.h>
48 #include <vtkPlaneSource.h>
49 #include <vtkTransform.h>
60 virtual void Execute(vtkObject *caller,
unsigned long event,
void *)
65 if(event == vtkCommand::InteractionEvent)
103 class axlActorPlanePrivate
107 vtkPlaneSource *planeSource;
108 vtkLineWidget *lineWidget;
110 QVTKOpenGLWidget *widget;
113 vtkSmartPointer<vtkRenderer> renderer;
116 #if (VTK_MAJOR_VERSION <= 5)
129 return d->planeSource;
142 if(display && d->lineWidget){
146 if(!display && d->lineWidget){
153 if(!d->lineWidget ) {
154 qDebug() <<
"No tet actor computed for this axlActorPlane.";
159 d->lineWidget->SetEnabled(1);
163 d->lineWidget->SetEnabled(0);
176 d->lineWidget = vtkLineWidget::New();
178 d->lineWidget->SetProp3D(this->
getActor());
179 d->lineWidget->PlaceWidget();
180 d->lineWidget->SetPoint1(d->planeSource->GetCenter());
181 axlPoint center(d->planeSource->GetCenter()[0], d->planeSource->GetCenter()[1], d->planeSource->GetCenter()[2]);
182 axlPoint normal(d->planeSource->GetNormal()[0], d->planeSource->GetNormal()[1], d->planeSource->GetNormal()[2]);
184 d->lineWidget->SetPoint2(center.coordinates());
189 d->lineWidget->AddObserver(vtkCommand::InteractionEvent, d->planeObserver);
192 d->planeObserver->lineWidget = d->lineWidget;
196 d->lineWidget->SetEnabled(
true);
207 d->lineWidget->RemoveAllObservers();
208 d->lineWidget->SetEnabled(
false);
209 d->lineWidget->Delete();
210 d->lineWidget = NULL;
214 if (d->planeObserver)
215 d->planeObserver->lineWidget = d->lineWidget;
224 this->
setMapper(vtkSmartPointer<vtkPolyDataMapper>::New());
225 this->
setActor(vtkSmartPointer<vtkActor>::New());
227 d->planeSource = vtkPlaneSource::New();
228 d->planeSource->SetResolution(1, 1);
231 #if (VTK_MAJOR_VERSION <= 5)
232 this->
getMapper()->SetInput(d->planeSource->GetOutput());
234 this->
getMapper()->SetInputData(d->planeSource->GetOutput());
241 if(!d->planeObserver)
245 this->
getInteractor()->AddObserver(vtkCommand::InteractionEvent, d->planeObserver);
248 d->planeObserver->observerDataAssembly =
this;
250 d->planeObserver->observerData_planeSource = d->planeSource;
251 d->planeObserver->observerData_plane = d->plane;
255 QColor color = d->plane->color();
256 this->
getActor()->GetProperty()->SetColor(color.redF(), color.greenF(), color.blueF());
258 QString shader = d->plane->shader();
259 if(!shader.isEmpty())
267 connect(d->plane, SIGNAL(modifiedGeometry()),
this, SLOT(
onUpdateGeometry()));
268 connect(d->plane, SIGNAL(modifiedProperty()),
this, SLOT(
onUpdateProperty()));
271 qDebug()<<
"no axlPlane available";
277 d->renderer = renderer;
297 QColor color =
data->color();
298 this->
getActor()->GetProperty()->SetColor(color.redF(), color.greenF(), color.blueF());
309 vtkProperty *prop = this->
getActor()->GetProperty();
313 QColor color =
data->color();
314 qreal *h =
new qreal(0.0);
315 qreal *s =
new qreal(0.0);
316 qreal *l =
new qreal(0.0);
317 color.getHslF(h, s, l);
318 color.setHslF(*h, *s, *l + (1.0 - *l) / 2.0);
319 prop->SetColor(color.redF(), color.greenF(), color.blueF());
332 vtkProperty *prop = this->
getActor()->GetProperty();
335 QColor color =
data->color();
336 qreal *h =
new qreal(0.0);
337 qreal *s =
new qreal(0.0);
338 qreal *l =
new qreal(0.0);
339 color.getHslF(h, s, l);
340 color.setHslF(*h, *s, *l + (1.0 - *l)/2.0);
341 prop->SetColor(color.redF(), color.greenF(), color.blueF());
361 this->
getInteractor()->RemoveObservers(vtkCommand::InteractionEvent, d->planeObserver);
362 this->
getInteractor()->RemoveObservers(vtkCommand::MouseMoveEvent, d->planeObserver);
363 d->planeObserver->observerDataAssembly = NULL;
365 d->planeObserver->observerData_planeSource = NULL;
366 d->planeObserver->observerData_plane = NULL;
367 d->planeObserver->axlInteractorStyle = NULL;
368 d->planeObserver->Delete();
369 d->planeObserver = NULL;
377 d->planeSource->Delete();
378 d->planeSource = NULL;
391 d->lineWidget = NULL;
395 this->RemoveAllObservers();
397 this->
getActor()->RemoveAllObservers();
400 actorComposite->removeActorReference(
this);
407 d->planeSource->SetOrigin(0.0, 0.0, 0.0);
408 d->planeSource->SetPoint1(d->plane->size() * 100, 0.0, 0.0);
409 d->planeSource->SetPoint2(0.0, d->plane->size() * 100, 0.0);
411 d->planeSource->SetCenter(d->plane->point()->coordinates());
412 d->planeSource->SetNormal(d->plane->normal()->coordinates());
413 d->planeSource->Update();
414 d->planeSource->Modified();
418 d->lineWidget->SetPoint1(d->plane->point()->coordinates());
419 axlPoint p2 = (*(d->plane->point())) + (*(d->plane->normal()));
424 if(!d->plane->fields().isEmpty())
425 d->plane->touchField();
427 if(d->plane->updateView())
435 d->planeSource->SetOrigin(0.0, 0.0, 0.0);
436 d->planeSource->SetPoint1(d->plane->size() * 100, 0.0, 0.0);
437 d->planeSource->SetPoint2(0.0, d->plane->size() * 100, 0.0);
439 d->planeSource->SetCenter(d->plane->point()->coordinates());
440 d->planeSource->SetNormal(d->plane->normal()->coordinates());
441 d->planeSource->Update();
442 d->planeSource->Modified();
444 if(!d->plane->fields().isEmpty())
445 d->plane->touchField();
451 d->lineWidget = NULL;
453 d->planeObserver = NULL;
454 d->planeSource =NULL;
469 qDebug() <<
"No tet actor computed for this axlActorBSpline.";
473 return d->lineWidget->GetEnabled();
void setNormal(axlPoint *normal)
Change second point of this plane.
Class axlPoint defines 3D points.
void showPlaneWidget(bool show)
void setPlaneWidget(bool planeWidget)
virtual void setDisplay(bool display)
double * coordinates(void) const
Returns coordinates of this point.
void stateChanged(dtkAbstractData *data, int mode)
Class axlPlane defines 3D planes.
virtual void setState(int state)
vtkPlaneSource * observerData_planeSource
static axlActorPlane * New(void)
virtual int getState(void)
axlActorPlane * observerDataAssembly
void setPoint(axlPoint *point)
Change first point of this plane.
void setSize(double size)
void onModeChanged(int state)
vtkStandardNewMacro(axlActorPlane)
void setDisplay(bool display)
virtual void Execute(vtkObject *caller, unsigned long event, void *)
bool isShowPlaneWidget(void)
virtual void setShader(QString vsfile)
virtual axlAbstractActor * parent(void)
virtual void setOpacity(double opacity)
void setRenderer(vtkRenderer *renderer)
void setMapper(vtkSmartPointer< vtkPolyDataMapper > mapper)
vtkLineWidget * lineWidget
axlAbstractActor * createAxlActorPlane(void)
void setQVTKWidget(QVTKOpenGLWidget *widget)
void setActor(vtkSmartPointer< vtkActor > actor)
vtkSmartPointer< vtkActor > getActor(void)
vtkCxxRevisionMacro(axlActorPlane,"$Revision: 0.0.1 $")
virtual void onUpdateProperty(void)
vtkSmartPointer< vtkPolyDataMapper > getMapper(void)
axlInteractorStyleSwitch * axlInteractorStyle
virtual void setData(dtkAbstractData *plane1)
vtkPlaneSource * plane(void)
dtkAbstractData * data(void)
virtual vtkRenderWindowInteractor * getInteractor(void)
axlPlane * observerData_plane
Class axlAbstractData defines an API for all type of axel data.
static axlActorPlaneObserver * New(void)