Simplify access to RimMainPlotCollection

* Add current() to RimMainPlotCollection to avoid include of RimProject
* Remove "segment" prefix
* Reload data when RftCase changes
This commit is contained in:
Magne Sjaastad
2022-08-19 05:30:25 -07:00
committed by GitHub
parent 506bfbd638
commit 4cd38d7daf
51 changed files with 240 additions and 418 deletions

View File

@@ -38,18 +38,15 @@ CAF_CMD_SOURCE_INIT( RicAddStoredWellAllocationPlotFeature, "RicAddStoredWellAll
//--------------------------------------------------------------------------------------------------
bool RicAddStoredWellAllocationPlotFeature::isCommandEnabled()
{
if ( RimProject::current() )
RimFlowPlotCollection* flowPlotColl = RimMainPlotCollection::current()->flowPlotCollection();
if ( flowPlotColl )
{
RimFlowPlotCollection* flowPlotColl = RimProject::current()->mainPlotCollection->flowPlotCollection();
if ( flowPlotColl )
{
RimWellAllocationPlot* wellAllocationPlot =
dynamic_cast<RimWellAllocationPlot*>( caf::SelectionManager::instance()->selectedItem() );
RimWellAllocationPlot* wellAllocationPlot =
dynamic_cast<RimWellAllocationPlot*>( caf::SelectionManager::instance()->selectedItem() );
if ( flowPlotColl->defaultWellAllocPlot() == wellAllocationPlot )
{
return true;
}
if ( flowPlotColl->defaultWellAllocPlot() == wellAllocationPlot )
{
return true;
}
}
@@ -61,28 +58,25 @@ bool RicAddStoredWellAllocationPlotFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
void RicAddStoredWellAllocationPlotFeature::onActionTriggered( bool isChecked )
{
if ( RimProject::current() )
RimFlowPlotCollection* flowPlotColl = RimMainPlotCollection::current()->flowPlotCollection();
if ( flowPlotColl )
{
RimFlowPlotCollection* flowPlotColl = RimProject::current()->mainPlotCollection->flowPlotCollection();
if ( flowPlotColl )
{
RimWellAllocationPlot* sourceObject =
dynamic_cast<RimWellAllocationPlot*>( caf::SelectionManager::instance()->selectedItem() );
RimWellAllocationPlot* sourceObject =
dynamic_cast<RimWellAllocationPlot*>( caf::SelectionManager::instance()->selectedItem() );
RimWellAllocationPlot* wellAllocationPlot = dynamic_cast<RimWellAllocationPlot*>(
sourceObject->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
RimWellAllocationPlot* wellAllocationPlot = dynamic_cast<RimWellAllocationPlot*>(
sourceObject->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
CVF_ASSERT( wellAllocationPlot );
CVF_ASSERT( wellAllocationPlot );
flowPlotColl->addWellAllocPlotToStoredPlots( wellAllocationPlot );
wellAllocationPlot->resolveReferencesRecursively();
flowPlotColl->addWellAllocPlotToStoredPlots( wellAllocationPlot );
wellAllocationPlot->resolveReferencesRecursively();
wellAllocationPlot->loadDataAndUpdate();
wellAllocationPlot->loadDataAndUpdate();
flowPlotColl->updateConnectedEditors();
flowPlotColl->updateConnectedEditors();
RiuPlotMainWindowTools::onObjectAppended( wellAllocationPlot );
}
RiuPlotMainWindowTools::onObjectAppended( wellAllocationPlot );
}
}