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