diff --git a/ApplicationCode/Commands/WellPathCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/WellPathCommands/CMakeLists_files.cmake index ea6635f73c..d1fb57747d 100644 --- a/ApplicationCode/Commands/WellPathCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/WellPathCommands/CMakeLists_files.cmake @@ -5,7 +5,9 @@ ${CMAKE_CURRENT_LIST_DIR}/RicWellPathsImportFileFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicWellPathsImportSsihubFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicNewEditableWellPathFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathListTargetFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathAttributeFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicDeleteWellPathTargetFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicDeleteWellPathAttributeFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicWellPathsUnitSystemSettingsImpl.h ${CMAKE_CURRENT_LIST_DIR}/RicWellPathsUnitSystemSettingsUi.h ${CMAKE_CURRENT_LIST_DIR}/RicWellPathViewerEventHandler.h @@ -19,7 +21,9 @@ ${CMAKE_CURRENT_LIST_DIR}/RicWellPathsImportFileFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicWellPathsImportSsihubFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewEditableWellPathFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathListTargetFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathAttributeFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicDeleteWellPathTargetFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDeleteWellPathAttributeFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicWellPathsUnitSystemSettingsImpl.cpp ${CMAKE_CURRENT_LIST_DIR}/RicWellPathsUnitSystemSettingsUi.cpp ${CMAKE_CURRENT_LIST_DIR}/RicWellPathViewerEventHandler.cpp diff --git a/ApplicationCode/Commands/WellPathCommands/RicDeleteWellPathAttributeFeature.cpp b/ApplicationCode/Commands/WellPathCommands/RicDeleteWellPathAttributeFeature.cpp new file mode 100644 index 0000000000..0b7d9ab30d --- /dev/null +++ b/ApplicationCode/Commands/WellPathCommands/RicDeleteWellPathAttributeFeature.cpp @@ -0,0 +1,76 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- equinor 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#include "RicDeleteWellPathAttributeFeature.h" + +#include "RimWellPathAttributeCollection.h" +#include "RimWellPathTarget.h" +#include "RimModeledWellPath.h" +#include "cafSelectionManager.h" +#include + +CAF_CMD_SOURCE_INIT(RicDeleteWellPathAttributeFeature, "RicDeleteWellPathAttributeFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicDeleteWellPathAttributeFeature::isCommandEnabled() +{ + { + std::vector objects; + caf::SelectionManager::instance()->objectsByType(&objects, caf::SelectionManager::CURRENT); + + if ( objects.size() > 0 ) + { + return true; + } + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicDeleteWellPathAttributeFeature::onActionTriggered(bool isChecked) +{ + std::vector attributes; + caf::SelectionManager::instance()->objectsByType(&attributes, caf::SelectionManager::CURRENT); + if (attributes.size() > 0) + { + RimWellPathAttributeCollection* wellPathAttributeCollection = nullptr; + attributes[0]->firstAncestorOrThisOfTypeAsserted(wellPathAttributeCollection); + RimWellPath* wellPath = nullptr; + wellPathAttributeCollection->firstAncestorOrThisOfTypeAsserted(wellPath); + for (RimWellPathAttribute* attributeToDelete : attributes) + { + wellPathAttributeCollection->deleteAttribute(attributeToDelete); + } + wellPath->updateConnectedEditors(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicDeleteWellPathAttributeFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Delete Attribute"); + actionToSetup->setIcon(QIcon(":/Erase.png")); +} + + diff --git a/ApplicationCode/Commands/WellPathCommands/RicDeleteWellPathAttributeFeature.h b/ApplicationCode/Commands/WellPathCommands/RicDeleteWellPathAttributeFeature.h new file mode 100644 index 0000000000..cf34107fee --- /dev/null +++ b/ApplicationCode/Commands/WellPathCommands/RicDeleteWellPathAttributeFeature.h @@ -0,0 +1,35 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- equinor 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicDeleteWellPathAttributeFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; +protected: + + // Overrides + virtual bool isCommandEnabled() override; + virtual void onActionTriggered( bool isChecked ) override; + virtual void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationCode/Commands/WellPathCommands/RicNewWellPathAttributeFeature.cpp b/ApplicationCode/Commands/WellPathCommands/RicNewWellPathAttributeFeature.cpp new file mode 100644 index 0000000000..9ecb48b3d9 --- /dev/null +++ b/ApplicationCode/Commands/WellPathCommands/RicNewWellPathAttributeFeature.cpp @@ -0,0 +1,98 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- equinor 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#include "RicNewWellPathAttributeFeature.h" + +#include "RimWellPathAttributeCollection.h" +#include "RimWellPathTarget.h" +#include "RimModeledWellPath.h" +#include "cafSelectionManager.h" +#include + +CAF_CMD_SOURCE_INIT(RicNewWellPathAttributeFeature, "RicNewWellPathAttributeFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicNewWellPathAttributeFeature::isCommandEnabled() +{ + { + std::vector objects; + caf::SelectionManager::instance()->objectsByType(&objects); + + if ( objects.size() > 0 ) + { + return true; + } + } + { + std::vector objects; + caf::SelectionManager::instance()->objectsByType(&objects, caf::SelectionManager::CURRENT); + + if ( objects.size() > 0 ) + { + return true; + } + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewWellPathAttributeFeature::onActionTriggered(bool isChecked) +{ + std::vector attributes; + caf::SelectionManager::instance()->objectsByType(&attributes, caf::SelectionManager::CURRENT); + if (attributes.size() > 0) + { + RimWellPathAttributeCollection* attributeCollection = nullptr; + attributes[0]->firstAncestorOrThisOfTypeAsserted(attributeCollection); + RimWellPath* wellPath = nullptr; + attributeCollection->firstAncestorOrThisOfTypeAsserted(wellPath); + attributes[0]->updateConnectedEditors(); + attributeCollection->insertAttribute(attributes[0], new RimWellPathAttribute); + wellPath->updateConnectedEditors(); + return; + } + + std::vector wellPaths; + caf::SelectionManager::instance()->objectsByType(&wellPaths); + + if (wellPaths.size() > 0) + { + std::vector attributeCollections; + wellPaths[0]->descendantsIncludingThisOfType(attributeCollections); + if (attributeCollections.size() > 0) + { + attributeCollections[0]->insertAttribute(nullptr, new RimWellPathAttribute); + } + wellPaths[0]->updateConnectedEditors(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewWellPathAttributeFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("New Attribute"); + actionToSetup->setIcon(QIcon(":/Well.png")); +} + + diff --git a/ApplicationCode/Commands/WellPathCommands/RicNewWellPathAttributeFeature.h b/ApplicationCode/Commands/WellPathCommands/RicNewWellPathAttributeFeature.h new file mode 100644 index 0000000000..4b6fd6b9b2 --- /dev/null +++ b/ApplicationCode/Commands/WellPathCommands/RicNewWellPathAttributeFeature.h @@ -0,0 +1,35 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- equinor 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicNewWellPathAttributeFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; +protected: + + // Overrides + virtual bool isCommandEnabled() override; + virtual void onActionTriggered( bool isChecked ) override; + virtual void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index 6c300d06e4..976ab92906 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -27,6 +27,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RimWellPath.h ${CMAKE_CURRENT_LIST_DIR}/RimFileWellPath.h ${CMAKE_CURRENT_LIST_DIR}/RimModeledWellPath.h ${CMAKE_CURRENT_LIST_DIR}/RimWellPathGeometryDef.h +${CMAKE_CURRENT_LIST_DIR}/RimWellPathAttribute.h +${CMAKE_CURRENT_LIST_DIR}/RimWellPathAttributeCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimWellPathCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimWellPathTarget.h ${CMAKE_CURRENT_LIST_DIR}/RimScriptCollection.h @@ -145,6 +147,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RimWellPath.cpp ${CMAKE_CURRENT_LIST_DIR}/RimFileWellPath.cpp ${CMAKE_CURRENT_LIST_DIR}/RimModeledWellPath.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellPathGeometryDef.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellPathAttribute.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellPathAttributeCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellPathCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellPathTarget.cpp ${CMAKE_CURRENT_LIST_DIR}/RimScriptCollection.cpp diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.cpp b/ApplicationCode/ProjectDataModel/RimWellPath.cpp index b028be0bed..a908d86c28 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPath.cpp @@ -37,6 +37,7 @@ #include "RimTools.h" #include "RimWellLogFile.h" #include "RimWellLogPlotCollection.h" +#include "RimWellPathAttributeCollection.h" #include "RimWellPathCollection.h" #include "RimWellPathCompletions.h" #include "RimWellPathFracture.h" @@ -115,6 +116,11 @@ RimWellPath::RimWellPath() m_wellLogFile_OBSOLETE.uiCapability()->setUiHidden(true); m_wellLogFile_OBSOLETE.xmlCapability()->setIOWritable(false); + CAF_PDM_InitFieldNoDefault(&m_wellPathAttributes, "WellPathAttributes", "", "", "", ""); + m_wellPathAttributes = new RimWellPathAttributeCollection; + m_wellPathAttributes->uiCapability()->setUiTreeHidden(true); + m_wellPathAttributes->uiCapability()->setUiTreeChildrenHidden(true); + m_wellPath = nullptr; } @@ -463,6 +469,8 @@ void RimWellPath::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiO formationFileInfoGroup->add(&m_wellPathFormationFilePath); formationFileInfoGroup->add(&m_formationKeyInFile); + m_wellPathAttributes->uiOrdering(uiConfigName, uiOrdering); + uiOrdering.skipRemainingFields(true); } diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.h b/ApplicationCode/ProjectDataModel/RimWellPath.h index 98318c5a40..3d6214fae5 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.h +++ b/ApplicationCode/ProjectDataModel/RimWellPath.h @@ -48,6 +48,7 @@ class RimFishboneWellPathCollection; class RimFishbonesCollection; class RimPerforationCollection; +class RimWellPathAttributeCollection; class RimWellPathCompletions; class RigWellPathFormations; @@ -152,9 +153,10 @@ private: caf::PdmField m_wellPathRadiusScaleFactor; caf::PdmField m_wellPathColor; - caf::PdmChildArrayField m_wellLogFiles; - caf::PdmChildField m_3dWellLogCurves; - caf::PdmChildField m_completions; + caf::PdmChildArrayField m_wellLogFiles; + caf::PdmChildField m_3dWellLogCurves; + caf::PdmChildField m_completions; + caf::PdmChildField m_wellPathAttributes; private: diff --git a/ApplicationCode/ProjectDataModel/RimWellPathAttribute.cpp b/ApplicationCode/ProjectDataModel/RimWellPathAttribute.cpp new file mode 100644 index 0000000000..5545af03d0 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimWellPathAttribute.cpp @@ -0,0 +1,107 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 - Equinor 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#include "RimWellPathAttribute.h" + +CAF_PDM_SOURCE_INIT(RimWellPathAttribute, "WellPathAttribute"); + +namespace caf +{ +template<> +void caf::AppEnum::setUp() +{ + addItem(RimWellPathAttribute::AttributeCasing, "CASING", "Casing"); + addItem(RimWellPathAttribute::AttributeLining, "LINING", "Lining"); + setDefault(RimWellPathAttribute::AttributeCasing); +} +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellPathAttribute::RimWellPathAttribute() +{ + CAF_PDM_InitObject("RimWellPathAttribute", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_type, "AttributeType", "Type ", "", "", ""); + CAF_PDM_InitField(&m_depthStart, "DepthStart", 0.0, "Depth Start", "", "", ""); + CAF_PDM_InitField(&m_depthEnd, "DepthEnd", 0.0, "Depth End", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_label, "Label", "Label", "", "", ""); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellPathAttribute::~RimWellPathAttribute() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellPathAttribute::AttributeType RimWellPathAttribute::type() const +{ + return m_type(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimWellPathAttribute::depthStart() const +{ + return m_depthStart(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimWellPathAttribute::depthEnd() const +{ + return m_depthEnd(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimWellPathAttribute::label() const +{ + return m_label(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellPathAttribute::fieldChangedByUi(const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue) +{ + if (changedField == &m_type) + { + if (m_type() == AttributeCasing) + { + m_depthEnd = 0; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellPathAttribute::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + m_depthEnd.uiCapability()->setUiReadOnly(m_type() == AttributeCasing); +} diff --git a/ApplicationCode/ProjectDataModel/RimWellPathAttribute.h b/ApplicationCode/ProjectDataModel/RimWellPathAttribute.h new file mode 100644 index 0000000000..ab2893ce44 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimWellPathAttribute.h @@ -0,0 +1,56 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 - Equinor 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#pragma once + +#include "cafPdmObject.h" + +#include "cafAppEnum.h" +#include "cvfBase.h" +#include "cafPdmField.h" + +#include + +class RimWellPathAttribute : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; +public: + enum AttributeType + { + AttributeCasing, + AttributeLining + }; + typedef caf::AppEnum AttributeTypeEnum; + + RimWellPathAttribute(); + ~RimWellPathAttribute(); + + AttributeType type() const; + double depthStart() const; + double depthEnd() const; + QString label() const; + +private: + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + + caf::PdmField m_type; + caf::PdmField m_depthStart; + caf::PdmField m_depthEnd; + caf::PdmField m_label; +}; + diff --git a/ApplicationCode/ProjectDataModel/RimWellPathAttributeCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellPathAttributeCollection.cpp new file mode 100644 index 0000000000..d1a4d44477 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimWellPathAttributeCollection.cpp @@ -0,0 +1,104 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 - Equinor 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#include "RimWellPathAttributeCollection.h" + +#include "cafCmdFeatureMenuBuilder.h" +#include "cafPdmUiTableViewEditor.h" + +CAF_PDM_SOURCE_INIT(RimWellPathAttributeCollection, "WellPathAttributes"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellPathAttributeCollection::RimWellPathAttributeCollection() +{ + CAF_PDM_InitObject("WellPathAttributes", ":/Well.png", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_attributes, "Attributes", "", "", "", ""); + m_attributes.uiCapability()->setUiEditorTypeName(caf::PdmUiTableViewEditor::uiEditorTypeName()); + m_attributes.uiCapability()->setUiTreeChildrenHidden(true); + m_attributes.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + m_attributes.uiCapability()->setCustomContextMenuEnabled(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellPathAttributeCollection::~RimWellPathAttributeCollection() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimWellPathAttributeCollection::attributes() const +{ + std::vector attrs; + + for (auto attr : m_attributes) + { + attrs.push_back(attr.p()); + } + return attrs; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellPathAttributeCollection::insertAttribute(RimWellPathAttribute* insertBefore, RimWellPathAttribute* attribute) +{ + size_t index = m_attributes.index(insertBefore); + if (index < m_attributes.size()) + m_attributes.insert(index, attribute); + else + m_attributes.push_back(attribute); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellPathAttributeCollection::deleteAttribute(RimWellPathAttribute* attributeToDelete) +{ + m_attributes.removeChildObject(attributeToDelete); + delete attributeToDelete; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellPathAttributeCollection::defineCustomContextMenu(const caf::PdmFieldHandle* fieldNeedingMenu, + QMenu* menu, + QWidget* fieldEditorWidget) +{ + caf::CmdFeatureMenuBuilder menuBuilder; + + menuBuilder << "RicNewWellPathAttributeFeature"; + menuBuilder << "Separator"; + menuBuilder << "RicDeleteWellPathAttributeFeature"; + + menuBuilder.appendToMenu(menu); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellPathAttributeCollection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + caf::PdmUiGroup* attrGroup = uiOrdering.addNewGroup("Well Path Attributes"); + attrGroup->add(&m_attributes); +} diff --git a/ApplicationCode/ProjectDataModel/RimWellPathAttributeCollection.h b/ApplicationCode/ProjectDataModel/RimWellPathAttributeCollection.h new file mode 100644 index 0000000000..9cd62a59a9 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimWellPathAttributeCollection.h @@ -0,0 +1,44 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 - Equinor 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#pragma once + +#include "RimWellPathAttribute.h" + +#include "cafAppEnum.h" +#include "cvfBase.h" +#include "cafPdmChildArrayField.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" + +class RimWellPathAttributeCollection : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; +public: + RimWellPathAttributeCollection(); + ~RimWellPathAttributeCollection(); + + std::vector attributes() const; + void insertAttribute(RimWellPathAttribute* insertBefore, RimWellPathAttribute* attribute); + void deleteAttribute(RimWellPathAttribute* attributeToDelete); + +protected: + virtual void defineCustomContextMenu(const caf::PdmFieldHandle* fieldNeedingMenu, QMenu* menu, QWidget* fieldEditorWidget) override; + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; +private: + caf::PdmChildArrayField m_attributes; +}; \ No newline at end of file diff --git a/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.cpp b/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.cpp index cb04660b76..73a49e0083 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathGeometryDef.cpp @@ -124,7 +124,7 @@ void RimWellPathGeometryDef::deleteTarget(RimWellPathTarget* targetTodelete) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellPathGeometryDef::appendTarget() {