1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // GEOM OBJECT : interactive object for Geometry entities visualization
24 // File : GEOM_AISShape.hxx
27 #ifndef _GEOM_AISShape_HeaderFile
28 #define _GEOM_AISShape_HeaderFile
30 #include "GEOM_OBJECT_defs.hxx"
32 #include <GEOM_Gen.hh>
34 #ifndef _Standard_HeaderFile
35 #include <Standard.hxx>
37 #ifndef _Handle_GEOM_AISShape_HeaderFile
38 #include "Handle_GEOM_AISShape.hxx"
41 #ifndef _Handle_SALOME_InteractiveObject_HeaderFile
42 #include "Handle_SALOME_InteractiveObject.hxx"
44 #ifndef _Standard_CString_HeaderFile
45 #include <Standard_CString.hxx>
47 #ifndef _SALOME_AISShape_HeaderFile
48 #include "SALOME_AISShape.hxx"
50 #ifndef _Standard_Boolean_HeaderFile
51 #include <Standard_Boolean.hxx>
53 #ifndef _Handle_PrsMgr_PresentationManager3d_HeaderFile
54 #include <Handle_PrsMgr_PresentationManager3d.hxx>
56 #ifndef _Handle_Prs3d_Presentation_HeaderFile
57 #include <Handle_Prs3d_Presentation.hxx>
60 #include <TCollection_AsciiString.hxx>
62 #include <AIS_DisplayMode.hxx>
63 #include <Graphic3d_MaterialAspect.hxx>
68 class PrsMgr_PresentationManager3d;
69 class Prs3d_Presentation;
70 class SALOME_InteractiveObject;
73 class GEOM_OBJECT_EXPORT GEOM_AISShape : public SALOME_AISShape {
77 //! Enumeration of display modes
79 //WireFrame, //!< the same as AIS_WireFrame
80 //Shading, //!< the same as AIS_Shaded
81 ShadingWithEdges = AIS_Shaded+1, //!< shading with edges
82 TexturedShape = ShadingWithEdges+1, //!< the same as AIS_ExactHLR
83 CustomHighlight = TexturedShape+1
86 //! Enumeration of top level display modes
88 TopShowAdditionalWActor = 0,
89 TopKeepCurrent, //!< Keep current display mode
96 inline void* operator new(size_t,void* anAddress)
100 inline void* operator new(size_t size)
102 return Standard::Allocate(size);
104 inline void operator delete(void *anAddress)
106 if (anAddress) Standard::Free((Standard_Address&)anAddress);
108 // inline void operator delete(void *anAddress, size_t size)
110 // if (anAddress) Standard::Free((Standard_Address&)anAddress,size);
114 GEOM_AISShape(const TopoDS_Shape& shape, const Standard_CString aName);
115 Standard_Boolean hasIO() ;
116 void setIO(const Handle(SALOME_InteractiveObject)& name) ;
117 void setName(const Standard_CString aName) ;
118 Standard_CString getName() ;
119 Standard_Boolean isTopLevel();
120 void setTopLevel(Standard_Boolean);
121 Handle_SALOME_InteractiveObject getIO() ;
122 void highlightSubShapes(const TColStd_IndexedMapOfInteger& aIndexMap, const Standard_Boolean aHighlight );
125 void SetShadingColor(const Quantity_Color &aCol);
126 void SetEdgesInShadingColor(const Quantity_Color &aCol);
127 void SetDisplayVectors(bool isShow);
129 virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
130 const Handle(Prs3d_Presentation)& aPresentation,
131 const Standard_Integer aMode = 0) ;
133 virtual bool isShowVectors () { return myDisplayVectors; }
134 virtual Standard_Boolean switchTopLevel();
135 virtual Standard_Boolean toActivate();
139 friend Handle_Standard_Type& GEOM_AISShape_Type_();
140 const Handle(Standard_Type)& DynamicType() const;
141 Standard_Boolean IsKind(const Handle(Standard_Type)&) const;
143 void storeIsoNumbers();
144 void restoreIsoNumbers();
145 void resetIsoNumbers();
147 void storeBoundaryColors();
149 static Quantity_Color topLevelColor();
150 static void setTopLevelColor(const Quantity_Color c);
152 static TopLevelDispMode topLevelDisplayMode();
153 static void setTopLevelDisplayMode(const TopLevelDispMode dm);
155 void setPrevDisplayMode(const Standard_Integer mode);
156 Standard_Integer prevDisplayMode() const {return myPrevDisplayMode;}
158 // Field step information
159 void setFieldStepInfo( const GEOM::field_data_type theFieldDataType,
160 const int theFieldDimension,
161 const QList<QVariant>& theFieldStepData,
162 const TCollection_AsciiString& theFieldStepName,
163 const double theFieldStepRangeMin,
164 const double theFieldStepRangeMax );
165 void getFieldStepInfo( GEOM::field_data_type& theFieldDataType,
166 int& theFieldDimension,
167 QList<QVariant>& theFieldStepData,
168 TCollection_AsciiString& theFieldStepName,
169 double& theFieldStepRangeMin,
170 double& theFieldStepRangeMax ) const;
173 void shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
174 const Handle(Prs3d_Presentation)& aPrs,
175 const Standard_Integer aMode);
177 void restoreBoundaryColors();
179 // Displaying the field data
180 void drawField( const Handle(Prs3d_Presentation)& thePrs,
181 const bool theIsText = false,
182 const bool theIsHighlight = false );
184 // Auxiliary method to compute a center of mass for the specified shape
185 static Standard_Boolean computeMassCenter( const TopoDS_Shape& theShape,
188 Quantity_Color myShadingColor;
190 Quantity_Color myFreeBoundaryColor;
191 Quantity_Color myUnFreeBoundaryColor;
193 Quantity_Color myEdgesInShadingColor;
199 TCollection_AsciiString myName;
200 bool myDisplayVectors;
201 Standard_Boolean myTopLevel;
202 Standard_Integer myPrevDisplayMode;
204 GEOM::field_data_type myFieldDataType;
205 int myFieldDimension;
206 QList<QVariant> myFieldStepData;
207 TCollection_AsciiString myFieldStepName;
208 double myFieldStepRangeMin;
209 double myFieldStepRangeMax;
211 static TopLevelDispMode myTopLevelDm;
212 static Quantity_Color myTopLevelColor;
216 // other inline functions and methods (like "C++: function call" methods)