Salome HOME
Merge from V5_1_4_BR 07/05/2010
[modules/geom.git] / src / GEOMGUI / GEOM_Displayer.h
1 //  Copyright (C) 2007-2010  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 <Aspect_TypeOfMarker.hxx>
45
46 #include <QList>
47
48 #include <list>
49
50 #include <SALOMEconfig.h>
51 #include CORBA_CLIENT_HEADER(GEOM_Gen)
52
53 #define GEOM_ALLOBJECTS -1 // Selection of all objects is activated
54 #define GEOM_PREVIEW    -2 // Definition for preview selection
55 #define GEOM_ALLSHAPES  -3 // Selection of all shapes is activated
56 #define GEOM_ALLGEOM    -4 // Selection of all geom objects is activated
57
58 typedef std::list<GEOM::GEOM_Object_ptr> ObjectList;
59
60 class TColStd_MapOfInteger;
61 class LightApp_SelectionMgr;
62 class SalomeApp_Study;
63 class SalomeApp_Application;
64 class SUIT_SelectionFilter;
65 //class SALOME_Selection;
66
67 class GEOMGUI_EXPORT GEOM_Displayer : public LightApp_Displayer
68 {
69
70 public:
71   /* Constructor */
72   GEOM_Displayer( SalomeApp_Study* app );
73   /* Destructor */
74   virtual ~GEOM_Displayer();
75
76   virtual bool canBeDisplayed( const QString& /*entry*/, const QString& /*viewer_type*/ ) const;
77
78   /* Display/Erase object methods */
79   void          Display   ( const Handle(SALOME_InteractiveObject)& theIO,
80                             const bool updateViewer = true,
81                             SALOME_View* theViewFrame = 0 );
82
83   // This overloaded Display() method can be useful for operations
84   // not using dialog boxes.
85   void          Display   ( GEOM::GEOM_Object_ptr theObj,
86                             const bool updateViewer = true );
87
88   void          Redisplay ( const Handle(SALOME_InteractiveObject)& theIO,
89                             const bool updateViewer = true );
90
91   void          Erase     ( const Handle(SALOME_InteractiveObject)& theIO,
92                             const bool forced = false,
93                             const bool updateViewer = true,
94                             SALOME_View* theViewFrame = 0 );
95
96   void          Erase     ( GEOM::GEOM_Object_ptr theObj,
97                             const bool forced = false,
98                             const bool updateViewer = true );
99
100   /* Display/Erase list of objects methods */
101
102   void          Display   ( const SALOME_ListIO& theIOList,
103                             const bool updateViewer = true );
104
105   void          Erase     ( const SALOME_ListIO& theIOList,
106                             const bool forced = false,
107                             const bool updateViewer = true );
108
109   void          Redisplay ( const SALOME_ListIO& theIOList,
110                             const bool updateViewer = true );
111
112   /* build presentation accordint to the current viewer type*/
113   SALOME_Prs*   BuildPrs  ( GEOM::GEOM_Object_ptr );
114   SALOME_Prs*   BuildPrs  ( const TopoDS_Shape& );
115
116   /* Set color for shape displaying. If it is equal -1 then default color is used.
117      Available values are from Quantity_NameOfColor enumeration */
118   void          SetColor  ( const int );
119   void          UnsetColor();
120   int           GetColor  () const;
121   bool          HasColor  () const;
122
123   /* Set width for shape displaying. If it is equal -1 then default width is used. */
124   void          SetWidth  ( const double );
125   void          UnsetWidth();
126   double        GetWidth  () const;
127   bool          HasWidth  () const;
128   
129   /* Set display mode shape displaying. If it is equal -1 then display mode is used. */
130   int           SetDisplayMode( const int );
131   int           GetDisplayMode() const;
132   int           UnsetDisplayMode();
133
134
135   /* Sets name - for temporary objects only */
136   void          SetName( const char* theName );
137   void          UnsetName();
138
139   /* Reimplemented from SALOME_Displayer */
140   virtual void  Update( SALOME_OCCPrs* );
141   virtual void  Update( SALOME_VTKPrs* );
142   virtual void  BeforeDisplay( SALOME_View*, const SALOME_OCCViewType& );
143   virtual void  AfterDisplay ( SALOME_View*, const SALOME_OCCViewType& );
144
145   /* This methos is used for activisation/deactivisation of objects to be displayed*/
146   void          SetToActivate( const bool );
147   bool          ToActivate() const;
148
149   /* Activate/Deactivate selection*/
150   void         LocalSelection( const Handle(SALOME_InteractiveObject)&, const int );
151   void         LocalSelection( const SALOME_ListIO& theIOList, const int );
152   void         GlobalSelection( const int = GEOM_ALLOBJECTS, const bool = false );
153   void         GlobalSelection( const TColStd_MapOfInteger&, const bool = false, const QList<int>* = 0 );
154
155   SalomeApp_Study* getStudy() const;
156
157   static SALOMEDS::Color getUniqueColor( const QList<SALOMEDS::Color>& );
158
159   /* Builds presentation of not published object */
160   virtual SALOME_Prs* buildSubshapePresentation(const TopoDS_Shape& aShape,
161                                                 const QString&,
162                                                 SALOME_View* = 0);
163
164 protected:
165   /* internal methods */
166   /* Builds presentation according to the current viewer type */
167   virtual SALOME_Prs* buildPresentation( const QString&, SALOME_View* = 0 );
168
169   /* Sets interactive object */
170   void        setIO( const Handle(SALOME_InteractiveObject)& theIO );
171
172   /* Sets shape */
173   void        setShape( const TopoDS_Shape& theShape );
174
175   /* Resets internal data */
176   void        internalReset();
177
178   void        clearTemporary( LightApp_SelectionMgr* theSelMgr );
179
180   SUIT_SelectionFilter* getFilter( const int theMode );
181   SUIT_SelectionFilter* getComplexFilter( const QList<int>* );
182
183 protected:
184   Handle(SALOME_InteractiveObject) myIO;
185   TopoDS_Shape                     myShape;
186   std::string                      myName;
187   int                              myType;
188   SALOME_View*                     myViewFrame;
189
190   // Attributes
191   Quantity_Color                   myShadingColor;
192   int                              myColor;
193   double                           myWidth;
194   bool                             myToActivate;
195   int                              myDisplayMode;
196   Aspect_TypeOfMarker              myTypeOfMarker;
197   double                           myScaleOfMarker;
198
199 private:
200   SalomeApp_Application* myApp;
201 };
202
203 #endif // GEOM_DISPLAYER_H
204