#include <vtkCamera.h>
// QT Includes
+#include <qtimer.h>
#include <qcolordialog.h>
-#include <qwidget.h>
#include <qpaintdevice.h>
#include "utilities.h"
//----------------------------------------------------------------------------
-SVTK_RenderWindowInteractor
-::SVTK_RenderWindowInteractor( QWidget* parent, const char* name ) :
- SVTK_RenderWindow( parent, name )
-{
- myInteractor = vtkGenericRenderWindowInteractor::New();
-
- myInteractor->SetRenderWindow( getRenderWindow() );
- myDisplayMode = 0;
+vtkStandardNewMacro(QtRenderWindowInteractor);
- mTimer = new QTimer( this ) ;
- connect(mTimer, SIGNAL(timeout()), this, SLOT(TimerFunc())) ;
-}
-
-
-SVTK_RenderWindowInteractor
-::~SVTK_RenderWindowInteractor()
+QtRenderWindowInteractor
+::QtRenderWindowInteractor()
{
- if(MYDEBUG) INFOS("SVTK_RenderWindowInteractor::~SVTK_RenderWindowInteractor()");
-
- // stop 3d space mouse driver
- SVTK_SpaceMouse* sm = SVTK_SpaceMouse::getInstance();
- if ( sm->isSpaceMouseOn() )
- sm->close( x11Display() );
-
- delete mTimer ;
-
- myInteractor->Delete();
+ myTimer = new QTimer( ) ;
+ connect(myTimer, SIGNAL(timeout()), this, SLOT(OnTimeOut())) ;
}
-//----------------------------------------------------------------------------
-void
-SVTK_RenderWindowInteractor
-::Initialize()
+QtRenderWindowInteractor
+::~QtRenderWindowInteractor()
{
- myInteractor->Initialize();
+ delete myTimer;
}
+
//----------------------------------------------------------------------------
void
-SVTK_RenderWindowInteractor
-::UpdateSize(int w, int h)
+QtRenderWindowInteractor
+::OnTimeOut()
{
- myInteractor->UpdateSize(w,h);
+ if( GetEnabled() ) {
+ this->InvokeEvent(vtkCommand::TimerEvent,NULL);
+ }
}
-//----------------------------------------------------------------------------
int
-SVTK_RenderWindowInteractor
+QtRenderWindowInteractor
::CreateTimer(int vtkNotUsed(timertype))
{
//
// Start a one-shot timer for 10ms.
//
- mTimer->start(10, TRUE) ;
+ myTimer->start(10, TRUE) ;
return 1 ;
}
int
-SVTK_RenderWindowInteractor
+QtRenderWindowInteractor
::DestroyTimer(void)
{
//
return 1 ;
}
-void
+
+//----------------------------------------------------------------------------
SVTK_RenderWindowInteractor
-::TimerFunc()
+::SVTK_RenderWindowInteractor( QWidget* parent, const char* name ) :
+ SVTK_RenderWindow( parent, name )
{
- if( ! myInteractor->GetEnabled() ) {
- return ;
- }
+ myInteractor = QtRenderWindowInteractor::New();
+
+ myInteractor->SetRenderWindow( getRenderWindow() );
+ myDisplayMode = 0;
+}
- vtkInteractorStyle* aStyle = vtkInteractorStyle::SafeDownCast( myInteractor->GetInteractorStyle() );
- aStyle->OnTimer();
- update();
+SVTK_RenderWindowInteractor
+::~SVTK_RenderWindowInteractor()
+{
+ if(MYDEBUG) INFOS("SVTK_RenderWindowInteractor::~SVTK_RenderWindowInteractor()");
+
+ // stop 3d space mouse driver
+ SVTK_SpaceMouse* sm = SVTK_SpaceMouse::getInstance();
+ if ( sm->isSpaceMouseOn() )
+ sm->close( x11Display() );
+
+ myInteractor->Delete();
}
+//----------------------------------------------------------------------------
+void
+SVTK_RenderWindowInteractor
+::Initialize()
+{
+ myInteractor->Initialize();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_RenderWindowInteractor
+::UpdateSize(int w, int h)
+{
+ myInteractor->UpdateSize(w,h);
+}
//----------------------------------------------------------------------------
int
SVTK_RenderWindowInteractor
::mouseMoveEvent( QMouseEvent* event )
{
- //cout << "SVTK_RenderWindowInteractor::mouseMoveEvent" << endl;
-
myInteractor->SetEventInformation( event->x(), event->y(),
( event->state() & ControlButton ),
( event->state() & ShiftButton ) );
myInteractor->MouseMoveEvent();
-
- //emit MouseMove( event ) ;
}
//----------------------------------------------------------------------------
SVTK_RenderWindowInteractor
::mousePressEvent( QMouseEvent* event )
{
- //cout << "SVTK_RenderWindowInteractor::mousePressEvent" << endl;
-
myInteractor->SetEventInformation( event->x(), event->y(),
( event->state() & ControlButton ),
( event->state() & ShiftButton ) );
-
if( event->button() & LeftButton )
myInteractor->LeftButtonPressEvent();
else if( event->button() & MidButton )
myInteractor->MiddleButtonPressEvent();
else if( event->button() & RightButton )
myInteractor->RightButtonPressEvent();
-
- //emit MouseButtonPressed( event );
}
//----------------------------------------------------------------------------
SVTK_RenderWindowInteractor
::mouseReleaseEvent( QMouseEvent *event )
{
- //cout << "SVTK_RenderWindowInteractor::mouseReleaseEvent" << endl;
-
myInteractor->SetEventInformation( event->x(), event->y(),
( event->state() & ControlButton ),
( event->state() & ShiftButton ) );
myInteractor->MiddleButtonReleaseEvent();
else if( event->button() & RightButton )
myInteractor->RightButtonReleaseEvent();
-
- //emit MouseButtonReleased( event );
}
//----------------------------------------------------------------------------
void
SVTK_RenderWindowInteractor
::mouseDoubleClickEvent( QMouseEvent* event )
-{
- //cout << "SVTK_RenderWindowInteractor::mouseDoubleClickEvent" << endl;
-
- //emit MouseDoubleClicked( event );
-}
+{}
//----------------------------------------------------------------------------
void
SVTK_RenderWindowInteractor
::keyPressEvent( QKeyEvent* event )
{
- //cout << "SVTK_RenderWindowInteractor::keyPressEvent" << endl;
-
myInteractor->SetKeyEventInformation( ( event->state() & ControlButton ),
( event->state() & ShiftButton ),
0 );
-
myInteractor->KeyPressEvent();
-
- //emit KeyPressed(event) ;
}
//----------------------------------------------------------------------------
SVTK_RenderWindowInteractor
::keyReleaseEvent( QKeyEvent * event )
{
- //cout << "SVTK_RenderWindowInteractor::keyReleaseEvent" << endl;
-
myInteractor->SetKeyEventInformation( ( event->state() & ControlButton ),
( event->state() & ShiftButton ),
0 );
-
myInteractor->KeyReleaseEvent();
-
- //emit KeyReleased(event) ;
}
//----------------------------------------------------------------------------
void
SVTK_RenderWindowInteractor
::wheelEvent( QWheelEvent* event )
-{
- //cout << "SVTK_RenderWindowInteractor::wheelEvent" << endl;
-
- //emit WheelMoved(event) ;
-}
+{}
//----------------------------------------------------------------------------
void
SVTK_RenderWindowInteractor
-::contextMenuEvent( QContextMenuEvent* event )
+::paintEvent( QPaintEvent* theEvent )
{
- //cout << "SVTK_RenderWindowInteractor::contextMenuEvent" << endl;
-
- if( !( event->state() & KeyButtonMask ) )
- emit contextMenuRequested( event );
+ getRenderWindow()->Render();
}
//----------------------------------------------------------------------------
void
SVTK_RenderWindowInteractor
-::paintEvent( QPaintEvent* theEvent )
+::contextMenuEvent( QContextMenuEvent* event )
{
- getRenderWindow()->Render();
+ if( !( event->state() & KeyButtonMask ) )
+ emit contextMenuRequested( event );
}
//----------------------------------------------------------------------------
#include "SALOME_InteractiveObject.hxx"
-// QT Includes
-#include <qtimer.h>
-
// VTK Includes
-#include <vtkVersion.h>
+#include <vtkGenericRenderWindowInteractor.h>
+
+class QTimer;
class vtkActorCollection;
class vtkGenericRenderWindowInteractor;
// Hence the order of the two classes QObject and vtkRenderWindowInteractor
// matters here. Be careful not to change it by accident.
// ------------------------------------------------------------
-class SVTK_EXPORT SVTK_RenderWindowInteractor: public SVTK_RenderWindow//, public vtkRenderWindowInteractor
+class SVTK_EXPORT QtRenderWindowInteractor:
+ public QObject,
+ public vtkGenericRenderWindowInteractor
{
- Q_OBJECT
+ Q_OBJECT;
+
+ protected slots:
+ virtual
+ void
+ OnTimeOut();
+
+ protected:
+ QtRenderWindowInteractor();
+ ~QtRenderWindowInteractor();
+
+ QTimer* myTimer ;
+
+ public:
+
+ static QtRenderWindowInteractor* New();
+ vtkTypeMacro(QtRenderWindowInteractor,vtkGenericRenderWindowInteractor);
+
+ virtual int CreateTimer( int ) ;
+ virtual int DestroyTimer() ;
+};
+
-public:
+// ------------------------------------------------------------
+class SVTK_EXPORT SVTK_RenderWindowInteractor: public SVTK_RenderWindow
+{
+ Q_OBJECT;
+
+ public:
SVTK_RenderWindowInteractor( QWidget*, const char* );
~SVTK_RenderWindowInteractor();
- vtkGenericRenderWindowInteractor* getInteractor() { return myInteractor; }
+ vtkRenderWindowInteractor* getInteractor() { return myInteractor; }
// Description:
// Initializes the event handlers without an XtAppContext. This is
// Event loop notification member for Window size change
virtual void UpdateSize(int x,int y);
- // Description:
- // Timer methods must be overridden by platform dependent subclasses.
- // flag is passed to indicate if this is first timer set or an update
- // as Win32 uses repeating timers, whereas X uses One shot more timer
- // if flag==VTKXI_TIMER_FIRST Win32 and X should createtimer
- // otherwise Win32 should exit and X should perform AddTimeOut()
- virtual int CreateTimer(int ) ;
- virtual int DestroyTimer() ;
-
/* Selection Management */
bool isInViewer( const Handle(SALOME_InteractiveObject)& IObject);
bool isVisible( const Handle(SALOME_InteractiveObject)& IObject);
protected:
vtkGenericRenderWindowInteractor* myInteractor;
- // Timer used during various mouse events to figure
- // out mouse movements.
- QTimer *mTimer ;
-
int myDisplayMode;
-
- // User for switching to stereo mode.
- int PositionBeforeStereo[2];
protected:
virtual void mouseMoveEvent( QMouseEvent* );
virtual void wheelEvent( QWheelEvent* );
virtual void keyPressEvent( QKeyEvent* );
virtual void keyReleaseEvent( QKeyEvent* );
- virtual void contextMenuEvent( QContextMenuEvent * e );
virtual bool x11Event( XEvent *e );
virtual void paintEvent( QPaintEvent* );
virtual void focusInEvent ( QFocusEvent* );
virtual void focusOutEvent( QFocusEvent* );
- private slots:
- // Not all of these slots are needed in VTK_MAJOR_VERSION=3,
- // but moc does not understand "#if VTK_MAJOR_VERSION". Hence,
- // we have to include all of these for the time being. Once,
- // this bug in MOC is fixed, we can separate these.
- void TimerFunc() ;
+ virtual void contextMenuEvent( QContextMenuEvent * e );
signals:
void contextMenuRequested( QContextMenuEvent *e );
-
};