26 #include <QVTKOpenGLWidget.h>
29 #include <vtkAssemblyPath.h>
31 #include <vtkCommand.h>
32 #include <vtkGlyph3D.h>
33 #include <vtkInteractorStyleSwitch.h>
35 #include <vtkLightCollection.h>
36 #include <vtkObjectFactory.h>
37 #include <vtkPoints.h>
38 #include <vtkPointWidget.h>
39 #include <vtkPolyData.h>
40 #include <vtkPolyDataMapper.h>
41 #include <vtkProperty.h>
42 #include <vtkRenderer.h>
43 #include <vtkRendererCollection.h>
44 #include <vtkRenderWindow.h>
45 #include <vtkRenderWindowInteractor.h>
46 #include <vtkSmartPointer.h>
47 #include <vtkSphereSource.h>
48 #include <vtkTransform.h>
68 virtual void Execute(vtkObject *caller,
unsigned long event,
void *)
70 vtkRenderWindowInteractor *interactor = observerDataAssembly->
getInteractor();
72 if(event == vtkCommand::InteractionEvent) {
73 observerData_sphereSource->Update();
74 observerData_sphereSource->Modified();
80 if(caller == pointWidget) {
81 observerData_point->
setCoordinates(pointWidget->GetPosition()[0], pointWidget->GetPosition()[1], pointWidget->GetPosition()[2]);
93 class axlActorPointPrivate
97 vtkSphereSource *sphereSource;
98 vtkPointWidget *pointWidget;
100 QVTKOpenGLWidget *widget;
104 #if (VTK_MAJOR_VERSION <= 5)
117 return d->sphereSource;
133 this->
setMapper(vtkSmartPointer<vtkPolyDataMapper>::New());
134 this->
setActor(vtkSmartPointer<vtkActor>::New());
136 d->sphereSource = vtkSphereSource::New();
137 d->sphereSource->SetPhiResolution(20);
138 d->sphereSource->SetThetaResolution(20);
141 #if (VTK_MAJOR_VERSION <= 5)
142 this->
getMapper()->SetInput(d->sphereSource->GetOutput());
144 this->
getMapper()->SetInputData(d->sphereSource->GetOutput());
150 if(!d->pointObserver)
154 this->
getInteractor()->AddObserver(vtkCommand::InteractionEvent, d->pointObserver);
155 this->
getInteractor()->AddObserver(vtkCommand::MouseMoveEvent, d->pointObserver);
157 d->pointObserver->observerDataAssembly =
this;
159 d->pointObserver->observerData_sphereSource = d->sphereSource;
160 d->pointObserver->observerData_point = d->point;
164 QColor color = d->point->color();
165 this->
getActor()->GetProperty()->SetColor(color.redF(), color.greenF(), color.blueF());
167 QString shader = d->point->shader();
168 if(!shader.isEmpty())
174 connect(d->point, SIGNAL(modifiedGeometry()),
this, SLOT(
onUpdateGeometry()));
175 connect(d->point, SIGNAL(modifiedProperty()),
this, SLOT(
onUpdateProperty()));
178 qDebug()<<
"no axlPoint available";
185 if (display && d->pointWidget) {
189 if (!display && d->pointWidget) {
196 if (!d->pointWidget) {
197 qDebug() <<
"No tet actor computed for this axlActorPoint.";
202 d->pointWidget->SetEnabled(1);
206 d->pointWidget->SetEnabled(0);
213 if (!d->pointWidget) {
215 d->pointWidget = vtkPointWidget::New();
217 d->pointWidget->SetProp3D(this->
getActor());
218 d->pointWidget->PlaceWidget();
219 d->pointWidget->AllOff();
220 d->pointWidget->SetTranslationMode(1);
222 d->pointWidget->SetPosition(d->sphereSource->GetCenter());
226 if(d->pointObserver) {
227 d->pointWidget->AddObserver(vtkCommand::InteractionEvent, d->pointObserver);
228 d->pointObserver->pointWidget = d->pointWidget;
232 d->pointWidget->SetEnabled(
true);
239 d->pointWidget->RemoveAllObservers();
240 d->pointWidget->SetEnabled(
false);
241 d->pointWidget->Delete();
242 d->pointWidget = NULL;
246 if (d->pointObserver)
247 d->pointObserver->pointWidget = d->pointWidget;
255 if(!d->pointWidget) {
256 qDebug() <<
"No tet actor computed for this axlActorBSpline.";
260 return d->pointWidget->GetEnabled();
280 QColor color =
data->color();
281 this->
getActor()->GetProperty()->SetColor(color.redF(), color.greenF(), color.blueF());
293 vtkProperty *prop = this->
getActor()->GetProperty();
297 QColor color =
data->color();
298 qreal *h =
new qreal(0.0);
299 qreal *s =
new qreal(0.0);
300 qreal *l =
new qreal(0.0);
301 color.getHslF(h, s, l);
302 color.setHslF(*h, *s, *l + (1.0 - *l) / 2.0);
303 prop->SetColor(color.redF(), color.greenF(), color.blueF());
315 vtkProperty *prop = this->
getActor()->GetProperty();
318 QColor color =
data->color();
319 qreal *h =
new qreal(0.0);
320 qreal *s =
new qreal(0.0);
321 qreal *l =
new qreal(0.0);
322 color.getHslF(h, s, l);
323 color.setHslF(*h, *s, *l + (1.0 - *l)/2.0);
324 prop->SetColor(color.redF(), color.greenF(), color.blueF());
344 this->
getInteractor()->RemoveObservers(vtkCommand::InteractionEvent, d->pointObserver);
345 this->
getInteractor()->RemoveObservers(vtkCommand::MouseMoveEvent, d->pointObserver);
346 d->pointObserver->observerDataAssembly = NULL;
348 d->pointObserver->observerData_sphereSource = NULL;
349 d->pointObserver->observerData_point = NULL;
350 d->pointObserver->axlInteractorStyle = NULL;
351 d->pointObserver->Delete();
352 d->pointObserver = NULL;
360 d->sphereSource->Delete();
361 d->sphereSource = NULL;
374 d->pointWidget = NULL;
378 this->RemoveAllObservers();
380 this->
getActor()->RemoveAllObservers();
383 actorComposite->removeActorReference(
this);
388 d->sphereSource->SetCenter(d->point->coordinates());
389 d->sphereSource->SetRadius(d->point->size());
390 d->sphereSource->Modified();
391 d->sphereSource->Update();
394 d->pointWidget->SetPosition(d->sphereSource->GetCenter());
397 if(!d->point->fields().isEmpty())
398 d->point->touchField();
400 if(d->point->updateView())
406 d->sphereSource->SetRadius(d->point->size());
408 if(!d->point->fields().isEmpty())
409 d->point->touchField();
416 d->pointWidget = NULL;
418 d->pointObserver = NULL;
419 d->sphereSource =NULL;
Class axlPoint defines 3D points.
virtual void Execute(vtkObject *caller, unsigned long event, void *)
void showPointWidget(bool show)
virtual void setDisplay(bool display)
void stateChanged(dtkAbstractData *data, int mode)
axlActorPoint * observerDataAssembly
void onUpdateGeometry(void)
dtkAbstractData * data(void)
virtual void setState(int state)
virtual void setData(dtkAbstractData *point1)
vtkSphereSource * observerData_sphereSource
axlInteractorStyleSwitch * axlInteractorStyle
virtual int getState(void)
void setPointWidget(bool pointWidget)
vtkCxxRevisionMacro(axlActorPoint,"$Revision: 0.0.1 $")
vtkSphereSource * sphere(void)
static axlActorPointObserver * New(void)
virtual void setShader(QString vsfile)
virtual axlAbstractActor * parent(void)
virtual void setOpacity(double opacity)
void setDisplay(bool display)
void setMapper(vtkSmartPointer< vtkPolyDataMapper > mapper)
vtkPointWidget * pointWidget
void setActor(vtkSmartPointer< vtkActor > actor)
vtkSmartPointer< vtkActor > getActor(void)
virtual void onUpdateProperty(void)
void setSize(double size)
vtkSmartPointer< vtkPolyDataMapper > getMapper(void)
axlAbstractActor * createAxlActorPoint(void)
vtkStandardNewMacro(axlActorPoint)
void onModeChanged(int state)
void setQVTKWidget(QVTKOpenGLWidget *widget)
virtual vtkRenderWindowInteractor * getInteractor(void)
static axlActorPoint * New(void)
void setCoordinates(double x, double y, double z)
Change coordinates of this point.
Class axlAbstractData defines an API for all type of axel data.
axlPoint * observerData_point