From: pkv Date: Wed, 23 Nov 2005 09:47:15 +0000 (+0000) Subject: Provides "S"- key for picking in both interactor styles X-Git-Tag: BR-D5-38-2003_D2005-24-11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=59ba5b8cf955d7dd1171da0eb3e72d2fda897e38;p=modules%2Fvisu.git Provides "S"- key for picking in both interactor styles --- diff --git a/src/VVTK/VVTK_InteractorStyle.cxx b/src/VVTK/VVTK_InteractorStyle.cxx index 9386a162..96e3cf8e 100644 --- a/src/VVTK/VVTK_InteractorStyle.cxx +++ b/src/VVTK/VVTK_InteractorStyle.cxx @@ -158,31 +158,6 @@ VVTK_InteractorStyle if ( myIsLeftButtonDown ) OnLeftButtonDown( ctrl, shift, x, y ); } - -//---------------------------------------------------------------------------- -void -VVTK_InteractorStyle -::OnKeyDown() -{ - if( GetSelector()->SelectionMode() != GaussPointSelection ) - return; - - char key = Interactor->GetKeyCode(); - - if ( key == 'S' ) { - // current mouse position (from last mouse move event or any other event) - int x, y; - Interactor->GetEventPosition( x, y ); - FindPokedRenderer( x, y ); // calls SetCurrentRenderer - - myOtherPoint = myPoint = QPoint(x, y); - - startOperation(VTK_INTERACTOR_STYLE_CAMERA_SELECT); - onFinishOperation(); - startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE); - } -} - //---------------------------------------------------------------------------- void VVTK_InteractorStyle::onFinishOperation() { @@ -269,25 +244,28 @@ VVTK_InteractorStyle { Interactor->InvokeEvent(VISU::SetSMIncreaseMagnificationEvent,NULL); } - -vtkStandardNewMacro(VVTK_InteractorStyleController); +//============================================================================ +// +// Controllers +// +vtkStandardNewMacro(VVTK_ControllerIncrement); //---------------------------------------------------------------------------- -VVTK_InteractorStyleController::VVTK_InteractorStyleController() +VVTK_ControllerIncrement::VVTK_ControllerIncrement() { myIncrement=10; } //---------------------------------------------------------------------------- -VVTK_InteractorStyleController::~VVTK_InteractorStyleController() +VVTK_ControllerIncrement::~VVTK_ControllerIncrement() { } //---------------------------------------------------------------------------- -int VVTK_InteractorStyleController::IncrementIncrease() +int VVTK_ControllerIncrement::Increase() { myIncrement*=2; return myIncrement; } //---------------------------------------------------------------------------- -int VVTK_InteractorStyleController::IncrementDecrease() +int VVTK_ControllerIncrement::Decrease() { myIncrement/=2; if (!myIncrement){ @@ -295,3 +273,29 @@ int VVTK_InteractorStyleController::IncrementDecrease() } return myIncrement; } +// +vtkStandardNewMacro(VVTK_ControllerOnKeyDown); +//---------------------------------------------------------------------------- +VVTK_ControllerOnKeyDown::VVTK_ControllerOnKeyDown() +{ +} +//---------------------------------------------------------------------------- +VVTK_ControllerOnKeyDown::~VVTK_ControllerOnKeyDown() +{ +} +//---------------------------------------------------------------------------- +bool VVTK_ControllerOnKeyDown::OnKeyDown(vtkInteractorStyle* theIS) +{ + SVTK_InteractorStyle *pIS=dynamic_cast(theIS); + if (pIS){ + if(pIS->GetSelector()->SelectionMode()==GaussPointSelection){ + char key = pIS->GetInteractor()->GetKeyCode(); + // + if (key == 'S') { + pIS->ActionPicking(); + return false; + } + } + } + return Superclass::OnKeyDown(theIS); +} diff --git a/src/VVTK/VVTK_InteractorStyle.h b/src/VVTK/VVTK_InteractorStyle.h index 8f06666e..2d6ec122 100644 --- a/src/VVTK/VVTK_InteractorStyle.h +++ b/src/VVTK/VVTK_InteractorStyle.h @@ -34,30 +34,54 @@ #include "SVTK_InteractorStyle.h" // +//------------------------------------------- //! Control the value of increment in new style of interaction. /*! This class controls of value of increment, for pan/rotate/zoom operations in new style of interaction */ -class VVTK_InteractorStyleController : public SVTK_InteractorStyleController { +class VVTK_ControllerIncrement : public SVTK_ControllerIncrement { public: - vtkTypeMacro(VVTK_InteractorStyleController,SVTK_InteractorStyleController); - static VVTK_InteractorStyleController* New(); + vtkTypeMacro(VVTK_ControllerIncrement,SVTK_ControllerIncrement); + static VVTK_ControllerIncrement* New(); //! Increace the increment value by multiplying on 2 - virtual int IncrementIncrease(); + virtual int Increase(); //! Decreace the increment value by division on 2 - virtual int IncrementDecrease(); + virtual int Decrease(); protected: - VVTK_InteractorStyleController(); - virtual ~VVTK_InteractorStyleController(); + VVTK_ControllerIncrement(); + virtual ~VVTK_ControllerIncrement(); // private: - VVTK_InteractorStyleController(const VVTK_InteractorStyleController&); //Not implemented - void operator=(const VVTK_InteractorStyleController&); //Not implemented + VVTK_ControllerIncrement(const VVTK_ControllerIncrement&); //Not implemented + void operator=(const VVTK_ControllerIncrement&); //Not implemented +}; +// +//------------------------------------------- +//! Control the behaviour of KeyDown event in new style of interaction. +/*! + This class controls of behaviour of of KeyDown event + in new style of interaction. +*/ +class VVTK_ControllerOnKeyDown : public SVTK_ControllerOnKeyDown{ + public: + vtkTypeMacro(VVTK_ControllerOnKeyDown, SVTK_ControllerOnKeyDown); + static VVTK_ControllerOnKeyDown* New(); + + //! Provides the action on event + virtual bool OnKeyDown(vtkInteractorStyle* ); + + protected: + VVTK_ControllerOnKeyDown(); + virtual ~VVTK_ControllerOnKeyDown(); + + private: + VVTK_ControllerOnKeyDown(const VVTK_ControllerOnKeyDown&);//Not implemented + void operator=(const VVTK_ControllerOnKeyDown&); //Not implemented }; class VISU_PickingSettings; @@ -77,7 +101,8 @@ class VVTK_EXPORT VVTK_InteractorStyle : public SVTK_InteractorStyle //! To share the VISU_PickingSettings void SetPickingSettings(VISU_PickingSettings* thePickingSettings); - + + protected: VVTK_InteractorStyle(); ~VVTK_InteractorStyle(); @@ -99,9 +124,6 @@ class VVTK_EXPORT VVTK_InteractorStyle : public SVTK_InteractorStyle //! Redefine SVTK_InteractorStyle::OnMiddleButtonUp virtual void OnMiddleButtonUp(int ctrl, int shift, int x, int y); - //! Redefine vtkInteractorStyle::OnKeyDown - virtual void OnKeyDown(); - //! Redefine SVTK_InteractorStyle::onFinishOperation virtual void onFinishOperation(); diff --git a/src/VVTK/VVTK_MainWindow.cxx b/src/VVTK/VVTK_MainWindow.cxx index b7c2e229..9f432d08 100644 --- a/src/VVTK/VVTK_MainWindow.cxx +++ b/src/VVTK/VVTK_MainWindow.cxx @@ -51,16 +51,22 @@ VVTK_MainWindow SUIT_ResourceMgr* theResourceMgr): SVTK_MainWindow(theParent,theName,theResourceMgr), myInteractorStyle(VVTK_InteractorStyle::New()), - myInteractorStyleController(VVTK_InteractorStyleController::New()) + myControllerIncrement(VVTK_ControllerIncrement::New()), + myControllerOnKeyDown(VVTK_ControllerOnKeyDown::New()) { - myInteractorStyle->SetController(myInteractorStyleController.GetPointer()); - myInteractorStyleController->Delete(); + myInteractorStyle->SetControllerIncrement(myControllerIncrement.GetPointer()); + myControllerIncrement->Delete(); + + myInteractorStyle->SetControllerOnKeyDown(myControllerOnKeyDown.GetPointer()); + myControllerOnKeyDown->Delete(); + myInteractorStyle->Delete(); moveDockWindow(myToolBar,Qt::DockLeft); myActionsMap[NonIsometric]->removeFrom(myToolBar); } +//---------------------------------------------------------------------------- void VVTK_MainWindow ::Initialize(SVTK_RenderWindowInteractor* theInteractor) @@ -68,11 +74,13 @@ VVTK_MainWindow vtkInteractorStyle* pVIS=theInteractor->GetInteractorStyle(); SVTK_InteractorStyle *pInteractorStyle=dynamic_cast(pVIS); if (pInteractorStyle){ - pInteractorStyle->SetController(myInteractorStyleController.GetPointer()); + pInteractorStyle->SetControllerIncrement(myControllerIncrement.GetPointer()); + pInteractorStyle->SetControllerOnKeyDown(myControllerOnKeyDown.GetPointer()); } SVTK_MainWindow::Initialize(theInteractor); } +//---------------------------------------------------------------------------- VVTK_MainWindow ::~VVTK_MainWindow() {} diff --git a/src/VVTK/VVTK_MainWindow.h b/src/VVTK/VVTK_MainWindow.h index edeb8dea..8ed61708 100644 --- a/src/VVTK/VVTK_MainWindow.h +++ b/src/VVTK/VVTK_MainWindow.h @@ -15,7 +15,8 @@ class VVTK_SegmentationCursorDlg; class VISU_OutsideCursorSettings; class VISU_PickingSettings; class VVTK_InteractorStyle; -class VVTK_InteractorStyleController; +class VVTK_ControllerIncrement; +class VVTK_ControllerOnKeyDown; class VVTK_PickingDlg; class VVTK_MainWindow2; class VVTK_Renderer1; @@ -59,7 +60,8 @@ public: protected: vtkSmartPointer myInteractorStyle; - vtkSmartPointer myInteractorStyleController; + vtkSmartPointer myControllerIncrement; + vtkSmartPointer myControllerOnKeyDown; };