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, |
de6273a3 |
20 | CurAction3d_WindowZooming, CurAction3d_DynamicPanning, |
21 | CurAction3d_GlobalPanning, CurAction3d_DynamicRotation }; |
7fd59977 |
22 | |
23 | public: |
24 | enum ViewAction { ViewFitAllId, ViewFitAreaId, ViewZoomId, ViewPanId, ViewGlobalPanId, |
25 | ViewFrontId, ViewBackId, ViewTopId, ViewBottomId, ViewLeftId, ViewRightId, |
26 | ViewAxoId, ViewRotationId, ViewResetId, ViewHlrOffId, ViewHlrOnId }; |
861a7b03 |
27 | enum RaytraceAction { ToolRaytracingId, ToolShadowsId, ToolReflectionsId, ToolAntialiasingId }; |
7fd59977 |
28 | |
861a7b03 |
29 | View( Handle(AIS_InteractiveContext) theContext, QWidget* parent ); |
e276548b |
30 | |
7fd59977 |
31 | ~View(); |
32 | |
33 | virtual void init(); |
34 | bool dump( Standard_CString theFile ); |
35 | QList<QAction*>* getViewActions(); |
861a7b03 |
36 | QList<QAction*>* getRaytraceActions(); |
7fd59977 |
37 | void noActiveActions(); |
38 | bool isShadingMode(); |
39 | |
861a7b03 |
40 | void EnableRaytracing(); |
41 | void DisableRaytracing(); |
42 | |
43 | void SetRaytracedShadows (bool theState); |
44 | void SetRaytracedReflections (bool theState); |
45 | void SetRaytracedAntialiasing (bool theState); |
46 | |
47 | bool IsRaytracingMode() const { return myIsRaytracing; } |
48 | bool IsShadowsEnabled() const { return myIsShadowsEnabled; } |
49 | bool IsReflectionsEnabled() const { return myIsReflectionsEnabled; } |
50 | bool IsAntialiasingEnabled() const { return myIsAntialiasingEnabled; } |
e276548b |
51 | |
7fd59977 |
52 | static QString GetMessages( int type,TopAbs_ShapeEnum aSubShapeType, |
53 | TopAbs_ShapeEnum aShapeType ); |
54 | static QString GetShapeType( TopAbs_ShapeEnum aShapeType ); |
55 | |
56 | Standard_EXPORT static void OnButtonuseraction( int ExerciceSTEP, |
de6273a3 |
57 | Handle(AIS_InteractiveContext)& ); |
7fd59977 |
58 | Standard_EXPORT static void DoSelection( int Id, |
59 | Handle(AIS_InteractiveContext)& ); |
60 | Standard_EXPORT static void OnSetSelectionMode( Handle(AIS_InteractiveContext)&, |
61 | Standard_Integer&, |
de6273a3 |
62 | TopAbs_ShapeEnum& SelectionMode, |
63 | Standard_Boolean& ); |
64 | virtual QPaintEngine* paintEngine() const; |
7fd59977 |
65 | signals: |
66 | void selectionChanged(); |
67 | |
68 | public slots: |
69 | void fitAll(); |
70 | void fitArea(); |
71 | void zoom(); |
72 | void pan(); |
73 | void globalPan(); |
74 | void front(); |
75 | void back(); |
76 | void top(); |
77 | void bottom(); |
78 | void left(); |
79 | void right(); |
80 | void axo(); |
81 | void rotation(); |
82 | void reset(); |
83 | void hlrOn(); |
84 | void hlrOff(); |
85 | void updateToggled( bool ); |
86 | void onBackground(); |
e276548b |
87 | void onEnvironmentMap(); |
861a7b03 |
88 | void onRaytraceAction(); |
7fd59977 |
89 | |
90 | protected: |
91 | virtual void paintEvent( QPaintEvent* ); |
92 | virtual void resizeEvent( QResizeEvent* ); |
93 | virtual void mousePressEvent( QMouseEvent* ); |
94 | virtual void mouseReleaseEvent(QMouseEvent* ); |
95 | virtual void mouseMoveEvent( QMouseEvent* ); |
96 | |
97 | virtual void addItemInPopup( QMenu* ); |
98 | |
99 | Handle(V3d_View)& getView(); |
100 | Handle(AIS_InteractiveContext)& getContext(); |
101 | void activateCursor( const CurrentAction3d ); |
102 | void Popup( const int x, const int y ); |
103 | CurrentAction3d getCurrentMode(); |
104 | |
105 | virtual void onLButtonDown( const int nFlags, const QPoint point ); |
106 | virtual void onMButtonDown( const int nFlags, const QPoint point ); |
107 | virtual void onRButtonDown( const int nFlags, const QPoint point ); |
108 | virtual void onLButtonUp( Qt::MouseButtons nFlags, const QPoint point ); |
109 | virtual void onMButtonUp( Qt::MouseButtons nFlags, const QPoint point ); |
110 | virtual void onRButtonUp( Qt::MouseButtons nFlags, const QPoint point ); |
111 | virtual void onMouseMove( Qt::MouseButtons nFlags, const QPoint point ); |
112 | |
113 | private: |
114 | void initCursors(); |
115 | void initViewActions(); |
861a7b03 |
116 | void initRaytraceActions(); |
7fd59977 |
117 | void DragEvent( const int x, const int y, const int TheState ); |
118 | void InputEvent( const int x, const int y ); |
119 | void MoveEvent( const int x, const int y ); |
120 | void MultiMoveEvent( const int x, const int y ); |
121 | void MultiDragEvent( const int x, const int y, const int TheState ); |
122 | void MultiInputEvent( const int x, const int y ); |
123 | void DrawRectangle( const int MinX, const int MinY, |
124 | const int MaxX, const int MaxY, const bool Draw ); |
125 | |
126 | private: |
861a7b03 |
127 | bool myIsRaytracing; |
128 | bool myIsShadowsEnabled; |
129 | bool myIsReflectionsEnabled; |
130 | bool myIsAntialiasingEnabled; |
131 | |
de6273a3 |
132 | bool myDrawRect; // set when a rect is used for selection or magnify |
7fd59977 |
133 | Handle(V3d_View) myView; |
134 | Handle(AIS_InteractiveContext) myContext; |
135 | CurrentAction3d myCurrentMode; |
136 | Standard_Integer myXmin; |
137 | Standard_Integer myYmin; |
138 | Standard_Integer myXmax; |
139 | Standard_Integer myYmax; |
140 | Quantity_Factor myCurZoom; |
de75ed09 |
141 | Standard_Boolean myHlrModeIsOn; |
7fd59977 |
142 | QList<QAction*>* myViewActions; |
861a7b03 |
143 | QList<QAction*>* myRaytraceActions; |
e276548b |
144 | QMenu* myBackMenu; |
7fd59977 |
145 | QRubberBand* myRectBand; //!< selection rectangle rubber band |
146 | }; |
147 | |
148 | #endif |
149 | |
150 | |