1 #ifndef VTKVIEWER_RENDERWINDOWINTERACTOR_H
2 #define VTKVIEWER_RENDERWINDOWINTERACTOR_H
5 #include "VTKViewer_Actor.h"
10 // Open CASCADE Includes
11 #include <TColStd_MapOfInteger.hxx>
12 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
13 #include <TColStd_IndexedMapOfInteger.hxx>
18 class vtkActorCollection;
20 class VTKViewer_Actor;
21 class VTKViewer_ViewWindow;
22 class VTKViewer_RenderWindow;
23 class VTKViewer_InteractorStyle;
25 #include "VTKViewer_Algorithm.h"
28 #include <vtkVersion.h>
29 #include <vtkRenderWindowInteractor.h>
31 class VTKVIEWER_EXPORT VTKViewer_RenderWindowInteractor : public QObject, public vtkRenderWindowInteractor
36 static VTKViewer_RenderWindowInteractor *New();
38 vtkTypeMacro(VTKViewer_RenderWindowInteractor,vtkRenderWindowInteractor);
40 void PrintSelf(ostream& os, vtkIndent indent);
42 virtual void Initialize();
44 virtual void SetInteractorStyle(vtkInteractorObserver *);
45 /*!Return interactor style pointer.*/
46 VTKViewer_InteractorStyle* GetInteractorStyle() const
48 return myInteractorStyle;
53 virtual void Enable();
54 virtual void Disable();
56 virtual void UpdateSize(int x,int y);
58 /** @name Timer options*/
60 virtual int CreateTimer(int ) ;
61 virtual int DestroyTimer() ;
65 * This function is called on 'q','e' keypress if exitmethod is not\n
66 * specified and should be overidden by platform dependent subclasses\n
67 * to provide a termination procedure if one is required.
69 virtual void TerminateApp(void) { /* empty */ }
72 // These methods correspond to the the Exit, User and Pick
73 // callbacks. They allow for the Style to invoke them.
74 //virtual void ExitCallback();
75 //virtual void UserCallback();
76 //virtual void StartPickCallback();
77 //virtual void EndPickCallback();
79 /** @name Selection Management */
81 bool highlightCell(const TColStd_IndexedMapOfInteger& MapIndex,
82 VTKViewer_Actor* theMapActor,
85 bool highlightEdge(const TColStd_IndexedMapOfInteger& MapIndex,
86 VTKViewer_Actor* theMapActor,
89 bool highlightPoint(const TColStd_IndexedMapOfInteger& MapIndex,
90 VTKViewer_Actor* theMapActor,
94 void unHighlightSubSelection();
95 bool unHighlightAll();
97 //void SetSelectionMode(Selection_Mode mode);
98 void SetSelectionProp(const double& theRed = 1, const double& theGreen = 1,
99 const double& theBlue = 0, const int& theWidth = 5);
100 void SetSelectionTolerance(const double& theTolNodes = 0.025, const double& theTolCell = 0.001);
103 /** @name Displaymode management*/
105 int GetDisplayMode();
106 void SetDisplayMode(int);
109 /** @name Change all actors to wireframe or surface*/
111 void ChangeRepresentationToWireframe();
112 void ChangeRepresentationToSurface();
115 /** @name Change to wireframe or surface a list of vtkactor*/
117 void ChangeRepresentationToWireframe(vtkActorCollection* ListofActors);
118 void ChangeRepresentationToSurface(vtkActorCollection* ListofActors);
121 /** @name Erase Display functions*/
125 void RemoveAll( const bool immediatly );
127 void Display( VTKViewer_Actor* SActor, bool immediatly = true );
128 void Erase( VTKViewer_Actor* SActor, bool immediatly = true );
129 void Remove( VTKViewer_Actor* SActor, bool updateViewer = true );
134 vtkRenderer* GetRenderer();
136 void setViewWindow( VTKViewer_ViewWindow* theViewWnd );
138 void setCellData(const int& theIndex,
139 VTKViewer_Actor* theMapActor,
140 VTKViewer_Actor* theActor) {}
141 void setEdgeData(const int& theCellIndex,
142 VTKViewer_Actor* theMapActor,
143 const int& theEdgeIndex,
144 VTKViewer_Actor* theActor ) {} //NB
145 void setPointData(const int& theIndex,
146 VTKViewer_Actor* theMapActor,
147 VTKViewer_Actor* theActor) {}
149 typedef void (*TUpdateActor)(const TColStd_IndexedMapOfInteger& theMapIndex,
150 VTKViewer_Actor* theMapActor,
151 VTKViewer_Actor* theActor);
154 VTKViewer_RenderWindowInteractor();
155 ~VTKViewer_RenderWindowInteractor();
157 VTKViewer_InteractorStyle* myInteractorStyle;
159 bool highlight(const TColStd_IndexedMapOfInteger& theMapIndex,
160 VTKViewer_Actor* theMapActor, VTKViewer_Actor* theActor,
161 TUpdateActor theFun, bool hilight, bool update);
162 void setActorData(const TColStd_IndexedMapOfInteger& theMapIndex,
163 VTKViewer_Actor* theMapActor,
164 VTKViewer_Actor *theActor,
165 TUpdateActor theFun);
167 /*! Timer used during various mouse events to figure
168 * out mouse movements.
174 //NRI: Selection mode
175 VTKViewer_Actor* myPointActor;
176 VTKViewer_Actor* myEdgeActor;
177 VTKViewer_Actor* myCellActor;
178 void MoveInternalActors();
180 vtkPicker* myBasicPicker;
181 vtkCellPicker* myCellPicker;
182 vtkPointPicker* myPointPicker;
184 /*! User for switching to stereo mode.*/
185 int PositionBeforeStereo[2];
188 void MouseMove(QMouseEvent *event) ;
189 void LeftButtonPressed(const QMouseEvent *event) ;
190 void LeftButtonReleased(const QMouseEvent *event) ;
191 void MiddleButtonPressed(const QMouseEvent *event) ;
192 void MiddleButtonReleased(const QMouseEvent *event) ;
193 void RightButtonPressed(const QMouseEvent *event) ;
194 void RightButtonReleased(const QMouseEvent *event) ;
195 void ButtonPressed(const QMouseEvent *event) ;
196 void ButtonReleased(const QMouseEvent *event) ;
197 void KeyPressed(QKeyEvent *event) ;
203 void RenderWindowModified() ;
204 void contextMenuRequested( QContextMenuEvent *e );
207 friend class VTKViewer_ViewWindow;
209 VTKViewer_ViewWindow* myViewWnd;
210 /** Selection node tolerance.*/
212 /** Selection cell tolerance.*/