- made sure that the units are read from the self.defaults and not from the GUI
- added Robber Bar option to Copper Thieving Tool
This commit is contained in:
@@ -288,7 +288,7 @@ class ToolCalculator(FlatCAMTool):
|
||||
FlatCAMTool.install(self, icon, separator, shortcut='ALT+C', **kwargs)
|
||||
|
||||
def set_tool_ui(self):
|
||||
self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
|
||||
self.units = self.app.defaults['units'].upper()
|
||||
|
||||
# ## Initialize form
|
||||
self.mm_entry.set_value('%.*f' % (self.decimals, 0))
|
||||
|
||||
@@ -620,7 +620,7 @@ class ToolCalibrateExcellon(FlatCAMTool):
|
||||
FlatCAMTool.install(self, icon, separator, shortcut='ALT+E', **kwargs)
|
||||
|
||||
def set_tool_ui(self):
|
||||
self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
|
||||
self.units = self.app.defaults['units'].upper()
|
||||
|
||||
# ## Initialize form
|
||||
# self.mm_entry.set_value('%.*f' % (self.decimals, 0))
|
||||
|
||||
@@ -329,6 +329,62 @@ class ToolCopperThieving(FlatCAMTool):
|
||||
)
|
||||
self.layout.addWidget(self.fill_button)
|
||||
|
||||
# ## Grid Layout
|
||||
grid_lay_1 = QtWidgets.QGridLayout()
|
||||
self.layout.addLayout(grid_lay_1)
|
||||
grid_lay_1.setColumnStretch(0, 0)
|
||||
grid_lay_1.setColumnStretch(1, 1)
|
||||
|
||||
separator_line_1 = QtWidgets.QFrame()
|
||||
separator_line_1.setFrameShape(QtWidgets.QFrame.HLine)
|
||||
separator_line_1.setFrameShadow(QtWidgets.QFrame.Sunken)
|
||||
grid_lay_1.addWidget(separator_line_1, 0, 0, 1, 2)
|
||||
|
||||
grid_lay_1.addWidget(QtWidgets.QLabel(''))
|
||||
|
||||
self.robber_bar_label = QtWidgets.QLabel('<b>%s</b>' % _('Robber Bar Parameters'))
|
||||
self.robber_bar_label.setToolTip(
|
||||
_("Parameters used for the robber bar.\n"
|
||||
"Robber bar = copper border to help in pattern hole plating.")
|
||||
)
|
||||
grid_lay_1.addWidget(self.robber_bar_label, 1, 0, 1, 2)
|
||||
|
||||
# ROBBER BAR MARGIN #
|
||||
self.rb_margin_label = QtWidgets.QLabel('%s:' % _("Margin"))
|
||||
self.rb_margin_label.setToolTip(
|
||||
_("Bounding box margin for robber bar.")
|
||||
)
|
||||
self.rb_margin_entry = FCDoubleSpinner()
|
||||
self.rb_margin_entry.set_range(-9999.9999, 9999.9999)
|
||||
self.rb_margin_entry.set_precision(self.decimals)
|
||||
self.rb_margin_entry.setSingleStep(0.1)
|
||||
|
||||
grid_lay_1.addWidget(self.rb_margin_label, 2, 0)
|
||||
grid_lay_1.addWidget(self.rb_margin_entry, 2, 1)
|
||||
|
||||
# THICKNESS #
|
||||
self.rb_thickness_label = QtWidgets.QLabel('%s:' % _("Thickness"))
|
||||
self.rb_thickness_label.setToolTip(
|
||||
_("The robber bar thickness.")
|
||||
)
|
||||
self.rb_thickness_entry = FCDoubleSpinner()
|
||||
self.rb_thickness_entry.set_range(0.0000, 9999.9999)
|
||||
self.rb_thickness_entry.set_precision(self.decimals)
|
||||
self.rb_thickness_entry.setSingleStep(0.1)
|
||||
|
||||
grid_lay_1.addWidget(self.rb_thickness_label, 3, 0)
|
||||
grid_lay_1.addWidget(self.rb_thickness_entry, 3, 1)
|
||||
|
||||
# ## Insert Robber Bar
|
||||
self.rb_button = QtWidgets.QPushButton(_("Insert Robber Bar"))
|
||||
self.rb_button.setToolTip(
|
||||
_("Will add a polygon with a defined thickness\n"
|
||||
"that will surround the actual Gerber object\n"
|
||||
"at a certain distance.\n"
|
||||
"Required when doing holes pattern plating.")
|
||||
)
|
||||
self.layout.addWidget(self.rb_button)
|
||||
|
||||
self.layout.addStretch()
|
||||
|
||||
# Objects involved in Copper thieving
|
||||
@@ -360,6 +416,7 @@ class ToolCopperThieving(FlatCAMTool):
|
||||
self.box_combo_type.currentIndexChanged.connect(self.on_combo_box_type)
|
||||
self.reference_radio.group_toggle_fn = self.on_toggle_reference
|
||||
self.fill_type_radio.activated_custom.connect(self.on_thieving_type)
|
||||
self.rb_button.clicked.connect(self.add_robber_bar)
|
||||
|
||||
def run(self, toggle=True):
|
||||
self.app.report_usage("ToolCopperThieving()")
|
||||
@@ -393,7 +450,7 @@ class ToolCopperThieving(FlatCAMTool):
|
||||
FlatCAMTool.install(self, icon, separator, shortcut='ALT+F', **kwargs)
|
||||
|
||||
def set_tool_ui(self):
|
||||
self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value()
|
||||
self.units = self.app.defaults['units']
|
||||
self.clearance_entry.set_value(float(self.app.defaults["tools_copper_thieving_clearance"]))
|
||||
self.margin_entry.set_value(float(self.app.defaults["tools_copper_thieving_margin"]))
|
||||
self.reference_radio.set_value(self.app.defaults["tools_copper_thieving_reference"])
|
||||
@@ -408,6 +465,9 @@ class ToolCopperThieving(FlatCAMTool):
|
||||
self.line_size_entry.set_value(self.app.defaults["tools_copper_thieving_lines_size"])
|
||||
self.lines_spacing_entry.set_value(self.app.defaults["tools_copper_thieving_lines_spacing"])
|
||||
|
||||
self.rb_margin_entry.set_value(self.app.defaults["tools_copper_thieving_rb_margin"])
|
||||
self.rb_thickness_entry.set_value(self.app.defaults["tools_copper_thieving_rb_thickness"])
|
||||
|
||||
# INIT SECTION
|
||||
self.area_method = False
|
||||
|
||||
@@ -464,6 +524,85 @@ class ToolCopperThieving(FlatCAMTool):
|
||||
self.squares_frame.hide()
|
||||
self.lines_frame.show()
|
||||
|
||||
def add_robber_bar(self):
|
||||
rb_margin = self.rb_margin_entry.get_value()
|
||||
rb_thickness = self.rb_thickness_entry.get_value()
|
||||
|
||||
# get the Gerber object on which the Robber bar will be inserted
|
||||
selection_index = self.grb_object_combo.currentIndex()
|
||||
model_index = self.app.collection.index(selection_index, 0, self.grb_object_combo.rootModelIndex())
|
||||
|
||||
try:
|
||||
self.grb_object = model_index.internalPointer().obj
|
||||
except Exception as e:
|
||||
log.debug("ToolCopperThieving.add_robber_bar() --> %s" % str(e))
|
||||
self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Gerber object loaded ..."))
|
||||
return 'fail'
|
||||
|
||||
try:
|
||||
outline_pol = self.grb_object.solid_geometry.envelope
|
||||
except TypeError:
|
||||
outline_pol = MultiPolygon(self.grb_object.solid_geometry).envelope
|
||||
|
||||
rb_distance = rb_margin + (rb_thickness / 2.0)
|
||||
robber_line = outline_pol.buffer(rb_distance).exterior
|
||||
|
||||
robber_geo = robber_line.buffer(rb_thickness / 2.0)
|
||||
|
||||
self.app.proc_container.update_view_text(' %s' % _("Append geometry"))
|
||||
|
||||
aperture_found = None
|
||||
for ap_id, ap_val in self.grb_object.apertures.items():
|
||||
if ap_val['type'] == 'C' and ap_val['size'] == rb_thickness:
|
||||
aperture_found = ap_id
|
||||
break
|
||||
|
||||
if aperture_found:
|
||||
geo_elem = dict()
|
||||
geo_elem['solid'] = robber_geo
|
||||
geo_elem['follow'] = robber_line
|
||||
self.grb_object.apertures[aperture_found]['geometry'].append(deepcopy(geo_elem))
|
||||
else:
|
||||
ap_keys = list(self.grb_object.apertures.keys())
|
||||
if ap_keys:
|
||||
new_apid = str(int(max(ap_keys)) + 1)
|
||||
else:
|
||||
new_apid = '10'
|
||||
|
||||
self.grb_object.apertures[new_apid] = dict()
|
||||
self.grb_object.apertures[new_apid]['type'] = 'C'
|
||||
self.grb_object.apertures[new_apid]['size'] = rb_thickness
|
||||
self.grb_object.apertures[new_apid]['geometry'] = list()
|
||||
|
||||
geo_elem = dict()
|
||||
geo_elem['solid'] = robber_geo
|
||||
geo_elem['follow'] = robber_line
|
||||
self.grb_object.apertures[new_apid]['geometry'].append(deepcopy(geo_elem))
|
||||
|
||||
geo_obj = self.grb_object.solid_geometry
|
||||
if isinstance(geo_obj, MultiPolygon):
|
||||
s_list = list()
|
||||
for pol in geo_obj.geoms:
|
||||
s_list.append(pol)
|
||||
s_list.append(robber_geo)
|
||||
geo_obj = MultiPolygon(s_list)
|
||||
elif isinstance(geo_obj, list):
|
||||
geo_obj.append(robber_geo)
|
||||
elif isinstance(geo_obj, Polygon):
|
||||
geo_obj = MultiPolygon([geo_obj, robber_geo])
|
||||
|
||||
self.grb_object.solid_geometry = geo_obj
|
||||
|
||||
self.app.proc_container.update_view_text(' %s' % _("Append source file"))
|
||||
# update the source file with the new geometry:
|
||||
self.grb_object.source_file = self.app.export_gerber(obj_name=self.grb_object.options['name'],
|
||||
filename=None,
|
||||
local_use=self.grb_object,
|
||||
use_thread=False)
|
||||
self.app.proc_container.update_view_text(' %s' % '')
|
||||
self.on_exit()
|
||||
self.app.inform.emit('[success] %s' % _("Copper Thieving Tool done."))
|
||||
|
||||
def execute(self):
|
||||
self.app.call_source = "copper_thieving_tool"
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ class Distance(FlatCAMTool):
|
||||
|
||||
# Switch notebook to tool page
|
||||
self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab)
|
||||
self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().lower()
|
||||
self.units = self.app.defaults['units'].lower()
|
||||
|
||||
self.app.command_active = "Distance"
|
||||
|
||||
@@ -210,7 +210,7 @@ class Distance(FlatCAMTool):
|
||||
self.original_call_source = copy(self.app.call_source)
|
||||
|
||||
self.app.inform.emit(_("MEASURING: Click on the Start point ..."))
|
||||
self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().lower()
|
||||
self.units = self.app.defaults['units'].lower()
|
||||
|
||||
# we can connect the app mouse events to the measurement tool
|
||||
# NEVER DISCONNECT THOSE before connecting some other handlers; it breaks something in VisPy
|
||||
|
||||
@@ -175,7 +175,7 @@ class DistanceMin(FlatCAMTool):
|
||||
# Switch notebook to tool page
|
||||
self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab)
|
||||
|
||||
self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().lower()
|
||||
self.units = self.app.defaults['units'].lower()
|
||||
|
||||
# initial view of the layout
|
||||
self.start_entry.set_value('(0, 0)')
|
||||
@@ -195,7 +195,7 @@ class DistanceMin(FlatCAMTool):
|
||||
# ENABLE the Measuring TOOL
|
||||
self.jump_hp_btn.setDisabled(False)
|
||||
|
||||
self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().lower()
|
||||
self.units = self.app.defaults['units'].lower()
|
||||
|
||||
if self.app.call_source == 'app':
|
||||
selected_objs = self.app.collection.get_selected()
|
||||
|
||||
@@ -370,7 +370,7 @@ class ToolFiducials(FlatCAMTool):
|
||||
FlatCAMTool.install(self, icon, separator, shortcut='ALT+J', **kwargs)
|
||||
|
||||
def set_tool_ui(self):
|
||||
self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value()
|
||||
self.units = self.app.defaults['units']
|
||||
self.fid_size_entry.set_value(self.app.defaults["tools_fiducials_dia"])
|
||||
self.margin_entry.set_value(float(self.app.defaults["tools_fiducials_margin"]))
|
||||
self.mode_radio.set_value(self.app.defaults["tools_fiducials_mode"])
|
||||
|
||||
@@ -314,7 +314,7 @@ class ToolMove(FlatCAMTool):
|
||||
|
||||
def draw_shape(self, shape):
|
||||
|
||||
if self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper() == 'MM':
|
||||
if self.app.defaults['units'].upper() == 'MM':
|
||||
proc_shape = shape.buffer(-0.1)
|
||||
proc_shape = proc_shape.buffer(0.2)
|
||||
else:
|
||||
|
||||
@@ -617,7 +617,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
|
||||
self.app.ui.notebook.setTabText(2, _("NCC Tool"))
|
||||
|
||||
def set_tool_ui(self):
|
||||
self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
|
||||
self.units = self.app.defaults['units'].upper()
|
||||
|
||||
if self.units == "IN":
|
||||
self.decimals = 4
|
||||
@@ -715,13 +715,13 @@ class NonCopperClear(FlatCAMTool, Gerber):
|
||||
self.bound_obj = None
|
||||
|
||||
self.tool_type_item_options = ["C1", "C2", "C3", "C4", "B", "V"]
|
||||
self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
|
||||
self.units = self.app.defaults['units'].upper()
|
||||
|
||||
def build_ui(self):
|
||||
self.ui_disconnect()
|
||||
|
||||
# updated units
|
||||
self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
|
||||
self.units = self.app.defaults['units'].upper()
|
||||
|
||||
sorted_tools = []
|
||||
for k, v in self.ncc_tools.items():
|
||||
@@ -954,7 +954,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
|
||||
|
||||
def on_tool_add(self, dia=None, muted=None):
|
||||
self.ui_disconnect()
|
||||
self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
|
||||
self.units = self.app.defaults['units'].upper()
|
||||
|
||||
if dia:
|
||||
tool_dia = dia
|
||||
@@ -1404,7 +1404,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
|
||||
# ####### Read the parameters #########################################
|
||||
# #####################################################################
|
||||
|
||||
units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value()
|
||||
units = self.app.defaults['units']
|
||||
|
||||
log.debug("NCC Tool started. Reading parameters.")
|
||||
self.app.inform.emit(_("NCC Tool started. Reading parameters."))
|
||||
|
||||
@@ -308,7 +308,7 @@ class ToolOptimal(FlatCAMTool):
|
||||
self.reset_fields()
|
||||
|
||||
def find_minimum_distance(self):
|
||||
self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
|
||||
self.units = self.app.defaults['units'].upper()
|
||||
self.decimals = int(self.precision_spinner.get_value())
|
||||
|
||||
selection_index = self.gerber_object_combo.currentIndex()
|
||||
|
||||
@@ -180,7 +180,7 @@ class ToolPDF(FlatCAMTool):
|
||||
self.pdf_decompressed[short_name] = ''
|
||||
|
||||
# the UNITS in PDF files are points and here we set the factor to convert them to real units (either MM or INCH)
|
||||
if self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper() == 'MM':
|
||||
if self.app.defaults['units'].upper() == 'MM':
|
||||
# 1 inch = 72 points => 1 point = 1 / 72 = 0.01388888888 inch = 0.01388888888 inch * 25.4 = 0.35277777778 mm
|
||||
self.point_to_unit_factor = 25.4 / 72
|
||||
else:
|
||||
|
||||
@@ -575,7 +575,7 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||
# make the default object type, "Geometry"
|
||||
self.type_obj_combo.setCurrentIndex(2)
|
||||
# updated units
|
||||
self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
|
||||
self.units = self.app.defaults['units'].upper()
|
||||
|
||||
if self.units == "IN":
|
||||
self.decimals = 4
|
||||
@@ -637,7 +637,7 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||
pass
|
||||
|
||||
# updated units
|
||||
self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
|
||||
self.units = self.app.defaults['units'].upper()
|
||||
|
||||
sorted_tools = []
|
||||
for k, v in self.paint_tools.items():
|
||||
|
||||
@@ -175,7 +175,7 @@ class Properties(FlatCAMTool):
|
||||
log.debug("PropertiesTool.addItems() --> %s" % str(e))
|
||||
|
||||
# calculate box area
|
||||
if self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().lower() == 'mm':
|
||||
if self.app.defaults['units'].lower() == 'mm':
|
||||
area = (length * width) / 100
|
||||
else:
|
||||
area = length * width
|
||||
@@ -205,7 +205,7 @@ class Properties(FlatCAMTool):
|
||||
width = abs(ymax - ymin)
|
||||
|
||||
# calculate box area
|
||||
if self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().lower() == 'mm':
|
||||
if self.app.defaults['units'].lower() == 'mm':
|
||||
area = (length * width) / 100
|
||||
else:
|
||||
area = length * width
|
||||
@@ -238,7 +238,7 @@ class Properties(FlatCAMTool):
|
||||
area_chull = None
|
||||
log.debug("Properties.addItems() --> %s" % str(e))
|
||||
|
||||
if self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().lower() == 'mm':
|
||||
if self.app.defaults['units'].lower() == 'mm':
|
||||
area_chull = area_chull / 100
|
||||
|
||||
self.calculations_finished.emit(area, length, width, area_chull, dims)
|
||||
@@ -251,7 +251,7 @@ class Properties(FlatCAMTool):
|
||||
'in': _('Inch'),
|
||||
'mm': _('Metric')
|
||||
}
|
||||
[str(self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().lower())]
|
||||
[str(self.app.defaults['units'].lower())]
|
||||
],
|
||||
True
|
||||
)
|
||||
@@ -353,12 +353,12 @@ class Properties(FlatCAMTool):
|
||||
|
||||
# add dimensions
|
||||
self.addChild(location, ['%s:' % _('Length'), '%.4f %s' % (
|
||||
length, self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().lower())], True)
|
||||
length, self.app.defaults['units'].lower())], True)
|
||||
self.addChild(location, ['%s:' % _('Width'), '%.4f %s' % (
|
||||
width, self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().lower())], True)
|
||||
width, self.app.defaults['units'].lower())], True)
|
||||
|
||||
# add box area
|
||||
if self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().lower() == 'mm':
|
||||
if self.app.defaults['units'].lower() == 'mm':
|
||||
self.addChild(location, ['%s:' % _('Box Area'), '%.4f %s' % (area, 'cm2')], True)
|
||||
self.addChild(location, ['%s:' % _('Convex_Hull Area'), '%.4f %s' % (chull_area, 'cm2')], True)
|
||||
|
||||
|
||||
@@ -353,7 +353,7 @@ class QRCode(FlatCAMTool):
|
||||
FlatCAMTool.install(self, icon, separator, shortcut='ALT+Q', **kwargs)
|
||||
|
||||
def set_tool_ui(self):
|
||||
self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value()
|
||||
self.units = self.app.defaults['units']
|
||||
self.version_entry.set_value(int(self.app.defaults["tools_qrcode_version"]))
|
||||
self.error_radio.set_value(self.app.defaults["tools_qrcode_error"])
|
||||
self.bsize_entry.set_value(int(self.app.defaults["tools_qrcode_box_size"]))
|
||||
|
||||
@@ -578,7 +578,7 @@ class SolderPaste(FlatCAMTool):
|
||||
self.name = ""
|
||||
self.obj = None
|
||||
|
||||
self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
|
||||
self.units = self.app.defaults['units'].upper()
|
||||
|
||||
if self.units == "IN":
|
||||
self.decimals = 4
|
||||
@@ -601,7 +601,7 @@ class SolderPaste(FlatCAMTool):
|
||||
self.ui_disconnect()
|
||||
|
||||
# updated units
|
||||
self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
|
||||
self.units = self.app.defaults['units'].upper()
|
||||
|
||||
sorted_tools = []
|
||||
for k, v in self.tooltable_tools.items():
|
||||
|
||||
Reference in New Issue
Block a user