本文整理汇总了Python中director.timercallback.TimerCallback.singleShot方法的典型用法代码示例。如果您正苦于以下问题:Python TimerCallback.singleShot方法的具体用法?Python TimerCallback.singleShot怎么用?Python TimerCallback.singleShot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类director.timercallback.TimerCallback
的用法示例。
在下文中一共展示了TimerCallback.singleShot方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: startApplication
# 需要导入模块: from director.timercallback import TimerCallback [as 别名]
# 或者: from director.timercallback.TimerCallback import singleShot [as 别名]
def startApplication(enableQuitTimer=False):
appInstance = QtGui.QApplication.instance()
if enableQuitTimer:
quitTimer = TimerCallback()
quitTimer.callback = appInstance.quit
quitTimer.singleShot(0.1)
appInstance.exec_()
示例2: PropertyPanelConnector
# 需要导入模块: from director.timercallback import TimerCallback [as 别名]
# 或者: from director.timercallback.TimerCallback import singleShot [as 别名]
class PropertyPanelConnector(object):
def __init__(self, propertySet, propertiesPanel, propertyNamesToAdd=None):
self.propertySet = propertySet
self.propertyNamesToAdd = propertyNamesToAdd
self.propertiesPanel = propertiesPanel
self.connections = []
self.connections.append(self.propertySet.connectPropertyAdded(self._onPropertyAdded))
self.connections.append(self.propertySet.connectPropertyChanged(self._onPropertyChanged))
self.connections.append(self.propertySet.connectPropertyAttributeChanged(self._onPropertyAttributeChanged))
self.propertiesPanel.connect('propertyValueChanged(QtVariantProperty*)', self._onPanelPropertyChanged)
self.timer = TimerCallback()
self.timer.callback = self._rebuildNow
self._blockSignals = True
PropertyPanelHelper.addPropertiesToPanel(self.propertySet, self.propertiesPanel, self.propertyNamesToAdd)
self._blockSignals = False
def cleanup(self):
self.timer.callback = None
self.propertiesPanel.disconnect('propertyValueChanged(QtVariantProperty*)', self._onPanelPropertyChanged)
for connection in self.connections:
self.propertySet.callbacks.disconnect(connection)
def _rebuild(self):
if not self.timer.singleShotTimer.isActive():
self.timer.singleShot(0)
def _rebuildNow(self):
self._blockSignals = True
self.propertiesPanel.clear()
PropertyPanelHelper.addPropertiesToPanel(self.propertySet, self.propertiesPanel)
self._blockSignals = False
def _onPropertyAdded(self, propertySet, propertyName):
self._rebuild()
def _onPropertyAttributeChanged(self, propertySet, propertyName, propertyAttribute):
self._rebuild()
def _onPropertyChanged(self, propertySet, propertyName):
self._blockSignals = True
PropertyPanelHelper.onPropertyValueChanged(self.propertiesPanel, propertySet, propertyName)
self._blockSignals = False
def _onPanelPropertyChanged(self, panelProperty):
if not self._blockSignals:
PropertyPanelHelper.setPropertyFromPanel(panelProperty, self.propertiesPanel, self.propertySet)
示例3: startQuitTimer
# 需要导入模块: from director.timercallback import TimerCallback [as 别名]
# 或者: from director.timercallback.TimerCallback import singleShot [as 别名]
def startQuitTimer(timeoutInSeconds):
quitTimer = TimerCallback()
quitTimer.callback = ConsoleApp.quit
quitTimer.singleShot(timeoutInSeconds)
示例4: DepthScanner
# 需要导入模块: from director.timercallback import TimerCallback [as 别名]
# 或者: from director.timercallback.TimerCallback import singleShot [as 别名]
class DepthScanner(object):
def __init__(self, view):
self.view = view
self.depthImage = None
self.pointCloudObj = None
self.renderObserver = None
self.windowToDepthBuffer = vtk.vtkWindowToImageFilter()
self.windowToDepthBuffer.SetInput(self.view.renderWindow())
self.windowToDepthBuffer.SetInputBufferTypeToZBuffer()
self.windowToDepthBuffer.ShouldRerenderOff()
self.windowToColorBuffer = vtk.vtkWindowToImageFilter()
self.windowToColorBuffer.SetInput(self.view.renderWindow())
self.windowToColorBuffer.SetInputBufferTypeToRGB()
self.windowToColorBuffer.ShouldRerenderOff()
useBackBuffer = False
if useBackBuffer:
self.windowToDepthBuffer.ReadFrontBufferOff()
self.windowToColorBuffer.ReadFrontBufferOff()
self.initDepthImageView()
self.initPointCloudView()
self._block = False
self.singleShotTimer = TimerCallback()
self.singleShotTimer.callback = self.update
def getDepthBufferImage(self):
return self.windowToDepthBuffer.GetOutput()
def getDepthImage(self):
return self.depthScaleFilter.GetOutput()
def getDepthImageAsNumpyArray(self):
vtk_image = self.getDepthImage()
return vtk_image_to_numpy_array(vtk_image)
def getColorBufferImage(self):
return self.windowToColorBuffer.GetOutput()
def updateBufferImages(self):
for f in [self.windowToDepthBuffer, self.windowToColorBuffer]:
f.Modified()
f.Update()
def initDepthImageView(self):
self.depthImageColorByRange = [0.0, 4.0]
lut = vtk.vtkLookupTable()
lut.SetNumberOfColors(256)
lut.SetHueRange(0, 0.667) # red to blue
lut.SetRange(self.depthImageColorByRange) # map red (near) to blue (far)
lut.SetRampToLinear()
lut.Build()
self.depthScaleFilter = vtk.vtkImageShiftScale()
self.depthScaleFilter.SetScale(1000)
self.depthScaleFilter.SetOutputScalarTypeToUnsignedShort()
self.depthImageLookupTable = lut
self.imageMapToColors = vtk.vtkImageMapToColors()
self.imageMapToColors.SetLookupTable(self.depthImageLookupTable)
self.imageMapToColors.SetInputConnection(self.depthScaleFilter.GetOutputPort())
self.imageView = imageview.ImageView()
self.imageView.view.setWindowTitle('Depth image')
self.imageView.setImage(self.imageMapToColors.GetOutput())
def initPointCloudView(self):
self.pointCloudView = PythonQt.dd.ddQVTKWidgetView()
self.pointCloudView.setWindowTitle('Pointcloud')
self.pointCloudViewBehaviors = viewbehaviors.ViewBehaviors(self.pointCloudView)
def update(self):
if not self.renderObserver:
def onEndRender(obj, event):
if self._block:
return
if not self.singleShotTimer.singleShotTimer.isActive():
self.singleShotTimer.singleShot(0)
self.renderObserver = self.view.renderWindow().AddObserver('EndEvent', onEndRender)
self._block = True
self.view.forceRender()
self.updateBufferImages()
self._block = False
depthImage, polyData, _ = computeDepthImageAndPointCloud(self.getDepthBufferImage(), self.getColorBufferImage(), self.view.camera())
self.depthScaleFilter.SetInputData(depthImage)
self.depthScaleFilter.Update()
self.depthImageLookupTable.SetRange(self.depthScaleFilter.GetOutput().GetScalarRange())
self.imageMapToColors.Update()
#.........这里部分代码省略.........
示例5: AffordanceObjectModelManager
# 需要导入模块: from director.timercallback import TimerCallback [as 别名]
# 或者: from director.timercallback.TimerCallback import singleShot [as 别名]
class AffordanceObjectModelManager(object):
def __init__(self, view):
self.collection = lcmobjectcollection.LCMObjectCollection(channel='AFFORDANCE_COLLECTION_COMMAND')
self.collection.connectDescriptionUpdated(self._onDescriptionUpdated)
self.collection.connectDescriptionRemoved(self._onDescriptionRemoved)
self.view = view
self.notifyFrequency = 30 # throttle lcm messages per second sent for affordance updates
self._ignoreChanges = False
self._pendingUpdates = set()
self.timer = TimerCallback()
self.timer.callback = self._notifyPendingUpdates
self.affordanceUpdater = None
def setAffordanceUpdater(self, affordanceUpdater):
self.affordanceUpdater = affordanceUpdater
def getAffordances(self):
return [obj for obj in om.getObjects() if isinstance(obj, affordanceitems.AffordanceItem)]
def getCollisionAffordances(self):
affs = []
for aff in self.getAffordances():
if aff.getProperty('Collision Enabled'):
affs.append(aff)
return affs
def getAffordanceId(self, aff):
return aff.getProperty('uuid')
def newAffordanceFromDescription(self, desc):
if 'uuid' not in desc:
desc['uuid'] = newUUID()
self.collection.updateDescription(desc)
return self.getAffordanceById(desc['uuid'])
def getAffordanceById(self, affordanceId):
for aff in self.getAffordances():
if self.getAffordanceId(aff) == affordanceId:
return aff
def getAffordanceDescription(self, aff):
return aff.getDescription()
def registerAffordance(self, aff, notify=True):
aff.connectRemovedFromObjectModel(self._onAffordanceRemovedFromObjectModel)
aff.properties.connectPropertyChanged(self._onAffordancePropertyChanged)
aff.getChildFrame().connectFrameModified(self._onAffordanceFrameChanged)
if notify:
self.notifyAffordanceUpdate(aff)
def removeAffordance(self, aff):
self.collection.removeDescription(aff.getProperty('uuid'), notify=False)
def notifyAffordanceUpdate(self, aff):
if not isinstance(aff, affordanceitems.AffordanceItem):
return
shouldNotify = not self._pendingUpdates and not self.timer.singleShotTimer.isActive()
self._pendingUpdates.add(aff)
if shouldNotify:
self._notifyPendingUpdates()
def _notifyPendingUpdates(self):
if self._pendingUpdates:
self.timer.singleShot(1.0/self.notifyFrequency)
for aff in self._pendingUpdates:
try:
self.collection.updateDescription(self.getAffordanceDescription(aff), notify=False)
except:
print traceback.format_exc()
self._pendingUpdates.clear()
def _onAffordancePropertyChanged(self, propertySet, propertyName):
if self._ignoreChanges:
return
self.notifyAffordanceUpdate(self.getAffordanceById(propertySet.getProperty('uuid')))
def _onAffordanceFrameChanged(self, frameObj):
if self._ignoreChanges:
return
aff = frameObj.parent()
self.notifyAffordanceUpdate(aff)
def _onAffordanceRemovedFromObjectModel(self, objectModel, aff):
if self._ignoreChanges:
return
self.removeAffordance(aff)
def _loadAffordanceFromDescription(self, desc):
className = desc['classname']
cls = getattr(affordanceitems, className)
aff = cls(desc['Name'], self.view)
#.........这里部分代码省略.........
示例6: DepthScanner
# 需要导入模块: from director.timercallback import TimerCallback [as 别名]
# 或者: from director.timercallback.TimerCallback import singleShot [as 别名]
class DepthScanner(object):
def __init__(self, view):
self.view = view
self.depthImage = None
self.pointCloudObj = None
self.renderObserver = None
self.parentFolder = 'depth scanner'
self.windowToDepthBuffer = vtk.vtkWindowToImageFilter()
self.windowToDepthBuffer.SetInput(self.view.renderWindow())
self.windowToDepthBuffer.SetInputBufferTypeToZBuffer()
self.windowToDepthBuffer.ShouldRerenderOff()
self.windowToColorBuffer = vtk.vtkWindowToImageFilter()
self.windowToColorBuffer.SetInput(self.view.renderWindow())
self.windowToColorBuffer.SetInputBufferTypeToRGB()
self.windowToColorBuffer.ShouldRerenderOff()
useBackBuffer = False
if useBackBuffer:
self.windowToDepthBuffer.ReadFrontBufferOff()
self.windowToColorBuffer.ReadFrontBufferOff()
self.initDepthImageView()
self.initPointCloudView()
self._block = False
self.singleShotTimer = TimerCallback()
self.singleShotTimer.callback = self.update
self._updateFunc = None
def getDepthBufferImage(self):
return self.windowToDepthBuffer.GetOutput()
def getDepthImage(self):
return self.depthScaleFilter.GetOutput()
def getColorBufferImage(self):
return self.windowToColorBuffer.GetOutput()
def updateBufferImages(self):
for f in [self.windowToDepthBuffer, self.windowToColorBuffer]:
f.Modified()
f.Update()
def initDepthImageView(self):
self.depthImageColorByRange = [0.0, 4.0]
lut = vtk.vtkLookupTable()
lut.SetNumberOfColors(256)
lut.SetHueRange(0, 0.667) # red to blue
lut.SetRange(self.depthImageColorByRange) # map red (near) to blue (far)
lut.SetRampToLinear()
lut.Build()
self.depthScaleFilter = vtk.vtkImageShiftScale()
self.depthScaleFilter.SetScale(1.0)
self.depthScaleFilter.SetOutputScalarTypeToDouble()
self.depthImageLookupTable = lut
self.imageMapToColors = vtk.vtkImageMapToColors()
self.imageMapToColors.SetLookupTable(self.depthImageLookupTable)
self.imageMapToColors.SetInputConnection(self.depthScaleFilter.GetOutputPort())
self.imageView = imageview.ImageView()
self.imageView.view.setWindowTitle('Depth image')
self.imageView.setImage(self.imageMapToColors.GetOutput())
def initPointCloudView(self):
self.pointCloudView = PythonQt.dd.ddQVTKWidgetView()
self.pointCloudView.setWindowTitle('Pointcloud')
self.pointCloudViewBehaviors = viewbehaviors.ViewBehaviors(self.pointCloudView)
def update(self):
if not self.renderObserver:
def onEndRender(obj, event):
if self._block:
return
if not self.singleShotTimer.singleShotTimer.isActive():
self.singleShotTimer.singleShot(0)
self.renderObserver = self.view.renderWindow().AddObserver('EndEvent', onEndRender)
if not self.pointCloudView.visible and not self.imageView.view.visible:
return
self._block = True
self.view.forceRender()
self.updateBufferImages()
self._block = False
depthImage, polyData = computeDepthImageAndPointCloud(self.getDepthBufferImage(), self.getColorBufferImage(), self.view.camera())
self.depthScaleFilter.SetInputData(depthImage)
self.depthScaleFilter.Update()
self.depthImageLookupTable.SetRange(self.depthScaleFilter.GetOutput().GetScalarRange())
#.........这里部分代码省略.........