Correct way to apply restrictions.
This commit is contained in:
parent
1bb0a896f5
commit
f072ee5888
|
@ -453,31 +453,50 @@ void DialogRestrictDimension::AddCell(int row, int column, int rowValue, int col
|
|||
|
||||
int base1 = 0;
|
||||
int base2 = 0;
|
||||
MeasurementDimension_p dimension;
|
||||
QVector<int> bases;
|
||||
|
||||
if (m_oneDimesionRestriction)
|
||||
{
|
||||
base1 = rowValue;
|
||||
|
||||
if (m_dimensions.size() >= 2)
|
||||
{
|
||||
dimension = m_dimensions.at(1);
|
||||
bases = dimension->ValidBases();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
base1 = ui->comboBoxDimensionA->currentData().toInt();
|
||||
base2 = rowValue;
|
||||
|
||||
if (m_dimensions.size() >= 3)
|
||||
{
|
||||
dimension = m_dimensions.at(2);
|
||||
bases = dimension->ValidBases();
|
||||
}
|
||||
}
|
||||
|
||||
QPair<int, int> restriction = m_restrictions.value(VMeasurement::CorrectionHash(base1, base2),
|
||||
QPair<int, int>(0, 0));
|
||||
int min = INT32_MIN;
|
||||
int max = INT32_MAX;
|
||||
|
||||
bool leftRestriction = true;
|
||||
if (restriction.first > 0 && restriction.first <= restriction.second)
|
||||
if (not dimension.isNull())
|
||||
{
|
||||
leftRestriction = columnValue >= restriction.first;
|
||||
min = bases.indexOf(restriction.first) != -1 ? restriction.first : dimension->MinValue();
|
||||
max = bases.indexOf(restriction.second) != -1 ? restriction.second : dimension->MaxValue();
|
||||
|
||||
if (max < min)
|
||||
{
|
||||
min = dimension->MinValue();
|
||||
max = dimension->MaxValue();
|
||||
}
|
||||
}
|
||||
|
||||
bool rightRestriction = true;
|
||||
if (restriction.second > 0 && restriction.second >= restriction.first)
|
||||
{
|
||||
rightRestriction = columnValue <= restriction.second;
|
||||
}
|
||||
const bool leftRestriction = columnValue >= min;
|
||||
const bool rightRestriction = columnValue <= max;
|
||||
|
||||
if (leftRestriction && rightRestriction)
|
||||
{
|
||||
|
|
|
@ -333,8 +333,9 @@ bool TMainWindow::LoadFile(const QString &path)
|
|||
mUnit = m->MUnit();
|
||||
pUnit = mUnit;
|
||||
|
||||
currentDimensionB = m->DimensionABase();
|
||||
currentDimensionA = m->DimensionBBase();
|
||||
currentDimensionA = m->DimensionABase();
|
||||
currentDimensionB = m->DimensionBBase();
|
||||
currentDimensionC = m->DimensionCBase();
|
||||
|
||||
ui->labelToolTip->setVisible(false);
|
||||
ui->tabWidget->setVisible(true);
|
||||
|
@ -3424,8 +3425,9 @@ bool TMainWindow::LoadFromExistingFile(const QString &path)
|
|||
mUnit = m->MUnit();
|
||||
pUnit = mUnit;
|
||||
|
||||
currentDimensionA = m->DimensionBBase();
|
||||
currentDimensionB = m->DimensionABase();
|
||||
currentDimensionA = m->DimensionABase();
|
||||
currentDimensionB = m->DimensionBBase();
|
||||
currentDimensionC = m->DimensionCBase();
|
||||
|
||||
ui->labelToolTip->setVisible(false);
|
||||
ui->tabWidget->setVisible(true);
|
||||
|
@ -4021,12 +4023,18 @@ QVector<int> TMainWindow::DimensionRestrictedValues(int index, const Measurement
|
|||
restriction = m->Restriction(currentDimensionA, currentDimensionB);
|
||||
}
|
||||
|
||||
if (restriction.first < dimension->MinValue() || restriction.second > dimension->MaxValue())
|
||||
{ // invalid restriction
|
||||
return dimension->ValidBases();
|
||||
const QVector<int> bases = dimension->ValidBases();
|
||||
|
||||
int min = bases.indexOf(restriction.first) != -1 ? restriction.first : dimension->MinValue();
|
||||
int max = bases.indexOf(restriction.second) != -1 ? restriction.second : dimension->MaxValue();
|
||||
|
||||
if (min > max)
|
||||
{
|
||||
min = dimension->MinValue();
|
||||
max = dimension->MaxValue();
|
||||
}
|
||||
|
||||
return VAbstartMeasurementDimension::ValidBases(restriction.first, restriction.second, dimension->Step());
|
||||
return VAbstartMeasurementDimension::ValidBases(min, max, dimension->Step());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue
Block a user