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
d2b90ebe
Commit
d2b90ebe
authored
Aug 28, 2011
by
kliment
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #55 from nesqi/master
Resize preview window on main window resize.
parents
8af5496a
4f4b1b4a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
27 deletions
+52
-27
gviz.py
gviz.py
+29
-7
pronterface.py
pronterface.py
+23
-20
No files found.
gviz.py
View file @
d2b90ebe
...
...
@@ -3,7 +3,7 @@ import wx,time
class
window
(
wx
.
Frame
):
def
__init__
(
self
,
f
,
size
=
(
600
,
600
),
bedsize
=
(
200
,
200
),
grid
=
(
10
,
50
),
extrusion_width
=
0.5
):
wx
.
Frame
.
__init__
(
self
,
None
,
title
=
"Layer view (Use shift+mousewheel to switch layers)"
,
size
=
(
size
[
0
],
size
[
1
]))
self
.
p
=
gviz
(
self
,
size
=
size
,
bedsize
=
bedsize
,
grid
=
grid
,
extrusion_width
=
extrusion_width
)
self
.
p
=
gviz
(
self
,
size
=
size
,
bedsize
=
bedsize
,
grid
=
grid
,
extrusion_width
=
extrusion_width
,
keepProportions
=
0
)
s
=
time
.
time
()
for
i
in
f
:
self
.
p
.
addgcode
(
i
)
...
...
@@ -15,7 +15,7 @@ class window(wx.Frame):
self
.
Bind
(
wx
.
EVT_MOUSEWHEEL
,
self
.
zoom
)
self
.
p
.
Bind
(
wx
.
EVT_MOUSE_EVENTS
,
self
.
mouse
)
self
.
Bind
(
wx
.
EVT_MOUSE_EVENTS
,
self
.
mouse
)
def
mouse
(
self
,
event
):
if
event
.
ButtonUp
(
wx
.
MOUSE_BTN_LEFT
):
if
(
self
.
initpos
is
not
None
):
...
...
@@ -53,11 +53,12 @@ class window(wx.Frame):
elif
z
<
0
:
self
.
p
.
zoom
(
event
.
GetX
(),
event
.
GetY
(),
1
/
1.2
)
class
gviz
(
wx
.
Panel
):
def
__init__
(
self
,
parent
,
size
=
(
200
,
200
),
bedsize
=
(
200
,
200
),
grid
=
(
10
,
50
),
extrusion_width
=
0.5
):
wx
.
Panel
.
__init__
(
self
,
parent
,
-
1
,
size
=
(
size
[
0
],
size
[
1
])
)
def
__init__
(
self
,
parent
,
size
=
(
200
,
200
),
bedsize
=
(
200
,
200
),
grid
=
(
10
,
50
),
extrusion_width
=
0.5
,
keepProportions
=
1
):
wx
.
Panel
.
__init__
(
self
,
parent
,
-
1
)
self
.
size
=
size
self
.
bedsize
=
bedsize
self
.
grid
=
grid
self
.
keepProportions
=
keepProportions
self
.
lastpos
=
[
0
,
0
,
0
,
0
,
0
]
self
.
hilightpos
=
self
.
lastpos
[:]
self
.
Bind
(
wx
.
EVT_PAINT
,
self
.
paint
)
...
...
@@ -67,7 +68,7 @@ class gviz(wx.Panel):
self
.
layers
=
[]
self
.
layerindex
=
0
self
.
filament_width
=
extrusion_width
# set it to 0 to disable scaling lines with zoom
self
.
scale
=
[
min
(
float
(
size
[
0
])
/
bedsize
[
0
],
float
(
size
[
1
])
/
bedsize
[
1
])]
*
2
self
.
calculatScale
()
penwidth
=
max
(
1.0
,
self
.
filament_width
*
((
self
.
scale
[
0
]
+
self
.
scale
[
1
])
/
2.0
))
self
.
translate
=
[
0.0
,
0.0
]
self
.
mainpen
=
wx
.
Pen
(
wx
.
Colour
(
0
,
0
,
0
),
penwidth
)
...
...
@@ -120,9 +121,30 @@ class gviz(wx.Panel):
#self.dirty=1
self
.
repaint
()
self
.
Refresh
()
def
calculatScale
(
self
):
self
.
scale
=
[
min
(
float
(
self
.
size
[
0
])
/
self
.
bedsize
[
0
],
float
(
self
.
size
[
1
])
/
self
.
bedsize
[
1
])]
*
2
def
setBedsize
(
self
,
width
,
height
):
self
.
bedsize
=
(
width
,
height
)
self
.
repaint
()
self
.
Refresh
()
def
adjustSize
(
self
):
width
=
self
.
size
[
0
]
height
=
self
.
size
[
1
]
wtoh
=
self
.
bedsize
[
1
]
/
self
.
bedsize
[
0
]
if
(
width
*
wtoh
>
height
):
self
.
size
[
0
]
=
height
/
wtoh
elif
(
height
/
wtoh
>
width
):
self
.
size
[
1
]
=
width
*
wtoh
def
repaint
(
self
):
self
.
blitmap
=
wx
.
EmptyBitmap
(
self
.
GetClientSize
()[
0
],
self
.
GetClientSize
()[
1
],
-
1
)
self
.
size
=
self
.
GetSize
()
if
self
.
keepProportions
:
self
.
adjustSize
()
self
.
calculatScale
()
self
.
blitmap
=
wx
.
EmptyBitmap
(
self
.
size
[
0
],
self
.
size
[
1
],
-
1
)
dc
=
wx
.
MemoryDC
()
dc
.
SelectObject
(
self
.
blitmap
)
dc
.
SetBackground
(
wx
.
Brush
((
250
,
250
,
200
)))
...
...
pronterface.py
View file @
d2b90ebe
...
...
@@ -368,7 +368,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
#sizer layout: topsizer is a column sizer containing two sections
#upper section contains the mini view buttons
#lower section contains the rest of the window - manual controls, console, visualizations
#TOP ROW:
#TOP
button
ROW:
uts
=
self
.
uppertopsizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
uts
.
Add
(
wx
.
StaticText
(
self
.
panel
,
-
1
,
_
(
"Port:"
),
pos
=
(
0
,
5
)),
wx
.
TOP
|
wx
.
LEFT
,
5
)
scan
=
self
.
scanserial
()
...
...
@@ -415,9 +415,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
uts
.
Add
((
15
,
-
1
),
flag
=
wx
.
EXPAND
)
uts
.
Add
(
self
.
minibtn
)
#SECOND ROW
#SECOND
button
ROW
ubs
=
self
.
upperbottomsizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
self
.
loadbtn
=
wx
.
Button
(
self
.
panel
,
-
1
,
_
(
"Load file"
),
pos
=
(
0
,
40
))
self
.
loadbtn
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
loadfile
)
ubs
.
Add
(
self
.
loadbtn
)
...
...
@@ -437,30 +436,31 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self
.
pausebtn
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
pause
)
ubs
.
Add
(
self
.
pausebtn
)
ubs
.
Add
((
50
,
-
1
),
flag
=
wx
.
EXPAND
)
#Right full view
#Log panel full view
lrs
=
self
.
lowerrsizer
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
self
.
logbox
=
wx
.
TextCtrl
(
self
.
panel
,
size
=
(
350
,
340
),
pos
=
(
440
,
75
),
style
=
wx
.
TE_MULTILINE
)
self
.
logbox
=
wx
.
TextCtrl
(
self
.
panel
,
style
=
wx
.
TE_MULTILINE
)
#,
size=(350,340),pos=(440,75),style = wx.TE_MULTILINE)
self
.
logbox
.
SetEditable
(
0
)
lrs
.
Add
(
self
.
logbox
)
lrs
.
Add
(
self
.
logbox
,
1
,
flag
=
wx
.
EXPAND
)
lbrs
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
self
.
commandbox
=
wx
.
TextCtrl
(
self
.
panel
,
size
=
(
250
,
30
),
pos
=
(
440
,
420
),
style
=
wx
.
TE_PROCESS_ENTER
)
self
.
commandbox
.
Bind
(
wx
.
EVT_TEXT_ENTER
,
self
.
sendline
)
self
.
commandbox
=
wx
.
TextCtrl
(
self
.
panel
,
style
=
wx
.
TE_PROCESS_ENTER
)
#,
size=(250,30),pos=(440,420),style = wx.TE_PROCESS_ENTER)
self
.
commandbox
.
Bind
(
wx
.
EVT_TEXT_ENTER
,
self
.
sendline
)
#self.printerControls.append(self.commandbox)
lbrs
.
Add
(
self
.
commandbox
)
self
.
sendbtn
=
wx
.
Button
(
self
.
panel
,
-
1
,
_
(
"Send"
)
,
pos
=
(
700
,
420
))
lbrs
.
Add
(
self
.
commandbox
,
1
,
flag
=
wx
.
EXPAND
)
self
.
sendbtn
=
wx
.
Button
(
self
.
panel
,
-
1
,
_
(
"Send"
))
#
,pos=(700,420))
self
.
sendbtn
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
sendline
)
#self.printerControls.append(self.sendbtn)
lbrs
.
Add
(
self
.
sendbtn
)
lrs
.
Add
(
lbrs
)
lrs
.
Add
(
lbrs
,
flag
=
wx
.
EXPAND
)
#left pane
lls
=
self
.
lowerlsizer
=
wx
.
GridBagSizer
()
lls
.
Add
(
wx
.
StaticText
(
self
.
panel
,
-
1
,
_
(
"mm/min"
)
,
pos
=
(
60
,
69
)
),
pos
=
(
0
,
4
),
span
=
(
1
,
4
))
lls
.
Add
(
wx
.
StaticText
(
self
.
panel
,
-
1
,
_
(
"mm/min"
)),
pos
=
(
0
,
4
),
span
=
(
1
,
4
))
self
.
xyfeedc
=
wx
.
SpinCtrl
(
self
.
panel
,
-
1
,
str
(
self
.
settings
.
xy_feedrate
),
min
=
0
,
max
=
50000
,
size
=
(
70
,
25
),
pos
=
(
25
,
83
))
lls
.
Add
(
wx
.
StaticText
(
self
.
panel
,
-
1
,
_
(
"XY:"
)
,
pos
=
(
2
,
90
-
2
)
),
pos
=
(
1
,
0
),
span
=
(
1
,
2
))
lls
.
Add
(
wx
.
StaticText
(
self
.
panel
,
-
1
,
_
(
"XY:"
)),
pos
=
(
1
,
0
),
span
=
(
1
,
2
))
lls
.
Add
(
self
.
xyfeedc
,
pos
=
(
1
,
2
),
span
=
(
1
,
4
))
lls
.
Add
(
wx
.
StaticText
(
self
.
panel
,
-
1
,
_
(
"Z:"
)
,
pos
=
(
90
,
90
-
2
)
),
pos
=
(
1
,
6
),
span
=
(
1
,
2
))
self
.
zfeedc
=
wx
.
SpinCtrl
(
self
.
panel
,
-
1
,
str
(
self
.
settings
.
z_feedrate
),
min
=
0
,
max
=
50000
,
size
=
(
70
,
25
),
pos
=
(
105
,
83
))
lls
.
Add
(
wx
.
StaticText
(
self
.
panel
,
-
1
,
_
(
"Z:"
)),
pos
=
(
1
,
6
),
span
=
(
1
,
2
))
self
.
zfeedc
=
wx
.
SpinCtrl
(
self
.
panel
,
-
1
,
str
(
self
.
settings
.
z_feedrate
),
min
=
0
,
max
=
50000
,
pos
=
(
105
,
83
))
lls
.
Add
(
self
.
zfeedc
,
pos
=
(
1
,
8
),
span
=
(
1
,
4
))
#lls.Add((200,375))
...
...
@@ -530,9 +530,9 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
extrusion_width
=
self
.
settings
.
preview_extrusion_width
)
self
.
gviz
.
Bind
(
wx
.
EVT_LEFT_DOWN
,
self
.
showwin
)
self
.
gwindow
.
Bind
(
wx
.
EVT_CLOSE
,
lambda
x
:
self
.
gwindow
.
Hide
())
cs
=
self
.
centersizer
=
wx
.
GridBag
Sizer
()
cs
.
Add
(
self
.
gviz
,
pos
=
(
0
,
0
),
span
=
(
1
,
3
)
)
lls
.
Add
(
cs
,
pos
=
(
0
,
10
),
span
=
(
15
,
1
))
cs
=
self
.
centersizer
=
wx
.
Box
Sizer
()
cs
.
Add
(
self
.
gviz
,
1
,
flag
=
wx
.
EXPAND
)
cs
.
Add
((
10
,
10
))
self
.
uppersizer
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
self
.
uppersizer
.
Add
(
self
.
uppertopsizer
)
...
...
@@ -540,10 +540,11 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self
.
lowersizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
self
.
lowersizer
.
Add
(
lls
)
self
.
lowersizer
.
Add
(
lrs
)
self
.
lowersizer
.
Add
(
cs
,
1
,
flag
=
wx
.
EXPAND
)
self
.
lowersizer
.
Add
(
lrs
,
1
,
flag
=
wx
.
EXPAND
)
self
.
topsizer
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
self
.
topsizer
.
Add
(
self
.
uppersizer
)
self
.
topsizer
.
Add
(
self
.
lowersizer
)
self
.
topsizer
.
Add
(
self
.
lowersizer
,
1
,
flag
=
wx
.
EXPAND
)
self
.
panel
.
SetSizer
(
self
.
topsizer
)
self
.
status
=
self
.
CreateStatusBar
()
self
.
status
.
SetStatusText
(
_
(
"Not connected to printer."
))
...
...
@@ -1261,6 +1262,8 @@ class options(wx.Dialog):
for
k
,
v
in
pronterface
.
settings
.
_all_settings
()
.
items
():
if
ctrls
[
k
]
.
GetValue
()
!=
str
(
v
):
pronterface
.
set
(
k
,
str
(
ctrls
[
k
]
.
GetValue
()))
pronterface
.
gviz
.
setBedsize
(
pronterface
.
settings
.
bed_size_x
,
pronterface
.
settings
.
bed_size_y
)
self
.
Destroy
()
class
ButtonEdit
(
wx
.
Dialog
):
...
...
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