1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
27 #pragma warning( disable:4251 )
32 #include <SALOME_InteractiveObject.hxx>
33 #include <SALOME_ListIO.hxx>
37 class vtkActorCollection;
41 class SVTK_ViewWindow;
49 class QContextMenuEvent;
53 //! Main purpose of the class is to provide a way to customize #SVTK_ViewWindow.
55 This class is initialized by #SVTK_ViewWindow and just pass Qt signals from
56 corresponding #SVTK_RenderWindowInteractor of the #SVTK_ViewWindow.
57 Its main purpose is to provide a simple and flexible way to customize the #SVTK_ViewWindow.
58 So, in your own viewer it is possible to derive new #SVTK_ViewWindow and
59 use existing functionality without any modifications.
61 class SVTK_EXPORT SVTK_SignalHandler : public QObject
66 SVTK_SignalHandler(SVTK_ViewWindow* theMainWindow);
69 ~SVTK_SignalHandler();
71 //! Get reference to its #SVTK_ViewWindow
75 //----------------------------------------------------------------------------
76 //! Redirect the request to #SVTK_ViewWindow::Repaint (just for flexibility)
78 Repaint(bool theUpdateTrihedron = true);
80 //----------------------------------------------------------------------------
81 //! Redirect the request to #SVTK_ViewWindow::GetRenderer (just for flexibility)
85 //! Redirect the request to #SVTK_ViewWindow::getRenderer (just for flexibility)
89 //----------------------------------------------------------------------------
91 void onSelectionChanged();
95 void MouseMove( QMouseEvent* );
96 void MouseButtonPressed( QMouseEvent* );
97 void MouseButtonReleased( QMouseEvent* );
98 void MouseDoubleClicked( QMouseEvent* );
99 void ButtonPressed(const QMouseEvent *event);
100 void ButtonReleased(const QMouseEvent *event);
101 void WheelMoved( QWheelEvent* );
102 void KeyPressed( QKeyEvent* );
103 void KeyReleased( QKeyEvent* );
104 void contextMenuRequested( QContextMenuEvent *e );
105 void selectionChanged();
108 SVTK_ViewWindow* myMainWindow;
112 //! This class is introduced just for compatibility with old code.
114 This class contains frequantly used functionality in old code.
115 Now, you are supposed to extend existing functionality through
116 writing corresponding functors (see SVTK_Functor.h for example).
118 class SVTK_EXPORT SVTK_View : public SVTK_SignalHandler
123 SVTK_View(SVTK_ViewWindow* theMainWindow);
128 /* interactive object management */
129 //! To highlight a VTK presentation with the same #SALOME_InteractiveObject
131 highlight(const Handle(SALOME_InteractiveObject)& IObject,
133 bool immediatly = true);
135 //! To unhighlight all VTK presentations
139 //! Try to find a SALOME_InteractiveObject in the view that corresponds to the entry
140 Handle(SALOME_InteractiveObject)
141 FindIObject(const char* Entry);
143 //! Check, if the viewer contains a presentatin with defined #SALOME_InteractiveObject
145 isInViewer(const Handle(SALOME_InteractiveObject)& IObject);
147 //! Check, if a presentatin with defined #SALOME_InteractiveObject is visible
149 isVisible(const Handle(SALOME_InteractiveObject)& IObject);
152 rename(const Handle(SALOME_InteractiveObject)& IObject,
153 const QString& newName);
155 //----------------------------------------------------------------------------
156 // Displaymode management
157 //! Get current display mode (obsolete)
161 //! Set current display mode
165 //! Switch representation wireframe/shading
167 SetDisplayMode(const Handle(SALOME_InteractiveObject)& IObject,
170 //! Change all actors to wireframe
172 ChangeRepresentationToWireframe();
174 //! Change all actors to surface
176 ChangeRepresentationToSurface();
178 //! Change all actors to surface with edges
180 ChangeRepresentationToSurfaceWithEdges();
182 //! Change to wireframe a list of vtkactor
184 ChangeRepresentationToWireframe(vtkActorCollection* theListofActors);
186 //! Change to surface a list of vtkactor
188 ChangeRepresentationToSurface(vtkActorCollection* theListofActors);
190 //! Change to surface with edges a list of vtkactor
192 ChangeRepresentationToSurfaceWithEdges(vtkActorCollection* theListofActors);
194 //! Change transparency
196 SetTransparency(const Handle(SALOME_InteractiveObject)& theIObject,
199 //! Get current transparency
201 GetTransparency(const Handle(SALOME_InteractiveObject)& theIObject);
205 SetColor(const Handle(SALOME_InteractiveObject)& theIObject,
206 const QColor& theColor);
208 //! Get current color
210 GetColor(const Handle(SALOME_InteractiveObject)& theIObject);
214 SetMaterial(const Handle(SALOME_InteractiveObject)& theIObject,
215 vtkProperty* thePropF, vtkProperty* thePropB);
217 //! Get current front material
219 GetFrontMaterial(const Handle(SALOME_InteractiveObject)& theIObject);
221 //! Get current back material
223 GetBackMaterial(const Handle(SALOME_InteractiveObject)& theIObject);
225 //----------------------------------------------------------------------------
226 // Erase Display functions
227 //! To erase all existing VTK presentations
231 //! To display all existing VTK presentations
235 //! To remove from the view all existing VTK presentations
237 RemoveAll( const bool immediatly );
239 //! To erase VTK presentation with defined #SALOME_InteractiveObject
241 Erase(const Handle(SALOME_InteractiveObject)& IObject,
242 bool immediatly = true);
244 Remove(const Handle(SALOME_InteractiveObject)& IObject,
245 bool immediatly = true);
247 //! To display VTK presentation with defined #SALOME_InteractiveObject
249 Display(const Handle(SALOME_InteractiveObject)& IObject,
250 bool immediatly = true);
252 //! To display VTK presentation with defined #SALOME_InteractiveObject and erase all anothers
254 DisplayOnly(const Handle(SALOME_InteractiveObject)& IObject);
256 //! To display the VTK presentation
258 Display(SALOME_Actor* SActor,
259 bool immediatly = true);
261 //! To erase the VTK presentation
263 Erase(SALOME_Actor* SActor,
264 bool immediatly = true);
266 //! To remove the VTK presentation
268 Remove(SALOME_Actor* SActor,
269 bool updateViewer = true);
271 //! Collect objects visible in viewer
273 GetVisible( SALOME_ListIO& theList );
275 //----------------------------------------------------------------------------
276 //! Redirect the request to #SVTK_Renderer::SetPreselectionProp
278 SetSelectionProp(const double& theRed = 1,
279 const double& theGreen = 1,
280 const double& theBlue = 0,
281 const int& theWidth = 5);
283 //! Redirect the request to #SVTK_Renderer::SetPreselectionProp
285 SetPreselectionProp(const double& theRed = 0,
286 const double& theGreen = 1,
287 const double& theBlue = 1,
288 const int& theWidth = 5);
290 //! Redirect the request to #SVTK_Renderer::SetPreselectionProp
292 SetSelectionTolerance(const double& theTolNodes = 0.025,
293 const double& theTolCell = 0.001,
294 const double& theTolObjects = 0.025);
301 #pragma warning( default:4251 )