Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
VTKViewer_RenderWindowInteractor.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 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 #ifndef VTKVIEWER_RENDERWINDOWINTERACTOR_H
24 #define VTKVIEWER_RENDERWINDOWINTERACTOR_H
25 
26 #include "VTKViewer.h"
27 #include "VTKViewer_Actor.h"
28 
29 #include <QObject>
30 
31 class QTimer;
32 class QMouseEvent;
33 class QKeyEvent;
34 class QContextMenuEvent;
35 
36 // Open CASCADE Includes
37 #include <TColStd_MapOfInteger.hxx>
38 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
39 #include <TColStd_IndexedMapOfInteger.hxx>
40 
41 class vtkPicker;
42 class vtkCellPicker;
43 class vtkPointPicker;
44 class vtkActorCollection;
45 
46 class VTKViewer_Actor;
50 
51 #include "VTKViewer_Algorithm.h"
52 
53 #include <vtkActor.h>
54 #include <vtkVersion.h>
55 #include <vtkRenderWindowInteractor.h>
56 
58 {
59  Q_OBJECT
60 
61 public:
63 
65 
66  void PrintSelf(ostream& os, vtkIndent indent);
67 
68  virtual void Initialize();
69 
70  virtual void SetInteractorStyle(vtkInteractorObserver *);
72  VTKViewer_InteractorStyle* GetInteractorStyle() const
73  {
74  return myInteractorStyle;
75  }
76 
77  virtual void Start();
78 
79  virtual void Enable();
80  virtual void Disable();
81 
82  virtual void UpdateSize(int x,int y);
83 
86  virtual int CreateTimer(int ) ;
87  virtual int DestroyTimer() ;
89 
95  virtual void TerminateApp(void) { /* empty */ }
96 
97  // Description:
98  // These methods correspond to the the Exit, User and Pick
99  // callbacks. They allow for the Style to invoke them.
100  //virtual void ExitCallback();
101  //virtual void UserCallback();
102  //virtual void StartPickCallback();
103  //virtual void EndPickCallback();
104 
107  bool highlightCell(const TColStd_IndexedMapOfInteger& MapIndex,
108  VTKViewer_Actor* theMapActor,
109  bool hilight,
110  bool update = true );
111  bool highlightEdge(const TColStd_IndexedMapOfInteger& MapIndex,
112  VTKViewer_Actor* theMapActor,
113  bool hilight,
114  bool update = true );
115  bool highlightPoint(const TColStd_IndexedMapOfInteger& MapIndex,
116  VTKViewer_Actor* theMapActor,
117  bool hilight,
118  bool update = true );
119 
120  void unHighlightSubSelection();
121  bool unHighlightAll();
122 
123  //void SetSelectionMode(Selection_Mode mode);
124  void SetSelectionProp(const double& theRed = 1, const double& theGreen = 1,
125  const double& theBlue = 0, const int& theWidth = 5);
126  void SetSelectionTolerance(const double& theTolNodes = 0.025, const double& theTolCell = 0.001);
128 
131  int GetDisplayMode();
132  void SetDisplayMode(int);
134 
137  void ChangeRepresentationToWireframe();
138  void ChangeRepresentationToSurface();
139  void ChangeRepresentationToSurfaceWithEdges();
141 
144  void ChangeRepresentationToWireframe(vtkActorCollection* ListofActors);
145  void ChangeRepresentationToSurface(vtkActorCollection* ListofActors);
146  void ChangeRepresentationToSurfaceWithEdges(vtkActorCollection* ListofActors);
148 
151  void EraseAll();
152  void DisplayAll();
153  void RemoveAll( const bool immediatly );
154 
155  void Display( VTKViewer_Actor* SActor, bool immediatly = true );
156  void Erase( VTKViewer_Actor* SActor, bool immediatly = true );
157  void Remove( VTKViewer_Actor* SActor, bool updateViewer = true );
159 
160  void Update();
161 
162  vtkRenderer* GetRenderer();
163 
164  void setViewWindow( VTKViewer_ViewWindow* theViewWnd );
165 
166  void setCellData(const int& theIndex,
167  VTKViewer_Actor* theMapActor,
168  VTKViewer_Actor* theActor) {}
169  void setEdgeData(const int& theCellIndex,
170  VTKViewer_Actor* theMapActor,
171  const int& theEdgeIndex,
172  VTKViewer_Actor* theActor ) {} //NB
173  void setPointData(const int& theIndex,
174  VTKViewer_Actor* theMapActor,
175  VTKViewer_Actor* theActor) {}
176 
177  typedef void (*TUpdateActor)(const TColStd_IndexedMapOfInteger& theMapIndex,
178  VTKViewer_Actor* theMapActor,
179  VTKViewer_Actor* theActor);
180  protected:
181 
184 
186 
187  bool highlight(const TColStd_IndexedMapOfInteger& theMapIndex,
188  VTKViewer_Actor* theMapActor, VTKViewer_Actor* theActor,
189  TUpdateActor theFun, bool hilight, bool update);
190  void setActorData(const TColStd_IndexedMapOfInteger& theMapIndex,
191  VTKViewer_Actor* theMapActor,
192  VTKViewer_Actor *theActor,
193  TUpdateActor theFun);
194 
198  QTimer *mTimer ;
199 
201 
202  //NRI: Selection mode
206  void MoveInternalActors();
207 
208  vtkPicker* myBasicPicker;
209  vtkCellPicker* myCellPicker;
210  vtkPointPicker* myPointPicker;
211 
213  int PositionBeforeStereo[2];
214 
215  public slots:
216  void MouseMove(QMouseEvent *event) ;
217  void LeftButtonPressed(const QMouseEvent *event) ;
218  void LeftButtonReleased(const QMouseEvent *event) ;
219  void MiddleButtonPressed(const QMouseEvent *event) ;
220  void MiddleButtonReleased(const QMouseEvent *event) ;
221  void RightButtonPressed(const QMouseEvent *event) ;
222  void RightButtonReleased(const QMouseEvent *event) ;
223  void ButtonPressed(const QMouseEvent *event) ;
224  void ButtonReleased(const QMouseEvent *event) ;
225  void KeyPressed(QKeyEvent *event) ;
226 
227  private slots:
228  void TimerFunc() ;
229 
230 signals:
231  void RenderWindowModified() ;
232  void contextMenuRequested( QContextMenuEvent *e );
233 
234 private:
235  friend class VTKViewer_ViewWindow;
236 
239  double myTolNodes;
241  double myTolItems;
242 };
243 
244 #endif