51 #include <dtkCoreSupport/dtkAbstractViewFactory.h>
52 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
53 #include <dtkCoreSupport/dtkGlobal.h>
79 #include <vtkActorCollection.h>
80 #include <vtkAssemblyNode.h>
81 #include <vtkAssemblyPath.h>
82 #include <vtkAxesActor.h>
83 #include <vtkCamera.h>
84 #include <vtkCellPicker.h>
85 #include <vtkImageData.h>
86 #include <vtkInteractorStyleTrackballCamera.h>
87 #include <vtkInteractorStyleJoystickCamera.h>
88 #include <vtkInteractorStyleRubberBandPick.h>
89 #include <vtkInteractorStyleJoystickActor.h>
90 #include <vtkInteractorStyleTrackballActor.h>
92 #include <vtkLightActor.h>
93 #include <vtkLightKit.h>
94 #include <vtkLightCollection.h>
95 #include <vtkPlaneSource.h>
96 #include <vtkPolyDataMapper.h>
97 #include <vtkDataSetMapper.h>
98 #include <vtkProp3DCollection.h>
99 #include <vtkRenderer.h>
100 #include <vtkRendererCollection.h>
101 #include <vtkRenderWindow.h>
102 #include <vtkRenderWindowInteractor.h>
103 #include <vtkSmartPointer.h>
104 #include <vtkTexture.h>
105 #include <vtkTimerLog.h>
106 #include <vtkCallbackCommand.h>
107 #include <vtkVersion.h>
108 #include <vtkStripper.h>
109 #include <vtkPointData.h>
110 #include <vtkTriangleFilter.h>
111 #include <vtkPNGReader.h>
112 #include <vtkFloatArray.h>
113 #include <vtkGenericOpenGLRenderWindow.h>
115 #include <vtkOpenGLRenderWindow.h>
117 #include <vtkProperty.h>
120 #include <QVTKOpenGLWidget.h>
121 #include <QVTKInteractor.h>
133 virtual void Execute(vtkObject *caller,
unsigned long event,
void *)
140 vtkAssemblyPath *path;
142 vtkRendererCollection * rendererCollection = renderWindow->GetRenderers();
143 vtkRenderer *render = rendererCollection->GetFirstRenderer();
147 if (!render || !render->IsInViewport(X, Y))
149 qDebug()<<
" No renderer or bad cursor coordonates in axlVtkView";
162 actorCollection->InitTraversal();
164 for(
int i = 0; i < actorCollection->GetNumberOfItems(); i++)
166 vtkProp *currentActor = actorCollection->GetNextProp();
167 if(path->GetFirstNode()->GetViewProp() == currentActor)
169 if(
axlAbstractActor *actorProp = dynamic_cast<axlAbstractActor *>(currentActor))
186 vtkAssemblyPath *path;
188 vtkRendererCollection * rendererCollection = renderWindow->GetRenderers();
189 vtkRenderer *render = rendererCollection->GetFirstRenderer();
193 if (!render || !render->IsInViewport(X, Y))
207 actorCollection->InitTraversal();
209 for(
int i = 0; i < actorCollection->GetNumberOfItems(); i++)
211 vtkProp *currentActor = actorCollection->GetNextProp();
212 if(
axlAbstractActor *actorProp = dynamic_cast<axlAbstractActor *>(currentActor))
219 if(event == vtkCommand::KeyPressEvent)
228 widget->GetRenderWindow()->Render();
230 else if(modifier.compare(
"e") || modifier.compare(
"u"))
233 actorCollection->InitTraversal();
234 for(
int i = 0; i < actorCollection->GetNumberOfItems(); i++)
236 vtkProp *currentActor = actorCollection->GetNextProp();
237 if(
axlAbstractActor *actorProp = dynamic_cast<axlAbstractActor *>(currentActor))
271 vtkSmartPointer<axlInteractorStyleSwitch> style;
272 vtkSmartPointer<vtkCellPicker> viewerPicker;
274 vtkRenderer *renderer;
277 vtkNew<vtkGenericOpenGLRenderWindow> window;
278 vtkSmartPointer<vtkViewObserver> observer;
280 QVTKOpenGLWidget *widget;
282 vtkSmartPointer<vtkLightKit> lightKit;
283 vtkSmartPointer<vtkLight> firstLight;
287 vtkSmartPointer<vtkLightActor> lightActor;
289 double camera_center[3];
290 double camera_focal[3];
291 double camera_view_up[3];
293 bool lastCameraIsDefault;
295 vtkSmartPointer<vtkActor> actorX;
296 vtkSmartPointer<vtkActor> actorY;
297 vtkSmartPointer<vtkActor> actorZ;
298 vtkSmartPointer<vtkAxesActor> axesActor;
299 vtkSmartPointer<vtkPlaneSource> planeSourceX;
300 vtkSmartPointer<vtkPlaneSource> planeSourceY;
301 vtkSmartPointer<vtkPlaneSource> planeSourceZ;
315 d->renderer = vtkRenderer::New();
316 d->renderer->SetGradientBackground(
true);
317 d->renderer->SetBackground (0.90, 0.90, 0.90);
318 d->renderer->SetBackground2(0.64, 0.64, 0.64);
320 QSurfaceFormat::setDefaultFormat(QVTKOpenGLWidget::defaultFormat());
321 d->widget =
new QVTKOpenGLWidget;
322 d->widget->SetRenderWindow(d->window.Get());
329 d->window->SetPointSmoothing(1);
330 d->window->SetLineSmoothing(1);
333 d->window->StereoCapableWindowOn();
336 if(qApp->arguments().contains(
"--stereo")) {
337 QString stereoMode = dtkApplicationArgumentsValue(qApp,
"--stereo");
339 if (stereoMode ==
"QUAD_BUFFER") {
340 d->window->SetStereoTypeToCrystalEyes();
341 }
else if (stereoMode ==
"HORIZONTAL_SPLIT") {
342 d->window->SetStereoTypeToSplitViewportHorizontal();
343 }
else if (stereoMode ==
"HORIZONTAL_INTERLACE") {
344 d->window->SetStereoTypeToInterlaced();
345 }
else if (stereoMode ==
"ANAGLYPHIC") {
346 d->window->SetStereoTypeToAnaglyph();
348 qDebug() <<
"WARNING: Unknown stereo mode ("<< stereoMode <<
"), will use QUAD BUFFER" ;
349 d->window->SetStereoTypeToCrystalEyes();
351 d->window->SetStereoRender(1);
354 d->window->AddRenderer(d->renderer);
356 #if (VTK_MAJOR_VERSION <= 5)
357 d->widget->SetRenderWindow(d->window);
362 d->viewerPicker = vtkSmartPointer<vtkCellPicker>::New();
363 d->viewerPicker->SetTolerance(0.001);
365 d->style = vtkSmartPointer<axlInteractorStyleSwitch>::New();
366 d->style->SetDefaultRenderer(d->renderer);
368 d->axesActor = vtkSmartPointer<vtkAxesActor>::New();
369 d->axesActor->AxisLabelsOff();
370 d->axesActor->SetConeRadius(0.3);
371 d->axesActor->SetNormalizedTipLength(0.1, 0.1, 0.1);
372 d->axesActor->SetNormalizedShaftLength(0.9, 0.9, 0.9);
373 d->axesActor->SetShaftTypeToCylinder();
374 d->axesActor->SetCylinderRadius(0.005);
376 d->renderer->AddActor(d->axesActor);
377 d->renderer->ResetCamera();
386 vtkCamera *camera = d->renderer->GetActiveCamera();
387 camera->GetPosition(d->camera_center);
388 camera->GetFocalPoint(d->camera_focal);
389 camera->GetViewUp(d->camera_view_up);
390 d->lastCameraIsDefault =
true;
397 d->observer->observerViewerPicker = d->viewerPicker;
398 d->observer->observerRenderer = d->renderer;
399 d->observer->observerInteractor = d->widget->GetInteractor();
400 d->observer->observerAxesActor = d->axesActor;
401 d->observer->widget = d->widget;
403 d->widget->GetInteractor()->AddObserver(vtkCommand::LeftButtonPressEvent, d->observer);
404 d->widget->GetInteractor()->AddObserver(vtkCommand::RightButtonPressEvent, d->observer);
405 d->widget->GetInteractor()->AddObserver(vtkCommand::KeyPressEvent, d->observer);
407 d->widget->setFocusPolicy(Qt::StrongFocus);
414 d->lightWidget->Delete();
417 d->widget->GetInteractor()->RemoveObservers(vtkCommand::LeftButtonPressEvent, d->observer);
418 d->widget->GetInteractor()->RemoveObservers(vtkCommand::RightButtonPressEvent, d->observer);
419 d->widget->GetInteractor()->RemoveObservers(vtkCommand::KeyPressEvent, d->observer);
421 d->observer->observerViewerPicker = NULL;
422 d->observer->observerRenderer = NULL;
423 d->observer->observerInteractor = NULL;
425 d->observer->Delete();
428 d->renderer->Delete();
449 if(dynamic_cast<vtkInteractorStyleJoystickActor *> (d->style->GetCurrentStyle()))
450 d->style->SetCurrentStyleToJoystickCamera();
452 if(dynamic_cast<vtkInteractorStyleTrackballActor *> (d->style->GetCurrentStyle()))
453 d->style->SetCurrentStyleToTrackballCamera();
458 if(dynamic_cast<vtkInteractorStyleJoystickCamera *> (d->style->GetCurrentStyle()))
459 d->style->SetCurrentStyleToJoystickActor();
461 if(dynamic_cast<vtkInteractorStyleTrackballCamera *> (d->style->GetCurrentStyle()))
462 d->style->SetCurrentStyleToTrackballActor();
467 if(dynamic_cast<vtkInteractorStyleJoystickActor *> (d->style->GetCurrentStyle()))
468 d->style->SetCurrentStyleToTrackballActor();
470 if(dynamic_cast<vtkInteractorStyleJoystickCamera *> (d->style->GetCurrentStyle()))
471 d->style->SetCurrentStyleToTrackballCamera();
476 if(dynamic_cast<vtkInteractorStyleTrackballActor *> (d->style->GetCurrentStyle()))
477 d->style->SetCurrentStyleToJoystickActor();
479 if(dynamic_cast<vtkInteractorStyleTrackballCamera *> (d->style->GetCurrentStyle()))
480 d->style->SetCurrentStyleToJoystickCamera();
483 void axlVtkView::bounds(
float& xmin,
float& xmax,
float& ymin,
float& ymax,
float& zmin,
float& zmax)
485 double bounds[6]; d->renderer->ComputeVisiblePropBounds(bounds);
497 vtkCamera *camera = d->renderer->GetActiveCamera();
499 camera->GetViewUp(coordinates);
504 vtkCamera *camera = d->renderer->GetActiveCamera();
506 camera->GetPosition(coordinates);
511 vtkCamera *camera = d->renderer->GetActiveCamera();
513 camera->GetFocalPoint(coordinates);
518 vtkCamera *camera = d->renderer->GetActiveCamera();
520 camera->SetPosition(x, y, z);
522 d->renderer->ResetCameraClippingRange();
527 vtkRenderWindowInteractor *iren = d->widget->GetInteractor();
528 d->widget->GetInteractor()->SetInteractorStyle(d->style);
532 QList<axlAbstractActor *> result;
534 double currentTime = vtkTimerLog::GetCPUTime();
537 dtkWarn()<<
"Start time"<<currentTime;
538 QList<axlAbstractData *>::Iterator data;
540 for(data = dataSet.begin(); data != dataSet.end(); data++)
542 if (
axlPoint *point = dynamic_cast<axlPoint *>(*data)) {
552 d->renderer->AddActor(actor);
556 connect(actor, SIGNAL(updated()),
this, SLOT(
update()));
557 result.push_back(actor);
559 else if (
axlCone *cone = dynamic_cast<axlCone *>(*data)) {
569 d->renderer->AddActor(actor);
573 connect(actor, SIGNAL(updated()),
this, SLOT(
update()));
574 result.push_back(actor);
576 else if (
axlCylinder *cylinder = dynamic_cast<axlCylinder *>(*data)) {
586 d->renderer->AddActor(actor);
590 connect(actor, SIGNAL(updated()),
this, SLOT(
update()));
591 result.push_back(actor);
593 else if (
axlTorus *torus = dynamic_cast<axlTorus *>(*data)) {
603 d->renderer->AddActor(actor);
607 connect(actor, SIGNAL(updated()),
this, SLOT(
update()));
608 result.push_back(actor);
626 else if (
axlEllipsoid *ellipsoid = dynamic_cast<axlEllipsoid *>(*data)) {
636 d->renderer->AddActor(actor);
640 connect(actor, SIGNAL(updated()),
this, SLOT(
update()));
641 result.push_back(actor);
643 else if (
axlLine *line = dynamic_cast<axlLine *>(*data)) {
653 d->renderer->AddActor(actor);
657 connect(actor, SIGNAL(updated()),
this, SLOT(
update()));
658 result.push_back(actor);
660 else if (
axlPlane *plane = dynamic_cast<axlPlane *>(*data)) {
671 d->renderer->AddActor(actor);
675 connect(actor, SIGNAL(updated()),
this, SLOT(
update()));
676 result.push_back(actor);
678 else if (
axlSphere *sphere = dynamic_cast<axlSphere *>(*data)) {
687 d->renderer->AddActor(actor);
691 connect(actor, SIGNAL(updated()),
this, SLOT(
update()));
692 result.push_back(actor);
701 d->renderer->AddActor(actor);
705 connect(spline_curve, SIGNAL(samplingChanged()), actor, SLOT(onSamplingChanged()));
706 connect(actor, SIGNAL(updated()),
this, SLOT(
update()));
707 result.push_back(actor);;
715 d->renderer->AddActor(actor);
719 connect(spline_surface,SIGNAL(samplingChanged()),actor,SLOT(onSamplingChanged()));
721 result.push_back(actor);
728 actor->
setData(spline_surface);
729 d->renderer->AddActor(actor);
733 connect(spline_surface,SIGNAL(samplingChanged()),actor,SLOT(onSamplingChanged()));
734 connect(actor, SIGNAL(updated()),
this, SLOT(
update()));
739 result.push_back(actor);
747 d->renderer->AddActor(actor);
751 connect(spline_volume,SIGNAL(samplingChanged()),actor,SLOT(onSamplingChanged()));
752 connect(actor, SIGNAL(updated()),
this, SLOT(
update()));
756 result.push_back(actor);
759 else if (
axlShapeBSpline *spline_surface = dynamic_cast<axlShapeBSpline *>(*data)) {
764 actor->
setData(spline_surface);
765 d->renderer->AddActor(actor);
769 connect(spline_surface,SIGNAL(samplingChanged()),actor,SLOT(onSamplingChanged()));
774 result.push_back(actor);
776 else if(
axlDataDynamic *dynamicData = dynamic_cast<axlDataDynamic *>(*data)) {
783 d->renderer->AddActor(actor);
789 result.push_back(actor);
799 d->renderer->AddActor(actor);
803 connect(composite,SIGNAL(samplingChanged()),actor,SLOT(onSamplingChanged()));
805 result.push_back(actor);
815 d->renderer->AddActor(actor);
820 result.push_back(actor);
832 d->renderer->AddActor(actor);
836 connect(actor, SIGNAL(updated()),
this, SLOT(
update()));
837 result.push_back(actor);
843 d->renderer->ResetCamera();
847 dtkWarn()<<
"End Time "<<vtkTimerLog::GetCPUTime()<< vtkTimerLog::GetCPUTime() - currentTime;
857 for(
int i = 0; i < actorSet.size() ; i++)
860 if(
axlActorFieldSpatial *currentactor = dynamic_cast<axlActorFieldSpatial *>(actorSet.value(i))){
862 disconnect(currentactor, SIGNAL(
stateChanged(dtkAbstractData*,
int)),
this, SIGNAL(
stateChanged(dtkAbstractData*,
int)));
864 if(currentactor->scalarBar()){
865 d->renderer->RemoveActor2D(currentactor->scalarBar());
867 d->renderer->RemoveActor(currentactor);
868 currentactor->setInteractor(NULL);
869 currentactor->Delete();
875 disconnect(currentactor, SIGNAL(
stateChanged(dtkAbstractData*,
int)),
this, SIGNAL(
stateChanged(dtkAbstractData*,
int)));
877 if(currentactor->scalarBar()){
878 d->renderer->RemoveActor2D(currentactor->scalarBar());
880 d->renderer->RemoveActor(currentactor);
881 currentactor->setInteractor(NULL);
883 currentactor->Delete();
887 }
else if(
axlActorFieldDiscrete *currentactor = dynamic_cast<axlActorFieldDiscrete *>(actorSet.value(i))){
889 disconnect(currentactor, SIGNAL(
stateChanged(dtkAbstractData*,
int)),
this, SIGNAL(
stateChanged(dtkAbstractData*,
int)));
891 if(currentactor->scalarBar()){
892 d->renderer->RemoveActor2D(currentactor->scalarBar());
894 d->renderer->RemoveActor(currentactor);
895 currentactor->setInteractor(NULL);
897 currentactor->Delete();
906 d->renderer->ResetCamera();
915 for(
int i = 0; i < actorSet.size() ; i++)
921 if(
axlActor *currentactor = dynamic_cast<axlActor *>(actorSet.value(i)))
928 if(
axlActorBSpline *actorBSlpine = dynamic_cast<axlActorBSpline *>(currentactor))
929 disconnect(actorBSlpine->data(),SIGNAL(samplingChanged()),actorBSlpine,SLOT(onSamplingChanged()));
933 disconnect(currentactor, SIGNAL(
stateChanged(dtkAbstractData*,
int)),
this, SIGNAL(
stateChanged(dtkAbstractData*,
int)));
935 currentactor->onRemoved();
936 d->renderer->RemoveActor(currentactor);
937 currentactor->setInteractor(NULL);
939 currentactor->Delete();
948 else if(
axlActorComposite *currentactor = dynamic_cast<axlActorComposite *>(actorSet.value(i)))
952 disconnect(currentactor, SIGNAL(
stateChanged(dtkAbstractData*,
int)),
this, SIGNAL(
stateChanged(dtkAbstractData*,
int)));
953 currentactor->onRemoved();
957 d->renderer->RemoveActor(currentactor);
959 currentactor->Delete();
964 d->renderer->ResetCamera();
971 vtkRenderWindowInteractor *iren = d->widget->GetInteractor();
972 d->widget->GetInteractor()->SetInteractorStyle(d->style);
974 if (
axlPoint *point = dynamic_cast<axlPoint *>(data)) {
984 d->renderer->AddActor(actor);
988 connect(actor, SIGNAL(updated()),
this, SLOT(
update()));
989 d->renderer->ResetCamera();
995 else if (
axlCone *cone = dynamic_cast<axlCone *>(data)) {
1005 d->renderer->AddActor(actor);
1009 connect(actor, SIGNAL(updated()),
this, SLOT(
update()));
1013 else if (
axlCylinder *cylinder = dynamic_cast<axlCylinder *>(data)) {
1023 d->renderer->AddActor(actor);
1029 connect(actor, SIGNAL(updated()),
this, SLOT(
update()));
1033 else if (
axlTorus *torus = dynamic_cast<axlTorus *>(data)) {
1043 d->renderer->AddActor(actor);
1049 connect(actor, SIGNAL(updated()),
this, SLOT(
update()));
1070 else if (
axlEllipsoid *ellipsoid = dynamic_cast<axlEllipsoid *>(data)) {
1080 d->renderer->AddActor(actor);
1085 connect(actor, SIGNAL(updated()),
this, SLOT(
update()));
1090 else if (
axlLine *line = dynamic_cast<axlLine *>(data)) {
1100 d->renderer->AddActor(actor);
1105 connect(actor, SIGNAL(updated()),
this, SLOT(
update()));
1106 d->renderer->ResetCamera();
1110 else if (
axlPlane *plane = dynamic_cast<axlPlane *>(data)) {
1121 d->renderer->AddActor(actor);
1126 connect(actor, SIGNAL(updated()),
this, SLOT(
update()));
1127 d->renderer->ResetCamera();
1147 else if (
axlSphere *sphere = dynamic_cast<axlSphere *>(data)) {
1157 d->renderer->AddActor(actor);
1162 connect(actor, SIGNAL(updated()),
this, SLOT(
update()));
1163 d->renderer->ResetCamera();
1175 d->renderer->AddActor(actor);
1180 connect(spline_curve, SIGNAL(samplingChanged()), actor, SLOT(onSamplingChanged()));
1181 connect(actor, SIGNAL(updated()),
this, SLOT(
update()));
1182 d->renderer->ResetCamera();
1192 actor->
setData(spline_surface);
1194 d->renderer->AddActor(actor);
1199 connect(spline_surface,SIGNAL(samplingChanged()),actor,SLOT(onSamplingChanged()));
1200 connect(spline_surface, SIGNAL(updated()),
this, SLOT(
update()));
1201 connect(actor, SIGNAL(updated()),
this, SLOT(
update()));
1204 d->renderer->ResetCamera();
1213 actor->
setData(spline_volume);
1215 d->renderer->AddActor(actor);
1220 connect(spline_volume,SIGNAL(samplingChanged()),actor,SLOT(onSamplingChanged()));
1221 connect(actor, SIGNAL(updated()),
this, SLOT(
update()));
1225 d->renderer->ResetCamera();
1229 else if(
axlShapeBSpline *spline_surface = dynamic_cast<axlShapeBSpline *>(data)) {
1234 actor->
setData(spline_surface);
1236 d->renderer->AddActor(actor);
1241 connect(spline_surface,SIGNAL(samplingChanged()),actor,SLOT(onSamplingChanged()));
1242 connect(spline_surface, SIGNAL(updated()),
this, SLOT(
update()));
1246 d->renderer->ResetCamera();
1251 else if (
axlDataDynamic *line = dynamic_cast<axlDataDynamic *>(data)) {
1262 d->renderer->AddActor(actor);
1268 d->renderer->ResetCamera();
1282 d->renderer->AddActor(actor);
1289 d->renderer->ResetCamera();
1301 d->renderer->AddActor(actor);
1313 d->renderer->AddActor(actor);
1318 connect(actor, SIGNAL(updated()),
this, SLOT(
update()));
1321 d->renderer->ResetCamera();
1332 d->renderer->SetGradientBackground(gradient);
1338 d->renderer->GetActiveCamera()->SetParallelScale(parallelScale);
1342 return d->renderer->GetActiveCamera()->GetParallelScale();
1346 return d->renderer->GetGradientBackground();
1350 return d->renderer->GetActiveCamera()->GetPosition();
1354 return d->axesActor->GetVisibility();
1358 return d->renderer->GetActiveCamera()->GetParallelProjection();
1362 return d->renderer->GetActiveCamera()->GetFocalPoint();
1366 d->renderer->GetActiveCamera()->SetFocalPoint(x, y, z);
1370 return d->renderer->GetActiveCamera()->GetViewUp();
1374 d->renderer->GetActiveCamera()->SetViewUp(x, y, z);
1378 return d->renderer->GetActiveCamera()->GetViewAngle();
1382 d->renderer->GetActiveCamera()->SetViewAngle(angle);
1386 return d->renderer->GetBackground();
1392 d->renderer->SetBackground (red, green, blue);
1440 if(d->lightWidget != NULL)
1442 d->lightWidget->SetEnabled(0);
1443 d->lightWidget->Delete();
1444 d->lightWidget = NULL;
1446 d->renderer->RemoveAllLights();
1447 d->lightKit = vtkSmartPointer<vtkLightKit>::New();
1448 d->lightKit->AddLightsToRenderer(d->renderer);
1457 d->renderer->RemoveAllLights();
1458 d->firstLight = vtkSmartPointer<vtkLight>::New();
1459 d->firstLight->SetAmbientColor(1.0, 1.0, 1.0);
1460 d->firstLight->SetDiffuseColor(1.0, 1.0, 1.0);
1461 d->firstLight->SetSpecularColor(1.0, 1.0, 1.0);
1462 d->firstLight->SetExponent(50);
1463 d->firstLight->SetIntensity(1);
1465 d->firstLight->SetPosition(0.0, 0.0, 0.0);
1467 double bounds[6]; d->renderer->ComputeVisiblePropBounds(bounds);
1469 center[0] = (bounds[1]+bounds[0])/2;
1470 center[1] = (bounds[3]+bounds[2])/2;
1471 center[2] = (bounds[5]+bounds[4])/2;
1472 d->firstLight->SetFocalPoint(center);
1473 d->firstLight->SetLightTypeToSceneLight();
1474 d->firstLight->SetPositional(1);
1475 d->renderer->AddLight(d->firstLight);
1476 if(d->lightWidget == NULL)
1479 d->lightWidget->setView(
this);
1480 d->lightWidget->SetInteractor(d->widget->GetInteractor());
1481 d->lightWidget->initializePoints();
1483 d->lightWidget->ptsActors()->InitTraversal();
1485 for(vtkIdType i = 0; i < d->lightWidget->ptsActors()->GetNumberOfItems(); i++)
1487 d->renderer->AddActor(d->lightWidget->ptsActors()->GetNextActor());
1490 d->lightWidget->SetEnabled(1);
1548 void axlVtkView::setLight(
int i,
bool hide,
double *position,
double *ambiant,
double *diffuse,
double *specular,
int exponent)
1552 d->firstLight->SetAmbientColor(ambiant);
1553 d->firstLight->SetDiffuseColor(diffuse);
1554 d->firstLight->SetSpecularColor(specular);
1555 d->firstLight->SetExponent(exponent);
1556 d->firstLight->SetPosition(position);
1558 d->firstLight->Modified();
1560 d->lightWidget->update();
1562 d->lightWidget->SetEnabled(!hide);
1570 d->lastCameraIsDefault =
true;
1572 vtkCamera *camera = d->renderer->GetActiveCamera();
1573 camera->SetParallelProjection(
false);
1574 camera->SetPosition(d->camera_center);
1575 camera->SetFocalPoint(d->camera_focal);
1576 camera->SetViewUp(d->camera_view_up);
1578 d->renderer->ResetCamera();
1586 vtkCamera *camera = d->renderer->GetActiveCamera();
1587 camera->SetParallelProjection(
true);
1589 if(d->lastCameraIsDefault)
1591 camera->GetPosition(d->camera_center);
1592 camera->GetFocalPoint(d->camera_focal);
1593 camera->GetViewUp(d->camera_view_up);
1594 d->lastCameraIsDefault =
false;
1597 double bounds[6]; d->renderer->ComputeVisiblePropBounds(bounds);
1599 double side = qAbs(bounds[1]-bounds[0]);
1602 center[0] = (bounds[1]+bounds[0])/2;
1603 center[1] = (bounds[3]+bounds[2])/2;
1604 center[2] = (bounds[5]+bounds[4])/2;
1606 camera->SetPosition(center[0]+side, center[1], center[2]);
1607 camera->SetFocalPoint(center[0], center[1], center[2]);
1608 camera->SetViewUp(0, 1, 0);
1610 d->renderer->ResetCamera();
1617 vtkCamera *camera = d->renderer->GetActiveCamera();
1618 camera->SetParallelProjection(
true);
1620 if(d->lastCameraIsDefault)
1622 camera->GetPosition(d->camera_center);
1623 camera->GetFocalPoint(d->camera_focal);
1624 camera->GetViewUp(d->camera_view_up);
1625 d->lastCameraIsDefault =
false;
1628 double bounds[6]; d->renderer->ComputeVisiblePropBounds(bounds);
1630 double side = qAbs(bounds[1]-bounds[0]);
1633 center[0] = (bounds[1]+bounds[0])/2;
1634 center[1] = (bounds[3]+bounds[2])/2;
1635 center[2] = (bounds[5]+bounds[4])/2;
1637 camera->SetPosition(center[0]-side, center[1], center[2]);
1638 camera->SetFocalPoint(center[0], center[1], center[2]);
1639 camera->SetViewUp(0, 1, 0);
1641 d->renderer->ResetCamera();
1648 vtkCamera *camera = d->renderer->GetActiveCamera();
1649 camera->SetParallelProjection(
true);
1651 if(d->lastCameraIsDefault)
1653 camera->GetPosition(d->camera_center);
1654 camera->GetFocalPoint(d->camera_focal);
1655 camera->GetViewUp(d->camera_view_up);
1656 d->lastCameraIsDefault =
false;
1659 double bounds[6]; d->renderer->ComputeVisiblePropBounds(bounds);
1661 double side = qAbs(bounds[3]-bounds[2]);
1664 center[0] = (bounds[1]+bounds[0])/2;
1665 center[1] = (bounds[3]+bounds[2])/2;
1666 center[2] = (bounds[5]+bounds[4])/2;
1668 camera->SetPosition(center[0], center[1]+side, center[2]);
1669 camera->SetFocalPoint(center[0], center[1], center[2]);
1670 camera->SetViewUp(0, 0, 1);
1672 d->renderer->ResetCamera();
1679 vtkCamera *camera = d->renderer->GetActiveCamera();
1680 camera->SetParallelProjection(
true);
1682 if(d->lastCameraIsDefault)
1684 camera->GetPosition(d->camera_center);
1685 camera->GetFocalPoint(d->camera_focal);
1686 camera->GetViewUp(d->camera_view_up);
1687 d->lastCameraIsDefault =
false;
1690 double bounds[6]; d->renderer->ComputeVisiblePropBounds(bounds);
1692 double side = qAbs(bounds[3]-bounds[2]);
1695 center[0] = (bounds[1]+bounds[0])/2;
1696 center[1] = (bounds[3]+bounds[2])/2;
1697 center[2] = (bounds[5]+bounds[4])/2;
1699 camera->SetPosition(center[0], center[1]-side, center[2]);
1700 camera->SetFocalPoint(center[0], center[1], center[2]);
1701 camera->SetViewUp(0, 0, 1);
1703 d->renderer->ResetCamera();
1710 vtkCamera *camera = d->renderer->GetActiveCamera();
1711 camera->SetParallelProjection(
true);
1713 if(d->lastCameraIsDefault)
1715 camera->GetPosition(d->camera_center);
1716 camera->GetFocalPoint(d->camera_focal);
1717 camera->GetViewUp(d->camera_view_up);
1718 d->lastCameraIsDefault =
false;
1721 double bounds[6]; d->renderer->ComputeVisiblePropBounds(bounds);
1723 double side = qAbs(bounds[5]-bounds[4]);
1726 center[0] = (bounds[1]+bounds[0])/2;
1727 center[1] = (bounds[3]+bounds[2])/2;
1728 center[2] = (bounds[5]+bounds[4])/2;
1730 camera->SetPosition(center[0], center[1], center[2]+side);
1731 camera->SetFocalPoint(center[0], center[1], center[2]);
1732 camera->SetViewUp(0, 1, 0);
1734 d->renderer->ResetCamera();
1741 vtkCamera *camera = d->renderer->GetActiveCamera();
1742 camera->SetParallelProjection(
true);
1744 if(d->lastCameraIsDefault)
1746 camera->GetPosition(d->camera_center);
1747 camera->GetFocalPoint(d->camera_focal);
1748 camera->GetViewUp(d->camera_view_up);
1749 d->lastCameraIsDefault =
false;
1752 double bounds[6]; d->renderer->ComputeVisiblePropBounds(bounds);
1754 double side = qAbs(bounds[5]-bounds[4]);
1757 center[0] = (bounds[1]+bounds[0])/2;
1758 center[1] = (bounds[3]+bounds[2])/2;
1759 center[2] = (bounds[5]+bounds[4])/2;
1761 camera->SetPosition(center[0], center[1], center[2]-side);
1762 camera->SetFocalPoint(center[0], center[1], center[2]);
1763 camera->SetViewUp(0, 1, 0);
1765 d->renderer->ResetCamera();
1778 vtkSmartPointer<vtkPolyData> polyDataX;
1781 vtkSmartPointer<vtkPolyDataMapper> mapperX;
1789 d->planeSourceX = vtkSmartPointer<vtkPlaneSource>::New();
1791 polyDataX = d->planeSourceX->GetOutput();
1795 mapperX = vtkSmartPointer<vtkPolyDataMapper>::New();
1796 d->actorX = vtkSmartPointer<vtkActor>::New();
1798 double bounds[6]; d->renderer->ComputeVisiblePropBounds(bounds);
1800 d->planeSourceX->SetPoint1(bounds[1], bounds[2], 0);
1801 d->planeSourceX->SetPoint2(bounds[0], bounds[3], 0);
1802 d->planeSourceX->SetOrigin(bounds[0], bounds[2], 0);
1803 d->planeSourceX->SetResolution(1, 1);
1804 d->planeSourceX->Update();
1806 polyDataX->Register(NULL);
1807 polyDataX->GetPointData()->SetNormals(NULL);
1822 #if (VTK_MAJOR_VERSION <= 5)
1823 mapperX->SetInput(polyDataX);
1825 mapperX->SetInputData(polyDataX);
1827 d->actorX->SetMapper(mapperX);
1828 d->actorX->SetUseBounds(
false);
1832 d->renderer->AddActor(d->actorX);
1839 vtkSmartPointer<vtkPolyData> polyDataY;
1842 vtkSmartPointer<vtkPolyDataMapper> mapperY;
1850 d->planeSourceY = vtkSmartPointer<vtkPlaneSource>::New();
1851 polyDataY = d->planeSourceY->GetOutput();
1855 mapperY = vtkSmartPointer<vtkPolyDataMapper>::New();
1856 d->actorY = vtkSmartPointer<vtkActor>::New();
1858 double bounds[6]; d->renderer->ComputeVisiblePropBounds(bounds);
1860 d->planeSourceY->SetPoint1(0, bounds[2], bounds[5]);
1861 d->planeSourceY->SetPoint2(0, bounds[3], bounds[4]);
1862 d->planeSourceY->SetOrigin(0, bounds[2], bounds[4]);
1863 d->planeSourceY->SetResolution(1, 1);
1864 d->planeSourceY->Update();
1866 polyDataY->Register(NULL);
1867 polyDataY->GetPointData()->SetNormals(NULL);
1882 #if (VTK_MAJOR_VERSION <= 5)
1883 mapperY->SetInput(polyDataY);
1885 mapperY->SetInputData(polyDataY);
1887 d->actorY->SetMapper(mapperY);
1888 d->actorY->SetUseBounds(
false);
1892 d->renderer->AddActor(d->actorY);
1899 vtkSmartPointer<vtkPolyData> polyDataZ;
1902 vtkSmartPointer<vtkPolyDataMapper> mapperZ;
1910 d->planeSourceZ = vtkSmartPointer<vtkPlaneSource>::New();
1911 polyDataZ = d->planeSourceZ->GetOutput();
1915 mapperZ = vtkSmartPointer<vtkPolyDataMapper>::New();
1916 d->actorZ = vtkSmartPointer<vtkActor>::New();
1918 double bounds[6]; d->renderer->ComputeVisiblePropBounds(bounds);
1920 d->planeSourceZ->SetPoint1(bounds[1], 0, bounds[4]);
1921 d->planeSourceZ->SetPoint2(bounds[0], 0, bounds[5]);
1922 d->planeSourceZ->SetOrigin(bounds[0], 0, bounds[4]);
1923 d->planeSourceZ->SetResolution(1, 1);
1924 d->planeSourceZ->Update();
1926 polyDataZ->Register(NULL);
1927 polyDataZ->GetPointData()->SetNormals(NULL);
1942 #if (VTK_MAJOR_VERSION <= 5)
1943 mapperZ->SetInput(polyDataZ);
1945 mapperZ->SetInputData(polyDataZ);
1947 d->actorZ->SetMapper(mapperZ);
1948 d->actorZ->SetUseBounds(
false);
1952 d->renderer->AddActor(d->actorZ);
1961 double bounds[6]; d->renderer->ComputeVisiblePropBounds(bounds);
1964 d->planeSourceX->SetPoint1(bounds[1], bounds[2], 0);
1965 d->planeSourceX->SetPoint2(bounds[0], bounds[3], 0);
1966 d->planeSourceX->SetOrigin(bounds[0], bounds[2], 0);
1967 d->planeSourceX->Update();
1968 d->actorX->SetVisibility(
true);
1971 d->actorX->SetVisibility(
false);
1979 double bounds[6]; d->renderer->ComputeVisiblePropBounds(bounds);
1981 d->planeSourceY->SetPoint1(0, bounds[2], bounds[5]);
1982 d->planeSourceY->SetPoint2(0, bounds[3], bounds[4]);
1983 d->planeSourceY->SetOrigin(0, bounds[2], bounds[4]);
1984 d->planeSourceY->Update();
1985 d->actorY->SetVisibility(
true);
1988 d->actorY->SetVisibility(
false);
1995 double bounds[6]; d->renderer->ComputeVisiblePropBounds(bounds);
1997 d->planeSourceZ->SetPoint1(bounds[1], 0, bounds[4]);
1998 d->planeSourceZ->SetPoint2(bounds[0], 0, bounds[5]);
1999 d->planeSourceZ->SetOrigin(bounds[0], 0, bounds[4]);
2000 d->planeSourceZ->Update();
2001 d->actorZ->SetVisibility(
true);
2004 d->actorZ->SetVisibility(
false);
2015 d->planeSourceX->SetResolution(resolution, resolution);
2018 d->planeSourceY->SetResolution(resolution, resolution);
2021 d->planeSourceZ->SetResolution(resolution, resolution);
2030 d->axesActor->SetVisibility(show);
2037 vtkCamera *camera = d->renderer->GetActiveCamera();
2039 camera->SetParallelProjection(parallel);
2047 d->widget->update();
2048 d->widget->GetRenderWindow()->Render();
2074 if(dynamic_cast<axlAbstractFieldSpatial *>(field)){
2078 fieldActor->
setData(spatialField);
2081 connect(spatialField, SIGNAL(updated()), fieldActor, SLOT(
update()));
2082 connect(axlData, SIGNAL(modifiedField()),fieldActor, SLOT(
update()));
2083 d->renderer->AddActor(fieldActor);
2086 d->renderer->AddActor2D(fieldActor->
scalarBar());
2096 }
else if(dynamic_cast<axlAbstractFieldParametric *>(field)){
2100 fieldActor->
setData(parametricField);
2103 connect(parametricField, SIGNAL(updated()), fieldActor, SLOT(
update()));
2104 connect(axlData, SIGNAL(modifiedField()),fieldActor, SLOT(
update()));
2105 d->renderer->AddActor(fieldActor);
2108 d->renderer->AddActor2D(fieldActor->
scalarBar());
2125 connect(field, SIGNAL(updated()), fieldActor, SLOT(
update()));
2126 connect(fieldActor, SIGNAL(updated()),
this, SLOT(
update()));
2127 connect(axlData, SIGNAL(modifiedField()),fieldActor, SLOT(
update()));
2128 d->renderer->AddActor(fieldActor);
2131 d->renderer->AddActor2D(fieldActor->
scalarBar());
2160 if(dynamic_cast<axlAbstractFieldSpatial *>(field)){
2164 fieldActor->
setData(spatialField);
2167 connect(spatialField, SIGNAL(updated()), fieldActor, SLOT(
update()));
2168 connect(data, SIGNAL(modifiedField()),fieldActor, SLOT(
update()));
2169 d->renderer->AddActor(fieldActor);
2172 d->renderer->AddActor2D(fieldActor->
scalarBar());
2175 }
else if(dynamic_cast<axlAbstractFieldParametric *>(field)){
2179 fieldActor->
setData(parametricField);
2182 connect(parametricField, SIGNAL(updated()), fieldActor, SLOT(
update()));
2183 connect(data, SIGNAL(modifiedField()),fieldActor, SLOT(
update()));
2184 d->renderer->AddActor(fieldActor);
2187 d->renderer->AddActor2D(fieldActor->
scalarBar());
2196 connect(field, SIGNAL(updated()), fieldActor, SLOT(
update()));
2197 connect(data, SIGNAL(modifiedField()),fieldActor, SLOT(
update()));
2198 d->renderer->AddActor(fieldActor);
2201 d->renderer->AddActor2D(fieldActor->
scalarBar());
2219 if(dynamic_cast<axlAbstractFieldSpatial *>(field)){
2220 qDebug() << Q_FUNC_INFO << field->
identifier();
2224 fieldActor->
setData(spatialField);
2227 connect(spatialField, SIGNAL(updated()), fieldActor, SLOT(
update()));
2228 connect(data, SIGNAL(modifiedField()),fieldActor, SLOT(
update()));
2229 d->renderer->AddActor(fieldActor);
2232 d->renderer->AddActor2D(fieldActor->
scalarBar());
2235 }
else if(dynamic_cast<axlAbstractFieldParametric *>(field)){
2239 fieldActor->
setData(parametricField);
2242 connect(parametricField, SIGNAL(updated()), fieldActor, SLOT(
update()));
2243 connect(data, SIGNAL(modifiedField()),fieldActor, SLOT(
update()));
2244 d->renderer->AddActor(fieldActor);
2247 d->renderer->AddActor2D(fieldActor->
scalarBar());
2256 connect(field, SIGNAL(updated()), fieldActor, SLOT(
update()));
2257 connect(data, SIGNAL(modifiedField()),fieldActor, SLOT(
update()));
2258 d->renderer->AddActor(fieldActor);
2261 d->renderer->AddActor2D(fieldActor->
scalarBar());
2269 qDebug()<<
" data is not an axlAbstractData *";
void onShowAxis(bool show)
static axlActorFieldParametric * New(void)
static axlActorSphere * New(void)
Class axlPoint defines 3D points.
void cameraUp(double *coordinates)
Class axlAbstractFieldParametric defines an API for parametric field.
void setParallelCamera(bool parallel)
virtual void setData(dtkAbstractData *line1)
QList< axlAbstractActor * > insertSet(QList< axlAbstractData * > dataSet)
void setCameraViewPositiveZ(void)
dtkAbstractView * createVtkView(void)
Class axlLine defines 3D lines.
static axlActorCylinder * New(void)
void setCameraViewDefaut(void)
void cameraFocalPoint(double *coordinates)
virtual void setDisplay(bool display)
void setCameraViewNegativeX(void)
void setLight(int i, bool hide, double *position, double *ambiant, double *diffuse, double *specular, int exponent)
bool getBackgroundGradient(void)
void setCameraFocalPoint(double x, double y, double z)
virtual void setData(dtkAbstractData *spline_Surface1)
vtkSmartPointer< vtkAxesActor > observerAxesActor
double * getCameraFocalPoint(void)
void setInteractor(void *interactor)
virtual void setInteractor(void *interactor)
double * getWorldCameraPosition(void)
double * getBackgroundColor(void)
void setActorField(axlAbstractActor *actor)
void setQVTKWidget(QVTKOpenGLWidget *widget)
static vtkViewObserver * New(void)
Class axlCylinder defines 3D cylinders.
static axlActorCone * New(void)
bool getAxesVisibility(void)
Class axlPlane defines 3D planes.
static axlActorVolumeDiscrete * New(void)
virtual void setData(dtkAbstractData *spline_curve1)
virtual ~axlVtkView(void)
static axlActorVolumeBSpline * New(void)
virtual void setData(dtkAbstractData *point1)
void setCameraViewPositiveX(void)
virtual void setData(dtkAbstractData *spline_Volume1)
static axlActorShapeBSpline * New(void)
virtual void setData(dtkAbstractData *data1)
virtual QString description(void) const
void setGrid(bool isGridX, bool isGridY, bool isGridZ)
void setQVTKWidget(QVTKOpenGLWidget *widget)
virtual void removeField(dtkAbstractData *data)
virtual QString identifier(void) const
void setActorField(axlAbstractActor *actor)
void setWorldCamera(void)
void setQVTKWidget(QVTKOpenGLWidget *widget)
static axlActorFieldDiscrete * New(void)
void setCameraPosition(double x, double y, double z)
static axlActorPlane * New(void)
void setData(dtkAbstractData *volume)
void setInteractor(void *interactor)
void setView(axlAbstractView *view)
virtual void setInteractor(void *interactor)
virtual void removeData(dtkAbstractData *data)
static axlActorCurveBSpline * New(void)
void setView(axlAbstractView *view)
void onUpdateActorField(QList< axlAbstractData * > axlDataSet, QString fieldName)
virtual void setData(dtkAbstractData *data1)
void cameraPosition(double *coordinates)
static axlActorLine * New(void)
Class axlDataDynamic defines a dynamic object.
virtual void Execute(vtkObject *caller, unsigned long event, void *)
void updateFieldActor(dtkAbstractData *data)
Use view as input to update fields actors on a data.
void setDisplay(bool display)
void setDisplay(bool display)
vtkScalarBarActor * scalarBar(void)
static axlActorSurfaceBSpline * New(void)
void setData(dtkAbstractData *data)
vtkSmartPointer< vtkCellPicker > observerViewerPicker
void setQVTKWidget(QVTKOpenGLWidget *widget)
Class axlSphere defines 3D spheres.
vtkSmartPointer< vtkRenderer > observerRenderer
virtual void setData(dtkAbstractData *field)
virtual void setData(dtkAbstractData *cylinder1)
vtkScalarBarActor * scalarBar(void)
void setObjectCamera(void)
void setActorField(axlAbstractActor *actor)
virtual axlAbstractActor * actor(dtkAbstractData *data)
Class axlAbstractFieldSpatial defines an API for spatial field.
virtual void setData(dtkAbstractData *cone1)
void setJoystickInteractor(void)
virtual void setData(dtkAbstractData *torus1)
void setRenderer(vtkRenderer *renderer)
vtkRenderWindowInteractor * observerInteractor
void onBackgroundGradientChange(bool gradient)
void setQVTKWidget(QVTKOpenGLWidget *widget)
void setDisplay(bool display)
virtual void setData(dtkAbstractData *sphere1)
void setCameraViewPositiveY(void)
Class axlAbstractField defines an API for arrays of numeric data.
double * getCameraUp(void)
virtual void setData(dtkAbstractData *spline_shape1)
void setRenderer(vtkRenderer *renderer)
void setQVTKWidget(QVTKOpenGLWidget *widget)
virtual void setData(dtkAbstractData *field)
void setQVTKWidget(QVTKOpenGLWidget *widget)
static axlActorComposite * New(void)
void setRenderer(vtkRenderer *renderer)
void activeDefaultLigh(bool useDefaultLight)
void bounds(float &xmin, float &xmax, float &ymin, float &ymax, float &zmin, float &zmax)
virtual axlAbstractActor * insert(axlAbstractData *data)
void removeSetFields(QList< axlAbstractActorField * > actorSet)
virtual void setData(dtkAbstractData *plane1)
void setBackgroundColor(double red, double green, double blue)
virtual void setData(dtkAbstractData *ellipsoid1)
void setDisplay(bool display)
void setParallelScale(double parallelScale)
double getCameraViewAngle(void)
bool getParallelProjection(void)
Class axlShapeBSpline defines a set of boundary curves (Edges) and bspline surface patches (Face)...
Class axlCone defines 3D cones.
void setCameraUp(double x, double y, double z)
static axlActorMesh * New(void)
void setQVTKWidget(QVTKOpenGLWidget *widget)
void setCameraViewNegativeZ(void)
void onGridResolutionChanged(int resolution)
static axlActorSurfaceTrimmed * New(void)
void setCameraViewNegativeY(void)
QList< axlAbstractField * > fields(void)
vtkScalarBarActor * scalarBar(void)
void setSurface(axlAbstractSurfaceTrimmed *Surface)
void setInteractor(void *interactor)
QVTKOpenGLWidget * widget
void setTrackballInteractor(void)
static dtkAbstractViewFactory * viewFactSingleton
double getParallelScale(void)
axlAbstractActor * insert(axlAbstractData *data)
virtual void setData(dtkAbstractData *field)
void stateChanged(dtkAbstractData *data, int mode)
static axlActorPoint * New(void)
Class axlEllipsoid defines 3D ellipsoids.
static bool registered(void)
Class axlAbstractData defines an API for all type of axel data.
void removeSet(QList< axlAbstractActor * > actorSet)
static axlActorTorus * New(void)
void setQVTKWidget(QVTKOpenGLWidget *widget)
static axlActorFieldSpatial * New(void)
double angle(axlPoint vCompute, axlPoint vRef, axlPoint normal)
static axlActorDataDynamic * New(void)
void setCameraViewAngle(double angle)