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
bbec5e53
Commit
bbec5e53
authored
Jun 17, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add keybinding to gcview to zoom on object in gcview (hit F key)
parent
b91265ee
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
5 deletions
+32
-5
gcview.py
printrun/gcview.py
+28
-5
actors.py
printrun/libtatlin/actors.py
+4
-0
No files found.
printrun/gcview.py
View file @
bbec5e53
...
@@ -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
]
...
@@ -415,6 +421,20 @@ class GcodeViewPanel(wxGLPanel):
...
@@ -415,6 +421,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 +444,7 @@ class GcodeViewPanel(wxGLPanel):
...
@@ -424,6 +444,7 @@ 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
]
# Zoom Out Keys
key
=
event
.
GetKeyCode
()
key
=
event
.
GetKeyCode
()
if
key
in
kup
:
if
key
in
kup
:
self
.
layerup
()
self
.
layerup
()
...
@@ -434,6 +455,8 @@ class GcodeViewPanel(wxGLPanel):
...
@@ -434,6 +455,8 @@ 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
()
event
.
Skip
()
event
.
Skip
()
wx
.
CallAfter
(
self
.
Refresh
)
wx
.
CallAfter
(
self
.
Refresh
)
...
...
printrun/libtatlin/actors.py
View file @
bbec5e53
...
@@ -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