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
ce8c3f3c
Commit
ce8c3f3c
authored
May 16, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply 2to3 and clean 2 minor conversion issues
parent
0376729a
Changes
28
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
345 additions
and
344 deletions
+345
-344
GCodeAnalyzer.py
GCodeAnalyzer.py
+1
-1
plater.py
plater.py
+8
-8
printcore.py
printcore.py
+19
-18
SkeinforgeQuickEditDialog.py
printrun/SkeinforgeQuickEditDialog.py
+1
-1
calibrateextruder.py
printrun/calibrateextruder.py
+21
-21
gcoder.py
printrun/gcoder.py
+11
-11
gcview.py
printrun/gcview.py
+20
-20
graph.py
printrun/graph.py
+2
-2
gui.py
printrun/gui.py
+6
-6
gviz.py
printrun/gviz.py
+10
-10
printrun_utils.py
printrun/printrun_utils.py
+3
-3
projectlayer.py
printrun/projectlayer.py
+5
-5
pronterface_widgets.py
printrun/pronterface_widgets.py
+4
-4
stltool.py
printrun/stltool.py
+17
-17
stlview.py
printrun/stlview.py
+39
-39
attributes.py
printrun/svg/attributes.py
+3
-3
__init__.py
printrun/svg/css/__init__.py
+1
-1
colour.py
printrun/svg/css/colour.py
+2
-2
identifier.py
printrun/svg/css/identifier.py
+5
-5
document.py
printrun/svg/document.py
+13
-13
xybuttons.py
printrun/xybuttons.py
+4
-4
zbuttons.py
printrun/zbuttons.py
+3
-3
zscaper.py
printrun/zscaper.py
+8
-8
pronserve.py
pronserve.py
+20
-20
pronsole.py
pronsole.py
+37
-37
pronterface.py
pronterface.py
+71
-71
basic_auth.py
server/basic_auth.py
+3
-3
setup.py
setup.py
+8
-8
No files found.
GCodeAnalyzer.py
View file @
ce8c3f3c
...
@@ -209,5 +209,5 @@ class GCodeAnalyzer():
...
@@ -209,5 +209,5 @@ class GCodeAnalyzer():
def
print_status
(
self
):
def
print_status
(
self
):
attrs
=
vars
(
self
)
attrs
=
vars
(
self
)
print
'
\n
'
.
join
(
"
%
s:
%
s"
%
item
for
item
in
attrs
.
items
(
))
print
(
'
\n
'
.
join
(
"
%
s:
%
s"
%
item
for
item
in
list
(
attrs
.
items
())
))
\ No newline at end of file
plater.py
View file @
ce8c3f3c
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
# Set up Internationalization using gettext
# Set up Internationalization using gettext
# searching for installed locales on /usr/share; uses relative folder if not found (windows)
# searching for installed locales on /usr/share; uses relative folder if not found (windows)
import
os
,
Q
ueue
,
re
import
os
,
q
ueue
,
re
from
printrun.printrun_utils
import
install_locale
from
printrun.printrun_utils
import
install_locale
install_locale
(
'plater'
)
install_locale
(
'plater'
)
...
@@ -209,18 +209,18 @@ class showstl(wx.Window):
...
@@ -209,18 +209,18 @@ class showstl(wx.Window):
offset
=
[
0
,
0
]
offset
=
[
0
,
0
]
scale
=
2
scale
=
2
dc
.
SetPen
(
wx
.
Pen
(
wx
.
Colour
(
100
,
100
,
100
)))
dc
.
SetPen
(
wx
.
Pen
(
wx
.
Colour
(
100
,
100
,
100
)))
for
i
in
x
range
(
20
):
for
i
in
range
(
20
):
dc
.
DrawLine
(
0
,
i
*
scale
*
10
,
400
,
i
*
scale
*
10
)
dc
.
DrawLine
(
0
,
i
*
scale
*
10
,
400
,
i
*
scale
*
10
)
dc
.
DrawLine
(
i
*
scale
*
10
,
0
,
i
*
scale
*
10
,
400
)
dc
.
DrawLine
(
i
*
scale
*
10
,
0
,
i
*
scale
*
10
,
400
)
dc
.
SetPen
(
wx
.
Pen
(
wx
.
Colour
(
0
,
0
,
0
)))
dc
.
SetPen
(
wx
.
Pen
(
wx
.
Colour
(
0
,
0
,
0
)))
for
i
in
x
range
(
4
):
for
i
in
range
(
4
):
dc
.
DrawLine
(
0
,
i
*
scale
*
50
,
400
,
i
*
scale
*
50
)
dc
.
DrawLine
(
0
,
i
*
scale
*
50
,
400
,
i
*
scale
*
50
)
dc
.
DrawLine
(
i
*
scale
*
50
,
0
,
i
*
scale
*
50
,
400
)
dc
.
DrawLine
(
i
*
scale
*
50
,
0
,
i
*
scale
*
50
,
400
)
dc
.
SetBrush
(
wx
.
Brush
(
wx
.
Colour
(
128
,
255
,
128
)))
dc
.
SetBrush
(
wx
.
Brush
(
wx
.
Colour
(
128
,
255
,
128
)))
dc
.
SetPen
(
wx
.
Pen
(
wx
.
Colour
(
128
,
128
,
128
)))
dc
.
SetPen
(
wx
.
Pen
(
wx
.
Colour
(
128
,
128
,
128
)))
t
=
time
.
time
()
t
=
time
.
time
()
dcs
=
wx
.
MemoryDC
()
dcs
=
wx
.
MemoryDC
()
for
m
in
self
.
parent
.
models
.
values
(
):
for
m
in
list
(
self
.
parent
.
models
.
values
()
):
b
=
m
.
bitmap
b
=
m
.
bitmap
#print b
#print b
im
=
b
.
ConvertToImage
()
im
=
b
.
ConvertToImage
()
...
@@ -288,7 +288,7 @@ class stlwin(wx.Frame):
...
@@ -288,7 +288,7 @@ class stlwin(wx.Frame):
#self.SetClientSize(size)
#self.SetClientSize(size)
def
autoplate
(
self
,
event
):
def
autoplate
(
self
,
event
):
print
_
(
"Autoplating"
)
print
(
_
(
"Autoplating"
)
)
separation
=
2
separation
=
2
bedsize
=
[
200
,
200
,
100
]
bedsize
=
[
200
,
200
,
100
]
cursor
=
[
0
,
0
,
0
]
cursor
=
[
0
,
0
,
0
]
...
@@ -316,7 +316,7 @@ class stlwin(wx.Frame):
...
@@ -316,7 +316,7 @@ class stlwin(wx.Frame):
max
[
1
]
=
cursor
[
1
]
+
x
max
[
1
]
=
cursor
[
1
]
+
x
cursor
[
0
]
+=
x
+
separation
cursor
[
0
]
+=
x
+
separation
if
(
cursor
[
1
]
+
y
)
>=
bedsize
[
1
]:
if
(
cursor
[
1
]
+
y
)
>=
bedsize
[
1
]:
print
_
(
"Bed full, sorry sir :("
)
print
(
_
(
"Bed full, sorry sir :("
)
)
self
.
Refresh
()
self
.
Refresh
()
return
return
centreoffset
=
[(
bedsize
[
0
]
-
max
[
0
])
/
2
,
(
bedsize
[
1
]
-
max
[
1
])
/
2
]
centreoffset
=
[(
bedsize
[
0
]
-
max
[
0
])
/
2
,
(
bedsize
[
1
]
-
max
[
1
])
/
2
]
...
@@ -378,7 +378,7 @@ class stlwin(wx.Frame):
...
@@ -378,7 +378,7 @@ class stlwin(wx.Frame):
def
writefiles
(
self
,
name
):
def
writefiles
(
self
,
name
):
sf
=
open
(
name
.
replace
(
"."
,
"_"
)
+
".scad"
,
"w"
)
sf
=
open
(
name
.
replace
(
"."
,
"_"
)
+
".scad"
,
"w"
)
facets
=
[]
facets
=
[]
for
i
in
self
.
models
.
values
(
):
for
i
in
list
(
self
.
models
.
values
()
):
r
=
i
.
rot
r
=
i
.
rot
o
=
i
.
offsets
o
=
i
.
offsets
...
@@ -390,7 +390,7 @@ class stlwin(wx.Frame):
...
@@ -390,7 +390,7 @@ class stlwin(wx.Frame):
facets
+=
i
.
facets
facets
+=
i
.
facets
sf
.
close
()
sf
.
close
()
stltool
.
emitstl
(
name
,
facets
,
"plater_export"
)
stltool
.
emitstl
(
name
,
facets
,
"plater_export"
)
print
_
(
"wrote
%
s"
)
%
name
print
(
_
(
"wrote
%
s"
)
%
name
)
def
right
(
self
,
event
):
def
right
(
self
,
event
):
dlg
=
wx
.
FileDialog
(
self
,
_
(
"Pick file to load"
),
self
.
basedir
,
style
=
wx
.
FD_OPEN
|
wx
.
FD_FILE_MUST_EXIST
)
dlg
=
wx
.
FileDialog
(
self
,
_
(
"Pick file to load"
),
self
.
basedir
,
style
=
wx
.
FD_OPEN
|
wx
.
FD_FILE_MUST_EXIST
)
...
...
printcore.py
View file @
ce8c3f3c
...
@@ -21,6 +21,7 @@ from select import error as SelectError
...
@@ -21,6 +21,7 @@ from select import error as SelectError
import
time
,
getopt
,
sys
import
time
,
getopt
,
sys
import
platform
,
os
import
platform
,
os
from
GCodeAnalyzer
import
GCodeAnalyzer
from
GCodeAnalyzer
import
GCodeAnalyzer
from
functools
import
reduce
def
control_ttyhup
(
port
,
disable_hup
):
def
control_ttyhup
(
port
,
disable_hup
):
"""Controls the HUPCL"""
"""Controls the HUPCL"""
...
@@ -120,19 +121,19 @@ class printcore():
...
@@ -120,19 +121,19 @@ class printcore():
if
self
.
recvcb
:
if
self
.
recvcb
:
try
:
self
.
recvcb
(
line
)
try
:
self
.
recvcb
(
line
)
except
:
pass
except
:
pass
if
self
.
loud
:
print
"RECV: "
,
line
.
rstrip
(
)
if
self
.
loud
:
print
(
"RECV: "
,
line
.
rstrip
()
)
return
line
return
line
except
SelectError
,
e
:
except
SelectError
as
e
:
if
'Bad file descriptor'
in
e
.
args
[
1
]:
if
'Bad file descriptor'
in
e
.
args
[
1
]:
print
"Can't read from printer (disconnected?)."
print
(
"Can't read from printer (disconnected?)."
)
return
None
return
None
else
:
else
:
raise
raise
except
SerialException
,
e
:
except
SerialException
as
e
:
print
"Can't read from printer (disconnected?)."
print
(
"Can't read from printer (disconnected?)."
)
return
None
return
None
except
OSError
,
e
:
except
OSError
as
e
:
print
"Can't read from printer (disconnected?)."
print
(
"Can't read from printer (disconnected?)."
)
return
None
return
None
def
_listen_can_continue
(
self
):
def
_listen_can_continue
(
self
):
...
@@ -201,7 +202,7 @@ class printcore():
...
@@ -201,7 +202,7 @@ class printcore():
self
.
clear
=
True
self
.
clear
=
True
def
_checksum
(
self
,
command
):
def
_checksum
(
self
,
command
):
return
reduce
(
lambda
x
,
y
:
x
^
y
,
map
(
ord
,
command
))
return
reduce
(
lambda
x
,
y
:
x
^
y
,
list
(
map
(
ord
,
command
)
))
def
startprint
(
self
,
data
,
startindex
=
0
):
def
startprint
(
self
,
data
,
startindex
=
0
):
"""Start a print, data is an array of gcode commands.
"""Start a print, data is an array of gcode commands.
...
@@ -312,7 +313,7 @@ class printcore():
...
@@ -312,7 +313,7 @@ class printcore():
time
.
sleep
(
0.001
)
time
.
sleep
(
0.001
)
wait
-=
1
wait
-=
1
else
:
else
:
print
"Not connected to printer."
print
(
"Not connected to printer."
)
def
send_now
(
self
,
command
,
wait
=
0
):
def
send_now
(
self
,
command
,
wait
=
0
):
"""Sends a command to the printer ahead of the command queue, without a checksum
"""Sends a command to the printer ahead of the command queue, without a checksum
...
@@ -332,7 +333,7 @@ class printcore():
...
@@ -332,7 +333,7 @@ class printcore():
time
.
sleep
(
0.001
)
time
.
sleep
(
0.001
)
wait
-=
1
wait
-=
1
else
:
else
:
print
"Not connected to printer."
print
(
"Not connected to printer."
)
def
_print
(
self
):
def
_print
(
self
):
if
self
.
startcb
:
if
self
.
startcb
:
...
@@ -414,14 +415,14 @@ class printcore():
...
@@ -414,14 +415,14 @@ class printcore():
self
.
sent
.
append
(
command
)
self
.
sent
.
append
(
command
)
self
.
analyzer
.
Analyze
(
command
)
# run the command through the analyzer
self
.
analyzer
.
Analyze
(
command
)
# run the command through the analyzer
if
self
.
loud
:
if
self
.
loud
:
print
"SENT: "
,
command
print
(
"SENT: "
,
command
)
if
self
.
sendcb
:
if
self
.
sendcb
:
try
:
self
.
sendcb
(
command
)
try
:
self
.
sendcb
(
command
)
except
:
pass
except
:
pass
try
:
try
:
self
.
printer
.
write
(
str
(
command
+
"
\n
"
))
self
.
printer
.
write
(
str
(
command
+
"
\n
"
))
except
SerialException
,
e
:
except
SerialException
as
e
:
print
"Can't write to printer (disconnected?)."
print
(
"Can't write to printer (disconnected?)."
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
baud
=
115200
baud
=
115200
...
@@ -430,13 +431,13 @@ if __name__ == '__main__':
...
@@ -430,13 +431,13 @@ if __name__ == '__main__':
try
:
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"h,b:,v,s"
,
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"h,b:,v,s"
,
[
"help"
,
"baud"
,
"verbose"
,
"statusreport"
])
[
"help"
,
"baud"
,
"verbose"
,
"statusreport"
])
except
getopt
.
GetoptError
,
err
:
except
getopt
.
GetoptError
as
err
:
print
str
(
err
)
print
(
str
(
err
)
)
sys
.
exit
(
2
)
sys
.
exit
(
2
)
for
o
,
a
in
opts
:
for
o
,
a
in
opts
:
if
o
in
(
'-h'
,
'--help'
):
if
o
in
(
'-h'
,
'--help'
):
# FIXME: Fix help
# FIXME: Fix help
print
"Opts are: --help , -b --baud = baudrate, -v --verbose, -s --statusreport"
print
(
"Opts are: --help , -b --baud = baudrate, -v --verbose, -s --statusreport"
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
if
o
in
(
'-b'
,
'--baud'
):
if
o
in
(
'-b'
,
'--baud'
):
baud
=
int
(
a
)
baud
=
int
(
a
)
...
@@ -448,9 +449,9 @@ if __name__ == '__main__':
...
@@ -448,9 +449,9 @@ if __name__ == '__main__':
if
len
(
args
)
>
1
:
if
len
(
args
)
>
1
:
port
=
args
[
-
2
]
port
=
args
[
-
2
]
filename
=
args
[
-
1
]
filename
=
args
[
-
1
]
print
"Printing:
%
s on
%
s with baudrate
%
d"
%
(
filename
,
port
,
baud
)
print
(
"Printing:
%
s on
%
s with baudrate
%
d"
%
(
filename
,
port
,
baud
)
)
else
:
else
:
print
"Usage: python [-h|-b|-v|-s] printcore.py /dev/tty[USB|ACM]x filename.gcode"
print
(
"Usage: python [-h|-b|-v|-s] printcore.py /dev/tty[USB|ACM]x filename.gcode"
)
sys
.
exit
(
2
)
sys
.
exit
(
2
)
p
=
printcore
(
port
,
baud
)
p
=
printcore
(
port
,
baud
)
p
.
loud
=
loud
p
.
loud
=
loud
...
...
printrun/SkeinforgeQuickEditDialog.py
View file @
ce8c3f3c
...
@@ -141,7 +141,7 @@ class SkeinforgeQuickEditDialog(wx.Dialog):
...
@@ -141,7 +141,7 @@ class SkeinforgeQuickEditDialog(wx.Dialog):
for
setting
in
settings
.
getReadRepository
(
repo
)
.
preferences
:
for
setting
in
settings
.
getReadRepository
(
repo
)
.
preferences
:
if
setting
.
name
==
settingName
:
if
setting
.
name
==
settingName
:
if
setting
.
value
==
None
or
str
(
x
.
GetValue
())
!=
str
(
setting
.
value
):
if
setting
.
value
==
None
or
str
(
x
.
GetValue
())
!=
str
(
setting
.
value
):
print
(
'Saving ... '
+
settingName
+
' = '
+
str
(
x
.
GetValue
(
)))
print
(
(
'Saving ... '
+
settingName
+
' = '
+
str
(
x
.
GetValue
()
)))
setting
.
value
=
x
.
GetValue
()
setting
.
value
=
x
.
GetValue
()
isDirty
=
True
isDirty
=
True
if
isDirty
:
if
isDirty
:
...
...
printrun/calibrateextruder.py
View file @
ce8c3f3c
...
@@ -38,7 +38,7 @@ def float_input(prompt=''):
...
@@ -38,7 +38,7 @@ def float_input(prompt=''):
import
sys
import
sys
f
=
None
f
=
None
while
f
==
None
:
while
f
==
None
:
s
=
raw_
input
(
prompt
)
s
=
input
(
prompt
)
try
:
try
:
f
=
float
(
s
)
f
=
float
(
s
)
except
ValueError
:
except
ValueError
:
...
@@ -54,7 +54,7 @@ def wait(t, m=''):
...
@@ -54,7 +54,7 @@ def wait(t, m=''):
sys
.
stdout
.
write
(
s
)
sys
.
stdout
.
write
(
s
)
sys
.
stdout
.
flush
()
sys
.
stdout
.
flush
()
time
.
sleep
(
1.0
/
5
)
time
.
sleep
(
1.0
/
5
)
print
print
()
def
w
(
s
):
def
w
(
s
):
sys
.
stdout
.
write
(
s
)
sys
.
stdout
.
write
(
s
)
sys
.
stdout
.
flush
()
sys
.
stdout
.
flush
()
...
@@ -73,9 +73,9 @@ def heatup(p, temp, s = 0):
...
@@ -73,9 +73,9 @@ def heatup(p, temp, s = 0):
time
.
sleep
(
1.5
)
time
.
sleep
(
1.5
)
f
=
True
f
=
True
curtemp
=
gettemp
(
p
)
curtemp
=
gettemp
(
p
)
if
curtemp
:
w
(
u
"
\r
Heating extruder up..
%3
d
\xb0
C"
%
curtemp
)
if
curtemp
:
w
(
"
\r
Heating extruder up..
%3
d
\xb0
C"
%
curtemp
)
if
s
:
print
if
s
:
print
()
else
:
print
"
\n
Ready."
else
:
print
(
"
\n
Ready."
)
def
gettemp
(
p
):
def
gettemp
(
p
):
try
:
p
.
logl
try
:
p
.
logl
...
@@ -87,14 +87,14 @@ def gettemp(p):
...
@@ -87,14 +87,14 @@ def gettemp(p):
if
'T:'
in
line
:
if
'T:'
in
line
:
try
:
try
:
setattr
(
p
,
'temp'
,
int
(
line
.
split
(
'T:'
)[
1
]
.
split
()[
0
]))
setattr
(
p
,
'temp'
,
int
(
line
.
split
(
'T:'
)[
1
]
.
split
()[
0
]))
except
:
print
line
except
:
print
(
line
)
p
.
logl
=
len
(
p
.
log
)
p
.
logl
=
len
(
p
.
log
)
return
p
.
temp
return
p
.
temp
if
not
os
.
path
.
exists
(
port
):
if
not
os
.
path
.
exists
(
port
):
port
=
0
port
=
0
#Parse options
#Parse options
help
=
u
"""
help
=
"""
%
s [ -l DISTANCE ] [ -s STEPS ] [ -t TEMP ] [ -p PORT ]
%
s [ -l DISTANCE ] [ -s STEPS ] [ -t TEMP ] [ -p PORT ]
-l --length Length of filament to extrude for each calibration step (default:
%
d mm)
-l --length Length of filament to extrude for each calibration step (default:
%
d mm)
-s --steps Initial amount of steps to use (default:
%
d steps)
-s --steps Initial amount of steps to use (default:
%
d steps)
...
@@ -104,13 +104,13 @@ help = u"""
...
@@ -104,13 +104,13 @@ help = u"""
"""
[
1
:
-
1
]
.
encode
(
'utf-8'
)
%
(
sys
.
argv
[
0
],
n
,
k
,
temp
,
tempmax
,
port
if
port
else
'auto'
)
"""
[
1
:
-
1
]
.
encode
(
'utf-8'
)
%
(
sys
.
argv
[
0
],
n
,
k
,
temp
,
tempmax
,
port
if
port
else
'auto'
)
try
:
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"hl:s:t:p:"
,[
"help"
,
"length="
,
"steps="
,
"temp="
,
"port="
])
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"hl:s:t:p:"
,[
"help"
,
"length="
,
"steps="
,
"temp="
,
"port="
])
except
getopt
.
GetoptError
,
err
:
except
getopt
.
GetoptError
as
err
:
print
str
(
err
)
print
(
str
(
err
)
)
print
help
print
(
help
)
sys
.
exit
(
2
)
sys
.
exit
(
2
)
for
o
,
a
in
opts
:
for
o
,
a
in
opts
:
if
o
in
(
'-h'
,
'--help'
):
if
o
in
(
'-h'
,
'--help'
):
print
help
print
(
help
)
sys
.
exit
()
sys
.
exit
()
elif
o
in
(
'-l'
,
'--length'
):
elif
o
in
(
'-l'
,
'--length'
):
n
=
float
(
a
)
n
=
float
(
a
)
...
@@ -119,17 +119,17 @@ for o, a in opts:
...
@@ -119,17 +119,17 @@ for o, a in opts:
elif
o
in
(
'-t'
,
'--temp'
):
elif
o
in
(
'-t'
,
'--temp'
):
temp
=
int
(
a
)
temp
=
int
(
a
)
if
temp
>=
tempmax
:
if
temp
>=
tempmax
:
print
(
u'
%
d
\xb0
C? Are you insane?'
.
encode
(
'utf-8'
)
%
temp
)
+
(
" That's over nine thousand!"
if
temp
>
9000
else
''
)
print
((
'
%
d
\xb0
C? Are you insane?'
.
encode
(
'utf-8'
)
%
temp
)
+
(
" That's over nine thousand!"
if
temp
>
9000
else
''
)
)
sys
.
exit
(
255
)
sys
.
exit
(
255
)
elif
o
in
(
'-p'
,
'--port'
):
elif
o
in
(
'-p'
,
'--port'
):
port
=
a
port
=
a
#Show initial parameters
#Show initial parameters
print
"Initial parameters"
print
(
"Initial parameters"
)
print
"Steps per mm:
%3
d steps"
%
k
print
(
"Steps per mm:
%3
d steps"
%
k
)
print
"Length extruded:
%3
d mm"
%
n
print
(
"Length extruded:
%3
d mm"
%
n
)
print
print
()
print
"Serial port:
%
s"
%
(
port
if
port
else
'auto'
)
print
(
"Serial port:
%
s"
%
(
port
if
port
else
'auto'
)
)
p
=
None
p
=
None
try
:
try
:
...
@@ -138,12 +138,12 @@ try:
...
@@ -138,12 +138,12 @@ try:
try
:
try
:
p
=
printcore
(
port
,
115200
)
p
=
printcore
(
port
,
115200
)
except
:
except
:
print
'Error.'
print
(
'Error.'
)
raise
raise
while
not
p
.
online
:
while
not
p
.
online
:
time
.
sleep
(
1
)
time
.
sleep
(
1
)
w
(
'.'
)
w
(
'.'
)
print
" connected."
print
(
" connected."
)
heatup
(
p
,
temp
)
heatup
(
p
,
temp
)
...
@@ -158,8 +158,8 @@ try:
...
@@ -158,8 +158,8 @@ try:
if
n
!=
m
:
if
n
!=
m
:
k
=
(
n
/
m
)
*
k
k
=
(
n
/
m
)
*
k
p
.
send_now
(
"M92 E
%
d"
%
int
(
round
(
k
)))
#Set new step count
p
.
send_now
(
"M92 E
%
d"
%
int
(
round
(
k
)))
#Set new step count
print
"Steps per mm:
%3
d steps"
%
k
#Tell user
print
(
"Steps per mm:
%3
d steps"
%
k
)
#Tell user
print
'Calibration completed.'
#Yay!
print
(
'Calibration completed.'
)
#Yay!
except
KeyboardInterrupt
:
except
KeyboardInterrupt
:
pass
pass
finally
:
finally
:
...
...
printrun/gcoder.py
View file @
ce8c3f3c
...
@@ -190,7 +190,7 @@ class GCode(object):
...
@@ -190,7 +190,7 @@ class GCode(object):
old_lines
+=
cur_lines
old_lines
+=
cur_lines
layers
[
prev_z
]
=
old_lines
layers
[
prev_z
]
=
old_lines
for
idx
in
l
ayers
.
keys
(
):
for
idx
in
l
ist
(
layers
.
keys
()
):
cur_lines
=
layers
[
idx
]
cur_lines
=
layers
[
idx
]
has_movement
=
False
has_movement
=
False
for
l
in
layers
[
idx
]:
for
l
in
layers
[
idx
]:
...
@@ -215,7 +215,7 @@ class GCode(object):
...
@@ -215,7 +215,7 @@ class GCode(object):
ymax
=
float
(
"-inf"
)
ymax
=
float
(
"-inf"
)
zmax
=
float
(
"-inf"
)
zmax
=
float
(
"-inf"
)
for
l
in
self
.
layers
.
values
(
):
for
l
in
list
(
self
.
layers
.
values
()
):
(
xm
,
xM
),
(
ym
,
yM
),
(
zm
,
zM
)
=
l
.
measure
()
(
xm
,
xM
),
(
ym
,
yM
),
(
zm
,
zM
)
=
l
.
measure
()
xmin
=
min
(
xm
,
xmin
)
xmin
=
min
(
xm
,
xmin
)
xmax
=
max
(
xM
,
xmax
)
xmax
=
max
(
xM
,
xmax
)
...
@@ -266,7 +266,7 @@ class GCode(object):
...
@@ -266,7 +266,7 @@ class GCode(object):
#TODO:
#TODO:
# get device caps from firmware: max speed, acceleration/axis (including extruder)
# get device caps from firmware: max speed, acceleration/axis (including extruder)
# calculate the maximum move duration accounting for above ;)
# calculate the maximum move duration accounting for above ;)
zs
=
self
.
layers
.
keys
(
)
zs
=
list
(
self
.
layers
.
keys
()
)
zs
.
sort
()
zs
.
sort
()
for
z
in
zs
:
for
z
in
zs
:
layer
=
self
.
layers
[
z
]
layer
=
self
.
layers
[
z
]
...
@@ -316,7 +316,7 @@ class GCode(object):
...
@@ -316,7 +316,7 @@ class GCode(object):
def
main
():
def
main
():
if
len
(
sys
.
argv
)
<
2
:
if
len
(
sys
.
argv
)
<
2
:
print
"usage:
%
s filename.gcode"
%
sys
.
argv
[
0
]
print
(
"usage:
%
s filename.gcode"
%
sys
.
argv
[
0
])
return
return
# d = [i.replace("\n","") for i in open(sys.argv[1])]
# d = [i.replace("\n","") for i in open(sys.argv[1])]
...
@@ -325,13 +325,13 @@ def main():
...
@@ -325,13 +325,13 @@ def main():
gcode
.
measure
()
gcode
.
measure
()
print
"Dimensions:"
print
(
"Dimensions:"
)
print
"
\t
X:
%0.02
f -
%0.02
f (
%0.02
f)"
%
(
gcode
.
xmin
,
gcode
.
xmax
,
gcode
.
width
)
print
(
"
\t
X:
%0.02
f -
%0.02
f (
%0.02
f)"
%
(
gcode
.
xmin
,
gcode
.
xmax
,
gcode
.
width
)
)
print
"
\t
Y:
%0.02
f -
%0.02
f (
%0.02
f)"
%
(
gcode
.
ymin
,
gcode
.
ymax
,
gcode
.
depth
)
print
(
"
\t
Y:
%0.02
f -
%0.02
f (
%0.02
f)"
%
(
gcode
.
ymin
,
gcode
.
ymax
,
gcode
.
depth
)
)
print
"
\t
Z:
%0.02
f -
%0.02
f (
%0.02
f)"
%
(
gcode
.
zmin
,
gcode
.
zmax
,
gcode
.
height
)
print
(
"
\t
Z:
%0.02
f -
%0.02
f (
%0.02
f)"
%
(
gcode
.
zmin
,
gcode
.
zmax
,
gcode
.
height
)
)
print
"Filament used:
%0.02
fmm"
%
gcode
.
filament_length
(
)
print
(
"Filament used:
%0.02
fmm"
%
gcode
.
filament_length
()
)
print
"Number of layers:
%
d"
%
gcode
.
num_layers
(
)
print
(
"Number of layers:
%
d"
%
gcode
.
num_layers
()
)
print
"Estimated duration (pessimistic):
%
s"
%
gcode
.
estimate_duration
(
)
print
(
"Estimated duration (pessimistic):
%
s"
%
gcode
.
estimate_duration
()
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
printrun/gcview.py
View file @
ce8c3f3c
...
@@ -26,7 +26,7 @@ pyglet.options['shadow_window'] = False
...
@@ -26,7 +26,7 @@ pyglet.options['shadow_window'] = False
pyglet
.
options
[
'debug_gl'
]
=
False
pyglet
.
options
[
'debug_gl'
]
=
False
from
pyglet.gl
import
*
from
pyglet.gl
import
*
import
stltool
from
.
import
stltool
import
threading
import
threading
...
@@ -258,7 +258,7 @@ class gcline(object):
...
@@ -258,7 +258,7 @@ class gcline(object):
self
.
calc_len
()
self
.
calc_len
()
def
__str__
(
self
):
def
__str__
(
self
):
return
u
"line from
%
s,
%
s,
%
s to
%
s,
%
s,
%
s with extrusion ratio
%
s and feedrate
%
s
\n
%
s"
%
(
return
"line from
%
s,
%
s,
%
s to
%
s,
%
s,
%
s with extrusion ratio
%
s and feedrate
%
s
\n
%
s"
%
(
self
.
prev_gcline
.
x
,
self
.
prev_gcline
.
x
,
self
.
prev_gcline
.
y
,
self
.
prev_gcline
.
y
,
self
.
prev_gcline
.
z
,
self
.
prev_gcline
.
z
,
...
@@ -338,18 +338,18 @@ class gcThreadRenderer(threading.Thread):
...
@@ -338,18 +338,18 @@ class gcThreadRenderer(threading.Thread):
threading
.
Thread
.
__init__
(
self
)
threading
.
Thread
.
__init__
(
self
)
self
.
gcview
=
gcview
self
.
gcview
=
gcview
self
.
lines
=
lines
self
.
lines
=
lines
print
"q init"
print
(
"q init"
)
def
run
(
self
):
def
run
(
self
):
for
line
in
self
.
lines
:
for
line
in
self
.
lines
:
layer_name
=
line
.
z
layer_name
=
line
.
z
if
line
.
z
not
in
self
.
gcview
.
layers
:
if
line
.
z
not
in
self
.
gcview
.
layers
:
self
.
gcview
.
layers
[
line
.
z
]
=
pyglet
.
graphics
.
Batch
()
self
.
gcview
.
layers
[
line
.
z
]
=
pyglet
.
graphics
.
Batch
()
self
.
gcview
.
layerlist
=
self
.
gcview
.
layers
.
keys
(
)
self
.
gcview
.
layerlist
=
list
(
self
.
gcview
.
layers
.
keys
()
)
self
.
gcview
.
layerlist
.
sort
()
self
.
gcview
.
layerlist
.
sort
()
self
.
gcview
.
layers
[
line
.
z
]
.
add
(
2
,
GL_LINES
,
None
,
(
"v3f"
,
line
.
glline
()),
(
"c3B"
,
line
.
glcolor
(
self
.
gcview
.
upper_limit
,
self
.
gcview
.
lower_limit
,
self
.
gcview
.
max_feedrate
)))
self
.
gcview
.
layers
[
line
.
z
]
.
add
(
2
,
GL_LINES
,
None
,
(
"v3f"
,
line
.
glline
()),
(
"c3B"
,
line
.
glcolor
(
self
.
gcview
.
upper_limit
,
self
.
gcview
.
lower_limit
,
self
.
gcview
.
max_feedrate
)))
self
.
gcview
.
t2
=
time
.
time
()
self
.
gcview
.
t2
=
time
.
time
()
print
"Rendered lines in
%
fs"
%
(
self
.
gcview
.
t2
-
self
.
gcview
.
t1
)
print
(
"Rendered lines in
%
fs"
%
(
self
.
gcview
.
t2
-
self
.
gcview
.
t1
)
)
class
gcview
(
object
):
class
gcview
(
object
):
"""gcode visualiser
"""gcode visualiser
...
@@ -358,7 +358,7 @@ class gcview(object):
...
@@ -358,7 +358,7 @@ class gcview(object):
def
__init__
(
self
,
lines
,
batch
,
w
=
0.5
,
h
=
0.5
):
def
__init__
(
self
,
lines
,
batch
,
w
=
0.5
,
h
=
0.5
):
if
len
(
lines
)
==
0
:
if
len
(
lines
)
==
0
:
return
return
print
"Loading
%
s lines"
%
(
len
(
lines
))
print
(
"Loading
%
s lines"
%
(
len
(
lines
)
))
#End pos of previous mode
#End pos of previous mode
self
.
prev
=
gcpoint
()
self
.
prev
=
gcpoint
()
# Correction for G92 moves
# Correction for G92 moves
...
@@ -369,7 +369,7 @@ class gcview(object):
...
@@ -369,7 +369,7 @@ class gcview(object):
lines
=
[
self
.
transform
(
i
)
for
i
in
lines
]
lines
=
[
self
.
transform
(
i
)
for
i
in
lines
]
lines
=
[
i
for
i
in
lines
if
i
is
not
None
]
lines
=
[
i
for
i
in
lines
if
i
is
not
None
]
self
.
t1
=
time
.
time
()
self
.
t1
=
time
.
time
()
print
"transformed
%
s lines in
%
fs"
%
(
len
(
lines
),
self
.
t1
-
self
.
t0
)
print
(
"transformed
%
s lines in
%
fs"
%
(
len
(
lines
),
self
.
t1
-
self
.
t0
)
)
self
.
upper_limit
=
0
self
.
upper_limit
=
0
self
.
lower_limit
=
None
self
.
lower_limit
=
None
self
.
max_feedrate
=
0
self
.
max_feedrate
=
0
...
@@ -472,8 +472,8 @@ def trackball(p1x, p1y, p2x, p2y, r):
...
@@ -472,8 +472,8 @@ def trackball(p1x, p1y, p2x, p2y, r):
p2
=
[
p2x
,
p2y
,
project_to_sphere
(
TRACKBALLSIZE
,
p2x
,
p2y
)]
p2
=
[
p2x
,
p2y
,
project_to_sphere
(
TRACKBALLSIZE
,
p2x
,
p2y
)]
a
=
stltool
.
cross
(
p2
,
p1
)
a
=
stltool
.
cross
(
p2
,
p1
)
d
=
map
(
lambda
x
,
y
:
x
-
y
,
p1
,
p2
)
d
=
list
(
map
(
lambda
x
,
y
:
x
-
y
,
p1
,
p2
)
)
t
=
math
.
sqrt
(
sum
(
map
(
lambda
x
:
x
*
x
,
d
)
))
/
(
2.0
*
TRACKBALLSIZE
)
t
=
math
.
sqrt
(
sum
(
[
x
*
x
for
x
in
d
]
))
/
(
2.0
*
TRACKBALLSIZE
)
if
(
t
>
1.0
):
if
(
t
>
1.0
):
t
=
1.0
t
=
1.0
...
@@ -490,9 +490,9 @@ def vec(*args):
...
@@ -490,9 +490,9 @@ def vec(*args):
def
axis_to_quat
(
a
,
phi
):
def
axis_to_quat
(
a
,
phi
):
#print a, phi
#print a, phi
lena
=
math
.
sqrt
(
sum
(
map
(
lambda
x
:
x
*
x
,
a
)
))
lena
=
math
.
sqrt
(
sum
(
[
x
*
x
for
x
in
a
]
))
q
=
map
(
lambda
x
:
x
*
(
1
/
lena
),
a
)
q
=
[
x
*
(
1
/
lena
)
for
x
in
a
]
q
=
map
(
lambda
x
:
x
*
math
.
sin
(
phi
/
2.0
),
q
)
q
=
[
x
*
math
.
sin
(
phi
/
2.0
)
for
x
in
q
]
q
.
append
(
math
.
cos
(
phi
/
2.0
))
q
.
append
(
math
.
cos
(
phi
/
2.0
))
return
q
return
q
...
@@ -559,10 +559,10 @@ class TestGlPanel(GLPanel):
...
@@ -559,10 +559,10 @@ class TestGlPanel(GLPanel):
def
double
(
self
,
event
):
def
double
(
self
,
event
):
p
=
event
.
GetPositionTuple
()
p
=
event
.
GetPositionTuple
()
sz
=
self
.
GetClientSize
()
sz
=
self
.
GetClientSize
()
v
=
map
(
lambda
m
,
w
,
b
:
b
*
m
/
w
,
p
,
sz
,
self
.
bedsize
)
v
=
list
(
map
(
lambda
m
,
w
,
b
:
b
*
m
/
w
,
p
,
sz
,
self
.
bedsize
)
)
v
[
1
]
=
self
.
bedsize
[
1
]
-
v
[
1
]
v
[
1
]
=
self
.
bedsize
[
1
]
-
v
[
1
]
v
+=
[
300
]
v
+=
[
300
]
print
v
print
(
v
)
self
.
add_file
(
"../prusa/metric-prusa/x-end-idler.stl"
,
v
)
self
.
add_file
(
"../prusa/metric-prusa/x-end-idler.stl"
,
v
)
def
forceresize
(
self
):
def
forceresize
(
self
):
...
@@ -654,7 +654,7 @@ class TestGlPanel(GLPanel):
...
@@ -654,7 +654,7 @@ class TestGlPanel(GLPanel):
p1
[
1
]
*=
-
1
p1
[
1
]
*=
-
1
p2
[
1
]
*=
-
1
p2
[
1
]
*=
-
1
self
.
transv
=
map
(
lambda
x
,
y
,
z
,
c
:
c
-
self
.
dist
*
(
x
-
y
)
/
z
,
list
(
p1
)
+
[
0
],
list
(
p2
)
+
[
0
],
list
(
sz
)
+
[
1
],
self
.
transv
)
self
.
transv
=
list
(
map
(
lambda
x
,
y
,
z
,
c
:
c
-
self
.
dist
*
(
x
-
y
)
/
z
,
list
(
p1
)
+
[
0
],
list
(
p2
)
+
[
0
],
list
(
sz
)
+
[
1
],
self
.
transv
)
)
glLoadIdentity
()
glLoadIdentity
()
glTranslatef
(
self
.
transv
[
0
],
self
.
transv
[
1
],
0
)
glTranslatef
(
self
.
transv
[
0
],
self
.
transv
[
1
],
0
)
...
@@ -668,7 +668,7 @@ class TestGlPanel(GLPanel):
...
@@ -668,7 +668,7 @@ class TestGlPanel(GLPanel):
#mouse is moving without a button press
#mouse is moving without a button press
p
=
event
.
GetPositionTuple
()
p
=
event
.
GetPositionTuple
()
sz
=
self
.
GetClientSize
()
sz
=
self
.
GetClientSize
()
v
=
map
(
lambda
m
,
w
,
b
:
b
*
m
/
w
,
p
,
sz
,
self
.
bedsize
)
v
=
list
(
map
(
lambda
m
,
w
,
b
:
b
*
m
/
w
,
p
,
sz
,
self
.
bedsize
)
)
v
[
1
]
=
self
.
bedsize
[
1
]
-
v
[
1
]
v
[
1
]
=
self
.
bedsize
[
1
]
-
v
[
1
]
self
.
mousepos
=
v
self
.
mousepos
=
v
...
@@ -720,7 +720,7 @@ class TestGlPanel(GLPanel):
...
@@ -720,7 +720,7 @@ class TestGlPanel(GLPanel):
def
keypress
(
self
,
event
):
def
keypress
(
self
,
event
):
"""gets keypress events and moves/rotates acive shape"""
"""gets keypress events and moves/rotates acive shape"""
keycode
=
event
.
GetKeyCode
()
keycode
=
event
.
GetKeyCode
()
print
keycode
print
(
keycode
)
step
=
5
step
=
5
angle
=
18
angle
=
18
if
event
.
ControlDown
():
if
event
.
ControlDown
():
...
@@ -815,14 +815,14 @@ class TestGlPanel(GLPanel):
...
@@ -815,14 +815,14 @@ class TestGlPanel(GLPanel):
rows
=
10
rows
=
10
cols
=
10
cols
=
10
zheight
=
50
zheight
=
50
for
i
in
x
range
(
-
rows
,
rows
+
1
):
for
i
in
range
(
-
rows
,
rows
+
1
):
if
i
%
5
==
0
:
if
i
%
5
==
0
:
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_AMBIENT_AND_DIFFUSE
,
vec
(
0.6
,
0.6
,
0.6
,
1
))
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_AMBIENT_AND_DIFFUSE
,
vec
(
0.6
,
0.6
,
0.6
,
1
))
else
:
else
:
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_AMBIENT_AND_DIFFUSE
,
vec
(
0.2
,
0.2
,
0.2
,
1
))
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_AMBIENT_AND_DIFFUSE
,
vec
(
0.2
,
0.2
,
0.2
,
1
))
glVertex3f
(
10
*
-
cols
,
10
*
i
,
0
)
glVertex3f
(
10
*
-
cols
,
10
*
i
,
0
)
glVertex3f
(
10
*
cols
,
10
*
i
,
0
)
glVertex3f
(
10
*
cols
,
10
*
i
,
0
)
for
i
in
x
range
(
-
cols
,
cols
+
1
):
for
i
in
range
(
-
cols
,
cols
+
1
):
if
i
%
5
==
0
:
if
i
%
5
==
0
:
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_AMBIENT_AND_DIFFUSE
,
vec
(
0.6
,
0.6
,
0.6
,
1
))
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_AMBIENT_AND_DIFFUSE
,
vec
(
0.6
,
0.6
,
0.6
,
1
))
else
:
else
:
...
@@ -872,7 +872,7 @@ class TestGlPanel(GLPanel):
...
@@ -872,7 +872,7 @@ class TestGlPanel(GLPanel):
glHint
(
GL_LINE_SMOOTH_HINT
,
GL_NICEST
)
glHint
(
GL_LINE_SMOOTH_HINT
,
GL_NICEST
)
glLineWidth
(
1.5
)
glLineWidth
(
1.5
)
for
i
in
self
.
parent
.
models
.
values
(
):
for
i
in
list
(
self
.
parent
.
models
.
values
()
):
glPushMatrix
()
glPushMatrix
()
glTranslatef
(
*
(
i
.
offsets
))
glTranslatef
(
*
(
i
.
offsets
))
glRotatef
(
i
.
rot
,
0.0
,
0.0
,
1.0
)
glRotatef
(
i
.
rot
,
0.0
,
0.0
,
1.0
)
...
...
printrun/graph.py
View file @
ce8c3f3c
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
import
wx
,
random
import
wx
,
random
from
bufferedcanvas
import
*
from
.
bufferedcanvas
import
*
class
Graph
(
BufferedCanvas
):
class
Graph
(
BufferedCanvas
):
'''A class to show a Graph with Pronterface.'''
'''A class to show a Graph with Pronterface.'''
...
@@ -110,7 +110,7 @@ class Graph(BufferedCanvas):
...
@@ -110,7 +110,7 @@ class Graph(BufferedCanvas):
for
y
in
range
(
self
.
ybars
):
for
y
in
range
(
self
.
ybars
):
y_pos
=
y
*
(
float
(
self
.
height
)
/
self
.
ybars
)
y_pos
=
y
*
(
float
(
self
.
height
)
/
self
.
ybars
)
dc
.
DrawLine
(
0
,
y_pos
,
self
.
width
,
y_pos
)
dc
.
DrawLine
(
0
,
y_pos
,
self
.
width
,
y_pos
)
gc
.
DrawText
(
unicode
(
int
(
self
.
maxyvalue
-
(
y
*
(
self
.
maxyvalue
/
self
.
ybars
)))),
1
,
y_pos
-
(
font
.
GetPointSize
()
/
2
))
gc
.
DrawText
(
str
(
int
(
self
.
maxyvalue
-
(
y
*
(
self
.
maxyvalue
/
self
.
ybars
)))),
1
,
y_pos
-
(
font
.
GetPointSize
()
/
2
))
if
self
.
timer
.
IsRunning
()
==
False
:
if
self
.
timer
.
IsRunning
()
==
False
:
font
=
wx
.
Font
(
14
,
wx
.
DEFAULT
,
wx
.
NORMAL
,
wx
.
BOLD
)
font
=
wx
.
Font
(
14
,
wx
.
DEFAULT
,
wx
.
NORMAL
,
wx
.
BOLD
)
...
...
printrun/gui.py
View file @
ce8c3f3c
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
try
:
try
:
import
wx
import
wx
except
:
except
:
print
_
(
"WX is not installed. This program requires WX to run."
)
print
(
_
(
"WX is not installed. This program requires WX to run."
)
)
raise
raise
global
buttonSize
global
buttonSize
...
@@ -88,13 +88,13 @@ class LeftPane(wx.GridBagSizer):
...
@@ -88,13 +88,13 @@ class LeftPane(wx.GridBagSizer):
root
.
monitorbox
.
Bind
(
wx
.
EVT_CHECKBOX
,
root
.
setmonitor
)
root
.
monitorbox
.
Bind
(
wx
.
EVT_CHECKBOX
,
root
.
setmonitor
)
self
.
Add
(
wx
.
StaticText
(
root
.
panel
,
-
1
,
_
(
"Heat:"
)),
pos
=
(
2
,
0
),
span
=
(
1
,
1
),
flag
=
wx
.
ALIGN_CENTER_VERTICAL
|
wx
.
ALIGN_RIGHT
)
self
.
Add
(
wx
.
StaticText
(
root
.
panel
,
-
1
,
_
(
"Heat:"
)),
pos
=
(
2
,
0
),
span
=
(
1
,
1
),
flag
=
wx
.
ALIGN_CENTER_VERTICAL
|
wx
.
ALIGN_RIGHT
)
htemp_choices
=
[
root
.
temps
[
i
]
+
" ("
+
i
+
")"
for
i
in
sorted
(
root
.
temps
.
keys
(
),
key
=
lambda
x
:
root
.
temps
[
x
])]
htemp_choices
=
[
root
.
temps
[
i
]
+
" ("
+
i
+
")"
for
i
in
sorted
(
list
(
root
.
temps
.
keys
()
),
key
=
lambda
x
:
root
.
temps
[
x
])]
root
.
settoff
=
make_button
(
root
.
panel
,
_
(
"Off"
),
lambda
e
:
root
.
do_settemp
(
"off"
),
_
(
"Switch Hotend Off"
),
size
=
(
36
,
-
1
),
style
=
wx
.
BU_EXACTFIT
)
root
.
settoff
=
make_button
(
root
.
panel
,
_
(
"Off"
),
lambda
e
:
root
.
do_settemp
(
"off"
),
_
(
"Switch Hotend Off"
),
size
=
(
36
,
-
1
),
style
=
wx
.
BU_EXACTFIT
)
root
.
printerControls
.
append
(
root
.
settoff
)
root
.
printerControls
.
append
(
root
.
settoff
)
self
.
Add
(
root
.
settoff
,
pos
=
(
2
,
1
),
span
=
(
1
,
1
))
self
.
Add
(
root
.
settoff
,
pos
=
(
2
,
1
),
span
=
(
1
,
1
))
if
root
.
settings
.
last_temperature
not
in
map
(
float
,
root
.
temps
.
values
(
)):
if
root
.
settings
.
last_temperature
not
in
list
(
map
(
float
,
list
(
root
.
temps
.
values
())
)):
htemp_choices
=
[
str
(
root
.
settings
.
last_temperature
)]
+
htemp_choices
htemp_choices
=
[
str
(
root
.
settings
.
last_temperature
)]
+
htemp_choices
root
.
htemp
=
wx
.
ComboBox
(
root
.
panel
,
-
1
,
root
.
htemp
=
wx
.
ComboBox
(
root
.
panel
,
-
1
,
choices
=
htemp_choices
,
style
=
wx
.
CB_DROPDOWN
,
size
=
(
70
,
-
1
))
choices
=
htemp_choices
,
style
=
wx
.
CB_DROPDOWN
,
size
=
(
70
,
-
1
))
...
@@ -107,13 +107,13 @@ class LeftPane(wx.GridBagSizer):
...
@@ -107,13 +107,13 @@ class LeftPane(wx.GridBagSizer):
self
.
Add
(
root
.
settbtn
,
pos
=
(
2
,
4
),
span
=
(
1
,
1
))
self
.
Add
(
root
.
settbtn
,
pos
=
(
2
,
4
),
span
=
(
1
,
1
))
self
.
Add
(
wx
.
StaticText
(
root
.
panel
,
-
1
,
_
(
"Bed:"
)),
pos
=
(
3
,
0
),
span
=
(
1
,
1
),
flag
=
wx
.
ALIGN_CENTER_VERTICAL
|
wx
.
ALIGN_RIGHT
)
self
.
Add
(
wx
.
StaticText
(
root
.
panel
,
-
1
,
_
(
"Bed:"
)),
pos
=
(
3
,
0
),
span
=
(
1
,
1
),
flag
=
wx
.
ALIGN_CENTER_VERTICAL
|
wx
.
ALIGN_RIGHT
)
btemp_choices
=
[
root
.
bedtemps
[
i
]
+
" ("
+
i
+
")"
for
i
in
sorted
(
root
.
bedtemps
.
keys
(
),
key
=
lambda
x
:
root
.
temps
[
x
])]
btemp_choices
=
[
root
.
bedtemps
[
i
]
+
" ("
+
i
+
")"
for
i
in
sorted
(
list
(
root
.
bedtemps
.
keys
()
),
key
=
lambda
x
:
root
.
temps
[
x
])]
root
.
setboff
=
make_button
(
root
.
panel
,
_
(
"Off"
),
lambda
e
:
root
.
do_bedtemp
(
"off"
),
_
(
"Switch Heated Bed Off"
),
size
=
(
36
,
-
1
),
style
=
wx
.
BU_EXACTFIT
)
root
.
setboff
=
make_button
(
root
.
panel
,
_
(
"Off"
),
lambda
e
:
root
.
do_bedtemp
(
"off"
),
_
(
"Switch Heated Bed Off"
),
size
=
(
36
,
-
1
),
style
=
wx
.
BU_EXACTFIT
)
root
.
printerControls
.
append
(
root
.
setboff
)
root
.
printerControls
.
append
(
root
.
setboff
)
self
.
Add
(
root
.
setboff
,
pos
=
(
3
,
1
),
span
=
(
1
,
1
))
self
.
Add
(
root
.
setboff
,
pos
=
(
3
,
1
),
span
=
(
1
,
1
))
if
root
.
settings
.
last_bed_temperature
not
in
map
(
float
,
root
.
bedtemps
.
values
(
)):
if
root
.
settings
.
last_bed_temperature
not
in
list
(
map
(
float
,
list
(
root
.
bedtemps
.
values
())
)):
btemp_choices
=
[
str
(
root
.
settings
.
last_bed_temperature
)]
+
btemp_choices
btemp_choices
=
[
str
(
root
.
settings
.
last_bed_temperature
)]
+
btemp_choices
root
.
btemp
=
wx
.
ComboBox
(
root
.
panel
,
-
1
,
root
.
btemp
=
wx
.
ComboBox
(
root
.
panel
,
-
1
,
choices
=
btemp_choices
,
style
=
wx
.
CB_DROPDOWN
,
size
=
(
70
,
-
1
))
choices
=
btemp_choices
,
style
=
wx
.
CB_DROPDOWN
,
size
=
(
70
,
-
1
))
...
@@ -207,7 +207,7 @@ class LogPane(wx.BoxSizer):
...
@@ -207,7 +207,7 @@ class LogPane(wx.BoxSizer):
root
.
commandbox
.
SetToolTip
(
wx
.
ToolTip
(
"Send commands to printer
\n
(Type 'help' for simple
\n
help function)"
))
root
.
commandbox
.
SetToolTip
(
wx
.
ToolTip
(
"Send commands to printer
\n
(Type 'help' for simple
\n
help function)"
))
root
.
commandbox
.
Bind
(
wx
.
EVT_TEXT_ENTER
,
root
.
sendline
)
root
.
commandbox
.
Bind
(
wx
.
EVT_TEXT_ENTER
,
root
.
sendline
)
root
.
commandbox
.
Bind
(
wx
.
EVT_CHAR
,
root
.
cbkey
)
root
.
commandbox
.
Bind
(
wx
.
EVT_CHAR
,
root
.
cbkey
)
root
.
commandbox
.
history
=
[
u
""
]
root
.
commandbox
.
history
=
[
""
]
root
.
commandbox
.
histindex
=
1
root
.
commandbox
.
histindex
=
1
#root.printerControls.append(root.commandbox)
#root.printerControls.append(root.commandbox)
lbrs
.
Add
(
root
.
commandbox
,
1
)
lbrs
.
Add
(
root
.
commandbox
,
1
)
...
...
printrun/gviz.py
View file @
ce8c3f3c
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
import
wx
,
time
import
wx
,
time
from
printrun
import
gcoder
from
printrun
import
gcoder
from
printrun_utils
import
imagefile
from
.
printrun_utils
import
imagefile
ID_ABOUT
=
101
ID_ABOUT
=
101
ID_EXIT
=
110
ID_EXIT
=
110
...
@@ -149,7 +149,7 @@ class gviz(wx.Panel):
...
@@ -149,7 +149,7 @@ class gviz(wx.Panel):
self
.
arcpen
=
wx
.
Pen
(
wx
.
Colour
(
255
,
0
,
0
),
penwidth
)
self
.
arcpen
=
wx
.
Pen
(
wx
.
Colour
(
255
,
0
,
0
),
penwidth
)
self
.
travelpen
=
wx
.
Pen
(
wx
.
Colour
(
10
,
80
,
80
),
penwidth
)
self
.
travelpen
=
wx
.
Pen
(
wx
.
Colour
(
10
,
80
,
80
),
penwidth
)
self
.
hlpen
=
wx
.
Pen
(
wx
.
Colour
(
200
,
50
,
50
),
penwidth
)
self
.
hlpen
=
wx
.
Pen
(
wx
.
Colour
(
200
,
50
,
50
),
penwidth
)
self
.
fades
=
[
wx
.
Pen
(
wx
.
Colour
(
250
-
0.6
**
i
*
100
,
250
-
0.6
**
i
*
100
,
200
-
0.4
**
i
*
50
),
penwidth
)
for
i
in
x
range
(
6
)]
self
.
fades
=
[
wx
.
Pen
(
wx
.
Colour
(
250
-
0.6
**
i
*
100
,
250
-
0.6
**
i
*
100
,
200
-
0.4
**
i
*
50
),
penwidth
)
for
i
in
range
(
6
)]
self
.
penslist
=
[
self
.
mainpen
,
self
.
travelpen
,
self
.
hlpen
]
+
self
.
fades
self
.
penslist
=
[
self
.
mainpen
,
self
.
travelpen
,
self
.
hlpen
]
+
self
.
fades
self
.
showall
=
0
self
.
showall
=
0
self
.
hilight
=
[]
self
.
hilight
=
[]
...
@@ -159,8 +159,8 @@ class gviz(wx.Panel):
...
@@ -159,8 +159,8 @@ class gviz(wx.Panel):
def
inject
(
self
):
def
inject
(
self
):
#import pdb; pdb.set_trace()
#import pdb; pdb.set_trace()
print
"Inject code here..."
print
(
"Inject code here..."
)
print
"Layer "
+
str
(
self
.
layerindex
+
1
)
+
" - Z = "
+
str
(
self
.
layers
[
self
.
layerindex
])
+
" mm"
print
(
"Layer "
+
str
(
self
.
layerindex
+
1
)
+
" - Z = "
+
str
(
self
.
layers
[
self
.
layerindex
])
+
" mm"
)
def
clear
(
self
):
def
clear
(
self
):
self
.
lastpos
=
[
0
,
0
,
0
,
0
,
0
,
0
,
0
]
self
.
lastpos
=
[
0
,
0
,
0
,
0
,
0
,
0
,
0
]
...
@@ -233,9 +233,9 @@ class gviz(wx.Panel):
...
@@ -233,9 +233,9 @@ class gviz(wx.Panel):
dc
.
SetPen
(
wx
.
Pen
(
wx
.
Colour
(
180
,
180
,
150
)))
dc
.
SetPen
(
wx
.
Pen
(
wx
.
Colour
(
180
,
180
,
150
)))
for
grid_unit
in
self
.
grid
:
for
grid_unit
in
self
.
grid
:
if
grid_unit
>
0
:
if
grid_unit
>
0
:
for
x
in
x
range
(
int
(
self
.
build_dimensions
[
0
]
/
grid_unit
)
+
1
):
for
x
in
range
(
int
(
self
.
build_dimensions
[
0
]
/
grid_unit
)
+
1
):
dc
.
DrawLine
(
self
.
translate
[
0
]
+
x
*
self
.
scale
[
0
]
*
grid_unit
,
self
.
translate
[
1
],
self
.
translate
[
0
]
+
x
*
self
.
scale
[
0
]
*
grid_unit
,
self
.
translate
[
1
]
+
self
.
scale
[
1
]
*
self
.
build_dimensions
[
1
])
dc
.
DrawLine
(
self
.
translate
[
0
]
+
x
*
self
.
scale
[
0
]
*
grid_unit
,
self
.
translate
[
1
],
self
.
translate
[
0
]
+
x
*
self
.
scale
[
0
]
*
grid_unit
,
self
.
translate
[
1
]
+
self
.
scale
[
1
]
*
self
.
build_dimensions
[
1
])
for
y
in
x
range
(
int
(
self
.
build_dimensions
[
1
]
/
grid_unit
)
+
1
):
for
y
in
range
(
int
(
self
.
build_dimensions
[
1
]
/
grid_unit
)
+
1
):
dc
.
DrawLine
(
self
.
translate
[
0
],
self
.
translate
[
1
]
+
y
*
self
.
scale
[
1
]
*
grid_unit
,
self
.
translate
[
0
]
+
self
.
scale
[
0
]
*
self
.
build_dimensions
[
0
],
self
.
translate
[
1
]
+
y
*
self
.
scale
[
1
]
*
grid_unit
)
dc
.
DrawLine
(
self
.
translate
[
0
],
self
.
translate
[
1
]
+
y
*
self
.
scale
[
1
]
*
grid_unit
,
self
.
translate
[
0
]
+
self
.
scale
[
0
]
*
self
.
build_dimensions
[
0
],
self
.
translate
[
1
]
+
y
*
self
.
scale
[
1
]
*
grid_unit
)
dc
.
SetPen
(
wx
.
Pen
(
wx
.
Colour
(
0
,
0
,
0
)))
dc
.
SetPen
(
wx
.
Pen
(
wx
.
Colour
(
0
,
0
,
0
)))
if
not
self
.
showall
:
if
not
self
.
showall
:
...
@@ -251,7 +251,7 @@ class gviz(wx.Panel):
...
@@ -251,7 +251,7 @@ class gviz(wx.Panel):
self
.
scale
[
1
]
*
x
[
1
]
+
self
.
translate
[
1
],
self
.
scale
[
1
]
*
x
[
1
]
+
self
.
translate
[
1
],
self
.
scale
[
0
]
*
x
[
2
]
+
self
.
translate
[
0
],
self
.
scale
[
0
]
*
x
[
2
]
+
self
.
translate
[
0
],
self
.
scale
[
1
]
*
x
[
3
]
+
self
.
translate
[
1
],)
self
.
scale
[
1
]
*
x
[
3
]
+
self
.
translate
[
1
],)
scaled_lines
=
map
(
_scaler
,
lines
)
scaled_lines
=
list
(
map
(
_scaler
,
lines
)
)
dc
.
DrawLineList
(
scaled_lines
,
pens
)
dc
.
DrawLineList
(
scaled_lines
,
pens
)
def
_drawarcs
(
arcs
,
pens
):
def
_drawarcs
(
arcs
,
pens
):
...
@@ -262,7 +262,7 @@ class gviz(wx.Panel):
...
@@ -262,7 +262,7 @@ class gviz(wx.Panel):
self
.
scale
[
1
]
*
x
[
3
]
+
self
.
translate
[
1
],
self
.
scale
[
1
]
*
x
[
3
]
+
self
.
translate
[
1
],
self
.
scale
[
0
]
*
x
[
4
]
+
self
.
translate
[
0
],
self
.
scale
[
0
]
*
x
[
4
]
+
self
.
translate
[
0
],
self
.
scale
[
1
]
*
x
[
5
]
+
self
.
translate
[
1
],)
self
.
scale
[
1
]
*
x
[
5
]
+
self
.
translate
[
1
],)
scaled_arcs
=
map
(
_scaler
,
arcs
)
scaled_arcs
=
list
(
map
(
_scaler
,
arcs
)
)
for
i
in
range
(
len
(
scaled_arcs
)):
for
i
in
range
(
len
(
scaled_arcs
)):
dc
.
SetPen
(
pens
[
i
]
if
type
(
pens
)
.
__name__
==
'list'
else
pens
)
dc
.
SetPen
(
pens
[
i
]
if
type
(
pens
)
.
__name__
==
'list'
else
pens
)
dc
.
SetBrush
(
wx
.
TRANSPARENT_BRUSH
)
dc
.
SetBrush
(
wx
.
TRANSPARENT_BRUSH
)
...
@@ -275,8 +275,8 @@ class gviz(wx.Panel):
...
@@ -275,8 +275,8 @@ class gviz(wx.Panel):
_drawlines
(
self
.
lines
[
i
],
self
.
pens
[
i
])
_drawlines
(
self
.
lines
[
i
],
self
.
pens
[
i
])
_drawarcs
(
self
.
arcs
[
i
],
self
.
arcpens
[
i
])
_drawarcs
(
self
.
arcs
[
i
],
self
.
arcpens
[
i
])
return
return
if
self
.
layerindex
<
len
(
self
.
layers
)
and
self
.
layers
[
self
.
layerindex
]
in
self
.
lines
.
keys
(
):
if
self
.
layerindex
<
len
(
self
.
layers
)
and
self
.
layers
[
self
.
layerindex
]
in
list
(
self
.
lines
.
keys
()
):
for
layer_i
in
x
range
(
max
(
0
,
self
.
layerindex
-
6
),
self
.
layerindex
):
for
layer_i
in
range
(
max
(
0
,
self
.
layerindex
-
6
),
self
.
layerindex
):
#print i, self.layerindex, self.layerindex-i
#print i, self.layerindex, self.layerindex-i
_drawlines
(
self
.
lines
[
self
.
layers
[
layer_i
]],
self
.
fades
[
self
.
layerindex
-
layer_i
-
1
])
_drawlines
(
self
.
lines
[
self
.
layers
[
layer_i
]],
self
.
fades
[
self
.
layerindex
-
layer_i
-
1
])
_drawarcs
(
self
.
arcs
[
self
.
layers
[
layer_i
]],
self
.
fades
[
self
.
layerindex
-
layer_i
-
1
])
_drawarcs
(
self
.
arcs
[
self
.
layers
[
layer_i
]],
self
.
fades
[
self
.
layerindex
-
layer_i
-
1
])
...
...
printrun/printrun_utils.py
View file @
ce8c3f3c
...
@@ -20,11 +20,11 @@ import gettext
...
@@ -20,11 +20,11 @@ import gettext
# searching for installed locales on /usr/share; uses relative folder if not found (windows)
# searching for installed locales on /usr/share; uses relative folder if not found (windows)
def
install_locale
(
domain
):
def
install_locale
(
domain
):
if
os
.
path
.
exists
(
'/usr/share/pronterface/locale'
):
if
os
.
path
.
exists
(
'/usr/share/pronterface/locale'
):
gettext
.
install
(
domain
,
'/usr/share/pronterface/locale'
,
unicode
=
1
)
gettext
.
install
(
domain
,
'/usr/share/pronterface/locale'
)
elif
os
.
path
.
exists
(
'/usr/local/share/pronterface/locale'
):
elif
os
.
path
.
exists
(
'/usr/local/share/pronterface/locale'
):
gettext
.
install
(
domain
,
'/usr/local/share/pronterface/locale'
,
unicode
=
1
)
gettext
.
install
(
domain
,
'/usr/local/share/pronterface/locale'
)
else
:
else
:
gettext
.
install
(
domain
,
'./locale'
,
unicode
=
1
)
gettext
.
install
(
domain
,
'./locale'
)
def
imagefile
(
filename
):
def
imagefile
(
filename
):
for
prefix
in
[
'/usr/local/share/pronterface/images'
,
'/usr/share/pronterface/images'
]:
for
prefix
in
[
'/usr/local/share/pronterface/images'
,
'/usr/share/pronterface/images'
]:
...
...
printrun/projectlayer.py
View file @
ce8c3f3c
...
@@ -55,7 +55,7 @@ class dispframe(wx.Frame):
...
@@ -55,7 +55,7 @@ class dispframe(wx.Frame):
if
self
.
slicer
==
'Skeinforge'
:
if
self
.
slicer
==
'Skeinforge'
:
for
i
in
image
:
for
i
in
image
:
#print i
#print i
points
=
[
wx
.
Point
(
*
map
(
lambda
x
:
int
(
round
(
float
(
x
)
*
self
.
scale
)),
j
.
strip
()
.
split
())
)
for
j
in
i
.
strip
()
.
split
(
"M"
)[
1
]
.
split
(
"L"
)]
points
=
[
wx
.
Point
(
*
[
int
(
round
(
float
(
x
)
*
self
.
scale
))
for
x
in
j
.
strip
()
.
split
()]
)
for
j
in
i
.
strip
()
.
split
(
"M"
)[
1
]
.
split
(
"L"
)]
dc
.
DrawPolygon
(
points
,
self
.
size
[
0
]
/
2
,
self
.
size
[
1
]
/
2
)
dc
.
DrawPolygon
(
points
,
self
.
size
[
0
]
/
2
,
self
.
size
[
1
]
/
2
)
elif
self
.
slicer
==
'Slic3r'
:
elif
self
.
slicer
==
'Slic3r'
:
gc
=
wx
.
GraphicsContext_Create
(
dc
)
gc
=
wx
.
GraphicsContext_Create
(
dc
)
...
@@ -90,12 +90,12 @@ class dispframe(wx.Frame):
...
@@ -90,12 +90,12 @@ class dispframe(wx.Frame):
if
self
.
index
<
len
(
self
.
layers
):
if
self
.
index
<
len
(
self
.
layers
):
i
=
self
.
index
i
=
self
.
index
print
i
print
(
i
)
wx
.
CallAfter
(
self
.
showimgdelay
,
self
.
layers
[
i
])
wx
.
CallAfter
(
self
.
showimgdelay
,
self
.
layers
[
i
])
wx
.
FutureCall
(
1000
*
self
.
interval
,
self
.
pic
.
Hide
)
wx
.
FutureCall
(
1000
*
self
.
interval
,
self
.
pic
.
Hide
)
self
.
index
+=
1
self
.
index
+=
1
else
:
else
:
print
"end"
print
(
"end"
)
wx
.
CallAfter
(
self
.
pic
.
Hide
)
wx
.
CallAfter
(
self
.
pic
.
Hide
)
wx
.
CallAfter
(
self
.
Refresh
)
wx
.
CallAfter
(
self
.
Refresh
)
wx
.
CallAfter
(
self
.
ShowFullScreen
,
0
)
wx
.
CallAfter
(
self
.
ShowFullScreen
,
0
)
...
@@ -228,8 +228,8 @@ class setframe(wx.Frame):
...
@@ -228,8 +228,8 @@ class setframe(wx.Frame):
layers
=
self
.
parsesvg
(
name
)
layers
=
self
.
parsesvg
(
name
)
layerHeight
=
layers
[
1
]
layerHeight
=
layers
[
1
]
self
.
thickness
.
SetValue
(
str
(
layers
[
1
]))
self
.
thickness
.
SetValue
(
str
(
layers
[
1
]))
print
"Layer thickness detected:"
,
layerHeight
,
"mm"
print
(
"Layer thickness detected:"
,
layerHeight
,
"mm"
)
print
len
(
layers
[
0
]),
"layers found, total height"
,
layerHeight
*
len
(
layers
[
0
]),
"mm"
print
(
len
(
layers
[
0
]),
"layers found, total height"
,
layerHeight
*
len
(
layers
[
0
]),
"mm"
)
self
.
layers
=
layers
self
.
layers
=
layers
self
.
f
.
slicer
=
layers
[
2
]
self
.
f
.
slicer
=
layers
[
2
]
dlg
.
Destroy
()
dlg
.
Destroy
()
...
...
printrun/pronterface_widgets.py
View file @
ce8c3f3c
...
@@ -146,7 +146,7 @@ class options(wx.Dialog):
...
@@ -146,7 +146,7 @@ class options(wx.Dialog):
topsizer
.
Layout
()
topsizer
.
Layout
()
topsizer
.
Fit
(
self
)
topsizer
.
Fit
(
self
)
if
self
.
ShowModal
()
==
wx
.
ID_OK
:
if
self
.
ShowModal
()
==
wx
.
ID_OK
:
for
k
,
v
in
pronterface
.
settings
.
_all_settings
()
.
items
(
):
for
k
,
v
in
list
(
pronterface
.
settings
.
_all_settings
()
.
items
()
):
if
ctrls
[
k
,
1
]
.
GetValue
()
!=
str
(
v
):
if
ctrls
[
k
,
1
]
.
GetValue
()
!=
str
(
v
):
pronterface
.
set
(
k
,
str
(
ctrls
[
k
,
1
]
.
GetValue
()))
pronterface
.
set
(
k
,
str
(
ctrls
[
k
,
1
]
.
GetValue
()))
self
.
Destroy
()
self
.
Destroy
()
...
@@ -185,9 +185,9 @@ class ButtonEdit(wx.Dialog):
...
@@ -185,9 +185,9 @@ class ButtonEdit(wx.Dialog):
try
:
try
:
if
macro
==
""
:
if
macro
==
""
:
valid
=
True
valid
=
True
elif
self
.
pronterface
.
macros
.
has_key
(
macro
)
:
elif
macro
in
self
.
pronterface
.
macros
:
valid
=
True
valid
=
True
elif
hasattr
(
self
.
pronterface
.
__class__
,
u
"do_"
+
macro
):
elif
hasattr
(
self
.
pronterface
.
__class__
,
"do_"
+
macro
):
valid
=
False
valid
=
False
elif
len
([
c
for
c
in
macro
if
not
c
.
isalnum
()
and
c
!=
"_"
]):
elif
len
([
c
for
c
in
macro
if
not
c
.
isalnum
()
and
c
!=
"_"
]):
valid
=
False
valid
=
False
...
@@ -196,7 +196,7 @@ class ButtonEdit(wx.Dialog):
...
@@ -196,7 +196,7 @@ class ButtonEdit(wx.Dialog):
except
:
except
:
if
macro
==
""
:
if
macro
==
""
:
valid
=
True
valid
=
True
elif
self
.
pronterface
.
macros
.
has_key
(
macro
)
:
elif
macro
in
self
.
pronterface
.
macros
:
valid
=
True
valid
=
True
elif
len
([
c
for
c
in
macro
if
not
c
.
isalnum
()
and
c
!=
"_"
]):
elif
len
([
c
for
c
in
macro
if
not
c
.
isalnum
()
and
c
!=
"_"
]):
valid
=
False
valid
=
False
...
...
printrun/stltool.py
View file @
ce8c3f3c
...
@@ -22,10 +22,10 @@ def genfacet(v):
...
@@ -22,10 +22,10 @@ def genfacet(v):
veca
=
[
v
[
1
][
0
]
-
v
[
0
][
0
],
v
[
1
][
1
]
-
v
[
0
][
1
],
v
[
1
][
2
]
-
v
[
0
][
2
]]
veca
=
[
v
[
1
][
0
]
-
v
[
0
][
0
],
v
[
1
][
1
]
-
v
[
0
][
1
],
v
[
1
][
2
]
-
v
[
0
][
2
]]
vecb
=
[
v
[
2
][
0
]
-
v
[
1
][
0
],
v
[
2
][
1
]
-
v
[
1
][
1
],
v
[
2
][
2
]
-
v
[
1
][
2
]]
vecb
=
[
v
[
2
][
0
]
-
v
[
1
][
0
],
v
[
2
][
1
]
-
v
[
1
][
1
],
v
[
2
][
2
]
-
v
[
1
][
2
]]
vecx
=
cross
(
veca
,
vecb
)
vecx
=
cross
(
veca
,
vecb
)
vlen
=
math
.
sqrt
(
sum
(
map
(
lambda
x
:
x
*
x
,
vecx
)
))
vlen
=
math
.
sqrt
(
sum
(
[
x
*
x
for
x
in
vecx
]
))
if
vlen
==
0
:
if
vlen
==
0
:
vlen
=
1
vlen
=
1
normal
=
map
(
lambda
x
:
x
/
vlen
,
vecx
)
normal
=
[
x
/
vlen
for
x
in
vecx
]
return
[
normal
,
v
]
return
[
normal
,
v
]
I
=
[
I
=
[
...
@@ -36,16 +36,16 @@ I = [
...
@@ -36,16 +36,16 @@ I = [
]
]
def
transpose
(
matrix
):
def
transpose
(
matrix
):
return
zip
(
*
matrix
)
return
list
(
zip
(
*
matrix
)
)
#return [[v[i] for v in matrix] for i in xrange(len(matrix[0]))]
#return [[v[i] for v in matrix] for i in xrange(len(matrix[0]))]
def
multmatrix
(
vector
,
matrix
):
def
multmatrix
(
vector
,
matrix
):
return
map
(
sum
,
transpose
(
map
(
lambda
x
:[
x
[
0
]
*
p
for
p
in
x
[
1
]],
zip
(
vector
,
transpose
(
matrix
))
)))
return
list
(
map
(
sum
,
transpose
([[
x
[
0
]
*
p
for
p
in
x
[
1
]]
for
x
in
zip
(
vector
,
transpose
(
matrix
))]
)))
def
applymatrix
(
facet
,
matrix
=
I
):
def
applymatrix
(
facet
,
matrix
=
I
):
#return facet
#return facet
#return [map(lambda x:-1.0*x, multmatrix(facet[0]+[1], matrix)[:3]), map(lambda x:multmatrix(x+[1], matrix)[:3], facet[1])]
#return [map(lambda x:-1.0*x, multmatrix(facet[0]+[1], matrix)[:3]), map(lambda x:multmatrix(x+[1], matrix)[:3], facet[1])]
return
genfacet
(
map
(
lambda
x
:
multmatrix
(
x
+
[
1
],
matrix
)[:
3
],
facet
[
1
])
)
return
genfacet
(
[
multmatrix
(
x
+
[
1
],
matrix
)[:
3
]
for
x
in
facet
[
1
]]
)
f
=
[[
0
,
0
,
0
],[[
-
3.022642
,
0.642482
,
-
9.510565
],[
-
3.022642
,
0.642482
,
-
9.510565
],[
-
3.022642
,
0.642482
,
-
9.510565
]]]
f
=
[[
0
,
0
,
0
],[[
-
3.022642
,
0.642482
,
-
9.510565
],[
-
3.022642
,
0.642482
,
-
9.510565
],[
-
3.022642
,
0.642482
,
-
9.510565
]]]
m
=
[
m
=
[
...
@@ -104,7 +104,7 @@ class stl:
...
@@ -104,7 +104,7 @@ class stl:
return
return
self
.
f
=
list
(
open
(
filename
))
self
.
f
=
list
(
open
(
filename
))
if
not
self
.
f
[
0
]
.
startswith
(
"solid"
):
if
not
self
.
f
[
0
]
.
startswith
(
"solid"
):
print
"Not an ascii stl solid - attempting to parse as binary"
print
(
"Not an ascii stl solid - attempting to parse as binary"
)
f
=
open
(
filename
,
"rb"
)
f
=
open
(
filename
,
"rb"
)
buf
=
f
.
read
(
84
)
buf
=
f
.
read
(
84
)
while
(
len
(
buf
)
<
84
):
while
(
len
(
buf
)
<
84
):
...
@@ -114,7 +114,7 @@ class stl:
...
@@ -114,7 +114,7 @@ class stl:
buf
+=
newdata
buf
+=
newdata
facetcount
=
struct
.
unpack_from
(
"<I"
,
buf
,
80
)
facetcount
=
struct
.
unpack_from
(
"<I"
,
buf
,
80
)
facetformat
=
struct
.
Struct
(
"<ffffffffffffH"
)
facetformat
=
struct
.
Struct
(
"<ffffffffffffH"
)
for
i
in
x
range
(
facetcount
[
0
]):
for
i
in
range
(
facetcount
[
0
]):
buf
=
f
.
read
(
50
)
buf
=
f
.
read
(
50
)
while
(
len
(
buf
)
<
50
):
while
(
len
(
buf
)
<
50
):
newdata
=
f
.
read
(
50
-
len
(
buf
))
newdata
=
f
.
read
(
50
-
len
(
buf
))
...
@@ -126,8 +126,8 @@ class stl:
...
@@ -126,8 +126,8 @@ class stl:
self
.
facet
=
[
fd
[:
3
],[
fd
[
3
:
6
],
fd
[
6
:
9
],
fd
[
9
:
12
]]]
self
.
facet
=
[
fd
[:
3
],[
fd
[
3
:
6
],
fd
[
6
:
9
],
fd
[
9
:
12
]]]
self
.
facets
+=
[
self
.
facet
]
self
.
facets
+=
[
self
.
facet
]
facet
=
self
.
facet
facet
=
self
.
facet
self
.
facetsminz
+=
[(
min
(
map
(
lambda
x
:
x
[
2
],
facet
[
1
])
),
facet
)]
self
.
facetsminz
+=
[(
min
(
[
x
[
2
]
for
x
in
facet
[
1
]]
),
facet
)]
self
.
facetsmaxz
+=
[(
max
(
map
(
lambda
x
:
x
[
2
],
facet
[
1
])
),
facet
)]
self
.
facetsmaxz
+=
[(
max
(
[
x
[
2
]
for
x
in
facet
[
1
]]
),
facet
)]
f
.
close
()
f
.
close
()
return
return
for
i
in
self
.
f
:
for
i
in
self
.
f
:
...
@@ -187,8 +187,8 @@ class stl:
...
@@ -187,8 +187,8 @@ class stl:
s
.
facetloc
=
0
s
.
facetloc
=
0
s
.
name
=
self
.
name
s
.
name
=
self
.
name
for
facet
in
s
.
facets
:
for
facet
in
s
.
facets
:
s
.
facetsminz
+=
[(
min
(
map
(
lambda
x
:
x
[
2
],
facet
[
1
])
),
facet
)]
s
.
facetsminz
+=
[(
min
(
[
x
[
2
]
for
x
in
facet
[
1
]]
),
facet
)]
s
.
facetsmaxz
+=
[(
max
(
map
(
lambda
x
:
x
[
2
],
facet
[
1
])
),
facet
)]
s
.
facetsmaxz
+=
[(
max
(
[
x
[
2
]
for
x
in
facet
[
1
]]
),
facet
)]
return
s
return
s
def
export
(
self
,
f
=
sys
.
stdout
):
def
export
(
self
,
f
=
sys
.
stdout
):
...
@@ -218,21 +218,21 @@ class stl:
...
@@ -218,21 +218,21 @@ class stl:
self
.
infacet
=
11
self
.
infacet
=
11
self
.
facetloc
=
0
self
.
facetloc
=
0
self
.
facet
=
[[
0
,
0
,
0
],[[
0
,
0
,
0
],[
0
,
0
,
0
],[
0
,
0
,
0
]]]
self
.
facet
=
[[
0
,
0
,
0
],[[
0
,
0
,
0
],[
0
,
0
,
0
],[
0
,
0
,
0
]]]
self
.
facet
[
0
]
=
map
(
float
,
l
.
split
()[
2
:]
)
self
.
facet
[
0
]
=
list
(
map
(
float
,
l
.
split
()[
2
:])
)
elif
l
.
startswith
(
"endfacet"
):
elif
l
.
startswith
(
"endfacet"
):
self
.
infacet
=
0
self
.
infacet
=
0
self
.
facets
+=
[
self
.
facet
]
self
.
facets
+=
[
self
.
facet
]
facet
=
self
.
facet
facet
=
self
.
facet
self
.
facetsminz
+=
[(
min
(
map
(
lambda
x
:
x
[
2
],
facet
[
1
])
),
facet
)]
self
.
facetsminz
+=
[(
min
(
[
x
[
2
]
for
x
in
facet
[
1
]]
),
facet
)]
self
.
facetsmaxz
+=
[(
max
(
map
(
lambda
x
:
x
[
2
],
facet
[
1
])
),
facet
)]
self
.
facetsmaxz
+=
[(
max
(
[
x
[
2
]
for
x
in
facet
[
1
]]
),
facet
)]
elif
l
.
startswith
(
"vertex"
):
elif
l
.
startswith
(
"vertex"
):
l
=
l
.
replace
(
", "
,
"."
)
l
=
l
.
replace
(
", "
,
"."
)
self
.
facet
[
1
][
self
.
facetloc
]
=
map
(
float
,
l
.
split
()[
1
:]
)
self
.
facet
[
1
][
self
.
facetloc
]
=
list
(
map
(
float
,
l
.
split
()[
1
:])
)
self
.
facetloc
+=
1
self
.
facetloc
+=
1
return
1
return
1
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
s
=
stl
(
"../../Downloads/frame-vertex-neo-foot-x4.stl"
)
s
=
stl
(
"../../Downloads/frame-vertex-neo-foot-x4.stl"
)
for
i
in
x
range
(
11
,
11
):
for
i
in
range
(
11
,
11
):
working
=
s
.
facets
[:]
working
=
s
.
facets
[:]
for
j
in
reversed
(
sorted
(
s
.
facetsminz
)):
for
j
in
reversed
(
sorted
(
s
.
facetsminz
)):
if
(
j
[
0
]
>
i
):
if
(
j
[
0
]
>
i
):
...
@@ -245,6 +245,6 @@ if __name__ == "__main__":
...
@@ -245,6 +245,6 @@ if __name__ == "__main__":
else
:
else
:
break
break
print
i
,
len
(
working
)
print
(
i
,
len
(
working
)
)
emitstl
(
"../../Downloads/frame-vertex-neo-foot-x4-a.stl"
,
s
.
facets
,
"emitted_object"
)
emitstl
(
"../../Downloads/frame-vertex-neo-foot-x4-a.stl"
,
s
.
facets
,
"emitted_object"
)
#stl("../prusamendel/stl/mendelplate.stl")
#stl("../prusamendel/stl/mendelplate.stl")
printrun/stlview.py
View file @
ce8c3f3c
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
import
os
import
os
import
math
import
math
import
stltool
from
.
import
stltool
import
wx
import
wx
from
wx
import
glcanvas
from
wx
import
glcanvas
import
time
import
time
...
@@ -215,7 +215,7 @@ class stlview(object):
...
@@ -215,7 +215,7 @@ class stlview(object):
normals
.
extend
(
i
[
0
])
normals
.
extend
(
i
[
0
])
# Create a list of triangle indices.
# Create a list of triangle indices.
indices
=
range
(
3
*
len
(
facets
))
# [[3*i, 3*i+1, 3*i+2] for i in xrange(len(facets))]
indices
=
list
(
range
(
3
*
len
(
facets
)
))
# [[3*i, 3*i+1, 3*i+2] for i in xrange(len(facets))]
#print indices[:10]
#print indices[:10]
self
.
vertex_list
=
batch
.
add_indexed
(
len
(
vertices
)
//
3
,
self
.
vertex_list
=
batch
.
add_indexed
(
len
(
vertices
)
//
3
,
GL_TRIANGLES
,
GL_TRIANGLES
,
...
@@ -244,7 +244,7 @@ class gcview(object):
...
@@ -244,7 +244,7 @@ class gcview(object):
t0
=
time
.
time
()
t0
=
time
.
time
()
lines
=
[
self
.
transform
(
i
)
for
i
in
lines
]
lines
=
[
self
.
transform
(
i
)
for
i
in
lines
]
lines
=
[
i
for
i
in
lines
if
i
is
not
None
]
lines
=
[
i
for
i
in
lines
if
i
is
not
None
]
print
"transformed lines in
%
fs"
%
(
time
.
time
()
-
t0
)
print
(
"transformed lines in
%
fs"
%
(
time
.
time
()
-
t0
)
)
t0
=
time
.
time
()
t0
=
time
.
time
()
layertemp
=
{}
layertemp
=
{}
lasth
=
None
lasth
=
None
...
@@ -258,7 +258,7 @@ class gcview(object):
...
@@ -258,7 +258,7 @@ class gcview(object):
if
lasth
is
not
None
:
if
lasth
is
not
None
:
self
.
layers
[
lasth
]
=
pyglet
.
graphics
.
Batch
()
self
.
layers
[
lasth
]
=
pyglet
.
graphics
.
Batch
()
lt
=
layertemp
[
lasth
][
0
]
lt
=
layertemp
[
lasth
][
0
]
indices
=
range
(
len
(
layertemp
[
lasth
][
0
])
//
3
)
# [[3*i, 3*i+1, 3*i+2] for i in xrange(len(facets))]
indices
=
list
(
range
(
len
(
layertemp
[
lasth
][
0
])
//
3
)
)
# [[3*i, 3*i+1, 3*i+2] for i in xrange(len(facets))]
self
.
vlists
.
append
(
self
.
layers
[
lasth
]
.
add_indexed
(
len
(
layertemp
[
lasth
][
0
])
//
3
,
self
.
vlists
.
append
(
self
.
layers
[
lasth
]
.
add_indexed
(
len
(
layertemp
[
lasth
][
0
])
//
3
,
GL_TRIANGLES
,
GL_TRIANGLES
,
None
,
# group,
None
,
# group,
...
@@ -277,26 +277,26 @@ class gcview(object):
...
@@ -277,26 +277,26 @@ class gcview(object):
epoints
[
j
],
epoints
[
j
],
spoints
[(
j
+
1
)
%
8
],
spoints
[(
j
+
1
)
%
8
],
epoints
[(
j
+
1
)
%
8
]
epoints
[(
j
+
1
)
%
8
]
]
for
j
in
x
range
(
8
)]
]
for
j
in
range
(
8
)]
normalstoadd
=
[
map
(
vdiff
,
v
,
[
S
,
E
,
S
,
E
,
S
,
E
]
)
for
v
in
verticestoadd
]
normalstoadd
=
[
list
(
map
(
vdiff
,
v
,
[
S
,
E
,
S
,
E
,
S
,
E
])
)
for
v
in
verticestoadd
]
v1
=
[]
v1
=
[]
map
(
v1
.
extend
,
verticestoadd
)
list
(
map
(
v1
.
extend
,
verticestoadd
)
)
v2
=
[]
v2
=
[]
map
(
v2
.
extend
,
v1
)
list
(
map
(
v2
.
extend
,
v1
)
)
n1
=
[]
n1
=
[]
map
(
n1
.
extend
,
normalstoadd
)
list
(
map
(
n1
.
extend
,
normalstoadd
)
)
n2
=
[]
n2
=
[]
map
(
n2
.
extend
,
n1
)
list
(
map
(
n2
.
extend
,
n1
)
)
layertemp
[
i
[
0
][
2
]][
0
]
+=
v2
layertemp
[
i
[
0
][
2
]][
0
]
+=
v2
vertices
+=
v2
vertices
+=
v2
layertemp
[
i
[
0
][
2
]][
1
]
+=
n2
layertemp
[
i
[
0
][
2
]][
1
]
+=
n2
normals
+=
n2
normals
+=
n2
print
"appended lines in
%
fs"
%
(
time
.
time
()
-
t0
)
print
(
"appended lines in
%
fs"
%
(
time
.
time
()
-
t0
)
)
t0
=
time
.
time
()
t0
=
time
.
time
()
# Create a list of triangle indices.
# Create a list of triangle indices.
indices
=
range
(
3
*
16
*
len
(
lines
))
# [[3*i, 3*i+1, 3*i+2] for i in xrange(len(facets))]
indices
=
list
(
range
(
3
*
16
*
len
(
lines
)
))
# [[3*i, 3*i+1, 3*i+2] for i in xrange(len(facets))]
self
.
vlists
.
append
(
batch
.
add_indexed
(
len
(
vertices
)
//
3
,
self
.
vlists
.
append
(
batch
.
add_indexed
(
len
(
vertices
)
//
3
,
GL_TRIANGLES
,
GL_TRIANGLES
,
None
,
# group,
None
,
# group,
...
@@ -305,7 +305,7 @@ class gcview(object):
...
@@ -305,7 +305,7 @@ class gcview(object):
(
'n3f/static'
,
normals
)))
(
'n3f/static'
,
normals
)))
if
lasth
is
not
None
:
if
lasth
is
not
None
:
self
.
layers
[
lasth
]
=
pyglet
.
graphics
.
Batch
()
self
.
layers
[
lasth
]
=
pyglet
.
graphics
.
Batch
()
indices
=
range
(
len
(
layertemp
[
lasth
][
0
]
))
# [[3*i, 3*i+1, 3*i+2] for i in xrange(len(facets))]
indices
=
list
(
range
(
len
(
layertemp
[
lasth
][
0
])
))
# [[3*i, 3*i+1, 3*i+2] for i in xrange(len(facets))]
self
.
vlists
.
append
(
self
.
layers
[
lasth
]
.
add_indexed
(
len
(
layertemp
[
lasth
][
0
])
//
3
,
self
.
vlists
.
append
(
self
.
layers
[
lasth
]
.
add_indexed
(
len
(
layertemp
[
lasth
][
0
])
//
3
,
GL_TRIANGLES
,
GL_TRIANGLES
,
None
,
# group,
None
,
# group,
...
@@ -316,8 +316,8 @@ class gcview(object):
...
@@ -316,8 +316,8 @@ class gcview(object):
def
genline
(
self
,
i
,
h
,
w
):
def
genline
(
self
,
i
,
h
,
w
):
S
=
i
[
0
][:
3
]
S
=
i
[
0
][:
3
]
E
=
i
[
1
][:
3
]
E
=
i
[
1
][:
3
]
v
=
map
(
lambda
x
,
y
:
x
-
y
,
E
,
S
)
v
=
list
(
map
(
lambda
x
,
y
:
x
-
y
,
E
,
S
)
)
vlen
=
math
.
sqrt
(
float
(
sum
(
map
(
lambda
a
:
a
*
a
,
v
[:
3
])
)))
vlen
=
math
.
sqrt
(
float
(
sum
(
[
a
*
a
for
a
in
v
[:
3
]]
)))
if
vlen
==
0
:
if
vlen
==
0
:
vlen
=
0.01
vlen
=
0.01
...
@@ -336,23 +336,23 @@ class gcview(object):
...
@@ -336,23 +336,23 @@ class gcview(object):
[
sq2
*
d
,
-
sq2
*
d
,
0
]
[
sq2
*
d
,
-
sq2
*
d
,
0
]
]
]
axis
=
stltool
.
cross
([
0
,
0
,
1
],
v
)
axis
=
stltool
.
cross
([
0
,
0
,
1
],
v
)
alen
=
math
.
sqrt
(
float
(
sum
(
map
(
lambda
a
:
a
*
a
,
v
[:
3
])
)))
alen
=
math
.
sqrt
(
float
(
sum
(
[
a
*
a
for
a
in
v
[:
3
]]
)))
if
alen
>
0
:
if
alen
>
0
:
axis
=
map
(
lambda
m
:
m
/
alen
,
axis
)
axis
=
[
m
/
alen
for
m
in
axis
]
angle
=
math
.
acos
(
v
[
2
]
/
vlen
)
angle
=
math
.
acos
(
v
[
2
]
/
vlen
)
def
vrot
(
v
,
axis
,
angle
):
def
vrot
(
v
,
axis
,
angle
):
kxv
=
stltool
.
cross
(
axis
,
v
)
kxv
=
stltool
.
cross
(
axis
,
v
)
kdv
=
sum
(
map
(
lambda
x
,
y
:
x
*
y
,
axis
,
v
))
kdv
=
sum
(
map
(
lambda
x
,
y
:
x
*
y
,
axis
,
v
))
return
map
(
lambda
x
,
y
,
z
:
x
*
math
.
cos
(
angle
)
+
y
*
math
.
sin
(
angle
)
+
z
*
kdv
*
(
1.0
-
math
.
cos
(
angle
)),
v
,
kxv
,
axis
)
return
list
(
map
(
lambda
x
,
y
,
z
:
x
*
math
.
cos
(
angle
)
+
y
*
math
.
sin
(
angle
)
+
z
*
kdv
*
(
1.0
-
math
.
cos
(
angle
)),
v
,
kxv
,
axis
)
)
points
=
map
(
lambda
x
:
vrot
(
x
,
axis
,
angle
),
points
)
points
=
[
vrot
(
x
,
axis
,
angle
)
for
x
in
points
]
points
=
map
(
lambda
x
:
[
x
[
0
],
x
[
1
],
htw
*
x
[
2
]],
points
)
points
=
[[
x
[
0
],
x
[
1
],
htw
*
x
[
2
]]
for
x
in
points
]
def
vadd
(
v
,
o
):
def
vadd
(
v
,
o
):
return
map
(
sum
,
zip
(
v
,
o
))
return
list
(
map
(
sum
,
list
(
zip
(
v
,
o
))
))
spoints
=
map
(
lambda
x
:
vadd
(
S
,
x
),
points
)
spoints
=
[
vadd
(
S
,
x
)
for
x
in
points
]
epoints
=
map
(
lambda
x
:
vadd
(
E
,
x
),
points
)
epoints
=
[
vadd
(
E
,
x
)
for
x
in
points
]
return
spoints
,
epoints
,
S
,
E
return
spoints
,
epoints
,
S
,
E
def
transform
(
self
,
line
):
def
transform
(
self
,
line
):
...
@@ -399,8 +399,8 @@ def trackball(p1x, p1y, p2x, p2y, r):
...
@@ -399,8 +399,8 @@ def trackball(p1x, p1y, p2x, p2y, r):
p2
=
[
p2x
,
p2y
,
project_to_sphere
(
TRACKBALLSIZE
,
p2x
,
p2y
)]
p2
=
[
p2x
,
p2y
,
project_to_sphere
(
TRACKBALLSIZE
,
p2x
,
p2y
)]
a
=
stltool
.
cross
(
p2
,
p1
)
a
=
stltool
.
cross
(
p2
,
p1
)
d
=
map
(
lambda
x
,
y
:
x
-
y
,
p1
,
p2
)
d
=
list
(
map
(
lambda
x
,
y
:
x
-
y
,
p1
,
p2
)
)
t
=
math
.
sqrt
(
sum
(
map
(
lambda
x
:
x
*
x
,
d
)
))
/
(
2.0
*
TRACKBALLSIZE
)
t
=
math
.
sqrt
(
sum
(
[
x
*
x
for
x
in
d
]
))
/
(
2.0
*
TRACKBALLSIZE
)
if
(
t
>
1.0
):
if
(
t
>
1.0
):
t
=
1.0
t
=
1.0
...
@@ -417,9 +417,9 @@ def vec(*args):
...
@@ -417,9 +417,9 @@ def vec(*args):
def
axis_to_quat
(
a
,
phi
):
def
axis_to_quat
(
a
,
phi
):
#print a, phi
#print a, phi
lena
=
math
.
sqrt
(
sum
(
map
(
lambda
x
:
x
*
x
,
a
)
))
lena
=
math
.
sqrt
(
sum
(
[
x
*
x
for
x
in
a
]
))
q
=
map
(
lambda
x
:
x
*
(
1
/
lena
),
a
)
q
=
[
x
*
(
1
/
lena
)
for
x
in
a
]
q
=
map
(
lambda
x
:
x
*
math
.
sin
(
phi
/
2.0
),
q
)
q
=
[
x
*
math
.
sin
(
phi
/
2.0
)
for
x
in
q
]
q
.
append
(
math
.
cos
(
phi
/
2.0
))
q
.
append
(
math
.
cos
(
phi
/
2.0
))
return
q
return
q
...
@@ -486,11 +486,11 @@ class TestGlPanel(GLPanel):
...
@@ -486,11 +486,11 @@ class TestGlPanel(GLPanel):
def
double
(
self
,
event
):
def
double
(
self
,
event
):
p
=
event
.
GetPositionTuple
()
p
=
event
.
GetPositionTuple
()
sz
=
self
.
GetClientSize
()
sz
=
self
.
GetClientSize
()
v
=
map
(
lambda
m
,
w
,
b
:
b
*
m
/
w
,
p
,
sz
,
self
.
bedsize
)
v
=
list
(
map
(
lambda
m
,
w
,
b
:
b
*
m
/
w
,
p
,
sz
,
self
.
bedsize
)
)
v
[
1
]
=
self
.
bedsize
[
1
]
-
v
[
1
]
v
[
1
]
=
self
.
bedsize
[
1
]
-
v
[
1
]
v
+=
[
300
]
v
+=
[
300
]
print
"Double-click at "
+
str
(
v
)
+
" in "
print
(
"Double-click at "
+
str
(
v
)
+
" in "
)
print
self
print
(
self
)
def
forceresize
(
self
):
def
forceresize
(
self
):
self
.
SetClientSize
((
self
.
GetClientSize
()[
0
],
self
.
GetClientSize
()[
1
]
+
1
))
self
.
SetClientSize
((
self
.
GetClientSize
()[
0
],
self
.
GetClientSize
()[
1
]
+
1
))
...
@@ -581,7 +581,7 @@ class TestGlPanel(GLPanel):
...
@@ -581,7 +581,7 @@ class TestGlPanel(GLPanel):
p1
[
1
]
*=
-
1
p1
[
1
]
*=
-
1
p2
[
1
]
*=
-
1
p2
[
1
]
*=
-
1
self
.
transv
=
map
(
lambda
x
,
y
,
z
,
c
:
c
-
self
.
dist
*
(
x
-
y
)
/
z
,
list
(
p1
)
+
[
0
],
list
(
p2
)
+
[
0
],
list
(
sz
)
+
[
1
],
self
.
transv
)
self
.
transv
=
list
(
map
(
lambda
x
,
y
,
z
,
c
:
c
-
self
.
dist
*
(
x
-
y
)
/
z
,
list
(
p1
)
+
[
0
],
list
(
p2
)
+
[
0
],
list
(
sz
)
+
[
1
],
self
.
transv
)
)
glLoadIdentity
()
glLoadIdentity
()
glTranslatef
(
self
.
transv
[
0
],
self
.
transv
[
1
],
0
)
glTranslatef
(
self
.
transv
[
0
],
self
.
transv
[
1
],
0
)
...
@@ -595,7 +595,7 @@ class TestGlPanel(GLPanel):
...
@@ -595,7 +595,7 @@ class TestGlPanel(GLPanel):
#mouse is moving without a button press
#mouse is moving without a button press
p
=
event
.
GetPositionTuple
()
p
=
event
.
GetPositionTuple
()
sz
=
self
.
GetClientSize
()
sz
=
self
.
GetClientSize
()
v
=
map
(
lambda
m
,
w
,
b
:
b
*
m
/
w
,
p
,
sz
,
self
.
bedsize
)
v
=
list
(
map
(
lambda
m
,
w
,
b
:
b
*
m
/
w
,
p
,
sz
,
self
.
bedsize
)
)
v
[
1
]
=
self
.
bedsize
[
1
]
-
v
[
1
]
v
[
1
]
=
self
.
bedsize
[
1
]
-
v
[
1
]
self
.
mousepos
=
v
self
.
mousepos
=
v
...
@@ -647,7 +647,7 @@ class TestGlPanel(GLPanel):
...
@@ -647,7 +647,7 @@ class TestGlPanel(GLPanel):
def
keypress
(
self
,
event
):
def
keypress
(
self
,
event
):
"""gets keypress events and moves/rotates acive shape"""
"""gets keypress events and moves/rotates acive shape"""
keycode
=
event
.
GetKeyCode
()
keycode
=
event
.
GetKeyCode
()
print
keycode
print
(
keycode
)
step
=
5
step
=
5
angle
=
18
angle
=
18
if
event
.
ControlDown
():
if
event
.
ControlDown
():
...
@@ -742,14 +742,14 @@ class TestGlPanel(GLPanel):
...
@@ -742,14 +742,14 @@ class TestGlPanel(GLPanel):
rows
=
10
rows
=
10
cols
=
10
cols
=
10
zheight
=
50
zheight
=
50
for
i
in
x
range
(
-
rows
,
rows
+
1
):
for
i
in
range
(
-
rows
,
rows
+
1
):
if
i
%
5
==
0
:
if
i
%
5
==
0
:
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_AMBIENT_AND_DIFFUSE
,
vec
(
0.6
,
0.6
,
0.6
,
1
))
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_AMBIENT_AND_DIFFUSE
,
vec
(
0.6
,
0.6
,
0.6
,
1
))
else
:
else
:
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_AMBIENT_AND_DIFFUSE
,
vec
(
0.2
,
0.2
,
0.2
,
1
))
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_AMBIENT_AND_DIFFUSE
,
vec
(
0.2
,
0.2
,
0.2
,
1
))
glVertex3f
(
10
*
-
cols
,
10
*
i
,
0
)
glVertex3f
(
10
*
-
cols
,
10
*
i
,
0
)
glVertex3f
(
10
*
cols
,
10
*
i
,
0
)
glVertex3f
(
10
*
cols
,
10
*
i
,
0
)
for
i
in
x
range
(
-
cols
,
cols
+
1
):
for
i
in
range
(
-
cols
,
cols
+
1
):
if
i
%
5
==
0
:
if
i
%
5
==
0
:
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_AMBIENT_AND_DIFFUSE
,
vec
(
0.6
,
0.6
,
0.6
,
1
))
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_AMBIENT_AND_DIFFUSE
,
vec
(
0.6
,
0.6
,
0.6
,
1
))
else
:
else
:
...
@@ -794,7 +794,7 @@ class TestGlPanel(GLPanel):
...
@@ -794,7 +794,7 @@ class TestGlPanel(GLPanel):
glPushMatrix
()
glPushMatrix
()
glTranslatef
(
-
100
,
-
100
,
0
)
glTranslatef
(
-
100
,
-
100
,
0
)
for
i
in
self
.
parent
.
models
.
values
(
):
for
i
in
list
(
self
.
parent
.
models
.
values
()
):
glPushMatrix
()
glPushMatrix
()
glTranslatef
(
*
(
i
.
offsets
))
glTranslatef
(
*
(
i
.
offsets
))
glRotatef
(
i
.
rot
,
0.0
,
0.0
,
1.0
)
glRotatef
(
i
.
rot
,
0.0
,
0.0
,
1.0
)
...
@@ -803,7 +803,7 @@ class TestGlPanel(GLPanel):
...
@@ -803,7 +803,7 @@ class TestGlPanel(GLPanel):
try
:
try
:
if
i
.
curlayer
in
i
.
gc
.
layers
:
if
i
.
curlayer
in
i
.
gc
.
layers
:
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_AMBIENT_AND_DIFFUSE
,
vec
(
0.13
,
0.37
,
0.25
,
1
))
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_AMBIENT_AND_DIFFUSE
,
vec
(
0.13
,
0.37
,
0.25
,
1
))
[
i
.
gc
.
layers
[
j
]
.
draw
()
for
j
in
i
.
gc
.
layers
.
keys
(
)
if
j
<
i
.
curlayer
]
[
i
.
gc
.
layers
[
j
]
.
draw
()
for
j
in
list
(
i
.
gc
.
layers
.
keys
()
)
if
j
<
i
.
curlayer
]
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_AMBIENT_AND_DIFFUSE
,
vec
(
0.5
,
0.6
,
0.9
,
1
))
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_AMBIENT_AND_DIFFUSE
,
vec
(
0.5
,
0.6
,
0.9
,
1
))
b
=
i
.
gc
.
layers
[
i
.
curlayer
]
b
=
i
.
gc
.
layers
[
i
.
curlayer
]
b
.
draw
()
b
.
draw
()
...
@@ -879,4 +879,4 @@ def main():
...
@@ -879,4 +879,4 @@ def main():
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
import
cProfile
import
cProfile
print
cProfile
.
run
(
"main()"
)
print
(
cProfile
.
run
(
"main()"
)
)
printrun/svg/attributes.py
View file @
ce8c3f3c
...
@@ -16,12 +16,12 @@
...
@@ -16,12 +16,12 @@
"""
"""
Parsers for specific attributes
Parsers for specific attributes
"""
"""
import
urlparse
import
url
lib.
parse
from
pyparsing
import
(
Literal
,
from
pyparsing
import
(
Literal
,
Optional
,
oneOf
,
Group
,
StringEnd
,
Combine
,
Word
,
alphas
,
hexnums
,
Optional
,
oneOf
,
Group
,
StringEnd
,
Combine
,
Word
,
alphas
,
hexnums
,
CaselessLiteral
,
SkipTo
CaselessLiteral
,
SkipTo
)
)
from
css.colour
import
colourValue
from
.
css.colour
import
colourValue
import
string
import
string
##Paint values
##Paint values
...
@@ -30,7 +30,7 @@ currentColor = CaselessLiteral("currentColor").setParseAction(lambda t: ["CURREN
...
@@ -30,7 +30,7 @@ currentColor = CaselessLiteral("currentColor").setParseAction(lambda t: ["CURREN
def
parsePossibleURL
(
t
):
def
parsePossibleURL
(
t
):
possibleURL
,
fallback
=
t
[
0
]
possibleURL
,
fallback
=
t
[
0
]
return
[
urlparse
.
urlsplit
(
possibleURL
),
fallback
]
return
[
url
lib
.
parse
.
urlsplit
(
possibleURL
),
fallback
]
#Normal color declaration
#Normal color declaration
colorDeclaration
=
none
|
currentColor
|
colourValue
colorDeclaration
=
none
|
currentColor
|
colourValue
...
...
printrun/svg/css/__init__.py
View file @
ce8c3f3c
...
@@ -13,6 +13,6 @@
...
@@ -13,6 +13,6 @@
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
from
__future__
import
absolute_import
from
.transform
import
transformList
from
.transform
import
transformList
from
.inline
import
inlineStyle
from
.inline
import
inlineStyle
printrun/svg/css/colour.py
View file @
ce8c3f3c
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
"""
"""
import
wx
import
wx
import
string
import
string
import
urlparse
import
url
lib.
parse
from
pyparsing
import
nums
,
Literal
,
Optional
,
oneOf
,
Group
,
StringEnd
,
Combine
,
Word
,
alphas
,
hexnums
from
pyparsing
import
nums
,
Literal
,
Optional
,
oneOf
,
Group
,
StringEnd
,
Combine
,
Word
,
alphas
,
hexnums
from
..pathdata
import
number
,
sign
from
..pathdata
import
number
,
sign
...
@@ -294,5 +294,5 @@ def fillCSS2SystemColours():
...
@@ -294,5 +294,5 @@ def fillCSS2SystemColours():
}
}
NamedColours
.
update
(
NamedColours
.
update
(
#strip the alpha from the system colors. Is this really what we want to do?
#strip the alpha from the system colors. Is this really what we want to do?
(
k
.
lower
(),
wx
.
SystemSettings
.
GetColour
(
v
)[:
3
])
for
(
k
,
v
)
in
systemColors
.
ite
rite
ms
()
(
k
.
lower
(),
wx
.
SystemSettings
.
GetColour
(
v
)[:
3
])
for
(
k
,
v
)
in
systemColors
.
items
()
)
)
printrun/svg/css/identifier.py
View file @
ce8c3f3c
...
@@ -27,11 +27,11 @@ class White(White):
...
@@ -27,11 +27,11 @@ class White(White):
escaped
=
(
escaped
=
(
Literal
(
"
\\
"
)
.
suppress
()
+
Literal
(
"
\\
"
)
.
suppress
()
+
#chr(20)-chr(126) + chr(128)-unichr(sys.maxunicode)
#chr(20)-chr(126) + chr(128)-unichr(sys.maxunicode)
Regex
(
u
"[
\u0020
-
\u007e\u0080
-
\uffff
]"
,
re
.
IGNORECASE
)
Regex
(
"[
\u0020
-
\u007e\u0080
-
\uffff
]"
,
re
.
IGNORECASE
)
)
)
def
convertToUnicode
(
t
):
def
convertToUnicode
(
t
):
return
uni
chr
(
int
(
t
[
0
],
16
))
return
chr
(
int
(
t
[
0
],
16
))
hex_unicode
=
(
hex_unicode
=
(
Literal
(
"
\\
"
)
.
suppress
()
+
Literal
(
"
\\
"
)
.
suppress
()
+
Regex
(
"[0-9a-f]{1,6}"
,
re
.
IGNORECASE
)
+
Regex
(
"[0-9a-f]{1,6}"
,
re
.
IGNORECASE
)
+
...
@@ -42,11 +42,11 @@ hex_unicode = (
...
@@ -42,11 +42,11 @@ hex_unicode = (
escape
=
hex_unicode
|
escaped
escape
=
hex_unicode
|
escaped
#any unicode literal outside the 0-127 ascii range
#any unicode literal outside the 0-127 ascii range
nonascii
=
Regex
(
u
"[^
\u0000
-
\u007f
]"
)
nonascii
=
Regex
(
"[^
\u0000
-
\u007f
]"
)
#single character for starting an identifier.
#single character for starting an identifier.
nmstart
=
Regex
(
u
"[A-Z]"
,
re
.
IGNORECASE
)
|
nonascii
|
escape
nmstart
=
Regex
(
"[A-Z]"
,
re
.
IGNORECASE
)
|
nonascii
|
escape
nmchar
=
Regex
(
u
"[0-9A-Z-]"
,
re
.
IGNORECASE
)
|
nonascii
|
escape
nmchar
=
Regex
(
"[0-9A-Z-]"
,
re
.
IGNORECASE
)
|
nonascii
|
escape
identifier
=
Combine
(
nmstart
+
ZeroOrMore
(
nmchar
))
identifier
=
Combine
(
nmstart
+
ZeroOrMore
(
nmchar
))
printrun/svg/document.py
View file @
ce8c3f3c
...
@@ -18,16 +18,16 @@
...
@@ -18,16 +18,16 @@
"""
"""
import
wx
import
wx
from
cStringIO
import
StringIO
from
io
import
StringIO
import
warnings
import
warnings
import
math
import
math
from
functools
import
wraps
from
functools
import
wraps
import
pathdata
from
.
import
pathdata
import
css
from
.
import
css
from
svg.css.colour
import
colourValue
from
svg.css.colour
import
colourValue
from
svg.css
import
values
from
svg.css
import
values
from
attributes
import
paintValue
from
.
attributes
import
paintValue
document
=
"""<?xml version = "1.0" standalone = "no"?>
document
=
"""<?xml version = "1.0" standalone = "no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
...
@@ -60,7 +60,7 @@ def valueToPixels(val, defaultUnits = "px"):
...
@@ -60,7 +60,7 @@ def valueToPixels(val, defaultUnits = "px"):
try
:
try
:
val
,
unit
=
values
.
length
.
parseString
(
val
)
val
,
unit
=
values
.
length
.
parseString
(
val
)
except
ParseException
:
except
ParseException
:
print
"***"
,
val
print
(
"***"
,
val
)
raise
raise
#todo: unit conversion to something other than pixels
#todo: unit conversion to something other than pixels
return
val
return
val
...
@@ -128,7 +128,7 @@ class SVGDocument(object):
...
@@ -128,7 +128,7 @@ class SVGDocument(object):
"""
"""
#copy the current state
#copy the current state
current
=
dict
(
self
.
state
)
current
=
dict
(
self
.
state
)
current
.
update
(
element
.
items
(
))
current
.
update
(
list
(
element
.
items
()
))
current
.
update
(
css
.
inlineStyle
(
element
.
get
(
"style"
,
""
)))
current
.
update
(
css
.
inlineStyle
(
element
.
get
(
"style"
,
""
)))
self
.
stateStack
.
append
(
current
)
self
.
stateStack
.
append
(
current
)
handler
=
self
.
handlers
.
get
(
element
.
tag
,
lambda
*
any
:
(
None
,
None
))
handler
=
self
.
handlers
.
get
(
element
.
tag
,
lambda
*
any
:
(
None
,
None
))
...
@@ -389,10 +389,10 @@ class SVGDocument(object):
...
@@ -389,10 +389,10 @@ class SVGDocument(object):
else
:
else
:
arguments
=
iter
(
arguments
)
arguments
=
iter
(
arguments
)
if
command
==
'm'
:
if
command
==
'm'
:
yield
(
command
,
arguments
.
next
(
))
yield
(
command
,
next
(
arguments
))
command
=
"l"
command
=
"l"
elif
command
==
"M"
:
elif
command
==
"M"
:
yield
(
command
,
arguments
.
next
(
))
yield
(
command
,
next
(
arguments
))
command
=
"L"
command
=
"L"
for
arg
in
arguments
:
for
arg
in
arguments
:
yield
(
command
,
arg
)
yield
(
command
,
arg
)
...
@@ -574,9 +574,9 @@ class SVGDocument(object):
...
@@ -574,9 +574,9 @@ class SVGDocument(object):
path
.
AddLineToPoint
(
normalizePoint
(
arg
))
path
.
AddLineToPoint
(
normalizePoint
(
arg
))
elif
type
==
'C'
:
elif
type
==
'C'
:
#control1, control2, endpoint = arg
#control1, control2, endpoint = arg
control1
,
control2
,
endpoint
=
map
(
control1
,
control2
,
endpoint
=
list
(
map
(
normalizePoint
,
arg
normalizePoint
,
arg
)
)
)
self
.
lastControl
=
control2
self
.
lastControl
=
control2
path
.
AddCurveToPoint
(
path
.
AddCurveToPoint
(
control1
,
control1
,
...
@@ -592,9 +592,9 @@ class SVGDocument(object):
...
@@ -592,9 +592,9 @@ class SVGDocument(object):
elif
type
==
'S'
:
elif
type
==
'S'
:
#control2, endpoint = arg
#control2, endpoint = arg
control2
,
endpoint
=
map
(
control2
,
endpoint
=
list
(
map
(
normalizePoint
,
arg
normalizePoint
,
arg
)
)
)
if
self
.
lastControl
:
if
self
.
lastControl
:
control1
=
reflectPoint
(
self
.
lastControl
,
path
.
GetCurrentPoint
())
control1
=
reflectPoint
(
self
.
lastControl
,
path
.
GetCurrentPoint
())
else
:
else
:
...
@@ -607,7 +607,7 @@ class SVGDocument(object):
...
@@ -607,7 +607,7 @@ class SVGDocument(object):
endpoint
endpoint
)
)
elif
type
==
"Q"
:
elif
type
==
"Q"
:
(
cx
,
cy
),
(
x
,
y
)
=
map
(
normalizePoint
,
arg
)
(
cx
,
cy
),
(
x
,
y
)
=
list
(
map
(
normalizePoint
,
arg
)
)
self
.
lastControlQ
=
(
cx
,
cy
)
self
.
lastControlQ
=
(
cx
,
cy
)
path
.
AddQuadCurveToPoint
(
cx
,
cy
,
x
,
y
)
path
.
AddQuadCurveToPoint
(
cx
,
cy
,
x
,
y
)
elif
type
==
"T"
:
elif
type
==
"T"
:
...
...
printrun/xybuttons.py
View file @
ce8c3f3c
...
@@ -14,8 +14,8 @@
...
@@ -14,8 +14,8 @@
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
import
wx
,
os
,
math
import
wx
,
os
,
math
from
bufferedcanvas
import
*
from
.
bufferedcanvas
import
*
from
printrun_utils
import
*
from
.
printrun_utils
import
*
def
sign
(
n
):
def
sign
(
n
):
if
n
<
0
:
return
-
1
if
n
<
0
:
return
-
1
...
@@ -138,7 +138,7 @@ class XYButtons(BufferedCanvas):
...
@@ -138,7 +138,7 @@ class XYButtons(BufferedCanvas):
return
(
quadrant
,
idx
)
return
(
quadrant
,
idx
)
def
mouseOverKeypad
(
self
,
mpos
):
def
mouseOverKeypad
(
self
,
mpos
):
for
idx
,
kpos
in
XYButtons
.
keypad_positions
.
items
(
):
for
idx
,
kpos
in
list
(
XYButtons
.
keypad_positions
.
items
()
):
radius
=
self
.
distanceToPoint
(
mpos
[
0
],
mpos
[
1
],
kpos
[
0
],
kpos
[
1
])
radius
=
self
.
distanceToPoint
(
mpos
[
0
],
mpos
[
1
],
kpos
[
0
],
kpos
[
1
])
if
radius
<
9
:
if
radius
<
9
:
return
idx
return
idx
...
@@ -247,7 +247,7 @@ class XYButtons(BufferedCanvas):
...
@@ -247,7 +247,7 @@ class XYButtons(BufferedCanvas):
# Draw label overlays
# Draw label overlays
gc
.
SetPen
(
wx
.
Pen
(
wx
.
Colour
(
255
,
255
,
255
,
128
),
1
))
gc
.
SetPen
(
wx
.
Pen
(
wx
.
Colour
(
255
,
255
,
255
,
128
),
1
))
gc
.
SetBrush
(
wx
.
Brush
(
wx
.
Colour
(
255
,
255
,
255
,
128
+
64
)))
gc
.
SetBrush
(
wx
.
Brush
(
wx
.
Colour
(
255
,
255
,
255
,
128
+
64
)))
for
idx
,
kpos
in
XYButtons
.
label_overlay_positions
.
items
(
):
for
idx
,
kpos
in
list
(
XYButtons
.
label_overlay_positions
.
items
()
):
if
idx
!=
self
.
concentric
:
if
idx
!=
self
.
concentric
:
r
=
kpos
[
2
]
r
=
kpos
[
2
]
gc
.
DrawEllipse
(
kpos
[
0
]
-
r
,
kpos
[
1
]
-
r
,
r
*
2
,
r
*
2
)
gc
.
DrawEllipse
(
kpos
[
0
]
-
r
,
kpos
[
1
]
-
r
,
r
*
2
,
r
*
2
)
...
...
printrun/zbuttons.py
View file @
ce8c3f3c
...
@@ -14,8 +14,8 @@
...
@@ -14,8 +14,8 @@
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
import
wx
,
os
,
math
import
wx
,
os
,
math
from
bufferedcanvas
import
*
from
.
bufferedcanvas
import
*
from
printrun_utils
import
*
from
.
printrun_utils
import
*
def
sign
(
n
):
def
sign
(
n
):
if
n
<
0
:
return
-
1
if
n
<
0
:
return
-
1
...
@@ -108,7 +108,7 @@ class ZButtons(BufferedCanvas):
...
@@ -108,7 +108,7 @@ class ZButtons(BufferedCanvas):
# Draw label overlays
# Draw label overlays
gc
.
SetPen
(
wx
.
Pen
(
wx
.
Colour
(
255
,
255
,
255
,
128
),
1
))
gc
.
SetPen
(
wx
.
Pen
(
wx
.
Colour
(
255
,
255
,
255
,
128
),
1
))
gc
.
SetBrush
(
wx
.
Brush
(
wx
.
Colour
(
255
,
255
,
255
,
128
+
64
)))
gc
.
SetBrush
(
wx
.
Brush
(
wx
.
Colour
(
255
,
255
,
255
,
128
+
64
)))
for
idx
,
kpos
in
ZButtons
.
label_overlay_positions
.
items
(
):
for
idx
,
kpos
in
list
(
ZButtons
.
label_overlay_positions
.
items
()
):
if
kpos
and
idx
!=
self
.
range
:
if
kpos
and
idx
!=
self
.
range
:
r
=
kpos
[
2
]
r
=
kpos
[
2
]
gc
.
DrawEllipse
(
ZButtons
.
center
[
0
]
-
kpos
[
0
]
-
r
,
ZButtons
.
center
[
1
]
-
kpos
[
1
]
-
r
,
r
*
2
,
r
*
2
)
gc
.
DrawEllipse
(
ZButtons
.
center
[
0
]
-
kpos
[
0
]
-
r
,
ZButtons
.
center
[
1
]
-
kpos
[
1
]
-
r
,
r
*
2
,
r
*
2
)
...
...
printrun/zscaper.py
View file @
ce8c3f3c
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
import
wx
,
math
import
wx
,
math
from
stltool
import
*
from
.
stltool
import
*
a
=
wx
.
App
()
a
=
wx
.
App
()
def
genscape
(
data
=
[[
0
,
1
,
0
,
0
],[
1
,
0
,
2
,
0
],[
1
,
0
,
0
,
0
],[
0
,
1
,
0
,
1
]],
pscale
=
1.0
,
bheight
=
1.0
,
zscale
=
1.0
):
def
genscape
(
data
=
[[
0
,
1
,
0
,
0
],[
1
,
0
,
2
,
0
],[
1
,
0
,
0
,
0
],[
0
,
1
,
0
,
1
]],
pscale
=
1.0
,
bheight
=
1.0
,
zscale
=
1.0
):
...
@@ -24,7 +24,7 @@ def genscape(data = [[0, 1, 0, 0],[1, 0, 2, 0],[1, 0, 0, 0],[0, 1, 0, 1]], pscal
...
@@ -24,7 +24,7 @@ def genscape(data = [[0, 1, 0, 0],[1, 0, 2, 0],[1, 0, 0, 0],[0, 1, 0, 1]], pscal
#create bottom:
#create bottom:
bmidpoint
=
(
pscale
*
(
datal
-
1
)
/
2.0
,
pscale
*
(
datah
-
1
)
/
2.0
)
bmidpoint
=
(
pscale
*
(
datal
-
1
)
/
2.0
,
pscale
*
(
datah
-
1
)
/
2.0
)
#print range(datal), bmidpoint
#print range(datal), bmidpoint
for
i
in
zip
(
range
(
datal
+
1
)[:
-
1
],
range
(
datal
+
1
)[
1
:])[:
-
1
]:
for
i
in
zip
(
list
(
range
(
datal
+
1
))[:
-
1
],
list
(
range
(
datal
+
1
)
)[
1
:])[:
-
1
]:
#print (pscale*i[0], pscale*i[1])
#print (pscale*i[0], pscale*i[1])
o
.
facets
+=
[[[
0
,
0
,
-
1
],[[
0.0
,
pscale
*
i
[
0
],
0.0
],[
0.0
,
pscale
*
i
[
1
],
0.0
],[
bmidpoint
[
0
],
bmidpoint
[
1
],
0.0
]]]]
o
.
facets
+=
[[[
0
,
0
,
-
1
],[[
0.0
,
pscale
*
i
[
0
],
0.0
],[
0.0
,
pscale
*
i
[
1
],
0.0
],[
bmidpoint
[
0
],
bmidpoint
[
1
],
0.0
]]]]
o
.
facets
+=
[[[
0
,
0
,
-
1
],[[
2.0
*
bmidpoint
[
1
],
pscale
*
i
[
1
],
0.0
],[
2.0
*
bmidpoint
[
1
],
pscale
*
i
[
0
],
0.0
],[
bmidpoint
[
0
],
bmidpoint
[
1
],
0.0
]]]]
o
.
facets
+=
[[[
0
,
0
,
-
1
],[[
2.0
*
bmidpoint
[
1
],
pscale
*
i
[
1
],
0.0
],[
2.0
*
bmidpoint
[
1
],
pscale
*
i
[
0
],
0.0
],[
bmidpoint
[
0
],
bmidpoint
[
1
],
0.0
]]]]
...
@@ -35,7 +35,7 @@ def genscape(data = [[0, 1, 0, 0],[1, 0, 2, 0],[1, 0, 0, 0],[0, 1, 0, 1]], pscal
...
@@ -35,7 +35,7 @@ def genscape(data = [[0, 1, 0, 0],[1, 0, 2, 0],[1, 0, 0, 0],[0, 1, 0, 1]], pscal
#print o.facets[-1]
#print o.facets[-1]
pass
pass
#print o.facets[-4:]
#print o.facets[-4:]
for
i
in
zip
(
range
(
datah
+
1
)[:
-
1
],
range
(
datah
+
1
)[
1
:])[:
-
1
]:
for
i
in
zip
(
list
(
range
(
datah
+
1
))[:
-
1
],
list
(
range
(
datah
+
1
)
)[
1
:])[:
-
1
]:
#print (pscale*i[0], pscale*i[1])
#print (pscale*i[0], pscale*i[1])
o
.
facets
+=
[[[
0
,
0
,
-
1
],[[
pscale
*
i
[
1
],
0.0
,
0.0
],[
pscale
*
i
[
0
],
0.0
,
0.0
],[
bmidpoint
[
0
],
bmidpoint
[
1
],
0.0
]]]]
o
.
facets
+=
[[[
0
,
0
,
-
1
],[[
pscale
*
i
[
1
],
0.0
,
0.0
],[
pscale
*
i
[
0
],
0.0
,
0.0
],[
bmidpoint
[
0
],
bmidpoint
[
1
],
0.0
]]]]
o
.
facets
+=
[[[
0
,
0
,
-
1
],[[
pscale
*
i
[
0
],
2.0
*
bmidpoint
[
0
],
0.0
],[
pscale
*
i
[
1
],
2.0
*
bmidpoint
[
0
],
0.0
],[
bmidpoint
[
0
],
bmidpoint
[
1
],
0.0
]]]]
o
.
facets
+=
[[[
0
,
0
,
-
1
],[[
pscale
*
i
[
0
],
2.0
*
bmidpoint
[
0
],
0.0
],[
pscale
*
i
[
1
],
2.0
*
bmidpoint
[
0
],
0.0
],[
bmidpoint
[
0
],
bmidpoint
[
1
],
0.0
]]]]
...
@@ -45,8 +45,8 @@ def genscape(data = [[0, 1, 0, 0],[1, 0, 2, 0],[1, 0, 0, 0],[0, 1, 0, 1]], pscal
...
@@ -45,8 +45,8 @@ def genscape(data = [[0, 1, 0, 0],[1, 0, 2, 0],[1, 0, 0, 0],[0, 1, 0, 1]], pscal
o
.
facets
+=
[
genfacet
([[
pscale
*
i
[
1
],
0.0
,
0.0
],[
pscale
*
i
[
0
],
0.0
,
data
[
0
][
i
[
0
]]
*
zscale
+
bheight
],[
pscale
*
i
[
0
],
0.0
,
0.0
]])]
o
.
facets
+=
[
genfacet
([[
pscale
*
i
[
1
],
0.0
,
0.0
],[
pscale
*
i
[
0
],
0.0
,
data
[
0
][
i
[
0
]]
*
zscale
+
bheight
],[
pscale
*
i
[
0
],
0.0
,
0.0
]])]
o
.
facets
+=
[
genfacet
([[
pscale
*
i
[
0
],
2.0
*
bmidpoint
[
0
],
data
[
datal
-
1
][
i
[
0
]]
*
zscale
+
bheight
],[
pscale
*
i
[
1
],
2.0
*
bmidpoint
[
0
],
0.0
],[
pscale
*
i
[
0
],
2.0
*
bmidpoint
[
0
],
0.0
]])]
o
.
facets
+=
[
genfacet
([[
pscale
*
i
[
0
],
2.0
*
bmidpoint
[
0
],
data
[
datal
-
1
][
i
[
0
]]
*
zscale
+
bheight
],[
pscale
*
i
[
1
],
2.0
*
bmidpoint
[
0
],
0.0
],[
pscale
*
i
[
0
],
2.0
*
bmidpoint
[
0
],
0.0
]])]
pass
pass
for
i
in
x
range
(
datah
-
1
):
for
i
in
range
(
datah
-
1
):
for
j
in
x
range
(
datal
-
1
):
for
j
in
range
(
datal
-
1
):
o
.
facets
+=
[
genfacet
([[
pscale
*
i
,
pscale
*
j
,
data
[
j
][
i
]
*
zscale
+
bheight
],[
pscale
*
(
i
+
1
),
pscale
*
(
j
),
data
[
j
][
i
+
1
]
*
zscale
+
bheight
],[
pscale
*
(
i
+
1
),
pscale
*
(
j
+
1
),
data
[
j
+
1
][
i
+
1
]
*
zscale
+
bheight
]])]
o
.
facets
+=
[
genfacet
([[
pscale
*
i
,
pscale
*
j
,
data
[
j
][
i
]
*
zscale
+
bheight
],[
pscale
*
(
i
+
1
),
pscale
*
(
j
),
data
[
j
][
i
+
1
]
*
zscale
+
bheight
],[
pscale
*
(
i
+
1
),
pscale
*
(
j
+
1
),
data
[
j
+
1
][
i
+
1
]
*
zscale
+
bheight
]])]
o
.
facets
+=
[
genfacet
([[
pscale
*
(
i
),
pscale
*
(
j
+
1
),
data
[
j
+
1
][
i
]
*
zscale
+
bheight
],[
pscale
*
i
,
pscale
*
j
,
data
[
j
][
i
]
*
zscale
+
bheight
],[
pscale
*
(
i
+
1
),
pscale
*
(
j
+
1
),
data
[
j
+
1
][
i
+
1
]
*
zscale
+
bheight
]])]
o
.
facets
+=
[
genfacet
([[
pscale
*
(
i
),
pscale
*
(
j
+
1
),
data
[
j
+
1
][
i
]
*
zscale
+
bheight
],[
pscale
*
i
,
pscale
*
j
,
data
[
j
][
i
]
*
zscale
+
bheight
],[
pscale
*
(
i
+
1
),
pscale
*
(
j
+
1
),
data
[
j
+
1
][
i
+
1
]
*
zscale
+
bheight
]])]
#print o.facets[-1]
#print o.facets[-1]
...
@@ -55,10 +55,10 @@ def genscape(data = [[0, 1, 0, 0],[1, 0, 2, 0],[1, 0, 0, 0],[0, 1, 0, 1]], pscal
...
@@ -55,10 +55,10 @@ def genscape(data = [[0, 1, 0, 0],[1, 0, 2, 0],[1, 0, 0, 0],[0, 1, 0, 1]], pscal
def
zimage
(
name
,
out
):
def
zimage
(
name
,
out
):
i
=
wx
.
Image
(
name
)
i
=
wx
.
Image
(
name
)
s
=
i
.
GetSize
()
s
=
i
.
GetSize
()
print
len
(
map
(
ord
,
i
.
GetData
()[::
3
]
))
print
(
len
(
list
(
map
(
ord
,
i
.
GetData
()[::
3
]))
))
b
=
map
(
ord
,
i
.
GetData
()[::
3
]
)
b
=
list
(
map
(
ord
,
i
.
GetData
()[::
3
])
)
data
=
[]
data
=
[]
for
i
in
x
range
(
s
[
0
]):
for
i
in
range
(
s
[
0
]):
data
+=
[
b
[
i
*
s
[
1
]:(
i
+
1
)
*
s
[
1
]]]
data
+=
[
b
[
i
*
s
[
1
]:(
i
+
1
)
*
s
[
1
]]]
#data = [i[::5] for i in data[::5]]
#data = [i[::5] for i in data[::5]]
emitstl
(
out
,
genscape
(
data
,
zscale
=
0.1
)
.
facets
,
name
)
emitstl
(
out
,
genscape
(
data
,
zscale
=
0.1
)
.
facets
,
name
)
...
...
pronserve.py
View file @
ce8c3f3c
...
@@ -21,7 +21,7 @@ import pronsole
...
@@ -21,7 +21,7 @@ import pronsole
from
server
import
basic_auth
from
server
import
basic_auth
import
random
import
random
import
textwrap
import
textwrap
import
SocketS
erver
import
sockets
erver
import
socket
import
socket
import
mdns
import
mdns
import
uuid
import
uuid
...
@@ -133,21 +133,21 @@ class ConstructSocketHandler(tornado.websocket.WebSocketHandler):
...
@@ -133,21 +133,21 @@ class ConstructSocketHandler(tornado.websocket.WebSocketHandler):
def
open
(
self
):
def
open
(
self
):
pronserve
.
listeners
.
add
(
self
)
pronserve
.
listeners
.
add
(
self
)
self
.
write_message
({
'connected'
:
{
'jobs'
:
pronserve
.
jobs
.
public_list
()}})
self
.
write_message
({
'connected'
:
{
'jobs'
:
pronserve
.
jobs
.
public_list
()}})
print
"WebSocket opened.
%
i sockets currently open."
%
len
(
pronserve
.
listeners
)
print
(
"WebSocket opened.
%
i sockets currently open."
%
len
(
pronserve
.
listeners
)
)
def
send
(
self
,
dict_args
=
{},
**
kwargs
):
def
send
(
self
,
dict_args
=
{},
**
kwargs
):
args
=
dict
(
dict_args
.
items
()
+
kwargs
.
items
(
))
args
=
dict
(
list
(
dict_args
.
items
())
+
list
(
kwargs
.
items
()
))
args
[
'timestamp'
]
=
time
.
time
()
args
[
'timestamp'
]
=
time
.
time
()
self
.
write_message
(
args
)
self
.
write_message
(
args
)
def
on_message
(
self
,
msg
):
def
on_message
(
self
,
msg
):
print
"message received:
%
s"
%
(
msg
)
print
(
"message received:
%
s"
%
(
msg
)
)
# TODO: the read bit of repl!
# TODO: the read bit of repl!
# self.write_message("You said: " + msg)
# self.write_message("You said: " + msg)
def
on_close
(
self
):
def
on_close
(
self
):
pronserve
.
listeners
.
remove
(
self
)
pronserve
.
listeners
.
remove
(
self
)
print
"WebSocket closed.
%
i sockets currently open."
%
len
(
pronserve
.
listeners
)
print
(
"WebSocket closed.
%
i sockets currently open."
%
len
(
pronserve
.
listeners
)
)
dir
=
os
.
path
.
dirname
(
__file__
)
dir
=
os
.
path
.
dirname
(
__file__
)
settings
=
dict
(
settings
=
dict
(
...
@@ -226,12 +226,12 @@ class Pronserve(pronsole.pronsole, EventEmitter):
...
@@ -226,12 +226,12 @@ class Pronserve(pronsole.pronsole, EventEmitter):
self
.
update_job_progress
(
100
)
self
.
update_job_progress
(
100
)
self
.
fire
(
"job_finished"
,
self
.
jobs
.
sanitize
(
self
.
current_job
))
self
.
fire
(
"job_finished"
,
self
.
jobs
.
sanitize
(
self
.
current_job
))
if
len
(
self
.
jobs
.
list
)
>
0
:
if
len
(
self
.
jobs
.
list
)
>
0
:
print
"Starting the next print job"
print
(
"Starting the next print job"
)
self
.
current_job
=
self
.
jobs
.
list
.
popleft
()
self
.
current_job
=
self
.
jobs
.
list
.
popleft
()
self
.
p
.
startprint
(
self
.
current_job
[
'body'
]
.
split
(
"
\n
"
))
self
.
p
.
startprint
(
self
.
current_job
[
'body'
]
.
split
(
"
\n
"
))
self
.
fire
(
"job_started"
,
self
.
jobs
.
sanitize
(
self
.
current_job
))
self
.
fire
(
"job_started"
,
self
.
jobs
.
sanitize
(
self
.
current_job
))
else
:
else
:
print
"Finished all print jobs"
print
(
"Finished all print jobs"
)
self
.
current_job
=
None
self
.
current_job
=
None
self
.
printing_jobs
=
False
self
.
printing_jobs
=
False
...
@@ -273,12 +273,12 @@ class Pronserve(pronsole.pronsole, EventEmitter):
...
@@ -273,12 +273,12 @@ class Pronserve(pronsole.pronsole, EventEmitter):
def
_receive_sensor_update
(
self
,
l
):
def
_receive_sensor_update
(
self
,
l
):
words
=
filter
(
lambda
s
:
s
.
find
(
":"
)
>
0
,
l
.
split
(
" "
))
words
=
[
s
for
s
in
l
.
split
(
" "
)
if
s
.
find
(
":"
)
>
0
]
d
=
dict
([
s
.
split
(
":"
)
for
s
in
words
])
d
=
dict
([
s
.
split
(
":"
)
for
s
in
words
])
# print "sensor update received!"
# print "sensor update received!"
for
key
,
value
in
d
.
ite
rite
ms
():
for
key
,
value
in
d
.
items
():
self
.
__update_sensor
(
key
,
value
)
self
.
__update_sensor
(
key
,
value
)
self
.
fire
(
"sensor_changed"
)
self
.
fire
(
"sensor_changed"
)
...
@@ -295,7 +295,7 @@ class Pronserve(pronsole.pronsole, EventEmitter):
...
@@ -295,7 +295,7 @@ class Pronserve(pronsole.pronsole, EventEmitter):
def
log
(
self
,
*
msg
):
def
log
(
self
,
*
msg
):
msg
=
''
.
join
(
str
(
i
)
for
i
in
msg
)
msg
=
''
.
join
(
str
(
i
)
for
i
in
msg
)
msg
.
replace
(
"
\r
"
,
""
)
msg
.
replace
(
"
\r
"
,
""
)
print
msg
print
(
msg
)
self
.
fire
(
"log"
,
{
'msg'
:
msg
,
'level'
:
"debug"
})
self
.
fire
(
"log"
,
{
'msg'
:
msg
,
'level'
:
"debug"
})
def
write_prompt
(
self
):
def
write_prompt
(
self
):
...
@@ -338,14 +338,14 @@ class PrintJobQueue(EventEmitter):
...
@@ -338,14 +338,14 @@ class PrintJobQueue(EventEmitter):
self
.
__last_id
+=
1
self
.
__last_id
+=
1
self
.
list
.
append
(
job
)
self
.
list
.
append
(
job
)
print
"Added
%
s"
%
(
original_file_name
)
print
(
"Added
%
s"
%
(
original_file_name
)
)
self
.
fire
(
"job_added"
,
job
)
self
.
fire
(
"job_added"
,
job
)
def
display_summary
(
self
):
def
display_summary
(
self
):
print
"Print Jobs:"
print
(
"Print Jobs:"
)
for
job
in
self
.
list
:
for
job
in
self
.
list
:
print
"
%
i:
%
s"
%
(
job
[
'id'
],
job
[
'original_file_name'
]
)
print
(
"
%
i:
%
s"
%
(
job
[
'id'
],
job
[
'original_file_name'
])
)
print
""
print
(
""
)
return
True
return
True
def
remove
(
self
,
job_id
):
def
remove
(
self
,
job_id
):
...
@@ -353,7 +353,7 @@ class PrintJobQueue(EventEmitter):
...
@@ -353,7 +353,7 @@ class PrintJobQueue(EventEmitter):
if
job
==
None
:
if
job
==
None
:
return
False
return
False
self
.
list
.
remove
(
job
)
self
.
list
.
remove
(
job
)
print
"Print Job Removed"
print
(
"Print Job Removed"
)
self
.
fire
(
"job_removed"
,
job
)
self
.
fire
(
"job_removed"
,
job
)
def
update
(
self
,
job_id
,
job_attrs
):
def
update
(
self
,
job_id
,
job_attrs
):
...
@@ -362,7 +362,7 @@ class PrintJobQueue(EventEmitter):
...
@@ -362,7 +362,7 @@ class PrintJobQueue(EventEmitter):
return
False
return
False
job
[
'rank'
]
=
job_attrs
[
'position'
]
job
[
'rank'
]
=
job_attrs
[
'position'
]
self
.
order
()
self
.
order
()
print
"Print Job Updated"
print
(
"Print Job Updated"
)
self
.
fire
(
"job_updated"
,
job
)
self
.
fire
(
"job_updated"
,
job
)
def
find_by_id
(
self
,
job_id
):
def
find_by_id
(
self
,
job_id
):
...
@@ -379,7 +379,7 @@ class PrintJobQueue(EventEmitter):
...
@@ -379,7 +379,7 @@ class PrintJobQueue(EventEmitter):
# Server Start Up
# Server Start Up
# -------------------------------------------------
# -------------------------------------------------
print
"Pronserve is starting..."
print
(
"Pronserve is starting..."
)
pronserve
=
Pronserve
()
pronserve
=
Pronserve
()
pronserve
.
do_connect
(
""
)
pronserve
.
do_connect
(
""
)
...
@@ -389,13 +389,13 @@ pronserve.run_print_queue_loop()
...
@@ -389,13 +389,13 @@ pronserve.run_print_queue_loop()
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
application
.
listen
(
8888
)
application
.
listen
(
8888
)
print
"
\n
"
+
"-"
*
80
print
(
"
\n
"
+
"-"
*
80
)
welcome
=
textwrap
.
dedent
(
u
"""
welcome
=
textwrap
.
dedent
(
"""
+---+
\x1B
[0;32mPronserve: Your printer just got a whole lot better.
\x1B
[0m
+---+
\x1B
[0;32mPronserve: Your printer just got a whole lot better.
\x1B
[0m
|
\u2713
| Ready to print.
|
\u2713
| Ready to print.
+---+ More details at http://localhost:8888/"""
)
+---+ More details at http://localhost:8888/"""
)
sys
.
stdout
.
write
(
welcome
)
sys
.
stdout
.
write
(
welcome
)
print
"
\n\n
"
+
"-"
*
80
+
"
\n
"
print
(
"
\n\n
"
+
"-"
*
80
+
"
\n
"
)
try
:
try
:
pronserve
.
ioloop
.
start
()
pronserve
.
ioloop
.
start
()
...
...
pronsole.py
View file @
ce8c3f3c
This diff is collapsed.
Click to expand it.
pronterface.py
View file @
ce8c3f3c
This diff is collapsed.
Click to expand it.
server/basic_auth.py
View file @
ce8c3f3c
...
@@ -57,7 +57,7 @@ def authenticate(realm, authenticator,user_extractor) :
...
@@ -57,7 +57,7 @@ def authenticate(realm, authenticator,user_extractor) :
auth_decoded
=
base64
.
decodestring
(
auth_hdr
[
6
:])
auth_decoded
=
base64
.
decodestring
(
auth_hdr
[
6
:])
username
,
password
=
auth_decoded
.
split
(
':'
,
2
)
username
,
password
=
auth_decoded
.
split
(
':'
,
2
)
user_info
=
authenticator
(
realm
,
unicode
(
username
),
password
)
user_info
=
authenticator
(
realm
,
str
(
username
),
password
)
if
user_info
:
if
user_info
:
self
.
_user_info
=
user_info
self
.
_user_info
=
user_info
self
.
_current_user
=
user_extractor
(
user_info
)
self
.
_current_user
=
user_extractor
(
user_info
)
...
@@ -65,7 +65,7 @@ def authenticate(realm, authenticator,user_extractor) :
...
@@ -65,7 +65,7 @@ def authenticate(realm, authenticator,user_extractor) :
str
(
self
.
_user_info
))
str
(
self
.
_user_info
))
else
:
else
:
return
_request_basic_auth
(
self
)
return
_request_basic_auth
(
self
)
except
Exception
,
e
:
except
Exception
as
e
:
return
_request_basic_auth
(
self
)
return
_request_basic_auth
(
self
)
return
True
return
True
return
wrapper
return
wrapper
...
@@ -90,4 +90,4 @@ def interceptor(func):
...
@@ -90,4 +90,4 @@ def interceptor(func):
return
cls
return
cls
return
classwrapper
return
classwrapper
print
"moo"
print
(
"moo"
)
\ No newline at end of file
\ No newline at end of file
setup.py
View file @
ce8c3f3c
...
@@ -35,7 +35,7 @@ class install (_install):
...
@@ -35,7 +35,7 @@ class install (_install):
if
self
.
prefix
:
if
self
.
prefix
:
length
+=
len
(
self
.
prefix
)
length
+=
len
(
self
.
prefix
)
if
length
:
if
length
:
for
counter
in
x
range
(
len
(
outputs
)):
for
counter
in
range
(
len
(
outputs
)):
outputs
[
counter
]
=
outputs
[
counter
][
length
:]
outputs
[
counter
]
=
outputs
[
counter
][
length
:]
data
=
"
\n
"
.
join
(
outputs
)
data
=
"
\n
"
.
join
(
outputs
)
try
:
try
:
...
@@ -56,7 +56,7 @@ class install_data (_install_data):
...
@@ -56,7 +56,7 @@ class install_data (_install_data):
except
:
except
:
self
.
warn
(
"Could not chmod data file
%
s"
%
file
)
self
.
warn
(
"Could not chmod data file
%
s"
%
file
)
_install_data
.
run
(
self
)
_install_data
.
run
(
self
)
map
(
chmod_data_file
,
self
.
get_outputs
(
))
list
(
map
(
chmod_data_file
,
self
.
get_outputs
()
))
class
uninstall
(
_install
):
class
uninstall
(
_install
):
...
@@ -75,10 +75,10 @@ class uninstall (_install):
...
@@ -75,10 +75,10 @@ class uninstall (_install):
if
self
.
prefix
:
if
self
.
prefix
:
prepend
+=
self
.
prefix
prepend
+=
self
.
prefix
if
len
(
prepend
):
if
len
(
prepend
):
for
counter
in
x
range
(
len
(
files
)):
for
counter
in
range
(
len
(
files
)):
files
[
counter
]
=
prepend
+
files
[
counter
]
.
rstrip
()
files
[
counter
]
=
prepend
+
files
[
counter
]
.
rstrip
()
for
file
in
files
:
for
file
in
files
:
print
"Uninstalling
%
s"
%
file
print
(
"Uninstalling
%
s"
%
file
)
try
:
try
:
os
.
unlink
(
file
)
os
.
unlink
(
file
)
except
:
except
:
...
@@ -87,7 +87,7 @@ class uninstall (_install):
...
@@ -87,7 +87,7 @@ class uninstall (_install):
ops
=
(
"install"
,
"build"
,
"sdist"
,
"uninstall"
,
"clean"
)
ops
=
(
"install"
,
"build"
,
"sdist"
,
"uninstall"
,
"clean"
)
if
len
(
sys
.
argv
)
<
2
or
sys
.
argv
[
1
]
not
in
ops
:
if
len
(
sys
.
argv
)
<
2
or
sys
.
argv
[
1
]
not
in
ops
:
print
"Please specify operation :
%
s"
%
" | "
.
join
(
ops
)
print
(
"Please specify operation :
%
s"
%
" | "
.
join
(
ops
)
)
raise
SystemExit
raise
SystemExit
prefix
=
None
prefix
=
None
...
@@ -126,14 +126,14 @@ for basedir, subdirs, files in os.walk("locale"):
...
@@ -126,14 +126,14 @@ for basedir, subdirs, files in os.walk("locale"):
if
not
basedir
.
endswith
(
"LC_MESSAGES"
):
if
not
basedir
.
endswith
(
"LC_MESSAGES"
):
continue
continue
destpath
=
os
.
path
.
join
(
"share"
,
"pronterface"
,
basedir
)
destpath
=
os
.
path
.
join
(
"share"
,
"pronterface"
,
basedir
)
files
=
filter
(
lambda
x
:
x
.
endswith
(
".mo"
),
files
)
files
=
[
x
for
x
in
files
if
x
.
endswith
(
".mo"
)]
files
=
map
(
lambda
x
:
os
.
path
.
join
(
basedir
,
x
),
files
)
files
=
[
os
.
path
.
join
(
basedir
,
x
)
for
x
in
files
]
data_files
.
append
((
destpath
,
files
))
data_files
.
append
((
destpath
,
files
))
extra_data_dirs
=
[
"css"
]
extra_data_dirs
=
[
"css"
]
for
extra_data_dir
in
extra_data_dirs
:
for
extra_data_dir
in
extra_data_dirs
:
for
basedir
,
subdirs
,
files
in
os
.
walk
(
extra_data_dir
):
for
basedir
,
subdirs
,
files
in
os
.
walk
(
extra_data_dir
):
files
=
map
(
lambda
x
:
os
.
path
.
join
(
basedir
,
x
),
files
)
files
=
[
os
.
path
.
join
(
basedir
,
x
)
for
x
in
files
]
destpath
=
os
.
path
.
join
(
"share"
,
"pronterface"
,
basedir
)
destpath
=
os
.
path
.
join
(
"share"
,
"pronterface"
,
basedir
)
data_files
.
append
((
destpath
,
files
))
data_files
.
append
((
destpath
,
files
))
...
...
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