20 #include <Eigen/Dense>
34 #if MRPT_HAS_ASIAN_FONTS
51 bool prepared_to_big_endian =
false;
66 #define SAVE_COMPRESSED(ARR) \
68 list_registered_fonts[#ARR].resize(sizeof(mrpt_font_##ARR)); \
70 &list_registered_fonts[#ARR][0], mrpt_font_##ARR, \
71 sizeof(mrpt_font_##ARR)); \
72 cout << #ARR << " -> " << sizeof(mrpt_font_##ARR) << endl; \
73 CFileGZOutputStream f( \
74 string("mrpt_font_") + string(#ARR) + string(".gz")); \
75 f.WriteBuffer(mrpt_font_##ARR, sizeof(mrpt_font_##ARR)); \
87 #if MRPT_HAS_ASIAN_FONTS
93 #if 1 // Normal operation: Load fonts and uncompress them:
95 #define LOAD_FONT(FONTNAME) \
97 std::vector<uint8_t> tmpBuf(sizeof(mrpt_font_gz_##FONTNAME)); \
99 &tmpBuf[0], mrpt_font_gz_##FONTNAME, \
100 sizeof(mrpt_font_gz_##FONTNAME)); \
101 mrpt::io::zip::decompress_gz_data_block( \
102 tmpBuf, list_registered_fonts[#FONTNAME].data); \
112 #if MRPT_HAS_ASIAN_FONTS
127 [[maybe_unused]]
unsigned int width, [[maybe_unused]]
TPenStyle penStyle)
131 auto Ax = (float)(x1 - x0);
132 auto Ay = (float)(y1 - y0);
135 if (Ax == 0 && Ay == 0)
return;
136 if (x0 < 0 && x1 < 0)
return;
137 if (y0 < 0 && y1 < 0)
return;
138 if (x0 >= (
int)getWidth() && x1 >= (int)getWidth())
return;
142 int i, N = (int)ceil(dist);
150 for (i = 0; i < N; i++)
154 setPixel((
int)x, (
int)y, color);
165 int w_min = (int)-ceil(((
float)width) / 2);
166 int w_max = (int)floor(((
float)width) / 2);
168 for (
int w = w_min; w <= w_max; w++)
170 line(x0 - w, y0 - w, x1 + w, y0 - w, color);
171 line(x1 + w, y0 - w, x1 + w, y1 + w, color);
172 line(x1 + w, y1 + w, x0 - w, y1 + w, color);
173 line(x0 - w, y1 + w, x0 - w, y0 - w, color);
189 line(x0, y0 +
size, x0 + ts, y0 - tc, color, width);
190 line(x0, y0 +
size, x0 - ts, y0 - tc, color, width);
191 line(x0 + ts, y0 - tc, x0 - ts, y0 - tc, color, width);
195 line(x0, y0 -
size, x0 + ts, y0 + tc, color, width);
196 line(x0, y0 -
size, x0 - ts, y0 + tc, color, width);
197 line(x0 + ts, y0 + tc, x0 - ts, y0 + tc, color, width);
208 int x_min = max(x0, 0);
209 int x_max = min(x1, (
int)getWidth() - 1);
210 int y_min = max(y0, 0);
211 int y_max = min(y1, (
int)
getHeight() - 1);
213 for (
int y = y_min; y <= y_max; y++)
214 for (
int x = x_min; x <= x_max; x++) setPixel(x, y, color);
229 cerr <<
"[CCanvas::selectTextFont] Warning: Unknown font: " << fontName
236 m_selectedFontBitmaps =
reinterpret_cast<const uint32_t*
>(&fd.
data[0]);
237 m_selectedFont = fontName;
239 #if MRPT_IS_BIG_ENDIAN
244 uint32_t* ptr =
reinterpret_cast<uint32_t*
>(&fd.
data[0]);
245 for (
size_t i = 0; i < fd.
data.size() /
sizeof(uint32_t); i++)
265 for (
int xx = 0; xx < img_lx; xx++)
266 for (
int yy = 0; yy < img_ly; yy++)
268 auto ptr = img(xx, yy);
269 const int p = ptr[0] | (ptr[1] << 8) | (ptr[2] << 16);
270 setPixel(x + xx, y + yy, p);
277 for (
int xx = 0; xx < img_lx; xx++)
278 for (
int yy = 0; yy < img_ly; yy++)
280 c = *((
unsigned char*)img(xx, yy));
281 col = c | (c << 8) | (c << 16);
282 setPixel(x + xx, y + yy, col);
293 [[maybe_unused]]
int x, [[maybe_unused]]
int y,
295 [[maybe_unused]]
float rotation, [[maybe_unused]]
float scale)
311 line(x0 -
size, y0, x0 +
size, y0, color, width);
312 line(x0, y0 -
size, x0, y0 +
size, color, width);
325 line(x0 -
size, y0, x0 - 2, y0, color, width);
326 line(x0 + 2, y0, x0 +
size, y0, color, width);
327 line(x0, y0 -
size, x0, y0 - 2, color, width);
328 line(x0, y0 + 2, x0, y0 +
size, color, width);
342 if (radius < 0) radius = -radius;
352 nSegments = int(
M_2PI * radius);
355 int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
356 double ang, Aa =
M_2PI / (nSegments - 1);
359 for (i = 0, ang = 0; i < nSegments; i++, ang += Aa)
361 x2 =
round(x + radius * cos(ang));
362 y2 =
round(y + radius * sin(ang));
364 if (i > 0) line(x1, y1, x2, y2, color, width);
379 if (!m_selectedFontBitmaps)
380 this->selectTextFont(
"9x15");
383 bool y_axis_reversed =
false;
384 auto* im_image =
dynamic_cast<CImage*
>(
this);
388 std::vector<uint16_t> uniStr;
395 int char_w = m_selectedFontBitmaps[0];
396 int char_h = m_selectedFontBitmaps[1];
398 for (
unsigned short unichar : uniStr)
401 const uint32_t* table_ptr = m_selectedFontBitmaps + 2;
402 uint32_t charset_ini = table_ptr[0];
403 uint32_t charset_end = table_ptr[1];
408 if (unichar <= charset_end && unichar >= charset_ini)
411 int pyy = y_axis_reversed ? (py + char_h - 1) : py;
413 const uint32_t* char_bitmap =
414 table_ptr + 2 + char_h * (unichar - charset_ini);
416 for (
int y = 0; y < char_h;
417 y++, pyy += y_axis_reversed ? -1 : 1)
423 memcpy(&row, char_bitmap,
sizeof(row));
425 for (
int x = 0, pxx = px; x < char_w; x++, pxx++)
426 if (!!(row & (1 << x))) setPixel(pxx, pyy, color);
438 uint32_t n_chars = charset_end - charset_ini + 1;
439 table_ptr += 2 + n_chars * char_h;
442 charset_ini = table_ptr[0];
443 charset_end = table_ptr[1];
454 const double mean_y,
double confIntervalStds,
458 int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
461 std::vector<double> eVals;
465 cov2D.
eig(eigVec, eVals);
474 for (i = 0, ang = 0; i < nEllipsePoints;
475 i++, ang += (
M_2PI / (nEllipsePoints - 1)))
477 double ccos = cos(ang);
478 double ssin = sin(ang);
481 mean_x + confIntervalStds * (ccos * M(0, 0) + ssin * M(1, 0)));
483 mean_y + confIntervalStds * (ccos * M(0, 1) + ssin * M(1, 1)));
485 if (i > 0) line(x1, y1, x2, y2, color, width);
493 << cov2D << std::endl;);