#1634 Calculating smallest positive value and using this value for the min range value when using logarithmic scale

This commit is contained in:
astridkbjorke
2017-06-30 16:16:27 +02:00
parent d6ae3b4a53
commit 032630f6e9
7 changed files with 25 additions and 10 deletions

View File

@@ -91,14 +91,14 @@ std::vector<QString> RimFractureTemplateCollection::stimPlanResultNames() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimFractureTemplateCollection::computeMinMax(const QString& resultName, const QString& unit, double* minValue, double* maxValue) const void RimFractureTemplateCollection::computeMinMax(const QString& resultName, const QString& unit, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const
{ {
for (const RimFractureTemplate* f : fractureDefinitions()) for (const RimFractureTemplate* f : fractureDefinitions())
{ {
auto stimPlanFracture = dynamic_cast<const RimStimPlanFractureTemplate*>(f); auto stimPlanFracture = dynamic_cast<const RimStimPlanFractureTemplate*>(f);
if (stimPlanFracture) if (stimPlanFracture)
{ {
stimPlanFracture->computeMinMax(resultName, unit, minValue, maxValue); stimPlanFracture->computeMinMax(resultName, unit, minValue, maxValue, posClosestToZero, negClosestToZero);
} }
} }
} }

View File

@@ -43,7 +43,7 @@ public:
std::vector<std::pair<QString, QString> > stimPlanResultNamesAndUnits() const; std::vector<std::pair<QString, QString> > stimPlanResultNamesAndUnits() const;
std::vector<QString> stimPlanResultNames() const; std::vector<QString> stimPlanResultNames() const;
void computeMinMax(const QString& resultName, const QString& unit, double* minValue, double* maxValue) const; void computeMinMax(const QString& resultName, const QString& unit, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const;
void deleteFractureDefinitions(); void deleteFractureDefinitions();
void loadAndUpdateData(); void loadAndUpdateData();

View File

@@ -348,11 +348,11 @@ std::vector<std::pair<QString, QString> > RimStimPlanFractureTemplate::resultNam
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimStimPlanFractureTemplate::computeMinMax(const QString& resultName, const QString& unitName, double* minValue, double* maxValue) const void RimStimPlanFractureTemplate::computeMinMax(const QString& resultName, const QString& unitName, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const
{ {
if (m_stimPlanFractureDefinitionData.notNull()) if (m_stimPlanFractureDefinitionData.notNull())
{ {
m_stimPlanFractureDefinitionData->computeMinMax(resultName, unitName, minValue, maxValue); m_stimPlanFractureDefinitionData->computeMinMax(resultName, unitName, minValue, maxValue, posClosestToZero, negClosestToZero);
} }
} }

View File

@@ -75,7 +75,7 @@ public:
const std::vector<double>& timeSteps(); const std::vector<double>& timeSteps();
std::vector<std::pair<QString, QString> > resultNamesWithUnit() const; std::vector<std::pair<QString, QString> > resultNamesWithUnit() const;
void computeMinMax(const QString& resultName, const QString& unitName, double* minValue, double* maxValue) const; void computeMinMax(const QString& resultName, const QString& unitName, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const;
std::vector<std::vector<double>> resultValues(const QString& resultName, const QString& unitName, size_t timeStepIndex) const; std::vector<std::vector<double>> resultValues(const QString& resultName, const QString& unitName, size_t timeStepIndex) const;
std::vector<double> fractureGridResults(const QString& resultName, const QString& unitName, size_t timeStepIndex) const; std::vector<double> fractureGridResults(const QString& resultName, const QString& unitName, size_t timeStepIndex) const;

View File

@@ -247,14 +247,17 @@ void RimStimPlanColors::updateLegendData()
{ {
double minValue = HUGE_VAL; double minValue = HUGE_VAL;
double maxValue = -HUGE_VAL; double maxValue = -HUGE_VAL;
double posClosestToZero = HUGE_VAL;
double negClosestToZero = -HUGE_VAL;
RimFractureTemplateCollection* fracTemplateColl = fractureTemplateCollection(); RimFractureTemplateCollection* fracTemplateColl = fractureTemplateCollection();
fracTemplateColl->computeMinMax(resultName(), unit(), &minValue, &maxValue); fracTemplateColl->computeMinMax(resultName(), unit(), &minValue, &maxValue, &posClosestToZero, &negClosestToZero);
if (minValue != HUGE_VAL) if (minValue != HUGE_VAL)
{ {
legendConfig->setAutomaticRanges(minValue, maxValue, minValue, maxValue); legendConfig->setAutomaticRanges(minValue, maxValue, minValue, maxValue);
legendConfig->setClosestToZeroValues(posClosestToZero, negClosestToZero, posClosestToZero, negClosestToZero);
} }
legendConfig->setTitle(cvfqt::Utils::toString(m_resultNameAndUnit())); legendConfig->setTitle(cvfqt::Utils::toString(m_resultNameAndUnit()));

View File

@@ -563,9 +563,11 @@ const std::vector<std::vector<double>>& RigStimPlanFractureDefinition::getDataAt
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RigStimPlanFractureDefinition::computeMinMax(const QString& resultName, const QString& unit, double* minValue, double* maxValue) const void RigStimPlanFractureDefinition::computeMinMax(const QString& resultName, const QString& unit,
double* minValue, double* maxValue,
double* posClosestToZero, double* negClosestToZero) const
{ {
CVF_ASSERT(minValue && maxValue); CVF_ASSERT(minValue && maxValue && posClosestToZero && negClosestToZero);
size_t resIndex = resultIndex(resultName, unit); size_t resIndex = resultIndex(resultName, unit);
if (resIndex == cvf::UNDEFINED_SIZE_T) return; if (resIndex == cvf::UNDEFINED_SIZE_T) return;
@@ -585,6 +587,16 @@ void RigStimPlanFractureDefinition::computeMinMax(const QString& resultName, con
{ {
*maxValue = resultValue; *maxValue = resultValue;
} }
if (resultValue > 0 && resultValue < *posClosestToZero)
{
*posClosestToZero = resultValue;
}
if (resultValue < 0 && resultValue > *negClosestToZero)
{
*posClosestToZero = resultValue;
}
} }
} }
} }

View File

@@ -102,7 +102,7 @@ public:
std::vector<double> fractureGridResults(const QString& resultName, std::vector<double> fractureGridResults(const QString& resultName,
const QString& unitName, const QString& unitName,
size_t timeStepIndex) const; size_t timeStepIndex) const;
void computeMinMax(const QString& resultName, const QString& unit, double* minValue, double* maxValue) const; void computeMinMax(const QString& resultName, const QString& unit, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const;
// Setup // Setup
void reorderYgridToDepths(); void reorderYgridToDepths();