]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Provides "S"- key for picking in both interactor styles BR-D5-38-2003_D2005-24-11
authorpkv <pkv@opencascade.com>
Wed, 23 Nov 2005 09:47:15 +0000 (09:47 +0000)
committerpkv <pkv@opencascade.com>
Wed, 23 Nov 2005 09:47:15 +0000 (09:47 +0000)
src/VVTK/VVTK_InteractorStyle.cxx
src/VVTK/VVTK_InteractorStyle.h
src/VVTK/VVTK_MainWindow.cxx
src/VVTK/VVTK_MainWindow.h

index 9386a162733e182be428cfaf50640a172b5f2031..96e3cf8ee54f25dc9c328f8e8a46227d2a2d99af 100644 (file)
@@ -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<SVTK_InteractorStyle *>(theIS);
+  if (pIS){
+    if(pIS->GetSelector()->SelectionMode()==GaussPointSelection){
+      char key = pIS->GetInteractor()->GetKeyCode();
+      //
+      if (key == 'S') {
+       pIS->ActionPicking();
+       return false;
+      }
+    }
+  }
+  return Superclass::OnKeyDown(theIS);
+}
index 8f06666e0226626efed57c7d8d70cd0114d9e88a..2d6ec122ffd9ba78512ad8759a5599527ebd76dd 100644 (file)
 
 #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();
 
index b7c2e2298d07354516895530e1021712efd492db..9f432d0820835251b34df26aa13f3de43394b455 100644 (file)
@@ -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<SVTK_InteractorStyle*>(pVIS);
   if (pInteractorStyle){
-    pInteractorStyle->SetController(myInteractorStyleController.GetPointer());
+    pInteractorStyle->SetControllerIncrement(myControllerIncrement.GetPointer());
+    pInteractorStyle->SetControllerOnKeyDown(myControllerOnKeyDown.GetPointer());
   }
   SVTK_MainWindow::Initialize(theInteractor);
 }
 
+//----------------------------------------------------------------------------
 VVTK_MainWindow
 ::~VVTK_MainWindow()
 {}
index edeb8dea5d513fb78aa5955aada202a2e5ef73f4..8ed617087d695ece9937306c5b8123d5f912ce62 100644 (file)
@@ -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<VVTK_InteractorStyle> myInteractorStyle;
-  vtkSmartPointer<VVTK_InteractorStyleController> myInteractorStyleController;
+  vtkSmartPointer<VVTK_ControllerIncrement> myControllerIncrement;
+  vtkSmartPointer<VVTK_ControllerOnKeyDown> myControllerOnKeyDown; 
 };