Beispiel #1
0
# test_blocks_plus_lines_slider1a.py
# Use simple lines, each with two points

from BlockW import *
bW = BlockW()

bW.add(bW.block, bW.loc(1, 2, 3), bW.size(1, 2, 3), bW.color(0, 0, 3))

bW.display()
print("End of test")
"""
lines_growing_cmds_100p_from_internal.py
Use simple lines, each with two points
Display from internal list
"""
import random
import time
from BlockW import *
bW = BlockW()

tdly = .1  # Time between displays
npoints = 100  # Number of points to display
points = []  # array of points to create/display
maxval = 4.  # Maximum (x,y,z) dimensional value
minval = -maxval  # Minimum (x,y,z) dimensional value
for i in range(npoints):
    xval = random.uniform(minval, maxval)
    yval = random.uniform(minval, maxval)
    zval = random.uniform(minval, maxval)
    points.append([xval, yval, zval])
"""
save commands for fast display
"""
for i in range(0, npoints - 1, 1):  # Loop over sub groups of all points
    pt1 = points[i]
    pt2 = points[i + 1]
    #    cmd = bW.add(bW.line, bW.color(0,1,0))
    cmd = bW.add(bW.line, bW.color(pt1[0], pt1[1], pt1[2]))
    cmd.addPoint(pt1[0], pt1[1], pt1[2])
    cmd.addPoint(pt2[0], pt2[1], pt2[2])
print("construct lines connecting {} points".format(i))
print("Args:")
for arg in parms:
    print(arg + " ")
print("")

trace = BwTrace("BlockWorld.properties")
##trace.setAccept(1)
##trace.setTokenAccept(1)
##trace.setTokQueue(1)
##trace.setAll()
##trace.clearAll()
##trace.setInput(1)
bExec = BwExec(trace)
parser = bExec.getParser()
# Jython BW script support
bW = BlockW(trace=trace, bExec=bExec)

graphicsFrame = javax.swing.JFrame("Graphics")
graphicsFrame.setVisible(True)  # Display the window.

nfile = 0  # Count files processed
i = 1  # Start with first arg
# Process flags -<...>
length = len(parms)
while i < length:
    arg = parms[i]
    i += 1
    match = re.match("^-{1,2}(.*)", arg)
    if not match:
        break  # No more flags
    opt = match.group(1)
Beispiel #4
0
#test_incl_2_1.py
print("In test_incl_2_1.py")
from BlockW import *
global bW
if 'bW' not in globals() or bW == None:
    is_incl = True
    bW = BlockW(tr="input,execute")

bW.add(bW.block, loc=(2,1,1), size=.2, color=(0,0,1))
bW.add(bW.block, loc=(2,1,2), size=.3, color=(0,0,1))
if 'is_incl' in locals():       # Only display if standalone
    bW.display()

# test_blocks_plus_lines_slider.py
# Use simple lines, each with two points

from BlockW import *
bW = BlockW()

bW.slider("winH", 0, 900, 2000)
bW.slider("winW", 0, 1400, 2000)
bW.add(bW.window, size=("winW", "winH"))
""" Still unrecognized bW.nop()
"""
bW.slider("lx", -20, 10, 20)
bW.slider("ly", -20, 10, 20)
bW.slider("lz", -20, 10, 20)
bW.add(bW.lookAtEye, loc=("lx", "ly", "lz"))

## Add focal point
bW.slider("px", -8, 0, 8)
bW.slider("py", -8, 1, 8)
bW.slider("pz", -8, 2, 8)
bW.add(bW.block, bW.color(1, 0, 0), bW.loc("px", "py", "pz"), bW.size(.1))
bW.add(bW.block, color=(1, 0, 0), loc=("px", "py", "pz"), size=.1)

bW.add(bW.block, color=(0, 1, 0), loc=(1, 0, 0), size=.05)
bW.add(bW.line, color=(0, 1, 0), pt=("px", "py", "pz"), pt2=(1, 0, 0))

bW.add(bW.block, color=(0, 0, 1), loc=(1, 1, 0), size=(.05))
bW.add(bW.line, color=(0, 0, 1), pt=("px", "py", "pz"), pt2=(1, 1, 0))

bW.add(bW.block, color=(1, 1, 0), loc=(0, 1, 0), size=(.05))
bW.add(bW.line, color=(1, 1, 0), pt=("px", "py", "pz"), pt2=(0, 1, 0))
Beispiel #6
0
# points.py
import random

from BlockW import *
bW = BlockW()

npoints = 100  # Number of points to display
points = []  # array of points to create/display
maxval = 4.  # Maximum (x,y,z) dimensional value
minval = -maxval  # Minimum (x,y,z) dimensional value
for i in range(npoints):
    xval = random.uniform(minval, maxval)
    yval = random.uniform(minval, maxval)
    zval = random.uniform(minval, maxval)
    points.append([xval, yval, zval])

cmd = bW.add(bW.line, bW.loc(1, 1, 1), bW.color(0, 1, 0))

print("Setup display {} points".format(npoints))
for pt in points:
    cmd.addPoint(pt[0], pt[1], pt[2])
bW.add(bW.text, bW.txt("after points"), bW.size(5), bW.color(1, 1, 1),
       bW.loc(0, 0, 0))
print("display")
bW.display()
print("End of %d points" % npoints)
Beispiel #7
0
"""
lines_grow_shrink.py
Use simple lines, each with two points
"""
import random
import time
from BlockW import *

bW = BlockW()

max_line_width = 50.
min_line_width = max_line_width / 10.
tdly_max = .5  # Time between displays
tdly_min = tdly_max / 10.
npoints = 200  # Number of points to display
###npoints = 5     # TFD - shorten test
points = []  # array of points to create/display
maxval = 4.  # Maximum (x,y,z) dimensional value
minval = -maxval  # Minimum (x,y,z) dimensional value
for i in range(npoints):
    xval = random.uniform(minval, maxval)
    yval = random.uniform(minval, maxval)
    zval = random.uniform(minval, maxval)
    points.append([xval, yval, zval])
"""
save commands for fast display
"""
"""
An unsuccessful attempt to avoid black lines
"""
"""test_slider1.py
   Simple slider debugging file
"""
from BlockW import *

trace = BwTrace()
trace.setAll()
bW = BlockW(trace=trace)
bW.slider("tsize", 0, 1, 10)
bW.add("block", bW.size("tsize", "tsize", "tsize"), bW.loc(0, 0, 0),
       bW.color(0, 1, 0))

bW.display()
"""test_block.py
   Simple test - simple block
"""   
from BlockW import *

trace = BwTrace()
trace.setAll()			
bW = BlockW(trace=trace)
block = "block"
bW.add(BlockW.axis)
bW.add(block, bW.loc(-4,2,2), bW.size(.5), bW.color(1,0,0))
bW.add(block, bW.loc(3,2,2), bW.size(.4), bW.color(1,0,.4))
bW.add(block, bW.loc(-2,2,2), bW.size(.3), bW.color(1,0,0.5))
bW.add(block, bW.loc(-4,4,4), bW.size(.2), bW.color(1,0,0.6))

bW.display()


Beispiel #10
0
# test_blocks_plus_lines_slider1a.py
# Use simple lines, each with two points

from BlockW import *
bW = BlockW()

bW.add(bW.block, loc=(1, 2, 3), size=(1, 2, 3), color=(1, 0, 0))
bW.add(bW.block, loc=(2, 2, 3), size=(1, 2, 3), color=(0, 1, 0))
bW.add(bW.block, loc=(4, 2, 3), size=(1, 2, 3), color=(0, 0, 1))
print("Commands Stored:")
bW.bExec.list()
bW.display()
print("End of test")
Beispiel #11
0
"""test_slider.py
   Simple test - simple block
"""   
from BlockW import *

trace = BwTrace()
trace.setAll()			
bW = BlockW(tr="input")
bW.add(BlockW.axis)

bW.slider("tsize",0,1,10)

bW.slider("t_x",0,2,10)
bW.slider("t_y",0,3,10)
bW.slider("t_z",0,4,10)
bW.slider("talign", BlockW.ALIGN_CENTER, BlockW.ALIGN_FIRST, BlockW.ALIGN_LAST)
bW.slider("tpath", BlockW.PATH_LEFT, BlockW.PATH_RIGHT, BlockW.PATH_DOWN)
bW.slider("leyex",-20,10,20)
bW.slider("leyey",-20,-10,20)
bW.slider("leyez",-20,10,20)

bW.add("lookateye", bW.loc("leyex", "leyey", "leyez"))
bW.add("block", bW.loc(-4,2,2), bW.size(.5), bW.color(1,0,0))
bW.add("block", bW.loc("t_x","t_y","t_z"), bW.size(.5), bW.color(1,1,0))

"""
bW.add("text", bW.txt("text at loc=-4,2,2", "talign", "tpath"),
           bW.loc("t_x", "t_y", "t_z"), bW.size("tsize"), bW.color(1,0,0))
"""
bW.display()
"""test_text.py
   Stand alone Python version of .bwif program
"""
from BlockW import *

bW = BlockW()
bW.add(bW.axis)
bW.slider("tsize", 0, 5, 10)
bW.slider("t_x", 0, 1, 10)
bW.slider("t_y", 0, 1, 10)
bW.slider("t_z", 0, 1, 10)
bW.slider("talign", bW.ALIGN_CENTER, bW.ALIGN_FIRST, bW.ALIGN_LAST)
bW.slider("tpath", bW.PATH_LEFT, bW.PATH_RIGHT, bW.PATH_DOWN)
bW.slider("leyex", -20, 10, 20)
bW.slider("leyey", -20, -10, 20)
bW.slider("leyez", -20, 10, 20)
bW.add(bW.lookAtEye, loc=("leyex", "leyey", "leyez"))
bW.add(bW.text,
       text=("text at loc=(t_x,t_y,t_z)", "talign", "tpath"),
       loc=("t_x", "t_y", "t_z"),
       size="tsize",
       color=(1, 0, 0))
bW.add(bW.text,
       text=("text at loc=(5,5,5)", "talign", "tpath"),
       loc=(5, 5, 5),
       size="tsize",
       color=(1, 0, .4))
bW.add(bW.text,
       text=("loc=(2,2,2)", "talign", "tpath"),
       loc=(2, 2, 2),
       size="tsize",
Beispiel #13
0
"""
lines_growing.py
Use simple lines, each with two points
"""
import random
import time
from BlockW import *
bW = BlockW()

bW.slider("winH", 0, 900, 2000)
bW.slider("winW", 0, 1400, 2000)
bW.add(bW.window, size=("winW", "winH"))
tdly = 2  # Time between displays
print("Number of points shortened because of time limitations")
npoints = 10  # Number of points to display
points = []  # array of points to create/display
maxval = 4.  # Maximum (x,y,z) dimensional value
minval = -maxval  # Minimum (x,y,z) dimensional value
for i in range(npoints):
    xval = random.uniform(minval, maxval)
    yval = random.uniform(minval, maxval)
    zval = random.uniform(minval, maxval)
    points.append([xval, yval, zval])

for i in range(2, npoints + 1, 1):  # Loop over sub groups of all points
    for npt in range(2, i):
        for ip1 in range(0, npt - 1):  # First point of line
            ip2 = ip1 + 1
            pt = points[ip1]
            pt2 = points[ip2]  # Second point of line
            cmd = bW.add(bW.line, bW.color(0, 1, 0))
Beispiel #14
0
# test_blocks_plus_lines_slider.py
# Use simple lines, each with two points

from BlockW import *
bW = BlockW()


bW.add(bW.window, size=("winW", "winH"))

bW.display()
Beispiel #15
0
#test_incl_3.py
print("In test_incl_3.py")
from BlockW import *
global bW
if 'bW' not in globals() or bW == None:
    is_incl = True
    bW = BlockW(tr="input,execute")

bW.add(bW.block, loc=(3, 0, 1), size=.2, color=(0, 1, 0))
bW.include("test_incl_3_1")
bW.include("test_incl_3_2")
bW.add(bW.block, loc=(3, 0, 2), size=.2, color=(0, 1, 0))
if 'is_incl' in locals():  # Only display if standalone
    bW.display()
Beispiel #16
0
#test_include.py
print("In test_include.py")

from BlockW import *
global bW
bW = BlockW(tr="input")

bW.add(bW.block, loc=(-4, 2, 2), size=.5, color=(1, 0, 0))
bW.include("test_incl_1")
bW.add(bW.block, loc=(-3, 2, 2), size=.4, color=(1, 0, .4))
bW.include("test_incl_2")
bW.add(bW.block, loc=(-2, 2, 2), size=.3, color=(1, 0, 0.5))
bW.include("test_incl_3")
bW.add(bW.block, loc=(-4, 4, 4), size=.2, color=(1, 0, 0.6))

bW.display()
Beispiel #17
0
#test_include1.py
# Smallest test
print("In test_include1.py")

from BlockW import *

global bW
bW = BlockW(tr="input,execute=2")
bW.add(bW.block, loc=(-4, 2, 2), size=.5, color=(1, 0, 0))
bW.include("test_incl_1", globals())
### TBD can't seem to get default to work: bW.include("test_incl_1")

bW.display()
Beispiel #18
0
#test_incl_2.py
print("In test_incl_2.py")
from BlockW import *
global bW
if 'bW' not in globals() or bW == None:
    is_incl = True
    bW = BlockW(tr="input,execute")

bW.add(bW.block, loc=(2, 1, 0), size=.3, color=(0, 1, 0))
bW.include("test_incl_2_1")
bW.include("test_incl_2_2")
bW.add(bW.block, loc=(2, 2, 0), size=.3, color=(0, 1, 0))
if 'is_incl' in locals():  # Only display if standalone
    bW.display()
Beispiel #19
0
"""
lines_growing.py
Use simple lines, each with two points
"""
import random
import time
from BlockW import *
bW = BlockW()

tdly = 2         # Time between displays
npoints = 100    # Number of points to display
points = []     # array of points to create/display
maxval = 4.     # Maximum (x,y,z) dimensional value
minval = -maxval    # Minimum (x,y,z) dimensional value
for i in range(npoints):
    xval = random.uniform(minval, maxval)
    yval = random.uniform(minval, maxval)
    zval = random.uniform(minval, maxval)
    points.append([xval,yval,zval])
    

for i in range(2, npoints+1, 1):        # Loop over sub groups of all points
    for npt in range(2, i):
        for ip1 in range(0, npt-1):     # First point of line
            ip2 = ip1 + 1
            pt = points[ip1]
            pt2 = points[ip2]               # Second point of line
            cmd = bW.add(bW.line, bW.color(0,1,0))
            cmd.addPoint(pt[0], pt[1], pt[2])
            cmd.addPoint(pt2[0], pt2[1], pt2[2])
    print("display {} points".format(i));
Beispiel #20
0
"""test_text.py
   Stand alone Python version of .bwif program
"""
from BlockW import *

bW = BlockW()
bW.add(bW.axis)
bW.add(BlockW.lookAtEye, loc=(10, -10, 10))
bW.add(bW.text, bW.txt("test_txt", bW.ALIGN_FIRST, bW.PATH_RIGHT), bW.size(5),
       bW.loc(1, 1, 1), bW.color(0, 1, 0))
bW.display()