Salome HOME
45a1e4f41a3501de9b7eb6db51b446b4a4260cc8
[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 QAD_ViewFrame;
52 class SALOME_Selection;
53
54 class GEOM_Displayer : public SALOME_Displayer
55 {
56     
57 public:
58   /* Constructor */
59   GEOM_Displayer();
60   /* Destructor */
61   virtual ~GEOM_Displayer();
62
63   /* Display/Erase object methods */
64
65   void          Display   ( const Handle(SALOME_InteractiveObject)& theIO,
66                             const bool updateViewer = true,
67                             QAD_ViewFrame* theViewFrame = 0 );
68
69   // This overloaded Display() method can be useful for operations
70   // not using dialog boxes.
71   void          Display   ( GEOM::GEOM_Object_ptr theObj, 
72                             const bool updateViewer = true );
73                          
74   void          Redisplay ( const Handle(SALOME_InteractiveObject)& theIO,
75                             const bool updateViewer = true );
76
77   void          Erase     ( const Handle(SALOME_InteractiveObject)& theIO,
78                             const bool forced = false,
79                             const bool updateViewer = true,
80                             QAD_ViewFrame* theViewFrame = 0 );
81
82   void          Erase     ( GEOM::GEOM_Object_ptr theObj,
83                             const bool forced = false,
84                             const bool updateViewer = true );                            
85
86   /* Display/Erase list of objects methods */
87   
88   void          Display   ( const SALOME_ListIO& theIOList,
89                             const bool updateViewer = true );
90                             
91   void          Erase     ( const SALOME_ListIO& theIOList,
92                             const bool forced = false,
93                             const bool updateViewer = true );
94                             
95   void          Redisplay ( const SALOME_ListIO& theIOList,
96                             const bool updateViewer = true );
97
98   /* Update current viewer */
99   void          UpdateViewer();
100
101   /* build presentation accordint to the current viewer type*/
102   SALOME_Prs*   BuildPrs  ( GEOM::GEOM_Object_ptr );
103   SALOME_Prs*   BuildPrs  ( const TopoDS_Shape& );
104
105   /* Set color for shape displaying. If it is equal -1 then default color is used.
106      Available values are from Quantity_NameOfColor enumeration */
107   void          SetColor  ( const int );
108   void          UnsetColor();
109   int           GetColor  () const;
110   bool          HasColor  () const;
111
112   /* Set width for shape displaying. If it is equal -1 then default width is used. */
113   void          SetWidth  ( const double );
114   void          UnsetWidth();
115   double        GetWidth  () const;
116   bool          HasWidth  () const;
117
118
119   /* Sets name - for temporary objects only */
120   void          SetName( const char* theName ) { myName = theName; }
121   void          UnsetName() { myName = ""; }
122
123   /* Reimplemented from SALOME_Displayer */
124   virtual void  Update( SALOME_OCCPrs* );
125   virtual void  Update( SALOME_VTKPrs* );
126   virtual void  BeforeDisplay( SALOME_View*, const SALOME_OCCViewType& );
127   virtual void  AfterDisplay ( SALOME_View*, const SALOME_OCCViewType& );
128
129   /* This methos is used for activisation/deactivisation of objects to be displayed*/
130   void          SetToActivate( const bool );
131   bool          ToActivate() const;
132
133   /* Activate/Deactivate selection*/
134   void         LocalSelection( const Handle(SALOME_InteractiveObject)&, const int );
135   void         LocalSelection( const SALOME_ListIO& theIOList, const int );
136   void         GlobalSelection( const int = GEOM_ALLOBJECTS, const bool = false );
137   void         GlobalSelection( const TColStd_MapOfInteger&, const bool = false );
138
139   static QAD_ViewFrame* GetActiveView();
140
141 protected:
142   /* internal methods */
143   /* Builds presentation accordint to the current viewer type */
144   SALOME_Prs* buildPresentation( const Handle(SALOME_InteractiveObject)& theIO,
145                                  QAD_ViewFrame* theViewFrame = 0 );
146   
147   /* Sets interactive object */
148   void        setIO( const Handle(SALOME_InteractiveObject)& theIO ) { myIO = theIO; }
149   
150   /* Sets shape */
151   void        setShape( const TopoDS_Shape& theShape ) { myShape = theShape; }
152   
153   /* Resets internal data */
154   void        internalReset();
155
156   void        clearTemporary( SALOME_Selection* );
157
158 protected:
159   Handle(SALOME_InteractiveObject) myIO;
160   TopoDS_Shape                     myShape;
161   string                           myName;
162   int                              myType;
163   QAD_ViewFrame*                   myViewFrame;
164
165   // Attributes
166   Quantity_Color                   myShadingColor;
167   int                              myColor;
168   double                           myWidth;
169   bool                             myToActivate;
170 };
171
172 #endif // __GEOM_DISPLAYER_H
173