Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
labelme
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jakambs
labelme
Commits
796a1a25
Commit
796a1a25
authored
Apr 1, 2018
by
Kentaro Wada
Browse files
Options
Downloads
Patches
Plain Diff
Fix for flake8: labelme/shape.py
parent
95c22cd5
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
labelme/shape.py
+27
-28
27 additions, 28 deletions
labelme/shape.py
with
27 additions
and
28 deletions
labelme/shape.py
+
27
−
28
View file @
796a1a25
# flake8: noqa
# -*- coding: utf-8 -*-
#
#
# Copyright (C) 2011 Michael Pitidis, Hussein Abdulwahid.
# Copyright (C) 2011 Michael Pitidis, Hussein Abdulwahid.
#
#
...
@@ -20,32 +18,32 @@
...
@@ -20,32 +18,32 @@
#
#
try
:
try
:
from
PyQt5.QtGui
import
*
from
PyQt5
import
QtGui
from
PyQt5.QtCore
import
*
except
ImportError
:
except
ImportError
:
from
PyQt4.QtGui
import
*
from
PyQt4
import
QtGui
from
PyQt4.QtCore
import
*
from
.lib
import
distance
from
.lib
import
distance
# TODO:
# TODO(unknown):
# - [opt] Store paths instead of creating new ones at each paint.
# - [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_LINE_COLOR
=
QtGui
.
QColor
(
0
,
255
,
0
,
128
)
DEFAULT_SELECT_LINE_COLOR
=
QColor
(
255
,
255
,
255
)
DEFAULT_FILL_COLOR
=
QtGui
.
QColor
(
255
,
0
,
0
,
128
)
DEFAULT_SELECT_FILL_COLOR
=
QColor
(
0
,
128
,
255
,
155
)
DEFAULT_SELECT_LINE_COLOR
=
QtGui
.
QColor
(
255
,
255
,
255
)
DEFAULT_VERTEX_FILL_COLOR
=
QColor
(
0
,
255
,
0
,
255
)
DEFAULT_SELECT_FILL_COLOR
=
QtGui
.
QColor
(
0
,
128
,
255
,
155
)
DEFAULT_HVERTEX_FILL_COLOR
=
QColor
(
255
,
0
,
0
)
DEFAULT_VERTEX_FILL_COLOR
=
QtGui
.
QColor
(
0
,
255
,
0
,
255
)
DEFAULT_HVERTEX_FILL_COLOR
=
QtGui
.
QColor
(
255
,
0
,
0
)
class
Shape
(
object
):
class
Shape
(
object
):
P_SQUARE
,
P_ROUND
=
0
,
1
P_SQUARE
,
P_ROUND
=
0
,
1
MOVE_VERTEX
,
NEAR_VERTEX
=
0
,
1
MOVE_VERTEX
,
NEAR_VERTEX
=
0
,
1
## The following class variables influence the drawing
# The following class variables influence the drawing of all shape objects.
## of _all_ shape objects.
line_color
=
DEFAULT_LINE_COLOR
line_color
=
DEFAULT_LINE_COLOR
fill_color
=
DEFAULT_FILL_COLOR
fill_color
=
DEFAULT_FILL_COLOR
select_line_color
=
DEFAULT_SELECT_LINE_COLOR
select_line_color
=
DEFAULT_SELECT_LINE_COLOR
...
@@ -100,14 +98,15 @@ class Shape(object):
...
@@ -100,14 +98,15 @@ class Shape(object):
def
paint
(
self
,
painter
):
def
paint
(
self
,
painter
):
if
self
.
points
:
if
self
.
points
:
color
=
self
.
select_line_color
if
self
.
selected
else
self
.
line_color
color
=
self
.
select_line_color
\
pen
=
QPen
(
color
)
if
self
.
selected
else
self
.
line_color
pen
=
QtGui
.
QPen
(
color
)
# Try using integer sizes for smoother drawing(?)
# Try using integer sizes for smoother drawing(?)
pen
.
setWidth
(
max
(
1
,
int
(
round
(
2.0
/
self
.
scale
))))
pen
.
setWidth
(
max
(
1
,
int
(
round
(
2.0
/
self
.
scale
))))
painter
.
setPen
(
pen
)
painter
.
setPen
(
pen
)
line_path
=
QPainterPath
()
line_path
=
QtGui
.
QPainterPath
()
vrtx_path
=
QPainterPath
()
vrtx_path
=
QtGui
.
QPainterPath
()
line_path
.
moveTo
(
self
.
points
[
0
])
line_path
.
moveTo
(
self
.
points
[
0
])
# Uncommenting the following line will draw 2 paths
# Uncommenting the following line will draw 2 paths
...
@@ -125,7 +124,8 @@ class Shape(object):
...
@@ -125,7 +124,8 @@ class Shape(object):
painter
.
drawPath
(
vrtx_path
)
painter
.
drawPath
(
vrtx_path
)
painter
.
fillPath
(
vrtx_path
,
self
.
vertex_fill_color
)
painter
.
fillPath
(
vrtx_path
,
self
.
vertex_fill_color
)
if
self
.
fill
:
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
)
painter
.
fillPath
(
line_path
,
color
)
def
drawVertex
(
self
,
path
,
i
):
def
drawVertex
(
self
,
path
,
i
):
...
@@ -160,7 +160,7 @@ class Shape(object):
...
@@ -160,7 +160,7 @@ class Shape(object):
return
self
.
makePath
().
contains
(
point
)
return
self
.
makePath
().
contains
(
point
)
def
makePath
(
self
):
def
makePath
(
self
):
path
=
QPainterPath
(
self
.
points
[
0
])
path
=
QtGui
.
QPainterPath
(
self
.
points
[
0
])
for
p
in
self
.
points
[
1
:]:
for
p
in
self
.
points
[
1
:]:
path
.
lineTo
(
p
)
path
.
lineTo
(
p
)
return
path
return
path
...
@@ -201,4 +201,3 @@ class Shape(object):
...
@@ -201,4 +201,3 @@ class Shape(object):
def
__setitem__
(
self
,
key
,
value
):
def
__setitem__
(
self
,
key
,
value
):
self
.
points
[
key
]
=
value
self
.
points
[
key
]
=
value
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment