7fd59977 |
1 | #ifndef VIEW_H |
2 | #define VIEW_H |
3 | |
4 | #include <QWidget> |
5 | #include <QAction> |
6 | #include <QList> |
7 | |
8 | #include <AIS_InteractiveContext.hxx> |
9 | #include <V3d_View.hxx> |
10 | |
11 | class TopoDS_Shape; |
12 | class QRubberBand; |
13 | |
14 | //class COMMONSAMPLE_EXPORT View: public QWidget |
15 | class View: public QWidget |
16 | { |
17 | Q_OBJECT |
18 | protected: |
19 | enum CurrentAction3d { CurAction3d_Nothing, CurAction3d_DynamicZooming, |
20 | CurAction3d_WindowZooming, CurAction3d_DynamicPanning, |
21 | CurAction3d_GlobalPanning, CurAction3d_DynamicRotation }; |
22 | |
23 | public: |
24 | enum ViewAction { ViewFitAllId, ViewFitAreaId, ViewZoomId, ViewPanId, ViewGlobalPanId, |
25 | ViewFrontId, ViewBackId, ViewTopId, ViewBottomId, ViewLeftId, ViewRightId, |
26 | ViewAxoId, ViewRotationId, ViewResetId, ViewHlrOffId, ViewHlrOnId }; |
27 | |
28 | View( Handle(AIS_InteractiveContext) theContext, |
e276548b |
29 | QWidget* parent, |
30 | bool theRT = false ); |
31 | |
7fd59977 |
32 | ~View(); |
33 | |
34 | virtual void init(); |
35 | bool dump( Standard_CString theFile ); |
36 | QList<QAction*>* getViewActions(); |
37 | void noActiveActions(); |
38 | bool isShadingMode(); |
39 | |
e276548b |
40 | void setRaytracedShadows( int state ); |
41 | void setRaytracedReflections( int state ); |
42 | void setRaytracedAntialiasing( int state ); |
43 | |
7fd59977 |
44 | static QString GetMessages( int type,TopAbs_ShapeEnum aSubShapeType, |
45 | TopAbs_ShapeEnum aShapeType ); |
46 | static QString GetShapeType( TopAbs_ShapeEnum aShapeType ); |
47 | |
48 | Standard_EXPORT static void OnButtonuseraction( int ExerciceSTEP, |
49 | Handle(AIS_InteractiveContext)& ); |
50 | Standard_EXPORT static void DoSelection( int Id, |
51 | Handle(AIS_InteractiveContext)& ); |
52 | Standard_EXPORT static void OnSetSelectionMode( Handle(AIS_InteractiveContext)&, |
53 | Standard_Integer&, |
54 | TopAbs_ShapeEnum& SelectionMode, |
55 | Standard_Boolean& ); |
4d183a4b |
56 | virtual QPaintEngine* paintEngine() const; |
7fd59977 |
57 | signals: |
58 | void selectionChanged(); |
59 | |
60 | public slots: |
61 | void fitAll(); |
62 | void fitArea(); |
63 | void zoom(); |
64 | void pan(); |
65 | void globalPan(); |
66 | void front(); |
67 | void back(); |
68 | void top(); |
69 | void bottom(); |
70 | void left(); |
71 | void right(); |
72 | void axo(); |
73 | void rotation(); |
74 | void reset(); |
75 | void hlrOn(); |
76 | void hlrOff(); |
77 | void updateToggled( bool ); |
78 | void onBackground(); |
e276548b |
79 | void onEnvironmentMap(); |
7fd59977 |
80 | |
81 | protected: |
82 | virtual void paintEvent( QPaintEvent* ); |
83 | virtual void resizeEvent( QResizeEvent* ); |
84 | virtual void mousePressEvent( QMouseEvent* ); |
85 | virtual void mouseReleaseEvent(QMouseEvent* ); |
86 | virtual void mouseMoveEvent( QMouseEvent* ); |
87 | |
88 | virtual void addItemInPopup( QMenu* ); |
89 | |
90 | Handle(V3d_View)& getView(); |
91 | Handle(AIS_InteractiveContext)& getContext(); |
92 | void activateCursor( const CurrentAction3d ); |
93 | void Popup( const int x, const int y ); |
94 | CurrentAction3d getCurrentMode(); |
95 | |
96 | virtual void onLButtonDown( const int nFlags, const QPoint point ); |
97 | virtual void onMButtonDown( const int nFlags, const QPoint point ); |
98 | virtual void onRButtonDown( const int nFlags, const QPoint point ); |
99 | virtual void onLButtonUp( Qt::MouseButtons nFlags, const QPoint point ); |
100 | virtual void onMButtonUp( Qt::MouseButtons nFlags, const QPoint point ); |
101 | virtual void onRButtonUp( Qt::MouseButtons nFlags, const QPoint point ); |
102 | virtual void onMouseMove( Qt::MouseButtons nFlags, const QPoint point ); |
103 | |
104 | private: |
105 | void initCursors(); |
106 | void initViewActions(); |
107 | void DragEvent( const int x, const int y, const int TheState ); |
108 | void InputEvent( const int x, const int y ); |
109 | void MoveEvent( const int x, const int y ); |
110 | void MultiMoveEvent( const int x, const int y ); |
111 | void MultiDragEvent( const int x, const int y, const int TheState ); |
112 | void MultiInputEvent( const int x, const int y ); |
113 | void DrawRectangle( const int MinX, const int MinY, |
114 | const int MaxX, const int MaxY, const bool Draw ); |
115 | |
116 | private: |
e276548b |
117 | bool myIsRT; |
7fd59977 |
118 | bool myFirst; |
119 | bool myDrawRect; // set when a rect is used for selection or magnify |
120 | Handle(V3d_View) myView; |
121 | Handle(AIS_InteractiveContext) myContext; |
122 | CurrentAction3d myCurrentMode; |
123 | Standard_Integer myXmin; |
124 | Standard_Integer myYmin; |
125 | Standard_Integer myXmax; |
126 | Standard_Integer myYmax; |
127 | Quantity_Factor myCurZoom; |
de75ed09 |
128 | Standard_Boolean myHlrModeIsOn; |
7fd59977 |
129 | QList<QAction*>* myViewActions; |
e276548b |
130 | QMenu* myBackMenu; |
7fd59977 |
131 | QRubberBand* myRectBand; //!< selection rectangle rubber band |
132 | }; |
133 | |
134 | #endif |
135 | |
136 | |