コード例 #1
0
ファイル: view.py プロジェクト: seanth/PyTectonics
 def __init__(self, world, projection, style):
     
     scene.title = 'pyTectonics'    
     
     self._world = world
     self._projection=projection
     self._style = style
     
     self._foreground=[]
     self._background=None
     
     self._updateBackground()
     self._projection.control.start()
     
     def getPos(row, col, rowTop=75, rowHeight=25, colWidth=50):
         return (col*colWidth,
                 rowTop - row*rowHeight)
         
     self.control = controls()
     self.speedSlider = slider(pos = getPos(0, -1.5),      
                               length = getPos(0, 3)[0],   
                               min=0., max=10., value=1.)
     self.ageLabel =   label(display=self.control.display, text='Initializing...', 
                             pos = getPos(.5,1),
                             opacity=0, line=False, box=False)
     self.speedLabel = label(display=self.control.display, text='Speed: 1 My', 
                             pos = getPos(.5,-1),
                             opacity=0, line=False, box=False)
     
     self.viewMenu = menu(pos=getPos(2, -1), width=60, height=20, text='Map type')
     
     self.projectionMenu = menu(pos=getPos(2, 1), width=60, height=20, text='Projection')
コード例 #2
0
ファイル: main-file.py プロジェクト: maccabifan08/cancer
 def initializePositions(self):
     #wire frame of space
     backBottom = curve(pos=[(self.MINX, self.MINY, self.MINZ), (self.MAXX, self.MINY, self.MINZ)], color=color.white)
     backTop = curve(pos=[(self.MINX, self.MAXY, self.MINZ), (self.MAXX, self.MAXY, self.MINZ)], color=color.white)
     frontBottom = curve(pos=[(self.MINX, self.MINY, self.MAXZ), (self.MAXX, self.MINY, self.MAXZ)], color=color.white)
     frontTop = curve(pos=[(self.MINX, self.MAXY, self.MAXZ), (self.MAXX, self.MAXY, self.MAXZ)], color=color.white)
     leftBottom = curve(pos=[(self.MINX, self.MINY, self.MINZ), (self.MINX, self.MINY, self.MAXZ)], color=color.white)
     leftTop = curve(pos=[(self.MINX, self.MAXY, self.MINZ), (self.MINX, self.MAXY, self.MAXZ)], color=color.white)
     rightBottom = curve(pos=[(self.MAXX, self.MINY, self.MINZ), (self.MAXX, self.MINY, self.MAXZ)], color=color.white)
     rightTop = curve(pos=[(self.MAXX, self.MAXY, self.MINZ), (self.MAXX, self.MAXY, self.MAXZ)], color=color.white)
     backLeft = curve(pos=[(self.MINX, self.MINY, self.MINZ), (self.MINX, self.MAXY, self.MINZ)], color=color.white)
     backRight = curve(pos=[(self.MAXX, self.MINY, self.MINZ), (self.MAXX, self.MAXY, self.MINZ)], color=color.white)
     frontLeft = curve(pos=[(self.MINX, self.MINY, self.MAXZ), (self.MINX, self.MAXY, self.MAXZ)], color=color.white)
     frontRight = curve(pos=[(self.MAXX, self.MINY, self.MAXZ), (self.MAXX, self.MAXY, self.MAXZ)], color=color.white)
     
     # Creating initial 8 cells
     for x in range(int(self.num/2),int(self.num/2)+2):
         for y in range(int(self.num/2),int(self.num/2)+2):
             for z in range(int(self.num/2),int(self.num/2)+2):
                 self.array[x][y][z] = sphere(frame = self.f,pos=(x,y,z), radius=self.radius, color=color.white)
     
     c = controls(height=360)                # Creating the buttons to control the Display
     b1 = button(pos=(0,75), height=42, width=110, text='Show All', action=lambda: self.showall())
     b2 = button(pos=(0,25), height=42, width=110, text='Show Cancer Cells', action=lambda: self.showcancer())
     b5 = button(pos=(0,-25), height=42, width=100, text='Chemo 1 doze', action=lambda: self.chemodoze())
コード例 #3
0
 def runControls(self):
     self.reset()
     self.preStart=False
     self.inGame=True
     width = 300
     height = 500
     c = controls(x=scene.width, y = 0 ,width=width ,height = height,
                  title = "Controls", range=150)
     #makes a controller panel for the Rubik Cube Generator
     self.buttons()
コード例 #4
0
ファイル: panel.py プロジェクト: berit/Project-E-and-M
	def run(self):
		
		def change(x): # Called by controls when button is clicked
			if b.text == 'Click me':
				b.text = 'Try again'
				self.addPoint([3,-1,3], 40)
			else:
				b.text = 'Click me'
			print 'change called'
		
		def changeMenu(ch):
			m.text='Hello'
			if self.activeCharge:
				self.activeCharge.revert()
			self.select(ch)
			print 'I done got called'

		def g(x):
			return lambda: changeMenu(x)
			
			
 		c = controls(x=500, y=50, width=500, height=200, range=250) # Create controls window
		# Create a button in the controls window:
		b = button( pos=(0,0), width=150, height=30, text='Click me', action=lambda: change(0) )

		
		m=menu(text='Select Charge', pos=(-100, 50), width=200, height=15)

		
		for i in range(len(self.field.charges)):
			text=str(self.field.charges[i])
			m.items.append((text, g(self.field.charges[i])))		

		self.field.start()
		scene.range=10
		pick=None
		while 1:
			c.interact() # Check for mouse events and drive specified actions
			if scene.mouse.events:
				m1 = scene.mouse.getevent() # obtain drag or drop event
				if m1.drag and m1.pick: # if clicked on the ball
					drag_pos = m1.pickpos # where on the ball the mouse was
					pick = m1.pick # pick is now True (nonzero)
				elif m1.drop: # released the mouse button at end of drag
					pick = None # end dragging (None is False)
			if pick:
				new_pos = scene.mouse.project(normal=(0,1,0)) # project onto xz plane
				if new_pos != drag_pos: # if the mouse has moved since last position
					pick.pos += new_pos - drag_pos # offset for where the ball was clicked
					drag_pos = new_pos # update drag position
					self.field.change=True
					
			time.sleep(.005)

		pygame.quit()
コード例 #5
0
    def initScene(self):
        w = 500
        display(x=w,
                y=0,
                width=w,
                height=w,
                range=1.5,
                forward=-vector(0, 1, 1),
                newzoom=1)
        self.controls = controls(0, 0, width=w, height=w)
        self.incomingThetaSlider = slider(
            pos=(-10, -50),
            width=7,
            length=100,
            axis=(0, 1, 0),
            action=lambda: self.update(theta=(self.incomingThetaSlider.value /
                                              100.0) - 0.5))
        self.incomingPhiSlider = slider(
            pos=(10, -50),
            width=7,
            length=100,
            axis=(0, 1, 0),
            action=lambda: self.update(phi=self.incomingPhiSlider.value / 100.0
                                       ))
        self.etaInSlider = slider(
            pos=(50, -50),
            width=7,
            length=100,
            axis=(0, 1, 0),
            action=lambda: self.update(etaIn=(self.etaInSlider.value / 100.0)))

        drawWorldCoordinates()
        box(pos=(0, 0, 0),
            axis=(0, 0, 1),
            length=0.01,
            height=1.0,
            width=1.0,
            opacity=0.25)
        box(pos=(0, 0, -0.5),
            axis=(0, 0, 1),
            length=1,
            height=1.0,
            width=1.0,
            opacity=0.1)

        self.incomingArrow = drawRayDirection()
        self.reflectedArrow = drawRayDirection(color=visual.color.green)
        self.refractedArrow = drawRayDirection(color=visual.color.orange)

        self.incomingThetaSlider.value = 100.0 * (
            (self.incoming.theta / math.pi) + 0.5)
        self.incomingPhiSlider.value = 100.0 * self.incoming.phi / (2 *
                                                                    math.pi)
        self.etaInSlider.value = 100.0 * self.etaIn
コード例 #6
0
    def initGraphs(self):

        self.scene = display(
            title=
            'Pursuit and Evasion Predator/Protector/Prey System  -Dynamic Games Simulator-',
            x=0,
            y=0,
            width=800,
            height=600,
            center=(0, 0, 0),
            background=(1, 1, 1),
            autoscale=0,
            fullscreen=0)

        self.gtitle = label(display=self.scene, pos=(0, 8), text="Information")

        self.cw = controls(x=900, y=0, width=100, height=100, range=60)
        self.btngrabimage = button(pos=(0, 0),
                                   height=30,
                                   width=40,
                                   text="grab",
                                   action=lambda: self.grabimage())
        self.image_num = 0
        #self.cw.interact()

        #Goal
        self.goal = Agent(self.goalPos, color.white, (0, 0, 0), L=3.0)
        self.goal.setac(radians(0), 0.0)
        self.goal.update()

        #Pata
        self.Pata = Agent(radians(45),
                          10, (randint(-5, 5), randint(-5, 5), 0),
                          color.orange, (-1, 0, 0),
                          L=1.5)
        self.Pata.setac(radians(0), 0.0)
        self.Pata.update()

        #Patito
        self.Patito = Agent(radians(75),
                            10, (randint(-5, 5), randint(-5, 5), 0),
                            color.yellow, (0, 1, 0),
                            L=1.5)
        self.Patito.setac(radians(0), 0.1)
        self.Patito.update()

        #Zorro
        self.Zorro = Agent(radians(85),
                           10, (randint(-5, 5), randint(-5, 5), 0),
                           (0.5, 0.5, 0.5),
                           L=2.0)
        self.Zorro.setac(radians(0), 0.075)
        self.Zorro.update()
コード例 #7
0
ファイル: 3d_snake.py プロジェクト: Duncan93/3D-Snake
    def initALL(self):
        self.snake = []
        self.food = [0,0,0,0,0,0]
        self.range = 30
        self.isGameOver = False
        self.isPaused = True
        
        self.score = 0
        
        self.tempX = 20
        self.tempY = 20
        self.tempZ = 20
        # Only works with even values
        self.drawPrism_and_Score()
        
        self.prism.length = 20 # Might be redundant data
        self.prism.height = 20
        self.prism.width = 20
        
        # These need to be even
        self.deltaX = 0
        self.deltaY = 0
        self.deltaZ = 0
        
        self.xInfo = 0
        self.yInfo = 0
        self.zInfo = 0
        
        self.initInfo()
        self.dimensionControl = 'On'
        # This makes it so food does not occupy the
        # space which fails the autoResize
        self.initSnakeHead()
        self.placeFood()
        
        #self.pause_unpause()

        self.w = 450
        c = controls(x=self.w-19, y=0, width=self.w, height=self.w, range=50)
        m = menu(pos=(0,-20,0), height=8, width=50, text='Auto Resize')
        m.items.append(('On', lambda: toggleControl('On')))
        m.items.append(('Off', lambda: toggleControl('Off')))
        
        # Try to put high score list on here

        def toggleControl(state):
            if (state == 'On'):
                self.dimensionControl = 'On'
            else:
                self.dimensionControl = 'Off'
            #.value means 'On'

        self.run()
コード例 #8
0
    def __init__(self, window_size, window_pos, visualizer):

        # reference to the visualizer
        self.visualizer = visualizer

        # create control window
        self.control = controls(x=window_pos[0],
                                y=window_pos[1],
                                width=window_size[0],
                                height=window_size[1],
                                title='Control Panel')

        # map from the names to functions
        algo_dict = {
            'Bubble': bubble_sort,
            'Cocktail': cocktail_sort,
            'Odd-even': odd_even_sort,
            'Comb': comb_sort,
            'Gnome': gnome_sort,
            'Quick': quick_sort,
            'Selection': selection_sort,
            'Heap': heap_sort,
            'Cycle': cycle_sort,
            'Insertion': insertion_sort,
            'Shell': shell_sort
        }

        # order the dict by key
        self.algo_dict = collections.OrderedDict(
            sorted(algo_dict.items(), key=lambda t: t[0]))

        # create a button for shuffling the boxes
        self.shuffle_button = button(pos=(0, 80),
                                     width=70,
                                     height=24,
                                     text="Shuffle",
                                     action=self.shuffle_handler)

        # create buttons for executing the algorithms
        self.button_list = []
        x, y = 0, 60  # start position (centered)
        for k in self.algo_dict:
            func = functools.partial(self.algo_handler, k)
            new_button = button(pos=(x, y),
                                width=70,
                                height=25,
                                text=k,
                                action=func)
            self.button_list.append(new_button)
            y -= 14  # line offset
コード例 #9
0
    def __init__(self):


        self.c = controls(x=500, y=0, width=250, height=250, range=60)
        self.c.visible = True
        bl = button(pos=(-30,30), height=30, width=40, text='Left',
                    action=lambda: self.test())
        m1 = menu(pos=(0,0,0), height=7, width=25, text='Options')

        self.scene = display(title='RNAMake GUI',
         x=800, y=0, width=800, height=800,
        center=(5,0,0), background=(1,1,1), ambient=color.gray(0.5))

        self.pick = 0
        self.dragpos = []
コード例 #10
0
    def __init__(self, window_size, window_pos, visualizer):

        # reference to the visualizer
        self.visualizer = visualizer
        
        # create control window
        self.control = controls(x = window_pos[0],
                                y = window_pos[1],
                                width = window_size[0],
                                height = window_size[1],
                                title = 'Control Panel')
        
        # map from the names to functions
        algo_dict = {'Bubble': bubble_sort,
                     'Cocktail': cocktail_sort,
                     'Odd-even': odd_even_sort,
                     'Comb': comb_sort,
                     'Gnome': gnome_sort,
                     'Quick': quick_sort,
                     'Selection': selection_sort,
                     'Heap': heap_sort,
                     'Cycle': cycle_sort,
                     'Insertion': insertion_sort,
                     'Shell': shell_sort}

        # order the dict by key
        self.algo_dict = collections.OrderedDict(
                sorted(algo_dict.items(), key = lambda t: t[0]))
        
        # create a button for shuffling the boxes
        self.shuffle_button = button(pos = (0, 80),
                                     width = 70,
                                     height = 24,
                                     text = "Shuffle",
                                     action = self.shuffle_handler)
        
        # create buttons for executing the algorithms
        self.button_list = []
        x, y = 0, 60 # start position (centered)
        for k in self.algo_dict:
            func = functools.partial(self.algo_handler, k)    
            new_button = button(pos = (x, y),
                                width = 70,
                                height = 25,
                                text = k,
                                action = func)
            self.button_list.append(new_button)
            y -= 14 # line offset
コード例 #11
0
ファイル: camera-tilt.py プロジェクト: bzamecnik/bokehlab
    def initScene(self):
        w = 500
        display(x=w, y=0, width=w, height=w, range=1.5, forward=-vector(0,1,1), newzoom=1)
        self.controls = controls(0, 0, width=w, height=w)
        self.xRotSlider = slider(pos=(-10,-50), width=7, length=100, axis=(0,1,0),
            action=lambda: self.updateXYTilt(xRot=self.xRotSlider.value / 100.0 - 0.5))
        self.yRotSlider = slider(pos=(10,-50), width=7, length=100, axis=(0,1,0),
            action=lambda: self.updateXYTilt(yRot=self.yRotSlider.value / 100.0 - 0.5))
        self.tiltModeMenu = menu(pos=(0,-60,0), height=7, width=25, text='Tilt mode')
        self.tiltModeMenu.items.append(('X, Y', lambda: self.setTiltMode("XY")))
        self.tiltModeMenu.items.append(('Z, modified X', lambda: self.setTiltMode("ZmodX")))

        drawWorldCoordinates()
        self.plane = box(length=0.01, axis=self.normal)

        self.normalArrow = drawRayDirection((0,0,0), self.normal)
        self.upArrow = drawRayDirection((0,0,0), self.up, color=color.green)

        self.xRotSlider.value = (self.xRot + 0.5) * 100.0
        self.yRotSlider.value = (self.yRot + 0.5) * 100.0
コード例 #12
0
    def initGraphs(self):


        self.scene = display(title='Pursuit and Evasion Predator/Protector/Prey System  -Dynamic Games Simulator-',x=0,y=0,
                width=800, height=600,
                center=(0,0,0), background=(1,1,1),
                autoscale=0,fullscreen=0)

        self.gtitle = label (display = self.scene, pos=(0,8), text="Information")

        self.cw = controls(x=900, y=0, width=100, height=100, range=60)
        self.btngrabimage = button(pos=(0,0), height=30, width=40, text="grab", action=lambda: self.grabimage())
        self.image_num=0
        #self.cw.interact()



        #Goal
        self.goal=Agent(self.goalPos,color.white,(0,0,0),L=3.0)
        self.goal.setac(radians(0),0.0)
        self.goal.update()


        #Pata
        self.Pata=Agent(radians(45),10,(randint(-5,5),randint(-5,5),0),color.orange,(-1,0,0),L=1.5)
        self.Pata.setac(radians(0),0.0)
        self.Pata.update()



        #Patito
        self.Patito=Agent(radians(75),10,(randint(-5,5),randint(-5,5),0),color.yellow,(0,1,0),L=1.5)
        self.Patito.setac(radians(0),0.1)
        self.Patito.update()

        #Zorro
        self.Zorro=Agent(radians(85),10,(randint(-5,5),randint(-5,5),0),(0.5,0.5,0.5),L=2.0)
        self.Zorro.setac(radians(0),0.075)
        self.Zorro.update()
コード例 #13
0
    def initScene(self):
        w = 500
        display(x=w,
                y=0,
                width=w,
                height=w,
                range=1.5,
                forward=-vector(0, 1, 1),
                newzoom=1)
        self.controls = controls(0, 0, width=w, height=w)
        self.xRotSlider = slider(pos=(-10, -50),
                                 width=7,
                                 length=100,
                                 axis=(0, 1, 0),
                                 action=lambda: self.updateXYTilt(
                                     xRot=self.xRotSlider.value / 100.0 - 0.5))
        self.yRotSlider = slider(pos=(10, -50),
                                 width=7,
                                 length=100,
                                 axis=(0, 1, 0),
                                 action=lambda: self.updateXYTilt(
                                     yRot=self.yRotSlider.value / 100.0 - 0.5))
        self.tiltModeMenu = menu(pos=(0, -60, 0),
                                 height=7,
                                 width=25,
                                 text='Tilt mode')
        self.tiltModeMenu.items.append(
            ('X, Y', lambda: self.setTiltMode("XY")))
        self.tiltModeMenu.items.append(
            ('Z, modified X', lambda: self.setTiltMode("ZmodX")))

        drawWorldCoordinates()
        self.plane = box(length=0.01, axis=self.normal)

        self.normalArrow = drawRayDirection((0, 0, 0), self.normal)
        self.upArrow = drawRayDirection((0, 0, 0), self.up, color=color.green)

        self.xRotSlider.value = (self.xRot + 0.5) * 100.0
        self.yRotSlider.value = (self.yRot + 0.5) * 100.0
コード例 #14
0
    def __init__(self):

        self.c = controls(x=500, y=0, width=250, height=250, range=60)
        self.c.visible = True
        bl = button(pos=(-30, 30),
                    height=30,
                    width=40,
                    text='Left',
                    action=lambda: self.test())
        m1 = menu(pos=(0, 0, 0), height=7, width=25, text='Options')

        self.scene = display(title='RNAMake GUI',
                             x=800,
                             y=0,
                             width=800,
                             height=800,
                             center=(5, 0, 0),
                             background=(1, 1, 1),
                             ambient=color.gray(0.5))

        self.pick = 0
        self.dragpos = []
コード例 #15
0
    def initScene(self):
        w = 500
        display(x=w, y=0, width=w, height=w, range=1.5, forward=-vector(0,1,1), newzoom=1)
        self.controls = controls(0, 0, width=w, height=w)
        self.incomingThetaSlider = slider(pos=(-10,-50), width=7, length=100, axis=(0,1,0),
            action=lambda: self.update(theta=(self.incomingThetaSlider.value / 100.0)-0.5))
        self.incomingPhiSlider = slider(pos=(10,-50), width=7, length=100, axis=(0,1,0),
            action=lambda: self.update(phi=self.incomingPhiSlider.value / 100.0))
        self.etaInSlider = slider(pos=(50,-50), width=7, length=100, axis=(0,1,0),
            action=lambda: self.update(etaIn=(self.etaInSlider.value / 100.0)))

        drawWorldCoordinates()
        box(pos=(0,0,0), axis=(0,0,1), length=0.01, height=1.0, width=1.0, opacity=0.25)
        box(pos=(0,0,-0.5), axis=(0,0,1), length=1, height=1.0, width=1.0, opacity=0.1)

        self.incomingArrow = drawRayDirection()
        self.reflectedArrow = drawRayDirection(color=visual.color.green)
        self.refractedArrow = drawRayDirection(color=visual.color.orange)

        self.incomingThetaSlider.value = 100.0 * ((self.incoming.theta / math.pi) + 0.5)
        self.incomingPhiSlider.value = 100.0 * self.incoming.phi / (2 * math.pi)
        self.etaInSlider.value = 100.0 * self.etaIn
コード例 #16
0
ファイル: editor.py プロジェクト: CPonty/PyPlant
    def __init__(self):
        """Set up the controls window and process input."""    

        #Make controls window
        self.ctrlWin = controls(x=25, y=25, width=ctrlWinW,
                                title='==PyPlant Seed Editor==        Controls',
                                height=ctrlWinH, range=ctrlWinH)
        slider(pos=(-999,-999))

        #Make data window        
        self.dataWin = display(height=dataWinH, width=dataWinW,
                               range=dataWinH,
                               title='==PyPlant Seed Editor==        Data',
                               x = self.ctrlWin.x,
                               y=self.ctrlWin.y+self.ctrlWin.height)
        
        self.g = GUI()

        #Main loop
        while True:
            rate(100)
            self.ctrlWin.interact()
コード例 #17
0
        cuerpos_celestes[indice].retain = 0
        lista_botones[indice].text = etiquetas_botones[indice] + ' off'
        lista_botones[indice].button.color = colorOff
    else:
        cuerpos_celestes[indice].retain = tiempos_estela[indice]
        lista_botones[indice].text = etiquetas_botones[indice] + ' on'
        lista_botones[indice].button.color = color.green


#--------------------------------------------------------
# CREAR LA VENTANA PARA LOS BOTONES DE CONTROL
#--------------------------------------------------------

ventanaControl = controls(title='Botones de control',
                          x=800,
                          y=00,
                          width=200,
                          height=500)  #, range=110)

# Crear botones para mostrar u ocultar trayectorias
anchoBoton = 45
altoBoton = 16
posX = -10
colorOn = color.green
b0 = button(pos=(posX, 55),
            width=anchoBoton,
            height=altoBoton,
            color=colorOn,
            text='Mercurio on',
            action=lambda: mostarOrbitas(0))
b1 = button(pos=(posX, 45),
コード例 #18
0
	del arrayPred[i]	
	
	
def Guardar():
	global running
	
	filePresas = open('presas.csv', 'w')
	filePred = open('pred.csv', 'w')
	for index in range(nDatos):
		filePresas.write('{0:3d}, {1:3d}\n'.format(vTiempos[index], vPresas[index]))
		filePred.write('{0:3d}, {1:3d}\n'.format(vTiempos[index], vPred[index]))
	filePresas.close()
	filePred.close()
	
# Controles
control = controls(title = 'Parametros', x = scene.width + 10, y = scene.y, width = 300, height = 300, range = 50)
boton = button( pos=(0,0), width=60, height=60, text='Guardar datos', action = lambda: Guardar() )

# Grafica
grafica = display(title="Animales", x=scene.x + scene.width + 8, y = control.y + control.width, width=384, height=300, background=(0, 0, 0))
grafica.autoscale = True
grafica.xmin = 0
scene.select()
lsPresas = curve(display=grafica, color = color.yellow)
lsPred = curve(display = grafica, color = color.red)

# Prepara main loop
crecPresas = 0
crecPred = 0
crecDepred = 0
t = 0
コード例 #19
0
# add distance marks
marker_font = floor.length/30
mark = {}
divisions = 5
for n in range(0, divisions + 1):
    mark[n] = box(length = floor.length/50, height = floor.height*1.1, width = floor.width, pos = (-floor.length*.5 + n*floor.length/divisions, -.5*floor.height, .1), color = color.red) 
    text(text=(str(n*floor.length/divisions)), pos = (mark[n].x - marker_font, mark[n].y - floor.height*1.5, mark[n].z + .4), height = marker_font, color = mark[n].color)



## set up graph window----------------------------------------------
point_r = 1 # size of graphing sphere points

graph = display(x = screen.width + 10, width = 800, height = 800, center = (40,30,40), title = "angle and V vs. range")
c = controls(x = screen.x, y = screen.height + 5, width = screen.width, height = 200, title = "Simulation Controls")

graph.select()
width = 1
## angle
x_axis = arrow(axis = (1,0,0), length = 90, shaftwidth = width, color = color.red)
# make angle tick marks
marker_font = 13
mark_x = {}
divisions = 6
for n in range(0, divisions + 1):
    mark_x[n] = box(length = floor.length/50, height = floor.height*1.1, width = floor.width, pos = (n*x_axis.length/divisions, -.3*floor.height, .4*floor.width), color = color.green) 
    label(text=(str(n*90/divisions)), pos = (mark_x[n].x, mark_x[n].y - floor.height*1.5, mark_x[n].z), height = marker_font, color = mark_x[n].color)
    
# launch speed axis
z_axis = arrow(axis = (0,0,1), length = 90, shaftwidth = width, color = color.red)
コード例 #20
0
    elif wf.text == "sqsin":
        wf.text = "sqtri"
    elif wf.text == "sqtri":
        wf.text = "1/2 sin"

def stop():
    stp.stp = 1

def autotoggle():
    if auto.text == "Auto":
        auto.text = "Manual"
    elif auto.text == "Manual":
        auto.text = "Auto"

#Control scene
c = controls(title='Controls',
     x=0, y=600, width=1024, height=150, range=50)
ss = button(pos=(-5,0), width=10, height=10,
              text='Start', action=lambda:togglego())
wf1 = button(pos=(-15,0), width=10, height=10,
              text='sine', action=lambda:wfcycle(wf1))
wf2 = button(pos=(25,0), width=10, height=10,
              text='sine', action=lambda:wfcycle(wf2))
stp = button(pos=(5,0), width=10, height=10,
              text='Stop', action=lambda:stop())
auto = button(pos=(15,0), width=10, height=10,
              text='Auto', action=lambda:autotoggle())

#Main Loop:
while 1:
    ss.go = 0
    stp.stp = 0
コード例 #21
0
ファイル: gas.py プロジェクト: dukeeagle/elastic_collisions
dfp = 1.
for fp in arange(0, 40. + dfp, dfp):  # theoretical prediction
    theoryl.plot(pos=(fp, Natoms * exp(-fp / meanfp) * deltal / meanfp))
###########################################
##add windows for future additions
###########################################
##pgraph = gdisplay(xmin=-0.1,xmax=1., x=win,y=.5*win, ymax = Natoms/5.,
##             width=win, height=win/2., xtitle='x', ytitle='dN',
##                 title="Pressure")
##panel = gdisplay(xmin=-0.1,xmax=1., x=2.*win,y=0, ymax = Natoms/5.,
##             width=.7*win, height=2*win, xtitle='x', ytitle='dN',
##                 title="Control panel")
ctrl = controls(x=2 * win,
                y=0,
                width=.7 * win,
                height=2 * win,
                title='Control Panel')
bpause = button(pos=(0, 30), width=60, height=30, action=lambda: pause())
##brepeat = button(pos=(0,60), width=60, height=30, text='Repeat',
##             action=lambda: repeat())
##benergy = button(pos=(0,90), width=60, height=30,
##             action=lambda: energy())
##bget = button(pos=(0,0), width=60, height=30, text='Get File',
##              action=lambda: getsituation())
##bsave = button(pos=(0,-30), width=60, height=30, text='Save File',
##              action=lambda: savesituation())
##breset = button(pos=(0,-60), width=60, height=30, text='Reset',
##             action=lambda: reset())
##pause(state=1)
##bget.state = 0
コード例 #22
0
            p.N -= 1
            s.N += 1
            i -= 1
        i += 1


# Declaración de sistema
s = system(-10, -10, 20, color.blue)
p = pistonSystem(10, -10, 10, 1, color.red, maxPistonVel=0.6)
s.addParticles(50, color.blue)
p.addParticles(60, color.red)

# Controles
control = controls(title='Parametros',
                   x=scene.x + scene.width,
                   y=scene.y,
                   width=400,
                   height=400,
                   range=50)
pistonButton = button(pos=(0, 30),
                      height=15,
                      width=30,
                      text='Mover Piston',
                      action=lambda: MoveP())
wallsButton = button(pos=(0, 10),
                     height=15,
                     width=30,
                     text='Eliminar pared',
                     action=lambda: RemovePWalls())
moveAllButton = button(pos=(0, -10),
                       height=15,
                       width=40,
コード例 #23
0
t = 2  #horizontal component speed of shot (X dxn)
teta = 55  #angle from the ground towards the goal
g = 9.81
vt = 25  #terminal speed
k_D = 0.00275
k_L = 0.0025
phi = -5
#create a ball
ball = sphere(
    pos=(0, 0.8, 30), color=color.white, radius=0.22, mass=0.43
)  #change the position to try different distances in the z axis, and to a reasonable range the x axis, the y component is the v
#vertical height which is supposed to be on the ground level
ball.velocity = vector(t, u, s)
c = controls(title='Speed and Distance selection',
             x=440,
             y=0,
             range=100,
             width=400)

h = 0.01
ball.trail = curve(color=ball.color)
xs = 0  #initial value


##vx=slider(pos=(-50,0), width=7, length=50, axis=(10,0,0),min=-3,max=3,action=lambda: set())
##vx.value=t
##vy=slider(pos=(-50,-20), width=7, length=50, axis=(10,0,0),min=0,max=25,action=lambda: set())
##vy.value=u
##vz=slider(pos=(-50,-40), width=7, length=50, axis=(10,0,0),min=0,max=32,action=lambda: set())
##vz.value=s
##s_text=label(pos=(60,0), text='initial speed in x dxn ' ,display=c.display,box=0,line=0)
コード例 #24
0
                break
        exec(open('gammadecay.py').read())


def wirecube(s):  #setting the cube borders
    c = curve(color=color.white, radius=1)
    pts = [(-s, -s, -s), (-s, -s, s), (-s, s, s), (-s, s, -s), (-s, -s, -s),
           (s, -s, -s), (s, s, -s), (-s, s, -s), (s, s, -s), (s, s, s),
           (-s, s, s), (s, s, s), (s, -s, s), (-s, -s, s), (s, -s, s),
           (s, -s, -s)]
    for pt in pts:
        c.append(pos=pt)


#the controls window
c = controls(x=0, y=0, width=300, height=200, range=60)
bl = button(pos=(-30, 0),
            height=30,
            width=40,
            text='HOME',
            action=lambda: home())
b2 = button(pos=(30, 0),
            height=30,
            width=40,
            text='RESET',
            action=lambda: restart())

scene = display(title='Radioactive Decay', x=350, y=0,
                background=(0, 0, 0))  #setting the size of the display screen
scene.exit = False
scene.material = materials.plastic
コード例 #25
0
ファイル: czastka.py プロジェクト: jacor1996/Python-symulacje
from visual import *
import math
from visual.controls import *
 

# Create controls window
c = controls(title='Magnetic field',
     x=0, y=0, width=300, height=300, range=100) 
# Create the buttons in the controls window:

run_button = button( pos=(-50,0), width=50, height=50,
              text='Run', action=lambda: ruch(100) )

run_slow = button( pos=(0,0), width=50, height=50,
              text='Run\nSlow\nMotion', action=lambda: ruch(25) )

exit_button = button(pos=(50,0), width=50, height=50,
              text='Exit', action=lambda: exit() )


def ruch(speed):
       scene1 = display(title='Particle',
       x=0, y=0, width=800, height=600, 
       center=(100,10,200), background=(0,1,1),autoscale=False)
       vvec = arrow(pos=(0,0,-10), axis=(0,0,50), shaftwidth=0.5, color=color.green, text=("B"))
       
       magnet = box(pos=vector(0, 0, -1), length=50, height=50, width=1, color = (0.7,0.7,0.7))

       ball=sphere(color=color.green,radius=1)
       ball.trail = curve(color=color.blue)
                     
コード例 #26
0
def masRadio():

    global radio
    radio = radio + 1


def menosRadio():

    global radio
    radio = radio - 1


#ventana de botones
c = controls(title="Controles velocidad y radio",
             width=400,
             height=400,
             range=60,
             x=600,
             y=25)

#Botones
#por si acaso, lambda es una forma de llamar a la accion usando una funcion
b1 = button(pos=(20, 30),
            height=30,
            width=40,
            text='Omega+',
            action=lambda: masOmega())
b2 = button(pos=(-20, 30),
            height=30,
            width=40,
            text='Omega-',
            action=lambda: menosOmega())
コード例 #27
0
		t += deltaT
		if t > 5000:
			reset_rotation = true
		rate(500)

#Funcion para cambiar el omega
def recalculateOmega(value):
    global omega 
    omega = value
    print 'Omega changed!'
    animate()

#Funcion para cambiar el radio
def recalculateRadio(value):
    global radius_length 
    radius_length = value
    print 'Radio changed!'
    animate()


#Definicion de botones para cambiar omega
omega_plus = button( pos=(-40,30), width=60, height=60, text='Omega +', action=lambda: recalculateOmega(omega + 5) )
omega_minus = button( pos=(-40,-60), width=60, height=60, text='Omega -', action=lambda: recalculateOmega(omega - 5) )

#Definicion de botones para cambiar radio
radius_length_plus = button( pos=(50,30), width=60, height=60, text='Radio +', action=lambda: recalculateRadio(radius_length + 1) )
radius_length_minus = button( pos=(50,-60), width=60, height=60, text='Radio -', action=lambda: recalculateRadio(radius_length - 1) )
c = controls(title='Control de velocidad y radio', x=800, y=400, width=300, height=300, range=100)

animate()
コード例 #28
0
ファイル: threebody.py プロジェクト: drewsday/Old-Code
            for s in stars: # After updating momenta, update positions
                if s.visible == 0: continue
                s.pos = s.pos+(s.p/s.mass)*dt
                s.trail.append(pos=s.pos)

            if benergy.state:
                showenergy()

            if clock() > tclock+3:
                instruct.text = ''

#########################################################################

restoreview()
buildfiles()
ctrl = controls(x=scene.x+sw, y=scene.y, width=400, height=200)
bpause = button(pos=(-65,20), width=60, height=30,
             action=lambda: pause())
brepeat = button(pos=(0,20), width=60, height=30, text='Repeat',
             action=lambda: repeat())
benergy = button(pos=(65,20), width=60, height=30,
             action=lambda: energy())
bget = button(pos=(-65,-20), width=60, height=30, text='Get File',
              action=lambda: getsituation())
bsave = button(pos=(0,-20), width=60, height=30, text='Save File',
              action=lambda: savesituation())
breset = button(pos=(65,-20), width=60, height=30, text='Reset',
             action=lambda: reset())
pause(state=1)
bget.state = 0
breset.state = 0
コード例 #29
0
incline = []
path = [(0,0,earth.pos.z + .5*earth.width),(0,0,earth.pos.z - .5*earth.width)]

ball = sphere(radius = 5, color = color.orange)

ball.pos = (earth.pos.x - .45*earth.length, earth.pos.y + .5*earth.height + ball.radius + 500/9.8, 0)
ball.reset_x = ball.x
ball.v = vector(0,0,0)
ball.reset_v = ball.v


done_ball = False
breakout = False

# controls window
c = controls(x = scene.x, y = scene.height + 5, width = energy.x + energy.width, height = 150, title = "Simulation Controls")

apart = 8
lbl_size = 10
h_button = 10
angle_control = slider(text = 'angle',min = 0, max = 70, pos=(-apart*9,.5*apart), width=7, length=60, axis=(1,0,0), action = lambda:setangle(angle_control))
angle_lbl = button(text = 'angle', pos = (angle_control.pos.x - .2*angle_control.length, angle_control.pos.y), height=.5*h_button, width= h_button)

mu_control =  slider(text = 'mu', min = 0, max = 1, pos=(-apart*9,-.5*apart), width=7, length=60, axis=(1,0,0), action = lambda:setmu(mu_control))
mu_lbl = button(text = 'mu', pos = (mu_control.pos.x - .2*mu_control.length, mu_control.pos.y), height=.5*h_button, width= h_button)

start =  button(pos=(20,5), height=h_button, width= 2*h_button, text='Pause', action= lambda: pausenow())
restart = button(pos=(start.pos.x, start.pos.y - 9), height = h_button, width = 2*h_button, text = 'Restart', action = lambda: restartnow())

# give graph bars colors
potential.color = color.blue
コード例 #30
0
ファイル: parametricsurface.py プロジェクト: geo7/csci480
def psphere(s, t):
    return vector(sin(s) * cos(t), sin(s) * sin(t), cos(s))


sphereranges = [arange(0, 1.01 * pi, 0.1 * pi), arange(0, 2.01 * pi, 0.1 * pi)]


def init(func, ranges):
    global function, srange, trange
    function = func
    srange, trange = ranges


init(saddle, saddleranges)

ball = sphere(radius=0.1, color=color.cyan, pos=(min(srange), min(trange)))
svec = arrow(color=color.red, pos=ball.pos, axis=(1, 0, 0))
tvec = arrow(color=color.green, pos=ball.pos, axis=(0, 1, 0))
nvec = arrow(color=color.blue, pos=ball.pos, axis=(0, 0, 1))

c = controls(x=512, y=0, width=500, height=500)
sslider = slider(pos=(-64, 64), action=lambda: setBall(), color=color.red)
tslider = slider(pos=(-64, 32), action=lambda: setBall(), color=color.green)

shapemenu = menu(width=64, height=12, text="Shape")
shapemenu.items.append(("Saddle", lambda: reset()))
shapemenu.items.append(("Sphere", lambda: reset()))
shapemenu.items.append(("Torus", lambda: reset()))

reset()
コード例 #31
0
ファイル: controlstest.py プロジェクト: guitorri/vpython-wx
    if obj is s1:
        s2.value = s1.value # demonstrate coupling of the two sliders
    else:
        s1.value = s2.value

def cuberate(value):
    cube.dtheta = 2*value*pi/1e4

w = 350
display(x=w, y=0, width=w, height=w, range=1.5, forward=-vector(0,1,1), newzoom=1)
cube = box(color=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 = controls(x=0, y=0, width=w, height=w, 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
# in the appropriate namespace context in the case of importing the controls module.
コード例 #32
0
                                     0.5 * g.y * time * time,
                                     sloc.z + vz * time))
        while (
                sloc.y + vy * time + 0.5 * g.y * time * time >= 0
        ):  # Continue the analytic line if it hasn't reached the floor yet
            rate(1 / dt)
            time += dt
            analytic.append(pos=(sloc.x + vx * time,
                                 sloc.y + vy * time + 0.5 * g.y * time * time,
                                 sloc.z + vz * time))


# Controls Window and controlling elements
controlw = controls(x=600,
                    y=0,
                    width=300,
                    height=600,
                    title="Controls",
                    background=(0, 0.3, 0.3))
b1 = button(pos=(0, -80),
            width=30,
            height=15,
            text='Launch',
            action=lambda: launch(),
            color=(0.8, 0.8, 0.8))
vxslider = slider(pos=(-35, 75),
                  width=5,
                  height=10,
                  value=vx,
                  length=60,
                  text='x velocity',
                  action=lambda: setvx(vxslider.value),
コード例 #33
0
ファイル: Ventana.py プロジェクト: lauyader/proyectoPython
from visual import *

w = window(menus=False, title="VPython", x=0, y=0, width=600, height=600)
display(window=w, x=50, y=30, width=200, height=150) 


from visual.controls import *
 
def change(): # Called by controls when button clicked
    if b.text == 'Click me':
        b.text = 'Try again'
    else:
        b.text = 'Click me'
 
c = controls() # Create controls window
# Create a button in the controls window:
#b = button( pos=(0,0), width=60, height=60,text='Click me', action=lambda: change() ) 
d =toggle ( pos=(0,20), width=60, height=60,text='Click me', action=lambda: change() ) 

scene2 = display(title='Objetos',x=0, y=0, width=600, height=500,center=(5,0,0), background=(0.2,0.3,1))
n1 = sphere(pos=(1,0,1), radius=5, color = color.green)
suelo= box(pos=(-5,-10,0), lenght=10,width=60, height=50, axis=(0,1,0.2),color=color.orange)

grupo=frame()
cilindro = cylinder(frame=grupo, pos=(3,3,2), length=10, axis=(0,1,1), radius=3,color=color.red)
mybox = box(frame=grupo, pos=(3,3,2), length=5, height=25) 



#cilindro.rotate(angle=180, axis=(1,1,0))
コード例 #34
0
               height=300,
               background=(255, 255, 255))

graf.userzoom = True
graf.userspin = True
graf.autoscale = True
graf.visible = False
graf.select()

# Agregar títulos y ejes al gráfico
ls = curve(display=graf)

# Crear controles
ctrls = controls(x=graf.x,
                 y=graf.y + graf.height + 8,
                 width=384,
                 height=382,
                 range=100,
                 title="Opciones")

sliderMasa = slider(pos=(-55, 80),
                    length=100,
                    axis=(1, 0, 0),
                    width=5,
                    action=lambda: setMasa(sliderMasa.value),
                    min=1,
                    max=60)

label(display=ctrls.display, text="Masa:", pos=(-75, 80), height=8)
lblMasa = label(display=ctrls.display, text="0 kg", pos=(70, 80), height=8)

sliderKx = slider(pos=(-55, 60),
コード例 #35
0
                    width=60,
                    height=60,
                    text='Omega +',
                    action=lambda: recalculateOmega(omega + 5))
omega_minus = button(pos=(-40, -60),
                     width=60,
                     height=60,
                     text='Omega -',
                     action=lambda: recalculateOmega(omega - 5))

#Definicion de botones para cambiar radio
radius_length_plus = button(pos=(50, 30),
                            width=60,
                            height=60,
                            text='Radio +',
                            action=lambda: recalculateRadio(radius_length + 1))
radius_length_minus = button(
    pos=(50, -60),
    width=60,
    height=60,
    text='Radio -',
    action=lambda: recalculateRadio(radius_length - 1))
c = controls(title='Control de velocidad y radio',
             x=800,
             y=400,
             width=300,
             height=300,
             range=100)

animate()
コード例 #36
0
ファイル: bodies.py プロジェクト: k1ll3rzamb0n1/Code_backup
# Set Constants

dt = 0.01
density = 10
G = 1
integrationMethod = 1
retain = True
reduced = False

# Initialize Global Variables in the System

bodies = []
time = [0]


c = controls(title="Choose Algorithm", x=350, height=350, width=350, range=150)  # Create controls window
# Create a button in the controls window:
b1 = button(pos=(-30, 65), width=120, height=60, text="Euler", action=lambda: changeEuler())
b2 = button(pos=(-30, 0), width=120, height=60, text="Runge-Kutta 2", action=lambda: changeRK2())
b3 = button(pos=(-30, -65), width=120, height=60, text="Runge-Kutta 4", action=lambda: changeRK4())
t1 = toggle(pos=(70, 0), text0="Not-Reduced", text1="Reduced", action=lambda: toggleReduced())
Alg = display(title="Algorithm Running", x=700, height=200, width=1000, range=5)
Alg.autoscale = True
alg1Text = text(display=Alg, text="Euler", align="center", depth=-0.3, color=color.green)
alg2Text = text(display=Alg, text="Runge-Kutta 2", align="center", depth=-0.3, color=color.green)
alg2Text.visible = False
alg3Text = text(display=Alg, text="Runge-Kutta 4", align="center", depth=-0.3, color=color.green)
alg3Text.visible = False
alg4Text = text(display=Alg, text="Reduced", align="center", depth=-0.3, color=color.yellow, pos=(0, -1.2, 0))
alg4Text.visible = False
コード例 #37
0
# Lagrange.py: Langrange interpolation tabulated data; 2, 4, 8 degree poly

from visual import*
from visual.graph import*
from visual.controls import *

sceneK = display(x=0,y=0,width=500,height=500,
title='Lagrange Interpolation with Toggle Switch')
graph=curve(color= color.yellow,x=range(0,201),radius=3)
xin = array([0, 25, 50, 75, 100, 125, 150, 175, 200])
yin = array([10.6, 6, 45, 83.5, 52.8, 19.9, 10.8, 8.25, 4.7])
expts=[]                          # Poits to fit
yy=zeros((204),float)
w=150
c = controls(x=300, y=50, width=w, height=w, range=60)
t1 = toggle(pos=(0,0), width=30, height=30, text0='1 polynom deg 8', 
      text1='4 polynms deg. 2', action=lambda:  selectpoly())

def selectpoly():
    global polinom                         # Change previous value
    if t1.value:
        polinom = 3        
    else:
        polinom = 9    

def axis():
    xmin=-200
    xmax=200
    xincr=100
    yincr=400.0/6.0
コード例 #38
0
ファイル: FinalMSL.py プロジェクト: richard2191/Python
#Setting/Resetting planet positions & relative velocity vectors
def setplanets():
    for i in[0, 3, 4, 7]:
        bodies[i].pos = (bodies[i].orbit*cos(bodies[i].angle), bodies[i].orbit*sin(bodies[i].angle),0)
        bodies[i].velocity = vector(-(bodies[i].speed*sin(bodies[i].angle)), bodies[i].speed*cos(bodies[i].angle),0)
    msl.pos =       (earth.pos.x+earth.radius,earth.pos.y,0)
    msl.velocity =      vector(-(earth.speed*sin(earth.angle)),(earth.speed*cos(earth.angle))+msl.speed,0)
    moon.pos =      (moon.orbit*cos(moon.angle)+earth.pos.x, moon.orbit*sin(moon.angle)+earth.pos.y,0)
    moon.velocity =     vector((earth.velocity.x-(moon.speed*sin(moon.angle))),(earth.velocity.y+(moon.speed*cos(moon.angle))),0)
    deimos.pos =    (deimos.orbit*cos(deimos.angle)+mars.pos.x, deimos.orbit*sin(deimos.angle)+mars.pos.y,0)
    deimos.velocity =   vector((mars.velocity.x-(deimos.speed*sin(deimos.angle))),(mars.velocity.y+(deimos.speed*cos(deimos.angle))),0)
    phobos.pos =    (phobos.orbit*cos(phobos.angle)+mars.pos.x, phobos.orbit*sin(phobos.angle)+mars.pos.y,0)
    phobos.velocity =   vector((mars.velocity.x-(phobos.speed*sin(phobos.angle))),(mars.velocity.y+(phobos.speed*cos(phobos.angle))),0)

#Window control
c = controls(x=95, y=20, width=150, height=300, range=60)
readouts = display(title='Info', width=300, height=280, x=20, y=340)
scene = display(title='Main Window', width=800,height=600, x=340, y=20, background=(0,0,0))

############################
# Decleration of Variables #
############################

#Sun Constants [4]
sun1= local_light(pos=(0,0,0), color=color.yellow)
sun=sphere(pos=sun1.pos, color=sun1.color, material=materials.emissive)
sun.velocity=vector(0,0,0)
sun.mass=1.98892e30
sun.radius=6955e6

#Earth Constants [2]
コード例 #39
0
ファイル: co2_gas_2.py プロジェクト: michaelaye/pymars
observationfp = ghistogram(bins=arange(0,40.,deltal),
                        accumulate=1, average=1, color=color.orange)

dfp = 1.
for fp in arange(0,40.+dfp,dfp): # theoretical prediction
    theoryl.plot(pos=(fp,Natoms*exp(-fp/meanfp)*deltal/meanfp))
###########################################
##add windows for future additions
###########################################
##pgraph = gdisplay(xmin=-0.1,xmax=1., x=win,y=.5*win, ymax = Natoms/5.,
##             width=win, height=win/2., xtitle='x', ytitle='dN',
##                 title="Pressure")
##panel = gdisplay(xmin=-0.1,xmax=1., x=2.*win,y=0, ymax = Natoms/5.,
##             width=.7*win, height=2*win, xtitle='x', ytitle='dN',
##                 title="Control panel")
ctrl = controls(x=2*win, y=0, width=.7*win, height=2*win, title='Control Panel')
bpause = button(pos=(0,30), width=60, height=30,
             action=lambda: pause())
##brepeat = button(pos=(0,60), width=60, height=30, text='Repeat',
##             action=lambda: repeat())
##benergy = button(pos=(0,90), width=60, height=30,
##             action=lambda: energy())
##bget = button(pos=(0,0), width=60, height=30, text='Get File',
##              action=lambda: getsituation())
##bsave = button(pos=(0,-30), width=60, height=30, text='Save File',
##              action=lambda: savesituation())
##breset = button(pos=(0,-60), width=60, height=30, text='Reset',
##             action=lambda: reset())
##pause(state=1)
##bget.state = 0
##breset.state = 0
コード例 #40
0
ファイル: bloch.py プロジェクト: rnowotniak/qclib
        arc2 = curve()
        self.arcs = (arc1, arc2)

    def __redraw(self):
        self.axis = (self.X, self.Z, self.Y)
        self.__drawlines()
        if hasattr(self, 'label'):
            self.label.pos = self.axis
            self.label.text = self.__getlabel()



scene = display(title="Qubit Bloch sphere. Robert Nowotniak (C) 2006", width=790, height=650)
scene.ambient = 0.4

c = controls(x=0, y=0, width = 400, height = 100, range = 100, title = 'Angles controls')
s1 = slider(pos=(-90,  10), min=0, max=pi/2, length = 180, action=lambda: setangles())
s2 = slider(pos=(-90, -10), min=0, max=2*pi, length = 180, action=lambda: setangles())

def setangles():
    qubit.theta = s1.value
    qubit.phi = s2.value

torusesThickness = 0.018
labelHeights = 25

ring(color = color.red, pos=(0,0,0), radius=1, thickness=torusesThickness, axis=(0,0,1))
ring(color = color.green, pos=(0,0,0), radius=1, thickness=torusesThickness, axis=(0,1,0))
ring(color = color.blue, pos=(0,0,0), radius=1, thickness=torusesThickness, axis=(1,0,0))

curve(pos=[(-1,0,0), (1,0,0)], color=color.red)
         pos=(mark[n].x - marker_font, mark[n].y - floor.height * 1.5,
              mark[n].z),
         height=marker_font,
         color=mark[n].color)

## set up graph window----------------------------------------------
point_r = 1  # size of graphing sphere points

graph = display(x=screen.width + 10,
                width=800,
                height=800,
                center=(40, 30, 40),
                title="angle and V vs. range")
c = controls(x=screen.x,
             y=screen.height + 5,
             width=screen.width,
             height=200,
             title="Simulation Controls")

graph.select()
width = 1
## angle
x_axis = arrow(axis=(1, 0, 0), length=90, shaftwidth=width, color=color.red)
# make angle tick marks
marker_font = 13
mark_x = {}
divisions = 6
for n in range(0, divisions + 1):
    mark_x[n] = box(length=floor.length / 50,
                    height=floor.height * 1.1,
                    width=floor.width,
コード例 #42
0
from visual.graph import *
from visual.controls import *

escena = display(width=600, hight=600, range=100)  #para pintar
escena.center = (0, 0, 200)  #trae curve pos a la posicion (0,0,200)
piramide = pyramid(pos=(-50, 0, 0), size=(100, 50, 200))

caja = []  #lista vacía
curve(pos=[(-250, -250,
            250), (250, -250, 250), (250, 250, 250), (-250, 250,
                                                      250), (-250, -250, 250)])
curve(pos=[(-250, -250, -250), (250, -250,
                                -250), (250, 250,
                                        -250), (-250, 250,
                                                -250), (-250, -250, -250)])
C = controls(title='colores', x=600, y=0, width=300, height=300, range=255)


def escojaro(obj):
    return obj.value


def escojaz(obj):
    return obj.value


def escojaver(obj):
    return obj.value


#Deslizadores
コード例 #43
0
def changeA():
    if choice != 3:
        print('''This won't do you much good right now.''')
    else:
        print('Amplitude of driven mass changed to:', A.value)


def changeR():
    print('Speed of animation changed to:', R.value)


# Create controls window
C = controls(
    title='Sliders for k(cyan), w(magenta), A(yellow), and rate(green)',
    x=640,
    y=0,
    height=600,
    width=640,
)
# Create a button in the controls window:
reset = button(pos=(-70, -60),
               length=15,
               height=15,
               text='RESET',
               action=lambda: change(),
               color=color.red)
k = slider(pos=(-30, 60),
           min=5,
           max=50,
           length=60,
           width=30,
コード例 #44
0
    def __redraw(self):
        self.axis = (self.X, self.Z, self.Y)
        self.__drawlines()
        if hasattr(self, 'label'):
            self.label.pos = self.axis
            self.label.text = self.__getlabel()


scene = display(title="Qubit Bloch sphere. Robert Nowotniak (C) 2006",
                width=790,
                height=650)
scene.ambient = 0.4

c = controls(x=0,
             y=0,
             width=400,
             height=100,
             range=100,
             title='Angles controls')
s1 = slider(pos=(-90, 10),
            min=0,
            max=pi / 2,
            length=180,
            action=lambda: setangles())
s2 = slider(pos=(-90, -10),
            min=0,
            max=2 * pi,
            length=180,
            action=lambda: setangles())


def setangles():
コード例 #45
0
ファイル: test.py プロジェクト: ncanac/TicTacToe_4x4x4
def menu():
    c=controls(title='Menu',x=0,y=0,width=scene.width,height=100,range=50)
    b=button(pos=(0,0),width=60,height=60,text='Click me')
コード例 #46
0

pause = False
falling = False

console = True

g = vector(0, -5, 0)
s_g = 40 * g
m = 1  # mass of ball
mu = .1  # coefficeint of friction

# controls window
h_win = 600
spacing = 8
c = controls(x=0, width=400, height=h_win, title="Simulation Controls")

##control_2 = slider(text = 'Power 2',min = -3, max = 2, pos=(-apart*9,.5*apart), width=7, length=60, axis=(1,0,0), action = lambda:set_coeff(control_2))

indent = -40
begin_power_controls = indent
apart = 14
lbl_size = 10
h_button = 10
wid = 10

start = button(pos=(0, 80),
               height=h_button,
               width=2 * h_button,
               text='Pause',
               action=lambda: pausenow())
コード例 #47
0
def CambiaLambda(val):
    global lambdaA
    global labelLamb
    Reset()
    lambdaA = val*3.14159/180
    labelLamb.text = "Lambda = {0} grados".format(val)
    
def CambiaOmega(val):
    global omega
    global labelOmega
    Reset()
    omega = val
    labelOmega.text = "Omega = {0:.2}".format(val)
    
# Control
control = controls(title = 'Parametros', x = grafica.x, y = grafica.y + grafica.height + 8, width = 400, height = 400, range = 50)
labelVAT = label(display = control.display, text = "Vel. Tierra = 0.1", pos = (30, 0), height = 8)
sliderVAT = slider(pos = (-40,0), length = 50, axis = (1,0,0), width = 5, action = lambda: CambiaVelAngularTierra(sliderVAT.value), min = 0.00, max = 15000)
sliderVAT.value = 4750

labelLamb = label(display = control.display, text = "Lambda = 1 rad", pos = (30, -20), height = 8)
sliderLamb = slider(pos = (-40,-20), length = 50, axis = (1,0,0), width = 5, action = lambda: CambiaLambda(sliderLamb.value), min = 0.00, max = 180)
sliderLamb.value = 90

labelOmega = label(display = control.display, text = "Omega = 1", pos = (30, -40), height = 8)
sliderOmega = slider(pos = (-40,-40), length = 50, axis = (1,0,0), width = 5, action = lambda: CambiaOmega(sliderOmega.value), min = 0.00, max = 3)
sliderOmega.value = 1

menuButton = menu(pos = (0,30), height = 15, width = 30, text = 'Vista')
menuButton.items.append(('Tierra', lambda: CambiaVistaTierra(True)))
menuButton.items.append(('Pendulo', lambda: CambiaVistaTierra(False)))
コード例 #48
0
# Preparar gráfico
graf = display(title="Curva de Lissajous", x=scene.x + scene.width + 8,
               y=scene.y, width=384, height=300)
               
graf.userzoom = True
graf.userspin = True
graf.autoscale = True
graf.visible = False
graf.select()

# Agregar títulos y ejes al gráfico
ls = curve(display=graf)

# Crear controles
ctrls = controls(x=graf.x, y=graf.y + graf.height + 8, width=384,
                 height=382, range=100, title="Opciones")
                 
sliderMasa = slider(pos=(-55,80), length=100, axis=(1,0,0), width=5,
                    action=lambda: setMasa(sliderMasa.value), min=1, max=60)

label(display=ctrls.display, text="Masa:", pos=(-75,80), height=8)
lblMasa = label(display=ctrls.display, text="0 kg", pos=(70,80), height=8)

sliderKx = slider(pos=(-55,66), length=100, axis=(1,0,0), width=5,
                  action=lambda: setKx(sliderKx.value), min=1, max=1000)

label(display=ctrls.display, text="K (x):", pos=(-75,66), height=8)
lblKx = label(display=ctrls.display, text="0 N/m", pos=(70,66), height=8)

sliderKy = slider(pos=(-55,54), length=100, axis=(1,0,0), width=5,
                    action=lambda: setKy(sliderKy.value), min=1, max=1000)
コード例 #49
0
           background=color.white,
           pos=(0, 0.5, 0))
lr = label(border=10,
           color=color.black,
           background=color.white,
           pos=lf.pos + (0, -0.5, 0))
lm = label(border=10,
           color=color.black,
           background=color.white,
           pos=lf.pos + (0, -1, 0))

scene2 = display(title='show')  #建立視窗模擬實際狀況
center = sphere(radius=0.05)
a = sphere(pos=center.pos + (1, 0, 0), radius=0.1, color=(1, 0, 0))

c = controls(width=330, height=440)  #建立控制視窗
r = slider(min=0.3, max=3.0, length=70, width=20)  #m
m = slider(min=1, max=20, length=70, width=20, pos=(0, -60, 0))  #m
botr = button(pos=r.pos + (-50, 0), text='radius(m)')
botm = button(pos=botr.pos + (0, -60), text='mass(kg)')

while True:
    rate(1 / dt)
    a.pos.x = r.value * np.cos(w * t)  #x=r*cos(w*t)
    a.pos.y = r.value * np.sin(w * t)  #y=r*sin(w*t)
    lf.text = u'Centripetal force=' + str(
        round(m.value * w * w * np.sqrt(a.pos.x**2 + a.pos.y**2), 2)) + 'N'
    lr.text = u'radius=' + str(round(r.value, 2)) + ' m'
    lm.text = u'mass=' + str(round(m.value, 2)) + ' kg'
    t += dt
コード例 #50
0
ファイル: sim.py プロジェクト: RoboArmadillo/RoboSim-V1

def togglecubecolor(): # called on toggle switch flips
    global SWARM_MODE
    if SWARM_MODE == False:
        SWARM_MODE= True
    else:
        SWARM_MODE = False

def number_of_robots(obj): # called on slider drag events
    global SWARM_NUMBER
    SWARM_NUMBER = int(obj.value)


 
c = controls(width=500, height=500) # Create controls window
# Create a button in the controls window:
b = button( pos=(0,50), width=90, height=60,
              text='Start Simulation', action=lambda: change() )

t1 = toggle(pos=(35,-25), width=10, height=10, text0='False', text1='True', action=lambda: togglecubecolor())
s3 = slider(pos=(50,-60), width=7, length=50, axis=(0,1,0),min=1,max = 11, action=lambda: number_of_robots(s3))
m4 = menu(pos=(50,5,-5), height=7, width=65, text='Swarm Mode Stuff')



s2 = slider(pos=(-60,-60), width=7, length=50, axis=(0,1,0), action=lambda: number_of_markers(s2))
m1 = menu(pos=(-60,-70,0), height=7, width=10, text='0')
m2 = menu(pos=(-60,-5,0), height=7, width=10, text='25')
m3 = menu(pos=(-55,5,0), height=7, width=65, text='Number of Tokens')
コード例 #51
0
    else:
        loadVertical(spring, wall, ground, initBoxPosition, initBoxVelocity, boxMass, initSpringPosition, initSpringAxis, horSpringLength)


### start horizontal
(spring, wall, ground, sBox, vBox, pBox) = initVertical(spring, wall, wall, horSpringLength, boxMass, scene, verSceneCenter)


### general visual elements
attributesLabel = label(pos = scene.center, color = color.white, height = 10, border = 6, display = scene)
attributesLabelText = LabelText(attributesLabel, orientationWrapper[0], kWrapper[0])
attributesLabelText.updateAssociatedLabelText()

### sets up the control window

c = controls(title="Configure Spring Attributes", width=300, height=400)

def changeOrientation(orientationWrapper, attributesLabelText):
    if (orientationWrapper[0] == 'horizontal'):
        orientationWrapper[0] = 'vertical'
    else:
        orientationWrapper[0] = 'horizontal'

    attributesLabelText.setOrientation(orientationWrapper[0])
    attributesLabelText.updateAssociatedLabelText()

btnOrientation = button(pos = (0, 60), width = 120, height = 40, border = 0, text = 'Change String Orientation', action = lambda: changeOrientation(orientationWrapper, attributesLabelText))



#  count = 0
コード例 #52
0
    global m
    global labelM
    Reset()
    m = val
    labelM.text = "M = {0} ".format(val)
    
def CambiaK(val):
    global k
    global labelK
    Reset()
    k = val
    labelK.text = "K = {0} ".format(val)

    
# Control
control = controls(title = 'Parametros', x=scene.x + scene.width + 8, y = scene.y, width = 400, height = 400, range = 50)
labelX1 = label(display = control.display, pos = (30, 0), height = 8)
sliderX1 = slider(pos = (-40,0), length = 50, axis = (1,0,0), width = 5, action = lambda: CambiaX1(sliderX1.value), min = 0.00, max = 10)
sliderX1.value = x1_init
CambiaX1(x1_init)

labelX2 = label(display = control.display, pos = (30, -5), height = 8)
sliderX2 = slider(pos = (-40,-5), length = 50, axis = (1,0,0), width = 5, action = lambda: CambiaX2(sliderX2.value), min = 0.00, max = 10)
sliderX2.value = x2_init
CambiaX2(x2_init)

labelX3 = label(display = control.display, pos = (30, -10), height = 8)
sliderX3 = slider(pos = (-40,-10), length = 50, axis = (1,0,0), width = 5, action = lambda: CambiaX3(sliderX3.value), min = 0.00, max = 10)
sliderX3.value = x3_init
CambiaX3(x3_init)
コード例 #53
0
    filePresas = open('presas.csv', 'w')
    filePred = open('pred.csv', 'w')
    for index in range(nDatos):
        filePresas.write('{0:3d}, {1:3d}\n'.format(vTiempos[index],
                                                   vPresas[index]))
        filePred.write('{0:3d}, {1:3d}\n'.format(vTiempos[index],
                                                 vPred[index]))
    filePresas.close()
    filePred.close()


# Controles
control = controls(title='Parametros',
                   x=scene.width + 10,
                   y=scene.y,
                   width=300,
                   height=300,
                   range=50)
boton = button(pos=(0, 0),
               width=60,
               height=60,
               text='Guardar datos',
               action=lambda: Guardar())

# Grafica
grafica = display(title="Animales",
                  x=scene.x + scene.width + 8,
                  y=control.y + control.width,
                  width=384,
                  height=300,
                  background=(0, 0, 0))
コード例 #54
0
        wf.text = "1/2 sin"


def stop():
    stp.stp = 1


def autotoggle():
    if auto.text == "Auto":
        auto.text = "Manual"
    elif auto.text == "Manual":
        auto.text = "Auto"


#Control scene
c = controls(title='Controls', x=0, y=600, width=1024, height=150, range=50)
ss = button(pos=(-5, 0),
            width=10,
            height=10,
            text='Start',
            action=lambda: togglego())
wf1 = button(pos=(-15, 0),
             width=10,
             height=10,
             text='sine',
             action=lambda: wfcycle(wf1))
wf2 = button(pos=(25, 0),
             width=10,
             height=10,
             text='sine',
             action=lambda: wfcycle(wf2))
コード例 #55
0
ファイル: controlstest.py プロジェクト: rubenrm97/vpython-wx
    else:
        s1.value = s2.value


def cuberate(value):
    cube.dtheta = 2 * value * pi / 1e4


w = 350
display(x=w, y=0, width=w, height=w, range=1.5, forward=-vector(0, 1, 1))
cube = box(color=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 = controls(x=0, y=0, width=w, height=w, 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
# in the appropriate namespace context in the case of importing the controls module.
コード例 #56
0
ファイル: main-file.py プロジェクト: maccabifan08/cancer
    def initializePositions(self):
        #wire frame of space
        backBottom = curve(pos=[(self.MINX, self.MINY, self.MINZ),
                                (self.MAXX, self.MINY, self.MINZ)],
                           color=color.white)
        backTop = curve(pos=[(self.MINX, self.MAXY, self.MINZ),
                             (self.MAXX, self.MAXY, self.MINZ)],
                        color=color.white)
        frontBottom = curve(pos=[(self.MINX, self.MINY, self.MAXZ),
                                 (self.MAXX, self.MINY, self.MAXZ)],
                            color=color.white)
        frontTop = curve(pos=[(self.MINX, self.MAXY, self.MAXZ),
                              (self.MAXX, self.MAXY, self.MAXZ)],
                         color=color.white)
        leftBottom = curve(pos=[(self.MINX, self.MINY, self.MINZ),
                                (self.MINX, self.MINY, self.MAXZ)],
                           color=color.white)
        leftTop = curve(pos=[(self.MINX, self.MAXY, self.MINZ),
                             (self.MINX, self.MAXY, self.MAXZ)],
                        color=color.white)
        rightBottom = curve(pos=[(self.MAXX, self.MINY, self.MINZ),
                                 (self.MAXX, self.MINY, self.MAXZ)],
                            color=color.white)
        rightTop = curve(pos=[(self.MAXX, self.MAXY, self.MINZ),
                              (self.MAXX, self.MAXY, self.MAXZ)],
                         color=color.white)
        backLeft = curve(pos=[(self.MINX, self.MINY, self.MINZ),
                              (self.MINX, self.MAXY, self.MINZ)],
                         color=color.white)
        backRight = curve(pos=[(self.MAXX, self.MINY, self.MINZ),
                               (self.MAXX, self.MAXY, self.MINZ)],
                          color=color.white)
        frontLeft = curve(pos=[(self.MINX, self.MINY, self.MAXZ),
                               (self.MINX, self.MAXY, self.MAXZ)],
                          color=color.white)
        frontRight = curve(pos=[(self.MAXX, self.MINY, self.MAXZ),
                                (self.MAXX, self.MAXY, self.MAXZ)],
                           color=color.white)

        # Creating initial 8 cells
        for x in range(int(self.num / 2), int(self.num / 2) + 2):
            for y in range(int(self.num / 2), int(self.num / 2) + 2):
                for z in range(int(self.num / 2), int(self.num / 2) + 2):
                    self.array[x][y][z] = sphere(frame=self.f,
                                                 pos=(x, y, z),
                                                 radius=self.radius,
                                                 color=color.white)

        c = controls(height=360)  # Creating the buttons to control the Display
        b1 = button(pos=(0, 75),
                    height=42,
                    width=110,
                    text='Show All',
                    action=lambda: self.showall())
        b2 = button(pos=(0, 25),
                    height=42,
                    width=110,
                    text='Show Cancer Cells',
                    action=lambda: self.showcancer())
        b5 = button(pos=(0, -25),
                    height=42,
                    width=100,
                    text='Chemo 1 doze',
                    action=lambda: self.chemodoze())