/
wmigor
/
z-plane
Обзор
Документация
Войти
/
wmigor
/
z-plane
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
editor/src/AirfoilEditor.cpp
103 строки
3 KB
wmigor
Добавлены графики аэродинамических коэффициентов профиля
07 июн 2026, 23:17
Верифицирован
07 июн 2026, 23:17
d94fa3b
Код
Авторство
О чём код?
#include "AirfoilEditor.h" #include "ui_AirfoilEditor.h" #include <QChartView> #include <QChart> #include <QLineSeries> #include <QValueAxis> #include <asim/Airfoil.h> AirfoilEditor::AirfoilEditor(): QWidget(), _ui(std::make_unique<Ui::AirfoilEditor>()) { _ui->setupUi(this); _chartView = new QChartView(); layout()->addWidget(_chartView); setDefaultGuiValues(); updatePlots(); connect(_ui->liftSlope, &QDoubleSpinBox::valueChanged, this, &AirfoilEditor::updatePlots); connect(_ui->stallAngleMax, &QDoubleSpinBox::valueChanged, this, &AirfoilEditor::updatePlots); connect(_ui->stallAngleMin, &QDoubleSpinBox::valueChanged, this, &AirfoilEditor::updatePlots); connect(_ui->zeroLiftAngle, &QDoubleSpinBox::valueChanged, this, &AirfoilEditor::updatePlots); connect(_ui->stallWidth, &QDoubleSpinBox::valueChanged, this, &AirfoilEditor::updatePlots); connect(_ui->dragMin, &QDoubleSpinBox::valueChanged, this, &AirfoilEditor::updatePlots); connect(_ui->smallUavFactor, &QDoubleSpinBox::valueChanged, this, &AirfoilEditor::updatePlots); connect(_ui->aspectRatio, &QDoubleSpinBox::valueChanged, this, &AirfoilEditor::updatePlots); connect(_ui->range, &QDoubleSpinBox::valueChanged, this, &AirfoilEditor::updatePlots); } AirfoilEditor::~AirfoilEditor() = default; void AirfoilEditor::setDefaultGuiValues() { asim::Airfoil airfoil; auto &settings = airfoil.baseSettings; _ui->liftSlope->setValue(settings.liftSlope); _ui->stallAngleMax->setValue(glm::degrees(settings.stallAngleMax)); _ui->stallAngleMin->setValue(glm::degrees(settings.stallAngleMin)); _ui->zeroLiftAngle->setValue(glm::degrees(settings.zeroLiftAngle)); _ui->stallWidth->setValue(glm::degrees(settings.stallWidth)); _ui->dragMin->setValue(settings.dragMin); _ui->smallUavFactor->setValue(airfoil.smallUavFactor); } void AirfoilEditor::readAirfoilValues(asim::Airfoil *airfoil) { airfoil->smallUavFactor = _ui->smallUavFactor->value(); airfoil->baseSettings.liftSlope = _ui->liftSlope->value(); airfoil->baseSettings.stallAngleMax = glm::radians(_ui->stallAngleMax->value()); airfoil->baseSettings.stallAngleMin = glm::radians(_ui->stallAngleMin->value()); airfoil->baseSettings.zeroLiftAngle = glm::radians(_ui->zeroLiftAngle->value()); airfoil->baseSettings.stallWidth = glm::radians(_ui->stallWidth->value()); airfoil->baseSettings.dragMin = _ui->dragMin->value(); } void AirfoilEditor::updatePlots() { asim::Airfoil airfoil; asim::Airfoil::WingData wing; wing.aspectRatio = _ui->aspectRatio->value(); readAirfoilValues(&airfoil); auto chart = new QChart(); chart->setTitle("Airfoil"); auto liftLine = new QLineSeries(); liftLine->setName("CL"); auto dragLine = new QLineSeries(); dragLine->setName("CD"); auto pitchLine = new QLineSeries(); pitchLine->setName("CM"); auto range = _ui->range->value(); auto degree = -range; auto step = 0.1; while (degree <= range) { wing.angle = glm::radians(degree); auto factors = airfoil.calculate(wing); liftLine->append(degree, factors.lift); dragLine->append(degree, factors.drag); pitchLine->append(degree, factors.pitch); degree += step; } chart->addSeries(liftLine); chart->addSeries(dragLine); chart->addSeries(pitchLine); chart->createDefaultAxes(); auto axisY = dynamic_cast<QValueAxis *>(chart->axes(Qt::Vertical)[0]); if (axisY != NULL) { auto range = glm::max(glm::abs(axisY->min()), glm::abs(axisY->max())); axisY->setRange(-range, range); } _chartView->setChart(chart); }