Back to index

salome-gui  6.5.0
SVTK_ViewModel.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_VIEWMODEL_H
00024 #define SVTK_VIEWMODEL_H
00025 
00026 #include "SVTK.h"
00027 #include "SVTK_ViewModelBase.h"
00028 
00029 #include "Qtx.h"
00030 
00031 #include <SALOME_Prs.h>
00032 #include <SALOME_InteractiveObject.hxx>
00033 #include <SALOME_ListIO.hxx>
00034 
00035 #include <QColor>
00036 #include <QMap>
00037 
00038 class QMouseEvent;
00039 
00040 class SVTK_ViewWindow;
00041 class VTKViewer_Actor;
00042 
00044 class SVTK_EXPORT SVTK_Viewer : public SVTK_ViewModelBase, public SALOME_View 
00045 {
00046   Q_OBJECT;
00047 
00048 public:
00050   enum { 
00051     HorizontalGradient,
00052     VerticalGradient,
00053     FirstDiagonalGradient,
00054     SecondDiagonalGradient,
00055     FirstCornerGradient,
00056     SecondCornerGradient,
00057     ThirdCornerGradient,
00058     FourthCornerGradient,
00059     LastGradient = FourthCornerGradient,
00060   };
00061 
00062   typedef SVTK_ViewWindow TViewWindow;
00063   
00065   static QString           Type() { return "VTKViewer"; }
00066   static QString           backgroundData( QStringList&, QIntList&, QIntList& );
00067 
00068   SVTK_Viewer();
00069   virtual ~SVTK_Viewer();
00070 
00072   virtual SUIT_ViewWindow* createView(SUIT_Desktop*);
00073 
00075   virtual void setViewManager(SUIT_ViewManager* theViewManager);
00076 
00078   virtual void contextMenuPopup( QMenu* );
00079 
00081   virtual QString getType() const { return Type(); }
00082 
00084   QColor backgroundColor() const;
00085 
00087   void setBackgroundColor( const QColor& );
00088 
00090   Qtx::BackgroundData background() const;
00091 
00093   void setBackground( const Qtx::BackgroundData& );
00094 
00096   vtkFloatingPointType trihedronSize() const;
00097 
00099   bool trihedronRelative() const;
00100 
00102   void setTrihedronSize( const vtkFloatingPointType, const bool = true );
00103 
00105   bool isStaticTrihedronVisible() const;
00106 
00108   void setStaticTrihedronVisible( const bool );
00109 
00111   int projectionMode() const;
00112 
00114   void setProjectionMode( const int );
00115 
00117   int interactionStyle() const;
00118 
00120   void setInteractionStyle( const int );
00121 
00123   int zoomingStyle() const;
00124 
00126   void setZoomingStyle( const int );
00127 
00129   bool dynamicPreSelection() const;
00130 
00132   void setDynamicPreSelection( const bool );
00133 
00135   int incrementalSpeed() const;
00136 
00138   int incrementalSpeedMode() const;
00139 
00141   void setIncrementalSpeed( const int, const int = 0 );
00142 
00144   int spacemouseBtn( const int ) const;
00145 
00147   void setSpacemouseButtons( const int, const int, const int );
00148 
00149 public:
00150   void enableSelection(bool isEnabled);
00151   bool isSelectionEnabled() const { return mySelectionEnabled; }
00152 
00153   void enableMultiselection(bool isEnable);
00154   bool isMultiSelectionEnabled() const { return myMultiSelectionEnabled; }
00155 
00156   int  getSelectionCount() const;
00157 
00158   /* Reimplemented from SALOME_View */
00159 
00161   void Display( const SALOME_VTKPrs* ); 
00162 
00164   void Erase( const SALOME_VTKPrs*, const bool = false );
00165 
00167   void EraseAll( const bool = false );
00168 
00170   virtual void GetVisible( SALOME_ListIO& );
00171 
00173   SALOME_Prs* CreatePrs( const char* entry = 0 );
00174 
00176   virtual bool isVisible( const Handle(SALOME_InteractiveObject)& );
00177 
00179   virtual void Repaint();
00180 
00181  signals:
00182   void actorAdded(SVTK_ViewWindow*, VTKViewer_Actor*);
00183   void actorRemoved(SVTK_ViewWindow*, VTKViewer_Actor*);
00184 
00185 protected slots:
00186   void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
00187   void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
00188   void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
00189 
00190   void onDumpView();
00191   void onChangeBackground();
00192 
00193   void onActorAdded(VTKViewer_Actor*);
00194   void onActorRemoved(VTKViewer_Actor*);
00195 
00196 private:
00197   void updateToolBars();
00198 
00199   Qtx::BackgroundData  myDefaultBackground;
00200   vtkFloatingPointType myTrihedronSize;
00201   bool                 myTrihedronRelative;
00202   bool                 myIsStaticTrihedronVisible;
00203   bool                 mySelectionEnabled;
00204   bool                 myMultiSelectionEnabled;
00205   int                  myIncrementSpeed;
00206   int                  myIncrementMode;
00207   int                  myProjMode;
00208   int                  myStyle;
00209   int                  myZoomingStyle;
00210   bool                 myDynamicPreSelection;
00211   int                  mySpaceBtn[3];
00212 };
00213 
00214 #endif