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
d6bd9e75
Commit
d6bd9e75
authored
Apr 03, 2014
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Flake8 cleanup
parent
25717357
Changes
20
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
169 additions
and
262 deletions
+169
-262
calibrateextruder.py
calibrateextruder.py
+6
-6
bmpDisplay.py
printrun/bmpDisplay.py
+0
-91
gcoder.py
printrun/gcoder.py
+5
-5
gcview.py
printrun/gcview.py
+0
-2
bufferedcanvas.py
printrun/gui/bufferedcanvas.py
+6
-6
controls.py
printrun/gui/controls.py
+8
-8
graph.py
printrun/gui/graph.py
+21
-21
log.py
printrun/gui/log.py
+0
-2
widgets.py
printrun/gui/widgets.py
+7
-11
xybuttons.py
printrun/gui/xybuttons.py
+3
-3
zbuttons.py
printrun/gui/zbuttons.py
+3
-3
gviz.py
printrun/gviz.py
+3
-3
packer.py
printrun/packer.py
+39
-39
pronterface.py
printrun/pronterface.py
+21
-21
stlplater.py
printrun/stlplater.py
+9
-9
stltool.py
printrun/stltool.py
+6
-6
stlview.py
printrun/stlview.py
+23
-17
zscaper.py
printrun/zscaper.py
+6
-6
pronterface.py
pronterface.py
+1
-1
setup.py
setup.py
+2
-2
No files found.
printrun/
calibrateextruder.py
→
calibrateextruder.py
View file @
d6bd9e75
...
...
@@ -14,8 +14,8 @@
# You should have received a copy of the GNU General Public License
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
#Interactive RepRap e axis calibration program
#(C) Nathan Zadoks 2011
#
Interactive RepRap e axis calibration program
#
(C) Nathan Zadoks 2011
s
=
300
# Extrusion speed (mm/min)
n
=
100
# Default length to extrude
...
...
@@ -95,7 +95,7 @@ def gettemp(p):
if
not
os
.
path
.
exists
(
port
):
port
=
0
#Parse options
#
Parse options
help
=
u"""
%
s [ -l DISTANCE ] [ -s STEPS ] [ -t TEMP ] [ -p PORT ]
-l --length Length of filament to extrude for each calibration step (default:
%
d mm)
...
...
@@ -126,7 +126,7 @@ for o, a in opts:
elif
o
in
(
'-p'
,
'--port'
):
port
=
a
#Show initial parameters
#
Show initial parameters
print
"Initial parameters"
print
"Steps per mm:
%3
d steps"
%
k
print
"Length extruded:
%3
d mm"
%
n
...
...
@@ -135,7 +135,7 @@ print "Serial port: %s" % (port if port else 'auto')
p
=
None
try
:
#Connect to printer
#
Connect to printer
w
(
"Connecting to printer.."
)
try
:
p
=
printcore
(
port
,
115200
)
...
...
@@ -149,7 +149,7 @@ try:
heatup
(
p
,
temp
)
#Calibration loop
#
Calibration loop
while
n
!=
m
:
heatup
(
p
,
temp
,
True
)
p
.
send_now
(
"G92 E0"
)
# Reset e axis
...
...
printrun/bmpDisplay.py
deleted
100644 → 0
View file @
25717357
# This file is part of the Printrun suite.
#
# Printrun is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Printrun is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
# create a simple image slide show using the
# wx.PaintDC surface as a canvas and
# DrawBitmap(bitmap, x, y, bool transparent)
# Source: vegaseat
import
wx
import
os
import
zipfile
import
tempfile
import
shutil
class
MyFrame
(
wx
.
Frame
):
def
__init__
(
self
,
parent
,
mysize
):
wx
.
Frame
.
__init__
(
self
,
parent
,
wx
.
ID_ANY
,
size
=
mysize
)
self
.
SetBackgroundColour
(
'black'
)
# milliseconds per frame
self
.
delay
=
60
# number of loops
self
.
loops
=
1
zipfilename
=
'images/out.3dlp.zip'
if
not
zipfile
.
is_zipfile
(
zipfilename
):
raise
Exception
(
zipfilename
+
" is not a zip file!"
)
zip
=
zipfile
.
ZipFile
(
zipfilename
,
'r'
)
self
.
mytmpdir
=
tempfile
.
mkdtemp
()
zip
.
extractall
(
self
.
mytmpdir
)
image_type
=
".bmp"
image_dir
=
self
.
mytmpdir
file_list
=
[]
self
.
name_list
=
[]
for
file
in
os
.
listdir
(
image_dir
):
path
=
os
.
path
.
join
(
image_dir
,
file
)
if
os
.
path
.
isfile
(
path
)
and
path
.
endswith
(
image_type
):
# just the file name
self
.
name_list
.
append
(
file
)
# full path name
file_list
.
append
(
path
)
# create a list of image objects
self
.
image_list
=
[]
for
image_file
in
file_list
:
self
.
image_list
.
append
(
wx
.
Bitmap
(
image_file
))
# bind the panel to the paint event
wx
.
EVT_PAINT
(
self
,
self
.
onPaint
)
def
__del__
(
self
):
if
self
.
mytmpdir
:
shutil
.
rmtree
(
self
.
mytmpdir
)
def
onPaint
(
self
,
event
=
None
):
# this is the wxPython drawing surface/canvas
dc
=
wx
.
PaintDC
(
self
)
while
self
.
loops
:
self
.
loops
-=
1
for
ix
,
bmp
in
enumerate
(
self
.
image_list
):
# optionally show some image information
w
,
h
=
bmp
.
GetSize
()
info
=
"
%
s
%
dx
%
d"
%
(
self
.
name_list
[
ix
],
w
,
h
)
self
.
SetTitle
(
info
)
#self.SetSize((w, h))
# draw the image
dc
.
DrawBitmap
(
bmp
,
0
,
0
,
True
)
wx
.
MilliSleep
(
self
.
delay
)
# don't clear on fast slide shows to avoid flicker
if
self
.
delay
>
200
:
dc
.
Clear
()
app
=
wx
.
App
()
width
=
800
frameoffset
=
35
height
=
600
+
frameoffset
MyFrame
(
None
,
(
width
,
height
))
.
Show
()
app
.
MainLoop
()
printrun/gcoder.py
View file @
d6bd9e75
...
...
@@ -271,7 +271,7 @@ class GCode(object):
cur_layer_has_extrusion
=
False
for
line
in
lines
:
## Parse line
#
# Parse line
split_raw
=
split
(
line
)
if
line
.
command
:
# Update properties
...
...
@@ -342,7 +342,7 @@ class GCode(object):
line
.
current_y
=
current_y
line
.
current_z
=
current_z
## Process extrusion
#
# Process extrusion
if
line
.
e
is
not
None
:
if
line
.
is_move
:
if
line
.
relative_e
:
...
...
@@ -358,7 +358,7 @@ class GCode(object):
elif
line
.
command
==
"G92"
:
offset_e
=
current_e
-
line
.
e
## Create layers
#
# Create layers
if
not
build_layers
:
continue
# FIXME : looks like this needs to be tested with "lift Z on move"
...
...
@@ -413,7 +413,7 @@ class GCode(object):
line_idxs
.
append
(
layer_line
)
layer_line
+=
1
prev_z
=
cur_z
### Loop done
#
## Loop done
# Store current status
self
.
imperial
=
imperial
...
...
@@ -494,7 +494,7 @@ class GCode(object):
totalduration
=
0.0
acceleration
=
2000.0
# mm/s^2
layerbeginduration
=
0.0
#TODO:
#
TODO:
# get device caps from firmware: max speed, acceleration/axis
# (including extruder)
# calculate the maximum move duration accounting for above ;)
...
...
printrun/gcview.py
View file @
d6bd9e75
...
...
@@ -22,11 +22,9 @@ from . import gcoder
from
.gl.panel
import
wxGLPanel
from
.gl.trackball
import
build_rotmatrix
from
.gl.libtatlin
import
actors
from
.gl.libtatlin.actors
import
vec
from
pyglet.gl
import
glPushMatrix
,
glPopMatrix
,
\
glTranslatef
,
glRotatef
,
glScalef
,
glMultMatrixd
from
pyglet.gl
import
*
from
.gviz
import
GvizBaseFrame
...
...
printrun/gui/bufferedcanvas.py
View file @
d6bd9e75
...
...
@@ -73,9 +73,9 @@ class BufferedCanvas(wx.Panel):
pass
# the sauce, please
self
.
Bind
(
wx
.
EVT_ERASE_BACKGROUND
,
disable_event
)
#
#
#
#
General methods
#
#
#
# General methods
#
def
draw
(
self
,
dc
,
w
,
h
):
"""
...
...
@@ -97,9 +97,9 @@ class BufferedCanvas(wx.Panel):
height
=
1
return
(
width
,
height
)
#
#
#
#
Event handlers
#
#
#
# Event handlers
#
def
onPaint
(
self
,
event
):
# Blit the front buffer to the screen
...
...
printrun/gui/controls.py
View file @
d6bd9e75
...
...
@@ -123,7 +123,7 @@ def add_extra_controls(self, root, parentpanel, extra_buttons = None, mini_mode
container
=
self
container
.
Add
(
widget
,
*
args
,
**
kwargs
)
#
# Hotend & bed temperatures
#
Hotend & bed temperatures #
# Hotend temp
add
(
"htemp_label"
,
wx
.
StaticText
(
parentpanel
,
-
1
,
_
(
"Heat:"
)),
flag
=
wx
.
ALIGN_CENTER_VERTICAL
|
wx
.
ALIGN_RIGHT
)
...
...
@@ -168,8 +168,8 @@ def add_extra_controls(self, root, parentpanel, extra_buttons = None, mini_mode
root
.
btemp
.
SetValue
(
str
(
root
.
settings
.
last_bed_temperature
))
root
.
htemp
.
SetValue
(
str
(
root
.
settings
.
last_temperature
))
#
#
added for an error where only the bed would get (pla) or (abs).
#This ensures, if last temp is a default pla or abs, it will be marked so.
# added for an error where only the bed would get (pla) or (abs).
#
This ensures, if last temp is a default pla or abs, it will be marked so.
# if it is not, then a (user) remark is added. This denotes a manual entry
for
i
in
btemp_choices
:
...
...
@@ -184,7 +184,7 @@ def add_extra_controls(self, root, parentpanel, extra_buttons = None, mini_mode
if
'('
not
in
root
.
htemp
.
Value
:
root
.
htemp
.
SetValue
(
root
.
htemp
.
Value
+
' (user)'
)
#
# Speed control
#
Speed control #
speedpanel
=
root
.
newPanel
(
parentpanel
)
speedsizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
speedsizer
.
Add
(
wx
.
StaticText
(
speedpanel
,
-
1
,
_
(
"Print speed:"
)),
flag
=
wx
.
ALIGN_CENTER_VERTICAL
|
wx
.
ALIGN_RIGHT
)
...
...
@@ -210,7 +210,7 @@ def add_extra_controls(self, root, parentpanel, extra_buttons = None, mini_mode
root
.
speed_label
.
SetLabel
(
_
(
"
%
d
%%
"
)
%
value
)
root
.
speed_slider
.
Bind
(
wx
.
EVT_SCROLL
,
speedslider_scroll
)
#
# Temperature gauges
#
Temperature gauges #
if
root
.
display_gauges
:
root
.
hottgauge
=
TempGauge
(
parentpanel
,
size
=
(
-
1
,
24
),
title
=
_
(
"Heater:"
),
maxval
=
300
,
bgcolor
=
root
.
bgcolor
)
...
...
@@ -234,7 +234,7 @@ def add_extra_controls(self, root, parentpanel, extra_buttons = None, mini_mode
root
.
hottgauge
.
Bind
(
wx
.
EVT_MOUSEWHEEL
,
hotendgauge_scroll_setpoint
)
root
.
bedtgauge
.
Bind
(
wx
.
EVT_MOUSEWHEEL
,
bedgauge_scroll_setpoint
)
#
# Temperature (M105) feedback display
#
Temperature (M105) feedback display #
root
.
tempdisp
=
wx
.
StaticText
(
parentpanel
,
-
1
,
""
,
style
=
wx
.
ST_NO_AUTORESIZE
)
def
on_tempdisp_size
(
evt
):
...
...
@@ -248,14 +248,14 @@ def add_extra_controls(self, root, parentpanel, extra_buttons = None, mini_mode
root
.
tempdisp
.
SetLabel
=
tempdisp_setlabel
add
(
"tempdisp"
,
root
.
tempdisp
,
flag
=
wx
.
EXPAND
)
#
# Temperature graph
#
Temperature graph #
if
root
.
display_graph
:
root
.
graph
=
Graph
(
parentpanel
,
wx
.
ID_ANY
,
root
)
add
(
"tempgraph"
,
root
.
graph
,
flag
=
wx
.
EXPAND
|
wx
.
ALL
,
border
=
5
)
root
.
graph
.
Bind
(
wx
.
EVT_LEFT_DOWN
,
root
.
graph
.
show_graph_window
)
#
# Extrusion controls
#
Extrusion controls #
# Extrusion settings
esettingspanel
=
root
.
newPanel
(
parentpanel
)
...
...
printrun/gui/graph.py
View file @
d6bd9e75
...
...
@@ -67,8 +67,8 @@ class Graph(BufferedCanvas):
if
self
.
rescaley
:
self
.
_ybounds
=
Graph
.
_YBounds
(
self
)
#If rescaley is set then ybars gives merely an estimate
#Note that "bars" actually indicate the number of internal+external gridlines.
#
If rescaley is set then ybars gives merely an estimate
#
Note that "bars" actually indicate the number of internal+external gridlines.
self
.
ybars
=
5
self
.
xbars
=
7
# One bar per 10 second
self
.
xsteps
=
60
# Covering 1 minute in the graph
...
...
@@ -99,22 +99,22 @@ class Graph(BufferedCanvas):
self
.
Refresh
()
def
drawgrid
(
self
,
dc
,
gc
):
#cold, medium, hot = wx.Colour(0, 167, 223),\
#
cold, medium, hot = wx.Colour(0, 167, 223),\
# wx.Colour(239, 233, 119),\
# wx.Colour(210, 50.100)
#col1 = wx.Colour(255, 0, 0, 255)
#col2 = wx.Colour(255, 255, 255, 128)
#
col1 = wx.Colour(255, 0, 0, 255)
#
col2 = wx.Colour(255, 255, 255, 128)
#b = gc.CreateLinearGradientBrush(0, 0, w, h, col1, col2)
#
b = gc.CreateLinearGradientBrush(0, 0, w, h, col1, col2)
gc
.
SetPen
(
wx
.
Pen
(
wx
.
Colour
(
255
,
0
,
0
,
0
),
1
))
#gc.SetBrush(wx.Brush(wx.Colour(245, 245, 255, 52)))
#
gc.SetBrush(wx.Brush(wx.Colour(245, 245, 255, 52)))
#gc.SetBrush(gc.CreateBrush(wx.Brush(wx.Colour(0, 0, 0, 255))))
#
gc.SetBrush(gc.CreateBrush(wx.Brush(wx.Colour(0, 0, 0, 255))))
gc
.
SetPen
(
wx
.
Pen
(
wx
.
Colour
(
255
,
0
,
0
,
255
),
1
))
#gc.DrawLines(wx.Point(0, 0), wx.Point(50, 10))
#
gc.DrawLines(wx.Point(0, 0), wx.Point(50, 10))
font
=
wx
.
Font
(
10
,
wx
.
DEFAULT
,
wx
.
NORMAL
,
wx
.
BOLD
)
gc
.
SetFont
(
font
,
wx
.
Colour
(
23
,
44
,
44
))
...
...
@@ -134,7 +134,7 @@ class Graph(BufferedCanvas):
firstbar
=
int
(
ceil
(
self
.
minyvalue
/
spacing
))
# in degrees
dc
.
SetPen
(
wx
.
Pen
(
wx
.
Colour
(
225
,
225
,
225
),
1
))
for
y
in
range
(
firstbar
,
firstbar
+
ybars
+
1
):
#y_pos = y*(float(self.height)/self.ybars)
#
y_pos = y*(float(self.height)/self.ybars)
degrees
=
y
*
spacing
y_pos
=
self
.
_y_pos
(
degrees
)
dc
.
DrawLine
(
0
,
y_pos
,
self
.
width
,
y_pos
)
...
...
@@ -148,15 +148,15 @@ class Graph(BufferedCanvas):
self
.
width
/
2
-
(
font
.
GetPointSize
()
*
3
),
self
.
height
/
2
-
(
font
.
GetPointSize
()
*
1
))
#dc.DrawCircle(50, 50, 1)
#
dc.DrawCircle(50, 50, 1)
#gc.SetPen(wx.Pen(wx.Colour(255, 0, 0, 0), 1))
#gc.DrawLines([[20, 30], [10, 53]])
#dc.SetPen(wx.Pen(wx.Colour(255, 0, 0, 0), 1))
#
gc.SetPen(wx.Pen(wx.Colour(255, 0, 0, 0), 1))
#
gc.DrawLines([[20, 30], [10, 53]])
#
dc.SetPen(wx.Pen(wx.Colour(255, 0, 0, 0), 1))
def
_y_pos
(
self
,
temperature
):
"""Converts a temperature, in degrees, to a pixel position"""
#fraction of the screen from the bottom
#
fraction of the screen from the bottom
frac
=
(
float
(
temperature
-
self
.
minyvalue
)
/
(
self
.
maxyvalue
-
self
.
minyvalue
))
return
int
((
1.0
-
frac
)
*
(
self
.
height
-
1
))
...
...
@@ -168,7 +168,7 @@ class Graph(BufferedCanvas):
log_yspan
=
log10
(
yspan
/
self
.
ybars
)
exponent
=
int
(
floor
(
log_yspan
))
#calculate boundary points between allowed spacings
#
calculate boundary points between allowed spacings
log1_25
=
log10
(
2
)
+
log10
(
1
)
+
log10
(
2.5
)
-
log10
(
1
+
2.5
)
log25_5
=
log10
(
2
)
+
log10
(
2.5
)
+
log10
(
5
)
-
log10
(
2.5
+
5
)
log5_10
=
log10
(
2
)
+
log10
(
5
)
+
log10
(
10
)
-
log10
(
5
+
10
)
...
...
@@ -205,7 +205,7 @@ class Graph(BufferedCanvas):
if
len
(
text
)
>
0
:
font
=
wx
.
Font
(
8
,
wx
.
DEFAULT
,
wx
.
NORMAL
,
wx
.
BOLD
)
#font = wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL)
#
font = wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL)
if
self
.
timer
.
IsRunning
()
is
False
:
gc
.
SetFont
(
font
,
wx
.
Colour
(
128
,
128
,
128
))
else
:
...
...
@@ -337,7 +337,7 @@ class Graph(BufferedCanvas):
# Frequency to rescale the graph
self
.
update_freq
=
10
#number of updates since last full refresh
#
number of updates since last full refresh
self
.
_last_update
=
self
.
update_freq
def
update
(
self
,
forceUpdate
=
False
):
...
...
@@ -418,7 +418,7 @@ class Graph(BufferedCanvas):
miny
=
min
(
miny
,
bed_min
,
bed_target
)
maxy
=
max
(
maxy
,
bed_max
,
bed_target
)
#We have to rescale, so add padding
#
We have to rescale, so add padding
bufratio
=
self
.
buffer
/
(
1.0
-
self
.
buffer
)
if
miny
<
self
.
graph
.
minyvalue
:
padding
=
(
self
.
graph
.
maxyvalue
-
miny
)
*
bufratio
...
...
printrun/gui/log.py
View file @
d6bd9e75
...
...
@@ -34,9 +34,7 @@ class LogPane(wx.BoxSizer):
root
.
commandbox
.
Bind
(
wx
.
EVT_CHAR
,
root
.
cbkey
)
root
.
commandbox
.
history
=
[
u""
]
root
.
commandbox
.
histindex
=
1
#root.printerControls.append(root.commandbox)
lbrs
.
Add
(
root
.
commandbox
,
1
)
root
.
sendbtn
=
make_button
(
bottom_panel
,
_
(
"Send"
),
root
.
sendline
,
_
(
"Send Command to Printer"
),
style
=
wx
.
BU_EXACTFIT
,
container
=
lbrs
)
#root.printerControls.append(root.sendbtn)
bottom_panel
.
SetSizer
(
lbrs
)
self
.
Add
(
bottom_panel
,
0
,
wx
.
EXPAND
)
printrun/gui/widgets.py
View file @
d6bd9e75
...
...
@@ -31,7 +31,6 @@ class MacroEditor(wx.Dialog):
self
.
panel
=
wx
.
Panel
(
self
,
-
1
)
titlesizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
self
.
titletext
=
wx
.
StaticText
(
self
.
panel
,
-
1
,
" _"
)
# title%macro_name)
#title.SetFont(wx.Font(11, wx.NORMAL, wx.NORMAL, wx.BOLD))
titlesizer
.
Add
(
self
.
titletext
,
1
)
self
.
findb
=
wx
.
Button
(
self
.
panel
,
-
1
,
_
(
"Find"
),
style
=
wx
.
BU_EXACTFIT
)
# New button for "Find" (Jezmy)
self
.
findb
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
find
)
...
...
@@ -66,11 +65,8 @@ class MacroEditor(wx.Dialog):
somecode
=
self
.
e
.
GetValue
()
position
=
somecode
.
find
(
FindValue
,
self
.
e
.
GetInsertionPoint
())
if
position
==
-
1
:
# ShowMessage(self,-1, "Not found!")
self
.
titletext
.
SetLabel
(
_
(
"Not Found!"
))
else
:
# self.title.SetValue("Position : "+str(position))
self
.
titletext
.
SetLabel
(
str
(
position
))
# ananswer = wx.MessageBox(str(numLines)+" Lines detected in file\n"+str(position), "OK")
...
...
@@ -101,7 +97,6 @@ class MacroEditor(wx.Dialog):
self
.
indent_chars
=
" "
unindented
=
""
lines
=
re
.
split
(
r"(?:\r\n?|\n)"
,
text
)
#print lines
if
len
(
lines
)
<=
1
:
return
text
for
line
in
lines
:
...
...
@@ -293,7 +288,8 @@ class TempGauge(wx.Panel):
dc
.
SetBackground
(
wx
.
Brush
(
self
.
bgcolor
))
dc
.
Clear
()
cold
,
medium
,
hot
=
wx
.
Colour
(
0
,
167
,
223
),
wx
.
Colour
(
239
,
233
,
119
),
wx
.
Colour
(
210
,
50.100
)
gauge1
,
gauge2
=
wx
.
Colour
(
255
,
255
,
210
),
(
self
.
gaugeColour
or
wx
.
Colour
(
234
,
82
,
0
))
# gauge1, gauge2 = wx.Colour(255, 255, 210), (self.gaugeColour or wx.Colour(234, 82, 0))
gauge1
=
wx
.
Colour
(
255
,
255
,
210
)
shadow1
,
shadow2
=
wx
.
Colour
(
110
,
110
,
110
),
self
.
bgcolor
gc
=
wx
.
GraphicsContext
.
Create
(
dc
)
# draw shadow first
...
...
@@ -319,8 +315,8 @@ class TempGauge(wx.Panel):
w1
=
y0
+
9
-
width
/
2
w2
=
w1
+
width
value
=
x0
+
max
(
10
,
min
(
self
.
width
+
1
-
2
,
int
(
self
.
value
*
self
.
scale
)))
#gc.SetBrush(gc.CreateLinearGradientBrush(x0, y0 + 3, x0, y0 + 15, gauge1, gauge2))
#gc.SetBrush(gc.CreateLinearGradientBrush(0, 3, 0, 15, wx.Colour(255, 255, 255), wx.Colour(255, 90, 32)))
#
gc.SetBrush(gc.CreateLinearGradientBrush(x0, y0 + 3, x0, y0 + 15, gauge1, gauge2))
#
gc.SetBrush(gc.CreateLinearGradientBrush(0, 3, 0, 15, wx.Colour(255, 255, 255), wx.Colour(255, 90, 32)))
gc
.
SetBrush
(
gc
.
CreateLinearGradientBrush
(
x0
,
y0
+
3
,
x0
,
y0
+
15
,
gauge1
,
self
.
interpolatedColour
(
value
,
x0
,
x1
,
xE
,
cold
,
medium
,
hot
)))
val_path
=
gc
.
CreatePath
()
val_path
.
MoveToPoint
(
x0
,
w1
)
...
...
@@ -328,7 +324,7 @@ class TempGauge(wx.Panel):
val_path
.
AddLineToPoint
(
value
+
2
,
w1
+
width
/
4
)
val_path
.
AddLineToPoint
(
value
+
2
,
w2
-
width
/
4
)
val_path
.
AddLineToPoint
(
value
,
w2
)
#val_path.AddLineToPoint(value-4, 10)
#
val_path.AddLineToPoint(value-4, 10)
val_path
.
AddLineToPoint
(
x0
,
w2
)
gc
.
DrawPath
(
val_path
)
# draw setpoint markers
...
...
@@ -344,8 +340,8 @@ class TempGauge(wx.Panel):
gc
.
DrawPath
(
setp_path
)
# draw readout
text
=
u"T
\u00B0
%
u/
%
u"
%
(
self
.
value
,
self
.
setpoint
)
#gc.SetFont(gc.CreateFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD), wx.WHITE))
#gc.DrawText(text, 29,-2)
#
gc.SetFont(gc.CreateFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD), wx.WHITE))
#
gc.DrawText(text, 29,-2)
gc
.
SetFont
(
gc
.
CreateFont
(
wx
.
Font
(
10
,
wx
.
FONTFAMILY_DEFAULT
,
wx
.
FONTSTYLE_NORMAL
,
wx
.
FONTWEIGHT_BOLD
),
wx
.
WHITE
))
gc
.
DrawText
(
self
.
title
,
x0
+
19
,
y0
+
4
)
gc
.
DrawText
(
text
,
x0
+
119
,
y0
+
4
)
...
...
printrun/gui/xybuttons.py
View file @
d6bd9e75
...
...
@@ -281,9 +281,9 @@ class XYButtons(BufferedCanvas):
# for idx, kpos in self.label_overlay_positions.items():
# dc.DrawCircle(kpos[0], kpos[1], kpos[2])
#
# ------ #
#
#
# Events #
#
#
# ------ #
#
#
------
#
#
Events
#
#
------
#
def
OnTopLevelKey
(
self
,
evt
):
# Let user press escape on any control, and return focus here
if
evt
.
GetKeyCode
()
==
wx
.
WXK_ESCAPE
:
...
...
printrun/gui/zbuttons.py
View file @
d6bd9e75
...
...
@@ -124,9 +124,9 @@ class ZButtons(BufferedCanvas):
gc
.
SetBrush
(
wx
.
Brush
(
self
.
bgcolormask
))
gc
.
DrawRectangle
(
0
,
0
,
w
,
h
)
#
# ------ #
#
#
# Events #
#
#
# ------ #
#
#
------
#
#
Events
#
#
------
#
def
OnMotion
(
self
,
event
):
if
not
self
.
enabled
:
...
...
printrun/gviz.py
View file @
d6bd9e75
...
...
@@ -72,7 +72,7 @@ class GvizWindow(GvizBaseFrame):
self
.
p
=
Gviz
(
panel
,
size
=
size
,
build_dimensions
=
build_dimensions
,
grid
=
grid
,
extrusion_width
=
extrusion_width
,
bgcolor
=
bgcolor
,
realparent
=
self
)
self
.
toolbar
.
AddSeparator
()
#self.toolbar.AddSimpleTool(6, wx.Image(imagefile('inject.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap(), _("Insert Code at start of this layer"), '')
#
self.toolbar.AddSimpleTool(6, wx.Image(imagefile('inject.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap(), _("Insert Code at start of this layer"), '')
self
.
toolbar
.
Realize
()
vbox
.
Add
(
self
.
p
,
1
,
wx
.
EXPAND
)
...
...
@@ -82,7 +82,7 @@ class GvizWindow(GvizBaseFrame):
self
.
Bind
(
wx
.
EVT_TOOL
,
lambda
x
:
self
.
p
.
layerup
(),
id
=
3
)
self
.
Bind
(
wx
.
EVT_TOOL
,
lambda
x
:
self
.
p
.
layerdown
(),
id
=
4
)
self
.
Bind
(
wx
.
EVT_TOOL
,
self
.
resetview
,
id
=
5
)
#self.Bind(wx.EVT_TOOL, lambda x:self.p.inject(), id = 6)
#
self.Bind(wx.EVT_TOOL, lambda x:self.p.inject(), id = 6)
self
.
initpos
=
None
self
.
p
.
Bind
(
wx
.
EVT_KEY_DOWN
,
self
.
key
)
...
...
@@ -201,7 +201,7 @@ class Gviz(wx.Panel):
self
.
paint_overlay
=
None
def
inject
(
self
):
#import pdb; pdb.set_trace()
#
import pdb; pdb.set_trace()
print
"Inject code here..."
print
"Layer "
+
str
(
self
.
layerindex
+
1
)
+
" - Z = "
+
str
(
self
.
get_currentz
())
+
" mm"
...
...
printrun/packer.py
View file @
d6bd9e75
#
#
Imported from python-rectangle-packer commit 32fce1aaba
#
#
https://github.com/maxretter/python-rectangle-packer
#
#
#
#
Python Rectangle Packer - Packs rectangles around a central point
#
#
Copyright (C) 2013 Max Retter
#
#
#
#
This program is free software: you can redistribute it and/or modify
#
#
it under the terms of the GNU General Public License as published by
#
#
the Free Software Foundation, either version 3 of the License, or
#
#
(at your option) any later version.
#
#
#
#
This program is distributed in the hope that it will be useful,
#
#
but WITHOUT ANY WARRANTY; without even the implied warranty of
#
#
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#
#
GNU General Public License for more details.
#
#
#
#
You should have received a copy of the GNU General Public License
#
#
along with this program. If not, see <http://www.gnu.org/licenses/>.
# Imported from python-rectangle-packer commit 32fce1aaba
# https://github.com/maxretter/python-rectangle-packer
#
# Python Rectangle Packer - Packs rectangles around a central point
# Copyright (C) 2013 Max Retter
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
math
...
...
@@ -67,7 +67,7 @@ class Rect(object):
self
.
height
=
height
self
.
data
=
data
#
#
upper left
# upper left
self
.
position
=
Vector2
()
def
half
(
self
):
...
...
@@ -130,7 +130,7 @@ class PointList(object):
index
=
i
+
1
segs
.
append
(
LineSegment
(
Vector2
(
self
.
points
[
index
-
1
][
0
],
self
.
points
[
index
-
1
][
1
]),
Vector2
(
self
.
points
[
index
-
1
][
0
],
self
.
points
[
index
-
1
][
1
]),
Vector2
(
self
.
points
[
index
][
0
],
self
.
points
[
index
][
1
])
))
...
...
@@ -158,17 +158,17 @@ class LineSegment(object):
seg_mag
=
segment_vector
.
magnitude
()
#
#
project point_vector on segment_vector
# project point_vector on segment_vector
projection
=
segment_vector
.
dot_product
(
point_vector
)
#
#
scalar value used to interpolate new point along segment_vector
# scalar value used to interpolate new point along segment_vector
scalar
=
projection
/
seg_mag
**
2
#
#
clamp on [0,1]
# clamp on [0,1]
scalar
=
1.0
if
scalar
>
1.0
else
scalar
scalar
=
0.0
if
scalar
<
0.0
else
scalar
#
#
interpolate scalar along segment and add start point back in
# interpolate scalar along segment and add start point back in
return
self
.
start
.
add
(
segment_vector
.
unit
()
.
scale
(
scalar
*
seg_mag
))
def
closest_distance_to_point
(
self
,
point
):
...
...
@@ -185,44 +185,44 @@ class Packer(object):
self
.
_rects
.
append
(
Rect
(
width
,
height
,
data
))
def
pack
(
self
,
padding
=
0
,
center
=
Vector2
()):
#
#
init everything
# init everything
placed_rects
=
[]
sorted_rects
=
sorted
(
self
.
_rects
,
key
=
lambda
rect
:
-
rect
.
area
())
#
#
double padding due to halfing later on
# double padding due to halfing later on
padding
*=
2
for
rect
in
sorted_rects
:
if
not
placed_rects
:
#
#
first rect, right on target.
# first rect, right on target.
rect
.
set_center
(
center
)
else
:
#
#
Expand each rectangle based on new rect size and padding
#
#
get a list of points
#
#
build a polygon
# Expand each rectangle based on new rect size and padding
# get a list of points
# build a polygon
point_lists
=
[
pr
.
expand
(
rect
.
width
+
padding
,
rect
.
height
+
padding
)
.
point_list
()
.
polygon
()
for
pr
in
placed_rects
]
#
#
take the union of all the polygons (relies on + operator override)
#
#
the [0] at the end returns the first "contour", which is the only one we need
# take the union of all the polygons (relies on + operator override)
# the [0] at the end returns the first "contour", which is the only one we need
bounding_points
=
PointList
(
sum
(
point_lists
[
1
:],
point_lists
[
0
]
)[
0
])
#
#
find the closest segment
# find the closest segment
closest_segments
=
sorted
(
bounding_points
.
segments
(),
key
=
lambda
segment
:
segment
.
closest_distance_to_point
(
center
)
)
#
#
get the closest point
# get the closest point
place_point
=
closest_segments
[
0
]
.
closest_point_to_point
(
center
)
#
#
set the rect position
# set the rect position
rect
.
set_center
(
place_point
)
placed_rects
.
append
(
rect
)
...
...
printrun/pronterface.py
View file @
d6bd9e75
...
...
@@ -177,7 +177,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self
.
display_graph
=
self
.
settings
.
tempgraph
self
.
display_gauges
=
self
.
settings
.
tempgauges
#set feedrates in printcore for pause/resume
#
set feedrates in printcore for pause/resume
self
.
p
.
xy_feedrate
=
self
.
settings
.
xy_feedrate
self
.
p
.
z_feedrate
=
self
.
settings
.
z_feedrate
...
...
@@ -361,7 +361,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
def
do_settemp
(
self
,
l
=
""
):
try
:
if
not
l
.
__class__
in
(
str
,
unicode
)
or
not
len
(
l
):
if
l
.
__class__
not
in
(
str
,
unicode
)
or
not
len
(
l
):
l
=
str
(
self
.
htemp
.
GetValue
()
.
split
()[
0
])
l
=
l
.
lower
()
.
replace
(
", "
,
"."
)
for
i
in
self
.
temps
.
keys
():
...
...
@@ -381,7 +381,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
def
do_bedtemp
(
self
,
l
=
""
):
try
:
if
not
l
.
__class__
in
(
str
,
unicode
)
or
not
len
(
l
):
if
l
.
__class__
not
in
(
str
,
unicode
)
or
not
len
(
l
):
l
=
str
(
self
.
btemp
.
GetValue
()
.
split
()[
0
])
l
=
l
.
lower
()
.
replace
(
", "
,
"."
)
for
i
in
self
.
bedtemps
.
keys
():
...
...
@@ -401,7 +401,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
def
do_setspeed
(
self
,
l
=
""
):
try
:
if
not
l
.
__class__
in
(
str
,
unicode
)
or
not
len
(
l
):
if
l
.
__class__
not
in
(
str
,
unicode
)
or
not
len
(
l
):
l
=
str
(
self
.
speed_slider
.
GetValue
())
else
:
l
=
l
.
lower
()
...
...
@@ -1175,7 +1175,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
self
.
p
.
pause
()
self
.
p
.
runSmallScript
(
self
.
pauseScript
)
self
.
paused
=
True
#self.p.runSmallScript(self.pauseScript)
#
self.p.runSmallScript(self.pauseScript)
self
.
extra_print_time
+=
int
(
time
.
time
()
-
self
.
starttime
)
wx
.
CallAfter
(
self
.
pausebtn
.
SetLabel
,
_
(
"Resume"
))
wx
.
CallAfter
(
self
.
toolbarsizer
.
Layout
)
...
...
@@ -1213,7 +1213,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
self
.
recvlisteners
.
append
(
self
.
waitforsdresponse
)
self
.
p
.
send_now
(
"M23 "
+
target
.
lower
())
dlg
.
Destroy
()
#print self.sdfiles
#
print self.sdfiles
def
getfiles
(
self
):
if
not
self
.
p
.
online
:
...
...
@@ -1695,7 +1695,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
self
.
endcb
()
return
if
"SD printing byte"
in
l
:
#M27 handler
#
M27 handler
try
:
resp
=
l
.
split
()
vals
=
resp
[
-
1
]
.
split
(
"/"
)
...
...
@@ -1718,7 +1718,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
if
btndef
is
None
:
if
i
==
len
(
custombuttons
)
-
1
:
self
.
newbuttonbutton
=
b
=
wx
.
Button
(
self
.
centerpanel
,
-
1
,
"+"
,
size
=
(
19
,
18
),
style
=
wx
.
BU_EXACTFIT
)
#b.SetFont(wx.Font(12, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
#
b.SetFont(wx.Font(12, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
b
.
SetForegroundColour
(
"#4444ff"
)
b
.
SetToolTip
(
wx
.
ToolTip
(
_
(
"click to add new custom button"
)))
b
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
cbutton_edit
)
...
...
@@ -1755,7 +1755,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
return
rest
[
1
:]
.
split
(
'"'
,
1
)
else
:
return
rest
.
split
(
None
,
1
)
#try:
#
try:
num
,
argstr
=
nextarg
(
argstr
)
num
=
int
(
num
)
title
,
argstr
=
nextarg
(
argstr
)
...
...
@@ -1777,7 +1777,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
self
.
custombuttons
[
num
]
.
background
=
colour
if
not
self
.
processing_rc
:
self
.
cbuttons_reload
()
#except Exception, x:
#
except Exception, x:
# print "Bad syntax for button definition, see 'help button'"
# print x
...
...
@@ -1788,7 +1788,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
elif
bdef
.
background
:
colour
=
bdef
.
background
if
type
(
colour
)
not
in
(
str
,
unicode
):
#print type(colour), map(type, colour)
#
print type(colour), map(type, colour)
if
type
(
colour
)
==
tuple
and
tuple
(
map
(
type
,
colour
))
==
(
int
,
int
,
int
):
colour
=
map
(
lambda
x
:
x
%
256
,
colour
)
colour
=
wx
.
Colour
(
*
colour
)
.
GetAsString
(
wx
.
C2S_NAME
|
wx
.
C2S_HTML_SYNTAX
)
...
...
@@ -1807,7 +1807,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
if
button
.
properties
.
background
:
colour
=
button
.
properties
.
background
if
type
(
colour
)
not
in
(
str
,
unicode
):
#print type(colour)
#
print type(colour)
if
type
(
colour
)
==
tuple
and
tuple
(
map
(
type
,
colour
))
==
(
int
,
int
,
int
):
colour
=
map
(
lambda
x
:
x
%
256
,
colour
)
colour
=
wx
.
Colour
(
*
colour
)
.
GetAsString
(
wx
.
C2S_NAME
|
wx
.
C2S_HTML_SYNTAX
)
...
...
@@ -1846,7 +1846,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
self
.
custombuttons
[
n
],
self
.
custombuttons
[
n
+
1
]
=
self
.
custombuttons
[
n
+
1
],
self
.
custombuttons
[
n
]
self
.
cbutton_save
(
n
,
self
.
custombuttons
[
n
])
self
.
cbutton_save
(
n
+
1
,
self
.
custombuttons
[
n
+
1
])
#if self.custombuttons[-1] is None:
#
if self.custombuttons[-1] is None:
# del self.custombuttons[-1]
wx
.
CallAfter
(
self
.
cbuttons_reload
)
...
...
@@ -1889,15 +1889,15 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
if
not
hasattr
(
self
,
"dragging"
):
# init dragging of the custom button
if
hasattr
(
obj
,
"custombutton"
)
and
obj
.
properties
is
not
None
:
#self.newbuttonbutton.SetLabel("")
#self.newbuttonbutton.SetFont(wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
#self.newbuttonbutton.SetForegroundColour("black")
#self.newbuttonbutton.SetSize(obj.GetSize())
#if self.toolbarsizer.GetItem(self.newbuttonbutton) is not None:
#
self.newbuttonbutton.SetLabel("")
#
self.newbuttonbutton.SetFont(wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
#
self.newbuttonbutton.SetForegroundColour("black")
#
self.newbuttonbutton.SetSize(obj.GetSize())
#
if self.toolbarsizer.GetItem(self.newbuttonbutton) is not None:
# self.toolbarsizer.SetItemMinSize(self.newbuttonbutton, obj.GetSize())
# self.mainsizer.Layout()
for
b
in
self
.
custombuttons_widgets
:
#if b.IsFrozen(): b.Thaw()
#
if b.IsFrozen(): b.Thaw()
if
b
.
properties
is
None
:
b
.
Enable
()
b
.
SetLabel
(
""
)
...
...
@@ -1930,7 +1930,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
if
b
.
GetScreenRect
()
.
Contains
(
scrpos
):
dst
=
b
break
#if dst is None and self.panel.GetScreenRect().Contains(scrpos):
#
if dst is None and self.panel.GetScreenRect().Contains(scrpos):
# # try to check if it is after buttons at the end
# tspos = self.panel.ClientToScreen(self.toolbarsizer.GetPosition())
# bspos = self.panel.ClientToScreen(self.cbuttonssizer.GetPosition())
...
...
@@ -2047,7 +2047,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
hbox
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
okb
=
wx
.
Button
(
dialog
,
wx
.
ID_OK
,
_
(
"Ok"
),
size
=
(
60
,
24
))
dialog
.
Bind
(
wx
.
EVT_TEXT_ENTER
,
lambda
e
:
dialog
.
EndModal
(
wx
.
ID_OK
),
dialog
.
namectrl
)
#dialog.Bind(wx.EVT_BUTTON, lambda e:self.new_macro_named(dialog, e), okb)
#
dialog.Bind(wx.EVT_BUTTON, lambda e:self.new_macro_named(dialog, e), okb)
hbox
.
Add
(
okb
)
hbox
.
Add
(
wx
.
Button
(
dialog
,
wx
.
ID_CANCEL
,
_
(
"Cancel"
),
size
=
(
60
,
24
)))
vbox
.
Add
(
panel
)
...
...
printrun/stlplater.py
View file @
d6bd9e75
...
...
@@ -127,28 +127,28 @@ class showstl(wx.Window):
def
keypress
(
self
,
event
):
"""gets keypress events and moves/rotates acive shape"""
keycode
=
event
.
GetKeyCode
()
#print keycode
#
print keycode
step
=
5
angle
=
18
if
event
.
ControlDown
():
step
=
1
angle
=
1
#h
#
h
if
keycode
==
72
:
self
.
move_shape
((
-
step
,
0
))
#l
#
l
if
keycode
==
76
:
self
.
move_shape
((
step
,
0
))
#j
#
j
if
keycode
==
75
:
self
.
move_shape
((
0
,
step
))
#k
#
k
if
keycode
==
74
:
self
.
move_shape
((
0
,
-
step
))
#[
#
[
if
keycode
==
91
:
self
.
rotate_shape
(
-
angle
)
#]
#
]
if
keycode
==
93
:
self
.
rotate_shape
(
angle
)
event
.
Skip
()
...
...
@@ -297,7 +297,7 @@ class StlPlater(Plater):
self
.
s
.
drawmodel
(
newmodel
,
2
)
break
else
:
#Filter out the path, just show the STL filename.
#
Filter out the path, just show the STL filename.
self
.
load_stl_into_model
(
name
,
name
)
self
.
Refresh
()
...
...
@@ -402,4 +402,4 @@ class StlPlater(Plater):
del
models
[
name
]
break
if
p
.
wait
()
!=
0
:
raise
RuntimeError
,
_
(
"simarrange failed"
)
raise
RuntimeError
(
_
(
"simarrange failed"
)
)
printrun/stltool.py
View file @
d6bd9e75
...
...
@@ -39,14 +39,14 @@ I = [
def
transpose
(
matrix
):
return
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
):
return
map
(
sum
,
transpose
(
map
(
lambda
x
:
[
x
[
0
]
*
p
for
p
in
x
[
1
]],
zip
(
vector
,
transpose
(
matrix
)))))
def
applymatrix
(
facet
,
matrix
=
I
):
#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 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
genfacet
(
map
(
lambda
x
:
multmatrix
(
x
+
[
1
],
matrix
)[:
3
],
facet
[
1
]))
f
=
[[
0
,
0
,
0
],
[[
-
3.022642
,
0.642482
,
-
9.510565
],
[
-
3.022642
,
0.642482
,
-
9.510565
],
[
-
3.022642
,
0.642482
,
-
9.510565
]]]
...
...
@@ -70,7 +70,7 @@ def emitstl(filename, facets = [], objname = "stltool_export", binary = 1):
for
j
in
i
[
1
]:
l
+=
j
[:]
l
+=
[
0
]
#print len(l)
#
print len(l)
buf
+=
facetformat
.
pack
(
*
l
)
f
.
write
(
buf
)
f
.
close
()
...
...
@@ -204,7 +204,7 @@ class stl(object):
if
l
.
startswith
(
"solid"
):
self
.
insolid
=
1
self
.
name
=
l
[
6
:]
#print self.name
#
print self.name
elif
l
.
startswith
(
"endsolid"
):
self
.
insolid
=
0
...
...
@@ -244,4 +244,4 @@ if __name__ == "__main__":
print
i
,
len
(
working
)
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 @
d6bd9e75
...
...
@@ -21,11 +21,17 @@ import time
import
pyglet
pyglet
.
options
[
'debug_gl'
]
=
True
from
pyglet.gl
import
*
from
pyglet.gl
import
GL_AMBIENT_AND_DIFFUSE
,
glBegin
,
glClearColor
,
\
glColor3f
,
GL_CULL_FACE
,
GL_DEPTH_TEST
,
GL_DIFFUSE
,
GL_EMISSION
,
\
glEnable
,
glEnd
,
GL_FILL
,
GLfloat
,
GL_FRONT_AND_BACK
,
GL_LIGHT0
,
\
GL_LIGHT1
,
glLightfv
,
GL_LIGHTING
,
GL_LINE
,
glMaterialf
,
glMaterialfv
,
\
glMultMatrixd
,
glNormal3f
,
glPolygonMode
,
glPopMatrix
,
GL_POSITION
,
\
glPushMatrix
,
glRotatef
,
glScalef
,
glShadeModel
,
GL_SHININESS
,
\
GL_SMOOTH
,
GL_SPECULAR
,
glTranslatef
,
GL_TRIANGLES
,
glVertex3f
from
pyglet
import
gl
from
.gl.panel
import
wxGLPanel
from
.gl.trackball
import
trackball
,
mulquat
,
build_rotmatrix
from
.gl.trackball
import
build_rotmatrix
from
.gl.libtatlin
import
actors
def
vec
(
*
args
):
...
...
@@ -44,7 +50,7 @@ class stlview(object):
# 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))]
#print indices[:10]
#
print indices[:10]
self
.
vertex_list
=
batch
.
add_indexed
(
len
(
vertices
)
//
3
,
GL_TRIANGLES
,
None
,
# group,
...
...
@@ -87,25 +93,25 @@ class StlViewPanel(wxGLPanel):
self
.
mview_initialized
=
False
super
(
StlViewPanel
,
self
)
.
OnReshape
()
#==========================================================================
#
==========================================================================
# GLFrame OpenGL Event Handlers
#==========================================================================
#
==========================================================================
def
OnInitGL
(
self
,
call_reshape
=
True
):
'''Initialize OpenGL for use in the window.'''
if
self
.
GLinitialized
:
return
self
.
GLinitialized
=
True
#create a pyglet context for this panel
#
create a pyglet context for this panel
self
.
pygletcontext
=
gl
.
Context
(
gl
.
current_context
)
self
.
pygletcontext
.
canvas
=
self
self
.
pygletcontext
.
set_current
()
#normal gl init
#
normal gl init
glClearColor
(
0
,
0
,
0
,
1
)
glColor3f
(
1
,
0
,
0
)
glEnable
(
GL_DEPTH_TEST
)
glEnable
(
GL_CULL_FACE
)
# Uncomment this line for a wireframe view
#glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
#
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
# Simple light setup. On Windows GL_LIGHT0 is enabled by default,
# but this is not the case on Linux or Mac, so remember to always
...
...
@@ -202,22 +208,22 @@ class StlViewPanel(wxGLPanel):
if
event
.
ControlDown
():
step
=
1
angle
=
1
#h
#
h
if
keycode
==
72
:
self
.
parent
.
move_shape
((
-
step
,
0
))
#l
#
l
if
keycode
==
76
:
self
.
parent
.
move_shape
((
step
,
0
))
#j
#
j
if
keycode
==
75
:
self
.
parent
.
move_shape
((
0
,
step
))
#k
#
k
if
keycode
==
74
:
self
.
parent
.
move_shape
((
0
,
-
step
))
#[
#
[
if
keycode
==
91
:
self
.
parent
.
rotate_shape
(
-
angle
)
#]
#
]
if
keycode
==
93
:
self
.
parent
.
rotate_shape
(
angle
)
event
.
Skip
()
...
...
@@ -235,7 +241,7 @@ class StlViewPanel(wxGLPanel):
v
+=
g
*
dt
if
obj
.
offsets
[
2
]
<
0
:
obj
.
scale
[
2
]
*=
1
-
3
*
dt
#return
#
return
v
=
v
/
4
while
obj
.
offsets
[
2
]
<
basepos
:
time
.
sleep
(
dt
)
...
...
@@ -256,8 +262,8 @@ class StlViewPanel(wxGLPanel):
stlview
(
m
.
facets
,
batch
=
batch
)
m
.
batch
=
batch
m
.
animoffset
=
300
#print m
#threading.Thread(target = self.anim, args = (m, )).start()
#
print m
#
threading.Thread(target = self.anim, args = (m, )).start()
wx
.
CallAfter
(
self
.
Refresh
)
def
update_object_resize
(
self
):
...
...
printrun/zscaper.py
View file @
d6bd9e75
...
...
@@ -22,11 +22,11 @@ def genscape(data = [[0, 1, 0, 0], [1, 0, 2, 0], [1, 0, 0, 0], [0, 1, 0, 1]],
o
=
stl
(
None
)
datal
=
len
(
data
)
datah
=
len
(
data
[
0
])
#create bottom:
#
create bottom:
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
]:
#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
],
[[
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
+=
[
genfacet
([[
0.0
,
pscale
*
i
[
0
],
data
[
i
[
0
]][
0
]
*
zscale
+
bheight
],
[
0.0
,
pscale
*
i
[
1
],
data
[
i
[
1
]][
0
]
*
zscale
+
bheight
],
[
0.0
,
pscale
*
i
[
1
],
0.0
]])]
...
...
@@ -34,7 +34,7 @@ def genscape(data = [[0, 1, 0, 0], [1, 0, 2, 0], [1, 0, 0, 0], [0, 1, 0, 1]],
o
.
facets
+=
[
genfacet
([[
0.0
,
pscale
*
i
[
0
],
data
[
i
[
0
]][
0
]
*
zscale
+
bheight
],
[
0.0
,
pscale
*
i
[
1
],
0.0
],
[
0.0
,
pscale
*
i
[
0
],
0.0
]])]
o
.
facets
+=
[
genfacet
([[
2.0
*
bmidpoint
[
1
],
pscale
*
i
[
1
],
0.0
],
[
2.0
*
bmidpoint
[
1
],
pscale
*
i
[
0
],
data
[
i
[
0
]][
datah
-
1
]
*
zscale
+
bheight
],
[
2.0
*
bmidpoint
[
1
],
pscale
*
i
[
0
],
0.0
]])]
for
i
in
zip
(
range
(
datah
+
1
)[:
-
1
],
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
[
0
],
2.0
*
bmidpoint
[
0
],
0.0
],
[
pscale
*
i
[
1
],
2.0
*
bmidpoint
[
0
],
0.0
],
[
bmidpoint
[
0
],
bmidpoint
[
1
],
0.0
]]]]
o
.
facets
+=
[
genfacet
([[
pscale
*
i
[
1
],
0.0
,
data
[
0
][
i
[
1
]]
*
zscale
+
bheight
],
[
pscale
*
i
[
0
],
0.0
,
data
[
0
][
i
[
0
]]
*
zscale
+
bheight
],
[
pscale
*
i
[
1
],
0.0
,
0.0
]])]
...
...
@@ -45,7 +45,7 @@ def genscape(data = [[0, 1, 0, 0], [1, 0, 2, 0], [1, 0, 0, 0], [0, 1, 0, 1]],
for
j
in
xrange
(
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
+
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]
return
o
def
zimage
(
name
,
out
):
i
=
wx
.
Image
(
name
)
...
...
@@ -55,7 +55,7 @@ def zimage(name, out):
data
=
[]
for
i
in
xrange
(
s
[
0
]):
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
)
"""
...
...
pronterface.py
View file @
d6bd9e75
...
...
@@ -18,7 +18,7 @@
import
sys
try
:
import
wx
import
wx
# NOQA
except
:
print
(
"wxPython is not installed. This program requires wxPython to run."
)
if
sys
.
version_info
.
major
>=
3
:
...
...
setup.py
View file @
d6bd9e75
...
...
@@ -122,8 +122,8 @@ if sys.argv[1] in("install", "uninstall") and len(prefix):
target_images_path
=
"share/pronterface/images/"
data_files
=
[(
'share/pixmaps/'
,
[
'pronterface.png'
,
'plater.png'
,
'pronsole.png'
]),
(
'share/applications'
,
[
'pronterface.desktop'
,
'pronsole.desktop'
,
'plater.desktop'
]),
(
'share/appdata'
,
[
'pronterface.appdata.xml'
,
'pronsole.appdata.xml'
,
'plater.appdata.xml'
])]
(
'share/applications'
,
[
'pronterface.desktop'
,
'pronsole.desktop'
,
'plater.desktop'
]),
(
'share/appdata'
,
[
'pronterface.appdata.xml'
,
'pronsole.appdata.xml'
,
'plater.appdata.xml'
])]
for
basedir
,
subdirs
,
files
in
os
.
walk
(
"images"
):
images
=
[]
...
...
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