From 99f4ed4f0c1372ca50aa8a6dc671111c78d2f95c Mon Sep 17 00:00:00 2001 From: royalcat Date: Tue, 16 May 2023 17:58:12 +0300 Subject: [PATCH] init --- .gitignore | 64 ++++++++++++ CMakeLists.txt | 50 +++++++++ RadarExt.h | 226 ++++++++++++++++++++++++++++++++++++++++ Readme | 28 +++++ kvedit.cpp | 22 ++++ kvedit.h | 30 ++++++ kvedit.ui | 273 +++++++++++++++++++++++++++++++++++++++++++++++++ main.cpp | 10 ++ mainwindow.cpp | 89 ++++++++++++++++ mainwindow.h | 45 ++++++++ mainwindow.ui | 155 ++++++++++++++++++++++++++++ mycanvas.cpp | 117 +++++++++++++++++++++ mycanvas.h | 42 ++++++++ 13 files changed, 1151 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 RadarExt.h create mode 100644 Readme create mode 100644 kvedit.cpp create mode 100644 kvedit.h create mode 100644 kvedit.ui create mode 100644 main.cpp create mode 100644 mainwindow.cpp create mode 100644 mainwindow.h create mode 100644 mainwindow.ui create mode 100644 mycanvas.cpp create mode 100644 mycanvas.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b9d4ce0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,64 @@ +# C++ objects and libs +*.slo +*.lo +*.o +*.a +*.la +*.lai +*.so +*.so.* +*.dll +*.dylib + +# Qt-es +object_script.*.Release +object_script.*.Debug +*_plugin_import.cpp +/.qmake.cache +/.qmake.stash +*.pro.user +*.pro.user.* +*.qbs.user +*.qbs.user.* +*.moc +moc_*.cpp +moc_*.h +qrc_*.cpp +ui_*.h +*.qmlc +*.jsc +Makefile* +*build-* +*.qm +*.prl + +# Qt unit tests +target_wrapper.* + +# QtCreator +*.autosave + +# QtCreator Qml +*.qmlproject.user +*.qmlproject.user.* + +# QtCreator CMake +CMakeLists.txt.user* + +# QtCreator 4.8< compilation database +compile_commands.json + +# QtCreator local machine specific files for imported projects +*creator.user* + +*_qmlcache.qrc + +build/ +.qtc_clangd +cmake_install.cmake +qtbuild* +CMakeFiles +.qtc +.qt +.cmake +qtcsettings.cmake \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..c2ccd5a --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,50 @@ +cmake_minimum_required(VERSION 3.5) + +project(Aperture VERSION 0.1 LANGUAGES CXX) + +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(Qt6 REQUIRED COMPONENTS Widgets Charts Gui OpenGLWidgets OpenGL) + +set(PROJECT_SOURCES + main.cpp + mainwindow.h mainwindow.cpp + mycanvas.h mycanvas.cpp + RadarExt.h + kvedit.h kvedit.cpp kvedit.ui + mainwindow.ui +) + +qt_add_executable(Aperture + MANUAL_FINALIZATION + ${PROJECT_SOURCES} +) + +target_link_libraries(Aperture PRIVATE Qt6::Widgets) +target_link_libraries(Aperture PRIVATE Qt6::Charts) +target_link_libraries(Aperture PRIVATE Qt6::Gui) +target_link_libraries(Aperture PRIVATE Qt6::OpenGLWidgets) +target_link_libraries(Aperture PRIVATE Qt6::OpenGL) + + +set_target_properties(Aperture PROPERTIES + MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com + MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} + MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} + MACOSX_BUNDLE TRUE + WIN32_EXECUTABLE TRUE +) + +install(TARGETS Aperture + BUNDLE DESTINATION . + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) + + +qt_finalize_executable(Aperture) diff --git a/RadarExt.h b/RadarExt.h new file mode 100644 index 0000000..15cf5e8 --- /dev/null +++ b/RadarExt.h @@ -0,0 +1,226 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define M_Pi 3.14159265358979323846 + +const float PDBt[] = { + 1, 0.9996547, 0.9986309, 0.9969996, 0.9947753, 0.992019, + 0.9887693, 0.9850653, 0.9809683, 0.9765174, 0.971751, 0.9667184, + 0.9614573, 0.9560267, 0.9504516, 0.9447785, 0.9390528, 0.9333188, + 0.9275984, 0.9219344, 0.9163682, 0.9109405, 0.9056805, 0.9006271, + 0.8958081, 0.8912509, 0.8869824, 0.8829681, 0.8791338, 0.8754372, + 0.8718264, 0.8682404, 0.8646393, 0.860964, 0.8571661, 0.8531983, + 0.8490143, 0.8445687, 0.839808, 0.8346896, 0.8291822, 0.8232277, + 0.8168081, 0.8098694, 0.8023891, 0.7943282, 0.7856697, 0.7763812, + 0.7664432, 0.7558489, 0.7445777, 0.7326305, 0.7200042, 0.7066999, + 0.6927157, 0.6780707, 0.662781, 0.646867, 0.6303547, 0.6132747, + 0.5956622, 0.5774907, 0.5584638, 0.5382822, 0.5167018, 0.4935714, + 0.468808, 0.442405, 0.4144718, 0.3851855, 0.3548133, 0.3237017, + 0.2922504, 0.2609126, 0.2301495, 0.200431, 0.1721929, 0.1458194, + 0.121624, 0.09983687, 0.08058908, 0.06391948, 0.0497765, 0.03802762, + 0.02847982, 0.02089019, 0.01499667, 0.01053091, 0.007224957, 0.004837355, + 0.003162278}; +const float PDEp[] = { + 1, 0.9996316, 0.9985504, 0.9968045, 0.9944203, 0.9914481, + 0.9879273, 0.9838978, 0.9793998, 0.9744846, 0.9691924, 0.9635517, + 0.9576239, 0.9514369, 0.9450287, 0.9384475, 0.9317298, 0.9249111, + 0.9180366, 0.9111293, 0.9042219, 0.8973668, 0.890574, 0.8838936, + 0.8773442, 0.8709636, 0.8647489, 0.8585884, 0.8523442, 0.8458824, + 0.8390831, 0.8318213, 0.8239674, 0.8154268, 0.8060834, 0.7958478, + 0.7846211, 0.7723337, 0.758927, 0.7443291, 0.7285175, 0.7114592, + 0.6931624, 0.6736201, 0.6528674, 0.6309574, 0.607974, 0.5841374, + 0.5596867, 0.5348352, 0.5097944, 0.4847524, 0.4598857, 0.4353415, + 0.4112633, 0.3877663, 0.3649471, 0.3428861, 0.3216511, 0.3012902, + 0.2818383, 0.2632964, 0.2455697, 0.2285625, 0.2121999, 0.1964332, + 0.1812278, 0.1665692, 0.1524526, 0.1388895, 0.1258924, 0.1134879, + 0.101702, 0.09056489, 0.08010306, 0.07034202, 0.06130171, 0.05299528, + 0.04542796, 0.03859663, 0.03248846, 0.02707951, 0.02234502, 0.01824281, + 0.01473092, 0.0117601, 0.009273618, 0.007224957, 0.005558777, 0.004219005, + 0.003162278}; + +const double KDeg = 57.295779513; + +struct TPoint3D { + TPoint3D() {} + TPoint3D(float x, float y, float z) : X(x), Y(y), Z(z) {} + + float X = 0; + float Y = 0; + float Z = 0; +}; + +struct TIzl { + TIzl() {} + TIzl(TPoint3D pos, float amp, float fase) : IzPos(pos), Amplitude(amp), Fase(fase) {} + + TPoint3D IzPos = TPoint3D(); + float Amplitude = 0; + float Fase = 0; +}; + +class TRadar { + +public: + const double FZAntena = 0.7; // половина антены по оси Z в м + const double FYAntena = 0.4; // половина антены по оси Y в м + const double FZYA = FZAntena * FYAntena; // Вспомогательная величина характеризующая геометрию антены + const double FLym = 0.03; + const double FKLym = M_Pi * 2 / FLym; + const double FStepZ = 0.017; + const double FStepY = 0.023; + const double FPowerValue = 0.75; + const double FKof132 = 1.32; + + std::vector FIzlArray; + + std::complex FSum, FAz, FUm; + double FSumAmp, FAzAmp, FUmAmp; + + double GetAmpOneIzl(float tet, float fi); + TIzl GetIzl(int i); + + void FillArrayIzl(); // FillArrayIzl1 + + TRadar(); + ~TRadar(); + + void GetAmplituds(float tet, float fi, float offsetTet, float offsetFi); + + std::vector Izls() const { return this->FIzlArray; } + double GetSumAmp() const { return this->FSumAmp; } + double GetAzAmp() const { return this->FAzAmp; } + double GetUmAmp() const { return this->FUmAmp; } + std::complex GetSum() const { return this->FSum; } + std::complex GetAz() const { return this->FAz; } + std::complex GetUm() const { return this->FUm; } +}; + +inline TRadar::TRadar() { + this->FillArrayIzl(); +} + +inline TRadar::~TRadar() {} + +inline double frac(double t) { return t - floor(t); } + +inline double TRadar::GetAmpOneIzl(float tet, float fi) { + int i; + std::complex wc{}; + + wc.real(std::abs(tet * KDeg)); + i = std::trunc(wc.real()); + wc.real(PDBt[i] + frac(wc.real()) * (PDBt[i + 1] - PDBt[i])); + + wc.imag(fi * KDeg); + i = std::trunc(wc.imag()); + wc.imag(PDEp[i] + frac(wc.real()) * (PDEp[i + 1] - PDEp[i])); + + return wc.real() * wc.imag(); +} + +inline void TRadar::GetAmplituds(float tet, float fi, float offsetTet, + float offsetFi) { + double pda = GetAmpOneIzl(offsetTet, offsetFi); + + tet = (std::sin(offsetTet) * std::cos(offsetFi) - + std::sin(tet) * std::cos(fi)) * + FKLym; + fi = (std::sin(offsetFi) * std::sin(fi)) * FKLym; + + std::complex us[4]{}; + + int c; + + for (int i = 0; i < FIzlArray.size(); i++) { + auto Izl = FIzlArray[i]; + Izl.Fase = Izl.IzPos.Z * tet + Izl.IzPos.Y * fi; + + c = i % 4; + us[c].real(us[c].real() + Izl.Amplitude * std::cos(Izl.Fase)); + us[c].imag(us[c].imag() + Izl.Amplitude * std::sin(Izl.Fase)); + } + + FSum.real((us[0].real() + us[1].real() + us[2].real() + us[3].real()) * pda); + FSum.imag((us[0].imag() + us[1].imag() + us[2].imag() + us[3].imag()) * pda); + + FAz.real((us[1].real() + us[2].real() + us[3].real() + us[0].real()) * pda); + FAz.imag((us[1].imag() + us[2].imag() + us[3].imag() + us[0].imag()) * pda); + + FUm.real((us[2].real() + us[3].real() + us[0].real() + us[1].real()) * pda); + FUm.imag((us[2].imag() + us[3].imag() + us[0].imag() + us[1].imag()) * pda); + + FSumAmp = std::abs(FSum); + FAzAmp = std::abs(FAz); + FUmAmp = std::abs(FUm); +} + +inline void TRadar::FillArrayIzl() { + const int + IzCountZ = 72, // Кол-во излучателей по оси Z ( Если предпологать, что антена прямоугольная ) + IzCountY = 35; // Кол-во излучателей по оси Y ( Если предпологать, что антена прямоугольная ) + const double + OfZ =-FStepZ*0.5-35*FStepZ, + OfY =-FStepY*0.25-17*FStepY; + + std::vector U1, U2, U3, U4; + + for (int i = 0; i < IzCountY-1; i++) { + for (int j = 0; j < IzCountZ-1; j++) { + float z = OfY+j*FStepZ; + float y; + if (j%2 == 0) { + y = OfY+FStepY*i; + } else { + y = OfY+FStepY*(i+0.5); + } + + float r = 1; + + if (z>0) { + if (y>0) { + U1.push_back(TIzl(TPoint3D(0, y, z), r, 0)); + } else { + U4.push_back(TIzl(TPoint3D(0, y, z), r, 0)); + } + } else { + if (y>0) { + U2.push_back(TIzl(TPoint3D(0, y, z), r, 0)); + } else { + U3.push_back(TIzl(TPoint3D(0, y, z), r, 0)); + } + } + } + } + + int maxLen = U1.size(); + if (U2.size()>maxLen) { + maxLen = U2.size(); + } + if (U3.size()>maxLen) { + maxLen = U3.size(); + } + if (U4.size()>maxLen) { + maxLen = U4.size(); + } + + U1.resize(maxLen, TIzl(TPoint3D(0, 0, 0), 0, 0)); + U2.resize(maxLen, TIzl(TPoint3D(0, 0, 0), 0, 0)); + U3.resize(maxLen, TIzl(TPoint3D(0, 0, 0), 0, 0)); + U4.resize(maxLen, TIzl(TPoint3D(0, 0, 0), 0, 0)); + + for (int i = 0; i < maxLen; i++) { + this->FIzlArray.push_back(U1[i]); + this->FIzlArray.push_back(U2[i]); + this->FIzlArray.push_back(U3[i]); + this->FIzlArray.push_back(U4[i]); + } +} diff --git a/Readme b/Readme new file mode 100644 index 0000000..f85ad30 --- /dev/null +++ b/Readme @@ -0,0 +1,28 @@ + + +Lable1 = "Азимут" +Lable2 = "Угол места" + +Button1 = "Амплитудное распределение" +Button2 = "Фазовое распределение" +Button3 = "Положение излучателей" +Button4 = "Время работы" +Button5 = "Диаграмма направленности" + +ValueListEditorExt1 = " +Параметр Значение +-------------------------------- +ДН Азимут = 0 +ДН Угол места = 0 + +От Азимут = -5 +До Азимут = 5 +Шаг Азимут = 0.05 + +От Угол места = -5 +До Угол места = 5 +Шаг Угол места = 0.05 + +Размер точки = 5 +" + diff --git a/kvedit.cpp b/kvedit.cpp new file mode 100644 index 0000000..3f134fe --- /dev/null +++ b/kvedit.cpp @@ -0,0 +1,22 @@ +#include "kvedit.h" +#include "ui_kvedit.h" + +KvEdit::KvEdit(QWidget *parent) : + QWidget(parent), + ui(new Ui::kvEdit) +{ + ui->setupUi(this); +} + +KvEdit::~KvEdit() +{ + delete ui; +} + +Values KvEdit::getValues() +{ + return Values{ui->dn_azimut->value(), ui->dn_angle->value(), + ui->from_angle->value(), ui->to_angle->value(), ui->step_angle->value(), + ui->from_angle->value(), ui->to_azimut->value(), ui->step_azimut->value()}; +} + diff --git a/kvedit.h b/kvedit.h new file mode 100644 index 0000000..db9572a --- /dev/null +++ b/kvedit.h @@ -0,0 +1,30 @@ +#ifndef KVEDIT_H +#define KVEDIT_H + +#include + +struct Values { + double dn_azimut, dn_angle, + from_angle, to_angle, step_angle, + from_azimut, to_azimut, step_azimut; +}; + +namespace Ui { +class kvEdit; +} + +class KvEdit : public QWidget +{ + Q_OBJECT + +public: + explicit KvEdit(QWidget *parent = nullptr); + ~KvEdit(); + + Values getValues(); + +private: + Ui::kvEdit *ui; +}; + +#endif // KVEDIT_H diff --git a/kvedit.ui b/kvedit.ui new file mode 100644 index 0000000..305258d --- /dev/null +++ b/kvedit.ui @@ -0,0 +1,273 @@ + + + kvEdit + + + + 0 + 0 + 311 + 345 + + + + Form + + + + + + + + ДН Азимут + + + + + + + -1000000000000000042420637374017961984.000000000000000 + + + 1000000000000000042420637374017961984.000000000000000 + + + + + + + + + + + ДН Угол места' + + + + + + + -1000000000000000042420637374017961984.000000000000000 + + + 1000000000000000042420637374017961984.000000000000000 + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + От ( Азимут ) + + + + + + + -1000000000000000042420637374017961984.000000000000000 + + + 1000000000000000042420637374017961984.000000000000000 + + + -5.000000000000000 + + + + + + + + + + + До ( Азимут ) + + + + + + + -1000000000000000042420637374017961984.000000000000000 + + + 1000000000000000042420637374017961984.000000000000000 + + + 5.000000000000000 + + + + + + + + + + + Шаг ( Азимут ) + + + + + + + -1000000000000000042420637374017961984.000000000000000 + + + 1000000000000000042420637374017961984.000000000000000 + + + 0.050000000000000 + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + От ( Угол места ) + + + + + + + -1000000000000000042420637374017961984.000000000000000 + + + 1000000000000000042420637374017961984.000000000000000 + + + -5.000000000000000 + + + + + + + + + + + До ( Угол места ) + + + + + + + -1000000000000000042420637374017961984.000000000000000 + + + 1000000000000000042420637374017961984.000000000000000 + + + 5.000000000000000 + + + + + + + + + 0 + + + + + Шаг ( Угол места ) + + + + + + + -1000000000000000042420637374017961984.000000000000000 + + + 1000000000000000042420637374017961984.000000000000000 + + + 0.050000000000000 + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Размер точки + + + + + + + -1000000000000000042420637374017961984.000000000000000 + + + 1000000000000000042420637374017961984.000000000000000 + + + 5.000000000000000 + + + + + + + + + + diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..58a0a63 --- /dev/null +++ b/main.cpp @@ -0,0 +1,10 @@ +#include "mainwindow.h" + +#include + +int main(int argc, char *argv[]) { + QApplication a(argc, argv); + MainWindow w; + w.show(); + return a.exec(); +} diff --git a/mainwindow.cpp b/mainwindow.cpp new file mode 100644 index 0000000..28ec969 --- /dev/null +++ b/mainwindow.cpp @@ -0,0 +1,89 @@ +#include "mainwindow.h" +#include "kvedit.h" +#include "ui_mainwindow.h" +#include +#include +#include + +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(qDegreesToRadians( + (vals.to_azimut - vals.from_azimut) / vals.step_azimut)); + int en = static_cast( + qDegreesToRadians((vals.to_angle - vals.from_angle) / vals.step_angle)); + + this->canvas->FDNMass.clear(); + this->canvas->FDNMass.resize(bn, QVector(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::min(); + double minA = std::numeric_limits::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)); +} + diff --git a/mainwindow.h b/mainwindow.h new file mode 100644 index 0000000..082afef --- /dev/null +++ b/mainwindow.h @@ -0,0 +1,45 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include +#include +#include "mycanvas.h" +#include "kvedit.h" + + + +QT_BEGIN_NAMESPACE +namespace Ui { +class MainWindow; +} +QT_END_NAMESPACE + +class MainWindow : public QMainWindow { + Q_OBJECT + +public: + MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + + private slots: + void on_pushButton_2_clicked(); + + private slots: + void on_pushButton_clicked(); + + private slots: + void on_pushButton_5_clicked(); + + private slots: + void on_pushButton_3_clicked(); + +private: + Ui::MainWindow *ui; + MyCanvas *canvas; + KvEdit *kvEdit; +}; + + + +#endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui new file mode 100644 index 0000000..b7c2065 --- /dev/null +++ b/mainwindow.ui @@ -0,0 +1,155 @@ + + + MainWindow + + + + 0 + 0 + 902 + 527 + + + + MainWindow + + + + + + 10 + 78 + 54 + 17 + + + + + Arial + 9 + + + + Азимут + + + + + + 10 + 114 + 91 + 17 + + + + + Arial + 9 + + + + Угол места + + + + + + 10 + 32 + 185 + 20 + + + + + Arial + 9 + + + + Амплитудное распределение + + + + + + 10 + 56 + 185 + 20 + + + + + Arial + 9 + + + + Положение излучателей + + + + + + 10 + 8 + 185 + 20 + + + + + Arial + 9 + + + + Фазовое распределение + + + + + + 10 + 140 + 185 + 20 + + + + + Arial + 9 + + + + Диаграмма направленности + + + + + + 330 + 20 + 531 + 431 + + + + + + + 10 + 170 + 311 + 345 + + + + + + + + diff --git a/mycanvas.cpp b/mycanvas.cpp new file mode 100644 index 0000000..41799a5 --- /dev/null +++ b/mycanvas.cpp @@ -0,0 +1,117 @@ + +#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(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); + + +} diff --git a/mycanvas.h b/mycanvas.h new file mode 100644 index 0000000..cda36f6 --- /dev/null +++ b/mycanvas.h @@ -0,0 +1,42 @@ +#ifndef MYCANVAS_H +#define MYCANVAS_H + +#include +#include +#include +#include +#include +#include +#include + +#include "RadarExt.h" + +struct TColPoint +{ + double x, y, amp; + QColor col; +}; + +class ToPaintState { +public: + ToPaintState() {} + ToPaintState(int type) : type (type) {} + + int type = 0; +}; + +class MyCanvas : public QChartView +{ + Q_OBJECT +public: + explicit MyCanvas(QWidget *parent = nullptr); + TRadar radar = TRadar(); + QVector> FDNMass; + void drawState(ToPaintState); + +private: + ToPaintState state = ToPaintState(); + +}; + +#endif // MYCANVAS_H