mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2460 Tensor Vectors: Use result as colormapping on the vectors
This commit is contained in:
@@ -379,9 +379,51 @@ void RimGeoMechView::updateLegends()
|
||||
{
|
||||
m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->legend());
|
||||
}
|
||||
|
||||
updateTensorLegendTextAndRanges(m_tensorResults->legendConfig(), m_currentTimeStep());
|
||||
|
||||
if (tensorResults()->vectorColors() == RimTensorResults::RESULT_COLORS)
|
||||
{
|
||||
m_viewer->addColorLegendToBottomLeftCorner(m_tensorResults->legendConfig->legend());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechView::updateTensorLegendTextAndRanges(RimLegendConfig* legendConfig, int timeStepIndex)
|
||||
{
|
||||
if (!m_geomechCase || !m_geomechCase->geoMechData()) return;
|
||||
|
||||
double localMin, localMax;
|
||||
double localPosClosestToZero, localNegClosestToZero;
|
||||
double globalMin, globalMax;
|
||||
double globalPosClosestToZero, globalNegClosestToZero;
|
||||
|
||||
RigGeoMechCaseData* gmCase = m_geomechCase->geoMechData();
|
||||
CVF_ASSERT(gmCase);
|
||||
|
||||
RigFemResultPosEnum resPos = tensorResults()->resultPositionType();
|
||||
QString resFieldName = tensorResults()->resultFieldName();
|
||||
|
||||
RigFemResultAddress resVarAddress(resPos, resFieldName.toStdString(), "");
|
||||
|
||||
gmCase->femPartResults()->minMaxScalarValuesOverAllTensorComponents(resVarAddress, timeStepIndex, &localMin, &localMax);
|
||||
gmCase->femPartResults()->posNegClosestToZeroOverAllTensorComponents(resVarAddress, timeStepIndex, &localPosClosestToZero, &localNegClosestToZero);
|
||||
|
||||
gmCase->femPartResults()->minMaxScalarValuesOverAllTensorComponents(resVarAddress, &globalMin, &globalMax);
|
||||
gmCase->femPartResults()->posNegClosestToZeroOverAllTensorComponents(resVarAddress, &globalPosClosestToZero, &globalNegClosestToZero);
|
||||
|
||||
legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero);
|
||||
legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax);
|
||||
|
||||
QString legendTitle = "Tensors:\n" + caf::AppEnum<RigFemResultPosEnum>(tensorResults()->resultPositionType()).uiText() + "\n"
|
||||
+ tensorResults()->resultFieldName();
|
||||
|
||||
legendConfig->setTitle(legendTitle);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -424,9 +466,8 @@ void RimGeoMechView::updateLegendTextAndRanges(RimLegendConfig* legendConfig, in
|
||||
legendConfig->setNamedCategoriesInverse(fnVector);
|
||||
}
|
||||
|
||||
QString legendTitle =
|
||||
caf::AppEnum<RigFemResultPosEnum>(cellResult->resultPositionType()).uiText() + "\n"
|
||||
+ cellResult->resultFieldUiName();
|
||||
QString legendTitle = "Cell Results:\n" + caf::AppEnum<RigFemResultPosEnum>(cellResult->resultPositionType()).uiText() +
|
||||
"\n" + cellResult->resultFieldUiName();
|
||||
|
||||
if (!cellResult->resultComponentUiName().isEmpty())
|
||||
{
|
||||
@@ -463,6 +504,14 @@ const RimTensorResults* RimGeoMechView::tensorResults() const
|
||||
return m_tensorResults;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimTensorResults* RimGeoMechView::tensorResults()
|
||||
{
|
||||
return m_tensorResults;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -91,6 +91,7 @@ public:
|
||||
|
||||
const cvf::ref<RivGeoMechVizLogic> vizLogic() const;
|
||||
const RimTensorResults* tensorResults() const;
|
||||
RimTensorResults* tensorResults();
|
||||
|
||||
protected:
|
||||
virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override;
|
||||
@@ -111,6 +112,8 @@ private:
|
||||
|
||||
void updateLegends();
|
||||
|
||||
void updateTensorLegendTextAndRanges(RimLegendConfig* legendConfig, int timeStepIndex);
|
||||
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
virtual void initAfterRead() override;
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "RigFemResultAddress.h"
|
||||
#include "RimGeoMechResultDefinition.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimLegendConfig.h"
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
#include "cafPdmUiListEditor.h"
|
||||
@@ -59,6 +60,10 @@ RimTensorResults::RimTensorResults()
|
||||
{
|
||||
CAF_PDM_InitObject("Tensor Results", ":/CellResult.png", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&legendConfig, "LegendDefinition", "Legend Definition", "", "", "");
|
||||
this->legendConfig = new RimLegendConfig();
|
||||
legendConfig.uiCapability()->setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_resultPositionType, "ResultPositionType", "Result Position", "", "", "");
|
||||
m_resultPositionType.uiCapability()->setUiHidden(true);
|
||||
|
||||
@@ -97,7 +102,7 @@ RimTensorResults::RimTensorResults()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimTensorResults::~RimTensorResults()
|
||||
{
|
||||
|
||||
delete legendConfig;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -108,6 +113,16 @@ RigFemResultAddress RimTensorResults::selectedTensorResult() const
|
||||
return RigFemResultAddress(m_resultPositionType(), m_resultFieldName().toStdString(), "");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimTensorResults::setShowTensors(bool enableTensors)
|
||||
{
|
||||
m_showTensors = enableTensors;
|
||||
updateConnectedEditors();
|
||||
updateUiIconFromState(enableTensors);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -172,6 +187,22 @@ RimTensorResults::ScaleMethod RimTensorResults::scaleMethod() const
|
||||
return m_scaleMethod();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigFemResultPosEnum RimTensorResults::resultPositionType() const
|
||||
{
|
||||
return m_resultPositionType();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimTensorResults::resultFieldName() const
|
||||
{
|
||||
return m_resultFieldName();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -208,6 +239,10 @@ void RimTensorResults::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
|
||||
m_resultPositionType = m_resultPositionTypeUiField;
|
||||
m_resultFieldName = m_resultFieldNameUiField;
|
||||
}
|
||||
if (changedField == &m_showTensors)
|
||||
{
|
||||
setShowTensors(m_showTensors);
|
||||
}
|
||||
|
||||
RimGeoMechView* view;
|
||||
firstAncestorOrThisOfType(view);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmChildField.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
@@ -28,6 +29,7 @@
|
||||
#include <vector>
|
||||
|
||||
class RigFemResultAddress;
|
||||
class RimLegendConfig;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@@ -56,6 +58,7 @@ public:
|
||||
virtual ~RimTensorResults();
|
||||
|
||||
RigFemResultAddress selectedTensorResult() const;
|
||||
void setShowTensors(bool enableTensors);
|
||||
bool showTensors() const;
|
||||
bool showPrincipal1() const;
|
||||
bool showPrincipal2() const;
|
||||
@@ -65,6 +68,11 @@ public:
|
||||
TensorColors vectorColors() const;
|
||||
ScaleMethod scaleMethod() const;
|
||||
|
||||
RigFemResultPosEnum resultPositionType() const;
|
||||
QString resultFieldName() const;
|
||||
|
||||
caf::PdmChildField<RimLegendConfig*> legendConfig;
|
||||
|
||||
private:
|
||||
std::vector<std::string> getResultMetaDataForUIFieldSetting();
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
|
||||
Reference in New Issue
Block a user