Version: 9.16.0
VTKViewer_RenderWindowInteractor.h
Go to the documentation of this file.
1// Copyright (C) 2007-2026 CEA, EDF, 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
31class QTimer;
32class QMouseEvent;
33class QKeyEvent;
34class QContextMenuEvent;
35
36// Open CASCADE Includes
37#include <TColStd_MapOfInteger.hxx>
38#include <TColStd_MapIteratorOfMapOfInteger.hxx>
39#include <TColStd_IndexedMapOfInteger.hxx>
40
41class vtkPicker;
42class vtkCellPicker;
43class vtkPointPicker;
44class vtkActorCollection;
45
46class 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
61public:
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 TIndexedMapOfVtkId& MapIndex,
108 VTKViewer_Actor* theMapActor,
109 bool hilight,
110 bool update = true );
111 bool highlightEdge(const TIndexedMapOfVtkId& MapIndex,
112 VTKViewer_Actor* theMapActor,
113 bool hilight,
114 bool update = true );
115 bool highlightPoint(const TIndexedMapOfVtkId& 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 TIndexedMapOfVtkId& theMapIndex,
178 VTKViewer_Actor* theMapActor,
179 VTKViewer_Actor* theActor);
180 protected:
181
184
186
187 bool highlight(const TIndexedMapOfVtkId& theMapIndex,
188 VTKViewer_Actor* theMapActor, VTKViewer_Actor* theActor,
189 TUpdateActor theFun, bool hilight, bool update);
190 void setActorData(const TIndexedMapOfVtkId& 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
230signals:
232 void contextMenuRequested( QContextMenuEvent *e );
233
234private:
236
242};
243
244#endif
@ Disable
Definition: SVTK_InteractorStyle.h:150
@ Start
Definition: SVTK_InteractorStyle.h:150
#define VTKVIEWER_EXPORT
Definition: VTKViewer.h:33
NCollection_IndexedMap< vtkIdType, vtkIdHasher > TIndexedMapOfVtkId
Definition: VTKViewer_Actor.h:415
For more information see QT documentation.
Definition: VTKViewer_Actor.h:79
Definition: VTKViewer_InteractorStyle.h:72
Definition: VTKViewer_RenderWindowInteractor.h:58
VTKViewer_Actor * myEdgeActor
Definition: VTKViewer_RenderWindowInteractor.h:204
vtkCellPicker * myCellPicker
Definition: VTKViewer_RenderWindowInteractor.h:209
bool highlightCell(const TIndexedMapOfVtkId &MapIndex, VTKViewer_Actor *theMapActor, bool hilight, bool update=true)
vtkPointPicker * myPointPicker
Definition: VTKViewer_RenderWindowInteractor.h:210
VTKViewer_Actor * myCellActor
Definition: VTKViewer_RenderWindowInteractor.h:205
void setCellData(const int &, VTKViewer_Actor *, VTKViewer_Actor *)
Definition: VTKViewer_RenderWindowInteractor.h:166
QTimer * mTimer
Definition: VTKViewer_RenderWindowInteractor.h:198
vtkTypeMacro(VTKViewer_RenderWindowInteractor, vtkRenderWindowInteractor) void PrintSelf(ostream &os
vtkPicker * myBasicPicker
Definition: VTKViewer_RenderWindowInteractor.h:208
int myDisplayMode
Definition: VTKViewer_RenderWindowInteractor.h:200
double myTolNodes
Selection node tolerance.
Definition: VTKViewer_RenderWindowInteractor.h:239
double myTolItems
Selection cell tolerance.
Definition: VTKViewer_RenderWindowInteractor.h:241
VTKViewer_Actor * myPointActor
Definition: VTKViewer_RenderWindowInteractor.h:203
bool highlightEdge(const TIndexedMapOfVtkId &MapIndex, VTKViewer_Actor *theMapActor, bool hilight, bool update=true)
bool highlightPoint(const TIndexedMapOfVtkId &MapIndex, VTKViewer_Actor *theMapActor, bool hilight, bool update=true)
VTKViewer_ViewWindow * myViewWnd
Definition: VTKViewer_RenderWindowInteractor.h:237
virtual void TerminateApp(void)
Definition: VTKViewer_RenderWindowInteractor.h:95
void setEdgeData(const int &, VTKViewer_Actor *, const int &, VTKViewer_Actor *)
Definition: VTKViewer_RenderWindowInteractor.h:169
VTKViewer_InteractorStyle * myInteractorStyle
Definition: VTKViewer_RenderWindowInteractor.h:185
void setPointData(const int &, VTKViewer_Actor *, VTKViewer_Actor *)
Definition: VTKViewer_RenderWindowInteractor.h:173
void contextMenuRequested(QContextMenuEvent *e)
Definition: VTKViewer_RenderWindow.h:33
Definition: VTKViewer_ViewWindow.h:47