]> Creatis software - cpPlugins.git/commitdiff
contour example updated
authorjose guzman <jose@gmail.com>
Tue, 6 Oct 2015 08:45:08 +0000 (10:45 +0200)
committerjose guzman <jose@gmail.com>
Tue, 6 Oct 2015 08:45:08 +0000 (10:45 +0200)
appli/examples/example_ContourWidget.cxx

index a523ce6c1c654839e0ef38e183884995e23c179b..c3b405cde3c3d59440d9bd94831d66771f1a5746 100644 (file)
@@ -48,45 +48,45 @@ public:
                vtkRenderWindowInteractor *rwi = this->Interactor;
                std::string key = rwi->GetKeySym();
 
+               int ctrlKeyInd = rwi->GetControlKey();
+
+               int altKeyInd = rwi->GetAltKey();
+
+               int shiftKeyInd = rwi->GetShiftKey();
+
                // Output the key that was pressed
                std::cout << "Pressed " << key << std::endl;
 
                // Handle an arrow key
                if (key == "Up")
-               {
-                       contourWidget =
-                               vtkSmartPointer<vtkContourWidget>::New();
-                       contourWidget->SetInteractor(interactor);
-                       contourWidget->SetRepresentation(contourRep);
-                       contourWidget->On();
-
-                       std::cout << "add and move points" << std::endl;
-                       contourWidget->GetEventTranslator()->RemoveTranslation(
-                               vtkCommand::LeftButtonPressEvent);
-                       contourWidget->GetEventTranslator()->SetTranslation(
-                               vtkCommand::LeftButtonPressEvent,
-                               vtkWidgetEvent::Translate);
-
-                       //contourWidget->Initialize(pd);
-                       //contourWidget->Render();
+               {       
 
-                       //interactor->Initialize();
-                       //interactor->Start();
-                       //Interactor->Disable();
+                       std::cout << "UP" << std::endl;
+                       
                }
 
                // Handle a "normal" key
                if (key == "Down")
                {
-                       std::cout << "Remove points" << std::endl;
-                       contourWidget->GetEventTranslator()->RemoveTranslation(
-                               vtkCommand::LeftButtonPressEvent);
-                       contourWidget->GetEventTranslator()->SetTranslation(
-                               vtkCommand::LeftButtonPressEvent,
-                               vtkWidgetEvent::Delete);
+                       std::cout << "DOWN" << std::endl;               
                        
                }
 
+               if (ctrlKeyInd != 0)
+               {
+                       if (key == "z" || key == "Z")
+                       {
+                               std::cout << "undo" << std::endl;
+
+                       }
+
+                       if (key == "y" || key == "Y")
+                       {
+                               std::cout << "redo" << std::endl;
+
+                       }
+               }
+
                // Forward events
                vtkInteractorStyleTrackballCamera::OnKeyPress();
        }
@@ -195,9 +195,9 @@ int main(int argc, char *argv[])
                vtkSmartPointer<vtkActor>::New();
        planeActor->SetMapper(mapper);
 
-       /*vtkSmartPointer<KeyPressInteractorStyle> style =
+       vtkSmartPointer<KeyPressInteractorStyle> style =
                vtkSmartPointer<KeyPressInteractorStyle>::New();
-       interactor->SetInteractorStyle(style);*/
+       interactor->SetInteractorStyle(style);
 
        // create the contour stuff
        vtkSmartPointer<vtkOrientedGlyphContourRepresentation> contourRep =