libosmscout  1.1.1
Styles.h
Go to the documentation of this file.
1 #ifndef OSMSCOUT_STYLES_H
2 #define OSMSCOUT_STYLES_H
3 
4 /*
5  This source is part of the libosmscout library
6  Copyright (C) 2009 Tim Teulings
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Lesser General Public
10  License as published by the Free Software Foundation; either
11  version 2.1 of the License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public
19  License along with this library; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22 
23 #include <list>
24 #include <set>
25 #include <vector>
26 
28 
29 #include <osmscout/Pixel.h>
30 #include <osmscout/util/Color.h>
32 
34 
35 namespace osmscout {
36 
40  enum class OffsetRel: int {
41  base,
42  leftOutline,
43  rightOutline,
44  laneDivider,
45 
57 
58  sidecar
59  };
60 
67  {
68  public:
69  enum CapStyle {
72  capSquare
73  };
74 
75  enum Attribute {
88  attrOffsetRel
89  };
90 
91  private:
92  std::string slot;
93  Color lineColor;
94  Color gapColor;
95  bool preferColorFeature;
96  double displayWidth;
97  double width;
98  double displayOffset;
99  double offset;
100  CapStyle joinCap;
101  CapStyle endCap;
102  std::vector<double> dash;
103  int priority;
104  int zIndex;
105  OffsetRel offsetRel;
106 
107  public:
108  LineStyle();
109  LineStyle(const LineStyle& style);
110 
111  void SetColorValue(int attribute, const Color& value) override;
112  void SetDoubleValue(int attribute, double value) override;
113  void SetDoubleArrayValue(int attribute, const std::vector<double>& value) override;
114  void SetIntValue(int attribute, int value) override;
115  void SetBoolValue(int attribute, bool value) override;
116 
117  LineStyle& SetSlot(const std::string& slot);
118 
119  LineStyle& SetLineColor(const Color& color);
120  LineStyle& SetGapColor(const Color& color);
121  LineStyle& SetPreferColorFeature(bool value);
122  LineStyle& SetDisplayWidth(double value);
123  LineStyle& SetWidth(double value);
124  LineStyle& SetDisplayOffset(double value);
125  LineStyle& SetOffset(double value);
126  LineStyle& SetJoinCap(CapStyle joinCap);
127  LineStyle& SetEndCap(CapStyle endCap);
128  LineStyle& SetDashes(const std::vector<double>& dashes);
129  LineStyle& SetPriority(int priority);
130  LineStyle& SetZIndex(int zIndex);
131  LineStyle& SetOffsetRel(OffsetRel offsetRel);
132 
133  bool IsVisible() const
134  {
135  return (displayWidth>0.0 ||
136  width>0.0) &&
137  lineColor.IsVisible();
138  }
139 
140  const std::string& GetSlot() const
141  {
142  return slot;
143  }
144 
145  const Color& GetLineColor() const
146  {
147  return lineColor;
148  }
149 
150  const Color& GetGapColor() const
151  {
152  return gapColor;
153  }
154 
156  {
157  return preferColorFeature;
158  }
159 
160  double GetDisplayWidth() const
161  {
162  return displayWidth;
163  }
164 
165  double GetWidth() const
166  {
167  return width;
168  }
169 
170  double GetDisplayOffset() const
171  {
172  return displayOffset;
173  }
174 
175  double GetOffset() const
176  {
177  return offset;
178  }
179 
181  {
182  return joinCap;
183  }
184 
186  {
187  return endCap;
188  }
189 
190  bool HasDashes() const
191  {
192  return !dash.empty();
193  }
194 
195  const std::vector<double>& GetDash() const
196  {
197  return dash;
198  }
199 
200  int GetPriority() const
201  {
202  return priority;
203  }
204 
205  int GetZIndex() const
206  {
207  return zIndex;
208  }
209 
211  {
212  return offsetRel;
213  }
214 
215  static StyleDescriptorRef GetDescriptor();
216 
217  void CopyAttributes(const LineStyle& other,
218  const std::set<Attribute>& attributes);
219 
220  bool operator==(const LineStyle& other) const;
221  bool operator!=(const LineStyle& other) const;
222  bool operator<(const LineStyle& other) const;
223  };
224 
225  class OSMSCOUT_MAP_API CapStyleEnumAttributeDescriptor CLASS_FINAL : public StyleEnumAttributeDescriptor
226  {
227  public:
228  CapStyleEnumAttributeDescriptor(const std::string& name,
229  int attribute)
231  attribute)
232  {
233  AddEnumValue("butt",LineStyle::capButt);
234  AddEnumValue("round",LineStyle::capRound);
235  AddEnumValue("square",LineStyle::capSquare);
236  }
237  };
238 
239  class OSMSCOUT_MAP_API OffsetRelAttributeDescriptor CLASS_FINAL : public StyleEnumAttributeDescriptor
240  {
241  public:
242  OffsetRelAttributeDescriptor(const std::string& name,
243  int attribute)
245  attribute)
246  {
247  AddEnumValue2("base",OffsetRel::base);
248  AddEnumValue2("leftOutline",OffsetRel::leftOutline);
249  AddEnumValue2("rightOutline",OffsetRel::rightOutline);
250  AddEnumValue2("laneDivider",OffsetRel::laneDivider);
251 
252  AddEnumValue2("laneForwardLeft",OffsetRel::laneForwardLeft);
253  AddEnumValue2("laneForwardThroughLeft",OffsetRel::laneForwardThroughLeft);
254  AddEnumValue2("laneForwardThrough",OffsetRel::laneForwardThrough);
255  AddEnumValue2("laneForwardThroughRight",OffsetRel::laneForwardThroughRight);
256  AddEnumValue2("laneForwardRight",OffsetRel::laneForwardRight);
257  AddEnumValue2("laneBackwardLeft",OffsetRel::laneBackwardLeft);
258  AddEnumValue2("laneBackwardThroughLeft",OffsetRel::laneBackwardThroughLeft);
259  AddEnumValue2("laneBackwardThrough",OffsetRel::laneBackwardThrough);
260  AddEnumValue2("laneBackwardThroughRight",OffsetRel::laneBackwardThroughRight);
261  AddEnumValue2("laneBackwardRight",OffsetRel::laneBackwardRight);
262 
263  AddEnumValue2("sidecar", OffsetRel::sidecar);
264  }
265 
266  void AddEnumValue2(const std::string& name,
267  OffsetRel value)
268  {
269  AddEnumValue(name, static_cast<int>(value));
270  }
271  };
272 
273  using LineStyleRef = std::shared_ptr<LineStyle>;
274 
281  {
282  public:
283  enum Attribute {
286  attrPatternMinMag
287  };
288 
289  private:
290  Color fillColor;
291  std::string pattern;
292  mutable size_t patternId;
293  Magnification patternMinMag;
294 
295  public:
296  FillStyle();
297  FillStyle(const FillStyle& style);
298 
299  void SetStringValue(int attribute, const std::string& value) override;
300  void SetColorValue(int attribute, const Color& value) override;
301  void SetMagnificationValue(int attribute, const Magnification& value) override;
302 
303  FillStyle& SetFillColor(const Color& color);
304  FillStyle& SetPattern(const std::string& pattern);
305  void SetPatternId(size_t id) const;
306  FillStyle& SetPatternMinMag(const Magnification& mag);
307 
308  bool IsVisible() const
309  {
310  return (fillColor.IsVisible() ||
311  !pattern.empty());
312  }
313 
314  const Color& GetFillColor() const
315  {
316  return fillColor;
317  }
318 
319  bool HasPattern() const
320  {
321  return !pattern.empty();
322  }
323 
324  std::string GetPatternName() const
325  {
326  return pattern;
327  }
328 
329  size_t GetPatternId() const
330  {
331  return patternId;
332  }
333 
334  const Magnification& GetPatternMinMag() const
335  {
336  return patternMinMag;
337  }
338 
339  static StyleDescriptorRef GetDescriptor();
340 
341  void CopyAttributes(const FillStyle& other,
342  const std::set<Attribute>& attributes);
343 
344  bool operator==(const FillStyle& other) const;
345  bool operator!=(const FillStyle& other) const;
346  bool operator<(const FillStyle& other) const;
347  };
348 
349  using FillStyleRef = std::shared_ptr<FillStyle>;
350 
357  {
358  public:
359  enum Attribute {
366  attrPriority
367  };
368 
369  private:
370  std::string slot;
371  Color color;
372  Color gapColor;
373  double width;
374  std::vector<double> dash;
375  double displayOffset;
376  double offset;
377  int priority;
378 
379  public:
380  BorderStyle();
381  BorderStyle(const BorderStyle& style);
382 
383  void SetColorValue(int attribute, const Color& value) override;
384  void SetDoubleValue(int attribute, double value) override;
385  void SetDoubleArrayValue(int attribute, const std::vector<double>& value) override;
386  void SetIntValue(int attribute, int value) override;
387 
388  BorderStyle& SetSlot(const std::string& slot);
389 
390  BorderStyle& SetColor(const Color& color);
391  BorderStyle& SetGapColor(const Color& color);
392  BorderStyle& SetWidth(double value);
393  BorderStyle& SetDashes(const std::vector<double>& dashes);
394  BorderStyle& SetDisplayOffset(double value);
395  BorderStyle& SetOffset(double value);
396  BorderStyle& SetPriority(int priority);
397 
398  bool IsVisible() const
399  {
400  return width>0 && color.IsVisible();
401  }
402 
403  const std::string& GetSlot() const
404  {
405  return slot;
406  }
407 
408  const Color& GetColor() const
409  {
410  return color;
411  }
412 
413  const Color& GetGapColor() const
414  {
415  return gapColor;
416  }
417 
418  double GetWidth() const
419  {
420  return width;
421  }
422 
423  bool HasDashes() const
424  {
425  return !dash.empty();
426  }
427 
428  const std::vector<double>& GetDash() const
429  {
430  return dash;
431  }
432 
433  double GetDisplayOffset() const
434  {
435  return displayOffset;
436  }
437 
438  double GetOffset() const
439  {
440  return offset;
441  }
442 
443  int GetPriority() const
444  {
445  return priority;
446  }
447 
448  static StyleDescriptorRef GetDescriptor();
449 
450  void CopyAttributes(const BorderStyle& other,
451  const std::set<Attribute>& attributes);
452 
453  bool operator==(const BorderStyle& other) const;
454  bool operator!=(const BorderStyle& other) const;
455  bool operator<(const BorderStyle& other) const;
456  };
457 
458  using BorderStyleRef = std::shared_ptr<BorderStyle>;
459 
467  {
468  private:
469  size_t priority;
470  double size;
471 
472  public:
473  LabelStyle();
474  LabelStyle(const LabelStyle& style);
475 
476  ~LabelStyle() override = default;
477 
478  virtual bool IsVisible() const = 0;
479  virtual double GetAlpha() const = 0;
480 
481  LabelStyle& SetPriority(size_t priority);
482 
483  virtual LabelStyle& SetSize(double size);
484 
485  size_t GetPriority() const
486  {
487  return priority;
488  }
489 
490  double GetSize() const
491  {
492  return size;
493  }
494  };
495 
496  using LabelStyleRef = std::shared_ptr<LabelStyle>;
497 
504  {
505  public:
506  enum Style {
508  emphasize
509  };
510 
511  enum Attribute {
519  attrAutoSize
520  };
521 
522  private:
523  std::string slot;
524  LabelProviderRef label;
525  size_t position;
526  Color textColor;
527  Style style;
528  Magnification scaleAndFadeMag;
529  bool autoSize;
530 
531  public:
532  TextStyle();
533  TextStyle(const TextStyle& style);
534 
535  void SetBoolValue(int attribute, bool value) override;
536  void SetColorValue(int attribute, const Color& value) override;
537  void SetMagnificationValue(int attribute, const Magnification& value) override;
538  void SetDoubleValue(int attribute, double value) override;
539  void SetIntValue(int attribute, int value) override;
540  void SetUIntValue(int attribute, size_t value) override;
541  void SetLabelValue(int attribute, const LabelProviderRef& value) override;
542 
543  TextStyle& SetSlot(const std::string& slot);
544 
545  TextStyle& SetSize(double size) override;
546  TextStyle& SetLabel(const LabelProviderRef& label);
547  TextStyle& SetPosition(size_t position);
548  TextStyle& SetTextColor(const Color& color);
549  TextStyle& SetStyle(Style style);
550  TextStyle& SetScaleAndFadeMag(const Magnification& mag);
551  TextStyle& SetAutoSize(bool autoSize);
552 
553  bool IsVisible() const override
554  {
555  return label &&
556  GetTextColor().IsVisible();
557  }
558 
559  double GetAlpha() const override
560  {
561  return textColor.GetA();
562  }
563 
564  const std::string& GetSlot() const
565  {
566  return slot;
567  }
568 
569  const LabelProviderRef& GetLabel() const
570  {
571  return label;
572  }
573 
574  size_t GetPosition() const
575  {
576  return position;
577  }
578 
579  const Color& GetTextColor() const
580  {
581  return textColor;
582  }
583 
584  const Style& GetStyle() const
585  {
586  return style;
587  }
588 
589  Magnification GetScaleAndFadeMag() const
590  {
591  return scaleAndFadeMag;
592  }
593 
594  bool GetAutoSize() const
595  {
596  return autoSize;
597  }
598 
599  static StyleDescriptorRef GetDescriptor();
600 
601  void CopyAttributes(const TextStyle& other,
602  const std::set<Attribute>& attributes);
603 
604  bool operator==(const TextStyle& other) const;
605  bool operator!=(const TextStyle& other) const;
606  bool operator<(const TextStyle& other) const;
607  };
608 
609  class OSMSCOUT_MAP_API TextStyleEnumAttributeDescriptor CLASS_FINAL : public StyleEnumAttributeDescriptor
610  {
611  public:
612  TextStyleEnumAttributeDescriptor(const std::string& name,
613  int attribute)
615  attribute)
616  {
617  AddEnumValue("normal",TextStyle::normal);
618  AddEnumValue("emphasize",TextStyle::emphasize);
619  }
620  };
621 
622  using TextStyleRef = std::shared_ptr<TextStyle>;
623 
630  {
631  public:
632  enum Attribute {
638  attrBorderColor
639  };
640 
641  private:
642  LabelProviderRef label;
643  Color textColor;
644  Color bgColor;
645  Color borderColor;
646 
647  public:
648  ShieldStyle();
649  ShieldStyle(const ShieldStyle& style);
650 
651  ShieldStyle& SetLabel(const LabelProviderRef& label);
652  ShieldStyle& SetSize(double size) override;
653  ShieldStyle& SetTextColor(const Color& color);
654  ShieldStyle& SetBgColor(const Color& color);
655  ShieldStyle& SetBorderColor(const Color& color);
656 
657  bool IsVisible() const override
658  {
659  return label &&
660  GetTextColor().IsVisible();
661  }
662 
663  double GetAlpha() const override
664  {
665  return textColor.GetA();
666  }
667 
668  const LabelProviderRef& GetLabel() const
669  {
670  return label;
671  }
672 
673  const Color& GetTextColor() const
674  {
675  return textColor;
676  }
677 
678  const Color& GetBgColor() const
679  {
680  return bgColor;
681  }
682 
683  const Color& GetBorderColor() const
684  {
685  return borderColor;
686  }
687 
688  void CopyAttributes(const ShieldStyle& other,
689  const std::set<Attribute>& attributes);
690  };
691 
692  using ShieldStyleRef = std::shared_ptr<ShieldStyle>;
693 
702  {
703  public:
704  enum Attribute {
711  attrShieldSpace
712  };
713 
714  private:
715  ShieldStyleRef shieldStyle;
716  double shieldSpace;
717 
718  public:
719  PathShieldStyle();
720  PathShieldStyle(const PathShieldStyle& style);
721 
722  void SetLabelValue(int attribute, const LabelProviderRef& value) override;
723  void SetColorValue(int attribute, const Color& value) override;
724  void SetDoubleValue(int attribute, double value) override;
725  void SetUIntValue(int attribute, size_t value) override;
726 
727  PathShieldStyle& SetLabel(const LabelProviderRef& label);
728  PathShieldStyle& SetPriority(size_t priority);
729  PathShieldStyle& SetSize(double size);
730  PathShieldStyle& SetTextColor(const Color& color);
731  PathShieldStyle& SetBgColor(const Color& color);
732  PathShieldStyle& SetBorderColor(const Color& color);
733  PathShieldStyle& SetShieldSpace(double shieldSpace);
734 
735  bool IsVisible() const
736  {
737  return shieldStyle->IsVisible();
738  }
739 
740  double GetAlpha() const
741  {
742  return shieldStyle->GetAlpha();
743  }
744 
745  size_t GetPriority() const
746  {
747  return shieldStyle->GetPriority();
748  }
749 
750  double GetSize() const
751  {
752  return shieldStyle->GetSize();
753  }
754 
755  const LabelProviderRef& GetLabel() const
756  {
757  return shieldStyle->GetLabel();
758  }
759 
760  const Color& GetTextColor() const
761  {
762  return shieldStyle->GetTextColor();
763  }
764 
765  const Color& GetBgColor() const
766  {
767  return shieldStyle->GetBgColor();
768  }
769 
770  const Color& GetBorderColor() const
771  {
772  return shieldStyle->GetBorderColor();
773  }
774 
775  double GetShieldSpace() const
776  {
777  return shieldSpace;
778  }
779 
781  {
782  return shieldStyle;
783  }
784 
785  static StyleDescriptorRef GetDescriptor();
786 
787  void CopyAttributes(const PathShieldStyle& other,
788  const std::set<Attribute>& attributes);
789  };
790 
791  using PathShieldStyleRef = std::shared_ptr<PathShieldStyle>;
792 
800  {
801  public:
802  enum Attribute {
808  attrPriority
809  };
810 
811  private:
812  LabelProviderRef label;
813  double size;
814  Color textColor;
815  double displayOffset;
816  double offset;
817  size_t priority;
818 
819  public:
820  PathTextStyle();
821  PathTextStyle(const PathTextStyle& style);
822 
823  void SetColorValue(int attribute, const Color& value) override;
824  void SetDoubleValue(int attribute, double value) override;
825  void SetLabelValue(int attribute, const LabelProviderRef& value) override;
826  void SetUIntValue(int attribute, size_t value) override;
827 
828  PathTextStyle& SetLabel(const LabelProviderRef& label);
829  PathTextStyle& SetSize(double size);
830  PathTextStyle& SetTextColor(const Color& color);
831  PathTextStyle& SetDisplayOffset(double value);
832  PathTextStyle& SetOffset(double value);
833  PathTextStyle& SetPriority(size_t value);
834 
835  bool IsVisible() const
836  {
837  return label &&
838  textColor.IsVisible();
839  }
840 
841  const LabelProviderRef& GetLabel() const
842  {
843  return label;
844  }
845 
846  double GetSize() const
847  {
848  return size;
849  }
850 
851  const Color& GetTextColor() const
852  {
853  return textColor;
854  }
855 
856  double GetDisplayOffset() const
857  {
858  return displayOffset;
859  }
860 
861  double GetOffset() const
862  {
863  return offset;
864  }
865 
866  size_t GetPriority() const
867  {
868  return priority;
869  }
870 
871  static StyleDescriptorRef GetDescriptor();
872 
873  void CopyAttributes(const PathTextStyle& other,
874  const std::set<Attribute>& attributes);
875  };
876 
877  using PathTextStyleRef = std::shared_ptr<PathTextStyle>;
878 
885  {
886  public:
887  enum Attribute {
892  attrOverlay
893  };
894 
895  private:
896  SymbolRef symbol;
897  std::string iconName;
898  size_t iconId;
899  unsigned int width;
900  unsigned int height;
901  size_t position;
902  size_t priority;
903  bool overlay;
904 
905  public:
906  IconStyle();
907  IconStyle(const IconStyle& style);
908 
909  void SetBoolValue(int attribute, bool value) override;
910  void SetStringValue(int attribute, const std::string& value) override;
911  void SetSymbolValue(int attribute, const SymbolRef& value) override;
912  void SetUIntValue(int attribute, size_t value) override;
913 
914  IconStyle& SetSymbol(const SymbolRef& symbol);
915  IconStyle& SetIconName(const std::string& iconName);
916  IconStyle& SetIconId(size_t id);
917  IconStyle& SetWidth(unsigned int w);
918  IconStyle& SetHeight(unsigned int h);
919  IconStyle& SetPosition(size_t position);
920  IconStyle& SetPriority(size_t priority);
921  IconStyle& SetOverlay(bool overlay);
922 
923  size_t GetPriority() const
924  {
925  return priority;
926  }
927 
928  bool IsVisible() const
929  {
930  return !iconName.empty() ||
931  symbol;
932  }
933 
934  const SymbolRef& GetSymbol() const
935  {
936  return symbol;
937  }
938 
939  std::string GetIconName() const
940  {
941  return iconName;
942  }
943 
944  size_t GetIconId() const
945  {
946  return iconId;
947  }
948 
949  unsigned int GetWidth() const
950  {
951  return width;
952  }
953 
954  unsigned int GetHeight() const
955  {
956  return height;
957  }
958 
959  size_t GetPosition() const
960  {
961  return position;
962  }
963 
964  bool IsOverlay() const
965  {
966  return overlay;
967  }
968 
969  static StyleDescriptorRef GetDescriptor();
970 
971  void CopyAttributes(const IconStyle& other,
972  const std::set<Attribute>& attributes);
973  };
974 
975  using IconStyleRef = std::shared_ptr<IconStyle>;
976 
982  {
983  public:
984  enum class ProjectionMode {
985  MAP,
986  GROUND
987  };
988 
989  private:
990  ProjectionMode projectionMode;
991  FillStyleRef fillStyle;
992  BorderStyleRef borderStyle;
993 
994  public:
995  DrawPrimitive(ProjectionMode projectionMode,
996  const FillStyleRef& fillStyle,
997  const BorderStyleRef& borderStyle);
998  virtual ~DrawPrimitive() = default;
999 
1001  {
1002  return projectionMode;
1003  }
1004 
1006  {
1007  return fillStyle;
1008  }
1009 
1011  {
1012  return borderStyle;
1013  }
1014 
1015  virtual void GetBoundingBox(double& minX,
1016  double& minY,
1017  double& maxX,
1018  double& maxY) const = 0;
1019  };
1020 
1021  using DrawPrimitiveRef = std::shared_ptr<DrawPrimitive>;
1022 
1028  {
1029  private:
1030  std::list<Vertex2D> coords;
1031 
1032  public:
1033  PolygonPrimitive(ProjectionMode projectionMode,
1034  const FillStyleRef& fillStyle,
1035  const BorderStyleRef& borderStyle);
1036 
1037  void AddCoord(const Vertex2D& coord);
1038 
1039  const std::list<Vertex2D>& GetCoords() const
1040  {
1041  return coords;
1042  }
1043 
1044  void GetBoundingBox(double& minX,
1045  double& minY,
1046  double& maxX,
1047  double& maxY) const override;
1048  };
1049 
1050  using PolygonPrimitiveRef = std::shared_ptr<PolygonPrimitive>;
1051 
1057  {
1058  private:
1059  Vertex2D topLeft;
1060  double width;
1061  double height;
1062 
1063  public:
1064  RectanglePrimitive(ProjectionMode projectionMode,
1065  const Vertex2D& topLeft,
1066  double width,
1067  double height,
1068  const FillStyleRef& fillStyle,
1069  const BorderStyleRef& borderStyle);
1070 
1071  const Vertex2D& GetTopLeft() const
1072  {
1073  return topLeft;
1074  }
1075 
1076  const double& GetWidth() const
1077  {
1078  return width;
1079  }
1080 
1081  const double& GetHeight() const
1082  {
1083  return height;
1084  }
1085 
1086  void GetBoundingBox(double& minX,
1087  double& minY,
1088  double& maxX,
1089  double& maxY) const override;
1090  };
1091 
1092  using RectanglePrimitiveRef = std::shared_ptr<RectanglePrimitive>;
1093 
1099  {
1100  private:
1101  Vertex2D center;
1102  double radius;
1103 
1104  public:
1105  CirclePrimitive(ProjectionMode projectionMode,
1106  const Vertex2D& center,
1107  double radius,
1108  const FillStyleRef& fillStyle,
1109  const BorderStyleRef& borderStyle);
1110 
1111  const Vertex2D& GetCenter() const
1112  {
1113  return center;
1114  }
1115 
1116  const double& GetRadius() const
1117  {
1118  return radius;
1119  }
1120 
1121  void GetBoundingBox(double& minX,
1122  double& minY,
1123  double& maxX,
1124  double& maxY) const override;
1125  };
1126 
1127  using CirclePrimitiveRef = std::shared_ptr<CirclePrimitive>;
1128 
1136  {
1137  private:
1138  std::string name;
1139  std::list<DrawPrimitiveRef> primitives;
1140 
1141  struct BoundingBox{
1142  double minX{0};
1143  double minY{0};
1144  double maxX{0};
1145  double maxY{0};
1146 
1147  double GetWidth() const
1148  {
1149  return maxX-minX;
1150  }
1151 
1152  double GetHeight() const
1153  {
1154  return maxY-minY;
1155  }
1156 
1157  void Update(double minX, double minY, double maxX, double maxY)
1158  {
1159  this->minX = std::min(this->minX, minX);
1160  this->minY = std::min(this->minY, minY);
1161 
1162  this->maxX = std::max(this->maxX, maxX);
1163  this->maxY = std::max(this->maxY, maxY);
1164  }
1165  };
1166 
1167  BoundingBox mapBoundingBox;
1168  BoundingBox groundBoundingBox;
1169 
1170  public:
1171  explicit Symbol(const std::string& name);
1172 
1173  void AddPrimitive(const DrawPrimitiveRef& primitive);
1174 
1175  std::string GetName() const
1176  {
1177  return name;
1178  }
1179 
1180  const std::list<DrawPrimitiveRef>& GetPrimitives() const
1181  {
1182  return primitives;
1183  }
1184 
1188  void GetBoundingBox(const Projection &projection,
1189  double& minX,
1190  double& minY,
1191  double& maxX,
1192  double& maxY) const
1193  {
1194  minX=std::min(projection.ConvertWidthToPixel(mapBoundingBox.minX),
1195  projection.GetMeterInPixel() * groundBoundingBox.minX);
1196  minY=std::min(projection.ConvertWidthToPixel(mapBoundingBox.minY),
1197  projection.GetMeterInPixel() * groundBoundingBox.minY);
1198 
1199  maxX=std::max(projection.ConvertWidthToPixel(mapBoundingBox.maxX),
1200  projection.GetMeterInPixel() * groundBoundingBox.maxX);
1201  maxY=std::max(projection.ConvertWidthToPixel(mapBoundingBox.maxY),
1202  projection.GetMeterInPixel() * groundBoundingBox.maxY);
1203  }
1204 
1208  double GetWidth(const Projection &projection) const
1209  {
1210  return std::max(projection.ConvertWidthToPixel(mapBoundingBox.GetWidth()),
1211  projection.GetMeterInPixel() * groundBoundingBox.GetWidth());
1212  }
1213 
1217  double GetHeight(const Projection &projection) const
1218  {
1219  return std::max(projection.ConvertWidthToPixel(mapBoundingBox.GetHeight()),
1220  projection.GetMeterInPixel() * groundBoundingBox.GetHeight());
1221  }
1222 
1223  };
1224 
1231  {
1232  public:
1233 
1234  enum Attribute {
1239  attrOffsetRel
1240  };
1241 
1242  private:
1243  std::string slot;
1244  SymbolRef symbol;
1245  double symbolSpace;
1246  double displayOffset;
1247  double offset;
1248  OffsetRel offsetRel{OffsetRel::base};
1249 
1250  public:
1251  PathSymbolStyle();
1252  PathSymbolStyle(const PathSymbolStyle& style);
1253 
1254  void SetDoubleValue(int attribute, double value) override;
1255  void SetSymbolValue(int attribute, const SymbolRef& value) override;
1256  void SetIntValue(int attribute, int value) override;
1257 
1258  PathSymbolStyle& SetSlot(const std::string& slot);
1259 
1260  PathSymbolStyle& SetSymbol(const SymbolRef& symbol);
1261  PathSymbolStyle& SetSymbolSpace(double space);
1262  PathSymbolStyle& SetDisplayOffset(double value);
1263  PathSymbolStyle& SetOffset(double value);
1264  PathSymbolStyle& SetOffsetRel(OffsetRel offsetRel);
1265 
1266  bool IsVisible() const
1267  {
1268  return (bool)symbol;
1269  }
1270 
1271  const std::string& GetSlot() const
1272  {
1273  return slot;
1274  }
1275 
1276  const SymbolRef& GetSymbol() const
1277  {
1278  return symbol;
1279  }
1280 
1281  double GetSymbolSpace() const
1282  {
1283  return symbolSpace;
1284  }
1285 
1286  double GetDisplayOffset() const
1287  {
1288  return displayOffset;
1289  }
1290 
1291  double GetOffset() const
1292  {
1293  return offset;
1294  }
1295 
1297  {
1298  return offsetRel;
1299  }
1300 
1301  static StyleDescriptorRef GetDescriptor();
1302 
1303  void CopyAttributes(const PathSymbolStyle& other,
1304  const std::set<Attribute>& attributes);
1305  };
1306 
1307  using PathSymbolStyleRef = std::shared_ptr<PathSymbolStyle>;
1308 }
1309 
1310 #endif
const Color & GetTextColor() const
Definition: Styles.h:760
Attribute
Definition: Styles.h:359
double ConvertWidthToPixel(double width) const
Definition: Projection.h:280
Definition: Styles.h:1230
const std::string & GetSlot() const
Definition: Styles.h:140
TextStyleEnumAttributeDescriptor(const std::string &name, int attribute)
Definition: Styles.h:612
Attribute
Definition: Styles.h:75
const FillStyleRef & GetFillStyle() const
Definition: Styles.h:1005
Definition: Styles.h:707
Definition: Styles.h:83
std::string GetIconName() const
Definition: Styles.h:939
double GetWidth() const
Definition: Styles.h:418
const Color & GetGapColor() const
Definition: Styles.h:413
const std::vector< double > & GetDash() const
Definition: Styles.h:195
special offset for routes, line are stacked next to way, same colors are "collapsed" ...
Definition: Styles.h:635
Attribute
Definition: Styles.h:1234
std::shared_ptr< FillStyle > FillStyleRef
Definition: Styles.h:349
Definition: Styles.h:884
Definition: StyleDescription.h:229
size_t GetPriority() const
Definition: Styles.h:866
Attribute
Definition: Styles.h:887
const SymbolRef & GetSymbol() const
Definition: Styles.h:934
Definition: Styles.h:636
std::shared_ptr< PathSymbolStyle > PathSymbolStyleRef
Definition: Styles.h:1307
double GetAlpha() const override
Definition: Styles.h:663
const LabelProviderRef & GetLabel() const
Definition: Styles.h:841
OffsetRelAttributeDescriptor(const std::string &name, int attribute)
Definition: Styles.h:242
unsigned int GetHeight() const
Definition: Styles.h:954
const ShieldStyleRef & GetShieldStyle() const
Definition: Styles.h:780
Definition: Styles.h:87
Definition: Styles.h:891
std::string GetName() const
Definition: Styles.h:1175
std::shared_ptr< LineStyle > LineStyleRef
Definition: Styles.h:273
Definition: Styles.h:85
ProjectionMode GetProjectionMode() const
Definition: Styles.h:1000
right side of the way
const std::list< Vertex2D > & GetCoords() const
Definition: Styles.h:1039
bool IsVisible() const override
Definition: Styles.h:553
const Color & GetGapColor() const
Definition: Styles.h:150
bool IsVisible() const
Definition: Styles.h:735
const LabelProviderRef & GetLabel() const
Definition: Styles.h:569
double GetOffset() const
Definition: Styles.h:175
Definition: Styles.h:360
Definition: Styles.h:86
size_t GetPriority() const
Definition: Styles.h:745
bool HasDashes() const
Definition: Styles.h:423
bool IsVisible() const
Definition: Styles.h:1266
const Color & GetTextColor() const
Definition: Styles.h:673
double GetSymbolSpace() const
Definition: Styles.h:1281
bool IsVisible() const override
Definition: Styles.h:657
Definition: Styles.h:285
Definition: Styles.h:365
double GetAlpha() const override
Definition: Styles.h:559
std::shared_ptr< BorderStyle > BorderStyleRef
Definition: Styles.h:458
Definition: Styles.h:76
Definition: Styles.h:803
Definition: Styles.h:629
const Color & GetBorderColor() const
Definition: Styles.h:683
bool operator!=(const MapViewStruct &r1, const MapViewStruct &r2)
Definition: DBThread.h:61
bool IsVisible() const
Definition: Styles.h:308
Attribute
Definition: Styles.h:632
double GetOffset() const
Definition: Styles.h:438
Definition: Styles.h:84
Definition: Styles.h:362
void GetBoundingBox(const std::vector< N > &nodes, double &minLon, double &maxLon, double &minLat, double &maxLat)
Definition: Geometry.h:107
double GetOffset() const
Definition: Styles.h:861
double GetDisplayOffset() const
Definition: Styles.h:856
Definition: Styles.h:508
const Vertex2D & GetCenter() const
Definition: Styles.h:1111
std::shared_ptr< RectanglePrimitive > RectanglePrimitiveRef
Definition: Styles.h:1092
Magnification GetScaleAndFadeMag() const
Definition: Styles.h:589
std::shared_ptr< LabelProvider > LabelProviderRef
Definition: LabelProvider.h:61
Definition: Styles.h:514
bool IsVisible() const
Definition: Styles.h:398
when way has multiple lanes, line is rendered as its divider
Definition: Styles.h:807
CapStyle GetJoinCap() const
Definition: Styles.h:180
size_t GetPriority() const
Definition: Styles.h:923
int GetPriority() const
Definition: Styles.h:200
double GetOffset() const
Definition: Styles.h:1291
const Color & GetBgColor() const
Definition: Styles.h:765
std::string GetPatternName() const
Definition: Styles.h:324
const std::vector< double > & GetDash() const
Definition: Styles.h:428
bool IsVisible() const
Definition: Styles.h:835
double GetMeterInPixel() const
Definition: Projection.h:259
Definition: Projection.h:43
double GetSize() const
Definition: Styles.h:846
Attribute
Definition: Styles.h:802
std::shared_ptr< PathTextStyle > PathTextStyleRef
Definition: Styles.h:877
Definition: Area.h:38
double GetWidth() const
Definition: Styles.h:165
Definition: Styles.h:701
const LabelProviderRef & GetLabel() const
Definition: Styles.h:668
Definition: Styles.h:284
Attribute
Definition: Styles.h:283
Definition: Styles.h:1135
bool IsVisible() const
Definition: Styles.h:133
std::shared_ptr< PolygonPrimitive > PolygonPrimitiveRef
Definition: Styles.h:1050
CapStyle GetEndCap() const
Definition: Styles.h:185
Definition: Styles.h:1056
int GetPriority() const
Definition: Styles.h:443
Definition: Styles.h:1098
Definition: Styles.h:517
#define CLASS_FINAL
Definition: Compiler.h:26
std::shared_ptr< PathShieldStyle > PathShieldStyleRef
Definition: Styles.h:791
bool HasDashes() const
Definition: Styles.h:190
bool operator<(const TileCacheKey &a, const TileCacheKey &b)
Definition: Styles.h:71
Definition: Styles.h:634
int GetZIndex() const
Definition: Styles.h:205
double GetSize() const
Definition: Styles.h:750
Definition: Styles.h:356
#define OSMSCOUT_MAP_API
Definition: MapImportExport.h:45
void GetBoundingBox(const Projection &projection, double &minX, double &minY, double &maxX, double &maxY) const
Definition: Styles.h:1188
double GetWidth(const Projection &projection) const
Definition: Styles.h:1208
Definition: Styles.h:981
const std::string & GetSlot() const
Definition: Styles.h:1271
double GetDisplayOffset() const
Definition: Styles.h:1286
Definition: Styles.h:515
const Color & GetTextColor() const
Definition: Styles.h:851
const Color & GetBgColor() const
Definition: Styles.h:678
bool GetPreferColorFeature() const
Definition: Styles.h:155
OffsetRel
Definition: Styles.h:40
const std::list< DrawPrimitiveRef > & GetPrimitives() const
Definition: Styles.h:1180
const Magnification & GetPatternMinMag() const
Definition: Styles.h:334
size_t GetIconId() const
Definition: Styles.h:944
Definition: Styles.h:799
double GetSize() const
Definition: Styles.h:490
size_t GetPatternId() const
Definition: Styles.h:329
Definition: Styles.h:507
size_t GetPosition() const
Definition: Styles.h:959
const Color & GetBorderColor() const
Definition: Styles.h:770
bool IsOverlay() const
Definition: Styles.h:964
const Color & GetColor() const
Definition: Styles.h:408
Definition: Styles.h:513
double GetAlpha() const
Definition: Styles.h:740
const Vertex2D & GetTopLeft() const
Definition: Styles.h:1071
Definition: StyleDescription.h:51
bool operator==(const MapView &a, const MapView &b)
Definition: InputHandler.h:222
double GetShieldSpace() const
Definition: Styles.h:775
const std::string & GetSlot() const
Definition: Styles.h:564
Definition: Styles.h:804
const SymbolRef & GetSymbol() const
Definition: Styles.h:1276
Definition: Styles.h:77
Style
Definition: Styles.h:506
Definition: Styles.h:280
Definition: Styles.h:706
const Color & GetTextColor() const
Definition: Styles.h:579
double GetDisplayOffset() const
Definition: Styles.h:170
const Color & GetLineColor() const
Definition: Styles.h:145
Definition: Styles.h:363
std::shared_ptr< Symbol > SymbolRef
Definition: StyleDescription.h:37
Definition: Styles.h:361
const Color & GetFillColor() const
Definition: Styles.h:314
const BorderStyleRef & GetBorderStyle() const
Definition: Styles.h:1010
size_t GetPriority() const
Definition: Styles.h:485
double GetDisplayWidth() const
Definition: Styles.h:160
const LabelProviderRef & GetLabel() const
Definition: Styles.h:755
unsigned int GetWidth() const
Definition: Styles.h:949
Attribute
Definition: Styles.h:704
Definition: Styles.h:72
const Style & GetStyle() const
Definition: Styles.h:584
ProjectionMode
Definition: Styles.h:984
std::shared_ptr< StyleDescriptor > StyleDescriptorRef
Definition: StyleDescription.h:495
const double & GetRadius() const
Definition: Styles.h:1116
Definition: Styles.h:503
std::shared_ptr< LabelStyle > LabelStyleRef
Definition: Styles.h:496
Definition: Styles.h:890
const std::string & GetSlot() const
Definition: Styles.h:403
Definition: Styles.h:1027
double GetHeight(const Projection &projection) const
Definition: Styles.h:1217
bool GetAutoSize() const
Definition: Styles.h:594
Definition: Styles.h:66
bool HasPattern() const
Definition: Styles.h:319
const double & GetHeight() const
Definition: Styles.h:1081
std::shared_ptr< ShieldStyle > ShieldStyleRef
Definition: Styles.h:692
double GetDisplayOffset() const
Definition: Styles.h:433
Definition: Styles.h:466
OffsetRel GetOffsetRel() const
Definition: Styles.h:1296
OffsetRel GetOffsetRel() const
Definition: Styles.h:210
Definition: Styles.h:512
CapStyleEnumAttributeDescriptor(const std::string &name, int attribute)
Definition: Styles.h:228
Definition: Styles.h:1238
Definition: Styles.h:516
std::shared_ptr< DrawPrimitive > DrawPrimitiveRef
Definition: Styles.h:1021
size_t GetPosition() const
Definition: Styles.h:574
Definition: Styles.h:1235
Definition: Styles.h:637
std::shared_ptr< CirclePrimitive > CirclePrimitiveRef
Definition: Styles.h:1127
Definition: Styles.h:888
const double & GetWidth() const
Definition: Styles.h:1076
Definition: Styles.h:70
Definition: Styles.h:889
Definition: Styles.h:80
Attribute
Definition: Styles.h:511
void AddEnumValue2(const std::string &name, OffsetRel value)
Definition: Styles.h:266
Definition: Styles.h:633
Definition: Styles.h:82
std::shared_ptr< IconStyle > IconStyleRef
Definition: Styles.h:975
std::shared_ptr< TextStyle > TextStyleRef
Definition: Styles.h:622
bool IsVisible() const
Definition: Styles.h:928
CapStyle
Definition: Styles.h:69