#include "mainwindow.h" #include "ui_mainwindow.h" #include "QDebug" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); initializeGraphics(); connect(&m_wire,&Wire::calculation, [&]() { ui->lineEditWireGauge->setText(m_wire.gauge()); ui->lineEditWireWeight->setText(QString::number(m_wire.weight())); }); connect(&m_battery,&Battery::calculation, [&]() { ui->lineEditCellCount->setText(QString::number(m_battery.seriesCells())+"S"); ui->lineEditVoltageRange->setText(QString::number(m_battery.minimumPackVoltage())+" - "+QString::number(m_battery.maximumPackVoltage())); ui->lineEditPeakCurrent->setText(QString::number(m_battery.peakCurrent())); }); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_spinBoxPeakSystemPower_valueChanged(double arg1) { m_wire.setPeakSystemPower(arg1); m_wire.calculate(); m_battery.setPeakSystemPower(arg1); m_battery.calculate(); } void MainWindow :: initializeGraphics() { for(auto entry : batteries)ui->comboBoxBatteryChemistry->addItem(entry.name); for(auto entry : wireMaterials)ui->comboBoxWireMaterial->addItem(entry); } void MainWindow::on_comboBoxBatteryChemistry_currentIndexChanged(int index) { m_battery.changeBatteryChemistry(index); m_battery.calculate(); } void MainWindow::on_actionactionSettings_triggered() { } void MainWindow::on_comboBoxWireMaterial_currentIndexChanged(int index) { m_wire.setActiveWireType(index); m_wire.calculate(); } void MainWindow::on_doubleSpinBoxSystemVoltage_valueChanged(double arg1) { //m_wire.setSystemVoltage(arg1); //m_wire.calculate(); m_battery.setSystemVoltage(arg1); m_battery.calculate(); } void MainWindow::on_doubleSpinBoxEstimatedWireLength_valueChanged(double arg1) { m_wire.setWireLength(arg1); m_wire.calculate(); } void MainWindow::on_lineEditVoltageRange_textChanged(const QString &arg1) { m_wire.setSystemVoltage((arg1.split(" -")[0]).toDouble()); m_wire.calculate(); }