Commit d478707c authored by sumpfralle's avatar sumpfralle

added a status line for displaying the dimensions of the model above the 3d view


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@183 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 51d8ae62
...@@ -17,6 +17,7 @@ import OpenGL.GLUT as GLUT ...@@ -17,6 +17,7 @@ import OpenGL.GLUT as GLUT
#import gtk.gtkgl #import gtk.gtkgl
import pygtk import pygtk
import gtk import gtk
import pango
import time import time
import os import os
import sys import sys
...@@ -82,15 +83,24 @@ class GLView: ...@@ -82,15 +83,24 @@ class GLView:
# first run; might also be important when doing other fancy gtk/gdk stuff # first run; might also be important when doing other fancy gtk/gdk stuff
self.area.connect_after('realize', self.paint) self.area.connect_after('realize', self.paint)
# called when a part of the screen is uncovered # called when a part of the screen is uncovered
self.area.connect('expose_event', self.paint) self.area.connect('expose-event', self.paint)
# resize window # resize window
self.area.connect('configure_event', self._resize_window) self.area.connect('configure-event', self._resize_window)
# catch mouse events # catch mouse events
self.area.set_events(gtk.gdk.MOUSE | gtk.gdk.BUTTON_PRESS_MASK) self.area.set_events(gtk.gdk.MOUSE | gtk.gdk.BUTTON_PRESS_MASK)
self.area.connect("button-press-event", self.mouse_handler) self.area.connect("button-press-event", self.mouse_handler)
self.area.connect('motion-notify-event', self.mouse_handler) self.area.connect('motion-notify-event', self.mouse_handler)
self.area.show() self.area.show()
self.camera = ogl_tools.Camera(self.settings, lambda: (self.area.allocation.width, self.area.allocation.height)) self.camera = ogl_tools.Camera(self.settings, lambda: (self.area.allocation.width, self.area.allocation.height))
# color the dimension value according to the axes
for color, names in (
(pango.AttrForeground(65535, 0, 0, 0, 100), ("model_dim_x_label", "model_dim_x")),
(pango.AttrForeground(0, 65535, 0, 0, 100), ("model_dim_y_label", "model_dim_y")),
(pango.AttrForeground(0, 0, 65535, 0, 100), ("model_dim_z_label", "model_dim_z"))):
attributes = pango.AttrList()
attributes.insert(color)
for name in names:
self.gui.get_object(name).set_attributes(attributes)
self.container.add(self.area) self.container.add(self.area)
self.container.show() self.container.show()
self.show() self.show()
...@@ -277,6 +287,11 @@ class GLView: ...@@ -277,6 +287,11 @@ class GLView:
def _paint_raw(self, widget=None): def _paint_raw(self, widget=None):
GuiCommon.draw_complete_model_view(self.settings) GuiCommon.draw_complete_model_view(self.settings)
# update the dimension display
s = self.settings
self.gui.get_object("model_dim_x").set_text("%.3f %s" % (s.get("maxx") - s.get("minx"), s.get("unit")))
self.gui.get_object("model_dim_y").set_text("%.3f %s" % (s.get("maxy") - s.get("miny"), s.get("unit")))
self.gui.get_object("model_dim_z").set_text("%.3f %s" % (s.get("maxz") - s.get("minz"), s.get("unit")))
class ProjectGui: class ProjectGui:
...@@ -337,6 +352,7 @@ class ProjectGui: ...@@ -337,6 +352,7 @@ class ProjectGui:
unit_field.append_text("inch") unit_field.append_text("inch")
unit_field.set_active(0) unit_field.set_active(0)
unit_field.show() unit_field.show()
unit_field.connect("changed", self.update_view)
scale_box.add(unit_field) scale_box.add(unit_field)
# move it to the top # move it to the top
scale_box.reorder_child(unit_field, 1) scale_box.reorder_child(unit_field, 1)
......
...@@ -398,10 +398,11 @@ ...@@ -398,10 +398,11 @@
<child> <child>
<object class="GtkLabel" id="UnitLabel"> <object class="GtkLabel" id="UnitLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Unit:</property> <property name="label" translatable="yes">Unit:</property>
</object> </object>
<packing> <packing>
<property name="fill">False</property> <property name="expand">False</property>
<property name="padding">3</property> <property name="padding">3</property>
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
...@@ -473,7 +474,7 @@ ...@@ -473,7 +474,7 @@
</child> </child>
<child> <child>
<object class="GtkButton" id="Scale up"> <object class="GtkButton" id="Scale up">
<property name="label" translatable="yes">Enlage</property> <property name="label" translatable="yes">Enlarge</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">True</property> <property name="receives_default">True</property>
...@@ -2160,6 +2161,110 @@ ...@@ -2160,6 +2161,110 @@
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkHBox" id="view3ddimension">
<property name="visible">True</property>
<property name="spacing">6</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkHBox" id="hbox10">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="model_dim_x_label">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="xpad">3</property>
<property name="label" translatable="yes">&#x394;x:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="model_dim_x">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">x</property>
<property name="single_line_mode">True</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox14">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="model_dim_y_label">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="xpad">3</property>
<property name="label" translatable="yes">&#x394;y:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="model_dim_y">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">y</property>
<property name="single_line_mode">True</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox15">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="model_dim_z_label">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="xpad">3</property>
<property name="label" translatable="yes">&#x394;z:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="model_dim_z">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">z</property>
<property name="single_line_mode">True</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child> <child>
<object class="GtkHBox" id="view3dbox"> <object class="GtkHBox" id="view3dbox">
<property name="visible">True</property> <property name="visible">True</property>
...@@ -2234,7 +2339,7 @@ ...@@ -2234,7 +2339,7 @@
</child> </child>
</object> </object>
<packing> <packing>
<property name="position">1</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
</object> </object>
......
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