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

117 lines
3.5 KiB
C++

#include "mycanvas.h"
MyCanvas::MyCanvas(QWidget *parent) : QChartView(new QChart(), 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;
chart()->removeAllSeries();
chart()->createDefaultAxes();
QScatterSeries *series1 = new QScatterSeries();
series1->setMarkerSize(5);
switch (this->state.type) {
case 1: // фазвовое распределение
{
series1->setMarkerShape(QScatterSeries::MarkerShapeRectangle);
for (int i = 0; i < this->radar.FIzlArray.size(); i++) {
int c = i % 4;
TIzl izls = radar.FIzlArray[i];
// double x = izls.IzPos.Z - 0.0085;
// double y = izls.IzPos.Y - 0.0115;
// double x2 = izls.IzPos.Z + 0.0085;
// double y2 = izls.IzPos.Y + 0.0115;
// series1->setPen(QPen(QColor(63 * c, 255 - 63 * c, 163 * c)));
*series1 << QPointF(izls.IzPos.Z, izls.IzPos.Y);
}
chart()->addSeries(series1);
}
break;
case 2:
// IAmpIzls
{
series1->setMarkerShape(QScatterSeries::MarkerShapeRectangle);
//series1->setPen(QPen(QColor(izls.Amplitude)));
for (int i = 0; i < this->radar.FIzlArray.size(); ++i) {
TIzl izls = radar.FIzlArray[i];
QPoint point(izls.IzPos.Z, izls.IzPos.Y);
series1->append(point);
}
chart()->addSeries(series1);
// for(int index= 0; index < series1->count(); index++){
// QPointF p = chart()->mapToPosition(series1->at(index) , series1);
// QGraphicsItem *it = this->itemAt(this->mapFromScene(p));
// if(QGraphicsRectItem *rect = qgraphicsitem_cast<QGraphicsRectItem*>(it)){
// QColor color = QColor(radar.FIzlArray[index].Amplitude);;
// rect->setBrush(color);
// }
// }
}
break;
case 3:
{
// FazIzls
series1->setMarkerShape(QScatterSeries::MarkerShapeRectangle);
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;
// double x = izls.IzPos.Z - 0.008;
// double y = izls.IzPos.Y - 0.011;
// double x2 = izls.IzPos.Z + 0.008;
// double y2 = izls.IzPos.Y + 0.011;
//series1->setPen(QPen(QColor(faz)));
series1->append(QPointF(izls.IzPos.Z, izls.IzPos.Y));
}
chart()->addSeries(series1);
}
break;
case 4:
{
// DN
series1->setMarkerShape(QScatterSeries::MarkerShapeCircle);
series1->setMarkerSize(20);
for (int i = 0; i < this->FDNMass.size(); ++i) {
for (int j = 0; j < this->FDNMass[i].size(); ++j) {
//series1->setPen(QPen(QColor(this->FDNMass[i][j].col)));
double x =this->FDNMass[i][j].x,
y = this->FDNMass[i][j].y;
*series1 << QPointF(x, y);
}
}
}
break;
}
chart()->addSeries(series1);
}