9 #ifndef VIBES_CPP_API_H
10 #define VIBES_CPP_API_H
27 #define VIBES_GENERATE_vibesXXX_MACROS
30 #undef VIBES_DEBUG_API
42 #ifdef VIBES_DEBUG_API
44 #define VIBES_DEBUG(i) std::cout << "VibesDebug " << __FILE__ << "(" << __LINE__ << ") : " << i << std::endl;
46 #define VIBES_DEBUG(i)
63 vt_none, vt_integer, vt_string, vt_decimal, vt_array, vt_object
72 std::vector<
Value> _array;
75 Value() : _type(vt_none) {}
76 Value(
int i) : _integer(i), _type(vt_integer) {}
77 Value(
const double &d) : _decimal(d), _type(vt_decimal) {}
78 Value(
const std::string &s) : _string(s), _type(vt_string) {}
79 Value(
const char *s) : _string(s), _type(vt_string) {}
80 Value(
const std::vector<
Value> &a) : _array(a), _type(vt_array) {}
81 template <
typename T> Value(
const std::vector<T> &v) : _array(v.begin(),v.end()), _type(vt_array) {}
82 Value(
const Params &p) : _object(&p), _type(vt_object) {}
83 bool empty() {
return (_type == vt_none);}
84 std::string toJSONString()
const;
97 template<
typename T,
int N>
121 typedef std::map<std::string,
Value> KeyValueMap;
125 template<
typename T> Params(
const std::string & name,
const T &p) {_values[name] = p;}
126 Value & operator[](
const std::string &key) {
return _values[key];}
127 Value pop(
const std::string &key,
const Value &value_not_found =
Value());
129 Params& operator& (
const Params &p) {
for(KeyValueMap::const_iterator it = p._values.begin(); it != p._values.end(); ++it) _values[it->first] = it->second;
return *
this;}
130 std::size_t size()
const {
return _values.size(); }
131 std::string toJSON()
const;
141 NameHelper(
Params & list,
const std::string & name) : _params(list), _name(name) {}
142 Params & operator, (
const Value &value) { _params[_name] = value;
return _params; }
145 operator
Params&() {_params[
"format"] = _name;
return _params;}
156 #define VIBES_COLOR_PARAM_NAME "format"
157 #define VIBES_FUNC_COLOR_PARAM_1(func_name, T1, a)
158 void func_name(T1 a, Params params);
159 inline void func_name(T1 a,
160 const std::string &format=std::string(), Params params=Params()) {func_name(a,(params,VIBES_COLOR_PARAM_NAME,format));}
161 #define VIBES_FUNC_COLOR_PARAM_2(func_name, T1, a, T2, b)
162 void func_name(T1 a, T2 b, Params params);
163 inline void func_name(T1 a, T2 b,
164 const std::string &format=std::string(), Params params=Params()) {func_name(a,b,(params,VIBES_COLOR_PARAM_NAME,format));}
165 #define VIBES_FUNC_COLOR_PARAM_3(func_name, T1, a, T2, b, T3, c)
166 void func_name(T1 a, T2 b, T3 c, Params params);
167 inline void func_name(T1 a, T2 b, T3 c,
168 const std::string &format=std::string(), Params params=Params()) {func_name(a,b,c,(params,VIBES_COLOR_PARAM_NAME,format));}
169 #define VIBES_FUNC_COLOR_PARAM_4(func_name, T1, a, T2, b, T3, c, T4, d)
170 void func_name(T1 a, T2 b, T3 c, T4 d, Params params);
171 inline void func_name(T1 a, T2 b, T3 c, T4 d,
172 const std::string &format=std::string(), Params params=Params()) {func_name(a,b,c,d,(params,VIBES_COLOR_PARAM_NAME,format));}
173 #define VIBES_FUNC_COLOR_PARAM_5(func_name, T1, a, T2, b, T3, c, T4, d, T5, e)
174 void func_name(T1 a, T2 b, T3 c, T4 d, T5 e, Params params);
175 inline void func_name(T1 a, T2 b, T3 c, T4 d, T5 e,
176 const std::string &format=std::string(), Params params=Params()) {func_name(a,b,c,d,e,(params,VIBES_COLOR_PARAM_NAME,format));}
177 #define VIBES_FUNC_COLOR_PARAM_6(func_name, T1, a, T2, b, T3, c, T4, d, T5, e, T6, f)
178 void func_name(T1 a, T2 b, T3 c, T4 d, T5 e, T6 f, Params params);
179 inline void func_name(T1 a, T2 b, T3 c, T4 d, T5 e, T6 f,
180 const std::string &format=std::string(), Params params=Params()) {func_name(a,b,c,d,e,f,(params,VIBES_COLOR_PARAM_NAME,format));}
219 void newFigure(
const std::string &figureName = std::string());
222 void clearFigure(
const std::string &figureName = std::string());
225 void closeFigure(
const std::string &figureName = std::string());
229 void saveImage(
const std::string &fileName = std::string(),
const std::string &figureName = std::string());
242 void axisLimits(
const double &x_lb,
const double &x_ub,
const double &y_lb,
const double &y_ub,
Params params=
Params());
273 VIBES_FUNC_COLOR_PARAM_5(
drawEllipse,
const double &,cx,
const double &,cy,
const double &,a,
const double &,b,
const double &,rot)
276 const double &,sxx,
const double &,sxy,
const double &,syy,
280 const std::vector<
double> &,cov,
303 void clearGroup(
const std::string &figureName,
const std::string &groupName);
305 void clearGroup(
const std::string &groupName);
308 void removeObject(
const std::string &figureName,
const std::string &objectName);
317 void setObjectProperty(
const std::string &figureName,
const std::string &objectName,
const std::string &key,
const Value &value);
359 #ifdef _IBEX_INTERVAL_H_
362 #ifdef __IBEX_INTERVAL_VECTOR_H__
381 inline void drawCircle(
const double &cx,
const double &cy,
const double &r,
const Params ¶ms)
406 inline void setObjectProperty(
const std::string &figureName,
const std::string &objectName,
const std::string &key,
const Value &value)
417 #ifdef _IBEX_INTERVAL_H_
422 #ifdef __IBEX_INTERVAL_VECTOR_H__
435 #define vibesParams(...) (vibes::Params(), __VA_ARGS__)
437 #define vibesDrawBox(x_lb,x_ub,y_lb,y_ub,...) vibes::drawBox(x_lb,x_ub,y_lb,y_ub,vibesParams(__VA_ARGS__))
438 #define vibesDrawEllipse(cx,cy,a,b,rot,...) vibes::drawEllipse(cx,cy,a,b,rot,vibesParams(__VA_ARGS__))
439 #define vibesDrawConfidenceEllipse(cx,cy,sxx,sxy,syy,K,...) vibes::drawConfidenceEllipse(cx,cy,sxx,sxy,syy,K,vibesParams(__VA_ARGS__))
440 #define vibesDrawCircle(cx,cy,r,...) vibes::drawCircle(cx,cy,r,vibesParams(__VA_ARGS__))
#define VIBES_GENERATE_vibesXXX_MACROS
Vec< int, 4 > RGBA
A RGBA triplet [0..255].
void beginDrawing(const std::string &fileName)
Start VIBes in file saving mode. All commands are saved to the specified file.
#define VIBES_FUNC_COLOR_PARAM_3(func_name, T1, a, T2, b, T3, c)
#define vibesParams(...)
Macro to simplify contruction of a Params object.
#define VIBES_FUNC_COLOR_PARAM_2(func_name, T1, a, T2, b)
Vec< double, 3 > Vec3d
A 3D floating point vector.
void removeObject(const std::string &figureName, const std::string &objectName)
Delete the named graphical object objectName from figure figureName.
void setObjectProperties(const std::string &objectName, const Params &properties)
Assign properties to the named object objectName in current figure.
void drawLine(const std::vector< double > &x, const std::vector< double > &y, Params params)
Draw a 2-D line from the list of abscissae x and the list of ordinates y.
void clearGroup(const std::string &groupName)
Clear the contents of the group groupName in current figure.
void drawEllipse(const double &cx, const double &cy, const double &a, const double &b, const double &rot, Params params)
Draw an ellipse centered at (cx, cy), with semi-major and minor axes a and b, and rotated by rot degr...
void setObjectProperties(const std::string &figureName, const std::string &objectName, const Params &properties)
Assign properties to the named object objectName in figure figureName.
Vec< double, 2 > Vec2d
A 2D floating point vector.
#define VIBES_FUNC_COLOR_PARAM_1(func_name, T1, a)
void endDrawing()
Close connection to the viewer or the drawing file.
void drawBoxes(const std::vector< std::vector< double > > &bounds, Params params)
Draw a list of N-D rectangles from a list of list of bounds in the form ((x_lb_1, x_ub_1...
#define VIBES_FUNC_COLOR_PARAM_6(func_name, T1, a, T2, b, T3, c, T4, d, T5, e, T6, f)
void drawConfidenceEllipse(const double &cx, const double &cy, const double &sxx, const double &sxy, const double &syy, const double &K, Params params)
Draw a 2-D confidence ellipse centered at (cx, cy), with covariance sxx, sxy, syy and scale K...
Vec< double, 4 > Vec4d
A 4D floating point vector.
void beginDrawing()
Start VIBes in connected mode: connects to the VIBes viewer.
void setObjectProperty(const std::string &objectName, const std::string &key, const Value &value)
Set the property key to the provided value for the named object objectName in current figure...
#define VIBES_COLOR_PARAM_NAME
void setObjectProperty(const std::string &figureName, const std::string &objectName, const std::string &key, const Value &value)
Set the property key to the provided value for the named object objectName in figure figureName...
#define VIBES_FUNC_COLOR_PARAM_5(func_name, T1, a, T2, b, T3, c, T4, d, T5, e)
void drawBoxesUnion(const std::vector< std::vector< double > > &bounds, Params params)
Computes and draw the union of a list of N-D rectangles, from a list of list of bounds in the form ((...
#define VIBES_FUNC_COLOR_PARAM_4(func_name, T1, a, T2, b, T3, c, T4, d)
void clearGroup(const std::string &figureName, const std::string &groupName)
Clear the contents of the group groupName in figure figureName.
void drawBox(const vector< double > &bounds, Params params)
Draw a N-D box from a list of bounds in the form (x_lb, x_ub, y_lb, y_ub, z_lb, z_ub, ...)
void removeObject(const std::string &objectName)
Delete the named graphical object objectName from current figure.
void drawLine(const std::vector< std::vector< double > > &points, Params params)
Draw a N-D line from the list of coordinates points in the form ((x_1, y_1, z_1, ...), (x_2, y_2, z_2, ...), ...)
void newGroup(const std::string &name, Params params)
Create a new group with the specified name.
void drawConfidenceEllipse(const vector< double > ¢er, const vector< double > &cov, const double &K, Params params)
Draw a N-D confidence ellipse centered at center, with covariance in cov and scale K...
void drawBox(const double &x_lb, const double &x_ub, const double &y_lb, const double &y_ub, Params params)
Draw a 2-D box with a left lower corner at (x_lb, y_lb) and a right upper corner at (x_ub...
Vec< int, 3 > RGB
A RGB triplet [0..255].