Salome HOME
Merge from OCC_development_generic_2006
[modules/gui.git] / src / SVTK / SVTK_GenericRenderWindowInteractor.h
1 //  SALOME VTKViewer : build VTK viewer into Salome desktop
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : 
25 //  Author : 
26 //  Module : SALOME
27 //  $Header$
28
29 #ifndef SVTK_GenericRenderWindowInteractor_h
30 #define SVTK_GenericRenderWindowInteractor_h
31
32 #include "SVTK.h"
33
34 #include <qobject.h>
35 #include <vtkGenericRenderWindowInteractor.h>
36 #include <vtkSmartPointer.h>
37
38 class QTimer;
39 class QWidget;
40
41 class SVTK_Selector;
42 class SVTK_Renderer;
43
44
45 //============================================================================
46 //! Introduction of the class is intended to implement Qt based #CreateTimer and #DestroyTimer functionality.
47 /*!
48   The class intendes to implement platform indepenedant subclass of vtkRenderWindowInteractor.
49   This is done by usage of Qt library.
50   \note
51   The Signal/Slot mechanism used by Qt requires that QObject 
52   appear as the first class when using multiple inheritance. 
53   Hence the order of the two classes QObject and vtkRenderWindowInteractor
54   matters here. So, be careful, not to change the sequence of the inheritance by accident. 
55 */
56 class SVTK_EXPORT QVTK_GenericRenderWindowInteractor: 
57  public QObject,
58  public vtkGenericRenderWindowInteractor
59 {
60   Q_OBJECT;
61
62  public:
63   static QVTK_GenericRenderWindowInteractor* New();
64   vtkTypeMacro(QVTK_GenericRenderWindowInteractor,vtkGenericRenderWindowInteractor);
65
66   //! Starts the QTimer instance on defined microseconds
67   virtual
68   int
69   CreateTimer( int ) ; 
70
71   //! Stops the QTimer instance
72   virtual
73   int
74   DestroyTimer() ; 
75
76  protected slots:
77   //! The slot connects to QTimer::timeout signal to invoke vtkCommand::TimerEvent
78   void
79   OnTimeOut();
80
81  protected:
82   QVTK_GenericRenderWindowInteractor(); //!< Instatiate QTimer
83   ~QVTK_GenericRenderWindowInteractor(); //!< Destroy the instance of QTimer
84
85   QTimer* myTimer; //!< Qt timer device
86 };
87
88
89 //============================================================================
90 //! This class introduce SALOME specific to the base one
91 /*!
92   In this class new members is added (#mySelector and #myRenderWidget).
93   They are used for initialization of #SVTK_InteractorStyle by redefinition of
94   #SVTK_InteractorStyle::SetInteractor method
95 */
96 class SVTK_EXPORT SVTK_GenericRenderWindowInteractor: public QVTK_GenericRenderWindowInteractor
97 {
98  public:
99   static SVTK_GenericRenderWindowInteractor* New();
100   vtkTypeMacro(SVTK_GenericRenderWindowInteractor,QVTK_GenericRenderWindowInteractor);
101
102   //! To get access to SVTK_Selector
103   SVTK_Selector* 
104   GetSelector(); 
105
106   //! To initialize mySelector field
107   void
108   SetSelector(SVTK_Selector* theSelector);
109
110   //! To get access to QWidget, where vtkRenderWindow maps to.
111   QWidget*
112   GetRenderWidget();
113
114   //! To initialize myRenderWidget field.
115   void
116   SetRenderWidget(QWidget* theRenderWidget);
117
118  protected:
119   SVTK_GenericRenderWindowInteractor();
120   ~SVTK_GenericRenderWindowInteractor();
121
122   vtkSmartPointer<SVTK_Selector> mySelector; //!< Keeps a pointer to SVTK_Selector
123   QWidget* myRenderWidget; //!< Keeps a pointer to QWidget, where vtkRenderWindow maps to.
124 };
125
126 #endif