mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Added context menu items for adding new statistical case
p4#: 20523
This commit is contained in:
parent
67cab9448e
commit
c92e822f3f
@ -22,6 +22,7 @@
|
||||
#include "RimReservoir.h"
|
||||
#include "RimReservoirView.h"
|
||||
#include "RigEclipseCase.h"
|
||||
#include "RimStatisticalCalculation.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimIdenticalGridCaseGroup, "RimIdenticalGridCaseGroup");
|
||||
@ -34,6 +35,12 @@ RimIdenticalGridCaseGroup::RimIdenticalGridCaseGroup()
|
||||
CAF_PDM_InitObject("Identical Grids", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&reservoirs, "Reservoirs", "", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&statisticalReservoirs, "StatisticalReservoirs", "", "", "", "");
|
||||
|
||||
RimStatisticalCalculation* dummyStat = new RimStatisticalCalculation;
|
||||
dummyStat->caseName = "Statistics 1";
|
||||
|
||||
statisticalReservoirs.push_back(dummyStat);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -81,3 +88,17 @@ RigMainGrid* RimIdenticalGridCaseGroup::mainGrid()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimStatisticalCalculation* RimIdenticalGridCaseGroup::createAndAppendStatisticalCalculation()
|
||||
{
|
||||
RimStatisticalCalculation* newObject = new RimStatisticalCalculation;
|
||||
|
||||
newObject->caseName = "Statistics 1";
|
||||
|
||||
statisticalReservoirs.push_back(newObject);
|
||||
|
||||
return newObject;
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
class RimReservoir;
|
||||
class RigMainGrid;
|
||||
class RimStatisticalCalculation;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
@ -42,9 +43,11 @@ public:
|
||||
void addCase(RimReservoir* reservoir);
|
||||
|
||||
caf::PdmPointersField<RimReservoir*> reservoirs;
|
||||
caf::PdmPointersField<RimReservoir*> statisticalReservoirs;
|
||||
|
||||
RigMainGrid* mainGrid();
|
||||
|
||||
RimStatisticalCalculation* createAndAppendStatisticalCalculation();
|
||||
private:
|
||||
cvf::ref<RigMainGrid> m_mainGrid;
|
||||
|
||||
|
@ -20,6 +20,8 @@
|
||||
|
||||
#include "RimStatisticalCalculation.h"
|
||||
#include "RimReservoirView.h"
|
||||
#include "cafPdmUiOrdering.h"
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimStatisticalCalculation, "RimStatisticalCalculation");
|
||||
@ -34,6 +36,7 @@ RimStatisticalCalculation::RimStatisticalCalculation()
|
||||
CAF_PDM_InitField(&statisticsMax, "StatisticsMax", true, "Maximum", "", "" ,"");
|
||||
CAF_PDM_InitField(&statisticsMean, "StatisticsMean", true, "Mean", "", "" ,"");
|
||||
CAF_PDM_InitField(&statisticsStdDev, "StatisticsStdDev", true, "Std dev", "", "" ,"");
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -51,3 +54,100 @@ bool RimStatisticalCalculation::openEclipseGridFile()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimStatisticalCalculation::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const
|
||||
{
|
||||
// Fields declared in RimCellFilter
|
||||
uiOrdering.add(&caseName);
|
||||
|
||||
// Fields declared in RimResultDefinition
|
||||
caf::PdmUiGroup* group1 = uiOrdering.addNewGroup("Statistical parameters");
|
||||
group1->add(&statisticsMin);
|
||||
group1->add(&statisticsMax);
|
||||
group1->add(&statisticsMean);
|
||||
group1->add(&statisticsStdDev);
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimIdenticalGridCaseGroup* RimStatisticalCalculation::parent()
|
||||
{
|
||||
std::vector<caf::PdmObject*> parentObjects;
|
||||
this->parentObjects(parentObjects);
|
||||
|
||||
RimIdenticalGridCaseGroup* parentObject = NULL;
|
||||
for (size_t i = 0; i < parentObjects.size(); i++)
|
||||
{
|
||||
if (parentObject) continue;
|
||||
|
||||
caf::PdmObject* obj = parentObjects[i];
|
||||
parentObject = dynamic_cast<RimIdenticalGridCaseGroup*>(obj);
|
||||
}
|
||||
|
||||
CVF_ASSERT(parentObject);
|
||||
|
||||
return parentObject;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimStatisticalCalculation::computeStatistics()
|
||||
{
|
||||
if (statisticsMin)
|
||||
{
|
||||
createAndComputeMin();
|
||||
}
|
||||
|
||||
if (statisticsMax)
|
||||
{
|
||||
createAndComputeMax();
|
||||
}
|
||||
|
||||
if (statisticsMean)
|
||||
{
|
||||
createAndComputeMean();
|
||||
}
|
||||
|
||||
if (statisticsStdDev)
|
||||
{
|
||||
createAndComputeStdDev();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimStatisticalCalculation::createAndComputeMin()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimStatisticalCalculation::createAndComputeMax()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimStatisticalCalculation::createAndComputeMean()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimStatisticalCalculation::createAndComputeStdDev()
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -25,6 +25,9 @@
|
||||
|
||||
#include "RimReservoir.h"
|
||||
|
||||
class RimIdenticalGridCaseGroup;
|
||||
class RimResultDefinition;
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
@ -46,6 +49,15 @@ public:
|
||||
caf::PdmField<bool> statisticsMean;
|
||||
caf::PdmField<bool> statisticsStdDev;
|
||||
|
||||
RimIdenticalGridCaseGroup* parent();
|
||||
|
||||
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) const;
|
||||
void computeStatistics();
|
||||
|
||||
private:
|
||||
void createAndComputeMin();
|
||||
void createAndComputeMax();
|
||||
void createAndComputeMean();
|
||||
void createAndComputeStdDev();
|
||||
|
||||
};
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "RimInputPropertyCollection.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "RimInputReservoir.h"
|
||||
#include "RimStatisticalCalculation.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -442,3 +443,43 @@ void RimUiTreeModelPdm::deleteInputProperty(const QModelIndex& itemIndex)
|
||||
delete inputProperty;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimStatisticalCalculation* RimUiTreeModelPdm::addStatisticalCalculation(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex)
|
||||
{
|
||||
caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex);
|
||||
|
||||
QModelIndex collectionIndex;
|
||||
RimIdenticalGridCaseGroup* caseGroup = NULL;
|
||||
caf::PdmUiTreeItem* parentCollectionItem = NULL;
|
||||
int position = 0;
|
||||
|
||||
if (dynamic_cast<RimStatisticalCalculation*>(currentItem->dataObject().p()))
|
||||
{
|
||||
RimStatisticalCalculation* currentObject = dynamic_cast<RimStatisticalCalculation*>(currentItem->dataObject().p());
|
||||
caseGroup = currentObject->parent();
|
||||
parentCollectionItem = currentItem->parent();
|
||||
position = itemIndex.row();
|
||||
collectionIndex = itemIndex.parent();
|
||||
}
|
||||
else if (dynamic_cast<RimIdenticalGridCaseGroup*>(currentItem->dataObject().p()))
|
||||
{
|
||||
caseGroup = dynamic_cast<RimIdenticalGridCaseGroup*>(currentItem->dataObject().p());
|
||||
parentCollectionItem = currentItem;
|
||||
position = parentCollectionItem->childCount();
|
||||
collectionIndex = itemIndex;
|
||||
}
|
||||
|
||||
beginInsertRows(collectionIndex, position, position);
|
||||
|
||||
RimStatisticalCalculation* createdObject = caseGroup->createAndAppendStatisticalCalculation();
|
||||
caf::PdmUiTreeItem* childItem = new caf::PdmUiTreeItem(parentCollectionItem, position, createdObject);
|
||||
|
||||
endInsertRows();
|
||||
|
||||
insertedModelIndex = index(position, 0, collectionIndex);
|
||||
|
||||
return createdObject;
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ class RimCellPropertyFilter;
|
||||
class RimCellRangeFilter;
|
||||
class RimReservoirView;
|
||||
class RimInputProperty;
|
||||
class RimStatisticalCalculation;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -55,6 +56,8 @@ public:
|
||||
RimReservoirView* addReservoirView(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex);
|
||||
void addInputProperty(const QModelIndex& itemIndex, const QStringList& fileNames);
|
||||
|
||||
RimStatisticalCalculation* addStatisticalCalculation(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex);
|
||||
|
||||
void updateScriptPaths();
|
||||
|
||||
private slots:
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "RimInputReservoir.h"
|
||||
#include "RimBinaryExportSettings.h"
|
||||
#include "RigReservoirCellResults.h"
|
||||
#include "RimStatisticalCalculation.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -143,6 +144,19 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event)
|
||||
menu.addAction(QString("Save Property To File"), this, SLOT(slotWriteBinaryResultAsInputProperty()));
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
else if (dynamic_cast<RimIdenticalGridCaseGroup*>(uiItem->dataObject().p()))
|
||||
{
|
||||
QMenu menu;
|
||||
menu.addAction(QString("New Statistical Case"), this, SLOT(slotNewStatisticalCase()));
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
else if (dynamic_cast<RimStatisticalCalculation*>(uiItem->dataObject().p()))
|
||||
{
|
||||
QMenu menu;
|
||||
menu.addAction(QString("Compute"), this, SLOT(slotComputeStatisticalCases()));
|
||||
menu.addAction(QString("Close"), this, SLOT(slotCloseCase()));
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
else if (dynamic_cast<RimReservoir*>(uiItem->dataObject().p()))
|
||||
{
|
||||
QMenu menu;
|
||||
@ -750,3 +764,32 @@ void RimUiTreeView::slotCloseCase()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::slotNewStatisticalCase()
|
||||
{
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
if (myModel)
|
||||
{
|
||||
QModelIndex insertedIndex;
|
||||
RimStatisticalCalculation* newObject = myModel->addStatisticalCalculation(currentIndex(), insertedIndex);
|
||||
setCurrentIndex(insertedIndex);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::slotComputeStatisticalCases()
|
||||
{
|
||||
QModelIndex index = currentIndex();
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex());
|
||||
|
||||
RimStatisticalCalculation* statisticalObject = dynamic_cast<RimStatisticalCalculation*>(uiItem->dataObject().p());
|
||||
if (!statisticalObject) return;
|
||||
|
||||
statisticalObject->computeStatistics();
|
||||
}
|
||||
|
||||
|
@ -69,6 +69,9 @@ private slots:
|
||||
|
||||
void slotCloseCase();
|
||||
|
||||
void slotNewStatisticalCase();
|
||||
void slotComputeStatisticalCases();
|
||||
|
||||
void slotSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected);
|
||||
|
||||
signals:
|
||||
|
Loading…
Reference in New Issue
Block a user