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 Encode the Lambert93 coordinates to the absolute double value
94 static void LambertToDouble( const int theDegrees,
96 const double theSeconds,
100 * \brief Decode the Lambert93 coordinates from the absolute double value
102 static void DoubleToLambert( const double theCoord,
105 double& theSeconds );
108 * \brief Check that the specified objects are equal.
109 * \param theObj1 first object
110 * \param theObj2 second object
112 static bool IsEqual( const Handle(HYDROData_Object)& theObj1,
113 const Handle(HYDROData_Object)& theObj2 );
116 * \brief Set the specified view manager to be active on the desktop.
117 * \param theModule module
118 * \param theViewManager view manager
120 static void SetActiveViewManager( HYDROGUI_Module* theModule,
121 SUIT_ViewManager* theViewManager );
124 * \brief Get sub-objects to build presentations.
125 * \param theModule module
126 * \param theSeq sequence of sub-objects
128 static void GetPrsSubObjects( HYDROGUI_Module* theModule,
129 HYDROData_SequenceOfObjects& theSeq );
132 * \brief Get presentation built for specified data object.
133 * \param theObj data object
134 * \param theObjects list of existing presentations
135 * \return presentation
137 static HYDROGUI_Prs* GetPresentation( const Handle(HYDROData_Object)& theObj,
138 const GraphicsView_ObjectList& theObjects );
141 * \brief Get list of HYDRO presentations from the specified viewport.
142 * \param theViewPort viewport
143 * \return list of HYDRO presentations
145 static GraphicsView_ObjectList GetPrsList( GraphicsView_ViewPort* theViewPort );
148 * \brief Get list of the selected data objects.
149 * \param theModule module
150 * \return list of the selected data objects
152 static HYDROData_SequenceOfObjects GetSelectedObjects( HYDROGUI_Module* theModule );
155 * \brief Get the selected data object (first in the selected list).
156 * \param theModule module
157 * \return selected data object
159 static Handle(HYDROData_Object) GetSelectedObject( HYDROGUI_Module* theModule );
162 * \brief Find the data object with the specified name.
163 * \param theModule module
164 * \param theName name
165 * \param theObjectKind kind of object
166 * \return data object
168 static Handle(HYDROData_Object) FindObjectByName( HYDROGUI_Module* theModule,
169 const QString& theName,
170 const ObjectKind theObjectKind = KIND_UNKNOWN );
173 * \brief Generate name for new object.
174 * \param theModule module
175 * \param thePrefix name prefix
176 * \return generated name
178 static QString GenerateObjectName( HYDROGUI_Module* theModule,
179 const QString& thePrefix );
182 * \brief Get id of the active GraphicsView view.
183 * \param theModule module
186 static size_t GetActiveGraphicsViewId( HYDROGUI_Module* theModule );
189 * \brief Get list of ids of existing GraphicsView views.
190 * \param theModule module
191 * \return list of view ids
193 static QList<size_t> GetGraphicsViewIdList( HYDROGUI_Module* theModule );
196 * \brief Get the list of references (recursively) for the specified image object
197 * \param theImage image data object
198 * \param theRefObjects list of reference objects
199 * \param theRefNames list of reference object names
201 static void GetObjectReferences( const Handle(HYDROData_Image)& theImage,
202 HYDROData_SequenceOfObjects& theRefObjects,
203 QStringList& theRefNames );
206 * \brief Get the list of back-references for the specified object
207 * \param theModule module
208 * \param theObj data object
209 * \param theBackRefObjects list of back-reference objects
210 * \param theBackRefNames list of back-reference object names
212 static void GetObjectBackReferences( HYDROGUI_Module* theModule,
213 const Handle(HYDROData_Object)& theObj,
214 HYDROData_SequenceOfObjects& theBackRefObjects,
215 QStringList& theBackRefNames );
218 * \brief Get father dock window for widget
220 * \return dock window
222 static QDockWidget* WindowDock( QWidget* wid );