TclCommandPlotAll.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 appGUI.")
  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 appGUI.",
  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. try:
  39. par = args['use_thread'].capitalize()
  40. except AttributeError:
  41. par = args['use_thread']
  42. threaded = bool(eval(par))
  43. else:
  44. threaded = False
  45. plot_status = True
  46. if 'plot_status' in args:
  47. try:
  48. if args['plot_status'] is None:
  49. plot_status = True
  50. else:
  51. try:
  52. par = args['plot_status'].capitalize()
  53. except AttributeError:
  54. par = args['plot_status']
  55. plot_status = bool(eval(par))
  56. except KeyError:
  57. plot_status = True
  58. for obj in self.app.collection.get_list():
  59. obj.options["plot"] = True if plot_status is True else False
  60. if self.app.cmd_line_headless != 1:
  61. self.app.plot_all(use_thread=threaded)