mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
(#467) Implemented drag & drop for moving tracks between plots
This commit is contained in:
parent
ab0e3819a1
commit
2893b29bbc
@ -19,9 +19,14 @@
|
||||
|
||||
#include "RicWellLogPlotTrackFeatureImpl.h"
|
||||
|
||||
#include "RimWellLogPlot.h"
|
||||
#include "RimWellLogPlotTrack.h"
|
||||
#include "RimWellLogPlotCurve.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "cafPdmUiTreeView.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -44,3 +49,27 @@ void RicWellLogPlotTrackFeatureImpl::moveCurvesToWellLogPlotTrack(RimWellLogPlot
|
||||
wellLogPlotTrack->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicWellLogPlotTrackFeatureImpl::moveTracksToWellLogPlot(RimWellLogPlot* wellLogPlot, const std::vector<RimWellLogPlotTrack*>& tracks)
|
||||
{
|
||||
CVF_ASSERT(wellLogPlot);
|
||||
|
||||
for (size_t tIdx = 0; tIdx < tracks.size(); tIdx++)
|
||||
{
|
||||
RimWellLogPlot* oldPlot;
|
||||
tracks[tIdx]->firstAnchestorOrThisOfType(oldPlot);
|
||||
if (oldPlot)
|
||||
{
|
||||
oldPlot->removeTrack(tracks[tIdx]);
|
||||
oldPlot->updateConnectedEditors();
|
||||
}
|
||||
|
||||
wellLogPlot->addTrack(tracks[tIdx]);
|
||||
wellLogPlot->updateTracks();
|
||||
wellLogPlot->updateConnectedEditors();
|
||||
RiuMainWindow::instance()->projectTreeView()->selectAsCurrentItem(tracks[tIdx]);
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RimWellLogPlot;
|
||||
class RimWellLogPlotTrack;
|
||||
class RimWellLogPlotCurve;
|
||||
|
||||
@ -32,4 +33,5 @@ class RicWellLogPlotTrackFeatureImpl
|
||||
public:
|
||||
|
||||
static void moveCurvesToWellLogPlotTrack(RimWellLogPlotTrack* wellLogPlotTrack, const std::vector<RimWellLogPlotCurve*>& curves);
|
||||
static void moveTracksToWellLogPlot(RimWellLogPlot* wellLogPlot, const std::vector<RimWellLogPlotTrack*>& tracks);
|
||||
};
|
||||
|
@ -170,11 +170,16 @@ caf::PdmFieldHandle* RimWellLogPlot::objectToggleField()
|
||||
void RimWellLogPlot::addTrack(RimWellLogPlotTrack* track)
|
||||
{
|
||||
tracks.push_back(track);
|
||||
if(m_viewer)
|
||||
if (m_viewer)
|
||||
{
|
||||
track->recreateViewer();
|
||||
m_viewer->insertTrackPlot(track->viewer());
|
||||
}
|
||||
|
||||
for (size_t tIdx = 0; tIdx < tracks.size(); tIdx++)
|
||||
{
|
||||
tracks[tIdx]->setDescription(QString("Track %1").arg(tIdx + 1));
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -211,12 +211,14 @@ void RimWellLogPlotTrack::loadDataAndUpdate()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellLogPlotTrack::recreateViewer()
|
||||
{
|
||||
CVF_ASSERT(m_wellLogTrackPlotWidget == NULL);
|
||||
|
||||
m_wellLogTrackPlotWidget = new RiuWellLogTrackPlot(this);
|
||||
for (size_t cIdx = 0; cIdx < curves.size(); ++cIdx)
|
||||
if (m_wellLogTrackPlotWidget == NULL)
|
||||
{
|
||||
curves[cIdx]->setPlot(this->m_wellLogTrackPlotWidget);
|
||||
m_wellLogTrackPlotWidget = new RiuWellLogTrackPlot(this);
|
||||
|
||||
for (size_t cIdx = 0; cIdx < curves.size(); ++cIdx)
|
||||
{
|
||||
curves[cIdx]->setPlot(this->m_wellLogTrackPlotWidget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "RimWellLogFileChannel.h"
|
||||
#include "RimWellLogPlotTrack.h"
|
||||
#include "RimWellLogPlotCurve.h"
|
||||
#include "RimWellLogPlot.h"
|
||||
|
||||
#include "RimWellLogPlotTrack.h"
|
||||
#include "RiuMainWindow.h"
|
||||
@ -69,6 +70,8 @@ Qt::DropActions RiuDragDrop::supportedDropActions() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
Qt::ItemFlags RiuDragDrop::flags(const QModelIndex &index) const
|
||||
{
|
||||
Qt::ItemFlags itemflags = 0;
|
||||
|
||||
if (index.isValid())
|
||||
{
|
||||
caf::PdmUiTreeView* uiTreeView = RiuMainWindow::instance()->projectTreeView();
|
||||
@ -76,20 +79,22 @@ Qt::ItemFlags RiuDragDrop::flags(const QModelIndex &index) const
|
||||
|
||||
if (dynamic_cast<RimIdenticalGridCaseGroup*>(uiItem) ||
|
||||
dynamic_cast<RimCaseCollection*>(uiItem) ||
|
||||
dynamic_cast<RimWellLogPlot*>(uiItem) ||
|
||||
dynamic_cast<RimWellLogPlotTrack*>(uiItem))
|
||||
{
|
||||
return Qt::ItemIsDropEnabled;
|
||||
itemflags |= Qt::ItemIsDropEnabled;
|
||||
}
|
||||
else if (dynamic_cast<RimEclipseCase*>(uiItem) ||
|
||||
|
||||
if (dynamic_cast<RimEclipseCase*>(uiItem) ||
|
||||
dynamic_cast<RimWellLogPlotCurve*>(uiItem) ||
|
||||
dynamic_cast<RimWellLogPlotTrack*>(uiItem) ||
|
||||
dynamic_cast<RimWellLogFileChannel*>(uiItem))
|
||||
{
|
||||
// TODO: Remember to handle reservoir holding the main grid
|
||||
return Qt::ItemIsDragEnabled;
|
||||
itemflags |= Qt::ItemIsDragEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
Qt::ItemFlags itemflags;
|
||||
return itemflags;
|
||||
}
|
||||
|
||||
@ -137,6 +142,13 @@ bool RiuDragDrop::dropMimeData(const QMimeData *data, Qt::DropAction action, int
|
||||
{
|
||||
return handleWellLogPlotTrackDrop(action, objectGroup, wellLogPlotTrack);
|
||||
}
|
||||
|
||||
RimWellLogPlot* wellLogPlot;
|
||||
objHandle->firstAnchestorOrThisOfType(wellLogPlot);
|
||||
if (wellLogPlot)
|
||||
{
|
||||
return handleWellLogPlotDrop(action, objectGroup, wellLogPlot);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -252,7 +264,34 @@ bool RiuDragDrop::handleWellLogPlotTrackDrop(Qt::DropAction action, caf::PdmObje
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiuDragDrop::handleWellLogPlotDrop(Qt::DropAction action, caf::PdmObjectGroup& objectGroup, RimWellLogPlot* wellLogPlot)
|
||||
{
|
||||
std::vector<caf::PdmPointer<RimWellLogPlotTrack> > typedObjects;
|
||||
objectGroup.objectsByType(&typedObjects);
|
||||
if (typedObjects.size() > 0)
|
||||
{
|
||||
std::vector<RimWellLogPlotTrack*> wellLogPlotTracks;
|
||||
for (size_t cIdx = 0; cIdx < typedObjects.size(); cIdx++)
|
||||
{
|
||||
wellLogPlotTracks.push_back(typedObjects[cIdx]);
|
||||
}
|
||||
|
||||
if (wellLogPlotTracks.size() > 0)
|
||||
{
|
||||
if (action == Qt::CopyAction)
|
||||
{
|
||||
RicWellLogPlotTrackFeatureImpl::moveTracksToWellLogPlot(wellLogPlot, wellLogPlotTracks);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
class RimIdenticalGridCaseGroup;
|
||||
class RimWellLogPlotTrack;
|
||||
class RimWellLogPlot;
|
||||
|
||||
namespace caf
|
||||
{
|
||||
@ -48,5 +49,6 @@ private:
|
||||
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);
|
||||
bool handleWellLogPlotDrop(Qt::DropAction action, caf::PdmObjectGroup& objectGroup, RimWellLogPlot* wellLogPlot);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user