SVTK_Selection.h \
SVTK_SelectionEvent.h \
SVTK_SpaceMouse.h \
- SVTK_SpaceMouseEvent.h \
+ SVTK_Event.h \
SVTK_ViewModelBase.h
# Libraries targets
--- /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 : SVTK_SpaceMouseEvent.h
+// Author : Alexander SLADKOV
+// Module : SALOME
+// $Header$
+
+#ifndef SVTK_SpaceMouseEvent_h
+#define SVTK_SpaceMouseEvent_h
+
+#include <vtkCommand.h>
+
+enum Event {
+ SpaceMouseMoveEvent = vtkCommand::UserEvent+1,
+ SpaceMouseButtonEvent,
+ PanLeftEvent,
+ PanRightEvent,
+ PanUpEvent,
+ PanDownEvent,
+ ZoomInEvent,
+ ZoomOutEvent,
+ RotateLeftEvent,
+ RotateRightEvent,
+ RotateUpEvent,
+ RotateDownEvent,
+ PlusSpeedIncrementEvent,
+ MinusSpeedIncrementEvent,
+ SetSpeedIncrementEvent,
+ SetSpaceMouseF1Event,
+ SetSpaceMouseF2Event,
+ SetSpaceMouseF3Event,
+ SetSpaceMouseF4Event,
+ SetSpaceMouseF5Event,
+ LastEvent
+};
+
+#endif
#include "SVTK_RenderWindow.h"
#include "SVTK_ViewWindow.h"
#include "SVTK_Selection.h"
-#include "SVTK_SpaceMouseEvent.h"
+#include "SVTK_Event.h"
#include "SVTK_Selector.h"
#include "SVTK_Functor.h"
#include "SALOME_ListIteratorOfListIO.hxx"
#include "SALOME_ListIO.hxx"
-#include "SUIT_Session.h"
-#include "SUIT_ResourceMgr.h"
-
#include <vtkObjectFactory.h>
#include <vtkMath.h>
#include <vtkCommand.h>
FindPokedRenderer( 0, 0 );
// register EventCallbackCommand as observer of custorm event (3d space mouse event)
- interactor->AddObserver( SpaceMouseMoveEvent, EventCallbackCommand, Priority );
+ interactor->AddObserver( SpaceMouseMoveEvent, EventCallbackCommand, Priority );
interactor->AddObserver( SpaceMouseButtonEvent, EventCallbackCommand, Priority );
+ interactor->AddObserver( PanLeftEvent, EventCallbackCommand, Priority );
+ interactor->AddObserver( PanRightEvent, EventCallbackCommand, Priority );
+ interactor->AddObserver( PanUpEvent, EventCallbackCommand, Priority );
+ interactor->AddObserver( PanDownEvent, EventCallbackCommand, Priority );
+ interactor->AddObserver( ZoomInEvent, EventCallbackCommand, Priority );
+ interactor->AddObserver( ZoomOutEvent, EventCallbackCommand, Priority );
+ interactor->AddObserver( RotateLeftEvent, EventCallbackCommand, Priority );
+ interactor->AddObserver( RotateRightEvent, EventCallbackCommand, Priority );
+ interactor->AddObserver( RotateUpEvent, EventCallbackCommand, Priority );
+ interactor->AddObserver( RotateDownEvent, EventCallbackCommand, Priority );
}
}
SVTK_InteractorStyle
::onSpaceMouseButton( int button )
{
- // printf( "Button pressed [%d] \n", button );
- SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
- if ( resMgr->integerValue( "VISU", "spacemouse_func1_btn" ) == button )
- DecreaseSpeedIncrement();
- if ( resMgr->integerValue( "VISU", "spacemouse_func2_btn" ) == button )
- IncreaseSpeedIncrement();
- if ( resMgr->integerValue( "VISU", "spacemouse_func3_btn" ) == button )
- DecreaseGaussPointMagnification();
- if ( resMgr->integerValue( "VISU", "spacemouse_func4_btn" ) == button )
- IncreaseGaussPointMagnification();
- if ( resMgr->integerValue( "VISU", "spacemouse_func5_btn" ) == button )
- DominantCombinedSwitch();
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_InteractorStyle
-::DecreaseSpeedIncrement()
-{
- printf( "\n--DecreaseSpeedIncrement() NOT IMPLEMENTED--\n" );
-
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_InteractorStyle
-::IncreaseSpeedIncrement()
-{
- printf( "\n--IncreaseSpeedIncrement() NOT IMPLEMENTED--\n" );
+ if ( mySpaceMouseBtns[0] == button ) --mySpeedIncrement;
+ if ( mySpaceMouseBtns[1] == button ) ++mySpeedIncrement;
+ if ( mySpaceMouseBtns[2] == button ) DecreaseGaussPointMagnification();
+ if ( mySpaceMouseBtns[3] == button ) IncreaseGaussPointMagnification();
+ if ( mySpaceMouseBtns[4] == button ) DominantCombinedSwitch();
}
//----------------------------------------------------------------------------
void* clientData,
void* callData )
{
- if ( event != SpaceMouseMoveEvent && event != SpaceMouseButtonEvent )
+ if ( event < vtkCommand::UserEvent )
vtkInteractorStyle::ProcessEvents( object, event, clientData, callData );
- else if ( clientData && callData ) {
+ else if ( clientData ) {
vtkObject* anObject = reinterpret_cast<vtkObject*>( clientData );
SVTK_InteractorStyle* self = dynamic_cast<SVTK_InteractorStyle*>( anObject );
if ( self ) {
case SpaceMouseButtonEvent :
self->onSpaceMouseButton( *((int*)callData) );
break;
+ case PanLeftEvent:
+ self->IncrementalPan( -self->mySpeedIncrement, 0 );
+ break;
+ case PanRightEvent:
+ self->IncrementalPan( self->mySpeedIncrement, 0 );
+ break;
+ case PanUpEvent:
+ self->IncrementalPan( 0, self->mySpeedIncrement );
+ break;
+ case PanDownEvent:
+ self->IncrementalPan( 0, -self->mySpeedIncrement );
+ break;
+ case ZoomInEvent:
+ self->IncrementalZoom( self->mySpeedIncrement );
+ break;
+ case ZoomOutEvent:
+ self->IncrementalZoom( -self->mySpeedIncrement );
+ break;
+ case RotateLeftEvent:
+ self->IncrementalRotate( -self->mySpeedIncrement, 0 );
+ break;
+ case RotateRightEvent:
+ self->IncrementalRotate( self->mySpeedIncrement, 0 );
+ break;
+ case RotateUpEvent:
+ self->IncrementalRotate( 0, -self->mySpeedIncrement );
+ break;
+ case RotateDownEvent:
+ self->IncrementalRotate( 0, self->mySpeedIncrement );
+ break;
+ case PlusSpeedIncrementEvent:
+ ++(self->mySpeedIncrement);
+ break;
+ case MinusSpeedIncrementEvent:
+ --(self->mySpeedIncrement);
+ break;
+ case SetSpeedIncrementEvent:
+ self->mySpeedIncrement = *((int*)callData);
+ break;
+ case SetSpaceMouseF1Event:
+ self->mySpaceMouseBtns[0] = *((int*)callData);
+ break;
+ case SetSpaceMouseF2Event:
+ self->mySpaceMouseBtns[1] = *((int*)callData);
+ break;
+ case SetSpaceMouseF3Event:
+ self->mySpaceMouseBtns[2] = *((int*)callData);
+ break;
+ case SetSpaceMouseF4Event:
+ self->mySpaceMouseBtns[3] = *((int*)callData);
+ break;
+ case SetSpaceMouseF5Event:
+ self->mySpaceMouseBtns[4] = *((int*)callData);
+ break;
}
}
}
void onSpaceMouseMove( double* data );
void onSpaceMouseButton( int button );
- void DecreaseSpeedIncrement();
- void IncreaseSpeedIncrement();
void DecreaseGaussPointMagnification();
void IncreaseGaussPointMagnification();
void DominantCombinedSwitch();
bool myCursorState;
bool myShiftState;
int ForcedState;
+
+ int mySpeedIncrement; // "increment" for pan/rotate/zoom operations
+ int mySpaceMouseBtns[5]; // space_mouse_button assigned for functions 1..5 :
+ // [1] Decrease Speed Increment
+ // [2] Increase Speed Increment
+ // [3] Decrease Gauss Point Magnification
+ // [4] Increase Gauss Point Magnification
+ // [5] Dominant Combined Switch
QWidget* myRenderWidget;
vtkSmartPointer<SVTK_Selector> mySelector;
#include "SVTK_Functor.h"
#include "SALOME_Actor.h"
#include "SVTK_SpaceMouse.h"
-#include "SVTK_SpaceMouseEvent.h"
+#include "SVTK_Event.h"
#include <stdio.h>
#include <stdlib.h>
TSetFunction<SALOME_Actor,const char*,QString>
(&SALOME_Actor::setName,theName.latin1()));
}
+
+void
+SVTK_RenderWindowInteractor
+::FireEvent(const int svtkEvent, void* data)
+{
+ myInteractor->InvokeEvent( svtkEvent, data );
+}
QColor thecolor);
QColor GetColor(const Handle(SALOME_InteractiveObject)& IObject);
+ // SVTK events manamegent (key accelerators, speed increment, etc.)
+ void FireEvent( const int svtkAccelEvent, void* data );
+
protected:
int myDisplayMode;
+++ /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 : SVTK_SpaceMouseEvent.h
-// Author : Alexander SLADKOV
-// Module : SALOME
-// $Header$
-
-#ifndef SVTK_SpaceMouseEvent_h
-#define SVTK_SpaceMouseEvent_h
-
-#include <vtkCommand.h>
-
-enum SpaceMouseEvent {
- SpaceMouseMoveEvent = vtkCommand::UserEvent+1,
- SpaceMouseButtonEvent
-};
-
-#endif
#include "SUIT_Tools.h"
#include "SUIT_ResourceMgr.h"
+#include "SUIT_Accel.h"
#include "VTKViewer_Utilities.h"
#include "VTKViewer_CellRectPicker.h"
-//#include "SVTK_View.h"
+#include "SVTK_Event.h"
#include "SVTK_ViewWindow.h"
#include "SVTK_ViewModelBase.h"
#include "SVTK_RenderWindowInteractor.h"
}
}
}
+
+//----------------------------------------------------------------------------
+int convertAction( const int accelAction )
+{
+ switch ( accelAction ) {
+ case SUIT_Accel::PanLeft : return PanLeftEvent;
+ case SUIT_Accel::PanRight : return PanRightEvent;
+ case SUIT_Accel::PanUp : return PanUpEvent;
+ case SUIT_Accel::PanDown : return PanDownEvent;
+ case SUIT_Accel::ZoomIn : return ZoomInEvent;
+ case SUIT_Accel::ZoomOut : return ZoomOutEvent;
+ case SUIT_Accel::RotateLeft : return RotateLeftEvent;
+ case SUIT_Accel::RotateRight : return RotateRightEvent;
+ case SUIT_Accel::RotateUp : return RotateUpEvent;
+ case SUIT_Accel::RotateDown : return RotateDownEvent;
+ }
+ return accelAction;
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_ViewWindow
+::action( const int accelAction )
+{
+ if ( accelAction == SUIT_Accel::ZoomFit )
+ onFitAll();
+ else {
+ int svtkEvent = convertAction( accelAction );
+ myView->FireEvent( svtkEvent, 0 );
+ }
+}
protected:
QImage dumpView();
+ virtual void action( const int );
SVTK_View* myView;
};