19#ifndef MiL_SVG_RADIAL_BASE_H
20#define MiL_SVG_RADIAL_BASE_H 1
47 static point_2t rrange = { 10, 350 };
57 auto& min = std::get<0>(rrange);
58 auto& max = std::get<1>(rrange);
81 if (rot == k::rrotation::cw)
83 if (rot == k::rrotation::ccw)
98 const double minadjust = 0.25)
109 double angle(minadjust);
110 const double arg((dist / 2) / r);
113 double angler = std::asin(arg);
114 angle = angler * (180.0 / k::pi);
166 const uint valuewidth = 9)
169 std::ostringstream oss;
170 oss.imbue(std::locale(
""));
171 oss << std::setfill(
' ') << std::setw(valuewidth)
172 << std::left << pvalue;
174 string label = oss.str() +
" -> " + pname;
183 auto lsizeless = [](
const string& s1,
const string& s2)
184 {
return s1.size() < s2.size(); };
185 sort(ids.begin(), ids.end(), lsizeless);
192 const point_2t origin,
const double deg)
205 const point_2t origin,
const double deg)
257 const int r,
const point_2t origin,
const double deg,
258 const bool roriginp =
false)
300 const strings& ids,
const double angled,
301 const point_2t origin,
double r,
double rspace,
302 const bool satellitep =
false)
310 const double maxdeg = angleprimed * (ids.size() - 1);
311 double angled2 = angled - (maxdeg / 2);
314 double rlabel = r + rspace;
315 double rprime = rlabel + (rspace * 2);
316 for (
const string& s: ids)
322 auto rring = rspace / 2;
329 angled2 += angleprimed;
337 const strings& ids,
const double angledo,
338 const point_2t origin,
double r,
double rspace)
340 double angledelta = typo.
_M_size;
341 double angled(angledo);
342 for (
const string& s: ids)
345 angled -= angledelta;
353 const strings& ids,
const double angled,
354 const point_2t origin,
double r,
double rspace)
358 auto imiddle = ids.begin() + (ids.size() / 2);
359 strings ids1(ids.begin(), imiddle);
360 strings ids2(imiddle, ids.end());
373 const strings& ids,
const double angled,
374 const point_2t origin,
double r,
const double rdelta = 10)
381 for (
const string& s: ids)
393 const strings& ids,
const double angled,
398 for (
const string& s: ids)
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.
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.
void styled_text_r(element_base &obj, const string text, const point_2t origin, const typography typo, const double deg)
Text at.
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, space_type defaults to double.
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.