Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wangsen
paddle_dbnet
Commits
f68f7df7
Commit
f68f7df7
authored
Jul 22, 2021
by
SLLH
Browse files
Update move box
parent
6887f457
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
34 deletions
+42
-34
PPOCRLabel/PPOCRLabel.py
PPOCRLabel/PPOCRLabel.py
+10
-4
PPOCRLabel/libs/canvas.py
PPOCRLabel/libs/canvas.py
+32
-30
No files found.
PPOCRLabel/PPOCRLabel.py
View file @
f68f7df7
...
@@ -885,10 +885,16 @@ class MainWindow(QMainWindow, WindowMixin):
...
@@ -885,10 +885,16 @@ class MainWindow(QMainWindow, WindowMixin):
self
.
updateComboBox
()
self
.
updateComboBox
()
def
updateBoxlist
(
self
):
def
updateBoxlist
(
self
):
for
shape
in
self
.
canvas
.
selectedShapes
+
[
self
.
canvas
.
hShape
]:
if
self
.
canvas
.
hShape
!=
None
:
item
=
self
.
shapesToItemsbox
[
shape
]
# listitem
for
shape
in
self
.
canvas
.
selectedShapes
+
[
self
.
canvas
.
hShape
]:
text
=
[(
int
(
p
.
x
()),
int
(
p
.
y
()))
for
p
in
shape
.
points
]
item
=
self
.
shapesToItemsbox
[
shape
]
# listitem
item
.
setText
(
str
(
text
))
text
=
[(
int
(
p
.
x
()),
int
(
p
.
y
()))
for
p
in
shape
.
points
]
item
.
setText
(
str
(
text
))
else
:
for
shape
in
self
.
canvas
.
selectedShapes
:
item
=
self
.
shapesToItemsbox
[
shape
]
# listitem
text
=
[(
int
(
p
.
x
()),
int
(
p
.
y
()))
for
p
in
shape
.
points
]
item
.
setText
(
str
(
text
))
self
.
actions
.
undo
.
setEnabled
(
True
)
self
.
actions
.
undo
.
setEnabled
(
True
)
self
.
setDirty
()
self
.
setDirty
()
...
...
PPOCRLabel/libs/canvas.py
View file @
f68f7df7
...
@@ -709,43 +709,45 @@ class Canvas(QWidget):
...
@@ -709,43 +709,45 @@ class Canvas(QWidget):
self
.
update
()
self
.
update
()
elif
key
==
Qt
.
Key_Return
and
self
.
canCloseShape
():
elif
key
==
Qt
.
Key_Return
and
self
.
canCloseShape
():
self
.
finalise
()
self
.
finalise
()
elif
key
==
Qt
.
Key_Left
and
self
.
selectedShape
:
elif
key
==
Qt
.
Key_Left
and
self
.
selectedShape
s
:
self
.
moveOnePixel
(
'Left'
)
self
.
moveOnePixel
(
'Left'
)
elif
key
==
Qt
.
Key_Right
and
self
.
selectedShape
:
elif
key
==
Qt
.
Key_Right
and
self
.
selectedShape
s
:
self
.
moveOnePixel
(
'Right'
)
self
.
moveOnePixel
(
'Right'
)
elif
key
==
Qt
.
Key_Up
and
self
.
selectedShape
:
elif
key
==
Qt
.
Key_Up
and
self
.
selectedShape
s
:
self
.
moveOnePixel
(
'Up'
)
self
.
moveOnePixel
(
'Up'
)
elif
key
==
Qt
.
Key_Down
and
self
.
selectedShape
:
elif
key
==
Qt
.
Key_Down
and
self
.
selectedShape
s
:
self
.
moveOnePixel
(
'Down'
)
self
.
moveOnePixel
(
'Down'
)
def
moveOnePixel
(
self
,
direction
):
def
moveOnePixel
(
self
,
direction
):
# print(self.selectedShape.points)
# print(self.selectedShape.points)
if
direction
==
'Left'
and
not
self
.
moveOutOfBound
(
QPointF
(
-
1.0
,
0
)):
for
i
in
range
(
len
(
self
.
selectedShapes
)):
# print("move Left one pixel")
self
.
selectedShape
=
self
.
selectedShapes
[
i
]
self
.
selectedShape
.
points
[
0
]
+=
QPointF
(
-
1.0
,
0
)
if
direction
==
'Left'
and
not
self
.
moveOutOfBound
(
QPointF
(
-
1.0
,
0
)):
self
.
selectedShape
.
points
[
1
]
+=
QPointF
(
-
1.0
,
0
)
# print("move Left one pixel")
self
.
selectedShape
.
points
[
2
]
+=
QPointF
(
-
1.0
,
0
)
self
.
selectedShape
.
points
[
0
]
+=
QPointF
(
-
1.0
,
0
)
self
.
selectedShape
.
points
[
3
]
+=
QPointF
(
-
1.0
,
0
)
self
.
selectedShape
.
points
[
1
]
+=
QPointF
(
-
1.0
,
0
)
elif
direction
==
'Right'
and
not
self
.
moveOutOfBound
(
QPointF
(
1.0
,
0
)):
self
.
selectedShape
.
points
[
2
]
+=
QPointF
(
-
1.0
,
0
)
# print("move Right one pixel")
self
.
selectedShape
.
points
[
3
]
+=
QPointF
(
-
1.0
,
0
)
self
.
selectedShape
.
points
[
0
]
+=
QPointF
(
1.0
,
0
)
elif
direction
==
'Right'
and
not
self
.
moveOutOfBound
(
QPointF
(
1.0
,
0
)):
self
.
selectedShape
.
points
[
1
]
+=
QPointF
(
1.0
,
0
)
# print("move Right one pixel")
self
.
selectedShape
.
points
[
2
]
+=
QPointF
(
1.0
,
0
)
self
.
selectedShape
.
points
[
0
]
+=
QPointF
(
1.0
,
0
)
self
.
selectedShape
.
points
[
3
]
+=
QPointF
(
1.0
,
0
)
self
.
selectedShape
.
points
[
1
]
+=
QPointF
(
1.0
,
0
)
elif
direction
==
'Up'
and
not
self
.
moveOutOfBound
(
QPointF
(
0
,
-
1.0
)):
self
.
selectedShape
.
points
[
2
]
+=
QPointF
(
1.0
,
0
)
# print("move Up one pixel")
self
.
selectedShape
.
points
[
3
]
+=
QPointF
(
1.0
,
0
)
self
.
selectedShape
.
points
[
0
]
+=
QPointF
(
0
,
-
1.0
)
elif
direction
==
'Up'
and
not
self
.
moveOutOfBound
(
QPointF
(
0
,
-
1.0
)):
self
.
selectedShape
.
points
[
1
]
+=
QPointF
(
0
,
-
1.0
)
# print("move Up one pixel")
self
.
selectedShape
.
points
[
2
]
+=
QPointF
(
0
,
-
1.0
)
self
.
selectedShape
.
points
[
0
]
+=
QPointF
(
0
,
-
1.0
)
self
.
selectedShape
.
points
[
3
]
+=
QPointF
(
0
,
-
1.0
)
self
.
selectedShape
.
points
[
1
]
+=
QPointF
(
0
,
-
1.0
)
elif
direction
==
'Down'
and
not
self
.
moveOutOfBound
(
QPointF
(
0
,
1.0
)):
self
.
selectedShape
.
points
[
2
]
+=
QPointF
(
0
,
-
1.0
)
# print("move Down one pixel")
self
.
selectedShape
.
points
[
3
]
+=
QPointF
(
0
,
-
1.0
)
self
.
selectedShape
.
points
[
0
]
+=
QPointF
(
0
,
1.0
)
elif
direction
==
'Down'
and
not
self
.
moveOutOfBound
(
QPointF
(
0
,
1.0
)):
self
.
selectedShape
.
points
[
1
]
+=
QPointF
(
0
,
1.0
)
# print("move Down one pixel")
self
.
selectedShape
.
points
[
2
]
+=
QPointF
(
0
,
1.0
)
self
.
selectedShape
.
points
[
0
]
+=
QPointF
(
0
,
1.0
)
self
.
selectedShape
.
points
[
3
]
+=
QPointF
(
0
,
1.0
)
self
.
selectedShape
.
points
[
1
]
+=
QPointF
(
0
,
1.0
)
self
.
shapeMoved
.
emit
()
self
.
selectedShape
.
points
[
2
]
+=
QPointF
(
0
,
1.0
)
self
.
repaint
()
self
.
selectedShape
.
points
[
3
]
+=
QPointF
(
0
,
1.0
)
self
.
shapeMoved
.
emit
()
self
.
repaint
()
def
moveOutOfBound
(
self
,
step
):
def
moveOutOfBound
(
self
,
step
):
points
=
[
p1
+
p2
for
p1
,
p2
in
zip
(
self
.
selectedShape
.
points
,
[
step
]
*
4
)]
points
=
[
p1
+
p2
for
p1
,
p2
in
zip
(
self
.
selectedShape
.
points
,
[
step
]
*
4
)]
...
...
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