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
a6b9c72d
Commit
a6b9c72d
authored
Apr 02, 2014
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Protect light gcode model as well with locks
parent
aa2da210
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
68 deletions
+76
-68
actors.py
printrun/gl/libtatlin/actors.py
+76
-68
No files found.
printrun/gl/libtatlin/actors.py
View file @
a6b9c72d
...
@@ -507,11 +507,11 @@ class GcodeModel(Model):
...
@@ -507,11 +507,11 @@ class GcodeModel(Model):
yield
layer_idx
yield
layer_idx
layer_idx
+=
1
layer_idx
+=
1
with
self
.
lock
:
self
.
dims
=
((
model_data
.
xmin
,
model_data
.
xmax
,
model_data
.
width
),
self
.
dims
=
((
model_data
.
xmin
,
model_data
.
xmax
,
model_data
.
width
),
(
model_data
.
ymin
,
model_data
.
ymax
,
model_data
.
depth
),
(
model_data
.
ymin
,
model_data
.
ymax
,
model_data
.
depth
),
(
model_data
.
zmin
,
model_data
.
zmax
,
model_data
.
height
))
(
model_data
.
zmin
,
model_data
.
zmax
,
model_data
.
height
))
with
self
.
lock
:
self
.
travels
.
resize
(
travel_vertex_k
,
refcheck
=
False
)
self
.
travels
.
resize
(
travel_vertex_k
,
refcheck
=
False
)
self
.
vertices
.
resize
(
vertex_k
,
refcheck
=
False
)
self
.
vertices
.
resize
(
vertex_k
,
refcheck
=
False
)
self
.
colors
.
resize
(
color_k
,
refcheck
=
False
)
self
.
colors
.
resize
(
color_k
,
refcheck
=
False
)
...
@@ -735,6 +735,7 @@ class GcodeModelLight(Model):
...
@@ -735,6 +735,7 @@ class GcodeModelLight(Model):
self
.
printed_until
=
-
1
self
.
printed_until
=
-
1
self
.
only_current
=
False
self
.
only_current
=
False
while
layer_idx
<
len
(
model_data
.
all_layers
):
while
layer_idx
<
len
(
model_data
.
all_layers
):
with
self
.
lock
:
nlines
=
len
(
model_data
)
nlines
=
len
(
model_data
)
if
nlines
*
6
!=
vertices
.
size
:
if
nlines
*
6
!=
vertices
.
size
:
self
.
vertices
.
resize
(
nlines
*
6
,
refcheck
=
False
)
self
.
vertices
.
resize
(
nlines
*
6
,
refcheck
=
False
)
...
@@ -784,6 +785,7 @@ class GcodeModelLight(Model):
...
@@ -784,6 +785,7 @@ class GcodeModelLight(Model):
yield
layer_idx
yield
layer_idx
layer_idx
+=
1
layer_idx
+=
1
with
self
.
lock
:
self
.
dims
=
((
model_data
.
xmin
,
model_data
.
xmax
,
model_data
.
width
),
self
.
dims
=
((
model_data
.
xmin
,
model_data
.
xmax
,
model_data
.
width
),
(
model_data
.
ymin
,
model_data
.
ymax
,
model_data
.
depth
),
(
model_data
.
ymin
,
model_data
.
ymax
,
model_data
.
depth
),
(
model_data
.
zmin
,
model_data
.
zmax
,
model_data
.
height
))
(
model_data
.
zmin
,
model_data
.
zmax
,
model_data
.
height
))
...
@@ -829,11 +831,14 @@ class GcodeModelLight(Model):
...
@@ -829,11 +831,14 @@ class GcodeModelLight(Model):
# ------------------------------------------------------------------------
# ------------------------------------------------------------------------
def
init
(
self
):
def
init
(
self
):
with
self
.
lock
:
self
.
layers_loaded
=
self
.
max_layers
self
.
initialized
=
True
self
.
vertex_buffer
=
numpy2vbo
(
self
.
vertices
,
use_vbos
=
self
.
use_vbos
)
self
.
vertex_buffer
=
numpy2vbo
(
self
.
vertices
,
use_vbos
=
self
.
use_vbos
)
self
.
vertex_color_buffer
=
numpy2vbo
(
self
.
colors
,
use_vbos
=
self
.
use_vbos
)
# each pair of vertices shares the color
self
.
vertex_color_buffer
=
numpy2vbo
(
self
.
colors
,
use_vbos
=
self
.
use_vbos
)
# each pair of vertices shares the color
self
.
initialized
=
True
def
display
(
self
,
mode_2d
=
False
):
def
display
(
self
,
mode_2d
=
False
):
with
self
.
lock
:
glPushMatrix
()
glPushMatrix
()
glTranslatef
(
self
.
offset_x
,
self
.
offset_y
,
0
)
glTranslatef
(
self
.
offset_x
,
self
.
offset_y
,
0
)
glEnableClientState
(
GL_VERTEX_ARRAY
)
glEnableClientState
(
GL_VERTEX_ARRAY
)
...
@@ -859,12 +864,15 @@ class GcodeModelLight(Model):
...
@@ -859,12 +864,15 @@ class GcodeModelLight(Model):
else
:
else
:
glColorPointer
(
4
,
GL_FLOAT
,
0
,
self
.
vertex_color_buffer
.
ptr
)
glColorPointer
(
4
,
GL_FLOAT
,
0
,
self
.
vertex_color_buffer
.
ptr
)
# Prevent race condition by using the number of currently loaded layers
max_layers
=
self
.
layers_loaded
start
=
0
start
=
0
if
self
.
num_layers_to_draw
<=
self
.
max_layers
:
if
self
.
num_layers_to_draw
<=
max_layers
:
end_prev_layer
=
self
.
layer_stops
[
self
.
num_layers_to_draw
-
1
]
end_prev_layer
=
self
.
layer_stops
[
self
.
num_layers_to_draw
-
1
]
else
:
else
:
end_prev_layer
=
-
1
end_prev_layer
=
-
1
end
=
self
.
layer_stops
[
min
(
self
.
num_layers_to_draw
,
self
.
max_layers
)]
end
=
self
.
layer_stops
[
min
(
self
.
num_layers_to_draw
,
max_layers
)]
glDisableClientState
(
GL_COLOR_ARRAY
)
glDisableClientState
(
GL_COLOR_ARRAY
)
...
...
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