diff --git a/src/Mod/Draft/draftfunctions/svg.py b/src/Mod/Draft/draftfunctions/svg.py index bf45cb2756..145cd082ca 100644 --- a/src/Mod/Draft/draftfunctions/svg.py +++ b/src/Mod/Draft/draftfunctions/svg.py @@ -21,7 +21,13 @@ # * USA * # * * # *************************************************************************** -"""Provides functions to return the SVG representation of various shapes.""" +"""Provides functions to return the SVG representation of various shapes. + +Warning: this still uses the `Drawing.projectToSVG` method to provide +the SVG representation of certain objects. +Therefore, even if the Drawing Workbench is obsolete, the `Drawing` module +may not be removed completely yet. This must be checked. +""" ## @package svg # \ingroup draftfuctions # \brief Provides functions to return the SVG representation of shapes. @@ -69,6 +75,8 @@ def get_line_style(line_style, scale): style = ",".join([str(float(d)/scale) for d in style]) # print("lstyle ", style) except: + # TODO: trap only specific exception; what is the problem? + # Bad string specification? return "none" else: return style @@ -85,6 +93,11 @@ def getLineStyle(linestyle, scale): def get_proj(vec, plane=None): """Get a projection of the vector in the plane's u and v directions. + TODO: check if the same function for SVG and DXF projection can be used + so that this function is not just duplicated code. + This function may also be present elsewhere, like `WorkingPlane` + or `DraftGeomUtils`, so we should avoid code duplication. + Parameters ---------- vec: Base::Vector3 @@ -251,7 +264,7 @@ def get_arrow(obj, _rotate = 'rotate({},{},{})'.format(math.degrees(angle), point.x, point.y) _transl = 'translate({},{})'.format(point.x, point.y) - _scale = 'scale({},{})'.format(arrowsize, arrowsize) + _scale = 'scale({size},{size})'.format(size=arrowsize) _style = 'style="stroke-miterlimit:4;stroke-dasharray:none"' if obj.ViewObject.ArrowType == "Circle": @@ -443,6 +456,9 @@ def get_text(plane, techdraw, _t = text[0].replace("&", "&").replace("<", "<") svg += _t.replace(">", ">") except: + # TODO: trap only specific exception; what is the problem? + # Bad UTF8 string specification? This can be removed + # once the code is only used with Python 3. _t = text[0].decode("utf8") _t = _t.replace("&", "&").replace("<", "<") svg += _t.replace(">", ">") @@ -457,6 +473,9 @@ def get_text(plane, techdraw, _t = text[i].replace("&", "&").replace("<", "<") svg += _t.replace(">", ">") except: + # TODO: trap only specific exception; what is the problem? + # Bad UTF8 string specification? This can be removed + # once the code is only used with Python 3. _t = text[i].decode("utf8") _t = _t.replace("&", "&").replace("<", "<") svg += _t.replace(">", ">") @@ -487,7 +506,11 @@ def get_path(obj, plane, fill, pathdata, stroke, linewidth, lstyle, fill_opacity=None, edges=[], wires=[], pathname=None): - """Get the SVG representation from an object's edges or wires.""" + """Get the SVG representation from an object's edges or wires. + + TODO: the `edges` and `wires` must not default to empty list `[]` + but to `None`. Verify that the code doesn't break with this change. + """ svg = "