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
23 #ifndef HYDROGUI_TOOL_H
24 #define HYDROGUI_TOOL_H
26 #include <HYDROData_Image.h>
28 #include <GraphicsView_Defs.h>
29 #include <GraphicsView_ViewPort.h>
31 #include <TCollection_AsciiString.hxx>
32 #include <TCollection_ExtendedString.hxx>
33 #include <TCollection_HAsciiString.hxx>
34 #include <TCollection_HExtendedString.hxx>
36 class SUIT_ViewManager;
37 class OCCViewer_ViewFrame;
39 class HYDROGUI_DataModel;
40 class HYDROGUI_Module;
44 class Handle(HYDROData_Document);
47 * \class HYDROGUI_Tool
48 * \brief This class contains several useful methods.
54 * \brief Convert \a TCollection_AsciiString to \a QString
56 static QString ToQString( const TCollection_AsciiString& );
59 * \brief Convert \a TCollection_ExtendedString to \a QString
61 static QString ToQString( const TCollection_ExtendedString& );
64 * \brief Convert \a Handle_TCollection_HAsciiString to \a QString
66 static QString ToQString( const Handle(TCollection_HAsciiString)& );
69 * \brief Convert \a Handle_TCollection_HExtendedString to \a QString
71 static QString ToQString( const Handle(TCollection_HExtendedString)& );
74 * \brief Convert \a QString to \a TCollection_AsciiString
76 static TCollection_AsciiString ToAsciiString( const QString& );
79 * \brief Convert \a QString to \a TCollection_ExtendedString
81 static TCollection_ExtendedString ToExtString( const QString& );
84 * \brief Convert \a QString to \a Handle_TCollection_HAsciiString
86 static Handle(TCollection_HAsciiString) ToHAsciiString( const QString& );
89 * \brief Convert \a QString to \a Handle_TCollection_HExtendedString
91 static Handle(TCollection_HExtendedString) ToHExtString( const QString& );
94 * \brief Get the active study id.
95 * \return active study id
97 static int GetActiveStudyId();
100 * \brief Get path to the temporary directory.
101 * \param theToCreate flag used to create a directory if it doesn't exist
104 static QString GetTempDir( const bool theToCreate );
107 * \brief Set the specified view manager to be active on the desktop.
108 * \param theModule module
109 * \param theViewManager view manager
111 static void SetActiveViewManager( HYDROGUI_Module* theModule,
112 SUIT_ViewManager* theViewManager );
115 * \brief Get sub-objects to build presentations.
116 * \param theModule module
117 * \param theSeq sequence of sub-objects
119 static void GetPrsSubObjects( HYDROGUI_Module* theModule,
120 HYDROData_SequenceOfObjects& theSeq );
123 * \brief Get presentation built for specified data object.
124 * \param theObj data object
125 * \param theObjects list of existing presentations
126 * \return presentation
128 static HYDROGUI_Prs* GetPresentation( const Handle(HYDROData_Entity)& theObj,
129 const GraphicsView_ObjectList& theObjects );
132 * \brief Get list of HYDRO presentations from the specified viewport.
133 * \param theViewPort viewport
134 * \return list of HYDRO presentations
136 static GraphicsView_ObjectList GetPrsList( GraphicsView_ViewPort* theViewPort );
139 * \brief Get list of the selected data objects.
140 * \param theModule module
141 * \return list of the selected data objects
143 static HYDROData_SequenceOfObjects GetSelectedObjects( HYDROGUI_Module* theModule );
146 * \brief Get the selected data object (first in the selected list).
147 * \param theModule module
148 * \return selected data object
150 static Handle(HYDROData_Entity) GetSelectedObject( HYDROGUI_Module* theModule );
153 * \brief Get the geometry data objects from document.
154 * \param theModule module
155 * \return sequence of data objects
157 static HYDROData_SequenceOfObjects GetGeometryObjects( HYDROGUI_Module* theModule );
160 * \brief Get kind of objects the selected partition contains.
161 * \param theModule module
162 * \return object kind
164 static ObjectKind GetSelectedPartition( HYDROGUI_Module* theModule );
167 * \brief Get the selected GEOM objects.
168 * \param theModule module
169 * \return list of GEOM objects entries
171 static QStringList GetSelectedGeomObjects( HYDROGUI_Module* theModule );
174 * \brief Find the data object with the specified name.
175 * \param theModule module
176 * \param theName name
177 * \param theObjectKind kind of object
178 * \return data object
180 static Handle(HYDROData_Entity) FindObjectByName( HYDROGUI_Module* theModule,
181 const QString& theName,
182 const ObjectKind theObjectKind = KIND_UNKNOWN );
185 * \brief Find the data objects with the specified names.
186 * \param theModule module
187 * \param theNames list of names
188 * \param theObjectKind kind of object
189 * \return list of data objects
191 static HYDROData_SequenceOfObjects FindObjectsByNames( HYDROGUI_Module* theModule,
192 const QStringList& theNames,
193 const ObjectKind theObjectKind = KIND_UNKNOWN );
196 * \brief Generate name for new object.
197 * \param theModule module
198 * \param thePrefix name prefix
199 * \param theUsedNames list of already used names
200 * \param theIsTryToUsePurePrefix if true - the prefix will be returned if the name equal to the prefix is not busy
201 * \return generated name
203 static QString GenerateObjectName( HYDROGUI_Module* theModule,
204 const QString& thePrefix,
205 const QStringList& theUsedNames = QStringList(),
206 const bool theIsTryToUsePurePrefix = false );
209 * \brief Get id of the active view.
210 * \param theModule module
213 static size_t GetActiveViewId( HYDROGUI_Module* theModule,
214 const QString& theViewId = QString() );
217 * \brief Get id of the active GraphicsView view.
218 * \param theModule module
221 static size_t GetActiveGraphicsViewId( HYDROGUI_Module* theModule );
224 * \brief Get id of the active OCC view.
225 * \param theModule module
228 static size_t GetActiveOCCViewId( HYDROGUI_Module* theModule );
231 * \brief Get list of ids of existing GraphicsView views.
232 * \param theModule module
233 * \return list of view ids
235 static QList<size_t> GetGraphicsViewIdList( HYDROGUI_Module* theModule );
238 * \brief Get list of ids of existing OCC views.
239 * \param theModule module
240 * \return list of view ids
242 static QList<size_t> GetOCCViewIdList( HYDROGUI_Module* theModule );
246 * \brief Change OCC viewer action visibility.
247 * \param theViewFrame OCC viewer frame
248 * \param theActionId an action index, which state should be changed
249 * \param isShown the action visibility state
251 static void setOCCActionShown( OCCViewer_ViewFrame* theViewFrame,
252 const int theActionId,
253 const bool isShown );
256 * \brief Change OCC viewer action visibility for all opened views.
257 * \param theActionId an action index, which state should be changed
258 * \param isShown the action visibility state
260 static void setOCCActionShown( HYDROGUI_Module* theModule,
261 const int theActionId,
262 const bool isShown );
265 * \brief Get the list of references (recursively) for the specified image object
266 * \param theImage image data object
267 * \param theRefObjects list of reference objects
268 * \param theRefNames list of reference object names
270 static void GetObjectReferences( const Handle(HYDROData_Image)& theImage,
271 HYDROData_SequenceOfObjects& theRefObjects,
272 QStringList& theRefNames );
275 * \brief Get the list of back-references for the specified object
276 * \param theModule module
277 * \param theObj data object
278 * \param theBackRefObjects list of back-reference objects
279 * \param theBackRefNames list of back-reference object names
281 static void GetObjectBackReferences( HYDROGUI_Module* theModule,
282 const Handle(HYDROData_Entity)& theObj,
283 HYDROData_SequenceOfObjects& theBackRefObjects,
284 QStringList& theBackRefNames );
287 * \brief Get father dock window for widget
289 * \return dock window
291 static QDockWidget* WindowDock( QWidget* wid );
294 * \brief Generates the filling color for intersected zone
295 * \param theModule module
296 * \param theZoneNames list of intersected zones
297 * \return result color
299 static QColor GenerateFillingColor( HYDROGUI_Module* theModule,
300 const QStringList& theZoneNames );
303 * \brief Generates the filling color for intersected zone
304 * \param theDoc model document
305 * \param theZoneNames list of intersected zones
306 * \return result color
308 static QColor GenerateFillingColor( const Handle(HYDROData_Document)& theDoc,
309 const QStringList& theZoneNames );
312 * \brief Find names of existing objects of the given kind.
313 * \param theDoc model document
314 * \param theObjectKind kind of object
315 * \return list of names
317 static QStringList FindExistingObjectsNames( const Handle(HYDROData_Document)& theDoc,
318 const ObjectKind theObjectKind );