From 4630695c8494a2ae809e863a7fae56af5704c997 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Tue, 2 Jun 2020 14:30:52 +0300 Subject: [PATCH] - 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 --- AppTools/ToolCutOut.py | 32 +++++++++++++++++++++++++++++++- AppTools/ToolNCC.py | 28 +++++++++++++++++++++++----- AppTools/ToolPaint.py | 32 ++++++++++++++++++++++++++------ CHANGELOG.md | 1 + 4 files changed, 81 insertions(+), 12 deletions(-) diff --git a/AppTools/ToolCutOut.py b/AppTools/ToolCutOut.py index 97a31975..990daf55 100644 --- a/AppTools/ToolCutOut.py +++ b/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, diff --git a/AppTools/ToolNCC.py b/AppTools/ToolNCC.py index c1aa6551..15ddd2b6 100644 --- a/AppTools/ToolNCC.py +++ b/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="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.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=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"]) diff --git a/AppTools/ToolPaint.py b/AppTools/ToolPaint.py index a2d40122..775b36e5 100644 --- a/AppTools/ToolPaint.py +++ b/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") - # 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() + # 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=kind) + self.on_reference_combo_changed() try: diameters = [float(self.app.defaults["tools_painttooldia"])] diff --git a/CHANGELOG.md b/CHANGELOG.md index 0795c787..fd36c19c 100644 --- a/CHANGELOG.md +++ b/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