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