结构更新

This commit is contained in:
2026-07-24 09:17:13 +08:00
parent a13a0e15f2
commit 7091ff5d79
6 changed files with 244 additions and 364 deletions
@@ -12,40 +12,35 @@
#include "../BaseWidget.h"
#include "../menu/BaseWidgetMenu.h"
#include "../BackEnd/MainWidget.h"
#include "YSGraphic_Core/DemoGallery/Tool.h"
#include "YSGraphic_Core/Demo_Gallery/export.h"
static YSG::Range frequent_range = {-12000, 12000};
static double max = 160;
QWidget* IntermediateFrequencyWidget::createSpectrogramPowerPlot() {
class SpectrumPlot : public YSG::Plot {
public:
YSG::Frequent_Axis *xAxis{};
YSG::Axis *yAxis{};
YSG::Frequent_Axis* xAxis{};
YSG::Axis* yAxis{};
YSG::Muti_Select_Rect* msr{};
YSG::Spectrum *sp{};
QMenu *mMenu{};
YSG::Spectrum* sp{};
QMenu* mMenu{};
void init() override {
Plot::init();
object_name = "SpectrumPlot";
xAxis = YSG::Frequent_Axis::Builder(this, Qt::Horizontal)
.set_tick_length(-10)
.set_coord_range(frequent_range)
.set_tick_length(-10)
.set_sub_tick_length(-5)
.build();
.set_tick_length(-10)
.set_coord_range(frequent_range)
.set_tick_length(-10)
.set_sub_tick_length(-5)
.build();
yAxis = YSG::Axis::Builder(this, Qt::Vertical)
.set_coord_range({160, 0})
.set_unit_text("功率")
.build();
.set_coord_range({160, 0})
.set_unit_text("功率")
.build();
sp = YSG::Spectrum::Builder(xAxis, yAxis)
.set_frequent_range(frequent_range)
.set_use_sweep_frequent_rect(true)
.set_frequent_point_size(1024)
.build();
.set_frequent_range(frequent_range)
.set_use_sweep_frequent_rect(true)
.set_frequent_point_size(1024)
.build();
msr = YSG::Muti_Select_Rect::Builder(xAxis, yAxis).build();
}
protected:
@@ -58,7 +53,7 @@ QWidget* IntermediateFrequencyWidget::createSpectrogramPowerPlot() {
yAxis->set_pixel_size(height());
}
void contextMenuEvent(QContextMenuEvent* event) override {
if(!mMenu) {
if (!mMenu) {
auto ws =
bw(cw(sp, -1), "频谱图") +
bw(cw(xAxis), "频率x轴") +
@@ -79,40 +74,32 @@ QWidget* IntermediateFrequencyWidget::createSpectrogramPowerPlot() {
};
return w;
}
QWidget* IntermediateFrequencyWidget::create_Afterglow_Plot(){
QWidget* IntermediateFrequencyWidget::create_Afterglow_Plot() {
class AfterglowPlot : public YSG::Plot {
public:
YSG::Frequent_Axis *xAxis{};
YSG::Axis *yAxis{};
YSG::Afterglow *ag{};
YSG::Frequent_Axis* xAxis{};
YSG::Axis* yAxis{};
YSG::Afterglow* ag{};
YSG::Muti_Select_Rect* msr{};
QMenu *mMenu{};
QMenu* mMenu{};
void init() override {
Plot::init();
object_name = "AfterglowPlot";
xAxis = YSG::Frequent_Axis::Builder(this, Qt::Horizontal)
.set_coord_range(frequent_range)
.set_tick_length(-10)
.set_sub_tick_length(-5)
.set_use_drag(true)
.build();
.set_coord_range(frequent_range)
.set_tick_length(-10)
.set_sub_tick_length(-5)
.set_use_drag(true)
.build();
yAxis = YSG::Axis::Builder(this, Qt::Vertical)
.set_coord_range({160, 0})
.set_use_drag(true)
.build();
.set_coord_range({160, 0})
.set_use_drag(true)
.build();
ag = YSG::Afterglow::Builder(xAxis, yAxis)
.set_frequent_range(frequent_range)
.set_power_range({0 , 160})
.set_frequent_point_size(1024)
.build();
.set_frequent_range(frequent_range)
.set_power_range({0, 160})
.set_frequent_point_size(1024)
.build();
msr = YSG::Muti_Select_Rect::Builder(xAxis, yAxis).build();
}
protected:
@@ -126,11 +113,11 @@ QWidget* IntermediateFrequencyWidget::create_Afterglow_Plot(){
ag->set_power_point_size(ag->power_axis()->get_pixel_point_size());
}
void contextMenuEvent(QContextMenuEvent* event) override {
if(!mMenu) {
if (!mMenu) {
auto ws =
bw(cw(ag, -1), "余辉图") +
bw(cw(xAxis), "频率轴") +
bw(cw(yAxis),"功率概率轴") +
bw(cw(yAxis), "功率概率轴") +
bw(cw(msr), "多选框");
mMenu = createMenu(this, ws);
}
@@ -142,10 +129,8 @@ QWidget* IntermediateFrequencyWidget::create_Afterglow_Plot(){
mAfterglow = w->ag;
return w;
}
//mAM, mATU, mVSQL, mNB, mNR, mDNF, mPRE, mATT, mSPL, mFIL1, mAGC_A
IntermediateFrequencyWidget::IntermediateFrequencyWidget(QWidget *parent) : BaseWidget(parent) {
IntermediateFrequencyWidget::IntermediateFrequencyWidget(QWidget* parent) : BaseWidget(parent) {
setObjectName("发射界面");
int fontSize = 20;
m1 = createNormal("RF Gain\n62", fontSize);
@@ -157,24 +142,22 @@ IntermediateFrequencyWidget::IntermediateFrequencyWidget(QWidget *parent) : Base
mFrequentShower = new FrequentShower(this);
QColor orange(255, 165, 0);
mProgressBar1 = new ProgressBar({
Tick("S", Qt::black),
{"3", Qt::black},
{"6", Qt::black},
{"9", Qt::black},
{"20", Qt::black},
{"+40", orange},
{"+60", orange},
{"+80", orange},
{"+100", Qt::red},
}, this);
Tick("S", Qt::black),
{"3", Qt::black},
{"6", Qt::black},
{"9", Qt::black},
{"20", Qt::black},
{"+40", orange},
{"+60", orange},
{"+80", orange},
{"+100", Qt::red},
}, this);
mProgressBar2 = new ProgressBar({
{"1", Qt::black},
{"2", Qt::yellow},
{"3", Qt::red},
{">5", Qt::red},
}, this);
{"1", Qt::black},
{"2", Qt::yellow},
{"3", Qt::red},
{">5", Qt::red},
}, this);
auto main = createVBoxLayout({}, this);
main->addStretch(1);
{
@@ -215,112 +198,91 @@ IntermediateFrequencyWidget::IntermediateFrequencyWidget(QWidget *parent) : Base
aH->addWidget(createSpectrogramPowerPlot(), 12);
aH->addSpacing(8);
main->addWidget(create_Afterglow_Plot(), 12);
initMenu();
}
IntermediateFrequencyWidget::~IntermediateFrequencyWidget() {
}
void IntermediateFrequencyWidget::focusInEvent(QFocusEvent *event) {
IntermediateFrequencyWidget::~IntermediateFrequencyWidget() {}
void IntermediateFrequencyWidget::focusInEvent(QFocusEvent* event) {
QWidget::focusInEvent(event);
mFrequentShower->setFocus();
}
void IntermediateFrequencyWidget::initMenu() {
int fontSize = 30;
auto btn1 = new DoubleTextMenuButton("设置最大值标记", "取消最大值标记", fontSize, [&](bool isFirst){
auto btn1 = new DoubleTextMenuButton("设置最大值标记", "取消最大值标记", fontSize, [&](bool isFirst) {
mSpectrogramLine->set_use_max_marker(isFirst);
mBaseWidgetMenu->hide();
MainWidget::instance()->getCurrentBaseWidget()->setFocus();
});
auto btn2 = new DoubleTextMenuButton("设置最小值标记", "取消最小值标记", fontSize, [&](bool isFirst){
auto btn2 = new DoubleTextMenuButton("设置最小值标记", "取消最小值标记", fontSize, [&](bool isFirst) {
mSpectrogramLine->set_use_min_marker(isFirst);
mBaseWidgetMenu->hide();
MainWidget::instance()->getCurrentBaseWidget()->setFocus();
});
auto btn3 = new MenuButton("设置自定义标记", fontSize, [&](){
auto btn3 = new MenuButton("设置自定义标记", fontSize, [&]() {
mBaseWidgetMenu->hide();
MainWidget::instance()->getCurrentBaseWidget()->setFocus();
});
auto frequentStep2 = new ValueMenuButton("频率步进:%1", fontSize, [this](ValueMenuButton* that, bool add){
int newFrequent = (int)that->mValue + (add?1:-1);
that->setValue(newFrequent);
mSpectrogramLine->set_current_marker_frequent(newFrequent);
}, qMax(0.0, mSpectrogramLine->frequent_range().length()/50.0));
auto frequentStep2 = new ValueMenuButton("频率步进:%1", fontSize, [this](ValueMenuButton* that, bool add) {
int newFrequent = (int)that->mValue + (add ? 1 : -1);
that->setValue(newFrequent);
mSpectrogramLine->set_current_marker_frequent(newFrequent);
}, qMax(0.0, mSpectrogramLine->frequent_range().length() / 50.0));
auto btn_middleFrequent = new ValueMenuButton("中频:%1 Hz", fontSize, nullptr, mSpectrogramLine->middle_sweep_frequent());
auto btn_frequentWidth = new ValueMenuButton("频宽:%1 Hz", fontSize, [this, frequentStep2](ValueMenuButton* that, bool add){
that->setValue(that->mValue + (double)(add?frequentStep2->mValue:-frequentStep2->mValue));
auto btn_frequentWidth = new ValueMenuButton("频宽:%1 Hz", fontSize, [this, frequentStep2](ValueMenuButton* that, bool add) {
that->setValue(that->mValue + (double)(add ? frequentStep2->mValue : -frequentStep2->mValue));
double middle_sweep_frequent = mSpectrogramLine->middle_sweep_frequent();
mSpectrogramLine->set_sweep_frequent_range({middle_sweep_frequent - that->mValue, middle_sweep_frequent + that->mValue});
}, qAbs(mSpectrogramLine->sweep_frequent_range().length()/2));
btn_middleFrequent->mValueChanged = [this, btn_frequentWidth, frequentStep2](ValueMenuButton* that, bool add){
that->setValue(that->mValue + (double)(add?frequentStep2->mValue:-frequentStep2->mValue));
}, qAbs(mSpectrogramLine->sweep_frequent_range().length() / 2));
btn_middleFrequent->mValueChanged = [this, btn_frequentWidth, frequentStep2](ValueMenuButton* that, bool add) {
that->setValue(that->mValue + (double)(add ? frequentStep2->mValue : -frequentStep2->mValue));
mSpectrogramLine->set_middle_sweep_frequent(that->mValue);
mSpectrogramLine->set_sweep_frequent_range({that->mValue - btn_frequentWidth->mValue, that->mValue + btn_frequentWidth->mValue});
};
auto btn2_2 = new ValueMenuButton("参考增益:%1", fontSize, [&](ValueMenuButton* that, bool add){
auto btn2_2 = new ValueMenuButton("参考增益:%1", fontSize, [&](ValueMenuButton* that, bool add) {
that->setValue(that->mValue + (double)(add ? 1 : -1));
}, 0);
mBaseWidgetMenu->addMenuButtonOnLayout1({btn1, btn2, btn3, btn2_2, });
mBaseWidgetMenu->addMenuButtonOnLayout2({frequentStep2, btn_middleFrequent, btn_frequentWidth,});
mBaseWidgetMenu->addMenuButtonOnLayout1({btn1, btn2, btn3, btn2_2,});
mBaseWidgetMenu->addMenuButtonOnLayout2({frequentStep2, btn_middleFrequent, btn_frequentWidth,});
BaseWidgetMenu* sub1 = mBaseWidgetMenu->createSubWidgetMenu(btn3);
auto frequentStep = new ValueMenuButton("频率步进:%1", fontSize, [this](ValueMenuButton* that, bool add){
int newFrequent = (int)that->mValue + (add?1:-1);
that->setValue(newFrequent);
mSpectrogramLine->set_current_marker_frequent(newFrequent);
}, qMax(0.0, mSpectrogramLine->frequent_range().length()/50.0));
auto markFrequent = new ValueMenuButton("更改标记频率:%1", fontSize, [frequentStep, this](ValueMenuButton* that, bool add){
int newFrequent = (int)that->mValue + (add?frequentStep->mValue:-frequentStep->mValue);
that->setValue(newFrequent);
mSpectrogramLine->set_current_marker_frequent(newFrequent);
auto frequentStep = new ValueMenuButton("频率步进:%1", fontSize, [this](ValueMenuButton* that, bool add) {
int newFrequent = (int)that->mValue + (add ? 1 : -1);
that->setValue(newFrequent);
mSpectrogramLine->set_current_marker_frequent(newFrequent);
}, qMax(0.0, mSpectrogramLine->frequent_range().length() / 50.0));
auto markFrequent = new ValueMenuButton("更改标记频率:%1", fontSize, [frequentStep, this](ValueMenuButton* that, bool add) {
int newFrequent = (int)that->mValue + (add ? frequentStep->mValue : -frequentStep->mValue);
that->setValue(newFrequent);
mSpectrogramLine->set_current_marker_frequent(newFrequent);
}, -1);
auto addInitFrequent = new ValueMenuButton("添加初始频率:%1", fontSize, [frequentStep,this](ValueMenuButton* that, bool add){
int newFrequent = (int)that->mValue + (add?frequentStep->mValue:-frequentStep->mValue);
that->setValue(newFrequent);
auto addInitFrequent = new ValueMenuButton("添加初始频率:%1", fontSize, [frequentStep,this](ValueMenuButton* that, bool add) {
int newFrequent = (int)that->mValue + (add ? frequentStep->mValue : -frequentStep->mValue);
that->setValue(newFrequent);
}, mSpectrogramLine->frequent_range().lower);
auto btn1_1 = new ValueMenuButton("当前标记:%1", fontSize, [&, markFrequent](ValueMenuButton* that, bool add){
int index = ((int)that->mValue + (add?1:-1) ) % mSpectrogramLine->select_line_marker_size();
auto btn1_1 = new ValueMenuButton("当前标记:%1", fontSize, [&, markFrequent](ValueMenuButton* that, bool add) {
int index = ((int)that->mValue + (add ? 1 : -1)) % mSpectrogramLine->select_line_marker_size();
that->setValue(index);
mSpectrogramLine->set_selected_line_marker(index);
markFrequent->setValue(mSpectrogramLine->get_mark_frequent(index));
}, -1);
auto btn1_2 = new MenuButton("添加标记", fontSize, [&, addInitFrequent](){
auto btn1_2 = new MenuButton("添加标记", fontSize, [&, addInitFrequent]() {
mSpectrogramLine->add_custom_line_marker(addInitFrequent->mValue);
});
auto btn1_3 = new MenuButton("删除标记", fontSize, [&](){
auto btn1_3 = new MenuButton("删除标记", fontSize, [&]() {
mSpectrogramLine->remove_current_marker();
int size = mSpectrogramLine->select_line_marker_size();
if(size == 0){
if (size == 0) {
mSpectrogramLine->set_selected_line_marker(-1);
} else {
}
else {
mSpectrogramLine->set_selected_line_marker(0);
}
});
connect(sub1, &BaseWidgetMenu::showThat, [&, markFrequent](){
connect(sub1, &BaseWidgetMenu::showThat, [&, markFrequent]() {
mSpectrogramLine->set_selected_line_marker(0);
markFrequent->setValue(mSpectrogramLine->get_mark_frequent(0));
});
connect(sub1, &BaseWidgetMenu::hideThat, [&](){
connect(sub1, &BaseWidgetMenu::hideThat, [&]() {
mSpectrogramLine->un_select_marker();
});
sub1->addMenuButtonOnLayout1({btn1_1, btn1_2, btn1_3},2);
sub1->addMenuButtonOnLayout1({btn1_1, btn1_2, btn1_3}, 2);
sub1->addMenuButtonOnLayout2({frequentStep, markFrequent, addInitFrequent}, 2);
}
+107 -156
View File
@@ -8,41 +8,35 @@
#include "../menu/BaseWidgetMenu.h"
#include "BackEnd.h"
#include "../BackEnd/MainWidget.h"
#include "YSGraphic_Core/DemoGallery/Tool.h"
#include "YSGraphic_Core/Demo_Gallery/export.h"
static bool use_Performance_shower = false;
static double max = 160;
static YSG::Range frequent_range = {-12000, 12000};
QWidget* RadioWidget::createSpectrogramPowerPlot() {
class SpectrumPlot : public YSG::Plot {
public:
YSG::Frequent_Axis *xAxis{};
YSG::Axis *yAxis{};
YSG::Frequent_Axis* xAxis{};
YSG::Axis* yAxis{};
YSG::Muti_Select_Rect* msr{};
YSG::Spectrum *sp{};
QMenu *mMenu{};
YSG::Spectrum* sp{};
QMenu* mMenu{};
void init() override {
Plot::init();
object_name = "SpectrumPlot";
xAxis = YSG::Frequent_Axis::Builder(this, Qt::Horizontal)
.set_coord_range(frequent_range)
.set_tick_length(-10)
.build();
.set_coord_range(frequent_range)
.set_tick_length(-10)
.build();
yAxis = YSG::Axis::Builder(this, Qt::Vertical)
.set_coord_range({max, 0})
.set_unit_text("功率")
.build();
.set_coord_range({max, 0})
.set_unit_text("功率")
.build();
sp = YSG::Spectrum::Builder(xAxis, yAxis)
.set_frequent_range(frequent_range)
.set_frequent_point_size(1024)
.build();
.set_frequent_range(frequent_range)
.set_frequent_point_size(1024)
.build();
msr = YSG::Muti_Select_Rect::Builder(xAxis, yAxis).build();
if(use_Performance_shower) set_use_performance_shower(true);
if (use_Performance_shower) set_use_performance_shower(true);
}
protected:
void resizeEvent(QResizeEvent* event) override {
@@ -54,7 +48,7 @@ QWidget* RadioWidget::createSpectrogramPowerPlot() {
yAxis->set_pixel_size(height());
}
void contextMenuEvent(QContextMenuEvent* event) override {
if(!mMenu) {
if (!mMenu) {
auto ws =
bw(cw(sp, -1), "频谱图") +
bw(cw(xAxis), "频率x轴") +
@@ -75,35 +69,33 @@ QWidget* RadioWidget::createSpectrogramPowerPlot() {
};
return w;
}
QWidget* RadioWidget::createWaterFallPlot() {
class WaterFallPlot : public YSG::Plot {
public:
YSG::Frequent_Axis *xAxis{};
YSG::Time_Axis *yAxis{};
YSG::Muti_Select_Rect *msr{};
YSG::Waterfall *wf{};
QMenu *mMenu{};
YSG::Frequent_Axis* xAxis{};
YSG::Time_Axis* yAxis{};
YSG::Muti_Select_Rect* msr{};
YSG::Waterfall* wf{};
QMenu* mMenu{};
void init() override {
Plot::init();
object_name = "WaterFallPlot";
xAxis = YSG::Frequent_Axis::Builder(this, Qt::Horizontal)
.set_tick_length(-10)
.set_sub_tick_length(-5)
.set_coord_range(frequent_range)
.build();
.set_tick_length(-10)
.set_sub_tick_length(-5)
.set_coord_range(frequent_range)
.build();
yAxis = YSG::Time_Axis::Builder(this, Qt::Vertical)
.set_time_point_size(100)
.build();
.set_time_point_size(100)
.build();
wf = YSG::Waterfall::Builder(xAxis, yAxis)
.set_frequent_range(frequent_range)
.set_frequent_point_size(1024)
.set_power_range({0, max})
// .set_time_point_size(100)
.build();
.set_frequent_range(frequent_range)
.set_frequent_point_size(1024)
.set_power_range({0, max})
// .set_time_point_size(100)
.build();
msr = YSG::Muti_Select_Rect::Builder(xAxis, yAxis).build();
if(use_Performance_shower) set_use_performance_shower(true);
if (use_Performance_shower) set_use_performance_shower(true);
}
protected:
void resizeEvent(QResizeEvent* event) override {
@@ -115,7 +107,7 @@ QWidget* RadioWidget::createWaterFallPlot() {
yAxis->set_pixel_size(height());
}
void contextMenuEvent(QContextMenuEvent* event) override {
if(!mMenu) {
if (!mMenu) {
auto ws =
bw(cw(wf, -1), "瀑布图") +
bw(cw(xAxis), "频率轴") +
@@ -131,41 +123,31 @@ QWidget* RadioWidget::createWaterFallPlot() {
mWaterFall = w->wf;
return w;
}
QWidget* RadioWidget::createAudioSpectrogramPlot() {
class SpectrumPlot : public YSG::Plot {
public:
YSG::Frequent_Axis *xAxis{};
YSG::Axis *yAxis{};
YSG::Frequent_Axis* xAxis{};
YSG::Axis* yAxis{};
YSG::Muti_Select_Rect* msr{};
YSG::Spectrum *sp{};
QMenu *mMenu{};
YSG::Spectrum* sp{};
QMenu* mMenu{};
void init() override {
Plot::init();
object_name = "SpectrumPlot";
xAxis = YSG::Frequent_Axis::Builder(this, Qt::Horizontal)
.set_coord_range({-12000 ,12000})
.set_tick_length(-10)
.set_sub_tick_length(-5)
.build();
.set_coord_range({-12000, 12000})
.set_tick_length(-10)
.set_sub_tick_length(-5)
.build();
yAxis = YSG::Axis::Builder(this, Qt::Vertical)
.set_coord_range({12000, -12000})
.set_unit_text("功率").build();
.set_coord_range({12000, -12000})
.set_unit_text("功率").build();
sp = YSG::Spectrum::Builder(xAxis, yAxis)
.set_frequent_range({-12000 ,12000})
.set_frequent_point_size(512)
.build();
.set_frequent_range({-12000, 12000})
.set_frequent_point_size(512)
.build();
msr = YSG::Muti_Select_Rect::Builder(xAxis, yAxis).build();
if(use_Performance_shower) set_use_performance_shower(true);
if (use_Performance_shower) set_use_performance_shower(true);
}
protected:
void resizeEvent(QResizeEvent* event) override {
@@ -176,10 +158,8 @@ QWidget* RadioWidget::createAudioSpectrogramPlot() {
yAxis->set_y(0);
yAxis->set_pixel_size(height());
}
void contextMenuEvent(QContextMenuEvent* event) override {
if(!mMenu) {
if (!mMenu) {
auto ws =
bw(cw(sp, -1), "频谱图") +
bw(cw(xAxis), "频率x轴") +
@@ -195,35 +175,28 @@ QWidget* RadioWidget::createAudioSpectrogramPlot() {
mAudioSpectrogramPlot = w->sp;
return w;
}
QWidget* RadioWidget::createTimePowerPlot() {
class AudioPlot : public YSG::Plot {
public:
YSG::Time_Axis *xAxis{};
YSG::Axis *yAxis{};
YSG::Audio_Frequent *audio{};
YSG::Time_Axis* xAxis{};
YSG::Axis* yAxis{};
YSG::Audio_Frequent* audio{};
YSG::Muti_Select_Rect* msr{};
QMenu *mMenu{};
QMenu* mMenu{};
void init() override {
Plot::init();
object_name = "AudioPlot";
xAxis = YSG::Time_Axis::Builder(this, Qt::Horizontal)
.set_tick_length(-10)
.set_sub_tick_length(-5)
.build();
.set_tick_length(-10)
.set_sub_tick_length(-5)
.build();
yAxis = YSG::Axis::Builder(this, Qt::Vertical)
.set_coord_range({12000, -12000})
.build();
.set_coord_range({12000, -12000})
.build();
audio = YSG::Audio_Frequent::Builder(xAxis, yAxis)
.build();
msr = YSG::Muti_Select_Rect::Builder(xAxis, yAxis).build();
if(use_Performance_shower) set_use_performance_shower(true);
if (use_Performance_shower) set_use_performance_shower(true);
}
protected:
void resizeEvent(QResizeEvent* event) override {
@@ -236,10 +209,10 @@ QWidget* RadioWidget::createTimePowerPlot() {
audio->set_time_point_size(xAxis->get_pixel_point_size());
}
void contextMenuEvent(QContextMenuEvent* event) override {
if(!mMenu) {
if (!mMenu) {
auto ws =
bw( cw(audio, -1), "音频图") +
bw(cw(yAxis),"功率y轴") +
bw(cw(audio, -1), "音频图") +
bw(cw(yAxis), "功率y轴") +
bw(cw(xAxis), "时间轴") +
bw(cw(msr), "多选框");
mMenu = createMenu(this, ws);
@@ -252,10 +225,8 @@ QWidget* RadioWidget::createTimePowerPlot() {
mTimePower = w->audio;
return w;
}
//mAM, mATU, mVSQL, mNB, mNR, mDNF, mPRE, mATT, mSPL, mFIL1, mAGC_A
RadioWidget::RadioWidget(QWidget *parent) : BaseWidget(parent) {
RadioWidget::RadioWidget(QWidget* parent) : BaseWidget(parent) {
setObjectName("电台界面");
mVoiceValue = BackEnd::instance()->YsGetAfGain();
mRFGainValue = BackEnd::instance()->YsGetRfGain();
@@ -269,34 +240,33 @@ RadioWidget::RadioWidget(QWidget *parent) : BaseWidget(parent) {
mSelectValueWidget = new FrequentShower(this);
int n = 5;
QVector<double> tickList(n);
double space = 100.0/n;
for(int i = 0; i < n; ++i){
double space = 100.0 / n;
for (int i = 0; i < n; ++i) {
tickList[i] = i * space;
}
QColor orange(255, 165, 0);
mProgressBar1 = new ProgressBar({
Tick("S", Qt::black),
{"3", Qt::black},
{"6", Qt::black},
{"9", Qt::black},
{"20", Qt::black},
{"40", orange},
{"60", orange},
{"100", orange},
{"+160", Qt::red},
}, this);
Tick("S", Qt::black),
{"3", Qt::black},
{"6", Qt::black},
{"9", Qt::black},
{"20", Qt::black},
{"40", orange},
{"60", orange},
{"100", orange},
{"+160", Qt::red},
}, this);
mProgressBar2 = new ProgressBar({
{"1", Qt::black},
{"2", Qt::yellow},
{"3", Qt::red},
{">5", Qt::red},
}, this);
{"1", Qt::black},
{"2", Qt::yellow},
{"3", Qt::red},
{">5", Qt::red},
}, this);
mProgressBar1->mTickSpaceW = 2.0f;
auto main = createVBoxLayout({}, this);
main->addStretch(1);
{ // 中心Layout
{
// 中心Layout
auto center = createHBoxLayout();
main->addLayout(center, 7);
auto front = createVBoxLayout();
@@ -328,8 +298,6 @@ RadioWidget::RadioWidget(QWidget *parent) : BaseWidget(parent) {
back2->addWidget(m6, 3);
}
main->addStretch(1);
auto aH1 = createHBoxLayout();
aH1->setSpacing(8);
main->addLayout(aH1, 12);
@@ -343,76 +311,60 @@ RadioWidget::RadioWidget(QWidget *parent) : BaseWidget(parent) {
aH2->addWidget(createAudioSpectrogramPlot(), 4);
initMenu();
}
RadioWidget::~RadioWidget() {
}
RadioWidget::~RadioWidget() {}
void RadioWidget::initMenu() {
int fontSize = 30;
auto btn1_1 = new MenuButton("模式设置", fontSize, [](){});
auto btn1_2 = new ValueMenuButton("发射功率:%1 W", fontSize, [&](ValueMenuButton* that, bool add){
that->setValue(that->mValue + (double)(add?1:-1));
auto btn1_1 = new MenuButton("模式设置", fontSize, []() {});
auto btn1_2 = new ValueMenuButton("发射功率:%1 W", fontSize, [&](ValueMenuButton* that, bool add) {
that->setValue(that->mValue + (double)(add ? 1 : -1));
}, -1);
auto btn2_1 = new ValueMenuButton("参考增益:%1", fontSize, [&](ValueMenuButton* that, bool add){
that->setValue(that->mValue + (double)(add?1:-1));
auto btn2_1 = new ValueMenuButton("参考增益:%1", fontSize, [&](ValueMenuButton* that, bool add) {
that->setValue(that->mValue + (double)(add ? 1 : -1));
}, -1);
mBaseWidgetMenu->addMenuButtonOnLayout1({btn1_1, btn1_2, {btn2_1},});
//mBaseWidgetMenu->addMenuButtonOnLayout2( );
BaseWidgetMenu* sub1 = mBaseWidgetMenu->createSubWidgetMenu(btn1_1);
auto s1_1 = new MenuButton("AM", fontSize, [](){
});
auto s1_2 = new MenuButton("FM", fontSize, [](){
});
auto s1_3 = new MenuButton("SSB", fontSize, [](){
});
auto s1_4 = new MenuButton("CW", fontSize, [](){
});
auto s1_1 = new MenuButton("AM", fontSize, []() {});
auto s1_2 = new MenuButton("FM", fontSize, []() {});
auto s1_3 = new MenuButton("SSB", fontSize, []() {});
auto s1_4 = new MenuButton("CW", fontSize, []() {});
sub1->addMenuButtonOnLayout1({s1_1, s1_2, s1_3, s1_4}, 1);
}
void RadioWidget::focusInEvent(QFocusEvent *event) {
void RadioWidget::focusInEvent(QFocusEvent* event) {
QWidget::focusInEvent(event);
mSelectValueWidget->setFocus();
}
void RadioWidget::keyPressEvent(QKeyEvent *event) {
void RadioWidget::keyPressEvent(QKeyEvent* event) {
if (event->type() == QEvent::KeyPress) {
BackEnd* g = BackEnd::instance();
auto *keyEvent = dynamic_cast<QKeyEvent *>(event);
if(g->match(keyEvent, "切换音量/RF Gain")){
if(m1->text().startsWith("RF Gain")){
auto* keyEvent = dynamic_cast<QKeyEvent*>(event);
if (g->match(keyEvent, "切换音量/RF Gain")) {
if (m1->text().startsWith("RF Gain")) {
m1->setText("Voice\n" + QString::number(mVoiceValue));
} else {
}
else {
m1->setText("RF Gain\n" + QString::number(mRFGainValue));
}
}
if(g->match(keyEvent, "特别增加")){
if(m1->text().startsWith("RF Gain")){
if (g->match(keyEvent, "特别增加")) {
if (m1->text().startsWith("RF Gain")) {
mRFGainValue++;
BackEnd::instance()->YsSetRfGain(mRFGainValue);
m1->setText("RF Gain\n" + QString::number(mRFGainValue));
} else {
}
else {
mVoiceValue++;
BackEnd::instance()->YsSetAfGain(mVoiceValue);
m1->setText("Voice\n" + QString::number(mVoiceValue));
}
}
if(g->match(keyEvent, "特别减小")){
if(m1->text().startsWith("RF Gain")){
if (g->match(keyEvent, "特别减小")) {
if (m1->text().startsWith("RF Gain")) {
mRFGainValue--;
BackEnd::instance()->YsSetRfGain(mRFGainValue);
m1->setText("RF Gain\n" + QString::number(mRFGainValue));
} else {
}
else {
mVoiceValue--;
BackEnd::instance()->YsSetAfGain(mVoiceValue);
m1->setText("Voice\n" + QString::number(mVoiceValue));
@@ -421,4 +373,3 @@ void RadioWidget::keyPressEvent(QKeyEvent *event) {
}
BaseWidget::keyPressEvent(event);
}
+34 -52
View File
@@ -10,36 +10,29 @@
#include "../component/ShowTime.h"
#include "../Global.h"
#include "../menu/BaseWidgetMenu.h"
#include "YSGraphic_Core/DemoGallery/Tool.h"
#include "YSGraphic_Core/Demo_Gallery/export.h"
QWidget* SweepFrequencyWidget::createSpectrogramPowerPlot() {
class SweepFrequentPlot : public YSG::Plot {
public:
YSG::Axis *xAxis{};
YSG::Axis *yAxis{};
YSG::Muti_Select_Rect *msr{};
YSG::Axis* xAxis{};
YSG::Axis* yAxis{};
YSG::Muti_Select_Rect* msr{};
YSG::Sweep_Frequent* sf{};
QMenu *mMenu{};
QMenu* mMenu{};
void init() override {
Plot::init();
object_name = "AxisTestPlot";
xAxis = YSG::Axis::Builder(this, Qt::Horizontal)
.set_coord_range({0, 100})
.set_tick_length(-10).build();
.set_coord_range({0, 100})
.set_tick_length(-10).build();
yAxis = YSG::Axis::Builder(this, Qt::Vertical)
.set_coord_range({100, 0})
.set_tick_length(-10).build();
.set_coord_range({100, 0})
.set_tick_length(-10).build();
sf = YSG::Sweep_Frequent::Builder(xAxis, yAxis)
.set_block_num(200)
.set_block_frequent_point_size(20)
.set_frequent_range({0 , 100})
.build();
.set_block_num(200)
.set_block_frequent_point_size(20)
.set_frequent_range({0, 100})
.build();
msr = YSG::Muti_Select_Rect::Builder(xAxis, yAxis).build();
}
protected:
@@ -52,7 +45,7 @@ QWidget* SweepFrequencyWidget::createSpectrogramPowerPlot() {
yAxis->set_pixel_size(height());
}
void contextMenuEvent(QContextMenuEvent* event) override {
if(!mMenu) {
if (!mMenu) {
auto ws =
bw(cw(sf, -1), "扫频图") +
bw(cw(xAxis), "x轴") +
@@ -68,9 +61,8 @@ QWidget* SweepFrequencyWidget::createSpectrogramPowerPlot() {
mSweepFrequencyLine = w->sf;
return w;
}
//mAM, mATU, mVSQL, mNB, mNR, mDNF, mPRE, mATT, mSPL, mFIL1, mAGC_A
SweepFrequencyWidget::SweepFrequencyWidget(QWidget *parent) : BaseWidget(parent) {
SweepFrequencyWidget::SweepFrequencyWidget(QWidget* parent) : BaseWidget(parent) {
setObjectName("扫频界面");
int fontSize = 20;
m1 = createNormal("RF Gain\n62", fontSize);
@@ -79,25 +71,25 @@ SweepFrequencyWidget::SweepFrequencyWidget(QWidget *parent) : BaseWidget(parent)
m4 = createNormal("MODEM\nRTTY", fontSize);
mSelectValueWidget = new FrequentShower(this);
mProgressBar1 = new ProgressBar({
{"S", Qt::black},
{"3", Qt::black},
{"5", Qt::black},
{"7", Qt::black},
{"9", Qt::black},
{"+20", Qt::yellow},
{"+40", Qt::yellow},
{"+60", Qt::red},
{"S", Qt::black},
{"3", Qt::black},
{"5", Qt::black},
{"7", Qt::black},
{"9", Qt::black},
{"+20", Qt::yellow},
{"+40", Qt::yellow},
{"+60", Qt::red},
}, this);
mProgressBar2 = new ProgressBar({
{"1", Qt::black},
{"2", Qt::yellow},
{"3", Qt::red},
{">5", Qt::red},
{"1", Qt::black},
{"2", Qt::yellow},
{"3", Qt::red},
{">5", Qt::red},
}, this);
auto main = createVBoxLayout({}, this);
main->addStretch(1);
{ // 中心Layout
{
// 中心Layout
auto center = createHBoxLayout();
main->addLayout(center, 7);
auto front = createVBoxLayout();
@@ -129,33 +121,23 @@ SweepFrequencyWidget::SweepFrequencyWidget(QWidget *parent) : BaseWidget(parent)
main->addWidget(createSpectrogramPowerPlot(), 24);
initMenu();
}
SweepFrequencyWidget::~SweepFrequencyWidget() {
}
void SweepFrequencyWidget::focusInEvent(QFocusEvent *event) {
SweepFrequencyWidget::~SweepFrequencyWidget() {}
void SweepFrequencyWidget::focusInEvent(QFocusEvent* event) {
QWidget::focusInEvent(event);
mSelectValueWidget->setFocus();
}
void SweepFrequencyWidget::initMenu() {
int fontSize = 30;
auto startFreq = new ValueMenuButton("起始频率:%1 Hz", fontSize, [&](ValueMenuButton* that, bool add){
auto startFreq = new ValueMenuButton("起始频率:%1 Hz", fontSize, [&](ValueMenuButton* that, bool add) {
that->setValue(that->mValue + (double)(add ? 1 : -1));
}, -1);
startFreq->setValue(mSweepFrequencyLine->frequent_range().lower);
auto endFreq = new ValueMenuButton("终止频率:%1 Hz", fontSize, [&](ValueMenuButton* that, bool add){
auto endFreq = new ValueMenuButton("终止频率:%1 Hz", fontSize, [&](ValueMenuButton* that, bool add) {
that->setValue(that->mValue + (double)(add ? 1 : -1));
}, -1);
endFreq->setValue(mSweepFrequencyLine->frequent_range().upper);
auto btn3 = new MenuButton("设置频率", fontSize, [&, startFreq, endFreq](){
auto btn3 = new MenuButton("设置频率", fontSize, [&, startFreq, endFreq]() {
mSweepFrequencyLine->set_frequent_range({startFreq->mValue, endFreq->mValue});
});
mBaseWidgetMenu->addMenuButtonOnLayout1({startFreq, endFreq, btn3}, 2);
}
+8 -19
View File
@@ -1,7 +1,7 @@
#ifndef Global_H
#define Global_H
#include "BackEnd/BackEnd.h"
#include "YSGraphic_Core/GlobalTypes.h"
#include "YSGraphic_Core/architecture/export.h"
#include <QApplication>
#include <QDebug>
#include <QHBoxLayout>
@@ -21,29 +21,18 @@ public:
int adaptHeight(int fullScreenHeight);
int adaptWidth(int fullScreenWidth);
};
QVBoxLayout* createVBoxLayout(const QVector<QWidget*>& children = {}, QWidget *parent = nullptr);
QHBoxLayout* createHBoxLayout(const QVector<QWidget*>& children = {}, QWidget *parent = nullptr);
QVBoxLayout* createVBoxLayout(const QVector<QWidget*>& children = {}, QWidget* parent = nullptr);
QHBoxLayout* createHBoxLayout(const QVector<QWidget*>& children = {}, QWidget* parent = nullptr);
QRect getMaxRect(const QRect& rect, double WHRate);
int calculateOptimalFontSize(const QString& text, const QSize& spaceSize, const QFont& font);
int calculateOptimalFontSize(const QVector<QString>& textList, const QSize& spaceSize, const QFont& font);
QPushButton* createButton(const QString& text, int fontSize, const std::function<void(void)>& mFunc = nullptr);
namespace YSG{
template <typename T>
class Roll_Object;
namespace YSG {
template <typename T>
class Roll_Object;
}
class BaseWidgetMenu;
void initClickButton(QPushButton* button, const QString &text, int fontSize, const std::function<void(void)> &mFunc, YSG::Roll_Object<QPushButton>*);
QPushButton *createClickButton(const QString &text, int fontSize, const std::function<void(void)> &mFunc, YSG::Roll_Object<QPushButton>*);
void initClickButton(QPushButton* button, const QString& text, int fontSize, const std::function<void(void)>& mFunc, YSG::Roll_Object<QPushButton>*);
QPushButton* createClickButton(const QString& text, int fontSize, const std::function<void(void)>& mFunc, YSG::Roll_Object<QPushButton>*);
QPushButton* createNormal(const QString& text, int fontSize, const std::function<void(void)>& mFunc = nullptr);
#endif
+2 -4
View File
@@ -5,10 +5,8 @@
#endif
#include "./BackEnd/MainWidget.h"
#include "Application.h"
#include "YSGraphic_Core/base/Plot.h"
int main(int argc, char *argv[]) {
#include "YSGraphic_Core/architecture/export.h"
int main(int argc, char* argv[]) {
Application app(argc, argv);
Application::setAttribute(Qt::AA_UseHighDpiPixmaps);
BackEnd::instance();
-2
View File
@@ -1,7 +1,5 @@
#ifndef BaseWidgetMenu_H
#define BaseWidgetMenu_H
#include "YSGraphic_Core/base/Node.hpp"
#include "YSGraphic_Core/base/Roll_Object.h"
#include "YSGraphic_Core/export.h"
#include <QMap>