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
540faffe
Commit
540faffe
authored
Nov 07, 2011
by
Duane Johnson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
XY and Z control panels working side by side
parent
69c639e6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
103 additions
and
12 deletions
+103
-12
control_xy.png
images/control_xy.png
+0
-0
control_z.png
images/control_z.png
+0
-0
test.py
test.py
+103
-12
No files found.
images/control_xy.png
View replaced file @
69c639e6
View file @
540faffe
41.9 KB
|
W:
|
H:
44.1 KB
|
W:
|
H:
2-up
Swipe
Onion skin
images/control_z.png
View replaced file @
69c639e6
View file @
540faffe
11.9 KB
|
W:
|
H:
9.43 KB
|
W:
|
H:
2-up
Swipe
Onion skin
test.py
View file @
540faffe
...
...
@@ -4,13 +4,99 @@ from bufferedcanvas import *
def
imagefile
(
filename
):
return
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"images"
,
filename
)
def
sign
(
n
):
if
n
<
0
:
return
-
1
elif
n
>
0
:
return
1
else
:
return
0
class
ZButtons
(
BufferedCanvas
):
button_ydistances
=
[
16
,
46
,
80
,
118
]
center
=
(
36
,
147
)
def
__init__
(
self
,
parent
,
ID
=-
1
):
self
.
bg_bmp
=
wx
.
Image
(
imagefile
(
"control_z.png"
),
wx
.
BITMAP_TYPE_PNG
)
.
ConvertToBitmap
()
self
.
range
=
None
self
.
direction
=
None
self
.
orderOfMagnitudeIdx
=
0
# 0 means '1', 1 means '10', 2 means '100', etc.
BufferedCanvas
.
__init__
(
self
,
parent
,
ID
)
self
.
SetSize
(
wx
.
Size
(
71
,
297
))
# 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
)
def
lookupRange
(
self
,
ydist
):
idx
=
-
1
for
d
in
ZButtons
.
button_ydistances
:
if
ydist
<
d
:
return
idx
idx
+=
1
return
None
def
highlight
(
self
,
dc
,
rng
,
dir
):
assert
(
rng
>=
-
1
and
rng
<=
2
)
assert
(
dir
>=
-
1
and
dir
<=
1
)
fudge
=
10
x
=
0
+
fudge
w
=
72
-
fudge
*
2
if
rng
==
-
1
:
y
=
ZButtons
.
center
[
1
]
-
ZButtons
.
button_ydistances
[
0
]
h
=
ZButtons
.
button_ydistances
[
0
]
*
2
else
:
k
=
1
if
dir
>
0
else
0
y
=
ZButtons
.
center
[
1
]
-
(
dir
*
ZButtons
.
button_ydistances
[
rng
+
k
])
h
=
ZButtons
.
button_ydistances
[
rng
+
1
]
-
ZButtons
.
button_ydistances
[
rng
]
dc
.
DrawRectangle
(
x
,
y
,
w
,
h
)
# self.drawPartialPie(dc, center, r1-inner_ring_radius, r2-inner_ring_radius, a1+fudge, a2-fudge)
def
getRangeDir
(
self
,
pos
):
ydelta
=
ZButtons
.
center
[
1
]
-
pos
[
1
]
return
(
self
.
lookupRange
(
abs
(
ydelta
)),
sign
(
ydelta
))
def
OnMotion
(
self
,
event
):
oldr
,
oldd
=
self
.
range
,
self
.
direction
mpos
=
event
.
GetPosition
()
self
.
range
,
self
.
direction
=
self
.
getRangeDir
(
mpos
)
if
oldr
!=
self
.
range
or
oldd
!=
self
.
direction
:
self
.
update
()
def
OnLeftDown
(
self
,
event
):
mpos
=
event
.
GetPosition
()
r
,
d
=
self
.
getRangeDir
(
mpos
)
if
r
>=
0
:
value
=
math
.
pow
(
10
,
self
.
orderOfMagnitudeIdx
)
*
math
.
pow
(
10
,
r
-
1
)
*
d
print
'z'
,
value
else
:
print
'Z home'
def
draw
(
self
,
dc
):
dc
.
Clear
()
# center = wx.Point(XYButtons.center[0], XYButtons.center[1])
dc
.
SetPen
(
wx
.
Pen
(
wx
.
Colour
(
100
,
100
,
100
,
172
),
4
))
dc
.
SetBrush
(
wx
.
Brush
(
wx
.
Colour
(
0
,
0
,
0
,
128
)))
dc
.
DrawBitmap
(
self
.
bg_bmp
,
0
,
0
)
if
self
.
range
!=
None
and
self
.
direction
!=
None
:
self
.
highlight
(
dc
,
self
.
range
,
self
.
direction
)
return
True
class
XYButtons
(
BufferedCanvas
):
keypad_positions
=
{
0
:
(
102
,
109
),
1
:
(
78
,
86
),
2
:
(
49
,
58
)
}
concentric_circle_radii
=
[
1
9
,
45
,
81
,
120
]
concentric_circle_radii
=
[
1
7
,
45
,
83
,
122
]
center
=
(
146
,
149
)
distance
=
[
# Order of Magnitude 0 (i.e. 0.1, 1, 10)
...
...
@@ -41,12 +127,14 @@ class XYButtons(BufferedCanvas):
self
.
bg_bmp
=
wx
.
Image
(
imagefile
(
"control_xy.png"
),
wx
.
BITMAP_TYPE_PNG
)
.
ConvertToBitmap
()
self
.
keypad_bmp
=
wx
.
Image
(
imagefile
(
"arrow_keys.png"
),
wx
.
BITMAP_TYPE_PNG
)
.
ConvertToBitmap
()
self
.
keypad_idx
=
0
self
.
orderOfMagnitude
=
0
self
.
orderOfMagnitude
Idx
=
0
self
.
quadrant
=
None
self
.
concentric
=
None
BufferedCanvas
.
__init__
(
self
,
parent
,
ID
)
self
.
SetSize
(
wx
.
Size
(
297
,
297
))
# Set up mouse and keyboard event capture
self
.
Bind
(
wx
.
EVT_LEFT_DOWN
,
self
.
OnLeftDown
)
self
.
Bind
(
wx
.
EVT_LEFT_DCLICK
,
self
.
OnLeftDown
)
...
...
@@ -115,7 +203,7 @@ class XYButtons(BufferedCanvas):
idx
=
self
.
mouseOverKeypad
(
mpos
)
if
idx
!=
None
:
self
.
quadrant
=
None
self
.
concentric
=
None
self
.
concentric
=
-
1
else
:
self
.
quadrant
,
self
.
concentric
=
self
.
getQuadrantConcentricFromPosition
(
mpos
)
...
...
@@ -132,9 +220,9 @@ class XYButtons(BufferedCanvas):
quadrant
,
concentric
=
self
.
getQuadrantConcentricFromPosition
(
mpos
)
# print 'click:', mpos, quadrant, concentric
if
concentric
==
-
1
:
print
'
center button
'
print
'
XY home
'
elif
quadrant
!=
None
and
concentric
!=
None
:
dist
=
XYButtons
.
distance
[
self
.
orderOfMagnitude
][
quadrant
][
concentric
]
dist
=
XYButtons
.
distance
[
self
.
orderOfMagnitude
Idx
][
quadrant
][
concentric
]
print
'x'
,
dist
[
0
],
'y'
,
dist
[
1
]
def
drawPartialPie
(
self
,
dc
,
center
,
r1
,
r2
,
angle1
,
angle2
):
...
...
@@ -186,33 +274,36 @@ class XYButtons(BufferedCanvas):
self
.
drawPartialPie
(
dc
,
center
,
r1
-
inner_ring_radius
,
r2
-
inner_ring_radius
,
a1
+
fudge
,
a2
-
fudge
)
def
draw
(
self
,
dc
):
# print 'draw called'
dc
.
Clear
()
center
=
wx
.
Point
(
XYButtons
.
center
[
0
],
XYButtons
.
center
[
1
])
start
=
wx
.
Point
(
50
,
0
)
end
=
wx
.
Point
(
0
,
50
)
dc
.
SetPen
(
wx
.
Pen
(
wx
.
Colour
(
100
,
100
,
100
,
172
),
4
))
dc
.
SetBrush
(
wx
.
Brush
(
wx
.
Colour
(
0
,
0
,
0
,
128
)))
dc
.
DrawBitmap
(
self
.
bg_bmp
,
0
,
0
)
# dc.DrawArc(50, 0, 0, 50, XYButtons.center[0], XYButtons.center[1])
# self.drawPartialPie(dc, center, 19, 44, -math.pi/4, math.pi/4)
if
self
.
concentric
==
-
1
:
pass
inner_ring_radius
=
XYButtons
.
concentric_circle_radii
[
0
]
dc
.
DrawCircle
(
XYButtons
.
center
[
0
],
XYButtons
.
center
[
1
],
inner_ring_radius
+
2
)
elif
self
.
quadrant
!=
None
and
self
.
concentric
!=
None
:
self
.
highlightQuadrant
(
dc
,
self
.
quadrant
,
self
.
concentric
)
pos
=
XYButtons
.
keypad_positions
[
self
.
keypad_idx
]
dc
.
DrawBitmap
(
self
.
keypad_bmp
,
pos
[
0
],
pos
[
1
])
# dc.DrawArcPoint(start, end, center)
return
True
class
MyFrame
(
wx
.
Frame
):
def
__init__
(
self
,
parent
,
id
,
title
):
wx
.
Frame
.
__init__
(
self
,
parent
,
id
,
title
,
wx
.
DefaultPosition
,
wx
.
Size
(
800
,
600
))
sizer
=
wx
.
BoxSizer
()
self
.
xy
=
XYButtons
(
self
)
sizer
.
Add
(
self
.
xy
)
self
.
z
=
ZButtons
(
self
)
sizer
.
Add
(
self
.
z
)
self
.
SetSizer
(
sizer
)
class
MyApp
(
wx
.
App
):
...
...
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