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
e2359ce6
Commit
e2359ce6
authored
Jun 18, 2013
by
D1plo1d
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'experimental' of github.com:kliment/Printrun into experimental
parents
ab95356d
46c2805d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
6 deletions
+38
-6
gcview.py
printrun/gcview.py
+34
-6
actors.py
printrun/libtatlin/actors.py
+4
-0
No files found.
printrun/gcview.py
View file @
e2359ce6
...
@@ -125,17 +125,21 @@ class wxGLPanel(wx.Panel):
...
@@ -125,17 +125,21 @@ class wxGLPanel(wx.Panel):
glOrtho
(
-
width
/
2
,
width
/
2
,
-
height
/
2
,
height
/
2
,
0.1
,
3
*
self
.
dist
)
glOrtho
(
-
width
/
2
,
width
/
2
,
-
height
/
2
,
height
/
2
,
0.1
,
3
*
self
.
dist
)
else
:
else
:
gluPerspective
(
60.
,
float
(
width
)
/
height
,
10.0
,
3
*
self
.
dist
)
gluPerspective
(
60.
,
float
(
width
)
/
height
,
10.0
,
3
*
self
.
dist
)
glMatrixMode
(
GL_MODELVIEW
)
glLoadIdentity
()
self
.
reset_mview
(
0.9
)
if
self
.
orthographic
:
ratio
=
0.9
*
float
(
min
(
self
.
width
,
self
.
height
))
/
self
.
dist
glScalef
(
ratio
,
ratio
,
1
)
# Wrap text to the width of the window
# Wrap text to the width of the window
if
self
.
GLinitialized
:
if
self
.
GLinitialized
:
self
.
pygletcontext
.
set_current
()
self
.
pygletcontext
.
set_current
()
self
.
update_object_resize
()
self
.
update_object_resize
()
def
reset_mview
(
self
,
factor
):
glMatrixMode
(
GL_MODELVIEW
)
glLoadIdentity
()
if
self
.
orthographic
:
ratio
=
factor
*
float
(
min
(
self
.
width
,
self
.
height
))
/
self
.
dist
glScalef
(
ratio
,
ratio
,
1
)
def
OnDraw
(
self
,
*
args
,
**
kwargs
):
def
OnDraw
(
self
,
*
args
,
**
kwargs
):
"""Draw the window."""
"""Draw the window."""
self
.
pygletcontext
.
set_current
()
self
.
pygletcontext
.
set_current
()
...
@@ -251,8 +255,10 @@ class GcodeViewPanel(wxGLPanel):
...
@@ -251,8 +255,10 @@ class GcodeViewPanel(wxGLPanel):
self
.
initpos
=
None
self
.
initpos
=
None
if
build_dimensions
:
if
build_dimensions
:
self
.
dist
=
max
(
build_dimensions
[
0
],
build_dimensions
[
1
])
self
.
dist
=
max
(
build_dimensions
[
0
],
build_dimensions
[
1
])
self
.
build_dimensions
=
build_dimensions
else
:
else
:
self
.
dist
=
200
self
.
dist
=
200
self
.
build_dimensions
=
[
200
,
200
,
100
,
0
,
0
,
0
]
self
.
basequat
=
[
0
,
0
,
0
,
1
]
self
.
basequat
=
[
0
,
0
,
0
,
1
]
self
.
mousepos
=
[
0
,
0
]
self
.
mousepos
=
[
0
,
0
]
...
@@ -273,7 +279,8 @@ class GcodeViewPanel(wxGLPanel):
...
@@ -273,7 +279,8 @@ class GcodeViewPanel(wxGLPanel):
glPushMatrix
()
glPushMatrix
()
glTranslatef
(
0
,
0
,
-
self
.
dist
)
# Move back
glTranslatef
(
0
,
0
,
-
self
.
dist
)
# Move back
glMultMatrixd
(
build_rotmatrix
(
self
.
basequat
))
# Rotate according to trackball
glMultMatrixd
(
build_rotmatrix
(
self
.
basequat
))
# Rotate according to trackball
glTranslatef
(
-
self
.
parent
.
platform
.
width
/
2
,
-
self
.
parent
.
platform
.
depth
/
2
,
0
)
# Move origin to bottom left of platform
glTranslatef
(
-
self
.
build_dimensions
[
3
]
-
self
.
parent
.
platform
.
width
/
2
,
-
self
.
build_dimensions
[
4
]
-
self
.
parent
.
platform
.
depth
/
2
,
0
)
# Move origin to bottom left of platform
for
obj
in
self
.
parent
.
objects
:
for
obj
in
self
.
parent
.
objects
:
if
not
obj
.
model
or
not
obj
.
model
.
loaded
or
not
obj
.
model
.
initialized
:
if
not
obj
.
model
or
not
obj
.
model
.
loaded
or
not
obj
.
model
.
initialized
:
...
@@ -415,6 +422,20 @@ class GcodeViewPanel(wxGLPanel):
...
@@ -415,6 +422,20 @@ class GcodeViewPanel(wxGLPanel):
gluUnProject
(
x
,
y
,
1.0
,
mvmat
,
pmat
,
viewport
,
px
,
py
,
pz
)
gluUnProject
(
x
,
y
,
1.0
,
mvmat
,
pmat
,
viewport
,
px
,
py
,
pz
)
return
(
px
.
value
,
py
.
value
,
pz
.
value
)
return
(
px
.
value
,
py
.
value
,
pz
.
value
)
def
fit
(
self
):
if
not
self
.
parent
.
model
or
not
self
.
parent
.
model
.
loaded
:
return
dims
=
self
.
parent
.
model
.
dims
self
.
reset_mview
(
1.0
)
center_x
=
(
dims
[
0
][
0
]
+
dims
[
0
][
1
])
/
2
center_y
=
(
dims
[
1
][
0
]
+
dims
[
1
][
1
])
/
2
center_x
=
self
.
build_dimensions
[
0
]
/
2
-
center_x
center_y
=
self
.
build_dimensions
[
1
]
/
2
-
center_y
if
self
.
orthographic
:
ratio
=
float
(
self
.
dist
)
/
max
(
dims
[
0
][
2
],
dims
[
1
][
2
])
glScalef
(
ratio
,
ratio
,
1
)
glTranslatef
(
center_x
,
center_y
,
0
)
def
keypress
(
self
,
event
):
def
keypress
(
self
,
event
):
"""gets keypress events and moves/rotates acive shape"""
"""gets keypress events and moves/rotates acive shape"""
step
=
1.1
step
=
1.1
...
@@ -424,6 +445,8 @@ class GcodeViewPanel(wxGLPanel):
...
@@ -424,6 +445,8 @@ class GcodeViewPanel(wxGLPanel):
kdo
=
[
68
,
317
]
# Down Keys
kdo
=
[
68
,
317
]
# Down Keys
kzi
=
[
wx
.
WXK_PAGEDOWN
,
388
,
316
,
61
]
# Zoom In Keys
kzi
=
[
wx
.
WXK_PAGEDOWN
,
388
,
316
,
61
]
# Zoom In Keys
kzo
=
[
wx
.
WXK_PAGEUP
,
390
,
314
,
45
]
# Zoom Out Keys
kzo
=
[
wx
.
WXK_PAGEUP
,
390
,
314
,
45
]
# Zoom Out Keys
kfit
=
[
70
]
# Fit to print keys
kreset
=
[
82
]
# Reset keys
key
=
event
.
GetKeyCode
()
key
=
event
.
GetKeyCode
()
if
key
in
kup
:
if
key
in
kup
:
self
.
layerup
()
self
.
layerup
()
...
@@ -434,6 +457,11 @@ class GcodeViewPanel(wxGLPanel):
...
@@ -434,6 +457,11 @@ class GcodeViewPanel(wxGLPanel):
self
.
zoom
(
step
,
(
x
,
y
))
self
.
zoom
(
step
,
(
x
,
y
))
if
key
in
kzo
:
if
key
in
kzo
:
self
.
zoom
(
1
/
step
,
(
x
,
y
))
self
.
zoom
(
1
/
step
,
(
x
,
y
))
if
key
in
kfit
:
self
.
fit
()
if
key
in
kreset
:
self
.
reset_mview
(
0.9
)
self
.
basequat
=
[
0
,
0
,
0
,
1
]
event
.
Skip
()
event
.
Skip
()
wx
.
CallAfter
(
self
.
Refresh
)
wx
.
CallAfter
(
self
.
Refresh
)
...
...
printrun/libtatlin/actors.py
View file @
e2359ce6
...
@@ -249,6 +249,10 @@ class GcodeModel(Model):
...
@@ -249,6 +249,10 @@ class GcodeModel(Model):
def
load_data
(
self
,
model_data
,
callback
=
None
):
def
load_data
(
self
,
model_data
,
callback
=
None
):
t_start
=
time
.
time
()
t_start
=
time
.
time
()
self
.
dims
=
((
model_data
.
xmin
,
model_data
.
xmax
,
model_data
.
width
),
(
model_data
.
ymin
,
model_data
.
ymax
,
model_data
.
depth
),
(
model_data
.
zmin
,
model_data
.
zmax
,
model_data
.
height
))
vertex_list
=
[]
vertex_list
=
[]
color_list
=
[]
color_list
=
[]
self
.
layer_stops
=
[
0
]
self
.
layer_stops
=
[
0
]
...
...
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