Salome HOME
f666361265248298247f685965fa671af3ac03df
[modules/geom.git] / src / OBJECT / GEOM_AISShape.hxx
1 // Copyright (C) 2007-2015  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 #ifndef _GEOM_AISShape_HeaderFile
24 #define _GEOM_AISShape_HeaderFile
25
26 #include <SALOME_AISShape.hxx>
27 #include <SALOME_InteractiveObject.hxx>
28
29 #include <Standard.hxx>
30 #include <Standard_DefineHandle.hxx>
31 #include <PrsMgr_PresentationManager.hxx>
32 #include <Handle_Prs3d_Presentation.hxx>
33 #include <TCollection_AsciiString.hxx>
34 #include <AIS_DisplayMode.hxx>
35
36 #include <QList>
37 #include <QVariant>
38
39 #include <SALOMEconfig.h>
40 #include CORBA_SERVER_HEADER(GEOM_Gen)
41
42 class TopoDS_Shape;
43
44 class GEOM_AISShape : public SALOME_AISShape
45 {
46 public:
47   //! Enumeration of display modes
48   typedef enum {
49     Wireframe        = AIS_WireFrame,       //!< wireframe
50     Shading          = AIS_Shaded,          //!< shadin
51     ShadingWithEdges,                       //!< shading with edges
52     TexturedShape,                          //!< texture
53     CustomHighlight                         //!< fields
54   } DispMode;
55
56   //! Enumeration of top level display modes
57   typedef enum {
58     TopShowAdditionalWActor = 0,
59     TopKeepCurrent, //!< Keep current display mode
60     TopWireFrame, 
61     TopShading, 
62     TopShadingWithEdges,
63   } TopLevelDispMode;
64   
65   Standard_EXPORT GEOM_AISShape(const TopoDS_Shape& shape, const Standard_CString aName);
66   Standard_EXPORT ~GEOM_AISShape();
67
68   Standard_EXPORT Standard_Boolean                 hasIO();
69   Standard_EXPORT void                             setIO(const Handle(SALOME_InteractiveObject)& name);
70   Standard_EXPORT Handle(SALOME_InteractiveObject) getIO();
71
72   Standard_EXPORT void             setName(const Standard_CString aName);
73   Standard_EXPORT Standard_CString getName();
74
75   Standard_EXPORT Standard_Boolean isTopLevel();
76   Standard_EXPORT void setTopLevel(Standard_Boolean);
77
78   Standard_EXPORT void highlightSubShapes(const TColStd_IndexedMapOfInteger& aIndexMap, const Standard_Boolean aHighlight );
79   
80   Standard_EXPORT void SetShadingColor(const Quantity_Color &aCol);
81   Standard_EXPORT void SetEdgesInShadingColor(const Quantity_Color &aCol);
82   Standard_EXPORT void SetLabelColor(const Quantity_Color &aCol);
83   Standard_EXPORT void SetDisplayVectors(bool isShow);
84   Standard_EXPORT void SetDisplayVertices(bool isShow);
85   Standard_EXPORT void SetDisplayName(bool isShow);
86
87   Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
88                                        const Handle(Prs3d_Presentation)& aPresentation,
89                                        const Standard_Integer aMode = 0);
90   
91   Standard_EXPORT virtual bool isShowVectors() { return myDisplayVectors; }
92   Standard_EXPORT virtual bool isShowVertices() { return myDisplayVertices; }
93   Standard_EXPORT virtual bool isShowName() { return myDisplayName; }
94
95   Standard_EXPORT virtual Standard_Boolean switchTopLevel();
96   Standard_EXPORT virtual Standard_Boolean toActivate();
97         
98   Standard_EXPORT static Quantity_Color topLevelColor();
99   Standard_EXPORT static void           setTopLevelColor(const Quantity_Color c);
100
101   Standard_EXPORT static TopLevelDispMode topLevelDisplayMode();
102   Standard_EXPORT static void             setTopLevelDisplayMode(const TopLevelDispMode dm);
103
104   Standard_EXPORT void setPrevDisplayMode(const Standard_Integer mode);
105   Standard_EXPORT Standard_Integer prevDisplayMode() const {return myPrevDisplayMode;}
106
107   // Field step information
108   Standard_EXPORT void setFieldStepInfo( const GEOM::field_data_type theFieldDataType,
109                                          const int theFieldDimension,
110                                          const QList<QVariant>& theFieldStepData,
111                                          const TCollection_AsciiString& theFieldStepName,
112                                          const double theFieldStepRangeMin,
113                                          const double theFieldStepRangeMax );
114   Standard_EXPORT void getFieldStepInfo( GEOM::field_data_type& theFieldDataType,
115                                          int& theFieldDimension,
116                                          QList<QVariant>& theFieldStepData,
117                                          TCollection_AsciiString& theFieldStepName,
118                                          double& theFieldStepRangeMin,
119                                          double& theFieldStepRangeMax ) const;
120
121 protected: 
122   Standard_EXPORT void shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
123                                    const Handle(Prs3d_Presentation)& aPrs,
124                                    const Standard_Integer aMode);
125   
126   // Displaying the field data
127   Standard_EXPORT void drawField( const Handle(Prs3d_Presentation)& thePrs,
128                                   const bool theIsText = false,
129                                   const bool theIsHighlight = false );
130   
131   // Displaying the name of shape
132   Standard_EXPORT void drawName( const Handle(Prs3d_Presentation)& thePrs );
133
134   // Auxiliary method to compute a center of mass for the specified shape
135   Standard_EXPORT static Standard_Boolean computeMassCenter( const TopoDS_Shape& theShape,
136                                                              gp_Pnt& theCenter );
137   
138 private: 
139   Quantity_Color           myShadingColor;
140   Quantity_Color           myEdgesInShadingColor;
141   Quantity_Color           myLabelColor;
142
143   TCollection_AsciiString  myName;
144   bool                     myDisplayVectors;
145   bool                     myDisplayVertices;
146   bool                     myDisplayName;
147   Standard_Boolean         myTopLevel;
148   Standard_Integer         myPrevDisplayMode;
149
150   GEOM::field_data_type    myFieldDataType;
151   int                      myFieldDimension;
152   QList<QVariant>          myFieldStepData;
153   TCollection_AsciiString  myFieldStepName;
154   double                   myFieldStepRangeMin;
155   double                   myFieldStepRangeMax;
156
157   static TopLevelDispMode  myTopLevelDm;
158   static Quantity_Color    myTopLevelColor;
159
160 public:
161   DEFINE_STANDARD_RTTI(GEOM_AISShape);
162 };
163
164 DEFINE_STANDARD_HANDLE(GEOM_AISShape, SALOME_AISShape)
165
166 #endif