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
85078b82
Commit
85078b82
authored
Jul 29, 2011
by
kliment
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First working version of the plater tool.
parent
9b1b45d0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
13 deletions
+50
-13
plater.py
plater.py
+50
-13
No files found.
plater.py
View file @
85078b82
...
...
@@ -16,10 +16,14 @@ class showstl(wx.Window):
def
__init__
(
self
,
parent
,
size
,
pos
):
wx
.
Window
.
__init__
(
self
,
parent
,
size
=
size
,
pos
=
pos
)
self
.
l
=
wx
.
ListCtrl
(
self
,
size
=
(
300
,
100
),
pos
=
(
0
,
size
[
1
]
-
100
))
self
.
b
=
wx
.
Button
(
self
,
label
=
"Export"
,
pos
=
(
300
,
size
[
1
]
-
100
))
self
.
b
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
export
)
self
.
eb
=
wx
.
Button
(
self
,
label
=
"Export"
,
pos
=
(
300
,
size
[
1
]
-
100
))
self
.
sb
=
wx
.
Button
(
self
,
label
=
"Snap to Z=0"
,
pos
=
(
300
,
size
[
1
]
-
70
))
self
.
cb
=
wx
.
Button
(
self
,
label
=
"Put at 100,100"
,
pos
=
(
300
,
size
[
1
]
-
40
))
self
.
eb
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
export
)
self
.
sb
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
snap
)
self
.
cb
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
center
)
#self.SetBackgroundColour((0,0,0))
wx
.
FutureCall
(
200
,
self
.
paint
)
#
wx.FutureCall(200,self.paint)
self
.
i
=
0
self
.
previ
=
0
self
.
Bind
(
wx
.
EVT_MOUSEWHEEL
,
self
.
rot
)
...
...
@@ -32,6 +36,22 @@ class showstl(wx.Window):
self
.
initpos
=
None
self
.
prevsel
=-
1
def
center
(
self
,
event
):
i
=
self
.
l
.
GetFirstSelected
()
if
i
!=
-
1
:
m
=
self
.
models
[
self
.
l
.
GetItemText
(
i
)]
m
.
offsets
=
[
100
,
100
,
m
.
offsets
[
2
]]
self
.
Refresh
()
def
snap
(
self
,
event
):
i
=
self
.
l
.
GetFirstSelected
()
if
i
!=
-
1
:
m
=
self
.
models
[
self
.
l
.
GetItemText
(
i
)]
m
.
offsets
[
2
]
=-
1.0
*
min
(
m
.
facetsminz
)[
0
]
#print m.offsets[2]
self
.
Refresh
()
def
export
(
self
,
event
):
dlg
=
wx
.
FileDialog
(
self
,
"Pick file to save to"
,
self
.
basedir
,
style
=
wx
.
FD_SAVE
)
dlg
.
SetWildcard
(
"STL files (;*.stl;)"
)
...
...
@@ -39,6 +59,8 @@ class showstl(wx.Window):
name
=
dlg
.
GetPath
()
facets
=
[]
for
i
in
self
.
models
.
values
():
if
i
.
offsets
!=
[
0
,
0
,
0
]:
i
=
i
.
translate
(
i
.
offsets
)
facets
+=
i
.
facets
stltool
.
emitstl
(
name
,
facets
,
"plater_export"
)
print
"wrote "
,
name
...
...
@@ -56,10 +78,15 @@ class showstl(wx.Window):
t
=
time
.
time
()
#print name
if
name
.
lower
()
.
endswith
(
".stl"
):
self
.
models
[
name
]
=
stltool
.
stl
(
name
)
self
.
models
[
name
]
.
offsets
=
[
0
,
0
,
0
]
newname
=
name
c
=
1
while
newname
in
self
.
models
:
newname
=
name
+
"(
%
d)"
%
c
c
+=
1
self
.
models
[
newname
]
=
stltool
.
stl
(
name
)
self
.
models
[
newname
]
.
offsets
=
[
0
,
0
,
0
]
#print time.time()-t
self
.
l
.
Append
([
stlwrap
(
self
.
models
[
n
ame
],
name
)])
self
.
l
.
Append
([
stlwrap
(
self
.
models
[
n
ewname
],
new
name
)])
self
.
Refresh
()
#print time.time()-t
...
...
@@ -72,7 +99,7 @@ class showstl(wx.Window):
#print (p[0]-self.initpos[0]),(p[1]-self.initpos[1])
t
=
time
.
time
()
m
=
self
.
models
[
self
.
l
.
GetItemText
(
i
)]
m
.
offsets
=
[
m
.
offsets
[
0
]
+
0.5
*
(
p
[
0
]
-
self
.
initpos
[
0
]),
m
.
offsets
[
1
]
+
0.5
*
(
p
[
1
]
-
self
.
initpos
[
1
]),
m
.
offsets
[
2
]]
m
.
offsets
=
[
m
.
offsets
[
0
]
+
0.5
*
(
p
[
0
]
-
self
.
initpos
[
0
]),
m
.
offsets
[
1
]
-
0.5
*
(
p
[
1
]
-
self
.
initpos
[
1
]),
m
.
offsets
[
2
]]
#self.models[self.l.GetItemText(i)]=self.models[self.l.GetItemText(i)].translate([0.5*(p[0]-self.initpos[0]),0.5*(p[1]-self.initpos[1]),0])
#print time.time()-t
self
.
Refresh
()
...
...
@@ -97,7 +124,9 @@ class showstl(wx.Window):
if
(
self
.
i
!=
self
.
previ
):
i
=
self
.
l
.
GetFirstSelected
()
if
i
!=
-
1
:
o
=
self
.
models
[
self
.
l
.
GetItemText
(
i
)]
.
offsets
self
.
models
[
self
.
l
.
GetItemText
(
i
)]
=
self
.
models
[
self
.
l
.
GetItemText
(
i
)]
.
rotate
([
0
,
0
,
self
.
i
-
self
.
previ
])
self
.
models
[
self
.
l
.
GetItemText
(
i
)]
.
offsets
=
o
self
.
previ
=
self
.
i
wx
.
CallAfter
(
self
.
Refresh
)
self
.
triggered
=
0
...
...
@@ -125,23 +154,31 @@ class showstl(wx.Window):
if
dc
is
None
:
dc
=
wx
.
ClientDC
(
self
)
offset
=
[
0
,
0
]
scale
=
3
scale
=
2
dc
.
SetPen
(
wx
.
Pen
(
wx
.
Colour
(
100
,
100
,
100
)))
for
i
in
xrange
(
20
):
dc
.
DrawLine
(
0
,
i
*
scale
*
10
,
400
,
i
*
scale
*
10
)
dc
.
DrawLine
(
i
*
scale
*
10
,
0
,
i
*
scale
*
10
,
400
)
dc
.
SetPen
(
wx
.
Pen
(
wx
.
Colour
(
0
,
0
,
0
)))
for
i
in
xrange
(
4
):
dc
.
DrawLine
(
0
,
i
*
scale
*
50
,
400
,
i
*
scale
*
50
)
dc
.
DrawLine
(
i
*
scale
*
50
,
0
,
i
*
scale
*
50
,
400
)
dc
.
SetBrush
(
wx
.
Brush
(
wx
.
Colour
(
128
,
255
,
128
)))
dc
.
SetPen
(
wx
.
Pen
(
wx
.
Colour
(
128
,
255
,
128
)))
dc
.
SetPen
(
wx
.
Pen
(
wx
.
Colour
(
128
,
128
,
128
)))
t
=
time
.
time
()
for
m
in
self
.
models
.
values
():
for
i
in
m
.
facets
:
#random.sample(m.facets,min(100000,len(m.facets))):
dc
.
DrawPolygon
([
wx
.
Point
(
offset
[
0
]
+
scale
*
m
.
offsets
[
0
]
+
scale
*
p
[
0
],
0
-
(
offset
[
1
]
+
scale
*
m
.
offsets
[
1
]
+
scale
*
p
[
1
]))
for
p
in
i
[
1
]])
dc
.
DrawPolygon
([
wx
.
Point
(
offset
[
0
]
+
scale
*
m
.
offsets
[
0
]
+
scale
*
p
[
0
],
40
0
-
(
offset
[
1
]
+
scale
*
m
.
offsets
[
1
]
+
scale
*
p
[
1
]))
for
p
in
i
[
1
]])
#if(time.time()-t)>5:
# break
del
dc
print
time
.
time
()
-
t
#
print time.time()-t
#s.export()
class
stlwin
(
wx
.
Frame
):
def
__init__
(
self
,
size
=
(
600
,
7
00
)):
def
__init__
(
self
,
size
=
(
400
,
5
00
)):
wx
.
Frame
.
__init__
(
self
,
None
,
title
=
"Right-click to add a file"
,
size
=
size
)
self
.
s
=
showstl
(
self
,(
600
,
7
00
),(
0
,
0
))
self
.
s
=
showstl
(
self
,(
400
,
5
00
),(
0
,
0
))
if
__name__
==
'__main__'
:
app
=
wx
.
App
(
False
)
...
...
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