86 lines
2.8 KiB
C++
86 lines
2.8 KiB
C++
#pragma once
|
|
#include "global.h"
|
|
#include "../base/Color.h"
|
|
#include "../base/Geometry.h"
|
|
#include "../base/String_Format.h"
|
|
#include "../base/Style.h"
|
|
#include "../base/Text.h"
|
|
#include <string>
|
|
namespace renderive {
|
|
struct Axis_Render_Access;
|
|
struct Abs_Axis_Prop {
|
|
int x{};
|
|
int y{};
|
|
Orientation orientation = Orientation::Horizontal;
|
|
int tick_length = 10;
|
|
int sub_tick_length = 5;
|
|
double coord_start = 0;
|
|
double coord_length = 20;
|
|
Color color = Color::white();
|
|
Number_Locale locale;
|
|
std::string unit_text = "";
|
|
Font unit_text_font;
|
|
Pen unit_text_pen = Pen{.color = Color::white()};
|
|
Brush unit_text_background_brush = Brush{.color = Color::black()};
|
|
int label_rotation_degrees = 0;
|
|
};
|
|
struct Abs_Axis_Private;
|
|
class LIB_DECL Abs_Axis : public Renderable {
|
|
public:
|
|
Render_Object_Owner create_render_data() override;
|
|
Render_Object_Owner create_render_state() override;
|
|
Render_Object_Owner create_input_data() override;
|
|
Abs_Axis();
|
|
PROP(int, x)
|
|
PROP(int, y)
|
|
PROP(Orientation, orientation)
|
|
PROP(size_t, pixel_length)
|
|
PROP(int, tick_length)
|
|
PROP(int, sub_tick_length)
|
|
PROP(Color, color)
|
|
PROP(Number_Locale, locale)
|
|
PROP(std::string, unit_text)
|
|
PROP(Font, unit_text_font)
|
|
PROP(Pen, unit_text_pen)
|
|
PROP(Brush, unit_text_background_brush)
|
|
PROP(int, label_rotation_degrees)
|
|
[[nodiscard]] virtual double pixel_to_coord(double pixel);
|
|
[[nodiscard]] virtual double coord_to_pixel(double coord);
|
|
[[nodiscard]] virtual double tick_step(const Range& range);
|
|
[[nodiscard]] virtual int sub_tick_count(double tick_step);
|
|
virtual std::string tick_label(double tick);
|
|
virtual std::vector<double> create_tick_vector(double tick_step, const Range& range);
|
|
virtual std::vector<double> create_sub_tick_vector(int sub_tick_count, const std::vector<double>& ticks, const Range& range);
|
|
virtual std::vector<std::string> create_label_vector(const std::vector<double>& ticks);
|
|
double start_coord();
|
|
double end_coord();
|
|
Range coord_range();
|
|
int pixel_sample_count(Range range);
|
|
int pixel_sample_count();
|
|
template <typename That>
|
|
struct Builder_T;
|
|
private:
|
|
friend struct Axis_Render_Access;
|
|
Abs_Axis_Private* d();
|
|
};
|
|
template <typename That>
|
|
struct Abs_Axis::Builder_T : protected Abs_Axis_Prop {
|
|
PROP_BT(int, x)
|
|
PROP_BT(int, y)
|
|
PROP_BT(Orientation, orientation)
|
|
PROP_BT(size_t, pixel_length)
|
|
PROP_BT(int, tick_length)
|
|
PROP_BT(int, sub_tick_length)
|
|
PROP_BT(Color, color)
|
|
PROP_BT(Number_Locale, locale)
|
|
PROP_BT(std::string, unit_text)
|
|
PROP_BT(Font, unit_text_font)
|
|
PROP_BT(Pen, unit_text_pen)
|
|
PROP_BT(Brush, unit_text_background_brush)
|
|
PROP_BT(int, label_rotation_degrees)
|
|
std::shared_ptr<Renderable> parent{};
|
|
size_t pixel_size{};
|
|
void set(Abs_Axis* ret);
|
|
};
|
|
} // namespace renderive
|