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