57 #include <vtkAssemblyNode.h>
58 #include <vtkAssemblyPath.h>
59 #include <vtkCellArray.h>
60 #include <vtkCellPicker.h>
61 #include <vtkDoubleArray.h>
62 #include <vtkCommand.h>
63 #include <vtkMatrix4x4.h>
64 #include <vtkObjectFactory.h>
65 #include <vtkPoints.h>
66 #include <vtkPointData.h>
67 #include <vtkPolyData.h>
68 #include <vtkPolyDataMapper.h>
69 #include <vtkProp3DCollection.h>
70 #include <vtkProperty.h>
71 #include <vtkRenderer.h>
72 #include <vtkRendererCollection.h>
73 #include <vtkRenderWindow.h>
74 #include <vtkRenderWindowInteractor.h>
75 #include <vtkSmartPointer.h>
76 #include <vtkTimerLog.h>
86 virtual void Execute(vtkObject *caller,
unsigned long event,
void *)
98 class axlActorCompositePrivate
101 vtkSmartPointer<vtkPoints> points;
102 vtkSmartPointer<vtkPolyData> polyData;
103 vtkSmartPointer<vtkCellArray> cellArray;
104 vtkSmartPointer<vtkActor> actor;
105 vtkSmartPointer<vtkPolyDataMapper> mapper;
106 vtkSmartPointer<vtkRenderWindowInteractor> interactor;
107 vtkSmartPointer<vtkCellPicker> CpCursorPicker;
108 vtkSmartPointer<axlActorCompositeObserver> observer;
109 vtkSmartPointer<vtkRenderer> renderer;
114 QList<axlAbstractActor *> listCompositeActorChild;
119 #if (VTK_MAJOR_VERSION <= 5)
132 return d->listCompositeActorChild.removeOne(actor);
140 for (
int i = 0; i < d->composite->count(); i++)
146 currentComposite->
setData(currentData);
147 d->view->insert(currentData, currentComposite);
148 this->AddPart(currentComposite);
149 connect(currentData,SIGNAL(samplingChanged()),currentComposite,SLOT(
onSamplingChanged()));
150 d->listCompositeActorChild << currentComposite;
158 currentComposite->
setData(currentData);
159 d->view->insert(currentData, currentComposite);
160 this->AddPart(currentComposite);
161 connect(currentData,SIGNAL(samplingChanged()),currentComposite,SLOT(
onSamplingChanged()));
162 d->listCompositeActorChild << currentComposite;
169 currentComposite->
setData(currentData);
170 d->view->insert(currentData, currentComposite);
171 this->AddPart(currentComposite);
172 connect(currentData,SIGNAL(samplingChanged()),currentComposite,SLOT(
onSamplingChanged()));
173 d->listCompositeActorChild << currentComposite;
180 currentComposite->
setData(currentData);
181 d->view->insert(currentData, currentComposite);
182 this->AddPart(currentComposite);
183 connect(currentData,SIGNAL(samplingChanged()),currentComposite,SLOT(
onSamplingChanged()));
184 d->listCompositeActorChild << currentComposite;
192 d->view->insert(currentData, currentComposite);
193 this->AddPart(currentComposite);
194 connect(currentData,SIGNAL(samplingChanged()),currentComposite,SLOT(
onSamplingChanged()));
195 d->listCompositeActorChild << currentComposite;
197 else if(
axlCone *currentData = dynamic_cast<axlCone *>(d->composite->get(i)))
202 currentComposite->
setData(currentData);
203 d->view->insert(currentData, currentComposite);
204 this->AddPart(currentComposite);
205 d->listCompositeActorChild << currentComposite;
208 else if(
axlCylinder *currentData = dynamic_cast<axlCylinder *>(d->composite->get(i)))
213 currentComposite->
setData(currentData);
214 d->view->insert(currentData, currentComposite);
215 this->AddPart(currentComposite);
216 d->listCompositeActorChild << currentComposite;
219 else if(
axlTorus *currentData = dynamic_cast<axlTorus *>(d->composite->get(i)))
224 currentComposite->
setData(currentData);
225 d->view->insert(currentData, currentComposite);
226 this->AddPart(currentComposite);
227 d->listCompositeActorChild << currentComposite;
241 else if(
axlEllipsoid *currentData = dynamic_cast<axlEllipsoid *>(d->composite->get(i)))
246 currentComposite->
setData(currentData);
247 d->view->insert(currentData, currentComposite);
248 this->AddPart(currentComposite);
249 d->listCompositeActorChild << currentComposite;
252 else if(
axlLine *currentData = dynamic_cast<axlLine *>(d->composite->get(i)))
257 currentComposite->
setData(currentData);
258 d->view->insert(currentData, currentComposite);
259 this->AddPart(currentComposite);
260 d->listCompositeActorChild << currentComposite;
263 else if(
axlPlane *currentData = dynamic_cast<axlPlane *>(d->composite->get(i)))
268 currentComposite->
setData(currentData);
269 d->view->insert(currentData, currentComposite);
270 this->AddPart(currentComposite);
271 d->listCompositeActorChild << currentComposite;
285 else if(
axlSphere *currentData = dynamic_cast<axlSphere *>(d->composite->get(i)))
289 currentComposite->
setData(currentData);
292 d->view->insert(currentData, currentComposite);
293 this->AddPart(currentComposite);
294 d->listCompositeActorChild << currentComposite;
310 currentComposite->
setData(d->composite->get(i));
311 d->view->insert(d->composite->get(i), currentComposite);
312 this->AddPart(currentComposite);
313 d->listCompositeActorChild << currentComposite;
322 vtkProp3DCollection *actors2 = this->GetParts();
323 actors2->InitTraversal();
324 for(
int i = 0; i<actors2->GetNumberOfPaths(); i++)
326 vtkProp *path = actors2->GetNextProp();
332 actorProp->onControlPointChanged();
351 vtkSmartPointer<vtkPropCollection> actors = vtkSmartPointer<vtkPropCollection>::New();
352 this->GetActors(actors);
353 actors->InitTraversal();
356 color = composite->color();
358 color.setRgb(1.0, 1.0, 1.0);
360 for(
int i = 0; i< actors->GetNumberOfItems(); i++)
362 vtkProp *prop = actors->GetNextProp();
363 if(vtkActor *actor = dynamic_cast<vtkActor *>(prop))
365 actor->GetProperty()->SetColor(color.redF(), color.greenF(), color.blueF());
371 d->renderer->AddActor(
this);
375 if(
axlActor *actorProp = dynamic_cast<axlActor *>(abstractActor))
377 disconnect(actorProp, SIGNAL(
stateChanged(dtkAbstractData*,
int)), d->view, SIGNAL(
stateChanged(dtkAbstractData*,
int)));
378 d->renderer->RemoveActor(actorProp);
381 if(
axlActorComposite *actorProp = dynamic_cast<axlActorComposite *>(abstractActor))
383 disconnect(actorProp, SIGNAL(
stateChanged(dtkAbstractData*,
int)), d->view, SIGNAL(
stateChanged(dtkAbstractData*,
int)));
384 d->renderer->RemoveActor(actorProp);
413 qDebug()<<
"avant selection";
424 vtkSmartPointer<vtkPropCollection> actors = vtkSmartPointer<vtkPropCollection>::New();
425 this->GetActors(actors);
426 actors->InitTraversal();
431 color = composite->color();
432 qreal *h =
new qreal(0.0);
433 qreal *s =
new qreal(0.0);
434 qreal *l =
new qreal(0.0);
435 color.getHslF(h, s, l);
436 color.setHslF(*h, *s, *l + (1.0 - *l) / 2.0);
439 color.setRgb(0.0, 0.0, 1.0);
441 for(
int i = 0; i< actors->GetNumberOfItems(); i++)
443 vtkProp *prop = actors->GetNextProp();
444 if(vtkActor *actor = dynamic_cast<vtkActor *>(prop))
445 actor->GetProperty()->SetColor(color.redF(), color.greenF(), color.blueF());
448 if(!d->renderer->HasViewProp(
this))
450 d->renderer->AddActor(
this);
454 if(
axlActor *actorProp = dynamic_cast<axlActor *>(abstractActor))
456 disconnect(actorProp, SIGNAL(
stateChanged(dtkAbstractData*,
int)), d->view, SIGNAL(
stateChanged(dtkAbstractData*,
int)));
457 d->renderer->RemoveActor(actorProp);
460 if(
axlActorComposite *actorProp = dynamic_cast<axlActorComposite *>(abstractActor))
462 disconnect(actorProp, SIGNAL(
stateChanged(dtkAbstractData*,
int)), d->view, SIGNAL(
stateChanged(dtkAbstractData*,
int)));
463 d->renderer->RemoveActor(actorProp);
495 vtkSmartPointer<vtkPropCollection> actors = vtkSmartPointer<vtkPropCollection>::New();
496 this->GetActors(actors);
497 actors->InitTraversal();
502 color = composite->color();
503 qreal *h =
new qreal(0.0);
504 qreal *s =
new qreal(0.0);
505 qreal *l =
new qreal(0.0);
506 color.getHslF(h, s, l);
507 color.setHslF(*h, *s, *l + (1.0 - *l) / 2.0);
510 color.setRgb(0.0, 0.0, 1.0);
512 for(
int i = 0; i< actors->GetNumberOfItems(); i++)
515 vtkProp *prop = actors->GetNextProp();
516 if(vtkActor *actor = dynamic_cast<vtkActor *>(prop))
518 actor->GetProperty()->SetColor(color.redF(), color.greenF(), color.blueF());
531 d->renderer->RemoveActor(
this);
533 vtkProp3DCollection *actors2 = this->GetParts();
534 actors2->InitTraversal();
536 for(
int i = 0 ; i < d->composite->count() ; i ++)
539 axlData->
setColor(d->composite->color());
544 if(
axlActor *actorProp = dynamic_cast<axlActor *>(abstractActor))
546 connect(actorProp, SIGNAL(
stateChanged(dtkAbstractData*,
int)), d->view, SIGNAL(
stateChanged(dtkAbstractData*,
int)));
547 d->renderer->AddActor(actorProp);
564 if(
axlActorComposite *actorProp = dynamic_cast<axlActorComposite *>(abstractActor))
566 connect(actorProp, SIGNAL(
stateChanged(dtkAbstractData*,
int)), d->view, SIGNAL(
stateChanged(dtkAbstractData*,
int)));
567 d->renderer->AddActor(actorProp);
593 QColor color =
data->color();
594 vtkSmartPointer<vtkPropCollection> actors = vtkSmartPointer<vtkPropCollection>::New();
595 this->GetActors(actors);
596 actors->InitTraversal();
600 for(
int i = 0; i< actors->GetNumberOfItems(); i++)
602 vtkProp *prop = actors->GetNextProp();
603 if(vtkActor *actor = dynamic_cast<vtkActor *>(prop))
605 actor->GetProperty()->SetColor(color.redF(), color.greenF(), color.blueF());
612 qreal *h =
new qreal(0.0);
613 qreal *s =
new qreal(0.0);
614 qreal *l =
new qreal(0.0);
615 color.getHslF(h, s, l);
616 color.setHslF(*h, *s, *l + (1.0 - *l) / 2.0);
618 for(
int i = 0; i< actors->GetNumberOfItems(); i++)
620 vtkProp *prop = actors->GetNextProp();
621 if(vtkActor *actor = dynamic_cast<vtkActor *>(prop))
623 actor->GetProperty()->SetColor(color.redF(), color.greenF(), color.blueF());
637 d->renderer = renderer;
642 return (
bool)(this->GetVisibility());
647 d->interactor =
static_cast<vtkRenderWindowInteractor *
>(interactor);
653 return d->interactor;
658 if(d->observer == NULL)
662 this->
getInteractor()->AddObserver(vtkCommand::LeftButtonPressEvent, d->observer);
663 this->
getInteractor()->AddObserver(vtkCommand::RightButtonPressEvent, d->observer);
664 this->
getInteractor()->AddObserver(vtkCommand::InteractionEvent, d->observer);
665 this->
getInteractor()->AddObserver(vtkCommand::KeyPressEvent, d->observer);
668 qDebug()<<
"WARNING : You try to create an observer that it's already created";
673 if(d->observer != NULL)
675 this->
getInteractor()->RemoveObservers(vtkCommand::LeftButtonPressEvent, d->observer);
676 this->
getInteractor()->RemoveObservers(vtkCommand::RightButtonPressEvent, d->observer);
677 this->
getInteractor()->RemoveObservers(vtkCommand::InteractionEvent, d->observer);
678 this->
getInteractor()->RemoveObservers(vtkCommand::KeyPressEvent, d->observer);
680 d->observer->Delete();
685 qDebug()<<
"WARNING : You try to delete an observer that it's not initialized";
703 qDebug() <<
"No tet actor computed for this axlActorComposite";
708 if(!this->GetParts()->IsItemPresent(d->actor)){
709 this->VisibilityOn();
714 if (this->GetParts()->IsItemPresent(d->actor)!=0){
715 this->VisibilityOff();
722 vtkProp3DCollection *actors2 = this->GetParts();
723 actors2->InitTraversal();
724 for(
int i = 0; i<actors2->GetNumberOfPaths(); i++)
726 vtkProp *path = actors2->GetNextProp();
732 actorProp->onSamplingChanged();
744 double opacity = composite->opacity();
746 vtkSmartPointer<vtkPropCollection> actors = vtkSmartPointer<vtkPropCollection>::New();
747 this->GetActors(actors);
748 actors->InitTraversal();
750 for(
int i = 0; i< actors->GetNumberOfItems(); i++)
752 vtkProp *prop = actors->GetNextProp();
753 if(vtkActor *actor = dynamic_cast<vtkActor *>(prop))
755 actor->GetProperty()->SetOpacity(opacity);
764 if(QFile::exists(xmlfile))
766 vtkSmartPointer<vtkPropCollection> actors = vtkSmartPointer<vtkPropCollection>::New();
767 this->GetActors(actors);
768 actors->InitTraversal();
770 for(
int i = 0; i< actors->GetNumberOfItems(); i++)
773 vtkProp *prop = actors->GetNextProp();
774 if(vtkActor *actor = dynamic_cast<vtkActor *>(prop))
776 vtkProperty *prop = actor->GetProperty();
777 if(QFile::exists(xmlfile))
779 QString currentShader = dtkReadFile(xmlfile);
786 prop->vtkProperty::ShadingOff();
797 { vtkSmartPointer<vtkPropCollection> actors = vtkSmartPointer<vtkPropCollection>::New();
798 this->GetActors(actors);
799 actors->InitTraversal();
801 for(
int i = 0; i< actors->GetNumberOfItems(); i++)
804 vtkProp *prop = actors->GetNextProp();
805 if(vtkActor *actor = dynamic_cast<vtkActor *>(prop))
807 vtkProperty *prop = actor->GetProperty();
812 prop->vtkProperty::ShadingOn();
816 prop->vtkProperty::ShadingOff();
829 this->VisibilityOff();
835 this->VisibilityOn();
847 this->
getInteractor()->RemoveObservers(vtkCommand::LeftButtonPressEvent, d->observer);
848 this->
getInteractor()->RemoveObservers(vtkCommand::RightButtonPressEvent, d->observer);
849 this->
getInteractor()->RemoveObservers(vtkCommand::InteractionEvent, d->observer);
850 this->
getInteractor()->RemoveObservers(vtkCommand::KeyPressEvent, d->observer);
851 this->RemoveObserver(d->observer);
859 if(
axlActor *actor = dynamic_cast<axlActor *>(abstracActor))
860 d->renderer->RemoveActor(actor);
861 else if(
axlActorComposite *actorComposite = dynamic_cast<axlActorComposite *>(abstracActor))
862 d->renderer->RemoveActor(actorComposite);
864 d->view->removeData(abstracActor->
data());
875 if(
axlActor *actor = dynamic_cast<axlActor *>(abstracActor))
877 if(
axlActorBSpline *actorBSlpine = dynamic_cast<axlActorBSpline *>(abstracActor))
878 disconnect(actorBSlpine->data(),SIGNAL(samplingChanged()),actorBSlpine,SLOT(
onSamplingChanged()));
879 this->RemovePart(actor);
882 else if(
axlActorComposite *actorComposite = dynamic_cast<axlActorComposite *>(abstracActor))
884 this->RemovePart(actorComposite);
885 actorComposite->Delete();
888 d->listCompositeActorChild.removeOne(abstracActor);
898 d->CpCursorPicker = vtkSmartPointer<vtkCellPicker>::New();
899 d->CpCursorPicker->SetTolerance(0.001);
static axlActorSphere * New(void)
virtual void setData(dtkAbstractData *line1)
Class axlLine defines 3D lines.
static axlActorCylinder * New(void)
virtual dtkAbstractData * data(void)=0
void stateChanged(dtkAbstractData *data, int mode)
virtual void setData(dtkAbstractData *spline_Surface1)
virtual void setInteractor(void *interactor)
virtual bool isVisible(void)
Class axlCylinder defines 3D cylinders.
static axlActorCone * New(void)
Class axlPlane defines 3D planes.
virtual void setData(dtkAbstractData *spline_curve1)
virtual void onRemoved(void)
static axlActorCompositeObserver * New(void)
static axlActorVolumeBSpline * New(void)
virtual dtkAbstractData * data(void)
virtual void setData(dtkAbstractData *spline_Volume1)
virtual void setData(dtkAbstractData *data1)
axlAbstractActor * createAxlActorComposite(void)
static axlActorPlane * New(void)
void setView(axlAbstractView *view)
virtual void setInteractor(void *interactor)
virtual void update(void)
virtual void onRemoved(void)
static axlActorCurveBSpline * New(void)
static axlActorLine * New(void)
virtual void setParent(axlAbstractActor *parent)
static axlActorSurfaceBSpline * New(void)
void setData(dtkAbstractData *data)
Class axlSphere defines 3D spheres.
virtual void setData(dtkAbstractData *cylinder1)
bool removeActorReference(axlAbstractActor *actor)
virtual void setColor(double red, double green, double blue)
virtual void setData(dtkAbstractData *cone1)
virtual void setData(dtkAbstractData *torus1)
virtual void setShaderFromString(QString xmlfile)
virtual void setData(dtkAbstractData *sphere1)
void setRenderer(vtkRenderer *renderer)
static axlActorComposite * New(void)
virtual void setMode(int state)
virtual void setState(int state)
virtual void setOpacity(double opacity)
virtual void setData(dtkAbstractData *plane1)
virtual void setData(dtkAbstractData *ellipsoid1)
virtual void Execute(vtkObject *caller, unsigned long event, void *)
void deleteObserver(void)
virtual vtkRenderWindowInteractor * getInteractor(void)
vtkStandardNewMacro(axlActorComposite)
Class axlCone defines 3D cones.
static axlActorMesh * New(void)
static axlActorSurfaceTrimmed * New(void)
void setSurface(axlAbstractSurfaceTrimmed *Surface)
virtual void onControlPointChanged()
virtual void onSamplingChanged(void)
void setColor(double r, double g, double b)
vtkCxxRevisionMacro(axlActorComposite,"$Revision: 0.0.1 $")
Class axlEllipsoid defines 3D ellipsoids.
virtual void onModeChanged(int state)
Class axlAbstractData defines an API for all type of axel data.
static axlActorTorus * New(void)
virtual int getState(void)
virtual void setShader(QString xmlfile)
virtual void setDisplay(bool display)