Commit 805f4be5 authored by sumpfralle's avatar sumpfralle

fixed various plugin dependencies and teardown methods

added plugin filters for easier browsing


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@1161 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 0544c30d
...@@ -36,6 +36,51 @@ ...@@ -36,6 +36,51 @@
</row> </row>
</data> </data>
</object> </object>
<object class="GtkListStore" id="StatusList">
<columns>
<!-- column-name label -->
<column type="gchararray"/>
<!-- column-name name -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">All</col>
<col id="1" translatable="yes">all</col>
</row>
<row>
<col id="0" translatable="yes">Enabled</col>
<col id="1" translatable="yes">enabled</col>
</row>
<row>
<col id="0" translatable="yes">Disabled</col>
<col id="1" translatable="yes">disabled</col>
</row>
<row>
<col id="0" translatable="yes">Dependencies missing</col>
<col id="1" translatable="yes">dep_missing</col>
</row>
<row>
<col id="0" translatable="yes">Dependencies satisfied</col>
<col id="1" translatable="yes">dep_satisfied</col>
</row>
<row>
<col id="0" translatable="yes">Not required</col>
<col id="1" translatable="yes">not_required</col>
</row>
</data>
</object>
<object class="GtkListStore" id="CategoryList">
<columns>
<!-- column-name label -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">Model</col>
</row>
</data>
</object>
<object class="GtkDialog" id="PluginManagerWindow"> <object class="GtkDialog" id="PluginManagerWindow">
<property name="width_request">640</property> <property name="width_request">640</property>
<property name="height_request">500</property> <property name="height_request">500</property>
...@@ -48,7 +93,51 @@ ...@@ -48,7 +93,51 @@
<object class="GtkVBox" id="dialog-vbox1"> <object class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="spacing">2</property> <property name="spacing">3</property>
<child>
<object class="GtkHButtonBox" id="hbuttonbox1">
<property name="visible">True</property>
<property name="layout_style">spread</property>
<child>
<object class="GtkComboBox" id="StatusFilter">
<property name="visible">True</property>
<property name="model">StatusList</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="CategoryFilter">
<property name="visible">True</property>
<property name="model">CategoryList</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext2"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child> <child>
<object class="GtkScrolledWindow" id="scrolledwindow1"> <object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property> <property name="visible">True</property>
...@@ -125,7 +214,7 @@ ...@@ -125,7 +214,7 @@
</child> </child>
</object> </object>
<packing> <packing>
<property name="position">1</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
<child internal-child="action_area"> <child internal-child="action_area">
......
...@@ -303,7 +303,7 @@ class EventCore(pycam.Gui.Settings.Settings): ...@@ -303,7 +303,7 @@ class EventCore(pycam.Gui.Settings.Settings):
def unregister_chain(self, name, func): def unregister_chain(self, name, func):
if name in self.chains: if name in self.chains:
for index, data in self.chains[name]: for index, data in enumerate(self.chains[name]):
if data[CHAIN_FUNC_INDEX] == func: if data[CHAIN_FUNC_INDEX] == func:
self.chains[name].pop(index) self.chains[name].pop(index)
break break
......
...@@ -155,6 +155,14 @@ class Bounds(pycam.Plugins.ListPluginBase): ...@@ -155,6 +155,14 @@ class Bounds(pycam.Plugins.ListPluginBase):
def teardown(self): def teardown(self):
if self.gui: if self.gui:
self.core.unregister_ui("main", self.gui.get_object("BoundsBox")) self.core.unregister_ui("main", self.gui.get_object("BoundsBox"))
self.core.unregister_event("bounds-selection-changed",
self._switch_bounds)
self.core.unregister_event("bounds-changed",
self._store_bounds_settings)
self.core.unregister_event("bounds-changed",
self._trigger_table_update)
self.core.unregister_event("model-list-changed",
self._update_model_list)
self.core.set("bounds", None) self.core.set("bounds", None)
return True return True
......
...@@ -222,6 +222,8 @@ class OpenGLWindow(pycam.Plugins.PluginBase): ...@@ -222,6 +222,8 @@ class OpenGLWindow(pycam.Plugins.PluginBase):
self.core.unregister_event("visual-item-updated", self.update_view) self.core.unregister_event("visual-item-updated", self.update_view)
self.core.unregister_event("visualization-state-changed", self.core.unregister_event("visualization-state-changed",
self._update_widgets) self._update_widgets)
self.core.unregister_event("model-list-changed",
self._restore_latest_view)
# the area will be created during setup again # the area will be created during setup again
self.container.remove(self.area) self.container.remove(self.area)
self.area = None self.area = None
......
...@@ -182,4 +182,5 @@ class PathParamTraceModel(pycam.Plugins.PluginBase): ...@@ -182,4 +182,5 @@ class PathParamTraceModel(pycam.Plugins.PluginBase):
def teardown(self): def teardown(self):
self.core.get("unregister_parameter")("process", "pathgenerator", self.core.get("unregister_parameter")("process", "pathgenerator",
"trace_models") "trace_models")
self.core.unregister_event("model-list-changed", self._update_models)
...@@ -53,6 +53,13 @@ class PluginSelector(pycam.Plugins.PluginBase): ...@@ -53,6 +53,13 @@ class PluginSelector(pycam.Plugins.PluginBase):
self.register_gtk_accelerator("plugins", action, None, self.register_gtk_accelerator("plugins", action, None,
"TogglePluginWindow") "TogglePluginWindow")
self.core.register_ui("view_menu", "TogglePluginWindow", action, 60) self.core.register_ui("view_menu", "TogglePluginWindow", action, 60)
# model filters
model_filter = self.gui.get_object("PluginsModel").filter_new()
for obj_name in ("StatusFilter", "CategoryFilter"):
self.gui.get_object(obj_name).connect("changed",
lambda widget: model_filter.refilter())
self.gui.get_object("PluginsTable").set_model(model_filter)
model_filter.set_visible_func(self._filter_set_visible)
self.gui.get_object("PluginsEnabledCell").connect("toggled", self.gui.get_object("PluginsEnabledCell").connect("toggled",
self.toggle_plugin_state) self.toggle_plugin_state)
self.core.register_event("plugin-list-changed", self.core.register_event("plugin-list-changed",
...@@ -86,13 +93,53 @@ class PluginSelector(pycam.Plugins.PluginBase): ...@@ -86,13 +93,53 @@ class PluginSelector(pycam.Plugins.PluginBase):
# don't destroy the window with a "destroy" event # don't destroy the window with a "destroy" event
return True return True
def _filter_set_visible(self, model, m_iter):
manager = self.core.get("plugin-manager")
status_filter = self.gui.get_object("StatusFilter")
status_index = status_filter.get_active()
if status_index > 0:
status_name = status_filter.get_model()[status_index][1]
cat_filter = self.gui.get_object("CategoryFilter")
cat_index = cat_filter.get_active()
if cat_index > 0:
cat_name = cat_filter.get_model()[cat_index][0]
plugin_name = model.get_value(m_iter, 0)
if not plugin_name:
return False
plugin = manager.get_plugin(plugin_name)
if (cat_index > 0) and (not cat_name in plugin.CATEGORIES):
return False
elif (status_index > 0):
if (status_name == "enabled") and \
not manager.get_plugin_state(plugin_name):
return False
elif (status_name == "disabled") and \
manager.get_plugin_state(plugin_name):
return False
elif (status_name == "dep_missing") and \
not manager.get_plugin_missing_dependencies(plugin_name):
return False
elif (status_name == "dep_satisfied") and \
(manager.get_plugin_state(plugin_name) or \
manager.get_plugin_missing_dependencies(plugin_name)):
return False
elif (status_name == "not_required") and \
(not manager.get_plugin_state(plugin_name) or \
manager.is_plugin_required(plugin_name) or \
(plugin_name == "PluginSelector")):
return False
return True
def _update_plugin_model(self): def _update_plugin_model(self):
manager = self.core.get("plugin-manager") manager = self.core.get("plugin-manager")
names = manager.get_plugin_names() names = manager.get_plugin_names()
model = self._treemodel model = self._treemodel
model.clear() model.clear()
categories = {}
for name in names: for name in names:
plugin = manager.get_plugin(name) plugin = manager.get_plugin(name)
for cat_name in plugin.CATEGORIES:
categories[cat_name] = True
enabled = manager.get_plugin_state(name) enabled = manager.get_plugin_state(name)
depends_missing = manager.get_plugin_missing_dependencies(name) depends_missing = manager.get_plugin_missing_dependencies(name)
is_required = manager.is_plugin_required(name) is_required = manager.is_plugin_required(name)
...@@ -112,9 +159,34 @@ class PluginSelector(pycam.Plugins.PluginBase): ...@@ -112,9 +159,34 @@ class PluginSelector(pycam.Plugins.PluginBase):
"Hint")) "Hint"))
self.gui.get_object("PluginsDescriptionColumn").queue_resize() self.gui.get_object("PluginsDescriptionColumn").queue_resize()
self.gui.get_object("PluginsTable").queue_resize() self.gui.get_object("PluginsTable").queue_resize()
# update the category filter
categories = categories.keys()
categories.sort()
categories.insert(0, "All categories")
model = self.gui.get_object("CategoryList")
cat_index = self.gui.get_object("CategoryFilter").get_active()
if cat_index >= 0:
cat_selection = model[cat_index][0]
else:
cat_selection = None
model.clear()
for cat_name in categories:
model.append((cat_name, ))
if cat_selection in categories:
cat_index = categories.index(cat_selection)
else:
cat_index = 0
self.gui.get_object("CategoryFilter").set_active(cat_index)
# status selection
status_selector = self.gui.get_object("StatusFilter")
if status_selector.get_active() < 0:
status_selector.set_active(0)
# trigger an update of the filter model
self.gui.get_object("PluginsTable").get_model().refilter()
def toggle_plugin_state(self, cell, path): def toggle_plugin_state(self, cell, path):
plugin_name = self._treemodel[int(path)][self.COLUMN_NAME] filter_model = self.gui.get_object("PluginsTable").get_model()
plugin_name = filter_model[int(path)][self.COLUMN_NAME]
manager = self.core.get("plugin-manager") manager = self.core.get("plugin-manager")
enabled = manager.get_plugin_state(plugin_name) enabled = manager.get_plugin_state(plugin_name)
if enabled: if enabled:
......
...@@ -34,5 +34,5 @@ class PostprocessorEMC2(pycam.Plugins.PluginBase): ...@@ -34,5 +34,5 @@ class PostprocessorEMC2(pycam.Plugins.PluginBase):
return True return True
def teardown(self): def teardown(self):
self.core.get("unregister_postprocessor")("emc2", "EMC2") self.core.get("unregister_postprocessor")("emc2")
...@@ -57,6 +57,7 @@ class TaskParamCollisionModels(pycam.Plugins.PluginBase): ...@@ -57,6 +57,7 @@ class TaskParamCollisionModels(pycam.Plugins.PluginBase):
def teardown(self): def teardown(self):
self.core.get("unregister_parameter")("task", "models", self.core.get("unregister_parameter")("task", "models",
"collision_models") "collision_models")
self.core.unregister_event("model-list-changed", self._update_models)
def _update_models(self): def _update_models(self):
choices = [] choices = []
......
...@@ -73,14 +73,14 @@ class Tasks(pycam.Plugins.ListPluginBase): ...@@ -73,14 +73,14 @@ class Tasks(pycam.Plugins.ListPluginBase):
changed_set_event="task-type-changed", changed_set_event="task-type-changed",
changed_set_list_event="task-type-list-changed", changed_set_list_event="task-type-list-changed",
get_current_set_func=self._get_type) get_current_set_func=self._get_type)
models_parameter_widget = self.core.get( self.models_parameter_widget = self.core.get(
"register_parameter_section")("task", "models") "register_parameter_section")("task", "models")
self.core.register_ui("task_parameters", "Collision models", self.core.register_ui("task_parameters", "Collision models",
models_parameter_widget, weight=20) self.models_parameter_widget, weight=20)
components_parameter_widget = self.core.get( self.components_parameter_widget = self.core.get(
"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) self.components_parameter_widget, weight=10)
# table # table
self.gui.get_object("TaskNameCell").connect("edited", self.gui.get_object("TaskNameCell").connect("edited",
self._edit_task_name) self._edit_task_name)
...@@ -135,10 +135,10 @@ class Tasks(pycam.Plugins.ListPluginBase): ...@@ -135,10 +135,10 @@ class Tasks(pycam.Plugins.ListPluginBase):
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_event("task-type-changed", self._store_task)
self.core.unregister_ui("task_parameters", models_parameter_widget,
weight=20)
self.core.unregister_ui("task_parameters", self.core.unregister_ui("task_parameters",
components_parameter_widget, weight=10) self.models_parameter_widget)
self.core.unregister_ui("task_parameters",
self.components_parameter_widget)
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)
......
...@@ -30,7 +30,7 @@ import pycam.Gui.ControlsGTK ...@@ -30,7 +30,7 @@ import pycam.Gui.ControlsGTK
class ToolpathCrop(pycam.Plugins.PluginBase): class ToolpathCrop(pycam.Plugins.PluginBase):
UI_FILE = "toolpath_crop.ui" UI_FILE = "toolpath_crop.ui"
DEPENDS = ["Toolpaths"] DEPENDS = ["Models", "Toolpaths"]
CATEGORIES = ["Toolpath"] CATEGORIES = ["Toolpath"]
def setup(self): def setup(self):
......
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