diff options
| author | Nikita Kostovsky <nikita@kostovsky.me> | 2026-01-07 02:10:04 +0100 |
|---|---|---|
| committer | Nikita Kostovsky <nikita@kostovsky.me> | 2026-01-07 02:10:04 +0100 |
| commit | 55e79f0d7179f5105eff11897bb3926a8f7b36cb (patch) | |
| tree | 718dbc278b82d41f1f5b38967cdb99b27e717ea8 /src/mainwindow.cpp | |
| parent | d3f97c3929c525890be9984a03464754b2daf6bc (diff) | |
Diffstat (limited to 'src/mainwindow.cpp')
| -rw-r--r-- | src/mainwindow.cpp | 70 |
1 files changed, 67 insertions, 3 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d573473..f9a9692 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -3,6 +3,7 @@ // qt #include <QComboBox> #include <QDoubleSpinBox> +#include <QFile> #include <QFormLayout> #include <QGroupBox> #include <QHBoxLayout> @@ -415,8 +416,8 @@ void MainWindow::initUi() qOverload<double>(&OpticalDesign::scannerBodyFrontWallOffsetMmChanged), &OpticalDesign::get_scannerBodyFrontWallOffsetMm, &OpticalDesign::set_scannerBodyFrontWallOffsetMm, - MinValue{-50.}, - MaxValue{50.}, + MinValue{-500.}, + MaxValue{500.}, SingleStep{1.}, scannerBodyGroup ); @@ -429,7 +430,7 @@ void MainWindow::initUi() ); addFormLabel( - tr("FoV (YZ, V) (°):"), + tr("Field of View (YZ, V) (°):"), qOverload<double>(&OpticalDesign::vFoVDegreesChanged), Decimals{3}, resultsGroup @@ -465,6 +466,20 @@ void MainWindow::initUi() ); addFormLabel( + tr("Actual X Start (mm):"), + qOverload<double>(&OpticalDesign::actualXStartMmChanged), + Decimals{2}, + resultsGroup + ); + + addFormLabel( + tr("Actual X End (mm):"), + qOverload<double>(&OpticalDesign::actualXEndMmChanged), + Decimals{2}, + resultsGroup + ); + + addFormLabel( tr("Lense-Sensor Distance (mm):"), qOverload<double>(&OpticalDesign::lenseSensorDistanceMmChanged), Decimals{2}, @@ -522,4 +537,53 @@ void MainWindow::initUi() void MainWindow::initShortcuts() { new QShortcut{Qt::CTRL | Qt::Key_Q, this, this, &MainWindow::close}; + new QShortcut{ + Qt::CTRL | Qt::SHIFT | Qt::Key_E, + this, + this, + std::bind( + &MainWindow::onExport, + this, + QStringLiteral("/home/nikita/git/scanner/hw/body/design.scad") + ) + }; +} + +void MainWindow::onExport(const QString& filepath) +{ + QFile f{filepath}; + + if (!f.open(QFile::WriteOnly | QFile::Truncate)) + { + qCritical() << "cannot open file:" << f.errorString(); + + return; + } + + QTextStream s{&f}; + + const auto mo = m_design->metaObject(); + + for (int i{mo->propertyOffset()}; i < mo->propertyCount(); ++i) + { + const auto property = mo->property(i); + const QString name{property.name()}; + + const auto value = property.read(m_design); + + const auto valueString = property.isEnumType() + // write enums as `int`s + ? QString::number(value.toInt()) + : (property.typeId() == QMetaType::QString + // wrap strings into "" + ? ('"' + value.toString() + '"') + : value.toString()); + + qDebug().noquote().nospace() + << '$' << name << " = " << valueString << " (" << value << ')'; + + s << '$' << name << " = " << valueString << ';' << Qt::endl; + } + + qDebug() << "desing written to" << filepath; } |
