diff --git a/src/Mod/Draft/Resources/Draft.qrc b/src/Mod/Draft/Resources/Draft.qrc
index f914187b7f..e403999a49 100644
--- a/src/Mod/Draft/Resources/Draft.qrc
+++ b/src/Mod/Draft/Resources/Draft.qrc
@@ -105,6 +105,7 @@
icons/Snap_Perpendicular.svgicons/Snap_Special.svgicons/Snap_WorkingPlane.svg
+ icons/Draft_NewLayer.svgpatterns/aluminium.svgpatterns/brick01.svgpatterns/concrete.svg
diff --git a/src/Mod/Draft/Resources/icons/Draft_NewLayer.svg b/src/Mod/Draft/Resources/icons/Draft_NewLayer.svg
new file mode 100644
index 0000000000..eb0fa91ea4
--- /dev/null
+++ b/src/Mod/Draft/Resources/icons/Draft_NewLayer.svg
@@ -0,0 +1,720 @@
+
+
diff --git a/src/Mod/Draft/draftfunctions/svg.py b/src/Mod/Draft/draftfunctions/svg.py
index e8f68fd604..02c13031d5 100644
--- a/src/Mod/Draft/draftfunctions/svg.py
+++ b/src/Mod/Draft/draftfunctions/svg.py
@@ -478,7 +478,12 @@ def get_svg(obj,
else:
stroke = utils.get_rgb(color)
elif App.GuiUp:
- if hasattr(obj, "ViewObject"):
+ # find print color
+ pc = get_print_color(obj)
+ if pc:
+ stroke = utils.get_rgb(pc)
+ # get line color
+ elif hasattr(obj, "ViewObject"):
if hasattr(obj.ViewObject, "LineColor"):
stroke = utils.get_rgb(obj.ViewObject.LineColor)
elif hasattr(obj.ViewObject, "TextColor"):
@@ -918,6 +923,17 @@ def get_svg(obj,
return svg
+def get_print_color(obj):
+ """returns the print color of the parent layer, if available"""
+ for parent in obj.InListRecursive:
+ if (hasattr(parent,"ViewObject")
+ and hasattr(parent.ViewObject,"UsePrintColor")
+ and parent.ViewObject.UsePrintColor):
+ if hasattr(parent.ViewObject,"LinePrintColor"):
+ return parent.ViewObject.LinePrintColor
+ return None
+
+
def getSVG(obj,
scale=1, linewidth=0.35, fontsize=12,
fillstyle="shape color", direction=None,
diff --git a/src/Mod/Draft/draftviewproviders/view_layer.py b/src/Mod/Draft/draftviewproviders/view_layer.py
index 740cb77a83..897380827a 100644
--- a/src/Mod/Draft/draftviewproviders/view_layer.py
+++ b/src/Mod/Draft/draftviewproviders/view_layer.py
@@ -80,6 +80,17 @@ class ViewProviderLayer:
_tip)
vobj.OverrideShapeColorChildren = True
+ if "UsePrintColor" not in properties:
+ _tip = QT_TRANSLATE_NOOP("App::Property",
+ "If it is true, the print color "
+ "will be used when objects in this "
+ "layer are placed on a TechDraw page")
+ vobj.addProperty("App::PropertyBool",
+ "UsePrintColor",
+ "Print",
+ _tip)
+
+
def set_visual_properties(self, vobj, properties):
"""Set visual properties only if they don't already exist."""
view_group = App.ParamGet("User parameter:BaseApp/Preferences/View")
@@ -145,6 +156,16 @@ class ViewProviderLayer:
_tip)
vobj.Transparency = 0
+ if "LinePrintColor" not in properties:
+ _tip = QT_TRANSLATE_NOOP("App::Property",
+ "The line color of the objects "
+ "contained within this layer, "
+ "when used on a TechDraw page")
+ vobj.addProperty("App::PropertyColor",
+ "LinePrintColor",
+ "Print",
+ _tip)
+
def getIcon(self):
"""Return the path to the icon used by the viewprovider.
@@ -382,6 +403,11 @@ class ViewProviderLayerContainer:
menu)
action1.triggered.connect(self.merge_by_name)
menu.addAction(action1)
+ action2 = QtGui.QAction(QtGui.QIcon(":/icons/Draft_NewLayer.svg"),
+ translate("Draft", "Add new layer"),
+ menu)
+ action2.triggered.connect(self.add_layer)
+ menu.addAction(action2)
def merge_by_name(self):
"""Merge the layers that have the same name."""
@@ -442,6 +468,12 @@ class ViewProviderLayerContainer:
_msg("InList not empty. "
"Unable to delete layer: " + layer.Label)
+ def add_layer(self):
+ """Creates a new layer"""
+ import Draft
+ Draft.make_layer()
+ App.ActiveDocument.recompute()
+
def __getstate__(self):
"""Return a tuple of objects to save or None."""
return None