Aperture/mainwindow.cpp
2023-05-16 17:58:12 +03:00

89 lines
2.4 KiB
C++

#include "mainwindow.h"
#include "kvedit.h"
#include "ui_mainwindow.h"
#include <QHBoxLayout>
#include <QLayout>
#include <QtMath>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow) {
ui->setupUi(this);
ui->canvas->setLayout(new QHBoxLayout());
this->canvas = new MyCanvas();
ui->canvas->layout()->addWidget(this->canvas);
ui->valueTable->setLayout(new QHBoxLayout());
this->kvEdit = new KvEdit();
ui->valueTable->layout()->addWidget(this->kvEdit);
}
MainWindow::~MainWindow() { delete ui; }
void MainWindow::on_pushButton_3_clicked() {
this->canvas->drawState(ToPaintState(1));
}
void MainWindow::on_pushButton_5_clicked() {
auto vals = this->kvEdit->getValues();
int bn = static_cast<int>(qDegreesToRadians(
(vals.to_azimut - vals.from_azimut) / vals.step_azimut));
int en = static_cast<int>(
qDegreesToRadians((vals.to_angle - vals.from_angle) / vals.step_angle));
this->canvas->FDNMass.clear();
this->canvas->FDNMass.resize(bn, QVector<TColPoint>(en));
double bdn = qDegreesToRadians(vals.dn_azimut);
double edn = qDegreesToRadians(vals.dn_angle);
double emin = qDegreesToRadians(vals.from_azimut);
double es = qDegreesToRadians(vals.step_angle);
double bs = qDegreesToRadians(vals.step_azimut);
double maxA = std::numeric_limits<double>::min();
double minA = std::numeric_limits<double>::max();
double b = qDegreesToRadians(vals.from_azimut);
for (int i = 0; i < bn; ++i) {
double e = emin;
for (int j = 0; j < en; ++j) {
this->canvas->radar.GetAmplituds(b, e, bdn, edn);
this->canvas->FDNMass[i][j].x = qRadiansToDegrees(b);
this->canvas->FDNMass[i][j].y = qRadiansToDegrees(e);
double sumAmp = this->canvas->radar.GetSumAmp();
this->canvas->FDNMass[i][j].amp = qRadiansToDegrees(sumAmp);
if (maxA < sumAmp) {
maxA = sumAmp;
}
if (minA > sumAmp) {
minA = sumAmp;
}
e = e + es;
}
b = b + bs;
}
// TODO DrawColorAsix
for (int i = 0; i < bn; ++i) {
for (int j = 0; j < en; ++j) {
this->canvas->FDNMass[i][j].col = QColor(this->canvas->FDNMass[i][j].amp);
}
}
this->canvas->drawState(ToPaintState(4));
}
void MainWindow::on_pushButton_clicked()
{
this->canvas->drawState(ToPaintState(2));
}
void MainWindow::on_pushButton_2_clicked()
{
this->canvas->drawState(ToPaintState(3));
}