Salome HOME
Merge from V6_main (04/10/2012)
[modules/geom.git] / src / GEOMGUI / GEOM_Displayer.h
1 // Copyright (C) 2007-2012  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.
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 // GEOM GEOMGUI : GUI for Geometry component
24 // File   : GEOM_Displayer.h
25 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
26 //
27 #ifndef GEOM_DISPLAYER_H
28 #define GEOM_DISPLAYER_H
29
30 #include "GEOM_GEOMGUI.hxx"
31
32 #include <SALOME_InteractiveObject.hxx>
33
34 class SALOME_ListIO;
35 class SALOME_View;
36 class SALOME_Prs;
37 class SALOME_OCCPrs;
38 class SALOME_VTKPrs;
39 class SALOME_OCCViewType;
40
41 #include <TopoDS_Shape.hxx>
42 #include <Quantity_Color.hxx>
43 #include <LightApp_Displayer.h>
44 #include <LightApp_Study.h>
45 #include <Aspect_TypeOfMarker.hxx>
46
47 #include <QList>
48
49 #include <list>
50
51 #include <SALOMEconfig.h>
52 #include CORBA_CLIENT_HEADER(GEOM_Gen)
53
54 #define GEOM_ALLOBJECTS -1 // Selection of all objects is activated
55 #define GEOM_PREVIEW    -2 // Definition for preview selection
56 #define GEOM_ALLSHAPES  -3 // Selection of all shapes is activated
57 #define GEOM_ALLGEOM    -4 // Selection of all geom objects is activated
58
59 typedef std::list<GEOM::GEOM_Object_ptr> ObjectList;
60
61 class TColStd_MapOfInteger;
62 class LightApp_SelectionMgr;
63 class SalomeApp_Study;
64 class SalomeApp_Application;
65 class SUIT_SelectionFilter;
66 //class SALOME_Selection;
67
68 class GEOMGUI_EXPORT GEOM_Displayer : public LightApp_Displayer
69 {
70
71 public:
72   /* Constructor */
73   GEOM_Displayer( SalomeApp_Study* app );
74   /* Destructor */
75   virtual ~GEOM_Displayer();
76
77   virtual bool canBeDisplayed( const QString& /*entry*/, const QString& /*viewer_type*/ ) const;
78
79   /* Display/Erase object methods */
80   void          Display   ( const Handle(SALOME_InteractiveObject)& theIO,
81                             const bool updateViewer = true,
82                             SALOME_View* theViewFrame = 0 );
83
84   // This overloaded Display() method can be useful for operations
85   // not using dialog boxes.
86   void          Display   ( GEOM::GEOM_Object_ptr theObj,
87                             const bool updateViewer = true );
88
89   void          Redisplay ( const Handle(SALOME_InteractiveObject)& theIO,
90                             const bool updateViewer = true );
91
92   void          Erase     ( const Handle(SALOME_InteractiveObject)& theIO,
93                             const bool forced = false,
94                             const bool updateViewer = true,
95                             SALOME_View* theViewFrame = 0 );
96
97   void          Erase     ( GEOM::GEOM_Object_ptr theObj,
98                             const bool forced = false,
99                             const bool updateViewer = true );
100
101   void          EraseWithChildren(const Handle(SALOME_InteractiveObject)& theIO,
102                                   const bool eraseOnlyChildren = false);
103
104   /* Display/Erase list of objects methods */
105
106   void          Display   ( const SALOME_ListIO& theIOList,
107                             const bool updateViewer = true );
108
109   void          Erase     ( const SALOME_ListIO& theIOList,
110                             const bool forced = false,
111                             const bool updateViewer = true );
112
113   void          Redisplay ( const SALOME_ListIO& theIOList,
114                             const bool updateViewer = true );
115
116   /* build presentation accordint to the current viewer type*/
117   SALOME_Prs*   BuildPrs  ( GEOM::GEOM_Object_ptr );
118   SALOME_Prs*   BuildPrs  ( const TopoDS_Shape& );
119
120   /* Set color for shape displaying. If it is equal -1 then default color is used.
121      Available values are from Quantity_NameOfColor enumeration */
122   void          SetColor  ( const int );
123   void          UnsetColor();
124   int           GetColor  () const;
125   bool          HasColor  () const;
126   
127   /* Set texture for shape displaying. */
128   void          SetTexture  ( const std::string& );
129   bool          HasTexture  () const;
130   std::string   GetTexture  () const;
131
132   /* Set width for shape displaying. If it is equal -1 then default width is used. */
133   void          SetWidth  ( const double );
134   void          UnsetWidth();
135   double        GetWidth  () const;
136   bool          HasWidth  () const;
137
138   /* Set width for iso-lines displaying. If it is equal -1 then default width is used. */
139   void          SetIsosWidth  ( const int );
140   int           GetIsosWidth  () const;
141   bool          HasIsosWidth  () const;
142   
143   /* Set display mode shape displaying. If it is equal -1 then display mode is used. */
144   int           SetDisplayMode( const int );
145   int           GetDisplayMode() const;
146   int           UnsetDisplayMode();
147
148
149   /* Sets name - for temporary objects only */
150   void          SetName( const char* theName );
151   void          UnsetName();
152
153   /* Reimplemented from SALOME_Displayer */
154   virtual void  Update( SALOME_OCCPrs* );
155   virtual void  Update( SALOME_VTKPrs* );
156   virtual void  BeforeDisplay( SALOME_View*, const SALOME_OCCPrs* );
157   virtual void  AfterDisplay ( SALOME_View*, const SALOME_OCCPrs* );
158
159   /* This methos is used for activisation/deactivisation of objects to be displayed*/
160   void          SetToActivate( const bool );
161   bool          ToActivate() const;
162
163   /* Activate/Deactivate selection*/
164   void         LocalSelection( const Handle(SALOME_InteractiveObject)&, const int );
165   void         LocalSelection( const SALOME_ListIO& theIOList, const int );
166   void         GlobalSelection( const int = GEOM_ALLOBJECTS, const bool = false );
167   void         GlobalSelection( const TColStd_MapOfInteger&, const bool = false, const QList<int>* = 0 );
168
169   SalomeApp_Study* getStudy() const;
170
171   static SALOMEDS::Color getUniqueColor( const QList<SALOMEDS::Color>& );
172   static SALOMEDS::Color getPredefinedUniqueColor();
173
174   static PropMap getDefaultPropertyMap(const QString& viewer_type);
175   
176   static bool MergePropertyMaps(PropMap& theOrigin, PropMap& theDefault);
177   
178   /*Get color of the geom object*/
179   static SALOMEDS::Color getColor(GEOM::GEOM_Object_var aGeomObject, bool& hasColor);
180
181   /* Get minimum or maximum enclosed shape type */
182   static int getMinMaxShapeType( const TopoDS_Shape& shape, bool ismin );
183
184   /* Check if the object is a vertex or a compound of vertices */
185   static bool isCompoundOfVertices( const TopoDS_Shape& theShape );
186
187
188   /* Builds presentation of not published object */
189   virtual SALOME_Prs* buildSubshapePresentation(const TopoDS_Shape& aShape,
190                                                 const QString&,
191                                                 SALOME_View* = 0);
192
193 protected:
194   /* internal methods */
195   /* Builds presentation according to the current viewer type */
196   virtual SALOME_Prs* buildPresentation( const QString&, SALOME_View* = 0 );
197
198   /* Sets interactive object */
199   void        setIO( const Handle(SALOME_InteractiveObject)& theIO );
200
201   /* Sets shape */
202   void        setShape( const TopoDS_Shape& theShape );
203
204   /* Resets internal data */
205   void        internalReset();
206
207   void        clearTemporary( LightApp_SelectionMgr* theSelMgr );
208
209   SUIT_SelectionFilter* getFilter( const int theMode );
210   SUIT_SelectionFilter* getComplexFilter( const QList<int>* );
211
212 protected:
213   Handle(SALOME_InteractiveObject) myIO;
214   TopoDS_Shape                     myShape;
215   std::string                      myName;
216   std::string                      myTexture;
217   int                              myType;
218   SALOME_View*                     myViewFrame;
219
220   // Attributes
221   Quantity_Color                   myShadingColor;
222   int                              myColor;
223   double                           myWidth;
224   int                              myIsosWidth;
225   bool                             myToActivate;
226   int                              myDisplayMode;
227   Aspect_TypeOfMarker              myTypeOfMarker;
228   double                           myScaleOfMarker;
229
230 private:
231   SalomeApp_Application* myApp;
232 };
233
234 #endif // GEOM_DISPLAYER_H
235