Commit 2a87c8ca authored by sumpfralle's avatar sumpfralle

moved bounds handling to a separate plugin (still quite broken)


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@1118 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent b5e69ecc
This diff is collapsed.
This diff is collapsed.
...@@ -51,6 +51,25 @@ except ImportError: ...@@ -51,6 +51,25 @@ except ImportError:
log = pycam.Utils.log.get_logger() log = pycam.Utils.log.get_logger()
def get_combined_bounds(models):
low = [None, None, None]
high = [None, None, None]
for model in models:
if (low[0] is None) or (model.minx < low[0]):
low[0] = model.minx
if (low[1] is None) or (model.miny < low[1]):
low[1] = model.miny
if (low[2] is None) or (model.minz < low[2]):
low[2] = model.minz
if (high[0] is None) or (model.maxx > high[0]):
high[0] = model.maxx
if (high[1] is None) or (model.maxy > high[1]):
high[1] = model.maxy
if (high[2] is None) or (model.maxz > high[2]):
high[2] = model.maxz
return low, high
class BaseModel(TransformableContainer): class BaseModel(TransformableContainer):
id = 0 id = 0
......
This diff is collapsed.
This diff is collapsed.
...@@ -38,7 +38,7 @@ class ModelSupport(pycam.Plugins.PluginBase): ...@@ -38,7 +38,7 @@ class ModelSupport(pycam.Plugins.PluginBase):
"support-model-changed") "support-model-changed")
self.core.register_event("model-change-after", self.core.register_event("model-change-after",
support_model_changed) support_model_changed)
self.core.register_event("boundary-updated", self.core.register_event("bounds-changed",
support_model_changed) support_model_changed)
self.core.register_event("support-model-changed", self.core.register_event("support-model-changed",
self.update_support_model) self.update_support_model)
......
...@@ -94,6 +94,7 @@ class Models(pycam.Plugins.ListPluginBase): ...@@ -94,6 +94,7 @@ class Models(pycam.Plugins.ListPluginBase):
self._treemodel.append((id(item), "Model #%d" % index, self._treemodel.append((id(item), "Model #%d" % index,
True, color, True, color,
int(self.DEFAULT_COLOR[3] * _GTK_COLOR_MAX))) int(self.DEFAULT_COLOR[3] * _GTK_COLOR_MAX)))
self.core.emit_event("model-list-changed")
self._get_colors_of_selected_models() self._get_colors_of_selected_models()
self.register_model_update(update_model) self.register_model_update(update_model)
self.core.set("models", self) self.core.set("models", self)
......
...@@ -21,10 +21,6 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>. ...@@ -21,10 +21,6 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
""" """
import pycam.Plugins import pycam.Plugins
from pycam.PathGenerators.PushCutter import PushCutter
from pycam.PathGenerators.ContourFollow import ContourFollow
from pycam.PathGenerators.DropCutter import DropCutter
from pycam.PathGenerators.EngraveCutter import EngraveCutter
class Processes(pycam.Plugins.ListPluginBase): class Processes(pycam.Plugins.ListPluginBase):
...@@ -84,8 +80,8 @@ class Processes(pycam.Plugins.ListPluginBase): ...@@ -84,8 +80,8 @@ class Processes(pycam.Plugins.ListPluginBase):
self.register_model_update(update_model) self.register_model_update(update_model)
# process settings # process settings
self._detail_handlers = [] self._detail_handlers = []
for objname in self.CONTROL_BUTTONS: for obj_name in self.CONTROL_BUTTONS:
obj = self.gui.get_object(objname) obj = self.gui.get_object(obj_name)
for signal in self.CONTROL_SIGNALS: for signal in self.CONTROL_SIGNALS:
try: try:
handler = obj.connect(signal, handler = obj.connect(signal,
...@@ -96,12 +92,12 @@ class Processes(pycam.Plugins.ListPluginBase): ...@@ -96,12 +92,12 @@ class Processes(pycam.Plugins.ListPluginBase):
except TypeError: except TypeError:
continue continue
else: else:
self.log.info("Failed to connect to widget '%s'" % str(objname)) self.log.info("Failed to connect to widget '%s'" % str(obj_name))
self.core.register_event("process-selection-changed", self.core.register_event("process-selection-changed",
self._process_change) self._process_switch)
self.core.register_event("process-changed", self.core.register_event("process-changed",
self._update_process_controls) self._store_process_settings)
self._update_process_controls() self._store_process_settings()
self.core.set("processes", self) self.core.set("processes", self)
return True return True
...@@ -153,7 +149,7 @@ class Processes(pycam.Plugins.ListPluginBase): ...@@ -153,7 +149,7 @@ class Processes(pycam.Plugins.ListPluginBase):
new_text: new_text:
self._treemodel[path][self.COLUMN_NAME] = new_text self._treemodel[path][self.COLUMN_NAME] = new_text
def _update_process_controls(self): def _store_process_settings(self):
data = self.get_selected() data = self.get_selected()
if data is None: if data is None:
self.gui.get_object("ProcessSettingsControlsBox").hide() self.gui.get_object("ProcessSettingsControlsBox").hide()
...@@ -167,7 +163,7 @@ class Processes(pycam.Plugins.ListPluginBase): ...@@ -167,7 +163,7 @@ class Processes(pycam.Plugins.ListPluginBase):
data[obj_name] = value data[obj_name] = value
break break
else: else:
log.info("Failed to update value of control %s" % objname) self.log.info("Failed to update value of control %s" % obj_name)
self.gui.get_object("ProcessSettingsControlsBox").show() self.gui.get_object("ProcessSettingsControlsBox").show()
while not self._validate_process_consistency(): while not self._validate_process_consistency():
pass pass
...@@ -176,7 +172,7 @@ class Processes(pycam.Plugins.ListPluginBase): ...@@ -176,7 +172,7 @@ class Processes(pycam.Plugins.ListPluginBase):
renderer = self.gui.get_object("DescriptionCell") renderer = self.gui.get_object("DescriptionCell")
cell.set_cell_data_func(renderer, self._render_process_description) cell.set_cell_data_func(renderer, self._render_process_description)
def _process_change(self, widget=None, data=None): def _process_switch(self, widget=None, data=None):
process = self.get_selected() process = self.get_selected()
control_box = self.gui.get_object("ProcessSettingsControlsBox") control_box = self.gui.get_object("ProcessSettingsControlsBox")
if not process: if not process:
...@@ -195,7 +191,7 @@ class Processes(pycam.Plugins.ListPluginBase): ...@@ -195,7 +191,7 @@ class Processes(pycam.Plugins.ListPluginBase):
getattr(obj, set_func)(value) getattr(obj, set_func)(value)
break break
else: else:
log.info("Failed to set value of control %s" % objname) self.log.info("Failed to set value of control %s" % obj_name)
for obj, handler in self._detail_handlers: for obj, handler in self._detail_handlers:
obj.handler_unblock(handler) obj.handler_unblock(handler)
control_box.show() control_box.show()
......
...@@ -165,7 +165,9 @@ class ListPluginBase(PluginBase, list): ...@@ -165,7 +165,9 @@ class ListPluginBase(PluginBase, list):
self._update_model() self._update_model()
return value return value
def _get_selected(self, modelview, index=False, force_list=False): def _get_selected(self, modelview, index=False, force_list=False, content=None):
if content is None:
content = self
if hasattr(modelview, "get_selection"): if hasattr(modelview, "get_selection"):
# a treeview selection # a treeview selection
selection = modelview.get_selection() selection = modelview.get_selection()
...@@ -178,7 +180,7 @@ class ListPluginBase(PluginBase, list): ...@@ -178,7 +180,7 @@ class ListPluginBase(PluginBase, list):
if index: if index:
get_result = lambda path: path[0] get_result = lambda path: path[0]
else: else:
get_result = lambda path: self[path[0]] get_result = lambda path: content[path[0]]
if (selection_mode == gtk.SELECTION_MULTIPLE) or force_list: if (selection_mode == gtk.SELECTION_MULTIPLE) or force_list:
result = [] result = []
for path in paths: for path in paths:
......
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