- some fixes in the Legacy(2D) graphic mode regarding the possibility of changing the color of the Gerber objects
- added a method to darken the outline color for Gerber objects when they have the color set - when Printing as PDF Gerber objects now the rendered color is the print color
This commit is contained in:
parent
5b62b3c5f6
commit
98d5986190
@ -56,7 +56,7 @@ from flatcamGUI.PlotCanvas import *
|
|||||||
from flatcamGUI.PlotCanvasLegacy import *
|
from flatcamGUI.PlotCanvasLegacy import *
|
||||||
from flatcamGUI.FlatCAMGUI import *
|
from flatcamGUI.FlatCAMGUI import *
|
||||||
|
|
||||||
from FlatCAMCommon import LoudDict, BookmarkManager, ToolsDB
|
from FlatCAMCommon import LoudDict, BookmarkManager, ToolsDB, color_variant
|
||||||
from FlatCAMPostProc import load_preprocessors
|
from FlatCAMPostProc import load_preprocessors
|
||||||
|
|
||||||
from flatcamEditors.FlatCAMGeoEditor import FlatCAMGeoEditor
|
from flatcamEditors.FlatCAMGeoEditor import FlatCAMGeoEditor
|
||||||
@ -10452,7 +10452,8 @@ class App(QtCore.QObject):
|
|||||||
mirror=None)
|
mirror=None)
|
||||||
|
|
||||||
if obj.kind.lower() == 'gerber':
|
if obj.kind.lower() == 'gerber':
|
||||||
color = self.defaults["global_plot_fill"][:-2]
|
# color = self.defaults["global_plot_fill"][:-2]
|
||||||
|
color = obj.fill_color[:-2]
|
||||||
elif obj.kind.lower() == 'excellon':
|
elif obj.kind.lower() == 'excellon':
|
||||||
color = '#C40000'
|
color = '#C40000'
|
||||||
elif obj.kind.lower() == 'geometry':
|
elif obj.kind.lower() == 'geometry':
|
||||||
@ -12378,7 +12379,7 @@ class App(QtCore.QObject):
|
|||||||
if act_name == 'green':
|
if act_name == 'green':
|
||||||
new_color = '#00FF00' + \
|
new_color = '#00FF00' + \
|
||||||
str(hex(self.ui.general_defaults_form.general_gui_group.pf_color_alpha_slider.value())[2:])
|
str(hex(self.ui.general_defaults_form.general_gui_group.pf_color_alpha_slider.value())[2:])
|
||||||
if act_name == 'violet':
|
if act_name == 'purple':
|
||||||
new_color = '#FF00FF' + \
|
new_color = '#FF00FF' + \
|
||||||
str(hex(self.ui.general_defaults_form.general_gui_group.pf_color_alpha_slider.value())[2:])
|
str(hex(self.ui.general_defaults_form.general_gui_group.pf_color_alpha_slider.value())[2:])
|
||||||
if act_name == 'brown':
|
if act_name == 'brown':
|
||||||
@ -12397,7 +12398,7 @@ class App(QtCore.QObject):
|
|||||||
str(hex(self.ui.general_defaults_form.general_gui_group.pf_color_alpha_slider.value())[2:])
|
str(hex(self.ui.general_defaults_form.general_gui_group.pf_color_alpha_slider.value())[2:])
|
||||||
|
|
||||||
if self.is_legacy is False:
|
if self.is_legacy is False:
|
||||||
new_line_color = new_color[:-2]
|
new_line_color = color_variant(new_color[:7], 0.7)
|
||||||
sel_obj.fill_color = new_color
|
sel_obj.fill_color = new_color
|
||||||
sel_obj.outline_color = new_line_color
|
sel_obj.outline_color = new_line_color
|
||||||
|
|
||||||
@ -12405,7 +12406,7 @@ class App(QtCore.QObject):
|
|||||||
update_colors=(new_color, new_line_color)
|
update_colors=(new_color, new_line_color)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
new_line_color = new_color
|
new_line_color = color_variant(new_color[:7], 0.7)
|
||||||
|
|
||||||
sel_obj.fill_color = new_color
|
sel_obj.fill_color = new_color
|
||||||
sel_obj.outline_color = new_line_color
|
sel_obj.outline_color = new_line_color
|
||||||
|
@ -1355,3 +1355,33 @@ class ToolsDB(QtWidgets.QWidget):
|
|||||||
|
|
||||||
def closeEvent(self, QCloseEvent):
|
def closeEvent(self, QCloseEvent):
|
||||||
super().closeEvent(QCloseEvent)
|
super().closeEvent(QCloseEvent)
|
||||||
|
|
||||||
|
|
||||||
|
def color_variant(hex_color, bright_factor=1):
|
||||||
|
"""
|
||||||
|
Takes a color in HEX format #FF00FF and produces a lighter or darker variant
|
||||||
|
|
||||||
|
:param hex_color: color to change
|
||||||
|
:param bright_factor: factor to change the color brightness [0 ... 1]
|
||||||
|
:return: modified color
|
||||||
|
"""
|
||||||
|
|
||||||
|
if len(hex_color) != 7:
|
||||||
|
print("Color is %s, but needs to be in #FF00FF format. Returning original color." % hex_color)
|
||||||
|
return hex_color
|
||||||
|
|
||||||
|
if bright_factor > 1.0:
|
||||||
|
bright_factor = 1.0
|
||||||
|
if bright_factor < 0.0:
|
||||||
|
bright_factor = 0.0
|
||||||
|
|
||||||
|
rgb_hex = [hex_color[x:x + 2] for x in [1, 3, 5]]
|
||||||
|
new_rgb = list()
|
||||||
|
for hex_value in rgb_hex:
|
||||||
|
# adjust each color channel and turn it into a INT suitable as argument for hex()
|
||||||
|
mod_color = round(int(hex_value, 16) * bright_factor)
|
||||||
|
# make sure that each color channel has two digits without the 0x prefix
|
||||||
|
mod_color_hex = str(hex(mod_color)[2:]).zfill(2)
|
||||||
|
new_rgb.append(mod_color_hex)
|
||||||
|
|
||||||
|
return "#" + "".join([i for i in new_rgb])
|
||||||
|
@ -9,6 +9,12 @@ CAD program, and create G-Code for Isolation routing.
|
|||||||
|
|
||||||
=================================================
|
=================================================
|
||||||
|
|
||||||
|
23.12.2019
|
||||||
|
|
||||||
|
- some fixes in the Legacy(2D) graphic mode regarding the possibility of changing the color of the Gerber objects
|
||||||
|
- added a method to darken the outline color for Gerber objects when they have the color set
|
||||||
|
- when Printing as PDF Gerber objects now the rendered color is the print color
|
||||||
|
|
||||||
22.12.2019
|
22.12.2019
|
||||||
|
|
||||||
- added a new option for the Gerber objects: on the project context menu now can be chosen a color for the selected Gerber object
|
- added a new option for the Gerber objects: on the project context menu now can be chosen a color for the selected Gerber object
|
||||||
|
@ -656,8 +656,8 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
|
|||||||
self.menuproject_green = self.menuprojectcolor.addAction(
|
self.menuproject_green = self.menuprojectcolor.addAction(
|
||||||
QtGui.QIcon(self.app.resource_location + '/green32.png'), _('Green'))
|
QtGui.QIcon(self.app.resource_location + '/green32.png'), _('Green'))
|
||||||
|
|
||||||
self.menuproject_violet = self.menuprojectcolor.addAction(
|
self.menuproject_purple = self.menuprojectcolor.addAction(
|
||||||
QtGui.QIcon(self.app.resource_location + '/violet32.png'), _('Violet'))
|
QtGui.QIcon(self.app.resource_location + '/violet32.png'), _('Purple'))
|
||||||
|
|
||||||
self.menuproject_brown = self.menuprojectcolor.addAction(
|
self.menuproject_brown = self.menuprojectcolor.addAction(
|
||||||
QtGui.QIcon(self.app.resource_location + '/brown32.png'), _('Brown'))
|
QtGui.QIcon(self.app.resource_location + '/brown32.png'), _('Brown'))
|
||||||
|
@ -957,9 +957,17 @@ class ShapeCollectionLegacy:
|
|||||||
:param linewidth: the width of the line
|
:param linewidth: the width of the line
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
self._color = color[:-2] if color is not None else None
|
self._color = color if color is not None else "#006E20"
|
||||||
self._face_color = face_color[:-2] if face_color is not None else None
|
self._face_color = face_color if face_color is not None else "#BBF268"
|
||||||
self._alpha = int(face_color[-2:], 16) / 255 if face_color is not None else 0.75
|
|
||||||
|
if len(self._color) > 7:
|
||||||
|
self._color = self._color[:7]
|
||||||
|
|
||||||
|
if len(self._face_color) > 7:
|
||||||
|
self._face_color = self._face_color[:7]
|
||||||
|
# self._alpha = int(self._face_color[-2:], 16) / 255
|
||||||
|
|
||||||
|
self._alpha = 0.75
|
||||||
|
|
||||||
if alpha is not None:
|
if alpha is not None:
|
||||||
self._alpha = alpha
|
self._alpha = alpha
|
||||||
|
Loading…
Reference in New Issue
Block a user