Example #1
0
    def draw(self):

        self.sliders = []
        self.slidercaptions = []

        w = 500.0

        spacing_px = 40.0

        button_px = 100

        marginbottom_px = 20.0
        margintop_px = 20.0
        button_area_px = 100.0
        button_height_px = 80

        r = 100.0

        h = len(
            self.variables
        ) * spacing_px + marginbottom_px + margintop_px + button_area_px + button_height_px

        spacing = (spacing_px / h) * r
        posy = -r / 2 + marginbottom_px / h * r + len(self.variables) * spacing

        self.c = controls.controls(x=0, y=0, width=w, height=h, range=r)
        for v in self.variables:
            s = controls.slider(pos=(-15, posy),
                                width=7,
                                length=70,
                                axis=(1, 0, 0))

            s.value = v.default
            s.min, s.max = v.bounds

            sc = controls.label(text=v.name,
                                align='right',
                                pos=(r * (-0.5 + 0.1), posy),
                                display=self.c.display,
                                box=False)
            self.sliders.append(s)
            self.slidercaptions.append(sc)
            print posy
            posy -= spacing

        controls.button(pos=(0, r * (0.5 - button_area_px / h)),
                        height=button_height_px / h * r,
                        width=r / 2,
                        text='reset',
                        action=lambda: self.reset())
Example #2
0
    def __init__(self, physicalEnvironment):
        self.logger = logging.getLogger(name='Quadsim.Visualizer')
        self.physEnv = physicalEnvironment
        self.obj = set()
        self.simFrames = 0
        self.objUpdates = 0
        self.canvas = v.display(title='Simulation', width=1024, height=768, background=(0.2,0.2,0.2))
        self.canvas.select()
        self.controls = vc.controls(x=640, y=0, range=20)
        self.infoLabel = v.label(display=self.controls.display,pos=(-10,-10), text='Click simulation to start', line=False)
        self.lastFPSCheckTime = None
        self.lastFPS = 0.0
        self.simTime = 0.0
        self.fpsValues = []

        self.geomLookup = {} 
Example #3
0
 def draw(self):
   w = 200
   self.c = controls.controls(x=0, y=0, width=w, height=w, range=100)
   controls.button(pos=(-60,30), height=30, width=40, text='<<' , action=lambda: self.first())
   controls.toggle(pos=(0,30),height=30, width=40, text='Pause', action=lambda: self.pauseToggle())
   controls.button(pos=(60,30), height=30, width=40, text='>>',action= lambda: self.last())
   
   self.timelabel = controls.label(pos=(-15,-55),display=self.c.display)
   self.s1=controls.slider(pos=(-15,-30), width=7, length=70, axis=(1,0,0), action=lambda: self.slider1())
   self.s1.value = 0
   
   self.s2=controls.slider(pos=(-15,80),min=-1,max=3, width=7, length=70, axis=(1,0,0),action=lambda: self.slider2())
   self.s2.value = 0
   
   
   self.pause = False
   self.advancestep = 1
Example #4
0
  def draw(self):
  
    
    self.sliders=[]
    self.slidercaptions = []
    
    
    
    w = 500.0
    
    spacing_px = 40.0
    
    button_px = 100
    
    marginbottom_px = 20.0
    margintop_px = 20.0
    button_area_px = 100.0
    button_height_px = 80
    
    
    
    r= 100.0
    
    h = len(self.variables)*spacing_px + marginbottom_px + margintop_px + button_area_px + button_height_px
    
    spacing = (spacing_px / h) * r
    posy = -r/2 + marginbottom_px/h*r + len(self.variables)*spacing

    

    self.c = controls.controls(x=0, y=0, width=w, height=h, range=r)
    for v in self.variables:
      s = controls.slider(pos=(-15,posy), width=7, length=70, axis=(1,0,0))
      
      s.value = v.default
      s.min,s.max = v.bounds
      
      sc = controls.label(text=v.name,align='right', pos=(r*(-0.5+0.1),posy),display=self.c.display,box = False )
      self.sliders.append(s)
      self.slidercaptions.append(sc)
      print posy
      posy-=spacing
    
    controls.button(pos=(0,r*(0.5-button_area_px/h)), height=button_height_px/h*r, width=r/2, text='reset' , action=lambda: self.reset())
Example #5
0
    def draw(self):
        w = 200
        self.c = controls.controls(x=0, y=0, width=w, height=w, range=100)
        controls.button(pos=(-60, 30),
                        height=30,
                        width=40,
                        text='<<',
                        action=lambda: self.first())
        controls.toggle(pos=(0, 30),
                        height=30,
                        width=40,
                        text='Pause',
                        action=lambda: self.pauseToggle())
        controls.button(pos=(60, 30),
                        height=30,
                        width=40,
                        text='>>',
                        action=lambda: self.last())

        self.timelabel = controls.label(pos=(-15, -55), display=self.c.display)
        self.s1 = controls.slider(pos=(-15, -30),
                                  width=7,
                                  length=70,
                                  axis=(1, 0, 0),
                                  action=lambda: self.slider1())
        self.s1.value = 0

        self.s2 = controls.slider(pos=(-15, 80),
                                  min=-1,
                                  max=3,
                                  width=7,
                                  length=70,
                                  axis=(1, 0, 0),
                                  action=lambda: self.slider2())
        self.s2.value = 0

        self.pause = False
        self.advancestep = 1
Example #6
0
        qn = 0.5;
        un = (3/(x[n-1]-x[n-2]))*(ypn - (y[n-1]-y[n-2])/(x[n-1]-x[n-2]))
    y2[n - 1] = (un - qn*u[n - 2])/(qn*y2[n - 2] + 1.)
    for k in range(n - 2, 1,  - 1):
        y2[k] = y2[k]*y2[k + 1] + u[k]
    for i in range(1, Nfit + 2):                              # Begin fit
        xout = x[0] + (x[n - 1] - x[0])*(i - 1)/(Nfit) 
        klo = 0;    khi = n - 1                         # Bisection algor
        while (khi - klo >1):
            k = (khi + klo) >> 1
            if (x[k] > xout): khi  = k
            else: klo = k
        h = x[khi] - x[klo] 
        if (x[k] > xout):  khi = k
        else: klo = k 
        h = x[khi] - x[klo]
        a = (x[khi] - xout)/h 
        b = (xout - x[klo])/h 
        yout = a*y[klo] + b*y[khi] + ((a*a*a-a)*y2[klo]+(b*b*b-b)*y2[khi])*h*h/6
        funct2.plot(pos = (xout, yout) )
c = controls(x=500,y=0,width=200,height=200)         # Control via slider
control = slider(pos=(-50,50,0), min = 2, max = 100, action = update)
toggle(pos = (0, 35,  - 5), text1 = "Number of points", height = 0)
control.value = 2
update()

while 1:
    c.interact()
    rate(50)                                            # update < 10/sec
    funct2.visible = 0
Example #7
0
        S2.value = S1.value # demonstrate coupling of the two sliders
    else:
        S1.value = S2.value

def cuberate(value):
    """ Get a rate for the cube."""
    CUBE.dtheta = 2*value* math.pi/1e4

WDT = 350
vp.display(x=WDT, y=0, width=WDT, height=WDT, range=1.5, forward=-vp.vector(0, 1, 1))
CUBE = vp.box(color=vp.color.red)

# In establishing the controls window, range=60 means what it usually means:
# (0,0) is in the center of the window, and (60,60) is the lower right corner.
# If range is not specified, the default is 100.
C = ctrls.controls(x=0, y=0, width=WDT, height=WDT, range=60)

# Buttons have a "text" attribute (the button label) which can be read and set.
# Toggles have "text0" and "text1" attributes which can be read and set.
# Toggles and sliders have a "value" attribute (0/1, or location of indicator)
# which can be read and set.

# The pos attribute for buttons, toggles, and menus is the center of the control (like "box").
# The pos attribute for sliders is at one end, and axis points to the other end (like "cylinder").

# By default a control is created in the most recently created "controls" window, but you
# can change this by specifying "controls=..." when creating a button, toggle, slider, or menu.

# The Python construct "lambda: setdir(-1)" below passes the location of the setdir function
# to the interact machinery, which uses "apply" to call the function when an action
# is to be taken. This scheme ensures that the execution of the function takes place
Example #8
0
mk = 150.0
mg = 500.0
l = 10
g = 9.81
a11 = mg / mk
a12 = 1 + mg / mk
z = l / g
dest = 3
lengthL = 2

# create fuzzy regulator
system = fuzzy.storage.fcl.Reader.Reader().load_from_file("modifiedRules.fcl")
#system = fuzzy.storage.fcl.Reader.Reader().load_from_file("diplomovkaRules.fcl")

#control window
c = cntrl.controls(x=0, y=600, width=920, height=210, background = color.black, range=60)

s1 = slider(pos=(-25,6), width=3, length=30, axis=(1,0,0), color = color.blue)
s2 = slider(pos=(-25,2), width=3, length=30, axis=(1,0,0), color = color.blue)
s3 = slider(pos=(-25,-2), width=3, length=30, axis=(1,0,0), color = color.blue)
s4 = slider(pos=(-25, -6), width=3, length=30, axis=(1,0,0), color = color.blue)

m1 = menu(pos=(-43,6), width=30, height=3, text = 'DESTINATION:')
m2 = menu(pos=(-43,2), width=30, height=3, text = 'ROPE LENGTH:')
m3 = menu(pos=(-43,-2), width=30, height=3, text = 'CART MASS:')
m4 = menu(pos=(-43,-6), width=30, height=3, text = 'LOAD MASS:')

bl = button(pos=(15,5), height=8, width=13, text='START', action=lambda: setStart())
b2 = button(pos=(15,-5), height=8, width=13, text='RESET', action=lambda: setReset())
b3 = button(pos=(30,5), height=8, width=13, text='PAUSE', action=lambda: setPause())
b4 = button(pos=(30,-5), height=8, width=13, text='EXIT', action=lambda: setExit())