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);
84 int glyphr = rbase + linelen + rspace;
85 typography typob(typo);
87 radial_text_r(obj, std::to_string(v), typob, glyphr, origin, angled);
88 return glyphr - rstart;
98 const int kr,
const int rspace,
const int rstart)
106 const string glyphtext = idst.
name;
107 const double glyphscale = idst.
multiple;
108 const double glyphrotate = idst.
rotate;
119 const double scale(kra * 2 / glyphscale);
120 const double scaledsize =
scale * 100;
121 const double scaledglyph =
scale * glyphscale;
122 const double svgr = rstart + rspace + (scaledglyph / 2);
126 insert_svg_at(obj, isvg, p, 100, scaledsize, angleda + glyphrotate,
128 glyphr += scaledsize;
133 const int vr = rstart + rspace + kra;
158 const double angled,
const double kr,
const int rspace,
159 const int rstart,
const string id,
const typography& typo)
167 glyphr +=
radiate_glyph(obj, origin, angled, idst, kr, rspace, rstart);
172 const int idr = rstart + glyphr + rspace;
178 const string playingabv(
" -> ");
179 if (
id.find(playingabv) != string::npos)
200 const int radius,
const int rspace,
const int rstart,
203 const double angled =
get_angle(v, value_max);
204 const double kr((
double(v) / value_max) * radius);
223 const int radius,
const int rspace,
const int rstart,
226 const bool wbyvaluep,
const bool satellitep =
false)
229 const double angled =
get_angle(v, value_max);
232 rspace, rstart, linelen, typo);
242 rstart + glyphr,
"", typo);
247 const double ar = rstart + glyphr;
254 kr = ((double(v) / value_max) * radius);
263 const double distnce = k + (kr * 2);
264 const double sr = ar + rspace + kr;
268 const double maxdeg = anglea * (ids.size() - 1);
269 double angled2 = angled - (maxdeg / 2);
271 for (
const string&
id : ids)
274 kr, rspace, ar,
id, typo);
276 constexpr bool debugp =
false;
288 maxglyphr2 = std::max(maxglyphr2, glyphr2);
290 glyphr += maxglyphr2;
304 const int radius,
const int rspace,
const int rstart,
309 const double angled =
get_angle(v, value_max);
316 rspace, rstart, linelen, typo);
322 rstart + glyphr, ids.front(), typo);
324 constexpr bool debugp =
false;
339 radius, rspace, rstart, linelen, typo, wbyvaluep,
349 const int radius,
const int rspace,
const int rstart,
351 const typography& typo,
const bool weighbyvaluep)
356 linelen, typo, weighbyvaluep);
359 constexpr bool overlayrayp =
false;
363 const double angled =
get_angle(v, value_max);
365 radius * 4, typo, rstyl);
369 constexpr bool showmaxvp =
true;
372 const double anglemax =
get_angle(value_max, value_max);
402 std::vector<ssize_type>& vuvalues,
vvstrings& vids,
404 const int radius,
const int rspace,
const int rstart,
405 const typography& typo,
const bool weighbyvaluep,
407 const int startlenm = 5)
411 std::vector<ssize_type> vuvaluesnear;
413 const int startlen = radius * startlenm;
414 const int linelen = rspace * 2;
421 for (
uint i = 0; i < vuvalues.size(); ++i)
425 const bool finalp = i + 1 == vuvalues.size();
426 const bool firstp = i == 0;
435 if (std::abs(v - vold) > (value_max / 4))
444 const bool lastyesp = !firstp && (v - threshold <= vuvalues[i - 1]);
445 const bool nextyesp = !finalp && (v + threshold >= vuvalues[i + 1]);
446 const bool firstyesp = firstp && \
447 (v + std::abs(value_max - vuvalues.back()) <= threshold);
448 if (!skip && (nextyesp || lastyesp || firstyesp))
451 rstart + startlen - linelen, linelen, typo,
457 vidsnear.push_back(ids);
458 vuvaluesnear.push_back(v);
465 vuvalues = vuvaluesnear;
487 const int rspace,
const bool weighbyvaluep =
true,
488 const bool collisionp =
false,
489 const bool sortstringsbysizep =
false)
504 std::vector<ssize_type> vuvalues(uvalues.begin(), uvalues.end());
505 std::vector<strings> vids;
506 for (
const auto& v : vuvalues)
509 auto irange = uvaluemm.equal_range(v);
510 auto ibegin = irange.first;
511 auto iend = irange.second;
513 for (
auto i = ibegin; i != iend; ++i)
514 ids.push_back(i->second);
515 if (sortstringsbysizep)
518 sort(ids.begin(), ids.end());
523 if (vuvalues.front() == 0)
526 std::clog <<
"eliding ids with value zero: " << std::endl;
527 for (
const auto& s: ids)
528 std::clog << s << std::endl;
529 vuvalues.erase(vuvalues.begin());
530 vids.erase(vids.begin());
537 if (collisionp && vuvalues.size() > 1)
541 if (value_max >= 20 && value_max < 190)
543 if (value_max >= 190 && value_max < 290)
545 if (value_max >= 290)
549 radius, rspace, radius, typo, weighbyvaluep,
554 for (
uint i = 0; i < vuvalues.size(); ++i)
558 int j = vuvalues.size() - 1 - i;
560 auto v = vuvalues[j];
563 radius, rspace, radius, rspace, typo, weighbyvaluep);
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...
void point_to_circle(svg_element &obj, const point_2t origin, style s, const space_type r=4, const string xform="")
Draws a circle around a point (x,y), of style (s), of radius (r).
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)
@ vector
svg path, circle, rectangle, etc.
@ svg
svg element, perhaps nested
void points_to_line(svg_element &obj, const style s, const point_2t origin, const point_2t end, const string dasharray="")
Line between two points.
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...
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.
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.