- optimized the Gerber UI

- added a Multi-color checkbox for the Geometry UI (will color differently tool geometry when the geometry is multitool)
This commit is contained in:
Marius Stanciu
2020-05-30 18:17:40 +03:00
committed by Marius
parent d8bf1a8a4e
commit 44191a5e07
8 changed files with 98 additions and 61 deletions

View File

@@ -219,7 +219,7 @@ class GerberObjectUI(ObjectUI):
self.name_hlay.addWidget(self.name_entry) self.name_hlay.addWidget(self.name_entry)
# Plot CB # Plot CB
self.plot_lbl = FCLabel('%s' % _("Plot")) self.plot_lbl = FCLabel('%s:' % _("Plot"))
self.plot_lbl.setToolTip(_("Plot (show) this object.")) self.plot_lbl.setToolTip(_("Plot (show) this object."))
self.plot_cb = FCCheckBox() self.plot_cb = FCCheckBox()
@@ -227,18 +227,12 @@ class GerberObjectUI(ObjectUI):
grid0.addWidget(self.plot_cb, 2, 1) grid0.addWidget(self.plot_cb, 2, 1)
# generate follow # generate follow
self.follow_lbl = FCLabel('%s:' % _("Follow")) self.follow_cb = FCCheckBox('%s' % _("Follow"))
self.follow_lbl.setToolTip(_("Generate a 'Follow' geometry.\n" self.follow_cb.setToolTip(_("Generate a 'Follow' geometry.\n"
"This means that it will cut through\n" "This means that it will cut through\n"
"the middle of the trace.")) "the middle of the trace."))
self.follow_lbl.setMinimumWidth(90) self.follow_cb.setMinimumWidth(55)
self.follow_cb = FCCheckBox() grid0.addWidget(self.follow_cb, 2, 2)
hf_lay = QtWidgets.QHBoxLayout()
self.custom_box.addLayout(hf_lay)
hf_lay.addWidget(self.follow_lbl)
hf_lay.addWidget(self.follow_cb)
hf_lay.addStretch()
hlay_plot = QtWidgets.QHBoxLayout() hlay_plot = QtWidgets.QHBoxLayout()
self.custom_box.addLayout(hlay_plot) self.custom_box.addLayout(hlay_plot)
@@ -328,14 +322,7 @@ class GerberObjectUI(ObjectUI):
self.tool_lbl = QtWidgets.QLabel('<b>%s</b>' % _("TOOLS")) self.tool_lbl = QtWidgets.QLabel('<b>%s</b>' % _("TOOLS"))
grid2.addWidget(self.tool_lbl, 0, 0, 1, 2) grid2.addWidget(self.tool_lbl, 0, 0, 1, 2)
# ## Isolation Routing # Isolation Tool - will create isolation paths around the copper features
self.iso_label = QtWidgets.QLabel("%s" % _("Isolation"))
self.iso_label.setToolTip(
_("Create a Geometry object with\n"
"toolpaths to cut around polygons.")
)
self.iso_label.setMinimumWidth(90)
self.iso_button = QtWidgets.QPushButton(_('Isolation Routing')) self.iso_button = QtWidgets.QPushButton(_('Isolation Routing'))
self.iso_button.setToolTip( self.iso_button.setToolTip(
_("Create a Geometry object with\n" _("Create a Geometry object with\n"
@@ -347,17 +334,9 @@ class GerberObjectUI(ObjectUI):
font-weight: bold; font-weight: bold;
} }
""") """)
grid2.addWidget(self.iso_label, 1, 0) grid2.addWidget(self.iso_button, 1, 0, 1, 2)
grid2.addWidget(self.iso_button, 1, 1)
# ## Clear non-copper regions # ## Clear non-copper regions
self.clearcopper_label = QtWidgets.QLabel("%s" % _("Clear N-copper"))
self.clearcopper_label.setToolTip(
_("Create a Geometry object with\n"
"toolpaths to cut all non-copper regions.")
)
self.clearcopper_label.setMinimumWidth(90)
self.generate_ncc_button = QtWidgets.QPushButton(_('NCC Tool')) self.generate_ncc_button = QtWidgets.QPushButton(_('NCC Tool'))
self.generate_ncc_button.setToolTip( self.generate_ncc_button.setToolTip(
_("Create the Geometry Object\n" _("Create the Geometry Object\n"
@@ -369,17 +348,9 @@ class GerberObjectUI(ObjectUI):
font-weight: bold; font-weight: bold;
} }
""") """)
grid2.addWidget(self.clearcopper_label, 2, 0) grid2.addWidget(self.generate_ncc_button, 2, 0, 1, 2)
grid2.addWidget(self.generate_ncc_button, 2, 1)
# ## Board cutout # ## Board cutout
self.board_cutout_label = QtWidgets.QLabel("%s" % _("Board cutout"))
self.board_cutout_label.setToolTip(
_("Create toolpaths to cut around\n"
"the PCB and separate it from\n"
"the original board.")
)
self.generate_cutout_button = QtWidgets.QPushButton(_('Cutout Tool')) self.generate_cutout_button = QtWidgets.QPushButton(_('Cutout Tool'))
self.generate_cutout_button.setToolTip( self.generate_cutout_button.setToolTip(
_("Generate the geometry for\n" _("Generate the geometry for\n"
@@ -391,8 +362,7 @@ class GerberObjectUI(ObjectUI):
font-weight: bold; font-weight: bold;
} }
""") """)
grid2.addWidget(self.board_cutout_label, 3, 0) grid2.addWidget(self.generate_cutout_button, 3, 0, 1, 2)
grid2.addWidget(self.generate_cutout_button, 3, 1)
separator_line = QtWidgets.QFrame() separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.HLine) separator_line.setFrameShape(QtWidgets.QFrame.HLine)
@@ -1312,12 +1282,28 @@ class GeometryObjectUI(ObjectUI):
) )
# Plot options # Plot options
grid_header = QtWidgets.QGridLayout()
grid_header.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
self.custom_box.addLayout(grid_header)
grid_header.setColumnStretch(0, 0)
grid_header.setColumnStretch(1, 1)
self.plot_options_label = QtWidgets.QLabel("<b>%s:</b>" % _("Plot Options")) self.plot_options_label = QtWidgets.QLabel("<b>%s:</b>" % _("Plot Options"))
self.custom_box.addWidget(self.plot_options_label) self.plot_options_label.setMinimumWidth(90)
grid_header.addWidget(self.plot_options_label, 0, 0)
# Multicolored CB
self.multicolored_cb = FCCheckBox(label=_('Multi-Color'))
self.multicolored_cb.setToolTip(
_("Draw polygons in different colors.")
)
self.multicolored_cb.setMinimumWidth(55)
grid_header.addWidget(self.multicolored_cb, 0, 2)
# ## Object name # ## Object name
self.name_hlay = QtWidgets.QHBoxLayout() self.name_hlay = QtWidgets.QHBoxLayout()
self.custom_box.addLayout(self.name_hlay) grid_header.addLayout(self.name_hlay, 1, 0, 1, 3)
name_label = QtWidgets.QLabel("<b>%s:</b>" % _("Name")) name_label = QtWidgets.QLabel("<b>%s:</b>" % _("Name"))
self.name_entry = FCEntry() self.name_entry = FCEntry()
@@ -1481,19 +1467,24 @@ class GeometryObjectUI(ObjectUI):
grid1.addWidget(self.addtool_entry_lbl, 3, 0) grid1.addWidget(self.addtool_entry_lbl, 3, 0)
grid1.addWidget(self.addtool_entry, 3, 1) grid1.addWidget(self.addtool_entry, 3, 1)
bhlay = QtWidgets.QHBoxLayout()
self.addtool_btn = QtWidgets.QPushButton(_('Add')) self.addtool_btn = QtWidgets.QPushButton(_('Add'))
self.addtool_btn.setToolTip( self.addtool_btn.setToolTip(
_("Add a new tool to the Tool Table\n" _("Add a new tool to the Tool Table\n"
"with the specified diameter.") "with the diameter specified above.")
) )
grid1.addWidget(self.addtool_btn, 4, 0, 1, 2)
self.addtool_from_db_btn = QtWidgets.QPushButton(_('Add from DB')) self.addtool_from_db_btn = QtWidgets.QPushButton(_('Add from DB'))
self.addtool_from_db_btn.setToolTip( self.addtool_from_db_btn.setToolTip(
_("Add a new tool to the Tool Table\n" _("Add a new tool to the Tool Table\n"
"from the Tool DataBase.") "from the Tool DataBase.")
) )
grid1.addWidget(self.addtool_from_db_btn, 7, 0, 1, 2)
bhlay.addWidget(self.addtool_btn)
bhlay.addWidget(self.addtool_from_db_btn)
grid1.addLayout(bhlay, 5, 0, 1, 2)
separator_line = QtWidgets.QFrame() separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.HLine) separator_line.setFrameShape(QtWidgets.QFrame.HLine)

View File

@@ -259,6 +259,7 @@ class PreferencesUIManager:
# Geometry General # Geometry General
"geometry_plot": self.ui.geometry_defaults_form.geometry_gen_group.plot_cb, "geometry_plot": self.ui.geometry_defaults_form.geometry_gen_group.plot_cb,
"geometry_multicolored": self.ui.geometry_defaults_form.geometry_gen_group.multicolored_cb,
"geometry_circle_steps": self.ui.geometry_defaults_form.geometry_gen_group.circle_steps_entry, "geometry_circle_steps": self.ui.geometry_defaults_form.geometry_gen_group.circle_steps_entry,
"geometry_cnctooldia": self.ui.geometry_defaults_form.geometry_gen_group.cnctooldia_entry, "geometry_cnctooldia": self.ui.geometry_defaults_form.geometry_gen_group.cnctooldia_entry,
"geometry_plot_line": self.ui.geometry_defaults_form.geometry_gen_group.line_color_entry, "geometry_plot_line": self.ui.geometry_defaults_form.geometry_gen_group.line_color_entry,

View File

@@ -31,12 +31,22 @@ class GeometryGenPrefGroupUI(OptionsGroupUI):
self.plot_options_label = QtWidgets.QLabel("<b>%s:</b>" % _("Plot Options")) self.plot_options_label = QtWidgets.QLabel("<b>%s:</b>" % _("Plot Options"))
self.layout.addWidget(self.plot_options_label) self.layout.addWidget(self.plot_options_label)
plot_hlay = QtWidgets.QHBoxLayout()
self.layout.addLayout((plot_hlay))
# Plot CB # Plot CB
self.plot_cb = FCCheckBox(label=_('Plot')) self.plot_cb = FCCheckBox(label=_('Plot'))
self.plot_cb.setToolTip( self.plot_cb.setToolTip(
_("Plot (show) this object.") _("Plot (show) this object.")
) )
self.layout.addWidget(self.plot_cb) plot_hlay.addWidget(self.plot_cb)
# Multicolored CB
self.multicolored_cb = FCCheckBox(label=_('M-Color'))
self.multicolored_cb.setToolTip(
_("Draw polygons in different colors.")
)
plot_hlay.addWidget(self.multicolored_cb)
grid0 = QtWidgets.QGridLayout() grid0 = QtWidgets.QGridLayout()
self.layout.addLayout(grid0) self.layout.addLayout(grid0)

View File

@@ -34,26 +34,26 @@ class GerberGenPrefGroupUI(OptionsGroupUI):
grid0 = QtWidgets.QGridLayout() grid0 = QtWidgets.QGridLayout()
self.layout.addLayout(grid0) self.layout.addLayout(grid0)
# Plot CB
self.plot_cb = FCCheckBox(label='%s' % _('Plot'))
self.plot_options_label.setToolTip(
_("Plot (show) this object.")
)
grid0.addWidget(self.plot_cb, 0, 0)
# Solid CB # Solid CB
self.solid_cb = FCCheckBox(label='%s' % _('Solid')) self.solid_cb = FCCheckBox(label='%s' % _('Solid'))
self.solid_cb.setToolTip( self.solid_cb.setToolTip(
_("Solid color polygons.") _("Solid color polygons.")
) )
grid0.addWidget(self.solid_cb, 0, 0) grid0.addWidget(self.solid_cb, 0, 1)
# Multicolored CB # Multicolored CB
self.multicolored_cb = FCCheckBox(label='%s' % _('M-Color')) self.multicolored_cb = FCCheckBox(label='%s' % _('M-Color'))
self.multicolored_cb.setToolTip( self.multicolored_cb.setToolTip(
_("Draw polygons in different colors.") _("Draw polygons in different colors.")
) )
grid0.addWidget(self.multicolored_cb, 0, 1) grid0.addWidget(self.multicolored_cb, 0, 2)
# Plot CB
self.plot_cb = FCCheckBox(label='%s' % _('Plot'))
self.plot_options_label.setToolTip(
_("Plot (show) this object.")
)
grid0.addWidget(self.plot_cb, 0, 2)
# Number of circle steps for circular aperture linear approximation # Number of circle steps for circular aperture linear approximation
self.circle_steps_label = QtWidgets.QLabel('%s:' % _("Circle Steps")) self.circle_steps_label = QtWidgets.QLabel('%s:' % _("Circle Steps"))

View File

@@ -52,6 +52,7 @@ class GeometryObject(FlatCAMObj, Geometry):
self.options.update({ self.options.update({
"plot": True, "plot": True,
"multicolored": False,
"cutz": -0.002, "cutz": -0.002,
"vtipdia": 0.1, "vtipdia": 0.1,
"vtipangle": 30, "vtipangle": 30,
@@ -396,6 +397,7 @@ class GeometryObject(FlatCAMObj, Geometry):
self.form_fields.update({ self.form_fields.update({
"plot": self.ui.plot_cb, "plot": self.ui.plot_cb,
"multicolored": self.ui.multicolored_cb,
"cutz": self.ui.cutz_entry, "cutz": self.ui.cutz_entry,
"vtipdia": self.ui.tipdia_entry, "vtipdia": self.ui.tipdia_entry,
"vtipangle": self.ui.tipangle_entry, "vtipangle": self.ui.tipangle_entry,
@@ -591,6 +593,8 @@ class GeometryObject(FlatCAMObj, Geometry):
self.ui.extracut_cb.toggled.connect(lambda state: self.ui.e_cut_entry.setDisabled(not state)) self.ui.extracut_cb.toggled.connect(lambda state: self.ui.e_cut_entry.setDisabled(not state))
self.ui.plot_cb.stateChanged.connect(self.on_plot_cb_click) self.ui.plot_cb.stateChanged.connect(self.on_plot_cb_click)
self.ui.multicolored_cb.stateChanged.connect(self.on_multicolored_cb_click)
self.ui.generate_cnc_button.clicked.connect(self.on_generatecnc_button_click) self.ui.generate_cnc_button.clicked.connect(self.on_generatecnc_button_click)
self.ui.paint_tool_button.clicked.connect(lambda: self.app.paint_tool.run(toggle=False)) self.ui.paint_tool_button.clicked.connect(lambda: self.app.paint_tool.run(toggle=False))
self.ui.generate_ncc_button.clicked.connect(lambda: self.app.ncclear_tool.run(toggle=False)) self.ui.generate_ncc_button.clicked.connect(lambda: self.app.ncclear_tool.run(toggle=False))
@@ -2665,6 +2669,27 @@ class GeometryObject(FlatCAMObj, Geometry):
if not FlatCAMObj.plot(self): if not FlatCAMObj.plot(self):
return return
if self.app.is_legacy is False:
def random_color():
r_color = np.random.rand(4)
r_color[3] = 1
return r_color
else:
def random_color():
while True:
r_color = np.random.rand(4)
r_color[3] = 1
new_color = '#'
for idx in range(len(r_color)):
new_color += '%x' % int(r_color[idx] * 255)
# do it until a valid color is generated
# a valid color has the # symbol, another 6 chars for the color and the last 2 chars for alpha
# for a total of 9 chars
if len(new_color) == 9:
break
return new_color
try: try:
# plot solid geometries found as members of self.tools attribute dict # plot solid geometries found as members of self.tools attribute dict
# for MultiGeo # for MultiGeo
@@ -2672,7 +2697,8 @@ class GeometryObject(FlatCAMObj, Geometry):
for tooluid_key in self.tools: for tooluid_key in self.tools:
solid_geometry = self.tools[tooluid_key]['solid_geometry'] solid_geometry = self.tools[tooluid_key]['solid_geometry']
self.plot_element(solid_geometry, visible=visible, self.plot_element(solid_geometry, visible=visible,
color=self.app.defaults["geometry_plot_line"]) color=random_color() if self.options['multicolored']
else self.app.defaults["geometry_plot_line"])
else: else:
# plot solid geometry that may be an direct attribute of the geometry object # plot solid geometry that may be an direct attribute of the geometry object
# for SingleGeo # for SingleGeo
@@ -2740,6 +2766,12 @@ class GeometryObject(FlatCAMObj, Geometry):
self.ui.plot_cb.setChecked(True) self.ui.plot_cb.setChecked(True)
self.ui_connect() self.ui_connect()
def on_multicolored_cb_click(self, *args):
if self.muted_ui:
return
self.read_form_item('multicolored')
self.plot()
@staticmethod @staticmethod
def merge(geo_list, geo_final, multigeo=None): def merge(geo_list, geo_final, multigeo=None):
""" """

View File

@@ -271,7 +271,7 @@ class ToolIsolation(AppTool, Gerber):
self.grid3.addWidget(self.addtool_entry_lbl, 6, 0) self.grid3.addWidget(self.addtool_entry_lbl, 6, 0)
self.grid3.addWidget(self.addtool_entry, 6, 1) self.grid3.addWidget(self.addtool_entry, 6, 1)
hlay = QtWidgets.QHBoxLayout() bhlay = QtWidgets.QHBoxLayout()
self.addtool_btn = QtWidgets.QPushButton(_('Add')) self.addtool_btn = QtWidgets.QPushButton(_('Add'))
self.addtool_btn.setToolTip( self.addtool_btn.setToolTip(
@@ -285,10 +285,10 @@ class ToolIsolation(AppTool, Gerber):
"from the Tool DataBase.") "from the Tool DataBase.")
) )
hlay.addWidget(self.addtool_btn) bhlay.addWidget(self.addtool_btn)
hlay.addWidget(self.addtool_from_db_btn) bhlay.addWidget(self.addtool_from_db_btn)
self.grid3.addLayout(hlay, 7, 0, 1, 2) self.grid3.addLayout(bhlay, 7, 0, 1, 2)
separator_line = QtWidgets.QFrame() separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.HLine) separator_line.setFrameShape(QtWidgets.QFrame.HLine)

View File

@@ -17,6 +17,8 @@ CHANGELOG for FlatCAM beta
- Fixed a recent change that made the edited Geometry objects in the Geometry Editor not to be plotted after saving changes - Fixed a recent change that made the edited Geometry objects in the Geometry Editor not to be plotted after saving changes
- modified the Tool Database such that when a tool shape is selected as 'V' any change in the Vdia or Vangle or CutZ parameters will update the tool diameter value - modified the Tool Database such that when a tool shape is selected as 'V' any change in the Vdia or Vangle or CutZ parameters will update the tool diameter value
- In Tool Isolation made sure that the use of ESC key while some processes are active will disconnect the mouse events that may be connected, correctly - In Tool Isolation made sure that the use of ESC key while some processes are active will disconnect the mouse events that may be connected, correctly
- optimized the Gerber UI
- added a Multi-color checkbox for the Geometry UI (will color differently tool geometry when the geometry is multitool)
29.05.2020 29.05.2020

View File

@@ -300,6 +300,7 @@ class FlatCAMDefaults:
# Geometry General # Geometry General
"geometry_plot": True, "geometry_plot": True,
"geometry_multicolored": False,
"geometry_circle_steps": 64, "geometry_circle_steps": 64,
"geometry_cnctooldia": "2.4", "geometry_cnctooldia": "2.4",
"geometry_plot_line": "#FF0000", "geometry_plot_line": "#FF0000",