Просмотр исходного кода

Merged in marius_stanciu/flatcam_beta/Beta (pull request #273)

Beta - improvements
Marius Stanciu 6 лет назад
Родитель
Сommit
15b09c3fc6
5 измененных файлов с 55 добавлено и 10 удалено
  1. 6 5
      FlatCAMApp.py
  2. 30 0
      FlatCAMCommon.py
  3. 6 0
      README.md
  4. 2 2
      flatcamGUI/FlatCAMGUI.py
  5. 11 3
      flatcamGUI/PlotCanvasLegacy.py

+ 6 - 5
FlatCAMApp.py

@@ -56,7 +56,7 @@ from flatcamGUI.PlotCanvas import *
 from flatcamGUI.PlotCanvasLegacy 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 flatcamEditors.FlatCAMGeoEditor import FlatCAMGeoEditor
@@ -10452,7 +10452,8 @@ class App(QtCore.QObject):
                                      mirror=None)
 
             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':
                 color = '#C40000'
             elif obj.kind.lower() == 'geometry':
@@ -12378,7 +12379,7 @@ class App(QtCore.QObject):
         if act_name == 'green':
             new_color = '#00FF00' + \
                         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' + \
                         str(hex(self.ui.general_defaults_form.general_gui_group.pf_color_alpha_slider.value())[2:])
         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:])
 
         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.outline_color = new_line_color
 
@@ -12405,7 +12406,7 @@ class App(QtCore.QObject):
                 update_colors=(new_color, new_line_color)
             )
         else:
-            new_line_color = new_color
+            new_line_color = color_variant(new_color[:7], 0.7)
 
             sel_obj.fill_color = new_color
             sel_obj.outline_color = new_line_color

+ 30 - 0
FlatCAMCommon.py

@@ -1355,3 +1355,33 @@ class ToolsDB(QtWidgets.QWidget):
 
     def closeEvent(self, 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])

+ 6 - 0
README.md

@@ -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
 
 - added a new option for the Gerber objects: on the project context menu now can be chosen a color for the selected Gerber object

+ 2 - 2
flatcamGUI/FlatCAMGUI.py

@@ -656,8 +656,8 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
         self.menuproject_green = self.menuprojectcolor.addAction(
             QtGui.QIcon(self.app.resource_location + '/green32.png'), _('Green'))
 
-        self.menuproject_violet = self.menuprojectcolor.addAction(
-            QtGui.QIcon(self.app.resource_location + '/violet32.png'), _('Violet'))
+        self.menuproject_purple = self.menuprojectcolor.addAction(
+            QtGui.QIcon(self.app.resource_location + '/violet32.png'), _('Purple'))
 
         self.menuproject_brown = self.menuprojectcolor.addAction(
             QtGui.QIcon(self.app.resource_location + '/brown32.png'), _('Brown'))

+ 11 - 3
flatcamGUI/PlotCanvasLegacy.py

@@ -957,9 +957,17 @@ class ShapeCollectionLegacy:
         :param linewidth: the width of the line
         :return:
         """
-        self._color = color[:-2] if color is not None else None
-        self._face_color = face_color[:-2] if face_color is not None else None
-        self._alpha = int(face_color[-2:], 16) / 255 if face_color is not None else 0.75
+        self._color = color if color is not None else "#006E20"
+        self._face_color = face_color if face_color is not None else "#BBF268"
+
+        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:
             self._alpha = alpha