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