Back to index

salome-gui  6.5.0
OCCViewer_ViewPort.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 OCCVIEWER_VIEWPORT_H
00024 #define OCCVIEWER_VIEWPORT_H
00025 
00026 #include "OCCViewer.h"
00027 
00028 #include "QtxAction.h"
00029 
00030 #include <QList>
00031 #include <QWidget>
00032 
00033 #include <Aspect_Window.hxx>
00034 
00035 class QColor;
00036 class QRect;
00037 class QPainter;
00038 class OCCViewer_ViewSketcher;
00039 
00040 #ifdef WIN32
00041 #pragma warning ( disable:4251 )
00042 #endif
00043 
00048 class OCCVIEWER_EXPORT OCCViewer_ViewPort : public QWidget
00049 {
00050   Q_OBJECT
00051 
00052   friend class OCCViewer_ViewSketcher;
00053 
00054 public:
00055   OCCViewer_ViewPort( QWidget* parent );
00056   virtual ~OCCViewer_ViewPort();
00057 
00058 public:
00059   void                           setSketchingEnabled( bool );
00060   bool                           isSketchingEnabled() const;
00061   void                           setTransformEnabled( bool );
00062   bool                           isTransformEnabled() const;
00063 
00064   virtual QColor                 backgroundColor() const;
00065   virtual void                   setBackgroundColor( const QColor& );
00066 
00067   void                           redrawPainters();
00068 
00069   virtual void                   onUpdate();
00070 
00071   virtual QPaintEngine*          paintEngine() const;
00072 
00073 protected:
00074 //      enum ViewType { Type2D, Type3D };
00075   void                           selectVisualId();
00076 
00077 // EVENTS
00078   virtual void                   paintEvent( QPaintEvent *);
00079   virtual void                   mouseMoveEvent( QMouseEvent *);
00080   virtual void                   mouseReleaseEvent( QMouseEvent *);
00081   virtual void                   mousePressEvent( QMouseEvent *);
00082   virtual void                   mouseDoubleClickEvent( QMouseEvent *);
00083   virtual void                   keyPressEvent( QKeyEvent *);
00084   virtual void                   keyReleaseEvent( QKeyEvent *);
00085 
00086 // TO BE REDEFINED
00087   virtual void                   reset() = 0;
00088   virtual void                   pan( int, int ) = 0;
00089   virtual void                   setCenter( int, int ) = 0;
00090   virtual void                   fitRect( const QRect& ) = 0;
00091   virtual void                   zoom( int, int, int, int ) = 0;
00092   virtual void                   fitAll( bool keepScale = false, bool withZ = true, bool upd = true ) = 0;
00093 
00094 // POPUP
00095 //  void                             onCreatePopup( QPopupMenu* );
00096 //  void                             onDestroyPopup( QPopupMenu* );
00097 
00098 public slots:
00099   virtual bool                   synchronize( OCCViewer_ViewPort* );
00100 
00101 protected slots:
00102   virtual void                   onChangeBackground();
00103 
00104 signals:
00105   void                           vpKeyEvent( QKeyEvent* );
00106   void                           vpMouseEvent( QMouseEvent* );
00107   void                           vpDrawExternal( QPainter* );
00108   void                           vpChangeBGColor( QColor );
00109   void                           vpTransformed( OCCViewer_ViewPort* );
00110 
00111 private:
00112   void                           initialize();
00113   void                           cleanup();
00114 
00115 protected:
00116   Handle(Aspect_Window)          myWindow;
00117   bool                           myEnableSketching;
00118   bool                           myEnableTransform;
00119   bool                           myPaintersRedrawing; /* set to draw externally */
00120   QList<QtxAction*>              myPopupActions;
00121   
00122 private:
00123   static int                     nCounter; /* objects counter */
00124 };
00125 
00126 #ifdef WIN32
00127 #pragma warning ( default:4251 )
00128 #endif
00129 
00130 #endif