2020-10-05 14:14:38 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file dialogrestrictdimension.cpp
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 5 10, 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 "dialogrestrictdimension.h"
|
|
|
|
#include "ui_dialogrestrictdimension.h"
|
|
|
|
|
2021-01-19 20:13:17 +01:00
|
|
|
#include <QMenu>
|
2020-10-06 17:00:53 +02:00
|
|
|
#include <QTableWidgetItem>
|
|
|
|
|
|
|
|
#include "../vpatterndb/variables/vmeasurement.h"
|
|
|
|
#include "../vwidgets/vdecorationaligningdelegate.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
auto FilterByMinimum(const QVector<qreal> &base, qreal restriction) -> QVector<qreal>
|
2020-10-06 17:00:53 +02:00
|
|
|
{
|
|
|
|
if (restriction <= 0)
|
|
|
|
{
|
|
|
|
return base;
|
|
|
|
}
|
|
|
|
|
2021-01-18 19:43:53 +01:00
|
|
|
QVector<qreal> filtered;
|
2020-10-06 17:00:53 +02:00
|
|
|
filtered.reserve(base.size());
|
2021-01-18 19:43:53 +01:00
|
|
|
for(const auto &b : base)
|
2020-10-06 17:00:53 +02:00
|
|
|
{
|
|
|
|
if (b >= restriction)
|
|
|
|
{
|
|
|
|
filtered.append(b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return filtered;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
auto FilterByMaximum(const QVector<qreal> &base, qreal restriction) -> QVector<qreal>
|
2020-10-06 17:00:53 +02:00
|
|
|
{
|
|
|
|
if (restriction <= 0)
|
|
|
|
{
|
|
|
|
return base;
|
|
|
|
}
|
|
|
|
|
2021-01-18 19:43:53 +01:00
|
|
|
QVector<qreal> filtered;
|
2020-10-06 17:00:53 +02:00
|
|
|
filtered.reserve(base.size());
|
2021-01-18 19:43:53 +01:00
|
|
|
for(const auto &b : base)
|
2020-10-06 17:00:53 +02:00
|
|
|
{
|
|
|
|
if (b <= restriction)
|
|
|
|
{
|
|
|
|
filtered.append(b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return filtered;
|
|
|
|
}
|
2021-01-18 19:43:53 +01:00
|
|
|
} // namespace
|
2020-10-06 17:00:53 +02:00
|
|
|
|
2020-10-05 14:14:38 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
DialogRestrictDimension::DialogRestrictDimension(const QList<MeasurementDimension_p> &dimensions,
|
2021-01-19 20:13:17 +01:00
|
|
|
const QMap<QString, VDimensionRestriction> &restrictions,
|
|
|
|
RestrictDimension restrictionType, bool fullCircumference,
|
2020-10-05 14:14:38 +02:00
|
|
|
QWidget *parent) :
|
|
|
|
QDialog(parent),
|
|
|
|
ui(new Ui::DialogRestrictDimension),
|
2021-01-19 20:13:17 +01:00
|
|
|
m_restrictionType(restrictionType),
|
2020-10-05 14:14:38 +02:00
|
|
|
m_fullCircumference(fullCircumference),
|
|
|
|
m_dimensions(dimensions),
|
|
|
|
m_restrictions(restrictions)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2020-10-06 17:00:53 +02:00
|
|
|
|
|
|
|
ui->tableWidget->setItemDelegate(
|
|
|
|
new VDecorationAligningDelegate(Qt::AlignHCenter | Qt::AlignCenter, ui->tableWidget));
|
2021-01-19 20:13:17 +01:00
|
|
|
ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
2020-10-06 17:00:53 +02:00
|
|
|
|
|
|
|
connect(ui->tableWidget, &QTableWidget::itemSelectionChanged, this, &DialogRestrictDimension::RowSelected);
|
2021-01-19 20:13:17 +01:00
|
|
|
connect(ui->tableWidget, &QTableWidget::customContextMenuRequested, this,
|
|
|
|
&DialogRestrictDimension::CellContextMenu);
|
2020-10-06 17:00:53 +02:00
|
|
|
|
|
|
|
connect(ui->comboBoxDimensionA, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
|
|
|
&DialogRestrictDimension::DimensionAChanged);
|
|
|
|
|
|
|
|
connect(ui->comboBoxMin, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
|
|
|
&DialogRestrictDimension::MinRestrictionChanged);
|
|
|
|
connect(ui->comboBoxMax, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
|
|
|
&DialogRestrictDimension::MaxRestrictionChanged);
|
|
|
|
|
|
|
|
InitDimensionsBaseValues();
|
|
|
|
InitTable();
|
2020-10-05 14:14:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
DialogRestrictDimension::~DialogRestrictDimension()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
2020-10-06 17:00:53 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogRestrictDimension::changeEvent(QEvent *event)
|
|
|
|
{
|
|
|
|
if (event->type() == QEvent::LanguageChange)
|
|
|
|
{
|
|
|
|
// retranslate designer form (single inheritance approach)
|
|
|
|
ui->retranslateUi(this);
|
|
|
|
|
|
|
|
auto RetranslateControls = [this](int index, QLabel *name, QComboBox *control)
|
|
|
|
{
|
|
|
|
SCASSERT(name != nullptr)
|
|
|
|
SCASSERT(control != nullptr)
|
|
|
|
|
|
|
|
if (m_dimensions.size() > index)
|
|
|
|
{
|
|
|
|
MeasurementDimension_p dimension = m_dimensions.at(index);
|
|
|
|
|
2022-02-14 12:26:24 +01:00
|
|
|
name->setText(dimension->Name()+QChar(':'));
|
|
|
|
name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension, m_fullCircumference));
|
2020-10-06 17:00:53 +02:00
|
|
|
|
|
|
|
InitDimensionGradation(dimension, control);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-01-19 20:13:17 +01:00
|
|
|
if (m_restrictionType == RestrictDimension::Third)
|
2020-10-06 17:00:53 +02:00
|
|
|
{
|
|
|
|
RetranslateControls(0, ui->labelDimensionA, ui->comboBoxDimensionA);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// remember to call base class implementation
|
|
|
|
QDialog::changeEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogRestrictDimension::RowSelected()
|
|
|
|
{
|
|
|
|
EnableRestrictionControls(false);
|
|
|
|
|
|
|
|
QTableWidgetItem *item = ui->tableWidget->currentItem();
|
|
|
|
|
2021-02-08 14:17:43 +01:00
|
|
|
if (item != nullptr && (item->flags() & Qt::ItemIsEnabled) != 0U)
|
2020-10-06 17:00:53 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
qreal base1 = 0;
|
|
|
|
qreal base2 = 0;
|
2020-10-06 17:00:53 +02:00
|
|
|
MeasurementDimension_p dimension;
|
|
|
|
|
2021-01-19 20:13:17 +01:00
|
|
|
if (m_restrictionType == RestrictDimension::Second)
|
2020-10-06 17:00:53 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
base1 = item->data(Qt::UserRole).toDouble();
|
2020-10-06 17:00:53 +02:00
|
|
|
|
|
|
|
if (m_dimensions.size() > 1)
|
|
|
|
{
|
|
|
|
dimension = m_dimensions.at(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
base1 = ui->comboBoxDimensionA->currentData().toDouble();
|
|
|
|
base2 = item->data(Qt::UserRole).toDouble();
|
2020-10-06 17:00:53 +02:00
|
|
|
|
|
|
|
if (m_dimensions.size() > 2)
|
|
|
|
{
|
|
|
|
dimension = m_dimensions.at(2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-19 20:13:17 +01:00
|
|
|
VDimensionRestriction restriction = m_restrictions.value(VMeasurement::CorrectionHash(base1, base2));
|
2020-10-06 17:00:53 +02:00
|
|
|
|
|
|
|
if (dimension.isNull())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-01-18 19:43:53 +01:00
|
|
|
const QVector<qreal> bases = dimension->ValidBases();
|
2020-10-06 17:00:53 +02:00
|
|
|
|
|
|
|
ui->comboBoxMin->blockSignals(true);
|
|
|
|
ui->comboBoxMin->clear();
|
2021-01-19 20:13:17 +01:00
|
|
|
QVector<qreal> filtered = FilterByMaximum(bases, restriction.GetMax());
|
2020-10-06 17:00:53 +02:00
|
|
|
FillBases(filtered, dimension, ui->comboBoxMin);
|
2021-01-19 20:13:17 +01:00
|
|
|
int index = ui->comboBoxMin->findData(restriction.GetMin());
|
2020-10-06 17:00:53 +02:00
|
|
|
ui->comboBoxMin->setCurrentIndex(index != -1 ? index : 0);
|
|
|
|
ui->comboBoxMin->blockSignals(false);
|
|
|
|
|
|
|
|
ui->comboBoxMax->blockSignals(true);
|
|
|
|
ui->comboBoxMax->clear();
|
2021-01-19 20:13:17 +01:00
|
|
|
filtered = FilterByMinimum(bases, restriction.GetMin());
|
|
|
|
FillBases(FilterByMinimum(bases, restriction.GetMin()), dimension, ui->comboBoxMax);
|
|
|
|
index = ui->comboBoxMax->findData(restriction.GetMax());
|
2020-10-06 17:00:53 +02:00
|
|
|
ui->comboBoxMax->setCurrentIndex(index != -1 ? index : ui->comboBoxMax->count() - 1);
|
|
|
|
ui->comboBoxMax->blockSignals(false);
|
|
|
|
|
|
|
|
EnableRestrictionControls(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogRestrictDimension::DimensionAChanged()
|
|
|
|
{
|
|
|
|
InitTable();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogRestrictDimension::MinRestrictionChanged()
|
|
|
|
{
|
|
|
|
QTableWidgetItem *item = ui->tableWidget->currentItem();
|
|
|
|
|
2021-01-18 19:43:53 +01:00
|
|
|
if (item != nullptr)
|
2020-10-06 17:00:53 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
qreal base1 = 0;
|
|
|
|
qreal base2 = 0;
|
2020-10-06 17:00:53 +02:00
|
|
|
|
2021-01-19 20:13:17 +01:00
|
|
|
if (m_restrictionType == RestrictDimension::Second)
|
2020-10-06 17:00:53 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
base1 = item->data(Qt::UserRole).toDouble();
|
2020-10-06 17:00:53 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
base1 = ui->comboBoxDimensionA->currentData().toDouble();
|
|
|
|
base2 = item->data(Qt::UserRole).toDouble();
|
2020-10-06 17:00:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const QString coordinates = VMeasurement::CorrectionHash(base1, base2);
|
2021-01-19 20:13:17 +01:00
|
|
|
VDimensionRestriction restriction = m_restrictions.value(coordinates);
|
2020-10-06 17:00:53 +02:00
|
|
|
|
2021-01-19 20:13:17 +01:00
|
|
|
restriction.SetMin(ui->comboBoxMin->currentData().toDouble());
|
2020-10-06 17:00:53 +02:00
|
|
|
m_restrictions.insert(coordinates, restriction);
|
|
|
|
|
|
|
|
const int currentRow = ui->tableWidget->currentRow();
|
|
|
|
RefreshTable();
|
|
|
|
|
|
|
|
ui->tableWidget->blockSignals(true);
|
|
|
|
ui->tableWidget->selectRow(currentRow);
|
|
|
|
ui->tableWidget->blockSignals(false);
|
|
|
|
|
|
|
|
RowSelected();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogRestrictDimension::MaxRestrictionChanged()
|
|
|
|
{
|
|
|
|
QTableWidgetItem *item = ui->tableWidget->currentItem();
|
|
|
|
|
2021-01-18 19:43:53 +01:00
|
|
|
if (item != nullptr)
|
2020-10-06 17:00:53 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
qreal base1 = 0;
|
|
|
|
qreal base2 = 0;
|
2020-10-06 17:00:53 +02:00
|
|
|
|
2021-01-19 20:13:17 +01:00
|
|
|
if (m_restrictionType == RestrictDimension::Second)
|
2020-10-06 17:00:53 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
base1 = item->data(Qt::UserRole).toDouble();
|
2020-10-06 17:00:53 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
base1 = ui->comboBoxDimensionA->currentData().toDouble();
|
|
|
|
base2 = item->data(Qt::UserRole).toDouble();
|
2020-10-06 17:00:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const QString coordinates = VMeasurement::CorrectionHash(base1, base2);
|
2021-01-19 20:13:17 +01:00
|
|
|
VDimensionRestriction restriction = m_restrictions.value(coordinates);
|
2020-10-06 17:00:53 +02:00
|
|
|
|
2021-01-19 20:13:17 +01:00
|
|
|
restriction.SetMax(ui->comboBoxMax->currentData().toDouble());
|
2020-10-06 17:00:53 +02:00
|
|
|
m_restrictions.insert(coordinates, restriction);
|
|
|
|
|
|
|
|
const int currentRow = ui->tableWidget->currentRow();
|
|
|
|
RefreshTable();
|
|
|
|
|
|
|
|
ui->tableWidget->blockSignals(true);
|
|
|
|
ui->tableWidget->selectRow(currentRow);
|
|
|
|
ui->tableWidget->blockSignals(false);
|
|
|
|
|
|
|
|
RowSelected();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-19 20:13:17 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogRestrictDimension::CellContextMenu(QPoint pos)
|
|
|
|
{
|
|
|
|
QTableWidgetItem *item = ui->tableWidget->itemAt(pos);
|
|
|
|
if (item != nullptr && (item->flags() & Qt::ItemIsEnabled) != 0U)
|
|
|
|
{
|
|
|
|
qreal columnValue = 0;
|
|
|
|
QString coordinates;
|
|
|
|
MeasurementDimension_p dimension;
|
|
|
|
|
|
|
|
if (m_restrictionType == RestrictDimension::First)
|
|
|
|
{
|
|
|
|
if (not m_dimensions.empty())
|
|
|
|
{
|
|
|
|
columnValue = m_dimensions.at(0)->ValidBases().at(item->column());
|
|
|
|
coordinates = QChar('0');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (m_restrictionType == RestrictDimension::Second)
|
|
|
|
{
|
|
|
|
if (m_dimensions.size() >= 2)
|
|
|
|
{
|
|
|
|
dimension = m_dimensions.at(1);
|
|
|
|
columnValue = dimension->ValidBases().at(item->column());
|
|
|
|
qreal base1 = m_dimensions.at(0)->ValidBases().at(item->row());
|
|
|
|
coordinates = VMeasurement::CorrectionHash(base1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (m_restrictionType == RestrictDimension::Third)
|
|
|
|
{
|
|
|
|
if (m_dimensions.size() >= 3)
|
|
|
|
{
|
|
|
|
dimension = m_dimensions.at(2);
|
|
|
|
columnValue = dimension->ValidBases().at(item->column());
|
|
|
|
qreal base1 = ui->comboBoxDimensionA->currentData().toDouble();
|
|
|
|
qreal base2 = m_dimensions.at(1)->ValidBases().at(item->row());
|
|
|
|
coordinates = VMeasurement::CorrectionHash(base1, base2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
VDimensionRestriction restriction = m_restrictions.value(coordinates);
|
|
|
|
bool exclude = not restriction.GetExcludeValues().contains(columnValue);
|
|
|
|
QScopedPointer<QMenu> menu(new QMenu());
|
|
|
|
QAction *actionExclude = menu->addAction(exclude ? tr("Exclude") : tr("Include"));
|
|
|
|
|
|
|
|
if (m_restrictionType == RestrictDimension::Second || m_restrictionType == RestrictDimension::Third)
|
|
|
|
{
|
|
|
|
if (dimension != nullptr)
|
|
|
|
{
|
|
|
|
qreal min = restriction.GetMin();
|
|
|
|
if (qFuzzyIsNull(min))
|
|
|
|
{
|
|
|
|
min = dimension->MinValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
qreal max = restriction.GetMax();
|
|
|
|
if (qFuzzyIsNull(max))
|
|
|
|
{
|
|
|
|
max = dimension->MaxValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
actionExclude->setEnabled(columnValue >= min && columnValue <= max);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QAction *selectedAction = menu->exec(ui->tableWidget->viewport()->mapToGlobal(pos));
|
|
|
|
if (selectedAction == actionExclude)
|
|
|
|
{
|
|
|
|
QSet<qreal> list = restriction.GetExcludeValues();
|
|
|
|
if (exclude)
|
|
|
|
{
|
|
|
|
list.insert(columnValue);
|
|
|
|
item->setIcon(QIcon(QStringLiteral("://icon/24x24/close.png")));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
list.remove(columnValue);
|
|
|
|
item->setIcon(QIcon(QStringLiteral("://icon/24x24/star.png")));
|
|
|
|
}
|
|
|
|
restriction.SetExcludeValues(list);
|
|
|
|
m_restrictions[coordinates] = restriction;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-06 17:00:53 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogRestrictDimension::InitDimensionsBaseValues()
|
|
|
|
{
|
|
|
|
auto DimensionsBaseValue = [this](int index, QLabel *name, QComboBox *control)
|
|
|
|
{
|
|
|
|
SCASSERT(name != nullptr)
|
|
|
|
SCASSERT(control != nullptr)
|
|
|
|
|
|
|
|
if (m_dimensions.size() > index)
|
|
|
|
{
|
|
|
|
MeasurementDimension_p dimension = m_dimensions.at(index);
|
2022-02-14 12:26:24 +01:00
|
|
|
name->setText(dimension->Name()+QChar(':'));
|
|
|
|
name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension, m_fullCircumference));
|
2020-10-06 17:00:53 +02:00
|
|
|
|
|
|
|
InitDimensionGradation(dimension, control);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-01-19 20:13:17 +01:00
|
|
|
if (m_restrictionType == RestrictDimension::First)
|
|
|
|
{
|
|
|
|
ui->labelDimensionA->setVisible(false);
|
|
|
|
ui->comboBoxDimensionA->setVisible(false);
|
|
|
|
ui->groupBoxRestriction->setVisible(false);
|
|
|
|
}
|
|
|
|
else if (m_restrictionType == RestrictDimension::Second)
|
|
|
|
{
|
|
|
|
ui->labelDimensionA->setVisible(false);
|
|
|
|
ui->comboBoxDimensionA->setVisible(false);
|
|
|
|
}
|
|
|
|
else if (m_restrictionType == RestrictDimension::Third)
|
2020-10-06 17:00:53 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
if (not m_dimensions.empty())
|
2020-10-06 17:00:53 +02:00
|
|
|
{
|
|
|
|
DimensionsBaseValue(0, ui->labelDimensionA, ui->comboBoxDimensionA);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->labelDimensionA->setVisible(false);
|
|
|
|
ui->comboBoxDimensionA->setVisible(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogRestrictDimension::InitDimensionGradation(const MeasurementDimension_p &dimension, QComboBox *control)
|
|
|
|
{
|
|
|
|
SCASSERT(control != nullptr)
|
|
|
|
|
2021-01-18 19:43:53 +01:00
|
|
|
qreal current = -1;
|
2020-10-06 17:00:53 +02:00
|
|
|
if (control->currentIndex() != -1)
|
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
current = control->currentData().toDouble();
|
2020-10-06 17:00:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
control->blockSignals(true);
|
|
|
|
control->clear();
|
|
|
|
|
2021-01-19 20:13:17 +01:00
|
|
|
FillBases(DimensionRestrictedValues(dimension), dimension, control);
|
2020-10-06 17:00:53 +02:00
|
|
|
|
|
|
|
int i = control->findData(current);
|
|
|
|
if (i != -1)
|
|
|
|
{
|
|
|
|
control->setCurrentIndex(i);
|
|
|
|
control->blockSignals(false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
control->blockSignals(false);
|
|
|
|
control->setCurrentIndex(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogRestrictDimension::InitTable()
|
|
|
|
{
|
|
|
|
ui->tableWidget->blockSignals(true);
|
|
|
|
ui->tableWidget->clear();
|
|
|
|
|
2021-01-19 20:13:17 +01:00
|
|
|
auto InitVerticalHeaderForDimension = [this](int index)
|
2020-10-06 17:00:53 +02:00
|
|
|
{
|
|
|
|
if (m_dimensions.size() > index)
|
|
|
|
{
|
2021-01-19 20:13:17 +01:00
|
|
|
MeasurementDimension_p dimension = m_dimensions.at(index);
|
|
|
|
const QVector<qreal> bases = dimension->ValidBases();
|
|
|
|
ui->tableWidget->setRowCount(bases.size());
|
|
|
|
ui->tableWidget->setVerticalHeaderLabels(DimensionLabels(bases, dimension));
|
|
|
|
}
|
|
|
|
};
|
2020-10-06 17:00:53 +02:00
|
|
|
|
2021-01-19 20:13:17 +01:00
|
|
|
auto InitHorizontalHeaderForDimension = [this](int index)
|
|
|
|
{
|
|
|
|
if (m_dimensions.size() > index)
|
|
|
|
{
|
|
|
|
MeasurementDimension_p dimension = m_dimensions.at(index);
|
|
|
|
const QVector<qreal> bases = dimension->ValidBases();
|
|
|
|
ui->tableWidget->setColumnCount(bases.size());
|
|
|
|
ui->tableWidget->setHorizontalHeaderLabels(DimensionLabels(bases, dimension));
|
2020-10-06 17:00:53 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-01-19 20:13:17 +01:00
|
|
|
if (m_restrictionType == RestrictDimension::First)
|
|
|
|
{
|
|
|
|
InitHorizontalHeaderForDimension(0);
|
|
|
|
ui->tableWidget->setRowCount(1);
|
|
|
|
}
|
|
|
|
else if (m_restrictionType == RestrictDimension::Second)
|
|
|
|
{
|
|
|
|
InitVerticalHeaderForDimension(0);
|
|
|
|
InitHorizontalHeaderForDimension(1);
|
|
|
|
}
|
|
|
|
else if (m_restrictionType == RestrictDimension::Third)
|
|
|
|
{
|
|
|
|
InitVerticalHeaderForDimension(1);
|
|
|
|
InitHorizontalHeaderForDimension(2);
|
|
|
|
}
|
|
|
|
|
2020-10-06 17:00:53 +02:00
|
|
|
ui->tableWidget->blockSignals(false);
|
|
|
|
|
|
|
|
RefreshTable();
|
2021-01-19 11:24:56 +01:00
|
|
|
ui->tableWidget->selectRow(StartRow());
|
2020-10-06 17:00:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogRestrictDimension::RefreshTable()
|
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
QVector<qreal> basesRow;
|
|
|
|
QVector<qreal> basesColumn;
|
2020-10-06 17:00:53 +02:00
|
|
|
|
2021-01-19 20:13:17 +01:00
|
|
|
if (m_restrictionType == RestrictDimension::First)
|
|
|
|
{
|
|
|
|
if (not m_dimensions.empty())
|
|
|
|
{
|
|
|
|
MeasurementDimension_p dimensionA = m_dimensions.at(0);
|
|
|
|
basesColumn = dimensionA->ValidBases();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (m_restrictionType == RestrictDimension::Second)
|
2020-10-06 17:00:53 +02:00
|
|
|
{
|
|
|
|
if (m_dimensions.size() >= 2)
|
|
|
|
{
|
|
|
|
MeasurementDimension_p dimensionA = m_dimensions.at(0);
|
|
|
|
basesRow = dimensionA->ValidBases();
|
|
|
|
|
|
|
|
MeasurementDimension_p dimensionB = m_dimensions.at(1);
|
|
|
|
basesColumn = dimensionB->ValidBases();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2021-01-19 20:13:17 +01:00
|
|
|
else if (m_restrictionType == RestrictDimension::Third)
|
2020-10-06 17:00:53 +02:00
|
|
|
{
|
|
|
|
if (m_dimensions.size() >= 3)
|
|
|
|
{
|
2021-01-19 11:24:56 +01:00
|
|
|
MeasurementDimension_p dimensionB = m_dimensions.at(1);
|
|
|
|
basesRow = dimensionB->ValidBases();
|
2020-10-06 17:00:53 +02:00
|
|
|
|
2021-01-19 11:24:56 +01:00
|
|
|
MeasurementDimension_p dimensionC = m_dimensions.at(2);
|
|
|
|
basesColumn = dimensionC->ValidBases();
|
2020-10-06 17:00:53 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->tableWidget->blockSignals(true);
|
|
|
|
ui->tableWidget->clearContents();
|
|
|
|
|
2021-01-19 20:13:17 +01:00
|
|
|
if (m_restrictionType == RestrictDimension::First)
|
2020-10-06 17:00:53 +02:00
|
|
|
{
|
|
|
|
for(int column=0; column < basesColumn.size(); ++column)
|
|
|
|
{
|
2021-01-19 20:13:17 +01:00
|
|
|
AddCell(0, column, 0, basesColumn.at(column));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for(int row=0; row < basesRow.size(); ++row)
|
|
|
|
{
|
|
|
|
for(int column=0; column < basesColumn.size(); ++column)
|
|
|
|
{
|
|
|
|
AddCell(row, column, basesRow.at(row), basesColumn.at(column));
|
|
|
|
}
|
2020-10-06 17:00:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
2021-01-19 20:13:17 +01:00
|
|
|
|
|
|
|
if (m_restrictionType != RestrictDimension::First)
|
|
|
|
{
|
|
|
|
ui->tableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
|
|
|
}
|
2020-10-06 17:00:53 +02:00
|
|
|
|
|
|
|
ui->tableWidget->blockSignals(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
void DialogRestrictDimension::AddCell(int row, int column, qreal rowValue, qreal columnValue)
|
2020-10-06 17:00:53 +02:00
|
|
|
{
|
|
|
|
auto *item = new QTableWidgetItem();
|
|
|
|
item->setData(Qt::UserRole, rowValue);
|
|
|
|
|
2021-01-19 20:13:17 +01:00
|
|
|
if (m_restrictionType == RestrictDimension::First)
|
2020-10-06 17:00:53 +02:00
|
|
|
{
|
2021-01-19 20:13:17 +01:00
|
|
|
VDimensionRestriction restriction = m_restrictions.value(QChar('0'));
|
|
|
|
if (restriction.GetExcludeValues().contains(columnValue))
|
2020-10-07 17:09:27 +02:00
|
|
|
{
|
2021-01-19 20:13:17 +01:00
|
|
|
item->setIcon(QIcon(QStringLiteral("://icon/24x24/close.png")));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
item->setIcon(QIcon(QStringLiteral("://icon/24x24/star.png")));
|
2020-10-07 17:09:27 +02:00
|
|
|
}
|
2020-10-06 17:00:53 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-01-19 20:13:17 +01:00
|
|
|
qreal base1 = 0;
|
|
|
|
qreal base2 = 0;
|
|
|
|
MeasurementDimension_p dimension;
|
|
|
|
QVector<qreal> bases;
|
|
|
|
QVector<qreal> validRows;
|
2020-10-07 17:09:27 +02:00
|
|
|
|
2021-01-19 20:13:17 +01:00
|
|
|
if (m_restrictionType == RestrictDimension::Second)
|
2020-10-07 17:09:27 +02:00
|
|
|
{
|
2021-01-19 20:13:17 +01:00
|
|
|
base1 = rowValue;
|
|
|
|
|
|
|
|
if (m_dimensions.size() >= 2)
|
|
|
|
{
|
2021-01-28 16:38:30 +01:00
|
|
|
validRows = DimensionRestrictedValues(m_dimensions.at(0));
|
2021-01-19 20:13:17 +01:00
|
|
|
dimension = m_dimensions.at(1);
|
|
|
|
bases = dimension->ValidBases();
|
|
|
|
}
|
2020-10-07 17:09:27 +02:00
|
|
|
}
|
2021-01-19 20:13:17 +01:00
|
|
|
else if (m_restrictionType == RestrictDimension::Third)
|
|
|
|
{
|
|
|
|
base1 = ui->comboBoxDimensionA->currentData().toDouble();
|
|
|
|
base2 = rowValue;
|
2020-10-06 17:00:53 +02:00
|
|
|
|
2021-01-19 20:13:17 +01:00
|
|
|
if (m_dimensions.size() >= 3)
|
|
|
|
{
|
|
|
|
validRows = DimensionRestrictedValues(m_dimensions.at(1));
|
|
|
|
dimension = m_dimensions.at(2);
|
|
|
|
bases = dimension->ValidBases();
|
|
|
|
}
|
|
|
|
}
|
2020-10-06 17:00:53 +02:00
|
|
|
|
2021-01-19 20:13:17 +01:00
|
|
|
VDimensionRestriction restriction = m_restrictions.value(VMeasurement::CorrectionHash(base1, base2));
|
|
|
|
qreal min = INT32_MIN;
|
|
|
|
qreal max = INT32_MAX;
|
2020-10-06 17:00:53 +02:00
|
|
|
|
2021-01-19 20:13:17 +01:00
|
|
|
if (not dimension.isNull())
|
2020-10-07 17:09:27 +02:00
|
|
|
{
|
2021-01-19 20:13:17 +01:00
|
|
|
min = bases.indexOf(restriction.GetMin()) != -1 ? restriction.GetMin() : dimension->MinValue();
|
|
|
|
max = bases.indexOf(restriction.GetMax()) != -1 ? restriction.GetMax() : dimension->MaxValue();
|
2020-10-06 17:00:53 +02:00
|
|
|
|
2021-01-19 20:13:17 +01:00
|
|
|
if (max < min)
|
|
|
|
{
|
|
|
|
min = dimension->MinValue();
|
|
|
|
max = dimension->MaxValue();
|
|
|
|
}
|
|
|
|
}
|
2021-01-19 11:24:56 +01:00
|
|
|
|
2021-01-19 20:13:17 +01:00
|
|
|
if (validRows.contains(rowValue))
|
2021-01-19 11:24:56 +01:00
|
|
|
{
|
2021-01-19 20:13:17 +01:00
|
|
|
const bool leftRestriction = columnValue >= min;
|
|
|
|
const bool rightRestriction = columnValue <= max;
|
|
|
|
|
|
|
|
if (leftRestriction && rightRestriction)
|
|
|
|
{
|
|
|
|
if (restriction.GetExcludeValues().contains(columnValue))
|
|
|
|
{
|
|
|
|
item->setIcon(QIcon(QStringLiteral("://icon/24x24/close.png")));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
item->setIcon(QIcon(QStringLiteral("://icon/24x24/star.png")));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
item->setIcon(QIcon(QStringLiteral("://icon/24x24/close.png")));
|
|
|
|
}
|
2021-01-19 11:24:56 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
item->setIcon(QIcon(QStringLiteral("://icon/24x24/close.png")));
|
|
|
|
|
2021-01-19 20:13:17 +01:00
|
|
|
Qt::ItemFlags flags = item->flags();
|
|
|
|
flags &= ~(Qt::ItemIsEnabled);
|
|
|
|
item->setFlags(flags);
|
|
|
|
}
|
2020-10-06 17:00:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// set the item non-editable (view only), and non-selectable
|
|
|
|
Qt::ItemFlags flags = item->flags();
|
|
|
|
flags &= ~(Qt::ItemIsEditable); // reset/clear the flag
|
|
|
|
item->setFlags(flags);
|
|
|
|
|
|
|
|
ui->tableWidget->setItem(row, column, item);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogRestrictDimension::EnableRestrictionControls(bool enable)
|
|
|
|
{
|
|
|
|
if (not enable)
|
|
|
|
{
|
|
|
|
ui->comboBoxMin->blockSignals(true);
|
|
|
|
ui->comboBoxMin->setCurrentIndex(-1);
|
|
|
|
ui->comboBoxMin->blockSignals(false);
|
|
|
|
|
|
|
|
ui->comboBoxMax->blockSignals(true);
|
|
|
|
ui->comboBoxMax->setCurrentIndex(-1);
|
|
|
|
ui->comboBoxMax->blockSignals(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->groupBoxRestriction->setEnabled(enable);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
void DialogRestrictDimension::FillBases(const QVector<qreal> &bases, const MeasurementDimension_p &dimension,
|
|
|
|
QComboBox *control) const
|
2020-10-06 17:00:53 +02:00
|
|
|
{
|
|
|
|
SCASSERT(control != nullptr)
|
|
|
|
|
2020-10-08 12:34:38 +02:00
|
|
|
const DimesionLabels labels = dimension->Labels();
|
2020-10-06 17:00:53 +02:00
|
|
|
const QString units = UnitsToStr(dimension->Units(), true);
|
|
|
|
|
|
|
|
if (dimension->Type() == MeasurementDimension::X)
|
|
|
|
{
|
|
|
|
for(auto base : bases)
|
|
|
|
{
|
2020-10-08 12:34:38 +02:00
|
|
|
if (labels.contains(base) && not labels.value(base).isEmpty())
|
|
|
|
{
|
|
|
|
control->addItem(labels.value(base), base);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
control->addItem(QStringLiteral("%1 %2").arg(base).arg(units), base);
|
2020-10-08 12:34:38 +02:00
|
|
|
}
|
2020-10-06 17:00:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (dimension->Type() == MeasurementDimension::Y)
|
|
|
|
{
|
|
|
|
for(auto base : bases)
|
|
|
|
{
|
2020-10-08 12:34:38 +02:00
|
|
|
if (labels.contains(base) && not labels.value(base).isEmpty())
|
2020-10-06 17:00:53 +02:00
|
|
|
{
|
2020-10-08 12:34:38 +02:00
|
|
|
control->addItem(labels.value(base), base);
|
2020-10-06 17:00:53 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-08 12:34:38 +02:00
|
|
|
if (dimension->IsCircumference())
|
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
control->addItem(QStringLiteral("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units), base);
|
2020-10-08 12:34:38 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
control->addItem(QString::number(base), base);
|
|
|
|
}
|
2020-10-06 17:00:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (dimension->Type() == MeasurementDimension::W || dimension->Type() == MeasurementDimension::Z)
|
|
|
|
{
|
|
|
|
for(auto base : bases)
|
|
|
|
{
|
2020-10-08 12:34:38 +02:00
|
|
|
if (labels.contains(base) && not labels.value(base).isEmpty())
|
|
|
|
{
|
|
|
|
control->addItem(labels.value(base), base);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
control->addItem(QStringLiteral("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units), base);
|
2020-10-08 12:34:38 +02:00
|
|
|
}
|
2020-10-06 17:00:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
auto DialogRestrictDimension::DimensionLabels(const QVector<qreal> &bases,
|
|
|
|
const MeasurementDimension_p &dimension) const -> QStringList
|
2020-10-06 17:00:53 +02:00
|
|
|
{
|
|
|
|
const bool showUnits = dimension->IsCircumference() || dimension->Type() == MeasurementDimension::X;
|
|
|
|
const QString units = showUnits ? UnitsToStr(dimension->Units(), true) : QString();
|
2020-10-08 12:34:38 +02:00
|
|
|
const DimesionLabels dimensionLabels = dimension->Labels();
|
2020-10-06 17:00:53 +02:00
|
|
|
|
|
|
|
QStringList labels;
|
|
|
|
|
|
|
|
if (dimension->Type() == MeasurementDimension::X)
|
|
|
|
{
|
|
|
|
for(auto base : bases)
|
|
|
|
{
|
2020-10-08 12:34:38 +02:00
|
|
|
if (dimensionLabels.contains(base) && not dimensionLabels.value(base).isEmpty())
|
|
|
|
{
|
|
|
|
labels.append(dimensionLabels.value(base));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
labels.append(QStringLiteral("%1 %2").arg(base).arg(units));
|
2020-10-08 12:34:38 +02:00
|
|
|
}
|
2020-10-06 17:00:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (dimension->Type() == MeasurementDimension::Y)
|
|
|
|
{
|
|
|
|
for(auto base : bases)
|
|
|
|
{
|
2020-10-08 12:34:38 +02:00
|
|
|
if (dimensionLabels.contains(base) && not dimensionLabels.value(base).isEmpty())
|
2020-10-06 17:00:53 +02:00
|
|
|
{
|
2020-10-08 12:34:38 +02:00
|
|
|
labels.append(dimensionLabels.value(base));
|
2020-10-06 17:00:53 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-08 12:34:38 +02:00
|
|
|
if (dimension->IsCircumference())
|
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
labels.append(QStringLiteral("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units));
|
2020-10-08 12:34:38 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
labels.append(QString::number(base));
|
|
|
|
}
|
2020-10-06 17:00:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (dimension->Type() == MeasurementDimension::W || dimension->Type() == MeasurementDimension::Z)
|
|
|
|
{
|
|
|
|
for(auto base : bases)
|
|
|
|
{
|
2020-10-08 12:34:38 +02:00
|
|
|
if (dimensionLabels.contains(base) && not dimensionLabels.value(base).isEmpty())
|
|
|
|
{
|
|
|
|
labels.append(dimensionLabels.value(base));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
labels.append(QStringLiteral("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units));
|
2020-10-08 12:34:38 +02:00
|
|
|
}
|
2020-10-06 17:00:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return labels;
|
|
|
|
}
|
2021-01-19 11:24:56 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
auto DialogRestrictDimension::DimensionRestrictedValues(const MeasurementDimension_p &dimension) const -> QVector<qreal>
|
|
|
|
{
|
2021-01-19 20:13:17 +01:00
|
|
|
VDimensionRestriction restriction;
|
2021-01-19 11:24:56 +01:00
|
|
|
|
2021-01-28 16:38:30 +01:00
|
|
|
if (m_restrictionType == RestrictDimension::First || m_restrictionType == RestrictDimension::Second)
|
2021-01-19 20:13:17 +01:00
|
|
|
{
|
|
|
|
restriction = m_restrictions.value(QChar('0'));
|
|
|
|
}
|
|
|
|
else if (m_restrictionType == RestrictDimension::Third)
|
2021-01-19 11:24:56 +01:00
|
|
|
{
|
|
|
|
qreal base1 = ui->comboBoxDimensionA->currentData().toDouble();
|
2021-01-19 20:13:17 +01:00
|
|
|
restriction = m_restrictions.value(VMeasurement::CorrectionHash(base1));
|
2021-01-19 11:24:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const QVector<qreal> bases = dimension->ValidBases();
|
|
|
|
|
2021-01-19 20:13:17 +01:00
|
|
|
qreal min = bases.indexOf(restriction.GetMin()) != -1 ? restriction.GetMin() : dimension->MinValue();
|
|
|
|
qreal max = bases.indexOf(restriction.GetMax()) != -1 ? restriction.GetMax() : dimension->MaxValue();
|
2021-01-19 11:24:56 +01:00
|
|
|
|
|
|
|
if (min > max)
|
|
|
|
{
|
|
|
|
min = dimension->MinValue();
|
|
|
|
max = dimension->MaxValue();
|
|
|
|
}
|
|
|
|
|
2021-01-19 20:13:17 +01:00
|
|
|
return VAbstartMeasurementDimension::ValidBases(min, max, dimension->Step(), restriction.GetExcludeValues());
|
2021-01-19 11:24:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
auto DialogRestrictDimension::StartRow() const -> int
|
|
|
|
{
|
2021-01-19 20:13:17 +01:00
|
|
|
if (m_restrictionType == RestrictDimension::Second)
|
2021-01-19 11:24:56 +01:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
QVector<qreal> basesRow;
|
|
|
|
|
|
|
|
if (m_dimensions.size() >= 3)
|
|
|
|
{
|
|
|
|
MeasurementDimension_p dimensionB = m_dimensions.at(1);
|
|
|
|
basesRow = dimensionB->ValidBases();
|
|
|
|
|
|
|
|
QVector<qreal> validRows = DimensionRestrictedValues(dimensionB);
|
|
|
|
|
|
|
|
for(int i=0; i < basesRow.size(); ++i)
|
|
|
|
{
|
|
|
|
if (validRows.contains(basesRow.at(i)))
|
|
|
|
{
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|