Salome HOME
Initial version
[modules/gui.git] / src / OCCViewer / OCCViewer_ViewPort.h
1 #ifndef OCCVIEWER_VIEWPORT_H
2 #define OCCVIEWER_VIEWPORT_H
3
4 #include "OCCViewer.h"
5
6 #include "QtxAction.h"
7
8 #include <qlist.h>
9 #include <qcolor.h>
10 #include <qwidget.h>
11
12 #include <Aspect_Window.hxx>
13
14 class QRect;
15 class QCursor;
16 class QPainter;
17 class OCCViewer_ViewSketcher;
18 class OCCViewer_ViewTransformer;
19
20 class OCCVIEWER_EXPORT OCCViewer_ViewPort : public QWidget
21 {
22         Q_OBJECT
23
24   friend class OCCViewer_ViewSketcher;
25
26 public:
27   OCCViewer_ViewPort( QWidget* parent );
28         virtual ~OCCViewer_ViewPort();
29
30 public:
31         void                             setSketchingEnabled( bool );
32   bool                           isSketchingEnabled() const;
33   void                           setTransformEnabled( bool );
34   bool                           isTransformEnabled() const;
35
36   virtual QColor                         backgroundColor() const;
37   virtual void                     setBackgroundColor( const QColor& );
38
39   void                           redrawPainters();
40
41   virtual void                     onUpdate();
42
43 protected:
44 //      enum ViewType { Type2D, Type3D };
45         void                                     selectVisualId();
46
47 // EVENTS
48         virtual void                   paintEvent( QPaintEvent *);
49         virtual void                     mouseMoveEvent( QMouseEvent *);
50         virtual void                     mouseReleaseEvent( QMouseEvent *);
51         virtual void                     mousePressEvent( QMouseEvent *);
52         virtual void                     mouseDoubleClickEvent( QMouseEvent *);
53   virtual void                     keyPressEvent( QKeyEvent *);
54   virtual void                     keyReleaseEvent( QKeyEvent *);
55
56 // TO BE REDEFINED
57   virtual void                   reset() = 0;
58   virtual void                   pan( int, int ) = 0;
59         virtual void                     setCenter( int, int ) = 0;
60         virtual void                     fitRect( const QRect& ) = 0;
61   virtual void                   zoom( int, int, int, int ) = 0;
62   virtual void                   fitAll( bool keepScale = false, bool withZ = true ) = 0;
63
64 // POPUP
65 //  void                             onCreatePopup( QPopupMenu* );
66 //      void                             onDestroyPopup( QPopupMenu* );
67
68 protected slots:
69   virtual void                   onChangeBgColor();
70
71 signals:
72   void                                   vpKeyEvent( QKeyEvent* );
73   void                                   vpMouseEvent( QMouseEvent* );
74         void                                 vpDrawExternal( QPainter* );
75   void                           vpChangeBGColor( QColor );
76
77 private:
78         void                             initialize();
79         void                             cleanup();
80
81 protected:
82   Handle(Aspect_Window)         myWindow;
83   bool                                      myEnableSketching;
84   bool                                      myEnableTransform;
85   bool                                      myPaintersRedrawing;        /* set to draw externally */
86   QPtrList<QtxAction>           myPopupActions;
87
88 private:
89         static int                               nCounter;                              /* objects counter */
90 };
91
92 #endif