2017-03-19 02:53:15 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2017 Statoil ASA
|
|
|
|
//
|
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicNewGridTimeHistoryCurveFeature.h"
|
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
|
|
|
|
|
|
|
#include "RicNewSummaryCurveFeature.h"
|
2017-03-19 15:41:13 -05:00
|
|
|
#include "RicSelectSummaryPlotUI.h"
|
2017-03-19 02:53:15 -05:00
|
|
|
#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h"
|
|
|
|
|
|
|
|
#include "RimGridTimeHistoryCurve.h"
|
|
|
|
#include "RimMainPlotCollection.h"
|
|
|
|
#include "RimProject.h"
|
2017-03-19 15:41:13 -05:00
|
|
|
#include "RimSummaryCaseCollection.h"
|
2017-03-19 02:53:15 -05:00
|
|
|
#include "RimSummaryPlot.h"
|
|
|
|
#include "RimSummaryPlotCollection.h"
|
|
|
|
|
|
|
|
#include "RiuMainPlotWindow.h"
|
|
|
|
#include "RiuSelectionManager.h"
|
|
|
|
|
2017-03-19 15:41:13 -05:00
|
|
|
#include "cafPdmReferenceHelper.h"
|
|
|
|
#include "cafPdmUiPropertyViewDialog.h"
|
2017-03-19 02:53:15 -05:00
|
|
|
|
2017-03-19 15:41:13 -05:00
|
|
|
#include "cvfAssert.h"
|
2017-03-19 02:53:15 -05:00
|
|
|
#include "cvfColor3.h"
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
|
|
|
|
|
|
|
CAF_CMD_SOURCE_INIT(RicNewGridTimeHistoryCurveFeature, "RicNewGridTimeHistoryCurveFeature");
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-03-19 15:41:13 -05:00
|
|
|
void RicNewGridTimeHistoryCurveFeature::createCurveFromSelectionItem(const RiuSelectionItem* selectionItem, RimSummaryPlot* plot)
|
|
|
|
{
|
|
|
|
CVF_ASSERT(selectionItem);
|
|
|
|
CVF_ASSERT(plot);
|
|
|
|
|
|
|
|
RimGridTimeHistoryCurve* newCurve = new RimGridTimeHistoryCurve();
|
|
|
|
newCurve->setFromSelectionItem(selectionItem);
|
|
|
|
newCurve->setYAxis(RimDefines::PLOT_AXIS_RIGHT);
|
|
|
|
newCurve->setLineThickness(2);
|
|
|
|
|
|
|
|
cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable(plot->curveCount());
|
|
|
|
newCurve->setColor(curveColor);
|
|
|
|
|
|
|
|
plot->addGridTimeHistoryCurve(newCurve);
|
|
|
|
|
|
|
|
newCurve->loadDataAndUpdate();
|
|
|
|
|
|
|
|
plot->updateConnectedEditors();
|
|
|
|
|
|
|
|
RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(newCurve);
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimSummaryPlot* RicNewGridTimeHistoryCurveFeature::userSelectedSummaryPlot()
|
2017-03-19 02:53:15 -05:00
|
|
|
{
|
2017-03-19 15:41:13 -05:00
|
|
|
const QString lastUsedViewKey("lastUsedSummaryPlotKey");
|
|
|
|
|
2017-03-19 02:53:15 -05:00
|
|
|
RimProject* project = RiaApplication::instance()->project();
|
|
|
|
CVF_ASSERT(project);
|
|
|
|
|
|
|
|
RimMainPlotCollection* mainPlotColl = project->mainPlotCollection();
|
|
|
|
CVF_ASSERT(mainPlotColl);
|
|
|
|
|
|
|
|
RimSummaryPlotCollection* summaryPlotColl = mainPlotColl->summaryPlotCollection();
|
|
|
|
CVF_ASSERT(summaryPlotColl);
|
|
|
|
|
2017-03-19 15:41:13 -05:00
|
|
|
RimSummaryPlot* defaultSelectedPlot = nullptr;
|
2017-03-19 02:53:15 -05:00
|
|
|
{
|
2017-03-19 15:41:13 -05:00
|
|
|
QString lastUsedPlotRef = RiaApplication::instance()->cacheDataObject(lastUsedViewKey).toString();
|
|
|
|
RimSummaryPlot* lastUsedPlot = dynamic_cast<RimSummaryPlot*>(caf::PdmReferenceHelper::objectFromReference(RiaApplication::instance()->project(), lastUsedPlotRef));
|
|
|
|
if (lastUsedPlot)
|
|
|
|
{
|
|
|
|
defaultSelectedPlot = lastUsedPlot;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!defaultSelectedPlot)
|
|
|
|
{
|
|
|
|
defaultSelectedPlot = RiaApplication::instance()->activeSummaryPlot();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!defaultSelectedPlot && summaryPlotColl->summaryPlots().size() > 0)
|
|
|
|
{
|
|
|
|
defaultSelectedPlot = summaryPlotColl->summaryPlots()[0];
|
|
|
|
}
|
2017-03-19 02:53:15 -05:00
|
|
|
}
|
|
|
|
|
2017-03-19 15:41:13 -05:00
|
|
|
RicSelectSummaryPlotUI featureUi;
|
|
|
|
if (defaultSelectedPlot)
|
2017-03-19 02:53:15 -05:00
|
|
|
{
|
2017-03-19 15:41:13 -05:00
|
|
|
featureUi.setDefaultSummaryPlot(defaultSelectedPlot);
|
|
|
|
}
|
2017-03-19 02:53:15 -05:00
|
|
|
|
2017-03-19 15:41:13 -05:00
|
|
|
caf::PdmUiPropertyViewDialog propertyDialog(NULL, &featureUi, "Select Summary Plot", "");
|
|
|
|
propertyDialog.resize(QSize(400, 200));
|
2017-03-19 02:53:15 -05:00
|
|
|
|
2017-03-19 15:41:13 -05:00
|
|
|
if (propertyDialog.exec() != QDialog::Accepted) return nullptr;
|
2017-03-19 02:53:15 -05:00
|
|
|
|
2017-03-19 15:41:13 -05:00
|
|
|
RimSummaryPlot* summaryPlot = nullptr;
|
|
|
|
if (featureUi.createNewPlot())
|
|
|
|
{
|
|
|
|
RimSummaryPlot* plot = new RimSummaryPlot();
|
|
|
|
summaryPlotColl->summaryPlots().push_back(plot);
|
|
|
|
|
|
|
|
plot->setDescription(featureUi.newPlotName());
|
2017-03-19 02:53:15 -05:00
|
|
|
|
2017-03-19 15:41:13 -05:00
|
|
|
summaryPlot = plot;
|
2017-03-19 02:53:15 -05:00
|
|
|
}
|
2017-03-19 15:41:13 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
summaryPlot = featureUi.selectedSummaryPlot();
|
|
|
|
}
|
|
|
|
|
|
|
|
return summaryPlot;
|
2017-03-19 02:53:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RicNewGridTimeHistoryCurveFeature::isCommandEnabled()
|
|
|
|
{
|
|
|
|
std::vector<RiuSelectionItem*> items;
|
|
|
|
RiuSelectionManager::instance()->selectedItems(items);
|
|
|
|
|
|
|
|
if (items.size() > 0)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicNewGridTimeHistoryCurveFeature::onActionTriggered(bool isChecked)
|
|
|
|
{
|
2017-03-19 15:41:13 -05:00
|
|
|
RimSummaryPlot* summaryPlot = RicNewGridTimeHistoryCurveFeature::userSelectedSummaryPlot();
|
|
|
|
if (!summaryPlot) return;
|
|
|
|
|
2017-03-19 02:53:15 -05:00
|
|
|
std::vector<RiuSelectionItem*> items;
|
|
|
|
RiuSelectionManager::instance()->selectedItems(items);
|
2017-03-19 15:41:13 -05:00
|
|
|
CVF_ASSERT(items.size() > 0);
|
2017-03-19 02:53:15 -05:00
|
|
|
|
|
|
|
for (auto item : items)
|
|
|
|
{
|
2017-03-19 15:41:13 -05:00
|
|
|
RicNewGridTimeHistoryCurveFeature::createCurveFromSelectionItem(item, summaryPlot);
|
2017-03-19 02:53:15 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicNewGridTimeHistoryCurveFeature::setupActionLook(QAction* actionToSetup)
|
|
|
|
{
|
|
|
|
actionToSetup->setText("Plot Time History for Selected Cells");
|
|
|
|
actionToSetup->setIcon(QIcon(":/SummaryCurve16x16.png"));
|
|
|
|
}
|
|
|
|
|