Salome HOME
Sinchronize clipped presentation in all 3D views; update highlighting box
[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(SALOMEDS)
39 #include CORBA_SERVER_HEADER(VISU_Gen)
40 #include CORBA_SERVER_HEADER(MED_Gen)
41
42 class SUIT_Desktop;
43 class SUIT_ViewWindow;
44 class VISU_Actor;
45 class SVTK_ViewWindow;
46 class SPlot2d_Viewer;
47 class CAM_Module;
48 class SalomeApp_Module;
49 class SalomeApp_SelectionMgr;
50 class SalomeApp_Study;
51
52 namespace VISU {
53   class Prs3d_i;
54   class Result_i;
55   class Table_i;
56   class Curve_i;
57   class Container_i;
58
59   typedef std::vector<SVTK_ViewWindow*> TViewWindows;
60
61   SUIT_Desktop*                        GetDesktop(const CAM_Module* theModule);
62   SalomeApp_Study*                     GetAppStudy(const CAM_Module* theModule);
63   _PTR(Study)                          GetCStudy(const SalomeApp_Study* theStudy);
64   SALOMEDS::StudyManager_var           GetStudyManager();
65
66   bool                                 IsStudyLocked( _PTR(Study) theStudy );
67   bool                                 CheckLock( _PTR(Study) theStudy );
68
69   VISU_Gen_i*                          GetVisuGen(const CAM_Module* theModule);
70   SALOME_MED::MED_Gen_var              GetMEDEngine();
71
72   VISU::Storable::TRestoringMap        getMapOfValue(SALOMEDS::SObject_var theSObject);
73   VISU::Storable::TRestoringMap        getMapOfValue(_PTR(SObject) theSObject);
74   QString                              getValue(SALOMEDS::SObject_var theSObject, QString theKey);
75   QString                              getValue(_PTR(SObject) theSObject, QString theKey);
76
77   // Selection
78   SalomeApp_SelectionMgr*              GetSelectionMgr(const SalomeApp_Module* theModule);
79   CORBA::Object_var                    GetSelectedObj(const SalomeApp_Study* theStudy,
80                                                       const QString& theEntry,
81                                                       VISU::Storable::TRestoringMap* theMap = NULL);
82   CORBA::Object_var                    GetSelectedObj(const SalomeApp_Module* theModule,
83                                                       Handle(SALOME_InteractiveObject)* theIO = NULL,
84                                                       VISU::Storable::TRestoringMap* theMap = NULL);
85
86   void                                 Add(SalomeApp_SelectionMgr* theSelectionMgr,
87                                            const Handle(SALOME_InteractiveObject)& theIO);
88   void                                 Remove(SalomeApp_SelectionMgr* theSelectionMgr,
89                                               const Handle(SALOME_InteractiveObject)& theIO);
90
91   bool                                 IsRemovableSelected(const SalomeApp_Module* theModule);
92
93   // Display/Erase
94   void                                 ErasePrs(const SalomeApp_Module* theModule,
95                                                 CORBA::Object_ptr theObject,
96                                                 bool theUpdate = true);
97   void                                 DeleteSObject(SalomeApp_Module* theModule,
98                                                      SALOMEDS::Study_ptr theStudy,
99                                                      SALOMEDS::SObject_ptr theSObject);
100   void                                 DeletePrs3d(SalomeApp_Module* theModule,
101                                                    VISU::Prs3d_i* thePrs,
102                                                    const Handle(SALOME_InteractiveObject)& theIO);
103   void                                 ErasePrs3d(const SalomeApp_Module* theModule,
104                                                   VISU::Prs3d_i* thePrs);
105
106   // Presentation management
107   void ChangeRepresentation (const SalomeApp_Module* theModule,
108                              VISU::PresentationType  theType);
109
110   // SObject type
111   bool                                 CheckTimeStamp(const SalomeApp_Module* theModule,
112                                                       SALOMEDS::SObject_var& theSObject,
113                                                       Handle(SALOME_InteractiveObject)* theIO = NULL);
114   VISU::Result_i*                      CheckResult(const SalomeApp_Module* theModule,
115                                                    SALOMEDS::SObject_var theSource,
116                                                    VISU::Result_var& theResult);
117   inline bool                          IsSObjectTable(_PTR(SObject) theSObject);
118
119   // Views
120   SUIT_ViewWindow*                     GetActiveView(const SalomeApp_Module* theModule,
121                                                      QString theType = QString::null);
122
123   // VTK View
124   TViewWindows                         GetViews(const SalomeApp_Module* theModule);
125   SVTK_ViewWindow*                     GetViewWindow(const SalomeApp_Module* theModule,
126                                                      const bool theCreate = false );
127   SVTK_ViewWindow*                     GetViewWindow();
128
129   VISU_Actor*                          PublishInView(const SalomeApp_Module* theModule,
130                                                      VISU::Prs3d_i* thePrs);
131   VISU_Actor*                          UpdateViewer(const SalomeApp_Module* theModule,
132                                                     VISU::Prs3d_i* thePrs,
133                                                     bool theDispOnly = false);
134
135   /*!
136    * \brief Repaint all SVTK view windows, where the given object is displayed.
137    * \param theModule  - is used to access application.
138    * \param theIObject - is supposed to be selected (is highlighted in this method).
139    */
140   void                                 RepaintViewWindows(const SalomeApp_Module* theModule,
141                                                           const Handle(SALOME_InteractiveObject)& theIObject);
142
143   VISU_Actor*                          FindActor(SVTK_ViewWindow* theViewWindow,
144                                                  const char* theEntry);
145   VISU_Actor*                          FindActor(SVTK_ViewWindow* theViewWindow,
146                                                  VISU::Prs3d_i* thePrs);
147   void                                 RecreateActor(const SalomeApp_Module* theModule,
148                                                      VISU::Prs3d_i* thePrs);
149
150   // Plot2d View
151   SPlot2d_Viewer*                      GetPlot2dViewer(const SalomeApp_Module* theModule,
152                                                        const bool theCreate = false);
153   void                                 PlotTable( const SalomeApp_Module* theModule,
154                                                   VISU::Table_i* table,
155                                                   int theDisplaying );
156   void                                 PlotCurve( const SalomeApp_Module* theModule,
157                                                   VISU::Curve_i* curve,
158                                                   int theDisplaying );
159   void                                 PlotContainer( const SalomeApp_Module* theModule,
160                                                       VISU::Container_i* container,
161                                                       int theDisplaying );
162   void                                 CreatePlot( SalomeApp_Module* theModule,
163                                                    _PTR(SObject) theSobj );
164
165   // Others
166   void CreateMesh (const SalomeApp_Module* theModule,
167                    const Handle(SALOME_InteractiveObject)& theIO);
168
169   std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
170                                             const Handle(SALOME_InteractiveObject)& theIO);
171   std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
172                                             SALOMEDS::SObject_ptr theObject);
173 }
174
175 bool VISU::IsSObjectTable( _PTR(SObject) theSObject )
176 {
177   if ( theSObject ) {
178     _PTR(GenericAttribute) anAttr;
179     if (theSObject->FindAttribute( anAttr, "AttributeTableOfInteger" ))
180       return true;
181     if (theSObject->FindAttribute( anAttr, "AttributeTableOfReal" ))
182       return true;
183   }
184   return false;
185 }
186
187 #endif