Developer documentation | Axl-2.5.1

axlActorTorus.cpp
Go to the documentation of this file.
1 /* axlActorTorus.cpp ---
2  *
3  * Author: Valentin Michelet
4  * Copyright (C) 2008 - Valentin Michelet, Inria.
5  * Created: Tue Nov 9 16:58:59 2010 (+0100)
6  * Version: $Id$
7  * Last-Updated: Mon Dec 17 15:02:34 2012 (+0100)
8  * By: Julien Wintz
9  * Update #: 26
10  */
11 
12 /* Commentary:
13  *
14  */
15 
16 /* Change log:
17  *
18  */
19 
20 #include "axlActorTorus.h"
21 
22 #include "axlActorComposite.h"
24 
25 #include <axlCore/axlTorus.h>
26 #include <axlCore/axlPoint.h>
27 
28 #include <QVTKOpenGLWidget.h>
29 
30 #include <vtkActor.h>
31 #include <vtkAssemblyPath.h>
32 //#include <vtkCellPicker.h>
33 #include <vtkCommand.h>
34 #include <vtkGlyph3D.h>
35 #include <vtkInteractorStyleSwitch.h>
36 #include <vtkLight.h>
37 #include <vtkLightCollection.h>
38 #include <vtkParametricFunctionSource.h>
39 #include <vtkParametricTorus.h>
40 #include <vtkLineWidget.h>
41 #include <vtkObjectFactory.h>
42 #include <vtkPoints.h>
43 #include <vtkPointWidget.h>
44 #include <vtkPolyData.h>
45 #include <vtkPolyDataMapper.h>
46 #include <vtkProperty.h>
47 #include <vtkRenderer.h>
48 #include <vtkRendererCollection.h>
49 #include <vtkRenderWindow.h>
50 #include <vtkRenderWindowInteractor.h>
51 #include <vtkSmartPointer.h>
52 #include <vtkTransform.h>
53 
54 
55 class axlActorTorusObserver : public vtkCommand {
56 public:
57  static axlActorTorusObserver *New(void) {
58  return new axlActorTorusObserver;
59  }
60 
61  virtual void Execute(vtkObject *caller, unsigned long event, void *) {
62  vtkRenderWindowInteractor *interactor = observerDataAssembly->getInteractor(); //interactor->Render();
63 
64  if(event == vtkCommand::InteractionEvent) {
65  observerData_torusSource->Update();
66  observerData_torusSource->Modified();
67  interactor->Render();
68 
70  return;
71 
72 // axlPoint center = *(observerData_torus->centerPoint());
73 //
75 // axlPoint orientationX(observerDataAssembly->getActor()->GetMatrix()->GetElement(0,0), observerDataAssembly->getActor()->GetMatrix()->GetElement(1,0), observerDataAssembly->getActor()->GetMatrix()->GetElement(2,0));
77 // axlPoint orientationY(observerDataAssembly->getActor()->GetMatrix()->GetElement(0,1), observerDataAssembly->getActor()->GetMatrix()->GetElement(1,1), observerDataAssembly->getActor()->GetMatrix()->GetElement(2,1));
78 // //axlPoint orientationZ((*observerDataAssembly->getActor()->GetMatrix())[0][2], (*observerDataAssembly->getActor()->GetMatrix())[1][2], (*observerDataAssembly->getActor()->GetMatrix())[2][2]);
79 // axlPoint orientationZ(*(observerData_torus->direction()) - *(observerData_torus->centerPoint()));
80 //
81 // orientationX.normalize();
82 // orientationY.normalize();
83 // orientationZ.normalize();
84 //
85 // axlPoint ringPoint(ringRadiusPointWidget->GetPosition()[0], ringRadiusPointWidget->GetPosition()[1], ringRadiusPointWidget->GetPosition()[2]);
86 // axlPoint ringPointStart((center + (orientationX * (observerData_torus->ringRadius() + observerData_torus->crossSectionRadius()))).coordinates());
87 //
88 // axlPoint crossSectionPoint(crossSectionRadiusPointWidget->GetPosition()[0], crossSectionRadiusPointWidget->GetPosition()[1], crossSectionRadiusPointWidget->GetPosition()[2]);
89 // axlPoint crossSectionPointStart((center + (orientationY * (observerData_torus->ringRadius() - observerData_torus->crossSectionRadius()))).coordinates());
90 //
91 // axlPoint directionPoint1(directionLineWidget->GetPoint1()[0], directionLineWidget->GetPoint1()[1], directionLineWidget->GetPoint1()[2]);
92 // axlPoint directionPoint2(directionLineWidget->GetPoint2()[0], directionLineWidget->GetPoint2()[1], directionLineWidget->GetPoint2()[2]);
93 //
94 // double ringRadius = observerData_torus->ringRadius();
95 // double crossSectionRadius = observerData_torus->crossSectionRadius();
96 
97  // if (axlPoint::distance(&crossSectionPoint, &crossSectionPointStart) > 0.001) {
98  if (caller == crossSectionRadiusPointWidget){
99  //We are moving the cross section radius point
100  axlPoint center = *(observerData_torus->centerPoint());
101  axlPoint orientationY(observerDataAssembly->getActor()->GetMatrix()->GetElement(0,1), observerDataAssembly->getActor()->GetMatrix()->GetElement(1,1), observerDataAssembly->getActor()->GetMatrix()->GetElement(2,1));
102  orientationY.normalize();
103  axlPoint crossSectionPoint(crossSectionRadiusPointWidget->GetPosition()[0], crossSectionRadiusPointWidget->GetPosition()[1], crossSectionRadiusPointWidget->GetPosition()[2]);
104  double ringRadius = observerData_torus->ringRadius();
105 
106  axlPoint v(orientationY);
107  axlPoint AB(crossSectionPoint - center);
108  double normABH = (v.x() * AB.x() + v.y() * AB.y() + v.z() * AB.z());
109  axlPoint ABH = v*normABH;
110  axlPoint BH = center+ABH;
111  double newCrossSectionRadius = ringRadius - axlPoint::distance(&BH, &center);
112  if (newCrossSectionRadius > 0) {
113  observerData_torus->setCrossSectionRadius(newCrossSectionRadius);
114  }
115  }//else if (axlPoint::distance(&ringPoint, &ringPointStart) > 0.001) {
116  else if (caller == ringRadiusPointWidget){
117  //We are moving the ring radius point
118  axlPoint center = *(observerData_torus->centerPoint());
119  axlPoint orientationX(observerDataAssembly->getActor()->GetMatrix()->GetElement(0,0), observerDataAssembly->getActor()->GetMatrix()->GetElement(1,0), observerDataAssembly->getActor()->GetMatrix()->GetElement(2,0));
120  orientationX.normalize();
121  axlPoint ringPoint(ringRadiusPointWidget->GetPosition()[0], ringRadiusPointWidget->GetPosition()[1], ringRadiusPointWidget->GetPosition()[2]);
122 
123  axlPoint u(orientationX);
124  axlPoint AB(ringPoint - center);
125  double normABH = (u.x() * AB.x() + u.y() * AB.y() + u.z() * AB.z());
126  axlPoint ABH = u*normABH;
127  axlPoint BH = center + ABH;
128  double newRingRadius = axlPoint::distance(&BH, &center) - observerData_torus->crossSectionRadius();
129  observerData_torus->setRingRadius(newRingRadius);
130  }
131  else if (caller == directionLineWidget){
132  axlPoint directionPoint1(directionLineWidget->GetPoint1()[0], directionLineWidget->GetPoint1()[1], directionLineWidget->GetPoint1()[2]);
133  axlPoint directionPoint2(directionLineWidget->GetPoint2()[0], directionLineWidget->GetPoint2()[1], directionLineWidget->GetPoint2()[2]);
134 
135  observerData_torus->setDirection(directionPoint1.coordinates());
136  observerData_torus->setCenter(directionPoint2.coordinates());
137  }
138  else
139  return;
140 
143  }
144 
145 // if(event == vtkCommand::MouseMoveEvent) {
146 // //qDebug() << "vtkCommand::MouseMoveEvent";
147 // if (observerData_torus) {
148 // vtkAssemblyPath *path;
149 // vtkRenderWindow *renderWindow = interactor->GetRenderWindow();
150 // vtkRendererCollection * rendererCollection = renderWindow->GetRenderers();
151 // vtkRenderer *render = rendererCollection->GetFirstRenderer();
152 // axlInteractorStyle = dynamic_cast<axlInteractorStyleSwitch *>(interactor->GetInteractorStyle());
153 
154 // int X = observerDataAssembly->getInteractor()->GetEventPosition()[0];
155 // int Y = observerDataAssembly->getInteractor()->GetEventPosition()[1];
156 
157 // if (!render || !render->IsInViewport(X, Y)) {
158 // //qDebug()<<" No renderer or bad cursor coordonates";
159 // }
160 
161 // axlTorusPicker->Pick(X,Y,0.0,render);
162 // path = axlTorusPicker->GetPath();
163 
164 // if (path != NULL) {
165 // double *position = observerDataAssembly->GetPosition();
166 // (void)position;
167 
168 // for(int j=0;j<3;j++) {
169 // //qDebug()<<"axlActorCylinderObserver :: Execute "<<position[j];
170 // //observerData_line->coordinates()[j] = position[j];
171 // }
172 
173 // }
174 // }
175 // }
176  }
178 // vtkCellPicker *axlTorusPicker;
181  vtkParametricFunctionSource *observerData_torusSource;
182  vtkParametricTorus *vtkTorus;
183 
184  vtkPointWidget *ringRadiusPointWidget = nullptr;
185  vtkPointWidget *crossSectionRadiusPointWidget = nullptr;
186  vtkLineWidget *directionLineWidget = nullptr;
187 
188 };
189 
193 
194 class axlActorTorusPrivate
195 {
196 public:
197  axlTorus *torus;
198  vtkParametricFunctionSource *torusSource;
199  vtkPointWidget *ringRadiusPointWidget;
200  vtkPointWidget *crosSectionRadiusPointWidget;
201  vtkLineWidget *directionLineWidget;
202  axlActorTorusObserver *torusObserver;
203  QVTKOpenGLWidget *widget;
204 // vtkCellPicker *axlTorusPicker;
205  vtkParametricTorus* vtkTorus;
206 };
207 
208 #if (VTK_MAJOR_VERSION <= 5)
209 vtkCxxRevisionMacro(axlActorTorus, "$Revision: 0.0.1 $")
210 #endif
211 
213 
214 dtkAbstractData *axlActorTorus::data(void) {
215  return d->torus;
216 }
217 
218 vtkParametricFunctionSource *axlActorTorus::torus(void) {
219  return d->torusSource;
220 }
221 
222 void axlActorTorus::setQVTKWidget(QVTKOpenGLWidget *widget) {
223  d->widget = widget;
224 }
225 
226 void axlActorTorus::setData(dtkAbstractData *torus1) {
227 
228  axlTorus *torus = dynamic_cast<axlTorus *>(torus1);
229  if(torus) {
230  d->torus = torus;
231  this->setMapper(vtkSmartPointer<vtkPolyDataMapper>::New());
232  this->setActor(vtkSmartPointer<vtkActor>::New());
233 
234  d->torusSource = vtkParametricFunctionSource::New();
235 
236  d->vtkTorus = vtkParametricTorus::New();
237  d->vtkTorus->SetRingRadius(d->torus->ringRadius());
238  d->vtkTorus->SetCrossSectionRadius(d->torus->crossSectionRadius());
239  d->torusSource->SetParametricFunction(d->vtkTorus);
240 
241  this->onUpdateGeometry();
242 #if (VTK_MAJOR_VERSION <= 5)
243  this->getMapper()->SetInput(d->torusSource->GetOutput());
244 #else
245  this->getMapper()->SetInputData(d->torusSource->GetOutput());
246 #endif
247  this->getActor()->SetMapper(this->getMapper());
248 
249  this->AddPart(this->getActor());
250 
251  if(!d->torusObserver) {
252 // d->axlTorusPicker = vtkCellPicker::New();
253  d->torusObserver = axlActorTorusObserver::New() ;
254  this->getInteractor()->AddObserver(vtkCommand::InteractionEvent, d->torusObserver);
255  this->getInteractor()->AddObserver(vtkCommand::MouseMoveEvent, d->torusObserver);
256 
257  d->torusObserver->observerDataAssembly = this;
258 // d->torusObserver->axlTorusPicker = d->axlTorusPicker;
259  d->torusObserver->observerData_torusSource = d->torusSource;
260  d->torusObserver->observerData_torus = d->torus;
261  d->torusObserver->vtkTorus = d->vtkTorus;
262  d->torusObserver->axlInteractorStyle = dynamic_cast<axlInteractorStyleSwitch *> (this->getInteractor()->GetInteractorStyle());
263  }
264 
265  QColor color = d->torus->color();
266  this->getActor()->GetProperty()->SetColor(color.redF(), color.greenF(), color.blueF());
267 
268  QString shader = d->torus->shader();
269  if(!shader.isEmpty())
270  this->setShader(shader);
271 
272  this->setOpacity(d->torus->opacity());
273  connect(d->torus, SIGNAL(modifiedGeometry()),this, SLOT(onUpdateGeometry()));
274  connect(d->torus, SIGNAL(modifiedProperty()),this, SLOT(onUpdateProperty()));
275  }
276  else
277  qDebug()<< "no axlTorus available";
278 }
279 
280 
281 void axlActorTorus::setDisplay(bool display) {
282  axlActor::setDisplay(display);
283 
284  if (display && d->directionLineWidget) {
285  this->showTorusWidget(true);
286  }
287 
288  if (!display && d->directionLineWidget) {
289  this->showTorusWidget(false);
290  }
291 }
292 
294  if (!d->ringRadiusPointWidget || !d->crosSectionRadiusPointWidget || !d->directionLineWidget) {
295  qDebug() << "No actor computed for this axlActorTorus.";
296  return;
297  }
298 
299  if (show) {
300  d->ringRadiusPointWidget->SetEnabled(1);
301  d->crosSectionRadiusPointWidget->SetEnabled(1);
302  d->directionLineWidget->SetEnabled(1);
303  }
304 
305  if (!show) {
306  d->ringRadiusPointWidget->SetEnabled(0);
307  d->crosSectionRadiusPointWidget->SetEnabled(0);
308  d->directionLineWidget->SetEnabled(0);
309 
310  }
311 }
312 
313 void axlActorTorus::setTorusWidget(bool torusWidget) {
314 
315  if(torusWidget) {
316  if(!d->ringRadiusPointWidget || !d->crosSectionRadiusPointWidget || !d->directionLineWidget) {
317  //widget drawing
318 
319  axlPoint center = *(d->torus->centerPoint());
320 
321  //Ring Radius pointWidget
322  d->ringRadiusPointWidget = vtkPointWidget::New();
323  d->ringRadiusPointWidget->SetInteractor(this->getInteractor());
324  d->ringRadiusPointWidget->SetProp3D(this->getActor());
325  d->ringRadiusPointWidget->PlaceWidget();
326  d->ringRadiusPointWidget->AllOff();
327  d->ringRadiusPointWidget->SetTranslationMode(1);
328 
329 // axlPoint orientationX((*this->getActor()->GetMatrix())[0][0], (*this->getActor()->GetMatrix())[1][0], (*this->getActor()->GetMatrix())[2][0]);
330  axlPoint orientationX(this->getActor()->GetMatrix()->GetElement(0,0), this->getActor()->GetMatrix()->GetElement(1,0), this->getActor()->GetMatrix()->GetElement(2,0));
331  orientationX.normalize();
332  d->ringRadiusPointWidget->SetPosition((center + (orientationX * (d->torus->ringRadius() + d->torus->crossSectionRadius()))).coordinates());
333 
334  //Ring Cross Section pointWidget
335  d->crosSectionRadiusPointWidget = vtkPointWidget::New();
336  d->crosSectionRadiusPointWidget->SetInteractor(this->getInteractor());
337  d->crosSectionRadiusPointWidget->SetProp3D(this->getActor());
338  d->crosSectionRadiusPointWidget->PlaceWidget();
339  d->crosSectionRadiusPointWidget->AllOff();
340  d->crosSectionRadiusPointWidget->SetTranslationMode(1);
341 
342 // axlPoint orientationY((*this->getActor()->GetMatrix())[0][1], (*this->getActor()->GetMatrix())[1][1], (*this->getActor()->GetMatrix())[2][1]);
343  axlPoint orientationY(this->getActor()->GetMatrix()->GetElement(0,1), this->getActor()->GetMatrix()->GetElement(1,1), this->getActor()->GetMatrix()->GetElement(2,1));
344  orientationY.normalize();
345  d->crosSectionRadiusPointWidget->SetPosition((center + (orientationY * (d->torus->ringRadius() - d->torus->crossSectionRadius()))).coordinates());
346 
347  //Direction lineWidget
348  d->directionLineWidget = vtkLineWidget::New();
349  d->directionLineWidget->SetInteractor(this->getInteractor());
350  d->directionLineWidget->SetProp3D(this->getActor());
351  d->directionLineWidget->PlaceWidget();
352 
353  d->directionLineWidget->SetPoint1(d->torus->direction()->coordinates());
354  d->directionLineWidget->SetPoint2(center.coordinates());
355  //d->directionLineWidget->SetPoint2((center - (orientationZ * d->torus->ringRadius())).coordinates());
356  }
357 
358  if(d->torusObserver) {
359  d->ringRadiusPointWidget->AddObserver(vtkCommand::InteractionEvent, d->torusObserver);
360  d->crosSectionRadiusPointWidget->AddObserver(vtkCommand::InteractionEvent, d->torusObserver);
361  d->directionLineWidget->AddObserver(vtkCommand::InteractionEvent, d->torusObserver);
362 
363  d->torusObserver->ringRadiusPointWidget = d->ringRadiusPointWidget;
364  d->torusObserver->crossSectionRadiusPointWidget = d->crosSectionRadiusPointWidget;
365  d->torusObserver->directionLineWidget = d->directionLineWidget;
366  }
367 
368  // there is always the controlPoints there
369  d->ringRadiusPointWidget->SetEnabled(true);
370  d->crosSectionRadiusPointWidget->SetEnabled(true);
371  d->directionLineWidget->SetEnabled(true);
372 
373  }
374 
375  if (!torusWidget) {
376  if (this->getActor()) {
377  // this->getMapper()->SetInput(this->getPolyData());
378 
379  if(d->ringRadiusPointWidget) {
380  d->ringRadiusPointWidget->RemoveAllObservers();
381  d->ringRadiusPointWidget->SetEnabled(false);
382  d->ringRadiusPointWidget->Delete(); // warning not sure
383  d->ringRadiusPointWidget = NULL;
384  }
385 
386  if(d->crosSectionRadiusPointWidget) {
387  d->crosSectionRadiusPointWidget->RemoveAllObservers();
388  d->crosSectionRadiusPointWidget->SetEnabled(false);
389  d->crosSectionRadiusPointWidget->Delete(); // warning not sure
390  d->crosSectionRadiusPointWidget = NULL;
391  }
392 
393  if(d->directionLineWidget) {
394  d->directionLineWidget->RemoveAllObservers();
395  d->directionLineWidget->SetEnabled(false);
396  d->directionLineWidget->Delete(); // warning not sure
397  d->directionLineWidget = NULL;
398  }
399  }
400  }
401  if (d->torusObserver){
402  d->torusObserver->ringRadiusPointWidget = d->ringRadiusPointWidget;
403  d->torusObserver->crossSectionRadiusPointWidget = d->crosSectionRadiusPointWidget;
404  d->torusObserver->directionLineWidget = d->directionLineWidget;
405  }
406 }
407 
409  if(!d->ringRadiusPointWidget || !d->crosSectionRadiusPointWidget || !d->directionLineWidget) {
410  qDebug() << "No actor computed for this axlActorBSpline.";
411  return false;
412  }
413 
414  return d->ringRadiusPointWidget->GetEnabled() && d->crosSectionRadiusPointWidget->GetEnabled() && d->directionLineWidget->GetEnabled();
415 }
416 
417 
418 void axlActorTorus::setMode(int state) {
419  this->onModeChanged(state);
420  emit stateChanged(this->data(), state);
421 }
422 
424  if(state == 0) {
426  this->getActor()->SetPickable(1);
427 
428  if(axlAbstractData *data = dynamic_cast<axlAbstractData *>(this->data())) {
429  QColor color = data->color();
430  this->getActor()->GetProperty()->SetColor(color.redF(), color.greenF(), color.blueF());
431  }
432  this->setTorusWidget(false);
433 
434  } else if(state == 1) {
435 
437  this->setTorusWidget(false);
438  this->getActor()->SetPickable(1);
439  vtkProperty *prop = this->getActor()->GetProperty();
440 
441  if(axlAbstractData *data = dynamic_cast<axlAbstractData *>(this->data())) {
442  QColor color = data->color();
443  qreal *h = new qreal(0.0);
444  qreal *s = new qreal(0.0);
445  qreal *l = new qreal(0.0);
446  color.getHslF(h, s, l);
447  color.setHslF(*h, *s, *l + (1.0 - *l) / 2.0);
448  prop->SetColor(color.redF(), color.greenF(), color.blueF());
449  delete l;
450  delete s;
451  delete h;
452  }
453 
454  } else if(state == 2) {
456  this->setTorusWidget(true);
457  this->getActor()->SetPickable(0);
458  vtkProperty *prop = this->getActor()->GetProperty();
459  if(axlAbstractData *data = dynamic_cast<axlAbstractData *>(this->data())) {
460  QColor color = data->color();
461  qreal *h = new qreal(0.0);
462  qreal *s = new qreal(0.0);
463  qreal *l = new qreal(0.0);
464  color.getHslF(h, s, l);
465  color.setHslF(*h, *s, *l + (1.0 - *l)/2.0);
466  prop->SetColor(color.redF(), color.greenF(), color.blueF());
467  delete l;
468  delete s;
469  delete h;
470  }
471  }
472 
473  this->Modified();
474 }
475 
476 
478 {
479 
480  // if on edit mode, change to selection mode (for stability)
481  if (this->getState() == 2)
482  setMode(1);
483 
484  //remove line specificity
485  if(d->torusObserver) {
486  this->getInteractor()->RemoveObservers(vtkCommand::InteractionEvent, d->torusObserver);
487  this->getInteractor()->RemoveObservers(vtkCommand::MouseMoveEvent, d->torusObserver);
488  d->torusObserver->observerDataAssembly = NULL;
489 // d->torusObserver->axlTorusPicker = NULL;
490  d->torusObserver->observerData_torusSource = NULL;
491  d->torusObserver->observerData_torus = NULL;
492  d->torusObserver->axlInteractorStyle = NULL;
493  d->torusObserver->Delete();
494  d->torusObserver = NULL;
495 
496 // d->axlTorusPicker->Delete();
497 // d->axlTorusPicker = NULL;
498 
499  }
500  if(d->torusSource) {
501  d->torusSource->Delete();
502  d->torusSource = NULL;
503  }
504  if(d->widget) {
505  d->widget = NULL;
506  }
507  if(d->torus) {
508  d->torus = NULL;
509  }
510  if(d->vtkTorus) {
511  d->vtkTorus->Delete();
512  d->vtkTorus = NULL;
513  }
514  if(d->ringRadiusPointWidget && d->crosSectionRadiusPointWidget && d->directionLineWidget) {
515  this->setTorusWidget(false);
516  d->ringRadiusPointWidget = NULL;
517  d->crosSectionRadiusPointWidget = NULL;
518  d->directionLineWidget = NULL;
519  }
520 
521  //remove actor specificity
522  this->RemoveAllObservers();
523  this->RemovePart(this->getActor());
524  this->getActor()->RemoveAllObservers();
525 
526  if(axlActorComposite *actorComposite = dynamic_cast<axlActorComposite *>(this->parent()) )
527  actorComposite->removeActorReference(this);
528 }
529 
531  d->vtkTorus->SetCrossSectionRadius(d->torus->crossSectionRadius());
532  d->vtkTorus->SetRingRadius(d->torus->ringRadius());
533  d->torusSource->Update();
534  d->torusSource->Modified();
535 
536  axlPoint* center = d->torus->centerPoint();
537  axlPoint* secondPoint = d->torus->direction();
538  axlPoint* direction = new axlPoint((*(secondPoint)) - (*(center)));
539 
540  //Set angle
541  direction->normalize();
542 
543  // Produit vectoriel entre la direction et l'axe du tore, Oz par défaut dans VTK
544  axlPoint n(direction->y(), -direction->x(), 0.0); //n = d vectoriel Oz
545  //if (!(fabs(n.x()) < 0.0001 && fabs(n.y()) < 0.0001)) {// vectorial product is not null
546  n.normalize();
547  //Rotation
548  this->getActor()->SetOrientation(0.0, 0.0, 0.0);
549  this->getActor()->RotateWXYZ(-acos(direction->z()) * 180 / 3.14159, n.x(), n.y(), 0.0);
550  // } else {
551 
552  // }
553 
554  //Set center
555  this->getActor()->SetPosition(center->coordinates());
556 
557  if(d->ringRadiusPointWidget && d->crosSectionRadiusPointWidget) {
558 // axlPoint orientationX((*this->getActor()->GetMatrix())[0][0], (*this->getActor()->GetMatrix())[1][0], (*this->getActor()->GetMatrix())[2][0]);
559  axlPoint orientationX(this->getActor()->GetMatrix()->GetElement(0,0), this->getActor()->GetMatrix()->GetElement(1,0), this->getActor()->GetMatrix()->GetElement(2,0));
560 // axlPoint orientationY((*this->getActor()->GetMatrix())[0][1], (*this->getActor()->GetMatrix())[1][1], (*this->getActor()->GetMatrix())[2][1]);
561  axlPoint orientationY(this->getActor()->GetMatrix()->GetElement(0,1), this->getActor()->GetMatrix()->GetElement(1,1), this->getActor()->GetMatrix()->GetElement(2,1));
562 
563  d->ringRadiusPointWidget->SetPosition((*center + (orientationX * (d->torus->ringRadius() + d->torus->crossSectionRadius()))).coordinates());
564  d->crosSectionRadiusPointWidget->SetPosition((*center + (orientationY * (d->torus->ringRadius() - d->torus->crossSectionRadius()))).coordinates());
565 
566  d->directionLineWidget->SetPoint1(secondPoint->x(), secondPoint->y(), secondPoint->z());
567  d->directionLineWidget->SetPoint2(center->x(), center->y(), center->z());
568  }
569 
570 
571  if(!d->torus->fields().isEmpty())
572  d->torus->touchField();
573 
574  if(d->torus->updateView())
575  emit updated();
576 }
577 
578 axlActorTorus::axlActorTorus(void) : axlActor(), d(new axlActorTorusPrivate) {
579  d->torus = NULL;
580  d->ringRadiusPointWidget = NULL;
581  d->crosSectionRadiusPointWidget = NULL;
582  d->directionLineWidget = NULL;
583 // d->axlTorusPicker = NULL;
584  d->torusObserver = NULL;
585  d->torusSource =NULL;
586  d->widget = NULL;
587  d->vtkTorus = NULL;
588 }
589 
591  delete d;
592  d = NULL;
593 }
594 
596 
597  return axlActorTorus::New();
598 }
axlInteractorStyleSwitch * axlInteractorStyle
void touchGeometry(void)
double crossSectionRadius
Definition: axlTorus.h:32
Class axlPoint defines 3D points.
Definition: axlPoint.h:34
void setDisplay(bool display)
vtkLineWidget * directionLineWidget
virtual void setDisplay(bool display)
Definition: axlActor.cpp:440
void setCenter(axlPoint *center)
Definition: axlTorus.cpp:136
axlPoint centerPoint
Definition: axlTorus.h:30
double * coordinates(void) const
Returns coordinates of this point.
Definition: axlPoint.cpp:445
void stateChanged(dtkAbstractData *data, int mode)
vtkParametricTorus * vtkTorus
void setCrossSectionRadius(double crossSectionRadius)
Definition: axlTorus.cpp:148
virtual void setState(int state)
Definition: axlActor.cpp:434
vtkCxxRevisionMacro(axlActorTorus,"$Revision: 0.0.1 $") vtkStandardNewMacro(axlActorTorus) dtkAbstractData *axlActorTorus
virtual void Execute(vtkObject *caller, unsigned long event, void *)
axlActorTorus * observerDataAssembly
virtual int getState(void)
Definition: axlActor.cpp:429
dtkAbstractData * data(void)
void updated(void)
vtkParametricFunctionSource * torus(void)
static axlActorTorusObserver * New(void)
void setQVTKWidget(QVTKOpenGLWidget *widget)
void normalize(void)
Definition: axlPoint.cpp:410
virtual void setShader(QString vsfile)
Definition: axlActor.cpp:517
void showTorusWidget(bool show)
axlAbstractActor * createAxlActorTorus(void)
void setTorusWidget(bool torusWidget)
virtual axlAbstractActor * parent(void)
virtual void setOpacity(double opacity)
Definition: axlActor.cpp:461
virtual void setData(dtkAbstractData *torus1)
vtkPointWidget * ringRadiusPointWidget
void onUpdateGeometry()
void setMapper(vtkSmartPointer< vtkPolyDataMapper > mapper)
Definition: axlActor.cpp:332
void setMode(int state)
void setRingRadius(double ringRadius)
Definition: axlTorus.cpp:144
void setDirection(axlPoint *direction)
Definition: axlTorus.cpp:140
double ringRadius
Definition: axlTorus.h:31
void setActor(vtkSmartPointer< vtkActor > actor)
Definition: axlActor.cpp:322
vtkSmartPointer< vtkActor > getActor(void)
Definition: axlActor.cpp:317
double y
Definition: axlPoint.h:37
virtual void onUpdateProperty(void)
vtkSmartPointer< vtkPolyDataMapper > getMapper(void)
Definition: axlActor.cpp:327
bool isShowTorusWidget(void)
void onModeChanged(int state)
vtkStandardNewMacro(axlActorCircleArc)
double z
Definition: axlPoint.h:38
static double distance(const axlPoint &lhs, const axlPoint &rhs)
Returns the distance between lhs point and rhs point.
Definition: axlPoint.cpp:459
double x
Definition: axlPoint.h:37
virtual vtkRenderWindowInteractor * getInteractor(void)
Definition: axlActor.cpp:264
Class axlAbstractData defines an API for all type of axel data.
vtkParametricFunctionSource * observerData_torusSource
static axlActorTorus * New(void)
vtkPointWidget * crossSectionRadiusPointWidget