Salome HOME
Make XGUI as a shared library
[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   ~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
71 protected:
72   virtual void paintEvent(QPaintEvent*);
73   virtual void resizeEvent(QResizeEvent*);
74
75 private:
76   Handle(V3d_View) activeView() const
77   {
78     return myActiveView;
79   }
80
81   bool mapView(const Handle(V3d_View)& theView);
82   bool setWindow(const Handle(V3d_View)& theView);
83   bool mapped(const Handle(V3d_View)& theView) const;
84   void updateBackground();
85   void attachWindow(const Handle(V3d_View)& theView, const Handle(Aspect_Window)& theWnd);
86
87   Handle(V3d_View) myOrthoView;Handle(V3d_View) myPerspView;Handle(V3d_View) myActiveView;
88
89   Handle(Aspect_Window) myWindow;
90
91   bool myPaintersRedrawing;
92   bool myIsAdvancedZoomingEnabled;
93
94   double myScale;
95
96   XGUI_ViewBackground myBackground;
97   int myBgImgHeight;
98   int myBgImgWidth;
99 };
100
101 #endif