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;
45 * \class HYDROGUI_Tool
46 * \brief This class contains several useful methods.
52 * \brief Convert \a TCollection_AsciiString to \a QString
54 static QString ToQString( const TCollection_AsciiString& );
57 * \brief Convert \a TCollection_ExtendedString to \a QString
59 static QString ToQString( const TCollection_ExtendedString& );
62 * \brief Convert \a Handle_TCollection_HAsciiString to \a QString
64 static QString ToQString( const Handle(TCollection_HAsciiString)& );
67 * \brief Convert \a Handle_TCollection_HExtendedString to \a QString
69 static QString ToQString( const Handle(TCollection_HExtendedString)& );
72 * \brief Convert \a QString to \a TCollection_AsciiString
74 static TCollection_AsciiString ToAsciiString( const QString& );
77 * \brief Convert \a QString to \a TCollection_ExtendedString
79 static TCollection_ExtendedString ToExtString( const QString& );
82 * \brief Convert \a QString to \a Handle_TCollection_HAsciiString
84 static Handle(TCollection_HAsciiString) ToHAsciiString( const QString& );
87 * \brief Convert \a QString to \a Handle_TCollection_HExtendedString
89 static Handle(TCollection_HExtendedString) ToHExtString( const QString& );
92 * \brief Check that the specified objects are equal.
93 * \param theObj1 first object
94 * \param theObj2 second object
96 static bool IsEqual( const Handle(HYDROData_Object)& theObj1,
97 const Handle(HYDROData_Object)& theObj2 );
100 * \brief Set the specified view manager to be active on the desktop.
101 * \param theModule module
102 * \param theViewManager view manager
104 static void SetActiveViewManager( HYDROGUI_Module* theModule,
105 SUIT_ViewManager* theViewManager );
108 * \brief Get sub-objects to build presentations.
109 * \param theModule module
110 * \param theSeq sequence of sub-objects
112 static void GetPrsSubObjects( HYDROGUI_Module* theModule,
113 HYDROData_SequenceOfObjects& theSeq );
116 * \brief Get presentation built for specified data object.
117 * \param theObj data object
118 * \param theObjects list of existing presentations
119 * \return presentation
121 static HYDROGUI_Prs* GetPresentation( const Handle(HYDROData_Object)& theObj,
122 const GraphicsView_ObjectList& theObjects );
125 * \brief Get list of HYDRO presentations from the specified viewport.
126 * \param theViewPort viewport
127 * \return list of HYDRO presentations
129 static GraphicsView_ObjectList GetPrsList( GraphicsView_ViewPort* theViewPort );
132 * \brief Get list of the selected data objects.
133 * \param theModule module
134 * \return list of the selected data objects
136 static HYDROData_SequenceOfObjects GetSelectedObjects( HYDROGUI_Module* theModule );
139 * \brief Get the selected data object (first in the selected list).
140 * \param theModule module
141 * \return selected data object
143 static Handle(HYDROData_Object) GetSelectedObject( HYDROGUI_Module* theModule );
146 * \brief Get kind of objects the selected partition contains.
147 * \param theModule module
148 * \return object kind
150 static ObjectKind GetSelectedPartition( HYDROGUI_Module* theModule );
153 * \brief Find the data object with the specified name.
154 * \param theModule module
155 * \param theName name
156 * \param theObjectKind kind of object
157 * \return data object
159 static Handle(HYDROData_Object) FindObjectByName( HYDROGUI_Module* theModule,
160 const QString& theName,
161 const ObjectKind theObjectKind = KIND_UNKNOWN );
164 * \brief Find the data objects with the specified names.
165 * \param theModule module
166 * \param theNames list of names
167 * \param theObjectKind kind of object
168 * \return list of data objects
170 static HYDROData_SequenceOfObjects FindObjectsByNames( HYDROGUI_Module* theModule,
171 const QStringList& theNames,
172 const ObjectKind theObjectKind = KIND_UNKNOWN );
175 * \brief Generate name for new object.
176 * \param theModule module
177 * \param thePrefix name prefix
178 * \param theUsedNames list of already used names
179 * \return generated name
181 static QString GenerateObjectName( HYDROGUI_Module* theModule,
182 const QString& thePrefix,
183 const QStringList& theUsedNames = QStringList() );
186 * \brief Get id of the active view.
187 * \param theModule module
190 static size_t GetActiveViewId( HYDROGUI_Module* theModule,
191 const QString& theViewId = QString() );
194 * \brief Get id of the active GraphicsView view.
195 * \param theModule module
198 static size_t GetActiveGraphicsViewId( HYDROGUI_Module* theModule );
201 * \brief Get id of the active OCC view.
202 * \param theModule module
205 static size_t GetActiveOCCViewId( HYDROGUI_Module* theModule );
208 * \brief Get list of ids of existing GraphicsView views.
209 * \param theModule module
210 * \return list of view ids
212 static QList<size_t> GetGraphicsViewIdList( HYDROGUI_Module* theModule );
215 * \brief Get list of ids of existing OCC views.
216 * \param theModule module
217 * \return list of view ids
219 static QList<size_t> GetOCCViewIdList( HYDROGUI_Module* theModule );
222 * \brief Get the list of references (recursively) for the specified image object
223 * \param theImage image data object
224 * \param theRefObjects list of reference objects
225 * \param theRefNames list of reference object names
227 static void GetObjectReferences( const Handle(HYDROData_Image)& theImage,
228 HYDROData_SequenceOfObjects& theRefObjects,
229 QStringList& theRefNames );
232 * \brief Get the list of back-references for the specified object
233 * \param theModule module
234 * \param theObj data object
235 * \param theBackRefObjects list of back-reference objects
236 * \param theBackRefNames list of back-reference object names
238 static void GetObjectBackReferences( HYDROGUI_Module* theModule,
239 const Handle(HYDROData_Object)& theObj,
240 HYDROData_SequenceOfObjects& theBackRefObjects,
241 QStringList& theBackRefNames );
244 * \brief Get father dock window for widget
246 * \return dock window
248 static QDockWidget* WindowDock( QWidget* wid );
251 * \brief Generates the filling color for intersected zone
252 * \param theModule module
253 * \param theZoneNames list of intersected zones
254 * \return result color
256 static QColor GenerateFillingColor( HYDROGUI_Module* theModule,
257 const QStringList& theZoneNames );