2020-04-13 17:04:44 +00:00
|
|
|
from tclCommands.TclCommand import TclCommandSignaled
|
2019-01-03 19:25:08 +00:00
|
|
|
|
2019-10-24 23:10:52 +00:00
|
|
|
import collections
|
|
|
|
|
2019-01-03 19:25:08 +00:00
|
|
|
|
2020-04-13 17:04:44 +00:00
|
|
|
class TclCommandPlotAll(TclCommandSignaled):
|
2019-01-03 19:25:08 +00:00
|
|
|
"""
|
|
|
|
Tcl shell command to update the plot on the user interface.
|
|
|
|
|
|
|
|
example:
|
|
|
|
plot
|
|
|
|
"""
|
|
|
|
|
|
|
|
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
|
2019-09-15 21:47:15 +00:00
|
|
|
aliases = ['plot_all']
|
2019-01-03 19:25:08 +00:00
|
|
|
|
2020-04-13 16:15:20 +00:00
|
|
|
description = '%s %s' % ("--", "Plots all objects on GUI.")
|
|
|
|
|
2019-01-03 19:25:08 +00:00
|
|
|
# Dictionary of types from Tcl command, needs to be ordered
|
|
|
|
arg_names = collections.OrderedDict([
|
|
|
|
|
|
|
|
])
|
|
|
|
|
|
|
|
# Dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value
|
|
|
|
option_types = collections.OrderedDict([
|
2020-04-13 17:28:39 +00:00
|
|
|
('plot_status', str),
|
2020-04-13 17:04:44 +00:00
|
|
|
('use_thread', str)
|
2019-01-03 19:25:08 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
# array of mandatory options for current Tcl command: required = {'name','outname'}
|
|
|
|
required = []
|
|
|
|
|
|
|
|
# structured help for current command, args needs to be ordered
|
|
|
|
help = {
|
2020-04-13 16:15:20 +00:00
|
|
|
'main': "Plots all objects on GUI.",
|
2019-01-03 19:25:08 +00:00
|
|
|
'args': collections.OrderedDict([
|
2020-04-13 17:28:39 +00:00
|
|
|
('plot_status', 'If to display or not the objects: True (1) or False (0).'),
|
2020-04-13 17:04:44 +00:00
|
|
|
('use_thread', 'If to use multithreading: True (1) or False (0).')
|
2019-01-03 19:25:08 +00:00
|
|
|
]),
|
2020-04-13 17:28:39 +00:00
|
|
|
'examples': ['plot_all', 'plot_all -plot_status False']
|
2019-01-03 19:25:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
def execute(self, args, unnamed_args):
|
|
|
|
"""
|
|
|
|
|
|
|
|
:param args:
|
|
|
|
:param unnamed_args:
|
|
|
|
:return:
|
|
|
|
"""
|
2020-04-13 17:04:44 +00:00
|
|
|
|
|
|
|
if 'use_thread' in args:
|
2020-04-22 11:37:03 +00:00
|
|
|
try:
|
|
|
|
par = args['use_thread'].capitalize()
|
|
|
|
except AttributeError:
|
|
|
|
par = args['use_thread']
|
|
|
|
threaded = bool(eval(par))
|
2020-04-13 17:04:44 +00:00
|
|
|
else:
|
|
|
|
threaded = False
|
|
|
|
|
2020-04-22 11:37:03 +00:00
|
|
|
plot_status = True
|
2020-04-13 17:28:39 +00:00
|
|
|
if 'plot_status' in args:
|
2020-04-22 11:37:03 +00:00
|
|
|
try:
|
|
|
|
if args['plot_status'] is None:
|
|
|
|
plot_status = True
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
par = args['plot_status'].capitalize()
|
|
|
|
except AttributeError:
|
|
|
|
par = args['plot_status']
|
|
|
|
plot_status = bool(eval(par))
|
|
|
|
except KeyError:
|
2020-04-13 17:28:39 +00:00
|
|
|
plot_status = True
|
|
|
|
|
|
|
|
for obj in self.app.collection.get_list():
|
|
|
|
obj.options["plot"] = True if plot_status is True else False
|
|
|
|
|
2019-09-19 00:55:47 +00:00
|
|
|
if self.app.cmd_line_headless != 1:
|
2020-04-13 17:04:44 +00:00
|
|
|
self.app.plot_all(use_thread=threaded)
|