Commit 723af3c1 authored by sumpfralle's avatar sumpfralle

migrated remaining GCode settings

fixed GCode settings visualization


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@1194 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent b840cc29
......@@ -4,6 +4,7 @@
<!-- interface-naming-policy project-wide -->
<object class="GtkDialog" id="GCodePreferencesWindow">
<property name="border_width">5</property>
<property name="title" translatable="yes">GCode preferences</property>
<property name="type_hint">normal</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox1">
......
This diff is collapsed.
This diff is collapsed.
......@@ -58,11 +58,12 @@ class InputBaseClass(object):
control = self.get_widget()
if not hasattr(self, "_handler_ids"):
self._handler_ids = []
self._handler_ids.append(control.connect(signal, handler))
self._handler_ids.append((control, control.connect(signal, handler)))
def destroy(self):
while hasattr(self, "_handler_ids") and self._handler_ids:
self.get_widget().disconnect(self._handler_ids.pop())
control, handler_id = self._handler_ids.pop()
control.disconnect(handler_id)
self.get_widget().destroy()
def get_widget(self):
......@@ -268,10 +269,10 @@ class ParameterSection(object):
self._table.remove(child)
# add the current controls
for index, widget in enumerate(widgets):
if hasattr(widget, "get_label"):
if hasattr(widget[0], "get_label"):
# checkbox
widget.set_label(widget[1])
self._table.attach(widget, 0, 2, index, index + 1,
widget[0].set_label(widget[1])
self._table.attach(widget[0], 0, 2, index, index + 1,
xoptions=gtk.FILL, yoptions=gtk.FILL)
elif not widget[1]:
self._table.attach(widget[0], 0, 2, index, index + 1,
......
......@@ -525,64 +525,6 @@ class ProjectGui(object):
main_tab.set_sensitive(True)
self.settings.register_event("gui-disable", disable_gui)
self.settings.register_event("gui-enable", enable_gui)
# gcode settings
for objname, setting in (
("GCodeTouchOffOnStartup", "touch_off_on_startup"),
("GCodeTouchOffOnToolChange", "touch_off_on_tool_change")):
obj = self.gui.get_object(objname)
obj.connect("toggled", self.update_gcode_controls)
self.settings.add_item(setting, obj.get_active, obj.set_active)
touch_off_pos_selector = self.gui.get_object("TouchOffLocationSelector")
def get_touch_off_position_type():
index = touch_off_pos_selector.get_active()
if index < 0:
return PREFERENCES_DEFAULTS["touch_off_position_type"]
else:
return touch_off_pos_selector.get_model()[index][0]
def set_touch_off_position_type(new_key):
model = touch_off_pos_selector.get_model()
for index, (key, value) in enumerate(model):
if key == new_key:
touch_off_pos_selector.set_active(index)
break
else:
touch_off_pos_selector.set_active(-1)
touch_off_pos_selector.connect("changed", self.update_gcode_controls)
self.settings.add_item("touch_off_position_type",
get_touch_off_position_type, set_touch_off_position_type)
for axis in "XYZ":
obj = self.gui.get_object("ToolChangePos%s" % axis.upper())
self.settings.add_item("touch_off_position_%s" % axis.lower(),
obj.get_value, obj.set_value)
for objname, setting in (
("ToolChangeRapidMoveDown", "touch_off_rapid_move"),
("ToolChangeSlowMoveDown", "touch_off_slow_move"),
("ToolChangeSlowMoveSpeed", "touch_off_slow_feedrate"),
("TouchOffHeight", "touch_off_height")):
obj = self.gui.get_object(objname)
self.settings.add_item(setting, obj.get_value, obj.set_value)
touch_off_pause = self.gui.get_object("TouchOffPauseExecution")
self.settings.add_item("touch_off_pause_execution",
touch_off_pause.get_active, touch_off_pause.set_active)
gcode_path_mode = self.gui.get_object("GCodeCornerStyleControl")
self.settings.add_item("gcode_path_mode", gcode_path_mode.get_active,
gcode_path_mode.set_active)
gcode_path_mode.connect("changed", self.update_gcode_controls)
gcode_motion_tolerance = self.gui.get_object(
"GCodeCornerStyleMotionTolerance")
self.settings.add_item("gcode_motion_tolerance",
gcode_motion_tolerance.get_value,
gcode_motion_tolerance.set_value)
gcode_naive_tolerance = self.gui.get_object(
"GCodeCornerStyleCAMTolerance")
self.settings.add_item("gcode_naive_tolerance",
gcode_naive_tolerance.get_value,
gcode_naive_tolerance.set_value)
gcode_start_stop_spindle = self.gui.get_object("GCodeStartStopSpindle")
self.settings.add_item("gcode_start_stop_spindle",
gcode_start_stop_spindle.get_active,
gcode_start_stop_spindle.set_active)
gcode_start_stop_spindle.connect("toggled", self.update_gcode_controls)
# configure locations of external programs
for auto_control_name, location_control_name, browse_button, key in (
("ExternalProgramInkscapeAuto",
......@@ -702,46 +644,8 @@ class ProjectGui(object):
self.window.show()
def update_all_controls(self):
self.update_gcode_controls()
self.update_ode_settings()
def update_gcode_controls(self, widget=None):
# path mode
path_mode = self.settings.get("gcode_path_mode")
self.gui.get_object("GCodeToleranceTable").set_sensitive(path_mode == 3)
# spindle delay
sensitive = self.settings.get("gcode_start_stop_spindle")
self.gui.get_object("GCodeSpindleDelayLabel").set_sensitive(sensitive)
self.gui.get_object("GCodeSpindleDelay").set_sensitive(sensitive)
# tool change controls
pos_control = self.gui.get_object("TouchOffLocationSelector")
tool_change_pos_model = pos_control.get_model()
active_pos_index = pos_control.get_active()
if active_pos_index < 0:
pos_key = None
else:
pos_key = tool_change_pos_model[active_pos_index][0]
# show or hide the vbox containing the absolute tool change location
absolute_pos_box = self.gui.get_object("AbsoluteToolChangePositionBox")
if pos_key == "absolute":
absolute_pos_box.show()
else:
absolute_pos_box.hide()
# disable/enable the touch off position controls
position_controls_table = self.gui.get_object("TouchOffLocationTable")
touch_off_enabled = any([self.gui.get_object(objname).get_active()
for objname in ("GCodeTouchOffOnStartup",
"GCodeTouchOffOnToolChange")])
position_controls_table.set_sensitive(touch_off_enabled)
# disable/enable touch probe height
if self.gui.get_object("GCodeTouchOffOnStartup").get_active():
update_func = "show"
else:
update_func = "hide"
for objname in ("TouchOffHeight", "TouchOffHeightLabel",
"LengthUnitTouchOffHeight"):
getattr(self.gui.get_object(objname), update_func)()
def update_ode_settings(self, widget=None):
if pycam.Utils.threading.is_multiprocessing_enabled() \
or not pycam.Physics.ode_physics.is_ode_available():
......
......@@ -35,25 +35,35 @@ class GCodePreferences(pycam.Plugins.PluginBase):
if self.gui:
import gtk
notebook = self.gui.get_object("GCodePrefsNotebook")
self._pref_items = []
def clear_preferences():
for child in notebook.get_children():
notebook.remove(child)
# we need to clear the whole path down to the "real" item
parent = notebook
while not child in self._pref_items:
parent.remove(child)
parent = child
child = child.get_children()[0]
parent.remove(child)
def add_preferences_item(item, name):
if not item in self._pref_items:
self._pref_items.append(item)
item.unparent()
if not isinstance(item, gtk.Frame):
# create a simple default frame if none was given
frame = gtk.Frame(name)
frame.get_label_widget().set_markup("<b>%s</b>" % name)
frame.set_shadow_type(gtk.SHADOW_NONE)
align = gtk.Alignment()
align.set_padding(5, 0, 12, 0)
align.set_padding(3, 0, 12, 0)
frame.add(align)
frame.show()
item.unparent()
align.add(item)
align.show()
item.show()
item = frame
notebook.append_page(item, gtk.Label(name))
notebook.show_all()
self.core.register_ui_section("gcode_preferences",
add_preferences_item, clear_preferences)
general_widget = pycam.Gui.ControlsGTK.ParameterSection()
......@@ -95,10 +105,10 @@ class GCodeSafetyHeight(pycam.Plugins.PluginBase):
self.safety_height = pycam.Gui.ControlsGTK.InputNumber(digits=0,
change_handler=lambda *args: \
self.core.emit_event("visual-item-updated"))
self.core.register_ui("gcode_general_parameters", "Safety Height",
self.safety_height.get_widget(), weight=20)
# TODO: this should be done via parameter groups based on postprocessors
self.safety_height.get_widget().show()
self.core.register_ui("gcode_general_parameters", "Safety Height",
self.safety_height.get_widget(), weight=20)
self.core.add_item("gcode_safety_height",
self.safety_height.get_value, self.safety_height.set_value)
return True
......@@ -117,11 +127,11 @@ class GCodeFilenameExtension(pycam.Plugins.PluginBase):
def setup(self):
self.filename_extension = pycam.Gui.ControlsGTK.InputString(
max_length=6)
# TODO: this should be done via parameter groups based on postprocessors
self.filename_extension.get_widget().show()
self.core.register_ui("gcode_general_parameters",
"Custom GCode filename extension",
self.filename_extension.get_widget(), weight=80)
# TODO: this should be done via parameter groups based on postprocessors
self.filename_extension.get_widget().show()
self.core.add_item("gcode_filename_extension",
self.filename_extension.get_value,
self.filename_extension.set_value)
......@@ -147,12 +157,12 @@ class GCodeStepWidth(pycam.Plugins.PluginBase):
for key in "xyz":
control = pycam.Gui.ControlsGTK.InputNumber(digits=8, start=0.0001,
increment=0.00005)
# TODO: this should be done via parameter groups based on postprocessors
control.get_widget().show()
self.core.add_item("gcode_minimum_step_%s" % key,
control.get_value, control.set_value)
self.core.register_ui("gcode_step_width", key.upper(),
control.get_widget(), weight="xyz".index(key))
# TODO: this should be done via parameter groups based on postprocessors
control.get_widget().show()
return True
......@@ -168,12 +178,62 @@ class GCodeSpindle(pycam.Plugins.PluginBase):
self.core.register_ui_section("gcode_spindle",
table.add_widget, table.clear_widgets)
self.spindle_delay = pycam.Gui.ControlsGTK.InputNumber(digits=1)
self.core.register_ui("gcode_spindle",
"Delay (in seconds) after start/stop",
self.spindle_delay.get_widget(), weight=20)
# TODO: this should be done via parameter groups based on postprocessors
self.spindle_delay.get_widget().show()
self.core.register_ui("gcode_spindle",
"Delay (in seconds) after start/stop",
self.spindle_delay.get_widget(), weight=50)
self.core.add_item("gcode_spindle_delay",
self.spindle_delay.get_value,
self.spindle_delay.set_value)
self.spindle_enable = pycam.Gui.ControlsGTK.InputCheckBox(
change_handler=self.update_widgets)
self.spindle_enable.get_widget().show()
self.core.register_ui("gcode_spindle", "Start / Stop Spindle (M3/M5)",
self.spindle_enable.get_widget(), weight=10)
self.update_widgets()
return True
def update_widgets(self, widget=None):
widget = self.spindle_delay.get_widget()
widget.set_sensitive(self.spindle_enable.get_value())
class GCodeCornerStyle(pycam.Plugins.PluginBase):
DEPENDS = ["GCodePreferences"]
CATEGORIES = ["GCode"]
def setup(self):
table = pycam.Gui.ControlsGTK.ParameterSection()
self.core.register_ui("gcode_preferences", "Corner style",
table.widget)
self.core.register_ui_section("gcode_corner_style",
table.add_widget, table.clear_widgets)
self.motion_tolerance = pycam.Gui.ControlsGTK.InputNumber(digits=3)
# TODO: this should be done via parameter groups based on postprocessors
self.motion_tolerance.get_widget().show()
self.core.register_ui("gcode_corner_style", "Motion blending tolerance",
self.motion_tolerance.get_widget(), weight=30)
self.naive_tolerance = pycam.Gui.ControlsGTK.InputNumber(digits=3)
self.naive_tolerance.get_widget().show()
self.core.register_ui("gcode_corner_style", "Naive CAM tolerance",
self.naive_tolerance.get_widget(), weight=50)
self.path_mode = pycam.Gui.ControlsGTK.InputChoice((
("Exact path mode (G61)", "exact_path"),
("Exact stop mode (G61.1)", "exact_stop"),
("Continuous with maximum speed (G64)", "optimize_speed"),
("Continuous with tolerance (G64 P/Q)", "optimize_tolerance")))
self.path_mode.get_widget().connect("changed", self.update_widgets)
self.core.register_ui("gcode_corner_style", "Path mode",
self.path_mode.get_widget(), weight=10)
table.widget.show_all()
self.update_widgets()
return True
def update_widgets(self, widget=None):
enable_tolerances = (self.path_mode.get_value() == "optimize_speed")
controls = (self.motion_tolerance, self.naive_tolerance)
for control in controls:
control.get_widget().set_sensitive(enable_tolerances)
# -*- coding: utf-8 -*-
"""
$Id$
Copyright 2011 Lars Kruse <devel@sumpfralle.de>
This file is part of PyCAM.
PyCAM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
PyCAM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
"""
import pycam.Plugins
class GCodeTouchOff(pycam.Plugins.PluginBase):
DEPENDS = ["GCodePreferences"]
CATEGORIES = ["GCode"]
UI_FILE = "gcode_touch_off.ui"
def setup(self):
if self.gui:
box = self.gui.get_object("TouchOffBox")
box.unparent()
self.core.register_ui("gcode_preferences", "Touch Off",
box, weight=70)
for objname, setting in (
("GCodeTouchOffOnStartup", "touch_off_on_startup"),
("GCodeTouchOffOnToolChange", "touch_off_on_tool_change")):
self.gui.get_object(objname).connect("toggled",
self.update_widgets)
self.gui.get_object("TouchOffLocationSelector").connect("changed",
self.update_widgets)
self.gui.get_object("TouchOffLocationSelector").set_active(0)
self.update_widgets()
return True
def update_widgets(self, widget=None):
# tool change controls
pos_control = self.gui.get_object("TouchOffLocationSelector")
tool_change_pos_model = pos_control.get_model()
active_pos_index = pos_control.get_active()
if active_pos_index < 0:
pos_key = None
else:
pos_key = tool_change_pos_model[active_pos_index][0]
# disable/enable the touch off position controls
position_controls_table = self.gui.get_object("TouchOffLocationTable")
touch_off_enabled = any([self.gui.get_object(objname).get_active()
for objname in ("GCodeTouchOffOnStartup",
"GCodeTouchOffOnToolChange")])
position_controls_table.set_sensitive(touch_off_enabled)
# show or hide the vbox containing the absolute tool change location
absolute_pos_box = self.gui.get_object("AbsoluteToolChangePositionBox")
if (pos_key == "absolute") and touch_off_enabled:
absolute_pos_box.show()
else:
absolute_pos_box.hide()
# disable/enable touch probe height
if self.gui.get_object("GCodeTouchOffOnStartup").get_active():
update_func = "show"
else:
update_func = "hide"
for objname in ("TouchOffHeight", "TouchOffHeightLabel",
"LengthUnitTouchOffHeight"):
getattr(self.gui.get_object(objname), update_func)()
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