19#ifndef MiL_SVG_RADIAL_KUSAMA_H
20#define MiL_SVG_RADIAL_KUSAMA_H 1
73 const int rspace,
const int rstart,
const int linelen,
78 const int rbase(rstart + rspace);
81 line_element l =
make_line(pl1, pl2, styl);
86 int glyphr = rbase + linelen + rspace;
87 typography typob(typo);
89 radial_text_r(obj, std::to_string(v), typob, glyphr, origin, angled);
90 return glyphr - rstart;
100 const int kr,
const int rspace,
const int rstart)
108 const string glyphtext = idst.
name;
109 const double glyphscale = idst.
multiple;
110 const double glyphrotate = idst.
rotate;
121 const double scale(kra * 2 / glyphscale);
122 const double scaledsize =
scale * 100;
123 const double scaledglyph =
scale * glyphscale;
124 const double svgr = rstart + rspace + (scaledglyph / 2);
128 insert_svg_at(obj, isvg, p, 100, scaledsize, angleda + glyphrotate,
130 glyphr += scaledsize;
135 const int vr = rstart + rspace + kra;
161 const double angled,
const double kr,
const int rspace,
162 const int rstart,
const string id,
const typography& typo)
170 glyphr +=
radiate_glyph(obj, origin, angled, idst, kr, rspace, rstart);
175 const int idr = rstart + glyphr + rspace;
181 const string playingabv(
" -> ");
182 if (
id.find(playingabv) != string::npos)
203 const int radius,
const int rspace,
const int rstart,
206 const double angled =
get_angle(v, value_max);
207 const double kr((
double(v) / value_max) * radius);
226 const int radius,
const int rspace,
const int rstart,
229 const bool wbyvaluep,
const bool satellitep =
false)
232 const double angled =
get_angle(v, value_max);
235 rspace, rstart, linelen, typo);
245 rstart + glyphr,
"", typo);
250 const double ar = rstart + glyphr;
257 kr = ((double(v) / value_max) * radius);
266 const double distnce = k + (kr * 2);
267 const double sr = ar + rspace + kr;
271 const double maxdeg = anglea * (ids.size() - 1);
272 double angled2 = angled - (maxdeg / 2);
274 for (
const string&
id : ids)
277 kr, rspace, ar,
id, typo);
279 constexpr bool debugp =
false;
292 maxglyphr2 = std::max(maxglyphr2, glyphr2);
294 glyphr += maxglyphr2;
308 const int radius,
const int rspace,
const int rstart,
313 const double angled =
get_angle(v, value_max);
320 rspace, rstart, linelen, typo);
326 rstart + glyphr, ids.front(), typo);
328 constexpr bool debugp =
false;
344 radius, rspace, rstart, linelen, typo, wbyvaluep,
354 const int radius,
const int rspace,
const int rstart,
356 const typography& typo,
const bool weighbyvaluep)
361 linelen, typo, weighbyvaluep);
364 constexpr bool overlayrayp =
false;
368 const double angled =
get_angle(v, value_max);
370 radius * 4, typo, rstyl);
374 constexpr bool showmaxvp =
true;
377 const double anglemax =
get_angle(value_max, value_max);
407 std::vector<ssize_type>& vuvalues,
vvstrings& vids,
409 const int radius,
const int rspace,
const int rstart,
410 const typography& typo,
const bool weighbyvaluep,
412 const int startlenm = 5)
416 std::vector<ssize_type> vuvaluesnear;
418 const int startlen = radius * startlenm;
419 const int linelen = rspace * 2;
426 for (
uint i = 0; i < vuvalues.size(); ++i)
430 const bool finalp = i + 1 == vuvalues.size();
431 const bool firstp = i == 0;
440 if (std::abs(v - vold) > (value_max / 4))
449 const bool lastyesp = !firstp && (v - threshold <= vuvalues[i - 1]);
450 const bool nextyesp = !finalp && (v + threshold >= vuvalues[i + 1]);
451 const bool firstyesp = firstp && \
452 (v + std::abs(value_max - vuvalues.back()) <= threshold);
453 if (!skip && (nextyesp || lastyesp || firstyesp))
456 rstart + startlen - linelen, linelen, typo,
462 vidsnear.push_back(ids);
463 vuvaluesnear.push_back(v);
470 vuvalues = vuvaluesnear;
492 const int rspace,
const bool weighbyvaluep =
true,
493 const bool collisionp =
false,
494 const bool sortstringsbysizep =
false)
509 std::vector<ssize_type> vuvalues(uvalues.begin(), uvalues.end());
510 std::vector<strings> vids;
511 for (
const auto& v : vuvalues)
514 auto irange = uvaluemm.equal_range(v);
515 auto ibegin = irange.first;
516 auto iend = irange.second;
518 for (
auto i = ibegin; i != iend; ++i)
519 ids.push_back(i->second);
520 if (sortstringsbysizep)
523 sort(ids.begin(), ids.end());
528 if (vuvalues.front() == 0)
531 std::clog <<
"eliding ids with value zero: " << std::endl;
532 for (
const auto& s: ids)
533 std::clog << s << std::endl;
534 vuvalues.erase(vuvalues.begin());
535 vids.erase(vids.begin());
542 if (collisionp && vuvalues.size() > 1)
546 if (value_max >= 20 && value_max < 190)
548 if (value_max >= 190 && value_max < 290)
550 if (value_max >= 290)
554 radius, rspace, radius, typo, weighbyvaluep,
559 for (
uint i = 0; i < vuvalues.size(); ++i)
563 int j = vuvalues.size() - 1 - i;
565 auto v = vuvalues[j];
568 radius, rspace, radius, rspace, typo, weighbyvaluep);
void add_element(const element_base &e)
line_element make_line(const point_2t origin, const point_2t end, style s, const string dasharray="")
Line primitive.
uint significant_digits_in(ssize_type maxval)
The number of significant digits in.
std::unordered_multimap< value_type, string > value_id_ummap
void radial_text_r(svg_element &obj, string text, const typography &typo, const int r, const point_2t origin, const double deg, const bool roriginp=false)
svg_element insert_svg_at(svg_element &obj, const string isvg, const point_2t origin, const double origsize, const double isize, const double angled=0, const style &styl=k::no_style)
Embed svg in group element.
std::unordered_map< string, value_type > id_value_umap
Hash multimap of unique value to (perhaps multiple) unique ids. Use this form for sorting by value.
ssize_type & get_label_spaces()
Get the label space. Value -> Name, as a string where value has labelspaces of fill NB: Should be the...
int radiate_glyph_and_id(svg_element &obj, const point_2t origin, const double angled, const double kr, const int rspace, const int rstart, const string id, const typography &typo)
double get_angle(ssize_type pvalue, ssize_type pmax)
Transform a value on a range to an angle on the radial range.
double adjust_angle_at_orbit_for_distance(double r, double dist, const double minadjust=0.25)
circle_element make_circle(const point_2t origin, const style s, const space_type r, const string xform="")
Make circle element.
std::vector< strings > vvstrings
double adjust_angle_rotation(const double dorig, const k::rrotation rot)
Adjust angle above to CW/CCW orientation.
std::set< value_type > value_set
string file_to_svg_insert(const string ifile)
Import svg file, convert it to svg_element for insertion. ifile is a plain SVG file with a 1:1 aspect...
double & get_min_satellite_distance()
The minimum distance between satellites in high orbit.
int radiate_glyph(svg_element &obj, const point_2t origin, const double angled, const id_rstate idst, const int kr, const int rspace, const int rstart)
constexpr double char_width_to_px(const uint sz)
Approximate pixel height of type of point size @sz.
int kusama_ids_orbit_high(svg_element &obj, const point_2t origin, const strings &ids, const ssize_type v, const ssize_type value_max, const int radius, const int rspace, const int rstart, const int linelen, const typography &typo, const bool wbyvaluep, const bool satellitep=false)
void kusama_collision_transforms(svg_element &obj, const point_2t origin, std::vector< ssize_type > &vuvalues, vvstrings &vids, const ssize_type value_max, const int radius, const int rspace, const int rstart, const typography &typo, const bool weighbyvaluep, const ssize_type threshold=1, const int startlenm=5)
point_2t get_circumference_point_d(const double ad, const double r, const point_2t origin)
Angle in degrees.
void kusama_ids_at_uvalue(svg_element &obj, const point_2t origin, const strings &ids, const ssize_type v, const ssize_type value_max, const int radius, const int rspace, const int rstart, const int linelen, const typography &typo, const bool weighbyvaluep)
Layer one value's glyphs and ids.
svg_element kusama_ids_per_uvalue_on_arc(svg_element &obj, const point_2t origin, const typography &typo, const id_value_umap &ivm, const ssize_type value_max, const int radius, const int rspace, const bool weighbyvaluep=true, const bool collisionp=false, const bool sortstringsbysizep=false)
int radiate_line_and_value(svg_element &obj, const point_2t origin, const double angled, const ssize_type v, const int rspace, const int rstart, const int linelen, const typography &typo, const style styl={color::black, 1, color::black,.25, 1})
void kusama_ids_orbit_low(svg_element &obj, const point_2t origin, const strings &ids, const ssize_type v, const ssize_type value_max, const int radius, const int rspace, const int rstart, const int linelen, const typography &typo, const bool wbyvaluep)
double set_min_satellite_distance(const double kuse)
By observation, 7pt = 5 minimum NB: Make sure distance is at least text height away for lowest values...
@ vector
svg path, circle, rectangle, etc.
@ svg
svg element, perhaps nested
int & get_min_ring_size()
The smallest (sattelite) radius size allowed in a kusama orbit.
std::tuple< space_type, space_type > point_2t
Point (x,y) in 2D space, space_type defaults to double.
int set_min_ring_size(const int sz)
By observation, type size 12pt = 5, 6pt = 2.
value_id_ummap to_value_id_mmap(const id_value_umap &ivm, value_set &uniquev)
Convert id_value_umap to value_id_mmap + set of unique values.
std::vector< string > strings
const id_rstate get_id_rstate(const string id)
Given identifier/name/id, get corresponding id_rstate from cache.
void sort_strings_by_size(strings &ids)
Sort vectors of strings to largest length string first. (Or use set<>).
Named render state. Datum to take id string and tie it to visual representation.
bool is_visible(const select v) const
Datum consolidating style preferences.