Files
Renderive/YSGraphic_Core/DemoGallery/AfterglowPlot.h
T
2026-06-16 13:33:27 +08:00

52 lines
1.7 KiB
C++

#pragma once
#include "Tool.h"
static QWidget* createAfterglow() {
class AfterglowPlot : public YSG::Plot {
public:
YSG::FrequentAxis *xAxis{};
YSG::Axis *yAxis{};
YSG::Afterglow *ag{};
YSG::MutiSelectRect* msr{};
QMenu *mMenu{};
void init() override {
Plot::init();
mObjectName = "AfterglowPlot";
bindRenderThread(mObjectName + "Thread");
xAxis = YSG::FrequentAxis::Builder(this, Qt::Horizontal).build();
yAxis = YSG::Axis::Builder(this, Qt::Vertical).build();
ag = YSG::Afterglow::Builder(xAxis, yAxis)
.set_frequentRange({0, 100})
.set_powerRange({0, 100})
.build();
msr = YSG::MutiSelectRect::Builder(xAxis, yAxis).build();
}
protected:
void resizeEvent(QResizeEvent* event) override {
xAxis->set_x(0);
xAxis->set_y(height() - 1);
xAxis->set_pixelSize(width());
yAxis->set_x(0);
yAxis->set_y(0);
yAxis->set_pixelSize(height());
ag->set_frequentPointSize(ag->frequentAxis()->getPixelPointSize());
ag->set_powerPointSize(ag->powerAxis()->getPixelPointSize());
}
void contextMenuEvent(QContextMenuEvent* event) override {
if(!mMenu) {
auto ws =
bw(cw(ag, -1), "余辉图") +
bw(cw(xAxis), "频率轴") +
bw(cw(yAxis),"功率概率轴") +
bw(cw(msr), "多选框");
mMenu = createMenu(this, ws);
}
mMenu->exec(event->globalPos());
}
};
auto w = new AfterglowPlot;
w->init();
return w;
}