Version: 6.3.1

src/GEOMGUI/GEOM_Displayer.h

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  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 width for shape displaying. If it is equal -1 then default width is used. */
00128   void          SetWidth  ( const double );
00129   void          UnsetWidth();
00130   double        GetWidth  () const;
00131   bool          HasWidth  () const;
00132   
00133   /* Set display mode shape displaying. If it is equal -1 then display mode is used. */
00134   int           SetDisplayMode( const int );
00135   int           GetDisplayMode() const;
00136   int           UnsetDisplayMode();
00137 
00138 
00139   /* Sets name - for temporary objects only */
00140   void          SetName( const char* theName );
00141   void          UnsetName();
00142 
00143   /* Reimplemented from SALOME_Displayer */
00144   virtual void  Update( SALOME_OCCPrs* );
00145   virtual void  Update( SALOME_VTKPrs* );
00146   virtual void  BeforeDisplay( SALOME_View*, const SALOME_OCCPrs* );
00147   virtual void  AfterDisplay ( SALOME_View*, const SALOME_OCCPrs* );
00148 
00149   /* This methos is used for activisation/deactivisation of objects to be displayed*/
00150   void          SetToActivate( const bool );
00151   bool          ToActivate() const;
00152 
00153   /* Activate/Deactivate selection*/
00154   void         LocalSelection( const Handle(SALOME_InteractiveObject)&, const int );
00155   void         LocalSelection( const SALOME_ListIO& theIOList, const int );
00156   void         GlobalSelection( const int = GEOM_ALLOBJECTS, const bool = false );
00157   void         GlobalSelection( const TColStd_MapOfInteger&, const bool = false, const QList<int>* = 0 );
00158 
00159   SalomeApp_Study* getStudy() const;
00160 
00161   static SALOMEDS::Color getUniqueColor( const QList<SALOMEDS::Color>& );
00162 
00163   static PropMap getDefaultPropertyMap(const QString& viewer_type);
00164   
00165   static bool MergePropertyMaps(PropMap& theOrigin, PropMap& theDefault);
00166   
00167   /*Get color of the geom object*/
00168   static SALOMEDS::Color getColor(GEOM::GEOM_Object_var aGeomObject, bool& hasColor);
00169 
00170   /* Get minimum or maximum enclosed shape type */
00171   static int getMinMaxShapeType( const TopoDS_Shape& shape, bool ismin );
00172 
00173   /* Check if the object is a vertex or a compound of vertices */
00174   static bool isCompoundOfVertices( const TopoDS_Shape& theShape );
00175 
00176 
00177   /* Builds presentation of not published object */
00178   virtual SALOME_Prs* buildSubshapePresentation(const TopoDS_Shape& aShape,
00179                                                 const QString&,
00180                                                 SALOME_View* = 0);
00181 
00182 protected:
00183   /* internal methods */
00184   /* Builds presentation according to the current viewer type */
00185   virtual SALOME_Prs* buildPresentation( const QString&, SALOME_View* = 0 );
00186 
00187   /* Sets interactive object */
00188   void        setIO( const Handle(SALOME_InteractiveObject)& theIO );
00189 
00190   /* Sets shape */
00191   void        setShape( const TopoDS_Shape& theShape );
00192 
00193   /* Resets internal data */
00194   void        internalReset();
00195 
00196   void        clearTemporary( LightApp_SelectionMgr* theSelMgr );
00197 
00198   SUIT_SelectionFilter* getFilter( const int theMode );
00199   SUIT_SelectionFilter* getComplexFilter( const QList<int>* );
00200 
00201 protected:
00202   Handle(SALOME_InteractiveObject) myIO;
00203   TopoDS_Shape                     myShape;
00204   std::string                      myName;
00205   int                              myType;
00206   SALOME_View*                     myViewFrame;
00207 
00208   // Attributes
00209   Quantity_Color                   myShadingColor;
00210   int                              myColor;
00211   double                           myWidth;
00212   bool                             myToActivate;
00213   int                              myDisplayMode;
00214   Aspect_TypeOfMarker              myTypeOfMarker;
00215   double                           myScaleOfMarker;
00216 
00217 private:
00218   SalomeApp_Application* myApp;
00219 };
00220 
00221 #endif // GEOM_DISPLAYER_H
00222 
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS