mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Surface: Support for folders, copy and drag'n'drop (#6335)
* Enable surface reordering support. Automatically update surface in view ordering based on surface collection ordering * Remove obsolete code * Enable drag'n'drop support for surfaces within a surface collection. Still missing the collection update part. * Bring back code lost in prev. commit * Add code to accept drops in surface collections. Keep view in sync. * Add command for adding additional surface folders. * Make sure we use the current surface collection as our parent when importing * Enable name editing. Make sure we use the correct surface collection when importing/creating surfaces * More work on getting surface collections working. * Clean up naming * Make sure name for surfaceinviewcollection is read only * Support drawing surfaces from subcollections, too * Allow deleting subfolders. Fix legends in view * Refactor topmost flag for surface collections. * Fix reload surface to work in all subfolders, too Add copy surface skeleton. Actual copy operation is still missing * Add support for copying surfaces * Remove possibility to choose I and J slice directions for grid case surfaces. * Fix warnings. * Make sure we create the surface folder at the correct level * More warning fix * Use XML serialization for copy operation * Fix missing delete * Fix typo * Remove unnecessary method.
This commit is contained in:
@@ -39,6 +39,8 @@
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RimSummaryCurveCollection.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimSurface.h"
|
||||
#include "RimSurfaceCollection.h"
|
||||
#include "RimWellAllocationPlot.h"
|
||||
#include "RimWellLogCurve.h"
|
||||
#include "RimWellLogFileChannel.h"
|
||||
@@ -223,7 +225,8 @@ Qt::ItemFlags RiuDragDrop::flags( const QModelIndex& index ) const
|
||||
|
||||
if ( dynamic_cast<RimEclipseCase*>( uiItem ) || dynamic_cast<RimWellLogCurve*>( uiItem ) ||
|
||||
dynamic_cast<RimWellLogFileChannel*>( uiItem ) || dynamic_cast<RimPlot*>( uiItem ) ||
|
||||
dynamic_cast<RimSummaryCase*>( uiItem ) || dynamic_cast<RimSummaryCurve*>( uiItem ) )
|
||||
dynamic_cast<RimSummaryCase*>( uiItem ) || dynamic_cast<RimSummaryCurve*>( uiItem ) ||
|
||||
dynamic_cast<RimSurface*>( uiItem ) )
|
||||
{
|
||||
// TODO: Remember to handle reservoir holding the main grid
|
||||
itemflags |= Qt::ItemIsDragEnabled;
|
||||
@@ -297,6 +300,13 @@ Qt::ItemFlags RiuDragDrop::flags( const QModelIndex& index ) const
|
||||
itemflags |= Qt::ItemIsDropEnabled;
|
||||
}
|
||||
}
|
||||
else if ( dynamic_cast<RimSurfaceCollection*>( uiItem ) )
|
||||
{
|
||||
if ( RiuTypedPdmObjects<RimSurface>::containsTypedObjects( m_dragItems ) )
|
||||
{
|
||||
itemflags |= Qt::ItemIsDropEnabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( m_proposedDropAction == Qt::CopyAction )
|
||||
{
|
||||
@@ -397,6 +407,13 @@ bool RiuDragDrop::dropMimeData( const QMimeData* data, Qt::DropAction action, in
|
||||
{
|
||||
return handleSummaryCaseMainCollectionDrop( action, draggedObjects, summaryCaseMainCollection );
|
||||
}
|
||||
|
||||
RimSurfaceCollection* surfaceCollection;
|
||||
dropTarget->firstAncestorOrThisOfType( surfaceCollection );
|
||||
if ( surfaceCollection )
|
||||
{
|
||||
return handleSurfaceCollectionDrop( action, row, draggedObjects, surfaceCollection );
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -681,3 +698,33 @@ void RiuDragDrop::onProposedDropActionUpdated( Qt::DropAction action )
|
||||
{
|
||||
m_proposedDropAction = action;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiuDragDrop::handleSurfaceCollectionDrop( Qt::DropAction action,
|
||||
int row,
|
||||
caf::PdmObjectGroup& objectGroup,
|
||||
RimSurfaceCollection* targetCollection )
|
||||
{
|
||||
std::vector<RimSurface*> surfaces = RiuTypedPdmObjects<RimSurface>::typedObjectsFromGroup( objectGroup );
|
||||
|
||||
if ( action != Qt::MoveAction || surfaces.size() == 0 ) return false;
|
||||
|
||||
for ( RimSurface* surface : surfaces )
|
||||
{
|
||||
RimSurfaceCollection* sourceCollection;
|
||||
surface->firstAncestorOrThisOfType( sourceCollection );
|
||||
|
||||
if ( sourceCollection )
|
||||
{
|
||||
sourceCollection->removeSurface( surface );
|
||||
sourceCollection->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
|
||||
targetCollection->addSurfacesAtIndex( row, surfaces );
|
||||
targetCollection->updateConnectedEditors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user