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
871edba8
Commit
871edba8
authored
Jun 15, 2013
by
D1plo1d
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'experimental' of github.com:kliment/Printrun into experimental
parents
01b7e909
4de130a1
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
302 additions
and
52 deletions
+302
-52
printcore.py
printcore.py
+2
-2
gcoder.py
printrun/gcoder.py
+20
-20
gcoder_line.pyx
printrun/gcoder_line.pyx
+233
-0
gui.py
printrun/gui.py
+4
-2
gviz.py
printrun/gviz.py
+34
-25
actors.py
printrun/libtatlin/actors.py
+1
-1
setup.py
setup.py
+8
-2
No files found.
printcore.py
View file @
871edba8
...
@@ -102,10 +102,10 @@ class printcore():
...
@@ -102,10 +102,10 @@ class printcore():
self
.
stop_read_thread
=
True
self
.
stop_read_thread
=
True
self
.
read_thread
.
join
()
self
.
read_thread
.
join
()
self
.
read_thread
=
None
self
.
read_thread
=
None
self
.
_stop_sender
()
if
self
.
print_thread
:
if
self
.
print_thread
:
self
.
printing
=
False
self
.
printing
=
False
self
.
print_thread
.
join
()
self
.
print_thread
.
join
()
self
.
_stop_sender
()
try
:
try
:
self
.
printer
.
close
()
self
.
printer
.
close
()
except
socket
.
error
:
except
socket
.
error
:
...
@@ -429,7 +429,7 @@ class printcore():
...
@@ -429,7 +429,7 @@ class printcore():
traceback
.
print_exc
()
traceback
.
print_exc
()
finally
:
finally
:
self
.
print_thread
=
None
self
.
print_thread
=
None
if
self
.
stop_send_thread
==
False
:
self
.
_start_sender
()
self
.
_start_sender
()
#now only "pause" is implemented as host command
#now only "pause" is implemented as host command
def
processHostCommand
(
self
,
command
):
def
processHostCommand
(
self
,
command
):
...
...
printrun/gcoder.py
View file @
871edba8
...
@@ -37,10 +37,11 @@ class PyLine(object):
...
@@ -37,10 +37,11 @@ class PyLine(object):
def
__getattr__
(
self
,
name
):
def
__getattr__
(
self
,
name
):
return
None
return
None
def
set
(
self
,
name
,
value
):
try
:
setattr
(
self
,
name
,
value
)
import
gcoder_line
LineBase
=
gcoder_line
.
GLine
LineBase
=
PyLine
except
ImportError
:
LineBase
=
PyLine
class
Line
(
LineBase
):
class
Line
(
LineBase
):
...
@@ -48,10 +49,10 @@ class Line(LineBase):
...
@@ -48,10 +49,10 @@ class Line(LineBase):
def
__init__
(
self
,
l
):
def
__init__
(
self
,
l
):
super
(
Line
,
self
)
.
__init__
()
super
(
Line
,
self
)
.
__init__
()
self
.
set
(
"raw"
,
l
)
self
.
raw
=
l
self
.
s
et
(
"split_raw"
,
gcode_exp
.
findall
(
self
.
raw
.
lower
()
))
self
.
s
plit_raw
=
gcode_exp
.
findall
(
self
.
raw
.
lower
(
))
self
.
set
(
"command"
,
self
.
split_raw
[
0
]
.
upper
()
if
not
self
.
split_raw
[
0
]
.
startswith
(
"n"
)
else
self
.
split_raw
[
1
]
.
upper
()
)
self
.
command
=
self
.
split_raw
[
0
]
.
upper
()
if
not
self
.
split_raw
[
0
]
.
startswith
(
"n"
)
else
self
.
split_raw
[
1
]
.
upper
(
)
self
.
set
(
"is_move"
,
self
.
command
in
move_gcodes
)
self
.
is_move
=
self
.
command
in
move_gcodes
def
parse_coordinates
(
self
,
imperial
=
False
,
force
=
False
):
def
parse_coordinates
(
self
,
imperial
=
False
,
force
=
False
):
# Not a G-line, we don't want to parse its arguments
# Not a G-line, we don't want to parse its arguments
...
@@ -61,13 +62,13 @@ class Line(LineBase):
...
@@ -61,13 +62,13 @@ class Line(LineBase):
for
bit
in
self
.
split_raw
:
for
bit
in
self
.
split_raw
:
code
=
bit
[
0
]
code
=
bit
[
0
]
if
code
in
gcode_parsed_args
and
len
(
bit
)
>
1
:
if
code
in
gcode_parsed_args
and
len
(
bit
)
>
1
:
se
lf
.
set
(
code
,
25.4
*
float
(
bit
[
1
:]))
se
tattr
(
self
,
code
,
25.4
*
float
(
bit
[
1
:]))
else
:
else
:
for
bit
in
self
.
split_raw
:
for
bit
in
self
.
split_raw
:
code
=
bit
[
0
]
code
=
bit
[
0
]
if
code
in
gcode_parsed_args
and
len
(
bit
)
>
1
:
if
code
in
gcode_parsed_args
and
len
(
bit
)
>
1
:
se
lf
.
set
(
code
,
float
(
bit
[
1
:]))
se
tattr
(
self
,
code
,
float
(
bit
[
1
:]))
self
.
set
(
"split_raw"
,
None
)
del
self
.
split_raw
def
__repr__
(
self
):
def
__repr__
(
self
):
return
self
.
raw
return
self
.
raw
...
@@ -123,9 +124,9 @@ class Layer(object):
...
@@ -123,9 +124,9 @@ class Layer(object):
current_y
=
line
.
y
or
current_y
current_y
=
line
.
y
or
current_y
current_z
=
line
.
z
or
current_z
current_z
=
line
.
z
or
current_z
line
.
set
(
"current_x"
,
current_x
)
line
.
current_x
=
current_x
line
.
set
(
"current_y"
,
current_y
)
line
.
current_y
=
current_y
line
.
set
(
"current_z"
,
current_z
)
line
.
current_z
=
current_z
return
(
current_x
,
current_y
,
current_z
),
(
xmin
,
xmax
),
(
ymin
,
ymax
),
(
zmin
,
zmax
)
return
(
current_x
,
current_y
,
current_z
),
(
xmin
,
xmax
),
(
ymin
,
ymax
),
(
zmin
,
zmax
)
class
GCode
(
object
):
class
GCode
(
object
):
...
@@ -192,9 +193,9 @@ class GCode(object):
...
@@ -192,9 +193,9 @@ class GCode(object):
current_tool
=
self
.
current_tool
current_tool
=
self
.
current_tool
for
line
in
lines
:
for
line
in
lines
:
if
line
.
is_move
:
if
line
.
is_move
:
line
.
set
(
"relative"
,
relative
)
line
.
relative
=
relative
line
.
set
(
"relative_e"
,
relative_e
)
line
.
relative_e
=
relative_e
line
.
set
(
"current_tool"
,
current_tool
)
line
.
current_tool
=
current_tool
elif
line
.
command
==
"G20"
:
elif
line
.
command
==
"G20"
:
imperial
=
True
imperial
=
True
elif
line
.
command
==
"G21"
:
elif
line
.
command
==
"G21"
:
...
@@ -230,10 +231,10 @@ class GCode(object):
...
@@ -230,10 +231,10 @@ class GCode(object):
continue
continue
if
line
.
is_move
:
if
line
.
is_move
:
if
line
.
relative_e
:
if
line
.
relative_e
:
line
.
set
(
"extruding"
,
line
.
e
!=
0
)
line
.
extruding
=
line
.
e
!=
0
total_e
+=
line
.
e
total_e
+=
line
.
e
else
:
else
:
line
.
set
(
"extruding"
,
line
.
e
!=
cur_e
)
line
.
extruding
=
line
.
e
!=
cur_e
total_e
+=
line
.
e
-
cur_e
total_e
+=
line
.
e
-
cur_e
cur_e
=
line
.
e
cur_e
=
line
.
e
max_e
=
max
(
max_e
,
total_e
)
max_e
=
max
(
max_e
,
total_e
)
...
@@ -417,6 +418,5 @@ def main():
...
@@ -417,6 +418,5 @@ def main():
print
"Number of layers:
%
d"
%
gcode
.
num_layers
()
print
"Number of layers:
%
d"
%
gcode
.
num_layers
()
print
"Estimated duration:
%
s"
%
gcode
.
estimate_duration
()
print
"Estimated duration:
%
s"
%
gcode
.
estimate_duration
()
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
main
()
main
()
printrun/gcoder_line.pyx
0 → 100644
View file @
871edba8
# This file is copied from GCoder.
#
# GCoder 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.
#
# GCoder 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/>.
from libc.stdlib cimport malloc, free
from libc.stdint cimport uint32_t
cdef extern from "string.h":
char *strncpy(char *dest, char *src, size_t n)
size_t strlen(const char *s)
cdef char* copy_string(object value):
cdef char* orig = value
str_len = len(orig)
cdef char* array = <char *>malloc(str_len + 1)
strncpy(array, orig, str_len)
array[str_len] = 0;
return array
cdef enum BitPos:
pos_x = 1 << 0
pos_y = 1 << 1
pos_z = 1 << 2
pos_e = 1 << 3
pos_f = 1 << 4
pos_i = 1 << 5
pos_j = 1 << 6
pos_s = 1 << 7
pos_p = 1 << 8
pos_is_move = 1 << 9
pos_relative = 1 << 10
pos_relative_e = 1 << 11
pos_extruding = 1 << 12
pos_current_x = 1 << 13
pos_current_y = 1 << 14
pos_current_z = 1 << 15
pos_current_tool = 1 << 16
pos_raw = 1 << 17
pos_split_raw = 1 << 18
pos_command = 1 << 19
pos_gcview_end_vertex = 1 << 20
cdef inline uint32_t has_var(uint32_t status, uint32_t pos):
return status & pos
cdef inline uint32_t set_has_var(uint32_t status, uint32_t pos):
return status | pos
cdef inline uint32_t unset_has_var(uint32_t status, uint32_t pos):
return status & ~pos
cdef class GLine(object):
cdef char* _raw
cdef char* _command
cdef object _split_raw
cdef float _x, _y, _z, _e, _f, _i, _j, _s, _p
cdef float _current_x, _current_y, _current_z
cdef uint32_t _gcview_end_vertex
cdef uint32_t _status
cdef char _current_tool
__slots__ = ()
def __cinit__(self):
self._status = 0
self._raw = NULL
self._command = NULL
def __dealloc__(self):
if self._raw != NULL: free(self._raw)
if self._command != NULL: free(self._command)
property x:
def __get__(self):
if has_var(self._status, pos_x): return self._x
else: return None
def __set__(self, value):
self._x = value
self._status = set_has_var(self._status, pos_x)
property y:
def __get__(self):
if has_var(self._status, pos_y): return self._y
else: return None
def __set__(self, value):
self._y = value
self._status = set_has_var(self._status, pos_y)
property z:
def __get__(self):
if has_var(self._status, pos_z): return self._z
else: return None
def __set__(self, value):
self._z = value
self._status = set_has_var(self._status, pos_z)
property e:
def __get__(self):
if has_var(self._status, pos_e): return self._e
else: return None
def __set__(self, value):
self._e = value
self._status = set_has_var(self._status, pos_e)
property f:
def __get__(self):
if has_var(self._status, pos_f): return self._f
else: return None
def __set__(self, value):
self._f = value
self._status = set_has_var(self._status, pos_f)
property i:
def __get__(self):
if has_var(self._status, pos_i): return self._i
else: return None
def __set__(self, value):
self._i = value
self._status = set_has_var(self._status, pos_i)
property j:
def __get__(self):
if has_var(self._status, pos_j): return self._j
else: return None
def __set__(self, value):
self._j = value
self._status = set_has_var(self._status, pos_j)
property s:
def __get__(self):
if has_var(self._status, pos_s): return self._s
else: return None
def __set__(self, value):
self._s = value
self._status = set_has_var(self._status, pos_s)
property p:
def __get__(self):
if has_var(self._status, pos_p): return self._p
else: return None
def __set__(self, value):
self._p = value
self._status = set_has_var(self._status, pos_p)
property is_move:
def __get__(self):
if has_var(self._status, pos_is_move): return True
else: return False
def __set__(self, value):
if value: self._status = set_has_var(self._status, pos_is_move)
else: self._status = unset_has_var(self._status, pos_is_move)
property relative:
def __get__(self):
if has_var(self._status, pos_relative): return True
else: return False
def __set__(self, value):
if value: self._status = set_has_var(self._status, pos_relative)
else: self._status = unset_has_var(self._status, pos_relative)
property relative_e:
def __get__(self):
if has_var(self._status, pos_relative_e): return True
else: return False
def __set__(self, value):
if value: self._status = set_has_var(self._status, pos_relative_e)
else: self._status = unset_has_var(self._status, pos_relative_e)
property extruding:
def __get__(self):
if has_var(self._status, pos_extruding): return True
else: return False
def __set__(self, value):
if value: self._status = set_has_var(self._status, pos_extruding)
else: self._status = unset_has_var(self._status, pos_extruding)
property current_x:
def __get__(self):
if has_var(self._status, pos_current_x): return self._current_x
else: return None
def __set__(self, value):
self._current_x = value
self._status = set_has_var(self._status, pos_current_x)
property current_y:
def __get__(self):
if has_var(self._status, pos_current_y): return self._current_y
else: return None
def __set__(self, value):
self._current_y = value
self._status = set_has_var(self._status, pos_current_y)
property current_z:
def __get__(self):
if has_var(self._status, pos_current_z): return self._current_z
else: return None
def __set__(self, value):
self._current_z = value
self._status = set_has_var(self._status, pos_current_z)
property current_tool:
def __get__(self):
if has_var(self._status, pos_current_tool): return self._current_tool
else: return None
def __set__(self, value):
self._current_tool = value
self._status = set_has_var(self._status, pos_current_tool)
property gcview_end_vertex:
def __get__(self):
if has_var(self._status, pos_gcview_end_vertex): return self._gcview_end_vertex
else: return None
def __set__(self, value):
self._gcview_end_vertex = value
self._status = set_has_var(self._status, pos_gcview_end_vertex)
property split_raw:
def __get__(self):
if has_var(self._status, pos_split_raw): return self._split_raw
else: return None
def __set__(self, value):
self._split_raw = value
self._status = set_has_var(self._status, pos_split_raw)
def __del__(self):
self._split_raw = None
property raw:
def __get__(self):
if has_var(self._status, pos_raw): return self._raw
else: return None
def __set__(self, value):
self._raw = copy_string(value)
self._status = set_has_var(self._status, pos_raw)
property command:
def __get__(self):
if has_var(self._status, pos_command): return self._command
else: return None
def __set__(self, value):
self._command = copy_string(value)
self._status = set_has_var(self._status, pos_command)
printrun/gui.py
View file @
871edba8
...
@@ -269,7 +269,8 @@ class VizPane(wx.BoxSizer):
...
@@ -269,7 +269,8 @@ class VizPane(wx.BoxSizer):
root
.
gviz
=
gviz
.
gviz
(
parentpanel
,
(
300
,
300
),
root
.
gviz
=
gviz
.
gviz
(
parentpanel
,
(
300
,
300
),
build_dimensions
=
root
.
build_dimensions_list
,
build_dimensions
=
root
.
build_dimensions_list
,
grid
=
(
root
.
settings
.
preview_grid_step1
,
root
.
settings
.
preview_grid_step2
),
grid
=
(
root
.
settings
.
preview_grid_step1
,
root
.
settings
.
preview_grid_step2
),
extrusion_width
=
root
.
settings
.
preview_extrusion_width
)
extrusion_width
=
root
.
settings
.
preview_extrusion_width
,
bgcolor
=
root
.
settings
.
bgcolor
)
root
.
gviz
.
SetToolTip
(
wx
.
ToolTip
(
"Click to examine / edit
\n
layers of loaded file"
))
root
.
gviz
.
SetToolTip
(
wx
.
ToolTip
(
"Click to examine / edit
\n
layers of loaded file"
))
root
.
gviz
.
showall
=
1
root
.
gviz
.
showall
=
1
root
.
gviz
.
Bind
(
wx
.
EVT_LEFT_DOWN
,
root
.
showwin
)
root
.
gviz
.
Bind
(
wx
.
EVT_LEFT_DOWN
,
root
.
showwin
)
...
@@ -290,7 +291,8 @@ class VizPane(wx.BoxSizer):
...
@@ -290,7 +291,8 @@ class VizPane(wx.BoxSizer):
root
.
gwindow
=
gviz
.
window
([],
root
.
gwindow
=
gviz
.
window
([],
build_dimensions
=
root
.
build_dimensions_list
,
build_dimensions
=
root
.
build_dimensions_list
,
grid
=
(
root
.
settings
.
preview_grid_step1
,
root
.
settings
.
preview_grid_step2
),
grid
=
(
root
.
settings
.
preview_grid_step1
,
root
.
settings
.
preview_grid_step2
),
extrusion_width
=
root
.
settings
.
preview_extrusion_width
)
extrusion_width
=
root
.
settings
.
preview_extrusion_width
,
bgcolor
=
root
.
settings
.
bgcolor
)
root
.
gwindow
.
Bind
(
wx
.
EVT_CLOSE
,
lambda
x
:
root
.
gwindow
.
Hide
())
root
.
gwindow
.
Bind
(
wx
.
EVT_CLOSE
,
lambda
x
:
root
.
gwindow
.
Hide
())
if
not
isinstance
(
root
.
gviz
,
NoViz
):
if
not
isinstance
(
root
.
gviz
,
NoViz
):
self
.
Add
(
root
.
gviz
.
widget
,
1
,
flag
=
wx
.
SHAPED
|
wx
.
ALIGN_CENTER_HORIZONTAL
)
self
.
Add
(
root
.
gviz
.
widget
,
1
,
flag
=
wx
.
SHAPED
|
wx
.
ALIGN_CENTER_HORIZONTAL
)
...
...
printrun/gviz.py
View file @
871edba8
...
@@ -23,14 +23,14 @@ from printrun_utils import imagefile
...
@@ -23,14 +23,14 @@ from printrun_utils import imagefile
ID_ABOUT
=
101
ID_ABOUT
=
101
ID_EXIT
=
110
ID_EXIT
=
110
class
window
(
wx
.
Frame
):
class
window
(
wx
.
Frame
):
def
__init__
(
self
,
f
,
size
=
(
600
,
600
),
build_dimensions
=
[
200
,
200
,
100
,
0
,
0
,
0
],
grid
=
(
10
,
50
),
extrusion_width
=
0.5
):
def
__init__
(
self
,
f
,
size
=
(
600
,
600
),
build_dimensions
=
[
200
,
200
,
100
,
0
,
0
,
0
],
grid
=
(
10
,
50
),
extrusion_width
=
0.5
,
bgcolor
=
"#000000"
):
wx
.
Frame
.
__init__
(
self
,
None
,
title
=
"Gcode view, shift to move view, mousewheel to set layer"
,
size
=
size
)
wx
.
Frame
.
__init__
(
self
,
None
,
title
=
"Gcode view, shift to move view, mousewheel to set layer"
,
size
=
size
)
self
.
CreateStatusBar
(
1
);
self
.
CreateStatusBar
(
1
);
self
.
SetStatusText
(
"Layer number and Z position show here when you scroll"
);
self
.
SetStatusText
(
"Layer number and Z position show here when you scroll"
);
panel
=
wx
.
Panel
(
self
,
-
1
)
panel
=
wx
.
Panel
(
self
,
-
1
)
self
.
p
=
gviz
(
panel
,
size
=
size
,
build_dimensions
=
build_dimensions
,
grid
=
grid
,
extrusion_width
=
extrusion_width
,
realparent
=
self
)
self
.
p
=
gviz
(
panel
,
size
=
size
,
build_dimensions
=
build_dimensions
,
grid
=
grid
,
extrusion_width
=
extrusion_width
,
bgcolor
=
bgcolor
,
realparent
=
self
)
vbox
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
vbox
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
toolbar
=
wx
.
ToolBar
(
panel
,
-
1
,
style
=
wx
.
TB_HORIZONTAL
|
wx
.
NO_BORDER
)
toolbar
=
wx
.
ToolBar
(
panel
,
-
1
,
style
=
wx
.
TB_HORIZONTAL
|
wx
.
NO_BORDER
)
...
@@ -128,10 +128,12 @@ class gviz(wx.Panel):
...
@@ -128,10 +128,12 @@ class gviz(wx.Panel):
self
.
_showall
=
showall
self
.
_showall
=
showall
showall
=
property
(
_get_showall
,
_set_showall
)
showall
=
property
(
_get_showall
,
_set_showall
)
def
__init__
(
self
,
parent
,
size
=
(
200
,
200
),
build_dimensions
=
[
200
,
200
,
100
,
0
,
0
,
0
],
grid
=
(
10
,
50
),
extrusion_width
=
0.5
,
realparent
=
None
):
def
__init__
(
self
,
parent
,
size
=
(
200
,
200
),
build_dimensions
=
[
200
,
200
,
100
,
0
,
0
,
0
],
grid
=
(
10
,
50
),
extrusion_width
=
0.5
,
bgcolor
=
"#000000"
,
realparent
=
None
):
wx
.
Panel
.
__init__
(
self
,
parent
,
-
1
,
size
=
size
)
wx
.
Panel
.
__init__
(
self
,
parent
,
-
1
)
self
.
widget
=
self
self
.
widget
=
self
self
.
SetMinSize
((
150
,
150
))
size
=
[
max
(
1.0
,
x
)
for
x
in
size
]
ratio
=
size
[
0
]
/
size
[
1
]
self
.
SetMinSize
((
150
,
150
/
ratio
))
self
.
parent
=
realparent
if
realparent
else
parent
self
.
parent
=
realparent
if
realparent
else
parent
self
.
size
=
size
self
.
size
=
size
self
.
build_dimensions
=
build_dimensions
self
.
build_dimensions
=
build_dimensions
...
@@ -163,7 +165,9 @@ class gviz(wx.Panel):
...
@@ -163,7 +165,9 @@ class gviz(wx.Panel):
self
.
hilightqueue
=
Queue
(
0
)
self
.
hilightqueue
=
Queue
(
0
)
self
.
hilightarcsqueue
=
Queue
(
0
)
self
.
hilightarcsqueue
=
Queue
(
0
)
self
.
dirty
=
1
self
.
dirty
=
1
self
.
blitmap
=
wx
.
EmptyBitmap
(
self
.
GetClientSize
()[
0
],
self
.
GetClientSize
()[
1
],
-
1
)
self
.
bgcolor
=
wx
.
Colour
()
self
.
bgcolor
.
SetFromName
(
bgcolor
)
self
.
blitmap
=
wx
.
EmptyBitmap
(
self
.
GetClientSize
()[
0
],
self
.
GetClientSize
()[
1
],
-
1
)
def
inject
(
self
):
def
inject
(
self
):
#import pdb; pdb.set_trace()
#import pdb; pdb.set_trace()
...
@@ -217,11 +221,10 @@ class gviz(wx.Panel):
...
@@ -217,11 +221,10 @@ class gviz(wx.Panel):
float
(
self
.
size
[
1
]
-
1
)
/
self
.
build_dimensions
[
1
])]
float
(
self
.
size
[
1
]
-
1
)
/
self
.
build_dimensions
[
1
])]
def
resize
(
self
,
event
):
def
resize
(
self
,
event
):
old
side
=
max
(
1.0
,
min
(
self
.
size
))
old
_basescale
=
self
.
basescale
self
.
size
=
self
.
GetClientSizeTuple
()
self
.
size
=
self
.
GetClientSizeTuple
()
self
.
update_basescale
()
self
.
update_basescale
()
newside
=
max
(
1.0
,
min
(
self
.
size
))
zoomratio
=
float
(
self
.
basescale
[
0
])
/
old_basescale
[
0
]
zoomratio
=
float
(
newside
)
/
oldside
wx
.
CallLater
(
200
,
self
.
zoom
,
0
,
0
,
zoomratio
)
wx
.
CallLater
(
200
,
self
.
zoom
,
0
,
0
,
zoomratio
)
def
zoom
(
self
,
x
,
y
,
factor
):
def
zoom
(
self
,
x
,
y
,
factor
):
...
@@ -230,8 +233,8 @@ class gviz(wx.Panel):
...
@@ -230,8 +233,8 @@ class gviz(wx.Panel):
x
=
y
=
side
/
2
x
=
y
=
side
/
2
self
.
scale
=
[
s
*
factor
for
s
in
self
.
scale
]
self
.
scale
=
[
s
*
factor
for
s
in
self
.
scale
]
self
.
translate
=
[
x
-
(
x
-
self
.
translate
[
0
])
*
factor
,
self
.
translate
=
[
x
-
(
x
-
self
.
translate
[
0
])
*
factor
,
y
-
(
y
-
self
.
translate
[
1
])
*
factor
]
y
-
(
y
-
self
.
translate
[
1
])
*
factor
]
penwidth
=
max
(
1.0
,
self
.
filament_width
*
((
self
.
scale
[
0
]
+
self
.
scale
[
1
])
/
2.0
))
penwidth
=
max
(
1.0
,
self
.
filament_width
*
((
self
.
scale
[
0
]
+
self
.
scale
[
1
])
/
2.0
))
for
pen
in
self
.
penslist
:
for
pen
in
self
.
penslist
:
pen
.
SetWidth
(
penwidth
)
pen
.
SetWidth
(
penwidth
)
...
@@ -239,18 +242,18 @@ class gviz(wx.Panel):
...
@@ -239,18 +242,18 @@ class gviz(wx.Panel):
wx
.
CallAfter
(
self
.
Refresh
)
wx
.
CallAfter
(
self
.
Refresh
)
def
_line_scaler
(
self
,
x
):
def
_line_scaler
(
self
,
x
):
return
(
self
.
scale
[
0
]
*
x
[
0
]
+
self
.
translate
[
0
]
,
return
(
self
.
scale
[
0
]
*
x
[
0
],
self
.
scale
[
1
]
*
x
[
1
]
+
self
.
translate
[
1
]
,
self
.
scale
[
1
]
*
x
[
1
],
self
.
scale
[
0
]
*
x
[
2
]
+
self
.
translate
[
0
]
,
self
.
scale
[
0
]
*
x
[
2
],
self
.
scale
[
1
]
*
x
[
3
]
+
self
.
translate
[
1
]
,)
self
.
scale
[
1
]
*
x
[
3
],)
def
_arc_scaler
(
self
,
x
):
def
_arc_scaler
(
self
,
x
):
return
(
self
.
scale
[
0
]
*
x
[
0
]
+
self
.
translate
[
0
]
,
return
(
self
.
scale
[
0
]
*
x
[
0
],
self
.
scale
[
1
]
*
x
[
1
]
+
self
.
translate
[
1
]
,
self
.
scale
[
1
]
*
x
[
1
],
self
.
scale
[
0
]
*
x
[
2
]
+
self
.
translate
[
0
]
,
self
.
scale
[
0
]
*
x
[
2
],
self
.
scale
[
1
]
*
x
[
3
]
+
self
.
translate
[
1
]
,
self
.
scale
[
1
]
*
x
[
3
],
self
.
scale
[
0
]
*
x
[
4
]
+
self
.
translate
[
0
]
,
self
.
scale
[
0
]
*
x
[
4
],
self
.
scale
[
1
]
*
x
[
5
]
+
self
.
translate
[
1
]
,)
self
.
scale
[
1
]
*
x
[
5
],)
def
_drawlines
(
self
,
dc
,
lines
,
pens
):
def
_drawlines
(
self
,
dc
,
lines
,
pens
):
scaled_lines
=
map
(
self
.
_line_scaler
,
lines
)
scaled_lines
=
map
(
self
.
_line_scaler
,
lines
)
...
@@ -264,7 +267,9 @@ class gviz(wx.Panel):
...
@@ -264,7 +267,9 @@ class gviz(wx.Panel):
dc
.
DrawArc
(
*
scaled_arcs
[
i
])
dc
.
DrawArc
(
*
scaled_arcs
[
i
])
def
repaint_everything
(
self
):
def
repaint_everything
(
self
):
self
.
blitmap
=
wx
.
EmptyBitmap
(
self
.
GetClientSize
()[
0
],
self
.
GetClientSize
()[
1
],
-
1
)
width
=
self
.
scale
[
0
]
*
self
.
build_dimensions
[
0
]
height
=
self
.
scale
[
1
]
*
self
.
build_dimensions
[
1
]
self
.
blitmap
=
wx
.
EmptyBitmap
(
width
+
1
,
height
+
1
,
-
1
)
dc
=
wx
.
MemoryDC
()
dc
=
wx
.
MemoryDC
()
dc
.
SelectObject
(
self
.
blitmap
)
dc
.
SelectObject
(
self
.
blitmap
)
dc
.
SetBackground
(
wx
.
Brush
((
250
,
250
,
200
)))
dc
.
SetBackground
(
wx
.
Brush
((
250
,
250
,
200
)))
...
@@ -273,9 +278,11 @@ class gviz(wx.Panel):
...
@@ -273,9 +278,11 @@ class gviz(wx.Panel):
for
grid_unit
in
self
.
grid
:
for
grid_unit
in
self
.
grid
:
if
grid_unit
>
0
:
if
grid_unit
>
0
:
for
x
in
xrange
(
int
(
self
.
build_dimensions
[
0
]
/
grid_unit
)
+
1
):
for
x
in
xrange
(
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
])
draw_x
=
self
.
scale
[
0
]
*
x
*
grid_unit
dc
.
DrawLine
(
draw_x
,
0
,
draw_x
,
height
)
for
y
in
xrange
(
int
(
self
.
build_dimensions
[
1
]
/
grid_unit
)
+
1
):
for
y
in
xrange
(
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
)
draw_y
=
self
.
scale
[
1
]
*
(
self
.
build_dimensions
[
1
]
-
y
*
grid_unit
)
dc
.
DrawLine
(
0
,
draw_y
,
width
,
draw_y
)
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
:
...
@@ -327,7 +334,9 @@ class gviz(wx.Panel):
...
@@ -327,7 +334,9 @@ class gviz(wx.Panel):
self
.
repaint_everything
()
self
.
repaint_everything
()
self
.
paint_hilights
()
self
.
paint_hilights
()
dc
=
wx
.
PaintDC
(
self
)
dc
=
wx
.
PaintDC
(
self
)
dc
.
DrawBitmap
(
self
.
blitmap
,
0
,
0
)
dc
.
SetBackground
(
wx
.
Brush
(
self
.
bgcolor
))
dc
.
Clear
()
dc
.
DrawBitmap
(
self
.
blitmap
,
self
.
translate
[
0
],
self
.
translate
[
1
])
def
addfile
(
self
,
gcode
):
def
addfile
(
self
,
gcode
):
self
.
clear
()
self
.
clear
()
...
...
printrun/libtatlin/actors.py
View file @
871edba8
...
@@ -267,7 +267,7 @@ class GcodeModel(Model):
...
@@ -267,7 +267,7 @@ class GcodeModel(Model):
color_list
.
append
(
vertex_color
)
color_list
.
append
(
vertex_color
)
prev_pos
=
current_pos
prev_pos
=
current_pos
gline
.
set
(
"gcview_end_vertex"
,
len
(
vertex_list
)
)
gline
.
gcview_end_vertex
=
len
(
vertex_list
)
self
.
layer_stops
.
append
(
len
(
vertex_list
))
self
.
layer_stops
.
append
(
len
(
vertex_list
))
...
...
setup.py
View file @
871edba8
...
@@ -21,6 +21,11 @@ from stat import *
...
@@ -21,6 +21,11 @@ from stat import *
from
distutils.core
import
setup
from
distutils.core
import
setup
from
distutils.command.install
import
install
as
_install
from
distutils.command.install
import
install
as
_install
from
distutils.command.install_data
import
install_data
as
_install_data
from
distutils.command.install_data
import
install_data
as
_install_data
try
:
from
Cython.Build
import
cythonize
extensions
=
cythonize
(
"printrun/gcoder_line.pyx"
)
except
ImportError
:
extensions
=
None
INSTALLED_FILES
=
"installed_files"
INSTALLED_FILES
=
"installed_files"
...
@@ -84,7 +89,7 @@ class uninstall (_install):
...
@@ -84,7 +89,7 @@ class uninstall (_install):
except
:
except
:
self
.
warn
(
"Could not remove file
%
s"
%
file
)
self
.
warn
(
"Could not remove file
%
s"
%
file
)
ops
=
(
"install"
,
"build"
,
"sdist"
,
"uninstall"
,
"clean"
)
ops
=
(
"install"
,
"build"
,
"sdist"
,
"uninstall"
,
"clean"
,
"build_ext"
)
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
)
...
@@ -148,5 +153,6 @@ setup (
...
@@ -148,5 +153,6 @@ setup (
scripts
=
[
"pronsole.py"
,
"pronterface.py"
,
"plater.py"
,
"printcore.py"
,
"prontserve.py"
],
scripts
=
[
"pronsole.py"
,
"pronterface.py"
,
"plater.py"
,
"printcore.py"
,
"prontserve.py"
],
cmdclass
=
{
"uninstall"
:
uninstall
,
cmdclass
=
{
"uninstall"
:
uninstall
,
"install"
:
install
,
"install"
:
install
,
"install_data"
:
install_data
}
"install_data"
:
install_data
},
ext_modules
=
extensions
,
)
)
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