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