19#ifndef MiL_SVG_RADIAL_BASE_H
20#define MiL_SVG_RADIAL_BASE_H 1
58 static point_2t rrange = { 10, 350 };
68 auto& min = std::get<0>(rrange);
69 auto& max = std::get<1>(rrange);
92 if (rot == k::rrotation::cw)
94 if (rot == k::rrotation::ccw)
109 const double minadjust = 0.25)
120 double angle(minadjust);
121 const double arg((dist / 2) / r);
124 double angler = std::asin(arg);
125 angle = angler * (180.0 / k::pi);
177 const uint valuewidth = 9)
180 std::ostringstream oss;
181 oss.imbue(std::locale(
""));
182 oss << std::setfill(
' ') << std::setw(valuewidth)
183 << std::left << pvalue;
185 string label = oss.str() +
" -> " + pname;
194 auto lsizeless = [](
const string& s1,
const string& s2)
195 {
return s1.size() < s2.size(); };
196 sort(ids.begin(), ids.end(), lsizeless);
203 const point_2t origin,
const double deg)
216 const point_2t origin,
const double deg)
268 const int r,
const point_2t origin,
const double deg,
269 const bool roriginp =
false)
311 const strings& ids,
const double angled,
312 const point_2t origin,
double r,
double rspace,
313 const bool satellitep =
false)
321 const double maxdeg = angleprimed * (ids.size() - 1);
322 double angled2 = angled - (maxdeg / 2);
325 double rlabel = r + rspace;
326 double rprime = rlabel + (rspace * 2);
327 for (
const string& s: ids)
333 auto rring = rspace / 2;
340 angled2 += angleprimed;
348 const strings& ids,
const double angledo,
349 const point_2t origin,
double r,
double rspace)
351 double angledelta = typo.
_M_size;
352 double angled(angledo);
353 for (
const string& s: ids)
356 angled -= angledelta;
364 const strings& ids,
const double angled,
365 const point_2t origin,
double r,
double rspace)
369 auto imiddle = ids.begin() + (ids.size() / 2);
370 strings ids1(ids.begin(), imiddle);
371 strings ids2(imiddle, ids.end());
384 const strings& ids,
const double angled,
385 const point_2t origin,
double r,
const double rdelta = 10)
392 for (
const string& s: ids)
404 const strings& ids,
const double angled,
409 for (
const string& s: ids)
rrotation
Radial rotation direction.
double zero_angle_north_ccw(double angled)
Zero degrees is top, going clockwise (cw).
uint significant_digits_in(ssize_type maxval)
The number of significant digits in.
void append_ids_at(svg_element &obj, const typography &typo, const strings &ids, const double angled, const point_2t origin, double r)
Concatenate ids onto one line.
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)
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).
double get_angle(ssize_type pvalue, ssize_type pmax)
Transform a value on a range to an angle on the radial range.
point_2t set_radial_range(const space_type rmin, const space_type rmax)
Convenience for setting radial range.
void radial_text_cw(svg_element &obj, string text, const typography &typo, const point_2t origin, const double deg)
Text with typography, arranged cw around points (x,y) on a circle.
void styled_text_r(svg_element &obj, const string text, const point_2t origin, const typography typo, const double deg)
Text at.
double scale_value_on_range(const ssize_type value, const ssize_type min, const ssize_type max, const ssize_type nfloor, const ssize_type nceil)
Scale value from min to max on range (nfloor, nceil).
point_2t & get_radial_range()
double adjust_angle_at_orbit_for_distance(double r, double dist, const double minadjust=0.25)
string make_label_for_value(string pname, ssize_type pvalue, const uint valuewidth=9)
Make radial labels.
double zero_angle_north_cw(double angled)
Zero degrees is top, going clockwise (cw).
double space_type
Base floating point type.
void splay_ids_around(svg_element &obj, const typography &typo, const strings &ids, const double angled, const point_2t origin, double r, double rspace, const bool satellitep=false)
Spread ids on either side of an origin point, along circumference path.
double adjust_angle_rotation(const double dorig, const k::rrotation rot)
Adjust angle above to CW/CCW orientation.
void splay_ids_after(svg_element &obj, const typography &typo, const strings &ids, const double angledo, const point_2t origin, double r, double rspace)
Spread ids past the origin point, along circumference path.
void splay_ids_stagger(svg_element &obj, const typography &typo, const strings &ids, const double angled, const point_2t origin, double r, double rspace)
Spread ids after in stepping pattern outward.
point_2t get_circumference_point_d(const double ad, const double r, const point_2t origin)
Angle in degrees.
space_type distance_cartesian(const point_2t &p1, const point_2t &p2)
Find cartesian distance between two 2D points.
void set_label_spaces(ssize_type spaces)
Set the number of label spaces.
void stack_ids_at(svg_element &obj, const typography &typoo, const strings &ids, const double angled, const point_2t origin, double r, const double rdelta=10)
Rotate and stack ids at origin point, extending radius for each from point of origin.
void radial_text_ccw(svg_element &obj, string text, const typography &typo, const point_2t origin, const double deg)
Text with typography, arranged ccw around points (x,y) on a circle.
std::tuple< space_type, space_type > point_2t
Point (x,y) in 2D space.
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.
Datum consolidating style preferences.
@ central
For rotated text.
@ right
Right part of text block.
@ left
Left-most part of text block.
@ end
End the text block at point.
@ start
Start the text block at point.