Back to index

salome-gui  6.5.0
VTKViewer_ViewWindow.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 VTKVIEWER_VIEWWINDOW_H
00024 #define VTKVIEWER_VIEWWINDOW_H
00025 
00026 #include "VTKViewer.h"
00027 
00028 #include "SUIT_ViewWindow.h"
00029 
00030 #include "QtxAction.h"
00031 
00032 class vtkRenderer;
00033 class SUIT_Desktop;
00034 class VTKViewer_Viewer;
00035 class VTKViewer_Trihedron;
00036 class VTKViewer_Transform;
00037 class VTKViewer_RenderWindow;
00038 class VTKViewer_InteractorStyle;
00039 class VTKViewer_RenderWindowInteractor;
00040 class VTKViewer_Actor;
00041 
00042 #ifdef WIN32
00043 #pragma warning( disable:4251 )
00044 #endif
00045 
00046 class VTKVIEWER_EXPORT VTKViewer_ViewWindow : public SUIT_ViewWindow
00047 {
00048   Q_OBJECT
00049 
00050 public:
00051   VTKViewer_ViewWindow( SUIT_Desktop*, VTKViewer_Viewer*,
00052                         VTKViewer_InteractorStyle* = 0,
00053                         VTKViewer_RenderWindowInteractor* = 0 );
00054   virtual ~VTKViewer_ViewWindow();
00055   
00057   QToolBar*                         getToolBar() { return myToolBar; }
00058   
00059   void                              setBackgroundColor( const QColor& ); // obsolete
00060   QColor                            backgroundColor() const;             // obsolete
00061   void                              setBackground( const Qtx::BackgroundData& );
00062   Qtx::BackgroundData               background() const;
00063 
00065   vtkRenderer*                      getRenderer()     { return myRenderer;     }
00067   VTKViewer_RenderWindow*           getRenderWindow() { return myRenderWindow; }
00069   VTKViewer_RenderWindowInteractor* getRWInteractor() { return myRWInteractor; }
00070   bool                              isTrihedronDisplayed();
00071 
00072   void Repaint( bool theUpdateTrihedron = true );
00073   void onAdjustTrihedron();
00074   void GetScale( double theScale[3] );
00075   void SetScale( double theScale[3] );
00076   void AddActor( VTKViewer_Actor*, bool update = false );
00077   void RemoveActor( VTKViewer_Actor*, bool update = false);
00078 
00079   virtual QString   getVisualParameters();
00080   virtual void      setVisualParameters( const QString& parameters );
00081 
00082 public slots:
00083   void onFrontView();
00084   void onBackView();
00085   void onTopView();
00086   void onBottomView();
00087   void onLeftView();
00088   void onRightView();
00089   void onClockWiseView();
00090   void onAntiClockWiseView();
00091   void onResetView();
00092   void onFitAll();
00093   void activateZoom();
00094   void activateWindowFit();
00095   void activateRotation();
00096   void activatePanning();
00097   void activateGlobalPanning();
00098   void onTrihedronShow();
00099 
00100 protected:
00101   QImage dumpView();
00102 
00103 protected slots:
00104   void onKeyPressed(QKeyEvent* event);
00105   void onKeyReleased(QKeyEvent* event);
00106   void onMousePressed(QMouseEvent* event);
00107   void onMouseDoubleClicked(QMouseEvent* event);
00108   void onMouseReleased(QMouseEvent* event);
00109   void onMouseMoving(QMouseEvent* event);
00110 
00111 private:
00112   void                              InsertActor( VTKViewer_Actor* theActor,
00113                                                  bool theMoveInternalActors = false );
00114   void                              MoveActor( VTKViewer_Actor* theActor );
00115 
00116 private:
00117   enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId,
00118          FrontId, BackId, TopId, BottomId, LeftId, RightId, ClockWiseId, AntiClockWiseId,
00119         ResetId, TrihedronShowId };
00120   typedef QMap<int, QtxAction*> ActionsMap;
00121   
00122   void    createActions();
00123   void    createToolBar();
00124   
00125   VTKViewer_Viewer*                 myModel;
00126  
00127   vtkRenderer*                      myRenderer;
00128   VTKViewer_RenderWindow*           myRenderWindow;
00129   VTKViewer_RenderWindowInteractor* myRWInteractor;
00130   
00131   VTKViewer_Trihedron*              myTrihedron;  
00132   VTKViewer_Transform*              myTransform;
00133   
00134   QToolBar*                         myToolBar;
00135   ActionsMap                        myActionsMap;  
00136   
00137   double                            myCurScale;
00138   Qtx::BackgroundData               myBackground;
00139 
00140   friend class VTKViewer_RenderWindowInteractor;
00141 };
00142 
00143 #ifdef WIN32
00144 #pragma warning( default:4251 )
00145 #endif
00146 
00147 #endif