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);
43 // Initializes the event handlers without an XtAppContext. This is
44 // good for when you don`t have a user interface, but you still
45 // want to have mouse interaction.
46 virtual void Initialize();
48 virtual void SetInteractorStyle(vtkInteractorObserver *);
49 VTKViewer_InteractorStyle* GetInteractorStyle() const
51 return myInteractorStyle;
55 // This will start up the X event loop and never return. If you
56 // call this method it will loop processing X events until the
57 // application is exited.
61 // Enable/Disable interactions. By default interactors are enabled when
62 // initialized. Initialize() must be called prior to enabling/disabling
63 // interaction. These methods are used when a window/widget is being
64 // shared by multiple renderers and interactors. This allows a "modal"
65 // display where one interactor is active when its data is to be displayed
66 // and all other interactors associated with the widget are disabled
67 // when their data is not displayed.
68 virtual void Enable();
69 virtual void Disable();
72 // Event loop notification member for Window size change
73 virtual void UpdateSize(int x,int y);
76 // Timer methods must be overridden by platform dependent subclasses.
77 // flag is passed to indicate if this is first timer set or an update
78 // as Win32 uses repeating timers, whereas X uses One shot more timer
79 // if flag==VTKXI_TIMER_FIRST Win32 and X should createtimer
80 // otherwise Win32 should exit and X should perform AddTimeOut()
81 virtual int CreateTimer(int ) ;
82 virtual int DestroyTimer() ;
85 // This function is called on 'q','e' keypress if exitmethod is not
86 // specified and should be overidden by platform dependent subclasses
87 // to provide a termination procedure if one is required.
88 virtual void TerminateApp(void) { /* empty */ }
91 // These methods correspond to the the Exit, User and Pick
92 // callbacks. They allow for the Style to invoke them.
93 //virtual void ExitCallback();
94 //virtual void UserCallback();
95 //virtual void StartPickCallback();
96 //virtual void EndPickCallback();
98 /* 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);
120 // Displaymode management
121 int GetDisplayMode();
122 void SetDisplayMode(int);
124 // Change all actors to wireframe or surface
125 void ChangeRepresentationToWireframe();
126 void ChangeRepresentationToSurface();
128 // Change to wireframe or surface a list of vtkactor
129 void ChangeRepresentationToWireframe(vtkActorCollection* ListofActors);
130 void ChangeRepresentationToSurface(vtkActorCollection* ListofActors);
132 // Erase Display functions
135 void RemoveAll( const bool immediatly );
137 void Display( VTKViewer_Actor* SActor, bool immediatly = true );
138 void Erase( VTKViewer_Actor* SActor, bool immediatly = true );
139 void Remove( VTKViewer_Actor* SActor, bool updateViewer = true );
143 vtkRenderer* GetRenderer();
145 void setViewWindow( VTKViewer_ViewWindow* theViewWnd );
147 void setCellData(const int& theIndex,
148 VTKViewer_Actor* theMapActor,
149 VTKViewer_Actor* theActor) {}
150 void setEdgeData(const int& theCellIndex,
151 VTKViewer_Actor* theMapActor,
152 const int& theEdgeIndex,
153 VTKViewer_Actor* theActor ) {} //NB
154 void setPointData(const int& theIndex,
155 VTKViewer_Actor* theMapActor,
156 VTKViewer_Actor* theActor) {}
158 typedef void (*TUpdateActor)(const TColStd_IndexedMapOfInteger& theMapIndex,
159 VTKViewer_Actor* theMapActor,
160 VTKViewer_Actor* theActor);
163 VTKViewer_RenderWindowInteractor();
164 ~VTKViewer_RenderWindowInteractor();
166 VTKViewer_InteractorStyle* myInteractorStyle;
168 bool highlight(const TColStd_IndexedMapOfInteger& theMapIndex,
169 VTKViewer_Actor* theMapActor, VTKViewer_Actor* theActor,
170 TUpdateActor theFun, bool hilight, bool update);
171 void setActorData(const TColStd_IndexedMapOfInteger& theMapIndex,
172 VTKViewer_Actor* theMapActor,
173 VTKViewer_Actor *theActor,
174 TUpdateActor theFun);
176 // Timer used during various mouse events to figure
177 // out mouse movements.
182 //NRI: Selection mode
183 VTKViewer_Actor* myPointActor;
184 VTKViewer_Actor* myEdgeActor;
185 VTKViewer_Actor* myCellActor;
186 void MoveInternalActors();
188 vtkPicker* myBasicPicker;
189 vtkCellPicker* myCellPicker;
190 vtkPointPicker* myPointPicker;
192 // User for switching to stereo mode.
193 int PositionBeforeStereo[2];
196 void MouseMove(QMouseEvent *event) ;
197 void LeftButtonPressed(const QMouseEvent *event) ;
198 void LeftButtonReleased(const QMouseEvent *event) ;
199 void MiddleButtonPressed(const QMouseEvent *event) ;
200 void MiddleButtonReleased(const QMouseEvent *event) ;
201 void RightButtonPressed(const QMouseEvent *event) ;
202 void RightButtonReleased(const QMouseEvent *event) ;
203 void ButtonPressed(const QMouseEvent *event) ;
204 void ButtonReleased(const QMouseEvent *event) ;
205 void KeyPressed(QKeyEvent *event) ;
208 // Not all of these slots are needed in VTK_MAJOR_VERSION=3,
209 // but moc does not understand "#if VTK_MAJOR_VERSION". Hence,
210 // we have to include all of these for the time being. Once,
211 // this bug in MOC is fixed, we can separate these.
215 void RenderWindowModified() ;
216 void contextMenuRequested( QContextMenuEvent *e );
219 friend class VTKViewer_ViewWindow;
221 VTKViewer_ViewWindow* myViewWnd;