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
856b46cc
Commit
856b46cc
authored
May 18, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up gviz a little more and ensure we have room to display border
parent
a6cab813
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
19 deletions
+26
-19
gviz.py
printrun/gviz.py
+26
-19
No files found.
printrun/gviz.py
View file @
856b46cc
...
...
@@ -152,7 +152,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
.
basescale
=
[
min
(
float
(
size
[
0
])
/
build_dimensions
[
0
],
float
(
size
[
1
])
/
build_dimensions
[
1
])]
*
2
self
.
update_basescale
()
self
.
scale
=
self
.
basescale
penwidth
=
max
(
1.0
,
self
.
filament_width
*
((
self
.
scale
[
0
]
+
self
.
scale
[
1
])
/
2.0
))
self
.
translate
=
[
0.0
,
0.0
]
...
...
@@ -212,12 +212,15 @@ class gviz(wx.Panel):
except
:
pass
def
update_basescale
(
self
):
self
.
basescale
=
2
*
[
min
(
float
(
self
.
size
[
0
]
-
1
)
/
self
.
build_dimensions
[
0
],
float
(
self
.
size
[
1
]
-
1
)
/
self
.
build_dimensions
[
1
])]
def
resize
(
self
,
event
):
oldside
=
max
(
1.0
,
min
(
self
.
size
))
self
.
size
=
self
.
GetClientSizeTuple
()
self
.
update_basescale
()
newside
=
max
(
1.0
,
min
(
self
.
size
))
self
.
basescale
=
2
*
[
min
(
float
(
self
.
size
[
0
])
/
self
.
build_dimensions
[
0
],
float
(
self
.
size
[
1
])
/
self
.
build_dimensions
[
1
])]
zoomratio
=
float
(
newside
)
/
oldside
wx
.
CallAfter
(
self
.
zoom
,
0
,
0
,
zoomratio
)
...
...
@@ -235,6 +238,20 @@ class gviz(wx.Panel):
self
.
dirty
=
1
wx
.
CallAfter
(
self
.
Refresh
)
def
_line_scaler
(
self
,
x
):
return
(
self
.
scale
[
0
]
*
x
[
0
]
+
self
.
translate
[
0
],
self
.
scale
[
1
]
*
x
[
1
]
+
self
.
translate
[
1
],
self
.
scale
[
0
]
*
x
[
2
]
+
self
.
translate
[
0
],
self
.
scale
[
1
]
*
x
[
3
]
+
self
.
translate
[
1
],)
def
_arc_scaler
(
self
,
x
):
return
(
self
.
scale
[
0
]
*
x
[
0
]
+
self
.
translate
[
0
],
self
.
scale
[
1
]
*
x
[
1
]
+
self
.
translate
[
1
],
self
.
scale
[
0
]
*
x
[
2
]
+
self
.
translate
[
0
],
self
.
scale
[
1
]
*
x
[
3
]
+
self
.
translate
[
1
],
self
.
scale
[
0
]
*
x
[
4
]
+
self
.
translate
[
0
],
self
.
scale
[
1
]
*
x
[
5
]
+
self
.
translate
[
1
],)
def
repaint
(
self
):
self
.
blitmap
=
wx
.
EmptyBitmap
(
self
.
GetClientSize
()[
0
],
self
.
GetClientSize
()[
1
],
-
1
)
dc
=
wx
.
MemoryDC
()
...
...
@@ -249,6 +266,7 @@ class gviz(wx.Panel):
for
y
in
xrange
(
int
(
self
.
build_dimensions
[
1
]
/
grid_unit
)
+
1
):
dc
.
DrawLine
(
self
.
translate
[
0
],
self
.
translate
[
1
]
+
y
*
self
.
scale
[
1
]
*
grid_unit
,
self
.
translate
[
0
]
+
self
.
scale
[
0
]
*
self
.
build_dimensions
[
0
],
self
.
translate
[
1
]
+
y
*
self
.
scale
[
1
]
*
grid_unit
)
dc
.
SetPen
(
wx
.
Pen
(
wx
.
Colour
(
0
,
0
,
0
)))
if
not
self
.
showall
:
dc
.
SetBrush
(
wx
.
Brush
((
43
,
144
,
255
)))
dc
.
DrawRectangle
(
self
.
size
[
0
]
-
15
,
0
,
15
,
self
.
size
[
1
])
...
...
@@ -257,26 +275,14 @@ class gviz(wx.Panel):
dc
.
DrawRectangle
(
self
.
size
[
0
]
-
14
,
(
1.0
-
(
1.0
*
(
self
.
layerindex
+
1
))
/
len
(
self
.
layers
))
*
self
.
size
[
1
],
13
,
self
.
size
[
1
]
-
1
)
def
_drawlines
(
lines
,
pens
):
def
_scaler
(
x
):
return
(
self
.
scale
[
0
]
*
x
[
0
]
+
self
.
translate
[
0
],
self
.
scale
[
1
]
*
x
[
1
]
+
self
.
translate
[
1
],
self
.
scale
[
0
]
*
x
[
2
]
+
self
.
translate
[
0
],
self
.
scale
[
1
]
*
x
[
3
]
+
self
.
translate
[
1
],)
scaled_lines
=
map
(
_scaler
,
lines
)
scaled_lines
=
map
(
self
.
_line_scaler
,
lines
)
dc
.
DrawLineList
(
scaled_lines
,
pens
)
def
_drawarcs
(
arcs
,
pens
):
def
_scaler
(
x
):
return
(
self
.
scale
[
0
]
*
x
[
0
]
+
self
.
translate
[
0
],
self
.
scale
[
1
]
*
x
[
1
]
+
self
.
translate
[
1
],
self
.
scale
[
0
]
*
x
[
2
]
+
self
.
translate
[
0
],
self
.
scale
[
1
]
*
x
[
3
]
+
self
.
translate
[
1
],
self
.
scale
[
0
]
*
x
[
4
]
+
self
.
translate
[
0
],
self
.
scale
[
1
]
*
x
[
5
]
+
self
.
translate
[
1
],)
scaled_arcs
=
map
(
_scaler
,
arcs
)
for
i
in
range
(
len
(
scaled_arcs
)):
dc
.
SetPen
(
pens
[
i
]
if
type
(
pens
)
.
__name__
==
'list'
else
pens
)
scaled_arcs
=
map
(
self
.
_arc_scaler
,
arcs
)
dc
.
SetBrush
(
wx
.
TRANSPARENT_BRUSH
)
for
i
in
range
(
len
(
scaled_arcs
)):
dc
.
SetPen
(
pens
[
i
]
if
type
(
pens
)
==
list
else
pens
)
dc
.
DrawArc
(
*
scaled_arcs
[
i
])
if
self
.
showall
:
...
...
@@ -286,6 +292,7 @@ class gviz(wx.Panel):
_drawlines
(
self
.
lines
[
i
],
self
.
pens
[
i
])
_drawarcs
(
self
.
arcs
[
i
],
self
.
arcpens
[
i
])
return
if
self
.
layerindex
<
len
(
self
.
layers
)
and
self
.
layers
[
self
.
layerindex
]
in
self
.
lines
.
keys
():
for
layer_i
in
xrange
(
max
(
0
,
self
.
layerindex
-
6
),
self
.
layerindex
):
#print i, self.layerindex, self.layerindex-i
...
...
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