#2509 Fracture : Add copy / paste of ellipse fracture template

This commit is contained in:
Magne Sjaastad 2018-02-20 07:20:25 +01:00
parent a218addbe5
commit fb95d896ef
8 changed files with 240 additions and 28 deletions

View File

@ -124,6 +124,7 @@ list( APPEND REFERENCED_CMAKE_FILES
Commands/EclipseCommands/EclipseWell/CMakeLists_files.cmake
Commands/ExportCommands/CMakeLists_files.cmake
Commands/FlowCommands/CMakeLists_files.cmake
Commands/FractureCommands/CMakeLists_files.cmake
Commands/IntersectionBoxCommands/CMakeLists_files.cmake
Commands/IntersectionViewCommands/CMakeLists_files.cmake
Commands/OctaveScriptCommands/CMakeLists_files.cmake

View File

@ -0,0 +1,23 @@
# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly
if (${CMAKE_VERSION} VERSION_GREATER "2.8.2")
set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/)
endif()
set (SOURCE_GROUP_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RicPasteEllipseFractureFeature.h
)
set (SOURCE_GROUP_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RicPasteEllipseFractureFeature.cpp
)
list(APPEND CODE_HEADER_FILES
${SOURCE_GROUP_HEADER_FILES}
)
list(APPEND CODE_SOURCE_FILES
${SOURCE_GROUP_SOURCE_FILES}
)
source_group( "CommandFeature\\Fracture" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake )

View File

@ -0,0 +1,111 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 Statoil ASA
//
// 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 "RicPasteEllipseFractureFeature.h"
#include "../OperationsUsingObjReferences/RicPasteFeatureImpl.h"
#include "RicNewEllipseFractureTemplateFeature.h"
#include "RimEllipseFractureTemplate.h"
#include "RimFractureTemplateCollection.h"
#include "cafPdmObjectGroup.h"
#include "cafSelectionManager.h"
#include <QAction>
#include <QString>
CAF_CMD_SOURCE_INIT(RicPasteEllipseFractureFeature, "RicPasteEllipseFractureFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicPasteEllipseFractureFeature::isCommandEnabled()
{
caf::PdmObjectGroup objectGroup;
RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup);
std::vector<caf::PdmPointer<RimEllipseFractureTemplate>> typedObjects;
objectGroup.objectsByType(&typedObjects);
if (typedObjects.size() == 0)
{
return false;
}
if (fractureTemplateCollection())
{
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteEllipseFractureFeature::onActionTriggered(bool isChecked)
{
auto fractureTemplateColl = fractureTemplateCollection();
if (!fractureTemplateColl) return;
caf::PdmObjectGroup objectGroup;
RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup);
std::vector<caf::PdmPointer<RimEllipseFractureTemplate>> typedObjects;
objectGroup.objectsByType(&typedObjects);
for (const auto& source : typedObjects)
{
auto rimReservoirView = dynamic_cast<RimEllipseFractureTemplate*>(
source->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
fractureTemplateColl->fractureDefinitions.push_back(rimReservoirView);
RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(fractureTemplateColl, rimReservoirView);
}
return;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteEllipseFractureFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Paste (Ellipse Fracture)");
RicPasteFeatureImpl::setIconAndShortcuts(actionToSetup);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimFractureTemplateCollection* RicPasteEllipseFractureFeature::fractureTemplateCollection()
{
RimFractureTemplateCollection* fractureTemplateColl = nullptr;
auto destinationObject = dynamic_cast<caf::PdmObjectHandle*>(caf::SelectionManager::instance()->selectedItem());
if (destinationObject)
{
destinationObject->firstAncestorOrThisOfType(fractureTemplateColl);
}
return fractureTemplateColl;
}

View File

@ -0,0 +1,44 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 Statoil ASA
//
// 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"
class RimFractureTemplateCollection;
namespace caf
{
class PdmObjectGroup;
}
//==================================================================================================
///
//==================================================================================================
class RicPasteEllipseFractureFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
private:
virtual bool isCommandEnabled() override;
virtual void onActionTriggered(bool isChecked) override;
virtual void setupActionLook(QAction* actionToSetup) override;
private:
static RimFractureTemplateCollection* fractureTemplateCollection();
};

View File

@ -21,6 +21,7 @@
#include "RimEclipseCase.h"
#include "RimEclipseView.h"
#include "RimFractureTemplate.h"
#include "RimGeoMechView.h"
#include "RimIntersection.h"
#include "RimIntersectionBox.h"
@ -162,6 +163,10 @@ bool RicCopyReferencesToClipboardFeature::isCopyOfObjectSupported(caf::PdmObject
{
if (!wellAllocPlot && !rftPlot) return true;
}
else if (dynamic_cast<RimFractureTemplate*>(pdmObject))
{
return true;
}
return false;
}

View File

@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- Statoil ASA
//
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@ -20,10 +20,10 @@
#include "RiaApplication.h"
#include "RimOilField.h"
#include "RimEclipseView.h"
#include "RimEllipseFractureTemplate.h"
#include "RimFractureTemplateCollection.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RiuMainWindow.h"
@ -34,11 +34,36 @@
#include <QAction>
CAF_CMD_SOURCE_INIT(RicNewEllipseFractureTemplateFeature, "RicNewEllipseFractureTemplateFeature");
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(RimFractureTemplateCollection* templateCollection,
RimEllipseFractureTemplate* ellipseFractureTemplate)
{
ellipseFractureTemplate->loadDataAndUpdate();
templateCollection->updateConnectedEditors();
RimProject* project = RiaApplication::instance()->project();
std::vector<Rim3dView*> views;
project->allVisibleViews(views);
for (Rim3dView* view : views)
{
if (dynamic_cast<RimEclipseView*>(view))
{
view->updateConnectedEditors();
}
}
RiuMainWindow::instance()->selectAsCurrentItem(ellipseFractureTemplate);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewEllipseFractureTemplateFeature::onActionTriggered(bool isChecked)
{
@ -49,35 +74,22 @@ void RicNewEllipseFractureTemplateFeature::onActionTriggered(bool isChecked)
if (oilfield == nullptr) return;
RimFractureTemplateCollection* fracDefColl = oilfield->fractureDefinitionCollection();
if (fracDefColl)
{
RimEllipseFractureTemplate* ellipseFractureTemplate = new RimEllipseFractureTemplate();
fracDefColl->fractureDefinitions.push_back(ellipseFractureTemplate);
ellipseFractureTemplate->setName("Ellipse Fracture Template");
ellipseFractureTemplate->setFractureTemplateUnit(fracDefColl->defaultUnitsForFracTemplates());
ellipseFractureTemplate->setDefaultValuesFromUnit();
ellipseFractureTemplate->loadDataAndUpdate();
fracDefColl->updateConnectedEditors();
std::vector<Rim3dView*> views;
project->allVisibleViews(views);
for (Rim3dView* view : views)
{
if (dynamic_cast<RimEclipseView*>(view))
{
view->updateConnectedEditors();
}
}
RiuMainWindow::instance()->selectAsCurrentItem(ellipseFractureTemplate);
selectFractureTemplateAndUpdate(fracDefColl, ellipseFractureTemplate);
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RicNewEllipseFractureTemplateFeature::setupActionLook(QAction* actionToSetup)
{
@ -86,7 +98,7 @@ void RicNewEllipseFractureTemplateFeature::setupActionLook(QAction* actionToSetu
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RicNewEllipseFractureTemplateFeature::isCommandEnabled()
{

View File

@ -22,6 +22,8 @@
#include <vector>
class RimEllipseFractureTemplate;
class RimFractureTemplateCollection;
//==================================================================================================
///
@ -29,8 +31,12 @@
class RicNewEllipseFractureTemplateFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
public:
static void selectFractureTemplateAndUpdate(RimFractureTemplateCollection* templateCollection,
RimEllipseFractureTemplate* ellipseFractureTemplate);
protected:
virtual void onActionTriggered(bool isChecked) override;
virtual void setupActionLook(QAction* actionToSetup) override;
virtual bool isCommandEnabled() override;

View File

@ -530,17 +530,27 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
{
menuBuilder << "RicNewSimWellFractureFeature";
}
else if (dynamic_cast<RimFractureTemplateCollection*>(uiItem) ||
dynamic_cast<RimStimPlanFractureTemplate*>(uiItem))
else if (dynamic_cast<RimFractureTemplateCollection*>(uiItem))
{
menuBuilder << "RicPasteEllipseFractureFeature";
menuBuilder.addSeparator();
menuBuilder << "RicNewEllipseFractureTemplateFeature";
menuBuilder << "RicNewStimPlanFractureTemplateFeature";
menuBuilder << "Separator";
menuBuilder << "RicConvertAllFractureTemplatesToMetricFeature";
menuBuilder << "RicConvertAllFractureTemplatesToFieldFeature";
}
else if (dynamic_cast<RimStimPlanFractureTemplate*>(uiItem))
{
menuBuilder << "RicPasteEllipseFractureFeature";
menuBuilder.addSeparator();
menuBuilder << "RicNewEllipseFractureTemplateFeature";
menuBuilder << "RicNewStimPlanFractureTemplateFeature";
}
else if (dynamic_cast<RimEllipseFractureTemplate*>(uiItem))
{
menuBuilder << "RicPasteEllipseFractureFeature";
menuBuilder.addSeparator();
menuBuilder << "RicNewEllipseFractureTemplateFeature";
menuBuilder << "RicNewStimPlanFractureTemplateFeature";
menuBuilder << "Separator";