2023-05-16 14:58:12 +00:00
|
|
|
#include "mycanvas.h"
|
2023-05-17 23:08:48 +00:00
|
|
|
#include <qpainter.h>
|
|
|
|
#include <qpen.h>
|
|
|
|
#include <qsize.h>
|
|
|
|
#include <qwidget.h>
|
|
|
|
|
|
|
|
MyCanvas::MyCanvas(QWidget *parent) : QWidget(parent) {
|
|
|
|
// chart()->setTitle("Фазовое распределение антенных решеток");
|
|
|
|
// chart()->legend()->hide();
|
|
|
|
|
|
|
|
// QValueAxis *qAxisX = new QValueAxis();
|
|
|
|
// QValueAxis *qAxisY = new QValueAxis();
|
|
|
|
// qAxisX->setRange(-1, 1);
|
|
|
|
// qAxisY->setRange(-1, 1);
|
|
|
|
// chart()->addAxis(qAxisX, Qt::AlignLeft);
|
|
|
|
// chart()->addAxis(qAxisY, Qt::AlignBottom);
|
2023-05-16 14:58:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyCanvas::drawState(ToPaintState state) {
|
2023-05-17 23:08:48 +00:00
|
|
|
this->state = state;
|
|
|
|
this->update();
|
|
|
|
}
|
2023-05-16 14:58:12 +00:00
|
|
|
|
2023-05-17 23:08:48 +00:00
|
|
|
void MyCanvas::paintEvent(QPaintEvent *event) {
|
|
|
|
QPainter painter(this);
|
2023-05-16 14:58:12 +00:00
|
|
|
|
|
|
|
|
2023-05-17 23:08:48 +00:00
|
|
|
switch (this->state.type) {
|
|
|
|
case 1:
|
|
|
|
for (int i = 0; i < this->radar.FIzlArray.size(); ++i) {
|
2023-05-16 14:58:12 +00:00
|
|
|
|
2023-05-17 23:08:48 +00:00
|
|
|
int c = i % 4;
|
|
|
|
painter.setPen(QPen(QColor(63 * c, 255 - 63 * c, 163 * c)));
|
2023-05-16 14:58:12 +00:00
|
|
|
|
2023-05-17 23:08:48 +00:00
|
|
|
TIzl izls = radar.FIzlArray[i];
|
|
|
|
QRectF rect = this->transposeRect(izls.IzPos.Z - 0.0085, izls.IzPos.Y - 0.0115, izls.IzPos.Z + 0.0085, izls.IzPos.Y + 0.0115, state.axisX, state.axisY);
|
|
|
|
painter.drawRect(rect);
|
|
|
|
}
|
2023-05-16 14:58:12 +00:00
|
|
|
|
2023-05-17 23:08:48 +00:00
|
|
|
case 2:
|
|
|
|
// IAmpIzls
|
|
|
|
for (int i = 0; i < this->radar.FIzlArray.size(); ++i) {
|
2023-05-16 14:58:12 +00:00
|
|
|
|
2023-05-17 23:08:48 +00:00
|
|
|
TIzl izls = radar.FIzlArray[i];
|
|
|
|
painter.setPen(QPen(QColor(izls.Amplitude)));
|
2023-05-16 14:58:12 +00:00
|
|
|
|
2023-05-17 23:08:48 +00:00
|
|
|
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);
|
2023-05-16 14:58:12 +00:00
|
|
|
}
|
|
|
|
break;
|
2023-05-17 23:08:48 +00:00
|
|
|
case 3:
|
|
|
|
// FazIzls
|
|
|
|
for (int i = 0; i < this->radar.FIzlArray.size(); ++i) {
|
|
|
|
|
|
|
|
TIzl izls = radar.FIzlArray[i];
|
|
|
|
double faz = frac(izls.Fase*0.5/M_PI)*2/M_PI;
|
|
|
|
painter.setPen(QPen(QColor(faz)));
|
|
|
|
|
|
|
|
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);
|
2023-05-16 14:58:12 +00:00
|
|
|
}
|
|
|
|
break;
|
2023-05-17 23:08:48 +00:00
|
|
|
case 4:
|
|
|
|
// DN
|
|
|
|
for (int i = 0; i < this->FDNMass.size(); ++i) {
|
|
|
|
for (int j = 0; j < this->FDNMass[i].size(); ++j) {
|
|
|
|
TColPoint mass = FDNMass[i][j];
|
|
|
|
QPen pen = QPen(QColor(255,255,255));
|
|
|
|
pen.setWidth(5);
|
|
|
|
painter.setPen(pen);
|
|
|
|
|
|
|
|
QPointF point = transposePoint(mass.x, mass.y, state.axisX, state.axisY);
|
|
|
|
painter.drawPoint(point);
|
|
|
|
}
|
2023-05-16 14:58:12 +00:00
|
|
|
}
|
|
|
|
break;
|
2023-05-17 23:08:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// chart()->addSeries(series1);
|
|
|
|
}
|
2023-05-16 14:58:12 +00:00
|
|
|
|
2023-05-17 23:08:48 +00:00
|
|
|
QPointF MyCanvas::transposePoint(double x, double y, double axisX, double axisY) {
|
|
|
|
double cwidth = static_cast<double>(width())/axisX;
|
|
|
|
double cheight = static_cast<double>(height())/axisY;
|
2023-05-16 14:58:12 +00:00
|
|
|
|
2023-05-17 23:08:48 +00:00
|
|
|
double zeroX = cwidth/2;
|
|
|
|
double zeroY = cheight/2;
|
|
|
|
|
|
|
|
return QPointF(zeroX + (x * cwidth), zeroY + (y * cheight));
|
|
|
|
}
|
2023-05-16 14:58:12 +00:00
|
|
|
|
2023-05-17 23:08:48 +00:00
|
|
|
QRectF MyCanvas::transposeRect(double x, double y, double x2, double y2, double axisX, double axisY) {
|
|
|
|
return QRectF(transposePoint(x, y, axisX, axisY), transposePoint(x2, y2, axisX, axisY));
|
2023-05-16 14:58:12 +00:00
|
|
|
}
|