当前位置: 首页>>代码示例>>Python>>正文


Python Target.draw方法代码示例

本文整理汇总了Python中target.Target.draw方法的典型用法代码示例。如果您正苦于以下问题:Python Target.draw方法的具体用法?Python Target.draw怎么用?Python Target.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在target.Target的用法示例。


在下文中一共展示了Target.draw方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Map

# 需要导入模块: from target import Target [as 别名]
# 或者: from target.Target import draw [as 别名]

#.........这里部分代码省略.........
			self.simStats.btPlaceTarget.setEnabled(False)
			self.simStats.btPlaceRobot.setEnabled(True)
			
			self.repaint()
			
		elif self.mouseActionType == Map.PlaceBlockAction:
			
			self.dragXend = x
			self.dragYend = y
			
			self.dragObject.updateDrag(self.dragXstart, self.dragYstart,
					self.dragXend, self.dragYend)
		
			self.objects.append(self.dragObject)
			self.dragObject = None
		
			self.saveToImage = True
			self.setChanged(True)
		
			self.mouseActionType = Map.NoAction
			#TODO
			#print(QMouseEvent.pos())
			self.repaint()
	
	
	def paintEvent(self, event):
		rect = self.contentsRect()
		
		if self.saveToImage == True:
			
			ImageMap.image = QtGui.QImage(rect.right(), rect.bottom(), QtGui.QImage.Format_RGB32)
			imagePainter = QtGui.QPainter(ImageMap.image)
			
			self.draw(imagePainter)
			
			ImageMap.image.save('image.jpg')
			
			self.saveToImage = False
	
		painter = QtGui.QPainter(self)
		self.draw(painter)
	
	
	def draw(self, painter):
		
		rect = self.contentsRect()
		
		painter.setPen(QtGui.QColor(0xff0000))
		#TODO
		#QtCore.qDebug('[sim_map.Map.paintEvent] %d %d %d %d' % (rect.top(), rect.left(), rect.bottom(), rect.right())) 
		painter.fillRect(0, 0, rect.right(), rect.bottom(), QtGui.QColor(0xffffff))
		
		for obj in self.objects:
			obj.draw(painter)
		
		if not self.dragObject is None:
			self.dragObject.draw(painter)
			
		if self.robot is not None and self.saveToImage != True:
			self.robot.draw(painter)
		
		if self.target is not None and self.saveToImage != True:
			self.target.draw(painter)
	
	
	def keyPressEvent(self, event):
开发者ID:paulvlase,项目名称:intelligent_car,代码行数:70,代码来源:sim_map.py

示例2: Trainer

# 需要导入模块: from target import Target [as 别名]
# 或者: from target.Target import draw [as 别名]

#.........这里部分代码省略.........
                elif event.key == pygame.K_f:
                    if self.dof == 1:
                        self.set_dof(2)
                    elif self.dof == 2:
                        self.set_dof(1)
                elif event.key == pygame.K_b:
                    self.target.set_new_target()
                elif event.key == pygame.K_v:
                    self.training_mode = not(self.training_mode)
                elif event.key == pygame.K_c:
                    self.target.set_fb_mode('hrf')
                elif event.key == pygame.K_x:
                    self.target.set_fb_mode('impulse')
                elif event.key == pygame.K_m:
                    if self.input_mode == 'mouse':
                        self.input_mode = 'sensor'
                    elif self.input_mode == 'sensor':
                        self.input_mode = 'mouse'

    def run_timed(self):
        ###########################################
        # main loop for time-to-target experiment #
        ###########################################
        while True:
            time_passed = self.clock.tick_busy_loop(self.FRAME_RATE)
            self.check_input()
            self.input_pos = self.get_pos()
            self.cursor.update(self.input_pos)
            self.target.update(self.cursor.pos)


            if not(self.timers['reset_hold'].time_limit_hit):
                gr.check_in_start(self, time_passed)
                self.target.draw_bool = True
            elif not(self.cursor.has_left):
                gr.check_if_left(self)
                self.target.draw_bool = False
            elif self.training_mode:
                self.target.draw_bool = True
            else:
                self.target.draw_bool = False

            if self.cursor.has_left:
                gr.frame_based_updates_timed(self)
                self.timers['signal'].update(time_passed)
                self.timers['tr'].update(time_passed)
                if self.timers['signal'].time_limit_hit:
                    gr.signal_based_updates(self)
                    if self.timers['tr'].time_limit_hit:
                        gr.tr_based_updates(self)

            self.draw_background()
            self.therm.draw(self.cursor.has_left,
                            self.target.error_metric)
            self.target.draw()
            if (self.trial_count == 0
                    and not self.cursor.has_left):
                self.draw_instructions_timed()
            self.cursor.draw()
            pygame.display.flip()

    def run_block(self):
        ###########################################
        # main loop for block feedback experiment #
        ###########################################
        self.target.draw_bool = False 
开发者ID:efunn,项目名称:rtfmri-trainer,代码行数:70,代码来源:trainer.py


注:本文中的target.Target.draw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。