mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#467) Implemented drag & drop for moving tracks after drop target track
This commit is contained in:
parent
32d49e4ba3
commit
e2eaf5f1a3
@ -83,3 +83,19 @@ void RicWellLogPlotTrackFeatureImpl::moveTracksToWellLogPlot(RimWellLogPlot* wel
|
||||
RiuMainWindow::instance()->projectTreeView()->selectAsCurrentItem(wellLogPlotTrack);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicWellLogPlotTrackFeatureImpl::moveTracks(RimWellLogPlotTrack* insertAfterTrack, const std::vector<RimWellLogPlotTrack*>& tracks)
|
||||
{
|
||||
CVF_ASSERT(insertAfterTrack);
|
||||
|
||||
RimWellLogPlot* wellLogPlot;
|
||||
insertAfterTrack->firstAnchestorOrThisOfType(wellLogPlot);
|
||||
if (wellLogPlot)
|
||||
{
|
||||
wellLogPlot->moveTracks(insertAfterTrack, tracks);
|
||||
wellLogPlot->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
|
@ -34,4 +34,5 @@ public:
|
||||
|
||||
static void moveCurvesToWellLogPlotTrack(RimWellLogPlotTrack* wellLogPlotTrack, const std::vector<RimWellLogPlotCurve*>& curves);
|
||||
static void moveTracksToWellLogPlot(RimWellLogPlot* wellLogPlot, const std::vector<RimWellLogPlotTrack*>& tracks);
|
||||
static void moveTracks(RimWellLogPlotTrack* insertAfterTrack, const std::vector<RimWellLogPlotTrack*>& tracks);
|
||||
};
|
||||
|
@ -173,13 +173,26 @@ void RimWellLogPlot::addTrack(RimWellLogPlotTrack* track)
|
||||
if (m_viewer)
|
||||
{
|
||||
track->recreateViewer();
|
||||
m_viewer->insertTrackPlot(track->viewer());
|
||||
m_viewer->addTrackPlot(track->viewer());
|
||||
}
|
||||
|
||||
for (size_t tIdx = 0; tIdx < tracks.size(); tIdx++)
|
||||
updateTrackNames();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellLogPlot::insertTrack(RimWellLogPlotTrack* track, size_t index)
|
||||
{
|
||||
tracks.insert(index, track);
|
||||
|
||||
if (m_viewer)
|
||||
{
|
||||
tracks[tIdx]->setDescription(QString("Track %1").arg(tIdx + 1));
|
||||
track->recreateViewer();
|
||||
m_viewer->insertTrackPlot(track->viewer(), index);
|
||||
}
|
||||
|
||||
updateTrackNames();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -194,6 +207,35 @@ void RimWellLogPlot::removeTrack(RimWellLogPlotTrack* track)
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellLogPlot::moveTracks(RimWellLogPlotTrack* insertAfterTrack, const std::vector<RimWellLogPlotTrack*>& tracksToMove)
|
||||
{
|
||||
for (size_t tIdx = 0; tIdx < tracksToMove.size(); tIdx++)
|
||||
{
|
||||
RimWellLogPlotTrack* track = tracksToMove[tIdx];
|
||||
|
||||
RimWellLogPlot* wellLogPlot;
|
||||
track->firstAnchestorOrThisOfType(wellLogPlot);
|
||||
if (wellLogPlot)
|
||||
{
|
||||
wellLogPlot->removeTrack(track);
|
||||
wellLogPlot->updateTrackNames();
|
||||
wellLogPlot->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
|
||||
size_t index = tracks.index(insertAfterTrack) + 1;
|
||||
|
||||
for (size_t tIdx = 0; tIdx < tracksToMove.size(); tIdx++)
|
||||
{
|
||||
insertTrack(tracksToMove[tIdx], index + tIdx);
|
||||
}
|
||||
|
||||
updateTrackNames();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -355,6 +397,16 @@ void RimWellLogPlot::updateTracks()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellLogPlot::updateTrackNames()
|
||||
{
|
||||
for (size_t tIdx = 0; tIdx < tracks.size(); tIdx++)
|
||||
{
|
||||
tracks[tIdx]->setDescription(QString("Track %1").arg(tIdx + 1));
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -396,7 +448,7 @@ void RimWellLogPlot::recreateTrackPlots()
|
||||
for (size_t tIdx = 0; tIdx < tracks.size(); ++tIdx)
|
||||
{
|
||||
tracks[tIdx]->recreateViewer();
|
||||
m_viewer->insertTrackPlot(tracks[tIdx]->viewer());
|
||||
m_viewer->addTrackPlot(tracks[tIdx]->viewer());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,11 +53,14 @@ public:
|
||||
void updateViewerWidgetWindowTitle();
|
||||
|
||||
void addTrack(RimWellLogPlotTrack* track);
|
||||
void insertTrack(RimWellLogPlotTrack* track, size_t index);
|
||||
size_t trackCount() { return tracks.size();}
|
||||
void removeTrack(RimWellLogPlotTrack* track);
|
||||
void moveTracks(RimWellLogPlotTrack* insertAfterTrack, const std::vector<RimWellLogPlotTrack*>& tracks);
|
||||
|
||||
void loadDataAndUpdate();
|
||||
void updateTracks();
|
||||
void updateTrackNames();
|
||||
|
||||
RiuWellLogPlot* viewer();
|
||||
|
||||
|
@ -105,8 +105,6 @@ 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();
|
||||
@ -114,22 +112,25 @@ 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))
|
||||
dynamic_cast<RimWellLogPlot*>(uiItem))
|
||||
{
|
||||
itemflags |= Qt::ItemIsDropEnabled;
|
||||
return Qt::ItemIsDropEnabled;
|
||||
//cvf::Trace::show("");
|
||||
}
|
||||
|
||||
if (dynamic_cast<RimEclipseCase*>(uiItem) ||
|
||||
dynamic_cast<RimWellLogPlotCurve*>(uiItem) ||
|
||||
dynamic_cast<RimWellLogPlotTrack*>(uiItem) ||
|
||||
else if (dynamic_cast<RimEclipseCase*>(uiItem) ||
|
||||
dynamic_cast<RimWellLogFileChannel*>(uiItem))
|
||||
{
|
||||
// TODO: Remember to handle reservoir holding the main grid
|
||||
itemflags |= Qt::ItemIsDragEnabled;
|
||||
return Qt::ItemIsDragEnabled;
|
||||
}
|
||||
else if (dynamic_cast<RimWellLogPlotCurve*>(uiItem) ||
|
||||
dynamic_cast<RimWellLogPlotTrack*>(uiItem))
|
||||
{
|
||||
return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
Qt::ItemFlags itemflags = 0;
|
||||
return itemflags;
|
||||
}
|
||||
|
||||
@ -269,6 +270,16 @@ bool RiuDragDrop::handleWellLogPlotTrackDrop(Qt::DropAction action, caf::PdmObje
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<RimWellLogPlotTrack*> wellLogPlotTracks = RiuTypedObjectsFromObjectGroupGetter<RimWellLogPlotTrack>::typedObjectsFromGroup(objectGroup);
|
||||
if (wellLogPlotTracks.size() > 0)
|
||||
{
|
||||
if (action == Qt::MoveAction)
|
||||
{
|
||||
RicWellLogPlotTrackFeatureImpl::moveTracks(wellLogPlotTrack, wellLogPlotTracks);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -70,11 +70,19 @@ RiuWellLogPlot::~RiuWellLogPlot()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::insertTrackPlot(RiuWellLogTrackPlot* trackPlot)
|
||||
void RiuWellLogPlot::addTrackPlot(RiuWellLogTrackPlot* trackPlot)
|
||||
{
|
||||
// Insert the plot to the left of the scroll bar
|
||||
m_layout->insertWidget(m_layout->count() - 1, trackPlot);
|
||||
m_trackPlots.append(trackPlot);
|
||||
insertTrackPlot(trackPlot, m_layout->count() - 1);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlot::insertTrackPlot(RiuWellLogTrackPlot* trackPlot, size_t index)
|
||||
{
|
||||
m_layout->insertWidget(index, trackPlot);
|
||||
m_trackPlots.append(trackPlot); // insert?
|
||||
|
||||
modifyWidthOfContainingMdiWindow(trackPlot->width());
|
||||
}
|
||||
|
@ -45,7 +45,8 @@ public:
|
||||
|
||||
RimWellLogPlot* ownerPlotDefinition();
|
||||
|
||||
void insertTrackPlot(RiuWellLogTrackPlot* trackPlot);
|
||||
void addTrackPlot(RiuWellLogTrackPlot* trackPlot);
|
||||
void insertTrackPlot(RiuWellLogTrackPlot* trackPlot, size_t index);
|
||||
void removeTrackPlot(RiuWellLogTrackPlot* trackPlot);
|
||||
|
||||
void setDepthRangeAndReplot(double minDepth, double maxDepth);
|
||||
|
Loading…
Reference in New Issue
Block a user