diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index 03149d7c08..59157284e0 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -156,6 +156,7 @@ list( APPEND REFERENCED_CMAKE_FILES Commands/SummaryPlotCommands/CMakeLists_files.cmake Commands/WellPathCommands/CMakeLists_files.cmake Commands/CrossSectionCommands/CMakeLists_files.cmake + Commands/IntersectionBoxCommands/CMakeLists_files.cmake ) option (RESINSIGHT_INCLUDE_APPLICATION_UNIT_TESTS "Include ApplicationCode Unit Tests" OFF) diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/IntersectionBoxCommands/CMakeLists_files.cmake new file mode 100644 index 0000000000..2c63b158ff --- /dev/null +++ b/ApplicationCode/Commands/IntersectionBoxCommands/CMakeLists_files.cmake @@ -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}RicAppendIntersectionBoxFeature.h +) + +set (SOURCE_GROUP_SOURCE_FILES +${CEE_CURRENT_LIST_DIR}RicAppendIntersectionBoxFeature.cpp +) + +list(APPEND CODE_HEADER_FILES +${SOURCE_GROUP_HEADER_FILES} +) + +list(APPEND CODE_SOURCE_FILES +${SOURCE_GROUP_SOURCE_FILES} +) + +source_group( "CommandFeature\\IntersectionBox" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.cpp new file mode 100644 index 0000000000..38b3bd183a --- /dev/null +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.cpp @@ -0,0 +1,66 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicAppendIntersectionBoxFeature.h" + +#include "RimIntersectionBox.h" +#include "RimIntersectionBoxCollection.h" + +#include "cafCmdExecCommandManager.h" +#include "cafSelectionManager.h" + +#include "cvfAssert.h" + +#include + +CAF_CMD_SOURCE_INIT(RicAppendIntersectionBoxFeature, "RicAppendIntersectionBoxFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicAppendIntersectionBoxFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAppendIntersectionBoxFeature::onActionTriggered(bool isChecked) +{ + std::vector collection; + caf::SelectionManager::instance()->objectsByType(&collection); + CVF_ASSERT(collection.size() == 1); + + RimIntersectionBoxCollection* crossSectionCollection = NULL; + collection[0]->firstAnchestorOrThisOfType(crossSectionCollection); + + CVF_ASSERT(crossSectionCollection); + + crossSectionCollection->appendIntersectionBox(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAppendIntersectionBoxFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/IntersectionBox16x16.png")); + actionToSetup->setText("New Intersection Box"); +} + diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.h b/ApplicationCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.h new file mode 100644 index 0000000000..e417504f46 --- /dev/null +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.h @@ -0,0 +1,39 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" +#include "cafCmdExecuteCommand.h" +#include "cafPdmPointer.h" + + +//================================================================================================== +/// +//================================================================================================== +class RicAppendIntersectionBoxFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook( QAction* actionToSetup ); +}; + diff --git a/ApplicationCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.cpp b/ApplicationCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.cpp index dfcb311007..2ee34d3936 100644 --- a/ApplicationCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.cpp +++ b/ApplicationCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.cpp @@ -18,16 +18,23 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RicToggleItemsFeatureImpl.h" -#include -#include "cafPdmUiObjectHandle.h" -#include "cafSelectionManager.h" -#include "cafPdmUiItem.h" -#include -#include "RiuMainWindow.h" -#include "cafPdmUiTreeView.h" -#include "cafPdmUiTreeOrdering.h" -#include "cafPdmUiFieldHandle.h" +#include "RiuMainWindow.h" + +#include "cafPdmUiFieldHandle.h" +#include "cafPdmUiItem.h" +#include "cafPdmUiObjectHandle.h" +#include "cafPdmUiTreeOrdering.h" +#include "cafPdmUiTreeView.h" +#include "cafSelectionManager.h" + +#include + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- bool RicToggleItemsFeatureImpl::isToggleCommandsAvailable() { std::vector selectedItems; @@ -72,6 +79,9 @@ bool RicToggleItemsFeatureImpl::isToggleCommandsAvailable() return false; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- bool RicToggleItemsFeatureImpl::isToggleCommandsForSubItems() { std::vector selectedItems; @@ -83,7 +93,6 @@ bool RicToggleItemsFeatureImpl::isToggleCommandsForSubItems() return false; } - //-------------------------------------------------------------------------------------------------- /// Set toggle state for list of model indices. //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.h b/ApplicationCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.h index ed9688d64a..e612e23cd1 100644 --- a/ApplicationCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.h +++ b/ApplicationCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.h @@ -37,6 +37,5 @@ public: static bool isToggleCommandsAvailable(); static bool isToggleCommandsForSubItems(); static void setObjectToggleStateForSelection(SelectionToggleType state); - }; diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index 0c02e96915..cf6ce0f9b3 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -91,6 +91,8 @@ ${CEE_CURRENT_LIST_DIR}RimSummaryCaseCollection.h ${CEE_CURRENT_LIST_DIR}RimPlotCurve.h ${CEE_CURRENT_LIST_DIR}RimSummaryCurveAppearanceCalculator.h ${CEE_CURRENT_LIST_DIR}RimEclipseInputCaseOpm.h +${CEE_CURRENT_LIST_DIR}RimIntersectionBox.h +${CEE_CURRENT_LIST_DIR}RimIntersectionBoxCollection.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -180,6 +182,8 @@ ${CEE_CURRENT_LIST_DIR}RimSummaryCaseCollection.cpp ${CEE_CURRENT_LIST_DIR}RimPlotCurve.cpp ${CEE_CURRENT_LIST_DIR}RimSummaryCurveAppearanceCalculator.cpp ${CEE_CURRENT_LIST_DIR}RimEclipseInputCaseOpm.cpp +${CEE_CURRENT_LIST_DIR}RimIntersectionBox.cpp +${CEE_CURRENT_LIST_DIR}RimIntersectionBoxCollection.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index e73eec20b1..11307fc74e 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -42,6 +42,8 @@ #include "RimGeoMechPropertyFilterCollection.h" #include "RimGeoMechView.h" #include "RimIdenticalGridCaseGroup.h" +#include "RimIntersectionBox.h" +#include "RimIntersectionBoxCollection.h" #include "RimScriptCollection.h" #include "RimSummaryCase.h" #include "RimSummaryCurve.h" @@ -307,6 +309,16 @@ QStringList RimContextCommandBuilder::commandsFromSelection() commandIds << "Separator"; commandIds << "RicDeleteItemFeature"; } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicAppendIntersectionBoxFeature"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicAppendIntersectionBoxFeature"; + commandIds << "Separator"; + commandIds << "RicDeleteItemFeature"; + } else if (dynamic_cast(uiItem)) { commandIds << "RicNewSimWellCrossSectionFeature"; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index fe0d733f9f..f8f8311868 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -25,6 +25,7 @@ #include "RigCaseCellResultsData.h" #include "RigCaseData.h" +#include "RigFormationNames.h" #include "RigResultAccessor.h" #include "RigResultAccessorFactory.h" @@ -41,6 +42,7 @@ #include "RimEclipseWellCollection.h" #include "RimFaultCollection.h" #include "RimGridCollection.h" +#include "RimIntersectionBoxCollection.h" #include "RimLegendConfig.h" #include "RimOilField.h" #include "RimProject.h" @@ -74,7 +76,6 @@ #include #include -#include "RigFormationNames.h" @@ -1342,6 +1343,7 @@ void RimEclipseView::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering uiTreeOrdering.add(m_rangeFilterCollection()); uiTreeOrdering.add(m_propertyFilterCollection()); + uiTreeOrdering.add(intersectionBoxCollection()); uiTreeOrdering.setForgetRemainingFields(true); } diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index 18cc1197ba..d88e0db433 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -25,6 +25,7 @@ #include "RigFemPartCollection.h" #include "RigFemPartGrid.h" #include "RigFemPartResultsCollection.h" +#include "RigFormationNames.h" #include "RigGeoMechCaseData.h" #include "Rim3dOverlayInfoConfig.h" @@ -35,6 +36,7 @@ #include "RimGeoMechCellColors.h" #include "RimGeoMechPropertyFilterCollection.h" #include "RimGridCollection.h" +#include "RimIntersectionBoxCollection.h" #include "RimLegendConfig.h" #include "RimViewLinker.h" @@ -61,7 +63,6 @@ #include "cvfqtUtils.h" #include -#include "RigFormationNames.h" CAF_PDM_SOURCE_INIT(RimGeoMechView, "GeoMechView"); @@ -677,7 +678,9 @@ void RimGeoMechView::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering uiTreeOrdering.add(m_rangeFilterCollection()); uiTreeOrdering.add(m_propertyFilterCollection()); - + + uiTreeOrdering.add(intersectionBoxCollection()); + uiTreeOrdering.setForgetRemainingFields(true); } diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionBox.cpp b/ApplicationCode/ProjectDataModel/RimIntersectionBox.cpp new file mode 100644 index 0000000000..9318b6ca07 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimIntersectionBox.cpp @@ -0,0 +1,165 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimIntersectionBox.h" + +#include "RimView.h" + +#include "cafPdmUiSliderEditor.h" + + + +CAF_PDM_SOURCE_INIT(RimIntersectionBox, "IntersectionBox"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimIntersectionBox::RimIntersectionBox() +{ + CAF_PDM_InitObject("Intersection Box", ":/IntersectionBox16x16.png", "", ""); + + CAF_PDM_InitField(&name, "UserDescription", QString("Intersection Name"), "Name", "", "", ""); + CAF_PDM_InitField(&isActive, "Active", true, "Active", "", "", ""); + isActive.uiCapability()->setUiHidden(true); + + CAF_PDM_InitField(&minXCoord, "MinXCoord", 0.0, "MinXCoord", "", "", ""); + minXCoord.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName()); + + CAF_PDM_InitField(&maxXCoord, "MaxXCoord", 0.0, "MaxXCoord", "", "", ""); + maxXCoord.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName()); + + CAF_PDM_InitField(&minYCoord, "MinYCoord", 0.0, "MinYCoord", "", "", ""); + minYCoord.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName()); + + CAF_PDM_InitField(&maxYCoord, "MaxYCoord", 0.0, "MaxYCoord", "", "", ""); + maxYCoord.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName()); + + CAF_PDM_InitField(&minZCoord, "MinZCoord", 0.0, "MinZCoord", "", "", ""); + minZCoord.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName()); + + CAF_PDM_InitField(&maxZCoord, "MaxZCoord", 0.0, "MaxZCoord", "", "", ""); + maxZCoord.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimIntersectionBox::~RimIntersectionBox() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionBox::setModelBoundingBox(cvf::BoundingBox& boundingBox) +{ + m_boundingBox = boundingBox; + + minXCoord = cvf::Math::floor(boundingBox.min().x()); + minYCoord = cvf::Math::floor(boundingBox.min().y()); + minZCoord = cvf::Math::floor(boundingBox.min().z()); + + maxXCoord = cvf::Math::ceil(boundingBox.max().x()); + maxYCoord = cvf::Math::ceil(boundingBox.max().y()); + maxZCoord = cvf::Math::ceil(boundingBox.max().z()); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionBox::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + if (changedField == &isActive) + { + rebuildGeometryAndScheduleCreateDisplayModel(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionBox::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) +{ + caf::PdmUiSliderEditorAttribute* myAttr = static_cast(attribute); + + if (myAttr) + { + if (field == &minXCoord || field == &maxXCoord) + { + myAttr->m_minimum = cvf::Math::floor(m_boundingBox.min().x()); + myAttr->m_maximum = cvf::Math::ceil(m_boundingBox.max().x()); + } + else if (field == &minYCoord || field == &maxYCoord) + { + myAttr->m_minimum = cvf::Math::floor(m_boundingBox.min().y()); + myAttr->m_maximum = cvf::Math::ceil(m_boundingBox.max().y()); + } + else if (field == &minZCoord || field == &maxZCoord) + { + myAttr->m_minimum = cvf::Math::floor(m_boundingBox.min().z()); + myAttr->m_maximum = cvf::Math::ceil(m_boundingBox.max().z()); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionBox::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + uiOrdering.add(&name); + +/* + uiOrdering.add(&minXCoord); + uiOrdering.add(&maxXCoord); + + uiOrdering.setForgetRemainingFields(true); +*/ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimIntersectionBox::userDescriptionField() +{ + return &name; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimIntersectionBox::objectToggleField() +{ + return &isActive; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionBox::rebuildGeometryAndScheduleCreateDisplayModel() +{ + RimView* rimView = NULL; + this->firstAnchestorOrThisOfType(rimView); + if (rimView) + { + rimView->scheduleCreateDisplayModelAndRedraw(); + } +} + diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionBox.h b/ApplicationCode/ProjectDataModel/RimIntersectionBox.h new file mode 100644 index 0000000000..9cac8104ae --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimIntersectionBox.h @@ -0,0 +1,68 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmObject.h" +#include "cafPdmField.h" + +#include "cvfBoundingBox.h" + + +//================================================================================================== +// +// +// +//================================================================================================== +class RimIntersectionBox : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimIntersectionBox(); + ~RimIntersectionBox(); + + // Fields + caf::PdmField name; + caf::PdmField isActive; + + void setModelBoundingBox(cvf::BoundingBox& boundingBox); + +protected: + virtual caf::PdmFieldHandle* userDescriptionField() override; + virtual caf::PdmFieldHandle* objectToggleField() override; + + virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute) override; + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + +private: + void rebuildGeometryAndScheduleCreateDisplayModel(); + +private: + caf::PdmField minXCoord; + caf::PdmField minYCoord; + caf::PdmField minZCoord; + + caf::PdmField maxXCoord; + caf::PdmField maxYCoord; + caf::PdmField maxZCoord; + + + cvf::BoundingBox m_boundingBox; +}; diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionBoxCollection.cpp b/ApplicationCode/ProjectDataModel/RimIntersectionBoxCollection.cpp new file mode 100644 index 0000000000..260fd1b7f0 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimIntersectionBoxCollection.cpp @@ -0,0 +1,181 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimIntersectionBoxCollection.h" + +#include "RimCase.h" +#include "RimIntersectionBox.h" +#include "RimView.h" + +#include "RiuMainWindow.h" + +#include "cvfBoundingBox.h" + + +CAF_PDM_SOURCE_INIT(RimIntersectionBoxCollection, "IntersectionBoxCollection"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimIntersectionBoxCollection::RimIntersectionBoxCollection() +{ + CAF_PDM_InitObject("Intersection Boxes", ":/IntersectionBoxes16x16.png", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_intersectionBoxes, "IntersectionBoxes", "IntersectionBoxes", "", "", ""); + m_intersectionBoxes.uiCapability()->setUiHidden(true); + + CAF_PDM_InitField(&isActive, "Active", true, "Active", "", "", ""); + isActive.uiCapability()->setUiHidden(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimIntersectionBoxCollection::~RimIntersectionBoxCollection() +{ + m_intersectionBoxes.deleteAllChildObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimIntersectionBoxCollection::objectToggleField() +{ + return &isActive; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionBoxCollection::applySingleColorEffect() +{ + for (size_t csIdx = 0; csIdx < m_intersectionBoxes.size(); ++csIdx) + { + RimIntersectionBox* cs = m_intersectionBoxes[csIdx]; + if (cs->isActive) + { +// cs->crossSectionPartMgr()->applySingleColorEffect(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionBoxCollection::updateCellResultColor(size_t timeStepIndex) +{ + for (size_t csIdx = 0; csIdx < m_intersectionBoxes.size(); ++csIdx) + { + RimIntersectionBox* cs = m_intersectionBoxes[csIdx]; + if (cs->isActive) + { +// cs->crossSectionPartMgr()->updateCellResultColor(timeStepIndex); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionBoxCollection::appendPartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform) +{ + if (!isActive) return; + + for (size_t csIdx = 0; csIdx < m_intersectionBoxes.size(); ++csIdx) + { + RimIntersectionBox* cs = m_intersectionBoxes[csIdx]; + if (cs->isActive) + { +// cs->crossSectionPartMgr()->appendNativeCrossSectionFacesToModel(model, scaleTransform); +// cs->crossSectionPartMgr()->appendMeshLinePartsToModel(model, scaleTransform); + +// if (cs->inputFromViewerEnabled) +// { +// // cs->crossSectionPartMgr()->appendPolylinePartsToModel(model, scaleTransform); +// } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionBoxCollection::appendIntersectionBox() +{ + RimIntersectionBox* intersectionBox = new RimIntersectionBox(); + intersectionBox->name = QString("Intersection Box"); + + RimCase* rimCase = NULL; + firstAnchestorOrThisOfType(rimCase); + if (rimCase) + { + intersectionBox->setModelBoundingBox(rimCase->activeCellsBoundingBox()); + } + + m_intersectionBoxes.push_back(intersectionBox); + + updateConnectedEditors(); + RiuMainWindow::instance()->selectAsCurrentItem(intersectionBox); + + RimView* rimView = NULL; + firstAnchestorOrThisOfType(rimView); + if (rimView) + { + rimView->scheduleCreateDisplayModelAndRedraw(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionBoxCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + if (changedField == &isActive) + { + RimView* rimView = NULL; + firstAnchestorOrThisOfType(rimView); + if (rimView) + { + rimView->scheduleCreateDisplayModelAndRedraw(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimIntersectionBoxCollection::hasActiveCrossSectionForSimulationWell(RimEclipseWell* eclipseWell) const +{ + if (!isActive) return false; + +/* + for (size_t csIdx = 0; csIdx < m_intersectionBoxes.size(); ++csIdx) + { + RimIntersectionBox* cs = m_intersectionBoxes[csIdx]; + + if (cs->isActive && + cs->type() == RimIntersectionBox::CS_SIMULATION_WELL && + cs->simulationWell() == eclipseWell) + { + return true; + } + } + +*/ + return true; +} diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionBoxCollection.h b/ApplicationCode/ProjectDataModel/RimIntersectionBoxCollection.h new file mode 100644 index 0000000000..f4165b1ffd --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimIntersectionBoxCollection.h @@ -0,0 +1,65 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmObject.h" +#include "cafPdmChildArrayField.h" +#include "cafPdmField.h" + +class RimIntersectionBox; +class RimEclipseCellColors; +class RimEclipseWell; + +namespace cvf { + class ModelBasicList; + class Transform; +} + +//================================================================================================== +// +// +// +//================================================================================================== +class RimIntersectionBoxCollection : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimIntersectionBoxCollection(); + ~RimIntersectionBoxCollection(); + + caf::PdmField isActive; + + void appendIntersectionBox(); + + bool hasActiveCrossSectionForSimulationWell(RimEclipseWell* eclipseWell) const; + + // Visualization interface + + void applySingleColorEffect(); + void updateCellResultColor(size_t timeStepIndex); + void appendPartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform); + +protected: + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); + virtual caf::PdmFieldHandle* objectToggleField(); + +private: + caf::PdmChildArrayField m_intersectionBoxes; +}; diff --git a/ApplicationCode/ProjectDataModel/RimView.cpp b/ApplicationCode/ProjectDataModel/RimView.cpp index 79c3b7a553..18e6fec09b 100644 --- a/ApplicationCode/ProjectDataModel/RimView.cpp +++ b/ApplicationCode/ProjectDataModel/RimView.cpp @@ -11,6 +11,7 @@ #include "RimEclipseCase.h" #include "RimEclipseView.h" #include "RimGridCollection.h" +#include "RimIntersectionBoxCollection.h" #include "RimOilField.h" #include "RimProject.h" #include "RimPropertyFilterCollection.h" @@ -126,6 +127,10 @@ RimView::RimView(void) crossSectionCollection.uiCapability()->setUiHidden(true); crossSectionCollection = new RimCrossSectionCollection(); + CAF_PDM_InitFieldNoDefault(&intersectionBoxCollection, "IntersectionBoxes", "Intersection Boxes", "", "", ""); + intersectionBoxCollection.uiCapability()->setUiHidden(true); + intersectionBoxCollection = new RimIntersectionBoxCollection(); + CAF_PDM_InitFieldNoDefault(&m_gridCollection, "GridCollection", "GridCollection", "", "", ""); m_gridCollection.uiCapability()->setUiHidden(true); m_gridCollection = new RimGridCollection(); @@ -178,6 +183,7 @@ RimView::~RimView(void) delete m_rangeFilterCollection; delete m_overrideRangeFilterCollection; + delete intersectionBoxCollection; delete crossSectionCollection; delete m_gridCollection; } diff --git a/ApplicationCode/ProjectDataModel/RimView.h b/ApplicationCode/ProjectDataModel/RimView.h index 38be3d837a..f2278555f0 100644 --- a/ApplicationCode/ProjectDataModel/RimView.h +++ b/ApplicationCode/ProjectDataModel/RimView.h @@ -43,9 +43,10 @@ class Rim3dOverlayInfoConfig; class RimCase; class RimCellRangeFilter; -class RimGridCollection; class RimCellRangeFilterCollection; class RimCrossSectionCollection; +class RimGridCollection; +class RimIntersectionBoxCollection; class RimPropertyFilterCollection; class RimViewController; class RimViewLinker; @@ -97,6 +98,7 @@ public: caf::PdmChildField crossSectionCollection; + caf::PdmChildField intersectionBoxCollection; // Draw style diff --git a/ApplicationCode/Resources/IntersectionBox16x16.png b/ApplicationCode/Resources/IntersectionBox16x16.png new file mode 100644 index 0000000000..10b5584507 Binary files /dev/null and b/ApplicationCode/Resources/IntersectionBox16x16.png differ diff --git a/ApplicationCode/Resources/IntersectionBoxes16x16.png b/ApplicationCode/Resources/IntersectionBoxes16x16.png new file mode 100644 index 0000000000..d24a88b612 Binary files /dev/null and b/ApplicationCode/Resources/IntersectionBoxes16x16.png differ diff --git a/ApplicationCode/Resources/ResInsight.qrc b/ApplicationCode/Resources/ResInsight.qrc index 6b961409aa..ec3a465877 100644 --- a/ApplicationCode/Resources/ResInsight.qrc +++ b/ApplicationCode/Resources/ResInsight.qrc @@ -57,15 +57,16 @@ CrossSection16x16.png CrossSections16x16.png Refresh-32.png - SummaryPlot16x16.png - SummaryPlots16x16.png - SummaryCurve16x16.png - SummaryCurveFilter16x16.png - FormationCollection16x16.png - Formations16x16.png - Parallel16x16.png - Perspective16x16.png - + SummaryPlot16x16.png + SummaryPlots16x16.png + SummaryCurve16x16.png + SummaryCurveFilter16x16.png + FormationCollection16x16.png + Formations16x16.png + Parallel16x16.png + Perspective16x16.png + IntersectionBox16x16.png + IntersectionBoxes16x16.png fs_CellFace.glsl