Salome HOME
Merge from OCC_development_generic_2006
[modules/gui.git] / src / SVTK / SVTK_GenericRenderWindowInteractor.cxx
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 #include "SVTK_GenericRenderWindowInteractor.h"
30 #include "SVTK_Selector.h"
31
32 #include <vtkObjectFactory.h>
33 #include <vtkCommand.h>
34
35 #include <qtimer.h>
36
37 using namespace std;
38
39 //----------------------------------------------------------------------------
40 vtkStandardNewMacro(QVTK_GenericRenderWindowInteractor);
41
42 QVTK_GenericRenderWindowInteractor
43 ::QVTK_GenericRenderWindowInteractor()
44 {
45   myTimer = new QTimer( ) ;
46   connect(myTimer, SIGNAL(timeout()), this, SLOT(OnTimeOut())) ;
47 }
48
49 QVTK_GenericRenderWindowInteractor
50 ::~QVTK_GenericRenderWindowInteractor()
51 {
52   delete myTimer;
53 }
54
55
56 //----------------------------------------------------------------------------
57 void
58 QVTK_GenericRenderWindowInteractor
59 ::OnTimeOut() 
60 {
61   if( GetEnabled() ) {
62     this->InvokeEvent(vtkCommand::TimerEvent,NULL);
63   }
64 }
65
66 int
67 QVTK_GenericRenderWindowInteractor
68 ::CreateTimer(int vtkNotUsed(timertype)) 
69 {
70   //
71   // Start a one-shot timer for <DELAY> ms. 
72   //
73   static int DELAY = 1;
74   myTimer->start(DELAY,TRUE);
75   return 1;
76 }
77
78 int
79 QVTK_GenericRenderWindowInteractor
80 ::DestroyTimer(void) 
81 {
82   //
83   // :TRICKY: Tue May  2 00:17:32 2000 Pagey
84   //
85   // QTimer will automatically expire after 10ms. So 
86   // we do not need to do anything here. In fact, we 
87   // should not even Stop() the QTimer here because doing 
88   // this will skip some of the processing that the TimerFunc()
89   // does and will result in undesirable effects. For 
90   // example, this will result in vtkLODActor to leave
91   // the models in low-res mode after the mouse stops
92   // moving. 
93   //
94   return 1;
95 }
96
97
98 //----------------------------------------------------------------------------
99 vtkStandardNewMacro(SVTK_GenericRenderWindowInteractor);
100
101 SVTK_GenericRenderWindowInteractor
102 ::SVTK_GenericRenderWindowInteractor():
103   myRenderWidget(NULL)
104 {
105 }
106
107 SVTK_GenericRenderWindowInteractor
108 ::~SVTK_GenericRenderWindowInteractor()
109 {
110 }
111
112 SVTK_Selector*
113 SVTK_GenericRenderWindowInteractor
114 ::GetSelector()
115 {
116   return mySelector.GetPointer();
117 }
118
119 void
120 SVTK_GenericRenderWindowInteractor
121 ::SetSelector(SVTK_Selector* theSelector)
122 {
123   mySelector = theSelector;
124 }
125
126 QWidget*
127 SVTK_GenericRenderWindowInteractor
128 ::GetRenderWidget()
129 {
130   return myRenderWidget;
131 }
132
133 void
134 SVTK_GenericRenderWindowInteractor
135 ::SetRenderWidget(QWidget* theRenderWidget)
136 {
137   myRenderWidget = theRenderWidget;
138 }