#5125 Update RimWellMeasurementInViewCollection when measurements are imported.

This commit is contained in:
Kristian Bendiksen 2019-12-03 10:20:45 +01:00
parent 66ac8fee1d
commit 3583e2ee10
7 changed files with 53 additions and 7 deletions

View File

@ -21,6 +21,8 @@
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "Rim3dView.h"
#include "RimGridView.h"
#include "RimPerforationCollection.h"
#include "RimPerforationInterval.h"
#include "RimProject.h"
@ -106,6 +108,17 @@ void RicImportWellMeasurementsFeature::onActionTriggered( bool isChecked )
if ( app->project() )
{
std::vector<Rim3dView*> views;
app->project()->allViews( views );
for ( auto& view : views )
{
RimGridView* gridView = dynamic_cast<RimGridView*>( view );
if ( gridView )
{
gridView->updateWellMeasurements();
}
}
app->project()->scheduleCreateDisplayModelAndRedrawAllViews();
}

View File

@ -932,6 +932,8 @@ void RimEclipseView::onLoadDataAndUpdate()
m_virtualPerforationResult->loadData();
}
m_wellMeasurementCollection->syncWithChangesInWellMeasurementCollection();
this->scheduleCreateDisplayModelAndRedraw();
}

View File

@ -175,6 +175,7 @@ void RimGeoMechView::onLoadDataAndUpdate()
updateMdiWindowVisibility();
this->geoMechPropertyFilterCollection()->loadAndInitializePropertyFilters();
m_wellMeasurementCollection->syncWithChangesInWellMeasurementCollection();
this->scheduleCreateDisplayModelAndRedraw();

View File

@ -557,3 +557,11 @@ RimViewLinker* RimGridView::viewLinkerIfMasterView() const
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGridView::updateWellMeasurements()
{
m_wellMeasurementCollection->syncWithChangesInWellMeasurementCollection();
}

View File

@ -71,6 +71,8 @@ public:
int fontSize,
bool forceChange = false ) override;
void updateWellMeasurements();
protected:
virtual void updateViewFollowingRangeFilterUpdates();
void onClearReservoirCellVisibilitiesIfNeccessary() override;

View File

@ -97,25 +97,44 @@ void RimWellMeasurementInViewCollection::fieldChangedByUi( const caf::PdmFieldHa
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellMeasurementInViewCollection::initAfterRead()
void RimWellMeasurementInViewCollection::syncWithChangesInWellMeasurementCollection()
{
// TODO: Need a better solution for this!!!
RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection();
if ( wellPathCollection )
{
const RimWellMeasurementCollection* measurementCollection = wellPathCollection->measurementCollection();
std::set<QString> measurementKinds;
for ( RimWellMeasurement* wellMeasurement : measurementCollection->measurements() )
// Make a set of the measurement kinds already present
std::set<QString> currentMeasurementKinds;
for ( RimWellMeasurementInView* wellMeasurement : measurements() )
{
measurementKinds.insert( wellMeasurement->kind() );
currentMeasurementKinds.insert( wellMeasurement->measurementKind() );
}
for ( QString kind : measurementKinds )
// Make a set of the measurements we should have after the update
std::set<QString> targetMeasurementKinds;
for ( RimWellMeasurement* wellMeasurement : measurementCollection->measurements() )
{
targetMeasurementKinds.insert( wellMeasurement->kind() );
}
// The difference between the sets is the measurement kinds to be added
std::set<QString> newMeasurementKinds;
std::set_difference( targetMeasurementKinds.begin(),
targetMeasurementKinds.end(),
currentMeasurementKinds.begin(),
currentMeasurementKinds.end(),
std::inserter( newMeasurementKinds, newMeasurementKinds.end() ) );
// Add the new measurement kinds
for ( QString kind : newMeasurementKinds )
{
RimWellMeasurementInView* measurementInView = new RimWellMeasurementInView;
measurementInView->setName( kind );
measurementInView->setMeasurementKind( kind );
m_measurementsInView.push_back( measurementInView );
}
updateConnectedEditors();
}
}

View File

@ -35,12 +35,13 @@ public:
std::vector<RimWellMeasurementInView*> measurements() const;
void syncWithChangesInWellMeasurementCollection();
protected:
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue ) override;
void initAfterRead();
private:
caf::PdmChildArrayField<RimWellMeasurementInView*> m_measurementsInView;