17 namespace datastructure {
40 string name = string();
46 Color *fillColor =
nullptr;
47 Color *strokeColor =
nullptr;
48 float *strokeWidth =
nullptr;
49 int* strokeDash =
nullptr;
50 float *opacity =
nullptr;
56 bool xform_flag =
false;
68 void matMult (
float m1[][3],
float m2[][3],
float result[][3])
70 for (
int i = 0; i < 3; ++i) {
71 for (
int j = 0; j < 3; ++j) {
73 for (
int k = 0; k < 3; ++k) {
74 result[i][j] += m1[i][k] * m2[k][j];
79 void identity(
float m[][3]) {
80 for (
int i = 0; i < 3; ++i)
81 for (
int j = 0; j < 3; ++j)
82 m[i][j] = (i == j) ? 1. : 0.;
85 void copyMat(
float m[][3],
float copy[][3]) {
86 for (
int i = 0; i < 3; ++i)
87 for (
int j = 0; j < 3; ++j)
90 void printMat(
float m[][3]) {
91 for (
int i = 0; i < 3; ++i) {
92 for (
int j = 0; j < 3; ++j)
93 cout << m[i][j] <<
", ";
98 void clear_optional() {
105 strokeColor =
nullptr;
109 strokeWidth =
nullptr;
113 strokeDash =
nullptr;
132 strokeColor(nullptr),
133 strokeWidth(nullptr),
146 :identifier(s.identifier), name(s.name), xform_flag (s.xform_flag) {
147 xform[0][0] = s.xform[0][0]; xform[0][1] = s.xform[0][1]; xform[0][2] = s.xform[0][2];
148 xform[1][0] = s.xform[1][0]; xform[1][1] = s.xform[1][1]; xform[1][2] = s.xform[1][2];
149 xform[2][0] = s.xform[2][0]; xform[2][1] = s.xform[2][1]; xform[2][2] = s.xform[2][2];
151 if (s.fillColor) this->fillColor =
new Color(*(s.fillColor));
152 if (s.strokeColor) this->strokeColor =
new Color(*(s.strokeColor));
153 if (s.strokeWidth) this->strokeWidth =
new float(*(s.strokeWidth));
154 if (s.strokeDash) this->strokeDash =
new int(*(s.strokeDash));
155 if (s.opacity) this->opacity =
new float(*(s.opacity));
156 if (s.layer) this->layer =
new int(*(s.layer));
163 this->identifier = s.identifier;
165 this->xform_flag = s.xform_flag;
166 xform[0][0] = s.xform[0][0]; xform[0][1] = s.xform[0][1]; xform[0][2] = s.xform[0][2];
167 xform[1][0] = s.xform[1][0]; xform[1][1] = s.xform[1][1]; xform[1][2] = s.xform[1][2];
168 xform[2][0] = s.xform[2][0]; xform[2][1] = s.xform[2][1]; xform[2][2] = s.xform[2][2];
170 if (s.fillColor) this->fillColor =
new Color(*(s.fillColor));
171 if (s.strokeColor) this->strokeColor =
new Color(*(s.strokeColor));
172 if (s.strokeWidth) this->strokeWidth =
new float(*(s.strokeWidth));
173 if (s.strokeDash) this->strokeDash =
new int(*(s.strokeDash));
174 if (s.opacity) this->opacity =
new float(*(s.opacity));
175 if (s.layer) this->layer =
new int(*(s.layer));
210 fillColor =
new Color;
223 fillColor =
new Color;
225 *fillColor =
Color(c);
236 throw "Fill color was not set!";
248 strokeColor =
new Color;
262 strokeColor =
new Color;
264 *strokeColor =
Color(c);
276 throw "Stroke color was not set!";
288 strokeWidth =
new float;
290 if (strk_width < 0.0f)
291 throw "Stroke width must be positive or null";
293 *strokeWidth = strk_width;
305 throw "Stroke width not set!";
319 if (op < 0.0f || op > 1.0f)
320 throw "Opacity must be between 0 and 1";
334 throw "Opacity not set!";
346 strokeDash =
new int;
348 if (dash < 0 || dash > 10)
349 throw "Dash must be between 0 and 10 (inclusive)";
363 throw "Stroke dash not set!";
413 float transl[3][3] = {
414 {1., 0., tx}, {0., 1., ty}, {0., 0., 1.}
418 matMult (xform, transl, result);
419 copyMat (result, xform);
434 float scale[3][3] = {
435 {sx, 0., 0.}, {0., sy, 0.}, {0., 0., 1.}
439 matMult (xform, scale, result);
440 copyMat (result, xform);
454 return scale(scalefactor, scalefactor);
467 float angle_r = angle *
M_PI / 180.;
468 float c = cos(angle_r);
469 float s = sin(angle_r);
473 float rotation[3][3] = {
474 {c, -s, 0.}, {s, c, 0.}, {0., 0., 1.}
478 matMult (xform, rotation, result);
479 copyMat (result, xform);
495 float result[3][3], result2[3][3];
496 float scale[3][3] = {
497 {sx, 0., 0.}, {0., sy, 0.}, {0., 0., 1.}
499 float transl1[3][3] =
500 { {1., 0., -px}, {0., 1., -py}, {0., 0., 1.} };
501 float transl2[3][3] =
502 { {1., 0., px}, {0., 1., py}, {0., 0., 1.} };
505 matMult (scale, transl1, result);
506 matMult (transl2, result, result2);
509 matMult (xform, result2, result);
510 copyMat (result, xform);
526 float angle_r = angle *
M_PI / 180.;
527 float c = cos(angle_r);
528 float s = sin(angle_r);
531 float result[3][3], result2[3][3];
532 float rotation[3][3] = {
533 {c, -s, 0.}, {s, c, 0.}, {0., 0., 1.}
535 float transl1[3][3] = {
536 {1., 0., -px}, {0., 1., -py}, {0., 0., 1.}
538 float transl2[3][3] = {
539 {1., 0., px}, {0., 1., py}, {0., 0., 1.}
543 matMult (rotation, transl1, result);
544 matMult (transl2, result, result2);
547 matMult (xform, result2, result);
548 copyMat (result, xform);
561 float d,
float e,
float f) {
562 xform[0][0] = a; xform[1][0] = b;
563 xform[0][1] = c; xform[1][1] = d;
564 xform[0][2] = e; xform[2][2] = f;
565 xform[2][0] = 0.0f; xform[2][1] = 0.0f; xform[2][2] = 1.0f;
596 if (this->xform_flag) {
615 if (getShapeType() ==
"group") {
617 symbol_attr_json.erase (symbol_attr_json.size() -1);
623 symbol_attr_json +=
QUOTE +
"fill-color" +
630 to_string(*opacity) +
COMMA;
634 symbol_attr_json +=
QUOTE +
"stroke-color" +
QUOTE +
639 symbol_attr_json +=
QUOTE +
"stroke-width" +
QUOTE +
644 symbol_attr_json +=
QUOTE +
"stroke-dasharray" +
QUOTE +
649 return symbol_attr_json;
#define M_PI
Definition: OSMData.h:13
This class represents Color, and supports rgba, hexadecimal and named color values.
Definition: Color.h:51
const string getCSSRepresentation() const
Definition: Color.h:404
This is an abstract class for deriving a number of Symbol shape objects, for use in a SymbolCollectio...
Definition: Symbol.h:32
float getStrokeWidth() const
This method gets stroke width.
Definition: Symbol.h:303
Symbol & setStrokeColor(Color c)
Definition: Symbol.h:246
Symbol & setTransform(float a, float b, float c, float d, float e, float f)
Definition: Symbol.h:560
Symbol & setLayer(int l)
Definition: Symbol.h:374
int getStrokeDash() const
This method gets stroke dash level.
Definition: Symbol.h:361
virtual string getShapeType() const =0
float getOpacity() const
This method gets symbol opacity.
Definition: Symbol.h:332
Symbol & setFillColor(Color c)
Set the symbol fill color.
Definition: Symbol.h:208
Symbol & translate(float tx, float ty)
Translate a 2D point.
Definition: Symbol.h:411
Symbol & scale(float sx, float sy)
Scale a Symbol.
Definition: Symbol.h:432
int getLayer() const
Definition: Symbol.h:389
Symbol & scale(float scalefactor)
Scale a Symbol.
Definition: Symbol.h:453
int getIdentifier() const
return the symbol identifier.
Definition: Symbol.h:199
Symbol & setOpacity(float op)
This method sets the symbol opacity.
Definition: Symbol.h:315
Symbol()
default constructor
Definition: Symbol.h:130
Symbol & rotate(float angle, float px, float py)
Rotate a 2D point about an arbitrary point (px, py)
Definition: Symbol.h:524
Symbol & setStrokeColor(string c)
This method sets the symbol stroke color.
Definition: Symbol.h:260
~Symbol()
Definition: Symbol.h:182
Symbol & setStrokeWidth(float strk_width)
This method sets the symbol stroke width.
Definition: Symbol.h:286
virtual const string getSymbolRepresentation() const =0
Virtual method to get the JSON representation of the symbol.
Symbol & rotate(float angle)
Rotate a 2D point (about Z)
Definition: Symbol.h:465
Color getFillColor() const
This method gets fill color.
Definition: Symbol.h:234
Color getStrokeColor()
This method gets stroke color.
Definition: Symbol.h:274
Symbol(const Symbol &s)
Definition: Symbol.h:145
const string getSymbolAttributeRepresentation() const
Get the JSON of the symbol representation.
Definition: Symbol.h:582
Symbol & setFillColor(string c)
This method sets the symbol fill color.
Definition: Symbol.h:221
Symbol & setStrokeDash(int dash)
This method sets the stroke dash level.
Definition: Symbol.h:344
Symbol & scale(float sx, float sy, float px, float py)
Scale about an arbitrary point (px, py)
Definition: Symbol.h:494
std::string JSONencode(const T &d)
Definition: JSONutil.h:37
these methods convert byte arrays in to base64 codes and are used in BRIDGES to represent the color a...
Definition: alltypes.h:4
const string COLON
Definition: DataStructure.h:51
const string OPEN_BOX
Definition: DataStructure.h:54
const string COMMA
Definition: DataStructure.h:50
const string OPEN_CURLY
Definition: DataStructure.h:52
const string CLOSE_BOX
Definition: DataStructure.h:55
const string CLOSE_CURLY
Definition: DataStructure.h:53
const string QUOTE
Definition: DataStructure.h:49