Bladeren bron

- modified behavior of object comboboxes in Paint, NCC and CutOut Tools: now if an object is selected in Project Tab and is of the supported kind in the Tool, it will be auto-selected

Marius Stanciu 5 jaren geleden
bovenliggende
commit
4630695c84
4 gewijzigde bestanden met toevoegingen van 81 en 12 verwijderingen
  1. 31 1
      AppTools/ToolCutOut.py
  2. 23 5
      AppTools/ToolNCC.py
  3. 26 6
      AppTools/ToolPaint.py
  4. 1 0
      CHANGELOG.md

+ 31 - 1
AppTools/ToolCutOut.py

@@ -455,7 +455,37 @@ class CutOut(AppTool):
         self.gapsize.set_value(float(self.app.defaults["tools_cutoutgapsize"]))
         self.gaps.set_value(self.app.defaults["tools_gaps_ff"])
         self.convex_box.set_value(self.app.defaults['tools_cutout_convexshape'])
-        self.type_obj_radio.set_value('grb')
+
+        # use the current selected object and make it visible in the Paint object combobox
+        sel_list = self.app.collection.get_selected()
+        if len(sel_list) == 1:
+            active = self.app.collection.get_active()
+            kind = active.kind
+            if kind == 'gerber':
+                self.type_obj_radio.set_value('grb')
+            else:
+                self.type_obj_radio.set_value('geo')
+
+            # run those once so the obj_type attribute is updated for the FCComboboxes
+            # so the last loaded object is displayed
+            if kind == 'gerber':
+                self.on_type_obj_changed(val='grb')
+            else:
+                self.on_type_obj_changed(val='geo')
+
+            self.obj_combo.set_value(active.options['name'])
+        else:
+            kind = 'gerber'
+            self.type_obj_radio.set_value('grb')
+
+            # run those once so the obj_type attribute is updated for the FCComboboxes
+            # so the last loaded object is displayed
+            if kind == 'gerber':
+                self.on_type_obj_changed(val='grb')
+            else:
+                self.on_type_obj_changed(val='geo')
+
+        # self.type_obj_radio.set_value('grb')
 
         self.default_data.update({
             "plot":             True,

+ 23 - 5
AppTools/ToolNCC.py

@@ -979,12 +979,30 @@ class NonCopperClear(AppTool, Gerber):
 
         self.tools_frame.show()
 
-        self.type_obj_radio.set_value('gerber')
+        # use the current selected object and make it visible in the NCC object combobox
+        sel_list = self.app.collection.get_selected()
+        if len(sel_list) == 1:
+            active = self.app.collection.get_active()
+            kind = active.kind
+            if kind == 'gerber':
+                self.type_obj_radio.set_value('gerber')
+            else:
+                self.type_obj_radio.set_value('geometry')
+
+            # run those once so the obj_type attribute is updated for the FCComboboxes
+            # so the last loaded object is displayed
+            self.on_type_obj_index_changed(val=kind)
+            self.on_reference_combo_changed()
+
+            self.object_combo.set_value(active.options['name'])
+        else:
+            kind = 'gerber'
+            self.type_obj_radio.set_value('gerber')
 
-        # run those once so the obj_type attribute is updated for the FCComboboxes
-        # so the last loaded object is displayed
-        self.on_type_obj_index_changed(val="gerber")
-        self.on_reference_combo_changed()
+            # run those once so the obj_type attribute is updated for the FCComboboxes
+            # so the last loaded object is displayed
+            self.on_type_obj_index_changed(val=kind)
+            self.on_reference_combo_changed()
 
         self.op_radio.set_value(self.app.defaults["tools_nccoperation"])
         self.ncc_order_radio.set_value(self.app.defaults["tools_nccorder"])

+ 26 - 6
AppTools/ToolPaint.py

@@ -1046,13 +1046,33 @@ class ToolPaint(AppTool, Gerber):
 
         self.on_tool_type(val=self.tool_type_radio.get_value())
 
-        # make the default object type, "Geometry"
-        self.type_obj_combo.set_value("geometry")
+        # # make the default object type, "Geometry"
+        # self.type_obj_combo.set_value("geometry")
+
+        # use the current selected object and make it visible in the Paint object combobox
+        sel_list = self.app.collection.get_selected()
+        if len(sel_list) == 1:
+            active = self.app.collection.get_active()
+            kind = active.kind
+            if kind == 'gerber':
+                self.type_obj_radio.set_value('gerber')
+            else:
+                self.type_obj_radio.set_value('geometry')
+
+            # run those once so the obj_type attribute is updated in the FCComboBoxes
+            # to make sure that the last loaded object is displayed in the combobox
+            self.on_type_obj_changed(val=kind)
+            self.on_reference_combo_changed()
+
+            self.object_combo.set_value(active.options['name'])
+        else:
+            kind = 'geometry'
+            self.type_obj_radio.set_value('geometry')
 
-        # run those once so the obj_type attribute is updated in the FCComboBoxes
-        # to make sure that the last loaded object is displayed in the combobox
-        self.on_type_obj_changed(val="geometry")
-        self.on_reference_combo_changed()
+            # run those once so the obj_type attribute is updated in the FCComboBoxes
+            # to make sure that the last loaded object is displayed in the combobox
+            self.on_type_obj_changed(val=kind)
+            self.on_reference_combo_changed()
 
         try:
             diameters = [float(self.app.defaults["tools_painttooldia"])]

+ 1 - 0
CHANGELOG.md

@@ -15,6 +15,7 @@ CHANGELOG for FlatCAM beta
 - Etch Compensation Tool - added a new etchant: alkaline baths
 - fixed spacing in the status toolbar icons
 - updated the translation files to the latest changes
+ - modified behavior of object comboboxes in Paint, NCC and CutOut Tools: now if an object is selected in Project Tab and is of the supported kind in the Tool, it will be auto-selected
 
 1.06.2020