Salome HOME
OCC displayer implementation.
[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 class QDockWidget;
43
44 /**
45  * \class HYDROGUI_Tool
46  * \brief This class contains several useful methods.
47  */
48 class HYDROGUI_Tool
49 {
50 public:
51   /**
52    * \brief Convert \a TCollection_AsciiString to \a QString
53    */
54   static QString                                  ToQString( const TCollection_AsciiString& );
55
56   /**
57    * \brief Convert \a TCollection_ExtendedString to \a QString
58    */
59   static QString                                  ToQString( const TCollection_ExtendedString& );
60
61   /**
62    * \brief Convert \a Handle_TCollection_HAsciiString to \a QString
63    */
64   static QString                                  ToQString( const Handle(TCollection_HAsciiString)& );
65
66   /**
67    * \brief Convert \a Handle_TCollection_HExtendedString to \a QString
68    */
69   static QString                                  ToQString( const Handle(TCollection_HExtendedString)& );
70
71   /**
72    * \brief Convert \a QString to \a TCollection_AsciiString
73    */
74   static TCollection_AsciiString                  ToAsciiString( const QString& );
75
76   /**
77    * \brief Convert \a QString to \a TCollection_ExtendedString
78    */
79   static TCollection_ExtendedString               ToExtString( const QString& );
80
81   /**
82    * \brief Convert \a QString to \a Handle_TCollection_HAsciiString
83    */
84   static Handle(TCollection_HAsciiString)         ToHAsciiString( const QString& );
85
86   /**
87    * \brief Convert \a QString to \a Handle_TCollection_HExtendedString
88    */
89   static Handle(TCollection_HExtendedString)      ToHExtString( const QString& );
90
91   /**
92    * \brief Encode the Lambert93 coordinates to the absolute double value
93    */
94   static void                     LambertToDouble( const int theDegrees,
95                                                    const int theMinutes,
96                                                    const double theSeconds,
97                                                    double& theCoord );
98
99   /**
100    * \brief Decode the Lambert93 coordinates from the absolute double value
101    */
102   static void                     DoubleToLambert( const double theCoord,
103                                                    int& theDegrees,
104                                                    int& theMinutes,
105                                                    double& theSeconds );
106
107   /**
108    * \brief Check that the specified objects are equal.
109    * \param theObj1 first object
110    * \param theObj2 second object
111    */
112   static bool                     IsEqual( const Handle(HYDROData_Object)& theObj1,
113                                            const Handle(HYDROData_Object)& theObj2 );
114
115   /**
116    * \brief Set the specified view manager to be active on the desktop.
117    * \param theModule module
118    * \param theViewManager view manager
119    */
120   static void                     SetActiveViewManager( HYDROGUI_Module* theModule,
121                                                         SUIT_ViewManager* theViewManager );
122
123   /**
124    * \brief Get sub-objects to build presentations.
125    * \param theModule module
126    * \param theSeq sequence of sub-objects
127    */
128   static void                     GetPrsSubObjects( HYDROGUI_Module* theModule,
129                                                     HYDROData_SequenceOfObjects& theSeq );
130
131   /**
132    * \brief Get presentation built for specified data object.
133    * \param theObj data object
134    * \param theObjects list of existing presentations
135    * \return presentation
136    */
137   static HYDROGUI_Prs*            GetPresentation( const Handle(HYDROData_Object)& theObj,
138                                                    const GraphicsView_ObjectList& theObjects );
139
140   /**
141    * \brief Get list of HYDRO presentations from the specified viewport.
142    * \param theViewPort viewport
143    * \return list of HYDRO presentations
144    */
145   static GraphicsView_ObjectList  GetPrsList( GraphicsView_ViewPort* theViewPort );
146
147   /**
148    * \brief Get list of the selected data objects.
149    * \param theModule module
150    * \return list of the selected data objects
151    */
152   static HYDROData_SequenceOfObjects GetSelectedObjects( HYDROGUI_Module* theModule );
153
154   /**
155    * \brief Get the selected data object (first in the selected list).
156    * \param theModule module
157    * \return selected data object
158    */
159   static Handle(HYDROData_Object) GetSelectedObject( HYDROGUI_Module* theModule );
160
161   /**
162    * \brief Get kind of objects the selected partition contains.
163    * \param theModule module
164    * \return object kind
165    */
166   static ObjectKind GetSelectedPartition( HYDROGUI_Module* theModule );
167
168   /**
169    * \brief Find the data object with the specified name.
170    * \param theModule module
171    * \param theName name
172    * \param theObjectKind kind of object
173    * \return data object
174    */
175   static Handle(HYDROData_Object) FindObjectByName( HYDROGUI_Module* theModule,
176                                                     const QString& theName,
177                                                     const ObjectKind theObjectKind = KIND_UNKNOWN );
178
179   /**
180    * \brief Find the data objects with the specified names.
181    * \param theModule module
182    * \param theNames list of names
183    * \param theObjectKind kind of object
184    * \return list of data objects
185    */
186   static HYDROData_SequenceOfObjects FindObjectsByNames( HYDROGUI_Module*   theModule,
187                                                          const QStringList& theNames,
188                                                          const ObjectKind   theObjectKind = KIND_UNKNOWN );
189
190   /**
191    * \brief Generate name for new object.
192    * \param theModule module
193    * \param thePrefix name prefix
194    * \param theUsedNames list of already used names
195    * \return generated name
196    */
197   static QString                  GenerateObjectName( HYDROGUI_Module*   theModule,
198                                                       const QString&     thePrefix,
199                                                       const QStringList& theUsedNames = QStringList() );
200
201   /**
202    * \brief Get id of the active view.
203    * \param theModule module
204    * \return view id
205    */
206   static size_t                   GetActiveViewId( HYDROGUI_Module* theModule,
207                                                    const QString&   theViewId = QString() );
208
209   /**
210    * \brief Get id of the active GraphicsView view.
211    * \param theModule module
212    * \return view id
213    */
214   static size_t                   GetActiveGraphicsViewId( HYDROGUI_Module* theModule );
215
216   /**
217    * \brief Get id of the active OCC view.
218    * \param theModule module
219    * \return view id
220    */
221   static size_t                   GetActiveOCCViewId( HYDROGUI_Module* theModule );
222
223   /**
224    * \brief Get list of ids of existing GraphicsView views.
225    * \param theModule module
226    * \return list of view ids
227    */
228   static QList<size_t>            GetGraphicsViewIdList( HYDROGUI_Module* theModule );
229
230   /**
231    * \brief Get list of ids of existing OCC views.
232    * \param theModule module
233    * \return list of view ids
234    */
235   static QList<size_t>            GetOCCViewIdList( HYDROGUI_Module* theModule );
236
237   /**
238    * \brief Get the list of references (recursively) for the specified image object
239    * \param theImage image data object
240    * \param theRefObjects list of reference objects
241    * \param theRefNames list of reference object names
242    */
243   static void                     GetObjectReferences( const Handle(HYDROData_Image)& theImage,
244                                                        HYDROData_SequenceOfObjects& theRefObjects,
245                                                        QStringList& theRefNames );
246
247   /**
248    * \brief Get the list of back-references for the specified object
249    * \param theModule module
250    * \param theObj data object
251    * \param theBackRefObjects list of back-reference objects
252    * \param theBackRefNames list of back-reference object names
253    */
254   static void                     GetObjectBackReferences( HYDROGUI_Module* theModule,
255                                                            const Handle(HYDROData_Object)& theObj,
256                                                            HYDROData_SequenceOfObjects& theBackRefObjects,
257                                                            QStringList& theBackRefNames );
258
259   /**
260    * \brief Get father dock window for widget 
261    * \param wid widget
262    * \return dock window
263    */
264   static QDockWidget*             WindowDock( QWidget* wid );
265
266   /**
267    * \brief Generates the filling color for intersected zone
268    * \param theModule module
269    * \param theZoneNames list of intersected zones
270    * \return result color
271    */
272   static QColor                   GenerateFillingColor( HYDROGUI_Module*   theModule,
273                                                         const QStringList& theZoneNames );
274
275 };
276
277 #endif