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
18fce213
Commit
18fce213
authored
Jun 16, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve gviz code a little bit
parent
ac06e549
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
6 deletions
+10
-6
gui.py
printrun/gui.py
+1
-1
gviz.py
printrun/gviz.py
+9
-5
No files found.
printrun/gui.py
View file @
18fce213
...
@@ -288,7 +288,7 @@ class VizPane(wx.BoxSizer):
...
@@ -288,7 +288,7 @@ class VizPane(wx.BoxSizer):
print
"Falling back to 2D view, and here is the backtrace:"
print
"Falling back to 2D view, and here is the backtrace:"
traceback
.
print_exc
()
traceback
.
print_exc
()
if
not
use3dview
:
if
not
use3dview
:
root
.
gwindow
=
gviz
.
GvizWindow
(
[],
root
.
gwindow
=
gviz
.
GvizWindow
(
build_dimensions
=
root
.
build_dimensions_list
,
build_dimensions
=
root
.
build_dimensions_list
,
grid
=
(
root
.
settings
.
preview_grid_step1
,
root
.
settings
.
preview_grid_step2
),
grid
=
(
root
.
settings
.
preview_grid_step1
,
root
.
settings
.
preview_grid_step2
),
extrusion_width
=
root
.
settings
.
preview_extrusion_width
,
extrusion_width
=
root
.
settings
.
preview_extrusion_width
,
...
...
printrun/gviz.py
View file @
18fce213
...
@@ -24,7 +24,7 @@ install_locale('pronterface')
...
@@ -24,7 +24,7 @@ install_locale('pronterface')
ID_ABOUT
=
101
ID_ABOUT
=
101
ID_EXIT
=
110
ID_EXIT
=
110
class
GvizWindow
(
wx
.
Frame
):
class
GvizWindow
(
wx
.
Frame
):
def
__init__
(
self
,
f
,
size
=
(
600
,
600
),
build_dimensions
=
[
200
,
200
,
100
,
0
,
0
,
0
],
grid
=
(
10
,
50
),
extrusion_width
=
0.5
,
bgcolor
=
"#000000"
):
def
__init__
(
self
,
f
=
None
,
size
=
(
600
,
600
),
build_dimensions
=
[
200
,
200
,
100
,
0
,
0
,
0
],
grid
=
(
10
,
50
),
extrusion_width
=
0.5
,
bgcolor
=
"#000000"
):
wx
.
Frame
.
__init__
(
self
,
None
,
title
=
_
(
"Gcode view, shift to move view, mousewheel to set layer"
),
size
=
size
)
wx
.
Frame
.
__init__
(
self
,
None
,
title
=
_
(
"Gcode view, shift to move view, mousewheel to set layer"
),
size
=
size
)
self
.
CreateStatusBar
(
1
);
self
.
CreateStatusBar
(
1
);
...
@@ -34,16 +34,17 @@ class GvizWindow(wx.Frame):
...
@@ -34,16 +34,17 @@ class GvizWindow(wx.Frame):
self
.
p
=
Gviz
(
panel
,
size
=
size
,
build_dimensions
=
build_dimensions
,
grid
=
grid
,
extrusion_width
=
extrusion_width
,
bgcolor
=
bgcolor
,
realparent
=
self
)
self
.
p
=
Gviz
(
panel
,
size
=
size
,
build_dimensions
=
build_dimensions
,
grid
=
grid
,
extrusion_width
=
extrusion_width
,
bgcolor
=
bgcolor
,
realparent
=
self
)
vbox
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
vbox
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
toolbar
=
wx
.
ToolBar
(
panel
,
-
1
,
style
=
wx
.
TB_HORIZONTAL
|
wx
.
NO_BORDER
)
toolbar
=
wx
.
ToolBar
(
panel
,
-
1
,
style
=
wx
.
TB_HORIZONTAL
|
wx
.
NO_BORDER
|
wx
.
TB_HORZ_TEXT
)
toolbar
.
AddSimpleTool
(
1
,
wx
.
Image
(
imagefile
(
'zoom_in.png'
),
wx
.
BITMAP_TYPE_PNG
)
.
ConvertToBitmap
(),
_
(
"Zoom In [+]"
),
''
)
toolbar
.
AddSimpleTool
(
1
,
wx
.
Image
(
imagefile
(
'zoom_in.png'
),
wx
.
BITMAP_TYPE_PNG
)
.
ConvertToBitmap
(),
_
(
"Zoom In [+]"
),
''
)
toolbar
.
AddSimpleTool
(
2
,
wx
.
Image
(
imagefile
(
'zoom_out.png'
),
wx
.
BITMAP_TYPE_PNG
)
.
ConvertToBitmap
(),
_
(
"Zoom Out [-]"
),
''
)
toolbar
.
AddSimpleTool
(
2
,
wx
.
Image
(
imagefile
(
'zoom_out.png'
),
wx
.
BITMAP_TYPE_PNG
)
.
ConvertToBitmap
(),
_
(
"Zoom Out [-]"
),
''
)
toolbar
.
AddSeparator
()
toolbar
.
AddSeparator
()
toolbar
.
AddSimpleTool
(
3
,
wx
.
Image
(
imagefile
(
'arrow_up.png'
),
wx
.
BITMAP_TYPE_PNG
)
.
ConvertToBitmap
(),
_
(
"Move Up a Layer [U]"
),
''
)
toolbar
.
AddSimpleTool
(
3
,
wx
.
Image
(
imagefile
(
'arrow_up.png'
),
wx
.
BITMAP_TYPE_PNG
)
.
ConvertToBitmap
(),
_
(
"Move Up a Layer [U]"
),
''
)
toolbar
.
AddSimpleTool
(
4
,
wx
.
Image
(
imagefile
(
'arrow_down.png'
),
wx
.
BITMAP_TYPE_PNG
)
.
ConvertToBitmap
(),
_
(
"Move Down a Layer [D]"
),
''
)
toolbar
.
AddSimpleTool
(
4
,
wx
.
Image
(
imagefile
(
'arrow_down.png'
),
wx
.
BITMAP_TYPE_PNG
)
.
ConvertToBitmap
(),
_
(
"Move Down a Layer [D]"
),
''
)
toolbar
.
Add
SimpleTool
(
5
,
wx
.
Image
(
imagefile
(
'reset.png'
),
wx
.
BITMAP_TYPE_PNG
)
.
ConvertToBitmap
(),
_
(
"Reset view"
),
''
)
toolbar
.
Add
LabelTool
(
5
,
" "
+
_
(
"Reset view"
),
wx
.
Image
(
imagefile
(
'reset.png'
),
wx
.
BITMAP_TYPE_PNG
)
.
ConvertToBitmap
(),
shortHelp
=
_
(
"Reset view"
),
longHelp
=
''
)
toolbar
.
AddSeparator
()
toolbar
.
AddSeparator
()
#toolbar.AddSimpleTool(6, wx.Image(imagefile('inject.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap(), _("Insert Code at start of this layer"), '')
#toolbar.AddSimpleTool(6, wx.Image(imagefile('inject.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap(), _("Insert Code at start of this layer"), '')
toolbar
.
Realize
()
toolbar
.
Realize
()
self
.
toolbar
=
toolbar
vbox
.
Add
(
toolbar
,
0
,
border
=
5
)
vbox
.
Add
(
toolbar
,
0
,
border
=
5
)
vbox
.
Add
(
self
.
p
,
1
,
wx
.
EXPAND
)
vbox
.
Add
(
self
.
p
,
1
,
wx
.
EXPAND
)
panel
.
SetSizer
(
vbox
)
panel
.
SetSizer
(
vbox
)
...
@@ -55,7 +56,7 @@ class GvizWindow(wx.Frame):
...
@@ -55,7 +56,7 @@ class GvizWindow(wx.Frame):
self
.
Bind
(
wx
.
EVT_TOOL
,
self
.
resetview
,
id
=
5
)
self
.
Bind
(
wx
.
EVT_TOOL
,
self
.
resetview
,
id
=
5
)
#self.Bind(wx.EVT_TOOL, lambda x:self.p.inject(), id = 6)
#self.Bind(wx.EVT_TOOL, lambda x:self.p.inject(), id = 6)
self
.
initpos
=
[
0
,
0
]
self
.
initpos
=
None
self
.
p
.
Bind
(
wx
.
EVT_KEY_DOWN
,
self
.
key
)
self
.
p
.
Bind
(
wx
.
EVT_KEY_DOWN
,
self
.
key
)
self
.
Bind
(
wx
.
EVT_KEY_DOWN
,
self
.
key
)
self
.
Bind
(
wx
.
EVT_KEY_DOWN
,
self
.
key
)
self
.
p
.
Bind
(
wx
.
EVT_MOUSEWHEEL
,
self
.
zoom
)
self
.
p
.
Bind
(
wx
.
EVT_MOUSEWHEEL
,
self
.
zoom
)
...
@@ -81,7 +82,7 @@ class GvizWindow(wx.Frame):
...
@@ -81,7 +82,7 @@ class GvizWindow(wx.Frame):
self
.
initpos
=
None
self
.
initpos
=
None
elif
event
.
Dragging
():
elif
event
.
Dragging
():
e
=
event
.
GetPositionTuple
()
e
=
event
.
GetPositionTuple
()
if
self
.
initpos
is
None
or
not
hasattr
(
self
,
"basetrans"
)
:
if
self
.
initpos
is
None
:
self
.
initpos
=
e
self
.
initpos
=
e
self
.
basetrans
=
self
.
p
.
translate
self
.
basetrans
=
self
.
p
.
translate
self
.
p
.
translate
=
[
self
.
basetrans
[
0
]
+
(
e
[
0
]
-
self
.
initpos
[
0
]),
self
.
p
.
translate
=
[
self
.
basetrans
[
0
]
+
(
e
[
0
]
-
self
.
initpos
[
0
]),
...
@@ -169,6 +170,7 @@ class Gviz(wx.Panel):
...
@@ -169,6 +170,7 @@ class Gviz(wx.Panel):
self
.
bgcolor
=
wx
.
Colour
()
self
.
bgcolor
=
wx
.
Colour
()
self
.
bgcolor
.
SetFromName
(
bgcolor
)
self
.
bgcolor
.
SetFromName
(
bgcolor
)
self
.
blitmap
=
wx
.
EmptyBitmap
(
self
.
GetClientSize
()[
0
],
self
.
GetClientSize
()[
1
],
-
1
)
self
.
blitmap
=
wx
.
EmptyBitmap
(
self
.
GetClientSize
()[
0
],
self
.
GetClientSize
()[
1
],
-
1
)
self
.
paint_overlay
=
None
def
inject
(
self
):
def
inject
(
self
):
#import pdb; pdb.set_trace()
#import pdb; pdb.set_trace()
...
@@ -338,6 +340,8 @@ class Gviz(wx.Panel):
...
@@ -338,6 +340,8 @@ class Gviz(wx.Panel):
dc
.
SetBackground
(
wx
.
Brush
(
self
.
bgcolor
))
dc
.
SetBackground
(
wx
.
Brush
(
self
.
bgcolor
))
dc
.
Clear
()
dc
.
Clear
()
dc
.
DrawBitmap
(
self
.
blitmap
,
self
.
translate
[
0
],
self
.
translate
[
1
])
dc
.
DrawBitmap
(
self
.
blitmap
,
self
.
translate
[
0
],
self
.
translate
[
1
])
if
self
.
paint_overlay
:
self
.
paint_overlay
(
dc
)
def
addfile
(
self
,
gcode
):
def
addfile
(
self
,
gcode
):
self
.
clear
()
self
.
clear
()
...
...
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