--- /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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : VVTK_InteractorStyle.cxx
+// Author : Christophe ATTANASIO
+// Module : SALOME
+// $Header$
+
+
+#include "VVTK_InteractorStyle.h"
+
+#include <vtkObjectFactory.h>
+#include <vtkCommand.h>
+
+//----------------------------------------------------------------------------
+vtkStandardNewMacro(VVTK_InteractorStyle);
+//----------------------------------------------------------------------------
+
+VVTK_InteractorStyle
+::VVTK_InteractorStyle()
+{
+ printf ( "\n--- VVTK_InteractorStyle created ---\n" );
+}
+
+//----------------------------------------------------------------------------
+VVTK_InteractorStyle
+::~VVTK_InteractorStyle()
+{
+}
+
+//----------------------------------------------------------------------------
+void
+VVTK_InteractorStyle
+::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)
+ startOperation(VTK_INTERACTOR_STYLE_CAMERA_ZOOM);
+ else {
+ if ( myIsMidButtonDown )
+ startOperation(VTK_INTERACTOR_STYLE_CAMERA_ZOOM);
+ else
+ startOperation(VTK_INTERACTOR_STYLE_CAMERA_ROTATE);
+ }
+ }
+ return;
+}
+
+//----------------------------------------------------------------------------
+void
+VVTK_InteractorStyle
+::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 ( myIsLeftButtonDown )
+ startOperation(VTK_INTERACTOR_STYLE_CAMERA_ZOOM);
+ else
+ startOperation(VTK_INTERACTOR_STYLE_CAMERA_PAN);
+ }
+}
+
+//----------------------------------------------------------------------------
+void
+VVTK_InteractorStyle
+::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
+VVTK_InteractorStyle
+::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 );
+}
--- /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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : VVTK_InteractorStyle.h
+// Author : Christophe ATTANASIO
+// Module : SALOME
+// $Header$
+
+#ifndef __VVTK_InteractorStyle_h
+#define __VVTK_InteractorStyle_h
+
+#include "VVTK.h"
+
+#include "SVTK_InteractorStyle.h"
+
+class VVTK_EXPORT VVTK_InteractorStyle : public SVTK_InteractorStyle
+{
+ public:
+ // Description:
+ // This class must be supplied with a vtkRenderWindowInteractor wrapper or
+ // parent. This class should not normally be instantiated by application
+ // programmers.
+ static VVTK_InteractorStyle *New();
+ vtkTypeMacro(VVTK_InteractorStyle, vtkInteractorStyle);
+
+ protected:
+ VVTK_InteractorStyle();
+ ~VVTK_InteractorStyle();
+ VVTK_InteractorStyle(const VVTK_InteractorStyle&) {};
+ void operator=(const VVTK_InteractorStyle&) {};
+
+ // Generic event bindings must be overridden in subclasses
+ virtual void OnLeftButtonDown(int ctrl, int shift, int x, int y);
+ virtual void OnMiddleButtonDown(int ctrl, int shift, int x, int y);
+ virtual void OnLeftButtonUp(int ctrl, int shift, int x, int y);
+ virtual void OnMiddleButtonUp(int ctrl, int shift, int x, int y);
+
+ private:
+ bool myIsMidButtonDown;
+ bool myIsLeftButtonDown;
+};
+
+#endif