#1359 Sort tracers in category selection list in property editor

This commit is contained in:
Magne Sjaastad 2017-03-24 21:34:46 +01:00
parent da53183f41
commit fcd2d96907
4 changed files with 42 additions and 2 deletions

View File

@ -279,6 +279,30 @@ bool RimEclipsePropertyFilter::isPropertyFilterControlled()
return isPropertyFilterControlled;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilter::setCategoriesFromTracerNames(const std::vector<QString>& tracerNames)
{
std::vector<std::pair<QString, int>> tracerNameValuesSorted;
{
std::set<std::pair<QString, int>> tracerNameSet;
for (size_t i = 0; i < tracerNames.size(); i++)
{
tracerNameSet.insert(std::make_pair(tracerNames[i], static_cast<int>(i)));
}
for (auto it : tracerNameSet)
{
tracerNameValuesSorted.push_back(it);
}
}
setCategoryNamesAndValues(tracerNameValuesSorted);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -337,7 +361,7 @@ void RimEclipsePropertyFilter::computeResultValueRange()
if ( resultDefinition->hasCategoryResult() )
{
setCategoryNames(resultDefinition->flowDiagSolution()->tracerNames());
setCategoriesFromTracerNames(resultDefinition->flowDiagSolution()->tracerNames());
}
}
}
@ -423,7 +447,7 @@ void RimEclipsePropertyFilter::updateFromCurrentTimeStep()
if (resultDefinition->hasCategoryResult())
{
setCategoryNames(resultDefinition->flowDiagSolution()->tracerNames());
setCategoriesFromTracerNames(resultDefinition->flowDiagSolution()->tracerNames());
}
}

View File

@ -71,6 +71,7 @@ private:
void updateReadOnlyStateOfAllFields();
void updateRangeLabel();
bool isPropertyFilterControlled();
void setCategoriesFromTracerNames(const std::vector<QString>& tracerNames);
RimEclipsePropertyFilterCollection* parentContainer();

View File

@ -102,6 +102,20 @@ void RimPropertyFilter::setCategoryNames(const std::vector<QString>& categoryNam
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPropertyFilter::setCategoryNamesAndValues(const std::vector<std::pair<QString, int>>& categoryNamesAndValues)
{
clearCategories();
for (auto it : categoryNamesAndValues)
{
m_categoryNames.push_back(it.first);
m_categoryValues.push_back(it.second);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -37,6 +37,7 @@ public:
protected:
void setCategoryValues(const std::vector<int>& categoryValues);
void setCategoryNames(const std::vector<QString>& categoryNames);
void setCategoryNamesAndValues(const std::vector<std::pair<QString, int>>& categoryNamesAndValues);
void clearCategories();
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;