X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=appli%2Fexamples%2Fexample_ContourWidget.cxx;h=c3b405cde3c3d59440d9bd94831d66771f1a5746;hb=2553991938011b002691361f0ed4ae95a552a686;hp=a523ce6c1c654839e0ef38e183884995e23c179b;hpb=8919b8f97d766e10514bdd765d597e08693cc7a2;p=cpPlugins.git diff --git a/appli/examples/example_ContourWidget.cxx b/appli/examples/example_ContourWidget.cxx index a523ce6..c3b405c 100644 --- a/appli/examples/example_ContourWidget.cxx +++ b/appli/examples/example_ContourWidget.cxx @@ -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::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::New(); planeActor->SetMapper(mapper); - /*vtkSmartPointer style = + vtkSmartPointer style = vtkSmartPointer::New(); - interactor->SetInteractorStyle(style);*/ + interactor->SetInteractorStyle(style); // create the contour stuff vtkSmartPointer contourRep =