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