mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merge pull request #8732 from OPM/summarymultiplot_updates2
Summary Multiplot updates
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "RiaSummaryTools.h"
|
||||
|
||||
#include "PlotBuilderCommands/RicSummaryPlotBuilder.h"
|
||||
#include "RicEditSummaryPlotFeature.h"
|
||||
#include "RicNewSummaryCurveFeature.h"
|
||||
#include "RicNewSummaryEnsembleCurveSetFeature.h"
|
||||
@@ -36,6 +37,7 @@
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
#include "RimSummaryCaseMainCollection.h"
|
||||
#include "RimSummaryMultiPlot.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimSummaryPlotCollection.h"
|
||||
|
||||
@@ -129,6 +131,13 @@ RimSummaryPlot* RicNewDefaultSummaryPlotFeature::createFromSummaryCases( RimSumm
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicNewDefaultSummaryPlotFeature::isCommandEnabled()
|
||||
{
|
||||
RimSummaryMultiPlot* multiPlot =
|
||||
dynamic_cast<RimSummaryMultiPlot*>( caf::SelectionManager::instance()->selectedItem() );
|
||||
if ( multiPlot )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<RimSummaryCase*> selectedIndividualSummaryCases;
|
||||
std::vector<RimSummaryCaseCollection*> selectedEnsembles;
|
||||
|
||||
@@ -152,6 +161,16 @@ bool RicNewDefaultSummaryPlotFeature::isCommandEnabled()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewDefaultSummaryPlotFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
RimSummaryMultiPlot* multiPlot =
|
||||
dynamic_cast<RimSummaryMultiPlot*>( caf::SelectionManager::instance()->selectedItem() );
|
||||
if ( multiPlot )
|
||||
{
|
||||
RimSummaryPlot* plot = new RimSummaryPlot();
|
||||
plot->enableAutoPlotTitle( true );
|
||||
RicSummaryPlotBuilder::appendPlotsToSummaryMultiPlot( multiPlot, { plot } );
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<RimSummaryCase*> selectedIndividualSummaryCases;
|
||||
std::vector<RimSummaryCaseCollection*> selectedEnsembles;
|
||||
extractPlotObjectsFromSelection( &selectedIndividualSummaryCases, &selectedEnsembles );
|
||||
@@ -178,13 +197,13 @@ void RicNewDefaultSummaryPlotFeature::setupActionLook( QAction* actionToSetup )
|
||||
|
||||
extractPlotObjectsFromSelection( &selectedIndividualSummaryCases, &selectedEnsembles );
|
||||
|
||||
if ( !selectedIndividualSummaryCases.empty() )
|
||||
if ( !selectedEnsembles.empty() )
|
||||
{
|
||||
actionToSetup->setText( "New Summary Plot" );
|
||||
actionToSetup->setText( "Add Ensemble Summary Plot" );
|
||||
}
|
||||
else
|
||||
{
|
||||
actionToSetup->setText( "New Ensemble Summary Plot" );
|
||||
actionToSetup->setText( "Add Summary Plot" );
|
||||
}
|
||||
actionToSetup->setIcon( QIcon( ":/SummaryPlotLight16x16.png" ) );
|
||||
}
|
||||
|
||||
@@ -35,15 +35,13 @@ class RicNewSummaryEnsembleCurveSetFeature : public caf::CmdFeature
|
||||
|
||||
public:
|
||||
static RimSummaryPlot* createPlotForCurveSetsAndUpdate( std::vector<RimSummaryCaseCollection*> ensembles );
|
||||
static std::vector<RimEnsembleCurveSet*> addDefaultCurveSets( RimSummaryPlot* plot, RimSummaryCaseCollection* ensemble );
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
private:
|
||||
static std::vector<RimEnsembleCurveSet*> addDefaultCurveSets( RimSummaryPlot* plot, RimSummaryCaseCollection* ensemble );
|
||||
|
||||
private:
|
||||
RimSummaryPlot* selectedSummaryPlot() const;
|
||||
};
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RimSummaryCurveAutoName.h"
|
||||
#include "RimSummaryCurveCollection.h"
|
||||
#include "RimSummaryMultiPlot.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimSummaryPlotCollection.h"
|
||||
|
||||
@@ -83,6 +84,7 @@ std::vector<T> toVector( const std::set<T>& set );
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicSummaryPlotEditorUi::RicSummaryPlotEditorUi()
|
||||
: m_plotContainer( nullptr )
|
||||
{
|
||||
CAF_PDM_InitFieldNoDefault( &m_targetPlot, "TargetPlot", "Target Plot" );
|
||||
|
||||
@@ -162,6 +164,7 @@ void RicSummaryPlotEditorUi::updateFromSummaryPlot( RimSummaryPlot*
|
||||
|
||||
if ( m_targetPlot )
|
||||
{
|
||||
targetPlot->firstAncestorOfType( m_plotContainer );
|
||||
populateCurveCreator( *m_targetPlot );
|
||||
syncPreviewCurvesFromUiSelection();
|
||||
setInitialCurveVisibility( targetPlot );
|
||||
@@ -172,6 +175,7 @@ void RicSummaryPlotEditorUi::updateFromSummaryPlot( RimSummaryPlot*
|
||||
setDefaultCurveSelection( defaultSources );
|
||||
m_previewPlot->enableAutoPlotTitle( true );
|
||||
syncPreviewCurvesFromUiSelection();
|
||||
m_plotContainer = nullptr;
|
||||
}
|
||||
|
||||
caf::PdmUiItem::updateConnectedEditors();
|
||||
@@ -262,19 +266,25 @@ QList<caf::PdmOptionItemInfo>
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
|
||||
if ( fieldNeedingOptions == &m_targetPlot )
|
||||
if ( m_targetPlot && ( fieldNeedingOptions == &m_targetPlot ) )
|
||||
{
|
||||
RimProject* proj = RimProject::current();
|
||||
|
||||
RimSummaryPlotCollection* summaryPlotColl = proj->mainPlotCollection()->summaryPlotCollection();
|
||||
|
||||
// Create New Plot item
|
||||
QString displayName = "( New Plot )";
|
||||
options.push_back( caf::PdmOptionItemInfo( displayName, nullptr ) );
|
||||
|
||||
if ( summaryPlotColl )
|
||||
if ( m_plotContainer )
|
||||
{
|
||||
summaryPlotColl->summaryPlotItemInfos( &options );
|
||||
m_plotContainer->summaryPlotItemInfos( &options );
|
||||
}
|
||||
else
|
||||
{
|
||||
RimProject* proj = RimProject::current();
|
||||
|
||||
RimSummaryPlotCollection* summaryPlotColl = proj->mainPlotCollection()->summaryPlotCollection();
|
||||
if ( summaryPlotColl )
|
||||
{
|
||||
summaryPlotColl->summaryPlotItemInfos( &options );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -841,52 +851,39 @@ void RicSummaryPlotEditorUi::createNewPlot()
|
||||
{
|
||||
RimProject* proj = RimProject::current();
|
||||
|
||||
RimSummaryPlot* newSummaryPlot = nullptr;
|
||||
|
||||
RimSummaryPlotCollection* summaryPlotColl = proj->mainPlotCollection()->summaryPlotCollection();
|
||||
if ( summaryPlotColl )
|
||||
|
||||
if ( m_plotContainer )
|
||||
{
|
||||
RimSummaryPlot* newSummaryPlot = nullptr;
|
||||
if ( m_useAutoPlotTitleProxy() )
|
||||
newSummaryPlot = new RimSummaryPlot();
|
||||
newSummaryPlot->setAsPlotMdiWindow();
|
||||
newSummaryPlot->enableAutoPlotTitle( true );
|
||||
m_plotContainer->addPlot( newSummaryPlot );
|
||||
}
|
||||
else if ( summaryPlotColl )
|
||||
{
|
||||
newSummaryPlot = summaryPlotColl->createSummaryPlotWithAutoTitle();
|
||||
}
|
||||
|
||||
if ( newSummaryPlot )
|
||||
{
|
||||
newSummaryPlot->loadDataAndUpdate();
|
||||
|
||||
if ( m_plotContainer )
|
||||
{
|
||||
newSummaryPlot = summaryPlotColl->createSummaryPlotWithAutoTitle();
|
||||
m_plotContainer->updateConnectedEditors();
|
||||
}
|
||||
else
|
||||
else if ( summaryPlotColl )
|
||||
{
|
||||
QString candidatePlotName;
|
||||
if ( m_previewPlot )
|
||||
{
|
||||
candidatePlotName = m_previewPlot->generatedPlotTitleFromAllCurves();
|
||||
}
|
||||
|
||||
{
|
||||
bool ok = false;
|
||||
candidatePlotName = QInputDialog::getText( nullptr,
|
||||
"New Summary Plot Name",
|
||||
"New Summary Plot Name",
|
||||
QLineEdit::Normal,
|
||||
candidatePlotName,
|
||||
&ok,
|
||||
RiuTools::defaultDialogFlags() );
|
||||
if ( !ok )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
newSummaryPlot = summaryPlotColl->createNamedSummaryPlot( candidatePlotName );
|
||||
}
|
||||
}
|
||||
|
||||
if ( newSummaryPlot )
|
||||
{
|
||||
newSummaryPlot->loadDataAndUpdate();
|
||||
|
||||
summaryPlotColl->updateConnectedEditors();
|
||||
|
||||
m_targetPlot = newSummaryPlot;
|
||||
updateTargetPlot();
|
||||
|
||||
RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow();
|
||||
mainPlotWindow->updateSummaryPlotToolBar();
|
||||
}
|
||||
|
||||
m_targetPlot = newSummaryPlot;
|
||||
|
||||
RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow();
|
||||
mainPlotWindow->updateSummaryPlotToolBar();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ class PdmObject;
|
||||
};
|
||||
|
||||
class RimSummaryCase;
|
||||
class RimSummaryMultiPlot;
|
||||
class RimSummaryCurveAutoName;
|
||||
class RimSummaryPlot;
|
||||
class RiaSummaryCurveDefinition;
|
||||
@@ -133,4 +134,6 @@ private:
|
||||
caf::PdmField<bool> m_closeButtonField;
|
||||
|
||||
std::unique_ptr<RiuSummaryVectorSelectionWidgetCreator> m_summaryCurveSelectionEditor;
|
||||
|
||||
RimSummaryMultiPlot* m_plotContainer;
|
||||
};
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RimSummaryMultiPlotCollection.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimSummaryPlotCollection.h"
|
||||
|
||||
@@ -78,61 +79,6 @@ std::vector<RimSummaryCurve*> RicSummaryPlotFeatureImpl::addDefaultCurvesToPlot(
|
||||
return addCurvesFromAddressFiltersToPlot( curveFilters, plot, summaryCase, addHistoryCurve );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSummaryPlotFeatureImpl::ensureAtLeastOnePlot( RimSummaryPlotCollection* summaryPlotCollection,
|
||||
RimSummaryCase* summaryCase )
|
||||
{
|
||||
if ( summaryPlotCollection && summaryCase )
|
||||
{
|
||||
if ( summaryPlotCollection->plots().empty() )
|
||||
{
|
||||
auto objectToSelect = createDefaultSummaryPlot( summaryCase );
|
||||
if ( objectToSelect )
|
||||
{
|
||||
RiuPlotMainWindowTools::setExpanded( objectToSelect );
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem( objectToSelect );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmObject* RicSummaryPlotFeatureImpl::createDefaultSummaryPlot( RimSummaryCase* summaryCase )
|
||||
{
|
||||
RimSummaryPlotCollection* summaryPlotCollection = RimProject::current()->mainPlotCollection->summaryPlotCollection();
|
||||
|
||||
RiaPreferencesSummary* prefs = RiaPreferencesSummary::current();
|
||||
|
||||
caf::PdmObject* itemToSelect = nullptr;
|
||||
|
||||
if ( summaryPlotCollection && summaryCase && !prefs->defaultSummaryCurvesTextFilter().isEmpty() )
|
||||
{
|
||||
auto plot = summaryPlotCollection->createSummaryPlotWithAutoTitle();
|
||||
|
||||
std::vector<RimSummaryCurve*> curves = RicSummaryPlotFeatureImpl::addDefaultCurvesToPlot( plot, summaryCase );
|
||||
|
||||
plot->applyDefaultCurveAppearances();
|
||||
plot->loadDataAndUpdate();
|
||||
|
||||
summaryPlotCollection->updateConnectedEditors();
|
||||
|
||||
if ( curves.size() )
|
||||
{
|
||||
itemToSelect = curves[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
itemToSelect = plot;
|
||||
}
|
||||
}
|
||||
|
||||
return itemToSelect;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user