Added command features for paste of Eclipse view and Eclipse case

This commit is contained in:
Magne Sjaastad 2015-08-14 10:17:18 +02:00
parent 9cae0e09ff
commit d466624e45
11 changed files with 655 additions and 74 deletions

View File

@ -6,10 +6,18 @@ endif()
set (SOURCE_GROUP_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RicCopyReferencesToClipboardFeature.h
${CEE_CURRENT_LIST_DIR}RicPasteFeatureImpl.h
${CEE_CURRENT_LIST_DIR}RicPasteEclipseCasesFeature.h
${CEE_CURRENT_LIST_DIR}RicPasteEclipseViewsFeature.h
)
set (SOURCE_GROUP_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RicCopyReferencesToClipboardFeature.cpp
${CEE_CURRENT_LIST_DIR}RicPasteFeatureImpl.cpp
${CEE_CURRENT_LIST_DIR}RicPasteEclipseCasesFeature.cpp
${CEE_CURRENT_LIST_DIR}RicPasteEclipseViewsFeature.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -1,42 +1,26 @@
//##################################################################################################
/////////////////////////////////////////////////////////////////////////////////
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
// 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.
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
/////////////////////////////////////////////////////////////////////////////////
#include "RicCopyReferencesToClipboardFeature.h"
#include "RimMimeData.h"
#include "cafPdmUiItem.h"
#include "cafSelectionManager.h"
@ -82,7 +66,7 @@ void RicCopyReferencesToClipboardFeature::onActionTriggered(bool isChecked)
//--------------------------------------------------------------------------------------------------
void RicCopyReferencesToClipboardFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("RicCopyReferencesToClipboardFeature");
actionToSetup->setText("Copy");
}
} // end namespace caf

View File

@ -1,38 +1,21 @@
//##################################################################################################
/////////////////////////////////////////////////////////////////////////////////
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
// 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.
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
/////////////////////////////////////////////////////////////////////////////////
#pragma once

View File

@ -0,0 +1,193 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicPasteEclipseCasesFeature.h"
#include "RiaApplication.h"
#include "RicPasteFeatureImpl.h"
#include "RigGridManager.h"
#include "RimCaseCollection.h"
#include "RimEclipseCaseCollection.h"
#include "RimEclipseResultCase.h"
#include "RimIdenticalGridCaseGroup.h"
#include "RimMimeData.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "cafPdmObjectGroup.h"
#include "cafPdmObjectHandle.h"
#include "cafPdmReferenceHelper.h"
#include "cafSelectionManager.h"
#include <QAction>
#include <QString>
namespace caf
{
CAF_CMD_SOURCE_INIT(RicPasteEclipseCasesFeature, "RicPasteEclipseCasesFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicPasteEclipseCasesFeature::isCommandEnabled()
{
PdmObjectGroup objectGroup;
RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup);
std::vector<caf::PdmPointer<RimEclipseResultCase> > typedObjects;
objectGroup.objectsByType(&typedObjects);
if (typedObjects.size() == 0)
{
return false;
}
PdmObjectHandle* destinationObject = dynamic_cast<PdmObjectHandle*>(SelectionManager::instance()->selectedItem());
RimIdenticalGridCaseGroup* gridCaseGroup = RicPasteFeatureImpl::findGridCaseGroup(destinationObject);
if (gridCaseGroup) return true;
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteEclipseCasesFeature::onActionTriggered(bool isChecked)
{
RimProject* proj = RiaApplication::instance()->project();
CVF_ASSERT(proj);
PdmObjectHandle* destinationObject = dynamic_cast<PdmObjectHandle*>(SelectionManager::instance()->selectedItem());
RimIdenticalGridCaseGroup* gridCaseGroup = RicPasteFeatureImpl::findGridCaseGroup(destinationObject);
if (!gridCaseGroup) return;
PdmObjectGroup objectGroup;
RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup);
if (objectGroup.objects.size() == 0) return;
{
std::vector<caf::PdmPointer<RimEclipseResultCase> > typedObjects;
objectGroup.createCopyByType(&typedObjects, PdmDefaultObjectFactory::instance());
if (typedObjects.size() == 0)
{
return;
}
RimEclipseResultCase* mainResultCase = NULL;
std::vector< std::vector<int> > mainCaseGridDimensions;
// Read out main grid and main grid dimensions if present in case group
if (gridCaseGroup->mainCase())
{
mainResultCase = dynamic_cast<RimEclipseResultCase*>(gridCaseGroup->mainCase());
CVF_ASSERT(mainResultCase);
mainResultCase->readGridDimensions(mainCaseGridDimensions);
}
std::vector<RimEclipseResultCase*> insertedCases;
// Add cases to case group
for (size_t i = 0; i < typedObjects.size(); i++)
{
RimEclipseResultCase* rimResultReservoir = typedObjects[i];
proj->assignCaseIdToCase(rimResultReservoir);
if (gridCaseGroup->contains(rimResultReservoir))
{
continue;
}
insertedCases.push_back(rimResultReservoir);
}
// Initialize the new objects
for (size_t i = 0; i < insertedCases.size(); i++)
{
RimEclipseResultCase* rimResultReservoir = insertedCases[i];
caf::PdmDocument::initAfterReadTraversal(rimResultReservoir);
}
// Load stuff
for (size_t i = 0; i < insertedCases.size(); i++)
{
RimEclipseResultCase* rimResultReservoir = insertedCases[i];
if (!mainResultCase)
{
rimResultReservoir->openEclipseGridFile();
rimResultReservoir->readGridDimensions(mainCaseGridDimensions);
mainResultCase = rimResultReservoir;
}
else
{
std::vector< std::vector<int> > caseGridDimensions;
rimResultReservoir->readGridDimensions(caseGridDimensions);
bool identicalGrid = RigGridManager::isGridDimensionsEqual(mainCaseGridDimensions, caseGridDimensions);
if (!identicalGrid)
{
continue;
}
if (!rimResultReservoir->openAndReadActiveCellData(mainResultCase->reservoirData()))
{
CVF_ASSERT(false);
}
}
RimOilField* activeOilField = proj ? proj->activeOilField() : NULL;
RimEclipseCaseCollection* analysisModels = (activeOilField) ? activeOilField->analysisModels() : NULL;
if (analysisModels) analysisModels->insertCaseInCaseGroup(gridCaseGroup, rimResultReservoir);
caf::PdmDocument::updateUiIconStateRecursively(rimResultReservoir);
gridCaseGroup->updateConnectedEditors();
for (size_t rvIdx = 0; rvIdx < rimResultReservoir->reservoirViews.size(); rvIdx++)
{
RimEclipseView* riv = rimResultReservoir->reservoirViews()[rvIdx];
riv->loadDataAndUpdate();
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteEclipseCasesFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Paste (Eclipse Cases)");
}
} // end namespace caf

View File

@ -0,0 +1,45 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafCmdFeature.h"
namespace caf
{
//==================================================================================================
///
//==================================================================================================
class RicPasteEclipseCasesFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered(bool isChecked);
virtual void setupActionLook(QAction* actionToSetup);
};
} // end namespace caf

View File

@ -0,0 +1,120 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicPasteEclipseViewsFeature.h"
#include "RiaApplication.h"
#include "RicPasteFeatureImpl.h"
#include "RimEclipseCase.h"
#include "RimEclipseView.h"
#include "RimEclipseWellCollection.h"
#include "cafPdmDocument.h"
#include "cafPdmObjectGroup.h"
#include "cafSelectionManager.h"
#include <QAction>
namespace caf
{
CAF_CMD_SOURCE_INIT(RicPasteEclipseViewsFeature, "RicPasteEclipseViewsFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicPasteEclipseViewsFeature::isCommandEnabled()
{
PdmObjectGroup objectGroup;
RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup);
std::vector<caf::PdmPointer<RimEclipseView> > typedObjects;
objectGroup.objectsByType(&typedObjects);
if (typedObjects.size() == 0)
{
return false;
}
PdmObjectHandle* destinationObject = dynamic_cast<PdmObjectHandle*>(SelectionManager::instance()->selectedItem());
RimIdenticalGridCaseGroup* gridCaseGroup = RicPasteFeatureImpl::findGridCaseGroup(destinationObject);
if (gridCaseGroup) return false;
RimEclipseCase* eclipseCase = RicPasteFeatureImpl::findEclipseCase(destinationObject);
if (eclipseCase) return true;
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteEclipseViewsFeature::onActionTriggered(bool isChecked)
{
PdmObjectHandle* destinationObject = dynamic_cast<PdmObjectHandle*>(SelectionManager::instance()->selectedItem());
RimEclipseCase* eclipseCase = RicPasteFeatureImpl::findEclipseCase(destinationObject);
assert(eclipseCase);
PdmObjectGroup objectGroup;
RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup);
if (objectGroup.objects.size() == 0) return;
std::vector<caf::PdmPointer<RimEclipseView> > eclipseViews;
objectGroup.createCopyByType(&eclipseViews, PdmDefaultObjectFactory::instance());
if (eclipseViews.size() != 0)
{
// Add cases to case group
for (size_t i = 0; i < eclipseViews.size(); i++)
{
RimEclipseView* rimReservoirView = eclipseViews[i];
QString nameOfCopy = QString("Copy of ") + rimReservoirView->name;
rimReservoirView->name = nameOfCopy;
eclipseCase->reservoirViews().push_back(rimReservoirView);
// Delete all wells to be able to copy/paste between cases, as the wells differ between cases
rimReservoirView->wellCollection()->wells().deleteAllChildObjects();
caf::PdmDocument::initAfterReadTraversal(rimReservoirView);
rimReservoirView->setEclipseCase(eclipseCase);
caf::PdmDocument::updateUiIconStateRecursively(rimReservoirView);
rimReservoirView->loadDataAndUpdate();
eclipseCase->updateConnectedEditors();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteEclipseViewsFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Paste (Eclipse Views)");
}
} // end namespace caf

View File

@ -0,0 +1,45 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafCmdFeature.h"
namespace caf
{
//==================================================================================================
///
//==================================================================================================
class RicPasteEclipseViewsFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered(bool isChecked);
virtual void setupActionLook(QAction* actionToSetup);
};
} // end namespace caf

View File

@ -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

View File

@ -0,0 +1,56 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 QString;
class RimIdenticalGridCaseGroup;
class RimEclipseCase;
namespace caf
{
class PdmObjectGroup;
class PdmObjectHandle;
//==================================================================================================
///
//==================================================================================================
class RicPasteFeatureImpl
{
public:
static void findObjectsFromClipboardRefs(caf::PdmObjectGroup* objectGroup);
static RimIdenticalGridCaseGroup* findGridCaseGroup(PdmObjectHandle* objectHandle);
static RimEclipseCase* findEclipseCase(PdmObjectHandle* objectHandle);
private:
static void populateObjectGroupFromReferences(const std::vector<QString>& referenceList, caf::PdmObjectGroup* objectGroup);
static void referencesFromClipboard(std::vector<QString>& referenceList);
};
} // end namespace caf

View File

@ -43,6 +43,7 @@
#include "cafPdmUiTreeOrdering.h"
#include <QDir>
#include "cafCmdFeature.h"
CAF_PDM_SOURCE_INIT(RimProject, "ResInsightProject");
//--------------------------------------------------------------------------------------------------
@ -554,17 +555,31 @@ void RimProject::actionsBasedOnSelection(std::vector<QAction*>& actions)
{
commandIds << "RicCopyReferencesToClipboardFeature";
commandIds << "RicEclipseCasePaste";
commandIds << "RicPasteEclipseCasesFeature";
commandIds << "RicPasteEclipseViewsFeature";
commandIds << "RicEclipseCaseClose";
commandIds << "RicEclipseCaseNewView";
commandIds << "RicEclipseCaseNewGroup";
commandIds << "RicEclipseCaseExecuteScript";
}
else if (dynamic_cast<RimIdenticalGridCaseGroup*>(uiItem))
{
commandIds << "RicEclipseCaseNewView";
commandIds << "RicPasteEclipseCasesFeature";
commandIds << "RicPasteEclipseViewsFeature";
}
else if (dynamic_cast<RimCaseCollection*>(uiItem))
{
commandIds << "RicPasteEclipseCasesFeature";
}
else if (dynamic_cast<RimEclipseView*>(uiItem))
{
commandIds << "RicCopyReferencesToClipboardFeature";
commandIds << "RicPasteEclipseViewsFeature";
commandIds << "RicEclipseViewNew";
commandIds << "RicEclipseViewCopy";
commandIds << "RicEclipseViewPaste";
commandIds << "RicEclipseViewDelete";
}
else if (dynamic_cast<RimEclipseCellColors*>(uiItem))
@ -619,14 +634,17 @@ void RimProject::actionsBasedOnSelection(std::vector<QAction*>& actions)
}
}
caf::CmdFeatureManager* commandManager = caf::CmdFeatureManager::instance();
for (int i = 0; i < commandIds.size(); i++)
{
QAction* act = commandManager->action(commandIds[i]);
CVF_ASSERT(act);
caf::CmdFeature* feature = commandManager->getCommandFeature(commandIds[i].toStdString());
if (feature->canFeatureBeExecuted())
{
QAction* act = commandManager->action(commandIds[i]);
CVF_ASSERT(act);
actions.push_back(act);
actions.push_back(act);
}
}
}

View File

@ -81,6 +81,8 @@ public:
void refreshEnabledState();
void refreshCheckedState();
bool canFeatureBeExecuted() { return this->isCommandEnabled(); }
public slots:
void actionTriggered(bool isChecked) { this->onActionTriggered(isChecked); }