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
8f2a5b3f
Commit
8f2a5b3f
authored
Jul 25, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factorize wheel handling and patching
parent
2614bb5e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
21 deletions
+34
-21
gcview.py
printrun/gcview.py
+10
-6
objectplater.py
printrun/objectplater.py
+13
-0
stlview.py
printrun/stlview.py
+11
-15
No files found.
printrun/gcview.py
View file @
8f2a5b3f
...
@@ -154,14 +154,10 @@ class GcodeViewPanel(wxGLPanel):
...
@@ -154,14 +154,10 @@ class GcodeViewPanel(wxGLPanel):
self
.
parent
.
setlayercb
(
new_layer
)
self
.
parent
.
setlayercb
(
new_layer
)
wx
.
CallAfter
(
self
.
Refresh
)
wx
.
CallAfter
(
self
.
Refresh
)
def
wheel
(
self
,
event
):
def
handle_wheel
(
self
,
event
):
"""react to mouse wheel actions:
without shift: set max layer
with shift: zoom viewport
"""
delta
=
event
.
GetWheelRotation
()
delta
=
event
.
GetWheelRotation
()
factor
=
1.05
factor
=
1.05
if
event
.
ShiftDown
():
if
hasattr
(
self
.
parent
,
"model"
)
and
event
.
ShiftDown
():
if
not
self
.
parent
.
model
:
if
not
self
.
parent
.
model
:
return
return
count
=
1
if
not
event
.
ControlDown
()
else
10
count
=
1
if
not
event
.
ControlDown
()
else
10
...
@@ -176,6 +172,14 @@ class GcodeViewPanel(wxGLPanel):
...
@@ -176,6 +172,14 @@ class GcodeViewPanel(wxGLPanel):
else
:
else
:
self
.
zoom
(
1
/
factor
,
(
x
,
y
))
self
.
zoom
(
1
/
factor
,
(
x
,
y
))
def
wheel
(
self
,
event
):
"""react to mouse wheel actions:
without shift: set max layer
with shift: zoom viewport
"""
self
.
handle_wheel
(
event
)
wx
.
CallAfter
(
self
.
Refresh
)
def
fit
(
self
):
def
fit
(
self
):
if
not
self
.
parent
.
model
or
not
self
.
parent
.
model
.
loaded
:
if
not
self
.
parent
.
model
or
not
self
.
parent
.
model
.
loaded
:
return
return
...
...
printrun/objectplater.py
View file @
8f2a5b3f
...
@@ -103,6 +103,19 @@ class Plater(wx.Frame):
...
@@ -103,6 +103,19 @@ class Plater(wx.Frame):
else
:
else
:
orig_handler
(
event
)
orig_handler
(
event
)
patch_method
(
viewer
,
"handle_rotation"
,
handle_rotation
)
patch_method
(
viewer
,
"handle_rotation"
,
handle_rotation
)
# Patch handle_wheel on the fly
if
hasattr
(
viewer
,
"handle_wheel"
):
def
handle_wheel
(
self
,
event
,
orig_handler
):
if
not
event
.
ShiftDown
():
delta
=
event
.
GetWheelRotation
()
angle
=
10
if
delta
>
0
:
self
.
parent
.
rotate_shape
(
angle
/
2
)
else
:
self
.
parent
.
rotate_shape
(
-
angle
/
2
)
else
:
orig_handler
(
event
)
patch_method
(
viewer
,
"handle_wheel"
,
handle_wheel
)
self
.
s
=
viewer
self
.
s
=
viewer
self
.
mainsizer
.
Add
(
self
.
s
,
1
,
wx
.
EXPAND
)
self
.
mainsizer
.
Add
(
self
.
s
,
1
,
wx
.
EXPAND
)
...
...
printrun/stlview.py
View file @
8f2a5b3f
...
@@ -170,26 +170,22 @@ class StlViewPanel(wxGLPanel):
...
@@ -170,26 +170,22 @@ class StlViewPanel(wxGLPanel):
event
.
Skip
()
event
.
Skip
()
wx
.
CallAfter
(
self
.
Refresh
)
wx
.
CallAfter
(
self
.
Refresh
)
def
handle_wheel
(
self
,
event
):
delta
=
event
.
GetWheelRotation
()
factor
=
1.05
x
,
y
=
event
.
GetPositionTuple
()
x
,
y
,
_
=
self
.
mouse_to_3d
(
x
,
y
)
if
delta
>
0
:
self
.
zoom
(
factor
,
(
x
,
y
))
else
:
self
.
zoom
(
1
/
factor
,
(
x
,
y
))
def
wheel
(
self
,
event
):
def
wheel
(
self
,
event
):
"""react to mouse wheel actions:
"""react to mouse wheel actions:
rotate object
rotate object
with shift zoom viewport
with shift zoom viewport
"""
"""
delta
=
event
.
GetWheelRotation
()
self
.
handle_wheel
(
event
)
if
not
event
.
ShiftDown
():
angle
=
10
if
delta
>
0
:
self
.
parent
.
rotate_shape
(
angle
/
2
)
else
:
self
.
parent
.
rotate_shape
(
-
angle
/
2
)
else
:
factor
=
1.05
x
,
y
=
event
.
GetPositionTuple
()
x
,
y
,
_
=
self
.
mouse_to_3d
(
x
,
y
)
if
delta
>
0
:
self
.
zoom
(
factor
,
(
x
,
y
))
else
:
self
.
zoom
(
1
/
factor
,
(
x
,
y
))
wx
.
CallAfter
(
self
.
Refresh
)
wx
.
CallAfter
(
self
.
Refresh
)
def
keypress
(
self
,
event
):
def
keypress
(
self
,
event
):
...
...
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