From: stv Date: Wed, 22 Feb 2006 07:22:21 +0000 (+0000) Subject: no message X-Git-Tag: LAST_STABLE_VERSION_21_09_2006_ON_3_2_0~99 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fe5d10e563a80d9ea57bf90a1cfdbe3866d56654;p=modules%2Fgui.git no message --- diff --git a/src/SVTK/SVTK.h b/src/SVTK/SVTK.h index d4d8cf530..a5b0ba916 100755 --- a/src/SVTK/SVTK.h +++ b/src/SVTK/SVTK.h @@ -16,17 +16,17 @@ // // See http://www.salome-platform.org/ // -#ifdef WNT -#ifdef SVTK_EXPORTS -#define SVTK_EXPORT __declspec(dllexport) -#else -#define SVTK_EXPORT __declspec(dllimport) -#endif -#else -#define SVTK_EXPORT -#endif - -#if defined WNT -#pragma warning ( disable: 4251 ) -#pragma warning ( disable: 4786 ) -#endif +#ifdef WNT +#ifdef SVTK_EXPORTS +#define SVTK_EXPORT __declspec(dllexport) +#else +#define SVTK_EXPORT __declspec(dllimport) +#endif +#else +#define SVTK_EXPORT +#endif + +#if defined WNT +#pragma warning ( disable: 4251 ) +#pragma warning ( disable: 4786 ) +#endif diff --git a/src/SVTK/SVTK_RenderWindowInteractor.cxx b/src/SVTK/SVTK_RenderWindowInteractor.cxx index a2b8aa176..bc4de96c6 100644 --- a/src/SVTK/SVTK_RenderWindowInteractor.cxx +++ b/src/SVTK/SVTK_RenderWindowInteractor.cxx @@ -80,33 +80,29 @@ QVTK_RenderWindowInteractor } -void -QVTK_RenderWindowInteractor -::Initialize(vtkGenericRenderWindowInteractor* theDevice) +void QVTK_RenderWindowInteractor::Initialize( vtkGenericRenderWindowInteractor* theDevice ) { - if(GetDevice()) - myDevice->SetRenderWindow(NULL); + if ( GetDevice() ) + myDevice->SetRenderWindow( NULL ); myDevice = theDevice; - if(theDevice) - theDevice->SetRenderWindow(getRenderWindow()); + if ( theDevice ) + theDevice->SetRenderWindow( getRenderWindow() ); } //---------------------------------------------------------------------------- -QVTK_RenderWindowInteractor -::~QVTK_RenderWindowInteractor() +QVTK_RenderWindowInteractor::~QVTK_RenderWindowInteractor() { - if(SVTK_SpaceMouse* aSpaceMouse = SVTK_SpaceMouse::getInstance()) - if(aSpaceMouse->isSpaceMouseOn()) - aSpaceMouse->close(x11Display()); +#ifndef WIN32 + SVTK_SpaceMouse* aSpaceMouse = SVTK_SpaceMouse::getInstance(); + if ( aSpaceMouse && aSpaceMouse->isSpaceMouseOn() ) + aSpaceMouse->close( x11Display() ); +#endif } - //---------------------------------------------------------------------------- -vtkGenericRenderWindowInteractor* -QVTK_RenderWindowInteractor -::GetDevice() +vtkGenericRenderWindowInteractor* QVTK_RenderWindowInteractor::GetDevice() { return myDevice.GetPointer(); } @@ -318,56 +314,69 @@ QVTK_RenderWindowInteractor //---------------------------------------------------------------------------- -void -QVTK_RenderWindowInteractor -::focusInEvent( QFocusEvent* event ) +void QVTK_RenderWindowInteractor::focusInEvent( QFocusEvent* event ) { QWidget::focusInEvent( event ); +#ifndef WIN32 // register set space mouse events receiver - if(SVTK_SpaceMouse* aSpaceMouse = SVTK_SpaceMouse::getInstance()){ - if(!aSpaceMouse->isSpaceMouseOn()) {// initialize 3D space mouse driver - aSpaceMouse->initialize(x11Display(),winId()); - }else{ - aSpaceMouse->setWindow(x11Display(),winId()); - } + SVTK_SpaceMouse* aSpaceMouse = SVTK_SpaceMouse::getInstance(); + + if ( aSpaceMouse ) + { + if ( !aSpaceMouse->isSpaceMouseOn() ) + // initialize 3D space mouse driver + aSpaceMouse->initialize( x11Display(), winId() ); + else + aSpaceMouse->setWindow( x11Display(), winId() ); } +#endif } //---------------------------------------------------------------------------- -void -QVTK_RenderWindowInteractor -::focusOutEvent ( QFocusEvent* event ) +void QVTK_RenderWindowInteractor::focusOutEvent( QFocusEvent* event ) { QWidget::focusOutEvent( event ); +#ifndef WIN32 // unregister set space mouse events receiver - if(SVTK_SpaceMouse* aSpaceMouse = SVTK_SpaceMouse::getInstance()){ - if(aSpaceMouse->isSpaceMouseOn()) - aSpaceMouse->setWindow(x11Display(),0); - } + SVTK_SpaceMouse* aSpaceMouse = SVTK_SpaceMouse::getInstance(); + if ( aSpaceMouse && aSpaceMouse->isSpaceMouseOn() ) + aSpaceMouse->setWindow( x11Display(), 0 ); +#endif } //---------------------------------------------------------------------------- -bool -QVTK_RenderWindowInteractor -::x11Event( XEvent *xEvent ) +#ifdef WIN32 + +bool QVTK_RenderWindowInteractor::winEvent( MSG* msg ) +{ + // TODO: Implement event handling for SpaceMouse + return QWidget::winEvent( msg ); +} + +#else + +bool QVTK_RenderWindowInteractor::x11Event( XEvent *xEvent ) { // handle 3d space mouse events - if(SVTK_SpaceMouse* aSpaceMouse = SVTK_SpaceMouse::getInstance()){ - if(aSpaceMouse->isSpaceMouseOn() && xEvent->type == ClientMessage){ + if ( SVTK_SpaceMouse* aSpaceMouse = SVTK_SpaceMouse::getInstance() ) + { + if ( aSpaceMouse->isSpaceMouseOn() && xEvent->type == ClientMessage ) + { SVTK_SpaceMouse::MoveEvent anEvent; int type = aSpaceMouse->translateEvent( x11Display(), xEvent, &anEvent, 1.0, 1.0 ); - switch( type ){ - case SVTK_SpaceMouse::SpaceMouseMove : - GetDevice()->InvokeEvent(SVTK::SpaceMouseMoveEvent, anEvent.data ); - break; - case SVTK_SpaceMouse::SpaceButtonPress : - GetDevice()->InvokeEvent( SVTK::SpaceMouseButtonEvent, &anEvent.button ); - break; - case SVTK_SpaceMouse::SpaceButtonRelease : - break; + switch ( type ) + { + case SVTK_SpaceMouse::SpaceMouseMove: + GetDevice()->InvokeEvent( SVTK::SpaceMouseMoveEvent, anEvent.data ); + break; + case SVTK_SpaceMouse::SpaceButtonPress: + GetDevice()->InvokeEvent( SVTK::SpaceMouseButtonEvent, &anEvent.button ); + break; + case SVTK_SpaceMouse::SpaceButtonRelease: + break; } return true; // stop handling the event } @@ -376,6 +385,7 @@ QVTK_RenderWindowInteractor return QWidget::x11Event( xEvent ); } +#endif //---------------------------------------------------------------------------- SVTK_RenderWindowInteractor diff --git a/src/SVTK/SVTK_RenderWindowInteractor.h b/src/SVTK/SVTK_RenderWindowInteractor.h index bc0020ddf..42011c4e2 100644 --- a/src/SVTK/SVTK_RenderWindowInteractor.h +++ b/src/SVTK/SVTK_RenderWindowInteractor.h @@ -116,8 +116,12 @@ class SVTK_EXPORT QVTK_RenderWindowInteractor: public QWidget virtual void focusInEvent( QFocusEvent* ); virtual void focusOutEvent( QFocusEvent* ); - //! To handle native X11 events (from such devices as SpaceMouse) + //! To handle native events (from such devices as SpaceMouse) +#ifdef WIN32 + virtual bool winEvent( MSG* ); +#else virtual bool x11Event( XEvent *e ); +#endif vtkSmartPointer myRenderWindow; vtkSmartPointer myDevice; diff --git a/src/SVTK/SVTK_Selector.cxx b/src/SVTK/SVTK_Selector.cxx index bc6dad148..b05a168a2 100644 --- a/src/SVTK/SVTK_Selector.cxx +++ b/src/SVTK/SVTK_Selector.cxx @@ -214,24 +214,19 @@ SVTK_SelectorDef theIndex.Clear(); } -bool -SVTK_SelectorDef -::IsIndexSelected(const Handle(SALOME_InteractiveObject)& theIO, - int theIndex) const +bool SVTK_SelectorDef::IsIndexSelected( const Handle(SALOME_InteractiveObject)& theIO, + int theIndex) const { TMapIOSubIndex::const_iterator anIter = myMapIOSubIndex.find(theIO); if(anIter != myMapIOSubIndex.end()){ const TColStd_IndexedMapOfInteger& aMapIndex = anIter->second.myMap; - return aMapIndex.Contains(theIndex); + return aMapIndex.Contains( theIndex ) == Standard_True; } return false; } -static -bool -removeIndex(TColStd_IndexedMapOfInteger& theMapIndex, - const int theIndex) +static bool removeIndex(TColStd_IndexedMapOfInteger& theMapIndex, const int theIndex) { int anId = theMapIndex.FindIndex(theIndex); // i==0 if Index is not in the MapIndex if(anId){ @@ -250,10 +245,9 @@ removeIndex(TColStd_IndexedMapOfInteger& theMapIndex, theMapIndex = aNewMap; } } - return anId; + return anId != 0; } - bool SVTK_SelectorDef ::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, @@ -327,23 +321,22 @@ SVTK_SelectorDef } TColStd_IndexedMapOfInteger& aMapIndex = anIter->second.myMap; - bool anIsConatains = aMapIndex.Contains(theIndex); - if(anIsConatains) - removeIndex(aMapIndex,theIndex); + bool anIsConatains = aMapIndex.Contains( theIndex ) == Standard_True; + if ( anIsConatains ) + removeIndex( aMapIndex, theIndex ); - if(!theIsModeShift) + if ( !theIsModeShift ) aMapIndex.Clear(); - if(!anIsConatains) + if ( !anIsConatains ) aMapIndex.Add( theIndex ); - if( aMapIndex.IsEmpty()) - myMapIOSubIndex.erase(theIO); + if ( aMapIndex.IsEmpty() ) + myMapIOSubIndex.erase( theIO ); return false; } - void SVTK_SelectorDef ::RemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, diff --git a/src/SVTK/SVTK_SpaceMouse.cxx b/src/SVTK/SVTK_SpaceMouse.cxx index 620e97ec0..8ee2e21d7 100644 --- a/src/SVTK/SVTK_SpaceMouse.cxx +++ b/src/SVTK/SVTK_SpaceMouse.cxx @@ -30,11 +30,13 @@ #include #include +#ifndef WIN32 #include #include #include #include #include +#endif #include "SVTK_SpaceMouse.h" @@ -52,11 +54,15 @@ SVTK_SpaceMouse* SVTK_SpaceMouse::getInstance() //--------------------------------------------- SVTK_SpaceMouse::SVTK_SpaceMouse() { +#ifndef WIN32 win = InputFocus; +#endif spaceMouseOn = 0; } //--------------------------------------------- +#ifndef WIN32 + int SVTK_SpaceMouse::initialize( Display *display, Window window ) { XMotionEvent = XInternAtom( display, "MotionEvent", 1 ); @@ -194,3 +200,4 @@ int SVTK_SpaceMouse::translateEvent( Display* display, XEvent* xEvent, MoveEvent return (!display); } +#endif diff --git a/src/SVTK/SVTK_SpaceMouse.h b/src/SVTK/SVTK_SpaceMouse.h index 57a6f8470..a282dae6f 100644 --- a/src/SVTK/SVTK_SpaceMouse.h +++ b/src/SVTK/SVTK_SpaceMouse.h @@ -29,11 +29,13 @@ #ifndef SVTK_SpaceMouse_h #define SVTK_SpaceMouse_h +#ifndef WIN32 extern "C" { #include #include } +#endif class SVTK_SpaceMouse { @@ -54,21 +56,25 @@ class SVTK_SpaceMouse bool isSpaceMouseOn() const { return spaceMouseOn != 0; } +#ifndef WIN32 int initialize ( Display*, Window ); int setWindow ( Display*, Window ); int translateEvent ( Display*, XEvent*, MoveEvent*, double, double ); int close ( Display* ); +#endif private: SVTK_SpaceMouse(); static SVTK_SpaceMouse* myInstance; +#ifndef WIN32 Atom XMotionEvent; Atom XButtonPressEvent; Atom XButtonReleaseEvent; Atom XCommandEvent; Window win; +#endif int spaceMouseOn; };