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, |
29 | QWidget* parent); |
30 | ~View(); |
31 | |
32 | virtual void init(); |
33 | bool dump( Standard_CString theFile ); |
34 | QList<QAction*>* getViewActions(); |
35 | void noActiveActions(); |
36 | bool isShadingMode(); |
37 | |
38 | static QString GetMessages( int type,TopAbs_ShapeEnum aSubShapeType, |
39 | TopAbs_ShapeEnum aShapeType ); |
40 | static QString GetShapeType( TopAbs_ShapeEnum aShapeType ); |
41 | |
42 | Standard_EXPORT static void OnButtonuseraction( int ExerciceSTEP, |
43 | Handle(AIS_InteractiveContext)& ); |
44 | Standard_EXPORT static void DoSelection( int Id, |
45 | Handle(AIS_InteractiveContext)& ); |
46 | Standard_EXPORT static void OnSetSelectionMode( Handle(AIS_InteractiveContext)&, |
47 | Standard_Integer&, |
48 | TopAbs_ShapeEnum& SelectionMode, |
49 | Standard_Boolean& ); |
4d183a4b |
50 | virtual QPaintEngine* paintEngine() const; |
7fd59977 |
51 | signals: |
52 | void selectionChanged(); |
53 | |
54 | public slots: |
55 | void fitAll(); |
56 | void fitArea(); |
57 | void zoom(); |
58 | void pan(); |
59 | void globalPan(); |
60 | void front(); |
61 | void back(); |
62 | void top(); |
63 | void bottom(); |
64 | void left(); |
65 | void right(); |
66 | void axo(); |
67 | void rotation(); |
68 | void reset(); |
69 | void hlrOn(); |
70 | void hlrOff(); |
71 | void updateToggled( bool ); |
72 | void onBackground(); |
73 | |
74 | protected: |
75 | virtual void paintEvent( QPaintEvent* ); |
76 | virtual void resizeEvent( QResizeEvent* ); |
77 | virtual void mousePressEvent( QMouseEvent* ); |
78 | virtual void mouseReleaseEvent(QMouseEvent* ); |
79 | virtual void mouseMoveEvent( QMouseEvent* ); |
80 | |
81 | virtual void addItemInPopup( QMenu* ); |
82 | |
83 | Handle(V3d_View)& getView(); |
84 | Handle(AIS_InteractiveContext)& getContext(); |
85 | void activateCursor( const CurrentAction3d ); |
86 | void Popup( const int x, const int y ); |
87 | CurrentAction3d getCurrentMode(); |
88 | |
89 | virtual void onLButtonDown( const int nFlags, const QPoint point ); |
90 | virtual void onMButtonDown( const int nFlags, const QPoint point ); |
91 | virtual void onRButtonDown( const int nFlags, const QPoint point ); |
92 | virtual void onLButtonUp( Qt::MouseButtons nFlags, const QPoint point ); |
93 | virtual void onMButtonUp( Qt::MouseButtons nFlags, const QPoint point ); |
94 | virtual void onRButtonUp( Qt::MouseButtons nFlags, const QPoint point ); |
95 | virtual void onMouseMove( Qt::MouseButtons nFlags, const QPoint point ); |
96 | |
97 | private: |
98 | void initCursors(); |
99 | void initViewActions(); |
100 | void DragEvent( const int x, const int y, const int TheState ); |
101 | void InputEvent( const int x, const int y ); |
102 | void MoveEvent( const int x, const int y ); |
103 | void MultiMoveEvent( const int x, const int y ); |
104 | void MultiDragEvent( const int x, const int y, const int TheState ); |
105 | void MultiInputEvent( const int x, const int y ); |
106 | void DrawRectangle( const int MinX, const int MinY, |
107 | const int MaxX, const int MaxY, const bool Draw ); |
108 | |
109 | private: |
110 | bool myFirst; |
111 | bool myDrawRect; // set when a rect is used for selection or magnify |
112 | Handle(V3d_View) myView; |
113 | Handle(AIS_InteractiveContext) myContext; |
114 | CurrentAction3d myCurrentMode; |
115 | Standard_Integer myXmin; |
116 | Standard_Integer myYmin; |
117 | Standard_Integer myXmax; |
118 | Standard_Integer myYmax; |
119 | Quantity_Factor myCurZoom; |
de75ed09 |
120 | Standard_Boolean myHlrModeIsOn; |
7fd59977 |
121 | QList<QAction*>* myViewActions; |
122 | QRubberBand* myRectBand; //!< selection rectangle rubber band |
123 | }; |
124 | |
125 | #endif |
126 | |
127 | |