Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void RicDeleteValveTemplateFeature::onActionTriggered( bool isChecked )
}

RimValveTemplateCollection* collection = valveTemplate->firstAncestorOrThisOfTypeAsserted<RimValveTemplateCollection>();
collection->removeAndDeleteValveTemplate( valveTemplate );
collection->deleteItem( valveTemplate );
collection->updateAllRequiredEditors();

project->scheduleCreateDisplayModelAndRedrawAllViews();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void RicImportValveTemplatesFeature::onActionTriggered( bool isChecked )
for ( const auto& aicdValue : aicdTemplates )
{
auto newTemplate = RimValveTemplate::createAicdTemplate( aicdValue, number++ );
templateColl->addValveTemplate( newTemplate );
templateColl->addItem( newTemplate );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ RimValveTemplate* RicNewValveTemplateFeature::createNewValveTemplate()
if ( valveTemplateColl )
{
RimValveTemplate* valveTemplate = new RimValveTemplate();
QString userLabel = QString( "Valve Template #%1" ).arg( valveTemplateColl->valveTemplates().size() + 1 );
QString userLabel = QString( "Valve Template #%1" ).arg( valveTemplateColl->count() + 1 );
valveTemplate->setUserLabel( userLabel );
valveTemplateColl->addValveTemplate( valveTemplate );
valveTemplateColl->addItem( valveTemplate );
valveTemplate->setUnitSystem( valveTemplateColl->defaultUnitSystemType() );
valveTemplate->setDefaultValuesFromUnits();
return valveTemplate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void RicNewElasticPropertyScalingFeature::onActionTriggered( bool isChecked )
RimElasticPropertyScaling* elasticPropertyScaling = new RimElasticPropertyScaling;
elasticPropertyScaling->ensureDefaultFormationAndFacies();

scalingColl->addElasticPropertyScaling( elasticPropertyScaling );
scalingColl->addItem( elasticPropertyScaling );

scalingColl->updateConnectedEditors();
Riu3DMainWindowTools::selectAsCurrentItem( elasticPropertyScaling );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,11 @@ void RicWellMeasurementImportTools::importWellMeasurementsFromFiles( const QStri
wellMeasurement->setValue( 0.0 );
}

wellPathCollection->measurementCollection()->appendMeasurement( wellMeasurement );
wellPathCollection->measurementCollection()->addItem( wellMeasurement );
wellPathCollection->measurementCollection()->addFilePath( wellMeasurement->filePath() );
lastWellMeasurement = wellMeasurement;
}
wellPathCollection->measurementCollection()->updateAllCurves();
wellPathCollection->uiCapability()->updateConnectedEditors();

auto proj = RimProject::current();
Expand Down
2 changes: 2 additions & 0 deletions ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimPdmObjectCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimPdmObjectCollection.inl
${CMAKE_CURRENT_LIST_DIR}/RimEclipseCaseCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimCaseCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimLegendConfigChangeType.h
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimIntervalCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimIntervalCollection.inl
${CMAKE_CURRENT_LIST_DIR}/RimCompletionCellIntersectionCalc.h
${CMAKE_CURRENT_LIST_DIR}/RimFishbonesCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimFishbones.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,7 @@

#include "RimCustomSegmentIntervalCollection.h"

#include "RiaLogging.h"
#include "RimCustomSegmentInterval.h"

#include "cafCmdFeatureMenuBuilder.h"
#include "cafPdmUiTableViewEditor.h"

#include <algorithm>
#include <cmath>

CAF_PDM_SOURCE_INIT( RimCustomSegmentIntervalCollection, "CustomSegmentIntervalCollection" );

Expand All @@ -35,8 +28,7 @@ CAF_PDM_SOURCE_INIT( RimCustomSegmentIntervalCollection, "CustomSegmentIntervalC
RimCustomSegmentIntervalCollection::RimCustomSegmentIntervalCollection()
{
CAF_PDM_InitObject( "Custom Segment Intervals", ":/WellPathComponent16x16.png" );

CAF_PDM_InitFieldNoDefault( &m_intervals, "Intervals", "Intervals" );
CAF_PDM_InitFieldNoDefault( &m_items, "Intervals", "Intervals" );
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -46,124 +38,6 @@ RimCustomSegmentIntervalCollection::~RimCustomSegmentIntervalCollection()
{
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimCustomSegmentInterval*> RimCustomSegmentIntervalCollection::intervals() const
{
return m_intervals.childrenByType();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCustomSegmentIntervalCollection::addInterval( RimCustomSegmentInterval* interval )
{
if ( interval )
{
m_intervals.push_back( interval );
sortIntervalsByMD();
updateConnectedEditors();
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCustomSegmentIntervalCollection::removeInterval( RimCustomSegmentInterval* interval )
{
if ( interval )
{
m_intervals.removeChild( interval );
delete interval;
updateConnectedEditors();
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCustomSegmentIntervalCollection::removeAllIntervals()
{
m_intervals.deleteChildren();
updateConnectedEditors();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCustomSegmentInterval* RimCustomSegmentIntervalCollection::createInterval( double startMD, double endMD )
{
auto* interval = new RimCustomSegmentInterval();
interval->setStartMD( startMD );
interval->setEndMD( endMD );

addInterval( interval );
return interval;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCustomSegmentInterval* RimCustomSegmentIntervalCollection::createDefaultInterval()
{
auto* interval = new RimCustomSegmentInterval();
addInterval( interval );
return interval;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCustomSegmentInterval* RimCustomSegmentIntervalCollection::findIntervalAtMD( double md ) const
{
for ( auto* interval : intervals() )
{
if ( interval && interval->containsMD( md ) )
{
return interval;
}
}
return nullptr;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimCustomSegmentIntervalCollection::hasValidIntervals() const
{
if ( isEmpty() ) return false;

for ( auto* interval : intervals() )
{
if ( !interval || !interval->isValidInterval() )
{
return false;
}
}
return true;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimCustomSegmentIntervalCollection::hasOverlappingIntervals() const
{
auto intervalList = intervals();

for ( size_t i = 0; i < intervalList.size(); ++i )
{
for ( size_t j = i + 1; j < intervalList.size(); ++j )
{
if ( intervalList[i]->overlaps( intervalList[j] ) )
{
return true;
}
}
}
return false;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -213,142 +87,6 @@ std::map<QString, QString> RimCustomSegmentIntervalCollection::validate( const Q
return errors;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCustomSegmentIntervalCollection::sortIntervalsByMD()
{
auto intervalList = intervals();
std::sort( intervalList.begin(),
intervalList.end(),
[]( const RimCustomSegmentInterval* a, const RimCustomSegmentInterval* b ) { return *a < *b; } );

// Rebuild the collection in sorted order
m_intervals.clearWithoutDelete();
for ( auto* interval : intervalList )
{
m_intervals.push_back( interval );
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimCustomSegmentIntervalCollection::isEmpty() const
{
return m_intervals.empty();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RimCustomSegmentIntervalCollection::count() const
{
return m_intervals.size();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCustomSegmentIntervalCollection::updateConnectedEditors()
{
m_intervals.uiCapability()->updateConnectedEditors();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmChildArrayField<RimCustomSegmentInterval*>& RimCustomSegmentIntervalCollection::intervalsField()
{
return m_intervals;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCustomSegmentIntervalCollection::updateOverlapVisualFeedback()
{
auto intervalList = intervals();

// First, reset all intervals to no overlap
for ( auto* interval : intervalList )
{
interval->updateOverlapVisualFeedback( false );
}

// Then check for overlaps and update visual feedback
for ( size_t i = 0; i < intervalList.size(); ++i )
{
bool hasOverlap = false;

for ( size_t j = 0; j < intervalList.size(); ++j )
{
if ( i != j && intervalList[i]->overlaps( intervalList[j] ) )
{
hasOverlap = true;
break;
}
}

if ( hasOverlap )
{
intervalList[i]->updateOverlapVisualFeedback( true );
}
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCustomSegmentIntervalCollection::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
{
if ( changedField == &m_intervals )
{
sortIntervalsByMD();
updateOverlapVisualFeedback();
}

updateConnectedEditors();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCustomSegmentIntervalCollection::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( &m_intervals );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCustomSegmentIntervalCollection::defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute )
{
if ( field == &m_intervals )
{
auto tvAttribute = dynamic_cast<caf::PdmUiTableViewEditorAttribute*>( attribute );
if ( tvAttribute )
{
tvAttribute->resizePolicy = caf::PdmUiTableViewEditorAttribute::RESIZE_TO_FILL_CONTAINER;
tvAttribute->alwaysEnforceResizePolicy = true;
tvAttribute->minimumHeight = 300;
}
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCustomSegmentIntervalCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
std::vector<caf::PdmObjectHandle*>& referringObjects )
{
updateConnectedEditors();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand All @@ -364,20 +102,3 @@ void RimCustomSegmentIntervalCollection::defineCustomContextMenu( const caf::Pdm

menuBuilder.appendToMenu( menu );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCustomSegmentIntervalCollection::insertInterval( RimCustomSegmentInterval* insertBefore, RimCustomSegmentInterval* interval )
{
if ( !interval ) return;

size_t index = m_intervals.indexOf( insertBefore );
if ( index < m_intervals.size() )
m_intervals.insert( index, interval );
else
m_intervals.push_back( interval );

sortIntervalsByMD();
updateConnectedEditors();
}
Loading