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 _PrsMgr_PresentationManager_HeaderFile
54 #include <PrsMgr_PresentationManager.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 Prs3d_Presentation;
69 class SALOME_InteractiveObject;
72 class GEOM_OBJECT_EXPORT GEOM_AISShape : public SALOME_AISShape {
76 //! Enumeration of display modes
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
85 //! Enumeration of top level display modes
87 TopShowAdditionalWActor = 0,
88 TopKeepCurrent, //!< Keep current display mode
95 inline void* operator new(size_t,void* anAddress)
99 inline void* operator new(size_t size)
101 return Standard::Allocate(size);
103 inline void operator delete(void *anAddress)
105 if (anAddress) Standard::Free((Standard_Address&)anAddress);
107 // inline void operator delete(void *anAddress, size_t size)
109 // if (anAddress) Standard::Free((Standard_Address&)anAddress,size);
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 );
124 void SetShadingColor(const Quantity_Color &aCol);
125 void SetEdgesInShadingColor(const Quantity_Color &aCol);
126 void SetDisplayVectors(bool isShow);
128 virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
129 const Handle(Prs3d_Presentation)& aPresentation,
130 const Standard_Integer aMode = 0) ;
132 virtual bool isShowVectors () { return myDisplayVectors; }
133 virtual Standard_Boolean switchTopLevel();
134 virtual Standard_Boolean toActivate();
138 friend Handle_Standard_Type& GEOM_AISShape_Type_();
139 const Handle(Standard_Type)& DynamicType() const;
140 Standard_Boolean IsKind(const Handle(Standard_Type)&) const;
142 static Quantity_Color topLevelColor();
143 static void setTopLevelColor(const Quantity_Color c);
145 static TopLevelDispMode topLevelDisplayMode();
146 static void setTopLevelDisplayMode(const TopLevelDispMode dm);
148 void setPrevDisplayMode(const Standard_Integer mode);
149 Standard_Integer prevDisplayMode() const {return myPrevDisplayMode;}
151 // Field step information
152 void setFieldStepInfo( const GEOM::field_data_type theFieldDataType,
153 const int theFieldDimension,
154 const QList<QVariant>& theFieldStepData,
155 const TCollection_AsciiString& theFieldStepName,
156 const double theFieldStepRangeMin,
157 const double theFieldStepRangeMax );
158 void getFieldStepInfo( GEOM::field_data_type& theFieldDataType,
159 int& theFieldDimension,
160 QList<QVariant>& theFieldStepData,
161 TCollection_AsciiString& theFieldStepName,
162 double& theFieldStepRangeMin,
163 double& theFieldStepRangeMax ) const;
166 void shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
167 const Handle(Prs3d_Presentation)& aPrs,
168 const Standard_Integer aMode);
170 // Displaying the field data
171 void drawField( const Handle(Prs3d_Presentation)& thePrs,
172 const bool theIsText = false,
173 const bool theIsHighlight = false );
175 // Auxiliary method to compute a center of mass for the specified shape
176 static Standard_Boolean computeMassCenter( const TopoDS_Shape& theShape,
179 Quantity_Color myShadingColor;
180 Quantity_Color myEdgesInShadingColor;
183 TCollection_AsciiString myName;
184 bool myDisplayVectors;
185 Standard_Boolean myTopLevel;
186 Standard_Integer myPrevDisplayMode;
188 GEOM::field_data_type myFieldDataType;
189 int myFieldDimension;
190 QList<QVariant> myFieldStepData;
191 TCollection_AsciiString myFieldStepName;
192 double myFieldStepRangeMin;
193 double myFieldStepRangeMax;
195 static TopLevelDispMode myTopLevelDm;
196 static Quantity_Color myTopLevelColor;
200 // other inline functions and methods (like "C++: function call" methods)