Salome HOME
updated copyright message
[modules/gui.git] / src / SVTK / SVTK_GenericRenderWindowInteractor.cxx
1 // Copyright (C) 2007-2023  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  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, or (at your option) any later version.
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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  SALOME VTKViewer : build VTK viewer into Salome desktop
24 //  File   : 
25 //  Author : 
26
27 #include "SVTK_GenericRenderWindowInteractor.h"
28 #include "SVTK_Selector.h"
29
30 #include <vtkObjectFactory.h>
31 #include <vtkCommand.h>
32
33 #include <QTimer>
34
35 vtkStandardNewMacro(QVTK_GenericRenderWindowInteractor)
36
37 /*!
38   Constructor
39 */
40 QVTK_GenericRenderWindowInteractor
41 ::QVTK_GenericRenderWindowInteractor()
42 {
43   myTimer = new QTimer( ) ;
44   connect(myTimer, SIGNAL(timeout()), this, SLOT(OnTimeOut())) ;
45 }
46
47 /*!
48   Destructor
49 */
50 QVTK_GenericRenderWindowInteractor
51 ::~QVTK_GenericRenderWindowInteractor()
52 {
53   delete myTimer;
54 }
55
56 /*!
57   The slot connects to QTimer::timeout signal to invoke vtkCommand::TimerEvent
58 */
59 void
60 QVTK_GenericRenderWindowInteractor
61 ::OnTimeOut() 
62 {
63   if( GetEnabled() ) {
64     this->InvokeEvent(vtkCommand::TimerEvent,NULL);
65   }
66 }
67
68 /*!
69   Starts the QTimer instance on defined microseconds
70 */
71 int
72 QVTK_GenericRenderWindowInteractor
73 ::CreateTimer(int vtkNotUsed(timertype)) 
74 {
75   //
76   // Start a one-shot timer for <DELAY> ms. 
77   //
78   static int DELAY = 1;
79   myTimer->setSingleShot(true);
80   myTimer->start(DELAY);
81   return 1;
82 }
83
84 /*!
85   Stops the QTimer instance
86 */
87 int
88 QVTK_GenericRenderWindowInteractor
89 ::DestroyTimer(void) 
90 {
91   //
92   // :TRICKY: Tue May  2 00:17:32 2000 Pagey
93   //
94   // QTimer will automatically expire after 10ms. So 
95   // we do not need to do anything here. In fact, we 
96   // should not even Stop() the QTimer here because doing 
97   // this will skip some of the processing that the TimerFunc()
98   // does and will result in undesirable effects. For 
99   // example, this will result in vtkLODActor to leave
100   // the models in low-res mode after the mouse stops
101   // moving. 
102   //
103   return 1;
104 }
105
106
107 vtkStandardNewMacro(SVTK_GenericRenderWindowInteractor)
108
109 /*!
110   Constructor
111 */
112 SVTK_GenericRenderWindowInteractor
113 ::SVTK_GenericRenderWindowInteractor():
114   myRenderWidget(NULL)
115 {
116 }
117
118 /*!
119   Destructor
120 */
121 SVTK_GenericRenderWindowInteractor
122 ::~SVTK_GenericRenderWindowInteractor()
123 {
124 }
125
126 /*!
127   To get access to SVTK_Selector
128 */
129 SVTK_Selector*
130 SVTK_GenericRenderWindowInteractor
131 ::GetSelector()
132 {
133   return mySelector;
134 }
135
136 /*!
137   To initialize mySelector field
138   \param theSelector - new selector
139 */
140 void
141 SVTK_GenericRenderWindowInteractor
142 ::SetSelector(SVTK_Selector* theSelector)
143 {
144   mySelector = theSelector;
145 }
146
147 /*!
148   To get access to QWidget, where vtkRenderWindow maps to.
149 */
150 QWidget*
151 SVTK_GenericRenderWindowInteractor
152 ::GetRenderWidget()
153 {
154   return myRenderWidget;
155 }
156
157 /*!
158   To initialize myRenderWidget field.
159 */
160 void
161 SVTK_GenericRenderWindowInteractor
162 ::SetRenderWidget(QWidget* theRenderWidget)
163 {
164   myRenderWidget = theRenderWidget;
165 }