+from Blender import BGL, Draw
+from Blender.BGL import *
+
+class GUI:
+
+ def _init():
+
+ # Output Format menu
+ default_value = outputWriters.keys().index(OUTPUT_FORMAT)+1
+ GUI.outFormatMenu = Draw.Create(default_value)
+ GUI.evtOutFormatMenu = 0
+
+ # Animation toggle button
+ GUI.animToggle = Draw.Create(RENDER_ANIMATION)
+ GUI.evtAnimToggle = 1
+
+ # Join Objects toggle button
+ GUI.joinObjsToggle = Draw.Create(OPTIMIZE_FOR_SPACE)
+ GUI.evtJoinObjsToggle = 2
+
+ # Render filled polygons
+ GUI.polygonsToggle = Draw.Create(PRINT_POLYGONS)
+ GUI.evtPolygonsToggle = 3
+ # We hide the POLYGON_EXPANSION_TRICK, for now
+
+ # Render polygon edges
+ GUI.showEdgesToggle = Draw.Create(PRINT_EDGES)
+ GUI.evtShowEdgesToggle = 4
+
+ # Render hidden edges
+ GUI.showHiddenEdgesToggle = Draw.Create(SHOW_HIDDEN_EDGES)
+ GUI.evtShowHiddenEdgesToggle = 5
+
+ # Edge Style menu
+ default_value = edgeSelectionStyles.keys().index(EDGE_STYLE)+1
+ GUI.edgeStyleMenu = Draw.Create(default_value)
+ GUI.evtEdgeStyleMenu = 6
+
+ # Edge Width slider
+ GUI.edgeWidthSlider = Draw.Create(EDGES_WIDTH)
+ GUI.evtEdgeWidthSlider = 7
+
+ # Render Button
+ GUI.evtRenderButton = 8
+
+ # Exit Button
+ GUI.evtExitButton = 9
+
+ def draw():
+
+ # initialize static members
+ GUI._init()
+
+ glClear(GL_COLOR_BUFFER_BIT)
+ glColor3f(0.0, 0.0, 0.0)
+ glRasterPos2i(10, 350)
+ Draw.Text("VRM: Vector Rendering Method script.")
+ glRasterPos2i(10, 335)
+ Draw.Text("Press Q or ESC to quit.")
+
+ # Build the output format menu
+ glRasterPos2i(10, 310)
+ Draw.Text("Select the output Format:")
+ outMenuStruct = "Output Format %t"
+ for t in outputWriters.keys():
+ outMenuStruct = outMenuStruct + "|%s" % t
+ GUI.outFormatMenu = Draw.Menu(outMenuStruct, GUI.evtOutFormatMenu,
+ 10, 285, 160, 18, GUI.outFormatMenu.val, "Choose the Output Format")
+
+ # Animation toggle
+ GUI.animToggle = Draw.Toggle("Animation", GUI.evtAnimToggle,
+ 10, 260, 160, 18, GUI.animToggle.val,
+ "Toggle rendering of animations")
+
+ # Join Objects toggle
+ GUI.joinObjsToggle = Draw.Toggle("Join objects", GUI.evtJoinObjsToggle,
+ 10, 235, 160, 18, GUI.joinObjsToggle.val,
+ "Join objects in the rendered file")
+
+ # Render Button
+ Draw.Button("Render", GUI.evtRenderButton, 10, 210-25, 75, 25+18,
+ "Start Rendering")
+ Draw.Button("Exit", GUI.evtExitButton, 95, 210-25, 75, 25+18, "Exit!")
+
+ # Rendering Styles
+ glRasterPos2i(200, 310)
+ Draw.Text("Rendering Style:")
+
+ # Render Polygons
+ GUI.polygonsToggle = Draw.Toggle("Filled Polygons", GUI.evtPolygonsToggle,
+ 200, 285, 160, 18, GUI.polygonsToggle.val,
+ "Render filled polygons")
+
+ # Render Edges
+ GUI.showEdgesToggle = Draw.Toggle("Show Edges", GUI.evtShowEdgesToggle,
+ 200, 260, 160, 18, GUI.showEdgesToggle.val,
+ "Render polygon edges")
+
+ if GUI.showEdgesToggle.val == 1:
+
+ # Edge Style
+ edgeStyleMenuStruct = "Edge Style %t"
+ for t in edgeSelectionStyles.keys():
+ edgeStyleMenuStruct = edgeStyleMenuStruct + "|%s" % t
+ GUI.edgeStyleMenu = Draw.Menu(edgeStyleMenuStruct, GUI.evtEdgeStyleMenu,
+ 200, 235, 160, 18, GUI.edgeStyleMenu.val,
+ "Choose the edge style")
+
+ # Edge size
+ GUI.edgeWidthSlider = Draw.Slider("Width: ", GUI.evtEdgeWidthSlider,
+ 200, 210, 160, 18, GUI.edgeWidthSlider.val,
+ 0.0, 10.0, 0, "Change Edge Width")
+
+ # Show Hidden Edges
+ GUI.showHiddenEdgesToggle = Draw.Toggle("Show Hidden Edges",
+ GUI.evtShowHiddenEdgesToggle,
+ 200, 185, 160, 18, GUI.showHiddenEdgesToggle.val,
+ "Render hidden edges as dashed lines")
+
+ glRasterPos2i(10, 160)
+ Draw.Text("Antonio Ospite (c) 2006")
+
+ def event(evt, val):
+
+ if evt == Draw.ESCKEY or evt == Draw.QKEY:
+ Draw.Exit()
+ else:
+ return