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
d4e01201
Commit
d4e01201
authored
Jul 20, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Heavily speedup 2D viewer loading speed by using gcoder correctly (#412)
parent
6f9a56ba
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
49 deletions
+50
-49
gviz.py
printrun/gviz.py
+50
-49
No files found.
printrun/gviz.py
View file @
d4e01201
...
@@ -380,7 +380,7 @@ class Gviz(wx.Panel):
...
@@ -380,7 +380,7 @@ class Gviz(wx.Panel):
def
addfile
(
self
,
gcode
):
def
addfile
(
self
,
gcode
):
self
.
clear
()
self
.
clear
()
self
.
add_parsed_gcodes
(
gcode
.
lines
)
self
.
add_parsed_gcodes
(
gcode
)
max_layers
=
len
(
self
.
layers
)
max_layers
=
len
(
self
.
layers
)
if
hasattr
(
self
.
parent
,
"layerslider"
):
if
hasattr
(
self
.
parent
,
"layerslider"
):
self
.
parent
.
layerslider
.
SetRange
(
0
,
max_layers
-
1
)
self
.
parent
.
layerslider
.
SetRange
(
0
,
max_layers
-
1
)
...
@@ -390,60 +390,61 @@ class Gviz(wx.Panel):
...
@@ -390,60 +390,61 @@ class Gviz(wx.Panel):
# the reason addgcode is not factored as a add_parsed_gcodes([gline]) is
# the reason addgcode is not factored as a add_parsed_gcodes([gline]) is
# because when loading a file there's no hilight, so it simply lets us not
# because when loading a file there's no hilight, so it simply lets us not
# do the if hilight: all the time for nothing when loading a lot of lines
# do the if hilight: all the time for nothing when loading a lot of lines
def
add_parsed_gcodes
(
self
,
lines
):
def
add_parsed_gcodes
(
self
,
gcode
):
def
_y
(
y
):
def
_y
(
y
):
return
self
.
build_dimensions
[
1
]
-
(
y
-
self
.
build_dimensions
[
4
])
return
self
.
build_dimensions
[
1
]
-
(
y
-
self
.
build_dimensions
[
4
])
def
_x
(
x
):
def
_x
(
x
):
return
x
-
self
.
build_dimensions
[
3
]
return
x
-
self
.
build_dimensions
[
3
]
for
gline
in
lines
:
for
layer_idx
,
layer
in
enumerate
(
gcode
.
all_layers
):
if
gline
.
command
not
in
[
"G0"
,
"G1"
,
"G2"
,
"G3"
]:
has_move
=
False
for
gline
in
layer
:
if
gline
.
is_move
:
has_move
=
True
break
if
not
has_move
:
continue
continue
self
.
lines
[
layer
.
z
]
=
[]
target
=
self
.
lastpos
[:]
self
.
pens
[
layer
.
z
]
=
[]
target
[
5
]
=
0.0
self
.
arcs
[
layer
.
z
]
=
[]
target
[
6
]
=
0.0
self
.
arcpens
[
layer
.
z
]
=
[]
if
gline
.
relative
:
self
.
layers
.
append
(
layer
.
z
)
if
gline
.
x
!=
None
:
target
[
0
]
+=
gline
.
x
for
gline
in
layer
:
if
gline
.
y
!=
None
:
target
[
1
]
+=
gline
.
y
if
not
gline
.
is_move
:
if
gline
.
z
!=
None
:
target
[
2
]
+=
gline
.
z
continue
else
:
if
gline
.
x
!=
None
:
target
[
0
]
=
gline
.
x
target
=
self
.
lastpos
[:]
if
gline
.
y
!=
None
:
target
[
1
]
=
gline
.
y
target
[
0
]
=
gline
.
current_x
if
gline
.
z
!=
None
:
target
[
2
]
=
gline
.
z
target
[
1
]
=
gline
.
current_y
if
gline
.
e
!=
None
:
target
[
2
]
=
gline
.
current_z
if
gline
.
relative_e
:
target
[
5
]
=
0.0
target
[
3
]
+=
gline
.
e
target
[
6
]
=
0.0
else
:
if
gline
.
e
!=
None
:
target
[
3
]
=
gline
.
e
if
gline
.
relative_e
:
if
gline
.
f
!=
None
:
target
[
4
]
=
gline
.
f
target
[
3
]
+=
gline
.
e
if
gline
.
i
!=
None
:
target
[
5
]
=
gline
.
i
else
:
if
gline
.
j
!=
None
:
target
[
6
]
=
gline
.
j
target
[
3
]
=
gline
.
e
z
=
target
[
2
]
if
gline
.
f
!=
None
:
target
[
4
]
=
gline
.
f
if
z
not
in
self
.
layers
:
if
gline
.
i
!=
None
:
target
[
5
]
=
gline
.
i
self
.
lines
[
z
]
=
[]
if
gline
.
j
!=
None
:
target
[
6
]
=
gline
.
j
self
.
pens
[
z
]
=
[]
self
.
arcs
[
z
]
=
[]
start_pos
=
self
.
lastpos
[:]
self
.
arcpens
[
z
]
=
[]
self
.
layers
.
append
(
z
)
if
gline
.
command
in
[
"G0"
,
"G1"
]:
self
.
lines
[
layer
.
z
]
.
append
((
_x
(
start_pos
[
0
]),
_y
(
start_pos
[
1
]),
_x
(
target
[
0
]),
_y
(
target
[
1
])))
start_pos
=
self
.
lastpos
[:]
self
.
pens
[
layer
.
z
]
.
append
(
self
.
mainpen
if
target
[
3
]
!=
self
.
lastpos
[
3
]
else
self
.
travelpen
)
elif
gline
.
command
in
[
"G2"
,
"G3"
]:
if
gline
.
command
in
[
"G0"
,
"G1"
]:
# startpos, endpos, arc center
self
.
lines
[
z
]
.
append
((
_x
(
start_pos
[
0
]),
_y
(
start_pos
[
1
]),
_x
(
target
[
0
]),
_y
(
target
[
1
])))
arc
=
[
_x
(
start_pos
[
0
]),
_y
(
start_pos
[
1
]),
self
.
pens
[
z
]
.
append
(
self
.
mainpen
if
target
[
3
]
!=
self
.
lastpos
[
3
]
else
self
.
travelpen
)
_x
(
target
[
0
]),
_y
(
target
[
1
]),
elif
gline
.
command
in
[
"G2"
,
"G3"
]:
_x
(
start_pos
[
0
]
+
target
[
5
]),
_y
(
start_pos
[
1
]
+
target
[
6
])]
# startpos, endpos, arc center
if
gline
.
command
==
"G2"
:
# clockwise, reverse endpoints
arc
=
[
_x
(
start_pos
[
0
]),
_y
(
start_pos
[
1
]),
arc
[
0
],
arc
[
1
],
arc
[
2
],
arc
[
3
]
=
arc
[
2
],
arc
[
3
],
arc
[
0
],
arc
[
1
]
_x
(
target
[
0
]),
_y
(
target
[
1
]),
_x
(
start_pos
[
0
]
+
target
[
5
]),
_y
(
start_pos
[
1
]
+
target
[
6
])]
self
.
arcs
[
layer
.
z
]
.
append
(
arc
)
if
gline
.
command
==
"G2"
:
# clockwise, reverse endpoints
self
.
arcpens
[
layer
.
z
]
.
append
(
self
.
arcpen
)
arc
[
0
],
arc
[
1
],
arc
[
2
],
arc
[
3
]
=
arc
[
2
],
arc
[
3
],
arc
[
0
],
arc
[
1
]
self
.
lastpos
=
target
self
.
arcs
[
z
]
.
append
(
arc
)
self
.
arcpens
[
z
]
.
append
(
self
.
arcpen
)
self
.
lastpos
=
target
self
.
dirty
=
1
self
.
dirty
=
1
self
.
Refresh
()
self
.
Refresh
()
...
...
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