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