FuncSketch
Loading...
Searching...
No Matches
plot_config.h
Go to the documentation of this file.
1/*
2 * Copyright 2026 MusicScience37 (Kenta Kabashima)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
20#pragma once
21
22#include <cstddef>
23
25
26namespace func_sketch::plotter {
27
28// TODO Tune these values
29
31constexpr int default_left_margin = 60;
32
34constexpr int default_right_margin = 60;
35
37constexpr int default_top_margin = 50;
38
40constexpr int default_bottom_margin = 50;
41
44
46constexpr int default_axes_line_width = 1;
47
49constexpr int default_grid_line_width = 1;
50
52constexpr int default_zero_line_width = 2;
53
55constexpr int default_curve_line_width = 1;
56
59 RGBColor{.r = 255, .g = 255, .b = 255};
60
62constexpr auto default_axes_color = RGBColor{.r = 0x24, .g = 0x24, .b = 0x24};
63
65constexpr auto default_grid_color = RGBColor{.r = 0xC8, .g = 0xC8, .b = 0xC8};
66
68constexpr std::size_t default_initial_num_sample_points = 110;
69
71constexpr std::size_t default_max_num_sample_points = 2000;
72
74constexpr std::size_t max_max_num_sample_points = 10000;
75
77constexpr double default_max_coordinate_change_rate = 0.01;
78
80constexpr double default_slope_change_threshold = 0.1;
81
83constexpr double default_min_param_change_rate = 0.001;
84
86constexpr double min_min_param_change_rate = 1e-4;
87
89constexpr std::size_t default_num_pixels_per_tick_in_x_axis = 120;
90
92constexpr std::size_t default_num_pixels_per_tick_in_y_axis = 100;
93
98public:
102 PlotConfig() = default;
103
110 PlotConfig& left_margin(int value);
111
118 PlotConfig& right_margin(int value);
119
126 PlotConfig& top_margin(int value);
127
134 PlotConfig& bottom_margin(int value);
135
143
150 PlotConfig& axes_line_width(int value);
151
158 PlotConfig& grid_line_width(int value);
159
166 PlotConfig& zero_line_width(int value);
167
174 PlotConfig& curve_line_width(int value);
175
182 PlotConfig& background_color(const RGBColor& value);
183
190 PlotConfig& axes_color(const RGBColor& value);
191
198 PlotConfig& grid_color(const RGBColor& value);
199
208 PlotConfig& initial_num_sample_points(std::size_t value);
209
223 PlotConfig& max_num_sample_points(std::size_t value);
224
234
243 PlotConfig& slope_change_threshold(double value);
244
255 PlotConfig& min_param_change_rate(double value);
256
263 PlotConfig& num_pixels_per_tick_in_x_axis(std::size_t value);
264
271 PlotConfig& num_pixels_per_tick_in_y_axis(std::size_t value);
272
278 [[nodiscard]] int left_margin() const noexcept;
279
285 [[nodiscard]] int right_margin() const noexcept;
286
292 [[nodiscard]] int top_margin() const noexcept;
293
299 [[nodiscard]] int bottom_margin() const noexcept;
300
306 [[nodiscard]] int tick_label_font_size() const noexcept;
307
313 [[nodiscard]] int axes_line_width() const noexcept;
314
320 [[nodiscard]] int grid_line_width() const noexcept;
321
327 [[nodiscard]] int zero_line_width() const noexcept;
328
334 [[nodiscard]] int curve_line_width() const noexcept;
335
341 [[nodiscard]] const RGBColor& background_color() const noexcept;
342
348 [[nodiscard]] const RGBColor& axes_color() const noexcept;
349
355 [[nodiscard]] const RGBColor& grid_color() const noexcept;
356
363 [[nodiscard]] std::size_t initial_num_sample_points() const noexcept;
364
371 [[nodiscard]] std::size_t max_num_sample_points() const noexcept;
372
380 [[nodiscard]] double max_coordinate_change_rate() const noexcept;
381
389 [[nodiscard]] double slope_change_threshold() const noexcept;
390
396 [[nodiscard]] double min_param_change_rate() const noexcept;
397
403 [[nodiscard]] std::size_t num_pixels_per_tick_in_x_axis() const noexcept;
404
410 [[nodiscard]] std::size_t num_pixels_per_tick_in_y_axis() const noexcept;
411
412private:
415
418
421
424
427
430
433
436
439
442
445
448
451
454
458
462
465
469
473};
474
475} // namespace func_sketch::plotter
const RGBColor & background_color() const noexcept
Get the color of background.
int left_margin_
Left margin of plots in pixels.
RGBColor grid_color_
Color of grid lines.
std::size_t num_pixels_per_tick_in_y_axis_
Number of pixels per tick in the y-axis.
PlotConfig & max_coordinate_change_rate(double value)
Set the threshold of the change in coordinates of sample points relative to the plot range in adaptiv...
int right_margin() const noexcept
Get the right margin of plots in pixels.
double min_param_change_rate() const noexcept
Get the minimum rate of parameter change in adaptive sampling.
int grid_line_width_
Line width of grid lines in pixels.
PlotConfig()=default
Constructor.
std::size_t num_pixels_per_tick_in_x_axis_
Number of pixels per tick in the x-axis.
std::size_t num_pixels_per_tick_in_y_axis() const noexcept
Get the number of pixels per tick in the y-axis.
int right_margin_
Right margin of plots in pixels.
std::size_t max_num_sample_points() const noexcept
Get the maximum number of points to sample in adaptive sampling.
PlotConfig & initial_num_sample_points(std::size_t value)
Set the number of points to sample initially in adaptive sampling.
PlotConfig & slope_change_threshold(double value)
Set the threshold of the change in slope normalized by the plot range in adaptive sampling.
int zero_line_width_
Line width of the grid line at zero in pixels.
int grid_line_width() const noexcept
Get the line width of grid lines in pixels.
std::size_t initial_num_sample_points_
Number of points to sample initially in adaptive sampling.
PlotConfig & top_margin(int value)
Set the top margin of plots in pixels.
std::size_t num_pixels_per_tick_in_x_axis() const noexcept
Get the number of pixels per tick in the x-axis.
PlotConfig & right_margin(int value)
Set the right margin of plots in pixels.
int bottom_margin_
Bottom margin of plots in pixels.
PlotConfig & num_pixels_per_tick_in_y_axis(std::size_t value)
Set the number of pixels per tick in the y-axis.
PlotConfig & tick_label_font_size(int value)
Set the font size of tick labels in pixels.
PlotConfig & grid_line_width(int value)
Set the line width of grid lines in pixels.
PlotConfig & zero_line_width(int value)
Set the line width of the grid line at zero in pixels.
PlotConfig & num_pixels_per_tick_in_x_axis(std::size_t value)
Set the number of pixels per tick in the x-axis.
int axes_line_width() const noexcept
Get the line width of axes in pixels.
int zero_line_width() const noexcept
Get the line width of the grid line at zero in pixels.
std::size_t max_num_sample_points_
Maximum number of points to sample in adaptive sampling.
double max_coordinate_change_rate() const noexcept
Get the threshold of the change in coordinates of sample points relative to the plot range in adaptiv...
RGBColor axes_color_
Color of axes.
RGBColor background_color_
Color of background.
PlotConfig & axes_line_width(int value)
Set the line width of axes in pixels.
PlotConfig & axes_color(const RGBColor &value)
Set the color of axes.
PlotConfig & curve_line_width(int value)
Set the line width of curves in pixels.
int curve_line_width() const noexcept
Get the line width of curves in pixels.
int curve_line_width_
Line width of curves in pixels.
int bottom_margin() const noexcept
Get the bottom margin of plots in pixels.
int top_margin() const noexcept
Get the top margin of plots in pixels.
int tick_label_font_size() const noexcept
Get the font size of tick labels in pixels.
PlotConfig & max_num_sample_points(std::size_t value)
Set the maximum number of points to sample in adaptive sampling.
int axes_line_width_
Line width of axes in pixels.
const RGBColor & grid_color() const noexcept
Get the color of grid lines.
double slope_change_threshold() const noexcept
Get the threshold of the change in slope normalized by the plot range in adaptive sampling.
std::size_t initial_num_sample_points() const noexcept
Get the number of points to sample initially in adaptive sampling.
double min_param_change_rate_
Minimum rate of parameter change in adaptive sampling.
int tick_label_font_size_
Font size of tick labels in pixels.
PlotConfig & min_param_change_rate(double value)
Set the minimum rate of parameter change in adaptive sampling.
int left_margin() const noexcept
Get the left margin of plots in pixels.
PlotConfig & bottom_margin(int value)
Set the bottom margin of plots in pixels.
PlotConfig & background_color(const RGBColor &value)
Set the color of background.
int top_margin_
Top margin of plots in pixels.
PlotConfig & grid_color(const RGBColor &value)
Set the color of grid lines.
const RGBColor & axes_color() const noexcept
Get the color of axes.
constexpr double min_min_param_change_rate
Minimum value of the minimum rate of parameter change in adaptive sampling for safety limit of memory...
Definition plot_config.h:86
constexpr int default_curve_line_width
Default line width of curves in pixels.
Definition plot_config.h:55
constexpr double default_min_param_change_rate
Default minimum rate of parameter change in adaptive sampling.
Definition plot_config.h:83
constexpr int default_axes_line_width
Default line width of axes in pixels.
Definition plot_config.h:46
constexpr double default_max_coordinate_change_rate
Default threshold of the change in coordinates of sample points relative to the plot range in adaptiv...
Definition plot_config.h:77
constexpr int default_left_margin
Default left margin in pixels.
Definition plot_config.h:31
constexpr auto default_grid_color
Default color of grid lines.
Definition plot_config.h:65
constexpr double default_slope_change_threshold
Default threshold of the change in slope normalized by the plot range in adaptive sampling.
Definition plot_config.h:80
constexpr std::size_t max_max_num_sample_points
Maximum value of the maximum number of points to sample in adaptive sampling for safety limit of memo...
Definition plot_config.h:74
constexpr std::size_t default_initial_num_sample_points
Default number of points to sample initially in adaptive sampling.
Definition plot_config.h:68
constexpr int default_tick_label_font_size
Default font size of tick labels in pixels.
Definition plot_config.h:43
constexpr int default_grid_line_width
Default line width of grid lines in pixels.
Definition plot_config.h:49
constexpr int default_zero_line_width
Default line width of the grid line at zero in pixels.
Definition plot_config.h:52
constexpr auto default_background_color
Default color of background.
Definition plot_config.h:58
constexpr std::size_t default_num_pixels_per_tick_in_x_axis
Default number of pixels per tick in the x-axis.
Definition plot_config.h:89
constexpr int default_top_margin
Default top margin in pixels.
Definition plot_config.h:37
constexpr std::size_t default_num_pixels_per_tick_in_y_axis
Default number of pixels per tick in the y-axis.
Definition plot_config.h:92
constexpr auto default_axes_color
Default color of axes.
Definition plot_config.h:62
constexpr int default_bottom_margin
Default bottom margin in pixels.
Definition plot_config.h:40
constexpr int default_right_margin
Default right margin in pixels.
Definition plot_config.h:34
constexpr std::size_t default_max_num_sample_points
Default maximum number of points to sample in adaptive sampling.
Definition plot_config.h:71
Definition of RGBColor struct.
Struct of RGB color.
Definition rgb_color.h:31