Commit 160592dc authored by sumpfralle's avatar sumpfralle

added a bounds size description


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@1135 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent abeaadae
...@@ -102,6 +102,7 @@ ...@@ -102,6 +102,7 @@
<child> <child>
<object class="GtkTreeViewColumn" id="DescriptionColumn"> <object class="GtkTreeViewColumn" id="DescriptionColumn">
<property name="title">Name</property> <property name="title">Name</property>
<property name="expand">True</property>
<child> <child>
<object class="GtkCellRendererText" id="NameCell"> <object class="GtkCellRendererText" id="NameCell">
<property name="editable">True</property> <property name="editable">True</property>
...@@ -112,6 +113,15 @@ ...@@ -112,6 +113,15 @@
</child> </child>
</object> </object>
</child> </child>
<child>
<object class="GtkTreeViewColumn" id="SizeColumn">
<property name="title">Size</property>
<property name="expand">True</property>
<child>
<object class="GtkCellRendererText" id="SizeCell"/>
</child>
</object>
</child>
</object> </object>
</child> </child>
</object> </object>
...@@ -740,23 +750,60 @@ ...@@ -740,23 +750,60 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="spacing">3</property> <property name="spacing">3</property>
<child> <child>
<object class="GtkTreeView" id="BoundsModelsTable"> <object class="GtkVBox" id="vbox2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="orientation">vertical</property>
<property name="model">BoundsModelsList</property>
<property name="headers_visible">False</property>
<property name="headers_clickable">False</property>
<property name="search_column">0</property>
<child> <child>
<object class="GtkTreeViewColumn" id="ModelDescriptionColumn"> <object class="GtkViewport" id="viewport2">
<property name="title">Model</property> <property name="visible">True</property>
<property name="resize_mode">queue</property>
<property name="shadow_type">etched-out</property>
<child> <child>
<object class="GtkCellRendererText" id="ModelNameCell"/> <object class="GtkTreeView" id="BoundsModelsTable">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">BoundsModelsList</property>
<property name="headers_visible">False</property>
<property name="headers_clickable">False</property>
<property name="search_column">0</property>
<child>
<object class="GtkTreeViewColumn" id="ModelDescriptionColumn">
<property name="title">Model</property>
<child>
<object class="GtkCellRendererText" id="ModelNameCell"/>
</child>
</object>
</child>
</object>
</child> </child>
</object> </object>
<packing>
<property name="padding">3</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="xpad">3</property>
<property name="ypad">3</property>
<property name="label" translatable="yes">Do not select a model if you want to use all models involved in this task.</property>
<property name="wrap">True</property>
<property name="width_chars">21</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">3</property>
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
...@@ -764,7 +811,8 @@ ...@@ -764,7 +811,8 @@
<object class="GtkLabel" id="MarginTypeRelativeLabel"> <object class="GtkLabel" id="MarginTypeRelativeLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="xpad">2</property> <property name="xpad">3</property>
<property name="ypad">3</property>
<property name="label" translatable="yes">&lt;i&gt;Relative margins are given in percent respectively mm/inch relative to the size of the selected models. Positive values create a margin around the model. Negative values create a bounding box that is smaller than the models.&lt;/i&gt;</property> <property name="label" translatable="yes">&lt;i&gt;Relative margins are given in percent respectively mm/inch relative to the size of the selected models. Positive values create a margin around the model. Negative values create a bounding box that is smaller than the models.&lt;/i&gt;</property>
<property name="use_markup">True</property> <property name="use_markup">True</property>
<property name="wrap">True</property> <property name="wrap">True</property>
...@@ -788,6 +836,7 @@ ...@@ -788,6 +836,7 @@
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">False</property>
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
...@@ -795,7 +844,8 @@ ...@@ -795,7 +844,8 @@
<object class="GtkLabel" id="MarginTypeCustomLabel"> <object class="GtkLabel" id="MarginTypeCustomLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="xpad">2</property> <property name="xpad">3</property>
<property name="ypad">3</property>
<property name="label" translatable="yes">&lt;i&gt;These values are absolute coordinates of the processing bounding box. They do not depend on any model.&lt;/i&gt;</property> <property name="label" translatable="yes">&lt;i&gt;These values are absolute coordinates of the processing bounding box. They do not depend on any model.&lt;/i&gt;</property>
<property name="use_markup">True</property> <property name="use_markup">True</property>
<property name="wrap">True</property> <property name="wrap">True</property>
......
...@@ -139,8 +139,11 @@ class Bounds(pycam.Plugins.ListPluginBase): ...@@ -139,8 +139,11 @@ class Bounds(pycam.Plugins.ListPluginBase):
self._switch_bounds) self._switch_bounds)
self.core.register_event("bounds-changed", self.core.register_event("bounds-changed",
self._store_bounds_settings) self._store_bounds_settings)
self.core.register_event("bounds-changed",
self._trigger_table_update)
self.core.register_event("model-list-changed", self.core.register_event("model-list-changed",
self._update_model_list) self._update_model_list)
self._trigger_table_update()
self._switch_bounds() self._switch_bounds()
self._update_model_list() self._update_model_list()
self.core.set("bounds", self) self.core.set("bounds", self)
...@@ -195,6 +198,21 @@ class Bounds(pycam.Plugins.ListPluginBase): ...@@ -195,6 +198,21 @@ class Bounds(pycam.Plugins.ListPluginBase):
this_model = all_models[model_ids.index(model_id)] this_model = all_models[model_ids.index(model_id)]
cell.set_property("text", all_models.get_attr(this_model, "name")) cell.set_property("text", all_models.get_attr(this_model, "name"))
def _render_bounds_size(self, column, cell, model, m_iter):
path = model.get_path(m_iter)
bounds = self[path[0]]
low, high = bounds.get_absolute_limits()
if None in low or None in high:
text = ""
else:
text = "%g x %g x %g" % tuple([high[i] - low[i] for i in range(3)])
cell.set_property("text", text)
def _trigger_table_update(self):
# trigger an update of the table - ugly!
self.gui.get_object("SizeColumn").set_cell_data_func(
self.gui.get_object("SizeCell"), self._render_bounds_size)
def _update_model_list(self): def _update_model_list(self):
model_ids = [id(m) for m in self.core.get("models")] model_ids = [id(m) for m in self.core.get("models")]
model_list = self._modelview.get_model() model_list = self._modelview.get_model()
...@@ -244,14 +262,9 @@ class Bounds(pycam.Plugins.ListPluginBase): ...@@ -244,14 +262,9 @@ class Bounds(pycam.Plugins.ListPluginBase):
custom_label.hide() custom_label.hide()
model_list.show() model_list.show()
percent_switch.show() percent_switch.show()
if self.get_selected_models(): controls_x.show()
controls_x.show() controls_y.show()
controls_y.show() controls_z.show()
controls_z.show()
else:
controls_x.hide()
controls_y.hide()
controls_z.hide()
else: else:
relative_label.hide() relative_label.hide()
custom_label.show() custom_label.show()
...@@ -399,7 +412,7 @@ class Bounds(pycam.Plugins.ListPluginBase): ...@@ -399,7 +412,7 @@ class Bounds(pycam.Plugins.ListPluginBase):
current_bounds_index = self.get_selected(index=True) current_bounds_index = self.get_selected(index=True)
if current_bounds_index is None: if current_bounds_index is None:
current_bounds_index = 0 current_bounds_index = 0
new_bounds = BoundsDict() new_bounds = BoundsDict(self.core)
self.append(new_bounds) self.append(new_bounds)
self.select(new_bounds) self.select(new_bounds)
...@@ -412,8 +425,9 @@ class Bounds(pycam.Plugins.ListPluginBase): ...@@ -412,8 +425,9 @@ class Bounds(pycam.Plugins.ListPluginBase):
class BoundsDict(dict): class BoundsDict(dict):
def __init__(self, *args, **kwargs): def __init__(self, core, *args, **kwargs):
super(BoundsDict, self).__init__(*args, **kwargs) super(BoundsDict, self).__init__(*args, **kwargs)
self.core = core
self.update({ self.update({
"BoundaryLowX": 0, "BoundaryLowX": 0,
"BoundaryLowY": 0, "BoundaryLowY": 0,
...@@ -433,8 +447,12 @@ class BoundsDict(dict): ...@@ -433,8 +447,12 @@ class BoundsDict(dict):
get_low_value = lambda axis: self["BoundaryLow%s" % "XYZ"[axis]] get_low_value = lambda axis: self["BoundaryLow%s" % "XYZ"[axis]]
get_high_value = lambda axis: self["BoundaryHigh%s" % "XYZ"[axis]] get_high_value = lambda axis: self["BoundaryHigh%s" % "XYZ"[axis]]
if self["TypeRelativeMargin"]: if self["TypeRelativeMargin"]:
# use the currently selected models or all visible ones
models = self["Models"]
if not models:
models = self.core.get("models").get_visible()
low_model, high_model = pycam.Geometry.Model.get_combined_bounds( low_model, high_model = pycam.Geometry.Model.get_combined_bounds(
self["Models"]) models)
if None in low_model or None in high_model: if None in low_model or None in high_model:
# zero-sized models -> no action # zero-sized models -> no action
return default return default
......
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