2020-09-28 15:38:32 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file dialogsetupmultisize.cpp
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 26 9, 2020
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
|
|
|
** This source code is part of the Valentina project, a pattern making
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2020 Valentina project
|
|
|
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
|
|
|
**
|
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation, either version 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
#include "dialogsetupmultisize.h"
|
|
|
|
#include "ui_dialogsetupmultisize.h"
|
|
|
|
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QShowEvent>
|
|
|
|
|
|
|
|
#include "../mapplication.h"
|
2022-08-12 17:50:13 +02:00
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
|
2020-09-28 15:38:32 +02:00
|
|
|
#include "../vmisc/backport/qoverload.h"
|
2022-08-12 17:50:13 +02:00
|
|
|
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
|
2020-09-28 15:38:32 +02:00
|
|
|
|
2022-02-14 12:26:24 +01:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
void InitDimensionTitle(QGroupBox *group, const MeasurementDimension_p &dimension)
|
|
|
|
{
|
|
|
|
SCASSERT(group != nullptr)
|
|
|
|
group->setTitle(QStringLiteral("%1 (%2)").arg(dimension->Name(), dimension->Axis()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-28 15:38:32 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
DialogSetupMultisize::DialogSetupMultisize(Unit unit, QWidget *parent) :
|
|
|
|
QDialog(parent),
|
|
|
|
ui(new Ui::DialogSetupMultisize),
|
|
|
|
m_xDimension(QSharedPointer<VXMeasurementDimension>::create(unit)),
|
|
|
|
m_yDimension(QSharedPointer<VYMeasurementDimension>::create(unit)),
|
|
|
|
m_wDimension(QSharedPointer<VWMeasurementDimension>::create(unit)),
|
|
|
|
m_zDimension(QSharedPointer<VZMeasurementDimension>::create(unit))
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
ui->labelError->clear();
|
|
|
|
|
|
|
|
InitXDimension();
|
|
|
|
InitYDimension();
|
|
|
|
InitWDimension();
|
|
|
|
InitZDimension();
|
|
|
|
|
|
|
|
// height
|
2021-01-18 19:43:53 +01:00
|
|
|
connect(ui->doubleSpinBoxXDimensionMinValue, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
|
|
|
|
this, [this](qreal value)
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
DimensionMinValueChanged(value, ui->doubleSpinBoxXDimensionMaxValue, ui->comboBoxXDimensionStep,
|
2020-09-28 15:38:32 +02:00
|
|
|
ui->comboBoxXDimensionBase, m_xDimension);
|
|
|
|
});
|
2021-01-18 19:43:53 +01:00
|
|
|
connect(ui->doubleSpinBoxXDimensionMaxValue, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
|
|
|
|
this, [this](qreal value)
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
DimensionMaxValueChanged(value, ui->doubleSpinBoxXDimensionMinValue, ui->comboBoxXDimensionStep,
|
2020-09-28 15:38:32 +02:00
|
|
|
ui->comboBoxXDimensionBase, m_xDimension);
|
|
|
|
});
|
|
|
|
connect(ui->comboBoxXDimensionStep, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
|
|
|
this, [this](int index)
|
|
|
|
{
|
|
|
|
DimensionStepChanged(index, ui->comboBoxXDimensionStep, ui->comboBoxXDimensionBase, m_xDimension);
|
|
|
|
});
|
|
|
|
connect(ui->comboBoxXDimensionBase, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
|
|
|
this, [this](int index)
|
|
|
|
{
|
|
|
|
DimensionBaseChanged(index, ui->comboBoxXDimensionBase, m_xDimension);
|
|
|
|
});
|
|
|
|
|
|
|
|
// size
|
2021-01-18 19:43:53 +01:00
|
|
|
connect(ui->doubleSpinBoxYDimensionMinValue, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
|
|
|
|
this, [this](qreal value)
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
DimensionMinValueChanged(value, ui->doubleSpinBoxYDimensionMaxValue, ui->comboBoxYDimensionStep,
|
2020-09-28 15:38:32 +02:00
|
|
|
ui->comboBoxYDimensionBase, m_yDimension);
|
|
|
|
});
|
2021-01-18 19:43:53 +01:00
|
|
|
connect(ui->doubleSpinBoxYDimensionMaxValue, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
|
|
|
|
this, [this](qreal value)
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
DimensionMaxValueChanged(value, ui->doubleSpinBoxYDimensionMinValue, ui->comboBoxYDimensionStep,
|
2020-09-28 15:38:32 +02:00
|
|
|
ui->comboBoxYDimensionBase, m_yDimension);
|
|
|
|
});
|
|
|
|
connect(ui->comboBoxYDimensionStep, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
|
|
|
this, [this](int index)
|
|
|
|
{
|
|
|
|
DimensionStepChanged(index, ui->comboBoxYDimensionStep, ui->comboBoxYDimensionBase, m_yDimension);
|
|
|
|
});
|
|
|
|
connect(ui->comboBoxYDimensionBase, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
|
|
|
this, [this](int index)
|
|
|
|
{
|
|
|
|
DimensionBaseChanged(index, ui->comboBoxYDimensionBase, m_yDimension);
|
|
|
|
});
|
|
|
|
|
|
|
|
// hip
|
2021-01-18 19:43:53 +01:00
|
|
|
connect(ui->doubleSpinBoxWDimensionMinValue, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
|
|
|
|
this, [this](qreal value)
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
DimensionMinValueChanged(value, ui->doubleSpinBoxWDimensionMaxValue, ui->comboBoxWDimensionStep,
|
2020-09-28 15:38:32 +02:00
|
|
|
ui->comboBoxWDimensionBase, m_wDimension);
|
|
|
|
});
|
2021-01-18 19:43:53 +01:00
|
|
|
connect(ui->doubleSpinBoxWDimensionMaxValue, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
|
|
|
|
this, [this](qreal value)
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
DimensionMaxValueChanged(value, ui->doubleSpinBoxWDimensionMinValue, ui->comboBoxWDimensionStep,
|
2020-09-28 15:38:32 +02:00
|
|
|
ui->comboBoxWDimensionBase, m_wDimension);
|
|
|
|
});
|
|
|
|
connect(ui->comboBoxWDimensionStep, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
|
|
|
this, [this](int index)
|
|
|
|
{
|
|
|
|
DimensionStepChanged(index, ui->comboBoxWDimensionStep, ui->comboBoxWDimensionBase, m_wDimension);
|
|
|
|
});
|
|
|
|
connect(ui->comboBoxWDimensionBase, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
|
|
|
this, [this](int index)
|
|
|
|
{
|
|
|
|
DimensionBaseChanged(index, ui->comboBoxWDimensionBase, m_wDimension);
|
|
|
|
});
|
|
|
|
|
|
|
|
// waist
|
2021-01-18 19:43:53 +01:00
|
|
|
connect(ui->doubleSpinBoxZDimensionMinValue, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
|
|
|
|
this, [this](qreal value)
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
DimensionMinValueChanged(value, ui->doubleSpinBoxZDimensionMaxValue, ui->comboBoxZDimensionStep,
|
2020-09-28 15:38:32 +02:00
|
|
|
ui->comboBoxZDimensionBase, m_zDimension);
|
|
|
|
});
|
2021-01-18 19:43:53 +01:00
|
|
|
connect(ui->doubleSpinBoxZDimensionMaxValue, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
|
|
|
|
this, [this](qreal value)
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
DimensionMaxValueChanged(value, ui->doubleSpinBoxZDimensionMinValue, ui->comboBoxZDimensionStep,
|
2020-09-28 15:38:32 +02:00
|
|
|
ui->comboBoxZDimensionBase, m_zDimension);
|
|
|
|
});
|
|
|
|
connect(ui->comboBoxZDimensionStep, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
|
|
|
this, [this](int index)
|
|
|
|
{
|
|
|
|
DimensionStepChanged(index, ui->comboBoxZDimensionStep, ui->comboBoxZDimensionBase, m_zDimension);
|
|
|
|
});
|
|
|
|
connect(ui->comboBoxZDimensionBase, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
|
|
|
this, [this](int index)
|
|
|
|
{
|
|
|
|
DimensionBaseChanged(index, ui->comboBoxZDimensionBase, m_zDimension);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
connect(ui->groupBoxXDimension, &QGroupBox::clicked, this, [this](){CheckState();});
|
|
|
|
connect(ui->groupBoxYDimension, &QGroupBox::clicked, this, [this](){CheckState();});
|
|
|
|
connect(ui->groupBoxWDimension, &QGroupBox::clicked, this, [this](){CheckState();});
|
|
|
|
connect(ui->groupBoxZDimension, &QGroupBox::clicked, this, [this](){CheckState();});
|
|
|
|
|
|
|
|
connect(ui->checkBoxFullCircumference, &QCheckBox::stateChanged,
|
|
|
|
this, &DialogSetupMultisize::ShowFullCircumference);
|
2022-02-14 12:26:24 +01:00
|
|
|
|
2022-07-19 19:00:34 +02:00
|
|
|
connect(ui->checkBoxXDimensionBodyMeasurement, &QCheckBox::stateChanged,
|
|
|
|
this, &DialogSetupMultisize::XDimensionBodyMeasurementChanged);
|
|
|
|
connect(ui->checkBoxYDimensionBodyMeasurement, &QCheckBox::stateChanged,
|
|
|
|
this, &DialogSetupMultisize::YDimensionBodyMeasurementChanged);
|
|
|
|
connect(ui->checkBoxWDimensionBodyMeasurement, &QCheckBox::stateChanged,
|
|
|
|
this, &DialogSetupMultisize::WDimensionBodyMeasurementChanged);
|
|
|
|
connect(ui->checkBoxZDimensionBodyMeasurement, &QCheckBox::stateChanged,
|
|
|
|
this, &DialogSetupMultisize::ZDimensionBodyMeasurementChanged);
|
2022-02-14 12:26:24 +01:00
|
|
|
|
|
|
|
connect(ui->lineEditCustomXDimensionName, &QLineEdit::textChanged, this, [this](const QString &text)
|
|
|
|
{
|
|
|
|
m_xDimension->SetCustomName(text);
|
|
|
|
InitDimensionTitle(ui->groupBoxXDimension, m_xDimension);
|
|
|
|
|
|
|
|
CheckState();
|
|
|
|
});
|
|
|
|
|
|
|
|
connect(ui->lineEditCustomYDimensionName, &QLineEdit::textChanged, this, [this](const QString &text)
|
|
|
|
{
|
|
|
|
m_yDimension->SetCustomName(text);
|
|
|
|
InitDimensionTitle(ui->groupBoxYDimension, m_yDimension);
|
|
|
|
|
|
|
|
CheckState();
|
|
|
|
});
|
|
|
|
|
|
|
|
connect(ui->lineEditCustomWDimensionName, &QLineEdit::textChanged, this, [this](const QString &text)
|
|
|
|
{
|
|
|
|
m_wDimension->SetCustomName(text);
|
|
|
|
InitDimensionTitle(ui->groupBoxWDimension, m_wDimension);
|
|
|
|
|
|
|
|
CheckState();
|
|
|
|
});
|
|
|
|
|
|
|
|
connect(ui->lineEditCustomZDimensionName, &QLineEdit::textChanged, this, [this](const QString &text)
|
|
|
|
{
|
|
|
|
m_zDimension->SetCustomName(text);
|
|
|
|
InitDimensionTitle(ui->groupBoxZDimension, m_zDimension);
|
|
|
|
|
|
|
|
CheckState();
|
|
|
|
});
|
2020-09-28 15:38:32 +02:00
|
|
|
|
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
DialogSetupMultisize::~DialogSetupMultisize()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
auto DialogSetupMultisize::Dimensions() const -> QVector<MeasurementDimension_p>
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2020-10-01 12:32:02 +02:00
|
|
|
QVector<MeasurementDimension_p> dimensions;
|
2020-09-28 15:38:32 +02:00
|
|
|
|
|
|
|
if (ui->groupBoxXDimension->isChecked())
|
|
|
|
{
|
2022-02-14 12:26:24 +01:00
|
|
|
if (not ui->groupBoxCustomXDimensionName->isChecked())
|
|
|
|
{
|
|
|
|
m_xDimension->SetCustomName(QString());
|
|
|
|
}
|
2020-09-28 15:38:32 +02:00
|
|
|
dimensions.append(m_xDimension);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ui->groupBoxYDimension->isChecked())
|
|
|
|
{
|
2022-02-14 12:26:24 +01:00
|
|
|
if (not ui->groupBoxCustomYDimensionName->isChecked())
|
|
|
|
{
|
|
|
|
m_yDimension->SetCustomName(QString());
|
|
|
|
}
|
2020-09-28 15:38:32 +02:00
|
|
|
dimensions.append(m_yDimension);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ui->groupBoxWDimension->isChecked())
|
|
|
|
{
|
2022-02-14 12:26:24 +01:00
|
|
|
if (not ui->groupBoxCustomWDimensionName->isChecked())
|
|
|
|
{
|
|
|
|
m_wDimension->SetCustomName(QString());
|
|
|
|
}
|
2020-09-28 15:38:32 +02:00
|
|
|
dimensions.append(m_wDimension);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ui->groupBoxZDimension->isChecked())
|
|
|
|
{
|
2022-02-14 12:26:24 +01:00
|
|
|
if (not ui->groupBoxCustomZDimensionName->isChecked())
|
|
|
|
{
|
|
|
|
m_zDimension->SetCustomName(QString());
|
|
|
|
}
|
2020-09-28 15:38:32 +02:00
|
|
|
dimensions.append(m_zDimension);
|
|
|
|
}
|
|
|
|
|
|
|
|
return dimensions;
|
|
|
|
}
|
|
|
|
|
2020-10-01 13:16:21 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
auto DialogSetupMultisize::FullCircumference() const -> bool
|
2020-10-01 13:16:21 +02:00
|
|
|
{
|
|
|
|
return ui->checkBoxFullCircumference->isChecked();
|
|
|
|
}
|
|
|
|
|
2020-09-28 15:38:32 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSetupMultisize::showEvent(QShowEvent *event)
|
|
|
|
{
|
|
|
|
QDialog::showEvent( event );
|
|
|
|
if ( event->spontaneous() )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_isInitialized)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// do your init stuff here
|
|
|
|
|
|
|
|
setMaximumSize(size());
|
|
|
|
setMinimumSize(size());
|
|
|
|
|
|
|
|
m_isInitialized = true;//first show windows are held
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSetupMultisize::ShowFullCircumference()
|
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
auto ShowDimensionFullCircumference = [this](QDoubleSpinBox *doubleSpinBoxMinValue,
|
|
|
|
QDoubleSpinBox *doubleSpinBoxMaxValue, QComboBox *comboBoxStep, QComboBox *comboBoxBase,
|
|
|
|
const MeasurementDimension_p &dimension)
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
SCASSERT(doubleSpinBoxMinValue != nullptr)
|
|
|
|
SCASSERT(doubleSpinBoxMaxValue != nullptr)
|
2020-09-28 15:38:32 +02:00
|
|
|
SCASSERT(comboBoxStep != nullptr)
|
|
|
|
SCASSERT(comboBoxBase != nullptr)
|
|
|
|
|
2021-01-18 19:43:53 +01:00
|
|
|
InitDimension(doubleSpinBoxMinValue, doubleSpinBoxMaxValue, comboBoxStep, dimension);
|
2020-09-28 15:38:32 +02:00
|
|
|
UpdateBase(comboBoxBase, dimension);
|
|
|
|
|
|
|
|
comboBoxBase->blockSignals(true);
|
|
|
|
comboBoxBase->setCurrentIndex(-1);
|
|
|
|
comboBoxBase->blockSignals(false);
|
|
|
|
};
|
|
|
|
|
2021-01-18 19:43:53 +01:00
|
|
|
ShowDimensionFullCircumference(ui->doubleSpinBoxYDimensionMinValue, ui->doubleSpinBoxYDimensionMaxValue,
|
2020-09-28 15:38:32 +02:00
|
|
|
ui->comboBoxYDimensionStep, ui->comboBoxYDimensionBase, m_yDimension);
|
2021-01-18 19:43:53 +01:00
|
|
|
ShowDimensionFullCircumference(ui->doubleSpinBoxWDimensionMinValue, ui->doubleSpinBoxWDimensionMaxValue,
|
2020-09-28 15:38:32 +02:00
|
|
|
ui->comboBoxWDimensionStep, ui->comboBoxWDimensionBase, m_wDimension);
|
2021-01-18 19:43:53 +01:00
|
|
|
ShowDimensionFullCircumference(ui->doubleSpinBoxZDimensionMinValue, ui->doubleSpinBoxZDimensionMaxValue,
|
2020-09-28 15:38:32 +02:00
|
|
|
ui->comboBoxZDimensionStep, ui->comboBoxZDimensionBase, m_zDimension);
|
|
|
|
|
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
|
2022-02-14 12:26:24 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2022-07-19 19:00:34 +02:00
|
|
|
void DialogSetupMultisize::XDimensionBodyMeasurementChanged()
|
2022-02-14 12:26:24 +01:00
|
|
|
{
|
2022-07-19 19:00:34 +02:00
|
|
|
bool checked = ui->checkBoxXDimensionBodyMeasurement->isChecked();
|
|
|
|
m_xDimension->SetBodyMeasurement(checked);
|
2022-02-14 12:26:24 +01:00
|
|
|
|
|
|
|
InitDimension(ui->doubleSpinBoxXDimensionMinValue, ui->doubleSpinBoxXDimensionMaxValue, ui->comboBoxXDimensionStep,
|
|
|
|
m_xDimension);
|
|
|
|
|
|
|
|
UpdateBase(ui->comboBoxXDimensionBase, m_xDimension);
|
|
|
|
|
|
|
|
ui->comboBoxXDimensionBase->blockSignals(true);
|
|
|
|
ui->comboBoxXDimensionBase->setCurrentIndex(-1);
|
|
|
|
ui->comboBoxXDimensionBase->blockSignals(false);
|
|
|
|
|
|
|
|
bool ok = false;
|
|
|
|
const qreal base = ui->comboBoxXDimensionBase->currentData().toDouble(&ok);
|
|
|
|
m_xDimension->SetBaseValue(ok ? base : -1);
|
|
|
|
|
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
|
2020-09-28 15:38:32 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2022-07-19 19:00:34 +02:00
|
|
|
void DialogSetupMultisize::YDimensionBodyMeasurementChanged()
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2022-07-19 19:00:34 +02:00
|
|
|
bool checked = ui->checkBoxYDimensionBodyMeasurement->isChecked();
|
|
|
|
m_yDimension->SetBodyMeasurement(checked);
|
2020-09-28 15:38:32 +02:00
|
|
|
|
2021-01-18 19:43:53 +01:00
|
|
|
InitDimension(ui->doubleSpinBoxYDimensionMinValue, ui->doubleSpinBoxYDimensionMaxValue, ui->comboBoxYDimensionStep,
|
2020-09-28 15:38:32 +02:00
|
|
|
m_yDimension);
|
|
|
|
|
|
|
|
UpdateBase(ui->comboBoxYDimensionBase, m_yDimension);
|
|
|
|
|
|
|
|
ui->comboBoxYDimensionBase->blockSignals(true);
|
|
|
|
ui->comboBoxYDimensionBase->setCurrentIndex(-1);
|
|
|
|
ui->comboBoxYDimensionBase->blockSignals(false);
|
|
|
|
|
|
|
|
bool ok = false;
|
2021-01-18 19:43:53 +01:00
|
|
|
const qreal base = ui->comboBoxYDimensionBase->currentData().toDouble(&ok);
|
2020-09-28 15:38:32 +02:00
|
|
|
m_yDimension->SetBaseValue(ok ? base : -1);
|
|
|
|
|
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
|
2022-02-14 12:26:24 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2022-07-19 19:00:34 +02:00
|
|
|
void DialogSetupMultisize::WDimensionBodyMeasurementChanged()
|
2022-02-14 12:26:24 +01:00
|
|
|
{
|
2022-07-19 19:00:34 +02:00
|
|
|
bool checked = ui->checkBoxWDimensionBodyMeasurement->isChecked();
|
|
|
|
m_wDimension->SetBodyMeasurement(checked);
|
2022-02-14 12:26:24 +01:00
|
|
|
|
|
|
|
InitDimension(ui->doubleSpinBoxWDimensionMinValue, ui->doubleSpinBoxWDimensionMaxValue, ui->comboBoxWDimensionStep,
|
|
|
|
m_wDimension);
|
|
|
|
|
|
|
|
UpdateBase(ui->comboBoxWDimensionBase, m_wDimension);
|
|
|
|
|
|
|
|
ui->comboBoxWDimensionBase->blockSignals(true);
|
|
|
|
ui->comboBoxWDimensionBase->setCurrentIndex(-1);
|
|
|
|
ui->comboBoxWDimensionBase->blockSignals(false);
|
|
|
|
|
|
|
|
bool ok = false;
|
|
|
|
const qreal base = ui->comboBoxWDimensionBase->currentData().toDouble(&ok);
|
|
|
|
m_wDimension->SetBaseValue(ok ? base : -1);
|
|
|
|
|
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2022-07-19 19:00:34 +02:00
|
|
|
void DialogSetupMultisize::ZDimensionBodyMeasurementChanged()
|
2022-02-14 12:26:24 +01:00
|
|
|
{
|
2022-07-19 19:00:34 +02:00
|
|
|
bool checked = ui->checkBoxZDimensionBodyMeasurement->isChecked();
|
|
|
|
m_zDimension->SetBodyMeasurement(checked);
|
2022-02-14 12:26:24 +01:00
|
|
|
|
|
|
|
InitDimension(ui->doubleSpinBoxZDimensionMinValue, ui->doubleSpinBoxZDimensionMaxValue, ui->comboBoxZDimensionStep,
|
|
|
|
m_zDimension);
|
|
|
|
|
|
|
|
UpdateBase(ui->comboBoxZDimensionBase, m_zDimension);
|
|
|
|
|
|
|
|
ui->comboBoxZDimensionBase->blockSignals(true);
|
|
|
|
ui->comboBoxZDimensionBase->setCurrentIndex(-1);
|
|
|
|
ui->comboBoxZDimensionBase->blockSignals(false);
|
|
|
|
|
|
|
|
bool ok = false;
|
|
|
|
const qreal base = ui->comboBoxZDimensionBase->currentData().toDouble(&ok);
|
|
|
|
m_zDimension->SetBaseValue(ok ? base : -1);
|
|
|
|
|
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
|
2020-09-28 15:38:32 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2022-07-20 07:29:59 +02:00
|
|
|
void DialogSetupMultisize::CheckDimension(QGroupBox *group, QGroupBox *nameGroup, QLineEdit *lineEdit,
|
|
|
|
bool &dimensionValid, int &dimensions,
|
|
|
|
const MeasurementDimension_p &dimension)
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2022-07-20 07:29:59 +02:00
|
|
|
SCASSERT(group != nullptr)
|
|
|
|
SCASSERT(nameGroup != nullptr)
|
|
|
|
SCASSERT(lineEdit != nullptr)
|
2020-09-28 15:38:32 +02:00
|
|
|
|
2022-07-20 07:29:59 +02:00
|
|
|
if (group->isChecked())
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2022-07-20 07:29:59 +02:00
|
|
|
dimensionValid = dimension->IsValid();
|
|
|
|
++dimensions;
|
2020-09-28 15:38:32 +02:00
|
|
|
|
2022-07-20 07:29:59 +02:00
|
|
|
if (ui->labelError->text().isEmpty() && not dimensionValid)
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2022-07-20 07:29:59 +02:00
|
|
|
ui->labelError->setText(tr("Please, provide correct data for dimension %1").arg(dimension->Axis()));
|
|
|
|
return;
|
|
|
|
}
|
2020-09-28 15:38:32 +02:00
|
|
|
|
2022-07-20 07:29:59 +02:00
|
|
|
if (nameGroup->isChecked() && lineEdit->text().isEmpty())
|
|
|
|
{
|
|
|
|
if (ui->labelError->text().isEmpty())
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2022-07-20 07:29:59 +02:00
|
|
|
ui->labelError->setText(tr("Please, provide custom name for dimension %1").arg(dimension->Axis()));
|
2022-02-14 12:26:24 +01:00
|
|
|
return;
|
|
|
|
}
|
2020-09-28 15:38:32 +02:00
|
|
|
}
|
2022-07-20 07:29:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSetupMultisize::CheckState()
|
|
|
|
{
|
|
|
|
ui->labelError->clear();
|
|
|
|
|
|
|
|
bool xDimensionValid = true;
|
|
|
|
bool yDimensionValid = true;
|
|
|
|
bool wDimensionValid = true;
|
|
|
|
bool zDimensionValid = true;
|
|
|
|
|
|
|
|
int dimensions = 0;
|
2020-09-28 15:38:32 +02:00
|
|
|
|
2022-02-14 12:26:24 +01:00
|
|
|
CheckDimension(ui->groupBoxXDimension, ui->groupBoxCustomXDimensionName, ui->lineEditCustomXDimensionName,
|
|
|
|
xDimensionValid, dimensions, m_xDimension);
|
|
|
|
CheckDimension(ui->groupBoxYDimension, ui->groupBoxCustomYDimensionName, ui->lineEditCustomYDimensionName,
|
|
|
|
yDimensionValid, dimensions, m_yDimension);
|
|
|
|
CheckDimension(ui->groupBoxWDimension, ui->groupBoxCustomWDimensionName, ui->lineEditCustomWDimensionName,
|
|
|
|
wDimensionValid, dimensions, m_wDimension);
|
|
|
|
CheckDimension(ui->groupBoxZDimension, ui->groupBoxCustomZDimensionName, ui->lineEditCustomZDimensionName,
|
|
|
|
zDimensionValid, dimensions, m_zDimension);
|
2020-09-28 15:38:32 +02:00
|
|
|
|
|
|
|
if (ui->labelError->text().isEmpty() && dimensions == 0)
|
|
|
|
{
|
|
|
|
ui->labelError->setText(tr("Please, select at least one dimension"));
|
|
|
|
}
|
|
|
|
else if (ui->labelError->text().isEmpty() && dimensions > 3)
|
|
|
|
{
|
|
|
|
ui->labelError->setText(tr("No more than 3 dimensions allowed"));
|
|
|
|
}
|
|
|
|
|
|
|
|
const bool enough = dimensions > 0 && dimensions <= 3;
|
|
|
|
|
|
|
|
QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
|
|
|
SCASSERT(bOk != nullptr)
|
|
|
|
bOk->setEnabled(enough && xDimensionValid && yDimensionValid && wDimensionValid && zDimensionValid);
|
|
|
|
|
|
|
|
if (ui->labelError->text().isEmpty())
|
|
|
|
{
|
|
|
|
ui->labelError->setText(tr("Ready"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
void DialogSetupMultisize::InitDimensionMinMax(QDoubleSpinBox *doubleSpinBoxMinValue,
|
|
|
|
QDoubleSpinBox *doubleSpinBoxMaxValue,
|
2020-10-01 12:32:02 +02:00
|
|
|
const MeasurementDimension_p &dimension)
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
SCASSERT(doubleSpinBoxMinValue != nullptr)
|
|
|
|
SCASSERT(doubleSpinBoxMaxValue != nullptr)
|
2020-09-28 15:38:32 +02:00
|
|
|
|
|
|
|
dimension->SetMinValue(dimension->RangeMin());
|
|
|
|
dimension->SetMaxValue(dimension->RangeMax());
|
|
|
|
|
2022-07-19 19:00:34 +02:00
|
|
|
const bool fc = dimension->Type() != MeasurementDimension::X ? ui->checkBoxFullCircumference->isChecked() : false;
|
|
|
|
const bool m = dimension->IsBodyMeasurement();
|
|
|
|
const QString unitStr = m ? " " + UnitsToStr(m_xDimension->Units()) : QString();
|
2020-09-28 15:38:32 +02:00
|
|
|
|
2021-01-18 19:43:53 +01:00
|
|
|
doubleSpinBoxMinValue->blockSignals(true);
|
2022-07-19 19:00:34 +02:00
|
|
|
doubleSpinBoxMinValue->setSuffix(unitStr);
|
2021-01-18 19:43:53 +01:00
|
|
|
doubleSpinBoxMinValue->setDecimals(dimension->Units() == Unit::Mm ? 0 : 1);
|
2022-07-19 19:00:34 +02:00
|
|
|
doubleSpinBoxMinValue->setMinimum(m && fc ? dimension->RangeMin()*2 : dimension->RangeMin());
|
|
|
|
doubleSpinBoxMinValue->setMaximum(m && fc ? dimension->MaxValue()*2 : dimension->MaxValue());
|
|
|
|
doubleSpinBoxMinValue->setValue(m && fc ? dimension->MinValue()*2 : dimension->MinValue());
|
2021-01-18 19:43:53 +01:00
|
|
|
doubleSpinBoxMinValue->blockSignals(false);
|
2020-09-28 15:38:32 +02:00
|
|
|
|
2021-01-18 19:43:53 +01:00
|
|
|
doubleSpinBoxMaxValue->blockSignals(true);
|
2022-07-19 19:00:34 +02:00
|
|
|
doubleSpinBoxMaxValue->setSuffix(unitStr);
|
2021-01-18 19:43:53 +01:00
|
|
|
doubleSpinBoxMaxValue->setDecimals(dimension->Units() == Unit::Mm ? 0 : 1);
|
2022-07-19 19:00:34 +02:00
|
|
|
doubleSpinBoxMaxValue->setMinimum(m && fc ? dimension->MinValue()*2 : dimension->MinValue());
|
|
|
|
doubleSpinBoxMaxValue->setMaximum(m && fc ? dimension->RangeMax()*2 : dimension->RangeMax());
|
|
|
|
doubleSpinBoxMaxValue->setValue(m && fc ? dimension->RangeMax()*2 : dimension->RangeMax());
|
|
|
|
doubleSpinBoxMaxValue->setValue(m && fc ? dimension->MaxValue()*2 : dimension->MaxValue());
|
2021-01-18 19:43:53 +01:00
|
|
|
doubleSpinBoxMaxValue->blockSignals(false);
|
2020-09-28 15:38:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSetupMultisize::InitDimensionStep(QComboBox *comboBoxStep,
|
2020-10-01 12:32:02 +02:00
|
|
|
const MeasurementDimension_p &dimension)
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
|
|
|
SCASSERT(comboBoxStep != nullptr)
|
|
|
|
|
2022-07-19 19:00:34 +02:00
|
|
|
const bool fc = dimension->Type() != MeasurementDimension::X ? ui->checkBoxFullCircumference->isChecked() : false;
|
|
|
|
const bool m = dimension->IsBodyMeasurement();
|
|
|
|
const QString unitStr = m ? " " + UnitsToStr(dimension->Units()) : QString();
|
2020-09-28 15:38:32 +02:00
|
|
|
|
|
|
|
dimension->SetStep(-1);
|
|
|
|
|
|
|
|
comboBoxStep->blockSignals(true);
|
2021-01-18 19:43:53 +01:00
|
|
|
const QVector<qreal> steps = dimension->ValidSteps();
|
2020-09-28 15:38:32 +02:00
|
|
|
comboBoxStep->clear();
|
|
|
|
for(auto step : steps)
|
|
|
|
{
|
2022-07-19 19:00:34 +02:00
|
|
|
comboBoxStep->addItem(QStringLiteral("%1%2").arg(m && fc ? step*2 : step).arg(unitStr), step);
|
2020-09-28 15:38:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
comboBoxStep->setCurrentIndex(-1); // force a user to select
|
|
|
|
comboBoxStep->blockSignals(false);
|
|
|
|
|
|
|
|
bool ok = false;
|
2021-01-18 19:43:53 +01:00
|
|
|
const qreal step = comboBoxStep->currentData().toDouble(&ok);
|
2020-09-28 15:38:32 +02:00
|
|
|
dimension->SetStep(ok ? step : -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
void DialogSetupMultisize::InitDimension(QDoubleSpinBox *doubleSpinBoxMinValue, QDoubleSpinBox *doubleSpinBoxMaxValue,
|
|
|
|
QComboBox *comboBoxStep, const MeasurementDimension_p &dimension)
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
InitDimensionMinMax(doubleSpinBoxMinValue, doubleSpinBoxMaxValue, dimension);
|
2020-09-28 15:38:32 +02:00
|
|
|
InitDimensionStep(comboBoxStep, dimension);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSetupMultisize::InitXDimension()
|
|
|
|
{
|
2022-02-14 12:26:24 +01:00
|
|
|
InitDimensionTitle(ui->groupBoxXDimension, m_xDimension);
|
2021-01-18 19:43:53 +01:00
|
|
|
InitDimension(ui->doubleSpinBoxXDimensionMinValue, ui->doubleSpinBoxXDimensionMaxValue, ui->comboBoxXDimensionStep,
|
2020-09-28 15:38:32 +02:00
|
|
|
m_xDimension);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSetupMultisize::InitYDimension()
|
|
|
|
{
|
2022-02-14 12:26:24 +01:00
|
|
|
InitDimensionTitle(ui->groupBoxYDimension, m_yDimension);
|
2021-01-18 19:43:53 +01:00
|
|
|
InitDimension(ui->doubleSpinBoxYDimensionMinValue, ui->doubleSpinBoxYDimensionMaxValue, ui->comboBoxYDimensionStep,
|
2020-09-28 15:38:32 +02:00
|
|
|
m_yDimension);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSetupMultisize::InitWDimension()
|
|
|
|
{
|
2022-02-14 12:26:24 +01:00
|
|
|
InitDimensionTitle(ui->groupBoxWDimension, m_wDimension);
|
2021-01-18 19:43:53 +01:00
|
|
|
InitDimension(ui->doubleSpinBoxWDimensionMinValue, ui->doubleSpinBoxWDimensionMaxValue, ui->comboBoxWDimensionStep,
|
2020-09-28 15:38:32 +02:00
|
|
|
m_wDimension);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSetupMultisize::InitZDimension()
|
|
|
|
{
|
2022-02-14 12:26:24 +01:00
|
|
|
InitDimensionTitle(ui->groupBoxZDimension, m_zDimension);
|
2021-01-18 19:43:53 +01:00
|
|
|
InitDimension(ui->doubleSpinBoxZDimensionMinValue, ui->doubleSpinBoxZDimensionMaxValue, ui->comboBoxZDimensionStep,
|
2020-09-28 15:38:32 +02:00
|
|
|
m_zDimension);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
void DialogSetupMultisize::DimensionMinValueChanged(qreal value, QDoubleSpinBox *doubleSpinBoxMaxValue,
|
|
|
|
QComboBox *comboBoxStep, QComboBox *comboBoxBase,
|
2020-10-01 12:32:02 +02:00
|
|
|
const MeasurementDimension_p &dimension)
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
SCASSERT(doubleSpinBoxMaxValue != nullptr)
|
2020-09-28 15:38:32 +02:00
|
|
|
SCASSERT(comboBoxStep != nullptr)
|
|
|
|
SCASSERT(comboBoxBase != nullptr)
|
|
|
|
|
2022-07-19 19:00:34 +02:00
|
|
|
const bool fc = dimension->Type() != MeasurementDimension::X ? ui->checkBoxFullCircumference->isChecked() : false;
|
|
|
|
const bool m = dimension->IsBodyMeasurement();
|
2020-09-28 15:38:32 +02:00
|
|
|
|
2022-07-19 19:00:34 +02:00
|
|
|
dimension->SetMinValue(m && fc ? value / 2 : value);
|
2020-09-28 15:38:32 +02:00
|
|
|
|
2021-01-18 19:43:53 +01:00
|
|
|
doubleSpinBoxMaxValue->blockSignals(true);
|
|
|
|
doubleSpinBoxMaxValue->setMinimum(value);
|
|
|
|
doubleSpinBoxMaxValue->blockSignals(false);
|
2020-09-28 15:38:32 +02:00
|
|
|
|
2022-07-19 19:00:34 +02:00
|
|
|
dimension->SetMaxValue(m && fc ? doubleSpinBoxMaxValue->value() / 2 : doubleSpinBoxMaxValue->value());
|
2020-09-28 15:38:32 +02:00
|
|
|
|
|
|
|
UpdateSteps(comboBoxStep, dimension);
|
|
|
|
UpdateBase(comboBoxBase, dimension);
|
|
|
|
|
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
void DialogSetupMultisize::DimensionMaxValueChanged(qreal value, QDoubleSpinBox *doubleSpinBoxMinValue,
|
|
|
|
QComboBox *comboBoxStep, QComboBox *comboBoxBase,
|
2020-10-01 12:32:02 +02:00
|
|
|
const MeasurementDimension_p &dimension)
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
SCASSERT(doubleSpinBoxMinValue != nullptr)
|
2020-09-28 15:38:32 +02:00
|
|
|
SCASSERT(comboBoxStep != nullptr)
|
|
|
|
SCASSERT(comboBoxBase != nullptr)
|
|
|
|
|
2022-07-19 19:00:34 +02:00
|
|
|
const bool fc = dimension->Type() != MeasurementDimension::X ? ui->checkBoxFullCircumference->isChecked() : false;
|
|
|
|
const bool m = dimension->IsBodyMeasurement();
|
2020-09-28 15:38:32 +02:00
|
|
|
|
2022-07-19 19:00:34 +02:00
|
|
|
dimension->SetMaxValue(m && fc ? value / 2 : value);
|
2020-09-28 15:38:32 +02:00
|
|
|
|
2021-01-18 19:43:53 +01:00
|
|
|
doubleSpinBoxMinValue->blockSignals(true);
|
|
|
|
doubleSpinBoxMinValue->setMaximum(value);
|
|
|
|
doubleSpinBoxMinValue->blockSignals(false);
|
2020-09-28 15:38:32 +02:00
|
|
|
|
2022-07-19 19:00:34 +02:00
|
|
|
dimension->SetMinValue(m && fc ? doubleSpinBoxMinValue->value() / 2 : doubleSpinBoxMinValue->value());
|
2020-09-28 15:38:32 +02:00
|
|
|
|
|
|
|
UpdateSteps(comboBoxStep, dimension);
|
|
|
|
UpdateBase(comboBoxBase, dimension);
|
|
|
|
|
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSetupMultisize::DimensionStepChanged(int index, QComboBox *comboBoxStep, QComboBox *comboBoxBase,
|
2020-10-01 12:32:02 +02:00
|
|
|
const MeasurementDimension_p &dimension)
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
|
|
|
SCASSERT(comboBoxStep != nullptr)
|
|
|
|
SCASSERT(comboBoxBase != nullptr)
|
|
|
|
|
|
|
|
bool ok = false;
|
2021-01-18 19:43:53 +01:00
|
|
|
const qreal step = comboBoxStep->itemData(index).toDouble(&ok);
|
2020-09-28 15:38:32 +02:00
|
|
|
dimension->SetStep(ok ? step : -1);
|
|
|
|
|
|
|
|
UpdateBase(comboBoxBase, dimension);
|
|
|
|
|
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSetupMultisize::DimensionBaseChanged(int index, QComboBox *comboBoxBase,
|
2020-10-01 12:32:02 +02:00
|
|
|
const MeasurementDimension_p &dimension)
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
|
|
|
SCASSERT(comboBoxBase != nullptr)
|
|
|
|
|
|
|
|
bool ok = false;
|
2021-01-18 19:43:53 +01:00
|
|
|
const qreal base = comboBoxBase->itemData(index).toDouble(&ok);
|
2020-09-28 15:38:32 +02:00
|
|
|
dimension->SetBaseValue(ok ? base : -1);
|
|
|
|
|
|
|
|
CheckState();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSetupMultisize::UpdateSteps(QComboBox *comboBoxStep,
|
2020-10-01 12:32:02 +02:00
|
|
|
const MeasurementDimension_p &dimension)
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
|
|
|
SCASSERT(comboBoxStep != nullptr)
|
|
|
|
|
2021-01-18 19:43:53 +01:00
|
|
|
qreal oldStep = -1;
|
2020-09-28 15:38:32 +02:00
|
|
|
if (comboBoxStep->currentIndex() != -1)
|
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
oldStep = comboBoxStep->currentData().toDouble();
|
2020-09-28 15:38:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
comboBoxStep->blockSignals(true);
|
|
|
|
|
2021-01-18 19:43:53 +01:00
|
|
|
const QVector<qreal> steps = dimension->ValidSteps();
|
2020-09-28 15:38:32 +02:00
|
|
|
comboBoxStep->clear();
|
|
|
|
|
2022-07-19 19:00:34 +02:00
|
|
|
const bool fc = dimension->Type() != MeasurementDimension::X ? ui->checkBoxFullCircumference->isChecked() : false;
|
|
|
|
const bool m = dimension->IsBodyMeasurement();
|
|
|
|
const QString unitStr = m ? " " + UnitsToStr(dimension->Units()) : QString();
|
2020-09-28 15:38:32 +02:00
|
|
|
|
|
|
|
for(auto step : steps)
|
|
|
|
{
|
2022-07-19 19:00:34 +02:00
|
|
|
comboBoxStep->addItem(QStringLiteral("%1%2").arg(m && fc ? step * 2 : step).arg(unitStr), step);
|
2020-09-28 15:38:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
comboBoxStep->setCurrentIndex(comboBoxStep->findData(oldStep));
|
|
|
|
comboBoxStep->blockSignals(false);
|
|
|
|
|
|
|
|
bool ok = false;
|
2021-01-18 19:43:53 +01:00
|
|
|
const qreal step = comboBoxStep->currentData().toDouble(&ok);
|
2020-09-28 15:38:32 +02:00
|
|
|
dimension->SetStep(ok ? step : -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogSetupMultisize::UpdateBase(QComboBox *comboBoxBase,
|
2020-10-01 12:32:02 +02:00
|
|
|
const MeasurementDimension_p &dimension)
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
|
|
|
SCASSERT(comboBoxBase != nullptr)
|
|
|
|
|
2021-01-18 19:43:53 +01:00
|
|
|
qreal oldBase = -1;
|
2020-09-28 15:38:32 +02:00
|
|
|
if (comboBoxBase->currentIndex() != -1)
|
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
oldBase = comboBoxBase->currentData().toDouble();
|
2020-09-28 15:38:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
comboBoxBase->blockSignals(true);
|
|
|
|
|
2021-01-18 19:43:53 +01:00
|
|
|
const QVector<qreal> bases = dimension->ValidBases();
|
2020-09-28 15:38:32 +02:00
|
|
|
comboBoxBase->clear();
|
2022-07-19 19:00:34 +02:00
|
|
|
const bool fc = dimension->Type() != MeasurementDimension::X ? ui->checkBoxFullCircumference->isChecked() : false;
|
|
|
|
const bool m = dimension->IsBodyMeasurement();
|
|
|
|
const QString unitStr = m ? " " + UnitsToStr(dimension->Units()) : QString();
|
2020-09-28 15:38:32 +02:00
|
|
|
|
|
|
|
for(auto base : bases)
|
|
|
|
{
|
2022-07-19 19:00:34 +02:00
|
|
|
comboBoxBase->addItem(QStringLiteral("%1%2").arg(m && fc ? base * 2 : base).arg(unitStr), base);
|
2020-09-28 15:38:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
comboBoxBase->setCurrentIndex(comboBoxBase->findData(oldBase));
|
|
|
|
comboBoxBase->blockSignals(false);
|
|
|
|
|
|
|
|
bool ok = false;
|
2021-01-18 19:43:53 +01:00
|
|
|
const qreal base = comboBoxBase->currentData().toDouble(&ok);
|
2020-09-28 15:38:32 +02:00
|
|
|
dimension->SetBaseValue(ok ? base : -1);
|
|
|
|
}
|
|
|
|
|