Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[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 /*!
39   \class OCCViewer_ViewPort
40   Visualisation canvas of SUIT-based application
41 */
42 class OCCVIEWER_EXPORT OCCViewer_ViewPort : public QWidget
43 {
44         Q_OBJECT
45
46   friend class OCCViewer_ViewSketcher;
47
48 public:
49   OCCViewer_ViewPort( QWidget* parent );
50         virtual ~OCCViewer_ViewPort();
51
52 public:
53         void                             setSketchingEnabled( bool );
54   bool                           isSketchingEnabled() const;
55   void                           setTransformEnabled( bool );
56   bool                           isTransformEnabled() const;
57
58   virtual QColor                         backgroundColor() const;
59   virtual void                     setBackgroundColor( const QColor& );
60
61   void                           redrawPainters();
62
63   virtual void                     onUpdate();
64
65 protected:
66 //      enum ViewType { Type2D, Type3D };
67         void                                     selectVisualId();
68
69 // EVENTS
70         virtual void                   paintEvent( QPaintEvent *);
71         virtual void                     mouseMoveEvent( QMouseEvent *);
72         virtual void                     mouseReleaseEvent( QMouseEvent *);
73         virtual void                     mousePressEvent( QMouseEvent *);
74         virtual void                     mouseDoubleClickEvent( QMouseEvent *);
75   virtual void                     keyPressEvent( QKeyEvent *);
76   virtual void                     keyReleaseEvent( QKeyEvent *);
77
78 // TO BE REDEFINED
79   virtual void                   reset() = 0;
80   virtual void                   pan( int, int ) = 0;
81         virtual void                     setCenter( int, int ) = 0;
82         virtual void                     fitRect( const QRect& ) = 0;
83   virtual void                   zoom( int, int, int, int ) = 0;
84   virtual void                   fitAll( bool keepScale = false, bool withZ = true, bool upd = true ) = 0;
85
86 // POPUP
87 //  void                             onCreatePopup( QPopupMenu* );
88 //      void                             onDestroyPopup( QPopupMenu* );
89
90 protected slots:
91   virtual void                   onChangeBgColor();
92
93 signals:
94   void                                   vpKeyEvent( QKeyEvent* );
95   void                                   vpMouseEvent( QMouseEvent* );
96         void                                 vpDrawExternal( QPainter* );
97   void                           vpChangeBGColor( QColor );
98
99 private:
100         void                             initialize();
101         void                             cleanup();
102
103 protected:
104   Handle(Aspect_Window)         myWindow;
105   bool                                      myEnableSketching;
106   bool                                      myEnableTransform;
107   bool                                      myPaintersRedrawing;        /* set to draw externally */
108   QPtrList<QtxAction>           myPopupActions;
109
110 private:
111         static int                               nCounter;                              /* objects counter */
112 };
113
114 #endif