Exemplo n.º 1
0
def eplot(plot, domain):
  def mixPlotWithLoc(loc):
    newPlot = copy.deepcopy(plot)
    newPlot["label"] = newPlot["label"].replace("%loc",loc)
    checkForAlgebraicExpressions(newPlot["expression"],["%loc"],[locations[loc]],str(0))
    solveAlgebraicExpressions(newPlot["expression"])
    newPlot["expression"] = checkForChains(newPlot["expression"])
    insertLocInExpression(newPlot["expression"],loc)
    return newPlot
  
  def mixPlotWithOrgDst(matrixCell):
    (org, dst, r) = matrixCell
    if (options.fullMatrix == False and r == 0):
      return nullInstruction
    if (org != dst):
      newPlot = copy.deepcopy(plot)
      newPlot["label"] = newPlot["label"].replace("%org",org)
      newPlot["label"] = newPlot["label"].replace("%dst",dst)
      checkForAlgebraicExpressions(newPlot["expression"],["%org","%dst"],[locations[org],locations[dst]],str(r))
      solveAlgebraicExpressions(newPlot["expression"])
      newPlot["expression"] = checkForChains(newPlot["expression"])
      insertOrgInExpression(newPlot["expression"],org)
      insertDstInExpression(newPlot["expression"],dst)
      return newPlot
    else:
      return nullInstruction

  plotBuilder = None
  if (domain[0].__class__ == "".__class__): #if it is string, it is just loc
    plotBuilder = mixPlotWithLoc
  else: #the type is tuple, it is a matrix
    plotBuilder = mixPlotWithOrgDst
  for r in map(plotBuilder, domain):
    printing.printPlot(r)