初步重构
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include "Audio_Frequent_p.h"
|
||||
#include "../Axis/Time_Axis.h"
|
||||
namespace YSG {
|
||||
using AudioFrequent_Binding = Renderable_Binding<Audio_Frequent, Audio_Frequent_Private, AudioFrequentRenderState, AudioFrequentInputData>;
|
||||
using AudioFrequent_Binding = Renderable_Binding<Audio_Frequent, Audio_Frequent_Private, Audio_Frequent_Render_State, Audio_Frequent_Input_Data>;
|
||||
Audio_Frequent::Audio_Frequent() {
|
||||
AudioFrequent_Binding::init(this, "AudioFrequent");
|
||||
}
|
||||
@@ -18,34 +18,34 @@ Input_Data* Audio_Frequent::create_input_data() {
|
||||
return AudioFrequent_Binding::create_input_data();
|
||||
}
|
||||
int Audio_Frequent::time_point_size(SRC src) {
|
||||
return d()->state_value(&AudioFrequentRenderState::time_point_size, src);
|
||||
return d()->state_value(&Audio_Frequent_Render_State::time_point_size, src);
|
||||
}
|
||||
void Audio_Frequent::set_time_point_size(int value) {
|
||||
d()->set_state_value(&AudioFrequentRenderState::time_point_size, value);
|
||||
d()->set_state_value(&Audio_Frequent_Render_State::time_point_size, value);
|
||||
}
|
||||
Time_Axis* Audio_Frequent::time_axis(SRC src) {
|
||||
return d()->state_value(&AudioFrequentRenderState::time_axis, src);
|
||||
return d()->state_value(&Audio_Frequent_Render_State::time_axis, src);
|
||||
}
|
||||
void Audio_Frequent::set_time_axis(Time_Axis* value) {
|
||||
d()->set_state_value(&AudioFrequentRenderState::time_axis, value);
|
||||
d()->set_state_value(&Audio_Frequent_Render_State::time_axis, value);
|
||||
}
|
||||
Axis* Audio_Frequent::value_axis(SRC src) {
|
||||
return d()->state_value(&AudioFrequentRenderState::value_axis, src);
|
||||
return d()->state_value(&Audio_Frequent_Render_State::value_axis, src);
|
||||
}
|
||||
void Audio_Frequent::set_value_axis(Axis* value) {
|
||||
d()->set_state_value(&AudioFrequentRenderState::value_axis, value);
|
||||
d()->set_state_value(&Audio_Frequent_Render_State::value_axis, value);
|
||||
}
|
||||
Range Audio_Frequent::key_range(SRC src) {
|
||||
return d()->state_value(&AudioFrequentRenderState::key_range, src);
|
||||
return d()->state_value(&Audio_Frequent_Render_State::key_range, src);
|
||||
}
|
||||
void Audio_Frequent::set_key_range(Range value) {
|
||||
d()->set_state_value(&AudioFrequentRenderState::key_range, std::move(value));
|
||||
d()->set_state_value(&Audio_Frequent_Render_State::key_range, std::move(value));
|
||||
}
|
||||
QColor Audio_Frequent::color(SRC src) {
|
||||
return d()->state_value(&AudioFrequentRenderState::color, src);
|
||||
return d()->state_value(&Audio_Frequent_Render_State::color, src);
|
||||
}
|
||||
void Audio_Frequent::set_color(QColor value) {
|
||||
d()->set_state_value(&AudioFrequentRenderState::color, std::move(value));
|
||||
d()->set_state_value(&Audio_Frequent_Render_State::color, std::move(value));
|
||||
}
|
||||
Audio_Frequent::Builder::Builder(Time_Axis* time_axis, Axis* value_axis) {
|
||||
ASSERT(time_axis->mPlot != nullptr, "AudioFrequent build error! time_axis->mPlot == nullptr");
|
||||
@@ -58,7 +58,7 @@ Audio_Frequent* Audio_Frequent::Builder::build() {
|
||||
auto ret = new Audio_Frequent();
|
||||
ret->init(plot, layerName);
|
||||
Audio_Frequent_Private* pd = ret->d();
|
||||
AudioFrequentRenderState* sc = reinterpret_cast<AudioFrequentRenderState*>(pd->state(State_Edit));
|
||||
Audio_Frequent_Render_State* sc = reinterpret_cast<Audio_Frequent_Render_State*>(pd->state(State_Edit));
|
||||
PROP_R(int, time_point_size)
|
||||
PROP_R(TimeAxis *, time_axis)
|
||||
PROP_R(Axis *, value_axis)
|
||||
@@ -69,7 +69,7 @@ Audio_Frequent* Audio_Frequent::Builder::build() {
|
||||
void Audio_Frequent::give_data(int tick, double data) {
|
||||
Q_UNUSED(tick)
|
||||
if (!ok()) return;
|
||||
Render_Input_Lease<Audio_Frequent_Private, AudioFrequentInputData> input(d());
|
||||
Render_Input_Lease<Audio_Frequent_Private, Audio_Frequent_Input_Data> input(d());
|
||||
input->mDataList.push_front(data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ public:
|
||||
protected:
|
||||
Audio_Frequent();
|
||||
friend struct Audio_Frequent_Private;
|
||||
friend struct AudioFrequentRenderState;
|
||||
friend struct AudioFrequentInputData;
|
||||
friend struct Audio_Frequent_Render_State;
|
||||
friend struct Audio_Frequent_Input_Data;
|
||||
public:
|
||||
void give_data(int tick, double data);
|
||||
PROP(int, time_point_size)
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
#include "../base/Performance_Shower_p.h"
|
||||
#include "../base/Plot_p.h"
|
||||
namespace YSG {
|
||||
struct AudioFrequentInputData : Input_Data {
|
||||
struct Audio_Frequent_Input_Data : Input_Data {
|
||||
std::list<double> mDataList;
|
||||
void clear() override {
|
||||
mDataList.clear();
|
||||
}
|
||||
};
|
||||
struct AudioFrequentRenderState : Render_State, AudioFrequent_Prop {};
|
||||
struct Audio_Frequent_Private : Typed_Render_Data<Audio_Frequent, AudioFrequentRenderState, AudioFrequentInputData> {
|
||||
struct Audio_Frequent_Render_State : Render_State, AudioFrequent_Prop {};
|
||||
struct Audio_Frequent_Private : Typed_Render_Data<Audio_Frequent, Audio_Frequent_Render_State, Audio_Frequent_Input_Data> {
|
||||
friend class Audio_Frequent;
|
||||
Psc::StreamRingBuffer_ST buffer;
|
||||
std::vector<double> powerSnapshot;
|
||||
@@ -41,8 +41,8 @@ struct Audio_Frequent_Private : Typed_Render_Data<Audio_Frequent, AudioFrequentR
|
||||
}
|
||||
void prepare_data() override {
|
||||
sync_state_pipeline();
|
||||
AudioFrequentRenderState* s = render_state();
|
||||
AudioFrequentInputData* d = render_input_data();
|
||||
Audio_Frequent_Render_State* s = render_state();
|
||||
Audio_Frequent_Input_Data* d = render_input_data();
|
||||
if (pointCount != s->time_point_size) {
|
||||
resizePowerBuffer(s->time_point_size);
|
||||
Performance_Shower* shower = q()->mPlot->d->mShower;
|
||||
@@ -57,7 +57,7 @@ struct Audio_Frequent_Private : Typed_Render_Data<Audio_Frequent, AudioFrequentR
|
||||
clear_render_input();
|
||||
}
|
||||
void draw(QPainter* painter) override {
|
||||
AudioFrequentRenderState* s = render_state();
|
||||
Audio_Frequent_Render_State* s = render_state();
|
||||
Performance_Shower* shower = q()->mPlot->d->mShower;
|
||||
if (shower) {
|
||||
shower->set_performance_line("time_point_size", Performance_Line(QString("time_point_size:%1").arg(s->time_axis->time_point_size())));
|
||||
|
||||
@@ -2,20 +2,20 @@
|
||||
#include "../base/Plot.h"
|
||||
namespace YSG {
|
||||
void Hover_Info_Render_State::draw_hover(QPainter* painter, Abs_Axis* h, Abs_Axis* v) {
|
||||
QPoint pos = hoverInfoPos;
|
||||
QPoint pos = hover_info_pos;
|
||||
if (!renderAble) {
|
||||
auto that = dynamic_cast<Render_State*>(this);
|
||||
renderAble = dynamic_cast<Hover_Info_Render_Able_InterFace*>(that->dPtr->qPtr);
|
||||
}
|
||||
QVector<QString> lines = renderAble->create_hover_string(h, v, pos);
|
||||
QFontMetrics fm(hoverInfoFont);
|
||||
QFontMetrics fm(hover_info_font);
|
||||
int width = std::numeric_limits<int>::min();
|
||||
for (QString& s : lines) width = qMax(width, fm.horizontalAdvance(s));
|
||||
QRect r = QRect(pos.x() + hoverInfoLeft, pos.y() + hoverInfoTop,
|
||||
(int)width + hoverInfoRight + hoverInfoLeft, fm.height() * lines.size() + hoverInfoBottom);
|
||||
painter->fillRect(r, hoverInfoBrush);
|
||||
QRect r = QRect(pos.x() + hover_info_left, pos.y() + hover_info_top,
|
||||
(int)width + hover_info_right + hover_info_left, fm.height() * lines.size() + hover_info_bottom);
|
||||
painter->fillRect(r, hover_info_brush);
|
||||
painter->setPen(hover_info_pen);
|
||||
painter->setFont(hoverInfoFont);
|
||||
painter->setFont(hover_info_font);
|
||||
int lineHeight = fm.height();
|
||||
for (int i = 0; i < lines.size(); ++i) {
|
||||
QRect lineRect(r.left(), r.top() + i * lineHeight, r.width(), lineHeight);
|
||||
@@ -24,7 +24,7 @@ void Hover_Info_Render_State::draw_hover(QPainter* painter, Abs_Axis* h, Abs_Axi
|
||||
}
|
||||
bool Hover_Info_Render_State::hover_ok(Renderable* able) const {
|
||||
auto tmp = dynamic_cast<Hover_Info_Render_Able_InterFace*>(able);
|
||||
return use_hover_info && hoverInfoActive && tmp->hover_test(hoverInfoPos);
|
||||
return use_hover_info && hover_info_active && tmp->hover_test(hover_info_pos);
|
||||
}
|
||||
QVector<QString> Hover_Info_Render_Able_InterFace::create_hover_string(Abs_Axis* h, Abs_Axis* v, QPoint pos) {
|
||||
double tick1 = h->pixel_to_coord(pos.x(), SRC::Render);
|
||||
|
||||
@@ -7,15 +7,15 @@ struct Hover_Info_Render_Able_InterFace;
|
||||
struct LIB_DECL Hover_Info_Render_State {
|
||||
virtual ~Hover_Info_Render_State() = default;
|
||||
Hover_Info_Render_State() {
|
||||
hoverInfoBrush = QBrush(Qt::white);
|
||||
hover_info_brush = QBrush(Qt::white);
|
||||
}
|
||||
int hoverInfoLeft = 4, hoverInfoTop = 4, hoverInfoRight = 4, hoverInfoBottom = 4;
|
||||
QBrush hoverInfoBrush;
|
||||
QFont hoverInfoFont;
|
||||
int hover_info_left = 4, hover_info_top = 4, hover_info_right = 4, hover_info_bottom = 4;
|
||||
QBrush hover_info_brush;
|
||||
QFont hover_info_font;
|
||||
QPen hover_info_pen;
|
||||
bool use_hover_info = true;
|
||||
bool hoverInfoActive = false;
|
||||
QPoint hoverInfoPos;
|
||||
bool hover_info_active = false;
|
||||
QPoint hover_info_pos;
|
||||
Hover_Info_Render_Able_InterFace* renderAble{};
|
||||
void draw_hover(QPainter* painter, Abs_Axis* h, Abs_Axis* v);
|
||||
bool hover_ok(Renderable* able) const;
|
||||
@@ -42,18 +42,18 @@ struct LIB_DECL Hover_Info_Render_Able_InterFace {
|
||||
}
|
||||
void set_hover_info_font(const QFont& font) {
|
||||
Hover_Info_Render_State* sc = begin_hover_edit();
|
||||
sc->hoverInfoFont = font;
|
||||
sc->hover_info_font = font;
|
||||
finish_hover_edit();
|
||||
}
|
||||
QFont hover_info_font(SRC src = SRC::Edit) {
|
||||
return hover_state(src)->hoverInfoFont;
|
||||
return hover_state(src)->hover_info_font;
|
||||
}
|
||||
QBrush hover_info_background_brush(SRC src = SRC::Edit) {
|
||||
return hover_state(src)->hoverInfoBrush;
|
||||
return hover_state(src)->hover_info_brush;
|
||||
}
|
||||
void set_hover_info_background_brush(const QBrush& brush) {
|
||||
Hover_Info_Render_State* sc = begin_hover_edit();
|
||||
sc->hoverInfoBrush = brush.color().isValid() ? brush : Qt::NoBrush;
|
||||
sc->hover_info_brush = brush.color().isValid() ? brush : Qt::NoBrush;
|
||||
finish_hover_edit();
|
||||
}
|
||||
QPen hover_info_pen(SRC src = SRC::Edit) {
|
||||
@@ -66,17 +66,17 @@ struct LIB_DECL Hover_Info_Render_Able_InterFace {
|
||||
}
|
||||
void get_hover_info_contents_margins(int& left, int& top, int& right, int& bottom, SRC src) {
|
||||
auto s = hover_state(src);
|
||||
left = s->hoverInfoLeft;
|
||||
top = s->hoverInfoTop;
|
||||
right = s->hoverInfoRight;
|
||||
bottom = s->hoverInfoBottom;
|
||||
left = s->hover_info_left;
|
||||
top = s->hover_info_top;
|
||||
right = s->hover_info_right;
|
||||
bottom = s->hover_info_bottom;
|
||||
}
|
||||
void set_hover_info_contents_margins(int left, int top, int right, int bottom) {
|
||||
Hover_Info_Render_State* sc = begin_hover_edit();
|
||||
sc->hoverInfoLeft = left;
|
||||
sc->hoverInfoTop = top;
|
||||
sc->hoverInfoRight = right;
|
||||
sc->hoverInfoBottom = bottom;
|
||||
sc->hover_info_left = left;
|
||||
sc->hover_info_top = top;
|
||||
sc->hover_info_right = right;
|
||||
sc->hover_info_bottom = bottom;
|
||||
finish_hover_edit();
|
||||
}
|
||||
protected:
|
||||
|
||||
@@ -126,8 +126,8 @@ struct Spectrum_Private : Typed_Render_Data<Spectrum, Spectrum_Render_State, Spe
|
||||
}
|
||||
void set_hover_state(const QPoint& pos, bool active) override {
|
||||
Render_Edit_Lease<Spectrum_Private, Spectrum_Render_State> edit(this);
|
||||
edit->hoverInfoPos = pos;
|
||||
edit->hoverInfoActive = active;
|
||||
edit->hover_info_pos = pos;
|
||||
edit->hover_info_active = active;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -82,8 +82,8 @@ struct Waterfall_Private : Typed_Render_Data<Waterfall, Waterfall_Render_State,
|
||||
}
|
||||
void set_hover_state(const QPoint& pos, bool active) override {
|
||||
Render_Edit_Lease<Waterfall_Private, Waterfall_Render_State> edit(this);
|
||||
edit->hoverInfoPos = pos;
|
||||
edit->hoverInfoActive = active;
|
||||
edit->hover_info_pos = pos;
|
||||
edit->hover_info_active = active;
|
||||
}
|
||||
void prepare_data() override {
|
||||
sync_state_pipeline();
|
||||
|
||||
Reference in New Issue
Block a user