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
681e9989
Commit
681e9989
authored
Apr 05, 2014
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add UI for stl cutting tool
parent
7cfcf617
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
87 additions
and
16 deletions
+87
-16
objectplater.py
printrun/objectplater.py
+2
-2
stlplater.py
printrun/stlplater.py
+70
-1
stlview.py
printrun/stlview.py
+15
-13
No files found.
printrun/objectplater.py
View file @
681e9989
...
@@ -36,8 +36,8 @@ class Plater(wx.Frame):
...
@@ -36,8 +36,8 @@ class Plater(wx.Frame):
self
.
filenames
=
filenames
self
.
filenames
=
filenames
self
.
SetIcon
(
wx
.
Icon
(
iconfile
(
"plater.png"
),
wx
.
BITMAP_TYPE_PNG
))
self
.
SetIcon
(
wx
.
Icon
(
iconfile
(
"plater.png"
),
wx
.
BITMAP_TYPE_PNG
))
self
.
mainsizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
self
.
mainsizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
panel
=
wx
.
Panel
(
self
,
-
1
)
panel
=
self
.
menupanel
=
wx
.
Panel
(
self
,
-
1
)
sizer
=
wx
.
GridBagSizer
()
sizer
=
self
.
menusizer
=
wx
.
GridBagSizer
()
self
.
l
=
wx
.
ListBox
(
panel
)
self
.
l
=
wx
.
ListBox
(
panel
)
sizer
.
Add
(
self
.
l
,
pos
=
(
1
,
0
),
span
=
(
1
,
2
),
flag
=
wx
.
EXPAND
)
sizer
.
Add
(
self
.
l
,
pos
=
(
1
,
0
),
span
=
(
1
,
2
),
flag
=
wx
.
EXPAND
)
sizer
.
AddGrowableRow
(
1
,
1
)
sizer
.
AddGrowableRow
(
1
,
1
)
...
...
printrun/stlplater.py
View file @
681e9989
...
@@ -227,19 +227,88 @@ class StlPlater(Plater):
...
@@ -227,19 +227,88 @@ class StlPlater(Plater):
super
(
StlPlater
,
self
)
.
__init__
(
filenames
,
size
,
callback
,
parent
,
build_dimensions
)
super
(
StlPlater
,
self
)
.
__init__
(
filenames
,
size
,
callback
,
parent
,
build_dimensions
)
self
.
cutting
=
False
self
.
cutting
=
False
self
.
cutting_axis
=
None
self
.
cutting_axis
=
None
self
.
cutting_dist
=
None
if
glview
:
if
glview
:
viewer
=
stlview
.
StlViewPanel
(
self
,
(
580
,
580
),
viewer
=
stlview
.
StlViewPanel
(
self
,
(
580
,
580
),
build_dimensions
=
self
.
build_dimensions
,
build_dimensions
=
self
.
build_dimensions
,
circular
=
circular_platform
,
circular
=
circular_platform
,
antialias_samples
=
antialias_samples
)
antialias_samples
=
antialias_samples
)
# Cutting tool
self
.
menusizer
.
Add
(
wx
.
StaticText
(
self
.
menupanel
,
-
1
,
_
(
"Cut along:"
)),
pos
=
(
6
,
0
),
span
=
(
1
,
1
),
flag
=
wx
.
ALIGN_CENTER
)
cutconfirmbutton
=
wx
.
Button
(
self
.
menupanel
,
label
=
_
(
"Confirm cut"
))
cutconfirmbutton
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
cut_confirm
)
cutconfirmbutton
.
Disable
()
self
.
cutconfirmbutton
=
cutconfirmbutton
self
.
menusizer
.
Add
(
cutconfirmbutton
,
pos
=
(
6
,
1
),
span
=
(
1
,
1
),
flag
=
wx
.
EXPAND
)
cutpanel
=
wx
.
Panel
(
self
.
menupanel
,
-
1
)
cutsizer
=
self
.
cutsizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
cutpanel
.
SetSizer
(
cutsizer
)
cutxplusbutton
=
wx
.
ToggleButton
(
cutpanel
,
label
=
_
(
">X"
),
style
=
wx
.
BU_EXACTFIT
)
cutxplusbutton
.
Bind
(
wx
.
EVT_TOGGLEBUTTON
,
lambda
event
:
self
.
start_cutting_tool
(
event
,
"x"
,
1
))
cutsizer
.
Add
(
cutxplusbutton
,
1
,
flag
=
wx
.
EXPAND
)
cutzplusbutton
=
wx
.
ToggleButton
(
cutpanel
,
label
=
_
(
">Y"
),
style
=
wx
.
BU_EXACTFIT
)
cutzplusbutton
.
Bind
(
wx
.
EVT_TOGGLEBUTTON
,
lambda
event
:
self
.
start_cutting_tool
(
event
,
"y"
,
1
))
cutsizer
.
Add
(
cutzplusbutton
,
1
,
flag
=
wx
.
EXPAND
)
cutzplusbutton
=
wx
.
ToggleButton
(
cutpanel
,
label
=
_
(
">Z"
),
style
=
wx
.
BU_EXACTFIT
)
cutzplusbutton
.
Bind
(
wx
.
EVT_TOGGLEBUTTON
,
lambda
event
:
self
.
start_cutting_tool
(
event
,
"z"
,
1
))
cutsizer
.
Add
(
cutzplusbutton
,
1
,
flag
=
wx
.
EXPAND
)
cutxminusbutton
=
wx
.
ToggleButton
(
cutpanel
,
label
=
_
(
"<X"
),
style
=
wx
.
BU_EXACTFIT
)
cutxminusbutton
.
Bind
(
wx
.
EVT_TOGGLEBUTTON
,
lambda
event
:
self
.
start_cutting_tool
(
event
,
"x"
,
-
1
))
cutsizer
.
Add
(
cutxminusbutton
,
1
,
flag
=
wx
.
EXPAND
)
cutzminusbutton
=
wx
.
ToggleButton
(
cutpanel
,
label
=
_
(
"<Y"
),
style
=
wx
.
BU_EXACTFIT
)
cutzminusbutton
.
Bind
(
wx
.
EVT_TOGGLEBUTTON
,
lambda
event
:
self
.
start_cutting_tool
(
event
,
"y"
,
-
1
))
cutsizer
.
Add
(
cutzminusbutton
,
1
,
flag
=
wx
.
EXPAND
)
cutzminusbutton
=
wx
.
ToggleButton
(
cutpanel
,
label
=
_
(
"<Z"
),
style
=
wx
.
BU_EXACTFIT
)
cutzminusbutton
.
Bind
(
wx
.
EVT_TOGGLEBUTTON
,
lambda
event
:
self
.
start_cutting_tool
(
event
,
"z"
,
-
1
))
cutsizer
.
Add
(
cutzminusbutton
,
1
,
flag
=
wx
.
EXPAND
)
self
.
menusizer
.
Add
(
cutpanel
,
pos
=
(
7
,
0
),
span
=
(
1
,
2
),
flag
=
wx
.
EXPAND
)
else
:
else
:
viewer
=
showstl
(
self
,
(
580
,
580
),
(
0
,
0
))
viewer
=
showstl
(
self
,
(
580
,
580
),
(
0
,
0
))
self
.
simarrange_path
=
simarrange_path
if
simarrange_path
else
"./simarrange/sa"
self
.
simarrange_path
=
simarrange_path
if
simarrange_path
else
"./simarrange/sa"
self
.
set_viewer
(
viewer
)
self
.
set_viewer
(
viewer
)
def
clickcb
(
self
,
event
):
def
start_cutting_tool
(
self
,
event
,
axis
,
direction
):
toggle
=
event
.
GetEventObject
()
if
toggle
.
GetValue
():
# Disable the other toggles
for
child
in
self
.
cutsizer
.
GetChildren
():
child
=
child
.
GetWindow
()
if
child
!=
toggle
:
child
.
SetValue
(
False
)
self
.
cutting
=
True
self
.
cutting_axis
=
axis
self
.
cutting_dist
=
None
self
.
cutting_direction
=
direction
else
:
self
.
cutting
=
False
self
.
cutting_axis
=
None
self
.
cutting_dist
=
None
self
.
cutting_direction
=
None
def
cut_confirm
(
self
,
event
):
name
=
self
.
l
.
GetSelection
()
name
=
self
.
l
.
GetString
(
name
)
model
=
self
.
models
[
name
]
print
"Cutting"
,
name
,
self
.
cutting_axis
,
self
.
cutting_direction
,
self
.
cutting_dist
,
model
self
.
cutconfirmbutton
.
Disable
()
def
clickcb
(
self
,
event
,
single
=
False
):
if
not
isinstance
(
self
.
s
,
stlview
.
StlViewPanel
):
if
not
isinstance
(
self
.
s
,
stlview
.
StlViewPanel
):
return
return
if
self
.
cutting
:
self
.
clickcb_cut
(
event
)
else
:
self
.
clickcb_rebase
(
event
)
def
clickcb_cut
(
self
,
event
):
axis
=
self
.
cutting_axis
self
.
cutting_dist
,
_
,
_
=
self
.
s
.
get_cutting_plane
(
axis
,
None
,
local_transform
=
True
)
if
self
.
cutting_dist
is
not
None
:
self
.
cutconfirmbutton
.
Enable
()
def
clickcb_rebase
(
self
,
event
):
x
,
y
=
event
.
GetPosition
()
x
,
y
=
event
.
GetPosition
()
ray_near
,
ray_far
=
self
.
s
.
mouse_to_ray
(
x
,
y
,
local_transform
=
True
)
ray_near
,
ray_far
=
self
.
s
.
mouse_to_ray
(
x
,
y
,
local_transform
=
True
)
best_match
=
None
best_match
=
None
...
...
printrun/stlview.py
View file @
681e9989
...
@@ -77,9 +77,9 @@ class StlViewPanel(wxGLPanel):
...
@@ -77,9 +77,9 @@ class StlViewPanel(wxGLPanel):
self
.
batches
=
[]
self
.
batches
=
[]
self
.
rot
=
0
self
.
rot
=
0
self
.
canvas
.
Bind
(
wx
.
EVT_MOUSE_EVENTS
,
self
.
move
)
self
.
canvas
.
Bind
(
wx
.
EVT_MOUSE_EVENTS
,
self
.
move
)
self
.
canvas
.
Bind
(
wx
.
EVT_LEFT_DCLICK
,
self
.
double
)
self
.
initialized
=
1
self
.
canvas
.
Bind
(
wx
.
EVT_MOUSEWHEEL
,
self
.
wheel
)
self
.
canvas
.
Bind
(
wx
.
EVT_MOUSEWHEEL
,
self
.
wheel
)
self
.
canvas
.
Bind
(
wx
.
EVT_LEFT_DCLICK
,
self
.
double_click
)
self
.
initialized
=
True
self
.
parent
=
parent
self
.
parent
=
parent
self
.
initpos
=
None
self
.
initpos
=
None
if
build_dimensions
:
if
build_dimensions
:
...
@@ -150,14 +150,14 @@ class StlViewPanel(wxGLPanel):
...
@@ -150,14 +150,14 @@ class StlViewPanel(wxGLPanel):
self
.
parent
.
loadcb
()
self
.
parent
.
loadcb
()
self
.
parent
.
filenames
=
None
self
.
parent
.
filenames
=
None
def
double
(
self
,
event
):
def
double
_click
(
self
,
event
):
if
hasattr
(
self
.
parent
,
"clickcb"
)
and
self
.
parent
.
clickcb
:
if
hasattr
(
self
.
parent
,
"clickcb"
)
and
self
.
parent
.
clickcb
:
self
.
parent
.
clickcb
(
event
)
self
.
parent
.
clickcb
(
event
)
def
forceresize
(
self
):
def
forceresize
(
self
):
self
.
SetClientSize
((
self
.
GetClientSize
()[
0
],
self
.
GetClientSize
()[
1
]
+
1
))
self
.
SetClientSize
((
self
.
GetClientSize
()[
0
],
self
.
GetClientSize
()[
1
]
+
1
))
self
.
SetClientSize
((
self
.
GetClientSize
()[
0
],
self
.
GetClientSize
()[
1
]
-
1
))
self
.
SetClientSize
((
self
.
GetClientSize
()[
0
],
self
.
GetClientSize
()[
1
]
-
1
))
self
.
initialized
=
0
self
.
initialized
=
False
def
move
(
self
,
event
):
def
move
(
self
,
event
):
"""react to mouse actions:
"""react to mouse actions:
...
@@ -323,7 +323,8 @@ class StlViewPanel(wxGLPanel):
...
@@ -323,7 +323,8 @@ class StlViewPanel(wxGLPanel):
if
self
.
parent
.
cutting
:
if
self
.
parent
.
cutting
:
# FIXME: make this a proper Actor
# FIXME: make this a proper Actor
axis
=
self
.
parent
.
cutting_axis
axis
=
self
.
parent
.
cutting_axis
dist
,
plane_width
,
plane_height
=
self
.
get_cutting_plane
(
axis
)
fixed_dist
=
self
.
parent
.
cutting_dist
dist
,
plane_width
,
plane_height
=
self
.
get_cutting_plane
(
axis
,
fixed_dist
)
if
dist
is
not
None
:
if
dist
is
not
None
:
glPushMatrix
()
glPushMatrix
()
if
axis
==
"x"
:
if
axis
==
"x"
:
...
@@ -338,7 +339,7 @@ class StlViewPanel(wxGLPanel):
...
@@ -338,7 +339,7 @@ class StlViewPanel(wxGLPanel):
glDisable
(
GL_CULL_FACE
)
glDisable
(
GL_CULL_FACE
)
glBegin
(
GL_TRIANGLES
)
glBegin
(
GL_TRIANGLES
)
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_AMBIENT_AND_DIFFUSE
,
vec
(
0
,
0.9
,
0.15
,
0.3
))
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_AMBIENT_AND_DIFFUSE
,
vec
(
0
,
0.9
,
0.15
,
0.3
))
glNormal3f
(
0
,
0
,
1
)
glNormal3f
(
0
,
0
,
self
.
parent
.
cutting_direction
)
glVertex3f
(
plane_width
,
plane_height
,
0
)
glVertex3f
(
plane_width
,
plane_height
,
0
)
glVertex3f
(
0
,
plane_height
,
0
)
glVertex3f
(
0
,
plane_height
,
0
)
glVertex3f
(
0
,
0
,
0
)
glVertex3f
(
0
,
0
,
0
)
...
@@ -354,7 +355,6 @@ class StlViewPanel(wxGLPanel):
...
@@ -354,7 +355,6 @@ class StlViewPanel(wxGLPanel):
glLineWidth
(
4.0
)
glLineWidth
(
4.0
)
glBegin
(
GL_LINE_LOOP
)
glBegin
(
GL_LINE_LOOP
)
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_AMBIENT_AND_DIFFUSE
,
vec
(
0
,
0.8
,
0.15
,
1
))
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_AMBIENT_AND_DIFFUSE
,
vec
(
0
,
0.8
,
0.15
,
1
))
glNormal3f
(
0
,
0
,
1
)
glVertex3f
(
0
,
0
,
0
)
glVertex3f
(
0
,
0
,
0
)
glVertex3f
(
0
,
plane_height
,
0
)
glVertex3f
(
0
,
plane_height
,
0
)
glVertex3f
(
plane_width
,
plane_height
,
0
)
glVertex3f
(
plane_width
,
plane_height
,
0
)
...
@@ -385,7 +385,13 @@ class StlViewPanel(wxGLPanel):
...
@@ -385,7 +385,13 @@ class StlViewPanel(wxGLPanel):
glGetDoublev
(
GL_MODELVIEW_MATRIX
,
mvmat
)
glGetDoublev
(
GL_MODELVIEW_MATRIX
,
mvmat
)
return
mvmat
return
mvmat
def
get_cutting_plane
(
self
,
cutting_axis
):
def
get_cutting_plane
(
self
,
cutting_axis
,
fixed_dist
,
local_transform
=
False
):
cutting_plane_sizes
=
{
"x"
:
(
self
.
platform
.
depth
,
self
.
platform
.
height
),
"y"
:
(
self
.
platform
.
width
,
self
.
platform
.
height
),
"z"
:
(
self
.
platform
.
width
,
self
.
platform
.
depth
)}
plane_width
,
plane_height
=
cutting_plane_sizes
[
cutting_axis
]
if
fixed_dist
is
not
None
:
return
fixed_dist
,
plane_width
,
plane_height
ref_sizes
=
{
"x"
:
self
.
platform
.
width
,
ref_sizes
=
{
"x"
:
self
.
platform
.
width
,
"y"
:
self
.
platform
.
depth
,
"y"
:
self
.
platform
.
depth
,
"z"
:
self
.
platform
.
height
,
"z"
:
self
.
platform
.
height
,
...
@@ -410,17 +416,13 @@ class StlViewPanel(wxGLPanel):
...
@@ -410,17 +416,13 @@ class StlViewPanel(wxGLPanel):
"y"
:
-
self
.
platform
.
width
/
2
,
"y"
:
-
self
.
platform
.
width
/
2
,
"z"
:
-
self
.
platform
.
width
/
2
,
"z"
:
-
self
.
platform
.
width
/
2
,
}
}
cutting_plane_sizes
=
{
"x"
:
(
self
.
platform
.
depth
,
self
.
platform
.
height
),
"y"
:
(
self
.
platform
.
width
,
self
.
platform
.
height
),
"z"
:
(
self
.
platform
.
width
,
self
.
platform
.
depth
)}
ref_size
=
ref_sizes
[
cutting_axis
]
ref_size
=
ref_sizes
[
cutting_axis
]
ref_plane
=
ref_planes
[
cutting_axis
]
ref_plane
=
ref_planes
[
cutting_axis
]
ref_offset
=
ref_offsets
[
cutting_axis
]
ref_offset
=
ref_offsets
[
cutting_axis
]
plane_width
,
plane_height
=
cutting_plane_sizes
[
cutting_axis
]
inter
=
self
.
mouse_to_plane
(
self
.
mousepos
[
0
],
self
.
mousepos
[
1
],
inter
=
self
.
mouse_to_plane
(
self
.
mousepos
[
0
],
self
.
mousepos
[
1
],
plane_normal
=
ref_plane
,
plane_normal
=
ref_plane
,
plane_offset
=
ref_offset
,
plane_offset
=
ref_offset
,
local_transform
=
False
)
local_transform
=
local_transform
)
max_size
=
max
((
self
.
platform
.
width
,
max_size
=
max
((
self
.
platform
.
width
,
self
.
platform
.
depth
,
self
.
platform
.
depth
,
self
.
platform
.
height
))
self
.
platform
.
height
))
...
...
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