]> SALOME platform Git repositories - modules/visu.git/blob - src/VISUGUI/VisuGUI_Tools.h
Salome HOME
Remove useless files; Use SALOMEDSClient classes instead of CORBA interfaces; fix...
[modules/visu.git] / src / VISUGUI / VisuGUI_Tools.h
1 //  VISU VISUGUI : GUI of VISU component
2 //
3 //  Copyright (C) 2005  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
21 //
22 //
23 //
24 //  File   : VisuGUI_Tools.h
25 //  Author : Sergey Anikin
26 //  Module : VISU
27
28 #ifndef VisuGUI_Tools_HeaderFile
29 #define VisuGUI_Tools_HeaderFile
30
31 #include "SALOME_InteractiveObject.hxx"
32
33 #include "VISUConfig.hh"
34
35 #include "SALOMEDSClient_Study.hxx"
36
37 #include "SALOMEconfig.h"
38 #include CORBA_SERVER_HEADER(MED_Gen)
39
40 class SUIT_Desktop;
41 class SUIT_ViewWindow;
42 class VISU_Actor;
43 class SVTK_ViewWindow;
44 class SPlot2d_Viewer;
45 class CAM_Module;
46 class SalomeApp_Module;
47 class SalomeApp_SelectionMgr;
48 class SalomeApp_Study;
49
50 namespace VISU {
51   class Prs3d_i;
52   class Result_i;
53   class Table_i;
54   class Curve_i;
55   class Container_i;
56
57   typedef std::vector<SVTK_ViewWindow*> TViewWindows;
58
59   SUIT_Desktop*                        GetDesktop(const CAM_Module* theModule);
60   SalomeApp_Study*                     GetAppStudy(const CAM_Module* theModule);
61   _PTR(Study)                          GetCStudy(const SalomeApp_Study* theStudy);
62
63   bool                                 IsStudyLocked( _PTR(Study) theStudy );
64   bool                                 CheckLock( _PTR(Study) theStudy );
65
66   VISU_Gen_i*                          GetVisuGen(const CAM_Module* theModule);
67   SALOME_MED::MED_Gen_var              GetMEDEngine();
68
69   VISU::Storable::TRestoringMap        getMapOfValue(_PTR(SObject) theSObject);
70   QString                              getValue(_PTR(SObject) theSObject, QString theKey);
71
72   // Selection
73   SalomeApp_SelectionMgr*              GetSelectionMgr(const SalomeApp_Module* theModule);
74   CORBA::Object_var                    GetSelectedObj(const SalomeApp_Study* theStudy,
75                                                       const QString& theEntry,
76                                                       VISU::Storable::TRestoringMap* theMap = NULL);
77   CORBA::Object_var                    GetSelectedObj(const SalomeApp_Module* theModule,
78                                                       Handle(SALOME_InteractiveObject)* theIO = NULL,
79                                                       VISU::Storable::TRestoringMap* theMap = NULL);
80
81   void                                 Add(SalomeApp_SelectionMgr* theSelectionMgr,
82                                            const Handle(SALOME_InteractiveObject)& theIO);
83   void                                 Remove(SalomeApp_SelectionMgr* theSelectionMgr,
84                                               const Handle(SALOME_InteractiveObject)& theIO);
85
86   bool                                 IsRemovableSelected(const SalomeApp_Module* theModule);
87
88   // Display/Erase
89   void                                 ErasePrs(const SalomeApp_Module* theModule,
90                                                 CORBA::Object_ptr theObject,
91                                                 bool theUpdate = true);
92   void                                 DeleteSObject(SalomeApp_Module* theModule,
93                                                      _PTR(Study)       theStudy,
94                                                      _PTR(SObject)     theSObject);
95   void                                 DeletePrs3d(SalomeApp_Module* theModule,
96                                                    VISU::Prs3d_i* thePrs,
97                                                    const Handle(SALOME_InteractiveObject)& theIO);
98   void                                 ErasePrs3d(const SalomeApp_Module* theModule,
99                                                   VISU::Prs3d_i* thePrs);
100
101   // Presentation management
102   void ChangeRepresentation (const SalomeApp_Module* theModule,
103                              VISU::PresentationType  theType);
104
105   // SObject type
106   bool                                 CheckTimeStamp(const SalomeApp_Module* theModule,
107                                                       _PTR(SObject)&          theSObject,
108                                                       Handle(SALOME_InteractiveObject)* theIO = NULL);
109   VISU::Result_i*                      CheckResult(const SalomeApp_Module* theModule,
110                                                    _PTR(SObject) theSource,
111                                                    VISU::Result_var& theResult);
112   inline bool                          IsSObjectTable(_PTR(SObject) theSObject);
113
114   // Views
115   SUIT_ViewWindow*                     GetActiveView(const SalomeApp_Module* theModule,
116                                                      QString theType = QString::null);
117
118   // VTK View
119   TViewWindows                         GetViews(const SalomeApp_Module* theModule);
120   SVTK_ViewWindow*                     GetViewWindow(const SalomeApp_Module* theModule,
121                                                      const bool theCreate = false );
122   SVTK_ViewWindow*                     GetViewWindow();
123
124   VISU_Actor*                          PublishInView(const SalomeApp_Module* theModule,
125                                                      VISU::Prs3d_i* thePrs);
126   VISU_Actor*                          UpdateViewer(const SalomeApp_Module* theModule,
127                                                     VISU::Prs3d_i* thePrs,
128                                                     bool theDispOnly = false);
129
130   /*!
131    * \brief Repaint all SVTK view windows, where the given object is displayed.
132    * \param theModule  - is used to access application.
133    * \param theIObject - is supposed to be selected (is highlighted in this method).
134    */
135   void                                 RepaintViewWindows(const SalomeApp_Module* theModule,
136                                                           const Handle(SALOME_InteractiveObject)& theIObject);
137
138   VISU_Actor*                          FindActor(SVTK_ViewWindow* theViewWindow,
139                                                  const char* theEntry);
140   VISU_Actor*                          FindActor(SVTK_ViewWindow* theViewWindow,
141                                                  VISU::Prs3d_i* thePrs);
142   void                                 RecreateActor(const SalomeApp_Module* theModule,
143                                                      VISU::Prs3d_i* thePrs);
144
145   // Plot2d View
146   SPlot2d_Viewer*                      GetPlot2dViewer(const SalomeApp_Module* theModule,
147                                                        const bool theCreate = false);
148   void                                 PlotTable( const SalomeApp_Module* theModule,
149                                                   VISU::Table_i* table,
150                                                   int theDisplaying );
151   void                                 PlotCurve( const SalomeApp_Module* theModule,
152                                                   VISU::Curve_i* curve,
153                                                   int theDisplaying );
154   void                                 PlotContainer( const SalomeApp_Module* theModule,
155                                                       VISU::Container_i* container,
156                                                       int theDisplaying );
157   void                                 CreatePlot( SalomeApp_Module* theModule,
158                                                    _PTR(SObject) theSobj );
159
160   // Others
161   void CreateMesh (const SalomeApp_Module* theModule,
162                    const Handle(SALOME_InteractiveObject)& theIO);
163
164   std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
165                                             const Handle(SALOME_InteractiveObject)& theIO);
166   std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
167                                             _PTR(SObject) theObject);
168 }
169
170 bool VISU::IsSObjectTable( _PTR(SObject) theSObject )
171 {
172   if ( theSObject ) {
173     _PTR(GenericAttribute) anAttr;
174     if (theSObject->FindAttribute( anAttr, "AttributeTableOfInteger" ))
175       return true;
176     if (theSObject->FindAttribute( anAttr, "AttributeTableOfReal" ))
177       return true;
178   }
179   return false;
180 }
181
182 #endif