Back to index

salome-gui  6.5.0
SVTK_GenericRenderWindowInteractor.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SALOME VTKViewer : build VTK viewer into Salome desktop
00024 //  File   : 
00025 //  Author : 
00026 
00027 #include "SVTK_GenericRenderWindowInteractor.h"
00028 #include "SVTK_Selector.h"
00029 
00030 #include <vtkObjectFactory.h>
00031 #include <vtkCommand.h>
00032 
00033 #include <QTimer>
00034 
00035 vtkStandardNewMacro(QVTK_GenericRenderWindowInteractor);
00036 
00040 QVTK_GenericRenderWindowInteractor
00041 ::QVTK_GenericRenderWindowInteractor()
00042 {
00043   myTimer = new QTimer( ) ;
00044   connect(myTimer, SIGNAL(timeout()), this, SLOT(OnTimeOut())) ;
00045 }
00046 
00050 QVTK_GenericRenderWindowInteractor
00051 ::~QVTK_GenericRenderWindowInteractor()
00052 {
00053   delete myTimer;
00054 }
00055 
00059 void
00060 QVTK_GenericRenderWindowInteractor
00061 ::OnTimeOut() 
00062 {
00063   if( GetEnabled() ) {
00064     this->InvokeEvent(vtkCommand::TimerEvent,NULL);
00065   }
00066 }
00067 
00071 int
00072 QVTK_GenericRenderWindowInteractor
00073 ::CreateTimer(int vtkNotUsed(timertype)) 
00074 {
00075   //
00076   // Start a one-shot timer for <DELAY> ms. 
00077   //
00078   static int DELAY = 1;
00079   myTimer->setSingleShot(TRUE);
00080   myTimer->start(DELAY);
00081   return 1;
00082 }
00083 
00087 int
00088 QVTK_GenericRenderWindowInteractor
00089 ::DestroyTimer(void) 
00090 {
00091   //
00092   // :TRICKY: Tue May  2 00:17:32 2000 Pagey
00093   //
00094   // QTimer will automatically expire after 10ms. So 
00095   // we do not need to do anything here. In fact, we 
00096   // should not even Stop() the QTimer here because doing 
00097   // this will skip some of the processing that the TimerFunc()
00098   // does and will result in undesirable effects. For 
00099   // example, this will result in vtkLODActor to leave
00100   // the models in low-res mode after the mouse stops
00101   // moving. 
00102   //
00103   return 1;
00104 }
00105 
00106 
00107 vtkStandardNewMacro(SVTK_GenericRenderWindowInteractor);
00108 
00112 SVTK_GenericRenderWindowInteractor
00113 ::SVTK_GenericRenderWindowInteractor():
00114   myRenderWidget(NULL)
00115 {
00116 }
00117 
00121 SVTK_GenericRenderWindowInteractor
00122 ::~SVTK_GenericRenderWindowInteractor()
00123 {
00124 }
00125 
00129 SVTK_Selector*
00130 SVTK_GenericRenderWindowInteractor
00131 ::GetSelector()
00132 {
00133   return mySelector;
00134 }
00135 
00140 void
00141 SVTK_GenericRenderWindowInteractor
00142 ::SetSelector(SVTK_Selector* theSelector)
00143 {
00144   mySelector = theSelector;
00145 }
00146 
00150 QWidget*
00151 SVTK_GenericRenderWindowInteractor
00152 ::GetRenderWidget()
00153 {
00154   return myRenderWidget;
00155 }
00156 
00160 void
00161 SVTK_GenericRenderWindowInteractor
00162 ::SetRenderWidget(QWidget* theRenderWidget)
00163 {
00164   myRenderWidget = theRenderWidget;
00165 }