Salome HOME
HYDRO bug 17: add HYDRO version in About dialog.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Tool.h
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef HYDROGUI_TOOL_H
24 #define HYDROGUI_TOOL_H
25
26 #include <HYDROData_Image.h>
27
28 #include <GraphicsView_Defs.h>
29 #include <GraphicsView_ViewPort.h>
30
31 #include <TCollection_AsciiString.hxx>
32 #include <TCollection_ExtendedString.hxx>
33 #include <TCollection_HAsciiString.hxx>
34 #include <TCollection_HExtendedString.hxx>
35
36 class SUIT_ViewManager;
37
38 class HYDROGUI_DataModel;
39 class HYDROGUI_Module;
40 class HYDROGUI_Prs;
41
42 /**
43  * \class HYDROGUI_Tool
44  * \brief This class contains several useful methods.
45  */
46 class HYDROGUI_Tool
47 {
48 public:
49   /**
50    * \brief Convert \a TCollection_AsciiString to \a QString
51    */
52   static QString                                  ToQString( const TCollection_AsciiString& );
53
54   /**
55    * \brief Convert \a TCollection_ExtendedString to \a QString
56    */
57   static QString                                  ToQString( const TCollection_ExtendedString& );
58
59   /**
60    * \brief Convert \a Handle_TCollection_HAsciiString to \a QString
61    */
62   static QString                                  ToQString( const Handle(TCollection_HAsciiString)& );
63
64   /**
65    * \brief Convert \a Handle_TCollection_HExtendedString to \a QString
66    */
67   static QString                                  ToQString( const Handle(TCollection_HExtendedString)& );
68
69   /**
70    * \brief Convert \a QString to \a TCollection_AsciiString
71    */
72   static TCollection_AsciiString                  ToAsciiString( const QString& );
73
74   /**
75    * \brief Convert \a QString to \a TCollection_ExtendedString
76    */
77   static TCollection_ExtendedString               ToExtString( const QString& );
78
79   /**
80    * \brief Convert \a QString to \a Handle_TCollection_HAsciiString
81    */
82   static Handle(TCollection_HAsciiString)         ToHAsciiString( const QString& );
83
84   /**
85    * \brief Convert \a QString to \a Handle_TCollection_HExtendedString
86    */
87   static Handle(TCollection_HExtendedString)      ToHExtString( const QString& );
88
89   /**
90    * \brief Encode the Lambert93 coordinates to the absolute double value
91    */
92   static void                     LambertToDouble( const int theDegrees,
93                                                    const int theMinutes,
94                                                    const double theSeconds,
95                                                    double& theCoord );
96
97   /**
98    * \brief Decode the Lambert93 coordinates from the absolute double value
99    */
100   static void                     DoubleToLambert( const double theCoord,
101                                                    int& theDegrees,
102                                                    int& theMinutes,
103                                                    double& theSeconds );
104
105   /**
106    * \brief Check that the specified objects are equal.
107    * \param theObj1 first object
108    * \param theObj2 second object
109    */
110   static bool                     IsEqual( const Handle(HYDROData_Object)& theObj1,
111                                            const Handle(HYDROData_Object)& theObj2 );
112
113   /**
114    * \brief Set the specified view manager to be active on the desktop.
115    * \param theModule module
116    * \param theViewManager view manager
117    */
118   static void                     SetActiveViewManager( HYDROGUI_Module* theModule,
119                                                         SUIT_ViewManager* theViewManager );
120
121   /**
122    * \brief Get sub-objects to build presentations.
123    * \param theModule module
124    * \param theSeq sequence of sub-objects
125    */
126   static void                     GetPrsSubObjects( HYDROGUI_Module* theModule,
127                                                     HYDROData_SequenceOfObjects& theSeq );
128
129   /**
130    * \brief Get presentation built for specified data object.
131    * \param theObj data object
132    * \param theObjects list of existing presentations
133    * \return presentation
134    */
135   static HYDROGUI_Prs*            GetPresentation( const Handle(HYDROData_Object)& theObj,
136                                                    const GraphicsView_ObjectList& theObjects );
137
138   /**
139    * \brief Get list of HYDRO presentations from the specified viewport.
140    * \param theViewPort viewport
141    * \return list of HYDRO presentations
142    */
143   static GraphicsView_ObjectList  GetPrsList( GraphicsView_ViewPort* theViewPort );
144
145   /**
146    * \brief Get list of the selected data objects.
147    * \param theModule module
148    * \return list of the selected data objects
149    */
150   static HYDROData_SequenceOfObjects GetSelectedObjects( HYDROGUI_Module* theModule );
151
152   /**
153    * \brief Get the selected data object (first in the selected list).
154    * \param theModule module
155    * \return selected data object
156    */
157   static Handle(HYDROData_Object) GetSelectedObject( HYDROGUI_Module* theModule );
158
159   /**
160    * \brief Find the data object with the specified name.
161    * \param theModule module
162    * \param theName name
163    * \param theObjectKind kind of object
164    * \return data object
165    */
166   static Handle(HYDROData_Object) FindObjectByName( HYDROGUI_Module* theModule,
167                                                     const QString& theName,
168                                                     const ObjectKind theObjectKind = KIND_UNKNOWN );
169
170   /**
171    * \brief Generate name for new object.
172    * \param theModule module
173    * \param thePrefix name prefix
174    * \return generated name
175    */
176   static QString                  GenerateObjectName( HYDROGUI_Module* theModule,
177                                                       const QString& thePrefix );
178
179   /**
180    * \brief Get id of the active GraphicsView view.
181    * \param theModule module
182    * \return view id
183    */
184   static size_t                   GetActiveGraphicsViewId( HYDROGUI_Module* theModule );
185
186   /**
187    * \brief Get list of ids of existing GraphicsView views.
188    * \param theModule module
189    * \return list of view ids
190    */
191   static QList<size_t>            GetGraphicsViewIdList( HYDROGUI_Module* theModule );
192
193   /**
194    * \brief Get the list of references (recursively) for the specified image object
195    * \param theImage image data object
196    * \param theRefObjects list of reference objects
197    * \param theRefNames list of reference object names
198    */
199   static void                     GetObjectReferences( const Handle(HYDROData_Image)& theImage,
200                                                        HYDROData_SequenceOfObjects& theRefObjects,
201                                                        QStringList& theRefNames );
202
203   /**
204    * \brief Get the list of back-references for the specified object
205    * \param theModule module
206    * \param theObj data object
207    * \param theBackRefObjects list of back-reference objects
208    * \param theBackRefNames list of back-reference object names
209    */
210   static void                     GetObjectBackReferences( HYDROGUI_Module* theModule,
211                                                            const Handle(HYDROData_Object)& theObj,
212                                                            HYDROData_SequenceOfObjects& theBackRefObjects,
213                                                            QStringList& theBackRefNames );
214 };
215
216 #endif