Developer documentation | Axl-2.5.1

axlActorEllipsoid.cpp
Go to the documentation of this file.
1 /* axlActorEllipsoid.cpp ---
2  *
3  * Author: Meriadeg Perrinel
4  * Copyright (C) 2008 - Meriadeg Perrinel, Inria.
5  * Created: Fri Dec 17 10:59:21 2010 (+0100)
6  * Version: $Id$
7  * Last-Updated: Mon Dec 17 15:03:23 2012 (+0100)
8  * By: Julien Wintz
9  * Update #: 29
10  */
11 
12 /* Commentary:
13  *
14  */
15 
16 /* Change log:
17  *
18  */
19 #include "axlActorEllipsoid.h"
20 
21 #include "axlActorComposite.h"
23 
24 #include <axlCore/axlEllipsoid.h>
25 #include <axlCore/axlPoint.h>
26 
27 #include <QVTKOpenGLWidget.h>
28 
29 #include <vtkActor.h>
30 #include <vtkAssemblyPath.h>
31 //#include <vtkCellPicker.h>
32 #include <vtkCommand.h>
33 #include <vtkGlyph3D.h>
34 #include <vtkInteractorStyleSwitch.h>
35 #include <vtkLight.h>
36 #include <vtkLightCollection.h>
37 #include <vtkObjectFactory.h>
38 #include <vtkPoints.h>
39 #include <vtkLineWidget.h>
40 #include <vtkPolyData.h>
41 #include <vtkPolyDataMapper.h>
42 #include <vtkProperty.h>
43 #include <vtkRenderer.h>
44 #include <vtkRendererCollection.h>
45 #include <vtkRenderWindowInteractor.h>
46 #include <vtkRenderWindow.h>
47 #include <vtkSmartPointer.h>
48 #include <vtkParametricEllipsoid.h>
49 #include <vtkParametricFunctionSource.h>
50 #include <vtkTransform.h>
51 
52 
53 class axlActorEllipsoidObserver : public vtkCommand {
54 public:
56  return new axlActorEllipsoidObserver;
57  }
58 
59  virtual void Execute(vtkObject *caller, unsigned long event, void *) {
60  vtkRenderWindowInteractor *interactor = observerDataAssembly->getInteractor();
61 
62  if (event == vtkCommand::InteractionEvent) {
63  observerData_ellipsoidSource->Modified();
65  interactor->Render();
66 
67  // we need to select which line widget we are moving then update the axlEllipsoid and then run onUpdateGeometry method
69  return;
70 
71  //now we select which line widget the user is moving
72 // if (axlPoint::distance(&lXCenter, observerData_ellipsoid->center())> 0.0001) {
73  if (caller == lineXWidget){
74  // we are moving lineXWidget
75  axlPoint lXP1(lineXWidget->GetPoint1()[0], lineXWidget->GetPoint1()[1], lineXWidget->GetPoint1()[2]);
76  axlPoint lXP2(lineXWidget->GetPoint2()[0], lineXWidget->GetPoint2()[1], lineXWidget->GetPoint2()[2]);
77  axlPoint lXCenter = (lXP1 + lXP2) / 2.0;
78 
79  axlPoint semiX = (lXP2 - lXP1)/2;
80  observerData_ellipsoid->modifyCenter(lXCenter.coordinates());
83  } //else if (axlPoint::distance(&lYCenter, observerData_ellipsoid->center())> 0.0001) {
84  else if (caller == lineYWidget){
85  // we move lineYWidget
86  axlPoint lYP1(lineYWidget->GetPoint1()[0], lineYWidget->GetPoint1()[1], lineYWidget->GetPoint1()[2]);
87  axlPoint lYP2(lineYWidget->GetPoint2()[0], lineYWidget->GetPoint2()[1], lineYWidget->GetPoint2()[2]);
88  axlPoint lYCenter = (lYP1 + lYP2) / 2.0;
89 
90  axlPoint semiY = (lYP2 - lYP1)/2;
91  observerData_ellipsoid->modifyCenter(lYCenter.coordinates());
94  } //else if(axlPoint::distance(&lZCenter, observerData_ellipsoid->center())> 0.0001) {
95  else if (caller == lineZWidget){
96  // we move lineZWidget
97  axlPoint lZP1(lineZWidget->GetPoint1()[0], lineZWidget->GetPoint1()[1], lineZWidget->GetPoint1()[2]);
98  axlPoint lZP2(lineZWidget->GetPoint2()[0], lineZWidget->GetPoint2()[1], lineZWidget->GetPoint2()[2]);
99  axlPoint lZCenter = (lZP1 + lZP2) / 2.0;
100 
101  axlPoint semiZ = (lZP2 - lZP1)/2;
102  observerData_ellipsoid->modifyCenter(lZCenter.coordinates());
105  }
106  else
107  return;
108 
110 
111  }
112 
113  // if (event == vtkCommand::MouseMoveEvent) {
114  // if (observerData_ellipsoid) {
115  // // we need the matrix transform of this actor
116 
117  // vtkAssemblyPath *path;
118  // vtkRenderWindow *renderWindow = interactor->GetRenderWindow();
119  // vtkRendererCollection * rendererCollection = renderWindow->GetRenderers();
120  // vtkRenderer *render = rendererCollection->GetFirstRenderer();
121  // axlInteractorStyle = dynamic_cast<axlInteractorStyleSwitch *>(interactor->GetInteractorStyle());
122 
123  // int X = observerDataAssembly->getInteractor()->GetEventPosition()[0];
124  // int Y = observerDataAssembly->getInteractor()->GetEventPosition()[1];
125 
126  // if (!render || !render->IsInViewport(X, Y)) {
127  // //qDebug()<<" No renderer or bad cursor coordonates";
128  // }
129 
130  // axlEllipsoidPicker->Pick(X,Y,0.0,render);
131  // path = axlEllipsoidPicker->GetPath();
132 
133  // if (path != NULL) {
134  // //qDebug()<< "axlActorEllipsoidObserver::MouseMoveEvent";
135 
136  // double *position = observerDataAssembly->GetPosition();
137  // for (int j = 0; j < 3; j++) {
138  // //qDebug()<<"axlActorEllipsoidObserver :: Execute "<<position[j];
139  // //observerData_ellipsoid->coordinates()[j] = position[j];
140  // }
141  // //WARNING We considered there the scale is uniforn in all direction;
142  // // observerData_ellipsoid->emitDataChanged();
143  // }
144  // }
145  // }
146  }
147 
149 // vtkCellPicker *axlEllipsoidPicker;
152  vtkParametricFunctionSource *observerData_ellipsoidSource;
153  vtkParametricEllipsoid *vtkEllipsoid;
154 
155  vtkLineWidget *lineXWidget = nullptr;
156  vtkLineWidget *lineYWidget = nullptr;
157  vtkLineWidget *lineZWidget = nullptr;
158 };
159 
160 // /////////////////////////////////////////////////////////////////
161 // axlActorEllipsoidPrivate
162 // /////////////////////////////////////////////////////////////////
163 
164 class axlActorEllipsoidPrivate
165 {
166 public:
167  axlEllipsoid *ellipsoid;
168  vtkParametricFunctionSource *ellipsoidSource;
169  vtkParametricEllipsoid *vtkEllipsoid;
170  vtkLineWidget *lineXWidget;
171  vtkLineWidget *lineYWidget;
172  vtkLineWidget *lineZWidget;
173  axlActorEllipsoidObserver *ellipsoidObserver;
174  QVTKOpenGLWidget *widget;
175 // vtkCellPicker *axlEllipsoidPicker ;
176 
177 };
178 
179 #if (VTK_MAJOR_VERSION <= 5)
180 vtkCxxRevisionMacro(axlActorEllipsoid, "$Revision: 0.0.1 $");
181 #endif
182 
184 
185 dtkAbstractData *axlActorEllipsoid::data(void) {
186  return d->ellipsoid;
187 }
188 
189 vtkParametricEllipsoid *axlActorEllipsoid::ellipsoid(void) {
190  return d->vtkEllipsoid;
191 }
192 
193 void axlActorEllipsoid::setQVTKWidget(QVTKOpenGLWidget *widget) {
194  d->widget = widget;
195 }
196 
197 
198 void axlActorEllipsoid::setData(dtkAbstractData *ellipsoid1) {
199 
200  axlEllipsoid *ellipsoid = dynamic_cast<axlEllipsoid *>(ellipsoid1);
201 
202  if (ellipsoid) {
203  d->ellipsoid = ellipsoid;
204 
205  double radiusX = d->ellipsoid->semiX()->norm();
206  double radiusY = d->ellipsoid->semiY()->norm();
207  double radiusZ = d->ellipsoid->semiZ()->norm();
208 
209  this->setMapper(vtkSmartPointer<vtkPolyDataMapper>::New());
210  this->setActor(vtkSmartPointer<vtkActor>::New());
211 
212  d->ellipsoidSource = vtkParametricFunctionSource::New();
213 
214  d->vtkEllipsoid = vtkParametricEllipsoid::New();
215  d->vtkEllipsoid->SetXRadius(radiusX);
216  d->vtkEllipsoid->SetYRadius(radiusY);
217  d->vtkEllipsoid->SetZRadius(radiusZ);
218  d->ellipsoidSource->SetParametricFunction(d->vtkEllipsoid);
219 
220  // connection of data to actor
221 #if (VTK_MAJOR_VERSION <= 5)
222  this->getMapper()->SetInput(d->ellipsoidSource->GetOutput());
223 #else
224  this->getMapper()->SetInputData(d->ellipsoidSource->GetOutput());
225 #endif
226  this->getActor()->SetMapper(this->getMapper());
227 
228  this->AddPart(this->getActor());
229 
230  if (!d->ellipsoidObserver) {
231 // d->axlEllipsoidPicker = vtkCellPicker::New();
232  d->ellipsoidObserver = axlActorEllipsoidObserver::New() ;
233  this->getInteractor()->AddObserver(vtkCommand::InteractionEvent, d->ellipsoidObserver);
234  this->getInteractor()->AddObserver(vtkCommand::MouseMoveEvent, d->ellipsoidObserver);
235 
236  d->ellipsoidObserver->observerDataAssembly = this;
237 // d->ellipsoidObserver->axlEllipsoidPicker = d->axlEllipsoidPicker;
238  d->ellipsoidObserver->observerData_ellipsoidSource = d->ellipsoidSource;
239  d->ellipsoidObserver->observerData_ellipsoid = d->ellipsoid;
240  d->ellipsoidObserver->axlInteractorStyle = dynamic_cast<axlInteractorStyleSwitch *> (this->getInteractor()->GetInteractorStyle());
241  }
242 
243  this->onUpdateGeometry();
244  QColor color = d->ellipsoid->color();
245  this->getActor()->GetProperty()->SetColor(color.redF(), color.greenF(), color.blueF());
246 
247  QString shader = d->ellipsoid->shader();
248  if(!shader.isEmpty())
249  this->setShader(shader);
250 
251  this->setOpacity(d->ellipsoid->opacity());
252 
253  connect(d->ellipsoid,SIGNAL(modifiedGeometry()),this,SLOT(onUpdateGeometry()));
254  connect(d->ellipsoid,SIGNAL(modifiedProperty()),this,SLOT(onUpdateProperty()));
255 
256  } else
257  qDebug()<< "no axlEllipsoid available";
258 }
259 
260 void axlActorEllipsoid::setDisplay(bool display) {
261  axlActor::setDisplay(display);
262 
263  if (display && d->lineXWidget) {
264  this->showEllipsoidWidget(true);
265  }
266 
267  if (!display && d->lineXWidget) {
268  this->showEllipsoidWidget(false);
269  }
270 }
271 
273  if (!d->lineXWidget || !d->lineYWidget || !d->lineZWidget) {
274  qDebug() << "No tet actor computed for this axlActorCylinder.";
275  return;
276  }
277 
278  if (show) {
279  d->lineXWidget->SetEnabled(1);
280  d->lineYWidget->SetEnabled(1);
281  d->lineZWidget->SetEnabled(1);
282  }
283 
284  if (!show) {
285  d->lineXWidget->SetEnabled(0);
286  d->lineYWidget->SetEnabled(0);
287  d->lineZWidget->SetEnabled(0);
288 
289  }
290 }
291 
292 void axlActorEllipsoid::setEllipsoidWidget(bool ellipsoidWidget) {
293  if (ellipsoidWidget) {
294  if (!d->lineXWidget || !d->lineYWidget || !d->lineZWidget) {
295  //widget drawing
296 
297  d->lineXWidget = vtkLineWidget::New();
298  d->lineXWidget->SetInteractor(this->getInteractor());
299  d->lineXWidget->SetProp3D(this->getActor());
300  d->lineXWidget->PlaceWidget();
301 
302  d->lineYWidget = vtkLineWidget::New();
303  d->lineYWidget->SetInteractor(this->getInteractor());
304  d->lineYWidget->SetProp3D(this->getActor());
305  d->lineYWidget->PlaceWidget();
306 
307  d->lineZWidget = vtkLineWidget::New();
308  d->lineZWidget->SetInteractor(this->getInteractor());
309  d->lineZWidget->SetProp3D(this->getActor());
310  d->lineZWidget->PlaceWidget();
311 
312  axlPoint center = *(d->ellipsoid->center());
313 
314 // axlPoint orientationX((*this->getActor()->GetMatrix())[0][0], (*this->getActor()->GetMatrix())[1][0], (*this->getActor()->GetMatrix())[2][0]);
315 // axlPoint orientationY((*this->getActor()->GetMatrix())[0][1], (*this->getActor()->GetMatrix())[1][1], (*this->getActor()->GetMatrix())[2][1]) ;
316 // axlPoint orientationZ((*this->getActor()->GetMatrix())[0][2], (*this->getActor()->GetMatrix())[1][2], (*this->getActor()->GetMatrix())[2][2]) ;
317 
318  axlPoint orientationX(this->getActor()->GetMatrix()->GetElement(0,0), this->getActor()->GetMatrix()->GetElement(1,0), this->getActor()->GetMatrix()->GetElement(2,0));
319  axlPoint orientationY(this->getActor()->GetMatrix()->GetElement(0,1), this->getActor()->GetMatrix()->GetElement(1,1), this->getActor()->GetMatrix()->GetElement(2,1)) ;
320  axlPoint orientationZ(this->getActor()->GetMatrix()->GetElement(0,2), this->getActor()->GetMatrix()->GetElement(1,2), this->getActor()->GetMatrix()->GetElement(2,2)) ;
321 
322  orientationX.normalize();
323  orientationY.normalize();
324  orientationZ.normalize();
325 
326  d->lineXWidget->SetPoint1((center - (orientationX * d->ellipsoid->semiX()->norm())).coordinates());
327  d->lineXWidget->SetPoint2((center + (orientationX * d->ellipsoid->semiX()->norm())).coordinates());
328 
329  d->lineYWidget->SetPoint1((center - (orientationY * d->ellipsoid->semiY()->norm())).coordinates());
330  d->lineYWidget->SetPoint2((center + (orientationY * d->ellipsoid->semiY()->norm())).coordinates());
331 
332  d->lineZWidget->SetPoint1((center - (orientationZ * d->ellipsoid->semiZ()->norm())).coordinates());
333  d->lineZWidget->SetPoint2((center + (orientationZ * d->ellipsoid->semiZ()->norm())).coordinates());
334  }
335 
336  if (d->ellipsoidObserver) {
337  d->lineXWidget->AddObserver(vtkCommand::InteractionEvent, d->ellipsoidObserver);
338  d->lineYWidget->AddObserver(vtkCommand::InteractionEvent, d->ellipsoidObserver);
339  d->lineZWidget->AddObserver(vtkCommand::InteractionEvent, d->ellipsoidObserver);
340 
341 
342  d->ellipsoidObserver->lineXWidget = d->lineXWidget;
343  d->ellipsoidObserver->lineYWidget = d->lineYWidget;
344  d->ellipsoidObserver->lineZWidget = d->lineZWidget;
345  }
346 
347  // there is always the controlPoints there
348  d->lineXWidget->SetEnabled(true);
349  d->lineYWidget->SetEnabled(true);
350  d->lineZWidget->SetEnabled(true);
351 
352 
353  } else { // (!pointWidget)
354  if (this->getActor()) {
355  if (d->lineXWidget) {
356  d->lineXWidget->RemoveAllObservers();
357  d->lineXWidget->SetEnabled(false);
358  d->lineXWidget->Delete(); // warning not sure
359  d->lineXWidget = NULL;
360  }
361 
362  if (d->lineYWidget) {
363  d->lineYWidget->RemoveAllObservers();
364  d->lineYWidget->SetEnabled(false);
365  d->lineYWidget->Delete(); // warning not sure
366  d->lineYWidget = NULL;
367  }
368 
369  if (d->lineZWidget) {
370  d->lineZWidget->RemoveAllObservers();
371  d->lineZWidget->SetEnabled(false);
372  d->lineZWidget->Delete(); // warning not sure
373  d->lineZWidget = NULL;
374  }
375  }
376  }
377  if (d->ellipsoidObserver){
378  d->ellipsoidObserver->lineXWidget = d->lineXWidget;
379  d->ellipsoidObserver->lineYWidget = d->lineYWidget;
380  d->ellipsoidObserver->lineZWidget = d->lineZWidget;
381  }
382 }
383 
385  if (!d->lineXWidget || !d->lineYWidget || !d->lineZWidget) {
386  qDebug() << "No tet actor computed for this axlActorBSpline.";
387  return false;
388  }
389 
390  return d->lineXWidget->GetEnabled() && d->lineYWidget->GetEnabled() && d->lineZWidget->GetEnabled();
391 }
392 
393 
394 void axlActorEllipsoid::setMode(int state) {
395  this->onModeChanged(state);
396  emit stateChanged(this->data(), state);
397 }
398 
400  if (state == 0) {
402  this->getActor()->SetPickable(1);
403 
404  if (axlAbstractData *data = dynamic_cast<axlAbstractData *>(this->data())) {
405  QColor color = data->color();
406  this->getActor()->GetProperty()->SetColor(color.redF(), color.greenF(), color.blueF());
407  }
408  this->setEllipsoidWidget(false);
409 
410  } else if (state == 1) {
412  this->getActor()->SetPickable(1);
413  vtkProperty *prop = this->getActor()->GetProperty();
414 
415  if(axlAbstractData *data = dynamic_cast<axlAbstractData *>(this->data())) {
416  QColor color = data->color();
417  qreal *h = new qreal(0.0);
418  qreal *s = new qreal(0.0);
419  qreal *l = new qreal(0.0);
420  color.getHslF(h, s, l);
421  color.setHslF(*h, *s, *l + (1.0 - *l) / 2.0);
422  prop->SetColor(color.redF(), color.greenF(), color.blueF());
423  delete l;
424  delete s;
425  delete h;
426  }
427  this->setEllipsoidWidget(false);
428  } else if (state == 2) {
430  this->getActor()->SetPickable(0);
431  vtkProperty *prop = this->getActor()->GetProperty();
432  if(axlAbstractData *data = dynamic_cast<axlAbstractData *>(this->data()))
433  {
434  QColor color = data->color();
435  qreal *h = new qreal(0.0);
436  qreal *s = new qreal(0.0);
437  qreal *l = new qreal(0.0);
438  color.getHslF(h, s, l);
439  color.setHslF(*h, *s, *l + (1.0 - *l)/2.0);
440  prop->SetColor(color.redF(), color.greenF(), color.blueF());
441  delete l;
442  delete s;
443  delete h;
444  }
445  this->setEllipsoidWidget(true);
446  }
447 
448  this->Modified();
449 }
450 
451 
453 
454  // if on edit mode, change to selection mode (for stability)
455  if (this->getState() == 2)
456  setMode(1);
457 
458  //remove ellipsoid specificity
459  if (d->ellipsoidObserver) {
460  this->getInteractor()->RemoveObservers(vtkCommand::InteractionEvent, d->ellipsoidObserver);
461  this->getInteractor()->RemoveObservers(vtkCommand::MouseMoveEvent, d->ellipsoidObserver);
462  d->ellipsoidObserver->observerDataAssembly = NULL;
463 // d->ellipsoidObserver->axlEllipsoidPicker = NULL;
464  d->ellipsoidObserver->observerData_ellipsoidSource = NULL;
465  d->ellipsoidObserver->observerData_ellipsoid = NULL;
466  d->ellipsoidObserver->axlInteractorStyle = NULL;
467  d->ellipsoidObserver->Delete();
468  d->ellipsoidObserver = NULL;
469 
470 // d->axlEllipsoidPicker->Delete();
471 // d->axlEllipsoidPicker = NULL;
472  }
473  if (d->ellipsoidSource) {
474  d->ellipsoidSource->Delete();
475  d->ellipsoidSource = NULL;
476  }
477  if (d->widget) {
478  d->widget = NULL;
479  }
480  if (d->ellipsoid) {
481  d->ellipsoid = NULL;
482  }
483  if (d->lineXWidget && d->lineYWidget && d->lineZWidget) {
484  this->setEllipsoidWidget(false);
485  d->lineXWidget = NULL;
486  d->lineYWidget = NULL;
487  d->lineZWidget = NULL;
488  }
489 
490  //remove actor specificity
491  this->RemoveAllObservers();
492  this->RemovePart(this->getActor());
493  this->getActor()->RemoveAllObservers();
494 
495  if(axlActorComposite *actorComposite = dynamic_cast<axlActorComposite *>(this->parent()))
496  actorComposite->removeActorReference(this);
497 }
498 
500  d->ellipsoidSource->Modified();
501  d->ellipsoidSource->Update();
502 
503  d->vtkEllipsoid->SetXRadius(d->ellipsoid->semiX()->norm());
504  d->vtkEllipsoid->SetYRadius(d->ellipsoid->semiY()->norm());
505  d->vtkEllipsoid->SetZRadius(d->ellipsoid->semiZ()->norm());
506 
507  vtkMatrix4x4 *actorMatrix = vtkMatrix4x4::New();
508 // (*actorMatrix)[0][0] = d->ellipsoid->semiX()->x();
509  actorMatrix->SetElement(0, 0, d->ellipsoid->semiX()->x());
510 // (*actorMatrix)[0][1] = d->ellipsoid->semiY()->x();
511  actorMatrix->SetElement(0, 1, d->ellipsoid->semiY()->x());
512 // (*actorMatrix)[0][2] = d->ellipsoid->semiZ()->x();
513  actorMatrix->SetElement(0, 2, d->ellipsoid->semiZ()->x());
514 
515 // (*actorMatrix)[1][0] = d->ellipsoid->semiX()->y();
516  actorMatrix->SetElement(1, 0, d->ellipsoid->semiX()->y());
517 // (*actorMatrix)[1][1] = d->ellipsoid->semiY()->y();
518  actorMatrix->SetElement(1, 1, d->ellipsoid->semiY()->y());
519 // (*actorMatrix)[1][2] = d->ellipsoid->semiZ()->y();
520  actorMatrix->SetElement(1, 2, d->ellipsoid->semiZ()->y());
521 
522 // (*actorMatrix)[2][0] = d->ellipsoid->semiX()->z();
523  actorMatrix->SetElement(2, 0, d->ellipsoid->semiX()->z());
524 // (*actorMatrix)[2][1] = d->ellipsoid->semiY()->z();
525  actorMatrix->SetElement(2, 1, d->ellipsoid->semiY()->z());
526 // (*actorMatrix)[2][2] = d->ellipsoid->semiZ()->z();
527  actorMatrix->SetElement(2, 2, d->ellipsoid->semiZ()->z());
528  double orient[3];
529  vtkTransform::GetOrientation(orient, actorMatrix);
530  this->getActor()->SetOrientation(orient);
531 
532  this->getActor()->SetPosition(d->ellipsoid->center()->coordinates());
533 
534  if(d->lineXWidget && d->lineYWidget && d->lineZWidget) {
535  axlPoint center = *(d->ellipsoid->center());
536 
537 // axlPoint orientationX((*this->getActor()->GetMatrix())[0][0], (*this->getActor()->GetMatrix())[1][0], (*this->getActor()->GetMatrix())[2][0]);
538 // axlPoint orientationY((*this->getActor()->GetMatrix())[0][1], (*this->getActor()->GetMatrix())[1][1], (*this->getActor()->GetMatrix())[2][1]) ;
539 // axlPoint orientationZ((*this->getActor()->GetMatrix())[0][2], (*this->getActor()->GetMatrix())[1][2], (*this->getActor()->GetMatrix())[2][2]) ;
540 
541  axlPoint orientationX(this->getActor()->GetMatrix()->GetElement(0,0), this->getActor()->GetMatrix()->GetElement(1,0), this->getActor()->GetMatrix()->GetElement(2,0));
542  axlPoint orientationY(this->getActor()->GetMatrix()->GetElement(0,1), this->getActor()->GetMatrix()->GetElement(1,1), this->getActor()->GetMatrix()->GetElement(2,1)) ;
543  axlPoint orientationZ(this->getActor()->GetMatrix()->GetElement(0,2), this->getActor()->GetMatrix()->GetElement(1,2), this->getActor()->GetMatrix()->GetElement(2,2)) ;
544 
545  orientationX.normalize();
546  orientationY.normalize();
547  orientationZ.normalize();
548 
549  d->lineXWidget->SetPoint1((center - (orientationX * (d->ellipsoid->semiX()->norm()))).coordinates());
550  d->lineXWidget->SetPoint2((center + (orientationX * (d->ellipsoid->semiX()->norm()))).coordinates());
551 
552  d->lineYWidget->SetPoint1((center - (orientationY * (d->ellipsoid->semiY()->norm()))).coordinates());
553  d->lineYWidget->SetPoint2((center + (orientationY * (d->ellipsoid->semiY()->norm()))).coordinates());
554 
555  d->lineZWidget->SetPoint1((center - (orientationZ * (d->ellipsoid->semiZ()->norm()))).coordinates());
556  d->lineZWidget->SetPoint2((center + (orientationZ * (d->ellipsoid->semiZ()->norm()))).coordinates());
557  }
558 
559  if(!d->ellipsoid->fields().isEmpty())
560  d->ellipsoid->touchField();
561 
562  if(d->ellipsoid->updateView())
563  emit updated();
564 }
565 
566 axlActorEllipsoid::axlActorEllipsoid(void) : axlActor(), d(new axlActorEllipsoidPrivate) {
567  d->ellipsoid = NULL;
568  d->lineXWidget = NULL;
569  d->lineYWidget = NULL;
570  d->lineZWidget = NULL;
571 // d->axlEllipsoidPicker = NULL;
572  d->ellipsoidObserver = NULL;
573  d->ellipsoidSource =NULL;
574  d->widget = NULL;
575 }
576 
578  delete d;
579  d = NULL;
580 }
581 
583 
584  return axlActorEllipsoid::New();
585 }
Class axlPoint defines 3D points.
Definition: axlPoint.h:34
void modifyCenter(double *center)
modify Center of this Ellipsoid.
void setEllipsoidWidget(bool ellipsoidWidget)
virtual void setDisplay(bool display)
Definition: axlActor.cpp:440
axlInteractorStyleSwitch * axlInteractorStyle
double * coordinates(void) const
Returns coordinates of this point.
Definition: axlPoint.cpp:445
void stateChanged(dtkAbstractData *data, int mode)
axlAbstractActor * createAxlActorEllipsoid(void)
virtual void setState(int state)
Definition: axlActor.cpp:434
vtkParametricEllipsoid * vtkEllipsoid
void setQVTKWidget(QVTKOpenGLWidget *widget)
virtual int getState(void)
Definition: axlActor.cpp:429
vtkParametricEllipsoid * ellipsoid(void)
void modifySemiX(double *semiX)
modify SemiX of this Ellipsoid.
void updated(void)
vtkParametricFunctionSource * observerData_ellipsoidSource
vtkCxxRevisionMacro(axlActorEllipsoid,"$Revision: 0.0.1 $")
void calculateXZ(void)
void calculateYZ(void)
void modifySemiY(double *semiY)
modify SemiY of this Ellipsoid.
void normalize(void)
Definition: axlPoint.cpp:410
virtual void setShader(QString vsfile)
Definition: axlActor.cpp:517
virtual axlAbstractActor * parent(void)
virtual void setOpacity(double opacity)
Definition: axlActor.cpp:461
void setMode(int state)
void setDisplay(bool display)
virtual void Execute(vtkObject *caller, unsigned long event, void *)
void setMapper(vtkSmartPointer< vtkPolyDataMapper > mapper)
Definition: axlActor.cpp:332
void setActor(vtkSmartPointer< vtkActor > actor)
Definition: axlActor.cpp:322
vtkSmartPointer< vtkActor > getActor(void)
Definition: axlActor.cpp:317
virtual void onUpdateProperty(void)
vtkSmartPointer< vtkPolyDataMapper > getMapper(void)
Definition: axlActor.cpp:327
virtual void setData(dtkAbstractData *ellipsoid1)
axlActorEllipsoid * observerDataAssembly
vtkStandardNewMacro(axlActorEllipsoid)
void showEllipsoidWidget(bool ellipsoidWidget)
void modifySemiZ(double *semiZ)
modify SemiZ of this Ellipsoid.
dtkAbstractData * data(void)
void onModeChanged(int state)
virtual vtkRenderWindowInteractor * getInteractor(void)
Definition: axlActor.cpp:264
Class axlEllipsoid defines 3D ellipsoids.
Definition: axlEllipsoid.h:35
void calculateXY(void)
Class axlAbstractData defines an API for all type of axel data.
bool isShowEllipsoidWidget(void)
static axlActorEllipsoidObserver * New(void)