28 #include <QVTKOpenGLWidget.h>
31 #include <vtkAssemblyPath.h>
32 #include <vtkCellPicker.h>
33 #include <vtkCommand.h>
34 #include <vtkGlyph3D.h>
35 #include <vtkInteractorStyleSwitch.h>
37 #include <vtkLightCollection.h>
38 #include <vtkLineSource.h>
39 #include <vtkConeSource.h>
40 #include <vtkCylinderSource.h>
41 #include <vtkPlaneSource.h>
42 #include <vtkSphereSource.h>
43 #include <vtkParametricFunctionSource.h>
44 #include <vtkParametricTorus.h>
45 #include <vtkPointWidget.h>
46 #include <vtkLineWidget.h>
47 #include <vtkObjectFactory.h>
48 #include <vtkPoints.h>
49 #include <vtkPolyData.h>
50 #include <vtkPolyDataMapper.h>
51 #include <vtkProperty.h>
52 #include <vtkRenderer.h>
53 #include <vtkRendererCollection.h>
54 #include <vtkRenderWindow.h>
55 #include <vtkRenderWindowInteractor.h>
56 #include <vtkSmartPointer.h>
57 #include <vtkTransform.h>
58 #include <vtkTubeFilter.h>
68 virtual void Execute(vtkObject *caller,
unsigned long event,
void *)
111 class axlActorDataDynamicPrivate
115 QList<axlAbstractActor *>outputActors;
117 QVTKOpenGLWidget *widget;
118 vtkCellPicker *axlPicker ;
121 vtkRenderer *renderer;
126 #if (VTK_MAJOR_VERSION <= 5)
134 return d->dynamicData;
139 return d->outputActors.at(0);
144 return d->outputActors.at(i);
154 d->renderer = renderer;
167 d->dynamicData =
data;
169 int n = d->dynamicData->numberOfChannels();
170 for(
int indice = 0; indice < n; indice++){
171 if(d->dynamicData->outputs(indice)){
173 d->outputActors.append(factory->
create(d->dynamicData->outputs(indice)->identifier()));
175 d->outputActors.last()->setInteractor(this->
getInteractor());
177 d->outputActors.last()->setData(currentOutput);
178 d->outputActors.last()->setParent(
this);
180 d->view->insert(currentOutput, d->outputActors.last());
182 this->
setMapper(vtkSmartPointer<vtkPolyDataMapper>::New());
183 this->
setActor(dynamic_cast<axlActor *>(d->outputActors.last())->
getActor());
184 this->
getActor()->SetMapper(dynamic_cast<axlActor *>(d->outputActors.last())->
getMapper());
193 d->axlPicker = vtkCellPicker::New();
195 this->
getInteractor()->AddObserver(vtkCommand::InteractionEvent, d->dataObserver);
196 this->
getInteractor()->AddObserver(vtkCommand::MouseMoveEvent, d->dataObserver);
199 d->dataObserver->observerDataAssembly =
this;
200 d->dataObserver->axldynamicPicker = d->axlPicker;
201 d->dataObserver->observerData_dynamic = d->dynamicData;
209 QString shader = d->dynamicData->shader();
210 if(!shader.isEmpty()){
220 qDebug()<<
"no axlDataDynamic available";
233 for(
int i = 0; i < d->dynamicData->numberOfChannels();i++){
234 d->outputActors.at(i)->setDisplay(display);
279 if((axlData->
editable() ==
false) && (state == 2)){
289 vtkSmartPointer<vtkPropCollection> actors = vtkSmartPointer<vtkPropCollection>::New();
290 this->GetActors(actors);
291 actors->InitTraversal();
309 d->renderer->AddActor(
this);
314 if(
axlActor *actorProp = dynamic_cast<axlActor *>(abstractActor))
316 disconnect(actorProp, SIGNAL(
stateChanged(dtkAbstractData*,
int)), d->view, SIGNAL(
stateChanged(dtkAbstractData*,
int)));
321 disconnect(actorProp, SIGNAL(
stateChanged(dtkAbstractData*,
int)), d->view, SIGNAL(
stateChanged(dtkAbstractData*,
int)));
331 vtkSmartPointer<vtkPropCollection> actors = vtkSmartPointer<vtkPropCollection>::New();
332 this->GetActors(actors);
333 actors->InitTraversal();
355 if(!d->renderer->HasViewProp(
this))
357 d->renderer->AddActor(
this);
361 if(
axlActor *actorProp = dynamic_cast<axlActor *>(abstractActor))
363 disconnect(actorProp, SIGNAL(
stateChanged(dtkAbstractData*,
int)), d->view, SIGNAL(
stateChanged(dtkAbstractData*,
int)));
364 d->renderer->RemoveActor(actorProp);
367 if(
axlActorComposite *actorProp = dynamic_cast<axlActorComposite *>(abstractActor))
369 disconnect(actorProp, SIGNAL(
stateChanged(dtkAbstractData*,
int)), d->view, SIGNAL(
stateChanged(dtkAbstractData*,
int)));
370 d->renderer->RemoveActor(actorProp);
380 vtkSmartPointer<vtkPropCollection> actors = vtkSmartPointer<vtkPropCollection>::New();
381 this->GetActors(actors);
382 actors->InitTraversal();
408 d->renderer->RemoveActor(
this);
413 for(
int i = 0 ; i < d->dynamicData->numberOfChannels(); i ++)
416 axlData->
setColor(d->dynamicData->color());
421 if(
axlActor *actorProp = dynamic_cast<axlActor *>(abstractActor))
423 connect(actorProp, SIGNAL(
stateChanged(dtkAbstractData*,
int)), d->view, SIGNAL(
stateChanged(dtkAbstractData*,
int)));
424 d->renderer->AddActor(actorProp);
427 if(
axlActorComposite *actorProp = dynamic_cast<axlActorComposite *>(abstractActor))
429 connect(actorProp, SIGNAL(
stateChanged(dtkAbstractData*,
int)), d->view, SIGNAL(
stateChanged(dtkAbstractData*,
int)));
430 d->renderer->AddActor(actorProp);
442 this->
getInteractor()->RemoveObservers(vtkCommand::LeftButtonPressEvent, d->dataObserver);
443 this->
getInteractor()->RemoveObservers(vtkCommand::RightButtonPressEvent, d->dataObserver);
447 d->dataObserver->observerDataAssembly = NULL;
448 d->dataObserver->axldynamicPicker = NULL;
449 d->dataObserver->observerData_dynamic = NULL;
450 d->dataObserver->axlInteractorStyle = NULL;
451 d->dataObserver->Delete();
452 d->dataObserver = NULL;
454 d->axlPicker->Delete();
465 for(
int i = 0;i < d->dynamicData->numberOfChannels();i++){
472 for (
int indice = 0; indice < d->dynamicData->numberOfChannels();indice++) {
474 if((!(d->outputActors.at(indice) == NULL))){
484 d->dynamicData = NULL;
488 actorComposite->removeActorReference(
this);
499 d->dynamicData = NULL;
504 d->dataObserver = NULL;
void setDisplay(bool display)
axlAbstractActor * createAxlActorDataDynamic(void)
static axlActorDataDynamicObserver * New(void)
void stateChanged(dtkAbstractData *data, int mode)
axlInteractorStyleSwitch * axlInteractorStyle
void onModeChanged(int state)
vtkStandardNewMacro(axlActorDataDynamic)
virtual void setState(int state)
const bool & editable(void)
axlAbstractActor * outputActors(int i)
virtual int getState(void)
~axlActorDataDynamic(void)
dtkAbstractData * data(void)
static axlInspectorActorFactory * instance(void)
void setView(axlAbstractView *view)
virtual void setData(dtkAbstractData *data1)
Class axlDataDynamic defines a dynamic object.
axlAbstractActor * outputActor(void)
virtual void Execute(vtkObject *caller, unsigned long event, void *)
virtual void onRemoved(void)
virtual axlAbstractActor * parent(void)
void setMapper(vtkSmartPointer< vtkPolyDataMapper > mapper)
void setQVTKWidget(QVTKOpenGLWidget *widget)
void setActor(vtkSmartPointer< vtkActor > actor)
vtkSmartPointer< vtkActor > getActor(void)
void setRenderer(vtkRenderer *renderer)
vtkSmartPointer< vtkPolyDataMapper > getMapper(void)
vtkCellPicker * axldynamicPicker
axlAbstractActor * create(const QString &interface_name)
vtkCxxRevisionMacro(axlActorDataDynamic,"$Revision: 0.0.1 $")
axlDataDynamic * observerData_dynamic
void setColor(double r, double g, double b)
axlActorDataDynamic(void)
axlActorDataDynamic * observerDataAssembly
virtual vtkRenderWindowInteractor * getInteractor(void)
Class axlAbstractData defines an API for all type of axel data.
static axlActorDataDynamic * New(void)