def closeDev(devID='current'): """ DES: close selected device INP: (int) device ID, 'all','current' (default) """ global CurrentDev, DevList if devID in ['current', 'curren', 'curre', 'curr', 'cur']: __MessHand.longinfo("closing the current device") ppgplot.pgclos() DevList.remove(CurrentDev) if not DevList == []: ppgplot.pgslct(DevList[0]) CurrentDev = ppgplot.pgqid() # store the actual deviceID else: CurrentDev = 0 elif devID in ['all']: __MessHand.longinfo("closing all devices") for device in DevList: ppgplot.pgslct(device) ppgplot.pgclos() DevList = [] CurrentDev = 0 elif devID in DevList: __MessHand.longinfo("closing device " + ` devID `) ppgplot.pgslct(devID) ppgplot.pgclos() DevList.remove(devID) if devID == CurrentDev and DevList != []: ppgplot.pgslct(DevList[0]) CurrentDev = ppgplot.pgqid() # store the actual deviceID else: ppgplot.pgslct(CurrentDev) else: __MessHand.error("this is not an open device: " + ` devID `) __queryDev()
def closeplot(): """ closeplot() Close the currenly opened device, finalizing the plot. """ # Close plot if ppgplot.pgqid()!=0: ppgplot.pgclos() else: sys.stderr.write("Cannot close plot. No pgplot device open.\n") raise "No open pgplot device"
def __checkReopen(): """ DES: check if the current device is actually open and usable, or if it has to be reopenned (e.g. after a plot produced by apexCalibrator) """ global CurrentDev, DevList ppgId = ppgplot.pgqid() if ppgId != CurrentDev: CurrentDev = ppgId ppgplot.pgask(0) DevList.append(CurrentDev)
def selectDev(devID=''): """ DES: select an open device INP: (int) device ID """ global CurrentDev, DevList if devID in DevList: ppgplot.pgslct(devID) # select the deviceID CurrentDev = ppgplot.pgqid() # store the actual pgplot deviceID else: __MessHand.error("this is not an open device: " + ` devID `) __queryDev()
def nextpage(vertical=False): """ Start a new page in the currently opened device. Default is to orient paper horizontally (landscape). If vertical is True then the paper will be oriented vertically. """ # New page if ppgplot.pgqid()!=0: ppgplot.pgpage() ppgplot.pgswin(0,1,0,1) if vertical: ppgplot.pgpap(7.9, 11.0/8.5) else: ppgplot.pgpap(10.25, 8.5/11.0) ppgplot.pgiden() else: sys.stderr.write("Cannot start new page. No pgplot device open.\n") raise "No open pgplot device"
def beginplot(fn, vertical=False): """ Set up a colour ps plot with filename fn for letter-size paper. Default is to orient paper horizontally (landscape). If vertical is True then the paper will be oriented vertically. """ if ppgplot.pgqid()!=0: # ppgplot already has a device open # # QUESTION: Should raise error here? # pass else: # Setup ppgplot.pgbeg("%s/CPS" % fn, 1, 1) if vertical: ppgplot.pgpap(7.9, 11.0/8.5) else: ppgplot.pgpap(10.25, 8.5/11.0) ppgplot.pgiden()
def __queryDev(): """ DES: query open and current devices INP: (int) a = message weight """ global CurrentDev, DevList DevList.sort() CurrentDev = ppgplot.pgqid() # store the actual deviceID if CurrentDev: __MessHand.info("current device = " + ` CurrentDev `) if not CurrentDev in DevList: # for some reason a device is open and not in the DevList DevList.append(CurrentDev) else: __MessHand.warning("current device = none") if len(DevList) > 0: __MessHand.longinfo("open devices = " + ` DevList `) else: __MessHand.warning("open devices = none")