#2575 Use Integration Point to calculate elm avg tensor

This commit is contained in:
Rebecca Cox
2018-03-06 12:54:02 +01:00
parent 7f06f51e59
commit f4b6542f60
3 changed files with 9 additions and 47 deletions

View File

@@ -421,8 +421,7 @@ void RimGeoMechView::updateTensorLegendTextAndRanges(RimLegendConfig* legendConf
legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero); legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero);
legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax); legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax);
QString legendTitle = "Tensors:\n" + caf::AppEnum<RigFemResultPosEnum>(tensorResults()->resultPositionType()).uiText() + "\n" QString legendTitle = "Tensors:\n" + RimTensorResults::uiFieldName(resFieldName);
+ tensorResults()->resultFieldName();
legendConfig->setTitle(legendTitle); legendConfig->setTitle(legendTitle);
} }

View File

@@ -59,22 +59,15 @@ namespace caf
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimTensorResults::RimTensorResults() RimTensorResults::RimTensorResults()
{ {
CAF_PDM_InitObject("Tensor Results", ":/CellResult.png", "", ""); CAF_PDM_InitObject("Element Tensor Results", ":/CellResult.png", "", "");
CAF_PDM_InitFieldNoDefault(&legendConfig, "LegendDefinition", "Legend Definition", "", "", ""); CAF_PDM_InitFieldNoDefault(&legendConfig, "LegendDefinition", "Legend Definition", "", "", "");
this->legendConfig = new RimLegendConfig(); this->legendConfig = new RimLegendConfig();
legendConfig.uiCapability()->setUiHidden(true); legendConfig.uiCapability()->setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&m_resultPositionType, "ResultPositionType", "Result Position", "", "", "");
m_resultPositionType.uiCapability()->setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&m_resultFieldName, "ResultVariable", "Result Variable", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_resultFieldName, "ResultVariable", "Result Variable", "", "", "");
m_resultFieldName.uiCapability()->setUiHidden(true); m_resultFieldName.uiCapability()->setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&m_resultPositionTypeUiField, "ResultPositionTypeUi", "Result Position", "", "", "");
m_resultPositionTypeUiField.xmlCapability()->setIOWritable(false);
m_resultPositionTypeUiField.xmlCapability()->setIOReadable(false);
CAF_PDM_InitField(&m_resultFieldNameUiField, "ResultVariableUI", QString(""), "Value", "", "", ""); CAF_PDM_InitField(&m_resultFieldNameUiField, "ResultVariableUI", QString(""), "Value", "", "", "");
m_resultFieldNameUiField.xmlCapability()->setIOWritable(false); m_resultFieldNameUiField.xmlCapability()->setIOWritable(false);
m_resultFieldNameUiField.xmlCapability()->setIOReadable(false); m_resultFieldNameUiField.xmlCapability()->setIOReadable(false);
@@ -93,9 +86,6 @@ RimTensorResults::RimTensorResults()
m_resultFieldNameUiField.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName()); m_resultFieldNameUiField.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName());
m_resultFieldNameUiField.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP); m_resultFieldNameUiField.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP);
m_resultPositionType = RIG_ELEMENT_NODAL;
m_resultPositionTypeUiField = m_resultPositionType;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -111,7 +101,7 @@ RimTensorResults::~RimTensorResults()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RigFemResultAddress RimTensorResults::selectedTensorResult() const RigFemResultAddress RimTensorResults::selectedTensorResult() const
{ {
return RigFemResultAddress(m_resultPositionType(), m_resultFieldName().toStdString(), ""); return RigFemResultAddress(resultPositionType(), m_resultFieldName().toStdString(), "");
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -191,9 +181,9 @@ RimTensorResults::ScaleMethod RimTensorResults::scaleMethod() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RigFemResultPosEnum RimTensorResults::resultPositionType() const RigFemResultPosEnum RimTensorResults::resultPositionType()
{ {
return m_resultPositionType(); return RIG_INTEGRATION_POINT;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -222,21 +212,8 @@ std::vector<std::string> RimTensorResults::getResultMetaDataForUIFieldSetting()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimTensorResults::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) void RimTensorResults::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{ {
if (changedField == &m_resultPositionTypeUiField)
{
if (m_resultPositionTypeUiField() == m_resultPositionType())
{
m_resultFieldNameUiField = uiFieldName(m_resultFieldName());
}
else
{
m_resultFieldNameUiField = "";
}
}
if (changedField == &m_resultFieldNameUiField) if (changedField == &m_resultFieldNameUiField)
{ {
m_resultPositionType = m_resultPositionTypeUiField;
m_resultFieldName = fieldNameFromUi(m_resultFieldNameUiField); m_resultFieldName = fieldNameFromUi(m_resultFieldNameUiField);
} }
if (changedField == &m_showTensors) if (changedField == &m_showTensors)
@@ -265,17 +242,7 @@ QList<caf::PdmOptionItemInfo> RimTensorResults::calculateValueOptions(const caf:
QList<caf::PdmOptionItemInfo> options; QList<caf::PdmOptionItemInfo> options;
*useOptionsOnly = true; *useOptionsOnly = true;
if ( fieldNeedingOptions == &m_resultPositionTypeUiField) if (fieldNeedingOptions == &m_resultFieldNameUiField)
{
using ResultEnum = caf::AppEnum<RigFemResultPosEnum>;
options.push_back(caf::PdmOptionItemInfo(ResultEnum::uiText(RigFemResultPosEnum::RIG_ELEMENT_NODAL),
RigFemResultPosEnum::RIG_ELEMENT_NODAL));
options.push_back(caf::PdmOptionItemInfo(ResultEnum::uiText(RigFemResultPosEnum::RIG_INTEGRATION_POINT),
RigFemResultPosEnum::RIG_INTEGRATION_POINT));
}
else if (fieldNeedingOptions == &m_resultFieldNameUiField)
{ {
std::vector<std::string> fieldCompNames = getResultMetaDataForUIFieldSetting(); std::vector<std::string> fieldCompNames = getResultMetaDataForUIFieldSetting();
@@ -293,7 +260,6 @@ QList<caf::PdmOptionItemInfo> RimTensorResults::calculateValueOptions(const caf:
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimTensorResults::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) void RimTensorResults::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{ {
uiOrdering.add(&m_resultPositionTypeUiField);
uiOrdering.add(&m_resultFieldNameUiField); uiOrdering.add(&m_resultFieldNameUiField);
caf::PdmUiGroup* visibilityGroup = uiOrdering.addNewGroup("Visibility"); caf::PdmUiGroup* visibilityGroup = uiOrdering.addNewGroup("Visibility");
@@ -317,7 +283,6 @@ void RimTensorResults::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimTensorResults::initAfterRead() void RimTensorResults::initAfterRead()
{ {
m_resultPositionTypeUiField = m_resultPositionType;
m_resultFieldNameUiField = uiFieldName(m_resultFieldName()); m_resultFieldNameUiField = uiFieldName(m_resultFieldName());
} }

View File

@@ -69,8 +69,9 @@ public:
TensorColors vectorColors() const; TensorColors vectorColors() const;
ScaleMethod scaleMethod() const; ScaleMethod scaleMethod() const;
RigFemResultPosEnum resultPositionType() const; static RigFemResultPosEnum resultPositionType();
QString resultFieldName() const; QString resultFieldName() const;
static QString uiFieldName(const QString& fieldName);
caf::PdmChildField<RimLegendConfig*> legendConfig; caf::PdmChildField<RimLegendConfig*> legendConfig;
@@ -83,16 +84,13 @@ private:
virtual void initAfterRead() override; virtual void initAfterRead() override;
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override;
static QString uiFieldName(const QString& fieldName);
static QString fieldNameFromUi(const QString& uiFieldName); static QString fieldNameFromUi(const QString& uiFieldName);
private: private:
caf::PdmField<bool> m_showTensors; caf::PdmField<bool> m_showTensors;
caf::PdmField<caf::AppEnum<RigFemResultPosEnum>> m_resultPositionType;
caf::PdmField<QString> m_resultFieldName; caf::PdmField<QString> m_resultFieldName;
caf::PdmField<caf::AppEnum<RigFemResultPosEnum>> m_resultPositionTypeUiField;
caf::PdmField<QString> m_resultFieldNameUiField; caf::PdmField<QString> m_resultFieldNameUiField;
caf::PdmField<bool> m_principal1; caf::PdmField<bool> m_principal1;