SVTK_MainWindow.h \
SVTK_Renderer.h \
SVTK_InteractorStyle.h \
+ SVTK_KeyFreeInteractorStyle.h \
SVTK_RenderWindowInteractor.h \
SVTK_GenericRenderWindowInteractor.h \
SVTK_Selector.h \
SVTK_ViewWindow.cxx \
SVTK_MainWindow.cxx \
SVTK_InteractorStyle.cxx \
+ SVTK_KeyFreeInteractorStyle.cxx \
SVTK_RenderWindowInteractor.cxx \
SVTK_GenericRenderWindowInteractor.cxx \
SVTK_SpaceMouse.cxx \
resources/vtk_view_rotation_point.png \
resources/vtk_view_parallel.png \
resources/vtk_view_perspective.png \
- resources/vtk_view_parameters.png
+ resources/vtk_view_parameters.png \
+ resources/vtk_view_style_switch.png
nodist_salomeres_DATA= \
SVTK_msg_en.qm \
*/
void SVTK_InteractorStyle::OnChar()
{
+ char key = GetInteractor()->GetKeyCode();
+ switch ( key ) {
+ case '+': ControllerIncrement()->Increase(); break;
+ case '-': ControllerIncrement()->Decrease(); break;
+ }
}
/*!
return myIncrement;
}
+vtkStandardNewMacro(SVTK_GeomControllerIncrement);
+SVTK_GeomControllerIncrement::SVTK_GeomControllerIncrement()
+{
+}
+SVTK_GeomControllerIncrement::~SVTK_GeomControllerIncrement()
+{
+}
+int SVTK_GeomControllerIncrement::Increase()
+{
+ myIncrement*=2;
+ return myIncrement;
+}
+int SVTK_GeomControllerIncrement::Decrease()
+{
+ myIncrement/=2;
+ if (myIncrement<1){
+ myIncrement=1;
+ }
+ return myIncrement;
+}
+
vtkStandardNewMacro(SVTK_ControllerOnKeyDown);
/*!
#endif
//
-//! Control the value of increment in SALOME way.
+//! Control the value of increment in arithmetic progression mode.
/*!
This class controls of value of increment,
- for pan/rotate/zoom operations in SALOME way
+ for pan/rotate/zoom operations in arithmetic progression mode
*/
class SVTK_EXPORT SVTK_ControllerIncrement : public vtkObject{
public:
SVTK_ControllerIncrement(const SVTK_ControllerIncrement&);//Not implemented
void operator=(const SVTK_ControllerIncrement&); //Not implemented
};
+
+//
+//! Control the value of increment in geometric progression mode.
+/*!
+ This class controls of value of increment,
+ for pan/rotate/zoom operations in geometric progression mode.
+*/
+class SVTK_EXPORT SVTK_GeomControllerIncrement : public SVTK_ControllerIncrement{
+ public:
+ vtkTypeMacro(SVTK_GeomControllerIncrement, SVTK_ControllerIncrement);
+ static SVTK_GeomControllerIncrement* New();
+
+ //! Increace the increment value by add 1
+ virtual int Increase();
+
+ //! Decreace the increment value by subtract 1
+ virtual int Decrease();
+ protected:
+ SVTK_GeomControllerIncrement();
+ virtual ~SVTK_GeomControllerIncrement();
+ private:
+ SVTK_GeomControllerIncrement(const SVTK_GeomControllerIncrement&);//Not implemented
+ void operator=(const SVTK_GeomControllerIncrement&); //Not implemented
+};
//
//! Control the behaviour of KeyDown event in SALOME way.
/*!
--- /dev/null
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File : SVTK_KeyFreeInteractorStyle.cxx
+// Author : Christophe ATTANASIO
+// Module : SALOME
+// $Header$
+
+
+#include "SVTK_KeyFreeInteractorStyle.h"
+#include "SVTK_Selector.h"
+
+#include <vtkObjectFactory.h>
+#include <vtkRenderWindowInteractor.h>
+#include <vtkCallbackCommand.h>
+#include <vtkCommand.h>
+#include <vtkRenderer.h>
+#include <vtkCamera.h>
+
+
+//----------------------------------------------------------------------------
+vtkStandardNewMacro(SVTK_KeyFreeInteractorStyle);
+//----------------------------------------------------------------------------
+
+SVTK_KeyFreeInteractorStyle::SVTK_KeyFreeInteractorStyle():
+ myIsMidButtonDown( false ),
+ myIsLeftButtonDown( false )
+{
+}
+
+//----------------------------------------------------------------------------
+SVTK_KeyFreeInteractorStyle::~SVTK_KeyFreeInteractorStyle()
+{
+}
+
+//----------------------------------------------------------------------------
+void SVTK_KeyFreeInteractorStyle::OnLeftButtonDown(int ctrl, int shift,
+ int x, int y)
+{
+ myIsLeftButtonDown = true;
+
+ if (this->HasObserver(vtkCommand::LeftButtonPressEvent)) {
+ this->InvokeEvent(vtkCommand::LeftButtonPressEvent,NULL);
+ return;
+ }
+ this->FindPokedRenderer(x, y);
+ if (this->CurrentRenderer == NULL) {
+ return;
+ }
+ myShiftState = shift;
+ // finishing current viewer operation
+ if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
+ onFinishOperation();
+ startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
+ }
+ myOtherPoint = myPoint = QPoint(x, y);
+ if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
+ startOperation(ForcedState);
+ }
+ else {
+ if (!(ctrl||shift)){
+ if (myIsMidButtonDown){
+ startOperation(VTK_INTERACTOR_STYLE_CAMERA_ZOOM);
+ }
+ else{
+ startOperation(VTK_INTERACTOR_STYLE_CAMERA_ROTATE);
+ }
+ }
+ }
+ return;
+}
+
+//----------------------------------------------------------------------------
+void SVTK_KeyFreeInteractorStyle::OnMiddleButtonDown(int ctrl,
+ int shift,
+ int x, int y)
+{
+ myIsMidButtonDown = true;
+
+ if (this->HasObserver(vtkCommand::MiddleButtonPressEvent)) {
+ this->InvokeEvent(vtkCommand::MiddleButtonPressEvent,NULL);
+ return;
+ }
+ this->FindPokedRenderer(x, y);
+ if (this->CurrentRenderer == NULL) {
+ return;
+ }
+ myShiftState = shift;
+ // finishing current viewer operation
+ if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
+ onFinishOperation();
+ startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
+ }
+ myOtherPoint = myPoint = QPoint(x, y);
+ if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
+ startOperation(ForcedState);
+ }
+ else {
+ if (!(ctrl||shift)){
+ if ( myIsLeftButtonDown ){
+ startOperation(VTK_INTERACTOR_STYLE_CAMERA_ZOOM);
+ }
+ else{
+ startOperation(VTK_INTERACTOR_STYLE_CAMERA_PAN);
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+void SVTK_KeyFreeInteractorStyle::OnLeftButtonUp(int ctrl, int shift, int x, int y)
+{
+ myIsLeftButtonDown = false;
+ SVTK_InteractorStyle::OnLeftButtonUp( ctrl, shift, x, y );
+
+ if ( myIsMidButtonDown )
+ OnMiddleButtonDown( ctrl, shift, x, y );
+}
+
+//----------------------------------------------------------------------------
+void SVTK_KeyFreeInteractorStyle::OnMiddleButtonUp(int ctrl, int shift, int x, int y)
+{
+ myIsMidButtonDown = false;
+ SVTK_InteractorStyle::OnMiddleButtonUp( ctrl, shift, x, y );
+
+ if ( myIsLeftButtonDown )
+ OnLeftButtonDown( ctrl, shift, x, y );
+}
+
+//----------------------------------------------------------------------------
+void SVTK_KeyFreeInteractorStyle::OnChar()
+{
+ char key = GetInteractor()->GetKeyCode();
+ switch (key) {
+ case 's':
+ case 'S':
+ ActionPicking();
+ return;
+ }
+ SVTK_InteractorStyle::OnChar();
+}
--- /dev/null
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File : SVTK_KeyFreeInteractorStyle.h
+// Author : Christophe ATTANASIO
+// Module : SALOME
+// $Header$
+
+#ifndef __SVTK_KeyFreeInteractorStyle_h
+#define __SVTK_KeyFreeInteractorStyle_h
+
+
+#include "SVTK.h"
+
+#include "SVTK_InteractorStyle.h"
+
+//! Introduce new style of interaction (keyboard free)
+class SVTK_EXPORT SVTK_KeyFreeInteractorStyle : public SVTK_InteractorStyle
+{
+ public:
+ static SVTK_KeyFreeInteractorStyle *New();
+ vtkTypeMacro(SVTK_KeyFreeInteractorStyle,SVTK_InteractorStyle);
+
+ protected:
+ SVTK_KeyFreeInteractorStyle();
+ ~SVTK_KeyFreeInteractorStyle();
+
+ SVTK_KeyFreeInteractorStyle(const SVTK_KeyFreeInteractorStyle&); // Not implemented
+ void operator=(const SVTK_KeyFreeInteractorStyle&); // Not implemented
+
+ // Generic event bindings must be overridden in subclasses
+
+ //! Redefine SVTK_InteractorStyle::OnLeftButtonDown
+ virtual void OnLeftButtonDown(int ctrl, int shift, int x, int y);
+
+ //! Redefine SVTK_InteractorStyle::OnMiddleButtonDown
+ virtual void OnMiddleButtonDown(int ctrl, int shift, int x, int y);
+
+ //! Redefine SVTK_InteractorStyle::OnLeftButtonUp
+ virtual void OnLeftButtonUp(int ctrl, int shift, int x, int y);
+
+ //! Redefine SVTK_InteractorStyle::OnMiddleButtonUp
+ virtual void OnMiddleButtonUp(int ctrl, int shift, int x, int y);
+
+ //! Redefine SVTK_InteractorStyle::OnChar
+ virtual void OnChar();
+
+ bool myIsMidButtonDown;
+ bool myIsLeftButtonDown;
+};
+
+#endif
#include "SVTK_Renderer.h"
#include "SVTK_RenderWindowInteractor.h"
#include "SVTK_InteractorStyle.h"
+#include "SVTK_KeyFreeInteractorStyle.h"
#include "SVTK_Selector.h"
#include "SVTK_ComboAction.h"
SUIT_ResourceMgr* theResourceMgr,
SUIT_ViewWindow* theViewWindow) :
QMainWindow(theParent),
- myViewWindow(theViewWindow)
+ myViewWindow(theViewWindow),
+ myKeyFreeInteractorStyle(SVTK_KeyFreeInteractorStyle::New())
{
setObjectName(theName);
setWindowFlags( windowFlags() & ~Qt::Window );
+ // specific of vtkSmartPointer
+ myKeyFreeInteractorStyle->Delete();
}
/*!
QtxActionToolMgr* mgr = toolMgr();
mgr->append( DumpId, myToolBar );
+ mgr->append( SwitchInteractionStyleId, myToolBar );
mgr->append( ViewTrihedronId, myToolBar );
QtxMultiAction* aScaleAction = new QtxMultiAction( this );
mgr->append( ProjectionModeId, myToolBar );
mgr->append( ViewParametersId, myToolBar );
-
- mgr->append( SwitchInteractionStyleId, myToolBar );
}
/*!
*/
void SVTK_MainWindow::onSwitchInteractionStyle(bool theOn)
{
+ if (theOn) {
+ // keep the same style extensions
+ SVTK_InteractorStyle* aStyle = (SVTK_InteractorStyle*)GetInteractorStyle();
+ if ( aStyle ) {
+ myKeyFreeInteractorStyle->SetControllerIncrement(aStyle->ControllerIncrement());
+ myKeyFreeInteractorStyle->SetControllerOnKeyDown(aStyle->ControllerOnKeyDown());
+ }
+
+ PushInteractorStyle(myKeyFreeInteractorStyle.GetPointer());
+ }
+ else {
+ PopInteractorStyle();
+ }
}
/*!
class SVTK_ViewParameterDlg;
class SVTK_Renderer;
class SVTK_Selector;
+class SVTK_KeyFreeInteractorStyle;
class VTKViewer_Trihedron;
class VTKViewer_Actor;
protected:
virtual QtxActionToolMgr* toolMgr() const;
- void
- createActions(SUIT_ResourceMgr* theResourceMgr);
+ void createActions(SUIT_ResourceMgr* theResourceMgr);
- void
- createToolBar();
+ void createToolBar();
- void
- SetEventDispatcher(vtkObject* theDispatcher);
+ void SetEventDispatcher(vtkObject* theDispatcher);
QtxAction* action( int ) const;
int myToolBar;
SVTK_RenderWindowInteractor* myInteractor;
+ vtkSmartPointer<SVTK_KeyFreeInteractorStyle> myKeyFreeInteractorStyle;
};
#ifdef WIN32