Source code for ImageSizePanel

"""
:filename:     ImageSizePlugin.py
:author:       thor@tordivel.no
:requirements: Scorpion 9.0.0.492 or higher

Scorpion plugin panel for showing acquired image size

::

  1.0.0.3, 11nov2015, RL: modified for autodoc
  1.0.0.2, 12nov2011, TV: remove start message
  1.0.0.1, 08oct2011, TV: created
"""

__version__ = '1.0.0.3'

from Scorpion import RegisterCallback,PluginChanged,GetControlByHandle,GetFloatValue,GetBoolValue,InputInt,GetImageMatr,PixToRef

[docs]class Plugin(object): def __init__(self,cntr,name): self.name=name cntr.deleteControls() #delete previous added controls if any self.panel=cntr.addControl('Panel',0,0) self.panel.align=5 #client self.panel.caption='Press Start to activate system' self.panel.font.size = 15 RegisterCallback('Actions.BeforeStart',self.beforeStart) RegisterCallback('Actions.AfterStop',self.afterStop) RegisterCallback('System.AfterInspect',self.afterInspect) RegisterCallback('System.ImageComplete',self.imageComplete) print self,'__init__' def __del__(self): print self,'__del__'
[docs] def __str__(self): ''' return a unique persistance name for host application storage ''' return '%s_%s'%(self.__class__.__name__,self.name)
[docs] def getConfig(self): ''' returns plugin configuration as string ''' from SPB import CreateSpb spb=CreateSpb() #create a spb instance, populate with the plugin configuration #and return the xml string spb.setInt('version',1) spb.setInt('fontSize',self.panel.font.size) return spb.xml
[docs] def setConfig(self,value): ''' set plugin configuration from the string 'value' ''' from SPB import CreateSpb spb=CreateSpb(value) # TODO: extract plugin configuration from the spb object if spb.getInt('version')>0: if spb.getInt('fontSize')<>None: self.panel.font.size=spb.getInt('fontSize')
[docs] def configure(self): ''' configure the plugin, return bool whether changed or not ''' ok,result=InputInt('Set Property','fontSize',self.panel.font.size) if ok : self.panel.font.size=result return ok
[docs] def beforeStart(self): ''' beforeStart ''' self.panel.caption='-'
[docs] def afterStop(self): ''' afterStop ''' self.panel.caption=''
[docs] def imageComplete(self,Image): ''' imageComplete ''' img = GetImageMatr(Image) rows,cols = img.dim() upperLeft = PixToRef('reference',0,0) lowerRight = PixToRef('reference',rows,cols) self.panel.caption=' FOV = (%.1f,%.1f) - (%.1f,%.1f) ' % (upperLeft[0],upperLeft[1],lowerRight[0],lowerRight[1])
[docs] def afterInspect(self,Result): ''' afterInspect - update panel ''' pass
[docs]def CreatePlugin(hWnd, name=''): ''' Scorpion Plugin Stub - Required ''' cntr=GetControlByHandle(hWnd) return Plugin(cntr,name)