mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2391 intersections. New copy to all views command feature
This commit is contained in:
@@ -10,6 +10,7 @@ ${CEE_CURRENT_LIST_DIR}RicNewSimWellIntersectionFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicNewWellPathIntersectionFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicNewPolylineIntersectionFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicNewAzimuthDipIntersectionFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicCopyIntersectionsToAllViewsInCaseFeature.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@@ -18,6 +19,7 @@ ${CEE_CURRENT_LIST_DIR}RicNewSimWellIntersectionFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicNewWellPathIntersectionFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicNewPolylineIntersectionFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicNewAzimuthDipIntersectionFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicCopyIntersectionsToAllViewsInCaseFeature.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@@ -0,0 +1,228 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicCopyIntersectionsToAllViewsInCaseFeature.h"
|
||||
|
||||
#include "RimIntersection.h"
|
||||
#include "RimIntersectionBox.h"
|
||||
#include "RimIntersectionCollection.h"
|
||||
#include "RimGridView.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimGridView.h"
|
||||
#include "RimEclipseCase.h"
|
||||
|
||||
#include "cafCmdExecCommandManager.h"
|
||||
#include "cafSelectionManagerTools.h"
|
||||
#include "cafPdmUiItem.h"
|
||||
|
||||
#include "cvfAssert.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicCopyIntersectionsToAllViewsInCaseFeature, "RicCopyIntersectionsToAllViewsInCaseFeature");
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Internal definitions
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
enum SelectionComposition {SEL_INVALID, SEL_COLLECTION, SEL_INTERSECTIONS, SEL_INTERSECTION_BOXES, SEL_BOTH_INTERSECTION_TYPES };
|
||||
|
||||
static RimIntersectionCollection* selectedIntersectionCollection();
|
||||
static std::vector<RimIntersection*> selectedIntersections();
|
||||
static std::vector<RimIntersectionBox*> selectedIntersectionBoxes();
|
||||
static SelectionComposition selectionComposition();
|
||||
static RimCase* commonGridCase(std::vector<caf::PdmUiItem*> selectedItems);
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicCopyIntersectionsToAllViewsInCaseFeature::isCommandEnabled()
|
||||
{
|
||||
return selectionComposition() != SEL_INVALID;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCopyIntersectionsToAllViewsInCaseFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RimCase* gridCase = nullptr;
|
||||
std::vector<caf::PdmUiItem*> selItems;
|
||||
caf::SelectionManager::instance()->selectedItems(selItems);
|
||||
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>(selItems.front());
|
||||
if (objHandle) objHandle->firstAncestorOrThisOfType(gridCase);
|
||||
|
||||
if (gridCase)
|
||||
{
|
||||
SelectionComposition compostion = selectionComposition();
|
||||
if (compostion == SEL_COLLECTION)
|
||||
{
|
||||
RimIntersectionCollection* coll = selectedIntersectionCollection();
|
||||
copyIntersectionsToOtherViews(*gridCase, coll->intersections());
|
||||
copyIntersectionBoxesToOtherViews(*gridCase, coll->intersectionBoxes());
|
||||
}
|
||||
|
||||
std::vector<RimIntersection*> selIntersections = selectedIntersections();
|
||||
std::vector<RimIntersectionBox*> selIntersectionBoxes = selectedIntersectionBoxes();
|
||||
|
||||
if (compostion == SEL_INTERSECTIONS || compostion == SEL_BOTH_INTERSECTION_TYPES)
|
||||
{
|
||||
copyIntersectionsToOtherViews(*gridCase, selIntersections);
|
||||
}
|
||||
if (compostion == SEL_INTERSECTION_BOXES || compostion == SEL_BOTH_INTERSECTION_TYPES)
|
||||
{
|
||||
copyIntersectionBoxesToOtherViews(*gridCase, selIntersectionBoxes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCopyIntersectionsToAllViewsInCaseFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setIcon(QIcon(":/Copy.png"));
|
||||
actionToSetup->setText("Copy intersections to all views in case");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCopyIntersectionsToAllViewsInCaseFeature::copyIntersectionsToOtherViews(RimCase& gridCase, std::vector<RimIntersection*> intersections)
|
||||
{
|
||||
for (RimIntersection* intersection : intersections)
|
||||
{
|
||||
for (Rim3dView* const view : gridCase.views())
|
||||
{
|
||||
RimGridView* currGridView = dynamic_cast<RimGridView*>(view);
|
||||
RimGridView* parentView = nullptr;
|
||||
intersection->firstAncestorOrThisOfType(parentView);
|
||||
|
||||
if (currGridView && parentView != nullptr && parentView != currGridView)
|
||||
{
|
||||
RimIntersectionCollection* destCollection = currGridView->crossSectionCollection();
|
||||
|
||||
RimIntersection* copy = dynamic_cast<RimIntersection*>(intersection->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
|
||||
CVF_ASSERT(copy);
|
||||
|
||||
destCollection->appendIntersectionAndUpdate(copy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCopyIntersectionsToAllViewsInCaseFeature::copyIntersectionBoxesToOtherViews(RimCase& gridCase, std::vector<RimIntersectionBox*> intersectionBoxes)
|
||||
{
|
||||
for (RimIntersectionBox* intersectionBox : intersectionBoxes)
|
||||
{
|
||||
for (Rim3dView* const view : gridCase.views())
|
||||
{
|
||||
RimGridView* currGridView = dynamic_cast<RimGridView*>(view);
|
||||
RimGridView* parentView = nullptr;
|
||||
intersectionBox->firstAncestorOrThisOfType(parentView);
|
||||
|
||||
if (currGridView && parentView != nullptr && parentView != currGridView)
|
||||
{
|
||||
RimIntersectionCollection* destCollection = currGridView->crossSectionCollection();
|
||||
|
||||
RimIntersectionBox* copy = dynamic_cast<RimIntersectionBox*>(intersectionBox->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
|
||||
CVF_ASSERT(copy);
|
||||
|
||||
destCollection->appendIntersectionBoxAndUpdate(copy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimIntersectionCollection* selectedIntersectionCollection()
|
||||
{
|
||||
std::vector<RimIntersectionCollection*> selObjects = caf::selectedObjectsByType<RimIntersectionCollection*>();
|
||||
return !selObjects.empty() ? selObjects[0] : nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimIntersection*> selectedIntersections()
|
||||
{
|
||||
return caf::selectedObjectsByType<RimIntersection*>();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimIntersectionBox*> selectedIntersectionBoxes()
|
||||
{
|
||||
return caf::selectedObjectsByType<RimIntersectionBox*>();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
SelectionComposition selectionComposition()
|
||||
{
|
||||
std::vector<caf::PdmUiItem*> allSelectedObjects;
|
||||
caf::SelectionManager::instance()->selectedItems(allSelectedObjects);
|
||||
|
||||
RimCase* gridCase = commonGridCase(allSelectedObjects);
|
||||
if (gridCase && gridCase->gridViews().size() > 1)
|
||||
{
|
||||
RimIntersectionCollection* selColl = selectedIntersectionCollection();
|
||||
std::vector<RimIntersection*> selIntersections = selectedIntersections();
|
||||
std::vector<RimIntersectionBox*> selIntersectionBoxes = selectedIntersectionBoxes();
|
||||
|
||||
if (selColl)
|
||||
{
|
||||
if (allSelectedObjects.size() == 1) return SEL_COLLECTION;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!selIntersections.empty() && !selIntersectionBoxes.empty()) return SEL_BOTH_INTERSECTION_TYPES;
|
||||
else if (!selIntersections.empty()) return SEL_INTERSECTIONS;
|
||||
else if (!selIntersectionBoxes.empty()) return SEL_INTERSECTION_BOXES;
|
||||
}
|
||||
}
|
||||
return SEL_INVALID;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimCase* commonGridCase(std::vector<caf::PdmUiItem*> selectedItems)
|
||||
{
|
||||
RimCase* gridCase = nullptr;
|
||||
|
||||
for (caf::PdmUiItem* item : selectedItems)
|
||||
{
|
||||
caf::PdmObjectHandle* obj = dynamic_cast<caf::PdmObjectHandle*>(item);
|
||||
RimCase* itemCase = nullptr;
|
||||
obj->firstAncestorOrThisOfType(itemCase);
|
||||
|
||||
if (gridCase == nullptr) gridCase = itemCase;
|
||||
else if (gridCase != itemCase) return nullptr;
|
||||
}
|
||||
return gridCase;
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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"
|
||||
#include "cafCmdExecuteCommand.h"
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
class RimCase;
|
||||
class RimIntersection;
|
||||
class RimIntersectionBox;
|
||||
class RimIntersectionCollection;
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicCopyIntersectionsToAllViewsInCaseFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled();
|
||||
virtual void onActionTriggered( bool isChecked );
|
||||
virtual void setupActionLook( QAction* actionToSetup );
|
||||
|
||||
void copyIntersectionsToOtherViews(RimCase& gridCase, std::vector<RimIntersection*> intersections);
|
||||
void copyIntersectionBoxesToOtherViews(RimCase& gridCase, std::vector<RimIntersectionBox*> intersectionBoxes);
|
||||
};
|
||||
|
||||
|
@@ -31,6 +31,7 @@
|
||||
#include "Rim2dIntersectionView.h"
|
||||
#include "Rim2dIntersectionViewCollection.h"
|
||||
#include "RimIntersection.h"
|
||||
#include "RimGridView.h"
|
||||
|
||||
|
||||
CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimCase, "RimCase");
|
||||
@@ -84,6 +85,21 @@ std::vector<Rim3dView*> RimCase::views() const
|
||||
return allViews;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimGridView*> RimCase::gridViews() const
|
||||
{
|
||||
std::vector<RimGridView*> grViews;
|
||||
|
||||
for (Rim3dView* const view : views())
|
||||
{
|
||||
RimGridView* grView = dynamic_cast<RimGridView*>(view);
|
||||
if (grView) grViews.push_back(grView);
|
||||
}
|
||||
return grViews;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@@ -31,6 +31,7 @@
|
||||
#include <vector>
|
||||
|
||||
class Rim3dView;
|
||||
class RimGridView;
|
||||
class RimFormationNames;
|
||||
class RimTimeStepFilter;
|
||||
class Rim2dIntersectionView;
|
||||
@@ -54,6 +55,7 @@ public:
|
||||
caf::PdmPtrField<RimFormationNames*> activeFormationNames;
|
||||
|
||||
std::vector<Rim3dView*> views() const;
|
||||
std::vector<RimGridView*> gridViews() const;
|
||||
|
||||
virtual void updateFilePathsFromProjectPath(const QString& projectPath, const QString& oldProjectPath) = 0;
|
||||
|
||||
|
@@ -453,6 +453,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
menuBuilder.addSeparator();
|
||||
menuBuilder << "RicAppendIntersectionFeature";
|
||||
menuBuilder << "RicAppendIntersectionBoxFeature";
|
||||
menuBuilder.addSeparator();
|
||||
menuBuilder << "RicCopyIntersectionsToAllViewsInCaseFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimIntersection*>(uiItem))
|
||||
{
|
||||
@@ -462,6 +464,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
menuBuilder << "RicAppendIntersectionBoxFeature";
|
||||
menuBuilder.addSeparator();
|
||||
menuBuilder << "RicNewIntersectionViewFeature";
|
||||
menuBuilder.addSeparator();
|
||||
menuBuilder << "RicCopyIntersectionsToAllViewsInCaseFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimIntersectionBox*>(uiItem))
|
||||
{
|
||||
@@ -469,6 +473,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
menuBuilder.addSeparator();
|
||||
menuBuilder << "RicAppendIntersectionFeature";
|
||||
menuBuilder << "RicAppendIntersectionBoxFeature";
|
||||
menuBuilder.addSeparator();
|
||||
menuBuilder << "RicCopyIntersectionsToAllViewsInCaseFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimSimWellInView*>(uiItem))
|
||||
{
|
||||
@@ -662,6 +668,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
menuBuilder << "RicNewSimWellFractureFeature";
|
||||
#endif // USE_PROTOTYPE_FEATURE_FRACTURES
|
||||
}
|
||||
menuBuilder.addSeparator();
|
||||
menuBuilder << "RicCopyIntersectionsToAllViewsInCaseFeature";
|
||||
}
|
||||
|
||||
{
|
||||
|
@@ -151,6 +151,22 @@ void RimIntersectionCollection::appendPartsToModel(cvf::ModelBasicList* model, c
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimIntersection*> RimIntersectionCollection::intersections() const
|
||||
{
|
||||
return m_intersections.childObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimIntersectionBox*> RimIntersectionCollection::intersectionBoxes() const
|
||||
{
|
||||
return m_intersectionBoxes.childObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@@ -71,6 +71,9 @@ public:
|
||||
const RivTernaryScalarMapper* ternaryColorMapper);
|
||||
void appendPartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform);
|
||||
|
||||
std::vector<RimIntersection*> intersections() const;
|
||||
std::vector<RimIntersectionBox*> intersectionBoxes() const;
|
||||
|
||||
protected:
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
|
||||
virtual caf::PdmFieldHandle* objectToggleField();
|
||||
|
Reference in New Issue
Block a user