Bridges-C++ 3.5.0
Bridges(C++ API)
Circle.h
Go to the documentation of this file.
1#include "DataStructure.h"
2#include "Symbol.h"
3#include <vector>
4
5using namespace std;
6
7#ifndef CIRCLE_H
8
9#define CIRCLE_H
10
11namespace bridges {
12 namespace datastructure {
21 class Circle : public Symbol {
22 private:
23
24 double center_x, center_y;
25 double radius = 1.;
26
32 virtual string getShapeType() const override {
33 return "circle";
34 }
35
36 public:
37
41 Circle () {
42 setCircle(0., 0., 1.);
43 }
44
49 Circle (double r) {
50 setCircle (0., 0., r);
51 }
52
59 Circle (double cx, double cy, double r) {
60 center_x = cx;
61 center_y = cy;
62 if (r < 0.)
63 throw "Illegal value for radius. Must be positive";
64 radius = r;
65 }
66
72 double getRadius() {
73 return radius;
74 }
80 void setRadius(double r) {
81 if (r < 0.)
82 throw "Illegal value for radius. Must be positive";
83 radius = r;
84 }
85
93 void setCircle (double cx, double cy, double r) {
94 setCenter(cx, cy);
95 if (r < 0.)
96 throw "Illegal value for radius. Must be positive";
97 radius = r;
98 }
99 void setCenter (double cx, double cy) {
100 center_x = cx;
101 center_y = cy;
102 }
103
104 double getCenterX() const {
105 return center_x;
106 }
107 double getCenterY() const {
108 return center_y;
109 }
110
116 const string getSymbolRepresentation() const override {
117
118 string shape_json = getSymbolAttributeRepresentation();
119
120 shape_json +=
121 QUOTE + "center" + QUOTE + COLON +
122 OPEN_BOX +
123 to_string(center_x) + COMMA + to_string(center_y) +
124 CLOSE_BOX + COMMA +
125 QUOTE + "r" + QUOTE + COLON + to_string(radius) + CLOSE_CURLY;
126
127 return shape_json;
128
129 }
130 };
131 }
132} // namespace bridges
133
134#endif
This class defines a circle and is part of the symbol collection. A circle has a radius.
Definition: Circle.h:21
Circle()
Definition: Circle.h:41
void setRadius(double r)
This method sets the radius of the circle.
Definition: Circle.h:80
double getRadius()
This method returns the radius of the circle.
Definition: Circle.h:72
void setCircle(double cx, double cy, double r)
This method sets the circle dimensions.
Definition: Circle.h:93
double getCenterX() const
Definition: Circle.h:104
const string getSymbolRepresentation() const override
Definition: Circle.h:116
void setCenter(double cx, double cy)
Definition: Circle.h:99
Circle(double r)
Definition: Circle.h:49
Circle(double cx, double cy, double r)
Definition: Circle.h:59
double getCenterY() const
Definition: Circle.h:107
This is an abstract class for deriving a number of Symbol shape objects, for use in a SymbolCollectio...
Definition: Symbol.h:31
const string getSymbolAttributeRepresentation() const
Get the JSON of the symbol representation.
Definition: Symbol.h:622
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:52
const string OPEN_BOX
Definition: DataStructure.h:55
const string COMMA
Definition: DataStructure.h:51
const string CLOSE_BOX
Definition: DataStructure.h:56
const string CLOSE_CURLY
Definition: DataStructure.h:54
const string QUOTE
Definition: DataStructure.h:50