Quellcode durchsuchen

- updated the Tcl commands PlotAll and PlotObjects to have a parameter that control if the objects are to be plotted or not on canvas; it serve as a disable/enable

Marius Stanciu vor 5 Jahren
Ursprung
Commit
742180d6e3
5 geänderte Dateien mit 54 neuen und 19 gelöschten Zeilen
  1. 19 15
      FlatCAMApp.py
  2. 5 0
      ObjectCollection.py
  3. 1 0
      README.md
  4. 14 1
      tclCommands/TclCommandPlotAll.py
  5. 15 3
      tclCommands/TclCommandPlotObjects.py

+ 19 - 15
FlatCAMApp.py

@@ -1029,8 +1029,10 @@ class App(QtCore.QObject):
                          'gbl, gbo, gbp, gbr, gbs, gdo, ger, gko, gm1, gm2, gm3, grb, gtl, gto, gtp, gts, ly15, ly2, '
                          'mil, pho, plc, pls, smb, smt, sol, spb, spt, ssb, sst, stc, sts, top, tsm',
             # Keyword list
-            "util_autocomplete_keywords": 'Desktop, Documents, FlatConfig, FlatPrj, Marius, My Documents, Paste_1, '
-                                          'Repetier, Roland_MDX_20, Users, Toolchange_Custom, Toolchange_Probe_MACH3, '
+            "util_autocomplete_keywords": 'Desktop, Documents, FlatConfig, FlatPrj, False, '
+                                          'Marius, My Documents, Paste_1, '
+                                          'Repetier, Roland_MDX_20, True, Users, Toolchange_Custom, '
+                                          'Toolchange_Probe_MACH3, '
                                           'Toolchange_manual, Users, all, angle_x, angle_y, axis, auto, axisoffset, '
                                           'box, center_x, center_y, columns, combine, connect, contour, default, '
                                           'depthperpass, dia, diatol, dist, drilled_dias, drillz, dwelltime, '
@@ -2305,28 +2307,30 @@ class App(QtCore.QObject):
         # ######################### Auto-complete KEYWORDS ####################################
         # #####################################################################################
         self.tcl_commands_list = ['add_circle', 'add_poly', 'add_polygon', 'add_polyline', 'add_rectangle',
-                                  'aligndrill', 'aligndrillgrid', 'bbox', 'bounding_box', 'clear', 'cncjob', 'cutout',
-                                  'del', 'delete', 'drillcncjob', 'export_dxf', 'edxf', 'export_excellon', 'ee',
+                                  'aligndrill', 'aligndrillgrid', 'bbox', 'clear', 'cncjob', 'cutout',
+                                  'del', 'drillcncjob', 'export_dxf', 'edxf', 'export_excellon',
                                   'export_exc',
-                                  'export_gcode', 'export_gerber', 'egr', 'export_svg', 'ext', 'exteriors', 'follow',
-                                  'geo_union', 'geocutout', 'get_names', 'get_sys', 'getsys', 'help', 'import_svg',
-                                  'interiors', 'isolate', 'join_excellon', 'join_excellons', 'join_geometries',
-                                  'join_geometry', 'list_sys', 'listsys', 'milld', 'mills', 'milldrills', 'millslots',
+                                  'export_gcode', 'export_gerber', 'export_svg', 'ext', 'exteriors', 'follow',
+                                  'geo_union', 'geocutout', 'get_bounds', 'get_names', 'get_sys', 'help', 'import_svg',
+                                  'interiors', 'isolate', 'join_excellon',
+                                  'join_geometry', 'list_sys', 'milld', 'mills', 'milldrills', 'millslots',
                                   'mirror', 'ncc',
-                                  'ncc_clear', 'ncr', 'new', 'new_geometry', 'non_copper_regions', 'offset',
+                                  'ncr', 'new', 'new_geometry', 'non_copper_regions', 'offset',
                                   'open_excellon', 'open_gcode', 'open_gerber', 'open_project', 'options', 'origin',
-                                  'paint', 'pan', 'panel', 'panelize', 'plot_all', 'plot_objects', 'quit_flatcam',
+                                  'paint', 'panelize', 'plot_all', 'plot_objects', 'plot_status', 'quit_flatcam',
                                   'save', 'save_project',
                                   'save_sys', 'scale', 'set_active', 'set_origin', 'set_sys',
-                                  'setsys', 'skew', 'subtract_poly', 'subtract_rectangle',
+                                  'skew', 'subtract_poly', 'subtract_rectangle',
                                   'version', 'write_gcode'
                                   ]
 
-        self.default_keywords = ['Desktop', 'Documents', 'FlatConfig', 'FlatPrj', 'Marius', 'My Documents', 'Paste_1',
+        self.default_keywords = ['Desktop', 'Documents', 'FlatConfig', 'FlatPrj', 'False', 'Marius', 'My Documents',
+                                 'Paste_1',
                                  'Repetier', 'Roland_MDX_20', 'Users', 'Toolchange_Custom', 'Toolchange_Probe_MACH3',
-                                 'Toolchange_manual', 'Users', 'all', 'angle_x', 'angle_y', 'auto', 'axis',
-                                 'axisoffset',
-                                 'box', 'center_x', 'center_y', 'columns', 'combine', 'connect', 'contour', 'default',
+                                 'Toolchange_manual', 'True', 'Users',
+                                 'all', 'angle_x', 'angle_y', 'auto', 'axis',
+                                 'axisoffset', 'box', 'center_x', 'center_y', 'columns', 'combine', 'connect',
+                                 'contour', 'default',
                                  'depthperpass', 'dia', 'diatol', 'dist', 'drilled_dias', 'drillz',
                                  'dwelltime', 'extracut_length', 'f',
                                  'feedrate_z', 'grbl_11', 'GRBL_laser', 'gridoffsety', 'gridx', 'gridy',

+ 5 - 0
ObjectCollection.py

@@ -912,6 +912,11 @@ class ObjectCollection(QtCore.QAbstractItemModel):
                 raise
 
     def get_list(self):
+        """
+        Will return a list of all objects currently opened.
+
+        :return:
+        """
         obj_list = []
         for group in self.root_item.child_items:
             for item in group.child_items:

+ 1 - 0
README.md

@@ -17,6 +17,7 @@ CAD program, and create G-Code for Isolation routing.
 - in Tcl Shell, the 'help' command will add also a brief description for each command in the list
 - updated the App.plot_all() method giving it the possibility to be run as threaded or not
 - updated the Tcl command PlotAll to be able to run threaded or not
+- updated the Tcl commands PlotAll and PlotObjects to have a parameter that control if the objects are to be plotted or not on canvas; it serve as a disable/enable
 
 11.04.2020 
 

+ 14 - 1
tclCommands/TclCommandPlotAll.py

@@ -23,6 +23,7 @@ class TclCommandPlotAll(TclCommandSignaled):
 
     # Dictionary of types from Tcl command, needs to be ordered , this  is  for options  like -optionname value
     option_types = collections.OrderedDict([
+        ('plot_status', str),
         ('use_thread', str)
     ])
 
@@ -33,9 +34,10 @@ class TclCommandPlotAll(TclCommandSignaled):
     help = {
         'main': "Plots all objects on GUI.",
         'args': collections.OrderedDict([
+            ('plot_status', 'If to display or not the objects: True (1) or False (0).'),
             ('use_thread', 'If to use multithreading: True (1) or False (0).')
         ]),
-        'examples': ['plot_all']
+        'examples': ['plot_all', 'plot_all -plot_status False']
     }
 
     def execute(self, args, unnamed_args):
@@ -51,5 +53,16 @@ class TclCommandPlotAll(TclCommandSignaled):
         else:
             threaded = False
 
+        if 'plot_status' in args:
+            if args['plot_status'] is None:
+                plot_status = True
+            else:
+                plot_status = bool(eval(args['plot_status']))
+        else:
+            plot_status = True
+
+        for obj in self.app.collection.get_list():
+            obj.options["plot"] = True if plot_status is True else False
+
         if self.app.cmd_line_headless != 1:
             self.app.plot_all(use_thread=threaded)

+ 15 - 3
tclCommands/TclCommandPlotObjects.py

@@ -30,7 +30,7 @@ class TclCommandPlotObjects(TclCommand):
 
     # Dictionary of types from Tcl command, needs to be ordered , this  is  for options  like -optionname value
     option_types = collections.OrderedDict([
-
+        ('plot_status', str)
     ])
 
     # array of mandatory options for current Tcl command: required = {'name','outname'}
@@ -41,7 +41,8 @@ class TclCommandPlotObjects(TclCommand):
         'main': "Plot a specified list of objects in GUI.",
         'args': collections.OrderedDict([
             ('names', "A list of object names to be plotted separated by comma. Required.\n"
-                      "WARNING: no spaces are allowed. If unsure enclose the entire list with quotes.")
+                      "WARNING: no spaces are allowed. If unsure enclose the entire list with quotes."),
+            ('plot_status', 'If to display or not the objects: True (1) or False (0).')
         ]),
         'examples': ["plot_objects gerber_obj.GRB,excellon_obj.DRL"]
     }
@@ -53,11 +54,22 @@ class TclCommandPlotObjects(TclCommand):
         :param unnamed_args:
         :return:
         """
+
+        if 'plot_status' in args:
+            if args['plot_status'] is None:
+                plot_status = True
+            else:
+                plot_status = bool(eval(args['plot_status']))
+        else:
+            plot_status = True
+
         if self.app.cmd_line_headless != 1:
             names = [x.strip() for x in args['names'].split(",") if x != '']
             objs = []
             for name in names:
-                objs.append(self.app.collection.get_by_name(name))
+                obj= self.app.collection.get_by_name(name)
+                obj.options["plot"] = True if plot_status is True else False
+                objs.append(obj)
 
             for obj in objs:
                 obj.plot()