16 namespace datastructure {
39 string name = string();
45 Color *fillColor =
nullptr;
46 Color *strokeColor =
nullptr;
47 float *strokeWidth =
nullptr;
48 int* strokeDash =
nullptr;
49 float *opacity =
nullptr;
54 bool xform_flag =
false;
64 void matMult (
float m1[][3],
float m2[][3],
float result[][3])
66 for (
int i = 0; i < 3; ++i) {
67 for (
int j = 0; j < 3; ++j) {
69 for (
int k = 0; k < 3; ++k) {
70 result[i][j] += m1[i][k] * m2[k][j];
75 void identity(
float m[][3]) {
76 for (
int i = 0; i < 3; ++i)
77 for (
int j = 0; j < 3; ++j)
78 m[i][j] = (i == j) ? 1. : 0.;
81 void copyMat(
float m[][3],
float copy[][3]) {
82 for (
int i = 0; i < 3; ++i)
83 for (
int j = 0; j < 3; ++j)
86 void printMat(
float m[][3]) {
87 for (
int i = 0; i < 3; ++i) {
88 for (
int j = 0; j < 3; ++j)
89 cout << m[i][j] <<
", ";
94 void clear_optional() {
101 strokeColor =
nullptr;
105 strokeWidth =
nullptr;
109 strokeDash =
nullptr;
128 strokeColor(nullptr),
129 strokeWidth(nullptr),
142 : identifier(s.identifier), name(s.name), xform_flag (s.xform_flag) {
143 xform[0][0] = s.xform[0][0];
144 xform[0][1] = s.xform[0][1];
145 xform[0][2] = s.xform[0][2];
146 xform[1][0] = s.xform[1][0];
147 xform[1][1] = s.xform[1][1];
148 xform[1][2] = s.xform[1][2];
149 xform[2][0] = s.xform[2][0];
150 xform[2][1] = s.xform[2][1];
151 xform[2][2] = s.xform[2][2];
154 this->fillColor =
new Color(*(s.fillColor));
156 this->strokeColor =
new Color(*(s.strokeColor));
158 this->strokeWidth =
new float(*(s.strokeWidth));
160 this->strokeDash =
new int(*(s.strokeDash));
162 this->opacity =
new float(*(s.opacity));
164 this->layer =
new int(*(s.layer));
171 this->identifier = s.identifier;
173 this->xform_flag = s.xform_flag;
174 xform[0][0] = s.xform[0][0];
175 xform[0][1] = s.xform[0][1];
176 xform[0][2] = s.xform[0][2];
177 xform[1][0] = s.xform[1][0];
178 xform[1][1] = s.xform[1][1];
179 xform[1][2] = s.xform[1][2];
180 xform[2][0] = s.xform[2][0];
181 xform[2][1] = s.xform[2][1];
182 xform[2][2] = s.xform[2][2];
185 this->fillColor =
new Color(*(s.fillColor));
187 this->strokeColor =
new Color(*(s.strokeColor));
189 this->strokeWidth =
new float(*(s.strokeWidth));
191 this->strokeDash =
new int(*(s.strokeDash));
193 this->opacity =
new float(*(s.opacity));
195 this->layer =
new int(*(s.layer));
228 fillColor =
new Color;
241 fillColor =
new Color;
243 *fillColor =
Color(c);
254 throw "Fill color was not set!";
266 strokeColor =
new Color;
280 strokeColor =
new Color;
282 *strokeColor =
Color(c);
294 throw "Stroke color was not set!";
306 strokeWidth =
new float;
308 if (strk_width < 0.0f)
309 throw "Stroke width must be positive or null";
311 *strokeWidth = strk_width;
323 throw "Stroke width not set!";
337 if (op < 0.0f || op > 1.0f)
338 throw "Opacity must be between 0 and 1";
352 throw "Opacity not set!";
364 strokeDash =
new int;
366 if (dash < 0 || dash > 10)
367 throw "Dash must be between 0 and 10 (inclusive)";
381 throw "Stroke dash not set!";
429 float transl[3][3] = {
430 {1., 0., tx}, {0., 1., ty}, {0., 0., 1.}
434 matMult (transl, xform, result);
435 copyMat (result, xform);
450 float scale[3][3] = {
451 {sx, 0., 0.}, {0., sy, 0.}, {0., 0., 1.}
455 matMult (scale, xform, result);
456 copyMat (result, xform);
470 return scale(scalefactor, scalefactor);
482 float angle_r = angle *
M_PI / 180.;
483 float c = cos(angle_r);
484 float s = sin(angle_r);
488 float rotation[3][3] = {
489 {c, -s, 0.}, {s, c, 0.}, {0., 0., 1.}
493 matMult (rotation, xform, result);
494 copyMat (result, xform);
510 float result[3][3], result2[3][3];
511 float scale[3][3] = {
512 {sx, 0., 0.}, {0., sy, 0.}, {0., 0., 1.}
514 float transl1[3][3] =
515 { {1., 0., -px}, {0., 1., -py}, {0., 0., 1.} };
516 float transl2[3][3] =
517 { {1., 0., px}, {0., 1., py}, {0., 0., 1.} };
520 matMult (scale, transl1, result);
521 matMult (transl2, result, result2);
524 matMult (result2, xform, result);
525 copyMat (result, xform);
541 float angle_r = angle *
M_PI / 180.;
542 float c = cos(angle_r);
543 float s = sin(angle_r);
546 float result[3][3], result2[3][3];
547 float rotation[3][3] = {
548 {c, -s, 0.}, {s, c, 0.}, {0., 0., 1.}
550 float transl1[3][3] = {
551 {1., 0., -px}, {0., 1., -py}, {0., 0., 1.}
553 float transl2[3][3] = {
554 {1., 0., px}, {0., 1., py}, {0., 0., 1.}
558 matMult (rotation, transl1, result);
559 matMult (transl2, result, result2);
562 matMult (result2, xform, result);
563 copyMat (result, xform);
576 float d,
float e,
float f) {
616 if (this->xform_flag) {
635 if (getShapeType() ==
"group") {
637 symbol_attr_json.erase (symbol_attr_json.size() - 1);
643 symbol_attr_json +=
QUOTE +
"fill-color" +
650 to_string(*opacity) +
COMMA;
654 symbol_attr_json +=
QUOTE +
"stroke-color" +
QUOTE +
659 symbol_attr_json +=
QUOTE +
"stroke-width" +
QUOTE +
664 symbol_attr_json +=
QUOTE +
"stroke-dasharray" +
QUOTE +
669 return symbol_attr_json;
#define M_PI
Definition: OSMData.h:12
This class represents Color, and supports rgba, hexadecimal and named color values.
Definition: Color.h:50
const string getCSSRepresentation() const
Definition: Color.h:403
This is an abstract class for deriving a number of Symbol shape objects, for use in a SymbolCollectio...
Definition: Symbol.h:31
float getStrokeWidth() const
This method gets stroke width.
Definition: Symbol.h:321
Symbol & setStrokeColor(Color c)
Definition: Symbol.h:264
Symbol & setTransform(float a, float b, float c, float d, float e, float f)
Definition: Symbol.h:575
Symbol & setLayer(int l)
Definition: Symbol.h:392
int getStrokeDash() const
This method gets stroke dash level.
Definition: Symbol.h:379
virtual string getShapeType() const =0
float getOpacity() const
This method gets symbol opacity.
Definition: Symbol.h:350
Symbol & setFillColor(Color c)
Set the symbol fill color.
Definition: Symbol.h:226
Symbol & translate(float tx, float ty)
Translate a 2D point.
Definition: Symbol.h:427
Symbol & scale(float sx, float sy)
Scale a Symbol.
Definition: Symbol.h:448
int getLayer() const
Definition: Symbol.h:407
Symbol & scale(float scalefactor)
Scale a Symbol.
Definition: Symbol.h:469
int getIdentifier() const
return the symbol identifier.
Definition: Symbol.h:217
Symbol & setOpacity(float op)
This method sets the symbol opacity.
Definition: Symbol.h:333
Symbol()
default constructor
Definition: Symbol.h:126
Symbol & rotate(float angle, float px, float py)
Rotate a 2D point about an arbitrary point (px, py)
Definition: Symbol.h:539
Symbol & setStrokeColor(string c)
This method sets the symbol stroke color.
Definition: Symbol.h:278
~Symbol()
Definition: Symbol.h:200
Symbol & setStrokeWidth(float strk_width)
This method sets the symbol stroke width.
Definition: Symbol.h:304
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:480
Color getFillColor() const
This method gets fill color.
Definition: Symbol.h:252
Color getStrokeColor()
This method gets stroke color.
Definition: Symbol.h:292
Symbol(const Symbol &s)
Definition: Symbol.h:141
const string getSymbolAttributeRepresentation() const
Get the JSON of the symbol representation.
Definition: Symbol.h:602
Symbol & setFillColor(string c)
This method sets the symbol fill color.
Definition: Symbol.h:239
Symbol & setStrokeDash(int dash)
This method sets the stroke dash level.
Definition: Symbol.h:362
Symbol & scale(float sx, float sy, float px, float py)
Scale about an arbitrary point (px, py)
Definition: Symbol.h:509
std::string JSONencode(const T &d)
Definition: JSONutil.h:38
Support for drawing Bar charts.
Definition: alltypes.h:4
const string COLON
Definition: DataStructure.h:52
const string OPEN_BOX
Definition: DataStructure.h:55
const string COMMA
Definition: DataStructure.h:51
const string OPEN_CURLY
Definition: DataStructure.h:53
const string CLOSE_BOX
Definition: DataStructure.h:56
const string CLOSE_CURLY
Definition: DataStructure.h:54
const string QUOTE
Definition: DataStructure.h:50