Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
a3582b47
Commit
a3582b47
authored
Aug 18, 2010
by
Yannick Verdie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt Python binding -- #512
parent
0816b49a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
102 additions
and
6 deletions
+102
-6
window_QT.cpp
modules/highgui/src/window_QT.cpp
+95
-5
window_QT.h
modules/highgui/src/window_QT.h
+7
-1
No files found.
modules/highgui/src/window_QT.cpp
View file @
a3582b47
...
...
@@ -547,10 +547,23 @@ CV_IMPL void cvResizeWindow(const char* name, int width, int height )
}
//TODO: implement the real one, not a wrapper
CV_IMPL
int
cvCreateTrackbar2
(
const
char
*
name_bar
,
const
char
*
window_name
,
int
*
val
,
int
count
,
CvTrackbarCallback2
on_notify
,
void
*
userdata
)
{
return
cvCreateTrackbar
(
name_bar
,
window_name
,
val
,
count
,
(
CvTrackbarCallback
)
on_notify
);
if
(
!
guiMainThread
)
CV_Error
(
CV_StsNullPtr
,
"NULL guiReceiver (please create a window)"
);
QMetaObject
::
invokeMethod
(
guiMainThread
,
"addSlider2"
,
Qt
::
AutoConnection
,
Q_ARG
(
QString
,
QString
(
name_bar
)),
Q_ARG
(
QString
,
QString
(
window_name
)),
Q_ARG
(
void
*
,
(
void
*
)
val
),
Q_ARG
(
int
,
count
),
Q_ARG
(
void
*
,
(
void
*
)
on_notify
),
Q_ARG
(
void
*
,
(
void
*
)
userdata
)
);
return
1
;
//dummy value
}
CV_IMPL
int
cvStartWindowThread
()
...
...
@@ -1016,6 +1029,34 @@ void GuiReceiver::addButton(QString button_name, int button_type, int initial_bu
b
->
addButton
(
button_name
,(
CvButtonCallback
)
on_change
,
userdata
,
button_type
,
initial_button_state
);
}
void
GuiReceiver
::
addSlider2
(
QString
bar_name
,
QString
window_name
,
void
*
value
,
int
count
,
void
*
on_change
,
void
*
userdata
)
{
QBoxLayout
*
layout
=
NULL
;
QPointer
<
CvWindow
>
w
;
if
(
window_name
!=
""
)
{
w
=
icvFindWindowByName
(
window_name
.
toLatin1
().
data
()
);
if
(
!
w
)
return
;
}
else
{
if
(
global_control_panel
)
layout
=
global_control_panel
->
myLayout
;
}
QPointer
<
CvTrackbar
>
t
=
icvFindTrackbarByName
(
bar_name
.
toLatin1
().
data
()
,
window_name
.
toLatin1
().
data
(),
layout
);
if
(
t
)
//trackbar exists
return
;
if
(
!
value
)
CV_Error
(
CV_StsNullPtr
,
"NULL value pointer"
);
if
(
count
<=
0
)
//count is the max value of the slider, so must be bigger than 0
CV_Error
(
CV_StsNullPtr
,
"Max value of the slider must be bigger than 0"
);
CvWindow
::
addSlider2
(
w
,
bar_name
,(
int
*
)
value
,
count
,(
CvTrackbarCallback2
)
on_change
,
userdata
);
}
void
GuiReceiver
::
addSlider
(
QString
bar_name
,
QString
window_name
,
void
*
value
,
int
count
,
void
*
on_change
)
{
...
...
@@ -1051,8 +1092,25 @@ int GuiReceiver::start()
return
qApp
->
exec
();
}
CvTrackbar
::
CvTrackbar
(
CvWindow
*
arg
,
QString
name
,
int
*
value
,
int
count
,
CvTrackbarCallback2
on_change
,
void
*
data
)
{
callback
=
NULL
;
callback2
=
on_change
;
userdata
=
data
;
construc_trackbar
(
arg
,
name
,
value
,
count
);
}
CvTrackbar
::
CvTrackbar
(
CvWindow
*
arg
,
QString
name
,
int
*
value
,
int
count
,
CvTrackbarCallback
on_change
)
{
callback
=
on_change
;
callback2
=
NULL
;
userdata
=
NULL
;
construc_trackbar
(
arg
,
name
,
value
,
count
);
}
void
CvTrackbar
::
construc_trackbar
(
CvWindow
*
arg
,
QString
name
,
int
*
value
,
int
count
)
{
type
=
type_CvTrackbar
;
myparent
=
arg
;
...
...
@@ -1060,7 +1118,6 @@ CvTrackbar::CvTrackbar(CvWindow* arg, QString name, int* value, int count, CvTra
setObjectName
(
name_bar
);
dataSlider
=
value
;
callback
=
on_change
;
slider
=
new
QSlider
(
Qt
::
Horizontal
);
slider
->
setFocusPolicy
(
Qt
::
StrongFocus
);
slider
->
setMinimum
(
0
);
...
...
@@ -1135,7 +1192,16 @@ void CvTrackbar::update(int myvalue)
*
dataSlider
=
myvalue
;
if
(
callback
)
{
callback
(
myvalue
);
return
;
}
if
(
callback2
)
{
callback2
(
myvalue
,
userdata
);
return
;
}
}
void
CvTrackbar
::
setLabel
(
int
myvalue
)
...
...
@@ -1422,8 +1488,6 @@ CvWindow::CvWindow(QString arg, int arg2)
CvWindow
::~
CvWindow
()
{
printf
(
"delete w
\n
"
);
QLayoutItem
*
child
;
if
(
myGlobalLayout
)
...
...
@@ -1664,6 +1728,32 @@ void CvWindow::setMouseCallBack(CvMouseCallback m, void* param)
myview
->
setMouseCallBack
(
m
,
param
);
}
//addSlider2 is static
void
CvWindow
::
addSlider2
(
CvWindow
*
w
,
QString
name
,
int
*
value
,
int
count
,
CvTrackbarCallback2
on_change
,
void
*
userdata
)
{
QPointer
<
CvTrackbar
>
t
=
new
CvTrackbar
(
w
,
name
,
value
,
count
,
on_change
,
userdata
);
t
->
setAlignment
(
Qt
::
AlignHCenter
);
QPointer
<
QBoxLayout
>
myLayout
;
if
(
w
)
{
myLayout
=
w
->
myBarLayout
;
}
else
{
myLayout
=
global_control_panel
->
myLayout
;
//if first one, enable control panel
if
(
myLayout
->
count
()
==
0
)
guiMainThread
->
enablePropertiesButtonEachWindow
();
}
myLayout
->
insertLayout
(
myLayout
->
count
(),
t
);
}
//addSlider is static
void
CvWindow
::
addSlider
(
CvWindow
*
w
,
QString
name
,
int
*
value
,
int
count
,
CvTrackbarCallback
on_change
)
{
...
...
modules/highgui/src/window_QT.h
View file @
a3582b47
...
...
@@ -127,6 +127,7 @@ public slots:
void
destroyWindow
(
QString
name
);
void
destroyAllWindow
();
void
addSlider
(
QString
trackbar_name
,
QString
window_name
,
void
*
value
,
int
count
,
void
*
on_change
);
void
addSlider2
(
QString
trackbar_name
,
QString
window_name
,
void
*
value
,
int
count
,
void
*
on_change
,
void
*
userdata
);
void
moveWindow
(
QString
name
,
int
x
,
int
y
);
void
resizeWindow
(
QString
name
,
int
width
,
int
height
);
void
showImage
(
QString
name
,
void
*
arr
);
...
...
@@ -229,7 +230,8 @@ class CvTrackbar : public CvBar
{
Q_OBJECT
public
:
CvTrackbar
(
CvWindow
*
parent
,
QString
name
,
int
*
value
,
int
count
,
CvTrackbarCallback
on_change
=
NULL
);
CvTrackbar
(
CvWindow
*
parent
,
QString
name
,
int
*
value
,
int
count
,
CvTrackbarCallback
on_change
);
CvTrackbar
(
CvWindow
*
parent
,
QString
name
,
int
*
value
,
int
count
,
CvTrackbarCallback2
on_change
,
void
*
data
);
~
CvTrackbar
();
//QString trackbar_name;
...
...
@@ -241,10 +243,13 @@ private slots:
private
:
void
setLabel
(
int
myvalue
);
void
construc_trackbar
(
CvWindow
*
arg
,
QString
name
,
int
*
value
,
int
count
);
QString
createLabel
();
QPointer
<
QPushButton
>
label
;
CvTrackbarCallback
callback
;
CvTrackbarCallback2
callback2
;
//look like it is use by python binding
int
*
dataSlider
;
void
*
userdata
;
};
...
...
@@ -281,6 +286,7 @@ public:
CvWindow
(
QString
arg2
,
int
flag
=
CV_WINDOW_NORMAL
);
~
CvWindow
();
static
void
addSlider
(
CvWindow
*
w
,
QString
name
,
int
*
value
,
int
count
,
CvTrackbarCallback
on_change
CV_DEFAULT
(
NULL
));
static
void
addSlider2
(
CvWindow
*
w
,
QString
name
,
int
*
value
,
int
count
,
CvTrackbarCallback2
on_change
CV_DEFAULT
(
NULL
),
void
*
userdata
CV_DEFAULT
(
0
));
void
setMouseCallBack
(
CvMouseCallback
m
,
void
*
param
);
void
updateImage
(
void
*
arr
);
void
displayInfo
(
QString
text
,
int
delayms
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment