TclCommandPlotAll.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. from tclCommands.TclCommand import TclCommandSignaled
  2. import collections
  3. class TclCommandPlotAll(TclCommandSignaled):
  4. """
  5. Tcl shell command to update the plot on the user interface.
  6. example:
  7. plot
  8. """
  9. # List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
  10. aliases = ['plot_all']
  11. description = '%s %s' % ("--", "Plots all objects on GUI.")
  12. # Dictionary of types from Tcl command, needs to be ordered
  13. arg_names = collections.OrderedDict([
  14. ])
  15. # Dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value
  16. option_types = collections.OrderedDict([
  17. ('plot_status', str),
  18. ('use_thread', str)
  19. ])
  20. # array of mandatory options for current Tcl command: required = {'name','outname'}
  21. required = []
  22. # structured help for current command, args needs to be ordered
  23. help = {
  24. 'main': "Plots all objects on GUI.",
  25. 'args': collections.OrderedDict([
  26. ('plot_status', 'If to display or not the objects: True (1) or False (0).'),
  27. ('use_thread', 'If to use multithreading: True (1) or False (0).')
  28. ]),
  29. 'examples': ['plot_all', 'plot_all -plot_status False']
  30. }
  31. def execute(self, args, unnamed_args):
  32. """
  33. :param args:
  34. :param unnamed_args:
  35. :return:
  36. """
  37. if 'use_thread' in args:
  38. threaded = bool(eval(args['use_thread']))
  39. else:
  40. threaded = False
  41. if 'plot_status' in args:
  42. if args['plot_status'] is None:
  43. plot_status = True
  44. else:
  45. plot_status = bool(eval(args['plot_status']))
  46. else:
  47. plot_status = True
  48. for obj in self.app.collection.get_list():
  49. obj.options["plot"] = True if plot_status is True else False
  50. if self.app.cmd_line_headless != 1:
  51. self.app.plot_all(use_thread=threaded)