Преглед изворни кода

- fixed the object collection methods that return a list of objects or names of objects such that they have a parameter now to allow adding to those lists (or not) for the objects of type Script or Document. Thus fixing some of the Tcl commands such Set Origin

Marius Stanciu пре 6 година
родитељ
комит
c1941bc882
3 измењених фајлова са 19 додато и 8 уклоњено
  1. 1 1
      CHANGELOG.md
  2. 1 1
      FlatCAMApp.py
  3. 17 6
      flatcamObjects/ObjectCollection.py

+ 1 - 1
CHANGELOG.md

@@ -15,7 +15,7 @@ CHANGELOG for FlatCAM beta
 - fixed the workspace being always A4
 - fixed the workspace being always A4
 - added a label in the status bar to show if the workplace is active and what size it is
 - added a label in the status bar to show if the workplace is active and what size it is
 - now the Edit command (either from Menu Edit ->Edit Object) or through the shortcut key (E key) or project tab context menu works also for the CNCJob objects (will open a text Editor with the GCode)
 - now the Edit command (either from Menu Edit ->Edit Object) or through the shortcut key (E key) or project tab context menu works also for the CNCJob objects (will open a text Editor with the GCode)
-- grid snap toolbar is now always active
+- fixed the object collection methods that return a list of objects or names of objects such that they have a parameter now to allow adding to those lists (or not) for the objects of type Script or Document. Thus fixing some of the Tcl commands such Set Origin
 
 
 16.05.2020
 16.05.2020
 
 

+ 1 - 1
FlatCAMApp.py

@@ -5219,7 +5219,7 @@ class App(QtCore.QObject):
             self.should_we_save = True
             self.should_we_save = True
             return
             return
 
 
-        if event.button == 1:
+        if event is not None and event.button == 1:
             if self.is_legacy is False:
             if self.is_legacy is False:
                 event_pos = event.pos
                 event_pos = event.pos
             else:
             else:

+ 17 - 6
flatcamObjects/ObjectCollection.py

@@ -593,16 +593,22 @@ class ObjectCollection(QtCore.QAbstractItemModel):
             # always open the notebook on object added to collection
             # always open the notebook on object added to collection
             self.app.ui.splitter.setSizes([1, 1])
             self.app.ui.splitter.setSizes([1, 1])
 
 
-    def get_names(self):
+    def get_names(self, sel_all=None):
         """
         """
         Gets a list of the names of all objects in the collection.
         Gets a list of the names of all objects in the collection.
 
 
-        :return: List of names.
-        :rtype: list
+        :param sel_all:     Will return all objects if True. If False or None all except Script and Document
+        :return:            List of names.
+        :rtype:             list
         """
         """
 
 
         # log.debug(str(inspect.stack()[1][3]) + " --> OC.get_names()")
         # log.debug(str(inspect.stack()[1][3]) + " --> OC.get_names()")
-        return [x.options['name'] for x in self.get_list()]
+        if sel_all is None or sel_all is False:
+            names_list = [x.options['name'] for x in self.get_list()]
+        else:
+            names_list = [x.options['name'] for x in self.get_list(sel_all=sel_all)]
+
+        return names_list
 
 
     def get_bounds(self):
     def get_bounds(self):
         """
         """
@@ -984,15 +990,20 @@ class ObjectCollection(QtCore.QAbstractItemModel):
                 self.app.inform.emit('[ERROR] %s: %s' % (_("Cause of error"), str(e)))
                 self.app.inform.emit('[ERROR] %s: %s' % (_("Cause of error"), str(e)))
                 raise
                 raise
 
 
-    def get_list(self):
+    def get_list(self, sel_all=None):
         """
         """
-        Will return a list of all objects currently opened.
+        Will return a list of all objects currently opened. Except FlatCAMScript and FlatCAMDocuments
 
 
+        :param sel_all:     Will return all objects if True. If False or None all except Script and Document
         :return:
         :return:
         """
         """
         obj_list = []
         obj_list = []
         for group in self.root_item.child_items:
         for group in self.root_item.child_items:
             for item in group.child_items:
             for item in group.child_items:
+                kind = item.obj.kind
+                if sel_all is None or sel_all is False:
+                    if kind == 'document' or kind == 'script':
+                        continue
                 obj_list.append(item.obj)
                 obj_list.append(item.obj)
 
 
         return obj_list
         return obj_list