Salome HOME
Feature 32: Image presentation in OCCViewer.
[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 Get the active study id.
93    * \return active study id
94    */
95   static int                      GetActiveStudyId();
96
97   /**
98    * \brief Get path to the temporary directory.
99    * \param theToCreate flag used to create a directory if it doesn't exist
100    * \return path
101    */
102   static QString                  GetTempDir( const bool theToCreate );
103
104   /**
105    * \brief Check that the specified objects are equal.
106    * \param theObj1 first object
107    * \param theObj2 second object
108    */
109   static bool                     IsEqual( const Handle(HYDROData_Object)& theObj1,
110                                            const Handle(HYDROData_Object)& theObj2 );
111
112   /**
113    * \brief Set the specified view manager to be active on the desktop.
114    * \param theModule module
115    * \param theViewManager view manager
116    */
117   static void                     SetActiveViewManager( HYDROGUI_Module* theModule,
118                                                         SUIT_ViewManager* theViewManager );
119
120   /**
121    * \brief Get sub-objects to build presentations.
122    * \param theModule module
123    * \param theSeq sequence of sub-objects
124    */
125   static void                     GetPrsSubObjects( HYDROGUI_Module* theModule,
126                                                     HYDROData_SequenceOfObjects& theSeq );
127
128   /**
129    * \brief Get presentation built for specified data object.
130    * \param theObj data object
131    * \param theObjects list of existing presentations
132    * \return presentation
133    */
134   static HYDROGUI_Prs*            GetPresentation( const Handle(HYDROData_Object)& theObj,
135                                                    const GraphicsView_ObjectList& theObjects );
136
137   /**
138    * \brief Get list of HYDRO presentations from the specified viewport.
139    * \param theViewPort viewport
140    * \return list of HYDRO presentations
141    */
142   static GraphicsView_ObjectList  GetPrsList( GraphicsView_ViewPort* theViewPort );
143
144   /**
145    * \brief Get list of the selected data objects.
146    * \param theModule module
147    * \return list of the selected data objects
148    */
149   static HYDROData_SequenceOfObjects GetSelectedObjects( HYDROGUI_Module* theModule );
150
151   /**
152    * \brief Get the selected data object (first in the selected list).
153    * \param theModule module
154    * \return selected data object
155    */
156   static Handle(HYDROData_Object) GetSelectedObject( HYDROGUI_Module* theModule );
157
158   /**
159    * \brief Get kind of objects the selected partition contains.
160    * \param theModule module
161    * \return object kind
162    */
163   static ObjectKind GetSelectedPartition( HYDROGUI_Module* theModule );
164
165   /**
166    * \brief Find the data object with the specified name.
167    * \param theModule module
168    * \param theName name
169    * \param theObjectKind kind of object
170    * \return data object
171    */
172   static Handle(HYDROData_Object) FindObjectByName( HYDROGUI_Module* theModule,
173                                                     const QString& theName,
174                                                     const ObjectKind theObjectKind = KIND_UNKNOWN );
175
176   /**
177    * \brief Find the data objects with the specified names.
178    * \param theModule module
179    * \param theNames list of names
180    * \param theObjectKind kind of object
181    * \return list of data objects
182    */
183   static HYDROData_SequenceOfObjects FindObjectsByNames( HYDROGUI_Module*   theModule,
184                                                          const QStringList& theNames,
185                                                          const ObjectKind   theObjectKind = KIND_UNKNOWN );
186
187   /**
188    * \brief Generate name for new object.
189    * \param theModule module
190    * \param thePrefix name prefix
191    * \param theUsedNames list of already used names
192    * \return generated name
193    */
194   static QString                  GenerateObjectName( HYDROGUI_Module*   theModule,
195                                                       const QString&     thePrefix,
196                                                       const QStringList& theUsedNames = QStringList() );
197
198   /**
199    * \brief Get id of the active view.
200    * \param theModule module
201    * \return view id
202    */
203   static size_t                   GetActiveViewId( HYDROGUI_Module* theModule,
204                                                    const QString&   theViewId = QString() );
205
206   /**
207    * \brief Get id of the active GraphicsView view.
208    * \param theModule module
209    * \return view id
210    */
211   static size_t                   GetActiveGraphicsViewId( HYDROGUI_Module* theModule );
212
213   /**
214    * \brief Get id of the active OCC view.
215    * \param theModule module
216    * \return view id
217    */
218   static size_t                   GetActiveOCCViewId( HYDROGUI_Module* theModule );
219
220   /**
221    * \brief Get list of ids of existing GraphicsView views.
222    * \param theModule module
223    * \return list of view ids
224    */
225   static QList<size_t>            GetGraphicsViewIdList( HYDROGUI_Module* theModule );
226
227   /**
228    * \brief Get list of ids of existing OCC views.
229    * \param theModule module
230    * \return list of view ids
231    */
232   static QList<size_t>            GetOCCViewIdList( HYDROGUI_Module* theModule );
233
234   /**
235    * \brief Get the list of references (recursively) for the specified image object
236    * \param theImage image data object
237    * \param theRefObjects list of reference objects
238    * \param theRefNames list of reference object names
239    */
240   static void                     GetObjectReferences( const Handle(HYDROData_Image)& theImage,
241                                                        HYDROData_SequenceOfObjects& theRefObjects,
242                                                        QStringList& theRefNames );
243
244   /**
245    * \brief Get the list of back-references for the specified object
246    * \param theModule module
247    * \param theObj data object
248    * \param theBackRefObjects list of back-reference objects
249    * \param theBackRefNames list of back-reference object names
250    */
251   static void                     GetObjectBackReferences( HYDROGUI_Module* theModule,
252                                                            const Handle(HYDROData_Object)& theObj,
253                                                            HYDROData_SequenceOfObjects& theBackRefObjects,
254                                                            QStringList& theBackRefNames );
255
256   /**
257    * \brief Get father dock window for widget 
258    * \param wid widget
259    * \return dock window
260    */
261   static QDockWidget*             WindowDock( QWidget* wid );
262
263   /**
264    * \brief Generates the filling color for intersected zone
265    * \param theModule module
266    * \param theZoneNames list of intersected zones
267    * \return result color
268    */
269   static QColor                   GenerateFillingColor( HYDROGUI_Module*   theModule,
270                                                         const QStringList& theZoneNames );
271
272 };
273
274 #endif