Commit e11c6dc3 authored by sumpfralle's avatar sumpfralle

implement storage of support grid adjustments


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@545 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 461bcc6d
...@@ -566,6 +566,8 @@ class ToolpathSettings: ...@@ -566,6 +566,8 @@ class ToolpathSettings:
"height": float, "height": float,
"offset_x": float, "offset_x": float,
"offset_y": float, "offset_y": float,
"adjustments_x": "list_of_float",
"adjustments_y": "list_of_float",
}, },
"Program": { "Program": {
"unit": str, "unit": str,
...@@ -641,8 +643,10 @@ class ToolpathSettings: ...@@ -641,8 +643,10 @@ class ToolpathSettings:
if self.support_grid: if self.support_grid:
return self.support_grid return self.support_grid
else: else:
return {"distance_x": None, "distance_y": None, "thickness": None, result = {}
"height": None, "offset_x": None, "offset_y": None} for key in self.SECTIONS["SupportGrid"].keys():
result[key] = None
return result
def set_calculation_backend(self, backend=None): def set_calculation_backend(self, backend=None):
self.program["enable_ode"] = (backend.upper() == "ODE") self.program["enable_ode"] = (backend.upper() == "ODE")
...@@ -696,12 +700,26 @@ class ToolpathSettings: ...@@ -696,12 +700,26 @@ class ToolpathSettings:
continue continue
elif value_type == bool: elif value_type == bool:
value = value_raw.lower() in ("1", "true", "yes", "on") value = value_raw.lower() in ("1", "true", "yes", "on")
elif isinstance(value_type, basestring) \
and (value_type.startswith("list_of_")):
item_type = value_type[len("list_of_"):]
if item_type == "float":
item_type = float
else:
continue
try:
value = [item_type(one_val)
for one_val in value_raw.split(",")]
except ValueError:
log.warn("Settings: Ignored invalid setting due to " \
+ "a failed list type parsing: " \
+ "(%s -> %s): %s" % (section, key, value_raw))
else: else:
try: try:
value = value_type(value_raw) value = value_type(value_raw)
except ValueError: except ValueError:
log.warn("Settings: Ignored invalid setting " \ log.warn("Settings: Ignored invalid setting " \
"(%s -> %s): %s" % (section, key, value_raw)) + "(%s -> %s): %s" % (section, key, value_raw))
config_dict[key] = value config_dict[key] = value
def get_string(self): def get_string(self):
...@@ -717,7 +735,11 @@ class ToolpathSettings: ...@@ -717,7 +735,11 @@ class ToolpathSettings:
for key, value_type in self.SECTIONS[section].items(): for key, value_type in self.SECTIONS[section].items():
if config_dict.has_key(key): if config_dict.has_key(key):
value = config_dict[key] value = config_dict[key]
if type(value) == value_type: if isinstance(value_type, basestring) \
and (value_type.startswith("list_of_")):
result.append("%s = %s" % (key,
",".join([str(val) for val in value])))
elif type(value) == value_type:
result.append("%s = %s" % (key, value)) result.append("%s = %s" % (key, value))
# add one empty line after each section # add one empty line after each section
result.append("") result.append("")
......
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