import DataSet
import Plotter

# We assume for the time being there is only a single Plot block
# should really pass a reference to this Plot block
# "data" could then be attached to this block
# currently "data" is attached to the parent and
# thus there can only be one Plot block
def plotWindow(block):
  model = block.rootNode
  # titles contains names of blocks connected to the Plot block
  titles = []
  for in_connect in block.in_connections_:
   plotted_block = in_connect.in_connections_[0]
   plotted_var_name = plotted_block.block_name.getValue()
   if plotted_var_name == "":
     print "ignoring unnamed blocks"
   else:
     titles.append(plotted_var_name)
  if not ("data" in dir(model)):
   model.data = DataSet.DataSet(source = 'simulator', titles = titles)
  gFrame = Plotter.GraphWindow(block.parent, [model.data])
  gFrame.title("Plot")

