2005-12-15 18:12:49 +00:00
|
|
|
#!BPY
|
|
|
|
|
|
|
|
"""
|
|
|
|
Name: 'Shape Widget Wizard'
|
|
|
|
Blender: 238
|
|
|
|
Group: 'Animation'
|
|
|
|
Tip: 'Adds Widgets for Driven Shapes'
|
|
|
|
"""
|
|
|
|
|
|
|
|
__author__ = ["Johnny Matthews (guitargeek)"]
|
|
|
|
__url__ = ("blender", "elysiun")
|
|
|
|
__version__ = "0.0.9 12/15/05"
|
|
|
|
|
|
|
|
__bpydoc__ = """\
|
|
|
|
"Shape Widget Wizard" creates objects that drive shape channels.
|
|
|
|
|
|
|
|
Explanation:
|
|
|
|
|
|
|
|
Shapes define morph targets and sometimes it is helpful to animate with a GUI
|
|
|
|
control panel of widgets. This script lets you define several different types
|
|
|
|
of controls that (depending on the type) control 1 to 4 shapes with a single
|
|
|
|
controller.
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
|
|
|
|
1. Click where you want the widget to go<br>
|
|
|
|
2. Highlight the object that has shapes<br>
|
|
|
|
3. Run the script<br>
|
|
|
|
4. Choose the type of widget (there are next and back buttons if you pick the wrong kind)<br>
|
|
|
|
5. Click next and choose what shapes go where on the widget<br>
|
|
|
|
6. Choose a display name for the widget<br>
|
|
|
|
7. Click finish
|
|
|
|
|
|
|
|
The widget is added and you are returned to the first screen for adding another widget.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
###################################################################
|
|
|
|
# #
|
|
|
|
# Shape Widget Wizard #
|
|
|
|
# #
|
|
|
|
# all versions (C) December 2005 Johnny Matthews (guitargeek) #
|
|
|
|
# #
|
|
|
|
# Released under the GPL #
|
|
|
|
# #
|
|
|
|
# Works in Blender 2.4 and higher #
|
|
|
|
# #
|
|
|
|
# This script can be found online at: #
|
|
|
|
# http://guitargeek.superihost.com/widgetmaker #
|
|
|
|
# #
|
|
|
|
# email: johnny.matthews@gmail.com #
|
|
|
|
###################################################################
|
|
|
|
# History #
|
|
|
|
# 0.9 #
|
|
|
|
# Added Name Objects #
|
|
|
|
# 0.81 #
|
|
|
|
# Added Single Shape Toggle #
|
|
|
|
# #
|
|
|
|
# 0.8 #
|
|
|
|
# Controller is Transform Locked and can only move #
|
|
|
|
# in appropriate directions #
|
|
|
|
# #
|
|
|
|
# 0.7 #
|
|
|
|
# Controller is named the same as the range + ".ctrl" #
|
|
|
|
# #
|
|
|
|
###################################################################
|
|
|
|
|
|
|
|
import Blender
|
2007-03-26 19:44:44 +00:00
|
|
|
import bpy
|
2005-12-15 18:12:49 +00:00
|
|
|
from Blender import Mesh,Object,Material,Window,IpoCurve,Ipo,Text3d
|
|
|
|
from Blender.BGL import *
|
|
|
|
from Blender.Draw import *
|
|
|
|
print "----------------------"
|
|
|
|
|
|
|
|
SHAPE1_ONE_MONE = 1
|
|
|
|
SHAPE1_ONE_ZERO = 2
|
|
|
|
SHAPE1_ZERO_MONE = 3
|
|
|
|
SHAPE1_TOGGLE = 12
|
|
|
|
SHAPE2_EXCLUSIVE = 4
|
|
|
|
SHAPE2_V = 5
|
|
|
|
SHAPE2_T = 6
|
|
|
|
SHAPE2_INVT = 7
|
|
|
|
SHAPE2_PLUS = 8
|
|
|
|
SHAPE3_T = 9
|
|
|
|
SHAPE3_INVT = 10
|
|
|
|
SHAPE4_X = 11
|
|
|
|
|
|
|
|
|
|
|
|
stage = 1
|
|
|
|
numshapes = Create(1)
|
|
|
|
widmenu = Create(1)
|
|
|
|
rangename = Create("Range")
|
|
|
|
shapes = [Create(0),Create(0),Create(0),Create(0)]
|
|
|
|
drawtype = 0
|
|
|
|
|
|
|
|
|
|
|
|
#get rid of an ipo curve by deleting all its points
|
|
|
|
def delCurve(ipo):
|
2006-12-25 09:17:23 +00:00
|
|
|
while len(ipo.bezierPoints) > 0:
|
2005-12-15 18:12:49 +00:00
|
|
|
ipo.delBezier(0)
|
|
|
|
ipo.recalc()
|
|
|
|
|
|
|
|
#if a given ipocurve is not there create it, otherwise get it
|
|
|
|
def verifyIpocurve(ky,index):
|
|
|
|
ipo = ky.ipo
|
|
|
|
if ipo == None:
|
2007-04-18 14:40:01 +00:00
|
|
|
nip = bpy.data.ipos.new("keyipo", "Key")
|
2005-12-15 18:12:49 +00:00
|
|
|
ky.ipo = nip
|
|
|
|
ipo = ky.ipo
|
2006-11-23 00:28:09 +00:00
|
|
|
if index == 0:
|
|
|
|
idx = "Basis"
|
|
|
|
else:
|
|
|
|
idx = "Key " + str(index)
|
2006-12-26 01:45:58 +00:00
|
|
|
crv = ipo[idx]
|
2005-12-15 18:12:49 +00:00
|
|
|
if crv == None:
|
2006-12-12 08:05:08 +00:00
|
|
|
# print idx
|
2006-11-23 00:28:09 +00:00
|
|
|
crv = ipo.addCurve(idx)
|
2006-12-25 09:17:23 +00:00
|
|
|
crv.interpolation = IpoCurve.InterpTypes.LINEAR
|
2005-12-15 18:12:49 +00:00
|
|
|
return crv
|
|
|
|
|
|
|
|
# Add the Drivers and Curves
|
|
|
|
def setupDrivers(ob,ctrl,type):
|
|
|
|
global shapes
|
2006-12-12 08:05:08 +00:00
|
|
|
me = ob.getData(mesh=1)
|
|
|
|
ky = me.key
|
|
|
|
|
|
|
|
# Should we add an error here??
|
|
|
|
if not ky:
|
|
|
|
return
|
2005-12-15 18:12:49 +00:00
|
|
|
|
|
|
|
if type in [SHAPE1_ONE_MONE,SHAPE1_ONE_ZERO,SHAPE1_ZERO_MONE]:
|
|
|
|
ctrl.protectFlags = int("111111011",2)
|
|
|
|
ipo = verifyIpocurve(ky,shapes[0].val)
|
|
|
|
ipo.driver = 1
|
|
|
|
ipo.driverObject = ctrl
|
|
|
|
ipo.driverChannel = IpoCurve.LOC_Z
|
|
|
|
ipo.recalc()
|
|
|
|
|
|
|
|
delCurve(ipo)
|
|
|
|
if type == 1:
|
2006-12-25 09:17:23 +00:00
|
|
|
ipo.append((-1,-1))
|
|
|
|
ipo.append((0,0))
|
|
|
|
ipo.append((1,1))
|
2005-12-15 18:12:49 +00:00
|
|
|
if type == 2:
|
2006-12-25 09:17:23 +00:00
|
|
|
ipo.append((0,0))
|
|
|
|
ipo.append((1,1))
|
2005-12-15 18:12:49 +00:00
|
|
|
if type == 3:
|
2006-12-25 09:17:23 +00:00
|
|
|
ipo.append((-1,-1))
|
|
|
|
ipo.append((0,0))
|
2005-12-15 18:12:49 +00:00
|
|
|
ipo.recalc()
|
|
|
|
|
|
|
|
if type == SHAPE1_TOGGLE:
|
|
|
|
ctrl.protectFlags = int("111111011",2)
|
|
|
|
ipo = verifyIpocurve(ky,shapes[0].val)
|
|
|
|
ipo.driver = 1
|
|
|
|
ipo.driverObject = ctrl
|
|
|
|
ipo.driverChannel = IpoCurve.LOC_Z
|
|
|
|
ipo.recalc()
|
|
|
|
delCurve(ipo)
|
2006-12-25 09:17:23 +00:00
|
|
|
ipo.append((0,0))
|
|
|
|
ipo.append((0.5,0))
|
|
|
|
ipo.append((0.500001,1))
|
|
|
|
ipo.append((1,1))
|
2005-12-15 18:12:49 +00:00
|
|
|
ipo.recalc()
|
|
|
|
|
|
|
|
if type == SHAPE2_EXCLUSIVE:
|
|
|
|
ctrl.protectFlags = int("111111011",2)
|
|
|
|
ipo = verifyIpocurve(ky,shapes[0].val)
|
|
|
|
ipo.driver = 1
|
|
|
|
ipo.driverObject = ctrl
|
|
|
|
ipo.driverChannel = IpoCurve.LOC_Z
|
|
|
|
ipo.recalc()
|
|
|
|
delCurve(ipo)
|
2006-12-25 09:17:23 +00:00
|
|
|
ipo.append((0,0))
|
|
|
|
ipo.append((1,1))
|
2005-12-15 18:12:49 +00:00
|
|
|
ipo.recalc()
|
|
|
|
|
|
|
|
ipo2 = verifyIpocurve(ky,shapes[1].val)
|
|
|
|
ipo2.driver = 1
|
|
|
|
ipo2.driverObject = ctrl
|
|
|
|
ipo2.driverChannel = IpoCurve.LOC_Z
|
|
|
|
ipo2.recalc()
|
|
|
|
delCurve(ipo2)
|
2006-12-25 09:17:23 +00:00
|
|
|
ipo2.append((-1,1))
|
|
|
|
ipo2.append((0,0))
|
2005-12-15 18:12:49 +00:00
|
|
|
ipo2.recalc()
|
|
|
|
|
|
|
|
if type == SHAPE2_T:
|
|
|
|
ctrl.protectFlags = int("111111010",2)
|
|
|
|
ipo = verifyIpocurve(ky,shapes[0].val)
|
|
|
|
ipo.driver = 1
|
|
|
|
ipo.driverObject = ctrl
|
|
|
|
ipo.driverChannel = IpoCurve.LOC_Z
|
|
|
|
ipo.recalc()
|
|
|
|
delCurve(ipo)
|
2006-12-25 09:17:23 +00:00
|
|
|
ipo.append((-1,-1))
|
|
|
|
ipo.append((0,0))
|
2005-12-15 18:12:49 +00:00
|
|
|
ipo.recalc()
|
|
|
|
|
|
|
|
ipo2 = verifyIpocurve(ky,shapes[1].val)
|
|
|
|
ipo2.driver = 1
|
|
|
|
ipo2.driverObject = ctrl
|
|
|
|
ipo2.driverChannel = IpoCurve.LOC_X
|
|
|
|
ipo2.recalc()
|
|
|
|
delCurve(ipo2)
|
2006-12-25 09:17:23 +00:00
|
|
|
ipo2.append((-1,-1))
|
|
|
|
ipo2.append((1,1))
|
2005-12-15 18:12:49 +00:00
|
|
|
ipo2.recalc()
|
|
|
|
|
|
|
|
if type == SHAPE2_INVT:
|
|
|
|
ctrl.protectFlags = int("111111010",2)
|
|
|
|
ipo = verifyIpocurve(ky,shapes[0].val)
|
|
|
|
ipo.driver = 1
|
|
|
|
ipo.driverObject = ctrl
|
|
|
|
ipo.driverChannel = IpoCurve.LOC_Z
|
|
|
|
ipo.recalc()
|
|
|
|
delCurve(ipo)
|
2006-12-25 09:17:23 +00:00
|
|
|
ipo.append((0,0))
|
|
|
|
ipo.append((1,1))
|
2005-12-15 18:12:49 +00:00
|
|
|
ipo.recalc()
|
|
|
|
|
|
|
|
ipo2 = verifyIpocurve(ky,shapes[1].val)
|
|
|
|
ipo2.driver = 1
|
|
|
|
ipo2.driverObject = ctrl
|
|
|
|
ipo2.driverChannel = IpoCurve.LOC_X
|
|
|
|
ipo2.recalc()
|
|
|
|
delCurve(ipo2)
|
2006-12-25 09:17:23 +00:00
|
|
|
ipo2.append((-1,-1))
|
|
|
|
ipo2.append((1,1))
|
2005-12-15 18:12:49 +00:00
|
|
|
ipo2.recalc()
|
|
|
|
|
|
|
|
if type == SHAPE2_PLUS:
|
|
|
|
ctrl.protectFlags = int("111111010",2)
|
|
|
|
ipo = verifyIpocurve(ky,shapes[0].val)
|
|
|
|
ipo.driver = 1
|
|
|
|
ipo.driverObject = ctrl
|
|
|
|
ipo.driverChannel = IpoCurve.LOC_Z
|
|
|
|
ipo.recalc()
|
|
|
|
delCurve(ipo)
|
2006-12-25 09:17:23 +00:00
|
|
|
ipo.append((-1,-1))
|
|
|
|
ipo.append((1,1))
|
2005-12-15 18:12:49 +00:00
|
|
|
ipo.recalc()
|
|
|
|
|
|
|
|
ipo2 = verifyIpocurve(ky,shapes[1].val)
|
|
|
|
ipo2.driver = 1
|
|
|
|
ipo2.driverObject = ctrl
|
|
|
|
ipo2.driverChannel = IpoCurve.LOC_X
|
|
|
|
ipo2.recalc()
|
|
|
|
delCurve(ipo2)
|
2006-12-25 09:17:23 +00:00
|
|
|
ipo2.append((-1,-1))
|
|
|
|
ipo2.append((1,1))
|
2005-12-15 18:12:49 +00:00
|
|
|
ipo2.recalc()
|
|
|
|
|
|
|
|
if type == SHAPE2_V: # 2 Shape Mix
|
|
|
|
ctrl.protectFlags = int("111111010",2)
|
|
|
|
ipo = verifyIpocurve(ky,shapes[0].val)
|
|
|
|
ipo.driver = 1
|
|
|
|
ipo.driverObject = ctrl
|
|
|
|
ipo.driverChannel = IpoCurve.LOC_Z
|
|
|
|
delCurve(ipo)
|
2006-12-25 09:17:23 +00:00
|
|
|
ipo.append((0,0))
|
|
|
|
ipo.append((1,1))
|
2005-12-15 18:12:49 +00:00
|
|
|
ipo.recalc()
|
|
|
|
|
|
|
|
ipo2 = verifyIpocurve(ky,shapes[1].val)
|
|
|
|
ipo2.driver = 1
|
|
|
|
ipo2.driverObject = ctrl
|
|
|
|
ipo2.driverChannel = IpoCurve.LOC_X
|
|
|
|
delCurve(ipo2)
|
2006-12-25 09:17:23 +00:00
|
|
|
ipo2.append((0,0))
|
|
|
|
ipo2.append((1,1))
|
2005-12-15 18:12:49 +00:00
|
|
|
ipo2.recalc()
|
|
|
|
|
|
|
|
|
|
|
|
if type == SHAPE3_INVT:
|
|
|
|
ctrl.protectFlags = int("111111010",2)
|
|
|
|
ipo = verifyIpocurve(ky,shapes[0].val)
|
|
|
|
ipo.driver = 1
|
|
|
|
ipo.driverObject = ctrl
|
|
|
|
ipo.driverChannel = IpoCurve.LOC_Z
|
|
|
|
ipo.recalc()
|
|
|
|
delCurve(ipo)
|
2006-12-25 09:17:23 +00:00
|
|
|
ipo.append((0,0))
|
|
|
|
ipo.append((1,1))
|
2005-12-15 18:12:49 +00:00
|
|
|
ipo.recalc()
|
|
|
|
|
|
|
|
ipo2 = verifyIpocurve(ky,shapes[1].val)
|
|
|
|
ipo2.driver = 1
|
|
|
|
ipo2.driverObject = ctrl
|
|
|
|
ipo2.driverChannel = IpoCurve.LOC_X
|
|
|
|
ipo2.recalc()
|
|
|
|
delCurve(ipo2)
|
2006-12-25 09:17:23 +00:00
|
|
|
ipo2.append((-1,1))
|
|
|
|
ipo2.append((0,0))
|
2005-12-15 18:12:49 +00:00
|
|
|
ipo2.recalc()
|
|
|
|
|
|
|
|
ipo2 = verifyIpocurve(ky,shapes[2].val)
|
|
|
|
ipo2.driver = 1
|
|
|
|
ipo2.driverObject = ctrl
|
|
|
|
ipo2.driverChannel = IpoCurve.LOC_X
|
|
|
|
ipo2.recalc()
|
|
|
|
delCurve(ipo2)
|
2006-12-25 09:17:23 +00:00
|
|
|
ipo2.append((0,0))
|
|
|
|
ipo2.append((1,1))
|
2005-12-15 18:12:49 +00:00
|
|
|
ipo2.recalc()
|
|
|
|
|
|
|
|
if type == SHAPE3_T:
|
|
|
|
ctrl.protectFlags = int("111111010",2)
|
|
|
|
ipo = verifyIpocurve(ky,shapes[0].val)
|
|
|
|
ipo.driver = 1
|
|
|
|
ipo.driverObject = ctrl
|
|
|
|
ipo.driverChannel = IpoCurve.LOC_Z
|
|
|
|
ipo.recalc()
|
|
|
|
delCurve(ipo)
|
2006-12-25 09:17:23 +00:00
|
|
|
ipo.append((-1,-1))
|
|
|
|
ipo.append((0,0))
|
2005-12-15 18:12:49 +00:00
|
|
|
ipo.recalc()
|
|
|
|
|
|
|
|
ipo2 = verifyIpocurve(ky,shapes[1].val)
|
|
|
|
ipo2.driver = 1
|
|
|
|
ipo2.driverObject = ctrl
|
|
|
|
ipo2.driverChannel = IpoCurve.LOC_X
|
|
|
|
ipo2.recalc()
|
|
|
|
delCurve(ipo2)
|
2006-12-25 09:17:23 +00:00
|
|
|
ipo2.append((-1,1))
|
|
|
|
ipo2.append((0,0))
|
2005-12-15 18:12:49 +00:00
|
|
|
ipo2.recalc()
|
|
|
|
|
|
|
|
ipo2 = verifyIpocurve(ky,shapes[2].val)
|
|
|
|
ipo2.driver = 1
|
|
|
|
ipo2.driverObject = ctrl
|
|
|
|
ipo2.driverChannel = IpoCurve.LOC_X
|
|
|
|
ipo2.recalc()
|
|
|
|
delCurve(ipo2)
|
2006-12-25 09:17:23 +00:00
|
|
|
ipo2.append((0,0))
|
|
|
|
ipo2.append((1,1))
|
2005-12-15 18:12:49 +00:00
|
|
|
ipo2.recalc()
|
|
|
|
|
|
|
|
if type == SHAPE4_X:
|
|
|
|
ctrl.protectFlags = int("111111010",2)
|
|
|
|
ipo = verifyIpocurve(ky,shapes[0].val)
|
|
|
|
ipo.driver = 1
|
|
|
|
ipo.driverObject = ctrl
|
|
|
|
ipo.driverChannel = IpoCurve.LOC_Z
|
|
|
|
delCurve(ipo)
|
2007-03-26 19:44:44 +00:00
|
|
|
ipo.append((0,0))
|
|
|
|
ipo.append((1,1))
|
2005-12-15 18:12:49 +00:00
|
|
|
ipo.recalc()
|
|
|
|
|
|
|
|
ipo2 = verifyIpocurve(ky,shapes[1].val)
|
|
|
|
ipo2.driver = 1
|
|
|
|
ipo2.driverObject = ctrl
|
|
|
|
ipo2.driverChannel = IpoCurve.LOC_X
|
|
|
|
delCurve(ipo2)
|
2007-03-26 19:44:44 +00:00
|
|
|
ipo2.append((0,0))
|
|
|
|
ipo2.append((1,1))
|
2005-12-15 18:12:49 +00:00
|
|
|
ipo2.recalc()
|
|
|
|
|
|
|
|
ipo3 = verifyIpocurve(ky,shapes[2].val)
|
|
|
|
ipo3.driver = 1
|
|
|
|
ipo3.driverObject = ctrl
|
|
|
|
ipo3.driverChannel = IpoCurve.LOC_X
|
|
|
|
delCurve(ipo3)
|
2007-03-26 19:44:44 +00:00
|
|
|
ipo3.append((-1,1))
|
2006-12-25 09:17:23 +00:00
|
|
|
ipo3.append((0,0))
|
2005-12-15 18:12:49 +00:00
|
|
|
ipo3.recalc()
|
|
|
|
|
|
|
|
ipo4 = verifyIpocurve(ky,shapes[3].val)
|
|
|
|
ipo4.driver = 1
|
|
|
|
ipo4.driverObject = ctrl
|
|
|
|
ipo4.driverChannel = IpoCurve.LOC_Z
|
|
|
|
delCurve(ipo4)
|
2006-12-25 09:17:23 +00:00
|
|
|
ipo4.append((-1,1))
|
|
|
|
ipo4.append((0,0))
|
2005-12-15 18:12:49 +00:00
|
|
|
ipo4.recalc()
|
|
|
|
|
|
|
|
#The Main Call to Build the Widget
|
|
|
|
|
|
|
|
def build(type):
|
|
|
|
global shapes,widmenu,rangename
|
2007-04-18 14:40:01 +00:00
|
|
|
sce = bpy.data.scenes.active
|
2006-12-12 08:05:08 +00:00
|
|
|
ob = sce.objects.active
|
|
|
|
|
|
|
|
try:
|
|
|
|
ob.getData(mesh=1).key
|
|
|
|
except:
|
|
|
|
Blender.Draw.PupMenu('Aborting%t|Object has no keys')
|
|
|
|
return
|
|
|
|
|
2005-12-15 18:12:49 +00:00
|
|
|
loc = Window.GetCursorPos()
|
2007-03-26 19:44:44 +00:00
|
|
|
range = makeRange(sce, type,rangename.val)
|
|
|
|
controller = makeController(sce, rangename.val)
|
|
|
|
text = makeText(sce, rangename.val)
|
2005-12-15 18:12:49 +00:00
|
|
|
|
2006-12-12 08:05:08 +00:00
|
|
|
range.restrictRender = True
|
|
|
|
controller.restrictRender = True
|
|
|
|
text.restrictRender = True
|
|
|
|
|
2005-12-15 18:12:49 +00:00
|
|
|
range.setLocation(loc)
|
|
|
|
controller.setLocation(loc)
|
|
|
|
text.setLocation(loc)
|
|
|
|
|
|
|
|
range.makeParent([controller],1)
|
|
|
|
range.makeParent([text],0)
|
|
|
|
|
|
|
|
sce.update()
|
2006-12-12 08:05:08 +00:00
|
|
|
|
2005-12-15 18:12:49 +00:00
|
|
|
setupDrivers(ob,controller,widmenu.val)
|
|
|
|
|
|
|
|
#Create the text
|
|
|
|
|
2007-03-26 19:44:44 +00:00
|
|
|
def makeText(sce, name):
|
2007-04-18 14:40:01 +00:00
|
|
|
txt = bpy.data.curves.new(name+'.name', 'Text3d')
|
2007-03-26 19:44:44 +00:00
|
|
|
|
2005-12-15 18:12:49 +00:00
|
|
|
txt.setDrawMode(Text3d.DRAW3D)
|
|
|
|
txt.setAlignment(Text3d.MIDDLE)
|
|
|
|
txt.setText(name)
|
2007-03-26 19:44:44 +00:00
|
|
|
ob = sce.objects.new(txt)
|
2007-02-28 22:49:20 +00:00
|
|
|
ob.setEuler((3.14159/2,0,0))
|
2005-12-15 18:12:49 +00:00
|
|
|
return ob
|
|
|
|
|
|
|
|
|
|
|
|
#Create the mesh controller
|
|
|
|
|
2007-03-26 19:44:44 +00:00
|
|
|
def makeController(sce, name):
|
2007-04-18 14:40:01 +00:00
|
|
|
me = bpy.data.meshes.new(name+".ctrl")
|
2007-03-26 19:44:44 +00:00
|
|
|
ob = sce.objects.new(me)
|
|
|
|
me.verts.extend([\
|
|
|
|
(-0.15,0, 0),\
|
|
|
|
( 0,0, 0.15),\
|
|
|
|
( 0.15,0, 0),\
|
|
|
|
( 0,0,-0.15)])
|
|
|
|
|
|
|
|
me.edges.extend([(0,1,2,3)])
|
2005-12-15 18:12:49 +00:00
|
|
|
return ob
|
|
|
|
|
|
|
|
#Create the mesh range
|
|
|
|
|
2007-03-26 19:44:44 +00:00
|
|
|
def makeRange(sce,type,name):
|
2005-12-15 18:12:49 +00:00
|
|
|
#ob.setDrawMode(8) # Draw Name
|
2007-04-18 14:40:01 +00:00
|
|
|
me = bpy.data.meshes.new(name)
|
2007-03-26 19:44:44 +00:00
|
|
|
ob = sce.objects.new(me)
|
2005-12-15 18:12:49 +00:00
|
|
|
|
|
|
|
if type == SHAPE1_ONE_ZERO:
|
2007-03-26 19:44:44 +00:00
|
|
|
me.verts.extend([\
|
|
|
|
(-0.15,0,0),\
|
|
|
|
( 0.15,0,0),\
|
|
|
|
(-0.15,0,1),\
|
|
|
|
( 0.15,0,1),\
|
|
|
|
(-0.25,0,.1),\
|
|
|
|
(-0.25,0,-.10),\
|
|
|
|
(0.25,0,.1),\
|
|
|
|
(0.25,0,-0.10)])
|
|
|
|
|
|
|
|
me.edges.extend([(0,1,3,2),(4,5,0),(6,7,1)])
|
2005-12-15 18:12:49 +00:00
|
|
|
|
|
|
|
elif type == SHAPE1_TOGGLE:
|
2007-03-26 19:44:44 +00:00
|
|
|
me.verts.extend([\
|
|
|
|
(-0.15,0,-0.5),\
|
|
|
|
( 0.15,0,-0.5),\
|
|
|
|
( 0.15,0, 0.5),\
|
|
|
|
(-0.15,0, 0.5),\
|
|
|
|
(-0.15,0, 1.5),\
|
|
|
|
( 0.15,0, 1.5)])
|
|
|
|
|
|
|
|
me.edges.extend([(0,1,2,3),(3,4,5,2)])
|
2005-12-15 18:12:49 +00:00
|
|
|
|
|
|
|
elif type == SHAPE1_ZERO_MONE:
|
2007-03-26 19:44:44 +00:00
|
|
|
me.verts.extend([\
|
|
|
|
(-0.15,0,0),\
|
|
|
|
( 0.15,0,0),\
|
|
|
|
(-0.15,0,-1),\
|
|
|
|
( 0.15,0,-1),\
|
|
|
|
(-0.25,0,.1),\
|
|
|
|
(-0.25,0,-.10),\
|
|
|
|
(0.25,0,.1),\
|
|
|
|
(0.25,0,-0.10)])
|
|
|
|
|
|
|
|
me.edges.extend([(0,1,3,2),(4,5,0),(6,7,1)])
|
2005-12-15 18:12:49 +00:00
|
|
|
|
|
|
|
elif type in [SHAPE1_ONE_MONE,SHAPE2_EXCLUSIVE]:
|
2007-03-26 19:44:44 +00:00
|
|
|
me.verts.extend([\
|
|
|
|
(-0.15,0,-1),\
|
|
|
|
( 0.15,0,-1),\
|
|
|
|
(-0.15,0,1),\
|
|
|
|
( 0.15,0,1),\
|
|
|
|
(-0.25,0,.1),\
|
|
|
|
(-0.25,0,-.10),\
|
|
|
|
(0.25,0,.1),\
|
|
|
|
(0.25,0,-0.10),\
|
|
|
|
(-0.15,0,0),\
|
|
|
|
( 0.15,0,0)])
|
2005-12-15 18:12:49 +00:00
|
|
|
|
2007-03-26 19:44:44 +00:00
|
|
|
l = [(0,1,3,2),(4,5,8),(6,7,9)]
|
2005-12-15 18:12:49 +00:00
|
|
|
me.edges.extend(l)
|
|
|
|
|
|
|
|
elif type == SHAPE2_T:
|
2007-03-26 19:44:44 +00:00
|
|
|
me.verts.extend([\
|
|
|
|
(-1,0,0),\
|
|
|
|
( 1,0,0),\
|
|
|
|
( 1,0,-1),\
|
|
|
|
(-1,0,-1)])
|
2005-12-15 18:12:49 +00:00
|
|
|
|
2007-03-26 19:44:44 +00:00
|
|
|
me.edges.extend([(0,1,2,3)])
|
2005-12-15 18:12:49 +00:00
|
|
|
|
|
|
|
elif type == SHAPE2_INVT:
|
2007-03-26 19:44:44 +00:00
|
|
|
me.verts.extend([\
|
|
|
|
(-1,0,0),\
|
|
|
|
( 1,0,0),\
|
|
|
|
( 1,0,1),\
|
|
|
|
(-1,0,1)])
|
2005-12-15 18:12:49 +00:00
|
|
|
|
2007-03-26 19:44:44 +00:00
|
|
|
me.edges.extend([(0,1,2,3)])
|
2005-12-15 18:12:49 +00:00
|
|
|
|
|
|
|
elif type == SHAPE2_PLUS:
|
2007-03-26 19:44:44 +00:00
|
|
|
me.verts.extend([\
|
|
|
|
(-1,0,-1),\
|
|
|
|
( 1,0,-1),\
|
|
|
|
( 1,0,1),\
|
|
|
|
(-1,0,1)])
|
|
|
|
me.edges.extend([(0,1,2,3)])
|
2005-12-15 18:12:49 +00:00
|
|
|
|
|
|
|
elif type == SHAPE2_V:
|
2007-03-26 19:44:44 +00:00
|
|
|
me.verts.extend([\
|
|
|
|
(0,0,0),\
|
|
|
|
(1,0,0),\
|
|
|
|
(1,0,1),\
|
|
|
|
(0,0,1)])
|
|
|
|
|
|
|
|
me.edges.extend([(0,1,2,3)])
|
2007-02-28 22:49:20 +00:00
|
|
|
ob.setEuler((0,-0.78539,0))
|
2005-12-15 18:12:49 +00:00
|
|
|
|
|
|
|
elif type == SHAPE3_INVT:
|
2007-03-26 19:44:44 +00:00
|
|
|
me.verts.extend([\
|
|
|
|
(-1,0,0),\
|
|
|
|
( 1,0,0),\
|
|
|
|
( 1,0,1),\
|
|
|
|
(-1,0,1)])
|
2005-12-15 18:12:49 +00:00
|
|
|
|
2007-03-26 19:44:44 +00:00
|
|
|
me.edges.extend([(0,1,2,3)])
|
2005-12-15 18:12:49 +00:00
|
|
|
|
|
|
|
elif type == SHAPE3_T:
|
2007-03-26 19:44:44 +00:00
|
|
|
me.verts.extend([\
|
|
|
|
(-1,0,0),\
|
|
|
|
( 1,0,0),\
|
|
|
|
( 1,0,-1),\
|
|
|
|
(-1,0,-1)])
|
2005-12-15 18:12:49 +00:00
|
|
|
|
2007-03-26 19:44:44 +00:00
|
|
|
me.edges.extend([(0,1,2,3)])
|
2005-12-15 18:12:49 +00:00
|
|
|
|
2007-03-26 19:44:44 +00:00
|
|
|
|
2005-12-15 18:12:49 +00:00
|
|
|
elif type == SHAPE4_X:
|
2007-03-26 19:44:44 +00:00
|
|
|
me.verts.extend([\
|
|
|
|
(0,0,-1),\
|
|
|
|
(1,0,-1),\
|
|
|
|
(1,0,0),\
|
|
|
|
(1,0,1),\
|
|
|
|
(0,0,1),\
|
|
|
|
(-1,0,1),\
|
|
|
|
(-1,0,0),\
|
|
|
|
(-1,0,-1)])
|
|
|
|
|
|
|
|
me.edges.extend([(0,1),(1,2),(2,3),(3,4),(4,5),(5,6),(6,7),(7,0)])
|
2007-02-28 22:49:20 +00:00
|
|
|
ob.setEuler((0,-0.78539,0))
|
2005-12-15 18:12:49 +00:00
|
|
|
|
|
|
|
return ob
|
|
|
|
|
|
|
|
|
|
|
|
def create():
|
|
|
|
main()
|
|
|
|
|
|
|
|
####################### gui ######################
|
|
|
|
|
|
|
|
|
|
|
|
EVENT_NONE = 1
|
|
|
|
EVENT_EXIT = 100
|
|
|
|
EVENT_WIDGET_MENU = 101
|
|
|
|
EVENT_NEXT = 102
|
|
|
|
EVENT_BACK = 103
|
|
|
|
|
|
|
|
#get the list of shapes from the selected object
|
|
|
|
|
|
|
|
def shapeMenuText():
|
2007-04-18 14:40:01 +00:00
|
|
|
ob = bpy.data.scenes.active.objects.active
|
2006-12-12 08:05:08 +00:00
|
|
|
if not ob:
|
2005-12-15 18:12:49 +00:00
|
|
|
return ""
|
2006-12-12 08:05:08 +00:00
|
|
|
|
|
|
|
me = ob.getData(mesh=1)
|
|
|
|
try: key= me.key
|
|
|
|
except: key = None
|
|
|
|
|
2005-12-15 18:12:49 +00:00
|
|
|
if key == None:
|
2006-12-12 08:05:08 +00:00
|
|
|
return ""
|
|
|
|
|
2006-12-26 01:45:58 +00:00
|
|
|
blocks = key.blocks
|
2005-12-15 18:12:49 +00:00
|
|
|
menu = "Choose Shape %t|"
|
2006-12-26 01:45:58 +00:00
|
|
|
for i, block in enumerate(blocks):
|
2007-02-28 22:49:20 +00:00
|
|
|
menu = menu + block.name + " %x" + str(i) + "|"
|
2006-12-26 01:45:58 +00:00
|
|
|
return menu
|
2005-12-15 18:12:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
#draw the widget for the gui
|
|
|
|
|
|
|
|
def drawWidget(type):
|
2007-03-27 11:37:54 +00:00
|
|
|
glColor3f(0.0,0.0,0.0)
|
2005-12-15 18:12:49 +00:00
|
|
|
global shapes
|
|
|
|
if type == SHAPE1_ONE_MONE:# 1 to -1 Single Shape
|
|
|
|
glBegin(GL_LINE_STRIP)
|
|
|
|
glVertex2i(150,50)
|
|
|
|
glVertex2i(170,50)
|
|
|
|
glVertex2i(170,150)
|
|
|
|
glVertex2i(150,150)
|
|
|
|
glVertex2i(150,50)
|
|
|
|
glEnd()
|
|
|
|
glBegin(GL_LINE_STRIP)
|
|
|
|
glVertex2i(140,100)
|
|
|
|
glVertex2i(190,100)
|
|
|
|
glEnd()
|
|
|
|
glRasterPos2d(180,140)
|
|
|
|
Text("1","normal")
|
|
|
|
glRasterPos2d(180,60)
|
|
|
|
Text("-1","normal")
|
|
|
|
shapes[0] = Menu(shapeMenuText(), EVENT_NONE, 190, 100, 100, 18, shapes[0].val, "Choose Shape.")
|
|
|
|
elif type == SHAPE1_TOGGLE:# Toggle Single Shape
|
|
|
|
glBegin(GL_LINE_STRIP)
|
|
|
|
glVertex2i(150,50)
|
|
|
|
glVertex2i(170,50)
|
|
|
|
glVertex2i(170,100)
|
|
|
|
glVertex2i(150,100)
|
|
|
|
glVertex2i(150,50)
|
|
|
|
glEnd()
|
|
|
|
glBegin(GL_LINE_STRIP)
|
|
|
|
glVertex2i(170,100)
|
|
|
|
glVertex2i(170,150)
|
|
|
|
glVertex2i(150,150)
|
|
|
|
glVertex2i(150,100)
|
|
|
|
glEnd()
|
|
|
|
glRasterPos2d(180,140)
|
|
|
|
Text("On","normal")
|
|
|
|
glRasterPos2d(180,60)
|
|
|
|
Text("Off","normal")
|
|
|
|
shapes[0] = Menu(shapeMenuText(), EVENT_NONE, 190, 100, 100, 18, shapes[0].val, "Choose Shape.")
|
|
|
|
elif type == SHAPE1_ONE_ZERO: # 1 to 0 Single Shape
|
|
|
|
glBegin(GL_LINE_STRIP)
|
|
|
|
glVertex2i(150,50)
|
|
|
|
glVertex2i(170,50)
|
|
|
|
glVertex2i(170,150)
|
|
|
|
glVertex2i(150,150)
|
|
|
|
glVertex2i(150,50)
|
|
|
|
glEnd()
|
|
|
|
glBegin(GL_LINE_STRIP)
|
|
|
|
glVertex2i(140,50)
|
|
|
|
glVertex2i(190,50)
|
|
|
|
glEnd()
|
|
|
|
glRasterPos2d(180,140)
|
|
|
|
Text("1","normal")
|
|
|
|
glRasterPos2d(180,60)
|
|
|
|
Text("0","normal")
|
|
|
|
shapes[0] = Menu(shapeMenuText(), EVENT_NONE, 190, 100, 100, 18, shapes[0].val, "Choose Shape.")
|
|
|
|
elif type == SHAPE1_ZERO_MONE:
|
|
|
|
glBegin(GL_LINE_STRIP)
|
|
|
|
glVertex2i(150,50)
|
|
|
|
glVertex2i(170,50)
|
|
|
|
glVertex2i(170,150)
|
|
|
|
glVertex2i(150,150)
|
|
|
|
glVertex2i(150,50)
|
|
|
|
glEnd()
|
|
|
|
glBegin(GL_LINE_STRIP)
|
|
|
|
glVertex2i(140,150)
|
|
|
|
glVertex2i(190,150)
|
|
|
|
glEnd()
|
|
|
|
glRasterPos2d(180,140)
|
|
|
|
Text("0","normal")
|
|
|
|
glRasterPos2d(180,60)
|
|
|
|
Text("-1","normal")
|
|
|
|
shapes[0] = Menu(shapeMenuText(), EVENT_NONE, 190, 100, 100, 18, shapes[0].val, "Choose Shape.")
|
|
|
|
elif type == SHAPE2_EXCLUSIVE:
|
|
|
|
glBegin(GL_LINE_STRIP)
|
|
|
|
glVertex2i(150,50)
|
|
|
|
glVertex2i(170,50)
|
|
|
|
glVertex2i(170,150)
|
|
|
|
glVertex2i(150,150)
|
|
|
|
glVertex2i(150,50)
|
|
|
|
glEnd()
|
|
|
|
glBegin(GL_LINE_STRIP)
|
|
|
|
glVertex2i(140,100)
|
|
|
|
glVertex2i(190,100)
|
|
|
|
glEnd()
|
|
|
|
glRasterPos2d(180,140)
|
|
|
|
Text("1","normal")
|
|
|
|
glRasterPos2d(180,60)
|
|
|
|
Text("1","normal")
|
|
|
|
shapes[0] = Menu(shapeMenuText(), EVENT_NONE, 195, 135, 100, 18, shapes[0].val, "Choose Shape 1.")
|
|
|
|
shapes[1] = Menu(shapeMenuText(), EVENT_NONE, 195, 52, 100, 18, shapes[1].val, "Choose Shape 2.")
|
|
|
|
elif type == SHAPE2_T:
|
|
|
|
glBegin(GL_LINE_STRIP)
|
|
|
|
glVertex2i(150,75)
|
|
|
|
glVertex2i(250,75)
|
|
|
|
glVertex2i(250,125)
|
|
|
|
glVertex2i(150,125)
|
|
|
|
glVertex2i(150,75)
|
|
|
|
glEnd()
|
|
|
|
glBegin(GL_LINE_STRIP)
|
|
|
|
glVertex2i(140,125)
|
|
|
|
glVertex2i(260,125)
|
|
|
|
glEnd()
|
|
|
|
glRasterPos2d(200,140)
|
|
|
|
Text("0","normal")
|
|
|
|
glRasterPos2d(200,60)
|
|
|
|
Text("-1","normal")
|
|
|
|
glRasterPos2d(250,140)
|
|
|
|
Text("1","normal")
|
|
|
|
glRasterPos2d(150,140)
|
|
|
|
Text("-1","normal")
|
|
|
|
shapes[0] = Menu(shapeMenuText(), EVENT_NONE, 220, 52, 100, 18, shapes[0].val, "Choose Shape 1.")
|
|
|
|
shapes[1] = Menu(shapeMenuText(), EVENT_NONE, 260, 135, 100, 18, shapes[1].val, "Choose Shape 2.")
|
|
|
|
elif type == SHAPE2_INVT:
|
|
|
|
glBegin(GL_LINE_STRIP)
|
|
|
|
glVertex2i(150,75)
|
|
|
|
glVertex2i(250,75)
|
|
|
|
glVertex2i(250,125)
|
|
|
|
glVertex2i(150,125)
|
|
|
|
glVertex2i(150,75)
|
|
|
|
glEnd()
|
|
|
|
glBegin(GL_LINE_STRIP)
|
|
|
|
glVertex2i(140,75)
|
|
|
|
glVertex2i(260,75)
|
|
|
|
glEnd()
|
|
|
|
glRasterPos2d(200,60)
|
|
|
|
Text("0","normal")
|
|
|
|
glRasterPos2d(200,140)
|
|
|
|
Text("1","normal")
|
|
|
|
glRasterPos2d(250,60)
|
|
|
|
Text("1","normal")
|
|
|
|
glRasterPos2d(150,60)
|
|
|
|
Text("-1","normal")
|
|
|
|
shapes[0] = Menu(shapeMenuText(), EVENT_NONE, 220, 135, 100, 18, shapes[0].val, "Choose Shape 1.")
|
|
|
|
shapes[1] = Menu(shapeMenuText(), EVENT_NONE, 260, 52, 100, 18, shapes[1].val, "Choose Shape 2.")
|
|
|
|
elif type == SHAPE2_PLUS:
|
|
|
|
glBegin(GL_LINE_STRIP)
|
|
|
|
glVertex2i(150,50)
|
|
|
|
glVertex2i(250,50)
|
|
|
|
glVertex2i(250,150)
|
|
|
|
glVertex2i(150,150)
|
|
|
|
glVertex2i(150,50)
|
|
|
|
glEnd()
|
|
|
|
glBegin(GL_LINE_STRIP)
|
|
|
|
glVertex2i(140,100)
|
|
|
|
glVertex2i(260,100)
|
|
|
|
glEnd()
|
|
|
|
glRasterPos2d(200,105)
|
|
|
|
Text("0","normal")
|
|
|
|
glRasterPos2d(200,140)
|
|
|
|
Text("1","normal")
|
|
|
|
glRasterPos2d(200,55)
|
|
|
|
Text("-1","normal")
|
|
|
|
glRasterPos2d(250,105)
|
|
|
|
Text("1","normal")
|
|
|
|
glRasterPos2d(150,105)
|
|
|
|
Text("-1","normal")
|
|
|
|
shapes[0] = Menu(shapeMenuText(), EVENT_NONE, 220, 155, 100, 18, shapes[0].val, "Choose Shape 1.")
|
|
|
|
shapes[1] = Menu(shapeMenuText(), EVENT_NONE, 260, 100, 100, 18, shapes[1].val, "Choose Shape 2.")
|
|
|
|
elif type == SHAPE2_V:
|
|
|
|
glBegin(GL_LINE_STRIP)
|
|
|
|
glVertex2i(150,70)
|
|
|
|
glVertex2i(185,105)
|
|
|
|
glVertex2i(150,141)
|
|
|
|
glVertex2i(115,105)
|
|
|
|
glVertex2i(150,70)
|
|
|
|
glEnd()
|
|
|
|
glRasterPos2d(110,105)
|
|
|
|
Text("1","normal")
|
|
|
|
glRasterPos2d(190,105)
|
|
|
|
Text("1","normal")
|
|
|
|
glRasterPos2d(150,80)
|
|
|
|
Text("0","normal")
|
|
|
|
shapes[0] = Menu(shapeMenuText(), EVENT_NONE, 20, 125, 100, 18, shapes[0].val, "Choose Shape 1.")
|
|
|
|
shapes[1] = Menu(shapeMenuText(), EVENT_NONE, 195, 125, 100, 18, shapes[1].val, "Choose Shape 2.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif type == SHAPE3_T:
|
|
|
|
glBegin(GL_LINE_STRIP)
|
|
|
|
glVertex2i(150,75)
|
|
|
|
glVertex2i(250,75)
|
|
|
|
glVertex2i(250,125)
|
|
|
|
glVertex2i(150,125)
|
|
|
|
glVertex2i(150,75)
|
|
|
|
glEnd()
|
|
|
|
glBegin(GL_LINE_STRIP)
|
|
|
|
glVertex2i(140,125)
|
|
|
|
glVertex2i(260,125)
|
|
|
|
glEnd()
|
|
|
|
glRasterPos2d(200,140)
|
|
|
|
Text("0","normal")
|
|
|
|
glRasterPos2d(200,60)
|
|
|
|
Text("-1","normal")
|
|
|
|
glRasterPos2d(250,140)
|
|
|
|
Text("1","normal")
|
|
|
|
glRasterPos2d(150,140)
|
|
|
|
Text("1","normal")
|
|
|
|
shapes[0] = Menu(shapeMenuText(), EVENT_NONE, 220, 52, 100, 18, shapes[0].val, "Choose Shape 1.")
|
|
|
|
shapes[1] = Menu(shapeMenuText(), EVENT_NONE, 45, 135, 100, 18, shapes[1].val, "Choose Shape 2.")
|
|
|
|
shapes[2] = Menu(shapeMenuText(), EVENT_NONE, 260, 135, 100, 18, shapes[2].val, "Choose Shape 3.")
|
|
|
|
elif type == SHAPE3_INVT:
|
|
|
|
glBegin(GL_LINE_STRIP)
|
|
|
|
glVertex2i(150,75)
|
|
|
|
glVertex2i(250,75)
|
|
|
|
glVertex2i(250,125)
|
|
|
|
glVertex2i(150,125)
|
|
|
|
glVertex2i(150,75)
|
|
|
|
glEnd()
|
|
|
|
glBegin(GL_LINE_STRIP)
|
|
|
|
glVertex2i(140,75)
|
|
|
|
glVertex2i(260,75)
|
|
|
|
glEnd()
|
|
|
|
glRasterPos2d(200,60)
|
|
|
|
Text("0","normal")
|
|
|
|
glRasterPos2d(200,140)
|
|
|
|
Text("1","normal")
|
|
|
|
glRasterPos2d(250,60)
|
|
|
|
Text("1","normal")
|
|
|
|
glRasterPos2d(150,60)
|
|
|
|
Text("1","normal")
|
|
|
|
shapes[0] = Menu(shapeMenuText(), EVENT_NONE, 220, 135, 100, 18, shapes[0].val, "Choose Shape 1.")
|
|
|
|
shapes[1] = Menu(shapeMenuText(), EVENT_NONE, 45, 52, 100, 18, shapes[1].val, "Choose Shape 2.")
|
|
|
|
shapes[2] = Menu(shapeMenuText(), EVENT_NONE, 260, 52, 100, 18, shapes[2].val, "Choose Shape 3.")
|
|
|
|
|
|
|
|
|
|
|
|
elif type == SHAPE4_X:
|
|
|
|
glBegin(GL_LINE_STRIP)
|
|
|
|
glVertex2i(150,70)
|
|
|
|
glVertex2i(185,105)
|
|
|
|
glVertex2i(150,141)
|
|
|
|
glVertex2i(115,105)
|
|
|
|
glVertex2i(150,70)
|
|
|
|
glEnd()
|
|
|
|
glRasterPos2d(120,125)
|
|
|
|
Text("1","normal")
|
|
|
|
glRasterPos2d(180,125)
|
|
|
|
Text("1","normal")
|
|
|
|
glRasterPos2d(120,80)
|
|
|
|
Text("1","normal")
|
|
|
|
glRasterPos2d(180,80)
|
|
|
|
Text("1","normal")
|
|
|
|
|
|
|
|
glRasterPos2d(145,105)
|
|
|
|
Text("0","normal")
|
|
|
|
shapes[0] = Menu(shapeMenuText(), EVENT_NONE, 10, 125, 100, 18, shapes[0].val, "Choose Shape 1.")
|
|
|
|
shapes[1] = Menu(shapeMenuText(), EVENT_NONE, 195, 125, 100, 18, shapes[1].val, "Choose Shape 2.")
|
|
|
|
shapes[2] = Menu(shapeMenuText(), EVENT_NONE, 10, 60, 100, 18, shapes[2].val, "Choose Shape 3.")
|
|
|
|
shapes[3] = Menu(shapeMenuText(), EVENT_NONE, 195, 60, 100, 18, shapes[3].val, "Choose Shape 4.")
|
|
|
|
|
|
|
|
#the gui callback
|
|
|
|
|
|
|
|
def draw():
|
|
|
|
global widmenu,numshapes,stage,type, shapes,rangename
|
2007-03-27 11:37:54 +00:00
|
|
|
#glRasterPos2d(5,200)
|
|
|
|
#Text("Shape Widget Wizard","large")
|
|
|
|
Label("Shape Widget Wizard", 5,200, 200, 12)
|
|
|
|
|
2005-12-15 18:12:49 +00:00
|
|
|
PushButton("Quit", EVENT_EXIT, 5, 5, 50, 18)
|
|
|
|
|
|
|
|
if stage == 1:
|
|
|
|
name = "Choose Widget Type %t|\
|
|
|
|
1 Shape: 1 / -1 %x" +str(SHAPE1_ONE_MONE) +"|\
|
|
|
|
1 Shape: 1,0 %x" +str(SHAPE1_ONE_ZERO) +"|\
|
|
|
|
1 Shape: 0,-1 %x" +str(SHAPE1_ZERO_MONE)+"|\
|
|
|
|
1 Shape: Toggle %x" +str(SHAPE1_TOGGLE) +"|\
|
|
|
|
2 Shape Exclusive %x"+str(SHAPE2_EXCLUSIVE)+"|\
|
|
|
|
2 Shape - V %x" +str(SHAPE2_V) +"|\
|
|
|
|
2 Shape - T %x" +str(SHAPE2_T) +"|\
|
|
|
|
2 Shape - Inv T %x" +str(SHAPE2_INVT) +"|\
|
|
|
|
2 Shape - + %x" +str(SHAPE2_PLUS) +"|\
|
|
|
|
3 Shape - T %x" +str(SHAPE3_T) +"|\
|
|
|
|
3 Shape - Inv T%x" +str(SHAPE3_INVT) +"|\
|
|
|
|
4 Shape - Mix %x" +str(SHAPE4_X)
|
2006-12-23 00:56:40 +00:00
|
|
|
widmenu = Menu(name, EVENT_NONE, 5, 120, 200, 40, widmenu.val, "Choose Widget Type.")
|
2005-12-15 18:12:49 +00:00
|
|
|
PushButton("Next", EVENT_NEXT, 5, 25, 50, 18)
|
|
|
|
|
|
|
|
elif stage == 2:
|
|
|
|
glRasterPos2d(60,140)
|
|
|
|
rangename = String("Name: ", EVENT_NONE, 5, 170, 200, 18, rangename.val, 50, "Name for Range Object")
|
|
|
|
drawWidget(widmenu.val)
|
2006-12-23 00:56:40 +00:00
|
|
|
BeginAlign()
|
|
|
|
PushButton("Back", EVENT_BACK, 5, 25, 50, 18, "Choose another shape type")
|
|
|
|
PushButton("Finish", EVENT_NEXT, 55, 25, 50, 18, "Add Objects at the cursor location")
|
|
|
|
EndAlign()
|
2005-12-15 18:12:49 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def event(evt, val):
|
|
|
|
if (evt == QKEY and not val):
|
|
|
|
Exit()
|
|
|
|
|
|
|
|
|
|
|
|
def bevent(evt):
|
|
|
|
global widmenu,stage,drawtype
|
|
|
|
######### Manages GUI events
|
|
|
|
if evt==EVENT_EXIT:
|
|
|
|
Exit()
|
|
|
|
elif evt==EVENT_BACK:
|
|
|
|
if stage == 2:
|
|
|
|
stage = 1
|
|
|
|
Redraw()
|
|
|
|
elif evt==EVENT_NEXT:
|
|
|
|
if stage == 1:
|
|
|
|
stage = 2
|
|
|
|
Redraw()
|
|
|
|
elif stage == 2:
|
|
|
|
build(widmenu.val)
|
|
|
|
stage = 1
|
|
|
|
Window.RedrawAll()
|
|
|
|
|
|
|
|
|
|
|
|
Register(draw, event, bevent)
|