]> SALOME platform Git repositories - modules/gui.git/blob - src/OCCViewer/OCCViewer_ViewPort.h
Salome HOME
5c60ad502c5a9a2e6ccc1a041eb53f4d09e1c9af
[modules/gui.git] / src / OCCViewer / OCCViewer_ViewPort.h
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 // 
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/
18 //
19 #ifndef OCCVIEWER_VIEWPORT_H
20 #define OCCVIEWER_VIEWPORT_H
21
22 #include "OCCViewer.h"
23
24 #include "QtxAction.h"
25
26 #include <qlist.h>
27 #include <qcolor.h>
28 #include <qwidget.h>
29
30 #include <Aspect_Window.hxx>
31
32 class QRect;
33 class QCursor;
34 class QPainter;
35 class OCCViewer_ViewSketcher;
36 class OCCViewer_ViewTransformer;
37
38 class OCCVIEWER_EXPORT OCCViewer_ViewPort : public QWidget
39 {
40         Q_OBJECT
41
42   friend class OCCViewer_ViewSketcher;
43
44 public:
45   OCCViewer_ViewPort( QWidget* parent );
46         virtual ~OCCViewer_ViewPort();
47
48 public:
49         void                             setSketchingEnabled( bool );
50   bool                           isSketchingEnabled() const;
51   void                           setTransformEnabled( bool );
52   bool                           isTransformEnabled() const;
53
54   virtual QColor                         backgroundColor() const;
55   virtual void                     setBackgroundColor( const QColor& );
56
57   void                           redrawPainters();
58
59   virtual void                     onUpdate();
60
61 protected:
62 //      enum ViewType { Type2D, Type3D };
63         void                                     selectVisualId();
64
65 // EVENTS
66         virtual void                   paintEvent( QPaintEvent *);
67         virtual void                     mouseMoveEvent( QMouseEvent *);
68         virtual void                     mouseReleaseEvent( QMouseEvent *);
69         virtual void                     mousePressEvent( QMouseEvent *);
70         virtual void                     mouseDoubleClickEvent( QMouseEvent *);
71   virtual void                     keyPressEvent( QKeyEvent *);
72   virtual void                     keyReleaseEvent( QKeyEvent *);
73
74 // TO BE REDEFINED
75   virtual void                   reset() = 0;
76   virtual void                   pan( int, int ) = 0;
77         virtual void                     setCenter( int, int ) = 0;
78         virtual void                     fitRect( const QRect& ) = 0;
79   virtual void                   zoom( int, int, int, int ) = 0;
80   virtual void                   fitAll( bool keepScale = false, bool withZ = true, bool upd = true ) = 0;
81
82 // POPUP
83 //  void                             onCreatePopup( QPopupMenu* );
84 //      void                             onDestroyPopup( QPopupMenu* );
85
86 protected slots:
87   virtual void                   onChangeBgColor();
88
89 signals:
90   void                                   vpKeyEvent( QKeyEvent* );
91   void                                   vpMouseEvent( QMouseEvent* );
92         void                                 vpDrawExternal( QPainter* );
93   void                           vpChangeBGColor( QColor );
94
95 private:
96         void                             initialize();
97         void                             cleanup();
98
99 protected:
100   Handle(Aspect_Window)         myWindow;
101   bool                                      myEnableSketching;
102   bool                                      myEnableTransform;
103   bool                                      myPaintersRedrawing;        /* set to draw externally */
104   QPtrList<QtxAction>           myPopupActions;
105
106 private:
107         static int                               nCounter;                              /* objects counter */
108 };
109
110 #endif