1 // Copyright (C) 2007-2008 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
26 #pragma warning( disable:4251 )
30 #include "SALOME_InteractiveObject.hxx"
34 class vtkActorCollection;
37 class SVTK_ViewWindow;
45 class QContextMenuEvent;
49 //! Main purpose of the class is to provide a way to customize #SVTK_ViewWindow.
51 This class is initialized by #SVTK_ViewWindow and just pass Qt signals from
52 corresponding #SVTK_RenderWindowInteractor of the #SVTK_ViewWindow.
53 Its main purpose is to provide a simple and flexible way to customize the #SVTK_ViewWindow.
54 So, in your own viewer it is possible to derive new #SVTK_ViewWindow and
55 use existing functionality without any modifications.
57 class SVTK_EXPORT SVTK_SignalHandler : public QObject
62 SVTK_SignalHandler(SVTK_ViewWindow* theMainWindow);
65 ~SVTK_SignalHandler();
67 //! Get reference to its #SVTK_ViewWindow
71 //----------------------------------------------------------------------------
72 //! Redirect the request to #SVTK_ViewWindow::Repaint (just for flexibility)
74 Repaint(bool theUpdateTrihedron = true);
76 //----------------------------------------------------------------------------
77 //! Redirect the request to #SVTK_ViewWindow::GetRenderer (just for flexibility)
81 //! Redirect the request to #SVTK_ViewWindow::getRenderer (just for flexibility)
85 //----------------------------------------------------------------------------
87 void onSelectionChanged();
91 void MouseMove( QMouseEvent* );
92 void MouseButtonPressed( QMouseEvent* );
93 void MouseButtonReleased( QMouseEvent* );
94 void MouseDoubleClicked( QMouseEvent* );
95 void ButtonPressed(const QMouseEvent *event);
96 void ButtonReleased(const QMouseEvent *event);
97 void WheelMoved( QWheelEvent* );
98 void KeyPressed( QKeyEvent* );
99 void KeyReleased( QKeyEvent* );
100 void contextMenuRequested( QContextMenuEvent *e );
101 void selectionChanged();
104 SVTK_ViewWindow* myMainWindow;
108 //! This class is introduced just for compatibility with old code.
110 This class contains frequantly used functionality in old code.
111 Now, you are supposed to extend existing functionality through
112 writing corresponding functors (see SVTK_Functor.h for example).
114 class SVTK_EXPORT SVTK_View : public SVTK_SignalHandler
119 SVTK_View(SVTK_ViewWindow* theMainWindow);
124 /* interactive object management */
125 //! To highlight a VTK presentation with the same #SALOME_InteractiveObject
127 highlight(const Handle(SALOME_InteractiveObject)& IObject,
129 bool immediatly = true);
131 //! To unhighlight all VTK presentations
135 //! Try to find a SALOME_InteractiveObject in the view that corresponds to the entry
136 Handle(SALOME_InteractiveObject)
137 FindIObject(const char* Entry);
139 //! Check, if the viewer contains a presentatin with defined #SALOME_InteractiveObject
141 isInViewer(const Handle(SALOME_InteractiveObject)& IObject);
143 //! Check, if a presentatin with defined #SALOME_InteractiveObject is visible
145 isVisible(const Handle(SALOME_InteractiveObject)& IObject);
148 rename(const Handle(SALOME_InteractiveObject)& IObject,
149 const QString& newName);
151 //----------------------------------------------------------------------------
152 // Displaymode management
153 //! Get current display mode (obsolete)
157 //! Set current display mode
161 //! Switch representation wireframe/shading
163 SetDisplayMode(const Handle(SALOME_InteractiveObject)& IObject,
166 //! Change all actors to wireframe
168 ChangeRepresentationToWireframe();
170 //! Change all actors to surface
172 ChangeRepresentationToSurface();
174 //! Change to wireframe a list of vtkactor
176 ChangeRepresentationToWireframe(vtkActorCollection* theListofActors);
178 //! Change to surface a list of vtkactor
180 ChangeRepresentationToSurface(vtkActorCollection* theListofActors);
182 //! Change transparency
184 SetTransparency(const Handle(SALOME_InteractiveObject)& theIObject,
187 //! Get current transparency
189 GetTransparency(const Handle(SALOME_InteractiveObject)& theIObject);
193 SetColor(const Handle(SALOME_InteractiveObject)& theIObject,
194 const QColor& theColor);
196 //! Get current color
198 GetColor(const Handle(SALOME_InteractiveObject)& theIObject);
200 //----------------------------------------------------------------------------
201 // Erase Display functions
202 //! To erase all existing VTK presentations
206 //! To display all existing VTK presentations
210 //! To remove from the view all existing VTK presentations
212 RemoveAll( const bool immediatly );
214 //! To erase VTK presentation with defined #SALOME_InteractiveObject
216 Erase(const Handle(SALOME_InteractiveObject)& IObject,
217 bool immediatly = true);
219 Remove(const Handle(SALOME_InteractiveObject)& IObject,
220 bool immediatly = true);
222 //! To display VTK presentation with defined #SALOME_InteractiveObject
224 Display(const Handle(SALOME_InteractiveObject)& IObject,
225 bool immediatly = true);
227 //! To display VTK presentation with defined #SALOME_InteractiveObject and erase all anothers
229 DisplayOnly(const Handle(SALOME_InteractiveObject)& IObject);
231 //! To display the VTK presentation
233 Display(SALOME_Actor* SActor,
234 bool immediatly = true);
236 //! To erase the VTK presentation
238 Erase(SALOME_Actor* SActor,
239 bool immediatly = true);
241 //! To remove the VTK presentation
243 Remove(SALOME_Actor* SActor,
244 bool updateViewer = true);
246 //----------------------------------------------------------------------------
247 //! Redirect the request to #SVTK_Renderer::SetPreselectionProp
249 SetSelectionProp(const double& theRed = 1,
250 const double& theGreen = 1,
251 const double& theBlue = 0,
252 const int& theWidth = 5);
254 //! Redirect the request to #SVTK_Renderer::SetPreselectionProp
256 SetPreselectionProp(const double& theRed = 0,
257 const double& theGreen = 1,
258 const double& theBlue = 1,
259 const int& theWidth = 5);
261 //! Redirect the request to #SVTK_Renderer::SetPreselectionProp
263 SetSelectionTolerance(const double& theTolNodes = 0.025,
264 const double& theTolCell = 0.001,
265 const double& theTolObjects = 0.025);
272 #pragma warning( default:4251 )