]> SALOME platform Git repositories - modules/geom.git/blob - src/OBJECT/GEOM_AISShape.hxx
Salome HOME
Fix compilation problem with the DEV OCCT
[modules/geom.git] / src / OBJECT / GEOM_AISShape.hxx
1 // Copyright (C) 2007-2014  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, or (at your option) any later version.
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 //  GEOM OBJECT : interactive object for Geometry entities visualization
24 //  File   : GEOM_AISShape.hxx
25 //  Module : GEOM
26 //
27 #ifndef _GEOM_AISShape_HeaderFile
28 #define _GEOM_AISShape_HeaderFile
29
30 #include "GEOM_OBJECT_defs.hxx"
31
32 #include <GEOM_Gen.hh>
33
34 #ifndef _Standard_HeaderFile
35 #include <Standard.hxx>
36 #endif
37 #ifndef _Handle_GEOM_AISShape_HeaderFile
38 #include "Handle_GEOM_AISShape.hxx"
39 #endif
40
41 #ifndef _Handle_SALOME_InteractiveObject_HeaderFile
42 #include "Handle_SALOME_InteractiveObject.hxx"
43 #endif
44 #ifndef _Standard_CString_HeaderFile
45 #include <Standard_CString.hxx>
46 #endif
47 #ifndef _SALOME_AISShape_HeaderFile
48 #include "SALOME_AISShape.hxx"
49 #endif
50 #ifndef _Standard_Boolean_HeaderFile
51 #include <Standard_Boolean.hxx>
52 #endif
53 #ifndef _PrsMgr_PresentationManager_HeaderFile
54 #include <PrsMgr_PresentationManager.hxx>
55 #endif
56 #ifndef _Handle_Prs3d_Presentation_HeaderFile
57 #include <Handle_Prs3d_Presentation.hxx>
58 #endif
59
60 #include <TCollection_AsciiString.hxx>
61
62 #include <AIS_DisplayMode.hxx>
63 #include <Graphic3d_MaterialAspect.hxx>
64
65 #include <QList>
66 #include <QVariant>
67
68 class Prs3d_Presentation;
69 class SALOME_InteractiveObject;
70 class TopoDS_Shape;
71
72 class GEOM_OBJECT_EXPORT GEOM_AISShape : public SALOME_AISShape {
73
74 public:
75
76     //! Enumeration of display modes
77     typedef enum {
78       //WireFrame,       //!< the same as AIS_WireFrame
79       //Shading,         //!< the same as AIS_Shaded
80       ShadingWithEdges = AIS_Shaded+1, //!< shading with edges
81       TexturedShape = ShadingWithEdges+1, //!< the same as AIS_ExactHLR
82       CustomHighlight = TexturedShape+1
83     } DispMode;
84
85     //! Enumeration of top level display modes
86     typedef enum {
87       TopShowAdditionalWActor = 0,
88       TopKeepCurrent, //!< Keep current display mode
89       TopWireFrame, 
90       TopShading, 
91       TopShadingWithEdges,
92     } TopLevelDispMode;
93
94
95     inline void* operator new(size_t,void* anAddress) 
96       {
97         return anAddress;
98       }
99     inline void* operator new(size_t size) 
100       { 
101         return Standard::Allocate(size); 
102       }
103     inline void  operator delete(void *anAddress) 
104       { 
105         if (anAddress) Standard::Free((Standard_Address&)anAddress); 
106       }
107 //    inline void  operator delete(void *anAddress, size_t size) 
108 //      { 
109 //        if (anAddress) Standard::Free((Standard_Address&)anAddress,size); 
110 //      }
111  // Methods PUBLIC
112  // 
113         GEOM_AISShape(const TopoDS_Shape& shape, const Standard_CString aName);
114         Standard_Boolean hasIO() ;
115         void setIO(const Handle(SALOME_InteractiveObject)& name) ;
116         void setName(const Standard_CString aName) ;
117         Standard_CString getName() ;
118         Standard_Boolean isTopLevel();
119         void setTopLevel(Standard_Boolean);
120         Handle_SALOME_InteractiveObject getIO() ;
121         void highlightSubShapes(const TColStd_IndexedMapOfInteger& aIndexMap, const Standard_Boolean aHighlight );
122         ~GEOM_AISShape();
123
124         void SetShadingColor(const Quantity_Color &aCol);
125         void SetEdgesInShadingColor(const Quantity_Color &aCol);
126         void SetDisplayVectors(bool isShow);
127
128         virtual  void Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
129                                       const Handle(Prs3d_Presentation)& aPresentation,
130                                       const Standard_Integer aMode = 0) ;
131
132         virtual  bool isShowVectors () { return myDisplayVectors; }
133                 virtual  Standard_Boolean switchTopLevel();
134                 virtual  Standard_Boolean toActivate();
135         
136  // Type management
137  //
138         friend Handle_Standard_Type& GEOM_AISShape_Type_();
139         const Handle(Standard_Type)& DynamicType() const;
140         Standard_Boolean             IsKind(const Handle(Standard_Type)&) const;
141
142         void storeIsoNumbers();
143         void restoreIsoNumbers();
144         void resetIsoNumbers();
145
146         void storeBoundaryColors();
147
148         static Quantity_Color topLevelColor();
149   static void           setTopLevelColor(const Quantity_Color c);
150
151   static TopLevelDispMode topLevelDisplayMode();
152   static void             setTopLevelDisplayMode(const TopLevelDispMode dm);
153
154   void setPrevDisplayMode(const Standard_Integer mode);
155   Standard_Integer prevDisplayMode() const {return myPrevDisplayMode;}
156
157   // Field step information
158   void setFieldStepInfo( const GEOM::field_data_type theFieldDataType,
159                          const int theFieldDimension,
160                          const QList<QVariant>& theFieldStepData,
161                          const TCollection_AsciiString& theFieldStepName,
162                          const double theFieldStepRangeMin,
163                          const double theFieldStepRangeMax );
164   void getFieldStepInfo( GEOM::field_data_type& theFieldDataType,
165                          int& theFieldDimension,
166                          QList<QVariant>& theFieldStepData,
167                          TCollection_AsciiString& theFieldStepName,
168                          double& theFieldStepRangeMin,
169                          double& theFieldStepRangeMax ) const;
170
171 protected: 
172   void shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
173                    const Handle(Prs3d_Presentation)& aPrs,
174                    const Standard_Integer aMode);
175
176   void restoreBoundaryColors();
177
178   // Displaying the field data
179   void drawField( const Handle(Prs3d_Presentation)& thePrs,
180                   const bool theIsText = false,
181                   const bool theIsHighlight = false );
182
183   // Auxiliary method to compute a center of mass for the specified shape
184   static Standard_Boolean computeMassCenter( const TopoDS_Shape& theShape,
185                                              gp_Pnt& theCenter );
186
187   Quantity_Color myShadingColor;
188
189   Quantity_Color myFreeBoundaryColor;
190   Quantity_Color myUnFreeBoundaryColor;
191
192   Quantity_Color myEdgesInShadingColor;
193
194   int            myUIsoNumber;
195   int            myVIsoNumber;
196
197 private: 
198   TCollection_AsciiString  myName;
199   bool                     myDisplayVectors;
200   Standard_Boolean         myTopLevel;
201   Standard_Integer         myPrevDisplayMode;
202
203   GEOM::field_data_type    myFieldDataType;
204   int                      myFieldDimension;
205   QList<QVariant>          myFieldStepData;
206   TCollection_AsciiString  myFieldStepName;
207   double                   myFieldStepRangeMin;
208   double                   myFieldStepRangeMax;
209
210   static TopLevelDispMode myTopLevelDm;
211   static Quantity_Color   myTopLevelColor;
212 };
213
214
215 // other inline functions and methods (like "C++: function call" methods)
216 //
217
218
219 #endif