1 // Copyright (C) 2007-2012 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);
217 //! Get current material
219 GetMaterial(const Handle(SALOME_InteractiveObject)& theIObject);
221 //----------------------------------------------------------------------------
222 // Erase Display functions
223 //! To erase all existing VTK presentations
227 //! To display all existing VTK presentations
231 //! To remove from the view all existing VTK presentations
233 RemoveAll( const bool immediatly );
235 //! To erase VTK presentation with defined #SALOME_InteractiveObject
237 Erase(const Handle(SALOME_InteractiveObject)& IObject,
238 bool immediatly = true);
240 Remove(const Handle(SALOME_InteractiveObject)& IObject,
241 bool immediatly = true);
243 //! To display VTK presentation with defined #SALOME_InteractiveObject
245 Display(const Handle(SALOME_InteractiveObject)& IObject,
246 bool immediatly = true);
248 //! To display VTK presentation with defined #SALOME_InteractiveObject and erase all anothers
250 DisplayOnly(const Handle(SALOME_InteractiveObject)& IObject);
252 //! To display the VTK presentation
254 Display(SALOME_Actor* SActor,
255 bool immediatly = true);
257 //! To erase the VTK presentation
259 Erase(SALOME_Actor* SActor,
260 bool immediatly = true);
262 //! To remove the VTK presentation
264 Remove(SALOME_Actor* SActor,
265 bool updateViewer = true);
267 //! Collect objects visible in viewer
269 GetVisible( SALOME_ListIO& theList );
271 //----------------------------------------------------------------------------
272 //! Redirect the request to #SVTK_Renderer::SetPreselectionProp
274 SetSelectionProp(const double& theRed = 1,
275 const double& theGreen = 1,
276 const double& theBlue = 0,
277 const int& theWidth = 5);
279 //! Redirect the request to #SVTK_Renderer::SetPreselectionProp
281 SetPreselectionProp(const double& theRed = 0,
282 const double& theGreen = 1,
283 const double& theBlue = 1,
284 const int& theWidth = 5);
286 //! Redirect the request to #SVTK_Renderer::SetPreselectionProp
288 SetSelectionTolerance(const double& theTolNodes = 0.025,
289 const double& theTolCell = 0.001,
290 const double& theTolObjects = 0.025);
297 #pragma warning( default:4251 )