Back to index

salome-geom  6.5.0
GEOM_Displayer.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // GEOM GEOMGUI : GUI for Geometry component
00024 // File   : GEOM_Displayer.h
00025 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
00026 //
00027 #ifndef GEOM_DISPLAYER_H
00028 #define GEOM_DISPLAYER_H
00029 
00030 #include "GEOM_GEOMGUI.hxx"
00031 
00032 #include <SALOME_InteractiveObject.hxx>
00033 
00034 class SALOME_ListIO;
00035 class SALOME_View;
00036 class SALOME_Prs;
00037 class SALOME_OCCPrs;
00038 class SALOME_VTKPrs;
00039 class SALOME_OCCViewType;
00040 
00041 #include <TopoDS_Shape.hxx>
00042 #include <Quantity_Color.hxx>
00043 #include <LightApp_Displayer.h>
00044 #include <LightApp_Study.h>
00045 #include <Aspect_TypeOfMarker.hxx>
00046 
00047 #include <QList>
00048 
00049 #include <list>
00050 
00051 #include <SALOMEconfig.h>
00052 #include CORBA_CLIENT_HEADER(GEOM_Gen)
00053 
00054 #define GEOM_ALLOBJECTS -1 // Selection of all objects is activated
00055 #define GEOM_PREVIEW    -2 // Definition for preview selection
00056 #define GEOM_ALLSHAPES  -3 // Selection of all shapes is activated
00057 #define GEOM_ALLGEOM    -4 // Selection of all geom objects is activated
00058 
00059 typedef std::list<GEOM::GEOM_Object_ptr> ObjectList;
00060 
00061 class TColStd_MapOfInteger;
00062 class LightApp_SelectionMgr;
00063 class SalomeApp_Study;
00064 class SalomeApp_Application;
00065 class SUIT_SelectionFilter;
00066 //class SALOME_Selection;
00067 
00068 class GEOMGUI_EXPORT GEOM_Displayer : public LightApp_Displayer
00069 {
00070 
00071 public:
00072   /* Constructor */
00073   GEOM_Displayer( SalomeApp_Study* app );
00074   /* Destructor */
00075   virtual ~GEOM_Displayer();
00076 
00077   virtual bool canBeDisplayed( const QString& /*entry*/, const QString& /*viewer_type*/ ) const;
00078 
00079   /* Display/Erase object methods */
00080   void          Display   ( const Handle(SALOME_InteractiveObject)& theIO,
00081                             const bool updateViewer = true,
00082                             SALOME_View* theViewFrame = 0 );
00083 
00084   // This overloaded Display() method can be useful for operations
00085   // not using dialog boxes.
00086   void          Display   ( GEOM::GEOM_Object_ptr theObj,
00087                             const bool updateViewer = true );
00088 
00089   void          Redisplay ( const Handle(SALOME_InteractiveObject)& theIO,
00090                             const bool updateViewer = true );
00091 
00092   void          Erase     ( const Handle(SALOME_InteractiveObject)& theIO,
00093                             const bool forced = false,
00094                             const bool updateViewer = true,
00095                             SALOME_View* theViewFrame = 0 );
00096 
00097   void          Erase     ( GEOM::GEOM_Object_ptr theObj,
00098                             const bool forced = false,
00099                             const bool updateViewer = true );
00100 
00101   void          EraseWithChildren(const Handle(SALOME_InteractiveObject)& theIO,
00102                               const bool eraseOnlyChildren = false);
00103 
00104   /* Display/Erase list of objects methods */
00105 
00106   void          Display   ( const SALOME_ListIO& theIOList,
00107                             const bool updateViewer = true );
00108 
00109   void          Erase     ( const SALOME_ListIO& theIOList,
00110                             const bool forced = false,
00111                             const bool updateViewer = true );
00112 
00113   void          Redisplay ( const SALOME_ListIO& theIOList,
00114                             const bool updateViewer = true );
00115 
00116   /* build presentation accordint to the current viewer type*/
00117   SALOME_Prs*   BuildPrs  ( GEOM::GEOM_Object_ptr );
00118   SALOME_Prs*   BuildPrs  ( const TopoDS_Shape& );
00119 
00120   /* Set color for shape displaying. If it is equal -1 then default color is used.
00121      Available values are from Quantity_NameOfColor enumeration */
00122   void          SetColor  ( const int );
00123   void          UnsetColor();
00124   int           GetColor  () const;
00125   bool          HasColor  () const;
00126   
00127   /* Set texture for shape displaying. */
00128   void          SetTexture  ( const std::string& );
00129   bool          HasTexture  () const;
00130   std::string   GetTexture  () const;
00131 
00132   /* Set width for shape displaying. If it is equal -1 then default width is used. */
00133   void          SetWidth  ( const double );
00134   void          UnsetWidth();
00135   double        GetWidth  () const;
00136   bool          HasWidth  () const;
00137 
00138   /* Set width for iso-lines displaying. If it is equal -1 then default width is used. */
00139   void          SetIsosWidth  ( const int );
00140   int           GetIsosWidth  () const;
00141   bool          HasIsosWidth  () const;
00142   
00143   /* Set display mode shape displaying. If it is equal -1 then display mode is used. */
00144   int           SetDisplayMode( const int );
00145   int           GetDisplayMode() const;
00146   int           UnsetDisplayMode();
00147 
00148 
00149   /* Sets name - for temporary objects only */
00150   void          SetName( const char* theName );
00151   void          UnsetName();
00152 
00153   /* Reimplemented from SALOME_Displayer */
00154   virtual void  Update( SALOME_OCCPrs* );
00155   virtual void  Update( SALOME_VTKPrs* );
00156   virtual void  BeforeDisplay( SALOME_View*, const SALOME_OCCPrs* );
00157   virtual void  AfterDisplay ( SALOME_View*, const SALOME_OCCPrs* );
00158 
00159   /* This methos is used for activisation/deactivisation of objects to be displayed*/
00160   void          SetToActivate( const bool );
00161   bool          ToActivate() const;
00162 
00163   /* Activate/Deactivate selection*/
00164   void         LocalSelection( const Handle(SALOME_InteractiveObject)&, const int );
00165   void         LocalSelection( const SALOME_ListIO& theIOList, const int );
00166   void         GlobalSelection( const int = GEOM_ALLOBJECTS, const bool = false );
00167   void         GlobalSelection( const TColStd_MapOfInteger&, const bool = false, const QList<int>* = 0 );
00168 
00169   SalomeApp_Study* getStudy() const;
00170 
00171   static SALOMEDS::Color getUniqueColor( const QList<SALOMEDS::Color>& );
00172 
00173   static PropMap getDefaultPropertyMap(const QString& viewer_type);
00174   
00175   static bool MergePropertyMaps(PropMap& theOrigin, PropMap& theDefault);
00176   
00177   /*Get color of the geom object*/
00178   static SALOMEDS::Color getColor(GEOM::GEOM_Object_var aGeomObject, bool& hasColor);
00179 
00180   /* Get minimum or maximum enclosed shape type */
00181   static int getMinMaxShapeType( const TopoDS_Shape& shape, bool ismin );
00182 
00183   /* Check if the object is a vertex or a compound of vertices */
00184   static bool isCompoundOfVertices( const TopoDS_Shape& theShape );
00185 
00186 
00187   /* Builds presentation of not published object */
00188   virtual SALOME_Prs* buildSubshapePresentation(const TopoDS_Shape& aShape,
00189                                                 const QString&,
00190                                                 SALOME_View* = 0);
00191 
00192 protected:
00193   /* internal methods */
00194   /* Builds presentation according to the current viewer type */
00195   virtual SALOME_Prs* buildPresentation( const QString&, SALOME_View* = 0 );
00196 
00197   /* Sets interactive object */
00198   void        setIO( const Handle(SALOME_InteractiveObject)& theIO );
00199 
00200   /* Sets shape */
00201   void        setShape( const TopoDS_Shape& theShape );
00202 
00203   /* Resets internal data */
00204   void        internalReset();
00205 
00206   void        clearTemporary( LightApp_SelectionMgr* theSelMgr );
00207 
00208   SUIT_SelectionFilter* getFilter( const int theMode );
00209   SUIT_SelectionFilter* getComplexFilter( const QList<int>* );
00210 
00211 protected:
00212   Handle(SALOME_InteractiveObject) myIO;
00213   TopoDS_Shape                     myShape;
00214   std::string                      myName;
00215   std::string                      myTexture;
00216   int                              myType;
00217   SALOME_View*                     myViewFrame;
00218 
00219   // Attributes
00220   Quantity_Color                   myShadingColor;
00221   int                              myColor;
00222   double                           myWidth;
00223   int                              myIsosWidth;
00224   bool                             myToActivate;
00225   int                              myDisplayMode;
00226   Aspect_TypeOfMarker              myTypeOfMarker;
00227   double                           myScaleOfMarker;
00228 
00229 private:
00230   SalomeApp_Application* myApp;
00231 };
00232 
00233 #endif // GEOM_DISPLAYER_H
00234