Skip to content

Commit

Permalink
#2316 Tensor Vectors: Create Object in Project tree
Browse files Browse the repository at this point in the history
  • Loading branch information
Rebecca Cox committed Feb 5, 2018
1 parent 24cd47a commit c6f8c95
Show file tree
Hide file tree
Showing 5 changed files with 279 additions and 2 deletions.
2 changes: 2 additions & 0 deletions ApplicationCode/ProjectDataModel/CMakeLists_files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ ${CEE_CURRENT_LIST_DIR}RimCalcScript.h
${CEE_CURRENT_LIST_DIR}RimExportInputPropertySettings.h
${CEE_CURRENT_LIST_DIR}RimBinaryExportSettings.h
${CEE_CURRENT_LIST_DIR}Rim3dOverlayInfoConfig.h
${CEE_CURRENT_LIST_DIR}RimTensorResults.h
${CEE_CURRENT_LIST_DIR}RimReservoirCellResultsStorage.h
${CEE_CURRENT_LIST_DIR}RimEclipseStatisticsCaseEvaluator.h
${CEE_CURRENT_LIST_DIR}RimMimeData.h
Expand Down Expand Up @@ -141,6 +142,7 @@ ${CEE_CURRENT_LIST_DIR}RimCalcScript.cpp
${CEE_CURRENT_LIST_DIR}RimExportInputPropertySettings.cpp
${CEE_CURRENT_LIST_DIR}RimBinaryExportSettings.cpp
${CEE_CURRENT_LIST_DIR}Rim3dOverlayInfoConfig.cpp
${CEE_CURRENT_LIST_DIR}RimTensorResults.cpp
${CEE_CURRENT_LIST_DIR}RimReservoirCellResultsStorage.cpp
${CEE_CURRENT_LIST_DIR}RimEclipseStatisticsCaseEvaluator.cpp
${CEE_CURRENT_LIST_DIR}RimMimeData.cpp
Expand Down
10 changes: 9 additions & 1 deletion ApplicationCode/ProjectDataModel/RimGeoMechView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@

#include "Rim3dOverlayInfoConfig.h"
#include "RimCellRangeFilterCollection.h"
#include "RimIntersectionCollection.h"
#include "RimEclipseView.h"
#include "RimGeoMechCase.h"
#include "RimGeoMechCellColors.h"
#include "RimGeoMechPropertyFilterCollection.h"
#include "RimGridCollection.h"
#include "RimIntersectionCollection.h"
#include "RimLegendConfig.h"
#include "RimTensorResults.h"
#include "RimViewLinker.h"

#include "RiuMainWindow.h"
Expand Down Expand Up @@ -81,6 +82,11 @@ RimGeoMechView::RimGeoMechView(void)
cellResult = new RimGeoMechCellColors();
cellResult.uiCapability()->setUiHidden(true);


CAF_PDM_InitFieldNoDefault(&m_tensorResults, "TensorResults", "Tensor Results", "", "", "");
m_tensorResults = new RimTensorResults();
m_tensorResults.uiCapability()->setUiHidden(true);

CAF_PDM_InitFieldNoDefault(&m_propertyFilterCollection, "PropertyFilters", "Property Filters", "", "", "");
m_propertyFilterCollection = new RimGeoMechPropertyFilterCollection();
m_propertyFilterCollection.uiCapability()->setUiHidden(true);
Expand All @@ -96,6 +102,7 @@ RimGeoMechView::~RimGeoMechView(void)
{
m_geomechCase = NULL;

delete m_tensorResults;
delete cellResult;
delete m_propertyFilterCollection;
}
Expand Down Expand Up @@ -624,6 +631,7 @@ void RimGeoMechView::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering
uiTreeOrdering.add(m_gridCollection());

uiTreeOrdering.add(cellResult());
uiTreeOrdering.add(m_tensorResults());

uiTreeOrdering.add(m_crossSectionCollection());

Expand Down
3 changes: 2 additions & 1 deletion ApplicationCode/ProjectDataModel/RimGeoMechView.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class RimGeoMechCase;
class RimGeoMechCellColors;
class RimGeoMechResultDefinition;
class RimGeoMechPropertyFilterCollection;
class RimTensorResults;
class RiuViewer;
class RivGeoMechPartMgr;
class RivGeoMechVizLogic;
Expand Down Expand Up @@ -110,7 +111,7 @@ class RimGeoMechView : public RimGridView
virtual void initAfterRead() override;



caf::PdmChildField<RimTensorResults*> m_tensorResults;
caf::PdmChildField<RimGeoMechPropertyFilterCollection*> m_propertyFilterCollection;
caf::PdmPointer<RimGeoMechPropertyFilterCollection> m_overridePropertyFilterCollection;

Expand Down
194 changes: 194 additions & 0 deletions ApplicationCode/ProjectDataModel/RimTensorResults.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////

#include "RimTensorResults.h"

#include "RimGeoMechResultDefinition.h"

#include "cafPdmUiListEditor.h"


CAF_PDM_SOURCE_INIT(RimTensorResults, "RimTensorResults");

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimTensorResults::RimTensorResults()
{
CAF_PDM_InitObject("Tensor Results", ":/CellResult.png", "", "");

CAF_PDM_InitFieldNoDefault(&m_resultPositionType, "ResultPositionType", "Result Position", "", "", "");
m_resultPositionType.uiCapability()->setUiHidden(true);

CAF_PDM_InitFieldNoDefault(&m_resultFieldName, "ResultVariable", "Result Variable", "", "", "");
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", "", "", "");
m_resultFieldNameUiField.xmlCapability()->setIOWritable(false);
m_resultFieldNameUiField.xmlCapability()->setIOReadable(false);

CAF_PDM_InitField(&m_showTensors, "ShowTensors", true, "", "", "", "");

CAF_PDM_InitField(&m_principal1, "Principal1", true, "Principal 1", "", "", "");
CAF_PDM_InitField(&m_principal2, "Principal2", true, "Principal 2", "", "", "");
CAF_PDM_InitField(&m_principal3, "Principal3", true, "Principal 3", "", "", "");

CAF_PDM_InitField(&m_threshold, "Threshold", 0.0, "Threshold", "", "", "");

CAF_PDM_InitFieldNoDefault(&m_vectorColor, "VectorColor", "Color", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_scaleMethod, "ScaleMethod", "Scale Method", "", "", "");
CAF_PDM_InitField(&m_sizeScale, "SizeScale", 1.0, "Size Scale", "", "", "");

m_resultFieldNameUiField.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName());
m_resultFieldNameUiField.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP);

m_resultPositionTypeUiField = RIG_ELEMENT_NODAL;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimTensorResults::~RimTensorResults()
{

}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::string> RimTensorResults::getResultMetaDataForUIFieldSetting()
{
std::vector<std::string> fieldNames;
fieldNames.push_back("SE");
fieldNames.push_back("ST");
fieldNames.push_back("E");

return fieldNames;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTensorResults::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
if (changedField == &m_resultPositionTypeUiField)
{
std::vector<std::string> fieldCompNames = getResultMetaDataForUIFieldSetting();
if (m_resultPositionTypeUiField() == m_resultPositionType())
{
m_resultFieldNameUiField = m_resultFieldName();
}
else
{
m_resultFieldNameUiField = "";
}
}

if (changedField == &m_resultFieldNameUiField)
{
m_resultPositionType = m_resultPositionTypeUiField;
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimTensorResults::objectToggleField()
{
return &m_showTensors;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimTensorResults::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly)
{
QList<caf::PdmOptionItemInfo> options;
*useOptionsOnly = true;

if ( fieldNeedingOptions == &m_resultPositionTypeUiField)
{
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();

for (int oIdx = 0; oIdx < fieldCompNames.size(); ++oIdx)
{
options.push_back(caf::PdmOptionItemInfo(QString::fromStdString(fieldCompNames[oIdx]), QString::fromStdString(fieldCompNames[oIdx])));
}

}
else if (fieldNeedingOptions == &m_vectorColor)
{
options.push_back(caf::PdmOptionItemInfo("White, Gray, Black", nullptr));
options.push_back(caf::PdmOptionItemInfo("Magenta, Brown, Black", nullptr));
options.push_back(caf::PdmOptionItemInfo("Result Colors", nullptr));
}
else if (fieldNeedingOptions == &m_scaleMethod)
{
options.push_back(caf::PdmOptionItemInfo("Result", nullptr));
options.push_back(caf::PdmOptionItemInfo("Constant", nullptr));
}

return options;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTensorResults::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
uiOrdering.add(&m_resultPositionTypeUiField);
uiOrdering.add(&m_resultFieldNameUiField);

caf::PdmUiGroup* visibilityGroup = uiOrdering.addNewGroup("Visibility");
visibilityGroup->add(&m_principal1);
visibilityGroup->add(&m_principal2);
visibilityGroup->add(&m_principal3);
visibilityGroup->add(&m_threshold);

caf::PdmUiGroup* vectorColorsGroup = uiOrdering.addNewGroup("Vector Colors");
vectorColorsGroup->add(&m_vectorColor);

caf::PdmUiGroup* vectorSizeGroup = uiOrdering.addNewGroup("Vector Size");
vectorSizeGroup->add(&m_scaleMethod);
vectorSizeGroup->add(&m_sizeScale);

uiOrdering.skipRemainingFields(true);
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTensorResults::initAfterRead()
{
m_resultPositionTypeUiField = m_resultPositionType;
m_resultFieldNameUiField = m_resultFieldName();
}
72 changes: 72 additions & 0 deletions ApplicationCode/ProjectDataModel/RimTensorResults.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////

#pragma once

#include "cafPdmField.h"
#include "cafPdmObject.h"

#include "RigFemResultPosEnum.h"

#include <QList>

#include <vector>


//==================================================================================================
///
///
//==================================================================================================
class RimTensorResults : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;

public:
RimTensorResults();
virtual ~RimTensorResults();

private:
std::vector<std::string> getResultMetaDataForUIFieldSetting();
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
virtual caf::PdmFieldHandle* objectToggleField() override;
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override;
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
virtual void initAfterRead() override;

private:

caf::PdmField<bool> m_showTensors;

caf::PdmField<caf::AppEnum<RigFemResultPosEnum>> m_resultPositionType;
caf::PdmField<QString> m_resultFieldName;

caf::PdmField<caf::AppEnum<RigFemResultPosEnum>> m_resultPositionTypeUiField;
caf::PdmField<QString> m_resultFieldNameUiField;

caf::PdmField<bool> m_principal1;
caf::PdmField<bool> m_principal2;
caf::PdmField<bool> m_principal3;

caf::PdmField<double> m_threshold;

caf::PdmField<QString> m_vectorColor;

caf::PdmField<QString> m_scaleMethod;
caf::PdmField<double> m_sizeScale;

};

0 comments on commit c6f8c95

Please sign in to comment.