1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #ifndef VTKVIEWER_RENDERWINDOWINTERACTOR_H
20 #define VTKVIEWER_RENDERWINDOWINTERACTOR_H
22 #include "VTKViewer.h"
23 #include "VTKViewer_Actor.h"
28 // Open CASCADE Includes
29 #include <TColStd_MapOfInteger.hxx>
30 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
31 #include <TColStd_IndexedMapOfInteger.hxx>
36 class vtkActorCollection;
38 class VTKViewer_Actor;
39 class VTKViewer_ViewWindow;
40 class VTKViewer_RenderWindow;
41 class VTKViewer_InteractorStyle;
43 #include "VTKViewer_Algorithm.h"
46 #include <vtkVersion.h>
47 #include <vtkRenderWindowInteractor.h>
49 class VTKVIEWER_EXPORT VTKViewer_RenderWindowInteractor : public QObject, public vtkRenderWindowInteractor
54 static VTKViewer_RenderWindowInteractor *New();
56 vtkTypeMacro(VTKViewer_RenderWindowInteractor,vtkRenderWindowInteractor);
58 void PrintSelf(ostream& os, vtkIndent indent);
60 virtual void Initialize();
62 virtual void SetInteractorStyle(vtkInteractorObserver *);
63 /*!Return interactor style pointer.*/
64 VTKViewer_InteractorStyle* GetInteractorStyle() const
66 return myInteractorStyle;
71 virtual void Enable();
72 virtual void Disable();
74 virtual void UpdateSize(int x,int y);
76 /** @name Timer options*/
78 virtual int CreateTimer(int ) ;
79 virtual int DestroyTimer() ;
83 * This function is called on 'q','e' keypress if exitmethod is not\n
84 * specified and should be overidden by platform dependent subclasses\n
85 * to provide a termination procedure if one is required.
87 virtual void TerminateApp(void) { /* empty */ }
90 // These methods correspond to the the Exit, User and Pick
91 // callbacks. They allow for the Style to invoke them.
92 //virtual void ExitCallback();
93 //virtual void UserCallback();
94 //virtual void StartPickCallback();
95 //virtual void EndPickCallback();
97 /** @name Selection Management */
99 bool highlightCell(const TColStd_IndexedMapOfInteger& MapIndex,
100 VTKViewer_Actor* theMapActor,
102 bool update = true );
103 bool highlightEdge(const TColStd_IndexedMapOfInteger& MapIndex,
104 VTKViewer_Actor* theMapActor,
106 bool update = true );
107 bool highlightPoint(const TColStd_IndexedMapOfInteger& MapIndex,
108 VTKViewer_Actor* theMapActor,
110 bool update = true );
112 void unHighlightSubSelection();
113 bool unHighlightAll();
115 //void SetSelectionMode(Selection_Mode mode);
116 void SetSelectionProp(const double& theRed = 1, const double& theGreen = 1,
117 const double& theBlue = 0, const int& theWidth = 5);
118 void SetSelectionTolerance(const double& theTolNodes = 0.025, const double& theTolCell = 0.001);
121 /** @name Displaymode management*/
123 int GetDisplayMode();
124 void SetDisplayMode(int);
127 /** @name Change all actors to wireframe or surface*/
129 void ChangeRepresentationToWireframe();
130 void ChangeRepresentationToSurface();
133 /** @name Change to wireframe or surface a list of vtkactor*/
135 void ChangeRepresentationToWireframe(vtkActorCollection* ListofActors);
136 void ChangeRepresentationToSurface(vtkActorCollection* ListofActors);
139 /** @name Erase Display functions*/
143 void RemoveAll( const bool immediatly );
145 void Display( VTKViewer_Actor* SActor, bool immediatly = true );
146 void Erase( VTKViewer_Actor* SActor, bool immediatly = true );
147 void Remove( VTKViewer_Actor* SActor, bool updateViewer = true );
152 vtkRenderer* GetRenderer();
154 void setViewWindow( VTKViewer_ViewWindow* theViewWnd );
156 void setCellData(const int& theIndex,
157 VTKViewer_Actor* theMapActor,
158 VTKViewer_Actor* theActor) {}
159 void setEdgeData(const int& theCellIndex,
160 VTKViewer_Actor* theMapActor,
161 const int& theEdgeIndex,
162 VTKViewer_Actor* theActor ) {} //NB
163 void setPointData(const int& theIndex,
164 VTKViewer_Actor* theMapActor,
165 VTKViewer_Actor* theActor) {}
167 typedef void (*TUpdateActor)(const TColStd_IndexedMapOfInteger& theMapIndex,
168 VTKViewer_Actor* theMapActor,
169 VTKViewer_Actor* theActor);
172 VTKViewer_RenderWindowInteractor();
173 ~VTKViewer_RenderWindowInteractor();
175 VTKViewer_InteractorStyle* myInteractorStyle;
177 bool highlight(const TColStd_IndexedMapOfInteger& theMapIndex,
178 VTKViewer_Actor* theMapActor, VTKViewer_Actor* theActor,
179 TUpdateActor theFun, bool hilight, bool update);
180 void setActorData(const TColStd_IndexedMapOfInteger& theMapIndex,
181 VTKViewer_Actor* theMapActor,
182 VTKViewer_Actor *theActor,
183 TUpdateActor theFun);
185 /*! Timer used during various mouse events to figure
186 * out mouse movements.
192 //NRI: Selection mode
193 VTKViewer_Actor* myPointActor;
194 VTKViewer_Actor* myEdgeActor;
195 VTKViewer_Actor* myCellActor;
196 void MoveInternalActors();
198 vtkPicker* myBasicPicker;
199 vtkCellPicker* myCellPicker;
200 vtkPointPicker* myPointPicker;
202 /*! User for switching to stereo mode.*/
203 int PositionBeforeStereo[2];
206 void MouseMove(QMouseEvent *event) ;
207 void LeftButtonPressed(const QMouseEvent *event) ;
208 void LeftButtonReleased(const QMouseEvent *event) ;
209 void MiddleButtonPressed(const QMouseEvent *event) ;
210 void MiddleButtonReleased(const QMouseEvent *event) ;
211 void RightButtonPressed(const QMouseEvent *event) ;
212 void RightButtonReleased(const QMouseEvent *event) ;
213 void ButtonPressed(const QMouseEvent *event) ;
214 void ButtonReleased(const QMouseEvent *event) ;
215 void KeyPressed(QKeyEvent *event) ;
221 void RenderWindowModified() ;
222 void contextMenuRequested( QContextMenuEvent *e );
225 friend class VTKViewer_ViewWindow;
227 VTKViewer_ViewWindow* myViewWnd;
228 /** Selection node tolerance.*/
230 /** Selection cell tolerance.*/