From: jose guzman Date: Tue, 6 Oct 2015 08:45:08 +0000 (+0200) Subject: contour example updated X-Git-Tag: v0.1~346 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=3484fd70d5911c42f100b0c0ce0289c69f942c55;p=cpPlugins.git contour example updated --- 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 =