diff --git a/AppGUI/ObjectUI.py b/AppGUI/ObjectUI.py
index 085fe23c..aaa56675 100644
--- a/AppGUI/ObjectUI.py
+++ b/AppGUI/ObjectUI.py
@@ -219,7 +219,7 @@ class GerberObjectUI(ObjectUI):
self.name_hlay.addWidget(self.name_entry)
# Plot CB
- self.plot_lbl = FCLabel('%s' % _("Plot"))
+ self.plot_lbl = FCLabel('%s:' % _("Plot"))
self.plot_lbl.setToolTip(_("Plot (show) this object."))
self.plot_cb = FCCheckBox()
@@ -227,18 +227,12 @@ class GerberObjectUI(ObjectUI):
grid0.addWidget(self.plot_cb, 2, 1)
# generate follow
- self.follow_lbl = FCLabel('%s:' % _("Follow"))
- self.follow_lbl.setToolTip(_("Generate a 'Follow' geometry.\n"
- "This means that it will cut through\n"
- "the middle of the trace."))
- self.follow_lbl.setMinimumWidth(90)
- self.follow_cb = FCCheckBox()
-
- 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()
+ self.follow_cb = FCCheckBox('%s' % _("Follow"))
+ self.follow_cb.setToolTip(_("Generate a 'Follow' geometry.\n"
+ "This means that it will cut through\n"
+ "the middle of the trace."))
+ self.follow_cb.setMinimumWidth(55)
+ grid0.addWidget(self.follow_cb, 2, 2)
hlay_plot = QtWidgets.QHBoxLayout()
self.custom_box.addLayout(hlay_plot)
@@ -328,14 +322,7 @@ class GerberObjectUI(ObjectUI):
self.tool_lbl = QtWidgets.QLabel('%s' % _("TOOLS"))
grid2.addWidget(self.tool_lbl, 0, 0, 1, 2)
- # ## Isolation Routing
- 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)
-
+ # Isolation Tool - will create isolation paths around the copper features
self.iso_button = QtWidgets.QPushButton(_('Isolation Routing'))
self.iso_button.setToolTip(
_("Create a Geometry object with\n"
@@ -347,17 +334,9 @@ class GerberObjectUI(ObjectUI):
font-weight: bold;
}
""")
- grid2.addWidget(self.iso_label, 1, 0)
- grid2.addWidget(self.iso_button, 1, 1)
+ grid2.addWidget(self.iso_button, 1, 0, 1, 2)
# ## 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.setToolTip(
_("Create the Geometry Object\n"
@@ -369,17 +348,9 @@ class GerberObjectUI(ObjectUI):
font-weight: bold;
}
""")
- grid2.addWidget(self.clearcopper_label, 2, 0)
- grid2.addWidget(self.generate_ncc_button, 2, 1)
+ grid2.addWidget(self.generate_ncc_button, 2, 0, 1, 2)
# ## 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.setToolTip(
_("Generate the geometry for\n"
@@ -391,8 +362,7 @@ class GerberObjectUI(ObjectUI):
font-weight: bold;
}
""")
- grid2.addWidget(self.board_cutout_label, 3, 0)
- grid2.addWidget(self.generate_cutout_button, 3, 1)
+ grid2.addWidget(self.generate_cutout_button, 3, 0, 1, 2)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
@@ -1312,12 +1282,28 @@ class GeometryObjectUI(ObjectUI):
)
# 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("%s:" % _("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
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("%s:" % _("Name"))
self.name_entry = FCEntry()
@@ -1481,19 +1467,24 @@ class GeometryObjectUI(ObjectUI):
grid1.addWidget(self.addtool_entry_lbl, 3, 0)
grid1.addWidget(self.addtool_entry, 3, 1)
+ bhlay = QtWidgets.QHBoxLayout()
+
self.addtool_btn = QtWidgets.QPushButton(_('Add'))
self.addtool_btn.setToolTip(
_("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.setToolTip(
_("Add a new tool to the Tool Table\n"
"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.setFrameShape(QtWidgets.QFrame.HLine)
diff --git a/AppGUI/preferences/PreferencesUIManager.py b/AppGUI/preferences/PreferencesUIManager.py
index 76cf63de..f848f5f0 100644
--- a/AppGUI/preferences/PreferencesUIManager.py
+++ b/AppGUI/preferences/PreferencesUIManager.py
@@ -259,6 +259,7 @@ class PreferencesUIManager:
# Geometry General
"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_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,
diff --git a/AppGUI/preferences/geometry/GeometryGenPrefGroupUI.py b/AppGUI/preferences/geometry/GeometryGenPrefGroupUI.py
index cf14c7ce..dd4f77ac 100644
--- a/AppGUI/preferences/geometry/GeometryGenPrefGroupUI.py
+++ b/AppGUI/preferences/geometry/GeometryGenPrefGroupUI.py
@@ -31,12 +31,22 @@ class GeometryGenPrefGroupUI(OptionsGroupUI):
self.plot_options_label = QtWidgets.QLabel("%s:" % _("Plot Options"))
self.layout.addWidget(self.plot_options_label)
+ plot_hlay = QtWidgets.QHBoxLayout()
+ self.layout.addLayout((plot_hlay))
+
# Plot CB
self.plot_cb = FCCheckBox(label=_('Plot'))
self.plot_cb.setToolTip(
_("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()
self.layout.addLayout(grid0)
diff --git a/AppGUI/preferences/gerber/GerberGenPrefGroupUI.py b/AppGUI/preferences/gerber/GerberGenPrefGroupUI.py
index f20fc00e..68cfed57 100644
--- a/AppGUI/preferences/gerber/GerberGenPrefGroupUI.py
+++ b/AppGUI/preferences/gerber/GerberGenPrefGroupUI.py
@@ -34,26 +34,26 @@ class GerberGenPrefGroupUI(OptionsGroupUI):
grid0 = QtWidgets.QGridLayout()
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
self.solid_cb = FCCheckBox(label='%s' % _('Solid'))
self.solid_cb.setToolTip(
_("Solid color polygons.")
)
- grid0.addWidget(self.solid_cb, 0, 0)
+ grid0.addWidget(self.solid_cb, 0, 1)
# Multicolored CB
self.multicolored_cb = FCCheckBox(label='%s' % _('M-Color'))
self.multicolored_cb.setToolTip(
_("Draw polygons in different colors.")
)
- grid0.addWidget(self.multicolored_cb, 0, 1)
-
- # 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)
+ grid0.addWidget(self.multicolored_cb, 0, 2)
# Number of circle steps for circular aperture linear approximation
self.circle_steps_label = QtWidgets.QLabel('%s:' % _("Circle Steps"))
diff --git a/AppObjects/FlatCAMGeometry.py b/AppObjects/FlatCAMGeometry.py
index 16c85c8f..cdb4b9ad 100644
--- a/AppObjects/FlatCAMGeometry.py
+++ b/AppObjects/FlatCAMGeometry.py
@@ -52,6 +52,7 @@ class GeometryObject(FlatCAMObj, Geometry):
self.options.update({
"plot": True,
+ "multicolored": False,
"cutz": -0.002,
"vtipdia": 0.1,
"vtipangle": 30,
@@ -396,6 +397,7 @@ class GeometryObject(FlatCAMObj, Geometry):
self.form_fields.update({
"plot": self.ui.plot_cb,
+ "multicolored": self.ui.multicolored_cb,
"cutz": self.ui.cutz_entry,
"vtipdia": self.ui.tipdia_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.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.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))
@@ -2665,6 +2669,27 @@ class GeometryObject(FlatCAMObj, Geometry):
if not FlatCAMObj.plot(self):
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:
# plot solid geometries found as members of self.tools attribute dict
# for MultiGeo
@@ -2672,7 +2697,8 @@ class GeometryObject(FlatCAMObj, Geometry):
for tooluid_key in self.tools:
solid_geometry = self.tools[tooluid_key]['solid_geometry']
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:
# plot solid geometry that may be an direct attribute of the geometry object
# for SingleGeo
@@ -2740,6 +2766,12 @@ class GeometryObject(FlatCAMObj, Geometry):
self.ui.plot_cb.setChecked(True)
self.ui_connect()
+ def on_multicolored_cb_click(self, *args):
+ if self.muted_ui:
+ return
+ self.read_form_item('multicolored')
+ self.plot()
+
@staticmethod
def merge(geo_list, geo_final, multigeo=None):
"""
diff --git a/AppTools/ToolIsolation.py b/AppTools/ToolIsolation.py
index d0375faf..de7f8593 100644
--- a/AppTools/ToolIsolation.py
+++ b/AppTools/ToolIsolation.py
@@ -271,7 +271,7 @@ class ToolIsolation(AppTool, Gerber):
self.grid3.addWidget(self.addtool_entry_lbl, 6, 0)
self.grid3.addWidget(self.addtool_entry, 6, 1)
- hlay = QtWidgets.QHBoxLayout()
+ bhlay = QtWidgets.QHBoxLayout()
self.addtool_btn = QtWidgets.QPushButton(_('Add'))
self.addtool_btn.setToolTip(
@@ -285,10 +285,10 @@ class ToolIsolation(AppTool, Gerber):
"from the Tool DataBase.")
)
- hlay.addWidget(self.addtool_btn)
- hlay.addWidget(self.addtool_from_db_btn)
+ bhlay.addWidget(self.addtool_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.setFrameShape(QtWidgets.QFrame.HLine)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 649d7089..ceefe67b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
- 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
+- 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
diff --git a/defaults.py b/defaults.py
index 326d9524..c72ad391 100644
--- a/defaults.py
+++ b/defaults.py
@@ -300,6 +300,7 @@ class FlatCAMDefaults:
# Geometry General
"geometry_plot": True,
+ "geometry_multicolored": False,
"geometry_circle_steps": 64,
"geometry_cnctooldia": "2.4",
"geometry_plot_line": "#FF0000",