From 55e79f0d7179f5105eff11897bb3926a8f7b36cb Mon Sep 17 00:00:00 2001 From: Nikita Kostovsky Date: Wed, 7 Jan 2026 02:10:04 +0100 Subject: add x start/end range; implement export to .scad --- src/mainwindow.cpp | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 3 deletions(-) (limited to 'src/mainwindow.cpp') 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 #include +#include #include #include #include @@ -415,8 +416,8 @@ void MainWindow::initUi() qOverload(&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(&OpticalDesign::vFoVDegreesChanged), Decimals{3}, resultsGroup @@ -464,6 +465,20 @@ void MainWindow::initUi() resultsGroup ); + addFormLabel( + tr("Actual X Start (mm):"), + qOverload(&OpticalDesign::actualXStartMmChanged), + Decimals{2}, + resultsGroup + ); + + addFormLabel( + tr("Actual X End (mm):"), + qOverload(&OpticalDesign::actualXEndMmChanged), + Decimals{2}, + resultsGroup + ); + addFormLabel( tr("Lense-Sensor Distance (mm):"), qOverload(&OpticalDesign::lenseSensorDistanceMmChanged), @@ -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; } -- cgit v1.2.3-70-g09d2