This commit is contained in:
royalcat 2023-05-24 03:04:44 +03:00
parent dffc96fd77
commit bb3a759dd6
3 changed files with 51 additions and 16 deletions

View file

@ -69,13 +69,13 @@ void MainWindow::on_pushButton_5_clicked() {
for (int i = 0; i < bn; ++i) { for (int i = 0; i < bn; ++i) {
for (int j = 0; j < en; ++j) { for (int j = 0; j < en; ++j) {
this->canvas->FDNMass[i][j].col = QColor(this->canvas->FDNMass[i][j].amp); this->canvas->FDNMass[i][j].col = QColor::fromHsvF(this->canvas->FDNMass[i][j].amp, 1, 1);
} }
} }
ToPaintState state(4); ToPaintState state(4);
state.axisX = maxA; state.axisX = vals.to_azimut;
state.axisY = maxA; state.axisY = vals.to_azimut;
this->canvas->drawState(state); this->canvas->drawState(state);
} }
@ -88,6 +88,9 @@ void MainWindow::on_pushButton_clicked()
void MainWindow::on_pushButton_2_clicked() void MainWindow::on_pushButton_2_clicked()
{ {
this->canvas->drawState(ToPaintState(3)); ToPaintState state(3);
state.axisX=M_PI*2;
state.axisY=M_PI*2;
this->canvas->drawState(state);
} }

View file

@ -4,6 +4,30 @@
#include <qsize.h> #include <qsize.h>
#include <qwidget.h> #include <qwidget.h>
void MyCanvas::ColorAxis(QPaintEvent *event, QPainter *painter, double step, double max) {
double centerX = event->rect().width()/2;
double centerY = event->rect().height()/2;
painter->setPen(QPen(QColor(0,0,0)));
painter->drawLine(QLineF(centerX, 0, centerX, event->rect().height()));
painter->drawLine(QLineF(0, centerY, event->rect().width(), centerY));
for (double x = 0; x<max; x+=step) {
painter->drawText(transposePoint(x, 0, max, max),
QString::number(x, 'f', 2));
}
for (double x = 0; x>-max; x-=step) {
painter->drawText(transposePoint(x, 0, max, max),
QString::number(x, 'f', 2));
}
for (double y = 0; y<max; y+=step) {
painter->drawText(transposePoint(0, y, max, max),
QString::number(y, 'f', 2));
}
for (double y = 0; y>-max; y-=step) {
painter->drawText(transposePoint(0, y, max, max),
QString::number(y, 'f', 2));
}
}
MyCanvas::MyCanvas(QWidget *parent) : QWidget(parent) { MyCanvas::MyCanvas(QWidget *parent) : QWidget(parent) {
// chart()->setTitle("Фазовое распределение антенных решеток"); // chart()->setTitle("Фазовое распределение антенных решеток");
// chart()->legend()->hide(); // chart()->legend()->hide();
@ -23,6 +47,7 @@ void MyCanvas::drawState(ToPaintState state) {
void MyCanvas::paintEvent(QPaintEvent *event) { void MyCanvas::paintEvent(QPaintEvent *event) {
QPainter painter(this); QPainter painter(this);
painter.fillRect(event->rect(), QColor(255,255,255));
switch (this->state.type) { switch (this->state.type) {
@ -39,10 +64,12 @@ void MyCanvas::paintEvent(QPaintEvent *event) {
case 2: case 2:
// IAmpIzls // IAmpIzls
this->ColorAxis(event, &painter, state.axisX/5, state.axisX);
for (int i = 0; i < this->radar.FIzlArray.size(); ++i) { for (int i = 0; i < this->radar.FIzlArray.size(); ++i) {
TIzl izls = radar.FIzlArray[i]; TIzl izls = radar.FIzlArray[i];
painter.setPen(QPen(QColor(izls.Amplitude))); painter.setPen(QPen(QColor::fromHsvF(izls.Amplitude, 1, 1)));
QRectF rect = this->transposeRect(izls.IzPos.Z - 0.008, izls.IzPos.Y - 0.011, izls.IzPos.Z + 0.008, izls.IzPos.Y + 0.011, state.axisX, state.axisY); QRectF rect = this->transposeRect(izls.IzPos.Z - 0.008, izls.IzPos.Y - 0.011, izls.IzPos.Z + 0.008, izls.IzPos.Y + 0.011, state.axisX, state.axisY);
painter.drawRect(rect); painter.drawRect(rect);
@ -50,11 +77,13 @@ void MyCanvas::paintEvent(QPaintEvent *event) {
break; break;
case 3: case 3:
// FazIzls // FazIzls
this->ColorAxis(event, &painter, state.axisX/5, state.axisX);
for (int i = 0; i < this->radar.FIzlArray.size(); ++i) { for (int i = 0; i < this->radar.FIzlArray.size(); ++i) {
TIzl izls = radar.FIzlArray[i]; TIzl izls = radar.FIzlArray[i];
double faz = frac(izls.Fase*0.5/M_PI)*2/M_PI; double faz = frac(izls.Fase*0.5/M_PI)*2/M_PI;
painter.setPen(QPen(QColor(faz))); painter.setPen(QPen(QColor::fromHsvF(faz, 1,1)));
QRectF rect = this->transposeRect( QRectF rect = this->transposeRect(
izls.IzPos.Z - 0.008, izls.IzPos.Y - 0.011, izls.IzPos.Z + 0.008, izls.IzPos.Y + 0.011, izls.IzPos.Z - 0.008, izls.IzPos.Y - 0.011, izls.IzPos.Z + 0.008, izls.IzPos.Y + 0.011,
@ -64,11 +93,12 @@ void MyCanvas::paintEvent(QPaintEvent *event) {
break; break;
case 4: case 4:
// DN // DN
this->ColorAxis(event, &painter, state.axisX/5, state.axisX);
for (int i = 0; i < this->FDNMass.size(); ++i) { for (int i = 0; i < this->FDNMass.size(); ++i) {
for (int j = 0; j < this->FDNMass[i].size(); ++j) { for (int j = 0; j < this->FDNMass[i].size(); ++j) {
TColPoint mass = FDNMass[i][j]; TColPoint mass = FDNMass[i][j];
QPen pen = QPen(QColor(255,255,255)); QPen pen = QPen(QColor(0,0,0));
pen.setWidth(5);
painter.setPen(pen); painter.setPen(pen);
QPointF point = transposePoint(mass.x, mass.y, state.axisX, state.axisY); QPointF point = transposePoint(mass.x, mass.y, state.axisX, state.axisY);
@ -81,14 +111,17 @@ void MyCanvas::paintEvent(QPaintEvent *event) {
// chart()->addSeries(series1); // chart()->addSeries(series1);
} }
QPointF MyCanvas::transposePoint(double x, double y, double axisX, double axisY) { QPointF MyCanvas::transposePoint(double x, double y, double axisX, double axisY) {
double cwidth = static_cast<double>(width())/axisX; double cwidth = static_cast<double>(width())/(axisX*2);
double cheight = static_cast<double>(height())/axisY; double cheight = static_cast<double>(height())/(axisY*2);
double zeroX = cwidth/2; double zeroX = width()/2;
double zeroY = cheight/2; double zeroY = height()/2;
return QPointF(zeroX + (x * cwidth), zeroY + (y * cheight)); QPointF point(zeroX + (x * cwidth), zeroY + (y * cheight));
return point;
} }
QRectF MyCanvas::transposeRect(double x, double y, double x2, double y2, double axisX, double axisY) { QRectF MyCanvas::transposeRect(double x, double y, double x2, double y2, double axisX, double axisY) {

View file

@ -35,8 +35,7 @@ public:
TRadar radar = TRadar(); TRadar radar = TRadar();
QVector<QVector<TColPoint>> FDNMass; QVector<QVector<TColPoint>> FDNMass;
void drawState(ToPaintState); void drawState(ToPaintState);
void ColorAxis(QPaintEvent *event, QPainter *painter, double step, double max);
private: private:
ToPaintState state = ToPaintState(); ToPaintState state = ToPaintState();