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
7c78d539
Commit
7c78d539
authored
May 25, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'experimental' of github.com:kliment/Printrun into experimental
parents
dea306eb
a6848356
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
11 deletions
+31
-11
gui.py
printrun/gui.py
+1
-1
xybuttons.py
printrun/xybuttons.py
+19
-8
pronterface.py
pronterface.py
+11
-2
No files found.
printrun/gui.py
View file @
7c78d539
...
@@ -48,7 +48,7 @@ class XYZControlsSizer(wx.GridBagSizer):
...
@@ -48,7 +48,7 @@ class XYZControlsSizer(wx.GridBagSizer):
def
__init__
(
self
,
root
):
def
__init__
(
self
,
root
):
super
(
XYZControlsSizer
,
self
)
.
__init__
()
super
(
XYZControlsSizer
,
self
)
.
__init__
()
root
.
xyb
=
XYButtons
(
root
.
panel
,
root
.
moveXY
,
root
.
homeButtonClicked
,
root
.
spacebarAction
,
root
.
settings
.
bgcolor
)
root
.
xyb
=
XYButtons
(
root
.
panel
,
root
.
moveXY
,
root
.
homeButtonClicked
,
root
.
spacebarAction
,
root
.
settings
.
bgcolor
,
zcallback
=
root
.
moveZ
)
self
.
Add
(
root
.
xyb
,
pos
=
(
0
,
1
),
flag
=
wx
.
ALIGN_CENTER
)
self
.
Add
(
root
.
xyb
,
pos
=
(
0
,
1
),
flag
=
wx
.
ALIGN_CENTER
)
root
.
zb
=
ZButtons
(
root
.
panel
,
root
.
moveZ
,
root
.
settings
.
bgcolor
)
root
.
zb
=
ZButtons
(
root
.
panel
,
root
.
moveZ
,
root
.
settings
.
bgcolor
)
self
.
Add
(
root
.
zb
,
pos
=
(
0
,
2
),
flag
=
wx
.
ALIGN_CENTER
)
self
.
Add
(
root
.
zb
,
pos
=
(
0
,
2
),
flag
=
wx
.
ALIGN_CENTER
)
...
...
printrun/xybuttons.py
View file @
7c78d539
...
@@ -41,7 +41,7 @@ class XYButtons(BufferedCanvas):
...
@@ -41,7 +41,7 @@ class XYButtons(BufferedCanvas):
center
=
(
124
,
121
)
center
=
(
124
,
121
)
spacer
=
7
spacer
=
7
def
__init__
(
self
,
parent
,
moveCallback
=
None
,
cornerCallback
=
None
,
spacebarCallback
=
None
,
bgcolor
=
"#FFFFFF"
,
ID
=-
1
):
def
__init__
(
self
,
parent
,
moveCallback
=
None
,
cornerCallback
=
None
,
spacebarCallback
=
None
,
bgcolor
=
"#FFFFFF"
,
ID
=-
1
,
zcallback
=
None
):
self
.
bg_bmp
=
wx
.
Image
(
imagefile
(
"control_xy.png"
),
wx
.
BITMAP_TYPE_PNG
)
.
ConvertToBitmap
()
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_bmp
=
wx
.
Image
(
imagefile
(
"arrow_keys.png"
),
wx
.
BITMAP_TYPE_PNG
)
.
ConvertToBitmap
()
self
.
keypad_idx
=
-
1
self
.
keypad_idx
=
-
1
...
@@ -51,6 +51,7 @@ class XYButtons(BufferedCanvas):
...
@@ -51,6 +51,7 @@ class XYButtons(BufferedCanvas):
self
.
moveCallback
=
moveCallback
self
.
moveCallback
=
moveCallback
self
.
cornerCallback
=
cornerCallback
self
.
cornerCallback
=
cornerCallback
self
.
spacebarCallback
=
spacebarCallback
self
.
spacebarCallback
=
spacebarCallback
self
.
zCallback
=
zcallback
self
.
enabled
=
False
self
.
enabled
=
False
# Remember the last clicked buttons, so we can repeat when spacebar pressed
# Remember the last clicked buttons, so we can repeat when spacebar pressed
self
.
lastMove
=
None
self
.
lastMove
=
None
...
@@ -108,10 +109,13 @@ class XYButtons(BufferedCanvas):
...
@@ -108,10 +109,13 @@ class XYButtons(BufferedCanvas):
self
.
update
()
self
.
update
()
def
getMovement
(
self
):
def
getMovement
(
self
):
xdir
=
[
1
,
0
,
-
1
,
0
][
self
.
quadrant
]
xdir
=
[
1
,
0
,
-
1
,
0
,
0
,
0
][
self
.
quadrant
]
ydir
=
[
0
,
1
,
0
,
-
1
][
self
.
quadrant
]
ydir
=
[
0
,
1
,
0
,
-
1
,
0
,
0
][
self
.
quadrant
]
zdir
=
[
0
,
0
,
0
,
0
,
1
,
-
1
][
self
.
quadrant
]
magnitude
=
math
.
pow
(
10
,
self
.
concentric
-
1
)
magnitude
=
math
.
pow
(
10
,
self
.
concentric
-
1
)
return
(
magnitude
*
xdir
,
magnitude
*
ydir
)
if
not
zdir
==
0
:
magnitude
=
min
(
magnitude
,
10
)
return
(
magnitude
*
xdir
,
magnitude
*
ydir
,
magnitude
*
zdir
)
def
lookupConcentric
(
self
,
radius
):
def
lookupConcentric
(
self
,
radius
):
idx
=
0
idx
=
0
...
@@ -285,14 +289,21 @@ class XYButtons(BufferedCanvas):
...
@@ -285,14 +289,21 @@ class XYButtons(BufferedCanvas):
self
.
quadrant
=
2
self
.
quadrant
=
2
elif
evt
.
GetKeyCode
()
==
wx
.
WXK_RIGHT
:
elif
evt
.
GetKeyCode
()
==
wx
.
WXK_RIGHT
:
self
.
quadrant
=
0
self
.
quadrant
=
0
elif
evt
.
GetKeyCode
()
==
wx
.
WXK_PAGEUP
:
self
.
quadrant
=
4
elif
evt
.
GetKeyCode
()
==
wx
.
WXK_PAGEDOWN
:
self
.
quadrant
=
5
else
:
else
:
evt
.
Skip
()
evt
.
Skip
()
return
return
if
self
.
moveCallback
:
self
.
concentric
=
self
.
keypad_idx
self
.
concentric
=
self
.
keypad_idx
x
,
y
=
self
.
getMovement
()
x
,
y
,
z
=
self
.
getMovement
()
if
x
!=
0
or
y
!=
0
and
self
.
moveCallback
:
self
.
moveCallback
(
x
,
y
)
self
.
moveCallback
(
x
,
y
)
if
z
!=
0
and
self
.
zCallback
:
self
.
zCallback
(
z
)
elif
evt
.
GetKeyCode
()
==
wx
.
WXK_SPACE
:
elif
evt
.
GetKeyCode
()
==
wx
.
WXK_SPACE
:
self
.
spacebarCallback
()
self
.
spacebarCallback
()
...
@@ -346,7 +357,7 @@ class XYButtons(BufferedCanvas):
...
@@ -346,7 +357,7 @@ class XYButtons(BufferedCanvas):
if
self
.
concentric
!=
None
:
if
self
.
concentric
!=
None
:
if
self
.
concentric
<
len
(
XYButtons
.
concentric_circle_radii
):
if
self
.
concentric
<
len
(
XYButtons
.
concentric_circle_radii
):
if
self
.
quadrant
!=
None
:
if
self
.
quadrant
!=
None
:
x
,
y
=
self
.
getMovement
()
x
,
y
,
z
=
self
.
getMovement
()
if
self
.
moveCallback
:
if
self
.
moveCallback
:
self
.
lastMove
=
(
x
,
y
)
self
.
lastMove
=
(
x
,
y
)
self
.
lastCorner
=
None
self
.
lastCorner
=
None
...
...
pronterface.py
View file @
7c78d539
...
@@ -1285,6 +1285,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
...
@@ -1285,6 +1285,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
if
len
(
target
):
if
len
(
target
):
self
.
recvlisteners
+=
[
self
.
waitforsdresponse
]
self
.
recvlisteners
+=
[
self
.
waitforsdresponse
]
self
.
p
.
send_now
(
"M23 "
+
target
.
lower
())
self
.
p
.
send_now
(
"M23 "
+
target
.
lower
())
dlg
.
Destroy
()
#print self.sdfiles
#print self.sdfiles
def
getfiles
(
self
):
def
getfiles
(
self
):
...
@@ -1368,6 +1369,8 @@ class PronterWindow(MainWindow, pronsole.pronsole):
...
@@ -1368,6 +1369,8 @@ class PronterWindow(MainWindow, pronsole.pronsole):
basedir
=
os
.
path
.
split
(
self
.
filename
)[
0
]
basedir
=
os
.
path
.
split
(
self
.
filename
)[
0
]
except
:
except
:
pass
pass
dlg
=
None
if
filename
is
None
:
dlg
=
wx
.
FileDialog
(
self
,
_
(
"Open file to print"
),
basedir
,
style
=
wx
.
FD_OPEN
|
wx
.
FD_FILE_MUST_EXIST
)
dlg
=
wx
.
FileDialog
(
self
,
_
(
"Open file to print"
),
basedir
,
style
=
wx
.
FD_OPEN
|
wx
.
FD_FILE_MUST_EXIST
)
dlg
.
SetWildcard
(
_
(
"OBJ, STL, and GCODE files (*.gcode;*.gco;*.g;*.stl;*.STL;*.obj;*.OBJ)|*.gcode;*.gco;*.g;*.stl;*.STL;*.obj;*.OBJ|All Files (*.*)|*.*"
))
dlg
.
SetWildcard
(
_
(
"OBJ, STL, and GCODE files (*.gcode;*.gco;*.g;*.stl;*.STL;*.obj;*.OBJ)|*.gcode;*.gco;*.g;*.stl;*.STL;*.obj;*.OBJ|All Files (*.*)|*.*"
))
if
(
filename
is
not
None
or
dlg
.
ShowModal
()
==
wx
.
ID_OK
):
if
(
filename
is
not
None
or
dlg
.
ShowModal
()
==
wx
.
ID_OK
):
...
@@ -1377,6 +1380,8 @@ class PronterWindow(MainWindow, pronsole.pronsole):
...
@@ -1377,6 +1380,8 @@ class PronterWindow(MainWindow, pronsole.pronsole):
name
=
dlg
.
GetPath
()
name
=
dlg
.
GetPath
()
if
not
(
os
.
path
.
exists
(
name
)):
if
not
(
os
.
path
.
exists
(
name
)):
self
.
status
.
SetStatusText
(
_
(
"File not found!"
))
self
.
status
.
SetStatusText
(
_
(
"File not found!"
))
if
dlg
is
not
None
:
dlg
.
Destroy
()
return
return
path
=
os
.
path
.
split
(
name
)[
0
]
path
=
os
.
path
.
split
(
name
)[
0
]
if
path
!=
self
.
settings
.
last_file_path
:
if
path
!=
self
.
settings
.
last_file_path
:
...
@@ -1397,6 +1402,8 @@ class PronterWindow(MainWindow, pronsole.pronsole):
...
@@ -1397,6 +1402,8 @@ class PronterWindow(MainWindow, pronsole.pronsole):
if
self
.
p
.
online
:
if
self
.
p
.
online
:
wx
.
CallAfter
(
self
.
printbtn
.
Enable
)
wx
.
CallAfter
(
self
.
printbtn
.
Enable
)
threading
.
Thread
(
target
=
self
.
loadviz
)
.
start
()
threading
.
Thread
(
target
=
self
.
loadviz
)
.
start
()
if
dlg
is
not
None
:
dlg
.
Destroy
()
def
loadviz
(
self
):
def
loadviz
(
self
):
gcode
=
self
.
fgcode
gcode
=
self
.
fgcode
...
@@ -1464,6 +1471,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
...
@@ -1464,6 +1471,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self
.
p
.
send_now
(
"M21"
)
self
.
p
.
send_now
(
"M21"
)
self
.
p
.
send_now
(
"M28 "
+
str
(
dlg
.
GetValue
()))
self
.
p
.
send_now
(
"M28 "
+
str
(
dlg
.
GetValue
()))
self
.
recvlisteners
+=
[
self
.
uploadtrigger
]
self
.
recvlisteners
+=
[
self
.
uploadtrigger
]
dlg
.
Destroy
()
def
pause
(
self
,
event
):
def
pause
(
self
,
event
):
print
_
(
"Paused."
)
print
_
(
"Paused."
)
...
@@ -1600,6 +1608,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
...
@@ -1600,6 +1608,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self
.
p
.
paused
=
0
self
.
p
.
paused
=
0
wx
.
CallAfter
(
self
.
pausebtn
.
SetLabel
,
_
(
"Pause"
))
wx
.
CallAfter
(
self
.
pausebtn
.
SetLabel
,
_
(
"Pause"
))
self
.
paused
=
0
self
.
paused
=
0
dlg
.
Destroy
()
class
PronterApp
(
wx
.
App
):
class
PronterApp
(
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