mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Support drag and drop of summary curves
This commit is contained in:
@@ -47,6 +47,7 @@ CAF_PDM_SOURCE_INIT( RimSummaryCurveCollection, "RimSummaryCurveCollection" );
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryCurveCollection::RimSummaryCurveCollection()
|
||||
: curvesAddedOrRemoved( this )
|
||||
{
|
||||
CAF_PDM_InitObject( "Summary Curves", ":/SummaryCurveFilter16x16.png", "", "" );
|
||||
|
||||
@@ -180,16 +181,42 @@ void RimSummaryCurveCollection::addCurve( RimSummaryCurve* curve )
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCurveCollection::insertCurve( RimSummaryCurve* curve, size_t index )
|
||||
{
|
||||
if ( index >= m_curves.size() )
|
||||
{
|
||||
m_curves.push_back( curve );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_curves.insert( index, curve );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCurveCollection::deleteCurve( RimSummaryCurve* curve )
|
||||
{
|
||||
removeCurve( curve );
|
||||
if ( curve )
|
||||
{
|
||||
curve->markCachedDataForPurge();
|
||||
delete curve;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCurveCollection::removeCurve( RimSummaryCurve* curve )
|
||||
{
|
||||
if ( curve )
|
||||
{
|
||||
m_curves.removeChildObject( curve );
|
||||
curve->markCachedDataForPurge();
|
||||
delete curve;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,6 +429,52 @@ RimSummaryPlotSourceStepping*
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCurveCollection::moveCurvesToCollection( RimSummaryCurveCollection* collection,
|
||||
const std::vector<RimSummaryCurve*> curves,
|
||||
RimSummaryCurve* curveToInsertBeforeOrAfter,
|
||||
bool isSwapOperation )
|
||||
{
|
||||
CAF_ASSERT( collection );
|
||||
|
||||
std::set<RimSummaryCurveCollection*> srcCollections;
|
||||
|
||||
for ( auto curve : curves )
|
||||
{
|
||||
RimSummaryCurveCollection* srcCollection = nullptr;
|
||||
curve->firstAncestorOrThisOfTypeAsserted( srcCollection );
|
||||
|
||||
srcCollection->removeCurve( curve );
|
||||
srcCollections.insert( srcCollection );
|
||||
}
|
||||
|
||||
for ( auto collection : srcCollections )
|
||||
{
|
||||
collection->updateConnectedEditors();
|
||||
collection->curvesAddedOrRemoved.send();
|
||||
}
|
||||
|
||||
size_t insertionStartIndex = std::numeric_limits<size_t>::infinity();
|
||||
if ( curveToInsertBeforeOrAfter )
|
||||
{
|
||||
insertionStartIndex = collection->m_curves.index( curveToInsertBeforeOrAfter );
|
||||
}
|
||||
|
||||
if ( insertionStartIndex < collection->m_curves.size() && !isSwapOperation )
|
||||
{
|
||||
insertionStartIndex += 1;
|
||||
}
|
||||
for ( size_t cIdx = 0; cIdx < curves.size(); ++cIdx )
|
||||
{
|
||||
collection->insertCurve( curves[cIdx], insertionStartIndex + cIdx );
|
||||
}
|
||||
|
||||
collection->updateConnectedEditors();
|
||||
collection->curvesAddedOrRemoved.send();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -39,6 +39,9 @@ class RimSummaryCurveCollection : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
caf::Signal<> curvesAddedOrRemoved;
|
||||
|
||||
public:
|
||||
RimSummaryCurveCollection();
|
||||
~RimSummaryCurveCollection() override;
|
||||
@@ -53,7 +56,9 @@ public:
|
||||
RimSummaryCurve* findRimCurveFromQwtCurve( const QwtPlotCurve* qwtCurve ) const;
|
||||
|
||||
void addCurve( RimSummaryCurve* curve );
|
||||
void insertCurve( RimSummaryCurve* curve, size_t index );
|
||||
void deleteCurve( RimSummaryCurve* curve );
|
||||
void removeCurve( RimSummaryCurve* curve );
|
||||
|
||||
std::vector<RimSummaryCurve*> curves() const;
|
||||
std::vector<RimSummaryCurve*>
|
||||
@@ -75,6 +80,11 @@ public:
|
||||
RimSummaryPlotSourceStepping*
|
||||
sourceSteppingObject( RimSummaryPlotSourceStepping::SourceSteppingType sourceSteppingType ) const;
|
||||
|
||||
static void moveCurvesToCollection( RimSummaryCurveCollection* collection,
|
||||
const std::vector<RimSummaryCurve*> curves,
|
||||
RimSummaryCurve* curveToInsertBeforeOrAfter,
|
||||
bool isSwapOperation );
|
||||
|
||||
private:
|
||||
caf::PdmFieldHandle* objectToggleField() override;
|
||||
void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
|
||||
|
||||
@@ -163,6 +163,7 @@ RimSummaryPlot::RimSummaryPlot()
|
||||
CAF_PDM_InitFieldNoDefault( &m_summaryCurveCollection, "SummaryCurveCollection", "", "", "", "" );
|
||||
m_summaryCurveCollection.uiCapability()->setUiTreeHidden( true );
|
||||
m_summaryCurveCollection = new RimSummaryCurveCollection;
|
||||
m_summaryCurveCollection->curvesAddedOrRemoved.connect( this, &RimSummaryPlot::onCurvesAddedOrRemoved );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_ensembleCurveSetCollection, "EnsembleCurveSetCollection", "", "", "", "" );
|
||||
m_ensembleCurveSetCollection.uiCapability()->setUiTreeHidden( true );
|
||||
@@ -2096,6 +2097,15 @@ void RimSummaryPlot::handleKeyPressEvent( QKeyEvent* keyEvent )
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::onCurvesAddedOrRemoved( const SignalEmitter* emitter )
|
||||
{
|
||||
loadDataAndUpdate();
|
||||
updateStackedCurveData();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -189,6 +189,8 @@ private:
|
||||
void doRemoveFromCollection() override;
|
||||
void handleKeyPressEvent( QKeyEvent* keyEvent ) override;
|
||||
|
||||
void onCurvesAddedOrRemoved( const SignalEmitter* emitter );
|
||||
|
||||
protected:
|
||||
// Overridden PDM methods
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
|
||||
Reference in New Issue
Block a user