Salome HOME
ccffe4f1a3f151059586973994053b23c490d751
[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   void setBackground(const XGUI_ViewBackground& bgData);
59
60 signals:
61   void vpChangeBackground(const XGUI_ViewBackground&);
62   void vpClosed();
63   void vpMapped();
64   void vpTransformed();
65   void vpUpdated();
66
67 protected:
68   virtual void paintEvent(QPaintEvent*);
69   virtual void resizeEvent(QResizeEvent*);
70
71 private:
72   Handle(V3d_View) activeView() const
73   {
74     return myActiveView;
75   }
76
77   bool mapView(const Handle(V3d_View)& theView);
78   bool setWindow(const Handle(V3d_View)& theView);
79   bool mapped(const Handle(V3d_View)& theView) const;
80   void updateBackground();
81   void attachWindow(const Handle(V3d_View)& theView, const Handle(Aspect_Window)& theWnd);
82
83   Handle(V3d_View) myOrthoView;Handle(V3d_View) myPerspView;Handle(V3d_View) myActiveView;
84
85   Handle(Aspect_Window) myWindow;
86
87   bool myPaintersRedrawing;
88   bool myIsAdvancedZoomingEnabled;
89
90   double myScale;
91
92   XGUI_ViewBackground myBackground;
93   int myBgImgHeight;
94   int myBgImgWidth;
95 };
96
97 #endif