Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
不会修仙的道士
labelme
提交
cbd52d31
L
labelme
项目概览
不会修仙的道士
/
labelme
与 Fork 源项目一致
从无法访问的项目Fork
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
labelme
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
cbd52d31
编写于
4月 01, 2018
作者:
K
Kentaro Wada
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix for flake8: labelme/shape.py
上级
aef37a8a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
27 addition
and
28 deletion
+27
-28
labelme/shape.py
labelme/shape.py
+27
-28
未找到文件。
labelme/shape.py
浏览文件 @
cbd52d31
# flake8: noqa
# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Michael Pitidis, Hussein Abdulwahid.
#
...
...
@@ -20,32 +18,32 @@
#
try
:
from
PyQt5.QtGui
import
*
from
PyQt5.QtCore
import
*
from
PyQt5
import
QtGui
except
ImportError
:
from
PyQt4.QtGui
import
*
from
PyQt4.QtCore
import
*
from
PyQt4
import
QtGui
from
.lib
import
distance
# TODO:
# TODO(unknown):
# - [opt] Store paths instead of creating new ones at each paint.
DEFAULT_LINE_COLOR
=
QColor
(
0
,
255
,
0
,
128
)
DEFAULT_FILL_COLOR
=
QColor
(
255
,
0
,
0
,
128
)
DEFAULT_SELECT_LINE_COLOR
=
QColor
(
255
,
255
,
255
)
DEFAULT_SELECT_FILL_COLOR
=
QColor
(
0
,
128
,
255
,
155
)
DEFAULT_VERTEX_FILL_COLOR
=
QColor
(
0
,
255
,
0
,
255
)
DEFAULT_HVERTEX_FILL_COLOR
=
QColor
(
255
,
0
,
0
)
DEFAULT_LINE_COLOR
=
QtGui
.
QColor
(
0
,
255
,
0
,
128
)
DEFAULT_FILL_COLOR
=
QtGui
.
QColor
(
255
,
0
,
0
,
128
)
DEFAULT_SELECT_LINE_COLOR
=
QtGui
.
QColor
(
255
,
255
,
255
)
DEFAULT_SELECT_FILL_COLOR
=
QtGui
.
QColor
(
0
,
128
,
255
,
155
)
DEFAULT_VERTEX_FILL_COLOR
=
QtGui
.
QColor
(
0
,
255
,
0
,
255
)
DEFAULT_HVERTEX_FILL_COLOR
=
QtGui
.
QColor
(
255
,
0
,
0
)
class
Shape
(
object
):
P_SQUARE
,
P_ROUND
=
0
,
1
MOVE_VERTEX
,
NEAR_VERTEX
=
0
,
1
## The following class variables influence the drawing
## of _all_ shape objects.
# The following class variables influence the drawing of all shape objects.
line_color
=
DEFAULT_LINE_COLOR
fill_color
=
DEFAULT_FILL_COLOR
select_line_color
=
DEFAULT_SELECT_LINE_COLOR
...
...
@@ -67,7 +65,7 @@ class Shape(object):
self
.
_highlightSettings
=
{
self
.
NEAR_VERTEX
:
(
4
,
self
.
P_ROUND
),
self
.
MOVE_VERTEX
:
(
1.5
,
self
.
P_SQUARE
),
}
}
self
.
_closed
=
False
...
...
@@ -100,20 +98,21 @@ class Shape(object):
def
paint
(
self
,
painter
):
if
self
.
points
:
color
=
self
.
select_line_color
if
self
.
selected
else
self
.
line_color
pen
=
QPen
(
color
)
color
=
self
.
select_line_color
\
if
self
.
selected
else
self
.
line_color
pen
=
QtGui
.
QPen
(
color
)
# Try using integer sizes for smoother drawing(?)
pen
.
setWidth
(
max
(
1
,
int
(
round
(
2.0
/
self
.
scale
))))
painter
.
setPen
(
pen
)
line_path
=
QPainterPath
()
vrtx_path
=
QPainterPath
()
line_path
=
Q
tGui
.
Q
PainterPath
()
vrtx_path
=
Q
tGui
.
Q
PainterPath
()
line_path
.
moveTo
(
self
.
points
[
0
])
# Uncommenting the following line will draw 2 paths
# for the 1st vertex, and make it non-filled, which
# may be desirable.
#self.drawVertex(vrtx_path, 0)
#
self.drawVertex(vrtx_path, 0)
for
i
,
p
in
enumerate
(
self
.
points
):
line_path
.
lineTo
(
p
)
...
...
@@ -125,7 +124,8 @@ class Shape(object):
painter
.
drawPath
(
vrtx_path
)
painter
.
fillPath
(
vrtx_path
,
self
.
vertex_fill_color
)
if
self
.
fill
:
color
=
self
.
select_fill_color
if
self
.
selected
else
self
.
fill_color
color
=
self
.
select_fill_color
\
if
self
.
selected
else
self
.
fill_color
painter
.
fillPath
(
line_path
,
color
)
def
drawVertex
(
self
,
path
,
i
):
...
...
@@ -140,9 +140,9 @@ class Shape(object):
else
:
self
.
vertex_fill_color
=
Shape
.
vertex_fill_color
if
shape
==
self
.
P_SQUARE
:
path
.
addRect
(
point
.
x
()
-
d
/
2
,
point
.
y
()
-
d
/
2
,
d
,
d
)
path
.
addRect
(
point
.
x
()
-
d
/
2
,
point
.
y
()
-
d
/
2
,
d
,
d
)
elif
shape
==
self
.
P_ROUND
:
path
.
addEllipse
(
point
,
d
/
2.0
,
d
/
2.0
)
path
.
addEllipse
(
point
,
d
/
2.0
,
d
/
2.0
)
else
:
assert
False
,
"unsupported vertex shape"
...
...
@@ -160,7 +160,7 @@ class Shape(object):
return
self
.
makePath
().
contains
(
point
)
def
makePath
(
self
):
path
=
QPainterPath
(
self
.
points
[
0
])
path
=
Q
tGui
.
Q
PainterPath
(
self
.
points
[
0
])
for
p
in
self
.
points
[
1
:]:
path
.
lineTo
(
p
)
return
path
...
...
@@ -183,7 +183,7 @@ class Shape(object):
def
copy
(
self
):
shape
=
Shape
(
self
.
label
)
shape
.
points
=
[
p
for
p
in
self
.
points
]
shape
.
points
=
[
p
for
p
in
self
.
points
]
shape
.
fill
=
self
.
fill
shape
.
selected
=
self
.
selected
shape
.
_closed
=
self
.
_closed
...
...
@@ -201,4 +201,3 @@ class Shape(object):
def
__setitem__
(
self
,
key
,
value
):
self
.
points
[
key
]
=
value
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录