-
Notifications
You must be signed in to change notification settings - Fork 136
/
occView.h
122 lines (96 loc) · 3.27 KB
/
occView.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
* Copyright (c) 2018 Shing Liu All Rights Reserved.
*
* File : OccView.h
* Author : Shing Liu([email protected])
* Date : 2018-01-09 21:00
* Version : OpenCASCADE7.2.0 & Qt5.7.1
*
* Description : Adapte OpenCASCADE view for Qt.
*/
#ifndef _OCCVIEW_H_
#define _OCCVIEW_H_
#include <QGLWidget>
#include <AIS_InteractiveContext.hxx>
class QMenu;
class QRubberBand;
//! Adapted a QWidget for OpenCASCADE viewer.
class OccView : public QWidget
{
Q_OBJECT
public:
//! mouse actions.
enum CurrentAction3d
{
CurAction3d_Nothing,
CurAction3d_DynamicZooming,
CurAction3d_WindowZooming,
CurAction3d_DynamicPanning,
CurAction3d_GlobalPanning,
CurAction3d_DynamicRotation
};
public:
//! constructor.
OccView(QWidget* parent);
const Handle(AIS_InteractiveContext)& getContext() const;
signals:
void selectionChanged(void);
public slots:
//! operations for the view.
void pan(void);
void fitAll(void);
void reset(void);
void zoom(void);
void rotate(void);
protected:
virtual QPaintEngine* paintEngine() const;
// Paint events.
virtual void paintEvent(QPaintEvent* theEvent);
virtual void resizeEvent(QResizeEvent* theEvent);
// Mouse events.
virtual void mousePressEvent(QMouseEvent* theEvent);
virtual void mouseReleaseEvent(QMouseEvent* theEvent);
virtual void mouseMoveEvent(QMouseEvent * theEvent);
virtual void wheelEvent(QWheelEvent * theEvent);
// Button events.
virtual void onLButtonDown(const int theFlags, const QPoint thePoint);
virtual void onMButtonDown(const int theFlags, const QPoint thePoint);
virtual void onRButtonDown(const int theFlags, const QPoint thePoint);
virtual void onMouseWheel(const int theFlags, const int theDelta, const QPoint thePoint);
virtual void onLButtonUp(const int theFlags, const QPoint thePoint);
virtual void onMButtonUp(const int theFlags, const QPoint thePoint);
virtual void onRButtonUp(const int theFlags, const QPoint thePoint);
virtual void onMouseMove(const int theFlags, const QPoint thePoint);
// Popup menu.
virtual void addItemInPopup(QMenu* theMenu);
protected:
void init(void);
void popup(const int x, const int y);
void dragEvent(const int x, const int y);
void inputEvent(const int x, const int y);
void moveEvent(const int x, const int y);
void multiMoveEvent(const int x, const int y);
void multiDragEvent(const int x, const int y);
void multiInputEvent(const int x, const int y);
void drawRubberBand(const int minX, const int minY, const int maxX, const int maxY);
void panByMiddleButton(const QPoint& thePoint);
private:
//! the occ viewer.
Handle(V3d_Viewer) myViewer;
//! the occ view.
Handle(V3d_View) myView;
//! the occ context.
Handle(AIS_InteractiveContext) myContext;
//! save the mouse position.
Standard_Integer myXmin;
Standard_Integer myYmin;
Standard_Integer myXmax;
Standard_Integer myYmax;
//! the mouse current mode.
CurrentAction3d myCurrentMode;
//! save the degenerate mode state.
Standard_Boolean myDegenerateModeIsOn;
//! rubber rectangle for the mouse selection.
QRubberBand* myRectBand;
};
#endif // _OCCVIEW_H_