Back to index

salome-gui  6.5.0
SVTK_View.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 #ifndef SVTK_VIEW_H
00024 #define SVTK_VIEW_H
00025 
00026 #ifdef WIN32
00027 #pragma warning( disable:4251 )
00028 #endif
00029 
00030 #include "SVTK.h"
00031 
00032 #include <SALOME_InteractiveObject.hxx>
00033 #include <SALOME_ListIO.hxx>
00034 
00035 #include <QObject>
00036 
00037 class vtkActorCollection;
00038 class vtkRenderer;
00039 class vtkProperty;
00040 
00041 class SVTK_ViewWindow;
00042 class SVTK_Renderer;
00043 
00044 class SALOME_Actor;
00045 
00046 class QMouseEvent;
00047 class QWheelEvent;
00048 class QKeyEvent;
00049 class QContextMenuEvent;
00050 class QColor;
00051 
00052 
00054 
00061 class SVTK_EXPORT SVTK_SignalHandler : public QObject
00062 {
00063   Q_OBJECT;
00064 
00065 public:
00066   SVTK_SignalHandler(SVTK_ViewWindow* theMainWindow);
00067 
00068   virtual
00069   ~SVTK_SignalHandler();
00070 
00072   SVTK_ViewWindow*
00073   GetMainWindow();
00074 
00075   //----------------------------------------------------------------------------
00077   void
00078   Repaint(bool theUpdateTrihedron = true);
00079 
00080   //----------------------------------------------------------------------------
00082   SVTK_Renderer* 
00083   GetRenderer();
00084 
00086   vtkRenderer* 
00087   getRenderer();
00088 
00089   //----------------------------------------------------------------------------
00090  public slots:
00091   void onSelectionChanged();
00092 
00093  public:
00094  signals:
00095   void MouseMove( QMouseEvent* );
00096   void MouseButtonPressed( QMouseEvent* );
00097   void MouseButtonReleased( QMouseEvent* );
00098   void MouseDoubleClicked( QMouseEvent* );
00099   void ButtonPressed(const QMouseEvent *event);
00100   void ButtonReleased(const QMouseEvent *event);
00101   void WheelMoved( QWheelEvent* );
00102   void KeyPressed( QKeyEvent* );
00103   void KeyReleased( QKeyEvent* );
00104   void contextMenuRequested( QContextMenuEvent *e );
00105   void selectionChanged();
00106 
00107  protected:
00108   SVTK_ViewWindow* myMainWindow;
00109 };
00110 
00111 
00113 
00118 class SVTK_EXPORT SVTK_View : public SVTK_SignalHandler
00119 {
00120   Q_OBJECT;
00121 
00122 public:
00123   SVTK_View(SVTK_ViewWindow* theMainWindow);
00124 
00125   virtual
00126   ~SVTK_View();
00127   
00128   /*  interactive object management */
00130   void
00131   highlight(const Handle(SALOME_InteractiveObject)& IObject, 
00132             bool highlight, 
00133             bool immediatly = true);
00134 
00136   void
00137   unHighlightAll();
00138 
00140   Handle(SALOME_InteractiveObject) 
00141   FindIObject(const char* Entry);
00142 
00144   bool
00145   isInViewer(const Handle(SALOME_InteractiveObject)& IObject);
00146 
00148   bool
00149   isVisible(const Handle(SALOME_InteractiveObject)& IObject);
00150 
00151   void
00152   rename(const Handle(SALOME_InteractiveObject)& IObject, 
00153          const QString& newName);
00154   
00155   //----------------------------------------------------------------------------
00156   // Displaymode management
00158   int 
00159   GetDisplayMode();
00160 
00162   void
00163   SetDisplayMode(int);
00164 
00166   void
00167   SetDisplayMode(const Handle(SALOME_InteractiveObject)& IObject, 
00168                  int theMode);
00169 
00171   void 
00172   ChangeRepresentationToWireframe();
00173 
00175   void
00176   ChangeRepresentationToSurface();
00177 
00179   void
00180   ChangeRepresentationToSurfaceWithEdges();
00181 
00183   void
00184   ChangeRepresentationToWireframe(vtkActorCollection* theListofActors);
00185 
00187   void
00188   ChangeRepresentationToSurface(vtkActorCollection* theListofActors);
00189 
00191   void
00192   ChangeRepresentationToSurfaceWithEdges(vtkActorCollection* theListofActors);
00193 
00195   void
00196   SetTransparency(const Handle(SALOME_InteractiveObject)& theIObject,
00197                   float trans);
00198 
00200   float 
00201   GetTransparency(const Handle(SALOME_InteractiveObject)& theIObject);
00202 
00204   void
00205   SetColor(const Handle(SALOME_InteractiveObject)& theIObject,
00206            const QColor& theColor);
00207 
00209   QColor
00210   GetColor(const Handle(SALOME_InteractiveObject)& theIObject);
00211 
00213   void
00214   SetMaterial(const Handle(SALOME_InteractiveObject)& theIObject,
00215              vtkProperty* thePropF);
00216 
00218   vtkProperty* 
00219   GetMaterial(const Handle(SALOME_InteractiveObject)& theIObject);
00220 
00221   //----------------------------------------------------------------------------
00222   // Erase Display functions
00224   void
00225   EraseAll();
00226 
00228   void
00229   DisplayAll();
00230 
00232   void
00233   RemoveAll( const bool immediatly );
00234 
00236   void
00237   Erase(const Handle(SALOME_InteractiveObject)& IObject, 
00238         bool immediatly = true);
00239   void
00240   Remove(const Handle(SALOME_InteractiveObject)& IObject, 
00241          bool immediatly = true);
00242 
00244   void
00245   Display(const Handle(SALOME_InteractiveObject)& IObject, 
00246           bool immediatly = true);
00247 
00249   void
00250   DisplayOnly(const Handle(SALOME_InteractiveObject)& IObject);
00251 
00253   void
00254   Display(SALOME_Actor* SActor, 
00255           bool immediatly = true);
00256 
00258   void
00259   Erase(SALOME_Actor* SActor, 
00260         bool immediatly = true);
00261 
00263   void
00264   Remove(SALOME_Actor* SActor, 
00265          bool updateViewer = true);
00266 
00268   void
00269   GetVisible( SALOME_ListIO& theList );
00270 
00271   //----------------------------------------------------------------------------
00273   void
00274   SetSelectionProp(const double& theRed = 1, 
00275                    const double& theGreen = 1,
00276                    const double& theBlue = 0, 
00277                    const int& theWidth = 5);
00278 
00280   void
00281   SetPreselectionProp(const double& theRed = 0, 
00282                       const double& theGreen = 1,
00283                       const double& theBlue = 1, 
00284                       const int& theWidth = 5);
00285 
00287   void
00288   SetSelectionTolerance(const double& theTolNodes = 0.025, 
00289                         const double& theTolCell = 0.001,
00290                         const double& theTolObjects = 0.025);
00291 
00292  protected:  
00293   int myDisplayMode;
00294 };
00295 
00296 #ifdef WIN32
00297 #pragma warning( default:4251 )
00298 #endif
00299 
00300 #endif