diff --git a/doc/grid.png b/doc/grid.png index 918a16b..0cda273 100644 Binary files a/doc/grid.png and b/doc/grid.png differ diff --git a/icons/icons.svg b/icons/icons.svg index 270c31e..d3bf5a6 100644 --- a/icons/icons.svg +++ b/icons/icons.svg @@ -184,9 +184,9 @@ showgrid="true" inkscape:document-units="px" inkscape:current-layer="layer1" - inkscape:cy="459.04494" - inkscape:cx="112.68908" - inkscape:zoom="2" + inkscape:cy="110.83427" + inkscape:cx="275.89976" + inkscape:zoom="16" inkscape:pageshadow="2" inkscape:pageopacity="0.0" borderopacity="1.0" diff --git a/roentgen/constructor.py b/roentgen/constructor.py index 358a2ea..2dd0ced 100644 --- a/roentgen/constructor.py +++ b/roentgen/constructor.py @@ -368,7 +368,7 @@ class Constructor: icon_set, priority = self.scheme.get_icon( self.icon_extractor, line.tags, for_="line" ) - labels = self.scheme.construct_text(line.tags, True) + labels = self.scheme.construct_text(line.tags, "all") self.nodes.append(Point( icon_set, labels, line.tags, center_point, @@ -388,7 +388,7 @@ class Constructor: icon_set, priority = self.scheme.get_icon( self.icon_extractor, line.tags ) - labels = self.scheme.construct_text(line.tags, True) + labels = self.scheme.construct_text(line.tags, "all") self.nodes.append(Point( icon_set, labels, line.tags, center_point, center_coordinates, diff --git a/roentgen/scheme.py b/roentgen/scheme.py index dbf8e55..cfa9604 100644 --- a/roentgen/scheme.py +++ b/roentgen/scheme.py @@ -10,8 +10,10 @@ from typing import Any, Dict, List, Optional, Set, Tuple, Union import yaml from colour import Color -from roentgen.icon import (DEFAULT_COLOR, DEFAULT_SHAPE_ID, Icon, IconSet, - ShapeExtractor, ShapeSpecification) +from roentgen.icon import ( + DEFAULT_COLOR, DEFAULT_SHAPE_ID, Icon, IconSet, ShapeExtractor, + ShapeSpecification +) from roentgen.text import Label, get_address, get_text @@ -296,7 +298,9 @@ class Scheme: return line_styles - def construct_text(self, tags, draw_captions) -> List[Label]: + def construct_text( + self, tags: Dict[str, str], draw_captions: str + ) -> List[Label]: """ Construct labels for not processed tags. """ @@ -343,9 +347,7 @@ class Scheme: if draw_captions == "main": return texts - for text in get_text(tags): # type: str - if text: - texts.append(Label(text)) + texts += get_text(tags) if "route_ref" in tags: texts.append(Label(tags["route_ref"].replace(";", " "))) diff --git a/roentgen/text.py b/roentgen/text.py index f548f17..2533ff4 100644 --- a/roentgen/text.py +++ b/roentgen/text.py @@ -79,11 +79,11 @@ def format_frequency(value: str) -> str: return value -def get_text(tags: Dict[str, Any]) -> List[str]: +def get_text(tags: Dict[str, Any]) -> List[Label]: """ Get text representation of writable tags. """ - texts: List[str] = [] + texts: List[Label] = [] values: List[str] = [] if "voltage:primary" in tags: @@ -92,11 +92,12 @@ def get_text(tags: Dict[str, Any]) -> List[str]: values.append(tags["voltage:secondary"]) if "voltage" in tags: values = tags["voltage"].split(";") - texts.append(", ".join(map(format_voltage, values))) + if values: + texts.append(Label(", ".join(map(format_voltage, values)))) if "frequency" in tags: - texts.append(", ".join(map( + texts.append(Label(", ".join(map( format_frequency, tags["frequency"].split(";") - ))) + )))) return texts