1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File : GEOM_Displayer.h
25 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
27 #ifndef GEOM_DISPLAYER_H
28 #define GEOM_DISPLAYER_H
30 #include "GEOM_GEOMGUI.hxx"
32 #include <SALOME_InteractiveObject.hxx>
40 class SALOME_OCCViewType;
42 #include <TopoDS_Shape.hxx>
43 #include <Quantity_Color.hxx>
44 #include <LightApp_Displayer.h>
45 #include <LightApp_Study.h>
46 #include <Aspect_TypeOfMarker.hxx>
52 #include <SALOMEconfig.h>
53 #include CORBA_CLIENT_HEADER(GEOM_Gen)
55 #define GEOM_ALLOBJECTS -1 // Selection of all objects is activated
56 #define GEOM_PREVIEW -2 // Definition for preview selection
57 #define GEOM_ALLSHAPES -3 // Selection of all shapes is activated
58 #define GEOM_ALLGEOM -4 // Selection of all geom objects is activated
60 typedef std::list<GEOM::GEOM_Object_ptr> ObjectList;
62 class TColStd_MapOfInteger;
63 class LightApp_SelectionMgr;
64 class SalomeApp_Study;
65 class SalomeApp_Application;
66 class SUIT_SelectionFilter;
67 class Handle_GEOM_AISShape;
68 //class SALOME_Selection;
70 class GEOMGUI_EXPORT GEOM_Displayer : public LightApp_Displayer
75 GEOM_Displayer( SalomeApp_Study* app );
77 virtual ~GEOM_Displayer();
79 virtual bool canBeDisplayed( const QString& /*entry*/, const QString& /*viewer_type*/ ) const;
81 /* Display/Erase object methods */
82 void Display ( const Handle(SALOME_InteractiveObject)& theIO,
83 const bool updateViewer = true,
84 SALOME_View* theViewFrame = 0 );
86 // This overloaded Display() method can be useful for operations
87 // not using dialog boxes.
88 void Display ( GEOM::GEOM_Object_ptr theObj,
89 const bool updateViewer = true );
91 void Redisplay ( const Handle(SALOME_InteractiveObject)& theIO,
92 const bool updateViewer = true );
94 void Erase ( const Handle(SALOME_InteractiveObject)& theIO,
95 const bool forced = false,
96 const bool updateViewer = true,
97 SALOME_View* theViewFrame = 0 );
99 void Erase ( GEOM::GEOM_Object_ptr theObj,
100 const bool forced = false,
101 const bool updateViewer = true );
103 void EraseWithChildren(const Handle(SALOME_InteractiveObject)& theIO,
104 const bool eraseOnlyChildren = false);
106 /* Display/Erase list of objects methods */
108 void Display ( const SALOME_ListIO& theIOList,
109 const bool updateViewer = true );
111 void Erase ( const SALOME_ListIO& theIOList,
112 const bool forced = false,
113 const bool updateViewer = true );
115 void Redisplay ( const SALOME_ListIO& theIOList,
116 const bool updateViewer = true );
118 /* build presentation accordint to the current viewer type*/
119 SALOME_Prs* BuildPrs ( GEOM::GEOM_Object_ptr );
120 SALOME_Prs* BuildPrs ( const TopoDS_Shape& );
122 /* Set color for shape displaying. If it is equal -1 then default color is used.
123 Available values are from Quantity_NameOfColor enumeration */
124 void SetColor ( const int );
126 int GetColor () const;
127 bool HasColor () const;
129 /* Set texture for shape displaying. */
130 void SetTexture ( const std::string& );
131 bool HasTexture () const;
132 std::string GetTexture () const;
134 /* Set width for shape displaying. If it is equal -1 then default width is used. */
135 void SetWidth ( const double );
137 double GetWidth () const;
138 bool HasWidth () const;
140 /* Set width for iso-lines displaying. If it is equal -1 then default width is used. */
141 void SetIsosWidth ( const int );
142 int GetIsosWidth () const;
143 bool HasIsosWidth () const;
145 /* Set display mode shape displaying. If it is equal -1 then display mode is used. */
146 int SetDisplayMode( const int );
147 int GetDisplayMode() const;
148 int UnsetDisplayMode();
149 bool HasDisplayMode() const;
151 /* Sets name - for temporary objects only */
152 void SetName( const char* theName );
155 /* Reimplemented from SALOME_Displayer */
156 virtual void Update( SALOME_OCCPrs* );
157 virtual void Update( SALOME_VTKPrs* );
158 virtual void BeforeDisplay( SALOME_View*, const SALOME_OCCPrs* );
159 virtual void AfterDisplay ( SALOME_View*, const SALOME_OCCPrs* );
161 /* This methos is used for activisation/deactivisation of objects to be displayed*/
162 void SetToActivate( const bool );
163 bool ToActivate() const;
165 /* Activate/Deactivate selection*/
166 void LocalSelection( const Handle(SALOME_InteractiveObject)&, const int );
167 void LocalSelection( const SALOME_ListIO& theIOList, const int );
168 void GlobalSelection( const int = GEOM_ALLOBJECTS, const bool = false );
169 void GlobalSelection( const TColStd_MapOfInteger&, const bool = false, const QList<int>* = 0 );
171 SalomeApp_Study* getStudy() const;
173 static SALOMEDS::Color getUniqueColor( const QList<SALOMEDS::Color>& );
174 static SALOMEDS::Color getPredefinedUniqueColor();
176 /*Get color of the geom object*/
177 static SALOMEDS::Color getColor(GEOM::GEOM_Object_var aGeomObject, bool& hasColor);
179 /* Get minimum or maximum enclosed shape type */
180 static int getMinMaxShapeType( const TopoDS_Shape& shape, bool ismin );
182 /* Check if the object is a vertex or a compound of vertices */
183 static bool isCompoundOfVertices( const TopoDS_Shape& theShape );
186 /* Builds presentation of not published object */
187 virtual SALOME_Prs* buildSubshapePresentation(const TopoDS_Shape& aShape,
192 /* internal methods */
193 /* Builds presentation according to the current viewer type */
194 virtual SALOME_Prs* buildPresentation( const QString&, SALOME_View* = 0 );
196 /* Sets interactive object */
197 void setIO( const Handle(SALOME_InteractiveObject)& theIO );
200 void setShape( const TopoDS_Shape& theShape );
202 /* Resets internal data */
203 void internalReset();
205 void clearTemporary( LightApp_SelectionMgr* theSelMgr );
207 SUIT_SelectionFilter* getFilter( const int theMode );
208 SUIT_SelectionFilter* getComplexFilter( const QList<int>* );
210 Quantity_Color qColorFromResources( const QString&, const QColor& );
211 QColor colorFromResources( const QString&, const QColor& );
212 void updateShapeProperties( const Handle(GEOM_AISShape)&, bool );
213 void updateActorProperties( GEOM_Actor*, bool );
215 PropMap getObjectProperties( SalomeApp_Study*, const QString&, SALOME_View* = 0 );
216 PropMap getDefaultPropertyMap();
219 Handle(SALOME_InteractiveObject) myIO;
220 TopoDS_Shape myShape;
222 std::string myTexture;
224 SALOME_View* myViewFrame;
227 Quantity_Color myShadingColor;
233 bool myHasDisplayMode;
234 Aspect_TypeOfMarker myTypeOfMarker;
235 double myScaleOfMarker;
238 SalomeApp_Application* myApp;
239 friend class GEOM_Swig;
242 #endif // GEOM_DISPLAYER_H