mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Updated to version 0.8.0
This commit is contained in:
55
ApplicationCode/ProjectDataModel/RimBinaryExportSettings.cpp
Normal file
55
ApplicationCode/ProjectDataModel/RimBinaryExportSettings.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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 "RIStdInclude.h"
|
||||
|
||||
#include "RimBinaryExportSettings.h"
|
||||
#include "cafPdmUiFilePathEditor.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimBinaryExportSettings, "RimBinaryExportSettings");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimBinaryExportSettings::RimBinaryExportSettings()
|
||||
{
|
||||
CAF_PDM_InitObject("RimBinaryExportSettings", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&fileName, "Filename", "Export filename", "", "", "");
|
||||
fileName.setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
|
||||
CAF_PDM_InitFieldNoDefault(&eclipseKeyword, "EclipseKeyword", "Eclipse Keyword", "", "", "");
|
||||
CAF_PDM_InitField(&undefinedValue, "UndefinedValue", 0.0, "Undefined value", "", "", "");
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimBinaryExportSettings::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute)
|
||||
{
|
||||
if (field == &fileName)
|
||||
{
|
||||
caf::PdmUiFilePathEditorAttribute* myAttr = static_cast<caf::PdmUiFilePathEditorAttribute*>(attribute);
|
||||
if (myAttr)
|
||||
{
|
||||
myAttr->m_selectSaveFileName = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
42
ApplicationCode/ProjectDataModel/RimBinaryExportSettings.h
Normal file
42
ApplicationCode/ProjectDataModel/RimBinaryExportSettings.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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"
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimBinaryExportSettings : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
public:
|
||||
RimBinaryExportSettings();
|
||||
|
||||
caf::PdmField<QString> fileName;
|
||||
caf::PdmField<QString> eclipseKeyword;
|
||||
caf::PdmField<double> undefinedValue;
|
||||
|
||||
protected:
|
||||
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute);
|
||||
};
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "RimCalcScript.h"
|
||||
#include "cafPdmUiFilePathEditor.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimCalcScript, "CalcScript");
|
||||
|
||||
@@ -33,7 +34,9 @@ RimCalcScript::RimCalcScript()
|
||||
|
||||
CAF_PDM_InitField(&absolutePath, "AbsolutePath", QString(), "Location", "", "" ,"");
|
||||
CAF_PDM_InitField(&content, "Content", QString(), "Directory", "", "" ,"");
|
||||
content.setHidden(true);
|
||||
content.setUiHidden(true);
|
||||
|
||||
absolutePath.setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
#include "RimReservoirView.h"
|
||||
#include "RigReservoirCellResults.h"
|
||||
#include "RigReservoir.h"
|
||||
#include "RifReaderInterface.h"
|
||||
|
||||
#include "cafPdmUiListEditor.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimCellEdgeResultSlot, "CellEdgeResultSlot");
|
||||
@@ -37,9 +38,11 @@ RimCellEdgeResultSlot::RimCellEdgeResultSlot()
|
||||
{
|
||||
CAF_PDM_InitObject("Cell Edge Result", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&resultVariable, "CellEdgeVariable", "Result variable", ":/Default.png", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&resultVariable, "CellEdgeVariable", "Result variable", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&legendConfig, "LegendDefinition", "Legend Definition", ":/Legend.png", "", "");
|
||||
|
||||
resultVariable.setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName());
|
||||
|
||||
legendConfig = new RimLegendConfig();
|
||||
|
||||
m_ignoredResultScalar = cvf::UNDEFINED_DOUBLE;
|
||||
@@ -68,13 +71,16 @@ void RimCellEdgeResultSlot::setReservoirView(RimReservoirView* ownerReservoirVie
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCellEdgeResultSlot::loadResult()
|
||||
{
|
||||
CVF_ASSERT(m_reservoirView && m_reservoirView->gridCellResults());
|
||||
|
||||
resetResultIndices();
|
||||
QStringList vars = findResultVariableNames();
|
||||
updateIgnoredScalarValue();
|
||||
|
||||
int i;
|
||||
for (i = 0; i < vars.size(); ++i)
|
||||
{
|
||||
size_t resultindex = gridCellResults()->loadResultIntoGrid(RimDefines::STATIC_NATIVE, vars[i]);
|
||||
size_t resultindex = m_reservoirView->gridCellResults()->findOrLoadScalarResult(RimDefines::STATIC_NATIVE, vars[i]);
|
||||
int cubeFaceIdx;
|
||||
for (cubeFaceIdx = 0; cubeFaceIdx < 6; ++cubeFaceIdx)
|
||||
{
|
||||
@@ -124,10 +130,13 @@ QList<caf::PdmOptionItemInfo> RimCellEdgeResultSlot::calculateValueOptions(const
|
||||
{
|
||||
if (fieldNeedingOptions == &resultVariable)
|
||||
{
|
||||
if (fileReaderinterface())
|
||||
if (m_reservoirView && m_reservoirView->gridCellResults())
|
||||
{
|
||||
QStringList varList;
|
||||
varList = fileReaderinterface()->staticResults();
|
||||
varList = m_reservoirView->gridCellResults()->resultNames(RimDefines::STATIC_NATIVE);
|
||||
|
||||
//TODO: Must also handle input properties
|
||||
//varList += m_reservoirView->gridCellResults()->resultNames(RimDefines::INPUT_PROPERTY);
|
||||
|
||||
QList<caf::PdmOptionItemInfo> optionList;
|
||||
|
||||
@@ -196,10 +205,12 @@ QStringList RimCellEdgeResultSlot::findResultVariableNames()
|
||||
{
|
||||
QStringList varNames;
|
||||
|
||||
if (fileReaderinterface() && !resultVariable().isEmpty())
|
||||
if (m_reservoirView && m_reservoirView->gridCellResults() && !resultVariable().isEmpty())
|
||||
{
|
||||
QStringList varList;
|
||||
varList = fileReaderinterface()->staticResults();
|
||||
varList = m_reservoirView->gridCellResults()->resultNames(RimDefines::STATIC_NATIVE);
|
||||
//TODO: Must handle Input properties
|
||||
|
||||
int i;
|
||||
for (i = 0; i < varList.size(); ++i)
|
||||
{
|
||||
@@ -212,33 +223,7 @@ QStringList RimCellEdgeResultSlot::findResultVariableNames()
|
||||
return varNames;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigReservoirCellResults* RimCellEdgeResultSlot::gridCellResults()
|
||||
{
|
||||
CVF_ASSERT(m_reservoirView != NULL
|
||||
&& m_reservoirView->eclipseCase()
|
||||
&& m_reservoirView->eclipseCase()->reservoirData()
|
||||
&& m_reservoirView->eclipseCase()->reservoirData()->mainGrid());
|
||||
|
||||
return m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->results();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifReaderInterface* RimCellEdgeResultSlot::fileReaderinterface()
|
||||
{
|
||||
if (m_reservoirView && m_reservoirView->eclipseCase())
|
||||
{
|
||||
return m_reservoirView->eclipseCase()->fileInterface();
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
|
||||
@@ -75,9 +75,6 @@ protected:
|
||||
QStringList findResultVariableNames();
|
||||
|
||||
private:
|
||||
RigReservoirCellResults* gridCellResults();
|
||||
RifReaderInterface* fileReaderinterface();
|
||||
|
||||
void resetResultIndices();
|
||||
void updateIgnoredScalarValue();
|
||||
protected:
|
||||
|
||||
@@ -53,7 +53,16 @@ RimCellPropertyFilter::RimCellPropertyFilter()
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&resultDefinition, "ResultDefinition", "Result definition", "", "", "");
|
||||
resultDefinition = new RimResultDefinition();
|
||||
resultDefinition.setHidden(true);
|
||||
|
||||
// Take ownership of the fields in RimResultDefinition to be able to trap fieldChangedByUi in this class
|
||||
resultDefinition->resultType.setOwnerObject(this);
|
||||
resultDefinition->resultVariable.setOwnerObject(this);
|
||||
resultDefinition->resultType.setUiName("");
|
||||
resultDefinition->resultVariable.setUiName("");
|
||||
|
||||
// Set to hidden to avoid this item to been displayed as a child item
|
||||
// Fields in this object are displayed using defineUiOrdering()
|
||||
resultDefinition.setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitField(&lowerBound, "LowerBound", 0.0, "Min", "", "", "");
|
||||
CAF_PDM_InitField(&upperBound, "UpperBound", 0.0, "Max", "", "", "");
|
||||
@@ -76,8 +85,10 @@ void RimCellPropertyFilter::fieldChangedByUi(const caf::PdmFieldHandle* changedF
|
||||
if (changedField == &name)
|
||||
{
|
||||
}
|
||||
else if (&resultDefinition == changedField)
|
||||
else if (&(resultDefinition->resultType) == changedField || &(resultDefinition->resultVariable) == changedField)
|
||||
{
|
||||
resultDefinition->fieldChangedByUi(changedField, oldValue, newValue);
|
||||
|
||||
setDefaultValues();
|
||||
m_parentContainer->fieldChangedByUi(changedField, oldValue, newValue);
|
||||
}
|
||||
@@ -86,71 +97,6 @@ void RimCellPropertyFilter::fieldChangedByUi(const caf::PdmFieldHandle* changedF
|
||||
m_parentContainer->fieldChangedByUi(changedField, oldValue, newValue);
|
||||
this->updateIconState();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimCellPropertyFilter::isCellRejected(const RigGridBase* grid, size_t timeStepIndex, size_t cellIndex) const
|
||||
{
|
||||
CVF_ASSERT(grid);
|
||||
|
||||
if (resultDefinition->gridScalarIndex() == cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t resultIndex = 0;
|
||||
if (resultDefinition->hasDynamicResult())
|
||||
{
|
||||
resultIndex = timeStepIndex;
|
||||
}
|
||||
|
||||
double scalarValue = grid->cellScalar(resultIndex, resultDefinition->gridScalarIndex(), cellIndex);
|
||||
bool rejected = false;
|
||||
if (scalarValue < lowerBound || scalarValue > upperBound)
|
||||
{
|
||||
rejected = true;
|
||||
}
|
||||
|
||||
if (filterMode == INCLUDE)
|
||||
{
|
||||
return rejected;
|
||||
}
|
||||
else
|
||||
{
|
||||
return !rejected;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::CellRangeFilter::CellStateType RimCellPropertyFilter::cellFilterState(const RigGridBase* grid, size_t timeStepIndex, size_t cellIndex) const
|
||||
{
|
||||
CVF_TIGHT_ASSERT(grid);
|
||||
CVF_TIGHT_ASSERT(resultDefinition->gridScalarIndex() != cvf::UNDEFINED_SIZE_T);
|
||||
|
||||
size_t tStepIdx = 0;
|
||||
if (resultDefinition->hasDynamicResult())
|
||||
{
|
||||
tStepIdx = timeStepIndex;
|
||||
}
|
||||
|
||||
double scalarValue = grid->cellScalar(tStepIdx, resultDefinition->gridScalarIndex(), cellIndex);
|
||||
|
||||
if ( lowerBound <= scalarValue && scalarValue <= upperBound)
|
||||
{
|
||||
if (filterMode == INCLUDE) return cvf::CellRangeFilter::INCLUDED;
|
||||
else return cvf::CellRangeFilter::EXCLUDED;
|
||||
}
|
||||
else
|
||||
{
|
||||
return cvf::CellRangeFilter::NOT_INCLUDED;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -204,3 +150,26 @@ void RimCellPropertyFilter::setDefaultValues()
|
||||
upperBound.setUiName(QString("Max (%1)").arg(max));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCellPropertyFilter::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const
|
||||
{
|
||||
// Fields declared in RimCellFilter
|
||||
uiOrdering.add(&name);
|
||||
|
||||
// Fields declared in RimResultDefinition
|
||||
caf::PdmUiGroup* group1 = uiOrdering.addNewGroup("Result");
|
||||
group1->add(&(resultDefinition->resultType));
|
||||
group1->add(&(resultDefinition->resultVariable));
|
||||
|
||||
// Fields declared in RimCellFilter
|
||||
uiOrdering.add(&active);
|
||||
uiOrdering.add(&filterMode);
|
||||
|
||||
// Fields declared in this class (RimCellPropertyFilter)
|
||||
uiOrdering.add(&lowerBound);
|
||||
uiOrdering.add(&upperBound);
|
||||
uiOrdering.add(&filterMode);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ class RimResultDefinition;
|
||||
|
||||
class RigGridBase;
|
||||
class RigReservoirCellResults;
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
//enum CellRangeFilter::CellStateType;
|
||||
@@ -66,13 +67,13 @@ public:
|
||||
caf::PdmField<double> upperBound;
|
||||
caf::PdmField< caf::AppEnum< EvaluationRegionType > > evaluationRegion;
|
||||
|
||||
bool isCellRejected(const RigGridBase* grid, size_t timeStepIndex, size_t cellIndex) const;
|
||||
cvf::CellRangeFilter::CellStateType cellFilterState(const RigGridBase* grid, size_t timeStepIndex, size_t cellIndex) const;
|
||||
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
|
||||
|
||||
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly );
|
||||
|
||||
protected:
|
||||
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const;
|
||||
|
||||
private:
|
||||
RimCellPropertyFilterCollection* m_parentContainer;
|
||||
};
|
||||
|
||||
@@ -102,64 +102,6 @@ RimCellPropertyFilter* RimCellPropertyFilterCollection::createAndAppendPropertyF
|
||||
return propertyFilter;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimCellPropertyFilterCollection::isCellRejected(const RigGridBase* grid, size_t timeStepIndex, size_t cellIndex) const
|
||||
{
|
||||
std::list< caf::PdmPointer< RimCellPropertyFilter > >::const_iterator it;
|
||||
if (propertyFilters.v().empty()) return false;
|
||||
|
||||
bool rejectCell = true;
|
||||
for (it = propertyFilters.v().begin(); it != propertyFilters.v().end(); ++it)
|
||||
{
|
||||
if (!(*it)->isCellRejected(grid, timeStepIndex, cellIndex))
|
||||
{
|
||||
rejectCell = false;
|
||||
}
|
||||
}
|
||||
|
||||
return rejectCell;
|
||||
}
|
||||
|
||||
cvf::CellRangeFilter::CellStateType RimCellPropertyFilterCollection::cellFilterState(const RigGridBase* grid, cvf::CellRangeFilter::CellStateType rangeCellState, size_t timeStepIndex, size_t cellIndex) const
|
||||
{
|
||||
bool included = false;
|
||||
|
||||
std::list< caf::PdmPointer< RimCellPropertyFilter > >::const_iterator it;
|
||||
for (it = propertyFilters.v().begin(); it != propertyFilters.v().end(); ++it)
|
||||
{
|
||||
RimCellPropertyFilter* propertyFilter = *it;
|
||||
CVF_ASSERT(propertyFilter);
|
||||
|
||||
if (propertyFilter->active() && propertyFilter->resultDefinition->hasResult())
|
||||
{
|
||||
// No property filter evaluation outside evaluation region
|
||||
if (propertyFilter->evaluationRegion == RimCellPropertyFilter::RANGE_FILTER_REGION && rangeCellState != cvf::CellRangeFilter::INCLUDED)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bool rejected = propertyFilter->isCellRejected(grid, timeStepIndex, cellIndex);
|
||||
|
||||
if (propertyFilter->filterMode == RimCellFilter::EXCLUDE)
|
||||
{
|
||||
if (rejected)
|
||||
{
|
||||
// Reject from exclude filters will always win
|
||||
return cvf::CellRangeFilter::EXCLUDED;
|
||||
}
|
||||
}
|
||||
|
||||
if (!rejected)
|
||||
{
|
||||
included = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return included ? cvf::CellRangeFilter::INCLUDED : cvf::CellRangeFilter::EXCLUDED;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
|
||||
@@ -39,9 +39,6 @@ public:
|
||||
RimCellPropertyFilter* createAndAppendPropertyFilter();
|
||||
void remove(RimCellPropertyFilter* propertyFilter);
|
||||
|
||||
bool isCellRejected(const RigGridBase* grid, size_t timeStepIndex, size_t cellIndex) const;
|
||||
cvf::CellRangeFilter::CellStateType cellFilterState(const RigGridBase* grid, cvf::CellRangeFilter::CellStateType rangeCellState, size_t timeStepIndex, size_t cellIndex) const;
|
||||
|
||||
bool hasActiveFilters() const;
|
||||
bool hasActiveDynamicFilters() const;
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
#include "RimDefines.h"
|
||||
#include "cafAppEnum.h"
|
||||
#include "RifReaderInterface.h"
|
||||
|
||||
|
||||
namespace caf
|
||||
@@ -30,7 +29,8 @@ namespace caf
|
||||
{
|
||||
addItem(RimDefines::DYNAMIC_NATIVE, "DYNAMIC_NATIVE", "Dynamic");
|
||||
addItem(RimDefines::STATIC_NATIVE, "STATIC_NATIVE", "Static");
|
||||
addItem(RimDefines::GENERATED, "Generated", "Generated");
|
||||
addItem(RimDefines::GENERATED, "GENERATED", "Generated");
|
||||
addItem(RimDefines::INPUT_PROPERTY, "INPUT_PROPERTY", "Input Property");
|
||||
|
||||
setDefault(RimDefines::DYNAMIC_NATIVE);
|
||||
}
|
||||
|
||||
@@ -18,11 +18,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmUiItem.h"
|
||||
#include <QList>
|
||||
|
||||
class RifReaderInterface;
|
||||
|
||||
#include <QString>
|
||||
|
||||
class RimDefines
|
||||
{
|
||||
@@ -32,8 +28,11 @@ public:
|
||||
{
|
||||
DYNAMIC_NATIVE,
|
||||
STATIC_NATIVE,
|
||||
GENERATED
|
||||
GENERATED,
|
||||
INPUT_PROPERTY,
|
||||
REMOVED
|
||||
};
|
||||
|
||||
|
||||
static QString nonSelectedResultName() { return "None"; }
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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 "RIStdInclude.h"
|
||||
|
||||
#include "RimExportInputPropertySettings.h"
|
||||
#include "cafPdmUiFilePathEditor.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimExportInputSettings, "RimExportInputSettings");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimExportInputSettings::RimExportInputSettings()
|
||||
{
|
||||
CAF_PDM_InitObject("RimExportInputSettings", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&fileName, "Filename", "Export filename", "", "", "");
|
||||
fileName.setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
|
||||
CAF_PDM_InitFieldNoDefault(&eclipseKeyword, "Eclipse Keyword", "Keyword", "", "", "");
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimExportInputSettings::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute)
|
||||
{
|
||||
if (field == &fileName)
|
||||
{
|
||||
caf::PdmUiFilePathEditorAttribute* myAttr = static_cast<caf::PdmUiFilePathEditorAttribute*>(attribute);
|
||||
if (myAttr)
|
||||
{
|
||||
myAttr->m_selectSaveFileName = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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"
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimExportInputSettings : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
public:
|
||||
RimExportInputSettings();
|
||||
|
||||
caf::PdmField<QString> fileName;
|
||||
caf::PdmField<QString> eclipseKeyword;
|
||||
|
||||
protected:
|
||||
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute);
|
||||
};
|
||||
|
||||
72
ApplicationCode/ProjectDataModel/RimInputProperty.cpp
Normal file
72
ApplicationCode/ProjectDataModel/RimInputProperty.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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 "RIStdInclude.h"
|
||||
|
||||
#include "RimInputProperty.h"
|
||||
|
||||
#include "cvfAssert.h"
|
||||
|
||||
#include "cafPdmUiLineEditor.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace caf {
|
||||
template<>
|
||||
void RimInputProperty::ResolveStateEnum::setUp()
|
||||
{
|
||||
addItem(RimInputProperty::UNKNOWN, "UNKNOWN", "Unknown");
|
||||
addItem(RimInputProperty::FILE_MISSING, "FILE_MISSING", "No data loaded, can't find the file");
|
||||
addItem(RimInputProperty::KEYWORD_NOT_IN_FILE, "KEYWORD_NOT_IN_FILE", "No data loaded, can't find the keyword");
|
||||
addItem(RimInputProperty::RESOLVED_NOT_SAVED, "RESOLVED_NOT_SAVED", "Ok, but not saved");
|
||||
addItem(RimInputProperty::RESOLVED, "RESOLVED", "Loaded, Ok");
|
||||
setDefault(RimInputProperty::UNKNOWN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimInputProperty, "RimInputProperty");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimInputProperty::RimInputProperty()
|
||||
{
|
||||
CAF_PDM_InitObject("Input Property", ":/EclipseInput48x48.png", "", "");
|
||||
|
||||
CAF_PDM_InitField(&resultName, "ResultName", QString(), "Result name", "", "" ,"");
|
||||
CAF_PDM_InitField(&eclipseKeyword, "EclipseKeyword", QString(), "Eclipse Keyword", "", "" ,"");
|
||||
CAF_PDM_InitField(&fileName, "FileName", QString(), "Filename", "", "" ,"");
|
||||
CAF_PDM_InitField(&resolvedState, "ResolvedState", (ResolveStateEnum)UNKNOWN, "Data state", "", "", "");
|
||||
|
||||
resolvedState.setUiReadOnly(true);
|
||||
resolvedState.setIOReadable(false);
|
||||
resolvedState.setIOWritable(false);
|
||||
resolvedState.setUiEditorTypeName(caf::PdmUiLineEditor::uiEditorTypeName());
|
||||
|
||||
fileName.setUiReadOnly(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimInputProperty::~RimInputProperty()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
64
ApplicationCode/ProjectDataModel/RimInputProperty.h
Normal file
64
ApplicationCode/ProjectDataModel/RimInputProperty.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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 "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafAppEnum.h"
|
||||
|
||||
class QString;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RimInputProperty : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimInputProperty();
|
||||
virtual ~RimInputProperty();
|
||||
|
||||
enum ResolveState
|
||||
{
|
||||
UNKNOWN,
|
||||
FILE_MISSING,
|
||||
KEYWORD_NOT_IN_FILE,
|
||||
RESOLVED_NOT_SAVED,
|
||||
RESOLVED
|
||||
};
|
||||
typedef caf::AppEnum<ResolveState> ResolveStateEnum;
|
||||
|
||||
// Fields:
|
||||
caf::PdmField<QString> resultName;
|
||||
caf::PdmField<QString> eclipseKeyword;
|
||||
caf::PdmField<QString> fileName; // ReadOnly Serves as key to syncronize read eclipse prop data and this inputProp object.
|
||||
caf::PdmField<ResolveStateEnum> resolvedState; // ReadOnly and not writable
|
||||
|
||||
// PdmObject Overrides
|
||||
virtual caf::PdmFieldHandle* userDescriptionField() { return &resultName;}
|
||||
|
||||
private:
|
||||
// Possibly the resultIndex, but it should be superfluous
|
||||
|
||||
};
|
||||
@@ -0,0 +1,97 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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 "RIStdInclude.h"
|
||||
|
||||
#include "RimInputPropertyCollection.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimInputPropertyCollection, "RimInputPropertyCollection");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimInputPropertyCollection::RimInputPropertyCollection()
|
||||
{
|
||||
CAF_PDM_InitObject("Input Properties", ":/EclipseInput48x48.png", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&inputProperties, "InputProperties", "", "", "", "");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimInputPropertyCollection::~RimInputPropertyCollection()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Returns the InputProperties pointing to the same file as \a fileName
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimInputProperty*> RimInputPropertyCollection::findInputProperties(QString fileName)
|
||||
{
|
||||
QFileInfo fileInfo(fileName);
|
||||
std::vector<RimInputProperty*> result;
|
||||
for (size_t i = 0; i < this->inputProperties.size(); ++i)
|
||||
{
|
||||
if (!inputProperties[i]) continue;
|
||||
|
||||
QFileInfo propFile(inputProperties[i]->fileName());
|
||||
if (fileInfo == propFile) result.push_back(inputProperties[i]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Remove given input property from collection and checks if the associated file is referenced by other input
|
||||
/// properties
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimInputPropertyCollection::removeInputProperty(RimInputProperty* inputProperty, bool& isPropertyFileReferencedByOthers)
|
||||
{
|
||||
CVF_ASSERT(inputProperty);
|
||||
|
||||
this->inputProperties.removeChildObject(inputProperty);
|
||||
|
||||
isPropertyFileReferencedByOthers = false;
|
||||
for (size_t i = 0; i < this->inputProperties.size(); i++)
|
||||
{
|
||||
if (inputProperties[i]->fileName() == inputProperty->fileName)
|
||||
{
|
||||
isPropertyFileReferencedByOthers = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Returns the InputProperty with resultName \a resultName
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimInputProperty * RimInputPropertyCollection::findInputProperty(QString resultName)
|
||||
{
|
||||
for (size_t i = 0; i < this->inputProperties.size(); i++)
|
||||
{
|
||||
if (inputProperties[i] && inputProperties[i]->resultName() == resultName)
|
||||
{
|
||||
return inputProperties[i];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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 "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include "RimInputProperty.h"
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RimInputPropertyCollection : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimInputPropertyCollection();
|
||||
virtual ~RimInputPropertyCollection();
|
||||
std::vector<RimInputProperty*> findInputProperties(QString fileName);
|
||||
RimInputProperty* findInputProperty(QString resultName);
|
||||
|
||||
void removeInputProperty(RimInputProperty* inputProperty, bool& isPropertyFileReferencedByOthers);
|
||||
|
||||
|
||||
// Fields:
|
||||
caf::PdmPointersField<RimInputProperty*> inputProperties;
|
||||
|
||||
};
|
||||
398
ApplicationCode/ProjectDataModel/RimInputReservoir.cpp
Normal file
398
ApplicationCode/ProjectDataModel/RimInputReservoir.cpp
Normal file
@@ -0,0 +1,398 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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 "RIStdInclude.h"
|
||||
|
||||
#include "RimInputReservoir.h"
|
||||
#include "RimInputProperty.h"
|
||||
#include "RimReservoirView.h"
|
||||
|
||||
#include "RifReaderEclipseInput.h"
|
||||
|
||||
#include "RigReservoir.h"
|
||||
#include "RigReservoirCellResults.h"
|
||||
|
||||
#include "cvfAssert.h"
|
||||
|
||||
#include <QString>
|
||||
#include "RifReaderMockModel.h"
|
||||
#include "RifEclipseInputFileTools.h"
|
||||
#include "cafProgressInfo.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimInputReservoir, "RimInputReservoir");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimInputReservoir::RimInputReservoir()
|
||||
: RimReservoir()
|
||||
{
|
||||
CAF_PDM_InitObject("RimInputReservoir", ":/EclipseInput48x48.png", "", "");
|
||||
CAF_PDM_InitField(&m_gridFileName, "GridFileName", QString(), "Case grid filename", "", "" ,"");
|
||||
CAF_PDM_InitFieldNoDefault(&m_additionalFileNames, "AdditionalFileNames", "Additional files", "", "" ,"");
|
||||
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_inputPropertyCollection, "InputPropertyCollection", "", "", "", "");
|
||||
m_inputPropertyCollection = new RimInputPropertyCollection;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimInputReservoir::~RimInputReservoir()
|
||||
{
|
||||
delete m_inputPropertyCollection;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Open the supplied file set. If no grid data has been read, it will first find the possible
|
||||
/// grid data among the files then read all supported properties from the files matching the grid
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimInputReservoir::openDataFileSet(const QStringList& filenames)
|
||||
{
|
||||
if (caseName().contains("Input Mock Debug Model"))
|
||||
{
|
||||
cvf::ref<RifReaderInterface> readerInterface = this->createMockModel(this->caseName());
|
||||
m_rigReservoir->mainGrid()->results()->setReaderInterface(readerInterface.p());
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_rigReservoir.isNull())
|
||||
{
|
||||
RigReservoir* reservoir = new RigReservoir;
|
||||
m_rigReservoir = reservoir;
|
||||
}
|
||||
|
||||
// First find and read the grid data
|
||||
if (this->reservoirData()->mainGrid()->gridPointDimensions() == cvf::Vec3st(0,0,0))
|
||||
{
|
||||
for (int i = 0; i < filenames.size(); i++)
|
||||
{
|
||||
if (RifEclipseInputFileTools::openGridFile(filenames[i], this->reservoirData()))
|
||||
{
|
||||
m_gridFileName = filenames[i];
|
||||
|
||||
m_rigReservoir->computeFaults();
|
||||
m_rigReservoir->mainGrid()->computeCachedData();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this->reservoirData()->mainGrid()->gridPointDimensions() == cvf::Vec3st(0,0,0))
|
||||
{
|
||||
return ; // No grid present
|
||||
}
|
||||
|
||||
// Then read the properties possibly in the grid file
|
||||
QStringList filesToRead;
|
||||
for (int i = 0; i < filenames.size(); i++)
|
||||
{
|
||||
size_t j;
|
||||
bool exist = false;
|
||||
for (j = 0; j < m_additionalFileNames().size(); j++)
|
||||
{
|
||||
if (m_additionalFileNames()[j] == filenames[i])
|
||||
{
|
||||
exist = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!exist)
|
||||
{
|
||||
filesToRead.push_back(filenames[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < filesToRead.size(); i++)
|
||||
{
|
||||
QString propertyFileName = filesToRead[i];
|
||||
std::map<QString, QString> readProperties = RifEclipseInputFileTools::readProperties(propertyFileName, this->reservoirData());
|
||||
|
||||
std::map<QString, QString>::iterator it;
|
||||
for (it = readProperties.begin(); it != readProperties.end(); ++it)
|
||||
{
|
||||
RimInputProperty* inputProperty = new RimInputProperty;
|
||||
inputProperty->resultName = it->first;
|
||||
inputProperty->eclipseKeyword = it->second;
|
||||
inputProperty->fileName = propertyFileName;
|
||||
inputProperty->resolvedState = RimInputProperty::RESOLVED;
|
||||
m_inputPropertyCollection->inputProperties.push_back(inputProperty);
|
||||
}
|
||||
|
||||
if (propertyFileName != m_gridFileName)
|
||||
{
|
||||
m_additionalFileNames.v().push_back(propertyFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimInputReservoir::openEclipseGridFile()
|
||||
{
|
||||
// Early exit if reservoir data is created
|
||||
if (m_rigReservoir.notNull()) return true;
|
||||
|
||||
cvf::ref<RifReaderInterface> readerInterface;
|
||||
|
||||
if (caseName().contains("Input Mock Debug Model"))
|
||||
{
|
||||
readerInterface = this->createMockModel(this->caseName());
|
||||
}
|
||||
else
|
||||
{
|
||||
RigReservoir* reservoir = new RigReservoir;
|
||||
readerInterface = new RifReaderEclipseInput;
|
||||
if (!readerInterface->open(m_gridFileName, reservoir))
|
||||
{
|
||||
delete reservoir;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_rigReservoir = reservoir;
|
||||
loadAndSyncronizeInputProperties();
|
||||
}
|
||||
|
||||
CVF_ASSERT(m_rigReservoir.notNull());
|
||||
CVF_ASSERT(readerInterface.notNull());
|
||||
|
||||
m_rigReservoir->mainGrid()->results()->setReaderInterface(readerInterface.p());
|
||||
m_rigReservoir->computeFaults();
|
||||
m_rigReservoir->mainGrid()->computeCachedData();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#define for_all(stdVector, indexName) for (size_t indexName = 0; indexName < stdVector.size(); ++indexName)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Loads input property data from the gridFile and additional files
|
||||
/// Creates new InputProperties if necessary, and flags the unused ones as obsolete
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimInputReservoir::loadAndSyncronizeInputProperties()
|
||||
{
|
||||
// Make sure we actually have reservoir data
|
||||
|
||||
CVF_ASSERT(m_rigReservoir.notNull());
|
||||
CVF_ASSERT(this->reservoirData()->mainGrid()->gridPointDimensions() != cvf::Vec3st(0,0,0));
|
||||
|
||||
// Then read the properties from all the files referenced by the InputReservoir
|
||||
|
||||
std::vector<QString> filenames = m_additionalFileNames;
|
||||
filenames.push_back(m_gridFileName);
|
||||
|
||||
const std::vector<QString>& knownKeywords = RifEclipseInputFileTools::knownPropertyKeywords();
|
||||
|
||||
size_t inputPropCount = this->m_inputPropertyCollection()->inputProperties.size();
|
||||
|
||||
caf::ProgressInfo progInfo(filenames.size() *( inputPropCount + knownKeywords.size()), "Reading Input properties" );
|
||||
int progress = 0;
|
||||
|
||||
for_all(filenames, i)
|
||||
{
|
||||
progress = i*( inputPropCount + knownKeywords.size());
|
||||
// Find all the keywords present on the file
|
||||
|
||||
progInfo.setProgressDescription(filenames[i]);
|
||||
|
||||
QFileInfo fileNameInfo(filenames[i]);
|
||||
bool isExistingFile = fileNameInfo.exists();
|
||||
|
||||
std::set<QString> fileKeywordSet;
|
||||
|
||||
if (isExistingFile)
|
||||
{
|
||||
std::vector<QString> fileKeywords = RifEclipseInputFileTools::findKeywordsOnFile(filenames[i]);
|
||||
for_all(fileKeywords, fkIt) fileKeywordSet.insert(fileKeywords[fkIt]);
|
||||
}
|
||||
|
||||
// Find the input property objects referring to the file
|
||||
|
||||
std::vector<RimInputProperty*> ipsUsingThisFile = this->m_inputPropertyCollection()->findInputProperties(filenames[i]);
|
||||
|
||||
// Read property data for each inputProperty
|
||||
|
||||
for_all(ipsUsingThisFile, ipIdx)
|
||||
{
|
||||
if (!isExistingFile)
|
||||
{
|
||||
ipsUsingThisFile[ipIdx]->resolvedState = RimInputProperty::FILE_MISSING;
|
||||
}
|
||||
else
|
||||
{
|
||||
QString kw = ipsUsingThisFile[ipIdx]->eclipseKeyword();
|
||||
ipsUsingThisFile[ipIdx]->resolvedState = RimInputProperty::KEYWORD_NOT_IN_FILE;
|
||||
if (fileKeywordSet.count(kw))
|
||||
{
|
||||
if (RifEclipseInputFileTools::readProperty(filenames[i], this->reservoirData(), kw, ipsUsingThisFile[ipIdx]->resultName ))
|
||||
{
|
||||
ipsUsingThisFile[ipIdx]->resolvedState = RimInputProperty::RESOLVED;
|
||||
}
|
||||
}
|
||||
fileKeywordSet.erase(kw);
|
||||
}
|
||||
|
||||
progInfo.setProgress(progress + ipIdx );
|
||||
}
|
||||
|
||||
progInfo.setProgress(progress + inputPropCount);
|
||||
// Check if there are more known property keywords left on file. If it is, read them and create inputProperty objects
|
||||
|
||||
if (!fileKeywordSet.empty())
|
||||
{
|
||||
|
||||
|
||||
std::vector<QString> knownKwsLeft;
|
||||
for_all(knownKeywords, fkIt)
|
||||
{
|
||||
if (fileKeywordSet.count(knownKeywords[fkIt]))
|
||||
{
|
||||
QString resultName = this->reservoirData()->mainGrid()->results()->makeResultNameUnique(knownKeywords[fkIt]);
|
||||
if (RifEclipseInputFileTools::readProperty(filenames[i], this->reservoirData(), knownKeywords[fkIt], resultName))
|
||||
{
|
||||
RimInputProperty* inputProperty = new RimInputProperty;
|
||||
inputProperty->resultName = resultName;
|
||||
inputProperty->eclipseKeyword = knownKeywords[fkIt];
|
||||
inputProperty->fileName = filenames[i];
|
||||
inputProperty->resolvedState = RimInputProperty::RESOLVED;
|
||||
m_inputPropertyCollection->inputProperties.push_back(inputProperty);
|
||||
}
|
||||
}
|
||||
progInfo.setProgress(progress + inputPropCount + fkIt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for_all(m_inputPropertyCollection->inputProperties, i)
|
||||
{
|
||||
if (m_inputPropertyCollection->inputProperties[i]->resolvedState() == RimInputProperty::UNKNOWN)
|
||||
{
|
||||
m_inputPropertyCollection->inputProperties[i]->resolvedState = RimInputProperty::FILE_MISSING;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimInputReservoir::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimInputReservoir::addFiles(const QStringList& newFileNames)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimInputReservoir::removeFiles(const QStringList& obsoleteFileNames)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimInputReservoir::removeProperty(RimInputProperty* inputProperty)
|
||||
{
|
||||
bool isPropertyFileReferencedByOthers = false;
|
||||
|
||||
m_inputPropertyCollection->removeInputProperty(inputProperty, isPropertyFileReferencedByOthers);
|
||||
if (!isPropertyFileReferencedByOthers)
|
||||
{
|
||||
std::vector<QString> newList;
|
||||
size_t i;
|
||||
for (i = 0; i < m_additionalFileNames().size(); i++)
|
||||
{
|
||||
if (m_additionalFileNames()[i] != inputProperty->fileName)
|
||||
{
|
||||
newList.push_back(m_additionalFileNames()[i]);
|
||||
}
|
||||
}
|
||||
|
||||
m_additionalFileNames.v() = newList;
|
||||
}
|
||||
|
||||
// Remove the results pointed to by this input property
|
||||
RigReservoirCellResults* results = m_rigReservoir->mainGrid()->results();
|
||||
results->removeResult(inputProperty->resultName);
|
||||
|
||||
this->removeResult(inputProperty->resultName);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<RifReaderInterface> RimInputReservoir::createMockModel(QString modelName)
|
||||
{
|
||||
cvf::ref<RigReservoir> reservoir = new RigReservoir;
|
||||
cvf::ref<RifReaderMockModel> mockFileInterface = new RifReaderMockModel;
|
||||
|
||||
if (modelName == "Input Mock Debug Model Simple")
|
||||
{
|
||||
// Create the mock file interface and and RigSerervoir and set them up.
|
||||
mockFileInterface->setWorldCoordinates(cvf::Vec3d(10, 10, 10), cvf::Vec3d(20, 20, 20));
|
||||
mockFileInterface->setGridPointDimensions(cvf::Vec3st(4, 5, 6));
|
||||
mockFileInterface->addLocalGridRefinement(cvf::Vec3st(0, 2, 2), cvf::Vec3st(0, 2, 2), cvf::Vec3st(3, 3, 3));
|
||||
mockFileInterface->setResultInfo(3, 10);
|
||||
|
||||
mockFileInterface->open("", reservoir.p());
|
||||
{
|
||||
size_t idx = reservoir->mainGrid()->cellIndexFromIJK(1, 3, 4);
|
||||
reservoir->mainGrid()->cell(idx).setActive(false);
|
||||
}
|
||||
|
||||
{
|
||||
size_t idx = reservoir->mainGrid()->cellIndexFromIJK(2, 2, 3);
|
||||
reservoir->mainGrid()->cell(idx).setActive(false);
|
||||
}
|
||||
|
||||
// Add a property
|
||||
RimInputProperty* inputProperty = new RimInputProperty;
|
||||
inputProperty->resultName = "PORO";
|
||||
inputProperty->eclipseKeyword = "PORO";
|
||||
inputProperty->fileName = "PORO.prop";
|
||||
m_inputPropertyCollection->inputProperties.push_back(inputProperty);
|
||||
}
|
||||
|
||||
m_rigReservoir = reservoir;
|
||||
|
||||
return mockFileInterface.p();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimInputReservoir::locationOnDisc() const
|
||||
{
|
||||
if (m_gridFileName().isEmpty()) return QString();
|
||||
|
||||
QFileInfo fi(m_gridFileName);
|
||||
return fi.absolutePath();
|
||||
}
|
||||
73
ApplicationCode/ProjectDataModel/RimInputReservoir.h
Normal file
73
ApplicationCode/ProjectDataModel/RimInputReservoir.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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 "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include "RimReservoir.h"
|
||||
#include "RimInputPropertyCollection.h"
|
||||
|
||||
|
||||
class QString;
|
||||
|
||||
class RifReaderInterface;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RimInputReservoir : public RimReservoir
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimInputReservoir();
|
||||
virtual ~RimInputReservoir();
|
||||
|
||||
// Fields
|
||||
caf::PdmField<std::vector<QString> > m_additionalFileNames;
|
||||
caf::PdmField<QString> m_gridFileName;
|
||||
|
||||
caf::PdmField<RimInputPropertyCollection*> m_inputPropertyCollection;
|
||||
|
||||
// File open methods
|
||||
void openDataFileSet(const QStringList& filenames);
|
||||
void loadAndSyncronizeInputProperties();
|
||||
|
||||
void removeProperty(RimInputProperty* inputProperty);
|
||||
|
||||
// RimReservoir overrides
|
||||
virtual bool openEclipseGridFile(); // Find grid file among file set. Read, Find read and validate property date. Syncronize child property sets.
|
||||
|
||||
// PdmObject overrides
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
|
||||
|
||||
virtual QString locationOnDisc() const;
|
||||
|
||||
private:
|
||||
void addFiles(const QStringList& newFileNames);
|
||||
void removeFiles(const QStringList& obsoleteFileNames);
|
||||
|
||||
cvf::ref<RifReaderInterface> createMockModel(QString modelName);
|
||||
|
||||
};
|
||||
@@ -20,6 +20,9 @@
|
||||
|
||||
#include "RimLegendConfig.h"
|
||||
#include "RimReservoirView.h"
|
||||
#include "cafFactory.h"
|
||||
#include "cafPdmUiLineEditor.h"
|
||||
#include "cafPdmUiComboBoxEditor.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimLegendConfig, "Legend");
|
||||
|
||||
@@ -78,7 +81,7 @@ RimLegendConfig::RimLegendConfig()
|
||||
CAF_PDM_InitField(&m_userDefinedMaxValue, "UserDefinedMax", 1.0, "Max", "", "Min value of the legend", "");
|
||||
CAF_PDM_InitField(&m_userDefinedMinValue, "UserDefinedMin", 0.0, "Min", "", "Max value of the legend", "");
|
||||
CAF_PDM_InitField(&resultVariableName, "ResultVariableUsage", QString(""), "", "", "", "");
|
||||
resultVariableName.setHidden(true);
|
||||
resultVariableName.setUiHidden(true);
|
||||
|
||||
m_linDiscreteScalarMapper = new cvf::ScalarMapperUniformLevels;
|
||||
m_linDiscreteScalarMapper->setTextureSize(1024);
|
||||
@@ -300,13 +303,13 @@ void RimLegendConfig::updateFieldVisibility()
|
||||
{
|
||||
if (m_rangeMode == USER_DEFINED)
|
||||
{
|
||||
m_userDefinedMaxValue.setHidden(false);
|
||||
m_userDefinedMinValue.setHidden(false);
|
||||
m_userDefinedMaxValue.setUiHidden(false);
|
||||
m_userDefinedMinValue.setUiHidden(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_userDefinedMaxValue.setHidden(true);
|
||||
m_userDefinedMinValue.setHidden(true);
|
||||
m_userDefinedMaxValue.setUiHidden(true);
|
||||
m_userDefinedMinValue.setUiHidden(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,13 +30,13 @@ CAF_PDM_SOURCE_INIT(RimProject, "ResInsightProject");
|
||||
RimProject::RimProject(void)
|
||||
{
|
||||
CAF_PDM_InitFieldNoDefault(&m_projectFileVersionString, "ProjectFileVersionString", "", "", "", "");
|
||||
m_projectFileVersionString.setHidden(true);
|
||||
m_projectFileVersionString.setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&reservoirs, "Reservoirs", "", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&scriptCollection, "ScriptCollection", "Scripts", ":/Default.png", "", "");
|
||||
|
||||
scriptCollection = new RimScriptCollection();
|
||||
scriptCollection->directory.setHidden(true);
|
||||
scriptCollection->directory.setUiHidden(true);
|
||||
|
||||
initAfterRead();
|
||||
}
|
||||
@@ -48,7 +48,7 @@ RimProject::~RimProject(void)
|
||||
{
|
||||
if (scriptCollection()) delete scriptCollection();
|
||||
|
||||
reservoirs.deleteChildren();
|
||||
reservoirs.deleteAllChildObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -56,7 +56,7 @@ RimProject::~RimProject(void)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::close()
|
||||
{
|
||||
reservoirs.deleteChildren();
|
||||
reservoirs.deleteAllChildObjects();
|
||||
|
||||
fileName = "";
|
||||
}
|
||||
@@ -89,8 +89,8 @@ void RimProject::setupBeforeSave()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::setUserScriptPath(const QString& scriptDirectory)
|
||||
{
|
||||
scriptCollection->calcScripts().deleteChildren();
|
||||
scriptCollection->subDirectories().deleteChildren();
|
||||
scriptCollection->calcScripts().deleteAllChildObjects();
|
||||
scriptCollection->subDirectories().deleteAllChildObjects();
|
||||
|
||||
|
||||
QDir dir(scriptDirectory);
|
||||
|
||||
@@ -18,45 +18,31 @@
|
||||
|
||||
#include "RIStdInclude.h"
|
||||
|
||||
#include "RifReaderInterfaceEcl.h"
|
||||
#include "RifReaderEclipseOutput.h"
|
||||
#include "RimReservoir.h"
|
||||
#include "RigReservoir.h"
|
||||
#include "RigMainGrid.h"
|
||||
#include "RigReservoirCellResults.h"
|
||||
|
||||
#include "RimWell.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "RimReservoirView.h"
|
||||
|
||||
#include "cvfAssert.h"
|
||||
|
||||
#include <QString>
|
||||
#include "RifReaderInterfaceMock.h"
|
||||
#include "RifReaderMockModel.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimReservoir, "EclipseCase");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimReservoir::RimReservoir()
|
||||
{
|
||||
m_rigReservoir = NULL;
|
||||
m_fileInterface = NULL;
|
||||
|
||||
CAF_PDM_InitObject("Reservoir", ":/AppLogo48x48.png", "", "");
|
||||
CAF_PDM_InitField(&caseName, "CaseName", QString(), "Case name", "", "" ,"");
|
||||
CAF_PDM_InitField(&caseDirectory, "CaseFolder", QString(), "Directory", "", "" ,"");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&reservoirViews, "ReservoirViews", "", "", "", "");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimReservoir::RimReservoir(RigReservoir* reservoir)
|
||||
{
|
||||
m_rigReservoir = reservoir;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -73,144 +59,6 @@ const RigReservoir* RimReservoir::reservoirData() const
|
||||
return m_rigReservoir.p();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifReaderInterface* RimReservoir::fileInterface()
|
||||
{
|
||||
return m_fileInterface.p();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const RifReaderInterface* RimReservoir::fileInterface() const
|
||||
{
|
||||
return m_fileInterface.p();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimReservoir::openEclipseGridFile()
|
||||
{
|
||||
// Early exit if reservoir data is created
|
||||
if (m_rigReservoir.notNull()) return true;
|
||||
|
||||
if (caseName().contains("Mock Debug Model"))
|
||||
{
|
||||
this->createMockModel(this->caseName());
|
||||
}
|
||||
else
|
||||
{
|
||||
QString fullCaseName = caseName + ".EGRID";
|
||||
|
||||
QDir dir(caseDirectory.v());
|
||||
if (!dir.exists(fullCaseName))
|
||||
{
|
||||
fullCaseName = caseName + ".GRID";
|
||||
if (!dir.exists(fullCaseName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QString fname = dir.absoluteFilePath(fullCaseName);
|
||||
|
||||
RigReservoir* reservoir = new RigReservoir;
|
||||
m_fileInterface = new RifReaderInterfaceECL;
|
||||
if (!m_fileInterface->open(fname, reservoir))
|
||||
{
|
||||
delete reservoir;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_rigReservoir = reservoir;
|
||||
}
|
||||
|
||||
CVF_ASSERT(m_rigReservoir.notNull());
|
||||
CVF_ASSERT(m_fileInterface.notNull());
|
||||
|
||||
m_rigReservoir->mainGrid()->results()->setReaderInterface(m_fileInterface.p());
|
||||
m_rigReservoir->computeFaults();
|
||||
m_rigReservoir->mainGrid()->computeCachedData();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimReservoir::createMockModel(QString modelName)
|
||||
{
|
||||
cvf::ref<RifReaderInterfaceMock> mockFileInterface = new RifReaderInterfaceMock;
|
||||
cvf::ref<RigReservoir> reservoir = new RigReservoir;
|
||||
|
||||
if (modelName == "Mock Debug Model Simple")
|
||||
{
|
||||
// Create the mock file interface and and RigSerervoir and set them up.
|
||||
mockFileInterface->setWorldCoordinates(cvf::Vec3d(10, 10, 10), cvf::Vec3d(20, 20, 20));
|
||||
mockFileInterface->setGridPointDimensions(cvf::Vec3st(4, 5, 6));
|
||||
mockFileInterface->addLocalGridRefinement(cvf::Vec3st(0, 2, 2), cvf::Vec3st(0, 2, 2), cvf::Vec3st(3, 3, 3));
|
||||
|
||||
mockFileInterface->open("", reservoir.p());
|
||||
{
|
||||
size_t idx = reservoir->mainGrid()->cellIndexFromIJK(1, 3, 4);
|
||||
reservoir->mainGrid()->cell(idx).setActive(false);
|
||||
}
|
||||
|
||||
{
|
||||
size_t idx = reservoir->mainGrid()->cellIndexFromIJK(2, 2, 3);
|
||||
reservoir->mainGrid()->cell(idx).setActive(false);
|
||||
}
|
||||
}
|
||||
else if (modelName == "Mock Debug Model With Results")
|
||||
{
|
||||
mockFileInterface->setWorldCoordinates(cvf::Vec3d(10, 10, 10), cvf::Vec3d(-20, -20, -20));
|
||||
mockFileInterface->setGridPointDimensions(cvf::Vec3st(5, 10, 20));
|
||||
mockFileInterface->addLocalGridRefinement(cvf::Vec3st(0, 3, 3), cvf::Vec3st(1, 4, 9), cvf::Vec3st(2, 2, 2));
|
||||
mockFileInterface->setResultInfo(3, 10);
|
||||
|
||||
mockFileInterface->open("", reservoir.p());
|
||||
|
||||
// Make a fault
|
||||
cvf::Vec3d& tmp = reservoir->mainGrid()->nodes()[1];
|
||||
tmp += cvf::Vec3d(1, 0, 0);
|
||||
}
|
||||
else if (modelName =="Mock Debug Model Large With Results")
|
||||
{
|
||||
double startX = 0;
|
||||
double startY = 0;
|
||||
double startZ = 0;
|
||||
|
||||
double widthX = 6000;
|
||||
double widthY = 12000;
|
||||
double widthZ = 500;
|
||||
|
||||
double offsetX = 0;
|
||||
double offsetY = 0;
|
||||
double offsetZ = 0;
|
||||
|
||||
// Test code to simulate UTM coordinates
|
||||
offsetX = 400000;
|
||||
offsetY = 6000000;
|
||||
offsetZ = 0;
|
||||
|
||||
|
||||
mockFileInterface->setWorldCoordinates(cvf::Vec3d(startX + offsetX, startY + offsetY, startZ + offsetZ), cvf::Vec3d(startX + widthX + offsetX, startY + widthY + offsetY, startZ + widthZ + offsetZ));
|
||||
mockFileInterface->setGridPointDimensions(cvf::Vec3st(50, 100, 200));
|
||||
mockFileInterface->addLocalGridRefinement(cvf::Vec3st(0, 30, 30), cvf::Vec3st(1, 40, 90), cvf::Vec3st(2, 2, 2));
|
||||
mockFileInterface->setResultInfo(3, 10);
|
||||
|
||||
mockFileInterface->open("", reservoir.p());
|
||||
|
||||
}
|
||||
|
||||
m_rigReservoir = reservoir;
|
||||
m_fileInterface = mockFileInterface;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -231,7 +79,7 @@ void RimReservoir::initAfterRead()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimReservoir::~RimReservoir()
|
||||
{
|
||||
reservoirViews.deleteChildren();
|
||||
reservoirViews.deleteAllChildObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -274,3 +122,54 @@ void RimReservoir::removeReservoirView(RimReservoirView* reservoirView)
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimReservoir::removeResult(const QString& resultName)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < reservoirViews().size(); i++)
|
||||
{
|
||||
RimReservoirView* reservoirView = reservoirViews()[i];
|
||||
CVF_ASSERT(reservoirView);
|
||||
|
||||
RimResultSlot* result = reservoirView->cellResult;
|
||||
CVF_ASSERT(result);
|
||||
|
||||
bool rebuildDisplayModel = false;
|
||||
|
||||
// Set cell result variable to none if displaying
|
||||
if (result->resultVariable() == resultName)
|
||||
{
|
||||
result->resultVariable.v() = QString("None");
|
||||
result->loadResult();
|
||||
|
||||
rebuildDisplayModel = true;
|
||||
}
|
||||
|
||||
std::list< caf::PdmPointer< RimCellPropertyFilter > >::iterator it;
|
||||
RimCellPropertyFilterCollection* propFilterCollection = reservoirView->propertyFilterCollection();
|
||||
for (it = propFilterCollection->propertyFilters.v().begin(); it != propFilterCollection->propertyFilters.v().end(); ++it)
|
||||
{
|
||||
RimCellPropertyFilter* propertyFilter = *it;
|
||||
if (propertyFilter->resultDefinition->resultVariable.v() == resultName)
|
||||
{
|
||||
propertyFilter->resultDefinition->resultVariable.v() = QString("None");
|
||||
propertyFilter->resultDefinition->loadResult();
|
||||
propertyFilter->setDefaultValues();
|
||||
|
||||
rebuildDisplayModel = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (rebuildDisplayModel)
|
||||
{
|
||||
reservoirViews()[i]->createDisplayModelAndRedraw();
|
||||
}
|
||||
|
||||
|
||||
// TODO
|
||||
// CellEdgeResults are not considered, as they do not support display of input properties yet
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,57 +23,51 @@
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include "RimWellCollection.h"
|
||||
|
||||
class QString;
|
||||
class RigReservoir;
|
||||
class RifReaderInterface;
|
||||
class RimWellCollection;
|
||||
class RigGridBase;
|
||||
class RimReservoirView;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
// Interface for reservoirs.
|
||||
// As this is a pure virtual class, the factory macros are not relevant (nor possible) to use
|
||||
// CAF_PDM_HEADER_INIT and CAF_PDM_SOURCE_INIT
|
||||
//
|
||||
//==================================================================================================
|
||||
class RimReservoir : public caf::PdmObject, public cvf::Object
|
||||
class RimReservoir : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimReservoir();
|
||||
RimReservoir(RigReservoir* reservoir);
|
||||
virtual ~RimReservoir();
|
||||
|
||||
bool openEclipseGridFile();
|
||||
virtual bool openEclipseGridFile() = 0;
|
||||
|
||||
RigReservoir* reservoirData();
|
||||
const RigReservoir* reservoirData() const;
|
||||
|
||||
RifReaderInterface* fileInterface();
|
||||
const RifReaderInterface* fileInterface() const;
|
||||
|
||||
RimReservoirView* createAndAddReservoirView();
|
||||
void removeReservoirView(RimReservoirView* reservoirView);
|
||||
|
||||
void removeResult(const QString& resultName);
|
||||
|
||||
// Fields:
|
||||
caf::PdmField<QString> caseName;
|
||||
caf::PdmField<QString> caseDirectory;
|
||||
|
||||
caf::PdmPointersField<RimReservoirView*> reservoirViews;
|
||||
|
||||
virtual caf::PdmFieldHandle* userDescriptionField() { return &caseName;}
|
||||
virtual caf::PdmFieldHandle* userDescriptionField() { return &caseName; }
|
||||
|
||||
virtual QString locationOnDisc() const { return QString(); }
|
||||
|
||||
protected:
|
||||
// Overridden methods
|
||||
virtual void initAfterRead();
|
||||
|
||||
private:
|
||||
void createMockModel(QString modelName);
|
||||
|
||||
private:
|
||||
protected:
|
||||
cvf::ref<RigReservoir> m_rigReservoir;
|
||||
cvf::ref<RifReaderInterface> m_fileInterface;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
#include "cafCadNavigation.h"
|
||||
#include "cafCeetronNavigation.h"
|
||||
#include "RimReservoir.h"
|
||||
#include "RifReaderInterface.h"
|
||||
|
||||
namespace caf {
|
||||
|
||||
@@ -90,13 +89,13 @@ RimReservoirView::RimReservoirView()
|
||||
CAF_PDM_InitField(&name, "UserDescription", QString(""), "Name", "", "", "");
|
||||
CAF_PDM_InitField(&scaleZ, "GridZScale", 1.0, "Z Scale", "", "Scales the scene in the Z direction", "");
|
||||
CAF_PDM_InitField(&showWindow, "ShowWindow", true, "Show 3D viewer", "", "", "");
|
||||
showWindow.setHidden(true);
|
||||
showWindow.setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitField(&m_currentTimeStep, "CurrentTimeStep", 0, "Current Time Step","", "", "");
|
||||
m_currentTimeStep.setHidden(true);
|
||||
m_currentTimeStep.setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitField(&animationMode, "AnimationMode", false, "Animation Mode","", "", "");
|
||||
animationMode.setHidden(true);
|
||||
animationMode.setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&wellCollection, "WellCollection","Wells", "", "", "");
|
||||
wellCollection = new RimWellCollection;
|
||||
@@ -113,7 +112,7 @@ RimReservoirView::RimReservoirView()
|
||||
CAF_PDM_InitFieldNoDefault(&surfaceMode, "SurfaceMode", "Grid surface", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&maximumFrameRate, "MaximumFrameRate", 10, "Maximum frame rate","", "", "");
|
||||
maximumFrameRate.setHidden(true);
|
||||
maximumFrameRate.setUiHidden(true);
|
||||
|
||||
// Visualization fields
|
||||
CAF_PDM_InitField(&showMainGrid, "ShowMainGrid", true, "Show Main Grid", "", "", "");
|
||||
@@ -404,12 +403,6 @@ void RimReservoirView::createDisplayModel()
|
||||
|
||||
if (m_reservoir && m_reservoir->reservoirData())
|
||||
{
|
||||
RigReservoir* reservoir = m_reservoir->reservoirData();
|
||||
CVF_ASSERT(reservoir);
|
||||
|
||||
RigReservoirCellResults* results = reservoir->mainGrid()->results();
|
||||
CVF_ASSERT(results);
|
||||
|
||||
// Define a vector containing time step indices to produce geometry for.
|
||||
// First entry in this vector is used to define the geometry only result mode with no results.
|
||||
std::vector<size_t> timeStepIndices;
|
||||
@@ -417,12 +410,16 @@ void RimReservoirView::createDisplayModel()
|
||||
// The one and only geometry entry
|
||||
timeStepIndices.push_back(0);
|
||||
|
||||
// Find the number of time frames the animation needs to show the requested data.
|
||||
|
||||
if (this->cellResult()->hasDynamicResult()
|
||||
|| this->propertyFilterCollection()->hasActiveDynamicFilters()
|
||||
|| this->wellCollection->hasVisibleWellPipes())
|
||||
{
|
||||
CVF_ASSERT(gridCellResults());
|
||||
|
||||
size_t i;
|
||||
for (i = 0; i < m_reservoir->fileInterface()->numTimeSteps(); i++)
|
||||
for (i = 0; i < gridCellResults()->maxTimeStepCount(); i++)
|
||||
{
|
||||
timeStepIndices.push_back(i);
|
||||
}
|
||||
@@ -522,16 +519,16 @@ void RimReservoirView::createDisplayModel()
|
||||
// Create Scenes from the frameModels
|
||||
// Animation frames for results display, starts from frame 1
|
||||
|
||||
size_t modelIndex;
|
||||
for (modelIndex = 0; modelIndex < frameModels.size(); modelIndex++)
|
||||
size_t frameIndex;
|
||||
for (frameIndex = 0; frameIndex < frameModels.size(); frameIndex++)
|
||||
{
|
||||
cvf::ModelBasicList* model = frameModels.at(modelIndex);
|
||||
cvf::ModelBasicList* model = frameModels.at(frameIndex);
|
||||
model->updateBoundingBoxesRecursive();
|
||||
|
||||
cvf::ref<cvf::Scene> scene = new cvf::Scene;
|
||||
scene->addModel(model);
|
||||
|
||||
if (modelIndex == 0)
|
||||
if (frameIndex == 0)
|
||||
m_viewer->setMainScene(scene.p());
|
||||
else
|
||||
m_viewer->addFrame(scene.p());
|
||||
@@ -552,7 +549,6 @@ void RimReservoirView::createDisplayModel()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimReservoirView::updateCurrentTimeStep()
|
||||
{
|
||||
updateLegends();
|
||||
|
||||
std::vector<RivReservoirViewPartMgr::ReservoirGeometryCacheType> geometriesToRecolor;
|
||||
|
||||
@@ -622,14 +618,33 @@ void RimReservoirView::updateCurrentTimeStep()
|
||||
cvf::Scene* frameScene = m_viewer->frame(m_currentTimeStep);
|
||||
if (frameScene)
|
||||
{
|
||||
cvf::ref<cvf::ModelBasicList> frameParts = new cvf::ModelBasicList;
|
||||
m_pipesPartManager->appendDynamicGeometryPartsToModel(frameParts.p(), m_currentTimeStep);
|
||||
cvf::String modelName = "WellPipeModel";
|
||||
std::vector<cvf::Model*> models;
|
||||
for (i = 0; i < frameScene->modelCount(); i++)
|
||||
{
|
||||
if (frameScene->model(i)->name() == modelName)
|
||||
{
|
||||
models.push_back(frameScene->model(i));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < models.size(); i++)
|
||||
{
|
||||
frameScene->removeModel(models[i]);
|
||||
}
|
||||
|
||||
cvf::ref<cvf::ModelBasicList> pipeModel = new cvf::ModelBasicList;
|
||||
pipeModel->setName(modelName);
|
||||
|
||||
m_pipesPartManager->appendDynamicGeometryPartsToModel(pipeModel.p(), m_currentTimeStep);
|
||||
m_pipesPartManager->updatePipeResultColor(m_currentTimeStep);
|
||||
|
||||
frameParts->updateBoundingBoxesRecursive();
|
||||
frameScene->addModel(frameParts.p());
|
||||
pipeModel->updateBoundingBoxesRecursive();
|
||||
frameScene->addModel(pipeModel.p());
|
||||
}
|
||||
}
|
||||
|
||||
updateLegends();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -643,7 +658,7 @@ void RimReservoirView::loadDataAndUpdate()
|
||||
{
|
||||
if (!m_reservoir->openEclipseGridFile())
|
||||
{
|
||||
QMessageBox::warning(RIMainWindow::instance(), "Error when opening project file", "Could not open the Eclipse Grid file (EGRID/GRID): \n"+ m_reservoir->caseName() + "\nIn directory " + m_reservoir->caseDirectory());
|
||||
QMessageBox::warning(RIMainWindow::instance(), "Error when opening project file", "Could not open the Eclipse Grid file (EGRID/GRID): \n"+ m_reservoir->caseName());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
class RIViewer;
|
||||
class RigGridBase;
|
||||
class RigGridCellFaceVisibilityFilter;
|
||||
class RimReservoir;
|
||||
class RivReservoirViewPartMgr;
|
||||
|
||||
namespace cvf
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "RigReservoirCellResults.h"
|
||||
#include "RigReservoir.h"
|
||||
#include "RigMainGrid.h"
|
||||
#include "RifReaderInterface.h"
|
||||
#include "cafPdmUiListEditor.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimResultDefinition, "ResultDefinition");
|
||||
@@ -38,8 +38,10 @@ RimResultDefinition::RimResultDefinition()
|
||||
{
|
||||
CAF_PDM_InitObject("Result Definition", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&resultType, "ResultType","Result type", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&resultVariable, "ResultVariable","Variable", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault(&resultType, "ResultType", "Type", "", "", "");
|
||||
CAF_PDM_InitField(&resultVariable, "ResultVariable", RimDefines::nonSelectedResultName(), "Variable", "", "", "" );
|
||||
|
||||
resultVariable.setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -65,21 +67,10 @@ void RimResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* changedFie
|
||||
{
|
||||
if (changedField == &resultType)
|
||||
{
|
||||
resultVariable = "";
|
||||
resultVariable = RimDefines::nonSelectedResultName();
|
||||
}
|
||||
|
||||
loadResult();
|
||||
|
||||
// Notify the parent objects that this object has changed
|
||||
// In this case the RimCellPropertyFilter.
|
||||
// The RimReservoirView can also be a parent, but the call should have no effect there
|
||||
|
||||
std::vector<caf::PdmFieldHandle*> parentFields;
|
||||
this->parentFields(parentFields);
|
||||
for (size_t i = 0; i < parentFields.size(); ++i)
|
||||
{
|
||||
parentFields[i]->ownerObject()->fieldChangedByUi(parentFields[i], QVariant(), QVariant());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -89,17 +80,13 @@ QList<caf::PdmOptionItemInfo> RimResultDefinition::calculateValueOptions(const c
|
||||
{
|
||||
if (fieldNeedingOptions == &resultVariable)
|
||||
{
|
||||
if (m_reservoirView &&
|
||||
m_reservoirView->eclipseCase() &&
|
||||
m_reservoirView->eclipseCase()->fileInterface())
|
||||
if (m_reservoirView && m_reservoirView->gridCellResults())
|
||||
{
|
||||
RifReaderInterface* readerInterface = m_reservoirView->eclipseCase()->fileInterface();
|
||||
CVF_ASSERT(readerInterface);
|
||||
|
||||
/*
|
||||
QStringList varList;
|
||||
if (resultType() == RimDefines::DYNAMIC_NATIVE)
|
||||
{
|
||||
varList = readerInterface->dynamicResults();
|
||||
varList = readerInterface->dynamicResultNames();
|
||||
|
||||
if (!varList.contains("SOIL", Qt::CaseInsensitive))
|
||||
{
|
||||
@@ -112,20 +99,26 @@ QList<caf::PdmOptionItemInfo> RimResultDefinition::calculateValueOptions(const c
|
||||
}
|
||||
else if (resultType == RimDefines::STATIC_NATIVE)
|
||||
{
|
||||
varList = readerInterface->staticResults();
|
||||
varList = readerInterface->staticResultNames();
|
||||
}
|
||||
else if (resultType == RimDefines::GENERATED)
|
||||
{
|
||||
varList = m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->results()->resultNames(resultType());
|
||||
}
|
||||
|
||||
else if (resultType == RimDefines::INPUT_PROPERTY)
|
||||
{
|
||||
varList = readerInterface->inputPropertyNames();
|
||||
}
|
||||
*/
|
||||
|
||||
QStringList varList = m_reservoirView->gridCellResults()->resultNames(resultType());
|
||||
QList<caf::PdmOptionItemInfo> optionList;
|
||||
int i;
|
||||
for (i = 0; i < varList.size(); ++i)
|
||||
{
|
||||
optionList.push_back(caf::PdmOptionItemInfo( varList[i], varList[i]));
|
||||
}
|
||||
optionList.push_front(caf::PdmOptionItemInfo( "None", "" ));
|
||||
optionList.push_front(caf::PdmOptionItemInfo( RimDefines::nonSelectedResultName(), RimDefines::nonSelectedResultName() ));
|
||||
|
||||
if (useOptionsOnly) *useOptionsOnly = true;
|
||||
|
||||
@@ -144,7 +137,7 @@ size_t RimResultDefinition::gridScalarIndex() const
|
||||
if (m_gridScalarResultIndex == cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
const RigReservoirCellResults* gridCellResults = m_reservoirView->gridCellResults();
|
||||
if (gridCellResults) m_gridScalarResultIndex = gridCellResults->findGridScalarIndex(resultType(), resultVariable());
|
||||
if (gridCellResults) m_gridScalarResultIndex = gridCellResults->findScalarResultIndex(resultType(), resultVariable());
|
||||
}
|
||||
return m_gridScalarResultIndex;
|
||||
}
|
||||
@@ -157,7 +150,7 @@ void RimResultDefinition::loadResult()
|
||||
RigReservoirCellResults* gridCellResults = m_reservoirView->gridCellResults();
|
||||
if (gridCellResults)
|
||||
{
|
||||
m_gridScalarResultIndex = gridCellResults->loadResultIntoGrid(resultType(), resultVariable);
|
||||
m_gridScalarResultIndex = gridCellResults->findOrLoadScalarResult(resultType(), resultVariable);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -167,7 +160,8 @@ void RimResultDefinition::loadResult()
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
/// Returns whether the result requested by the definition is a single frame result
|
||||
/// The result needs to be loaded before asking
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimResultDefinition::hasStaticResult() const
|
||||
{
|
||||
@@ -183,7 +177,7 @@ bool RimResultDefinition::hasStaticResult() const
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
/// Returns whether the result requested by the definition is loaded or possible to load from the result file
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimResultDefinition::hasResult() const
|
||||
{
|
||||
@@ -192,7 +186,7 @@ bool RimResultDefinition::hasResult() const
|
||||
const RigReservoirCellResults* gridCellResults = m_reservoirView->gridCellResults();
|
||||
if (gridCellResults)
|
||||
{
|
||||
m_gridScalarResultIndex = gridCellResults->findGridScalarIndex(resultType(), resultVariable());
|
||||
m_gridScalarResultIndex = gridCellResults->findScalarResultIndex(resultType(), resultVariable());
|
||||
return m_gridScalarResultIndex != cvf::UNDEFINED_SIZE_T;
|
||||
}
|
||||
|
||||
@@ -200,7 +194,8 @@ bool RimResultDefinition::hasResult() const
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
/// Returns whether the result requested by the definition is a multi frame result
|
||||
/// The result needs to be loaded before asking
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimResultDefinition::hasDynamicResult() const
|
||||
{
|
||||
@@ -210,3 +205,11 @@ bool RimResultDefinition::hasDynamicResult() const
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimReservoirView* RimResultDefinition::reservoirView()
|
||||
{
|
||||
return m_reservoirView;
|
||||
}
|
||||
|
||||
@@ -40,8 +40,9 @@ public:
|
||||
virtual ~RimResultDefinition();
|
||||
|
||||
virtual void setReservoirView(RimReservoirView* ownerReservoirView);
|
||||
RimReservoirView* reservoirView();
|
||||
|
||||
caf::PdmField< caf::AppEnum< RimDefines::ResultCatType > > resultType;
|
||||
caf::PdmField< caf::AppEnum< RimDefines::ResultCatType > > resultType;
|
||||
caf::PdmField<QString> resultVariable;
|
||||
|
||||
void loadResult();
|
||||
@@ -52,9 +53,6 @@ public:
|
||||
|
||||
|
||||
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly );
|
||||
|
||||
protected:
|
||||
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
|
||||
|
||||
protected:
|
||||
|
||||
191
ApplicationCode/ProjectDataModel/RimResultReservoir.cpp
Normal file
191
ApplicationCode/ProjectDataModel/RimResultReservoir.cpp
Normal file
@@ -0,0 +1,191 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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 "RIStdInclude.h"
|
||||
#include "RimResultReservoir.h"
|
||||
#include "RigReservoir.h"
|
||||
#include "RifReaderEclipseOutput.h"
|
||||
#include "RigReservoirCellResults.h"
|
||||
#include "RimReservoirView.h"
|
||||
#include "RifReaderMockModel.h"
|
||||
#include "RifReaderEclipseInput.h"
|
||||
#include "cafProgressInfo.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimResultReservoir, "EclipseCase");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimResultReservoir::RimResultReservoir()
|
||||
: RimReservoir()
|
||||
{
|
||||
CAF_PDM_InitField(&caseFileName, "CaseFileName", QString(), "Case file name", "", "" ,"");
|
||||
CAF_PDM_InitField(&caseDirectory, "CaseFolder", QString(), "Directory", "", "" ,"");
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimResultReservoir::openEclipseGridFile()
|
||||
{
|
||||
caf::ProgressInfo progInfo(2, "Reading Eclipse Grid File");
|
||||
|
||||
progInfo.setProgressDescription("Open Grid File");
|
||||
// Early exit if reservoir data is created
|
||||
if (m_rigReservoir.notNull()) return true;
|
||||
|
||||
cvf::ref<RifReaderInterface> readerInterface;
|
||||
|
||||
if (caseName().contains("Result Mock Debug Model"))
|
||||
{
|
||||
readerInterface = this->createMockModel(this->caseName());
|
||||
}
|
||||
else
|
||||
{
|
||||
QString fullCaseName = caseName + ".EGRID";
|
||||
|
||||
QDir dir(caseDirectory.v());
|
||||
if (!dir.exists(fullCaseName))
|
||||
{
|
||||
fullCaseName = caseName + ".GRID";
|
||||
if (!dir.exists(fullCaseName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QString fname = dir.absoluteFilePath(fullCaseName);
|
||||
|
||||
RigReservoir* reservoir = new RigReservoir;
|
||||
readerInterface = new RifReaderEclipseOutput;
|
||||
if (!readerInterface->open(fname, reservoir))
|
||||
{
|
||||
delete reservoir;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_rigReservoir = reservoir;
|
||||
}
|
||||
|
||||
progInfo.setProgress(1);
|
||||
|
||||
CVF_ASSERT(m_rigReservoir.notNull());
|
||||
CVF_ASSERT(readerInterface.notNull());
|
||||
|
||||
m_rigReservoir->mainGrid()->results()->setReaderInterface(readerInterface.p());
|
||||
|
||||
progInfo.setProgressDescription("Computing Faults");
|
||||
m_rigReservoir->computeFaults();
|
||||
progInfo.setProgressDescription("Computing Cache");
|
||||
m_rigReservoir->mainGrid()->computeCachedData();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<RifReaderInterface> RimResultReservoir::createMockModel(QString modelName)
|
||||
{
|
||||
cvf::ref<RifReaderMockModel> mockFileInterface = new RifReaderMockModel;
|
||||
cvf::ref<RigReservoir> reservoir = new RigReservoir;
|
||||
|
||||
if (modelName == "Result Mock Debug Model Simple")
|
||||
{
|
||||
// Create the mock file interface and and RigSerervoir and set them up.
|
||||
mockFileInterface->setWorldCoordinates(cvf::Vec3d(10, 10, 10), cvf::Vec3d(20, 20, 20));
|
||||
mockFileInterface->setGridPointDimensions(cvf::Vec3st(4, 5, 6));
|
||||
mockFileInterface->addLocalGridRefinement(cvf::Vec3st(0, 2, 2), cvf::Vec3st(0, 2, 2), cvf::Vec3st(3, 3, 3));
|
||||
|
||||
mockFileInterface->open("", reservoir.p());
|
||||
{
|
||||
size_t idx = reservoir->mainGrid()->cellIndexFromIJK(1, 3, 4);
|
||||
reservoir->mainGrid()->cell(idx).setActive(false);
|
||||
}
|
||||
|
||||
{
|
||||
size_t idx = reservoir->mainGrid()->cellIndexFromIJK(2, 2, 3);
|
||||
reservoir->mainGrid()->cell(idx).setActive(false);
|
||||
}
|
||||
}
|
||||
else if (modelName == "Result Mock Debug Model With Results")
|
||||
{
|
||||
mockFileInterface->setWorldCoordinates(cvf::Vec3d(10, 10, 10), cvf::Vec3d(-20, -20, -20));
|
||||
mockFileInterface->setGridPointDimensions(cvf::Vec3st(5, 10, 20));
|
||||
mockFileInterface->addLocalGridRefinement(cvf::Vec3st(0, 3, 3), cvf::Vec3st(1, 4, 9), cvf::Vec3st(2, 2, 2));
|
||||
mockFileInterface->setResultInfo(3, 10);
|
||||
|
||||
mockFileInterface->open("", reservoir.p());
|
||||
|
||||
// Make a fault
|
||||
cvf::Vec3d& tmp = reservoir->mainGrid()->nodes()[1];
|
||||
tmp += cvf::Vec3d(1, 0, 0);
|
||||
}
|
||||
else if (modelName =="Result Mock Debug Model Large With Results")
|
||||
{
|
||||
double startX = 0;
|
||||
double startY = 0;
|
||||
double startZ = 0;
|
||||
|
||||
double widthX = 6000;
|
||||
double widthY = 12000;
|
||||
double widthZ = 500;
|
||||
|
||||
double offsetX = 0;
|
||||
double offsetY = 0;
|
||||
double offsetZ = 0;
|
||||
|
||||
// Test code to simulate UTM coordinates
|
||||
offsetX = 400000;
|
||||
offsetY = 6000000;
|
||||
offsetZ = 0;
|
||||
|
||||
|
||||
mockFileInterface->setWorldCoordinates(cvf::Vec3d(startX + offsetX, startY + offsetY, startZ + offsetZ), cvf::Vec3d(startX + widthX + offsetX, startY + widthY + offsetY, startZ + widthZ + offsetZ));
|
||||
mockFileInterface->setGridPointDimensions(cvf::Vec3st(50, 100, 200));
|
||||
mockFileInterface->addLocalGridRefinement(cvf::Vec3st(0, 30, 30), cvf::Vec3st(1, 40, 90), cvf::Vec3st(2, 2, 2));
|
||||
mockFileInterface->setResultInfo(3, 10);
|
||||
|
||||
mockFileInterface->open("", reservoir.p());
|
||||
|
||||
}
|
||||
|
||||
m_rigReservoir = reservoir;
|
||||
|
||||
return mockFileInterface.p();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimResultReservoir::~RimResultReservoir()
|
||||
{
|
||||
reservoirViews.deleteAllChildObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimResultReservoir::locationOnDisc() const
|
||||
{
|
||||
return caseDirectory;
|
||||
}
|
||||
|
||||
56
ApplicationCode/ProjectDataModel/RimResultReservoir.h
Normal file
56
ApplicationCode/ProjectDataModel/RimResultReservoir.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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 "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "RimReservoir.h"
|
||||
|
||||
class RifReaderInterface;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RimResultReservoir : public RimReservoir
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimResultReservoir();
|
||||
virtual ~RimResultReservoir();
|
||||
|
||||
|
||||
// Fields:
|
||||
caf::PdmField<QString> caseFileName;
|
||||
caf::PdmField<QString> caseDirectory;
|
||||
|
||||
virtual bool openEclipseGridFile();
|
||||
|
||||
//virtual caf::PdmFieldHandle* userDescriptionField() { return &caseName;}
|
||||
|
||||
virtual QString locationOnDisc() const;
|
||||
|
||||
private:
|
||||
cvf::ref<RifReaderInterface> createMockModel(QString modelName);
|
||||
|
||||
};
|
||||
@@ -37,7 +37,7 @@ RimResultSlot::RimResultSlot()
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&legendConfig, "LegendDefinition", "Legend Definition", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_legendConfigData, "ResultVarLegendDefinitionList", "", "", "", "");
|
||||
m_legendConfigData.setHidden(true);
|
||||
m_legendConfigData.setUiHidden(true);
|
||||
|
||||
legendConfig = new RimLegendConfig();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "cafUtils.h"
|
||||
#include "RIMainWindow.h"
|
||||
#include "RimUiTreeModelPdm.h"
|
||||
#include "cafPdmUiFilePathEditor.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimScriptCollection, "ScriptLocation");
|
||||
|
||||
@@ -37,6 +38,8 @@ RimScriptCollection::RimScriptCollection()
|
||||
CAF_PDM_InitFieldNoDefault(&directory, "ScriptDirectory", "Dir", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&calcScripts, "CalcScripts", "", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&subDirectories, "SubDirectories", "", "", "", "");
|
||||
|
||||
directory.setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -44,8 +47,8 @@ RimScriptCollection::RimScriptCollection()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimScriptCollection::~RimScriptCollection()
|
||||
{
|
||||
calcScripts.deleteChildren();
|
||||
subDirectories.deleteChildren();
|
||||
calcScripts.deleteAllChildObjects();
|
||||
subDirectories.deleteAllChildObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -53,7 +56,7 @@ RimScriptCollection::~RimScriptCollection()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimScriptCollection::readContentFromDisc()
|
||||
{
|
||||
calcScripts.deleteChildren();
|
||||
calcScripts.deleteAllChildObjects();
|
||||
|
||||
if (directory().isEmpty())
|
||||
{
|
||||
@@ -91,7 +94,7 @@ void RimScriptCollection::readContentFromDisc()
|
||||
{
|
||||
QDir dir(directory);
|
||||
QFileInfoList fileInfoList = dir.entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot);
|
||||
subDirectories.deleteChildren();
|
||||
subDirectories.deleteAllChildObjects();
|
||||
|
||||
QStringList retFileNames;
|
||||
|
||||
@@ -162,3 +165,15 @@ void RimScriptCollection::fieldChangedByUi(const caf::PdmFieldHandle *changedFie
|
||||
if (treeModel) treeModel->rebuildUiSubTree(this);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimScriptCollection::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
|
||||
{
|
||||
if (field == &directory)
|
||||
{
|
||||
caf::PdmUiFilePathEditorAttribute* myAttr = static_cast<caf::PdmUiFilePathEditorAttribute*>(attribute);
|
||||
myAttr->m_selectDirectory = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,12 @@
|
||||
#include "cafPdmObject.h"
|
||||
#include "RimCalcScript.h"
|
||||
|
||||
namespace caf
|
||||
{
|
||||
class PdmUiEditorAttribute;
|
||||
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
@@ -47,5 +53,6 @@ public: // Methods
|
||||
// Overrides from PdmObject
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
|
||||
|
||||
|
||||
protected:
|
||||
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute );
|
||||
};
|
||||
|
||||
@@ -31,6 +31,10 @@
|
||||
#include "RimCalcScript.h"
|
||||
#include "RIApplication.h"
|
||||
#include "RIMainWindow.h"
|
||||
#include "RimInputProperty.h"
|
||||
#include "RimInputPropertyCollection.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "RimInputReservoir.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -103,7 +107,7 @@ bool RimUiTreeModelPdm::insertRows(int position, int rows, const QModelIndex &pa
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimUiTreeModelPdm::removePropertyFilter(const QModelIndex& itemIndex)
|
||||
bool RimUiTreeModelPdm::deletePropertyFilter(const QModelIndex& itemIndex)
|
||||
{
|
||||
CVF_ASSERT(itemIndex.isValid());
|
||||
|
||||
@@ -140,7 +144,7 @@ bool RimUiTreeModelPdm::removePropertyFilter(const QModelIndex& itemIndex)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimUiTreeModelPdm::removeRangeFilter(const QModelIndex& itemIndex)
|
||||
bool RimUiTreeModelPdm::deleteRangeFilter(const QModelIndex& itemIndex)
|
||||
{
|
||||
CVF_ASSERT(itemIndex.isValid());
|
||||
|
||||
@@ -178,7 +182,7 @@ bool RimUiTreeModelPdm::removeRangeFilter(const QModelIndex& itemIndex)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimUiTreeModelPdm::removeReservoirView(const QModelIndex& itemIndex)
|
||||
bool RimUiTreeModelPdm::deleteReservoirView(const QModelIndex& itemIndex)
|
||||
{
|
||||
CVF_ASSERT(itemIndex.isValid());
|
||||
|
||||
@@ -354,493 +358,64 @@ void RimUiTreeModelPdm::slotRefreshScriptTree(QString path)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimTreeView::RimTreeView(QWidget *parent /*= 0*/)
|
||||
: QTreeView(parent)
|
||||
void RimUiTreeModelPdm::addInputProperty(const QModelIndex& itemIndex, const QStringList& fileNames)
|
||||
{
|
||||
setHeaderHidden(true);
|
||||
}
|
||||
caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex);
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimTreeView::contextMenuEvent(QContextMenuEvent* event)
|
||||
{
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
if (myModel)
|
||||
RimInputPropertyCollection* inputPropertyCollection = dynamic_cast<RimInputPropertyCollection*>(currentItem->dataObject().p());
|
||||
CVF_ASSERT(inputPropertyCollection);
|
||||
|
||||
std::vector<caf::PdmObject*> parentObjects;
|
||||
inputPropertyCollection->parentObjects(parentObjects);
|
||||
|
||||
|
||||
CVF_ASSERT(parentObjects.size() == 1);
|
||||
|
||||
RimInputReservoir* inputReservoir = dynamic_cast<RimInputReservoir*>(parentObjects[0]);
|
||||
CVF_ASSERT(inputReservoir);
|
||||
if (inputReservoir)
|
||||
{
|
||||
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
|
||||
if (uiItem && uiItem->dataObject())
|
||||
{
|
||||
// Range filters
|
||||
if (dynamic_cast<RimReservoirView*>(uiItem->dataObject().p()))
|
||||
{
|
||||
QMenu menu;
|
||||
menu.addAction(QString("Show 3D Window"), this, SLOT(slotShowWindow()));
|
||||
menu.addAction(QString("New View"), this, SLOT(slotAddView()));
|
||||
menu.addAction(QString("Delete"), this, SLOT(slotDeleteView()));
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
else if (dynamic_cast<RimCellRangeFilterCollection*>(uiItem->dataObject().p()))
|
||||
{
|
||||
QMenu menu;
|
||||
menu.addAction(QString("New Range Filter"), this, SLOT(slotAddRangeFilter()));
|
||||
menu.addAction(QString("Slice I Filter"), this, SLOT(slotAddSliceFilterI()));
|
||||
menu.addAction(QString("Slice J Filter"), this, SLOT(slotAddSliceFilterJ()));
|
||||
menu.addAction(QString("Slice K Filter"), this, SLOT(slotAddSliceFilterK()));
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
else if (dynamic_cast<RimCellRangeFilter*>(uiItem->dataObject().p()))
|
||||
{
|
||||
QMenu menu;
|
||||
menu.addAction(QString("Insert Range Filter"), this, SLOT(slotAddRangeFilter()));
|
||||
menu.addAction(QString("Slice I Filter"), this, SLOT(slotAddSliceFilterI()));
|
||||
menu.addAction(QString("Slice J Filter"), this, SLOT(slotAddSliceFilterJ()));
|
||||
menu.addAction(QString("Slice K Filter"), this, SLOT(slotAddSliceFilterK()));
|
||||
menu.addSeparator();
|
||||
menu.addAction(QString("Delete"), this, SLOT(slotDeleteRangeFilter()));
|
||||
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
else if (dynamic_cast<RimCellPropertyFilterCollection*>(uiItem->dataObject().p()))
|
||||
{
|
||||
|
||||
QMenu menu;
|
||||
menu.addAction(QString("New Property Filter"), this, SLOT(slotAddPropertyFilter()));
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
else if (dynamic_cast<RimCellPropertyFilter*>(uiItem->dataObject().p()))
|
||||
{
|
||||
|
||||
QMenu menu;
|
||||
menu.addAction(QString("Insert Property Filter"), this, SLOT(slotAddPropertyFilter()));
|
||||
menu.addSeparator();
|
||||
menu.addAction(QString("Delete"), this, SLOT(slotDeletePropertyFilter()));
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
else if (dynamic_cast<RimCalcScript*>(uiItem->dataObject().p()))
|
||||
{
|
||||
RIApplication* app = RIApplication::instance();
|
||||
|
||||
QMenu menu;
|
||||
{
|
||||
QAction* action = menu.addAction(QString("Edit"), this, SLOT(slotEditScript()));
|
||||
if (app->scriptEditorPath().isEmpty())
|
||||
{
|
||||
action->setEnabled(false);
|
||||
}
|
||||
}
|
||||
menu.addAction(QString("New"), this, SLOT(slotNewScript()));
|
||||
//menu.addAction(QString("ReadFromFile"), this, SLOT(slotReadScriptContentFromFile()));
|
||||
menu.addSeparator();
|
||||
|
||||
{
|
||||
QAction* action = menu.addAction(QString("Execute"), this, SLOT(slotExecuteScript()));
|
||||
if (app->octavePath().isEmpty())
|
||||
{
|
||||
action->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimTreeView::slotAddChildItem()
|
||||
{
|
||||
|
||||
QModelIndex index = currentIndex();
|
||||
QAbstractItemModel* myModel = model();
|
||||
|
||||
// Insert a single row at the end of the collection of items
|
||||
int itemCount = myModel->rowCount(index);
|
||||
if (!myModel->insertRow(itemCount, index))
|
||||
return;
|
||||
|
||||
selectionModel()->setCurrentIndex(myModel->index(0, 0, index), QItemSelectionModel::ClearAndSelect);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimTreeView::slotDeleteItem()
|
||||
{
|
||||
QModelIndex index = currentIndex();
|
||||
QAbstractItemModel* myModel = model();
|
||||
|
||||
if (!myModel->removeRow(index.row(), index.parent()))
|
||||
return;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimTreeView::slotShowWindow()
|
||||
{
|
||||
QModelIndex index = currentIndex();
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
|
||||
RimReservoirView * riv = NULL;
|
||||
if (riv = dynamic_cast<RimReservoirView*>(uiItem->dataObject().p()))
|
||||
{
|
||||
riv->showWindow = true;
|
||||
bool generateDisplayModel = (riv->viewer() == NULL);
|
||||
riv->updateViewerWidget();
|
||||
if (generateDisplayModel)
|
||||
{
|
||||
riv->createDisplayModelAndRedraw();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimTreeView::slotDeletePropertyFilter()
|
||||
{
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
if (myModel)
|
||||
{
|
||||
myModel->removePropertyFilter(currentIndex());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimTreeView::slotDeleteRangeFilter()
|
||||
{
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
if (myModel)
|
||||
{
|
||||
myModel->removeRangeFilter(currentIndex());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimTreeView::slotAddPropertyFilter()
|
||||
{
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
if (myModel)
|
||||
{
|
||||
QModelIndex insertedIndex;
|
||||
RimCellPropertyFilter* propFilter = myModel->addPropertyFilter(currentIndex(), insertedIndex);
|
||||
setCurrentIndex(insertedIndex);
|
||||
if (propFilter)
|
||||
{
|
||||
propFilter->parentContainer()->reservoirView()->createDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimTreeView::slotAddRangeFilter()
|
||||
{
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
if (myModel)
|
||||
{
|
||||
QModelIndex insertedIndex;
|
||||
RimCellRangeFilter* newFilter = myModel->addRangeFilter(currentIndex(), insertedIndex);
|
||||
setCurrentIndex(insertedIndex);
|
||||
|
||||
if (newFilter && newFilter->parentContainer())
|
||||
{
|
||||
newFilter->parentContainer()->reservoirView()->createDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimTreeView::slotAddSliceFilterI()
|
||||
{
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
if (myModel)
|
||||
{
|
||||
QModelIndex insertedIndex;
|
||||
RimCellRangeFilter* rangeFilter = myModel->addRangeFilter(currentIndex(), insertedIndex);
|
||||
|
||||
RimCellRangeFilterCollection* rangeFilterCollection = rangeFilter->parentContainer();
|
||||
rangeFilter->name = QString("Slice I (%1)").arg(rangeFilterCollection->rangeFilters().size());
|
||||
rangeFilter->cellCountI = 1;
|
||||
|
||||
rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED);
|
||||
rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE);
|
||||
|
||||
rangeFilterCollection->reservoirView()->createDisplayModelAndRedraw();
|
||||
|
||||
setCurrentIndex(insertedIndex);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimTreeView::slotAddSliceFilterJ()
|
||||
{
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
if (myModel)
|
||||
{
|
||||
QModelIndex insertedIndex;
|
||||
RimCellRangeFilter* rangeFilter = myModel->addRangeFilter(currentIndex(), insertedIndex);
|
||||
|
||||
RimCellRangeFilterCollection* rangeFilterCollection = rangeFilter->parentContainer();
|
||||
rangeFilter->name = QString("Slice J (%1)").arg(rangeFilterCollection->rangeFilters().size());
|
||||
rangeFilter->cellCountJ = 1;
|
||||
|
||||
rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED);
|
||||
rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE);
|
||||
|
||||
rangeFilterCollection->reservoirView()->createDisplayModelAndRedraw();
|
||||
|
||||
setCurrentIndex(insertedIndex);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimTreeView::slotAddSliceFilterK()
|
||||
{
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
if (myModel)
|
||||
{
|
||||
QModelIndex insertedIndex;
|
||||
RimCellRangeFilter* rangeFilter = myModel->addRangeFilter(currentIndex(), insertedIndex);
|
||||
|
||||
RimCellRangeFilterCollection* rangeFilterCollection = rangeFilter->parentContainer();
|
||||
rangeFilter->name = QString("Slice K (%1)").arg(rangeFilterCollection->rangeFilters().size());
|
||||
rangeFilter->cellCountK = 1;
|
||||
|
||||
rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED);
|
||||
rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE);
|
||||
|
||||
rangeFilterCollection->reservoirView()->createDisplayModelAndRedraw();
|
||||
|
||||
setCurrentIndex(insertedIndex);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimTreeView::slotReadScriptContentFromFile()
|
||||
{
|
||||
QModelIndex index = currentIndex();
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
|
||||
if (uiItem)
|
||||
{
|
||||
RimCalcScript* calcScript = dynamic_cast<RimCalcScript*>(uiItem->dataObject().p());
|
||||
if (calcScript)
|
||||
{
|
||||
calcScript->readContentFromFile();
|
||||
}
|
||||
inputReservoir->openDataFileSet(fileNames);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimTreeView::slotEditScript()
|
||||
{
|
||||
QModelIndex index = currentIndex();
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
|
||||
if (uiItem)
|
||||
{
|
||||
RimCalcScript* calcScript = dynamic_cast<RimCalcScript*>(uiItem->dataObject().p());
|
||||
|
||||
RIApplication* app = RIApplication::instance();
|
||||
QString scriptEditor = app->scriptEditorPath();
|
||||
if (!scriptEditor.isEmpty())
|
||||
{
|
||||
QStringList arguments;
|
||||
arguments << calcScript->absolutePath;
|
||||
|
||||
QProcess* myProcess = new QProcess(this);
|
||||
myProcess->start(scriptEditor, arguments);
|
||||
|
||||
if (!myProcess->waitForStarted(1000))
|
||||
{
|
||||
QMessageBox::warning(RIMainWindow::instance(), "Script editor", "Failed to start script editor executable\n" + scriptEditor);
|
||||
}
|
||||
}
|
||||
}
|
||||
this->rebuildUiSubTree(inputPropertyCollection);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimTreeView::slotNewScript()
|
||||
void RimUiTreeModelPdm::deleteInputProperty(const QModelIndex& itemIndex)
|
||||
{
|
||||
QModelIndex index = currentIndex();
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
|
||||
RimCalcScript* calcScript = NULL;
|
||||
RimScriptCollection * scriptColl = NULL;
|
||||
if (!itemIndex.isValid()) return;
|
||||
|
||||
calcScript = dynamic_cast<RimCalcScript*>(uiItem->dataObject().p());
|
||||
scriptColl = dynamic_cast<RimScriptCollection*>(uiItem->dataObject().p());
|
||||
QString fullPathNewScript;
|
||||
caf::PdmUiTreeItem* uiItem = getTreeItemFromIndex(itemIndex);
|
||||
if (!uiItem) return;
|
||||
|
||||
if (calcScript )
|
||||
{
|
||||
QFileInfo existingScriptFileInfo(calcScript->absolutePath());
|
||||
fullPathNewScript = existingScriptFileInfo.absolutePath();
|
||||
}
|
||||
else if (scriptColl)
|
||||
{
|
||||
fullPathNewScript = scriptColl->directory();
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
caf::PdmObject* object = uiItem->dataObject().p();
|
||||
RimInputProperty* inputProperty = dynamic_cast<RimInputProperty*>(object);
|
||||
if (!inputProperty) return;
|
||||
|
||||
QString fullPathFilenameNewScript;
|
||||
// Remove item from UI tree model before delete of project data structure
|
||||
removeRow(itemIndex.row(), itemIndex.parent());
|
||||
|
||||
fullPathFilenameNewScript = fullPathNewScript + "/untitled.m";
|
||||
int num= 1;
|
||||
while (QFileInfo(fullPathFilenameNewScript).exists())
|
||||
{
|
||||
fullPathFilenameNewScript = fullPathNewScript + "/untitled" + QString::number(num) + ".m";
|
||||
num++;
|
||||
}
|
||||
std::vector<caf::PdmObject*> parentObjects;
|
||||
object->parentObjects(parentObjects);
|
||||
CVF_ASSERT(parentObjects.size() == 1);
|
||||
|
||||
RIApplication* app = RIApplication::instance();
|
||||
QString scriptEditor = app->scriptEditorPath();
|
||||
if (!scriptEditor.isEmpty())
|
||||
{
|
||||
QStringList arguments;
|
||||
arguments << fullPathFilenameNewScript;
|
||||
RimInputPropertyCollection* inputPropertyCollection = dynamic_cast<RimInputPropertyCollection*>(parentObjects[0]);
|
||||
if (!inputPropertyCollection) return;
|
||||
|
||||
QProcess* myProcess = new QProcess(this);
|
||||
myProcess->start(scriptEditor, arguments);
|
||||
std::vector<caf::PdmObject*> parentObjects2;
|
||||
inputPropertyCollection->parentObjects(parentObjects2);
|
||||
CVF_ASSERT(parentObjects2.size() == 1);
|
||||
|
||||
if (!myProcess->waitForStarted(1000))
|
||||
{
|
||||
QMessageBox::warning(RIMainWindow::instance(), "Script editor", "Failed to start script editor executable\n" + scriptEditor);
|
||||
}
|
||||
}
|
||||
RimInputReservoir* inputReservoir = dynamic_cast<RimInputReservoir*>(parentObjects2[0]);
|
||||
if (!inputReservoir) return;
|
||||
|
||||
inputReservoir->removeProperty(inputProperty);
|
||||
|
||||
delete inputProperty;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimTreeView::slotExecuteScript()
|
||||
{
|
||||
QModelIndex index = currentIndex();
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
|
||||
if (uiItem)
|
||||
{
|
||||
RimCalcScript* calcScript = dynamic_cast<RimCalcScript*>(uiItem->dataObject().p());
|
||||
|
||||
RIApplication* app = RIApplication::instance();
|
||||
QString octavePath = app->octavePath();
|
||||
if (!octavePath.isEmpty())
|
||||
{
|
||||
QStringList arguments;
|
||||
|
||||
arguments << calcScript->absolutePath();
|
||||
|
||||
if (!RIApplication::instance()->launchProcess(octavePath, arguments))
|
||||
{
|
||||
QMessageBox::warning(RIMainWindow::instance(), "Script execution", "Failed to start script executable located at\n" + octavePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimTreeView::slotAddView()
|
||||
{
|
||||
QModelIndex index = currentIndex();
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
|
||||
|
||||
RimReservoirView* rimView = dynamic_cast<RimReservoirView*>(uiItem->dataObject().p());
|
||||
if (rimView)
|
||||
{
|
||||
QModelIndex insertedIndex;
|
||||
myModel->addReservoirView(index, insertedIndex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimTreeView::slotDeleteView()
|
||||
{
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
if (myModel)
|
||||
{
|
||||
myModel->removeReservoirView(currentIndex());
|
||||
|
||||
RIApplication* app = RIApplication::instance();
|
||||
app->setActiveReservoirView(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimUiPropertyCreatorPdm::RimUiPropertyCreatorPdm(QObject* parent)
|
||||
: caf::UiPropertyCreatorPdm(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiPropertyCreatorPdm::uiFields(const caf::PdmObject* object, std::vector<caf::PdmFieldHandle*>& fields) const
|
||||
{
|
||||
const RimCellPropertyFilter* propertyFilter = dynamic_cast<const RimCellPropertyFilter*>(object);
|
||||
if (propertyFilter)
|
||||
{
|
||||
caf::UiPropertyCreatorPdm::uiFields(object, fields);
|
||||
|
||||
CVF_ASSERT(propertyFilter->resultDefinition);
|
||||
|
||||
// Append fields from result definition object
|
||||
std::vector<caf::PdmFieldHandle*> childFields;
|
||||
propertyFilter->resultDefinition->fields(childFields);
|
||||
|
||||
size_t i;
|
||||
for (i = 0; i < childFields.size(); i++)
|
||||
{
|
||||
fields.push_back(childFields[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
caf::UiPropertyCreatorPdm::uiFields(object, fields);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -21,14 +21,13 @@
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPointer.h"
|
||||
#include "cafUiTreeModelPdm.h"
|
||||
#include "RimCellRangeFilter.h"
|
||||
|
||||
#include <QTreeView>
|
||||
#include "cafUiPropertyCreatorPdm.h"
|
||||
|
||||
class QFileSystemWatcher;
|
||||
|
||||
class RimCellPropertyFilter;
|
||||
class RimCellRangeFilter;
|
||||
class RimReservoirView;
|
||||
class RimInputProperty;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@@ -45,13 +44,15 @@ public:
|
||||
virtual bool insertRows(int position, int rows, const QModelIndex &parent = QModelIndex());
|
||||
|
||||
// Special edit methods
|
||||
bool removeRangeFilter(const QModelIndex& itemIndex);
|
||||
bool removePropertyFilter(const QModelIndex& itemIndex);
|
||||
bool removeReservoirView(const QModelIndex& itemIndex);
|
||||
|
||||
bool deleteRangeFilter(const QModelIndex& itemIndex);
|
||||
bool deletePropertyFilter(const QModelIndex& itemIndex);
|
||||
bool deleteReservoirView(const QModelIndex& itemIndex);
|
||||
void deleteInputProperty(const QModelIndex& itemIndex);
|
||||
|
||||
RimCellPropertyFilter* addPropertyFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex);
|
||||
RimCellRangeFilter* addRangeFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex);
|
||||
RimReservoirView* addReservoirView(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex);
|
||||
void addInputProperty(const QModelIndex& itemIndex, const QStringList& fileNames);
|
||||
|
||||
void updateScriptPaths();
|
||||
|
||||
@@ -64,50 +65,5 @@ private:
|
||||
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimTreeView : public QTreeView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RimTreeView(QWidget *parent = 0);
|
||||
|
||||
protected:
|
||||
void contextMenuEvent(QContextMenuEvent* event);
|
||||
|
||||
private slots:
|
||||
void slotAddChildItem();
|
||||
void slotDeleteItem();
|
||||
void slotShowWindow();
|
||||
|
||||
void slotAddRangeFilter();
|
||||
void slotAddSliceFilterI();
|
||||
void slotAddSliceFilterJ();
|
||||
void slotAddSliceFilterK();
|
||||
|
||||
void slotAddPropertyFilter();
|
||||
|
||||
void slotDeletePropertyFilter();
|
||||
void slotDeleteRangeFilter();
|
||||
|
||||
void slotReadScriptContentFromFile();
|
||||
void slotEditScript();
|
||||
void slotNewScript();
|
||||
void slotExecuteScript();
|
||||
|
||||
void slotAddView();
|
||||
void slotDeleteView();
|
||||
};
|
||||
|
||||
|
||||
|
||||
class RimUiPropertyCreatorPdm : public caf::UiPropertyCreatorPdm
|
||||
{
|
||||
public:
|
||||
RimUiPropertyCreatorPdm(QObject* parent);
|
||||
|
||||
virtual void uiFields(const caf::PdmObject* object, std::vector<caf::PdmFieldHandle*>& fields) const;
|
||||
};
|
||||
|
||||
707
ApplicationCode/ProjectDataModel/RimUiTreeView.cpp
Normal file
707
ApplicationCode/ProjectDataModel/RimUiTreeView.cpp
Normal file
@@ -0,0 +1,707 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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 "RIStdInclude.h"
|
||||
|
||||
#include "RimUiTreeView.h"
|
||||
#include "RimUiTreeModelPdm.h"
|
||||
#include "RimReservoirView.h"
|
||||
#include "RimCalcScript.h"
|
||||
#include "RIApplication.h"
|
||||
#include "RIMainWindow.h"
|
||||
#include "RimInputPropertyCollection.h"
|
||||
#include "RimExportInputPropertySettings.h"
|
||||
#include "RIPreferencesDialog.h"
|
||||
#include "RifEclipseInputFileTools.h"
|
||||
#include "RimInputReservoir.h"
|
||||
#include "RimBinaryExportSettings.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimUiTreeView::RimUiTreeView(QWidget *parent /*= 0*/)
|
||||
: QTreeView(parent)
|
||||
{
|
||||
setHeaderHidden(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event)
|
||||
{
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
if (myModel)
|
||||
{
|
||||
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
|
||||
if (uiItem && uiItem->dataObject())
|
||||
{
|
||||
// Range filters
|
||||
if (dynamic_cast<RimReservoirView*>(uiItem->dataObject().p()))
|
||||
{
|
||||
QMenu menu;
|
||||
menu.addAction(QString("Show 3D Window"), this, SLOT(slotShowWindow()));
|
||||
menu.addAction(QString("New View"), this, SLOT(slotAddView()));
|
||||
menu.addAction(QString("Delete"), this, SLOT(slotDeleteView()));
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
else if (dynamic_cast<RimCellRangeFilterCollection*>(uiItem->dataObject().p()))
|
||||
{
|
||||
QMenu menu;
|
||||
menu.addAction(QString("New Range Filter"), this, SLOT(slotAddRangeFilter()));
|
||||
menu.addAction(QString("Slice I Filter"), this, SLOT(slotAddSliceFilterI()));
|
||||
menu.addAction(QString("Slice J Filter"), this, SLOT(slotAddSliceFilterJ()));
|
||||
menu.addAction(QString("Slice K Filter"), this, SLOT(slotAddSliceFilterK()));
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
else if (dynamic_cast<RimCellRangeFilter*>(uiItem->dataObject().p()))
|
||||
{
|
||||
QMenu menu;
|
||||
menu.addAction(QString("Insert Range Filter"), this, SLOT(slotAddRangeFilter()));
|
||||
menu.addAction(QString("Slice I Filter"), this, SLOT(slotAddSliceFilterI()));
|
||||
menu.addAction(QString("Slice J Filter"), this, SLOT(slotAddSliceFilterJ()));
|
||||
menu.addAction(QString("Slice K Filter"), this, SLOT(slotAddSliceFilterK()));
|
||||
menu.addSeparator();
|
||||
menu.addAction(QString("Delete"), this, SLOT(slotDeleteRangeFilter()));
|
||||
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
else if (dynamic_cast<RimCellPropertyFilterCollection*>(uiItem->dataObject().p()))
|
||||
{
|
||||
|
||||
QMenu menu;
|
||||
menu.addAction(QString("New Property Filter"), this, SLOT(slotAddPropertyFilter()));
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
else if (dynamic_cast<RimCellPropertyFilter*>(uiItem->dataObject().p()))
|
||||
{
|
||||
|
||||
QMenu menu;
|
||||
menu.addAction(QString("Insert Property Filter"), this, SLOT(slotAddPropertyFilter()));
|
||||
menu.addSeparator();
|
||||
menu.addAction(QString("Delete"), this, SLOT(slotDeletePropertyFilter()));
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
else if (dynamic_cast<RimCalcScript*>(uiItem->dataObject().p()))
|
||||
{
|
||||
RIApplication* app = RIApplication::instance();
|
||||
|
||||
QMenu menu;
|
||||
{
|
||||
QAction* action = menu.addAction(QString("Edit"), this, SLOT(slotEditScript()));
|
||||
if (app->scriptEditorPath().isEmpty())
|
||||
{
|
||||
action->setEnabled(false);
|
||||
}
|
||||
}
|
||||
menu.addAction(QString("New"), this, SLOT(slotNewScript()));
|
||||
//menu.addAction(QString("ReadFromFile"), this, SLOT(slotReadScriptContentFromFile()));
|
||||
menu.addSeparator();
|
||||
|
||||
{
|
||||
QAction* action = menu.addAction(QString("Execute"), this, SLOT(slotExecuteScript()));
|
||||
if (app->octavePath().isEmpty())
|
||||
{
|
||||
action->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
else if (dynamic_cast<RimInputPropertyCollection*>(uiItem->dataObject().p()))
|
||||
{
|
||||
QMenu menu;
|
||||
menu.addAction(QString("Add Input Property"), this, SLOT(slotAddInputProperty()));
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
else if (dynamic_cast<RimInputProperty*>(uiItem->dataObject().p()))
|
||||
{
|
||||
QMenu menu;
|
||||
menu.addAction(QString("Delete"), this, SLOT(slotDeleteObjectFromContainer()));
|
||||
menu.addAction(QString("Write"), this, SLOT(slotWriteInputProperty()));
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
else if (dynamic_cast<RimResultSlot*>(uiItem->dataObject().p()))
|
||||
{
|
||||
QMenu menu;
|
||||
menu.addAction(QString("Write"), this, SLOT(slotWriteBinaryResultAsInputProperty()));
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::slotAddChildItem()
|
||||
{
|
||||
|
||||
QModelIndex index = currentIndex();
|
||||
QAbstractItemModel* myModel = model();
|
||||
|
||||
// Insert a single row at the end of the collection of items
|
||||
int itemCount = myModel->rowCount(index);
|
||||
if (!myModel->insertRow(itemCount, index))
|
||||
return;
|
||||
|
||||
selectionModel()->setCurrentIndex(myModel->index(0, 0, index), QItemSelectionModel::ClearAndSelect);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::slotDeleteItem()
|
||||
{
|
||||
QModelIndex index = currentIndex();
|
||||
QAbstractItemModel* myModel = model();
|
||||
|
||||
if (!myModel->removeRow(index.row(), index.parent()))
|
||||
return;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::slotShowWindow()
|
||||
{
|
||||
QModelIndex index = currentIndex();
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
|
||||
RimReservoirView * riv = NULL;
|
||||
if (riv = dynamic_cast<RimReservoirView*>(uiItem->dataObject().p()))
|
||||
{
|
||||
riv->showWindow = true;
|
||||
bool generateDisplayModel = (riv->viewer() == NULL);
|
||||
riv->updateViewerWidget();
|
||||
if (generateDisplayModel)
|
||||
{
|
||||
riv->createDisplayModelAndRedraw();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::slotDeletePropertyFilter()
|
||||
{
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
if (myModel)
|
||||
{
|
||||
myModel->deletePropertyFilter(currentIndex());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::slotDeleteRangeFilter()
|
||||
{
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
if (myModel)
|
||||
{
|
||||
myModel->deleteRangeFilter(currentIndex());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::slotAddPropertyFilter()
|
||||
{
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
if (myModel)
|
||||
{
|
||||
QModelIndex insertedIndex;
|
||||
RimCellPropertyFilter* propFilter = myModel->addPropertyFilter(currentIndex(), insertedIndex);
|
||||
setCurrentIndex(insertedIndex);
|
||||
if (propFilter)
|
||||
{
|
||||
propFilter->parentContainer()->reservoirView()->createDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::slotAddRangeFilter()
|
||||
{
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
if (myModel)
|
||||
{
|
||||
QModelIndex insertedIndex;
|
||||
RimCellRangeFilter* newFilter = myModel->addRangeFilter(currentIndex(), insertedIndex);
|
||||
setCurrentIndex(insertedIndex);
|
||||
|
||||
if (newFilter && newFilter->parentContainer())
|
||||
{
|
||||
newFilter->parentContainer()->reservoirView()->createDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::slotAddSliceFilterI()
|
||||
{
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
if (myModel)
|
||||
{
|
||||
QModelIndex insertedIndex;
|
||||
RimCellRangeFilter* rangeFilter = myModel->addRangeFilter(currentIndex(), insertedIndex);
|
||||
|
||||
RimCellRangeFilterCollection* rangeFilterCollection = rangeFilter->parentContainer();
|
||||
rangeFilter->name = QString("Slice I (%1)").arg(rangeFilterCollection->rangeFilters().size());
|
||||
rangeFilter->cellCountI = 1;
|
||||
|
||||
rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED);
|
||||
rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE);
|
||||
|
||||
rangeFilterCollection->reservoirView()->createDisplayModelAndRedraw();
|
||||
|
||||
setCurrentIndex(insertedIndex);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::slotAddSliceFilterJ()
|
||||
{
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
if (myModel)
|
||||
{
|
||||
QModelIndex insertedIndex;
|
||||
RimCellRangeFilter* rangeFilter = myModel->addRangeFilter(currentIndex(), insertedIndex);
|
||||
|
||||
RimCellRangeFilterCollection* rangeFilterCollection = rangeFilter->parentContainer();
|
||||
rangeFilter->name = QString("Slice J (%1)").arg(rangeFilterCollection->rangeFilters().size());
|
||||
rangeFilter->cellCountJ = 1;
|
||||
|
||||
rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED);
|
||||
rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE);
|
||||
|
||||
rangeFilterCollection->reservoirView()->createDisplayModelAndRedraw();
|
||||
|
||||
setCurrentIndex(insertedIndex);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::slotAddSliceFilterK()
|
||||
{
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
if (myModel)
|
||||
{
|
||||
QModelIndex insertedIndex;
|
||||
RimCellRangeFilter* rangeFilter = myModel->addRangeFilter(currentIndex(), insertedIndex);
|
||||
|
||||
RimCellRangeFilterCollection* rangeFilterCollection = rangeFilter->parentContainer();
|
||||
rangeFilter->name = QString("Slice K (%1)").arg(rangeFilterCollection->rangeFilters().size());
|
||||
rangeFilter->cellCountK = 1;
|
||||
|
||||
rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED);
|
||||
rangeFilterCollection->reservoirView()->scheduleGeometryRegen(RivReservoirViewPartMgr::RANGE_FILTERED_INACTIVE);
|
||||
|
||||
rangeFilterCollection->reservoirView()->createDisplayModelAndRedraw();
|
||||
|
||||
setCurrentIndex(insertedIndex);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::slotReadScriptContentFromFile()
|
||||
{
|
||||
QModelIndex index = currentIndex();
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
|
||||
if (uiItem)
|
||||
{
|
||||
RimCalcScript* calcScript = dynamic_cast<RimCalcScript*>(uiItem->dataObject().p());
|
||||
if (calcScript)
|
||||
{
|
||||
calcScript->readContentFromFile();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::slotEditScript()
|
||||
{
|
||||
QModelIndex index = currentIndex();
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
|
||||
if (uiItem)
|
||||
{
|
||||
RimCalcScript* calcScript = dynamic_cast<RimCalcScript*>(uiItem->dataObject().p());
|
||||
|
||||
RIApplication* app = RIApplication::instance();
|
||||
QString scriptEditor = app->scriptEditorPath();
|
||||
if (!scriptEditor.isEmpty())
|
||||
{
|
||||
QStringList arguments;
|
||||
arguments << calcScript->absolutePath;
|
||||
|
||||
QProcess* myProcess = new QProcess(this);
|
||||
myProcess->start(scriptEditor, arguments);
|
||||
|
||||
if (!myProcess->waitForStarted(1000))
|
||||
{
|
||||
QMessageBox::warning(RIMainWindow::instance(), "Script editor", "Failed to start script editor executable\n" + scriptEditor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::slotNewScript()
|
||||
{
|
||||
QModelIndex index = currentIndex();
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
|
||||
RimCalcScript* calcScript = NULL;
|
||||
RimScriptCollection * scriptColl = NULL;
|
||||
|
||||
calcScript = dynamic_cast<RimCalcScript*>(uiItem->dataObject().p());
|
||||
scriptColl = dynamic_cast<RimScriptCollection*>(uiItem->dataObject().p());
|
||||
QString fullPathNewScript;
|
||||
|
||||
if (calcScript )
|
||||
{
|
||||
QFileInfo existingScriptFileInfo(calcScript->absolutePath());
|
||||
fullPathNewScript = existingScriptFileInfo.absolutePath();
|
||||
}
|
||||
else if (scriptColl)
|
||||
{
|
||||
fullPathNewScript = scriptColl->directory();
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QString fullPathFilenameNewScript;
|
||||
|
||||
fullPathFilenameNewScript = fullPathNewScript + "/untitled.m";
|
||||
int num= 1;
|
||||
while (QFileInfo(fullPathFilenameNewScript).exists())
|
||||
{
|
||||
fullPathFilenameNewScript = fullPathNewScript + "/untitled" + QString::number(num) + ".m";
|
||||
num++;
|
||||
}
|
||||
|
||||
RIApplication* app = RIApplication::instance();
|
||||
QString scriptEditor = app->scriptEditorPath();
|
||||
if (!scriptEditor.isEmpty())
|
||||
{
|
||||
QStringList arguments;
|
||||
arguments << fullPathFilenameNewScript;
|
||||
|
||||
QProcess* myProcess = new QProcess(this);
|
||||
myProcess->start(scriptEditor, arguments);
|
||||
|
||||
if (!myProcess->waitForStarted(1000))
|
||||
{
|
||||
QMessageBox::warning(RIMainWindow::instance(), "Script editor", "Failed to start script editor executable\n" + scriptEditor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::slotExecuteScript()
|
||||
{
|
||||
QModelIndex index = currentIndex();
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
|
||||
if (uiItem)
|
||||
{
|
||||
RimCalcScript* calcScript = dynamic_cast<RimCalcScript*>(uiItem->dataObject().p());
|
||||
|
||||
RIApplication* app = RIApplication::instance();
|
||||
QString octavePath = app->octavePath();
|
||||
if (!octavePath.isEmpty())
|
||||
{
|
||||
QStringList arguments;
|
||||
arguments.append("-q");
|
||||
arguments << calcScript->absolutePath();
|
||||
|
||||
if (!RIApplication::instance()->launchProcess(octavePath, arguments))
|
||||
{
|
||||
QMessageBox::warning(RIMainWindow::instance(), "Script execution", "Failed to start script executable located at\n" + octavePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::slotAddView()
|
||||
{
|
||||
QModelIndex index = currentIndex();
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
|
||||
|
||||
RimReservoirView* rimView = dynamic_cast<RimReservoirView*>(uiItem->dataObject().p());
|
||||
if (rimView)
|
||||
{
|
||||
QModelIndex insertedIndex;
|
||||
myModel->addReservoirView(index, insertedIndex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::slotDeleteView()
|
||||
{
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
if (myModel)
|
||||
{
|
||||
myModel->deleteReservoirView(currentIndex());
|
||||
|
||||
RIApplication* app = RIApplication::instance();
|
||||
app->setActiveReservoirView(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::slotSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected)
|
||||
{
|
||||
caf::PdmObject* pdmObject = NULL;
|
||||
|
||||
if (selected.indexes().size() == 1)
|
||||
{
|
||||
QModelIndex mi = selected.indexes()[0];
|
||||
if (mi.isValid())
|
||||
{
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
if (myModel)
|
||||
{
|
||||
caf::PdmUiTreeItem* treeItem = myModel->getTreeItemFromIndex(mi);
|
||||
if (treeItem && treeItem->dataObject())
|
||||
{
|
||||
pdmObject = treeItem->dataObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
emit selectedObjectChanged(pdmObject);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::setModel(QAbstractItemModel* model)
|
||||
{
|
||||
QTreeView::setModel(model);
|
||||
|
||||
if (selectionModel())
|
||||
{
|
||||
connect(selectionModel(), SIGNAL(selectionChanged( const QItemSelection & , const QItemSelection & )), SLOT(slotSelectionChanged( const QItemSelection & , const QItemSelection & )));
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::slotAddInputProperty()
|
||||
{
|
||||
QStringList fileNames = QFileDialog::getOpenFileNames(this, "Select Eclipse Input Property Files", NULL, "All Files (*.* *)");
|
||||
if (fileNames.isEmpty()) return;
|
||||
|
||||
QModelIndex index = currentIndex();
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
|
||||
|
||||
RimInputPropertyCollection* inputPropertyCollection = dynamic_cast<RimInputPropertyCollection*>(uiItem->dataObject().p());
|
||||
if (inputPropertyCollection)
|
||||
{
|
||||
myModel->addInputProperty(index, fileNames);
|
||||
|
||||
setCurrentIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::slotDeleteObjectFromContainer()
|
||||
{
|
||||
QModelIndex index = currentIndex();
|
||||
if (!index.isValid()) return;
|
||||
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
if (myModel) myModel->deleteInputProperty(index);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::slotWriteInputProperty()
|
||||
{
|
||||
QModelIndex index = currentIndex();
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
|
||||
|
||||
RimInputProperty* inputProperty = dynamic_cast<RimInputProperty*>(uiItem->dataObject().p());
|
||||
if (!inputProperty) return;
|
||||
|
||||
{
|
||||
bool isResolved = false;
|
||||
if (inputProperty->resolvedState == RimInputProperty::RESOLVED || inputProperty->resolvedState == RimInputProperty::RESOLVED_NOT_SAVED)
|
||||
{
|
||||
isResolved = true;
|
||||
}
|
||||
|
||||
if (!isResolved)
|
||||
{
|
||||
QMessageBox::warning(RIMainWindow::instance(), "Export failure", "Property is not resolved, and then it is not possible to export the property.");
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
RimExportInputSettings exportSettings;
|
||||
exportSettings.eclipseKeyword = inputProperty->eclipseKeyword;
|
||||
|
||||
// Find input reservoir for this property
|
||||
RimInputReservoir* inputReservoir = NULL;
|
||||
{
|
||||
std::vector<caf::PdmObject*> parentObjects;
|
||||
inputProperty->parentObjects(parentObjects);
|
||||
CVF_ASSERT(parentObjects.size() == 1);
|
||||
|
||||
RimInputPropertyCollection* inputPropertyCollection = dynamic_cast<RimInputPropertyCollection*>(parentObjects[0]);
|
||||
if (!inputPropertyCollection) return;
|
||||
|
||||
std::vector<caf::PdmObject*> parentObjects2;
|
||||
inputPropertyCollection->parentObjects(parentObjects2);
|
||||
CVF_ASSERT(parentObjects2.size() == 1);
|
||||
|
||||
inputReservoir = dynamic_cast<RimInputReservoir*>(parentObjects2[0]);
|
||||
}
|
||||
|
||||
if (!inputReservoir) return;
|
||||
|
||||
{
|
||||
QString projectFolder;
|
||||
|
||||
RIApplication* app = RIApplication::instance();
|
||||
QString projectFileName = app->currentProjectFileName();
|
||||
if (!projectFileName.isEmpty())
|
||||
{
|
||||
QFileInfo fi(projectFileName);
|
||||
projectFolder = fi.absolutePath();
|
||||
}
|
||||
else
|
||||
{
|
||||
projectFolder = inputReservoir->locationOnDisc();
|
||||
}
|
||||
|
||||
QString outputFileName = projectFolder + "/" + inputProperty->eclipseKeyword;
|
||||
|
||||
exportSettings.fileName = outputFileName;
|
||||
}
|
||||
|
||||
RIPreferencesDialog preferencesDialog(this, &exportSettings, "Export Eclipse Property to Text File");
|
||||
if (preferencesDialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
bool isOk = RifEclipseInputFileTools::writePropertyToTextFile(exportSettings.fileName, inputReservoir->reservoirData(), 0, inputProperty->resultName, exportSettings.eclipseKeyword);
|
||||
if (isOk)
|
||||
{
|
||||
inputProperty->fileName = exportSettings.fileName;
|
||||
inputProperty->eclipseKeyword = exportSettings.eclipseKeyword;
|
||||
inputProperty->resolvedState = RimInputProperty::RESOLVED;
|
||||
|
||||
inputProperty->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::slotWriteBinaryResultAsInputProperty()
|
||||
{
|
||||
QModelIndex index = currentIndex();
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
|
||||
|
||||
RimResultSlot* resultSlot = dynamic_cast<RimResultSlot*>(uiItem->dataObject().p());
|
||||
if (!resultSlot) return;
|
||||
if (!resultSlot->reservoirView()) return;
|
||||
if (!resultSlot->reservoirView()->eclipseCase()) return;
|
||||
if (!resultSlot->reservoirView()->eclipseCase()->reservoirData()) return;
|
||||
|
||||
RimBinaryExportSettings exportSettings;
|
||||
exportSettings.eclipseKeyword = resultSlot->resultVariable;
|
||||
|
||||
{
|
||||
QString projectFolder;
|
||||
|
||||
RIApplication* app = RIApplication::instance();
|
||||
QString projectFileName = app->currentProjectFileName();
|
||||
if (!projectFileName.isEmpty())
|
||||
{
|
||||
QFileInfo fi(projectFileName);
|
||||
projectFolder = fi.absolutePath();
|
||||
}
|
||||
else
|
||||
{
|
||||
projectFolder = resultSlot->reservoirView()->eclipseCase()->locationOnDisc();
|
||||
}
|
||||
|
||||
QString outputFileName = projectFolder + "/" + resultSlot->resultVariable;
|
||||
|
||||
exportSettings.fileName = outputFileName;
|
||||
}
|
||||
|
||||
RIPreferencesDialog preferencesDialog(this, &exportSettings, "Export Binary Eclipse Data to Text File");
|
||||
if (preferencesDialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
size_t timeStep = resultSlot->reservoirView()->currentTimeStep();
|
||||
bool isOk = RifEclipseInputFileTools::writeBinaryResultToTextFile(exportSettings.fileName, resultSlot->reservoirView()->eclipseCase()->reservoirData(), timeStep, resultSlot->resultVariable, exportSettings.eclipseKeyword, exportSettings.undefinedValue);
|
||||
if (!isOk)
|
||||
{
|
||||
QMessageBox::critical(NULL, "File export", "Failed to exported current result to " + exportSettings.fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
77
ApplicationCode/ProjectDataModel/RimUiTreeView.h
Normal file
77
ApplicationCode/ProjectDataModel/RimUiTreeView.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// 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 "cafPdmObject.h"
|
||||
|
||||
#include <QTreeView>
|
||||
|
||||
class QItemSelection;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimUiTreeView : public QTreeView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RimUiTreeView(QWidget *parent = 0);
|
||||
|
||||
virtual void setModel(QAbstractItemModel* model);
|
||||
|
||||
protected:
|
||||
void contextMenuEvent(QContextMenuEvent* event);
|
||||
|
||||
private slots:
|
||||
void slotAddChildItem();
|
||||
void slotDeleteItem();
|
||||
void slotShowWindow();
|
||||
|
||||
void slotAddRangeFilter();
|
||||
void slotAddSliceFilterI();
|
||||
void slotAddSliceFilterJ();
|
||||
void slotAddSliceFilterK();
|
||||
void slotDeleteRangeFilter();
|
||||
|
||||
void slotAddPropertyFilter();
|
||||
void slotDeletePropertyFilter();
|
||||
|
||||
void slotReadScriptContentFromFile();
|
||||
void slotEditScript();
|
||||
void slotNewScript();
|
||||
void slotExecuteScript();
|
||||
|
||||
void slotAddView();
|
||||
void slotDeleteView();
|
||||
|
||||
void slotAddInputProperty();
|
||||
void slotDeleteObjectFromContainer();
|
||||
void slotWriteInputProperty();
|
||||
void slotWriteBinaryResultAsInputProperty();
|
||||
|
||||
void slotSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected);
|
||||
|
||||
signals:
|
||||
void selectedObjectChanged( caf::PdmObject* pdmObject );
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -49,7 +49,8 @@ RimWell::RimWell()
|
||||
|
||||
|
||||
|
||||
name.setHidden(true);
|
||||
name.setUiHidden(true);
|
||||
name.setUiReadOnly(true);
|
||||
|
||||
m_reservoirView = NULL;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,10 @@ RimWellCollection::RimWellCollection()
|
||||
CAF_PDM_InitField(&wellHeadScaleFactor, "WellHeadScale", 1.0, " Well head scale", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&wellPipeVisibility, "GlobalWellPipeVisibility", WellVisibilityEnum(ALL_ON), "Global well pipe visibility", "", "", "");
|
||||
CAF_PDM_InitField(&pipeRadiusScaleFactor, "WellPipeRadiusScale", 0.1, " Pipe radius scale", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&pipeRadiusScaleFactor, "WellPipeRadiusScale", 0.1, " Pipe radius scale", "", "", "");
|
||||
CAF_PDM_InitField(&pipeCrossSectionVertexCount, "WellPipeVertexCount", 12, "Pipe vertex count", "", "", "");
|
||||
pipeCrossSectionVertexCount.setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitField(&wellCellVisibility, "GlobalWellCellVisibility", WellVisibilityEnum(FORCE_ALL_OFF), "Add cells to range filter", "", "", "");
|
||||
CAF_PDM_InitField(&showWellCellFences, "ShowWellFences", false, " Use well fence", "", "", "");
|
||||
@@ -74,6 +77,8 @@ RimWellCollection::RimWellCollection()
|
||||
|
||||
CAF_PDM_InitField(&wellCellTransparencyLevel, "WellCellTransparency", 0.5, "Well cell transparency", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&isAutoDetectingBranches, "IsAutoDetectingBranches", true, "Geometry based branch detection", "", "Toggle wether the well pipe visualization will try to detect when a part of the well \nis really a branch, and thus is starting from wellhead", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&wells, "Wells", "Wells", "", "", "");
|
||||
|
||||
m_reservoirView = NULL;
|
||||
@@ -84,7 +89,7 @@ RimWellCollection::RimWellCollection()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellCollection::~RimWellCollection()
|
||||
{
|
||||
wells.deleteChildren();
|
||||
wells.deleteAllChildObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -199,7 +204,11 @@ void RimWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField
|
||||
m_reservoirView->createDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
else if (&pipeRadiusScaleFactor == changedField || &wellHeadScaleFactor == changedField || &showWellHead == changedField)
|
||||
else if ( &pipeCrossSectionVertexCount == changedField
|
||||
|| &pipeRadiusScaleFactor == changedField
|
||||
|| &wellHeadScaleFactor == changedField
|
||||
|| &showWellHead == changedField
|
||||
|| &isAutoDetectingBranches == changedField)
|
||||
{
|
||||
if (m_reservoirView)
|
||||
{
|
||||
|
||||
@@ -68,9 +68,13 @@ public:
|
||||
|
||||
caf::PdmField<WellVisibilityEnum> wellPipeVisibility;
|
||||
caf::PdmField<double> pipeRadiusScaleFactor;
|
||||
caf::PdmField<int> pipeCrossSectionVertexCount;
|
||||
|
||||
caf::PdmField<double> wellHeadScaleFactor;
|
||||
caf::PdmField<bool> showWellHead;
|
||||
|
||||
caf::PdmField<bool> isAutoDetectingBranches;
|
||||
|
||||
caf::PdmPointersField<RimWell*> wells;
|
||||
|
||||
RimWell* findWell(QString name);
|
||||
|
||||
Reference in New Issue
Block a user