def __init__(self, ao, tName='', cName=None, tmRelation='pre', xRelation='event', fmt='tk', master=None): _MapCanvas.__init__(self) # bar height is the height of texture in pixels. the total height of a # of a window is determined by the number of textures self.tName = tName self.cName = cName # if none, assumes it is a texture self.tmRelation = tmRelation self.xRelation = xRelation # event or time if cName != None: # its a clone, dont force post tmRelation self.tmRelation = 'post' srcObj = ao.cloneLib.get(tName, cName) srcFmt = 'c' # clone else: srcObj = ao.textureLib[tName] srcFmt = 't' # texture self.c = fmt self.splitSco = eventList.EventSequenceSplit(srcObj, srcFmt) self.splitSco.load(self.tmRelation) # call clean method to remove bad data (strings) self.splitSco.clean() # updates colors and sizeing issues, splitSco must be defined self._updateAoPrefs(ao) self._updateSizePrefs() # looks at self.xRelation self._updateSingleGraphSize() hGutter = 2 # space between graphs nGraphs = len(self.splitSco.getKeys()) self.winWIDTH = self.wSingleGraph self.winHEIGHT = (self.hSingleGraph * nGraphs) + (hGutter * (nGraphs - 1)) # dynamic points xCurrent = 0 yCurrent = 0 # create canvas self.c = imageTools.Canvas(fmt, self.winWIDTH, self.winHEIGHT, self.COLORbgAbs, 'TImap: %s' % tName, master) #draw all parameters for pmtr in self.splitSco.getKeys(): dataList = self.splitSco.getCoord(pmtr, self.xRelation) # data list here is alist of x/y pairs, or possible xy/xy paurs # this will be process w/ process graph coord data title = self.splitSco.getTitle(pmtr) gObj = self._genGraph(dataList, xCurrent, yCurrent, title) gObj.update(self.c) gObj.draw() yCurrent = yCurrent + self.hSingleGraph + hGutter
def __init__(self, ao, srcList, srcFmt='pg', events=240, fmt='tk', master=None): _MapCanvas.__init__(self) self.c = fmt self.events = events # number of events environment.printDebug( ['TPmapCanvas splitSco srcList', srcList, srcFmt]) self.splitSco = eventList.EventSequenceSplit(srcList, srcFmt, self.events) self.splitSco.load() self.xRelation = 'event' # always event for tpmaps # updates colors and sizeing issues, splitSco must be defined self._updateAoPrefs(ao) self._updateSizePrefsDetail() self._updateSingleGraphSize() hGutter = 2 # space between graphs nGraphs = len(self.splitSco.getKeys()) self.winWIDTH = self.wSingleGraph self.winHEIGHT = (self.hSingleGraph * nGraphs) + (hGutter * (nGraphs - 1)) # dynamic points xCurrent = 0 yCurrent = 0 # create canvas self.c = imageTools.Canvas(fmt, self.winWIDTH, self.winHEIGHT, self.COLORbgAbs, 'TPmap', master) #draw all parameters # TODO: this is not showing source and filter, only one value for pmtr in self.splitSco.getKeys(): # xRelation will always be 'event' for parameter displays dataList = self.splitSco.getCoord(pmtr, 'event') title = self.splitSco.getTitle(pmtr) gObj = self._genGraph(dataList, xCurrent, yCurrent, title) gObj.update(self.c) gObj.draw() yCurrent = yCurrent + self.hSingleGraph + hGutter
def __init__(self, cmdObj=None, srcSize=2, dstSize=2, fmt='pil', master=None): # bar height is the height of texture in pixels. the total height of a # of a window is determined by the number of textures if cmdObj == None: from athenaCL.libATH import athenaObj # update need for color prefs update = athenaObj.External() update.updateAll('noMessages') ao = athenaObj.AthenaObject() self.scObj = SC.SetClass() mcObj = MC.MapClass() else: ao = cmdObj.ao self.scObj = cmdObj.scObj update = ao.external # rename update from AO # this is not necesssary, and thwarts manual-pref loading #update.updatePrefs() # get new settings mcObj = cmdObj.mcObj fontTitle = 'micro' fontText = 'micro' COLORfgMain = update.getPref('gui', 'COLORfgMain') COLORfgAlt = update.getPref('gui', 'COLORfgAlt') COLORbgMargin = update.getPref('gui', 'COLORbgMargin') COLORbgGrid = update.getPref('gui', 'COLORbgGrid') COLORtxTitle = update.getPref('gui', 'COLORtxTitle') COLORtxLabel = update.getPref('gui', 'COLORtxLabel') COLORtxUnit = update.getPref('gui', 'COLORtxUnit') COLORbgAbs = update.getPref('gui', 'COLORbgAbs') rowAxisSets = self.scObj.getAllScTriples(srcSize, ao.tniMode) columnAxisSets = self.scObj.getAllScTriples(dstSize, ao.tniMode) if srcSize == dstSize: self.totalSets = len(rowAxisSets) # ignoring col for now self.masterSetList = rowAxisSets else: self.totalSets = len(rowAxisSets) + len(columnAxisSets) self.masterSetList = rowAxisSets + columnAxisSets if (srcSize, dstSize) in list(self.fixedPosChart.keys()): self.mapPostitionType = 'fixed' else: self.mapPostitionType = 'perimeter' if self.mapPostitionType == 'fixed': sideUnits = self.fixedPosChart[(srcSize, dstSize)]['side'] area = pow(sideUnits, 2) elif self.mapPostitionType == 'perimeter': for side in range(1, 100): area = pow(side, 2) circumSquar = (side * 4) - 4 # units the fill outer perimeter if self.totalSets <= circumSquar: sideUnits = side break self.areaKeys = list(range(0, area)) # list to get a point for all area self.noGutters = sideUnits + 1 self.mapGUTTER = 3 # in pixels self.nodeWidth = 46 self.nodeRadius = 16 #self.yMarginShift = 0 #entryHeadHeight #self.xMarginShift = 23 #boundary on left self.rMarginSize = 4 self.tMarginSize = 4 self.lMarginSize = 24 self.bMarginSize = 4 self.cordDict = {} # used to hold info on each position xCord = 0 yCord = 0 for x in self.areaKeys: # initialize with empty dicts self.cordDict[(xCord, yCord)] = {} xCord = xCord + 1 if xCord == sideUnits: xCord = 0 yCord = yCord + 1 cordKeys = list(self.cordDict.keys()) cordKeys.sort() # this calculate the height of the entire window self.winHEIGHT = ((sideUnits * self.nodeWidth) + (self.noGutters * self.mapGUTTER) + self.tMarginSize + self.bMarginSize) self.winWIDTH = ((sideUnits * self.nodeWidth) + (self.noGutters * self.mapGUTTER) + self.lMarginSize + self.rMarginSize) self.mapHEIGHT = self.winHEIGHT - (self.tMarginSize + self.bMarginSize) self.mapWIDTH = self.winWIDTH - (self.lMarginSize + self.rMarginSize) self.heightAllGutters = self.mapGUTTER * self.noGutters self.heightAllEntries = self.mapHEIGHT - self.heightAllGutters # create canvas self.c = imageTools.Canvas(fmt, self.winWIDTH, self.winHEIGHT, COLORbgAbs, 'MCnet', master) # draw margin rectangles self.c.rectangle(0, 0, self.winWIDTH, self.tMarginSize, COLORbgMargin, None, 0) self.c.rectangle(0, 0, self.lMarginSize, self.winHEIGHT, COLORbgMargin, None, 0) self.c.rectangle(0, self.tMarginSize + self.mapHEIGHT, self.winWIDTH, self.winHEIGHT, COLORbgMargin, None, 0) self.c.rectangle(self.mapWIDTH + self.lMarginSize, 0, self.winWIDTH, self.winHEIGHT, COLORbgMargin, None, 0) # fill coord dict with coords for square, center xPos = self.lMarginSize + self.mapGUTTER yPos = self.tMarginSize + self.mapGUTTER xCord = 0 yCord = 0 for x in self.areaKeys: self.cordDict[(xCord, yCord)]['set'] = None # empty self.cordDict[(xCord, yCord)]['box'] = (xPos, yPos, (xPos + self.nodeWidth), (yPos + self.nodeWidth)) centerX = (xPos + (.5 * self.nodeWidth)) centerY = (yPos + (.5 * self.nodeWidth)) self.cordDict[(xCord, yCord)]['center'] = (centerX, centerY) xPos = xPos + self.nodeWidth + self.mapGUTTER if xPos >= (self.winWIDTH - self.nodeWidth): yPos = yPos + self.nodeWidth + self.mapGUTTER # rest to first x position xPos = self.lMarginSize + self.mapGUTTER xCord = xCord + 1 if xCord == sideUnits: xCord = 0 yCord = yCord + 1 # assign sets to area positions if self.mapPostitionType == 'fixed': setLoc = self.fixedPosChart[(srcSize, dstSize)]['setLoc'] # assign sets to coords for node in list(setLoc.keys()): position = setLoc[node] self.cordDict[position]['set'] = node # counter = counter + 1 elif self.mapPostitionType == 'perimeter': # use parimiter method # get perimeter points locations = list(self.cordDict.keys()) tempLocs = [] for node in locations: if node[0] == 0 or node[1] == 0: tempLocs.append(node) elif node[0] == sideUnits - 1 or node[1] == sideUnits - 1: tempLocs.append(node) # sort perimter clockwise perimeterLocs = [] usedList = [] rowList = [] for node in tempLocs: # do top if node[1] == 0 and node not in usedList: rowList.append(node) usedList.append(node) rowList.sort() perimeterLocs = perimeterLocs + rowList rowList = [] for node in tempLocs: # down right side if node[0] == (sideUnits - 1) and node not in usedList: rowList.append(node) usedList.append(node) rowList.sort() perimeterLocs = perimeterLocs + rowList rowList = [] for node in tempLocs: # across bottom if node[1] == (sideUnits - 1) and node not in usedList: rowList.append(node) usedList.append(node) rowList.sort() rowList.reverse() perimeterLocs = perimeterLocs + rowList rowList = [] for node in tempLocs: # across bottom if node[0] == 0 and node not in usedList: rowList.append(node) usedList.append(node) rowList.sort() rowList.reverse() perimeterLocs = perimeterLocs + rowList # assign sets to coords xCord = 0 yCord = 0 counter = 0 for node in self.masterSetList: position = perimeterLocs[counter] self.cordDict[position]['set'] = node counter = counter + 1 # read coords, create boxes only when there is a sset xCord = 0 yCord = 0 for x in self.areaKeys: if self.cordDict[(xCord, yCord)]['set'] != None: x1, y1, x2, y2 = self.cordDict[(xCord, yCord)]['box'] self.c.rectangle(x1, y1, x2, y2, COLORbgAbs, COLORfgAlt, 1) xCord = xCord + 1 if xCord == sideUnits: xCord = 0 yCord = yCord + 1 # create line nets #netList = [((0,2),(1,2)),((0,1),(2,0)),((0,0),(0,1))] netList = [] for colEntry in columnAxisSets: # 10 for leftmost column for rowEntry in rowAxisSets: srcSet = self.scObj.pcs(colEntry) dstSet = self.scObj.pcs(rowEntry) a = mcObj.displacement(srcSet, dstSet, 1) minDispl, maxDispl, orderedResults, counter = a if minDispl == 1: # find sets in grid lineCords = [] # clear before finding two points for node in list(self.cordDict.keys()): if self.cordDict[node]['set'] == colEntry: lineCords.append(node) if self.cordDict[node]['set'] == rowEntry: lineCords.append(node) if lineCords == []: pass elif lineCords in netList: pass elif (lineCords[1], lineCords[0]) in netList: pass else: netList.append(lineCords) # draw lines for net in netList: a, b = net x1, y1 = self.cordDict[a]['center'] x2, y2 = self.cordDict[b]['center'] self.c.line(x1, y1, x2, y2, COLORfgMain, 1) # read coords, create circles and labels xCord = 0 yCord = 0 for x in self.areaKeys: if self.cordDict[(xCord, yCord)]['set'] != None: setStr = self.scObj.scToStr(self.cordDict[(xCord, yCord)]['set']) centerX, centerY = self.cordDict[(xCord, yCord)]['center'] self.c.oval(centerX - self.nodeRadius, centerY - self.nodeRadius, centerX + self.nodeRadius, centerY + self.nodeRadius, COLORbgAbs, COLORfgMain, width=2) if len(setStr) <= 3: # smallest centerShift = 7 elif len(setStr) <= 4: centerShift = 10 else: # 5 or greater centerShift = 12 xLabel = centerX - centerShift yLabel = centerY - 3 self.c.gridText(xLabel, yLabel, 'nw', setStr, fontTitle, COLORtxTitle) xCord = xCord + 1 if xCord == sideUnits: xCord = 0 yCord = yCord + 1
def __init__(self, ao=None, tiMapDict=None, barHEIGHT=8, winWIDTH=700, fmt='tk', master=None): # bar height is the height of texture in pixels. the total height of a # of a window is determined by the number of textures if ao == None: from athenaCL.libATH import athenaObj # update needed for color prefs update = athenaObj.External() update.updateAll('noMessages') self.tiMapDict = tiMapDemo else: update = ao.external # rename update from AO textureLib = ao.textureLib self.tiMapDict = tiMapDict fontTitle = 'micro' fontText = 'micro' COLORfgMain = update.getPref('gui', 'COLORfgMain') COLORfgMainFrame = update.getPref('gui', 'COLORfgMainFrame') COLORfgAlt = update.getPref('gui', 'COLORfgAlt') COLORfgAltFrame = update.getPref('gui', 'COLORfgAltFrame') COLORbgMargin = update.getPref('gui', 'COLORbgMargin') COLORbgGrid = update.getPref('gui', 'COLORbgGrid') COLORbgAbs = update.getPref('gui', 'COLORbgAbs') COLORtxTitle = update.getPref('gui', 'COLORtxTitle') COLORtxLabel = update.getPref('gui', 'COLORtxLabel') COLORtxUnit = update.getPref('gui', 'COLORtxUnit') self.maxTime = self._findMaxTime(self.tiMapDict) self.noEntries = len(list(self.tiMapDict.keys())) for textName in list(self.tiMapDict.keys()): #count clones self.noEntries = self.noEntries + len( list(self.tiMapDict[textName]['cloneDict'].keys())) self.noGutters = self.noEntries + 1 self.mapGUTTER = 3 # in pixels self.headHeight = 2 # band at top of entry blocks self.rMarginSize = 4 self.tMarginSize = 12 self.lMarginSize = 96 self.bMarginSize = 4 # this calculate the height of the entire window self.winHEIGHT = ((self.noEntries * barHEIGHT) + (self.noGutters * self.mapGUTTER) + self.tMarginSize + self.bMarginSize) if winWIDTH < 200: self.winWIDTH = 200 elif winWIDTH > 3000: self.winWIDTH = 3000 else: self.winWIDTH = winWIDTH #600 # # map is region where digram exists; does not include key self.mapHEIGHT = self.winHEIGHT - (self.tMarginSize + self.bMarginSize) self.mapWIDTH = self.winWIDTH - (self.lMarginSize + self.rMarginSize) self.widthAllGutters = self.mapGUTTER * self.noGutters self.widthAllEntries = self.mapHEIGHT - self.widthAllGutters #round to nearest pix if self.noEntries > 0: self.widthEntry = round(self.widthAllEntries / (self.noEntries + 0.0)) else: self.widthEntry = 0 # create canvas self.c = imageTools.Canvas(fmt, self.winWIDTH, self.winHEIGHT, COLORbgAbs, 'TEmap', master) # draw margin rectangles self.c.rectangle(0, 0, self.winWIDTH, self.tMarginSize, COLORbgMargin, None, 0) self.c.rectangle(0, 0, self.lMarginSize, self.winHEIGHT, COLORbgMargin, None, 0) self.c.rectangle(0, self.tMarginSize + self.mapHEIGHT, self.winWIDTH, self.winHEIGHT, COLORbgMargin, None, 0) self.c.rectangle(self.mapWIDTH + self.lMarginSize, 0, self.winWIDTH, self.winHEIGHT, COLORbgMargin, None, 0) # key is one gutter from the window height # this is total time self.c.gridText(self.mapGUTTER, self.mapGUTTER, 'nw', '%.2f' % (self.maxTime), fontTitle, COLORtxUnit) # key for time noPartitions = 16 # needs to be int keyWidth = float(self.mapWIDTH) / noPartitions xCurrentPos = self.lMarginSize # draw grid for keyPartition in range(0, noPartitions): xStart = xCurrentPos xEnd = xCurrentPos + keyWidth # y must start at 1, not zero, otherwise grids gets shited up 1 yStart = 1 # will shift b/n lines and key labels yEnd = self.winHEIGHT - self.bMarginSize # set at bottom # post vector: skip as causes error in vector version # redundant in most cases anyways if keyPartition == 0: # first needs to be bkg color pass #self.c.line(xStart, yStart, xStart, yEnd, COLORbgAbs, 1) elif (keyPartition % 2) == 0: self.c.line(xStart, yStart + self.tMarginSize, xStart, yEnd, COLORbgMargin, .5) timeStr = '%.1f' % ( (self.maxTime / noPartitions) * keyPartition) # this adds numbers to key; buffer by a gutter from edge of window self.c.gridText(xCurrentPos, self.mapGUTTER, 'nc', timeStr, fontTitle, COLORtxUnit) else: # use sub pixel line size for vector version self.c.line(xStart, yStart + self.tMarginSize, xStart, yEnd, COLORbgGrid, .5) xCurrentPos = xCurrentPos + keyWidth # draw textures yPosition = self.tMarginSize + self.mapGUTTER # initial space tNameList = list(self.tiMapDict.keys()) tNameList.sort() for tName in tNameList: yEndPos = yPosition + self.widthEntry # this is actually the absolute time range tStart, tEnd = self.tiMapDict[tName]['tRange'] barOffsetStart = int( round(self.mapWIDTH * (float(tStart) / self.maxTime))) # must add 1 here to get off margin, and into map xStart = self.lMarginSize + barOffsetStart + 1 barOffsetEnd = int( round(self.mapWIDTH * (float(tEnd) / self.maxTime))) # must subtract 1 here to get into map xEnd = self.lMarginSize + barOffsetEnd - 1 yHeadStart = yPosition yHeadEnd = yPosition + self.headHeight yBodyStart = yPosition + self.headHeight yBodyEnd = yEndPos # create head box self.c.rectangle(xStart, yHeadStart, xEnd, yHeadEnd, COLORfgMainFrame, None, 0) if self.tiMapDict[tName]['muteStatus'] == 0: # normal self.c.rectangle(xStart, yBodyStart, xEnd, yBodyEnd, COLORfgMain, None, 0) else: # silenced self.c.rectangle(xStart, yBodyStart, xEnd, yBodyEnd, None, COLORfgMain, 1) # create texture label self.c.gridText(self.mapGUTTER, yBodyStart, 'nw', tName, fontTitle, COLORtxTitle) # shift down yPosition = yEndPos + self.mapGUTTER # clones cNameList = list(self.tiMapDict[tName]['cloneDict'].keys()) cNameList.sort() for cName in cNameList: yEndPos = yPosition + self.widthEntry cStart, cEnd = self.tiMapDict[tName]['cloneDict'][cName][ 'tRange'] barOffsetStart = int( round(self.mapWIDTH * (float(cStart) / self.maxTime))) # must add one to get onto map xStart = self.lMarginSize + barOffsetStart + 1 barOffsetEnd = int( round(self.mapWIDTH * (float(cEnd) / self.maxTime))) # must remove one to get onto map xEnd = self.lMarginSize + barOffsetEnd - 1 yHeadStart = yPosition yHeadEnd = yPosition + self.headHeight yBodyStart = yPosition + self.headHeight yBodyEnd = yEndPos # create head box self.c.rectangle(xStart, yHeadStart, xEnd, yHeadEnd, COLORfgAltFrame, None, 0) if self.tiMapDict[tName]['cloneDict'][cName][ 'muteStatus'] == 0: self.c.rectangle(xStart, yBodyStart, xEnd, yBodyEnd, COLORfgAlt, None, 0) else: # silenced self.c.rectangle(xStart, yBodyStart, xEnd, yBodyEnd, None, COLORfgAlt, 1) # clone labels are shifted right a bit self.c.gridText((self.mapGUTTER * 4), yBodyStart, 'nw', cName, fontTitle, COLORtxLabel) # shift down yPosition = yEndPos + self.mapGUTTER
def __init__(self, ao=None, caData=[], caDataDstValues=None, cellWIDTH=4, cellHEIGHT=4, fmt='png', master=None, title=None): if ao == None: from athenaCL.libATH import athenaObj # update need for color prefs update = athenaObj.External() update.updateAll('noMessages') else: update = ao.external # rename update from AO fontTitle = 'micro' fontText = 'micro' COLORfgMain = update.getPref('gui', 'COLORfgMain') COLORbgMargin = update.getPref('gui', 'COLORbgMargin') COLORbgGrid = update.getPref('gui', 'COLORbgGrid') COLORbgAbs = update.getPref('gui', 'COLORbgAbs') COLORfgAlt = update.getPref('gui', 'COLORfgAlt') COLORtxTitle = update.getPref('gui', 'COLORtxTitle') COLORtxLabel = update.getPref('gui', 'COLORtxLabel') COLORtxUnit = update.getPref('gui', 'COLORtxUnit') self.caData = caData self.caDataDstValues = caDataDstValues # None if continuous # scale bit data self.gutterWid = 0 #1 # pix between cells self.gutterColor = COLORbgMargin self.cellHEIGHT = cellHEIGHT self.cellWIDTH = cellWIDTH self.tMargin = 4 # same as value from imagePath.py self.lMargin = 96 # same as imagePath.py self.bMargin = 4 # same as value from imagePath.py self.rMargin = 4 # same as value from imagePath.py self.marginColor = self.gutterColor # make the same self.noCols = len(self.caData[0]) self.noRows = len(self.caData) self.winHEIGHT = ((self.cellHEIGHT * self.noRows) + self.bMargin + ((self.noRows - 1) * self.gutterWid) + self.tMargin) self.winWIDTH = ((self.cellWIDTH * self.noCols) + self.rMargin + ((self.noCols - 1) * self.gutterWid) + self.lMargin) self._makeBitMap() # processes self.caData # create canvas self.c = imageTools.Canvas(fmt, self.winWIDTH, self.winHEIGHT, COLORbgAbs, 'AUca', master) #self.graph = imageTools.BitGraph(self.caData, fg, bg, self.c, iconSize) self.c.bitmap(self.lMargin, self.tMargin, self.scaleData, None) labelStr = '' # draw margins self.c.rectangle(0, 0, self.winWIDTH, self.tMargin - 1, self.marginColor, None, 0) self.c.rectangle(0, 0, self.lMargin - 1, self.winHEIGHT, self.marginColor, None, 0) # bottom self.c.rectangle(0, self.winHEIGHT - self.bMargin, self.winWIDTH, self.winHEIGHT, self.marginColor, None, 0) # right self.c.rectangle(self.winWIDTH - self.rMargin, 0, self.winWIDTH, self.winHEIGHT, self.marginColor, None, 0) if title != None: # could be COLORtxUnit # cant use lMargin here, b/c it is very large! y = self.tMargin for chunk in title.split('\n'): self.c.gridText(self.tMargin, y, 'nw', chunk, 'micro', COLORtxTitle, 1, None, 1, 1) y = y + 10
def __init__(self, ao=None, barHEIGHT=10, winWIDTH=None, fmt='pil', master=None): # bar height is the height of texture in pixels. the total height of a # of a window is determined by the number of textures if ao == None: from athenaCL.libATH import athenaObj # update need for color prefs update = athenaObj.External() update.updateAll('noMessages') pcsPath = [(4,3,10),(1,5,4,3),(2,11,4),(7,5,3)] scPath = [(3,2,1),(4,14,0),(3,2,-1),(3,5,1)] mapDict = None activePath = 'testPath' else: update = ao.external # rename update from AO pathLib = ao.pathLib activePath = ao.activePath pcsPath = pathLib[activePath].get('pcsPath') scPath = pathLib[activePath].get('scPath') # gets a dict of (sourcePosition, destinationPosition) : map entries if pathLib[activePath].voiceType == 'none': mapDict = None else: mapDict = pathLib[activePath].voiceLib[ pathLib[activePath].activeVoice]['maps'] fontTitle = 'micro' fontText = 'micro' COLORfgMain = update.getPref('gui', 'COLORfgMain') COLORbgMargin = update.getPref('gui', 'COLORbgMargin') COLORbgGrid = update.getPref('gui', 'COLORbgGrid') COLORbgAbs = update.getPref('gui', 'COLORbgAbs') COLORfgAlt = update.getPref('gui', 'COLORfgAlt') COLORtxTitle = update.getPref('gui', 'COLORtxTitle') COLORtxLabel = update.getPref('gui', 'COLORtxLabel') COLORtxUnit = update.getPref('gui', 'COLORtxUnit') self.totalSets = len(pcsPath) self.vertEntries = 0 # max number of vertical cells for set in pcsPath: if len(set) >= self.vertEntries: self.vertEntries = len(set) # add ont vertical entry for the set-class key accross the top self.vertEntries = self.vertEntries + 1 self.noGutters = self.vertEntries + 1 self.mapGUTTER = 3 # in pixels, space between cells self.rMarginSize = 4 self.tMarginSize = 4 self.lMarginSize = 96 # same as imagePmtr; was 100 self.bMarginSize = 4 # half of imagePmtr # this calculate the height of the entire window self.winHEIGHT = (self.vertEntries * barHEIGHT) + (self.noGutters * self.mapGUTTER) + self.tMarginSize + self.bMarginSize if winWIDTH == None: self.winWIDTH = (self.lMarginSize + self.rMarginSize) + (66 * self.totalSets) elif winWIDTH < 200: self.winWIDTH = 200 elif winWIDTH > 3000: self.winWIDTH = 3000 else: self.winWIDTH = winWIDTH #600 # # get size of just the data region self.mapHEIGHT = self.winHEIGHT - (self.tMarginSize + self.bMarginSize) self.mapWIDTH = self.winWIDTH - (self.lMarginSize + self.rMarginSize) # map height includes all gutters; dont need to add belwo5 self.heightAllGutters = self.mapGUTTER * self.noGutters self.heightAllEntries = self.mapHEIGHT - self.heightAllGutters if self.vertEntries > 0: #round to nearest pix self.cellHeight = round(self.heightAllEntries/(self.vertEntries+0.0)) else: self.cellHeight = 0 self.cellWidth = round(self.mapWIDTH / (self.totalSets + 0.0)) self.cellEntryWidth = 18 # pixels for each pc entry # offset of lines above cell bottom self.vertCellOffset = round(self.cellHeight * .5) # create canvas self.c = imageTools.Canvas(fmt, self.winWIDTH, self.winHEIGHT, COLORbgAbs, 'PVview: %s' % activePath, master) # draw margin rectangles self.c.rectangle(0, 0, self.winWIDTH, self.tMarginSize, COLORbgMargin, None, 0) self.c.rectangle(0, 0, self.lMarginSize, self.winHEIGHT, COLORbgMargin, None, 0) self.c.rectangle(0, self.tMarginSize + self.mapHEIGHT, self.winWIDTH, self.winHEIGHT, COLORbgMargin, None, 0) self.c.rectangle(self.mapWIDTH + self.lMarginSize, 0, self.winWIDTH, self.winHEIGHT, COLORbgMargin, None, 0) # set name in upper left self.c.gridText(self.mapGUTTER, self.mapGUTTER + self.tMarginSize, 'nw', activePath, fontTitle, COLORtxUnit) # draw key for sets xCurrentPos = self.lMarginSize for keyPartition in range(self.totalSets): xStart = xCurrentPos xEnd = xCurrentPos + self.cellWidth yStart = self.tMarginSize yEnd = self.winHEIGHT # commented out portions create filled rectangles if keyPartition == 0: # first needs to be bkg color # removing first grid to remove ob1 error w/ vector graphics #self.c.line(xStart,yStart,xStart,yEnd, COLORbgAbs, width=1) scName = multiset.scToStr(scPath[keyPartition]) # this adds numbers to key self.c.gridText((xCurrentPos+self.mapGUTTER), self.mapGUTTER + self.tMarginSize, 'nw', scName, fontTitle, COLORtxUnit) elif (keyPartition % 1) == 0: self.c.line(xStart,yStart,xStart,yEnd, COLORbgMargin, .5) scName = multiset.scToStr(scPath[keyPartition]) # this adds numbers to key self.c.gridText((xCurrentPos+self.mapGUTTER), self.mapGUTTER + self.tMarginSize, 'nw', scName, fontTitle, COLORtxUnit) else: # this are the lines that divide verticalities self.c.line(xStart,yStart,xStart,yEnd, COLORbgGrid, .5) xCurrentPos = xCurrentPos + self.cellWidth # sets xPosition = self.lMarginSize axisDict = {} columnCount = 0 for chord in pcsPath: xPosition = xPosition + self.mapGUTTER yPosition = self.tMarginSize + (self.mapGUTTER*2) + self.cellHeight rowCount = 0 for note in chord: #yPosition = yPosition #+ self.mapGUTTER #+ self.cellHeight yLineStart = yPosition + 8 # needs to be shifted down xLineStart = xPosition - self.mapGUTTER - 1 # shift left 1 # axis dict used for drawing lines axisDict[(columnCount, rowCount)] = (xLineStart, yLineStart) pcString = '%i' % note self.c.gridText(xPosition, yPosition, 'nw', pcString, fontText, COLORtxTitle) rowCount = rowCount + 1 yPosition = yPosition + self.cellHeight + self.mapGUTTER xPosition = xPosition + (self.cellWidth - self.mapGUTTER) columnCount = columnCount + 1 # draw even if voices are not possible if mapDict != None: for i in range(self.totalSets-1): thisSetIndex = i nextSetIndex = i + 1 # this has been a source of error, but not clear why # some keys have produced a key error mapDictkey = (thisSetIndex, nextSetIndex) map = mcObj.fetchMap(mapDict[mapDictkey]) for j in range(len(map)): # go down vertically startCord = axisDict[(i,j)] nextRowPosition = map[j] if drawer.isList(nextRowPosition): for subRowPosition in nextRowPosition: # get next position endCord = axisDict[((i+1),subRowPosition)] self.c.line((startCord[0]+self.cellEntryWidth), (startCord[1]-self.vertCellOffset), (endCord[0]), (endCord[1]-self.vertCellOffset), COLORfgMain, 1) else: # get next position endCord = axisDict[((i+1),nextRowPosition)] self.c.line((startCord[0]+self.cellEntryWidth), (startCord[1]-self.vertCellOffset), (endCord[0]), (endCord[1]-self.vertCellOffset), COLORfgMain, 1)