#3595 Implement auto naming for contour maps

This commit is contained in:
Gaute Lindkvist 2018-11-09 10:12:33 +01:00
parent 551bf099d3
commit 72d3a6b46f
11 changed files with 238 additions and 9 deletions

View File

@ -120,6 +120,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimWellLogCurveCommonDataSource.h
${CMAKE_CURRENT_LIST_DIR}/RimContourMapProjection.h
${CMAKE_CURRENT_LIST_DIR}/RimContourMapView.h
${CMAKE_CURRENT_LIST_DIR}/RimContourMapViewCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimContourMapNameConfig.h
)
@ -244,6 +245,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimWellLogCurveCommonDataSource.cpp
${CMAKE_CURRENT_LIST_DIR}/RimContourMapProjection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimContourMapView.cpp
${CMAKE_CURRENT_LIST_DIR}/RimContourMapViewCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimContourMapNameConfig.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -0,0 +1,99 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- Equinor 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 "RimContourMapNameConfig.h"
//==================================================================================================
///
///
//==================================================================================================
CAF_PDM_SOURCE_INIT(RimContourMapNameConfig, "RimContourMapNameConfig");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimContourMapNameConfig::RimContourMapNameConfig(const RimNameConfigHolderInterface* configHolder)
: RimNameConfig(configHolder)
{
CAF_PDM_InitObject("Contour Map Name Generator", "", "", "");
CAF_PDM_InitField(&m_addCaseName, "AddCaseName", true, "Add Case Name", "", "", "");
CAF_PDM_InitField(&m_addAggregationType, "AddAggregationType", true, "Add Aggregation Type", "", "", "");
CAF_PDM_InitField(&m_addProperty, "AddProperty", true, "Add Property Type", "", "", "");
CAF_PDM_InitField(&m_addSampleSpacing, "AddSampleSpacing", false, "Add Sample Spacing", "", "", "");
m_customName = "Contour Map";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmUiGroup* RimContourMapNameConfig::createUiGroup(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
caf::PdmUiGroup* nameGroup = RimNameConfig::createUiGroup(uiConfigName, uiOrdering);
nameGroup->add(&m_addCaseName);
nameGroup->add(&m_addAggregationType);
nameGroup->add(&m_addProperty);
nameGroup->add(&m_addSampleSpacing);
return nameGroup;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimContourMapNameConfig::addCaseName() const
{
return m_addCaseName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimContourMapNameConfig::addAggregationType() const
{
return m_addAggregationType();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimContourMapNameConfig::addProperty() const
{
return m_addProperty();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimContourMapNameConfig::addSampleSpacing() const
{
return m_addSampleSpacing();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimContourMapNameConfig::enableAllAutoNameTags(bool enable)
{
m_addCaseName = enable;
m_addAggregationType = enable;
m_addProperty = enable;
m_addSampleSpacing = enable;
}

View File

@ -0,0 +1,49 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- Equinor 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 "RimNameConfig.h"
//==================================================================================================
///
///
//==================================================================================================
class RimContourMapNameConfig : public RimNameConfig
{
CAF_PDM_HEADER_INIT;
public:
RimContourMapNameConfig(const RimNameConfigHolderInterface* configHolder = nullptr);
caf::PdmUiGroup* createUiGroup(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
bool addCaseName() const;
bool addAggregationType() const;
bool addProperty() const;
bool addSampleSpacing() const;
void enableAllAutoNameTags(bool enable) override;
private:
caf::PdmField<bool> m_addCaseName;
caf::PdmField<bool> m_addAggregationType;
caf::PdmField<bool> m_addProperty;
caf::PdmField<bool> m_addSampleSpacing;
};

View File

@ -52,7 +52,7 @@ namespace caf
addItem(RimContourMapProjection::RESULTS_GAS_COLUMN, "GAS_COLUMN", "Gas Column");
addItem(RimContourMapProjection::RESULTS_HC_COLUMN, "HC_COLUMN", "Hydrocarbon Column");
setDefault(RimContourMapProjection::RESULTS_TOP_VALUE);
setDefault(RimContourMapProjection::RESULTS_OIL_COLUMN);
}
}
CAF_PDM_SOURCE_INIT(RimContourMapProjection, "RimContourMapProjection");
@ -347,6 +347,14 @@ double RimContourMapProjection::sampleSpacing() const
return m_relativeSampleSpacing * mainGrid()->characteristicIJCellSize();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimContourMapProjection::sampleSpacingFactor() const
{
return m_relativeSampleSpacing();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -71,6 +71,7 @@ public:
double meanValue() const;
double sumAllValues() const;
double sampleSpacing() const;
double sampleSpacingFactor() const;
bool showContourLines() const;
const std::vector<double>& aggregatedResults() const;

View File

@ -21,9 +21,11 @@
#include "RivContourMapProjectionPartMgr.h"
#include "RiuViewer.h"
#include "RimContourMapProjection.h"
#include "Rim3dOverlayInfoConfig.h"
#include "RimCase.h"
#include "RimCellRangeFilterCollection.h"
#include "RimContourMapNameConfig.h"
#include "RimContourMapProjection.h"
#include "RimEclipseCellColors.h"
#include "RimEclipsePropertyFilterCollection.h"
#include "RimFaultInViewCollection.h"
@ -58,9 +60,13 @@ RimContourMapView::RimContourMapView()
wellCollection()->isActive = false;
faultCollection()->showFaultCollection = false;
CAF_PDM_InitFieldNoDefault(&m_nameConfig, "NameConfig", "", "", "", "");
m_nameConfig = new RimContourMapNameConfig(this);
m_contourMapProjectionPartMgr = new RivContourMapProjectionPartMgr(contourMapProjection(), this);
((RiuViewerToViewInterface*)this)->setCameraPosition(defaultViewMatrix);
}
//--------------------------------------------------------------------------------------------------
@ -71,6 +77,50 @@ RimContourMapProjection* RimContourMapView::contourMapProjection() const
return m_contourMapProjection().p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimContourMapView::createAutoName() const
{
QStringList autoName;
if (!m_nameConfig->customName().isEmpty())
{
autoName.push_back(m_nameConfig->customName());
}
QStringList generatedAutoTags;
RimCase* ownerCase = nullptr;
this->firstAncestorOrThisOfTypeAsserted(ownerCase);
if (m_nameConfig->addCaseName())
{
generatedAutoTags.push_back(ownerCase->caseUserDescription());
}
if (m_nameConfig->addAggregationType())
{
generatedAutoTags.push_back(contourMapProjection()->resultAggregationText());
}
if (m_nameConfig->addProperty() && !contourMapProjection()->isColumnResult())
{
generatedAutoTags.push_back(cellResult()->resultVariable());
}
if (m_nameConfig->addSampleSpacing())
{
generatedAutoTags.push_back(QString("%1").arg(contourMapProjection()->sampleSpacingFactor(), 3, 'f', 2));
}
if (!generatedAutoTags.empty())
{
autoName.push_back(generatedAutoTags.join(", "));
}
return autoName.join(": ");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -106,6 +156,8 @@ void RimContourMapView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderin
viewGroup->add(this->userDescriptionField());
viewGroup->add(this->backgroundColorField());
viewGroup->add(&m_showAxisLines);
m_nameConfig()->createUiGroup(uiConfigName, uiOrdering);
uiOrdering.skipRemainingFields(true);
}
@ -240,3 +292,11 @@ void RimContourMapView::fieldChangedByUi(const caf::PdmFieldHandle* changedField
scheduleCreateDisplayModelAndRedraw();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimContourMapView::userDescriptionField()
{
return m_nameConfig()->nameField();
}

View File

@ -19,16 +19,20 @@
#pragma once
#include "RimEclipseView.h"
#include "RimNameConfig.h"
class RimContourMapNameConfig;
class RivContourMapProjectionPartMgr;
class RimContourMapView : public RimEclipseView
class RimContourMapView : public RimEclipseView, public RimNameConfigHolderInterface
{
CAF_PDM_HEADER_INIT;
public:
RimContourMapView();
RimContourMapProjection* contourMapProjection() const;
QString createAutoName() const override;
protected:
void initAfterRead() override;
void createDisplayModel() override;
@ -41,10 +45,13 @@ protected:
void onLoadDataAndUpdate() override;
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
caf::PdmFieldHandle* userDescriptionField() override;
private:
cvf::ref<RivContourMapProjectionPartMgr> m_contourMapProjectionPartMgr;
caf::PdmChildField<RimContourMapProjection*> m_contourMapProjection;
caf::PdmField<bool> m_showAxisLines;
caf::PdmChildField<RimContourMapNameConfig*> m_nameConfig;
};

View File

@ -30,7 +30,10 @@ class RimNameConfigHolderInterface
{
public:
virtual QString createAutoName() const = 0;
virtual void updateHolder() {}
void updateHolder() { performHolderUpdate(); }
protected:
virtual void performHolderUpdate() {}
};
//==================================================================================================

View File

@ -698,7 +698,7 @@ QString RimWellLogPlot::createAutoName() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::updateHolder()
void RimWellLogPlot::performHolderUpdate()
{
this->m_commonDataSource->updateDefaultOptions();
this->updatePlotTitle();

View File

@ -123,11 +123,11 @@ public:
void uiOrderingForPlotSettings(caf::PdmUiOrdering& uiOrdering);
QString createAutoName() const override;
void updateHolder() override;
void handleKeyPressEvent(QKeyEvent* keyEvent);
RimWellLogCurveCommonDataSource* commonDataSource() const;
protected:
void performHolderUpdate() override;
// Overridden PDM methods
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;