Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
fd1da009
O
Opencv
项目概览
Greenplum
/
Opencv
大约 1 年 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fd1da009
编写于
8月 18, 2016
作者:
A
Alexander Alekhin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7129 from paroj:mousecallback-dry-code
上级
2f069c10
46bfdbaf
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
122 addition
and
203 deletion
+122
-203
modules/highgui/src/window_QT.cpp
modules/highgui/src/window_QT.cpp
+100
-184
modules/highgui/src/window_QT.h
modules/highgui/src/window_QT.h
+22
-19
未找到文件。
modules/highgui/src/window_QT.cpp
浏览文件 @
fd1da009
...
@@ -2300,11 +2300,90 @@ void CvWindow::icvSaveTrackbars(QSettings* settings)
...
@@ -2300,11 +2300,90 @@ void CvWindow::icvSaveTrackbars(QSettings* settings)
}
}
//////////////////////////////////////////////////////
// OCVViewPort
OCVViewPort
::
OCVViewPort
()
{
mouseCallback
=
0
;
mouseData
=
0
;
}
void
OCVViewPort
::
setMouseCallBack
(
CvMouseCallback
callback
,
void
*
param
)
{
mouseCallback
=
callback
;
mouseData
=
param
;
}
void
OCVViewPort
::
icvmouseEvent
(
QMouseEvent
*
evnt
,
type_mouse_event
category
)
{
int
cv_event
=
-
1
,
flags
=
0
;
icvmouseHandler
(
evnt
,
category
,
cv_event
,
flags
);
icvmouseProcessing
(
QPointF
(
evnt
->
pos
()),
cv_event
,
flags
);
}
void
OCVViewPort
::
icvmouseHandler
(
QMouseEvent
*
evnt
,
type_mouse_event
category
,
int
&
cv_event
,
int
&
flags
)
{
Qt
::
KeyboardModifiers
modifiers
=
evnt
->
modifiers
();
Qt
::
MouseButtons
buttons
=
evnt
->
buttons
();
// This line gives excess flags flushing, with it you cannot predefine flags value.
// icvmouseHandler called with flags == 0 where it really need.
//flags = 0;
if
(
modifiers
&
Qt
::
ShiftModifier
)
flags
|=
CV_EVENT_FLAG_SHIFTKEY
;
if
(
modifiers
&
Qt
::
ControlModifier
)
flags
|=
CV_EVENT_FLAG_CTRLKEY
;
if
(
modifiers
&
Qt
::
AltModifier
)
flags
|=
CV_EVENT_FLAG_ALTKEY
;
if
(
buttons
&
Qt
::
LeftButton
)
flags
|=
CV_EVENT_FLAG_LBUTTON
;
if
(
buttons
&
Qt
::
RightButton
)
flags
|=
CV_EVENT_FLAG_RBUTTON
;
if
(
buttons
&
Qt
::
MidButton
)
flags
|=
CV_EVENT_FLAG_MBUTTON
;
if
(
cv_event
==
-
1
)
{
if
(
category
==
mouse_wheel
)
{
QWheelEvent
*
we
=
(
QWheelEvent
*
)
evnt
;
cv_event
=
((
we
->
orientation
()
==
Qt
::
Vertical
)
?
CV_EVENT_MOUSEWHEEL
:
CV_EVENT_MOUSEHWHEEL
);
flags
|=
(
we
->
delta
()
&
0xffff
)
<<
16
;
return
;
}
switch
(
evnt
->
button
())
{
case
Qt
::
LeftButton
:
cv_event
=
tableMouseButtons
[
category
][
0
];
flags
|=
CV_EVENT_FLAG_LBUTTON
;
break
;
case
Qt
::
RightButton
:
cv_event
=
tableMouseButtons
[
category
][
1
];
flags
|=
CV_EVENT_FLAG_RBUTTON
;
break
;
case
Qt
::
MidButton
:
cv_event
=
tableMouseButtons
[
category
][
2
];
flags
|=
CV_EVENT_FLAG_MBUTTON
;
break
;
default:
cv_event
=
CV_EVENT_MOUSEMOVE
;
}
}
}
void
OCVViewPort
::
icvmouseProcessing
(
QPointF
pt
,
int
cv_event
,
int
flags
)
{
if
(
mouseCallback
)
mouseCallback
(
cv_event
,
pt
.
x
(),
pt
.
y
(),
flags
,
mouseData
);
}
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
// DefaultViewPort
// DefaultViewPort
DefaultViewPort
::
DefaultViewPort
(
CvWindow
*
arg
,
int
arg2
)
:
QGraphicsView
(
arg
),
image2Draw_mat
(
0
)
DefaultViewPort
::
DefaultViewPort
(
CvWindow
*
arg
,
int
arg2
)
:
QGraphicsView
(
arg
),
OCVViewPort
(),
image2Draw_mat
(
0
)
{
{
centralWidget
=
arg
;
centralWidget
=
arg
;
param_keepRatio
=
arg2
;
param_keepRatio
=
arg2
;
...
@@ -2320,12 +2399,10 @@ DefaultViewPort::DefaultViewPort(CvWindow* arg, int arg2) : QGraphicsView(arg),
...
@@ -2320,12 +2399,10 @@ DefaultViewPort::DefaultViewPort(CvWindow* arg, int arg2) : QGraphicsView(arg),
connect
(
timerDisplay
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
stopDisplayInfo
()));
connect
(
timerDisplay
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
stopDisplayInfo
()));
drawInfo
=
false
;
drawInfo
=
false
;
mouseCoordinate
=
QPoint
(
-
1
,
-
1
);
positionGrabbing
=
QPointF
(
0
,
0
);
positionGrabbing
=
QPointF
(
0
,
0
);
positionCorners
=
QRect
(
0
,
0
,
size
().
width
(),
size
().
height
());
positionCorners
=
QRect
(
0
,
0
,
size
().
width
(),
size
().
height
());
on_mouse
=
0
;
on_mouse_param
=
0
;
mouseCoordinate
=
QPoint
(
-
1
,
-
1
);
//no border
//no border
setStyleSheet
(
"QGraphicsView { border-style: none; }"
);
setStyleSheet
(
"QGraphicsView { border-style: none; }"
);
...
@@ -2353,13 +2430,6 @@ QWidget* DefaultViewPort::getWidget()
...
@@ -2353,13 +2430,6 @@ QWidget* DefaultViewPort::getWidget()
}
}
void
DefaultViewPort
::
setMouseCallBack
(
CvMouseCallback
m
,
void
*
param
)
{
on_mouse
=
m
;
on_mouse_param
=
param
;
}
void
DefaultViewPort
::
writeSettings
(
QSettings
&
settings
)
void
DefaultViewPort
::
writeSettings
(
QSettings
&
settings
)
{
{
settings
.
setValue
(
"matrix_view.m11"
,
param_matrixWorld
.
m11
());
settings
.
setValue
(
"matrix_view.m11"
,
param_matrixWorld
.
m11
());
...
@@ -2634,13 +2704,10 @@ void DefaultViewPort::resizeEvent(QResizeEvent* evnt)
...
@@ -2634,13 +2704,10 @@ void DefaultViewPort::resizeEvent(QResizeEvent* evnt)
void
DefaultViewPort
::
wheelEvent
(
QWheelEvent
*
evnt
)
void
DefaultViewPort
::
wheelEvent
(
QWheelEvent
*
evnt
)
{
{
int
delta
=
evnt
->
delta
();
icvmouseEvent
((
QMouseEvent
*
)
evnt
,
mouse_wheel
);
int
cv_event
=
((
evnt
->
orientation
()
==
Qt
::
Vertical
)
?
CV_EVENT_MOUSEWHEEL
:
CV_EVENT_MOUSEHWHEEL
);
int
flags
=
(
delta
&
0xffff
)
<<
16
;
QPoint
pt
=
evnt
->
pos
();
icvmouseHandler
((
QMouseEvent
*
)
evnt
,
mouse_wheel
,
cv_event
,
flags
);
scaleView
(
evnt
->
delta
()
/
240.0
,
evnt
->
pos
()
);
icvmouseProcessing
(
QPointF
(
pt
),
cv_event
,
flags
);
viewport
()
->
update
(
);
QWidget
::
wheelEvent
(
evnt
);
QWidget
::
wheelEvent
(
evnt
);
}
}
...
@@ -2648,12 +2715,7 @@ void DefaultViewPort::wheelEvent(QWheelEvent* evnt)
...
@@ -2648,12 +2715,7 @@ void DefaultViewPort::wheelEvent(QWheelEvent* evnt)
void
DefaultViewPort
::
mousePressEvent
(
QMouseEvent
*
evnt
)
void
DefaultViewPort
::
mousePressEvent
(
QMouseEvent
*
evnt
)
{
{
int
cv_event
=
-
1
,
flags
=
0
;
icvmouseEvent
(
evnt
,
mouse_down
);
QPoint
pt
=
evnt
->
pos
();
//icvmouseHandler: pass parameters for cv_event, flags
icvmouseHandler
(
evnt
,
mouse_down
,
cv_event
,
flags
);
icvmouseProcessing
(
QPointF
(
pt
),
cv_event
,
flags
);
if
(
param_matrixWorld
.
m11
()
>
1
)
if
(
param_matrixWorld
.
m11
()
>
1
)
{
{
...
@@ -2667,12 +2729,7 @@ void DefaultViewPort::mousePressEvent(QMouseEvent* evnt)
...
@@ -2667,12 +2729,7 @@ void DefaultViewPort::mousePressEvent(QMouseEvent* evnt)
void
DefaultViewPort
::
mouseReleaseEvent
(
QMouseEvent
*
evnt
)
void
DefaultViewPort
::
mouseReleaseEvent
(
QMouseEvent
*
evnt
)
{
{
int
cv_event
=
-
1
,
flags
=
0
;
icvmouseEvent
(
evnt
,
mouse_up
);
QPoint
pt
=
evnt
->
pos
();
//icvmouseHandler: pass parameters for cv_event, flags
icvmouseHandler
(
evnt
,
mouse_up
,
cv_event
,
flags
);
icvmouseProcessing
(
QPointF
(
pt
),
cv_event
,
flags
);
if
(
param_matrixWorld
.
m11
()
>
1
)
if
(
param_matrixWorld
.
m11
()
>
1
)
setCursor
(
Qt
::
OpenHandCursor
);
setCursor
(
Qt
::
OpenHandCursor
);
...
@@ -2683,30 +2740,20 @@ void DefaultViewPort::mouseReleaseEvent(QMouseEvent* evnt)
...
@@ -2683,30 +2740,20 @@ void DefaultViewPort::mouseReleaseEvent(QMouseEvent* evnt)
void
DefaultViewPort
::
mouseDoubleClickEvent
(
QMouseEvent
*
evnt
)
void
DefaultViewPort
::
mouseDoubleClickEvent
(
QMouseEvent
*
evnt
)
{
{
int
cv_event
=
-
1
,
flags
=
0
;
icvmouseEvent
(
evnt
,
mouse_dbclick
);
QPoint
pt
=
evnt
->
pos
();
//icvmouseHandler: pass parameters for cv_event, flags
icvmouseHandler
(
evnt
,
mouse_dbclick
,
cv_event
,
flags
);
icvmouseProcessing
(
QPointF
(
pt
),
cv_event
,
flags
);
QWidget
::
mouseDoubleClickEvent
(
evnt
);
QWidget
::
mouseDoubleClickEvent
(
evnt
);
}
}
void
DefaultViewPort
::
mouseMoveEvent
(
QMouseEvent
*
evnt
)
void
DefaultViewPort
::
mouseMoveEvent
(
QMouseEvent
*
evnt
)
{
{
int
cv_event
=
CV_EVENT_MOUSEMOVE
,
flags
=
0
;
icvmouseEvent
(
evnt
,
mouse_move
);
QPoint
pt
=
evnt
->
pos
();
//icvmouseHandler: pass parameters for cv_event, flags
icvmouseHandler
(
evnt
,
mouse_move
,
cv_event
,
flags
);
icvmouseProcessing
(
QPointF
(
pt
),
cv_event
,
flags
);
if
(
param_matrixWorld
.
m11
()
>
1
&&
evnt
->
buttons
()
==
Qt
::
LeftButton
)
if
(
param_matrixWorld
.
m11
()
>
1
&&
evnt
->
buttons
()
==
Qt
::
LeftButton
)
{
{
QPoint
pt
=
evnt
->
pos
();
QPointF
dxy
=
(
pt
-
positionGrabbing
)
/
param_matrixWorld
.
m11
();
QPointF
dxy
=
(
pt
-
positionGrabbing
)
/
param_matrixWorld
.
m11
();
positionGrabbing
=
evnt
->
pos
()
;
positionGrabbing
=
pt
;
moveView
(
dxy
);
moveView
(
dxy
);
}
}
...
@@ -2853,48 +2900,6 @@ void DefaultViewPort::scaleView(qreal factor,QPointF center)
...
@@ -2853,48 +2900,6 @@ void DefaultViewPort::scaleView(qreal factor,QPointF center)
}
}
//up, down, dclick, move
void
DefaultViewPort
::
icvmouseHandler
(
QMouseEvent
*
evnt
,
type_mouse_event
category
,
int
&
cv_event
,
int
&
flags
)
{
Qt
::
KeyboardModifiers
modifiers
=
evnt
->
modifiers
();
Qt
::
MouseButtons
buttons
=
evnt
->
buttons
();
// This line gives excess flags flushing, with it you cannot predefine flags value.
// icvmouseHandler called with flags == 0 where it really need.
//flags = 0;
if
(
modifiers
&
Qt
::
ShiftModifier
)
flags
|=
CV_EVENT_FLAG_SHIFTKEY
;
if
(
modifiers
&
Qt
::
ControlModifier
)
flags
|=
CV_EVENT_FLAG_CTRLKEY
;
if
(
modifiers
&
Qt
::
AltModifier
)
flags
|=
CV_EVENT_FLAG_ALTKEY
;
if
(
buttons
&
Qt
::
LeftButton
)
flags
|=
CV_EVENT_FLAG_LBUTTON
;
if
(
buttons
&
Qt
::
RightButton
)
flags
|=
CV_EVENT_FLAG_RBUTTON
;
if
(
buttons
&
Qt
::
MidButton
)
flags
|=
CV_EVENT_FLAG_MBUTTON
;
if
(
cv_event
==
-
1
)
switch
(
evnt
->
button
())
{
case
Qt
::
LeftButton
:
cv_event
=
tableMouseButtons
[
category
][
0
];
flags
|=
CV_EVENT_FLAG_LBUTTON
;
break
;
case
Qt
::
RightButton
:
cv_event
=
tableMouseButtons
[
category
][
1
];
flags
|=
CV_EVENT_FLAG_RBUTTON
;
break
;
case
Qt
::
MidButton
:
cv_event
=
tableMouseButtons
[
category
][
2
];
flags
|=
CV_EVENT_FLAG_MBUTTON
;
break
;
default:
cv_event
=
CV_EVENT_MOUSEMOVE
;
}
}
void
DefaultViewPort
::
icvmouseProcessing
(
QPointF
pt
,
int
cv_event
,
int
flags
)
void
DefaultViewPort
::
icvmouseProcessing
(
QPointF
pt
,
int
cv_event
,
int
flags
)
...
@@ -2906,9 +2911,7 @@ void DefaultViewPort::icvmouseProcessing(QPointF pt, int cv_event, int flags)
...
@@ -2906,9 +2911,7 @@ void DefaultViewPort::icvmouseProcessing(QPointF pt, int cv_event, int flags)
mouseCoordinate
.
rx
()
=
floor
(
pfx
/
ratioX
);
mouseCoordinate
.
rx
()
=
floor
(
pfx
/
ratioX
);
mouseCoordinate
.
ry
()
=
floor
(
pfy
/
ratioY
);
mouseCoordinate
.
ry
()
=
floor
(
pfy
/
ratioY
);
if
(
on_mouse
)
OCVViewPort
::
icvmouseProcessing
(
QPointF
(
mouseCoordinate
),
cv_event
,
flags
);
on_mouse
(
cv_event
,
mouseCoordinate
.
x
(),
mouseCoordinate
.
y
(),
flags
,
on_mouse_param
);
}
}
...
@@ -3113,11 +3116,8 @@ void DefaultViewPort::setSize(QSize /*size_*/)
...
@@ -3113,11 +3116,8 @@ void DefaultViewPort::setSize(QSize /*size_*/)
#ifdef HAVE_QT_OPENGL
#ifdef HAVE_QT_OPENGL
OpenGlViewPort
::
OpenGlViewPort
(
QWidget
*
_parent
)
:
QGLWidget
(
_parent
),
size
(
-
1
,
-
1
)
OpenGlViewPort
::
OpenGlViewPort
(
QWidget
*
_parent
)
:
QGLWidget
(
_parent
),
OCVViewPort
(),
size
(
-
1
,
-
1
)
{
{
mouseCallback
=
0
;
mouseData
=
0
;
glDrawCallback
=
0
;
glDrawCallback
=
0
;
glDrawData
=
0
;
glDrawData
=
0
;
}
}
...
@@ -3131,11 +3131,6 @@ QWidget* OpenGlViewPort::getWidget()
...
@@ -3131,11 +3131,6 @@ QWidget* OpenGlViewPort::getWidget()
return
this
;
return
this
;
}
}
void
OpenGlViewPort
::
setMouseCallBack
(
CvMouseCallback
callback
,
void
*
param
)
{
mouseCallback
=
callback
;
mouseData
=
param
;
}
void
OpenGlViewPort
::
writeSettings
(
QSettings
&
/*settings*/
)
void
OpenGlViewPort
::
writeSettings
(
QSettings
&
/*settings*/
)
{
{
...
@@ -3196,116 +3191,37 @@ void OpenGlViewPort::paintGL()
...
@@ -3196,116 +3191,37 @@ void OpenGlViewPort::paintGL()
glDrawCallback
(
glDrawData
);
glDrawCallback
(
glDrawData
);
}
}
void
OpenGlViewPort
::
wheelEvent
(
QWheelEvent
*
evnt
)
void
OpenGlViewPort
::
wheelEvent
(
QWheelEvent
*
evnt
)
{
{
int
delta
=
evnt
->
delta
();
icvmouseEvent
((
QMouseEvent
*
)
evnt
,
mouse_wheel
);
int
cv_event
=
((
evnt
->
orientation
()
==
Qt
::
Vertical
)
?
CV_EVENT_MOUSEWHEEL
:
CV_EVENT_MOUSEHWHEEL
);
QGLWidget
::
wheelEvent
(
evnt
);
int
flags
=
(
delta
&
0xffff
)
<<
16
;
QPoint
pt
=
evnt
->
pos
();
icvmouseHandler
((
QMouseEvent
*
)
evnt
,
mouse_wheel
,
cv_event
,
flags
);
icvmouseProcessing
(
QPointF
(
pt
),
cv_event
,
flags
);
QWidget
::
wheelEvent
(
evnt
);
}
}
void
OpenGlViewPort
::
mousePressEvent
(
QMouseEvent
*
evnt
)
void
OpenGlViewPort
::
mousePressEvent
(
QMouseEvent
*
evnt
)
{
{
int
cv_event
=
-
1
,
flags
=
0
;
icvmouseEvent
(
evnt
,
mouse_down
);
QPoint
pt
=
evnt
->
pos
();
icvmouseHandler
(
evnt
,
mouse_down
,
cv_event
,
flags
);
icvmouseProcessing
(
QPointF
(
pt
),
cv_event
,
flags
);
QGLWidget
::
mousePressEvent
(
evnt
);
QGLWidget
::
mousePressEvent
(
evnt
);
}
}
void
OpenGlViewPort
::
mouseReleaseEvent
(
QMouseEvent
*
evnt
)
void
OpenGlViewPort
::
mouseReleaseEvent
(
QMouseEvent
*
evnt
)
{
{
int
cv_event
=
-
1
,
flags
=
0
;
icvmouseEvent
(
evnt
,
mouse_up
);
QPoint
pt
=
evnt
->
pos
();
icvmouseHandler
(
evnt
,
mouse_up
,
cv_event
,
flags
);
icvmouseProcessing
(
QPointF
(
pt
),
cv_event
,
flags
);
QGLWidget
::
mouseReleaseEvent
(
evnt
);
QGLWidget
::
mouseReleaseEvent
(
evnt
);
}
}
void
OpenGlViewPort
::
mouseDoubleClickEvent
(
QMouseEvent
*
evnt
)
void
OpenGlViewPort
::
mouseDoubleClickEvent
(
QMouseEvent
*
evnt
)
{
{
int
cv_event
=
-
1
,
flags
=
0
;
icvmouseEvent
(
evnt
,
mouse_dbclick
);
QPoint
pt
=
evnt
->
pos
();
icvmouseHandler
(
evnt
,
mouse_dbclick
,
cv_event
,
flags
);
icvmouseProcessing
(
QPointF
(
pt
),
cv_event
,
flags
);
QGLWidget
::
mouseDoubleClickEvent
(
evnt
);
QGLWidget
::
mouseDoubleClickEvent
(
evnt
);
}
}
void
OpenGlViewPort
::
mouseMoveEvent
(
QMouseEvent
*
evnt
)
void
OpenGlViewPort
::
mouseMoveEvent
(
QMouseEvent
*
evnt
)
{
{
int
cv_event
=
CV_EVENT_MOUSEMOVE
,
flags
=
0
;
icvmouseEvent
(
evnt
,
mouse_move
);
QPoint
pt
=
evnt
->
pos
();
//icvmouseHandler: pass parameters for cv_event, flags
icvmouseHandler
(
evnt
,
mouse_move
,
cv_event
,
flags
);
icvmouseProcessing
(
QPointF
(
pt
),
cv_event
,
flags
);
QGLWidget
::
mouseMoveEvent
(
evnt
);
QGLWidget
::
mouseMoveEvent
(
evnt
);
}
}
void
OpenGlViewPort
::
icvmouseHandler
(
QMouseEvent
*
evnt
,
type_mouse_event
category
,
int
&
cv_event
,
int
&
flags
)
{
Qt
::
KeyboardModifiers
modifiers
=
evnt
->
modifiers
();
Qt
::
MouseButtons
buttons
=
evnt
->
buttons
();
// This line gives excess flags flushing, with it you cannot predefine flags value.
// icvmouseHandler called with flags == 0 where it really need.
//flags = 0;
if
(
modifiers
&
Qt
::
ShiftModifier
)
flags
|=
CV_EVENT_FLAG_SHIFTKEY
;
if
(
modifiers
&
Qt
::
ControlModifier
)
flags
|=
CV_EVENT_FLAG_CTRLKEY
;
if
(
modifiers
&
Qt
::
AltModifier
)
flags
|=
CV_EVENT_FLAG_ALTKEY
;
if
(
buttons
&
Qt
::
LeftButton
)
flags
|=
CV_EVENT_FLAG_LBUTTON
;
if
(
buttons
&
Qt
::
RightButton
)
flags
|=
CV_EVENT_FLAG_RBUTTON
;
if
(
buttons
&
Qt
::
MidButton
)
flags
|=
CV_EVENT_FLAG_MBUTTON
;
if
(
cv_event
==
-
1
)
switch
(
evnt
->
button
())
{
case
Qt
::
LeftButton
:
cv_event
=
tableMouseButtons
[
category
][
0
];
flags
|=
CV_EVENT_FLAG_LBUTTON
;
break
;
case
Qt
::
RightButton
:
cv_event
=
tableMouseButtons
[
category
][
1
];
flags
|=
CV_EVENT_FLAG_RBUTTON
;
break
;
case
Qt
::
MidButton
:
cv_event
=
tableMouseButtons
[
category
][
2
];
flags
|=
CV_EVENT_FLAG_MBUTTON
;
break
;
default:
cv_event
=
CV_EVENT_MOUSEMOVE
;
}
}
void
OpenGlViewPort
::
icvmouseProcessing
(
QPointF
pt
,
int
cv_event
,
int
flags
)
{
if
(
mouseCallback
)
mouseCallback
(
cv_event
,
pt
.
x
(),
pt
.
y
(),
flags
,
mouseData
);
}
QSize
OpenGlViewPort
::
sizeHint
()
const
QSize
OpenGlViewPort
::
sizeHint
()
const
{
{
...
...
modules/highgui/src/window_QT.h
浏览文件 @
fd1da009
...
@@ -403,10 +403,26 @@ public:
...
@@ -403,10 +403,26 @@ public:
};
};
class
OCVViewPort
:
public
ViewPort
{
public:
explicit
OCVViewPort
();
~
OCVViewPort
()
{};
void
setMouseCallBack
(
CvMouseCallback
callback
,
void
*
param
);
protected:
void
icvmouseEvent
(
QMouseEvent
*
event
,
type_mouse_event
category
);
void
icvmouseHandler
(
QMouseEvent
*
event
,
type_mouse_event
category
,
int
&
cv_event
,
int
&
flags
);
void
icvmouseProcessing
(
QPointF
pt
,
int
cv_event
,
int
flags
);
CvMouseCallback
mouseCallback
;
void
*
mouseData
;
};
#ifdef HAVE_QT_OPENGL
#ifdef HAVE_QT_OPENGL
class
OpenGlViewPort
:
public
QGLWidget
,
public
ViewPort
class
OpenGlViewPort
:
public
QGLWidget
,
public
OCV
ViewPort
{
{
public:
public:
explicit
OpenGlViewPort
(
QWidget
*
parent
);
explicit
OpenGlViewPort
(
QWidget
*
parent
);
...
@@ -414,8 +430,6 @@ public:
...
@@ -414,8 +430,6 @@ public:
QWidget
*
getWidget
();
QWidget
*
getWidget
();
void
setMouseCallBack
(
CvMouseCallback
callback
,
void
*
param
);
void
writeSettings
(
QSettings
&
settings
);
void
writeSettings
(
QSettings
&
settings
);
void
readSettings
(
QSettings
&
settings
);
void
readSettings
(
QSettings
&
settings
);
...
@@ -448,20 +462,14 @@ protected:
...
@@ -448,20 +462,14 @@ protected:
private:
private:
QSize
size
;
QSize
size
;
CvMouseCallback
mouseCallback
;
void
*
mouseData
;
CvOpenGlDrawCallback
glDrawCallback
;
CvOpenGlDrawCallback
glDrawCallback
;
void
*
glDrawData
;
void
*
glDrawData
;
void
icvmouseHandler
(
QMouseEvent
*
event
,
type_mouse_event
category
,
int
&
cv_event
,
int
&
flags
);
void
icvmouseProcessing
(
QPointF
pt
,
int
cv_event
,
int
flags
);
};
};
#endif // HAVE_QT_OPENGL
#endif // HAVE_QT_OPENGL
class
DefaultViewPort
:
public
QGraphicsView
,
public
ViewPort
class
DefaultViewPort
:
public
QGraphicsView
,
public
OCV
ViewPort
{
{
Q_OBJECT
Q_OBJECT
...
@@ -471,8 +479,6 @@ public:
...
@@ -471,8 +479,6 @@ public:
QWidget
*
getWidget
();
QWidget
*
getWidget
();
void
setMouseCallBack
(
CvMouseCallback
callback
,
void
*
param
);
void
writeSettings
(
QSettings
&
settings
);
void
writeSettings
(
QSettings
&
settings
);
void
readSettings
(
QSettings
&
settings
);
void
readSettings
(
QSettings
&
settings
);
...
@@ -510,6 +516,7 @@ protected:
...
@@ -510,6 +516,7 @@ protected:
void
contextMenuEvent
(
QContextMenuEvent
*
event
);
void
contextMenuEvent
(
QContextMenuEvent
*
event
);
void
resizeEvent
(
QResizeEvent
*
event
);
void
resizeEvent
(
QResizeEvent
*
event
);
void
paintEvent
(
QPaintEvent
*
paintEventInfo
);
void
paintEvent
(
QPaintEvent
*
paintEventInfo
);
void
wheelEvent
(
QWheelEvent
*
event
);
void
wheelEvent
(
QWheelEvent
*
event
);
void
mouseMoveEvent
(
QMouseEvent
*
event
);
void
mouseMoveEvent
(
QMouseEvent
*
event
);
void
mousePressEvent
(
QMouseEvent
*
event
);
void
mousePressEvent
(
QMouseEvent
*
event
);
...
@@ -526,17 +533,13 @@ private:
...
@@ -526,17 +533,13 @@ private:
QImage
image2Draw_qt
;
QImage
image2Draw_qt
;
int
nbChannelOriginImage
;
int
nbChannelOriginImage
;
//for mouse callback
CvMouseCallback
on_mouse
;
void
*
on_mouse_param
;
void
scaleView
(
qreal
scaleFactor
,
QPointF
center
);
void
scaleView
(
qreal
scaleFactor
,
QPointF
center
);
void
moveView
(
QPointF
delta
);
void
moveView
(
QPointF
delta
);
QPoint
mouseCoordinate
;
QPoint
mouseCoordinate
;
QPointF
positionGrabbing
;
QPointF
positionGrabbing
;
QRect
positionCorners
;
QRect
positionCorners
;
QTransform
matrixWorld_inv
;
QTransform
matrixWorld_inv
;
float
ratioX
,
ratioY
;
float
ratioX
,
ratioY
;
...
@@ -555,7 +558,7 @@ private:
...
@@ -555,7 +558,7 @@ private:
void
draw2D
(
QPainter
*
painter
);
void
draw2D
(
QPainter
*
painter
);
void
drawStatusBar
();
void
drawStatusBar
();
void
controlImagePosition
();
void
controlImagePosition
();
void
icvmouseHandler
(
QMouseEvent
*
event
,
type_mouse_event
category
,
int
&
cv_event
,
int
&
flags
);
void
icvmouseProcessing
(
QPointF
pt
,
int
cv_event
,
int
flags
);
void
icvmouseProcessing
(
QPointF
pt
,
int
cv_event
,
int
flags
);
private
slots
:
private
slots
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录