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;
38 class HYDROGUI_DataModel;
39 class HYDROGUI_Module;
43 class Handle(HYDROData_Document);
46 * \class HYDROGUI_Tool
47 * \brief This class contains several useful methods.
53 * \brief Convert \a TCollection_AsciiString to \a QString
55 static QString ToQString( const TCollection_AsciiString& );
58 * \brief Convert \a TCollection_ExtendedString to \a QString
60 static QString ToQString( const TCollection_ExtendedString& );
63 * \brief Convert \a Handle_TCollection_HAsciiString to \a QString
65 static QString ToQString( const Handle(TCollection_HAsciiString)& );
68 * \brief Convert \a Handle_TCollection_HExtendedString to \a QString
70 static QString ToQString( const Handle(TCollection_HExtendedString)& );
73 * \brief Convert \a QString to \a TCollection_AsciiString
75 static TCollection_AsciiString ToAsciiString( const QString& );
78 * \brief Convert \a QString to \a TCollection_ExtendedString
80 static TCollection_ExtendedString ToExtString( const QString& );
83 * \brief Convert \a QString to \a Handle_TCollection_HAsciiString
85 static Handle(TCollection_HAsciiString) ToHAsciiString( const QString& );
88 * \brief Convert \a QString to \a Handle_TCollection_HExtendedString
90 static Handle(TCollection_HExtendedString) ToHExtString( const QString& );
93 * \brief Get the active study id.
94 * \return active study id
96 static int GetActiveStudyId();
99 * \brief Get path to the temporary directory.
100 * \param theToCreate flag used to create a directory if it doesn't exist
103 static QString GetTempDir( const bool theToCreate );
106 * \brief Set the specified view manager to be active on the desktop.
107 * \param theModule module
108 * \param theViewManager view manager
110 static void SetActiveViewManager( HYDROGUI_Module* theModule,
111 SUIT_ViewManager* theViewManager );
114 * \brief Get sub-objects to build presentations.
115 * \param theModule module
116 * \param theSeq sequence of sub-objects
118 static void GetPrsSubObjects( HYDROGUI_Module* theModule,
119 HYDROData_SequenceOfObjects& theSeq );
122 * \brief Get presentation built for specified data object.
123 * \param theObj data object
124 * \param theObjects list of existing presentations
125 * \return presentation
127 static HYDROGUI_Prs* GetPresentation( const Handle(HYDROData_Entity)& theObj,
128 const GraphicsView_ObjectList& theObjects );
131 * \brief Get list of HYDRO presentations from the specified viewport.
132 * \param theViewPort viewport
133 * \return list of HYDRO presentations
135 static GraphicsView_ObjectList GetPrsList( GraphicsView_ViewPort* theViewPort );
138 * \brief Get list of the selected data objects.
139 * \param theModule module
140 * \return list of the selected data objects
142 static HYDROData_SequenceOfObjects GetSelectedObjects( HYDROGUI_Module* theModule );
145 * \brief Get the selected data object (first in the selected list).
146 * \param theModule module
147 * \return selected data object
149 static Handle(HYDROData_Entity) GetSelectedObject( HYDROGUI_Module* theModule );
152 * \brief Get kind of objects the selected partition contains.
153 * \param theModule module
154 * \return object kind
156 static ObjectKind GetSelectedPartition( HYDROGUI_Module* theModule );
159 * \brief Find the data object with the specified name.
160 * \param theModule module
161 * \param theName name
162 * \param theObjectKind kind of object
163 * \return data object
165 static Handle(HYDROData_Entity) FindObjectByName( HYDROGUI_Module* theModule,
166 const QString& theName,
167 const ObjectKind theObjectKind = KIND_UNKNOWN );
170 * \brief Find the data objects with the specified names.
171 * \param theModule module
172 * \param theNames list of names
173 * \param theObjectKind kind of object
174 * \return list of data objects
176 static HYDROData_SequenceOfObjects FindObjectsByNames( HYDROGUI_Module* theModule,
177 const QStringList& theNames,
178 const ObjectKind theObjectKind = KIND_UNKNOWN );
181 * \brief Generate name for new object.
182 * \param theModule module
183 * \param thePrefix name prefix
184 * \param theUsedNames list of already used names
185 * \return generated name
187 static QString GenerateObjectName( HYDROGUI_Module* theModule,
188 const QString& thePrefix,
189 const QStringList& theUsedNames = QStringList() );
192 * \brief Get id of the active view.
193 * \param theModule module
196 static size_t GetActiveViewId( HYDROGUI_Module* theModule,
197 const QString& theViewId = QString() );
200 * \brief Get id of the active GraphicsView view.
201 * \param theModule module
204 static size_t GetActiveGraphicsViewId( HYDROGUI_Module* theModule );
207 * \brief Get id of the active OCC view.
208 * \param theModule module
211 static size_t GetActiveOCCViewId( HYDROGUI_Module* theModule );
214 * \brief Get list of ids of existing GraphicsView views.
215 * \param theModule module
216 * \return list of view ids
218 static QList<size_t> GetGraphicsViewIdList( HYDROGUI_Module* theModule );
221 * \brief Get list of ids of existing OCC views.
222 * \param theModule module
223 * \return list of view ids
225 static QList<size_t> GetOCCViewIdList( HYDROGUI_Module* theModule );
228 * \brief Get the list of references (recursively) for the specified image object
229 * \param theImage image data object
230 * \param theRefObjects list of reference objects
231 * \param theRefNames list of reference object names
233 static void GetObjectReferences( const Handle(HYDROData_Image)& theImage,
234 HYDROData_SequenceOfObjects& theRefObjects,
235 QStringList& theRefNames );
238 * \brief Get the list of back-references for the specified object
239 * \param theModule module
240 * \param theObj data object
241 * \param theBackRefObjects list of back-reference objects
242 * \param theBackRefNames list of back-reference object names
244 static void GetObjectBackReferences( HYDROGUI_Module* theModule,
245 const Handle(HYDROData_Entity)& theObj,
246 HYDROData_SequenceOfObjects& theBackRefObjects,
247 QStringList& theBackRefNames );
250 * \brief Get father dock window for widget
252 * \return dock window
254 static QDockWidget* WindowDock( QWidget* wid );
257 * \brief Generates the filling color for intersected zone
258 * \param theModule module
259 * \param theZoneNames list of intersected zones
260 * \return result color
262 static QColor GenerateFillingColor( HYDROGUI_Module* theModule,
263 const QStringList& theZoneNames );
266 * \brief Generates the filling color for intersected zone
267 * \param theDoc model document
268 * \param theZoneNames list of intersected zones
269 * \return result color
271 static QColor GenerateFillingColor( const Handle(HYDROData_Document)& theDoc,
272 const QStringList& theZoneNames );