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
05ee1da7
Commit
05ee1da7
authored
May 22, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add keypress handling to gcview
parent
a2dded25
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
54 deletions
+54
-54
gcview.py
printrun/gcview.py
+54
-54
No files found.
printrun/gcview.py
View file @
05ee1da7
...
@@ -254,6 +254,7 @@ class GcodeViewPanel(wxGLPanel):
...
@@ -254,6 +254,7 @@ class GcodeViewPanel(wxGLPanel):
self
.
rot
=
0
self
.
rot
=
0
self
.
canvas
.
Bind
(
wx
.
EVT_MOUSE_EVENTS
,
self
.
move
)
self
.
canvas
.
Bind
(
wx
.
EVT_MOUSE_EVENTS
,
self
.
move
)
self
.
canvas
.
Bind
(
wx
.
EVT_LEFT_DCLICK
,
self
.
double
)
self
.
canvas
.
Bind
(
wx
.
EVT_LEFT_DCLICK
,
self
.
double
)
self
.
canvas
.
Bind
(
wx
.
EVT_KEY_DOWN
,
self
.
keypress
)
self
.
initialized
=
0
self
.
initialized
=
0
self
.
canvas
.
Bind
(
wx
.
EVT_MOUSEWHEEL
,
self
.
wheel
)
self
.
canvas
.
Bind
(
wx
.
EVT_MOUSEWHEEL
,
self
.
wheel
)
self
.
parent
=
parent
self
.
parent
=
parent
...
@@ -317,6 +318,10 @@ class GcodeViewPanel(wxGLPanel):
...
@@ -317,6 +318,10 @@ class GcodeViewPanel(wxGLPanel):
LMB: rotate viewport
LMB: rotate viewport
RMB: move viewport
RMB: move viewport
"""
"""
if
event
.
Entering
():
self
.
canvas
.
SetFocus
()
event
.
Skip
()
return
if
event
.
Dragging
()
and
event
.
LeftIsDown
():
if
event
.
Dragging
()
and
event
.
LeftIsDown
():
if
self
.
initpos
==
None
:
if
self
.
initpos
==
None
:
self
.
initpos
=
event
.
GetPositionTuple
()
self
.
initpos
=
event
.
GetPositionTuple
()
...
@@ -375,7 +380,36 @@ class GcodeViewPanel(wxGLPanel):
...
@@ -375,7 +380,36 @@ class GcodeViewPanel(wxGLPanel):
self
.
rot
=
1
self
.
rot
=
1
self
.
initpos
=
None
self
.
initpos
=
None
else
:
else
:
event
.
Skip
()
return
return
event
.
Skip
()
wx
.
CallAfter
(
self
.
Refresh
)
def
layerup
(
self
):
if
not
self
.
parent
.
model
:
return
max_layers
=
self
.
parent
.
model
.
max_layers
current_layer
=
self
.
parent
.
model
.
num_layers_to_draw
new_layer
=
min
(
max_layers
,
current_layer
+
1
)
self
.
parent
.
model
.
num_layers_to_draw
=
new_layer
wx
.
CallAfter
(
self
.
Refresh
)
def
layerdown
(
self
):
if
not
self
.
parent
.
model
:
return
current_layer
=
self
.
parent
.
model
.
num_layers_to_draw
new_layer
=
max
(
1
,
current_layer
-
1
)
self
.
parent
.
model
.
num_layers_to_draw
=
new_layer
wx
.
CallAfter
(
self
.
Refresh
)
def
zoom
(
self
,
dist
):
self
.
transv
[
2
]
+=
dist
glLoadIdentity
()
glTranslatef
(
*
self
.
transv
)
if
self
.
rot
:
glMultMatrixd
(
build_rotmatrix
(
self
.
basequat
))
glGetDoublev
(
GL_MODELVIEW_MATRIX
,
self
.
mvmat
)
self
.
rot
=
1
wx
.
CallAfter
(
self
.
Refresh
)
wx
.
CallAfter
(
self
.
Refresh
)
def
wheel
(
self
,
event
):
def
wheel
(
self
,
event
):
...
@@ -384,61 +418,39 @@ class GcodeViewPanel(wxGLPanel):
...
@@ -384,61 +418,39 @@ class GcodeViewPanel(wxGLPanel):
with shift: zoom viewport
with shift: zoom viewport
"""
"""
z
=
event
.
GetWheelRotation
()
z
=
event
.
GetWheelRotation
()
angle
=
10
dist
=
10
if
event
.
ShiftDown
():
if
event
.
ShiftDown
():
if
not
self
.
parent
.
model
:
if
not
self
.
parent
.
model
:
return
return
if
z
>
0
:
if
z
>
0
:
max_layers
=
self
.
parent
.
model
.
max_layers
self
.
layerup
()
current_layer
=
self
.
parent
.
model
.
num_layers_to_draw
new_layer
=
min
(
max_layers
,
current_layer
+
1
)
self
.
parent
.
model
.
num_layers_to_draw
=
new_layer
else
:
else
:
current_layer
=
self
.
parent
.
model
.
num_layers_to_draw
self
.
layerdown
()
new_layer
=
max
(
1
,
current_layer
-
1
)
self
.
parent
.
model
.
num_layers_to_draw
=
new_layer
wx
.
CallAfter
(
self
.
Refresh
)
return
return
if
z
>
0
:
if
z
>
0
:
self
.
transv
[
2
]
+=
angle
self
.
zoom
(
dist
)
else
:
else
:
self
.
transv
[
2
]
-=
angle
self
.
zoom
(
-
dist
)
glLoadIdentity
()
glTranslatef
(
*
self
.
transv
)
if
self
.
rot
:
glMultMatrixd
(
build_rotmatrix
(
self
.
basequat
))
glGetDoublev
(
GL_MODELVIEW_MATRIX
,
self
.
mvmat
)
self
.
rot
=
1
wx
.
CallAfter
(
self
.
Refresh
)
def
keypress
(
self
,
event
):
def
keypress
(
self
,
event
):
"""gets keypress events and moves/rotates acive shape"""
"""gets keypress events and moves/rotates acive shape"""
keycode
=
event
.
GetKeyCode
()
keycode
=
event
.
GetKeyCode
()
print
keycode
step
=
10
step
=
5
angle
=
18
if
event
.
ControlDown
():
if
event
.
ControlDown
():
step
=
1
step
=
3
angle
=
1
kup
=
[
85
,
315
]
# Up keys
#h
kdo
=
[
68
,
317
]
# Down Keys
if
keycode
==
72
:
kzi
=
[
wx
.
WXK_PAGEDOWN
,
388
,
316
,
61
]
# Zoom In Keys
self
.
move_shape
((
-
step
,
0
))
kzo
=
[
wx
.
WXK_PAGEUP
,
390
,
314
,
45
]
# Zoom Out Keys
#l
x
=
event
.
GetKeyCode
()
if
keycode
==
76
:
if
x
in
kup
:
self
.
move_shape
((
step
,
0
))
self
.
layerup
()
#j
if
x
in
kdo
:
if
keycode
==
75
:
self
.
layerdown
()
self
.
move_shape
((
0
,
step
))
if
x
in
kzi
:
#k
self
.
zoom
(
step
)
if
keycode
==
74
:
if
x
in
kzo
:
self
.
move_shape
((
0
,
-
step
))
self
.
zoom
(
-
step
)
#[
if
keycode
==
91
:
self
.
rotate_shape
(
-
angle
)
#]
if
keycode
==
93
:
self
.
rotate_shape
(
angle
)
event
.
Skip
()
event
.
Skip
()
wx
.
CallAfter
(
self
.
Refresh
)
wx
.
CallAfter
(
self
.
Refresh
)
...
@@ -489,18 +501,6 @@ class GcodeViewFrame(wx.Frame):
...
@@ -489,18 +501,6 @@ class GcodeViewFrame(wx.Frame):
self
.
SetClientSize
((
self
.
GetClientSize
()[
0
],
self
.
GetClientSize
()[
1
]
-
1
))
self
.
SetClientSize
((
self
.
GetClientSize
()[
0
],
self
.
GetClientSize
()[
1
]
-
1
))
self
.
Refresh
()
self
.
Refresh
()
def
setlayerindex
(
self
,
z
):
model
=
self
.
objects
[
-
1
]
.
model
if
not
model
:
return
mlk
=
sorted
(
m
.
gc
.
layers
.
keys
())
if
z
>
0
and
self
.
modelindex
<
len
(
mlk
)
-
1
:
self
.
modelindex
+=
1
if
z
<
0
and
self
.
modelindex
>
0
:
self
.
modelindex
-=
1
m
.
curlayer
=
mlk
[
self
.
modelindex
]
wx
.
CallAfter
(
self
.
SetTitle
,
"Gcode view, shift to move. Layer
%
d, Z =
%
f"
%
(
self
.
modelindex
,
m
.
curlayer
))
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
import
sys
import
sys
app
=
wx
.
App
(
redirect
=
False
)
app
=
wx
.
App
(
redirect
=
False
)
...
...
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