Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
11af7b7e
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,发现更多精彩内容 >>
提交
11af7b7e
编写于
5月 25, 2017
作者:
V
Vadim Pisarevsky
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #8307 from AhiyaHiya:dev_xcode_macos_universal_binary
上级
ec49eb81
5d03262b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
88 addition
and
50 deletion
+88
-50
modules/highgui/src/window_cocoa.mm
modules/highgui/src/window_cocoa.mm
+88
-50
未找到文件。
modules/highgui/src/window_cocoa.mm
浏览文件 @
11af7b7e
...
...
@@ -83,11 +83,23 @@ static NSMutableDictionary *windows = nil;
static
bool
wasInitialized
=
false
;
@interface
CVView
:
NSView
{
NSImage
*
_image
;
}
@property
(
strong
)
NSImage
*
image
;
-
(
void
)
setImageData
:(
CvArr
*
)
arr
;
@end
@interface
CVSlider
:
NSView
{
NSSlider
*
_slider
;
NSTextField
*
_name
;
int
*
_value
;
void
*
_userData
;
CvTrackbarCallback
_callback
;
CvTrackbarCallback2
_callback2
;
}
@property
(
strong
)
NSSlider
*
slider
;
@property
(
strong
)
NSTextField
*
name
;
@property
(
assign
)
int
*
value
;
...
...
@@ -97,6 +109,14 @@ static bool wasInitialized = false;
@end
@interface
CVWindow
:
NSWindow
{
CvMouseCallback
_mouseCallback
;
void
*
_mouseParam
;
BOOL
_autosize
;
BOOL
_firstContent
;
NSMutableDictionary
*
_sliders
;
int
_status
;
}
@property
(
assign
)
CvMouseCallback
mouseCallback
;
@property
(
assign
)
void
*
mouseParam
;
@property
(
assign
)
BOOL
autosize
;
...
...
@@ -681,14 +701,21 @@ void cv::setWindowTitle(const String& winname, const String& title)
}
@implementation
CVWindow
#if defined(__LP64__)
@synthesize
mouseCallback
;
@synthesize
mouseParam
;
@synthesize
autosize
;
@synthesize
firstContent
;
@synthesize
sliders
;
@synthesize
status
;
#else // 32-bit Obj-C does not have automatic synthesize
@synthesize
mouseCallback
=
_mouseCallback
;
@synthesize
mouseParam
=
_mouseParam
;
@synthesize
autosize
=
_autosize
;
@synthesize
firstContent
=
_firstContent
;
@synthesize
sliders
=
_sliders
;
@synthesize
status
=
_status
;
#endif
-
(
void
)
cvSendMouseEvent
:(
NSEvent
*
)
event
type
:(
int
)
type
flags
:(
int
)
flags
{
(
void
)
event
;
//cout << "cvSendMouseEvent" << endl;
...
...
@@ -713,12 +740,13 @@ void cv::setWindowTitle(const String& winname, const String& title)
mp
.
y
=
mp
.
y
*
imageSize
.
height
/
std
::
max
(
viewHeight
,
1.
);
if
(
mp
.
x
>=
0
&&
mp
.
y
>=
0
&&
mp
.
x
<
imageSize
.
width
&&
mp
.
y
<
imageSize
.
height
)
mouseCallback
(
type
,
mp
.
x
,
mp
.
y
,
flags
,
mouseParam
);
_mouseCallback
(
type
,
mp
.
x
,
mp
.
y
,
flags
,
_
mouseParam
);
}
-
(
void
)
cvMouseEvent
:(
NSEvent
*
)
event
{
//cout << "cvMouseEvent" << endl;
if
(
!
mouseCallback
)
if
([
self
mouseCallback
]
==
nil
)
return
;
int
flags
=
0
;
...
...
@@ -778,13 +806,13 @@ void cv::setWindowTitle(const String& winname, const String& title)
-
(
void
)
createSliderWithName
:(
const
char
*
)
name
maxValue
:(
int
)
max
value
:(
int
*
)
value
callback
:(
CvTrackbarCallback
)
callback
{
//cout << "createSliderWithName" << endl;
if
(
sliders
==
nil
)
sliders
=
[[
NSMutableDictionary
alloc
]
init
];
if
(
_
sliders
==
nil
)
_
sliders
=
[[
NSMutableDictionary
alloc
]
init
];
NSString
*
cvname
=
[
NSString
stringWithFormat
:
@"%s"
,
name
];
// Avoid overwriting slider
if
([
sliders
valueForKey
:
cvname
]
!=
nil
)
if
([
_
sliders
valueForKey
:
cvname
]
!=
nil
)
return
;
// Create slider
...
...
@@ -803,11 +831,11 @@ void cv::setWindowTitle(const String& winname, const String& title)
[
slider
setCallback
:
callback
];
// Save slider
[
sliders
setValue
:
slider
forKey
:
cvname
];
[
_
sliders
setValue
:
slider
forKey
:
cvname
];
[[
self
contentView
]
addSubview
:
slider
];
//update contentView size to contain sliders
//update contentView size to contain
_
sliders
NSSize
viewSize
=
[[
self
contentView
]
frame
].
size
,
sliderSize
=
[
slider
frame
].
size
;
viewSize
.
height
+=
sliderSize
.
height
;
...
...
@@ -817,7 +845,7 @@ void cv::setWindowTitle(const String& winname, const String& title)
[[
self
contentView
]
setFrameSize
:
viewSize
];
[[
self
contentView
]
setNeedsDisplay
:
YES
];
//update window size to contain sliders
//update window size to contain
_
sliders
NSRect
rect
=
[
self
frame
];
rect
.
size
.
height
+=
[
slider
frame
].
size
.
height
;
rect
.
size
.
width
=
std
::
max
<
int
>
(
rect
.
size
.
width
,
MIN_SLIDER_WIDTH
);
...
...
@@ -834,13 +862,16 @@ void cv::setWindowTitle(const String& winname, const String& title)
@end
@implementation
CVView
#if defined(__LP64__)
@synthesize
image
;
#else // 32-bit Obj-C does not have automatic synthesize
@synthesize
image
=
_image
;
#endif
-
(
id
)
init
{
//cout << "CVView init" << endl;
[
super
init
];
image
=
[[
NSImage
alloc
]
init
];
_
image
=
[[
NSImage
alloc
]
init
];
return
self
;
}
...
...
@@ -895,11 +926,11 @@ void cv::setWindowTitle(const String& winname, const String& title)
dst
[
i
*
4
+
2
]
=
src
[
i
*
3
+
2
];
}
if
(
image
)
[
image
release
];
if
(
_
image
)
[
_
image
release
];
image
=
[[
NSImage
alloc
]
init
];
[
image
addRepresentation
:
bitmap
];
_
image
=
[[
NSImage
alloc
]
init
];
[
_
image
addRepresentation
:
bitmap
];
[
bitmap
release
];
/*CGColorSpaceRelease(colorspace);
...
...
@@ -920,7 +951,7 @@ void cv::setWindowTitle(const String& winname, const String& title)
int
height
=
size
.
height
;
CVWindow
*
cvwindow
=
(
CVWindow
*
)[
self
window
];
if
([
cvwindow
respondsToSelector
:
@selector
(
sliders
)])
{
if
([
cvwindow
respondsToSelector
:
@selector
(
_
sliders
)])
{
for
(
NSString
*
key
in
[
cvwindow
sliders
])
{
NSSlider
*
slider
=
[[
cvwindow
sliders
]
valueForKey
:
key
];
NSRect
r
=
[
slider
frame
];
...
...
@@ -940,17 +971,17 @@ void cv::setWindowTitle(const String& winname, const String& title)
NSAutoreleasePool
*
localpool
=
[[
NSAutoreleasePool
alloc
]
init
];
CVWindow
*
cvwindow
=
(
CVWindow
*
)[
self
window
];
int
height
=
0
;
if
([
cvwindow
respondsToSelector
:
@selector
(
sliders
)])
{
if
([
cvwindow
respondsToSelector
:
@selector
(
_
sliders
)])
{
for
(
NSString
*
key
in
[
cvwindow
sliders
])
{
height
+=
[[[
cvwindow
sliders
]
valueForKey
:
key
]
frame
].
size
.
height
;
}
}
NSRect
imageRect
=
{{
0
,
0
},
{[
image
size
].
width
,
[
image
size
].
height
}};
NSRect
imageRect
=
{{
0
,
0
},
{[
_image
size
].
width
,
[
_
image
size
].
height
}};
if
(
image
!=
nil
)
{
[
image
drawInRect
:
imageRect
if
(
_
image
!=
nil
)
{
[
_
image
drawInRect
:
imageRect
fromRect:
NSZeroRect
operation:
NSCompositeSourceOver
fraction:
1.0
];
...
...
@@ -962,40 +993,47 @@ void cv::setWindowTitle(const String& winname, const String& title)
@end
@implementation
CVSlider
#if defined(__LP64__)
@synthesize
slider
;
@synthesize
name
;
@synthesize
value
;
@synthesize
userData
;
@synthesize
callback
;
@synthesize
callback2
;
#else // 32-bit Obj-C does not have automatic synthesize
@synthesize
slider
=
_slider
;
@synthesize
name
=
_name
;
@synthesize
value
=
_value
;
@synthesize
userData
=
_userData
;
@synthesize
callback
=
_callback
;
@synthesize
callback2
=
_callback2
;
#endif
-
(
id
)
init
{
[
super
init
];
callback
=
NULL
;
value
=
NULL
;
userData
=
NULL
;
_
callback
=
NULL
;
_
value
=
NULL
;
_
userData
=
NULL
;
[
self
setFrame
:
NSMakeRect
(
0
,
0
,
200
,
30
)];
name
=
[[
NSTextField
alloc
]
initWithFrame
:
NSMakeRect
(
10
,
0
,
110
,
25
)];
[
name
setEditable
:
NO
];
[
name
setSelectable
:
NO
];
[
name
setBezeled
:
NO
];
[
name
setBordered
:
NO
];
[
name
setDrawsBackground
:
NO
];
[[
name
cell
]
setLineBreakMode
:
NSLineBreakByTruncatingTail
];
[
self
addSubview
:
name
];
slider
=
[[
NSSlider
alloc
]
initWithFrame
:
NSMakeRect
(
120
,
0
,
70
,
25
)];
[
slider
setAutoresizingMask
:
NSViewWidthSizable
];
[
slider
setMinValue
:
0
];
[
slider
setMaxValue
:
100
];
[
slider
setContinuous
:
YES
];
[
slider
setTarget
:
self
];
[
slider
setAction
:
@selector
(
sliderChanged
:)];
[
self
addSubview
:
slider
];
_
name
=
[[
NSTextField
alloc
]
initWithFrame
:
NSMakeRect
(
10
,
0
,
110
,
25
)];
[
_
name
setEditable
:
NO
];
[
_
name
setSelectable
:
NO
];
[
_
name
setBezeled
:
NO
];
[
_
name
setBordered
:
NO
];
[
_
name
setDrawsBackground
:
NO
];
[[
_
name
cell
]
setLineBreakMode
:
NSLineBreakByTruncatingTail
];
[
self
addSubview
:
_
name
];
_
slider
=
[[
NSSlider
alloc
]
initWithFrame
:
NSMakeRect
(
120
,
0
,
70
,
25
)];
[
_
slider
setAutoresizingMask
:
NSViewWidthSizable
];
[
_
slider
setMinValue
:
0
];
[
_
slider
setMaxValue
:
100
];
[
_
slider
setContinuous
:
YES
];
[
_
slider
setTarget
:
self
];
[
_
slider
setAction
:
@selector
(
sliderChanged
:)];
[
self
addSubview
:
_
slider
];
[
self
setAutoresizingMask
:
NSViewWidthSizable
];
...
...
@@ -1006,13 +1044,13 @@ void cv::setWindowTitle(const String& winname, const String& title)
-
(
void
)
sliderChanged
:(
NSNotification
*
)
notification
{
(
void
)
notification
;
int
pos
=
[
slider
intValue
];
if
(
value
)
*
value
=
pos
;
if
(
callback
)
callback
(
pos
);
if
(
callback2
)
callback2
(
pos
,
userData
);
int
pos
=
[
_
slider
intValue
];
if
(
_
value
)
*
_
value
=
pos
;
if
(
_
callback
)
_
callback
(
pos
);
if
(
_
callback2
)
_callback2
(
pos
,
_
userData
);
}
@end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录