Commit f613629e authored by sumpfralle's avatar sumpfralle

moved OpenGL settings to the plugin


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@1175 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent cbf5e215
...@@ -462,4 +462,119 @@ ...@@ -462,4 +462,119 @@
<property name="short_label">3D _View Window</property> <property name="short_label">3D _View Window</property>
<property name="tooltip">Display the model in the 3D view window.</property> <property name="tooltip">Display the model in the 3D view window.</property>
</object> </object>
<object class="GtkFrame" id="OpenGLPrefTab">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment11">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkCheckButton" id="OpenGLPolygon">
<property name="label" translatable="yes">Polygon fill</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="OpenGLLight">
<property name="label" translatable="yes">Lighting</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="OpenGLShadow">
<property name="label" translatable="yes">Shadows</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="OpenGLPerspective">
<property name="label" translatable="yes">Perspective view</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox7">
<property name="visible">True</property>
<property name="spacing">2</property>
<child>
<object class="GtkLabel" id="DrillUpdateFPSLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Maximum Frames per Second:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="DrillProgressFrameSkipControl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">DrillProgressMaxFPS</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">4</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="OpenGLSettingsFrameLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;OpenGL Settings&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<object class="GtkAdjustment" id="DrillProgressMaxFPS">
<property name="value">1</property>
<property name="lower">1</property>
<property name="upper">25</property>
<property name="step_increment">1</property>
</object>
</interface> </interface>
...@@ -427,24 +427,6 @@ Please read the description of the Server Mode (linked below) to understand the ...@@ -427,24 +427,6 @@ Please read the description of the Server Mode (linked below) to understand the
<property name="y_options">GTK_FILL</property> <property name="y_options">GTK_FILL</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkViewport" id="viewport2">
<property name="visible">True</property>
<property name="resize_mode">queue</property>
<property name="shadow_type">none</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child> <child>
<object class="GtkLabel" id="ZeroProcessesWarning"> <object class="GtkLabel" id="ZeroProcessesWarning">
<property name="visible">True</property> <property name="visible">True</property>
...@@ -455,6 +437,7 @@ You will need remote workers.&lt;/span&gt;</property> ...@@ -455,6 +437,7 @@ You will need remote workers.&lt;/span&gt;</property>
<property name="wrap">True</property> <property name="wrap">True</property>
</object> </object>
<packing> <packing>
<property name="right_attach">2</property>
<property name="top_attach">1</property> <property name="top_attach">1</property>
<property name="bottom_attach">2</property> <property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>
......
...@@ -68,11 +68,6 @@ ...@@ -68,11 +68,6 @@
</object> </object>
</child> </child>
</object> </object>
<object class="GtkAdjustment" id="DrillProgressMaxFPS">
<property name="lower">1</property>
<property name="upper">25</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="SafetyHeightValue"> <object class="GtkAdjustment" id="SafetyHeightValue">
<property name="lower">-2000</property> <property name="lower">-2000</property>
<property name="upper">2000</property> <property name="upper">2000</property>
...@@ -1520,139 +1515,6 @@ for contour lines and toolpaths, triangle's normals, et cetera).</property> ...@@ -1520,139 +1515,6 @@ for contour lines and toolpaths, triangle's normals, et cetera).</property>
<property name="tab_fill">False</property> <property name="tab_fill">False</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkFrame" id="OpenGLPrefTab">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment11">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkCheckButton" id="OpenGLPolygon">
<property name="label" translatable="yes">Polygon fill</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Toggle between polygon fill or polygon outline rendering.
Hotkey: &lt;m&gt;</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="OpenGLLight">
<property name="label" translatable="yes">Lighting</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Toggle the OpenGL lighting.
Hotkey: &lt;i&gt;</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="OpenGLShadow">
<property name="label" translatable="yes">Shadows</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Toggle the OpenGL shadow effect.
Hotkey: &lt;s&gt;</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="OpenGLPerspective">
<property name="label" translatable="yes">Perspective view</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Toggle between orthogonal and perspective view.
Hotkey: &lt;p&gt;</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox7">
<property name="visible">True</property>
<property name="spacing">2</property>
<child>
<object class="GtkLabel" id="DrillUpdateFPSLabel">
<property name="visible">True</property>
<property name="tooltip_text" translatable="yes">Maximum number of frame updates per second for drill progress visualization.</property>
<property name="label" translatable="yes">Maximum Frames per Second:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="DrillProgressFrameSkipControl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x2022;</property>
<property name="adjustment">DrillProgressMaxFPS</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">4</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="OpenGLSettingsFrameLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;OpenGL Settings&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="position">4</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel" id="GLSettingsTabLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">OpenGL</property>
</object>
<packing>
<property name="position">4</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child> <child>
<object class="GtkFrame" id="ProgramsPrefTab"> <object class="GtkFrame" id="ProgramsPrefTab">
<property name="visible">True</property> <property name="visible">True</property>
...@@ -1821,7 +1683,7 @@ Hotkey: &lt;p&gt;</property> ...@@ -1821,7 +1683,7 @@ Hotkey: &lt;p&gt;</property>
</child> </child>
</object> </object>
<packing> <packing>
<property name="position">5</property> <property name="position">4</property>
</packing> </packing>
</child> </child>
<child type="tab"> <child type="tab">
...@@ -1830,7 +1692,7 @@ Hotkey: &lt;p&gt;</property> ...@@ -1830,7 +1692,7 @@ Hotkey: &lt;p&gt;</property>
<property name="label" translatable="yes">Programs</property> <property name="label" translatable="yes">Programs</property>
</object> </object>
<packing> <packing>
<property name="position">5</property> <property name="position">4</property>
<property name="tab_fill">False</property> <property name="tab_fill">False</property>
</packing> </packing>
</child> </child>
......
...@@ -409,7 +409,6 @@ class ProjectGui(object): ...@@ -409,7 +409,6 @@ class ProjectGui(object):
self.update_save_actions) self.update_save_actions)
self.settings.register_event("model-change-after", self.settings.register_event("model-change-after",
lambda: self.settings.emit_event("visual-item-updated")) lambda: self.settings.emit_event("visual-item-updated"))
self.settings.set("load_model", self.load_model)
# set the availability of ODE # set the availability of ODE
self.enable_ode_control = self.gui.get_object("SettingEnableODE") self.enable_ode_control = self.gui.get_object("SettingEnableODE")
self.settings.add_item("enable_ode", self.enable_ode_control.get_active, self.settings.add_item("enable_ode", self.enable_ode_control.get_active,
...@@ -458,7 +457,6 @@ class ProjectGui(object): ...@@ -458,7 +457,6 @@ class ProjectGui(object):
("GCodePrefTab", "GCode", 10), ("GCodePrefTab", "GCode", 10),
("DisplayItemsPrefTab", "Display Items", 20), ("DisplayItemsPrefTab", "Display Items", 20),
("ColorPrefTab", "Colors", 30), ("ColorPrefTab", "Colors", 30),
("OpenGLPrefTab", "OpenGL", 40),
("ProgramsPrefTab", "Programs", 50)): ("ProgramsPrefTab", "Programs", 50)):
obj = self.gui.get_object(obj_name) obj = self.gui.get_object(obj_name)
obj.unparent() obj.unparent()
...@@ -557,16 +555,6 @@ class ProjectGui(object): ...@@ -557,16 +555,6 @@ class ProjectGui(object):
main_tab.set_sensitive(True) main_tab.set_sensitive(True)
self.settings.register_event("gui-disable", disable_gui) self.settings.register_event("gui-disable", disable_gui)
self.settings.register_event("gui-enable", enable_gui) self.settings.register_event("gui-enable", enable_gui)
for name, objname in (
("view_light", "OpenGLLight"),
("view_shadow", "OpenGLShadow"),
("view_polygon", "OpenGLPolygon"),
("view_perspective", "OpenGLPerspective")):
obj = self.gui.get_object(objname)
self.settings.add_item(name, obj.get_active, obj.set_active)
# send "True" to trigger a re-setup of GL settings
obj.connect("toggled", lambda widget: \
self.settings.emit_event("visual-item-updated"))
# color selectors # color selectors
def get_color_wrapper(obj): def get_color_wrapper(obj):
def gtk_color_to_float(): def gtk_color_to_float():
...@@ -602,8 +590,6 @@ class ProjectGui(object): ...@@ -602,8 +590,6 @@ class ProjectGui(object):
# repaint the 3d view after a color change # repaint the 3d view after a color change
obj.connect("color-set", lambda widget: \ obj.connect("color-set", lambda widget: \
self.settings.emit_event("visual-item-updated")) self.settings.emit_event("visual-item-updated"))
skip_obj = self.gui.get_object("DrillProgressFrameSkipControl")
self.settings.add_item("drill_progress_max_fps", skip_obj.get_value, skip_obj.set_value)
# gcode settings # gcode settings
gcode_minimum_step_x = self.gui.get_object("GCodeMinimumStep_x") gcode_minimum_step_x = self.gui.get_object("GCodeMinimumStep_x")
self.settings.add_item("gcode_minimum_step_x", self.settings.add_item("gcode_minimum_step_x",
......
...@@ -91,8 +91,28 @@ class OpenGLWindow(pycam.Plugins.PluginBase): ...@@ -91,8 +91,28 @@ class OpenGLWindow(pycam.Plugins.PluginBase):
self.is_visible = False self.is_visible = False
self._last_view = VIEWS["reset"] self._last_view = VIEWS["reset"]
self._position = [200, 200] self._position = [200, 200]
toggle_3d = self.gui.get_object("Toggle3DView") box = self.gui.get_object("OpenGLPrefTab")
self.core.register_ui("preferences", "OpenGL", box, 40)
self._gtk_handlers = [] self._gtk_handlers = []
# options
# TODO: move the default value somewhere else
for name, objname, default in (
("view_light", "OpenGLLight", True),
("view_shadow", "OpenGLShadow", True),
("view_polygon", "OpenGLPolygon", True),
("view_perspective", "OpenGLPerspective", True)):
obj = self.gui.get_object(objname)
self.core.add_item(name, obj.get_active, obj.set_active)
obj.set_active(default)
self._gtk_handlers.append((obj, "toggled", self.glsetup))
self._gtk_handlers.append((obj, "toggled",
"visual-item-updated"))
# frames per second
skip_obj = self.gui.get_object("DrillProgressFrameSkipControl")
self.core.add_item("drill_progress_max_fps",
skip_obj.get_value, skip_obj.set_value)
# toggle window state
toggle_3d = self.gui.get_object("Toggle3DView")
self._gtk_handlers.append((toggle_3d, "toggled", self._gtk_handlers.append((toggle_3d, "toggled",
self.toggle_3d_view)) self.toggle_3d_view))
self.register_gtk_accelerator("opengl", toggle_3d, self.register_gtk_accelerator("opengl", toggle_3d,
...@@ -331,7 +351,7 @@ class OpenGLWindow(pycam.Plugins.PluginBase): ...@@ -331,7 +351,7 @@ class OpenGLWindow(pycam.Plugins.PluginBase):
self.camera.zoom_in() self.camera.zoom_in()
else: else:
self.camera.zoom_out() self.camera.zoom_out()
self._paint_ignore_busy() self.paint()
elif keyval in move_keys_dict.keys(): elif keyval in move_keys_dict.keys():
self._last_view = None self._last_view = None
move_x, move_y = move_keys_dict[keyval] move_x, move_y = move_keys_dict[keyval]
...@@ -344,7 +364,7 @@ class OpenGLWindow(pycam.Plugins.PluginBase): ...@@ -344,7 +364,7 @@ class OpenGLWindow(pycam.Plugins.PluginBase):
else: else:
# no shift key -> moving # no shift key -> moving
self.camera.shift_view(x_dist=move_x, y_dist=move_y) self.camera.shift_view(x_dist=move_x, y_dist=move_y)
self._paint_ignore_busy() self.paint()
else: else:
# see dir(gtk.keysyms) # see dir(gtk.keysyms)
#print "Key pressed: %s (%s)" % (keyval, get_state()) #print "Key pressed: %s (%s)" % (keyval, get_state())
...@@ -383,7 +403,7 @@ class OpenGLWindow(pycam.Plugins.PluginBase): ...@@ -383,7 +403,7 @@ class OpenGLWindow(pycam.Plugins.PluginBase):
return result return result
return gtkgl_refresh_wrapper return gtkgl_refresh_wrapper
def glsetup(self): def glsetup(self, widget=None):
GLUT.glutInit() GLUT.glutInit()
GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA | GLUT.GLUT_DOUBLE | \ GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA | GLUT.GLUT_DOUBLE | \
GLUT.GLUT_DEPTH | GLUT.GLUT_MULTISAMPLE | GLUT.GLUT_ALPHA | \ GLUT.GLUT_DEPTH | GLUT.GLUT_MULTISAMPLE | GLUT.GLUT_ALPHA | \
......
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