mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#467) Implemented tree view drag & drop of LAS file well log channels to plot tracks
Did some refactoring/cleanup of existing drag & drop code to make it easier to add drag & drop for other item types.
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
#include "RimWellLogFileCurve.h"
|
#include "RimWellLogFileCurve.h"
|
||||||
#include "RimWellLogPlotTrack.h"
|
#include "RimWellLogPlotTrack.h"
|
||||||
#include "RimWellLogFile.h"
|
#include "RimWellLogFile.h"
|
||||||
|
#include "RimWellLogFileChannel.h"
|
||||||
#include "RimWellPath.h"
|
#include "RimWellPath.h"
|
||||||
#include "RimWellPathCollection.h"
|
#include "RimWellPathCollection.h"
|
||||||
#include "RimProject.h"
|
#include "RimProject.h"
|
||||||
@@ -157,3 +158,24 @@ RimWellLogFileCurve* RicNewWellLogFileCurveFeature::addCurve(RimWellLogPlotTrack
|
|||||||
|
|
||||||
return curve;
|
return curve;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicNewWellLogFileCurveFeature::addWellLogChannelsToPlotTrack(RimWellLogPlotTrack* plotTrack, const std::vector<RimWellLogFileChannel*>& wellLogFileChannels)
|
||||||
|
{
|
||||||
|
for (size_t cIdx = 0; cIdx < wellLogFileChannels.size(); cIdx++)
|
||||||
|
{
|
||||||
|
RimWellLogFileCurve* plotCurve = addCurve(plotTrack);
|
||||||
|
|
||||||
|
RimWellPath* wellPath;
|
||||||
|
wellLogFileChannels[cIdx]->firstAnchestorOrThisOfType(wellPath);
|
||||||
|
if (wellPath)
|
||||||
|
{
|
||||||
|
plotCurve->setWellPath(wellPath);
|
||||||
|
plotCurve->setWellLogChannelName(wellLogFileChannels[cIdx]->name());
|
||||||
|
plotCurve->updatePlotData();
|
||||||
|
plotCurve->updateConnectedEditors();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -21,9 +21,13 @@
|
|||||||
|
|
||||||
#include "cafCmdFeature.h"
|
#include "cafCmdFeature.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class RimWellLogPlotTrack;
|
class RimWellLogPlotTrack;
|
||||||
class RimWellLogFileCurve;
|
class RimWellLogFileCurve;
|
||||||
class RimWellPath;
|
class RimWellPath;
|
||||||
|
class RimWellLogFileChannel;
|
||||||
|
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
///
|
///
|
||||||
@@ -35,6 +39,7 @@ class RicNewWellLogFileCurveFeature : public caf::CmdFeature
|
|||||||
public:
|
public:
|
||||||
static RimWellLogFileCurve* addCurve(RimWellLogPlotTrack* plotTrack);
|
static RimWellLogFileCurve* addCurve(RimWellLogPlotTrack* plotTrack);
|
||||||
|
|
||||||
|
static void addWellLogChannelsToPlotTrack(RimWellLogPlotTrack* plotTrack, const std::vector<RimWellLogFileChannel*>& wellLogFileChannels);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Overrides
|
// Overrides
|
||||||
|
|||||||
@@ -21,12 +21,15 @@
|
|||||||
|
|
||||||
#include "OperationsUsingObjReferences/RicPasteEclipseCasesFeature.h"
|
#include "OperationsUsingObjReferences/RicPasteEclipseCasesFeature.h"
|
||||||
#include "RicCloseCaseFeature.h"
|
#include "RicCloseCaseFeature.h"
|
||||||
|
#include "WellLogCommands/RicNewWellLogFileCurveFeature.h"
|
||||||
|
|
||||||
#include "RimCaseCollection.h"
|
#include "RimCaseCollection.h"
|
||||||
#include "RimEclipseCase.h"
|
#include "RimEclipseCase.h"
|
||||||
#include "RimEclipseResultCase.h"
|
#include "RimEclipseResultCase.h"
|
||||||
#include "RimIdenticalGridCaseGroup.h"
|
#include "RimIdenticalGridCaseGroup.h"
|
||||||
#include "RimMimeData.h"
|
#include "RimMimeData.h"
|
||||||
|
#include "RimWellLogFileChannel.h"
|
||||||
|
#include "RimWellLogPlotTrack.h"
|
||||||
|
|
||||||
#include "RiuMainWindow.h"
|
#include "RiuMainWindow.h"
|
||||||
|
|
||||||
@@ -69,11 +72,13 @@ Qt::ItemFlags RiuDragDrop::flags(const QModelIndex &index) const
|
|||||||
caf::PdmUiItem* uiItem = uiTreeView->uiItemFromModelIndex(index);
|
caf::PdmUiItem* uiItem = uiTreeView->uiItemFromModelIndex(index);
|
||||||
|
|
||||||
if (dynamic_cast<RimIdenticalGridCaseGroup*>(uiItem) ||
|
if (dynamic_cast<RimIdenticalGridCaseGroup*>(uiItem) ||
|
||||||
dynamic_cast<RimCaseCollection*>(uiItem))
|
dynamic_cast<RimCaseCollection*>(uiItem) ||
|
||||||
|
dynamic_cast<RimWellLogPlotTrack*>(uiItem))
|
||||||
{
|
{
|
||||||
return Qt::ItemIsDropEnabled;
|
return Qt::ItemIsDropEnabled;
|
||||||
}
|
}
|
||||||
else if (dynamic_cast<RimEclipseCase*>(uiItem))
|
else if (dynamic_cast<RimEclipseCase*>(uiItem) ||
|
||||||
|
dynamic_cast<RimWellLogFileChannel*>(uiItem))
|
||||||
{
|
{
|
||||||
// TODO: Remember to handle reservoir holding the main grid
|
// TODO: Remember to handle reservoir holding the main grid
|
||||||
return Qt::ItemIsDragEnabled;
|
return Qt::ItemIsDragEnabled;
|
||||||
@@ -90,46 +95,44 @@ Qt::ItemFlags RiuDragDrop::flags(const QModelIndex &index) const
|
|||||||
bool RiuDragDrop::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
|
bool RiuDragDrop::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
|
||||||
{
|
{
|
||||||
caf::PdmUiTreeView* uiTreeView = RiuMainWindow::instance()->projectTreeView();
|
caf::PdmUiTreeView* uiTreeView = RiuMainWindow::instance()->projectTreeView();
|
||||||
RimIdenticalGridCaseGroup* gridCaseGroup = NULL;
|
caf::PdmUiItem* dropTarget = uiTreeView->uiItemFromModelIndex(parent);
|
||||||
|
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>(dropTarget);
|
||||||
|
if (objHandle)
|
||||||
{
|
{
|
||||||
caf::PdmUiItem* dropTarget = uiTreeView->uiItemFromModelIndex(parent);
|
caf::PdmObjectGroup objectGroup;
|
||||||
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>(dropTarget);
|
const MimeDataWithIndexes* myMimeData = qobject_cast<const MimeDataWithIndexes*>(data);
|
||||||
if (objHandle)
|
if (myMimeData && parent.isValid())
|
||||||
{
|
{
|
||||||
objHandle->firstAnchestorOrThisOfType(gridCaseGroup);
|
for (int i = 0; i < myMimeData->indexes().size(); i++)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!gridCaseGroup) return false;
|
|
||||||
|
|
||||||
const MimeDataWithIndexes* myMimeData = qobject_cast<const MimeDataWithIndexes*>(data);
|
|
||||||
if (myMimeData && parent.isValid())
|
|
||||||
{
|
|
||||||
caf::PdmObjectGroup pog;
|
|
||||||
|
|
||||||
for (int i = 0; i < myMimeData->indexes().size(); i++)
|
|
||||||
{
|
|
||||||
QModelIndex mi = myMimeData->indexes().at(i);
|
|
||||||
caf::PdmUiItem* currentItem = uiTreeView->uiItemFromModelIndex(mi);
|
|
||||||
caf::PdmObjectHandle* pdmObj = dynamic_cast<caf::PdmObjectHandle*>(currentItem);
|
|
||||||
|
|
||||||
if (pdmObj)
|
|
||||||
{
|
{
|
||||||
pog.objects.push_back(pdmObj);
|
QModelIndex mi = myMimeData->indexes().at(i);
|
||||||
|
caf::PdmUiItem* currentItem = uiTreeView->uiItemFromModelIndex(mi);
|
||||||
|
caf::PdmObjectHandle* pdmObj = dynamic_cast<caf::PdmObjectHandle*>(currentItem);
|
||||||
|
|
||||||
|
if (pdmObj)
|
||||||
|
{
|
||||||
|
objectGroup.objects.push_back(pdmObj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (action == Qt::CopyAction)
|
|
||||||
{
|
{
|
||||||
caf::RicPasteEclipseCasesFeature::addCasesToGridCaseGroup(pog, gridCaseGroup);
|
return false;
|
||||||
}
|
|
||||||
else if (action == Qt::MoveAction)
|
|
||||||
{
|
|
||||||
moveCasesToGridGroup(pog, gridCaseGroup);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
RimIdenticalGridCaseGroup* gridCaseGroup;
|
||||||
|
objHandle->firstAnchestorOrThisOfType(gridCaseGroup);
|
||||||
|
if (gridCaseGroup)
|
||||||
|
{
|
||||||
|
return handleGridCaseGroupDrop(action, objectGroup, gridCaseGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
RimWellLogPlotTrack* wellLogPlotTrack;
|
||||||
|
objHandle->firstAnchestorOrThisOfType(wellLogPlotTrack);
|
||||||
|
if (wellLogPlotTrack)
|
||||||
|
{
|
||||||
|
return handleWellLogPlotTrackDrop(action, objectGroup, wellLogPlotTrack);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -181,3 +184,46 @@ void RiuDragDrop::moveCasesToGridGroup(caf::PdmObjectGroup& objectGroup, RimIden
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RiuDragDrop::handleGridCaseGroupDrop(Qt::DropAction action, caf::PdmObjectGroup& objectGroup, RimIdenticalGridCaseGroup* gridCaseGroup)
|
||||||
|
{
|
||||||
|
if (action == Qt::CopyAction)
|
||||||
|
{
|
||||||
|
caf::RicPasteEclipseCasesFeature::addCasesToGridCaseGroup(objectGroup, gridCaseGroup);
|
||||||
|
}
|
||||||
|
else if (action == Qt::MoveAction)
|
||||||
|
{
|
||||||
|
moveCasesToGridGroup(objectGroup, gridCaseGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RiuDragDrop::handleWellLogPlotTrackDrop(Qt::DropAction action, caf::PdmObjectGroup& objectGroup, RimWellLogPlotTrack* wellLogPlotTrack)
|
||||||
|
{
|
||||||
|
std::vector<caf::PdmPointer<RimWellLogFileChannel> > typedObjects;
|
||||||
|
objectGroup.objectsByType(&typedObjects);
|
||||||
|
|
||||||
|
std::vector<RimWellLogFileChannel*> wellLogFileChannels;
|
||||||
|
for (size_t cIdx = 0; cIdx < typedObjects.size(); cIdx++)
|
||||||
|
{
|
||||||
|
wellLogFileChannels.push_back(typedObjects[cIdx]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wellLogFileChannels.size() > 0)
|
||||||
|
{
|
||||||
|
if (action == Qt::CopyAction)
|
||||||
|
{
|
||||||
|
RicNewWellLogFileCurveFeature::addWellLogChannelsToPlotTrack(wellLogPlotTrack, wellLogFileChannels);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "cafPdmUiDragDropHandle.h"
|
#include "cafPdmUiDragDropHandle.h"
|
||||||
|
|
||||||
class RimIdenticalGridCaseGroup;
|
class RimIdenticalGridCaseGroup;
|
||||||
|
class RimWellLogPlotTrack;
|
||||||
|
|
||||||
namespace caf
|
namespace caf
|
||||||
{
|
{
|
||||||
@@ -45,5 +46,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void moveCasesToGridGroup(caf::PdmObjectGroup& objectGroup, RimIdenticalGridCaseGroup* gridCaseGroup);
|
void moveCasesToGridGroup(caf::PdmObjectGroup& objectGroup, RimIdenticalGridCaseGroup* gridCaseGroup);
|
||||||
|
bool handleGridCaseGroupDrop(Qt::DropAction action, caf::PdmObjectGroup& objectGroup, RimIdenticalGridCaseGroup* gridCaseGroup);
|
||||||
|
bool handleWellLogPlotTrackDrop(Qt::DropAction action, caf::PdmObjectGroup& objectGroup, RimWellLogPlotTrack* wellLogPlotTrack);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user