mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Summary Multiplot: drag/drop updates (#8692)
Drag'n'drop improvements - accept drops in empty multiplot areas to create new plots
This commit is contained in:
@@ -260,30 +260,6 @@ void RimMultiPlot::movePlotsToThis( const std::vector<RimPlot*>& plotsToMove, in
|
||||
this->updateAllRequiredEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimMultiPlot::insertPlots( const std::vector<RimPlot*>& plots )
|
||||
{
|
||||
for ( auto plot : plots )
|
||||
{
|
||||
if ( plot )
|
||||
{
|
||||
setTickmarkCount( plot, m_majorTickmarkCount() );
|
||||
m_plots.insert( -1, plot );
|
||||
|
||||
if ( m_viewer )
|
||||
{
|
||||
plot->createPlotWidget();
|
||||
m_viewer->insertPlot( plot->plotWidget(), -1 );
|
||||
}
|
||||
plot->setShowWindow( true );
|
||||
plot->updateAfterInsertingIntoMultiPlot();
|
||||
}
|
||||
}
|
||||
onPlotAdditionOrRemoval();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -77,7 +77,6 @@ public:
|
||||
void removePlot( RimPlot* plot ) override;
|
||||
void movePlotsToThis( const std::vector<RimPlot*>& plots, int insertAtPosition );
|
||||
|
||||
void insertPlots( const std::vector<RimPlot*>& plots );
|
||||
void deleteAllPlots() override;
|
||||
|
||||
size_t plotCount() const override;
|
||||
|
||||
@@ -92,7 +92,10 @@ void RimSummaryMultiPlot::addPlot( RimPlot* plot )
|
||||
{
|
||||
RimSummaryPlot* sumPlot = dynamic_cast<RimSummaryPlot*>( plot );
|
||||
CVF_ASSERT( sumPlot != nullptr );
|
||||
if ( sumPlot ) RimMultiPlot::addPlot( plot );
|
||||
if ( sumPlot )
|
||||
{
|
||||
RimMultiPlot::addPlot( plot );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -102,7 +105,36 @@ void RimSummaryMultiPlot::insertPlot( RimPlot* plot, size_t index )
|
||||
{
|
||||
RimSummaryPlot* sumPlot = dynamic_cast<RimSummaryPlot*>( plot );
|
||||
CVF_ASSERT( sumPlot != nullptr );
|
||||
if ( sumPlot ) RimMultiPlot::insertPlot( plot, index );
|
||||
if ( sumPlot )
|
||||
{
|
||||
RimMultiPlot::insertPlot( plot, index );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryMultiPlot::addPlot( const std::vector<caf::PdmObjectHandle*>& objects )
|
||||
{
|
||||
RimSummaryPlot* plot = new RimSummaryPlot();
|
||||
plot->enableAutoPlotTitle( true );
|
||||
|
||||
addPlot( plot );
|
||||
|
||||
plot->handleDroppedObjects( objects );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryMultiPlot::removePlot( RimPlot* plot )
|
||||
{
|
||||
RimSummaryPlot* sumPlot = dynamic_cast<RimSummaryPlot*>( plot );
|
||||
CVF_ASSERT( sumPlot != nullptr );
|
||||
if ( sumPlot )
|
||||
{
|
||||
RimMultiPlot::removePlot( plot );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "cafPdmChildField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPtrArrayField.h"
|
||||
#include "cafSignal.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
@@ -56,11 +57,14 @@ public:
|
||||
|
||||
void addPlot( RimPlot* plot ) override;
|
||||
void insertPlot( RimPlot* plot, size_t index ) override;
|
||||
void removePlot( RimPlot* plot ) override;
|
||||
|
||||
std::vector<caf::PdmFieldHandle*> fieldsToShowInToolbar();
|
||||
|
||||
void syncAxisRanges();
|
||||
|
||||
void addPlot( const std::vector<caf::PdmObjectHandle*>& objects );
|
||||
|
||||
protected:
|
||||
bool handleGlobalKeyEvent( QKeyEvent* keyEvent ) override;
|
||||
bool handleGlobalWheelEvent( QWheelEvent* wheelEvent ) override;
|
||||
|
||||
@@ -94,7 +94,8 @@ CAF_PDM_SOURCE_INIT( RimSummaryPlot, "SummaryPlot" );
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryPlot::RimSummaryPlot( bool isCrossPlot )
|
||||
: m_isCrossPlot( isCrossPlot )
|
||||
: RimPlot()
|
||||
, m_isCrossPlot( isCrossPlot )
|
||||
{
|
||||
CAF_PDM_InitScriptableObject( "Summary Plot", ":/SummaryPlotLight16x16.png", "", "A Summary Plot" );
|
||||
|
||||
@@ -1972,6 +1973,34 @@ int RimSummaryPlot::handleAddressCollectionDrop( RimSummaryAddressCollection* ad
|
||||
return newCurves;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RimSummaryPlot::handleSummaryAddressDrop( RimSummaryAddress* summaryAddr )
|
||||
{
|
||||
int newCurves = 0;
|
||||
|
||||
if ( summaryAddr->isEnsemble() )
|
||||
{
|
||||
auto ensemble = RiaSummaryTools::ensembleById( summaryAddr->ensembleId() );
|
||||
if ( ensemble )
|
||||
{
|
||||
addNewEnsembleCurveY( summaryAddr->address(), ensemble );
|
||||
newCurves++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto summaryCase = RiaSummaryTools::summaryCaseById( summaryAddr->caseId() );
|
||||
if ( summaryCase )
|
||||
{
|
||||
addNewCurveY( summaryAddr->address(), summaryCase );
|
||||
newCurves++;
|
||||
}
|
||||
}
|
||||
return newCurves;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1988,26 +2017,10 @@ void RimSummaryPlot::handleDroppedObjects( const std::vector<caf::PdmObjectHandl
|
||||
continue;
|
||||
}
|
||||
|
||||
auto summaryAdr = dynamic_cast<RimSummaryAddress*>( obj );
|
||||
if ( summaryAdr )
|
||||
auto summaryAddr = dynamic_cast<RimSummaryAddress*>( obj );
|
||||
if ( summaryAddr )
|
||||
{
|
||||
if ( summaryAdr->isEnsemble() )
|
||||
{
|
||||
auto ensemble = RiaSummaryTools::ensembleById( summaryAdr->ensembleId() );
|
||||
if ( ensemble )
|
||||
{
|
||||
addNewEnsembleCurveY( summaryAdr->address(), ensemble );
|
||||
newCurves++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
auto summaryCase = RiaSummaryTools::summaryCaseById( summaryAdr->caseId() );
|
||||
if ( summaryCase )
|
||||
{
|
||||
addNewCurveY( summaryAdr->address(), summaryCase );
|
||||
newCurves++;
|
||||
}
|
||||
newCurves += handleSummaryAddressDrop( summaryAddr );
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "RiuSummaryPlot.h"
|
||||
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmObjectHandle.h"
|
||||
#include "cafPdmPtrArrayField.h"
|
||||
#include "cafPdmPtrField.h"
|
||||
|
||||
@@ -37,10 +38,12 @@
|
||||
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
class PdmUiTreeOrdering;
|
||||
class RimAsciiDataCurve;
|
||||
class RimGridTimeHistoryCurve;
|
||||
class RimSummaryAddress;
|
||||
class RimSummaryAddressCollection;
|
||||
class RimSummaryCase;
|
||||
class RimSummaryCaseCollection;
|
||||
@@ -199,6 +202,8 @@ public:
|
||||
|
||||
bool isDeletable() const override;
|
||||
|
||||
void handleDroppedObjects( const std::vector<caf::PdmObjectHandle*>& objects ) override;
|
||||
|
||||
private:
|
||||
RiuPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override;
|
||||
|
||||
@@ -226,7 +231,6 @@ protected:
|
||||
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
void onLoadDataAndUpdate() override;
|
||||
void handleDroppedObjects( const std::vector<caf::PdmObjectHandle*>& objects ) override;
|
||||
|
||||
QImage snapshotWindowContent() override;
|
||||
|
||||
@@ -278,6 +282,7 @@ private:
|
||||
|
||||
int handleSummaryCaseDrop( RimSummaryCase* summaryCase );
|
||||
int handleAddressCollectionDrop( RimSummaryAddressCollection* addrColl );
|
||||
int handleSummaryAddressDrop( RimSummaryAddress* summaryAddr );
|
||||
|
||||
bool isOnlyWaterCutCurvesVisible( RiuPlotAxis plotAxis );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user