Salome HOME
Merge branch 'BR_LAND_COVER_MAP' into BR_quadtree
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Shape.h
1 // Copyright (C) 2014-2015  EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
6 //
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10 // Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #ifndef HYDROGUI_SHAPE_H
20 #define HYDROGUI_SHAPE_H
21
22 #include <HYDROData_Entity.h>
23
24 #include <AIS_InteractiveContext.hxx>
25 #include <TopoDS_Shape.hxx>
26
27 #include <QColor>
28
29 class TopoDS_Compound;
30 class TopoDS_Face;
31 class TopoDS_Wire;
32
33 class HYDROGUI_Shape
34 {
35 public:
36   HYDROGUI_Shape( const Handle(AIS_InteractiveContext)& theContext,
37                   const Handle(HYDROData_Entity)&       theObject,
38                   const int                             theZLayer = -1 );
39   virtual ~HYDROGUI_Shape();
40
41 public:
42   virtual void               display( const bool theIsUpdateViewer = true );
43   virtual void               erase( const bool theIsUpdateViewer = true );
44
45   virtual void               highlight( bool theIsHighlight, bool isUpdateViewer );
46   virtual bool               isHighlighted() const;
47
48   Handle(AIS_InteractiveContext) getContext() const;
49   Handle(HYDROData_Entity)   getObject() const;
50   TopoDS_Shape               getTopoShape() const;
51
52   virtual void               update( bool isUpdateViewer,
53                                      bool isDeactivateSelection );
54
55   virtual bool               getIsToUpdate() const;
56   virtual void               setIsToUpdate( bool theState );
57
58   virtual bool               isVisible() const;
59   virtual void               setVisible( const bool theState,
60                                          const bool theIsUpdateViewer = true );
61
62   virtual void               setWire( const TopoDS_Wire& theWire,
63                                       const bool         theToDisplay = true,
64                                       const bool         theIsUpdateViewer = true );
65
66   virtual void               setFaces( const TopoDS_Compound& theWires,
67                                        const bool             theToDisplay = true,
68                                        const bool             theIsUpdateViewer = true );
69
70   virtual void               setFace( const TopoDS_Wire& theWire,
71                                       const bool         theToDisplay,
72                                       const bool         theIsUpdateViewer,
73                                       const QString&     theTextureFileName );
74
75   virtual void               setFace( const TopoDS_Face& theFace,
76                                       const bool         theToDisplay,
77                                       const bool         theIsUpdateViewer,
78                                       const QString&     theTextureFileName );
79
80   virtual void               setShape( const TopoDS_Shape& theShape,
81                                        const bool          theToDisplay = true,
82                                        const bool          theIsUpdateViewer = true,
83                                        const int           theDisplayMode = AIS_Shaded );
84
85   virtual void               setFillingColor( const QColor& theColor,
86                                               const bool    theToDisplay = true,
87                                               const bool    theIsUpdateViewer = true );
88   virtual QColor             getFillingColor() const;
89
90   virtual void               setBorderColor( const QColor& theColor,
91                                              const bool    theToDisplay = true,
92                                              const bool    theIsUpdateViewer = true );
93   virtual QColor             getBorderColor() const;
94
95   virtual void               setHighlightColor( const QColor& theColor );
96   virtual QColor             getHighlightColor() const;
97
98   virtual Handle(AIS_InteractiveObject)  getAISObject() const;
99
100   void                       setZLayer( const int theZLayer );
101
102   void                       setSelectionMode( int theSelectionMode );
103
104 protected:
105   virtual void               buildShape();
106   virtual void               updateShape( const bool theToDisplay      = true,
107                                           const bool theIsUpdateViewer = true );
108   virtual void               displayShape( const bool theIsUpdateViewer );
109   virtual void               eraseShape( const bool theIsUpdateViewer );
110
111   virtual QColor             getActiveColor() const;
112   virtual Handle_AIS_InteractiveObject createShape() const;
113
114   void setDisplayMode( int theDisplayMode );
115
116 private:
117   static double              getQuantityColorVal( const int theColorVal );
118   void                       colorShapeBorder( const QColor& theColor );
119
120 private:
121   Handle(AIS_InteractiveContext) myContext;
122   Handle(HYDROData_Entity)       myObject;
123   Handle(AIS_InteractiveObject)  myShape;
124
125   int                            myZLayer;
126
127   bool                           myIsToUpdate;
128   bool                           myIsVisible;
129
130   bool                           myIsHighlight;
131   TopoDS_Shape                   myTopoShape;
132   int                            myDisplayMode;
133   int                            mySelectionMode;
134   
135   QColor                         myFillingColor;
136   QColor                         myBorderColor;
137   QColor                         myHighlightColor;
138 };
139
140 #endif
141