]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOMGUI/GEOM_Displayer.h
Salome HOME
ENV: Windows porting.
[modules/geom.git] / src / GEOMGUI / GEOM_Displayer.h
1 //  GEOM GEOMGUI : GUI for Geometry component
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : GEOM_Displayer.h
25 //  Author : Vadim SANDLER
26 //  Module : GEOM
27 //  $Header$
28
29 #if !defined (__GEOM_DISPLAYER_H)
30 #define __GEOM_DISPLAYER_H
31
32 #include "SALOME_Prs.h"
33 #include "SALOME_InteractiveObject.hxx"
34 #include "SALOME_ListIO.hxx"
35 #include <TopoDS_Shape.hxx>
36 #include <Quantity_Color.hxx>
37
38 #include <list>
39
40 #include <SALOMEconfig.h>
41 #include CORBA_CLIENT_HEADER(GEOM_Gen)
42
43 #define GEOM_ALLOBJECTS -1 // Selection of all objects is activated
44 #define GEOM_PREVIEW    -2 // Definition for preview selection
45 #define GEOM_ALLSHAPES  -3 // Selection of all shapes is activated
46 #define GEOM_ALLGEOM    -4 // Selection of all geom objects is activated
47
48 typedef std::list<GEOM::GEOM_Object_ptr> ObjectList;
49
50 class TColStd_MapOfInteger;
51 class SalomeApp_SelectionMgr;
52 class SalomeApp_Study;
53 class SUIT_SelectionFilter;
54 //class SALOME_Selection;
55
56 #ifdef WNT
57 #include <SALOME_WNT.hxx>
58 #else
59 #define SALOME_WNT_EXPORT
60 #endif
61
62 class SALOME_WNT_EXPORT GEOM_Displayer : public SALOME_Displayer
63 {
64     
65 public:
66   /* Constructor */
67   GEOM_Displayer( SalomeApp_Study* study );
68   /* Destructor */
69   virtual ~GEOM_Displayer();
70
71   /* Display/Erase object methods */
72
73   void          Display   ( const Handle(SALOME_InteractiveObject)& theIO,
74                             const bool updateViewer = true,
75                             SALOME_View* theViewFrame = 0 );
76
77   // This overloaded Display() method can be useful for operations
78   // not using dialog boxes.
79   void          Display   ( GEOM::GEOM_Object_ptr theObj, 
80                             const bool updateViewer = true );
81                          
82   void          Redisplay ( const Handle(SALOME_InteractiveObject)& theIO,
83                             const bool updateViewer = true );
84
85   void          Erase     ( const Handle(SALOME_InteractiveObject)& theIO,
86                             const bool forced = false,
87                             const bool updateViewer = true,
88                             SALOME_View* theViewFrame = 0 );
89
90   void          Erase     ( GEOM::GEOM_Object_ptr theObj,
91                             const bool forced = false,
92                             const bool updateViewer = true );                            
93
94   /* Display/Erase list of objects methods */
95   
96   void          Display   ( const SALOME_ListIO& theIOList,
97                             const bool updateViewer = true );
98                             
99   void          Erase     ( const SALOME_ListIO& theIOList,
100                             const bool forced = false,
101                             const bool updateViewer = true );
102                             
103   void          Redisplay ( const SALOME_ListIO& theIOList,
104                             const bool updateViewer = true );
105
106   /* Erase all objects displayed in the given or active view */
107   void          EraseAll ( const bool forced = false,
108                            const bool updateViewer = true,
109                            SALOME_View* theViewFrame = 0 );
110
111   /* Update current viewer */
112   void          UpdateViewer();
113
114   /* build presentation accordint to the current viewer type*/
115   SALOME_Prs*   BuildPrs  ( GEOM::GEOM_Object_ptr );
116   SALOME_Prs*   BuildPrs  ( const TopoDS_Shape& );
117
118   /* Set color for shape displaying. If it is equal -1 then default color is used.
119      Available values are from Quantity_NameOfColor enumeration */
120   void          SetColor  ( const int );
121   void          UnsetColor();
122   int           GetColor  () const;
123   bool          HasColor  () const;
124
125   /* Set width for shape displaying. If it is equal -1 then default width is used. */
126   void          SetWidth  ( const double );
127   void          UnsetWidth();
128   double        GetWidth  () const;
129   bool          HasWidth  () const;
130
131
132   /* Sets name - for temporary objects only */
133   void          SetName( const char* theName ) { myName = theName; }
134   void          UnsetName() { myName = ""; }
135
136   /* Reimplemented from SALOME_Displayer */
137   virtual void  Update( SALOME_OCCPrs* );
138   virtual void  Update( SALOME_VTKPrs* );
139   virtual void  BeforeDisplay( SALOME_View*, const SALOME_OCCViewType& );
140   virtual void  AfterDisplay ( SALOME_View*, const SALOME_OCCViewType& );
141
142   /* This methos is used for activisation/deactivisation of objects to be displayed*/
143   void          SetToActivate( const bool );
144   bool          ToActivate() const;
145
146   /* Activate/Deactivate selection*/
147   void         LocalSelection( const Handle(SALOME_InteractiveObject)&, const int );
148   void         LocalSelection( const SALOME_ListIO& theIOList, const int );
149   void         GlobalSelection( const int = GEOM_ALLOBJECTS, const bool = false );
150   void         GlobalSelection( const TColStd_MapOfInteger&, const bool = false );
151
152   static SALOME_View* GetActiveView();
153   SalomeApp_Study* getStudy() const {return myStudy;}
154
155 protected:
156   /* internal methods */
157   /* Builds presentation accordint to the current viewer type */
158   SALOME_Prs* buildPresentation( const Handle(SALOME_InteractiveObject)& theIO,
159                                  SALOME_View* theViewFrame = 0 );
160   
161   /* Sets interactive object */
162   void        setIO( const Handle(SALOME_InteractiveObject)& theIO ) { myIO = theIO; }
163   
164   /* Sets shape */
165   void        setShape( const TopoDS_Shape& theShape ) { myShape = theShape; }
166   
167   /* Resets internal data */
168   void        internalReset();
169
170   void        clearTemporary( SalomeApp_SelectionMgr* theSelMgr );
171
172   SUIT_SelectionFilter* getFilter( const int theMode );
173   
174 protected:
175   Handle(SALOME_InteractiveObject) myIO;
176   TopoDS_Shape                     myShape;
177   string                           myName;
178   int                              myType;
179   SALOME_View*                     myViewFrame;
180
181   // Attributes
182   Quantity_Color                   myShadingColor;
183   int                              myColor;
184   double                           myWidth;
185   bool                             myToActivate;
186   int                              myDisplayMode;
187
188 private:
189   SalomeApp_Study* myStudy;
190 };
191
192 #endif // __GEOM_DISPLAYER_H
193