From 64da97b7c75e4e6f9619a2b064d5bcb48975bf1d Mon Sep 17 00:00:00 2001 From: wyc <1104749580@qq.com> Date: Sun, 2 Aug 2026 12:02:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=8B=A5=E5=B9=B2bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Core/Axis/Time_Axis.cpp | 6 ++-- Core/Axis/Time_Axis.h | 2 +- Core/base/Memory.h | 2 +- Core/plottable/Constellation_Diagram.cpp | 46 ++++++++++++------------ Core/plottable/Constellation_Diagram_p.h | 30 ++++++++-------- Core/plottable/Spectrum.cpp | 2 +- Core/plottable/Waterfall_p.h | 40 +++++++-------------- Core/primitive/Curve.cpp | 2 +- main.cmake | 4 +-- 9 files changed, 60 insertions(+), 74 deletions(-) diff --git a/Core/Axis/Time_Axis.cpp b/Core/Axis/Time_Axis.cpp index 3e59e32..38623b6 100644 --- a/Core/Axis/Time_Axis.cpp +++ b/Core/Axis/Time_Axis.cpp @@ -2,10 +2,10 @@ #include "../base/Memory.h" namespace renderive { RENDERIVE_DEFINE_RENDERABLE_BINDING(Time_Axis, Time_Axis_Private, Time_Axis_Render_State, Time_Axis_Input_Data, "time_axis") -int Time_Axis::time_point_size() { +int Time_Axis::visible_time_point_count() { return d()->edit_state_value(&Time_Axis_Render_State::visible_time_point_count); } -void Time_Axis::set_time_point_size(int value) { +void Time_Axis::set_visible_time_point_count(int value) { value = std::max(1, value); d()->set_state_value(&Time_Axis_Render_State::visible_time_point_count, value); } @@ -42,7 +42,7 @@ int Time_Axis::append_time(Time_Of_Day time) { Time_Of_Day Time_Axis::tick_to_time(int tick) { auto stream = timeline_stream(); if (stream) - return stream->capture(time_point_size(), d()->state_data(State_Edit)->label_tick_interval_hint(), start_coord_to_end_coord()).time_by_tick(tick); + return stream->capture(visible_time_point_count(), d()->state_data(State_Edit)->label_tick_interval_hint(), start_coord_to_end_coord()).time_by_tick(tick); return d()->time_by_tick(tick); } Time_Axis::Builder::Builder(std::shared_ptr parent, Orientation orientation) { diff --git a/Core/Axis/Time_Axis.h b/Core/Axis/Time_Axis.h index 21036ab..655b7cc 100644 --- a/Core/Axis/Time_Axis.h +++ b/Core/Axis/Time_Axis.h @@ -15,7 +15,7 @@ public: Render_Object_Owner create_render_state() override; Render_Object_Owner create_input_data() override; Time_Axis(); - PROP(int, time_point_size) + PROP(int, visible_time_point_count) PROP(int, tick_label_spacing_px) PROP(std::string, time_format) PROP(Font, font) diff --git a/Core/base/Memory.h b/Core/base/Memory.h index d6fba07..d353f79 100644 --- a/Core/base/Memory.h +++ b/Core/base/Memory.h @@ -44,7 +44,7 @@ enum class Memory_Domain : std::uint8_t { /// @brief Afterglow data and rendering storage. Afterglow, /// @brief Planisphere data and rendering storage. - Planisphere, + Constellation_Diagram, /// @brief Curve data and rendering storage. Curve, /// @brief Point-set data and rendering storage. diff --git a/Core/plottable/Constellation_Diagram.cpp b/Core/plottable/Constellation_Diagram.cpp index 258ec33..c148d79 100644 --- a/Core/plottable/Constellation_Diagram.cpp +++ b/Core/plottable/Constellation_Diagram.cpp @@ -4,69 +4,69 @@ #include "../base/Memory.h" #include "Constellation_Diagram_p.h" namespace renderive { -RENDERIVE_DEFINE_RENDERABLE_BINDING(Constellation_Diagram, Constellation_Diagram_Private, Planisphere_Render_State, Planisphere_Input_Data, "Planisphere") +RENDERIVE_DEFINE_RENDERABLE_BINDING(Constellation_Diagram, Constellation_Diagram_Private, Constellation_Diagram_State, Constellation_Diagram_Input_Data, "Planisphere") std::shared_ptr Constellation_Diagram::i_axis() { - return d()->edit_state_value(&Planisphere_Render_State::i_axis).lock(); + return d()->edit_state_value(&Constellation_Diagram_State::i_axis).lock(); } void Constellation_Diagram::set_i_axis(std::shared_ptr value) { - d()->set_state_value(&Planisphere_Render_State::i_axis, std::weak_ptr(value)); + d()->set_state_value(&Constellation_Diagram_State::i_axis, std::weak_ptr(value)); } std::shared_ptr Constellation_Diagram::q_axis() { - return d()->edit_state_value(&Planisphere_Render_State::q_axis).lock(); + return d()->edit_state_value(&Constellation_Diagram_State::q_axis).lock(); } void Constellation_Diagram::set_q_axis(std::shared_ptr value) { - d()->set_state_value(&Planisphere_Render_State::q_axis, std::weak_ptr(value)); + d()->set_state_value(&Constellation_Diagram_State::q_axis, std::weak_ptr(value)); } Range Constellation_Diagram::i_range() { - return d()->edit_state_value(&Planisphere_Render_State::i_range); + return d()->edit_state_value(&Constellation_Diagram_State::i_range); } void Constellation_Diagram::set_i_range(Range value) { if (value.length() == 0.0) return; - d()->set_state_value(&Planisphere_Render_State::i_range, std::move(value)); + d()->set_state_value(&Constellation_Diagram_State::i_range, std::move(value)); } Range Constellation_Diagram::q_range() { - return d()->edit_state_value(&Planisphere_Render_State::q_range); + return d()->edit_state_value(&Constellation_Diagram_State::q_range); } void Constellation_Diagram::set_q_range(Range value) { if (value.length() == 0.0) return; - d()->set_state_value(&Planisphere_Render_State::q_range, std::move(value)); + d()->set_state_value(&Constellation_Diagram_State::q_range, std::move(value)); } Color Constellation_Diagram::point_color() { - return d()->edit_state_value(&Planisphere_Render_State::point_color); + return d()->edit_state_value(&Constellation_Diagram_State::point_color); } void Constellation_Diagram::set_point_color(Color value) { - d()->set_state_value(&Planisphere_Render_State::point_color, std::move(value)); + d()->set_state_value(&Constellation_Diagram_State::point_color, std::move(value)); } Color Constellation_Diagram::anchor_color() { - return d()->edit_state_value(&Planisphere_Render_State::anchor_color); + return d()->edit_state_value(&Constellation_Diagram_State::anchor_color); } void Constellation_Diagram::set_anchor_color(Color value) { - d()->set_state_value(&Planisphere_Render_State::anchor_color, std::move(value)); + d()->set_state_value(&Constellation_Diagram_State::anchor_color, std::move(value)); } int Constellation_Diagram::point_lifetime_ms() { - return d()->edit_state_value(&Planisphere_Render_State::point_lifetime_ms); + return d()->edit_state_value(&Constellation_Diagram_State::point_lifetime_ms); } void Constellation_Diagram::set_point_lifetime_ms(int value) { - d()->set_state_value(&Planisphere_Render_State::point_lifetime_ms, std::max(1, value)); + d()->set_state_value(&Constellation_Diagram_State::point_lifetime_ms, std::max(1, value)); } Constellation_Diagram_Type Constellation_Diagram::type() { - return d()->edit_state_value(&Planisphere_Render_State::type); + return d()->edit_state_value(&Constellation_Diagram_State::type); } void Constellation_Diagram::set_type(Constellation_Diagram_Type value) { - d()->set_state_value(&Planisphere_Render_State::type, value); + d()->set_state_value(&Constellation_Diagram_State::type, value); } double Constellation_Diagram::phase_offset_radians() { - return d()->edit_state_value(&Planisphere_Render_State::phase_offset_radians); + return d()->edit_state_value(&Constellation_Diagram_State::phase_offset_radians); } void Constellation_Diagram::set_phase_offset_radians(double value) { - d()->set_state_value(&Planisphere_Render_State::phase_offset_radians, value); + d()->set_state_value(&Constellation_Diagram_State::phase_offset_radians, value); } void Constellation_Diagram::append_point(PointF pos) { if (!ok()) return; - Render_Input_Lease input(d()); + Render_Input_Lease input(d()); input->push(pos); } Constellation_Diagram::Builder::Builder(std::shared_ptr parent, std::shared_ptr i_axis, std::shared_ptr q_axis) { @@ -84,7 +84,7 @@ std::shared_ptr Constellation_Diagram::Builder::build() { auto ret = renderive::make_shared(); ret->init(parent); Constellation_Diagram_Private* pd = ret->d(); - Planisphere_Render_State* sc = reinterpret_cast(pd->state(State_Edit)); + Constellation_Diagram_State* sc = reinterpret_cast(pd->state(State_Edit)); PROP_R(std::weak_ptr, i_axis) PROP_R(std::weak_ptr, q_axis) PROP_R(Range, i_range) @@ -92,7 +92,7 @@ std::shared_ptr Constellation_Diagram::Builder::build() { PROP_R(Color, point_color) PROP_R(Color, anchor_color) PROP_R(int, point_lifetime_ms) - PROP_R(Planisphere_Type, type) + PROP_R(Constellation_Diagram_Type, type) PROP_R(double, phase_offset_radians) if (sc->i_range.length() == 0.0) sc->i_range = {0.0, 1.0}; @@ -102,7 +102,7 @@ std::shared_ptr Constellation_Diagram::Builder::build() { return ret; } void Constellation_Diagram::fit_square_to_axes() { - Planisphere_Render_State* s = reinterpret_cast(d()->state(State_Edit)); + Constellation_Diagram_State* s = reinterpret_cast(d()->state(State_Edit)); auto i_axis = s->i_axis.lock(); auto q_axis = s->q_axis.lock(); if (!i_axis || !q_axis) diff --git a/Core/plottable/Constellation_Diagram_p.h b/Core/plottable/Constellation_Diagram_p.h index dcd93a5..a5d3dcc 100644 --- a/Core/plottable/Constellation_Diagram_p.h +++ b/Core/plottable/Constellation_Diagram_p.h @@ -16,12 +16,12 @@ #include "../render/Canvas.h" #include "Constellation_Diagram.h" namespace renderive { -struct Planisphere_Data { +struct Constellation_Diagram_Data { PointF pos; std::uint64_t birth_time_ns{}; std::uint64_t expire_time_ns{}; }; -struct Planisphere_Input_Data : Input_Data { +struct Constellation_Diagram_Input_Data : Input_Data { static constexpr std::size_t Max_Pending_Point_Count = 128; struct Packet { double x{}; @@ -45,13 +45,13 @@ struct Planisphere_Input_Data : Input_Data { data_list.clear(); } }; -struct Planisphere_Render_State : Render_State, Planisphere_Prop {}; -struct Constellation_Diagram_Private : Typed_Render_Data { - std::pmr::list data_list{memory_resource(Memory_Domain::Planisphere)}; - std::pmr::vector prepared_points{memory_resource(Memory_Domain::Planisphere)}; - std::pmr::vector prepared_colors{memory_resource(Memory_Domain::Planisphere)}; - std::pmr::vector prepared_anchor_points{memory_resource(Memory_Domain::Planisphere)}; - std::pmr::vector anchor_points(const Planisphere_Render_State* s) const { +struct Constellation_Diagram_State : Render_State, Planisphere_Prop {}; +struct Constellation_Diagram_Private : Typed_Render_Data { + std::pmr::list data_list{memory_resource(Memory_Domain::Constellation_Diagram)}; + std::pmr::vector prepared_points{memory_resource(Memory_Domain::Constellation_Diagram)}; + std::pmr::vector prepared_colors{memory_resource(Memory_Domain::Constellation_Diagram)}; + std::pmr::vector prepared_anchor_points{memory_resource(Memory_Domain::Constellation_Diagram)}; + std::pmr::vector anchor_points(const Constellation_Diagram_State* s) const { std::pmr::vector points(frame_memory_resource()); const unsigned order = static_cast(s->type); if (order == 0) @@ -77,12 +77,12 @@ struct Constellation_Diagram_Private : Typed_Render_Data(std::max(1, s->point_lifetime_ms)) * 1000000ull; d->read_all([this, now_ns, lifetime_ns](const PointF& pos) { - Planisphere_Data data; + Constellation_Diagram_Data data; data.pos = pos; data.birth_time_ns = now_ns; data.expire_time_ns = now_ns + lifetime_ns; @@ -94,7 +94,7 @@ struct Constellation_Diagram_Private : Typed_Render_Data(data_list.size())); prepared_colors.reserve(static_cast(data_list.size())); - for (const Planisphere_Data& data : data_list) { + for (const Constellation_Diagram_Data& data : data_list) { Color color = s->point_color; const std::uint64_t total_ns = data.expire_time_ns > data.birth_time_ns ? data.expire_time_ns - data.birth_time_ns : 1; const std::uint64_t remain_ns = data.expire_time_ns > now_ns ? data.expire_time_ns - now_ns : 0; @@ -107,7 +107,7 @@ struct Constellation_Diagram_Private : Typed_Render_Datai_axis.lock(); auto q_axis = s->q_axis.lock(); if (!i_axis || !q_axis) diff --git a/Core/plottable/Spectrum.cpp b/Core/plottable/Spectrum.cpp index 58fc7bc..8673312 100644 --- a/Core/plottable/Spectrum.cpp +++ b/Core/plottable/Spectrum.cpp @@ -188,7 +188,7 @@ std::shared_ptr Spectrum::Builder::build() { PROP_R(bool, sweep_region_visible); PROP_R(bool, visible_range_only); PROP_R(Line_Interpolation_Mode, interpolation_mode); - PROP_R(Line_Sampling_Mode, sampling_strategy); + PROP_R(Line_Sampling_Strategy, sampling_strategy); PROP_R(Brush, max_brush); PROP_R(Brush, current_brush); PROP_R(Brush, min_brush); diff --git a/Core/plottable/Waterfall_p.h b/Core/plottable/Waterfall_p.h index 0d70637..2ce8f6a 100644 --- a/Core/plottable/Waterfall_p.h +++ b/Core/plottable/Waterfall_p.h @@ -85,7 +85,6 @@ struct Waterfall_Ring_Buffer { return value; } }; - struct Waterfall_Image_Cache_Key { int start_tick{}; int first_col{}; @@ -98,22 +97,20 @@ struct Waterfall_Image_Cache_Key { std::uint64_t color_map_hash{}; int width{}; int height{}; - bool operator==(const Waterfall_Image_Cache_Key& other) const { return start_tick == other.start_tick && - first_col == other.first_col && - last_col == other.last_col && - frequency_range == other.frequency_range && - power_range == other.power_range && - visible_range == other.visible_range && - background == other.background && - policy == other.policy && - color_map_hash == other.color_map_hash && - width == other.width && - height == other.height; + first_col == other.first_col && + last_col == other.last_col && + frequency_range == other.frequency_range && + power_range == other.power_range && + visible_range == other.visible_range && + background == other.background && + policy == other.policy && + color_map_hash == other.color_map_hash && + width == other.width && + height == other.height; } }; - struct Waterfall_Image_Snapshot { Waterfall_Image_Snapshot() : update_states(memory_resource(Memory_Domain::Update_Completion)) {} Waterfall_Image_Cache_Key key; @@ -123,7 +120,6 @@ struct Waterfall_Image_Snapshot { RectF source_rect{}; std::pmr::vector> update_states; }; - struct Waterfall_Image_Request { Waterfall_Image_Request() : rows(memory_resource(Memory_Domain::Waterfall)), @@ -135,19 +131,17 @@ struct Waterfall_Image_Request { int lower_stream_tick{}; int upper_stream_tick{}; int visible_time_count{}; - bool start_coord_to_end_coord{}; + bool newest_at_axis_start{}; Range draw_frequency_range{}; Range draw_time_range{}; RectF draw_source_rect{}; std::pmr::vector rows; std::pmr::vector> update_states; }; - struct Waterfall_Image_Tile { int y{}; Image image; }; - struct Waterfall_Image_Job { explicit Waterfall_Image_Job(std::shared_ptr request, int tile_count) : request(std::move(request)), remaining(tile_count) { @@ -157,7 +151,6 @@ struct Waterfall_Image_Job { std::vector tiles; std::atomic remaining; }; - static void complete_waterfall_request_states(Waterfall_Image_Request& request, std::error_code error, Update_Outcome outcome) { for (auto& state : request.update_states) { if (state) @@ -165,7 +158,6 @@ static void complete_waterfall_request_states(Waterfall_Image_Request& request, } request.update_states.clear(); } - static void complete_waterfall_result_states(Waterfall_Image_Snapshot& snapshot, std::error_code error, Update_Outcome outcome) { for (const auto& state : snapshot.update_states) { if (state) @@ -173,24 +165,21 @@ static void complete_waterfall_result_states(Waterfall_Image_Snapshot& snapshot, } snapshot.update_states.clear(); } - static bool waterfall_request_coord_by_stream_tick(const Waterfall_Image_Request& request, int stream_tick, int& coord) { if (request.visible_time_count <= 0) return false; if (stream_tick < request.lower_stream_tick || stream_tick > request.upper_stream_tick) return false; - if (request.start_coord_to_end_coord) + if (request.newest_at_axis_start) coord = request.key.start_tick + (request.upper_stream_tick - stream_tick); else coord = request.key.start_tick + (request.key.height - request.visible_time_count) + (stream_tick - request.lower_stream_tick); return coord >= request.key.start_tick && coord < request.key.start_tick + request.key.height; } - static int waterfall_tile_count(int height) { static constexpr int Tile_Height = 64; return std::max(1, (height + Tile_Height - 1) / Tile_Height); } - static void write_waterfall_tile(Waterfall_Image_Job& job, int tile_index) { const Waterfall_Image_Request& request = *job.request; int tile_count = static_cast(job.tiles.size()); @@ -220,14 +209,12 @@ static void write_waterfall_tile(Waterfall_Image_Job& job, int tile_index) { } } } - static Waterfall_Image_Snapshot build_waterfall_image_snapshot(const std::shared_ptr& request_ptr) { Waterfall_Image_Request& request = *request_ptr; int tile_count = waterfall_tile_count(request.key.height); Waterfall_Image_Job job(request_ptr, tile_count); for (int tile_index = 0; tile_index < tile_count; ++tile_index) write_waterfall_tile(job, tile_index); - Waterfall_Image_Snapshot snapshot; snapshot.key = request.key; snapshot.frequency_range = request.draw_frequency_range; @@ -245,7 +232,6 @@ static Waterfall_Image_Snapshot build_waterfall_image_snapshot(const std::shared snapshot.update_states = std::move(request.update_states); return snapshot; } - struct Waterfall_Private : Typed_Render_Data, Hit_Testable, Hover_Interactive { static constexpr std::size_t Row_Queue_Capacity = 256; Waterfall_Ring_Buffer ring_buffer; @@ -512,7 +498,7 @@ struct Waterfall_Private : Typed_Render_Datalower_stream_tick = timeline.first_stream_tick; request->upper_stream_tick = timeline.last_stream_tick; request->visible_time_count = static_cast(timeline.times.size()); - request->start_coord_to_end_coord = timeline.newest_at_axis_start; + request->newest_at_axis_start = timeline.newest_at_axis_start; request->draw_frequency_range = h_range; request->draw_time_range = v_range; request->draw_source_rect = RectF(source_start, 0.0, source_end - source_start, static_cast(row_count)); diff --git a/Core/primitive/Curve.cpp b/Core/primitive/Curve.cpp index 7b567b0..d424591 100644 --- a/Core/primitive/Curve.cpp +++ b/Core/primitive/Curve.cpp @@ -382,7 +382,7 @@ std::shared_ptr Curve::Builder::build() { PROP_R(bool, visible_range_only) PROP_R(bool, antialias) PROP_R(Line_Interpolation_Mode, interpolation_mode) - PROP_R(Line_Sampling_Mode, sample_mode) + PROP_R(Line_Sampling_Strategy, sample_mode) if (sc->data_range.length() == 0.0) sc->data_range = {0.0, 1.0}; return ret; diff --git a/main.cmake b/main.cmake index 1ab6ccb..829095d 100644 --- a/main.cmake +++ b/main.cmake @@ -18,7 +18,7 @@ else () find_package(GTest REQUIRED) find_package(Taskflow CONFIG REQUIRED) find_package(MPMCQueue CONFIG REQUIRED) - set(renderive_public_libraries + set(renderive_private_libraries blend2d::blend2d GTest::GTest Taskflow::Taskflow @@ -39,7 +39,7 @@ set(root_dir ${CMAKE_CURRENT_LIST_DIR}) append_glob_source(srcs ${root_dir}/Core) add_library(Renderive_Core STATIC ${srcs}) target_include_directories(Renderive_Core PUBLIC ${root_dir}) -target_link_libraries(Renderive_Core PUBLIC ${renderive_public_libraries}) +target_link_libraries(Renderive_Core PUBLIC ${renderive_private_libraries}) enable_testing() add_executable(Renderive_Core_Tests ${root_dir}/test/Renderive_Core_Tests.cpp