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