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