Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
d46f44b4
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,发现更多精彩内容 >>
提交
d46f44b4
编写于
3月 28, 2012
作者:
A
Andrey Kamaev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#1695 fixed arrow key events with the Qt backend
上级
dd01861d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
94 addition
and
96 deletion
+94
-96
modules/highgui/src/window_QT.cpp
modules/highgui/src/window_QT.cpp
+94
-96
未找到文件。
modules/highgui/src/window_QT.cpp
浏览文件 @
d46f44b4
...
@@ -256,77 +256,77 @@ CV_IMPL void cvDisplayStatusBar(const char* name, const char* text, int delayms)
...
@@ -256,77 +256,77 @@ CV_IMPL void cvDisplayStatusBar(const char* name, const char* text, int delayms)
CV_IMPL
int
cvWaitKey
(
int
delay
)
CV_IMPL
int
cvWaitKey
(
int
delay
)
{
{
int
result
=
-
1
;
int
result
=
-
1
;
if
(
!
guiMainThread
)
if
(
!
guiMainThread
)
return
result
;
return
result
;
unsigned
long
delayms
=
delay
<=
0
?
ULONG_MAX
:
delay
;
//in milliseconds
unsigned
long
delayms
=
delay
<=
0
?
ULONG_MAX
:
delay
;
//in milliseconds
if
(
multiThreads
)
if
(
multiThreads
)
{
{
mutexKey
.
lock
();
mutexKey
.
lock
();
if
(
key_pressed
.
wait
(
&
mutexKey
,
delayms
))
//false if timeout
if
(
key_pressed
.
wait
(
&
mutexKey
,
delayms
))
//false if timeout
{
{
result
=
last_key
;
result
=
last_key
;
}
}
last_key
=
-
1
;
last_key
=
-
1
;
mutexKey
.
unlock
();
mutexKey
.
unlock
();
}
}
else
else
{
{
//cannot use wait here because events will not be distributed before processEvents (the main eventLoop is broken)
//cannot use wait here because events will not be distributed before processEvents (the main eventLoop is broken)
//so I create a Thread for the QTimer
//so I create a Thread for the QTimer
if
(
delay
>
0
)
if
(
delay
>
0
)
guiMainThread
->
timer
->
start
(
delay
);
guiMainThread
->
timer
->
start
(
delay
);
//QMutex dummy;
//QMutex dummy;
while
(
!
guiMainThread
->
bTimeOut
)
while
(
!
guiMainThread
->
bTimeOut
)
{
{
qApp
->
processEvents
(
QEventLoop
::
AllEvents
);
qApp
->
processEvents
(
QEventLoop
::
AllEvents
);
if
(
!
guiMainThread
)
//when all the windows are deleted
if
(
!
guiMainThread
)
//when all the windows are deleted
return
result
;
return
result
;
mutexKey
.
lock
();
mutexKey
.
lock
();
if
(
last_key
!=
-
1
)
if
(
last_key
!=
-
1
)
{
{
result
=
last_key
;
result
=
last_key
;
last_key
=
-
1
;
last_key
=
-
1
;
guiMainThread
->
timer
->
stop
();
guiMainThread
->
timer
->
stop
();
//printf("keypressed\n");
//printf("keypressed\n");
}
}
mutexKey
.
unlock
();
mutexKey
.
unlock
();
if
(
result
!=-
1
)
if
(
result
!=-
1
)
{
{
break
;
break
;
}
}
else
else
{
{
/*
/*
* //will not work, I broke the event loop !!!!
* //will not work, I broke the event loop !!!!
dummy.lock();
dummy.lock();
QWaitCondition waitCondition;
QWaitCondition waitCondition;
waitCondition.wait(&dummy, 2);
waitCondition.wait(&dummy, 2);
*/
*/
//to decrease CPU usage
//to decrease CPU usage
//sleep 1 millisecond
//sleep 1 millisecond
#if defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64
#if defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64
Sleep
(
1
);
Sleep
(
1
);
#else
#else
usleep
(
1000
);
usleep
(
1000
);
#endif
#endif
}
}
}
}
guiMainThread
->
bTimeOut
=
false
;
guiMainThread
->
bTimeOut
=
false
;
}
}
return
result
;
return
result
;
}
}
...
@@ -1553,7 +1553,9 @@ CvWindow::CvWindow(QString name, int arg2)
...
@@ -1553,7 +1553,9 @@ CvWindow::CvWindow(QString name, int arg2)
//setAttribute(Qt::WA_DeleteOnClose); //in other case, does not release memory
//setAttribute(Qt::WA_DeleteOnClose); //in other case, does not release memory
setContentsMargins
(
0
,
0
,
0
,
0
);
setContentsMargins
(
0
,
0
,
0
,
0
);
setWindowTitle
(
name
);
setWindowTitle
(
name
);
setObjectName
(
name
);
setObjectName
(
name
);
setFocus
(
Qt
::
PopupFocusReason
);
//#1695 arrow keys are not recieved without the explicit focus
resize
(
400
,
300
);
resize
(
400
,
300
);
setMinimumSize
(
1
,
1
);
setMinimumSize
(
1
,
1
);
...
@@ -2060,22 +2062,18 @@ void CvWindow::keyPressEvent(QKeyEvent *event)
...
@@ -2060,22 +2062,18 @@ void CvWindow::keyPressEvent(QKeyEvent *event)
//see http://doc.trolltech.com/4.6/qt.html#Key-enum
//see http://doc.trolltech.com/4.6/qt.html#Key-enum
int
key
=
event
->
key
();
int
key
=
event
->
key
();
//bool goodKey = false;
Qt
::
Key
qtkey
=
static_cast
<
Qt
::
Key
>
(
key
);
bool
goodKey
=
true
;
char
asciiCode
=
QTest
::
keyToAscii
(
qtkey
);
if
(
asciiCode
!=
0
)
Qt
::
Key
qtkey
=
static_cast
<
Qt
::
Key
>
(
key
);
key
=
static_cast
<
int
>
(
asciiCode
);
char
asciiCode
=
QTest
::
keyToAscii
(
qtkey
);
else
if
(
asciiCode
!=
0
)
key
=
event
->
nativeVirtualKey
();
//same codes as returned by GTK-based backend
{
key
=
static_cast
<
int
>
(
asciiCode
);
}
//control plus (Z, +, -, up, down, left, right) are used for zoom/panning functions
//control plus (Z, +, -, up, down, left, right) are used for zoom/panning functions
if
(
event
->
modifiers
()
!=
Qt
::
ControlModifier
&&
goodKey
)
if
(
event
->
modifiers
()
!=
Qt
::
ControlModifier
)
{
{
mutexKey
.
lock
();
mutexKey
.
lock
();
last_key
=
key
;
last_key
=
key
;
//last_key = event->nativeVirtualKey ();
mutexKey
.
unlock
();
mutexKey
.
unlock
();
key_pressed
.
wakeAll
();
key_pressed
.
wakeAll
();
//event->accept();
//event->accept();
...
@@ -2813,41 +2811,41 @@ void DefaultViewPort::scaleView(qreal factor,QPointF center)
...
@@ -2813,41 +2811,41 @@ void DefaultViewPort::scaleView(qreal factor,QPointF center)
//up, down, dclick, move
//up, down, dclick, move
void
DefaultViewPort
::
icvmouseHandler
(
QMouseEvent
*
event
,
type_mouse_event
category
,
int
&
cv_event
,
int
&
flags
)
void
DefaultViewPort
::
icvmouseHandler
(
QMouseEvent
*
event
,
type_mouse_event
category
,
int
&
cv_event
,
int
&
flags
)
{
{
Qt
::
KeyboardModifiers
modifiers
=
event
->
modifiers
();
Qt
::
KeyboardModifiers
modifiers
=
event
->
modifiers
();
Qt
::
MouseButtons
buttons
=
event
->
buttons
();
Qt
::
MouseButtons
buttons
=
event
->
buttons
();
flags
=
0
;
flags
=
0
;
if
(
modifiers
&
Qt
::
ShiftModifier
)
if
(
modifiers
&
Qt
::
ShiftModifier
)
flags
|=
CV_EVENT_FLAG_SHIFTKEY
;
flags
|=
CV_EVENT_FLAG_SHIFTKEY
;
if
(
modifiers
&
Qt
::
ControlModifier
)
if
(
modifiers
&
Qt
::
ControlModifier
)
flags
|=
CV_EVENT_FLAG_CTRLKEY
;
flags
|=
CV_EVENT_FLAG_CTRLKEY
;
if
(
modifiers
&
Qt
::
AltModifier
)
if
(
modifiers
&
Qt
::
AltModifier
)
flags
|=
CV_EVENT_FLAG_ALTKEY
;
flags
|=
CV_EVENT_FLAG_ALTKEY
;
if
(
buttons
&
Qt
::
LeftButton
)
if
(
buttons
&
Qt
::
LeftButton
)
flags
|=
CV_EVENT_FLAG_LBUTTON
;
flags
|=
CV_EVENT_FLAG_LBUTTON
;
if
(
buttons
&
Qt
::
RightButton
)
if
(
buttons
&
Qt
::
RightButton
)
flags
|=
CV_EVENT_FLAG_RBUTTON
;
flags
|=
CV_EVENT_FLAG_RBUTTON
;
if
(
buttons
&
Qt
::
MidButton
)
if
(
buttons
&
Qt
::
MidButton
)
flags
|=
CV_EVENT_FLAG_MBUTTON
;
flags
|=
CV_EVENT_FLAG_MBUTTON
;
cv_event
=
CV_EVENT_MOUSEMOVE
;
cv_event
=
CV_EVENT_MOUSEMOVE
;
switch
(
event
->
button
())
switch
(
event
->
button
())
{
{
case
Qt
::
LeftButton
:
case
Qt
::
LeftButton
:
cv_event
=
tableMouseButtons
[
category
][
0
];
cv_event
=
tableMouseButtons
[
category
][
0
];
flags
|=
CV_EVENT_FLAG_LBUTTON
;
flags
|=
CV_EVENT_FLAG_LBUTTON
;
break
;
break
;
case
Qt
::
RightButton
:
case
Qt
::
RightButton
:
cv_event
=
tableMouseButtons
[
category
][
1
];
cv_event
=
tableMouseButtons
[
category
][
1
];
flags
|=
CV_EVENT_FLAG_RBUTTON
;
flags
|=
CV_EVENT_FLAG_RBUTTON
;
break
;
break
;
case
Qt
::
MidButton
:
case
Qt
::
MidButton
:
cv_event
=
tableMouseButtons
[
category
][
2
];
cv_event
=
tableMouseButtons
[
category
][
2
];
flags
|=
CV_EVENT_FLAG_MBUTTON
;
flags
|=
CV_EVENT_FLAG_MBUTTON
;
break
;
break
;
default:
;
default:
;
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录