- added the circle approximation parameter for Excellon geometry in Preferences

- updated the language strings
This commit is contained in:
Marius Stanciu
2021-10-05 01:12:43 +03:00
committed by Marius
parent 1b6b432f7c
commit 771365f65c
2 changed files with 201 additions and 159 deletions

View File

@@ -7,6 +7,10 @@ CHANGELOG for FlatCAM beta
================================================= =================================================
5.10.2021
- Corners Plugin made sure that Drill in Locations and Check in Locations functionality works for manual mode
4.10.2021 4.10.2021
- fixed a typo in the Object UI - fixed a typo in the Object UI

View File

@@ -135,7 +135,7 @@ class ToolCorners(AppTool):
self.ui.toggle_all_cb.toggled.connect(self.on_toggle_all) self.ui.toggle_all_cb.toggled.connect(self.on_toggle_all)
self.ui.drill_button.clicked.connect(self.on_create_drill_object) self.ui.drill_button.clicked.connect(self.on_create_drill_object)
self.ui.check_button.clicked.connect(self.on_create_check_object) self.ui.check_button.clicked.connect(self.on_create_check_object)
self.ui.sel_radio.activated_custom.connect(self.on_selection_changed) self.ui.mode_radio.activated_custom.connect(self.on_selection_changed)
def set_tool_ui(self): def set_tool_ui(self):
self.units = self.app.app_units self.units = self.app.app_units
@@ -151,7 +151,7 @@ class ToolCorners(AppTool):
self.ui.toggle_all_cb.set_value(False) self.ui.toggle_all_cb.set_value(False)
self.ui.type_radio.set_value(self.app.defaults["tools_corners_type"]) self.ui.type_radio.set_value(self.app.defaults["tools_corners_type"])
self.ui.drill_dia_entry.set_value(self.app.defaults["tools_corners_drill_dia"]) self.ui.drill_dia_entry.set_value(self.app.defaults["tools_corners_drill_dia"])
self.ui.sel_radio.set_value("a") self.ui.mode_radio.set_value("a")
# SELECT THE CURRENT OBJECT # SELECT THE CURRENT OBJECT
obj = self.app.collection.get_active() obj = self.app.collection.get_active()
@@ -237,7 +237,7 @@ class ToolCorners(AppTool):
def add_markers(self): def add_markers(self):
self.app.call_source = "corners_tool" self.app.call_source = "corners_tool"
select_type = self.ui.sel_radio.get_value() select_type = self.ui.mode_radio.get_value()
if select_type == 'a': if select_type == 'a':
self.handle_automatic_placement() self.handle_automatic_placement()
else: else:
@@ -248,6 +248,8 @@ class ToolCorners(AppTool):
self.connect_event_handlers() self.connect_event_handlers()
def handle_automatic_placement(self): def handle_automatic_placement(self):
self.points.clear()
tl_state = self.ui.tl_cb.get_value() tl_state = self.ui.tl_cb.get_value()
tr_state = self.ui.tr_cb.get_value() tr_state = self.ui.tr_cb.get_value()
bl_state = self.ui.bl_cb.get_value() bl_state = self.ui.bl_cb.get_value()
@@ -266,7 +268,7 @@ class ToolCorners(AppTool):
return return
xmin, ymin, xmax, ymax = self.grb_object.bounds() xmin, ymin, xmax, ymax = self.grb_object.bounds()
self.points = {}
if tl_state: if tl_state:
self.points['tl'] = (xmin, ymax) self.points['tl'] = (xmin, ymax)
if tr_state: if tr_state:
@@ -321,12 +323,15 @@ class ToolCorners(AppTool):
margin = self.ui.margin_entry.get_value() margin = self.ui.margin_entry.get_value()
line_length = self.ui.l_entry.get_value() / 2.0 line_length = self.ui.l_entry.get_value() / 2.0
mode = self.ui.mode_radio.get_value()
geo_list = [] geo_list = []
if not points_storage: if not points_storage:
self.app.inform.emit("[ERROR_NOTCL] %s." % _("Please select at least a location")) self.app.inform.emit("[ERROR_NOTCL] %s." % _("Please select at least a location"))
return 'fail' return 'fail'
if mode == 'a':
for key in points_storage: for key in points_storage:
if key == 'tl': if key == 'tl':
pt = points_storage[key] pt = points_storage[key]
@@ -408,7 +413,8 @@ class ToolCorners(AppTool):
]) ])
geo_list.append(line_geo_hor) geo_list.append(line_geo_hor)
geo_list.append(line_geo_vert) geo_list.append(line_geo_vert)
if key == 'manual': elif mode == 'm':
if 'manual' in points_storage:
if points_storage['manual']: if points_storage['manual']:
for man_pt in points_storage['manual']: for man_pt in points_storage['manual']:
x = man_pt[0] - line_thickness / 2.0 x = man_pt[0] - line_thickness / 2.0
@@ -463,11 +469,15 @@ class ToolCorners(AppTool):
s_list = [] s_list = []
if g_obj.solid_geometry: if g_obj.solid_geometry:
if isinstance(g_obj.solid_geometry, MultiPolygon):
work_geo = g_obj.solid_geometry.geoms
else:
work_geo = g_obj.solid_geometry
try: try:
for poly in g_obj.solid_geometry: for poly in work_geo:
s_list.append(poly) s_list.append(poly)
except TypeError: except TypeError:
s_list.append(g_obj.solid_geometry) s_list.append(work_geo)
geo_buff_list = MultiPolygon(geo_buff_list) geo_buff_list = MultiPolygon(geo_buff_list)
geo_buff_list = geo_buff_list.buffer(0) geo_buff_list = geo_buff_list.buffer(0)
@@ -529,7 +539,8 @@ class ToolCorners(AppTool):
self.app.call_source = "app" self.app.call_source = "app"
return return
if tl_state is False and tr_state is False and bl_state is False and br_state is False: if tl_state is False and tr_state is False and bl_state is False and br_state is False and \
'manual' not in self.points:
self.app.inform.emit("[ERROR_NOTCL] %s." % _("Please select at least a location")) self.app.inform.emit("[ERROR_NOTCL] %s." % _("Please select at least a location"))
self.app.call_source = "app" self.app.call_source = "app"
return return
@@ -539,6 +550,7 @@ class ToolCorners(AppTool):
# list of (x,y) tuples. Store here the drill coordinates # list of (x,y) tuples. Store here the drill coordinates
drill_list = [] drill_list = []
if 'manual' not in self.points:
if tl_state: if tl_state:
x = xmin - margin - line_thickness / 2.0 + tooldia / 2.0 x = xmin - margin - line_thickness / 2.0 + tooldia / 2.0
y = ymax + margin + line_thickness / 2.0 - tooldia / 2.0 y = ymax + margin + line_thickness / 2.0 - tooldia / 2.0
@@ -566,12 +578,24 @@ class ToolCorners(AppTool):
drill_list.append( drill_list.append(
Point((x, y)) Point((x, y))
) )
else:
if self.points['manual']:
for pt in self.points['manual']:
add_pt = (pt[0] - (line_thickness / 2)), (pt[1] + line_thickness / 2)
drill_list.append(
Point(add_pt)
)
else:
self.app.inform.emit("[ERROR_NOTCL] %s." % _("Please select at least a location"))
self.app.call_source = "app"
return
tools = { tools = {
1: { 1: {
"tooldia": tooldia, "tooldia": tooldia,
"drills": drill_list, "drills": drill_list,
"slots": [], "slots": [],
"data": {},
"solid_geometry": [] "solid_geometry": []
} }
} }
@@ -588,7 +612,7 @@ class ToolCorners(AppTool):
use_thread=False) use_thread=False)
outname = '%s_%s' % (str(self.grb_object.options['name']), 'corner_drills') outname = '%s_%s' % (str(self.grb_object.options['name']), 'corner_drills')
ret_val = self.app.app_obj.new_object("excellon", outname, obj_init) ret_val = self.app.app_obj.new_object("excellon", outname, obj_init, autoselected=False)
self.app.call_source = "app" self.app.call_source = "app"
if ret_val == 'fail': if ret_val == 'fail':
@@ -607,6 +631,7 @@ class ToolCorners(AppTool):
line_thickness = self.ui.thick_entry.get_value() line_thickness = self.ui.thick_entry.get_value()
margin = self.ui.margin_entry.get_value() margin = self.ui.margin_entry.get_value()
tl_state = self.ui.tl_cb.get_value() tl_state = self.ui.tl_cb.get_value()
tr_state = self.ui.tr_cb.get_value() tr_state = self.ui.tr_cb.get_value()
bl_state = self.ui.bl_cb.get_value() bl_state = self.ui.bl_cb.get_value()
@@ -624,7 +649,8 @@ class ToolCorners(AppTool):
self.app.call_source = "app" self.app.call_source = "app"
return return
if tl_state is False and tr_state is False and bl_state is False and br_state is False: if tl_state is False and tr_state is False and bl_state is False and br_state is False and \
'manual' not in self.points:
self.app.inform.emit("[ERROR_NOTCL] %s." % _("Please select at least a location")) self.app.inform.emit("[ERROR_NOTCL] %s." % _("Please select at least a location"))
self.app.call_source = "app" self.app.call_source = "app"
return return
@@ -634,6 +660,7 @@ class ToolCorners(AppTool):
# list of (x,y) tuples. Store here the drill coordinates # list of (x,y) tuples. Store here the drill coordinates
drill_list = [] drill_list = []
if 'manual' not in self.points:
if tl_state: if tl_state:
x = xmin - margin - line_thickness / 2.0 + tooldia / 2.0 x = xmin - margin - line_thickness / 2.0 + tooldia / 2.0
y = ymax + margin + line_thickness / 2.0 - tooldia / 2.0 y = ymax + margin + line_thickness / 2.0 - tooldia / 2.0
@@ -661,6 +688,17 @@ class ToolCorners(AppTool):
drill_list.append( drill_list.append(
Point((x, y)) Point((x, y))
) )
else:
if self.points['manual']:
for pt in self.points['manual']:
add_pt = (pt[0] - (line_thickness / 2)), (pt[1] + line_thickness / 2)
drill_list.append(
Point(add_pt)
)
else:
self.app.inform.emit("[ERROR_NOTCL] %s." % _("Please select at least a location"))
self.app.call_source = "app"
return
tools = { tools = {
1: { 1: {
@@ -691,7 +729,7 @@ class ToolCorners(AppTool):
use_thread=False) use_thread=False)
outname = '%s_%s' % (str(self.grb_object.options['name']), 'verification') outname = '%s_%s' % (str(self.grb_object.options['name']), 'verification')
ret_val = self.app.app_obj.new_object("excellon", outname, obj_init) ret_val = self.app.app_obj.new_object("excellon", outname, obj_init, autoselected=False)
self.app.call_source = "app" self.app.call_source = "app"
if ret_val == 'fail': if ret_val == 'fail':
@@ -981,8 +1019,8 @@ class CornersUI:
# Selection Frame # Selection Frame
# ############################################################################################################# # #############################################################################################################
# Selection # Selection
self.sel_label = FCLabel('<span style="color:green;"><b>%s</b></span>' % _("Selection")) self.mode_label = FCLabel('<span style="color:green;"><b>%s</b></span>' % _("Selection"))
self.tools_box.addWidget(self.sel_label) self.tools_box.addWidget(self.mode_label)
self.s_frame = FCFrame() self.s_frame = FCFrame()
self.tools_box.addWidget(self.s_frame) self.tools_box.addWidget(self.s_frame)
@@ -992,19 +1030,19 @@ class CornersUI:
self.s_frame.setLayout(grid_sel) self.s_frame.setLayout(grid_sel)
# Type of placement of markers # Type of placement of markers
self.sel_label = FCLabel('%s: ' % _("Mode")) self.mode_label = FCLabel('%s: ' % _("Mode"))
self.sel_label.setToolTip( self.mode_label.setToolTip(
_("When the manual type is chosen, the markers\n" _("When the manual type is chosen, the markers\n"
"are manually placed on canvas.") "are manually placed on canvas.")
) )
self.sel_radio = RadioSet([ self.mode_radio = RadioSet([
{"label": _("Auto"), "value": "a"}, {"label": _("Auto"), "value": "a"},
{"label": _("Manual"), "value": "m"}, {"label": _("Manual"), "value": "m"},
]) ])
grid_sel.addWidget(self.sel_label, 0, 0) grid_sel.addWidget(self.mode_label, 0, 0)
grid_sel.addWidget(self.sel_radio, 0, 1) grid_sel.addWidget(self.mode_radio, 0, 1)
# ############################################################################################################# # #############################################################################################################
# ## Insert Corner Marker Button # ## Insert Corner Marker Button