Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / XGUI / XGUI_ViewPort.h
1 #ifndef XGUI_ViewPort_H
2 #define XGUI_ViewPort_H
3
4 #include "XGUI.h"
5 #include "XGUI_ViewBackground.h"
6
7 #include <QWidget>
8 #include <V3d_Viewer.hxx>
9 #include <V3d_View.hxx>
10 #include <gp_Pnt.hxx>
11
12 class XGUI_ViewWindow;
13
14 class XGUI_EXPORT XGUI_ViewPort: public QWidget
15 {
16 Q_OBJECT
17 public:
18   XGUI_ViewPort(XGUI_ViewWindow* theParent, const Handle(V3d_Viewer)& theViewer,
19                 V3d_TypeOfView theType = V3d_ORTHOGRAPHIC);
20   virtual ~XGUI_ViewPort();
21
22   virtual QPaintEngine* paintEngine() const
23   {
24     return 0;
25   }
26
27   QImage dumpView(QRect theRect = QRect(), bool toUpdate = true);
28
29   Handle(V3d_View) getView() const
30   {
31     return activeView();
32   }
33
34   void startRotation(int x, int y, int theRotationPointType, const gp_Pnt& theSelectedPoint);
35   void rotate(int, int, int, const gp_Pnt&);
36   void endRotation();
37
38   // TRANSFORMATIONS
39   void pan(int dx, int dy);
40   void setCenter(int x, int y);
41   void fitRect(const QRect& rect);
42   void startZoomAtPoint(int x, int y);
43   void zoom(int x0, int y0, int x, int y);
44   void fitAll(bool theKeepScale = false, bool theWithZ = true, bool theUpd = true);
45
46   void setAdvancedZoomingEnabled(const bool theState)
47   {
48     myIsAdvancedZoomingEnabled = theState;
49   }
50   bool isAdvancedZoomingEnabled() const
51   {
52     return myIsAdvancedZoomingEnabled;
53   }
54
55   XGUI_ViewBackground background() const
56   {
57     return myBackground;
58   }
59
60   void setBackground(const XGUI_ViewBackground& bgData);
61
62   void syncronizeWith( const XGUI_ViewPort* ref );
63
64 signals:
65   void vpChangeBackground(const XGUI_ViewBackground&);
66   void vpClosed();
67   void vpMapped();
68   void vpTransformed();
69   void vpUpdated();
70   void resized();
71
72 protected:
73   virtual void paintEvent(QPaintEvent*);
74   virtual void resizeEvent(QResizeEvent*);
75
76 private:
77   Handle(V3d_View) activeView() const
78   {
79     return myActiveView;
80   }
81
82   bool mapView(const Handle(V3d_View)& theView);
83   bool setWindow(const Handle(V3d_View)& theView);
84   bool mapped(const Handle(V3d_View)& theView) const;
85   void updateBackground();
86   void attachWindow(const Handle(V3d_View)& theView, const Handle(Aspect_Window)& theWnd);
87
88   Handle(V3d_View) myOrthoView;Handle(V3d_View) myPerspView;Handle(V3d_View) myActiveView;
89
90   Handle(Aspect_Window) myWindow;
91
92   bool myPaintersRedrawing;
93   bool myIsAdvancedZoomingEnabled;
94
95   double myScale;
96
97   XGUI_ViewBackground myBackground;
98   int myBgImgHeight;
99   int myBgImgWidth;
100 };
101
102 #endif