plotter_10.py 1.1 KB

1234567891011121314151617181920212223242526272829
  1. def plot(workspace, tokens=None):
  2. """When called from window.py it initiates rendering of equations.
  3. Arguments:
  4. workspace {QtWidgets.QWidget} -- main layout
  5. """
  6. from visma.io.tokenize import tokenizer
  7. workspace.figure2D.clear()
  8. workspace.figure3D.clear()
  9. if tokens is None:
  10. tokens = workspace.eqToks[-1]
  11. eqType = getTokensType(tokens)
  12. LHStok, RHStok = getLHSandRHS(tokens)
  13. variables = sorted(getVariables(LHStok, RHStok))
  14. dim = len(variables)
  15. graphVars, func, variables = graphPlot(workspace, False, tokens)
  16. renderPlot(workspace, graphVars, func, variables, tokens)
  17. if (dim == 1):
  18. var2, var3 = selectAdditionalVariable(variables[0])
  19. if tokens is None:
  20. workspace.eqToks[-1] += tokenizer("0" + var2 + "+" + "0" + var3)
  21. else:
  22. tokens += tokenizer("0" + var2 + "+" + "0" + var3)
  23. if (((dim == 2) or (dim == 1)) & (eqType == 'equation')):
  24. graphVars, func, variables = graphPlot(workspace, True, tokens)
  25. renderPlot(workspace, graphVars, func, variables, tokens)