96 lines
2.9 KiB
C++
96 lines
2.9 KiB
C++
#include "mycanvas.h"
|
|
#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);
|
|
}
|
|
|
|
void MyCanvas::drawState(ToPaintState state) {
|
|
this->state = state;
|
|
this->update();
|
|
}
|
|
|
|
void MyCanvas::paintEvent(QPaintEvent *event) {
|
|
QPainter painter(this);
|
|
|
|
|
|
switch (this->state.type) {
|
|
case 1:
|
|
for (int i = 0; i < this->radar.FIzlArray.size(); ++i) {
|
|
|
|
int c = i % 4;
|
|
painter.setPen(QPen(QColor(63 * c, 255 - 63 * c, 163 * c)));
|
|
|
|
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);
|
|
}
|
|
|
|
case 2:
|
|
// IAmpIzls
|
|
for (int i = 0; i < this->radar.FIzlArray.size(); ++i) {
|
|
|
|
TIzl izls = radar.FIzlArray[i];
|
|
painter.setPen(QPen(QColor(izls.Amplitude)));
|
|
|
|
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);
|
|
}
|
|
break;
|
|
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);
|
|
}
|
|
break;
|
|
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);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
// chart()->addSeries(series1);
|
|
}
|
|
|
|
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;
|
|
|
|
double zeroX = cwidth/2;
|
|
double zeroY = cheight/2;
|
|
|
|
return QPointF(zeroX + (x * cwidth), zeroY + (y * cheight));
|
|
}
|
|
|
|
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));
|
|
}
|