| 66 | } |
| 67 | |
| 68 | std::string labels::data_string() { |
| 69 | // in absolute size, the rectangles match the words when |
| 70 | // the ranges are x [-17;+17], y [-17,+17] |
| 71 | // if the ranges are smaller than that, we increase the font size |
| 72 | // if the ranges are larger than that, we reduce the font size |
| 73 | double font_size_factor = 1.0; |
| 74 | if (!absolute_size_) { |
| 75 | auto [xmin, xmax, ymin, ymax] = parent_->child_limits(); |
| 76 | if (parent_->x_axis().limits_mode_manual()) { |
| 77 | auto [axmin, axmax] = parent_->x_axis().limits(); |
| 78 | if (std::isfinite(axmin)) { |
| 79 | xmin = std::min(xmin, axmin); |
| 80 | } |
| 81 | if (std::isfinite(axmax)) { |
| 82 | xmax = std::max(xmax, axmax); |
| 83 | } |
| 84 | } |
| 85 | if (parent_->y_axis().limits_mode_manual()) { |
| 86 | auto [aymin, aymax] = parent_->y_axis().limits(); |
| 87 | if (std::isfinite(aymin)) { |
| 88 | ymin = std::min(ymin, aymin); |
| 89 | } |
| 90 | if (std::isfinite(aymax)) { |
| 91 | ymax = std::max(ymax, aymax); |
| 92 | } |
| 93 | } |
| 94 | double xrange = xmax - xmin; |
| 95 | double yrange = ymax - ymin; |
| 96 | double xrange_increase = xrange / 34; |
| 97 | double yrange_increase = yrange / 34; |
| 98 | font_size_factor = (xrange_increase + yrange_increase) / 2.; |
| 99 | } |
| 100 | std::stringstream ss; |
| 101 | ss.precision(10); |
| 102 | ss << std::fixed; |
| 103 | const bool custom_sizes = !sizes_.empty(); |
| 104 | const bool custom_colors = !colors_.empty(); |
| 105 | for (size_t i = 0; i < labels_.size(); ++i) { |
| 106 | ss << " " << x_[i] << " " << y_[i] << " \""; |
| 107 | if (custom_sizes) { |
| 108 | ss << "{/=" << round(sizes_[i] / font_size_factor) << " "; |
| 109 | } |
| 110 | ss << escape(labels_[i]); |
| 111 | if (custom_sizes) { |
| 112 | ss << "}"; |
| 113 | } |
| 114 | ss << "\" "; |
| 115 | if (custom_colors) { |
| 116 | ss << colors_[i]; |
| 117 | } |
| 118 | ss << "\n"; |
| 119 | } |
| 120 | ss << "e\n"; |
| 121 | return ss.str(); |
| 122 | } |
| 123 | |
| 124 | std::string labels::unset_variables_string() { |
| 125 | std::string res; |
nothing calls this directly
no test coverage detected