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
50dbb802
Commit
50dbb802
authored
Jul 01, 2012
by
Gary Hodgson
Committed by
Guillaume Seguin
May 30, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial raft; auto scaling for slic3r svg.
parent
f50cc72a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
4 deletions
+80
-4
projectlayer.py
projectlayer.py
+80
-4
No files found.
projectlayer.py
View file @
50dbb802
...
...
@@ -82,7 +82,6 @@ class dispframe(wx.Frame):
if
slicer
==
'Skeinforge'
:
for
i
in
image
:
#print i
points
=
[
wx
.
Point
(
*
map
(
lambda
x
:
int
(
round
(
float
(
x
)
*
self
.
scale
)),
j
.
strip
()
.
split
()))
for
j
in
i
.
strip
()
.
split
(
"M"
)[
1
]
.
split
(
"L"
)]
dc
.
DrawPolygon
(
points
,
self
.
size
[
0
]
/
2
,
self
.
size
[
1
]
/
2
)
elif
slicer
==
'Slic3r'
:
...
...
@@ -143,7 +142,6 @@ class dispframe(wx.Frame):
self
.
scale
=
scale
self
.
thickness
=
thickness
self
.
index
=
0
#self.size = (size[0] + offset[0], size[1] + offset[1])
self
.
size
=
size
self
.
interval
=
interval
self
.
offset
=
offset
...
...
@@ -155,7 +153,7 @@ class dispframe(wx.Frame):
class
setframe
(
wx
.
Frame
):
def
__init__
(
self
,
parent
,
printer
=
None
):
wx
.
Frame
.
__init__
(
self
,
parent
,
title
=
"Projector setup"
,
size
=
(
400
,
3
00
))
wx
.
Frame
.
__init__
(
self
,
parent
,
title
=
"Projector setup"
,
size
=
(
400
,
4
00
))
self
.
f
=
dispframe
(
None
,
""
,
printer
=
printer
)
self
.
panel
=
wx
.
Panel
(
self
)
self
.
panel
.
SetBackgroundColour
(
"orange"
)
...
...
@@ -218,6 +216,18 @@ class setframe(wx.Frame):
self
.
showfirstlayer
=
wx
.
CheckBox
(
self
.
panel
,
-
1
,
pos
=
(
rightValueXPos
,
240
))
self
.
showfirstlayer
.
Bind
(
wx
.
EVT_CHECKBOX
,
self
.
presentfirstlayer
)
wx
.
StaticText
(
self
.
panel
,
-
1
,
"Raft:"
,
pos
=
(
rightlabelXPos
,
270
))
self
.
raft
=
wx
.
CheckBox
(
self
.
panel
,
-
1
,
pos
=
(
rightValueXPos
,
270
))
self
.
raft
.
Bind
(
wx
.
EVT_CHECKBOX
,
self
.
showRaft
)
wx
.
StaticText
(
self
.
panel
,
-
1
,
"Red?:"
,
pos
=
(
rightlabelXPos
+
70
,
270
))
self
.
previewRaft
=
wx
.
CheckBox
(
self
.
panel
,
-
1
,
pos
=
(
rightValueXPos
+
70
,
270
))
self
.
previewRaft
.
Bind
(
wx
.
EVT_CHECKBOX
,
self
.
showRaft
)
wx
.
StaticText
(
self
.
panel
,
-
1
,
"Raft Grid (mm):"
,
pos
=
(
rightlabelXPos
,
300
))
self
.
raftGridSize
=
floatspin
.
FloatSpin
(
self
.
panel
,
-
1
,
pos
=
(
rightValueXPos
+
40
,
300
),
value
=
5.0
,
increment
=
0.1
,
digits
=
1
)
self
.
raftGridSize
.
Bind
(
floatspin
.
EVT_FLOATSPIN
,
self
.
showRaft
)
self
.
Show
()
def
__del__
(
self
):
...
...
@@ -294,13 +304,16 @@ class setframe(wx.Frame):
print
len
(
layers
[
0
]),
"layers found, total height"
,
layerHeight
*
len
(
layers
[
0
]),
"mm"
self
.
layers
=
layers
self
.
f
.
slicer
=
layers
[
2
]
if
(
self
.
f
.
slicer
==
'Slic3r'
):
self
.
scale
.
SetValue
(
3.5
)
print
"Slic3r SVG detected: setting scale to 3.5 to correct size displayed."
dlg
.
Destroy
()
def
startcalibrate
(
self
,
event
):
if
self
.
calibrate
.
IsChecked
():
self
.
f
.
Raise
()
self
.
f
.
offset
=
(
float
(
self
.
offsetX
.
GetValue
()),
float
(
self
.
offsetY
.
GetValue
()))
self
.
f
.
scale
=
float
(
self
.
scale
.
GetValue
())
self
.
f
.
scale
=
1.0
resolutionXPixels
=
int
(
self
.
X
.
GetValue
())
resolutionYPixels
=
int
(
self
.
Y
.
GetValue
())
...
...
@@ -335,6 +348,67 @@ class setframe(wx.Frame):
self
.
f
.
drawlayer
(
gridBitmap
.
ConvertToImage
(),
'bitmap'
)
else
:
self
.
f
.
scale
=
float
(
self
.
scale
.
GetValue
())
self
.
f
.
clearlayer
()
def
showRaft
(
self
,
event
):
if
self
.
raft
.
IsChecked
():
self
.
f
.
Raise
()
self
.
f
.
offset
=
(
float
(
self
.
offsetX
.
GetValue
()),
-
float
(
self
.
offsetY
.
GetValue
()))
self
.
f
.
scale
=
1.0
resolutionXPixels
=
int
(
self
.
X
.
GetValue
())
resolutionYPixels
=
int
(
self
.
Y
.
GetValue
())
gridBitmap
=
wx
.
EmptyBitmap
(
resolutionXPixels
,
resolutionYPixels
)
dc
=
wx
.
MemoryDC
()
dc
.
SelectObject
(
gridBitmap
)
dc
.
SetBackground
(
wx
.
Brush
(
"black"
))
dc
.
Clear
()
if
(
self
.
previewRaft
.
IsChecked
()):
raftColor
=
"red"
else
:
raftColor
=
"white"
dc
.
SetPen
(
wx
.
Pen
(
raftColor
,
2
))
aspectRatio
=
float
(
resolutionXPixels
)
/
float
(
resolutionYPixels
)
projectedXmm
=
float
(
self
.
projectedXmm
.
GetValue
())
projectedYmm
=
round
(
projectedXmm
/
aspectRatio
)
pixelsXPerMM
=
resolutionXPixels
/
projectedXmm
pixelsYPerMM
=
resolutionYPixels
/
projectedYmm
if
(
hasattr
(
self
,
'layers'
)):
xDist
=
float
(
self
.
layers
[
0
][
0
]
.
get
(
'width'
)
.
replace
(
'm'
,
''
))
yDist
=
float
(
self
.
layers
[
0
][
0
]
.
get
(
'height'
)
.
replace
(
'm'
,
''
))
else
:
xDist
=
projectedXmm
yDist
=
projectedYmm
gridSize
=
self
.
raftGridSize
.
GetValue
()
gridCountX
=
int
(
xDist
/
gridSize
)
gridCountY
=
int
(
yDist
/
gridSize
)
xDistPixels
=
xDist
*
pixelsXPerMM
yDistPixels
=
yDist
*
pixelsYPerMM
# border
dc
.
DrawLine
(
0
,
0
,
xDistPixels
,
0
);
dc
.
DrawLine
(
0
,
0
,
0
,
yDistPixels
);
dc
.
DrawLine
(
xDistPixels
,
0
,
xDistPixels
,
yDistPixels
);
dc
.
DrawLine
(
0
,
yDistPixels
,
xDistPixels
,
yDistPixels
);
# grid
for
y
in
xrange
(
0
,
gridCountY
+
1
):
for
x
in
xrange
(
0
,
gridCountX
+
1
):
dc
.
DrawLine
(
0
,
y
*
(
pixelsYPerMM
*
gridSize
),
xDistPixels
,
y
*
(
pixelsYPerMM
*
gridSize
));
dc
.
DrawLine
(
x
*
(
pixelsXPerMM
*
gridSize
),
0
,
x
*
(
pixelsXPerMM
*
gridSize
),
yDistPixels
);
self
.
f
.
drawlayer
(
gridBitmap
.
ConvertToImage
(),
'bitmap'
)
else
:
self
.
f
.
offset
=
(
float
(
self
.
offsetX
.
GetValue
()),
float
(
self
.
offsetY
.
GetValue
()))
self
.
f
.
scale
=
float
(
self
.
scale
.
GetValue
())
self
.
f
.
clearlayer
()
def
updateoffset
(
self
,
event
):
...
...
@@ -385,6 +459,8 @@ class setframe(wx.Frame):
def
presentfirstlayer
(
self
,
event
):
if
(
self
.
showfirstlayer
.
GetValue
()):
self
.
f
.
offset
=
(
float
(
self
.
offsetX
.
GetValue
()),
float
(
self
.
offsetY
.
GetValue
()))
self
.
f
.
scale
=
float
(
self
.
scale
.
GetValue
())
self
.
f
.
drawlayer
(
self
.
layers
[
0
][
0
],
self
.
f
.
slicer
)
else
:
self
.
f
.
hidePic
()
...
...
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