Version: 6.3.1

src/VTKViewer/VTKViewer_RenderWindowInteractor.h

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  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 #ifndef VTKVIEWER_RENDERWINDOWINTERACTOR_H
00024 #define VTKVIEWER_RENDERWINDOWINTERACTOR_H
00025 
00026 #include "VTKViewer.h"
00027 #include "VTKViewer_Actor.h"
00028 
00029 #include <QObject>
00030 
00031 class QTimer;
00032 class QMouseEvent;
00033 class QKeyEvent;
00034 class QContextMenuEvent;
00035 
00036 // Open CASCADE Includes
00037 #include <TColStd_MapOfInteger.hxx>
00038 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
00039 #include <TColStd_IndexedMapOfInteger.hxx>
00040 
00041 class vtkPicker;
00042 class vtkCellPicker;
00043 class vtkPointPicker;
00044 class vtkActorCollection;
00045 
00046 class VTKViewer_Actor;
00047 class VTKViewer_ViewWindow;
00048 class VTKViewer_RenderWindow;
00049 class VTKViewer_InteractorStyle;
00050 
00051 #include "VTKViewer_Algorithm.h"
00052 
00053 #include <vtkActor.h>
00054 #include <vtkVersion.h>
00055 #include <vtkRenderWindowInteractor.h>
00056 
00057 class VTKVIEWER_EXPORT VTKViewer_RenderWindowInteractor : public QObject, public vtkRenderWindowInteractor
00058 {
00059   Q_OBJECT
00060 
00061 public:
00062   static VTKViewer_RenderWindowInteractor *New();
00063 
00064   vtkTypeMacro(VTKViewer_RenderWindowInteractor,vtkRenderWindowInteractor);
00065 
00066   void PrintSelf(ostream& os, vtkIndent indent);
00067 
00068   virtual void Initialize();
00069 
00070   virtual void               SetInteractorStyle(vtkInteractorObserver *);
00072   VTKViewer_InteractorStyle* GetInteractorStyle() const
00073   {
00074     return myInteractorStyle;
00075   }
00076 
00077   virtual void Start();
00078   
00079   virtual void Enable();
00080   virtual void Disable();
00081 
00082   virtual void UpdateSize(int x,int y);
00083 
00086   virtual int CreateTimer(int ) ;
00087   virtual int DestroyTimer() ; 
00089   
00095   virtual void TerminateApp(void) { /* empty */ }
00096   
00097   // Description:
00098   // These methods correspond to the the Exit, User and Pick
00099   // callbacks. They allow for the Style to invoke them.
00100   //virtual void ExitCallback();
00101   //virtual void UserCallback();
00102   //virtual void StartPickCallback();
00103   //virtual void EndPickCallback();
00104   
00107   bool highlightCell(const TColStd_IndexedMapOfInteger& MapIndex,
00108                      VTKViewer_Actor* theMapActor,
00109                      bool hilight,
00110                      bool update = true );
00111   bool highlightEdge(const TColStd_IndexedMapOfInteger& MapIndex,
00112                      VTKViewer_Actor* theMapActor,
00113                      bool hilight,
00114                      bool update = true );
00115   bool highlightPoint(const TColStd_IndexedMapOfInteger& MapIndex,
00116                       VTKViewer_Actor* theMapActor,
00117                       bool hilight,
00118                       bool update = true );
00119 
00120   void unHighlightSubSelection();
00121   bool unHighlightAll();
00122 
00123   //void SetSelectionMode(Selection_Mode mode);
00124   void SetSelectionProp(const double& theRed = 1, const double& theGreen = 1,
00125                         const double& theBlue = 0, const int& theWidth = 5);
00126   void SetSelectionTolerance(const double& theTolNodes = 0.025, const double& theTolCell = 0.001);
00128 
00131   int GetDisplayMode();
00132   void SetDisplayMode(int);
00134 
00137   void ChangeRepresentationToWireframe();
00138   void ChangeRepresentationToSurface();
00140 
00143   void ChangeRepresentationToWireframe(vtkActorCollection* ListofActors);
00144   void ChangeRepresentationToSurface(vtkActorCollection* ListofActors);
00146 
00149   void EraseAll();
00150   void DisplayAll();
00151   void RemoveAll( const bool immediatly );
00152 
00153   void Display( VTKViewer_Actor* SActor, bool immediatly = true );
00154   void Erase( VTKViewer_Actor* SActor, bool immediatly = true );
00155   void Remove( VTKViewer_Actor* SActor, bool updateViewer = true );
00157 
00158   void Update();
00159 
00160   vtkRenderer* GetRenderer();
00161 
00162   void setViewWindow( VTKViewer_ViewWindow* theViewWnd );
00163 
00164   void setCellData(const int& theIndex,
00165                    VTKViewer_Actor* theMapActor,
00166                    VTKViewer_Actor* theActor) {}
00167   void setEdgeData(const int& theCellIndex,
00168                    VTKViewer_Actor* theMapActor,
00169                    const int& theEdgeIndex,
00170                    VTKViewer_Actor* theActor ) {} //NB
00171   void setPointData(const int& theIndex,
00172                     VTKViewer_Actor* theMapActor,
00173                     VTKViewer_Actor* theActor) {}
00174 
00175   typedef void (*TUpdateActor)(const TColStd_IndexedMapOfInteger& theMapIndex,
00176                                VTKViewer_Actor* theMapActor,
00177                                VTKViewer_Actor* theActor);
00178  protected:
00179 
00180   VTKViewer_RenderWindowInteractor();
00181   ~VTKViewer_RenderWindowInteractor();
00182 
00183   VTKViewer_InteractorStyle* myInteractorStyle;
00184 
00185   bool highlight(const TColStd_IndexedMapOfInteger& theMapIndex,
00186                  VTKViewer_Actor* theMapActor, VTKViewer_Actor* theActor,
00187                  TUpdateActor theFun, bool hilight, bool update);
00188   void setActorData(const TColStd_IndexedMapOfInteger& theMapIndex,
00189                     VTKViewer_Actor* theMapActor,
00190                     VTKViewer_Actor *theActor,
00191                     TUpdateActor theFun);
00192 
00196   QTimer *mTimer ;
00197 
00198   int myDisplayMode;
00199 
00200   //NRI: Selection mode
00201   VTKViewer_Actor* myPointActor;
00202   VTKViewer_Actor* myEdgeActor;
00203   VTKViewer_Actor* myCellActor;
00204   void MoveInternalActors();
00205 
00206   vtkPicker* myBasicPicker;
00207   vtkCellPicker* myCellPicker;
00208   vtkPointPicker* myPointPicker;
00209   
00211   int PositionBeforeStereo[2];
00212 
00213  public slots:
00214   void MouseMove(QMouseEvent *event) ;
00215   void LeftButtonPressed(const QMouseEvent *event) ;
00216   void LeftButtonReleased(const QMouseEvent *event) ;
00217   void MiddleButtonPressed(const QMouseEvent *event) ;
00218   void MiddleButtonReleased(const QMouseEvent *event) ;
00219   void RightButtonPressed(const QMouseEvent *event) ;
00220   void RightButtonReleased(const QMouseEvent *event) ;
00221   void ButtonPressed(const QMouseEvent *event) ;
00222   void ButtonReleased(const QMouseEvent *event) ;
00223   void KeyPressed(QKeyEvent *event) ;
00224 
00225   private slots:
00226     void TimerFunc() ;
00227 
00228 signals:
00229   void RenderWindowModified() ;
00230   void contextMenuRequested( QContextMenuEvent *e );
00231 
00232 private:
00233   friend class VTKViewer_ViewWindow;
00234 
00235   VTKViewer_ViewWindow* myViewWnd;
00237   double       myTolNodes;
00239   double       myTolItems;
00240 };
00241 
00242 #endif
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS