Salome HOME
Prevent exception at shape selection if no mesh was pre-selected
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_VTKUtils.h
1 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
3 // 
4 //  This library is free software; you can redistribute it and/or 
5 //  modify it under the terms of the GNU Lesser General Public 
6 //  License as published by the Free Software Foundation; either 
7 //  version 2.1 of the License. 
8 // 
9 //  This library is distributed in the hope that it will be useful, 
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 //  Lesser General Public License for more details. 
13 // 
14 //  You should have received a copy of the GNU Lesser General Public 
15 //  License along with this library; if not, write to the Free Software 
16 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
17 // 
18 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
19
20 #ifndef SMESHGUI_VTKUtils_HeaderFile
21 #define SMESHGUI_VTKUtils_HeaderFile
22
23 class QString;
24 class vtkRenderer;  
25 class TColStd_IndexedMapOfInteger;
26
27 #include "SALOME_InteractiveObject.hxx"
28 #include "VTKViewer_Filter.h"
29
30 class QAD_Study;
31 class QAD_StudyFrame;
32 class SALOME_Selection;
33 class VTKViewer_ViewFrame;
34 class VTKViewer_InteractorStyleSALOME;
35
36 #include <CORBA.h>
37
38 #include "SALOMEconfig.h"
39 #include CORBA_CLIENT_HEADER(SALOMEDS)
40
41 #include <boost/shared_ptr.hpp>
42 #include "SMESH_Object.h"
43
44 class SALOME_Actor;
45 class SMESH_Actor;
46
47 namespace SMESH{
48
49   //----------------------------------------------------------------------------
50   typedef pair<int,string> TKeyOfVisualObj;
51   
52   TVisualObjPtr GetVisualObj(int theStudyId, 
53                              const char* theEntry);
54
55
56   //----------------------------------------------------------------------------
57   QAD_StudyFrame* GetActiveStudyFrame();
58
59   VTKViewer_ViewFrame* FindVtkViewFrame(QAD_Study* theStudy,
60                                         QAD_StudyFrame* theStudyFrame);
61
62   VTKViewer_ViewFrame* GetVtkViewFrame(QAD_StudyFrame* theStudyFrame);
63
64   VTKViewer_ViewFrame* GetCurrentVtkView();
65
66   void RepaintViewFrame(VTKViewer_ViewFrame* theFrame);
67
68   void RenderViewFrame(VTKViewer_ViewFrame* theFrame);
69
70   //----------------------------------------------------------------------------
71   SMESH_Actor* FindActorByEntry(QAD_StudyFrame *theStudyFrame, 
72                                 const char* theEntry);
73   SMESH_Actor* FindActorByEntry(const char* theEntry);
74
75   SMESH_Actor* FindActorByObject(CORBA::Object_ptr theObject);
76
77
78   //----------------------------------------------------------------------------
79   SMESH_Actor* CreateActor(SALOMEDS::Study_ptr theStudy,
80                            const char* theEntry,
81                            int theIsClear = false);
82
83   void DisplayActor(QAD_StudyFrame *theStudyFrame, 
84                     SMESH_Actor* theActor);
85   void RemoveActor(QAD_StudyFrame *theStudyFrame, 
86                    SMESH_Actor* theActor);
87
88
89   //----------------------------------------------------------------------------
90   enum EDisplaing {eDisplayAll, eDisplay, eDisplayOnly, eErase, eEraseAll};
91   void UpdateView(QAD_StudyFrame *theStudyFrame, 
92                   EDisplaing theAction, 
93                   const char* theEntry = "");
94   void UpdateView(EDisplaing theAction, 
95                   const char* theEntry = "");
96
97   void UpdateView();
98
99   void Update(const Handle(SALOME_InteractiveObject)& theIO,
100               bool theDisplay);
101
102
103   //----------------------------------------------------------------------------
104   void FitAll();
105
106   void RepaintCurrentView();
107
108   vtkRenderer* GetCurrentRenderer();
109
110
111   //----------------------------------------------------------------------------
112   void SetPointRepresentation(bool theIsVisible);
113
114   void SetPickable(SMESH_Actor* theActor = NULL);
115
116   void UpdateSelectionProp();
117
118
119   //----------------------------------------------------------------------------
120   VTKViewer_InteractorStyleSALOME* 
121     GetInteractorStyle(QAD_StudyFrame *theStudyFrame = GetActiveStudyFrame());
122
123   void SetFilter(const Handle(VTKViewer_Filter)& theFilter,
124                  VTKViewer_InteractorStyleSALOME* theStyle = GetInteractorStyle());
125
126   Handle(VTKViewer_Filter) 
127     GetFilter(int theId, VTKViewer_InteractorStyleSALOME* theStyle = GetInteractorStyle());
128
129   bool IsFilterPresent(int theId, 
130                        VTKViewer_InteractorStyleSALOME* theStyle = GetInteractorStyle());
131
132   void RemoveFilter(int theId, 
133                     VTKViewer_InteractorStyleSALOME* theStyle = GetInteractorStyle());
134
135   bool IsValid(SALOME_Actor* theActor, int theCellId,
136                VTKViewer_InteractorStyleSALOME* theStyle = GetInteractorStyle());
137
138   //----------------------------------------------------------------------------
139   int GetNameOfSelectedNodes(SALOME_Selection *theSel, 
140                              const Handle(SALOME_InteractiveObject)& theIO, 
141                              QString& theName);
142
143   int GetNameOfSelectedNodes(SALOME_Selection *theSel, 
144                              QString& aName);
145
146   int GetNameOfSelectedElements(SALOME_Selection *theSel, 
147                                 const Handle(SALOME_InteractiveObject)& theIO, 
148                                 QString& theName);
149
150   int GetNameOfSelectedElements(SALOME_Selection *theSel, 
151                                 QString& aName);
152
153   int GetSelected(SALOME_Selection* theSel, 
154                   TColStd_IndexedMapOfInteger& theMap, 
155                   const bool theIsElement = true );
156
157   int GetEdgeNodes(SALOME_Selection* theSel, int& theId1, int& theId2);
158
159   void SetControlsPrecision( const long theVal );
160
161 };
162
163
164 #endif
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192