1 // Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/
23 #pragma warning( disable:4251 )
27 #include "SALOME_InteractiveObject.hxx"
31 class vtkActorCollection;
34 class SVTK_MainWindow;
39 //! Main purpose of the class is to provide a way to customize #SVTK_MainWindow.
41 This class is initialized by #SVTK_MainWindow and just pass Qt signals from
42 corresponding #SVTK_RenderWindowInteractor of the #SVTK_MainWindow.
43 Its main purpose is to provide a simple and flexible way to customize the #SVTK_MainWindow.
44 So, in your own viewer it is possible to derive new #SVTK_MainWindow and
45 use existing functionality without any modifications.
47 class SVTK_EXPORT SVTK_SignalHandler : public QObject
52 SVTK_SignalHandler(SVTK_MainWindow* theMainWindow);
55 ~SVTK_SignalHandler();
57 //! Get reference to its #SVTK_MainWindow
61 //----------------------------------------------------------------------------
62 //! Redirect the request to #SVTK_MainWindow::Repaint (just for flexibility)
64 Repaint(bool theUpdateTrihedron = true);
66 //----------------------------------------------------------------------------
67 //! Redirect the request to #SVTK_MainWindow::GetRenderer (just for flexibility)
71 //! Redirect the request to #SVTK_MainWindow::getRenderer (just for flexibility)
75 //----------------------------------------------------------------------------
77 void onSelectionChanged();
81 void MouseMove( QMouseEvent* );
82 void MouseButtonPressed( QMouseEvent* );
83 void MouseButtonReleased( QMouseEvent* );
84 void MouseDoubleClicked( QMouseEvent* );
85 void ButtonPressed(const QMouseEvent *event);
86 void ButtonReleased(const QMouseEvent *event);
87 void WheelMoved( QWheelEvent* );
88 void KeyPressed( QKeyEvent* );
89 void KeyReleased( QKeyEvent* );
90 void contextMenuRequested( QContextMenuEvent *e );
91 void selectionChanged();
94 SVTK_MainWindow* myMainWindow;
98 //! This class is introduced just for compatibility with old code.
100 This class contains frequantly used functionality in old code.
101 Now, you are supposed to extend existing functionality through
102 writing corresponding functors (see SVTK_Functor.h for example).
104 class SVTK_EXPORT SVTK_View : public SVTK_SignalHandler
109 SVTK_View(SVTK_MainWindow* theMainWindow);
114 /* interactive object management */
115 //! To highlight a VTK presentation with the same #SALOME_InteractiveObject
117 highlight(const Handle(SALOME_InteractiveObject)& IObject,
119 bool immediatly = true);
121 //! To unhighlight all VTK presentations
125 //! Try to find a SALOME_InteractiveObject in the view that corresponds to the entry
126 Handle(SALOME_InteractiveObject)
127 FindIObject(const char* Entry);
129 //! Check, if the viewer contains a presentatin with defined #SALOME_InteractiveObject
131 isInViewer(const Handle(SALOME_InteractiveObject)& IObject);
133 //! Check, if a presentatin with defined #SALOME_InteractiveObject is visible
135 isVisible(const Handle(SALOME_InteractiveObject)& IObject);
138 rename(const Handle(SALOME_InteractiveObject)& IObject,
139 const QString& newName);
141 //----------------------------------------------------------------------------
142 // Displaymode management
143 //! Get current display mode (obsolete)
147 //! Set current display mode
151 //! Switch representation wireframe/shading
153 SetDisplayMode(const Handle(SALOME_InteractiveObject)& IObject,
156 //! Change all actors to wireframe
158 ChangeRepresentationToWireframe();
160 //! Change all actors to surface
162 ChangeRepresentationToSurface();
164 //! Change to wireframe a list of vtkactor
166 ChangeRepresentationToWireframe(vtkActorCollection* theListofActors);
168 //! Change to surface a list of vtkactor
170 ChangeRepresentationToSurface(vtkActorCollection* theListofActors);
172 //! Change transparency
174 SetTransparency(const Handle(SALOME_InteractiveObject)& theIObject,
177 //! Get current transparency
179 GetTransparency(const Handle(SALOME_InteractiveObject)& theIObject);
183 SetColor(const Handle(SALOME_InteractiveObject)& theIObject,
184 const QColor& theColor);
186 //! Get current color
188 GetColor(const Handle(SALOME_InteractiveObject)& theIObject);
190 //----------------------------------------------------------------------------
191 // Erase Display functions
192 //! To erase all existing VTK presentations
196 //! To display all existing VTK presentations
200 //! To remove from the view all existing VTK presentations
202 RemoveAll( const bool immediatly );
204 //! To erase VTK presentation with defined #SALOME_InteractiveObject
206 Erase(const Handle(SALOME_InteractiveObject)& IObject,
207 bool immediatly = true);
209 Remove(const Handle(SALOME_InteractiveObject)& IObject,
210 bool immediatly = true);
212 //! To display VTK presentation with defined #SALOME_InteractiveObject
214 Display(const Handle(SALOME_InteractiveObject)& IObject,
215 bool immediatly = true);
217 //! To display VTK presentation with defined #SALOME_InteractiveObject and erase all anothers
219 DisplayOnly(const Handle(SALOME_InteractiveObject)& IObject);
221 //! To display the VTK presentation
223 Display(SALOME_Actor* SActor,
224 bool immediatly = true);
226 //! To erase the VTK presentation
228 Erase(SALOME_Actor* SActor,
229 bool immediatly = true);
231 //! To remove the VTK presentation
233 Remove(SALOME_Actor* SActor,
234 bool updateViewer = true);
236 //----------------------------------------------------------------------------
237 //! Redirect the request to #SVTK_Renderer::SetPreselectionProp
239 SetSelectionProp(const double& theRed = 1,
240 const double& theGreen = 1,
241 const double& theBlue = 0,
242 const int& theWidth = 5);
244 //! Redirect the request to #SVTK_Renderer::SetPreselectionProp
246 SetPreselectionProp(const double& theRed = 0,
247 const double& theGreen = 1,
248 const double& theBlue = 1,
249 const int& theWidth = 5);
251 //! Redirect the request to #SVTK_Renderer::SetPreselectionProp
253 SetSelectionTolerance(const double& theTolNodes = 0.025,
254 const double& theTolCell = 0.001);
261 #pragma warning( default:4251 )