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
2614bb5e
Commit
2614bb5e
authored
Jul 25, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factorize method wrapping and fix orig_handler call
parent
4e359fde
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
objectplater.py
printrun/objectplater.py
+11
-6
No files found.
printrun/objectplater.py
View file @
2614bb5e
...
...
@@ -22,6 +22,14 @@ import os
import
types
import
wx
def
patch_method
(
obj
,
method
,
replacement
):
orig_handler
=
getattr
(
obj
,
method
)
def
wrapped
(
*
a
,
**
kwargs
):
kwargs
[
'orig_handler'
]
=
orig_handler
return
replacement
(
*
a
,
**
kwargs
)
setattr
(
obj
,
method
,
types
.
MethodType
(
wrapped
,
obj
))
class
Plater
(
wx
.
Frame
):
def
__init__
(
self
,
filenames
=
[],
size
=
(
800
,
580
),
callback
=
None
,
parent
=
None
,
build_dimensions
=
None
):
super
(
Plater
,
self
)
.
__init__
(
parent
,
title
=
_
(
"Plate building tool"
),
size
=
size
)
...
...
@@ -81,9 +89,7 @@ class Plater(wx.Frame):
def
set_viewer
(
self
,
viewer
):
# Patch handle_rotation on the fly
if
hasattr
(
viewer
,
"handle_rotation"
):
orig_handler
=
viewer
.
handle_rotation
def
handle_rotation
(
self
,
event
,
orig_handler
=
orig_handler
):
def
handle_rotation
(
self
,
event
,
orig_handler
):
if
self
.
initpos
is
None
:
self
.
initpos
=
event
.
GetPositionTuple
()
else
:
...
...
@@ -95,9 +101,8 @@ class Plater(wx.Frame):
self
.
parent
.
move_shape
((
x2
-
x1
,
y2
-
y1
))
self
.
initpos
=
p2
else
:
orig_handler
(
self
,
event
)
viewer
.
handle_rotation
=
types
.
MethodType
(
handle_rotation
,
viewer
)
orig_handler
(
event
)
patch_method
(
viewer
,
"handle_rotation"
,
handle_rotation
)
self
.
s
=
viewer
self
.
mainsizer
.
Add
(
self
.
s
,
1
,
wx
.
EXPAND
)
...
...
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