]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To use more convinent VTK interactor style
authorapo <apo@opencascade.com>
Fri, 30 Nov 2007 14:54:13 +0000 (14:54 +0000)
committerapo <apo@opencascade.com>
Fri, 30 Nov 2007 14:54:13 +0000 (14:54 +0000)
src/PIPELINE/VISUPipeLine.cxx

index 100ad4b0baba789f58b5c13244c80fe17ba7b46e..6cfa78f4a65f8fc6d193bfe55ca52a29d03ef320 100644 (file)
 #include "VISU_Convertor.hxx"
 #include "VISU_ConvertorUtils.hxx"
 
-typedef VISU_ScalarMapOnDeformedShapePL TPresent;
+typedef VISU_ScalarMapPL TPresent;
 
 #include <vtkUnstructuredGrid.h>
 #include <vtkDataSetMapper.h>
 
+#include <vtkInteractorStyleTrackballCamera.h>
 #include <vtkRenderWindowInteractor.h>
 #include <vtkRenderWindow.h>
 #include <vtkImageData.h>
@@ -165,12 +166,20 @@ main(int argc, char** argv)
 {
   try{
     if(argc > 1){
-      vtkRenderWindow *renWin = vtkRenderWindow::New();
-      vtkRenderer *ren = vtkRenderer::New();
-      renWin->AddRenderer(ren);
-      ren->GetActiveCamera()->ParallelProjectionOn();
-      vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
-      iren->SetRenderWindow(renWin);
+      vtkRenderWindow *aWindow = vtkRenderWindow::New();
+      vtkRenderer *aRenderer = vtkRenderer::New();
+
+      aWindow->AddRenderer(aRenderer);
+      aRenderer->GetActiveCamera()->ParallelProjectionOn();
+
+      vtkRenderWindowInteractor *anInteractor = vtkRenderWindowInteractor::New();
+      anInteractor->SetRenderWindow(aWindow);
+      aWindow->Delete();
+
+      vtkInteractorStyle* aStyle = vtkInteractorStyleTrackballCamera::New();
+      anInteractor->SetInteractorStyle(aStyle);
+      aStyle->Delete();
+
       VISU_Convertor* aConvertor = CreateConvertor(argv[1]);
       aConvertor->BuildEntities();
       aConvertor->BuildGroups();
@@ -196,12 +205,12 @@ main(int argc, char** argv)
        vtkActor* aActor = vtkActor::New();
        aActor->SetMapper(aPresent->GetMapper());
        aActor->GetProperty()->SetRepresentation(VTK_WIREFRAME);
-       //ren->ResetCameraClippingRange();
+       //aRenderer->ResetCameraClippingRange();
 
-       ren->AddActor(aActor);
+       aRenderer->AddActor(aActor);
 
-       renWin->Render();
-       iren->Start();
+       aWindow->Render();
+       anInteractor->Start();
        return 0;
       }
       //Import fields
@@ -223,13 +232,13 @@ main(int argc, char** argv)
 
          VISU_ColoredPL* aPresent = NULL;
          if(anEntity != VISU::NODE_ENTITY){
+           continue;
            aPresent = CreateColoredPL<TPresent>(aConvertor,
                                                 aMeshName,
                                                 anEntity,
                                                 aFieldName,
                                                 aTimeStamp);
          }else{
-           continue;
            aPresent = CreateColoredPL<TPresent>(aConvertor,
                                                 aMeshName,
                                                 anEntity,
@@ -243,13 +252,13 @@ main(int argc, char** argv)
          VISU_ScalarBarActor * aScalarBar = VISU_ScalarBarActor::New();
          aScalarBar->SetLookupTable(aPresent->GetBarTable());
 
-         ren->AddActor(anActor);
-         ren->AddActor2D(aScalarBar);
+         aRenderer->AddActor(anActor);
+         aRenderer->AddActor2D(aScalarBar);
 
-         renWin->Render();
-         ren->ResetCamera();
+         aWindow->Render();
+         aRenderer->ResetCamera();
 
-         iren->Start();
+         anInteractor->Start();
          return 0;
        }
       }