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