src/GEOMGUI/GEOM_Displayer.h

Go to the documentation of this file.
00001 //  GEOM GEOMGUI : GUI for Geometry component
00002 //
00003 //  Copyright (C) 2003  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 //
00024 //  File   : GEOM_Displayer.h
00025 //  Author : Vadim SANDLER
00026 //  Module : GEOM
00027 //  $Header: /home/server/cvs/GEOM/GEOM_SRC/src/GEOMGUI/GEOM_Displayer.h,v 1.12 2006/06/01 11:32:35 jfa Exp $
00028 
00029 #if !defined (__GEOM_DISPLAYER_H)
00030 #define __GEOM_DISPLAYER_H
00031 
00032 #include "SALOME_Prs.h"
00033 #include "SALOME_InteractiveObject.hxx"
00034 #include "SALOME_ListIO.hxx"
00035 #include <TopoDS_Shape.hxx>
00036 #include <Quantity_Color.hxx>
00037 #include <LightApp_Displayer.h>
00038 
00039 #include <list>
00040 
00041 #include <SALOMEconfig.h>
00042 #include CORBA_CLIENT_HEADER(GEOM_Gen)
00043 
00044 #define GEOM_ALLOBJECTS -1 // Selection of all objects is activated
00045 #define GEOM_PREVIEW    -2 // Definition for preview selection
00046 #define GEOM_ALLSHAPES  -3 // Selection of all shapes is activated
00047 #define GEOM_ALLGEOM    -4 // Selection of all geom objects is activated
00048 
00049 typedef std::list<GEOM::GEOM_Object_ptr> ObjectList;
00050 
00051 class TColStd_MapOfInteger;
00052 class LightApp_SelectionMgr;
00053 class SalomeApp_Study;
00054 class SalomeApp_Application;
00055 class SUIT_SelectionFilter;
00056 //class SALOME_Selection;
00057 
00058 //#ifdef WNT
00059 //#include <SALOME_WNT.hxx>
00060 //#else
00061 //#define SALOME_WNT_EXPORT
00062 //#endif
00063 #if defined WNT && defined WIN32 && defined SALOME_WNT_EXPORTS
00064 #define GEOMGUI_WNT_EXPORT __declspec( dllexport )
00065 #else
00066 #define GEOMGUI_WNT_EXPORT
00067 #endif
00068 
00069 class GEOMGUI_WNT_EXPORT GEOM_Displayer : public LightApp_Displayer
00070 {
00071     
00072 public:
00073   /* Constructor */
00074   GEOM_Displayer( SalomeApp_Study* app );
00075   /* Destructor */
00076   virtual ~GEOM_Displayer();
00077 
00078   virtual bool canBeDisplayed( const QString& /*entry*/, const QString& /*viewer_type*/ ) const;
00079 
00080   /* Display/Erase object methods */
00081   void          Display   ( const Handle(SALOME_InteractiveObject)& theIO,
00082                             const bool updateViewer = true,
00083                    SALOME_View* theViewFrame = 0 );
00084 
00085   // This overloaded Display() method can be useful for operations
00086   // not using dialog boxes.
00087   void          Display   ( GEOM::GEOM_Object_ptr theObj, 
00088                    const bool updateViewer = true );
00089                          
00090   void          Redisplay ( const Handle(SALOME_InteractiveObject)& theIO,
00091                             const bool updateViewer = true );
00092 
00093   void          Erase     ( const Handle(SALOME_InteractiveObject)& theIO,
00094                             const bool forced = false,
00095                             const bool updateViewer = true,
00096                    SALOME_View* theViewFrame = 0 );
00097 
00098   void          Erase     ( GEOM::GEOM_Object_ptr theObj,
00099                             const bool forced = false,
00100                             const bool updateViewer = true );                            
00101 
00102   /* Display/Erase list of objects methods */
00103   
00104   void          Display   ( const SALOME_ListIO& theIOList,
00105                             const bool updateViewer = true );
00106                             
00107   void          Erase     ( const SALOME_ListIO& theIOList,
00108                             const bool forced = false,
00109                             const bool updateViewer = true );
00110                             
00111   void          Redisplay ( const SALOME_ListIO& theIOList,
00112                             const bool updateViewer = true );
00113 
00114   /* build presentation accordint to the current viewer type*/
00115   SALOME_Prs*   BuildPrs  ( GEOM::GEOM_Object_ptr );
00116   SALOME_Prs*   BuildPrs  ( const TopoDS_Shape& );
00117 
00118   /* Set color for shape displaying. If it is equal -1 then default color is used.
00119      Available values are from Quantity_NameOfColor enumeration */
00120   void          SetColor  ( const int );
00121   void          UnsetColor();
00122   int           GetColor  () const;
00123   bool          HasColor  () const;
00124 
00125   /* Set width for shape displaying. If it is equal -1 then default width is used. */
00126   void          SetWidth  ( const double );
00127   void          UnsetWidth();
00128   double        GetWidth  () const;
00129   bool          HasWidth  () const;
00130 
00131 
00132   /* Sets name - for temporary objects only */
00133   void          SetName( const char* theName );
00134   void          UnsetName();
00135 
00136   /* Reimplemented from SALOME_Displayer */
00137   virtual void  Update( SALOME_OCCPrs* );
00138   virtual void  Update( SALOME_VTKPrs* );
00139   virtual void  BeforeDisplay( SALOME_View*, const SALOME_OCCViewType& );
00140   virtual void  AfterDisplay ( SALOME_View*, const SALOME_OCCViewType& );
00141 
00142   /* This methos is used for activisation/deactivisation of objects to be displayed*/
00143   void          SetToActivate( const bool );
00144   bool          ToActivate() const;
00145 
00146   /* Activate/Deactivate selection*/
00147   void         LocalSelection( const Handle(SALOME_InteractiveObject)&, const int );
00148   void         LocalSelection( const SALOME_ListIO& theIOList, const int );
00149   void         GlobalSelection( const int = GEOM_ALLOBJECTS, const bool = false );
00150   void         GlobalSelection( const TColStd_MapOfInteger&, const bool = false );
00151 
00152   SalomeApp_Study* getStudy() const;
00153 
00154 protected:
00155   /* internal methods */
00156   /* Builds presentation accordint to the current viewer type */
00157   virtual SALOME_Prs* buildPresentation( const QString&, SALOME_View* = 0 );
00158   
00159   /* Sets interactive object */
00160   void        setIO( const Handle(SALOME_InteractiveObject)& theIO );
00161   
00162   /* Sets shape */
00163   void        setShape( const TopoDS_Shape& theShape );
00164   
00165   /* Resets internal data */
00166   void        internalReset();
00167 
00168   void        clearTemporary( LightApp_SelectionMgr* theSelMgr );
00169 
00170   SUIT_SelectionFilter* getFilter( const int theMode );
00171   
00172 protected:
00173   Handle(SALOME_InteractiveObject) myIO;
00174   TopoDS_Shape                     myShape;
00175   string                           myName;
00176   int                              myType;
00177   SALOME_View*                     myViewFrame;
00178 
00179   // Attributes
00180   Quantity_Color                   myShadingColor;
00181   int                              myColor;
00182   double                           myWidth;
00183   bool                             myToActivate;
00184   int                              myDisplayMode;
00185 
00186 private:
00187   SalomeApp_Application* myApp;
00188 };
00189 
00190 #endif // __GEOM_DISPLAYER_H
00191