mirror of
https://github.com/OPM/ResInsight.git
synced 2026-11-02 09:00:14 -06:00
Refactor RimWellMeasurementCollection.
This commit is contained in:
1 parent
bd7e5ac1b9
commit
83d75de7d5
3 files changed
+29
-120
No files matched your search
@@ -94,9 +94,11 @@ void RicWellMeasurementImportTools::importWellMeasurementsFromFiles( const QStri
|
|||||||
wellMeasurement->setValue( 0.0 );
|
wellMeasurement->setValue( 0.0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
wellPathCollection->measurementCollection()->appendMeasurement( wellMeasurement );
|
wellPathCollection->measurementCollection()->addItem( wellMeasurement );
|
||||||
|
wellPathCollection->measurementCollection()->addFilePath( wellMeasurement->filePath() );
|
||||||
lastWellMeasurement = wellMeasurement;
|
lastWellMeasurement = wellMeasurement;
|
||||||
}
|
}
|
||||||
|
wellPathCollection->measurementCollection()->updateAllCurves();
|
||||||
wellPathCollection->uiCapability()->updateConnectedEditors();
|
wellPathCollection->uiCapability()->updateConnectedEditors();
|
||||||
|
|
||||||
auto proj = RimProject::current();
|
auto proj = RimProject::current();
|
||||||
|
|||||||
+17
-105
@@ -39,9 +39,9 @@ RimWellMeasurementCollection::RimWellMeasurementCollection()
|
|||||||
{
|
{
|
||||||
CAF_PDM_InitObject( "Well Measurements", ":/WellMeasurement16x16.png" );
|
CAF_PDM_InitObject( "Well Measurements", ":/WellMeasurement16x16.png" );
|
||||||
|
|
||||||
CAF_PDM_InitFieldNoDefault( &m_measurements, "Measurements", "Well Measurements" );
|
CAF_PDM_InitFieldNoDefault( &m_items, "Measurements", "Measurements" );
|
||||||
m_measurements.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() );
|
this->itemsField().uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() );
|
||||||
m_measurements.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP );
|
this->itemsField().uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP );
|
||||||
|
|
||||||
CAF_PDM_InitFieldNoDefault( &m_importedFiles, "ImportedFiles", "Imported Files" );
|
CAF_PDM_InitFieldNoDefault( &m_importedFiles, "ImportedFiles", "Imported Files" );
|
||||||
}
|
}
|
||||||
@@ -53,6 +53,14 @@ RimWellMeasurementCollection::~RimWellMeasurementCollection()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
std::vector<RimWellMeasurement*> RimWellMeasurementCollection::measurements() const
|
||||||
|
{
|
||||||
|
return this->items();
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -93,101 +101,6 @@ void RimWellMeasurementCollection::deleteAllEmptyCurves()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
std::vector<RimWellMeasurement*> RimWellMeasurementCollection::measurements() const
|
|
||||||
{
|
|
||||||
std::vector<RimWellMeasurement*> attrs;
|
|
||||||
|
|
||||||
for ( auto attr : m_measurements )
|
|
||||||
{
|
|
||||||
attrs.push_back( attr.p() );
|
|
||||||
}
|
|
||||||
return attrs;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
bool RimWellMeasurementCollection::isEmpty() const
|
|
||||||
{
|
|
||||||
return m_measurements.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RimWellMeasurementCollection::insertMeasurement( RimWellMeasurement* insertBefore, RimWellMeasurement* measurement )
|
|
||||||
{
|
|
||||||
size_t index = m_measurements.indexOf( insertBefore );
|
|
||||||
if ( index < m_measurements.size() )
|
|
||||||
m_measurements.insert( index, measurement );
|
|
||||||
else
|
|
||||||
m_measurements.push_back( measurement );
|
|
||||||
|
|
||||||
addFilePath( measurement->filePath() );
|
|
||||||
updateAllCurves();
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RimWellMeasurementCollection::appendMeasurement( RimWellMeasurement* measurement )
|
|
||||||
{
|
|
||||||
m_measurements.push_back( measurement );
|
|
||||||
addFilePath( measurement->filePath() );
|
|
||||||
updateAllCurves();
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RimWellMeasurementCollection::deleteMeasurement( RimWellMeasurement* measurementToDelete )
|
|
||||||
{
|
|
||||||
m_measurements.removeChild( measurementToDelete );
|
|
||||||
delete measurementToDelete;
|
|
||||||
|
|
||||||
updateAllCurves();
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RimWellMeasurementCollection::deleteAllMeasurements()
|
|
||||||
{
|
|
||||||
m_measurements.deleteChildren();
|
|
||||||
updateAllCurves();
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RimWellMeasurementCollection::defineEditorAttribute( const caf::PdmFieldHandle* field,
|
|
||||||
QString uiConfigName,
|
|
||||||
caf::PdmUiEditorAttribute* attribute )
|
|
||||||
{
|
|
||||||
if ( field == &m_measurements )
|
|
||||||
{
|
|
||||||
auto tvAttribute = dynamic_cast<caf::PdmUiTableViewEditorAttribute*>( attribute );
|
|
||||||
if ( tvAttribute )
|
|
||||||
{
|
|
||||||
tvAttribute->resizePolicy = caf::PdmUiTableViewEditorAttribute::RESIZE_TO_FILL_CONTAINER;
|
|
||||||
tvAttribute->alwaysEnforceResizePolicy = true;
|
|
||||||
tvAttribute->minimumHeight = 300;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RimWellMeasurementCollection::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
|
||||||
{
|
|
||||||
uiOrdering.add( &m_measurements );
|
|
||||||
uiOrdering.skipRemainingFields( true );
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -244,19 +157,18 @@ void RimWellMeasurementCollection::removeMeasurementsForFilePath( RimWellMeasure
|
|||||||
{
|
{
|
||||||
// Find all measurements for this file path
|
// Find all measurements for this file path
|
||||||
std::vector<RimWellMeasurement*> measurementsToRemove;
|
std::vector<RimWellMeasurement*> measurementsToRemove;
|
||||||
for ( auto attr : m_measurements )
|
for ( auto* measurement : this->items() )
|
||||||
{
|
{
|
||||||
if ( attr->filePath() == measurementFilePath->filePath() )
|
if ( measurement->filePath() == measurementFilePath->filePath() )
|
||||||
{
|
{
|
||||||
measurementsToRemove.push_back( attr );
|
measurementsToRemove.push_back( measurement );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove then remove them without invalidating the iterator
|
// Remove them without invalidating the iterator
|
||||||
for ( unsigned int i = 0; i < measurementsToRemove.size(); i++ )
|
for ( auto* measurement : measurementsToRemove )
|
||||||
{
|
{
|
||||||
m_measurements.removeChild( measurementsToRemove[i] );
|
this->deleteItem( measurement );
|
||||||
delete measurementsToRemove[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RimProject::current()->scheduleCreateDisplayModelAndRedrawAllViews();
|
RimProject::current()->scheduleCreateDisplayModelAndRedrawAllViews();
|
||||||
|
|||||||
@@ -17,18 +17,19 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cafPdmChildArrayField.h"
|
#include "RimWellMeasurement.h"
|
||||||
#include "cafPdmField.h"
|
|
||||||
#include "cafPdmObject.h"
|
#include "cafPdmChildArrayField.h"
|
||||||
#include "cafPdmProxyValueField.h"
|
#include "cafPdmObjectCollection.h"
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
|
||||||
class RimWellMeasurement;
|
|
||||||
class RimWellMeasurementFilePath;
|
class RimWellMeasurementFilePath;
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
///
|
///
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
class RimWellMeasurementCollection : public caf::PdmObject
|
class RimWellMeasurementCollection : public caf::PdmObjectCollection<RimWellMeasurement>
|
||||||
{
|
{
|
||||||
CAF_PDM_HEADER_INIT;
|
CAF_PDM_HEADER_INIT;
|
||||||
|
|
||||||
@@ -36,15 +37,12 @@ public:
|
|||||||
RimWellMeasurementCollection();
|
RimWellMeasurementCollection();
|
||||||
~RimWellMeasurementCollection() override;
|
~RimWellMeasurementCollection() override;
|
||||||
|
|
||||||
|
// Convenience accessor (delegates to base class items())
|
||||||
std::vector<RimWellMeasurement*> measurements() const;
|
std::vector<RimWellMeasurement*> measurements() const;
|
||||||
|
|
||||||
|
// Domain-specific methods
|
||||||
void updateAllCurves();
|
void updateAllCurves();
|
||||||
void deleteAllEmptyCurves();
|
void deleteAllEmptyCurves();
|
||||||
void insertMeasurement( RimWellMeasurement* insertBefore, RimWellMeasurement* measurement );
|
|
||||||
void appendMeasurement( RimWellMeasurement* measurement );
|
|
||||||
void deleteMeasurement( RimWellMeasurement* measurementToDelete );
|
|
||||||
void deleteAllMeasurements();
|
|
||||||
bool isEmpty() const;
|
|
||||||
|
|
||||||
std::set<QString> importedFiles() const;
|
std::set<QString> importedFiles() const;
|
||||||
|
|
||||||
@@ -53,11 +51,8 @@ public:
|
|||||||
void removeMeasurementsForFilePath( RimWellMeasurementFilePath* measurementFilePath );
|
void removeMeasurementsForFilePath( RimWellMeasurementFilePath* measurementFilePath );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
|
|
||||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
|
||||||
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
|
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
caf::PdmChildArrayField<RimWellMeasurement*> m_measurements;
|
|
||||||
caf::PdmChildArrayField<RimWellMeasurementFilePath*> m_importedFiles;
|
caf::PdmChildArrayField<RimWellMeasurementFilePath*> m_importedFiles;
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user