mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Added command features for paste of Eclipse view and Eclipse case
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicPasteFeatureImpl.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RimCaseCollection.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
#include "RimMimeData.h"
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "cafPdmObjectGroup.h"
|
||||
#include "cafPdmObjectHandle.h"
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QString>
|
||||
|
||||
|
||||
|
||||
namespace caf
|
||||
{
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPasteFeatureImpl::populateObjectGroupFromReferences(const std::vector<QString>& referenceList, caf::PdmObjectGroup* objectGroup)
|
||||
{
|
||||
PdmObjectHandle* referenceRoot = RiaApplication::instance()->project();
|
||||
|
||||
for (size_t i = 0; i < referenceList.size(); i++)
|
||||
{
|
||||
QString reference = referenceList[i];
|
||||
|
||||
PdmObjectHandle* pdmObj = PdmReferenceHelper::objectFromReference(referenceRoot, reference);
|
||||
if (pdmObj)
|
||||
{
|
||||
objectGroup->objects.push_back(pdmObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPasteFeatureImpl::referencesFromClipboard(std::vector<QString>& referenceList)
|
||||
{
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
if (!clipboard) return;
|
||||
|
||||
const MimeDataWithReferences* mimeDataReferences = dynamic_cast<const MimeDataWithReferences*>(clipboard->mimeData());
|
||||
if (!mimeDataReferences) return;
|
||||
|
||||
referenceList = mimeDataReferences->references();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPasteFeatureImpl::findObjectsFromClipboardRefs(caf::PdmObjectGroup* objectGroup)
|
||||
{
|
||||
std::vector<QString> referenceList;
|
||||
RicPasteFeatureImpl::referencesFromClipboard(referenceList);
|
||||
|
||||
RicPasteFeatureImpl::populateObjectGroupFromReferences(referenceList, objectGroup);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimIdenticalGridCaseGroup* RicPasteFeatureImpl::findGridCaseGroup(PdmObjectHandle* objectHandle)
|
||||
{
|
||||
if (dynamic_cast<RimIdenticalGridCaseGroup*>(objectHandle))
|
||||
{
|
||||
return dynamic_cast<RimIdenticalGridCaseGroup*>(objectHandle);
|
||||
}
|
||||
else if (dynamic_cast<RimCaseCollection*>(objectHandle) ||
|
||||
dynamic_cast<RimEclipseCase*>(objectHandle))
|
||||
{
|
||||
RimIdenticalGridCaseGroup* gridCaseGroup = NULL;
|
||||
objectHandle->firstAncestorOfType(gridCaseGroup);
|
||||
|
||||
return gridCaseGroup;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseCase* RicPasteFeatureImpl::findEclipseCase(PdmObjectHandle* objectHandle)
|
||||
{
|
||||
if (dynamic_cast<RimEclipseCase*>(objectHandle))
|
||||
{
|
||||
return dynamic_cast<RimEclipseCase*>(objectHandle);
|
||||
}
|
||||
else if (dynamic_cast<RimEclipseView*>(objectHandle))
|
||||
{
|
||||
RimEclipseView* reservoirView = dynamic_cast<RimEclipseView*>(objectHandle);
|
||||
|
||||
return reservoirView->eclipseCase();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
} // end namespace caf
|
||||
Reference in New Issue
Block a user