mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#467) Implemented drag & drop for moving curves between tracks
This commit is contained in:
parent
3a01fe0782
commit
1c3e9d8751
@ -14,6 +14,7 @@ ${CEE_CURRENT_LIST_DIR}RicNewWellLogPlotTrackFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicWellLogPlotCurveFeatureImpl.h
|
||||
${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicDeleteWellLogPlotTrackFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicWellLogPlotTrackFeatureImpl.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@ -26,6 +27,7 @@ ${CEE_CURRENT_LIST_DIR}RicNewWellLogPlotTrackFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicWellLogPlotCurveFeatureImpl.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicDeleteWellLogPlotTrackFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicWellLogPlotTrackFeatureImpl.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@ -0,0 +1,46 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicWellLogPlotTrackFeatureImpl.h"
|
||||
|
||||
#include "RimWellLogPlotTrack.h"
|
||||
#include "RimWellLogPlotCurve.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicWellLogPlotTrackFeatureImpl::moveCurvesToWellLogPlotTrack(RimWellLogPlotTrack* wellLogPlotTrack, const std::vector<RimWellLogPlotCurve*>& curves)
|
||||
{
|
||||
CVF_ASSERT(wellLogPlotTrack);
|
||||
|
||||
for (size_t cIdx = 0; cIdx < curves.size(); cIdx++)
|
||||
{
|
||||
RimWellLogPlotTrack* oldPlotTrack;
|
||||
curves[cIdx]->firstAnchestorOrThisOfType(oldPlotTrack);
|
||||
if (oldPlotTrack)
|
||||
{
|
||||
oldPlotTrack->removeCurve(curves[cIdx]);
|
||||
oldPlotTrack->updateConnectedEditors();
|
||||
}
|
||||
|
||||
wellLogPlotTrack->addCurve(curves[cIdx]);
|
||||
wellLogPlotTrack->updateAxisRangesAndReplot();
|
||||
wellLogPlotTrack->updateConnectedEditors();
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RimWellLogPlotTrack;
|
||||
class RimWellLogPlotCurve;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicWellLogPlotTrackFeatureImpl
|
||||
{
|
||||
public:
|
||||
|
||||
static void moveCurvesToWellLogPlotTrack(RimWellLogPlotTrack* wellLogPlotTrack, const std::vector<RimWellLogPlotCurve*>& curves);
|
||||
};
|
@ -118,6 +118,19 @@ void RimWellLogPlotTrack::addCurve(RimWellLogPlotCurve* curve)
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellLogPlotTrack::removeCurve(RimWellLogPlotCurve* curve)
|
||||
{
|
||||
size_t index = curves.index(curve);
|
||||
if (index >= 0 && index < curves.size())
|
||||
{
|
||||
curves[index]->detachCurve();
|
||||
curves.removeChildObject(curve);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
void setDescription(const QString& description);
|
||||
|
||||
void addCurve(RimWellLogPlotCurve* curve);
|
||||
void removeCurve(RimWellLogPlotCurve* curve);
|
||||
size_t curveCount() { return curves.size(); }
|
||||
|
||||
void recreateViewer();
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "OperationsUsingObjReferences/RicPasteEclipseCasesFeature.h"
|
||||
#include "RicCloseCaseFeature.h"
|
||||
#include "WellLogCommands/RicNewWellLogFileCurveFeature.h"
|
||||
#include "WellLogCommands/RicWellLogPlotTrackFeatureImpl.h"
|
||||
|
||||
#include "RimCaseCollection.h"
|
||||
#include "RimEclipseCase.h"
|
||||
@ -30,7 +31,9 @@
|
||||
#include "RimMimeData.h"
|
||||
#include "RimWellLogFileChannel.h"
|
||||
#include "RimWellLogPlotTrack.h"
|
||||
#include "RimWellLogPlotCurve.h"
|
||||
|
||||
#include "RimWellLogPlotTrack.h"
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "cafPdmObjectGroup.h"
|
||||
@ -78,6 +81,7 @@ Qt::ItemFlags RiuDragDrop::flags(const QModelIndex &index) const
|
||||
return Qt::ItemIsDropEnabled;
|
||||
}
|
||||
else if (dynamic_cast<RimEclipseCase*>(uiItem) ||
|
||||
dynamic_cast<RimWellLogPlotCurve*>(uiItem) ||
|
||||
dynamic_cast<RimWellLogFileChannel*>(uiItem))
|
||||
{
|
||||
// TODO: Remember to handle reservoir holding the main grid
|
||||
@ -206,22 +210,49 @@ bool RiuDragDrop::handleGridCaseGroupDrop(Qt::DropAction action, caf::PdmObjectG
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
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]);
|
||||
std::vector<caf::PdmPointer<RimWellLogFileChannel> > typedObjects;
|
||||
objectGroup.objectsByType(&typedObjects);
|
||||
if (typedObjects.size() > 0)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (wellLogFileChannels.size() > 0)
|
||||
{
|
||||
if (action == Qt::CopyAction)
|
||||
std::vector<caf::PdmPointer<RimWellLogPlotCurve> > typedObjects;
|
||||
objectGroup.objectsByType(&typedObjects);
|
||||
if (typedObjects.size() > 0)
|
||||
{
|
||||
RicNewWellLogFileCurveFeature::addWellLogChannelsToPlotTrack(wellLogPlotTrack, wellLogFileChannels);
|
||||
return true;
|
||||
std::vector<RimWellLogPlotCurve*> wellLogPlotCurves;
|
||||
for (size_t cIdx = 0; cIdx < typedObjects.size(); cIdx++)
|
||||
{
|
||||
wellLogPlotCurves.push_back(typedObjects[cIdx]);
|
||||
}
|
||||
|
||||
if (wellLogPlotCurves.size() > 0)
|
||||
{
|
||||
if (action == Qt::CopyAction)
|
||||
{
|
||||
RicWellLogPlotTrackFeatureImpl::moveCurvesToWellLogPlotTrack(wellLogPlotTrack, wellLogPlotCurves);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user