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
0920bc6e
Commit
0920bc6e
authored
May 16, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Greatly improve resizing behavior of GViz windows
parent
db04449a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
11 deletions
+17
-11
gviz.py
printrun/gviz.py
+17
-11
No files found.
printrun/gviz.py
View file @
0920bc6e
...
...
@@ -22,6 +22,10 @@ ID_EXIT = 110
class
window
(
wx
.
Frame
):
def
__init__
(
self
,
f
,
size
=
(
600
,
600
),
build_dimensions
=
[
200
,
200
,
100
,
0
,
0
,
0
],
grid
=
(
10
,
50
),
extrusion_width
=
0.5
):
wx
.
Frame
.
__init__
(
self
,
None
,
title
=
"Gcode view, shift to move view, mousewheel to set layer"
,
size
=
size
)
self
.
CreateStatusBar
(
1
);
self
.
SetStatusText
(
"Layer number and Z position show here when you scroll"
);
self
.
p
=
gviz
(
self
,
size
=
size
,
build_dimensions
=
build_dimensions
,
grid
=
grid
,
extrusion_width
=
extrusion_width
)
vbox
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
...
...
@@ -36,7 +40,9 @@ class window(wx.Frame):
#toolbar.AddSimpleTool(6, wx.Image('./images/inject.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'Insert Code at start of this layer', '')
toolbar
.
Realize
()
vbox
.
Add
(
toolbar
,
0
,
border
=
5
)
vbox
.
Add
(
self
.
p
,
1
,
wx
.
EXPAND
)
self
.
SetSizer
(
vbox
)
self
.
SetMinSize
(
self
.
ClientToWindowSize
(
vbox
.
GetMinSize
()))
self
.
Bind
(
wx
.
EVT_TOOL
,
lambda
x
:
self
.
p
.
zoom
(
200
,
200
,
1.2
),
id
=
1
)
self
.
Bind
(
wx
.
EVT_TOOL
,
lambda
x
:
self
.
p
.
zoom
(
200
,
200
,
1
/
1.2
),
id
=
2
)
self
.
Bind
(
wx
.
EVT_TOOL
,
lambda
x
:
self
.
p
.
layerup
(),
id
=
3
)
...
...
@@ -44,9 +50,6 @@ class window(wx.Frame):
self
.
Bind
(
wx
.
EVT_TOOL
,
self
.
resetview
,
id
=
5
)
#self.Bind(wx.EVT_TOOL, lambda x:self.p.inject(), id = 6)
self
.
CreateStatusBar
(
1
);
self
.
SetStatusText
(
"Layer number and Z position show here when you scroll"
);
self
.
initpos
=
[
0
,
0
]
self
.
p
.
Bind
(
wx
.
EVT_KEY_DOWN
,
self
.
key
)
self
.
Bind
(
wx
.
EVT_KEY_DOWN
,
self
.
key
)
...
...
@@ -121,10 +124,10 @@ class window(wx.Frame):
class
gviz
(
wx
.
Panel
):
def
__init__
(
self
,
parent
,
size
=
(
200
,
200
),
build_dimensions
=
[
200
,
200
,
100
,
0
,
0
,
0
],
grid
=
(
10
,
50
),
extrusion_width
=
0.5
):
wx
.
Panel
.
__init__
(
self
,
parent
,
-
1
,
size
=
(
-
1
,
-
1
))
wx
.
Panel
.
__init__
(
self
,
parent
,
-
1
,
size
=
size
)
self
.
SetMinSize
((
150
,
150
))
self
.
parent
=
parent
self
.
size
=
size
self
.
SetMinSize
((
300
,
300
))
self
.
build_dimensions
=
build_dimensions
self
.
grid
=
grid
self
.
lastpos
=
[
0
,
0
,
0
,
0
,
0
,
0
,
0
]
...
...
@@ -199,13 +202,16 @@ class gviz(wx.Panel):
pass
def
resize
(
self
,
event
):
size
=
self
.
GetClientSize
()
size
=
[
max
(
1.0
,
size
[
0
]),
max
(
1.0
,
size
[
1
])]
self
.
size
=
[
max
(
1.0
,
self
.
size
[
0
]),
max
(
1.0
,
self
.
size
[
1
])]
newsize
=
min
(
float
(
size
[
0
])
/
self
.
size
[
0
],
float
(
size
[
1
])
/
self
.
size
[
1
])
oldwidth
,
oldheight
=
max
(
1.0
,
self
.
size
[
0
]),
max
(
1.0
,
self
.
size
[
1
])
oldside
=
min
(
oldwidth
,
oldheight
)
newwidth
,
newheight
=
self
.
GetClientSizeTuple
()
newwidth
,
newheight
=
[
max
(
1.0
,
newwidth
),
max
(
1.0
,
newheight
)]
newside
=
min
(
newwidth
,
newheight
)
zoomratio
=
float
(
newside
)
/
oldside
print
newwidth
,
newheight
print
zoomratio
self
.
size
=
self
.
GetClientSize
()
wx
.
CallAfter
(
self
.
zoom
,
0
,
0
,
newsize
)
wx
.
CallAfter
(
self
.
zoom
,
0
,
0
,
zoomratio
)
def
zoom
(
self
,
x
,
y
,
factor
):
self
.
scale
=
[
s
*
factor
for
s
in
self
.
scale
]
...
...
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