mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4002 Renamed feature that opens the plot editor and created feature to create a new plot directly. The new feature uses the selected summary cases and creates a default curve for each.
This commit is contained in:
@@ -54,7 +54,7 @@ RimSummaryCurve* RicNewSummaryCurveFeature::addCurveToPlot(RimSummaryPlot* plot,
|
||||
cvf::Color3f curveColor = RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f(plot->singleColorCurveCount());
|
||||
newCurve->setColor(curveColor);
|
||||
|
||||
plot->addCurveAndUpdate(newCurve);
|
||||
plot->addCurveNoUpdate(newCurve);
|
||||
|
||||
if (summaryCase)
|
||||
{
|
||||
@@ -63,8 +63,6 @@ RimSummaryCurve* RicNewSummaryCurveFeature::addCurveToPlot(RimSummaryPlot* plot,
|
||||
|
||||
newCurve->setSummaryAddressYAndApplyInterpolation(RifEclipseSummaryAddress::fieldAddress("FOPT"));
|
||||
|
||||
newCurve->loadDataAndUpdate(true);
|
||||
|
||||
return newCurve;
|
||||
}
|
||||
|
||||
@@ -132,6 +130,7 @@ void RicNewSummaryCurveFeature::onActionTriggered(bool isChecked)
|
||||
|
||||
RimSummaryCurve* newCurve = addCurveToPlot(plot, defaultCase);
|
||||
|
||||
plot->loadDataAndUpdate();
|
||||
plot->updateConnectedEditors();
|
||||
|
||||
app->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(newCurve);
|
||||
|
||||
@@ -141,7 +141,98 @@ void RicNewSummaryPlotFeature::onActionTriggered(bool isChecked)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewSummaryPlotFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("New Summary Plot");
|
||||
actionToSetup->setText("Open Summary Plot Editor");
|
||||
actionToSetup->setIcon(QIcon(":/SummaryPlotLight16x16.png"));
|
||||
}
|
||||
|
||||
#include "RiuPlotMainWindowTools.h"
|
||||
#include "RicNewSummaryCurveFeature.h"
|
||||
#include "RimMainPlotCollection.h"
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicNewSummaryPlotDirectFeature, "RicNewSummaryPlotDirectFeature");
|
||||
|
||||
|
||||
auto extractSumPlotCollectionOrSelectedSumCasesFromSelection()
|
||||
{
|
||||
std::vector<RimSummaryCase*> selectedSumCases;
|
||||
RimSummaryPlotCollection* sumPlotColl = nullptr;
|
||||
|
||||
std::vector<caf::PdmUiItem*> selectedItems;
|
||||
caf::SelectionManager::instance()->selectedItems(selectedItems);
|
||||
|
||||
if ( selectedItems.size() )
|
||||
{
|
||||
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>(selectedItems[0]);
|
||||
sumPlotColl = RiaSummaryTools::parentSummaryPlotCollection(selObj);
|
||||
}
|
||||
|
||||
if (!sumPlotColl)
|
||||
{
|
||||
caf::SelectionManager::instance()->objectsByTypeStrict(&selectedSumCases);
|
||||
}
|
||||
|
||||
return std::make_pair(sumPlotColl, selectedSumCases);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicNewSummaryPlotDirectFeature::isCommandEnabled()
|
||||
{
|
||||
auto sumPlotSumCasesPair = extractSumPlotCollectionOrSelectedSumCasesFromSelection();
|
||||
|
||||
return sumPlotSumCasesPair.first || sumPlotSumCasesPair.second.size();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewSummaryPlotDirectFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
auto sumPlotSumCasesPair = extractSumPlotCollectionOrSelectedSumCasesFromSelection();
|
||||
|
||||
RimSummaryPlotCollection* sumPlotColl = RiaApplication::instance()->project()->mainPlotCollection()->summaryPlotCollection();
|
||||
|
||||
RimSummaryPlot* newPlot = nullptr;
|
||||
|
||||
if (sumPlotSumCasesPair.first)
|
||||
{
|
||||
auto sumCaseVector = RiaApplication::instance()->project()->allSummaryCases();
|
||||
|
||||
newPlot = sumPlotColl->createSummaryPlotWithAutoTitle();
|
||||
|
||||
if (sumCaseVector.size())
|
||||
{
|
||||
RicNewSummaryCurveFeature::addCurveToPlot(newPlot, sumCaseVector[0]);
|
||||
}
|
||||
}
|
||||
else if (sumPlotSumCasesPair.second.size())
|
||||
{
|
||||
newPlot = sumPlotColl->createSummaryPlotWithAutoTitle();
|
||||
|
||||
for (RimSummaryCase* sumCase : sumPlotSumCasesPair.second)
|
||||
{
|
||||
RicNewSummaryCurveFeature::addCurveToPlot(newPlot, sumCase);
|
||||
}
|
||||
}
|
||||
|
||||
if ( newPlot )
|
||||
{
|
||||
newPlot->loadDataAndUpdate();
|
||||
|
||||
sumPlotColl->updateConnectedEditors();
|
||||
|
||||
RiuPlotMainWindowTools::setExpanded(newPlot);
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem(newPlot);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewSummaryPlotDirectFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("New Summary Plot");
|
||||
actionToSetup->setIcon(QIcon(":/SummaryPlotLight16x16.png"));
|
||||
|
||||
}
|
||||
|
||||
@@ -37,3 +37,17 @@ protected:
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook(QAction* actionToSetup) override;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicNewSummaryPlotDirectFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook(QAction* actionToSetup) override;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user