Commit 9f494566 authored by sumpfralle's avatar sumpfralle

fixed teardown

fixed selection tracking during rebuild of strategy model
implemented basic toolpath generation


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@1148 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 2f528dff
...@@ -80,9 +80,7 @@ class Tasks(pycam.Plugins.ListPluginBase): ...@@ -80,9 +80,7 @@ class Tasks(pycam.Plugins.ListPluginBase):
"register_parameter_section")("task", "components") "register_parameter_section")("task", "components")
self.core.register_ui("task_parameters", "Components", self.core.register_ui("task_parameters", "Components",
components_parameter_widget, weight=10) components_parameter_widget, weight=10)
# handle table events # table
self.core.register_event("task-selection-changed",
self._task_switch)
self.gui.get_object("TaskNameCell").connect("edited", self.gui.get_object("TaskNameCell").connect("edited",
self._edit_task_name) self._edit_task_name)
selection = self._taskview.get_selection() selection = self._taskview.get_selection()
...@@ -130,22 +128,28 @@ class Tasks(pycam.Plugins.ListPluginBase): ...@@ -130,22 +128,28 @@ class Tasks(pycam.Plugins.ListPluginBase):
def teardown(self): def teardown(self):
if self.gui: if self.gui:
self.core.unregister_ui("main", self.gui.get_object("TaskBox")) self.core.unregister_ui("main", self.gui.get_object("TaskBox"))
self.core.unregister_event("task-selection-changed", self.core.unregister_event("task-type-list-changed",
self._task_switch) self._update_widgets)
self.core.unregister_event("task-selection-changed", self.core.unregister_event("task-selection-changed",
self._task_switch) self._task_switch)
self.core.unregister_event("task-changed", self._store_task) self.core.unregister_event("task-changed", self._store_task)
self.core.unregister_event("task-type-changed", self._store_task)
self.core.unregister_ui("task_parameters", models_parameter_widget,
weight=20)
self.core.unregister_ui("task_parameters",
components_parameter_widget, weight=10)
def get_selected(self, index=False): def get_selected(self, index=False):
return self._get_selected(self._taskview, index=index) return self._get_selected(self._taskview, index=index)
def select(self, tasks): def select(self, tasks):
print "Tasks: %s" % str(tasks)
selection = self._taskview.get_selection() selection = self._taskview.get_selection()
model = self._taskview.get_model()
if not isinstance(tasks, (list, tuple)): if not isinstance(tasks, (list, tuple)):
tasks = [tasks] tasks = [tasks]
for index, task in enumerate(self): tasks_ref = [id(task) for task in tasks]
if task in tasks: for index, row in enumerate(model):
if row[self.COLUMN_REF] in tasks_ref:
selection.select_path((index,)) selection.select_path((index,))
else: else:
selection.unselect_path((index,)) selection.unselect_path((index,))
...@@ -183,6 +187,7 @@ class Tasks(pycam.Plugins.ListPluginBase): ...@@ -183,6 +187,7 @@ class Tasks(pycam.Plugins.ListPluginBase):
selector.set_active(-1) selector.set_active(-1)
def _update_widgets(self): def _update_widgets(self):
selected = self._get_type()
model = self.gui.get_object("TaskTypeList") model = self.gui.get_object("TaskTypeList")
model.clear() model.clear()
types = self.core.get("get_parameter_sets")("task").values() types = self.core.get("get_parameter_sets")("task").values()
...@@ -193,7 +198,7 @@ class Tasks(pycam.Plugins.ListPluginBase): ...@@ -193,7 +198,7 @@ class Tasks(pycam.Plugins.ListPluginBase):
removal = [] removal = []
type_names = [one_type["name"] for one_type in types] type_names = [one_type["name"] for one_type in types]
for index, task in enumerate(self): for index, task in enumerate(self):
if not task["type"] in tape_names: if not task["type"] in type_names:
removal.append(index) removal.append(index)
removal.reverse() removal.reverse()
for index in removal: for index in removal:
...@@ -205,6 +210,8 @@ class Tasks(pycam.Plugins.ListPluginBase): ...@@ -205,6 +210,8 @@ class Tasks(pycam.Plugins.ListPluginBase):
selector_box.hide() selector_box.hide()
else: else:
selector_box.show() selector_box.show()
if selected:
self.select_type(selected["name"])
def _task_switch(self): def _task_switch(self):
tasks = self.get_selected() tasks = self.get_selected()
...@@ -266,6 +273,10 @@ class Tasks(pycam.Plugins.ListPluginBase): ...@@ -266,6 +273,10 @@ class Tasks(pycam.Plugins.ListPluginBase):
self.generate_toolpaths(self) self.generate_toolpaths(self)
def generate_toolpath(self, task, progress=None): def generate_toolpath(self, task, progress=None):
func = self.core.get("get_parameter_sets")("task")[task["type"]]["func"]
toolpath = func(task)
return toolpath
# TODO: remove this obsolete code as soon as toolpath generation works
models = task["models"] models = task["models"]
tool = task["tool"] tool = task["tool"]
process = task["process"] process = task["process"]
......
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