Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Printrun
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
Printrun
Commits
f606d6f0
Commit
f606d6f0
authored
Mar 25, 2014
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add mini control widgets
parent
1df3c16e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
117 additions
and
0 deletions
+117
-0
xybuttons.py
printrun/xybuttons.py
+106
-0
zbuttons.py
printrun/zbuttons.py
+11
-0
No files found.
printrun/xybuttons.py
View file @
f606d6f0
...
...
@@ -383,3 +383,109 @@ class XYButtons(BufferedCanvas):
self
.
quadrant
=
None
self
.
concentric
=
None
self
.
update
()
class
XYButtonsMini
(
XYButtons
):
imagename
=
"control_mini.png"
center
=
(
57
,
56.5
)
concentric_circle_radii
=
[
0
,
30.3
]
corner_inset
=
(
5
,
5
)
corner_size
=
(
50
,
50
)
outer_radius
=
31
corner_to_axis
=
{
0
:
"x"
,
1
:
"z"
,
2
:
"y"
,
3
:
"xy"
,
}
def
bind_events
(
self
):
# Set up mouse and keyboard event capture
self
.
Bind
(
wx
.
EVT_LEFT_DOWN
,
self
.
OnLeftDown
)
self
.
Bind
(
wx
.
EVT_LEFT_DCLICK
,
self
.
OnLeftDown
)
self
.
Bind
(
wx
.
EVT_MOTION
,
self
.
OnMotion
)
self
.
Bind
(
wx
.
EVT_LEAVE_WINDOW
,
self
.
OnLeaveWindow
)
def
OnMotion
(
self
,
event
):
if
not
self
.
enabled
:
return
oldcorner
=
self
.
corner
oldq
,
oldc
=
self
.
quadrant
,
self
.
concentric
mpos
=
event
.
GetPosition
()
self
.
quadrant
,
self
.
concentric
=
self
.
getQuadrantConcentricFromPosition
(
mpos
)
cx
,
cy
=
XYButtonsMini
.
center
if
mpos
.
x
<
cx
and
mpos
.
y
<
cy
:
self
.
corner
=
0
if
mpos
.
x
>=
cx
and
mpos
.
y
<
cy
:
self
.
corner
=
1
if
mpos
.
x
>=
cx
and
mpos
.
y
>=
cy
:
self
.
corner
=
2
if
mpos
.
x
<
cx
and
mpos
.
y
>=
cy
:
self
.
corner
=
3
if
oldq
!=
self
.
quadrant
or
oldc
!=
self
.
concentric
or
oldcorner
!=
self
.
corner
:
self
.
update
()
def
OnLeftDown
(
self
,
event
):
if
not
self
.
enabled
:
return
# Take focus when clicked so that arrow keys can control movement
self
.
SetFocus
()
mpos
=
event
.
GetPosition
()
self
.
quadrant
,
self
.
concentric
=
self
.
getQuadrantConcentricFromPosition
(
mpos
)
if
self
.
concentric
is
not
None
:
if
self
.
concentric
<
len
(
self
.
concentric_circle_radii
):
self
.
cornerCallback
(
"all"
)
elif
self
.
corner
is
not
None
:
if
self
.
cornerCallback
:
self
.
lastCorner
=
self
.
corner
self
.
lastMove
=
None
self
.
cornerCallback
(
self
.
corner_to_axis
[
self
.
corner
])
def
drawCorner
(
self
,
gc
,
x
,
y
,
angle
=
0.0
):
w
,
h
=
self
.
corner_size
gc
.
PushState
()
gc
.
Translate
(
x
,
y
)
gc
.
Rotate
(
angle
)
path
=
gc
.
CreatePath
()
path
.
MoveToPoint
(
-
w
/
2
,
-
h
/
2
)
path
.
AddLineToPoint
(
w
/
2
,
-
h
/
2
)
path
.
AddLineToPoint
(
w
/
2
,
-
h
/
2
+
h
/
4
)
path
.
AddArc
(
w
/
2
,
h
/
2
,
self
.
outer_radius
,
3
*
math
.
pi
/
2
,
math
.
pi
,
False
)
path
.
AddLineToPoint
(
-
w
/
2
,
h
/
2
)
path
.
AddLineToPoint
(
-
w
/
2
,
-
h
/
2
)
gc
.
DrawPath
(
path
)
gc
.
PopState
()
def
draw
(
self
,
dc
,
w
,
h
):
dc
.
SetBackground
(
wx
.
Brush
(
self
.
bgcolor
))
dc
.
Clear
()
gc
=
wx
.
GraphicsContext
.
Create
(
dc
)
if
self
.
bg_bmp
:
w
,
h
=
(
self
.
bg_bmp
.
GetWidth
(),
self
.
bg_bmp
.
GetHeight
())
gc
.
DrawBitmap
(
self
.
bg_bmp
,
0
,
0
,
w
,
h
)
if
self
.
enabled
:
# Brush and pen for grey overlay when mouse hovers over
gc
.
SetPen
(
wx
.
Pen
(
wx
.
Colour
(
100
,
100
,
100
,
172
),
4
))
gc
.
SetBrush
(
wx
.
Brush
(
wx
.
Colour
(
0
,
0
,
0
,
128
)))
if
self
.
concentric
is
not
None
:
if
self
.
concentric
<
len
(
self
.
concentric_circle_radii
):
cx
,
cy
=
XYButtonsMini
.
center
r
=
self
.
concentric_circle_radii
[
-
1
]
gc
.
DrawEllipse
(
cx
-
r
,
cy
-
r
,
r
*
2
,
r
*
2
)
elif
self
.
corner
is
not
None
:
self
.
highlightCorner
(
gc
,
self
.
corner
)
else
:
gc
.
SetPen
(
wx
.
Pen
(
self
.
bgcolor
,
0
))
gc
.
SetBrush
(
wx
.
Brush
(
self
.
bgcolormask
))
gc
.
DrawRectangle
(
0
,
0
,
w
,
h
)
printrun/zbuttons.py
View file @
f606d6f0
...
...
@@ -158,3 +158,14 @@ class ZButtons(BufferedCanvas):
self
.
range
=
None
self
.
direction
=
None
self
.
update
()
class
ZButtonsMini
(
ZButtons
):
button_ydistances
=
[
7
,
30
,
55
]
center
=
(
30
,
84
)
label_overlay_positions
=
{
0
:
(
1
,
18
,
9
),
1
:
(
1
,
42.8
,
12.9
),
}
imagename
=
"control_z_mini.png"
size
=
(
59
,
244
)
move_values
=
[
0.1
,
10
]
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