Commit 90afb988 authored by Guillaume Seguin's avatar Guillaume Seguin

Add settings to specify path width and height in new 3D viewer

Also change FloatSpinSetting to have an "increment" parameter and clean
some code. Also put 3D viewer options in their own tab
parent 20bff89b
......@@ -46,6 +46,21 @@ def set_model_colors(model, root):
if hasattr(root, root_fieldname):
setattr(model, field, getattr(root, root_fieldname))
def recreate_platform(self, build_dimensions, circular):
self.platform = actors.Platform(build_dimensions, circular = circular)
self.objects[0].model = self.platform
wx.CallAfter(self.Refresh)
def set_gcview_params(self, path_width, path_height):
self.path_halfwidth = path_width / 2
self.path_halfheight = path_height / 2
has_changed = False
for obj in self.objects[1:]:
if isinstance(obj.model, actors.GcodeModel):
obj.model.set_path_size(self.path_halfwidth, self.path_halfheight)
has_changed = True
return has_changed
class GcodeViewPanel(wxGLPanel):
def __init__(self, parent, id = wx.ID_ANY,
......@@ -262,9 +277,14 @@ class GCObject(object):
class GcodeViewLoader(object):
path_halfwidth = 0.2
path_halfheight = 0.15
def addfile_perlayer(self, gcode = None, showall = False):
self.model = create_model(self.root.settings.light3d
if self.root else False)
if isinstance(self.model, actors.GcodeModel):
self.model.set_path_size(self.path_halfwidth, self.path_halfheight)
self.objects[-1].model = self.model
if self.root:
set_model_colors(self.model, self.root)
......@@ -282,6 +302,9 @@ class GcodeViewLoader(object):
while generator.next() is not None:
continue
def set_gcview_params(self, path_width, path_height):
return set_gcview_params(self, path_width, path_height)
class GcodeViewMainWrapper(GcodeViewLoader):
def __init__(self, parent, build_dimensions, root, circular, antialias_samples):
......@@ -311,9 +334,7 @@ class GcodeViewMainWrapper(GcodeViewLoader):
self.refresh_timer.Start()
def recreate_platform(self, build_dimensions, circular):
self.platform = actors.Platform(build_dimensions, circular = circular)
self.objects[0].model = self.platform
wx.CallAfter(self.Refresh)
return recreate_platform(self, build_dimensions, circular)
def addgcodehighlight(self, *a):
pass
......@@ -385,9 +406,7 @@ class GcodeViewFrame(GvizBaseFrame, GcodeViewLoader):
self.refresh_timer.Start()
def recreate_platform(self, build_dimensions, circular):
self.platform = actors.Platform(build_dimensions, circular = circular)
self.objects[0].model = self.platform
wx.CallAfter(self.Refresh)
return recreate_platform(self, build_dimensions, circular)
def addfile(self, gcode = None):
if self.clonefrom:
......
......@@ -315,6 +315,11 @@ class GcodeModel(Model):
path_halfwidth = 0.2
path_halfheight = 0.2
def set_path_size(self, path_halfwidth, path_halfheight):
with self.lock:
self.path_halfwidth = path_halfwidth
self.path_halfheight = path_halfheight
def load_data(self, model_data, callback=None):
t_start = time.time()
......@@ -534,9 +539,9 @@ class GcodeModel(Model):
for var in ["vertices", "colors", "travels", "indices", "normals",
"max_layers", "num_layers_to_draw", "printed_until",
"layer_stops", "dims", "only_current",
"layer_idxs_map",
"count_travel_indices", "count_print_indices",
"count_print_vertices"]:
"layer_idxs_map", "count_travel_indices",
"count_print_indices", "count_print_vertices",
"path_halfwidth", "path_halfheight"]:
setattr(copy, var, getattr(self, var))
copy.loaded = True
copy.initialized = False
......
......@@ -123,6 +123,7 @@ class MacroEditor(wx.Dialog):
SETTINGS_GROUPS = {"Printer": _("Printer settings"),
"UI": _("User interface"),
"3D": _("3D Viewer"),
"Colors": _("Colors"),
"External": _("External commands")}
......
......@@ -177,10 +177,11 @@ class ComboSetting(wxSetting):
class SpinSetting(wxSetting):
def __init__(self, name, default, min, max, label = None, help = None, group = None):
def __init__(self, name, default, min, max, increment = 0.1, label = None, help = None, group = None):
super(SpinSetting, self).__init__(name, default, label, help, group)
self.min = min
self.max = max
self.increment = increment
def get_specific_widget(self, parent):
import wx
......@@ -192,7 +193,7 @@ class FloatSpinSetting(SpinSetting):
def get_specific_widget(self, parent):
from wx.lib.agw.floatspin import FloatSpin
self.widget = FloatSpin(parent, -1, value = self.value, min_val = self.min, max_val = self.max, digits = 2)
self.widget = FloatSpin(parent, -1, value = self.value, min_val = self.min, max_val = self.max, increment = self.increment, digits = 2)
return self.widget
class BooleanSetting(wxSetting):
......
......@@ -271,6 +271,10 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self.createGui(self.settings.uimode == "Compact",
self.settings.controlsmode == "Mini")
# Set gcview parameters here as they don't get set when viewers are
# created
self.update_gcview_params()
# Finalize
if self.online:
self.gui_set_connected()
......@@ -799,9 +803,11 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
self.settings._add(BooleanSetting("slic3rupdate", False, _("Update Slic3r default presets"), _("When selecting a profile in Slic3r integration menu, also save it as the default Slic3r preset"), "UI"))
self.settings._add(ComboSetting("mainviz", "2D", ["2D", "3D", "None"], _("Main visualization"), _("Select visualization for main window."), "UI"), self.reload_ui)
self.settings._add(BooleanSetting("viz3d", False, _("Use 3D in GCode viewer window"), _("Use 3D mode instead of 2D layered mode in the visualization window"), "UI"), self.reload_ui)
self.settings._add(BooleanSetting("light3d", True, _("Use a lighter 3D visualization"), _("Use a lighter visualization with simple lines instead of extruded paths for 3D viewer"), "UI"), self.reload_ui)
self.settings._add(ComboSetting("antialias3dsamples", "0", ["0", "2", "4", "8"], _("Number of anti-aliasing samples"), _("Amount of anti-aliasing samples used in the 3D viewer"), "UI"), self.reload_ui)
self.settings._add(BooleanSetting("trackcurrentlayer3d", False, _("Track current layer in main 3D view"), _("Track the currently printing layer in the main 3D visualization"), "UI"))
self.settings._add(BooleanSetting("light3d", True, _("Use a lighter 3D visualization"), _("Use a lighter visualization with simple lines instead of extruded paths for 3D viewer"), "3D"), self.reload_ui)
self.settings._add(ComboSetting("antialias3dsamples", "0", ["0", "2", "4", "8"], _("Number of anti-aliasing samples"), _("Amount of anti-aliasing samples used in the 3D viewer"), "3D"), self.reload_ui)
self.settings._add(BooleanSetting("trackcurrentlayer3d", False, _("Track current layer in main 3D view"), _("Track the currently printing layer in the main 3D visualization"), "3D"))
self.settings._add(FloatSpinSetting("gcview_path_width", 0.4, 0.01, 2, 0.05, _("Extrusion width for 3D viewer"), _("Width of printed path in 3D viewer"), "3D"), self.update_gcview_params)
self.settings._add(FloatSpinSetting("gcview_path_height", 0.3, 0.01, 2, 0.05, _("Layer height for 3D viewer"), _("Height of printed path in 3D viewer"), "3D"), self.update_gcview_params)
self.settings._add(BooleanSetting("tempgraph", True, _("Display temperature graph"), _("Display time-lapse temperature graph"), "UI"), self.reload_ui)
self.settings._add(BooleanSetting("tempgauges", False, _("Display temperature gauges"), _("Display graphical gauges for temperatures visualization"), "UI"), self.reload_ui)
self.settings._add(BooleanSetting("lockbox", False, _("Display interface lock checkbox"), _("Display a checkbox that, when check, locks most of Pronterface"), "UI"), self.reload_ui)
......@@ -812,7 +818,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
self.settings._add(HiddenSetting("last_bed_temperature", 0.0))
self.settings._add(HiddenSetting("last_file_path", u""))
self.settings._add(HiddenSetting("last_temperature", 0.0))
self.settings._add(FloatSpinSetting("preview_extrusion_width", 0.5, 0, 10, _("Preview extrusion width"), _("Width of Extrusion in Preview"), "UI"), self.update_gviz_params)
self.settings._add(FloatSpinSetting("preview_extrusion_width", 0.5, 0, 10, 0.1, _("Preview extrusion width"), _("Width of Extrusion in Preview"), "UI"), self.update_gviz_params)
self.settings._add(SpinSetting("preview_grid_step1", 10., 0, 200, _("Fine grid spacing"), _("Fine Grid Spacing"), "UI"), self.update_gviz_params)
self.settings._add(SpinSetting("preview_grid_step2", 50., 0, 200, _("Coarse grid spacing"), _("Coarse Grid Spacing"), "UI"), self.update_gviz_params)
self.settings._add(StringSetting("bgcolor", "#FFFFFF", _("Background color"), _("Pronterface background color"), "Colors"), self.reload_ui, validate = check_rgb_color)
......@@ -906,6 +912,15 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
if hasattr(self, "gwindow") and hasattr(self.gwindow, "recreate_platform"):
self.gwindow.recreate_platform(self.build_dimensions_list, self.settings.circular_bed)
def update_gcview_params(self, *args):
need_reload = False
if hasattr(self, "gviz") and hasattr(self.gviz, "set_gcview_params"):
need_reload |= self.gviz.set_gcview_params(self.settings.gcview_path_width, self.settings.gcview_path_height)
if hasattr(self, "gwindow") and hasattr(self.gwindow, "set_gcview_params"):
need_reload |= self.gwindow.set_gcview_params(self.settings.gcview_path_width, self.settings.gcview_path_height)
if need_reload:
self.start_viz_thread()
def update_monitor(self, *args):
if hasattr(self, "display_graph") and self.display_graph:
if self.settings.monitor:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment