60#ifndef guWhiteboard_PixelCoordinate_h
61#define guWhiteboard_PixelCoordinate_h
63#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
72#undef guWhiteboard_PixelCoordinate_DEFINED
73#define guWhiteboard_PixelCoordinate_DEFINED
75#undef PixelCoordinate_DEFINED
76#define PixelCoordinate_DEFINED
78#include <guunits/guunits.h>
79#include <gucoordinates/gucoordinates.h>
93 void init(int16_t t_x = 0, int16_t t_y = 0) {
104 this->init(t_x, t_y);
111 this->init(t_other.
x(), t_other.
y());
118 this->init(t_other.
x, t_other.
y);
125 this->init(t_other.
x(), t_other.
y());
133 this->init(t_other.
x, t_other.
y);
139 return x() == t_other.
x()
140 &&
y() == t_other.
y();
145 return !(*
this == t_other);
155 return !(*
this == t_other);
163 const int16_t &
x()
const
168 void set_x(
const int16_t &t_newValue)
178 const int16_t &
y()
const
183 void set_y(
const int16_t &t_newValue)
188#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
198#ifdef USE_WB_PIXEL_COORDINATE_C_CONVERSION
201 std::string descr = buffer;
204 std::ostringstream ss;
205 ss <<
"x=" <<
static_cast<signed>(this->
x());
207 ss <<
"y=" <<
static_cast<signed>(this->
y());
213#ifdef USE_WB_PIXEL_COORDINATE_C_CONVERSION
216 std::string toString = buffer;
219 std::ostringstream ss;
220 ss << static_cast<signed>(this->
x());
222 ss << static_cast<signed>(this->
y());
227#ifdef USE_WB_PIXEL_COORDINATE_C_CONVERSION
232 char * str_cstr =
const_cast<char *
>(t_str.c_str());
233 size_t temp_length = strlen(str_cstr);
234 int length = (temp_length <= INT_MAX) ? static_cast<int>(
static_cast<ssize_t
>(temp_length)) : -1;
239 char* var_str = &var_str_buffer[0];
241 char* key = &key_buffer[0];
248 if (index == 0 && str_cstr[0] ==
'{') {
254 for (
int i = index; i < length; i++) {
256 if (bracecount == 0 && str_cstr[i] ==
'=') {
261 if (bracecount == 0 && isspace(str_cstr[i])) {
268 if (bracecount == 0 && str_cstr[i] ==
',') {
272 if (str_cstr[i] ==
'{') {
276 if (str_cstr[i] ==
'}') {
278 if (bracecount < 0) {
283 if (i == length - 1) {
287 if (endKey >= startKey && endKey - startKey < length) {
288 strncpy(key, str_cstr + startKey,
static_cast<size_t>((endKey - startKey) + 1));
289 key[(endKey - startKey) + 1] = 0;
293 strncpy(var_str, str_cstr + startVar,
static_cast<size_t>((index - startVar) + 1));
294 var_str[(index - startVar) + 1] = 0;
300 if (strlen(key) > 0) {
301 if (0 == strcmp(
"x", key)) {
303 }
else if (0 == strcmp(
"y", key)) {
313 this->
set_x(
static_cast<int16_t
>(atoi(var_str)));
318 this->
set_y(
static_cast<int16_t
>(atoi(var_str)));
325 }
while(index < length);
331 this->init(px_t_to_i16(other.x()), px_t_to_i16(other.y()));
335 this->init(px_t_to_i16(other.x), px_t_to_i16(other.y));
338 GU::PixelCoordinate
pixelCoordinate(
const uint16_t resWidth,
const uint16_t resHeight)
Provides a C++ wrapper around wb_pixel_coordinate.
const int16_t & y() const
std::string description()
const int16_t & x() const
PixelCoordinate & operator=(const PixelCoordinate &t_other)
Copy Assignment Operator.
PixelCoordinate(const struct wb_pixel_coordinate &t_other)
Copy Constructor.
void from_string(const std::string &t_str)
bool operator!=(const PixelCoordinate &t_other) const
PixelCoordinate(const std::string &t_str)
String Constructor.
void set_y(const int16_t &t_newValue)
PixelCoordinate(const GU::PixelCoordinate &other)
WHITEBOARD_POSTER_STRING_CONVERSION.
PixelCoordinate(int16_t t_x=0, int16_t t_y=0)
Create a new PixelCoordinate.
PixelCoordinate(const PixelCoordinate &t_other)
Copy Constructor.
bool operator==(const PixelCoordinate &t_other) const
PixelCoordinate(const ::gu_pixel_coordinate &other)
GU::PixelCoordinate pixelCoordinate(const uint16_t resWidth, const uint16_t resHeight)
void set_x(const int16_t &t_newValue)
WHITEBOARD_POSTER_STRING_CONVERSION.
int16_t y
The y coordinate.
int16_t x
The x coordinate.
const char * wb_pixel_coordinate_description(const struct wb_pixel_coordinate *self, char *descString, size_t bufferSize)
Convert to a description string.
struct wb_pixel_coordinate * wb_pixel_coordinate_from_string(struct wb_pixel_coordinate *self, const char *str)
Convert from a string.
const char * wb_pixel_coordinate_to_string(const struct wb_pixel_coordinate *self, char *toString, size_t bufferSize)
Convert to a string.
gu_pixel_coordinate wb_px_coord_to_px_coord(const struct wb_pixel_coordinate coord, const uint16_t resWidth, const uint16_t resHeight)
#define PIXEL_COORDINATE_DESC_BUFFER_SIZE
#define PIXEL_COORDINATE_TO_STRING_BUFFER_SIZE