Commit 49ce4a72 authored by sumpfralle's avatar sumpfralle

fixed visibility of dimension box

aded drop-down list of visible items and the context menu for 3D view
cleanup of main UI file


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@1195 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 723af3c1
......@@ -2,60 +2,6 @@
<interface>
<!-- interface-requires gtk+ 2.12 -->
<!-- interface-naming-policy project-wide -->
<object class="GtkListStore" id="ProcessingConfigs">
<columns>
<!-- column-name Name -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkListStore" id="PathSetup">
<columns>
<!-- column-name index -->
<column type="guint"/>
<!-- column-name tool_id -->
<column type="guint"/>
<!-- column-name process_id -->
<column type="guint"/>
</columns>
</object>
<object class="GtkListStore" id="GCodeCornerStyleList">
<columns>
<!-- column-name name -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">Exact path mode (G61)</col>
</row>
<row>
<col id="0" translatable="yes">Exact stop mode (G61.1)</col>
</row>
<row>
<col id="0" translatable="yes">Continuous with maximum speed (G64)</col>
</row>
<row>
<col id="0" translatable="yes">Continuous with tolerance (G64 P/Q)</col>
</row>
</data>
</object>
<object class="GtkListStore" id="TouchOffLocationModel">
<columns>
<!-- column-name key -->
<column type="gchararray"/>
<!-- column-name name -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">startup</col>
<col id="1" translatable="yes">Initial location (at startup)</col>
</row>
<row>
<col id="0" translatable="yes">absolute</col>
<col id="1" translatable="yes">Fixed location (absolute)</col>
</row>
</data>
</object>
<object class="GtkWindow" id="ProjectWindow">
<property name="title" translatable="yes">PyCAM</property>
<property name="role">pycam-main</property>
......@@ -68,11 +14,6 @@
</object>
</child>
</object>
<object class="GtkAdjustment" id="SafetyHeightValue">
<property name="lower">-2000</property>
<property name="upper">2000</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAction" id="OpenModel">
<property name="label">_Open Model ...</property>
<property name="tooltip">Opens a model file.</property>
......@@ -574,14 +515,6 @@ You should have received a copy of the GNU General Public License along with thi
<object class="GtkAction" id="HelpHotkeys">
<property name="label">_Keyboard Shortcuts</property>
</object>
<object class="GtkAdjustment" id="GCodeCornerStyleMotionToleranceValue">
<property name="upper">100</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="GCodeCornerStyleCAMToleranceValue">
<property name="upper">100</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAction" id="OpenRecentModel">
<property name="label">Open _Recent</property>
</object>
......@@ -598,46 +531,6 @@ You should have received a copy of the GNU General Public License along with thi
<property name="label">Undo latest model change</property>
<property name="stock_id">gtk-undo</property>
</object>
<object class="GtkAdjustment" id="ToolChangeRapidMoveDownValue">
<property name="upper">10000</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="ToolChangeSlowMoveDownValue">
<property name="value">1</property>
<property name="lower">0.10000000000000001</property>
<property name="upper">10000</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="ToolChangeSlowMoveSpeedValue">
<property name="value">20</property>
<property name="lower">1</property>
<property name="upper">100000</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="ToolChangePosXValue">
<property name="lower">-10000</property>
<property name="upper">10000</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="ToolChangePosYValue">
<property name="lower">-10000</property>
<property name="upper">10000</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="ToolChangePosZValue">
<property name="lower">-10000</property>
<property name="upper">10000</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="TouchOffHeightValue">
<property name="lower">-10000</property>
<property name="upper">10000</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="GCodeSpindleDelayValue">
<property name="upper">100</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAction" id="HelpTouchOff">
<property name="label">_Touch off and tool change</property>
<property name="short_label">_Touch off</property>
......
......@@ -74,13 +74,7 @@ class OpenGLViewDimension(pycam.Plugins.PluginBase):
low, high = pycam.Geometry.Model.get_combined_bounds(models)
if None in low or None in high:
low, high = (0, 0, 0), (0, 0, 0)
# model corners in 3D view
if None in low or None in high:
# all models are empty
dimension_bar.hide()
return
if self.core.get("show_dimensions"):
dimension_bar.show()
for value, label_suffix in ((low[0], "XMin"), (low[1], "YMin"),
(low[2], "ZMin"), (high[0], "XMax"), (high[1], "YMax"),
(high[2], "ZMax")):
......@@ -94,3 +88,6 @@ class OpenGLViewDimension(pycam.Plugins.PluginBase):
self.gui.get_object(name).set_text("%.3f %s" \
% (size, self.core.get("unit_string")))
dimension_bar.show()
else:
dimension_bar.hide()
......@@ -80,6 +80,7 @@ class OpenGLWindow(pycam.Plugins.PluginBase):
+ "\nPlease install 'python-gtkglext1' to enable it.")
return False
if self.gui:
self.context_menu = gtk.Menu()
self.window = self.gui.get_object("OpenGLWindow")
self.core.get("configure-drag-drop-func")(self.window)
self.window.add_accel_group(self.core.get("gtk-accel-group"))
......@@ -204,47 +205,6 @@ class OpenGLWindow(pycam.Plugins.PluginBase):
self.gui.get_object("OpenGLBox").pack_end(self.area)
self.camera = Camera(self.core, lambda: (self.area.allocation.width,
self.area.allocation.height))
# add the items buttons (for configuring visible items)
# TODO: enable the context menu
if False and item_buttons:
items_button_container = self.gui.get_object("ViewItems")
for button in item_buttons:
new_checkbox = gtk.ToggleToolButton()
new_checkbox.set_label(button.get_label())
new_checkbox.set_active(button.get_active())
# Configure the two buttons (in "Preferences" and in the 3D view
# widget) to toggle each other. This is required for a
# consistent view of the setting.
connect_button_handlers("toggled", button, new_checkbox)
items_button_container.insert(new_checkbox, -1)
items_button_container.show_all()
# create the drop-down menu
if context_menu_actions:
action_group = gtk.ActionGroup("context")
for action in context_menu_actions:
action_group.add_action(action)
uimanager = gtk.UIManager()
# The "pos" parameter is optional since gtk 2.12 - we can
# remove it later.
uimanager.insert_action_group(action_group, pos=-1)
uimanager_template = '<ui><popup name="context">%s</popup></ui>'
uimanager_item_template = """<menuitem action="%s" />"""
uimanager_text = uimanager_template % "".join(
[uimanager_item_template % action.get_name()
for action in context_menu_actions])
uimanager.add_ui_from_string(uimanager_text)
self.context_menu = uimanager.get_widget("/context")
self.context_menu.insert(gtk.SeparatorMenuItem(), 0)
else:
self.context_menu = gtk.Menu()
for index, button in enumerate(item_buttons):
new_item = gtk.CheckMenuItem(button.get_label())
new_item.set_active(button.get_active())
connect_button_handlers("toggled", button, new_item)
self.context_menu.insert(new_item, index)
self.context_menu.show_all()
else:
self.context_menu = None
self._event_handlers = (
("visual-item-updated", self.update_view),
("visualization-state-changed", self._update_widgets),
......@@ -294,12 +254,21 @@ class OpenGLWindow(pycam.Plugins.PluginBase):
if name in self._display_items:
self.log.debug("Tried to register display item '%s' twice" % name)
return
widget = gtk.CheckButton(label)
widget.connect("toggled", lambda widget: \
# create an action and three derived items:
# - a checkbox for the preferences window
# - a tool item for the drop-down list in the 3D window
# - a menu item for the context menu in the 3D window
action = gtk.ToggleAction(name, label, "Show/hide %s" % label, None)
action.connect("toggled", lambda widget: \
self.core.emit_event("visual-item-updated"))
checkbox = gtk.CheckButton(label)
action.connect_proxy(checkbox)
tool_item = action.create_tool_item()
menu_item = action.create_menu_item()
widgets = (checkbox, tool_item, menu_item)
self._display_items[name] = {"name": name, "label": label,
"weight": weight, "widget": widget}
self.core.add_item(name, widget.get_active, widget.set_active)
"weight": weight, "widgets": widgets}
self.core.add_item(name, action.get_active, action.set_active)
self._rebuild_display_items()
def unregister_display_item(self, name):
......@@ -311,14 +280,20 @@ class OpenGLWindow(pycam.Plugins.PluginBase):
self._rebuild_display_items()
def _rebuild_display_items(self):
box = self.gui.get_object("PreferencesVisibleItemsBox")
for child in box.get_children():
box.remove(child)
pref_box = self.gui.get_object("PreferencesVisibleItemsBox")
toolbar = self.gui.get_object("ViewItems")
for parent in pref_box, self.context_menu, toolbar:
for child in parent.get_children():
parent.remove(child)
items = self._display_items.values()
items.sort(key=lambda item: item["weight"])
for item in items:
box.pack_start(item["widget"], expand=False)
box.show_all()
pref_box.pack_start(item["widgets"][0], expand=False)
toolbar.add(item["widgets"][1])
self.context_menu.add(item["widgets"][2])
pref_box.show_all()
toolbar.show_all()
self.context_menu.show_all()
def register_color_setting(self, name, label, weight=100):
if name in self._color_settings:
......
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