- added a control in Preferences -> Gerber Tab for Gerber colors storage usage

- made sure that the defaults on first install will set the number of workers to half the number of CPU's on the system but no less than 2
This commit is contained in:
Marius Stanciu 2020-07-21 00:04:18 +03:00
parent ebdb2b3ca0
commit a3e1570747
7 changed files with 56 additions and 26 deletions

View File

@ -11,6 +11,8 @@ CHANGELOG for FlatCAM beta
- fixed a bug in the FlatCAMGerber.on_mark_cb_click_table() method when moving a Gerber object
- added a way to remember the colors set for the Gerber objects; it will remember the order that they were loaded and set a color previously given
- added a control in Preferences -> Gerber Tab for Gerber colors storage usage
- made sure that the defaults on first install will set the number of workers to half the number of CPU's on the system but no less than 2
18.07.2020

View File

@ -119,6 +119,7 @@ class PreferencesUIManager:
"gerber_plot": self.ui.gerber_defaults_form.gerber_gen_group.plot_cb,
"gerber_solid": self.ui.gerber_defaults_form.gerber_gen_group.solid_cb,
"gerber_multicolored": self.ui.gerber_defaults_form.gerber_gen_group.multicolored_cb,
"gerber_store_color_list": self.ui.gerber_defaults_form.gerber_gen_group.store_colors_cb,
"gerber_circle_steps": self.ui.gerber_defaults_form.gerber_gen_group.circle_steps_entry,
"gerber_def_units": self.ui.gerber_defaults_form.gerber_gen_group.gerber_units_radio,
"gerber_def_zeros": self.ui.gerber_defaults_form.gerber_gen_group.gerber_zeros_radio,

View File

@ -1,7 +1,7 @@
from PyQt5 import QtWidgets, QtCore, QtGui
from PyQt5.QtCore import QSettings
from appGUI.GUIElements import FCCheckBox, FCSpinner, RadioSet, FCEntry, FCSliderWithSpinner, FCColorEntry
from appGUI.GUIElements import FCCheckBox, FCSpinner, RadioSet, FCButton, FCSliderWithSpinner, FCColorEntry
from appGUI.preferences.OptionsGroupUI import OptionsGroupUI
import gettext
@ -140,14 +140,30 @@ class GerberGenPrefGroupUI(OptionsGroupUI):
)
grid0.addWidget(self.gerber_extra_buffering, 8, 0, 1, 3)
# Store colors
self.store_colors_cb = FCCheckBox(label='%s' % _('Store colors'))
self.store_colors_cb.setToolTip(
_("It will store the set colors for Gerber objects.\n"
"Those will be used each time the application is started.")
)
grid0.addWidget(self.store_colors_cb, 11, 0)
# Clear stored colors
self.clear_colors_button = FCButton('%s' % _('Clear Colors'))
self.clear_colors_button.setIcon(QtGui.QIcon(self.app.resource_location + '/trash32.png'))
self.clear_colors_button.setToolTip(
_("Reset the colors associated with Gerber objects.")
)
grid0.addWidget(self.clear_colors_button, 11, 1, 1, 2)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
grid0.addWidget(separator_line, 9, 0, 1, 3)
grid0.addWidget(separator_line, 13, 0, 1, 3)
# Gerber Object Color
self.gerber_color_label = QtWidgets.QLabel('<b>%s</b>' % _('Object Color'))
grid0.addWidget(self.gerber_color_label, 10, 0, 1, 3)
grid0.addWidget(self.gerber_color_label, 15, 0, 1, 3)
# Plot Line Color
self.line_color_label = QtWidgets.QLabel('%s:' % _('Outline'))
@ -156,8 +172,8 @@ class GerberGenPrefGroupUI(OptionsGroupUI):
)
self.line_color_entry = FCColorEntry()
grid0.addWidget(self.line_color_label, 11, 0)
grid0.addWidget(self.line_color_entry, 11, 1, 1, 2)
grid0.addWidget(self.line_color_label, 17, 0)
grid0.addWidget(self.line_color_entry, 17, 1, 1, 2)
# Plot Fill Color
self.fill_color_label = QtWidgets.QLabel('%s:' % _('Fill'))
@ -168,8 +184,8 @@ class GerberGenPrefGroupUI(OptionsGroupUI):
)
self.fill_color_entry = FCColorEntry()
grid0.addWidget(self.fill_color_label, 12, 0)
grid0.addWidget(self.fill_color_entry, 12, 1, 1, 2)
grid0.addWidget(self.fill_color_label, 20, 0)
grid0.addWidget(self.fill_color_entry, 20, 1, 1, 2)
# Plot Fill Transparency Level
self.gerber_alpha_label = QtWidgets.QLabel('%s:' % _('Alpha'))
@ -178,8 +194,8 @@ class GerberGenPrefGroupUI(OptionsGroupUI):
)
self.gerber_alpha_entry = FCSliderWithSpinner(0, 255, 1)
grid0.addWidget(self.gerber_alpha_label, 13, 0)
grid0.addWidget(self.gerber_alpha_entry, 13, 1, 1, 2)
grid0.addWidget(self.gerber_alpha_label, 22, 0)
grid0.addWidget(self.gerber_alpha_entry, 22, 1, 1, 2)
self.layout.addStretch()
@ -189,6 +205,8 @@ class GerberGenPrefGroupUI(OptionsGroupUI):
self.gerber_alpha_entry.valueChanged.connect(self.on_gerber_alpha_changed) # alpha
self.clear_colors_button.clicked.connect(self.on_colors_clear_clicked)
# Setting plot colors handlers
def on_fill_color_changed(self):
self.app.defaults['gerber_plot_fill'] = self.fill_color_entry.get_value()[:7] + \
@ -205,3 +223,7 @@ class GerberGenPrefGroupUI(OptionsGroupUI):
def on_line_color_changed(self):
self.app.defaults['gerber_plot_line'] = self.line_color_entry.get_value()[:7] + \
self.app.defaults['gerber_plot_line'][7:9]
def on_colors_clear_clicked(self):
self.app.defaults['gerber_color_list'].clear()
self.app.inform.emit('[WARNING_NOTCL] %s' % _("Stored colors for Gerber objects are deleted."))

View File

@ -203,23 +203,27 @@ class AppObject(QtCore.QObject):
obj.outline_color = self.app.defaults["excellon_plot_line"]
if kind == 'gerber':
group = self.app.collection.group_items["gerber"]
index = group.child_count()
if self.app.defaults["gerber_store_color_list"] is True:
group = self.app.collection.group_items["gerber"]
index = group.child_count()
# when loading a Gerber object always create a color tuple (line color, fill_color)
# and add it to the self.app.defaults["gerber_color_list"] from where it will be picked and used
try:
colors = self.app.defaults["gerber_color_list"][index]
except IndexError:
# when loading a Gerber object always create a color tuple (line color, fill_color)
# and add it to the self.app.defaults["gerber_color_list"] from where it will be picked and used
try:
colors = self.app.defaults["gerber_color_list"][index]
except IndexError:
obj.outline_color = self.app.defaults["gerber_plot_line"]
obj.fill_color = self.app.defaults["gerber_plot_fill"]
self.app.defaults["gerber_color_list"].insert(index, (obj.outline_color, obj.fill_color))
colors = self.app.defaults["gerber_color_list"][index]
new_line_color = colors[0]
new_fill = colors[1]
obj.outline_color = new_line_color
obj.fill_color = new_fill
else:
obj.outline_color = self.app.defaults["gerber_plot_line"]
obj.fill_color = self.app.defaults["gerber_plot_fill"]
self.app.defaults["gerber_color_list"].insert(index, (obj.outline_color, obj.fill_color))
colors = self.app.defaults["gerber_color_list"][index]
new_line_color = colors[0]
new_color = colors[1]
obj.outline_color = new_line_color
obj.fill_color = new_color
except Exception as e:
log.warning("AppObject.new_object() -> setting colors error. %s" % str(e))

View File

@ -10131,7 +10131,7 @@ class App(QtCore.QObject):
group = self.collection.group_items["gerber"]
group_index = self.collection.index(group.row(), 0, QtCore.QModelIndex())
new_c = (new_color, new_line_color)
new_c = (new_line_color, new_color)
for sel_obj in sel_obj_list:
if sel_obj.kind == 'gerber':

View File

@ -5211,7 +5211,7 @@ class CNCjob(Geometry):
# Only if there are locations to mill
if not optimized_path:
log.debug("camlib.CNCJob.geometry_from_excellon_by_tool() -> Optimized path is empty.")
log.debug("camlib.CNCJob.geometry_tool_gcode_gen() -> Optimized path is empty.")
return 'fail'
if self.app.abort_flag:

View File

@ -94,7 +94,7 @@ class FlatCAMDefaults:
"global_project_at_startup": False,
"global_version_check": True,
"global_send_stats": True,
"global_worker_number": 2,
"global_worker_number": int((os.cpu_count()) / 2) if os.cpu_count() > 4 else 2,
"global_tolerance": 0.005,
"global_save_compressed": True,
@ -157,6 +157,7 @@ class FlatCAMDefaults:
"gerber_solid": True,
"gerber_multicolored": False,
"gerber_color_list": LoudUniqueList(),
"gerber_store_color_list": True,
"gerber_circle_steps": 64,
"gerber_use_buffer_for_union": True,