-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoccview.h
128 lines (103 loc) · 3.64 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
123
124
125
126
127
128
/*
* Copyright (c) 2014 eryar All Rights Reserved.
*
* File : OccView.h
* Author : eryar@163.com
* Date : 2014-07-15 21:00
* Version : OpenCASCADE6.8.0 & Qt5.4
*
* Description : Adapte OpenCASCADE view for Qt.
*
*/
#ifndef _OCCVIEW_H_
#define _OCCVIEW_H_
#include <QObject>
#include <QWidget>
#include <OpenGl_GraphicDriver.hxx>
#include <QtOpenGL/QGLWidget>
#include <AIS_InteractiveContext.hxx>
#include <V3d_View.hxx>
class QMenu;
class QRubberBand;
//! adapted a QGLWidget for OpenCASCADE viewer.
class OccView : public QGLWidget
{
Q_OBJECT
public:
//! mouse actions.
enum CurrentAction3d
{
CurAction3d_Nothing,
CurAction3d_DynamicZooming,
CurAction3d_WindowZooming,
CurAction3d_DynamicPanning,
CurAction3d_GlobalPanning,
CurAction3d_DynamicRotation
};
public:
//! constructor.
OccView(Handle_AIS_InteractiveContext theContext, QWidget* parent);
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:
// Paint events.
virtual void paintEvent(QPaintEvent* e);
virtual void resizeEvent(QResizeEvent* e);
// Mouse events.
virtual void mousePressEvent(QMouseEvent* e);
virtual void mouseReleaseEvent(QMouseEvent* e);
virtual void mouseMoveEvent(QMouseEvent * e);
virtual void wheelEvent(QWheelEvent * e);
// 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 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:
Handle_V3d_Viewer Viewer(const Standard_ExtString theName,
const Standard_CString theDomain,
const Standard_Real theViewSize,
const V3d_TypeOfOrientation theViewProj,
const Standard_Boolean theComputedMode,
const Standard_Boolean theDefaultComputedMode);
//! the occ viewer.
Handle_V3d_View mView;
Handle_V3d_Viewer myViewer;
//! the occ context.
Handle_AIS_InteractiveContext mContext;
//! save the mouse position.
Standard_Integer mXmin;
Standard_Integer mYmin;
Standard_Integer mXmax;
Standard_Integer mYmax;
//! the mouse current mode.
CurrentAction3d mCurrentMode;
//! save the degenerate mode state.
Standard_Boolean mDegenerateModeIsOn;
//! rubber rectangle for the mouse selection.
QRubberBand* mRectBand;
};
#endif // _OCCVIEW_H_