Salome HOME
Features and plugins loading mechanisms
[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
44   void setAdvancedZoomingEnabled(const bool theState)
45   {
46     myIsAdvancedZoomingEnabled = theState;
47   }
48   bool isAdvancedZoomingEnabled() const
49   {
50     return myIsAdvancedZoomingEnabled;
51   }
52
53   XGUI_ViewBackground background() const
54   {
55     return myBackground;
56   }
57   void setBackground(const XGUI_ViewBackground& bgData);
58
59 signals:
60   void vpChangeBackground(const XGUI_ViewBackground&);
61   void vpClosed();
62   void vpMapped();
63   void vpTransformed();
64   void vpUpdated();
65
66 protected:
67   virtual void paintEvent(QPaintEvent*);
68   virtual void resizeEvent(QResizeEvent*);
69
70 private:
71   Handle(V3d_View) activeView() const
72   {
73     return myActiveView;
74   }
75
76   bool mapView(const Handle(V3d_View)& theView);
77   bool setWindow(const Handle(V3d_View)& theView);
78   bool mapped(const Handle(V3d_View)& theView) const;
79   void updateBackground();
80   void attachWindow(const Handle(V3d_View)& theView, const Handle(Aspect_Window)& theWnd);
81
82   Handle(V3d_View) myOrthoView;Handle(V3d_View) myPerspView;Handle(V3d_View) myActiveView;
83
84   Handle(Aspect_Window) myWindow;
85
86   bool myPaintersRedrawing;
87   bool myIsAdvancedZoomingEnabled;
88
89   double myScale;
90
91   XGUI_ViewBackground myBackground;
92   int myBgImgHeight;
93   int myBgImgWidth;
94 };
95
96 #endif