Redesign filtering bases.
This commit is contained in:
parent
4a12c1ca74
commit
506ce6fb5e
|
@ -4000,77 +4000,27 @@ void TMainWindow::SetCurrentDimensionValues()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<int> TMainWindow::DimensionRestrictedValues(int index, const MeasurementDimension_p &dimension)
|
||||
{
|
||||
QPair<int, int> restriction;
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
return dimension->ValidBases();
|
||||
}
|
||||
|
||||
if (dimension->Type() == MeasurementDimension::X)
|
||||
else if (index == 1)
|
||||
{
|
||||
restriction = m->Restriction(currentDimensionA);
|
||||
}
|
||||
else
|
||||
{
|
||||
restriction = m->Restriction(currentDimensionA, currentDimensionB);
|
||||
}
|
||||
|
||||
if (restriction.first < dimension->MinValue() || restriction.second > dimension->MaxValue())
|
||||
{ // invalid restriction
|
||||
return dimension->ValidBases();
|
||||
}
|
||||
else if (dimension->Type() == MeasurementDimension::Y)
|
||||
{
|
||||
const QPair<int, int> restriction = m->Restriction(currentDimensionA);
|
||||
VYMeasurementDimension restricted(dimension->Units(), restriction.first, restriction.second, dimension->Step());
|
||||
restricted.SetCircumference(dimension->IsCircumference());
|
||||
|
||||
if (restriction.first < dimension->MinValue() || restriction.second > dimension->MaxValue()
|
||||
|| not restricted.IsValid())
|
||||
{ // invalid restriction
|
||||
return dimension->ValidBases();
|
||||
}
|
||||
|
||||
return restricted.ValidBases();
|
||||
}
|
||||
else if (dimension->Type() == MeasurementDimension::W)
|
||||
{
|
||||
QPair<int, int> restriction;
|
||||
|
||||
if (index == 1)
|
||||
{
|
||||
restriction = m->Restriction(currentDimensionA);
|
||||
}
|
||||
else
|
||||
{
|
||||
restriction = m->Restriction(currentDimensionA, currentDimensionB);
|
||||
}
|
||||
|
||||
VWMeasurementDimension restricted(dimension->Units(), restriction.first, restriction.second, dimension->Step());
|
||||
|
||||
if (restriction.first < dimension->MinValue() || restriction.second > dimension->MaxValue()
|
||||
|| not restricted.IsValid())
|
||||
{ // invalid restriction
|
||||
return dimension->ValidBases();
|
||||
}
|
||||
|
||||
return restricted.ValidBases();
|
||||
}
|
||||
else if (dimension->Type() == MeasurementDimension::Z)
|
||||
{
|
||||
QPair<int, int> restriction;
|
||||
|
||||
if (index == 1)
|
||||
{
|
||||
restriction = m->Restriction(currentDimensionA);
|
||||
}
|
||||
else
|
||||
{
|
||||
restriction = m->Restriction(currentDimensionA, currentDimensionB);
|
||||
}
|
||||
|
||||
VZMeasurementDimension restricted(dimension->Units(), restriction.first, restriction.second, dimension->Step());
|
||||
|
||||
if (restriction.first < dimension->MinValue() || restriction.second > dimension->MaxValue()
|
||||
|| not restricted.IsValid())
|
||||
{ // invalid restriction
|
||||
return dimension->ValidBases();
|
||||
}
|
||||
|
||||
return restricted.ValidBases();
|
||||
}
|
||||
|
||||
return QVector<int>();
|
||||
return VAbstartMeasurementDimension::ValidBases(restriction.first, restriction.second, dimension->Step());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -78,24 +78,7 @@ QVector<int> VAbstartMeasurementDimension::ValidSteps() const
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<int> VAbstartMeasurementDimension::ValidBases() const
|
||||
{
|
||||
QVector<int> validBases;
|
||||
int step = Step();
|
||||
|
||||
if (step < 0)
|
||||
{
|
||||
return validBases;
|
||||
}
|
||||
else if (step == 0)
|
||||
{
|
||||
step = 1;
|
||||
}
|
||||
|
||||
for (int value = MinValue(); value <= MaxValue(); value += step)
|
||||
{
|
||||
validBases.append(value);
|
||||
}
|
||||
|
||||
return validBases;
|
||||
return VAbstartMeasurementDimension::ValidBases(m_minValue, m_maxValue, m_step);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -111,6 +94,28 @@ QStringList VAbstartMeasurementDimension::ValidBasesList() const
|
|||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<int> VAbstartMeasurementDimension::ValidBases(int min, int max, int step)
|
||||
{
|
||||
QVector<int> validBases;
|
||||
|
||||
if (step < 0)
|
||||
{
|
||||
return validBases;
|
||||
}
|
||||
else if (step == 0)
|
||||
{
|
||||
step = 1;
|
||||
}
|
||||
|
||||
for (int value = min; value <= max; value += step)
|
||||
{
|
||||
validBases.append(value);
|
||||
}
|
||||
|
||||
return validBases;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VAbstartMeasurementDimension::IsRangeValid()
|
||||
{
|
||||
|
|
|
@ -83,6 +83,7 @@ public:
|
|||
QVector<int> ValidBases() const;
|
||||
QStringList ValidBasesList() const;
|
||||
|
||||
static QVector<int> ValidBases(int min, int max, int step);
|
||||
static QString DimensionName(MeasurementDimension type);
|
||||
static QString DimensionToolTip(MeasurementDimension type, bool circumference, bool fc);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user