mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1059 System : Use PdmOptionItemInfo constructor for PdmObjects
This commit is contained in:
parent
ebddaa31e6
commit
a9984c4bd5
@ -79,10 +79,10 @@ QList<caf::PdmOptionItemInfo> RicLinkVisibleViewsFeatureUi::calculateValueOption
|
||||
|
||||
if (fieldNeedingOptions == &m_masterView)
|
||||
{
|
||||
for (size_t i = 0; i < m_allViews.size(); i++)
|
||||
for (RimView* v : m_allViews)
|
||||
{
|
||||
RimCase* rimCase = NULL;
|
||||
m_allViews[i]->firstAncestorOrThisOfType(rimCase);
|
||||
RimCase* rimCase = nullptr;
|
||||
v->firstAncestorOrThisOfType(rimCase);
|
||||
|
||||
QIcon icon;
|
||||
if (rimCase)
|
||||
@ -90,11 +90,7 @@ QList<caf::PdmOptionItemInfo> RicLinkVisibleViewsFeatureUi::calculateValueOption
|
||||
icon = rimCase->uiCapability()->uiIcon();
|
||||
}
|
||||
|
||||
|
||||
optionList.push_back(caf::PdmOptionItemInfo(RimViewLinker::displayNameForView(m_allViews[i]),
|
||||
QVariant::fromValue(caf::PdmPointer<PdmObjectHandle>(m_allViews[i])),
|
||||
false,
|
||||
icon));
|
||||
optionList.push_back(caf::PdmOptionItemInfo(RimViewLinker::displayNameForView(v), v, false, icon));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "RimCase.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimTools.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
|
||||
@ -45,34 +46,18 @@ RicChangeDataSourceFeatureUi::RicChangeDataSourceFeatureUi()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo> RicChangeDataSourceFeatureUi::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> optionList;
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
|
||||
if (fieldNeedingOptions == &caseToApply)
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
|
||||
std::vector<RimCase*> cases;
|
||||
proj->allCases(cases);
|
||||
|
||||
for (RimCase* c : cases)
|
||||
{
|
||||
optionList.push_back(caf::PdmOptionItemInfo(c->caseUserDescription(), c));
|
||||
}
|
||||
RimTools::caseOptionItems(&options);
|
||||
}
|
||||
else if (fieldNeedingOptions == &wellPathToApply)
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
|
||||
if (proj->activeOilField()->wellPathCollection())
|
||||
{
|
||||
for (RimWellPath* wellPath : proj->activeOilField()->wellPathCollection()->wellPaths)
|
||||
{
|
||||
optionList.push_back(caf::PdmOptionItemInfo(wellPath->name(), wellPath));
|
||||
}
|
||||
}
|
||||
RimTools::wellPathOptionItems(&options);
|
||||
}
|
||||
|
||||
return optionList;
|
||||
return options;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -78,14 +78,11 @@ QList<caf::PdmOptionItemInfo> RimCase::calculateValueOptions(const caf::PdmField
|
||||
{
|
||||
for(RimFormationNames* fnames : proj->activeOilField()->formationNamesCollection()->formationNamesList())
|
||||
{
|
||||
optionList.push_back(caf::PdmOptionItemInfo(fnames->fileNameWoPath(),
|
||||
QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(fnames)),
|
||||
false,
|
||||
fnames->uiCapability()->uiIcon()));
|
||||
optionList.push_back(caf::PdmOptionItemInfo(fnames->fileNameWoPath(), fnames, false, fnames->uiCapability()->uiIcon()));
|
||||
}
|
||||
}
|
||||
|
||||
optionList.push_front(caf::PdmOptionItemInfo("None", QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(NULL))));
|
||||
optionList.push_front(caf::PdmOptionItemInfo("None", nullptr));
|
||||
}
|
||||
|
||||
return optionList;
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "RimEclipseWellCollection.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimTools.h"
|
||||
#include "RimView.h"
|
||||
#include "RimWellPath.h"
|
||||
|
||||
@ -235,21 +236,11 @@ QList<caf::PdmOptionItemInfo> RimIntersection::calculateValueOptions(const caf::
|
||||
|
||||
if (fieldNeedingOptions == &wellPath)
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
if (proj->activeOilField()->wellPathCollection())
|
||||
{
|
||||
caf::PdmChildArrayField<RimWellPath*>& wellPaths = proj->activeOilField()->wellPathCollection()->wellPaths;
|
||||
|
||||
QIcon wellIcon(":/Well.png");
|
||||
for (size_t i = 0; i < wellPaths.size(); i++)
|
||||
{
|
||||
options.push_back(caf::PdmOptionItemInfo(wellPaths[i]->name(), QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(wellPaths[i])), false, wellIcon));
|
||||
}
|
||||
}
|
||||
RimTools::wellPathOptionItems(&options);
|
||||
|
||||
if (options.size() == 0)
|
||||
if (options.size() > 0)
|
||||
{
|
||||
options.push_front(caf::PdmOptionItemInfo("None", QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(NULL))));
|
||||
options.push_front(caf::PdmOptionItemInfo("None", nullptr));
|
||||
}
|
||||
}
|
||||
else if (fieldNeedingOptions == &simulationWell)
|
||||
@ -260,15 +251,15 @@ QList<caf::PdmOptionItemInfo> RimIntersection::calculateValueOptions(const caf::
|
||||
caf::PdmChildArrayField<RimEclipseWell*>& eclWells = coll->wells;
|
||||
|
||||
QIcon simWellIcon(":/Well.png");
|
||||
for (size_t i = 0; i < eclWells.size(); i++)
|
||||
for (RimEclipseWell* eclWell : eclWells)
|
||||
{
|
||||
options.push_back(caf::PdmOptionItemInfo(eclWells[i]->name(), QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(eclWells[i])), false, simWellIcon));
|
||||
options.push_back(caf::PdmOptionItemInfo(eclWell->name(), eclWell, false, simWellIcon));
|
||||
}
|
||||
}
|
||||
|
||||
if (options.size() == 0)
|
||||
{
|
||||
options.push_front(caf::PdmOptionItemInfo("None", QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(NULL))));
|
||||
options.push_front(caf::PdmOptionItemInfo("None", nullptr));
|
||||
}
|
||||
}
|
||||
else if (fieldNeedingOptions == &m_branchIndex)
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimReservoirCellResultsStorage.h"
|
||||
#include "RimTools.h"
|
||||
#include "RimView.h"
|
||||
|
||||
#include "cafPdmPointer.h"
|
||||
@ -137,15 +138,7 @@ QList<caf::PdmOptionItemInfo> RimMultiSnapshotDefinition::calculateValueOptions(
|
||||
}
|
||||
else if (fieldNeedingOptions == &additionalCases)
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
std::vector<RimCase*> cases;
|
||||
proj->allCases(cases);
|
||||
|
||||
for (RimCase* rimCase : cases)
|
||||
{
|
||||
options.push_back(caf::PdmOptionItemInfo(rimCase->caseUserDescription(), rimCase));
|
||||
}
|
||||
|
||||
RimTools::caseOptionItems(&options);
|
||||
}
|
||||
|
||||
if (useOptionsOnly) *useOptionsOnly = true;
|
||||
|
@ -21,7 +21,15 @@
|
||||
#include "RimTools.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimWellLogFile.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
|
||||
#include "cafPdmUiItem.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
@ -200,3 +208,45 @@ QString RimTools::relocateFile(const QString& orgFileName, const QString& orgNew
|
||||
|
||||
return fileName;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimTools::wellPathOptionItems(QList<caf::PdmOptionItemInfo>* options)
|
||||
{
|
||||
CVF_ASSERT(options);
|
||||
if (!options) return;
|
||||
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
if (proj && proj->activeOilField() && proj->activeOilField()->wellPathCollection())
|
||||
{
|
||||
caf::PdmChildArrayField<RimWellPath*>& wellPaths = proj->activeOilField()->wellPathCollection()->wellPaths;
|
||||
|
||||
QIcon wellIcon(":/Well.png");
|
||||
for (RimWellPath* wellPath : wellPaths)
|
||||
{
|
||||
options->push_back(caf::PdmOptionItemInfo(wellPath->name(), wellPath, false, wellIcon));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimTools::caseOptionItems(QList<caf::PdmOptionItemInfo>* options)
|
||||
{
|
||||
CVF_ASSERT(options);
|
||||
if (!options) return;
|
||||
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
if (proj)
|
||||
{
|
||||
std::vector<RimCase*> cases;
|
||||
proj->allCases(cases);
|
||||
|
||||
for (RimCase* c : cases)
|
||||
{
|
||||
options->push_back(caf::PdmOptionItemInfo(c->caseUserDescription(), c, false, c->uiIcon()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,14 +20,22 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace caf {
|
||||
class PdmOptionItemInfo;
|
||||
}
|
||||
|
||||
class RimTools
|
||||
{
|
||||
public:
|
||||
static QString getCacheRootDirectoryPathFromProject();
|
||||
|
||||
static QString relocateFile(const QString& fileName, const QString& newProjectPath, const QString& oldProjectPath, bool* foundFile, std::vector<QString>* searchedPaths);
|
||||
|
||||
static void wellPathOptionItems(QList<caf::PdmOptionItemInfo>* options);
|
||||
static void caseOptionItems(QList<caf::PdmOptionItemInfo>* options);
|
||||
};
|
||||
|
@ -109,31 +109,29 @@ QList<caf::PdmOptionItemInfo> RimViewController::calculateValueOptions(const caf
|
||||
views.push_back(this->managedView());
|
||||
}
|
||||
|
||||
RimViewLinker* linkedViews = NULL;
|
||||
this->firstAncestorOrThisOfType(linkedViews);
|
||||
RimViewLinker* viewLinker = nullptr;
|
||||
this->firstAncestorOrThisOfType(viewLinker);
|
||||
CVF_ASSERT(viewLinker);
|
||||
|
||||
for (size_t i = 0; i< views.size(); i++)
|
||||
for (RimView* view : views)
|
||||
{
|
||||
if (views[i] != linkedViews->masterView())
|
||||
if (view != viewLinker->masterView())
|
||||
{
|
||||
RimCase* rimCase = NULL;
|
||||
views[i]->firstAncestorOrThisOfType(rimCase);
|
||||
RimCase* rimCase = nullptr;
|
||||
view->firstAncestorOrThisOfType(rimCase);
|
||||
QIcon icon;
|
||||
if (rimCase)
|
||||
{
|
||||
icon = rimCase->uiCapability()->uiIcon();
|
||||
}
|
||||
|
||||
optionList.push_back(caf::PdmOptionItemInfo(RimViewLinker::displayNameForView(views[i]),
|
||||
QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(views[i])),
|
||||
false,
|
||||
icon));
|
||||
optionList.push_back(caf::PdmOptionItemInfo(RimViewLinker::displayNameForView(view), view, false, icon));
|
||||
}
|
||||
}
|
||||
|
||||
if (optionList.size() > 0)
|
||||
{
|
||||
optionList.push_front(caf::PdmOptionItemInfo("None", QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(NULL))));
|
||||
optionList.push_front(caf::PdmOptionItemInfo("None", nullptr));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimTools.h"
|
||||
#include "RimWellLogCurve.h"
|
||||
#include "RimWellLogPlot.h"
|
||||
#include "RimWellLogPlotCollection.h"
|
||||
@ -49,9 +50,9 @@
|
||||
#include "RiuWellLogTrack.h"
|
||||
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
#include "cafUtils.h"
|
||||
|
||||
#include <cmath>
|
||||
#include "cafUtils.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -323,44 +324,27 @@ void RimWellLogExtractionCurve::onLoadDataAndUpdate()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo> RimWellLogExtractionCurve::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> optionList;
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
|
||||
optionList = RimWellLogCurve::calculateValueOptions(fieldNeedingOptions, useOptionsOnly);
|
||||
if (optionList.size() > 0) return optionList;
|
||||
options = RimWellLogCurve::calculateValueOptions(fieldNeedingOptions, useOptionsOnly);
|
||||
if (options.size() > 0) return options;
|
||||
|
||||
if (fieldNeedingOptions == &m_wellPath)
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
if (proj->activeOilField()->wellPathCollection())
|
||||
RimTools::wellPathOptionItems(&options);
|
||||
|
||||
if (options.size() > 0)
|
||||
{
|
||||
caf::PdmChildArrayField<RimWellPath*>& wellPaths = proj->activeOilField()->wellPathCollection()->wellPaths;
|
||||
|
||||
for (size_t i = 0; i< wellPaths.size(); i++)
|
||||
{
|
||||
optionList.push_back(caf::PdmOptionItemInfo(wellPaths[i]->name(), QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(wellPaths[i]))));
|
||||
}
|
||||
|
||||
if (optionList.size() > 0)
|
||||
{
|
||||
optionList.push_front(caf::PdmOptionItemInfo("None", QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(NULL))));
|
||||
}
|
||||
options.push_front(caf::PdmOptionItemInfo("None", nullptr));
|
||||
}
|
||||
}
|
||||
else if (fieldNeedingOptions == &m_case)
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
std::vector<RimCase*> cases;
|
||||
RimTools::caseOptionItems(&options);
|
||||
|
||||
proj->allCases(cases);
|
||||
|
||||
for (size_t i = 0; i< cases.size(); i++)
|
||||
if (options.size() > 0)
|
||||
{
|
||||
optionList.push_back(caf::PdmOptionItemInfo(cases[i]->caseUserDescription(), QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(cases[i]))));
|
||||
}
|
||||
|
||||
if (optionList.size() > 0)
|
||||
{
|
||||
optionList.push_front(caf::PdmOptionItemInfo("None", QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(NULL))));
|
||||
options.push_front(caf::PdmOptionItemInfo("None", nullptr));
|
||||
}
|
||||
}
|
||||
else if (fieldNeedingOptions == &m_timeStep)
|
||||
@ -374,11 +358,11 @@ QList<caf::PdmOptionItemInfo> RimWellLogExtractionCurve::calculateValueOptions(c
|
||||
|
||||
for (int i = 0; i < timeStepNames.size(); i++)
|
||||
{
|
||||
optionList.push_back(caf::PdmOptionItemInfo(timeStepNames[i], i));
|
||||
options.push_back(caf::PdmOptionItemInfo(timeStepNames[i], i));
|
||||
}
|
||||
}
|
||||
|
||||
return optionList;
|
||||
return options;
|
||||
}
|
||||
|
||||
|
||||
|
@ -210,15 +210,16 @@ QList<caf::PdmOptionItemInfo> RimWellLogFileCurve::calculateValueOptions(const c
|
||||
|
||||
for (size_t i = 0; i < wellPaths.size(); i++)
|
||||
{
|
||||
// Only include well paths coming from a well log file
|
||||
if (wellPaths[i]->m_wellLogFile())
|
||||
{
|
||||
optionList.push_back(caf::PdmOptionItemInfo(wellPaths[i]->name(), QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(wellPaths[i]))));
|
||||
optionList.push_back(caf::PdmOptionItemInfo(wellPaths[i]->name(), wellPaths[i]));
|
||||
}
|
||||
}
|
||||
|
||||
if (optionList.size() > 0)
|
||||
{
|
||||
optionList.push_front(caf::PdmOptionItemInfo("None", QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(NULL))));
|
||||
optionList.push_front(caf::PdmOptionItemInfo("None", nullptr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -306,16 +306,14 @@ QList<caf::PdmOptionItemInfo> RimSummaryCurve::calculateValueOptions(const caf::
|
||||
|
||||
proj->allSummaryCases(cases);
|
||||
|
||||
for (size_t i = 0; i < cases.size(); i++)
|
||||
for (RimSummaryCase* rimCase : cases)
|
||||
{
|
||||
RimSummaryCase* rimCase = cases[i];
|
||||
|
||||
optionList.push_back(caf::PdmOptionItemInfo(rimCase->caseName(), QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(rimCase))));
|
||||
optionList.push_back(caf::PdmOptionItemInfo(rimCase->caseName(), rimCase));
|
||||
}
|
||||
|
||||
if (optionList.size() > 0)
|
||||
{
|
||||
optionList.push_front(caf::PdmOptionItemInfo("None", QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(NULL))));
|
||||
optionList.push_front(caf::PdmOptionItemInfo("None", nullptr));
|
||||
}
|
||||
}
|
||||
else if(fieldNeedingOptions == &m_uiFilterResultSelection)
|
||||
|
@ -164,11 +164,9 @@ QList<caf::PdmOptionItemInfo> RimSummaryCurveFilter::calculateValueOptions(const
|
||||
|
||||
proj->allSummaryCases(cases);
|
||||
|
||||
for (size_t i = 0; i < cases.size(); i++)
|
||||
for (RimSummaryCase* rimCase : cases)
|
||||
{
|
||||
RimSummaryCase* rimCase = cases[i];
|
||||
|
||||
optionList.push_back(caf::PdmOptionItemInfo(rimCase->caseName(), QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(rimCase))));
|
||||
optionList.push_back(caf::PdmOptionItemInfo(rimCase->caseName(), rimCase));
|
||||
}
|
||||
}
|
||||
else if(fieldNeedingOptions == &m_uiFilterResultMultiSelection)
|
||||
|
Loading…
Reference in New Issue
Block a user