diff --git a/ApplicationCode/Commands/EclipseCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/EclipseCommands/CMakeLists_files.cmake index 767483654c..fabf93ac48 100644 --- a/ApplicationCode/Commands/EclipseCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/EclipseCommands/CMakeLists_files.cmake @@ -23,6 +23,7 @@ ${CEE_CURRENT_LIST_DIR}RicNewStatisticsCaseFeature.h ${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputPropertyFeature.h ${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.h ${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.h +${CEE_CURRENT_LIST_DIR}RicApplyPropertyFilterAsCellResultFeature.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -44,6 +45,7 @@ ${CEE_CURRENT_LIST_DIR}RicNewStatisticsCaseFeature.cpp ${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputPropertyFeature.cpp ${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.cpp ${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.cpp +${CEE_CURRENT_LIST_DIR}RicApplyPropertyFilterAsCellResultFeature.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Commands/EclipseCommands/RicApplyPropertyFilterAsCellResultFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicApplyPropertyFilterAsCellResultFeature.cpp new file mode 100644 index 0000000000..a9ab8dff7c --- /dev/null +++ b/ApplicationCode/Commands/EclipseCommands/RicApplyPropertyFilterAsCellResultFeature.cpp @@ -0,0 +1,121 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 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 "RicApplyPropertyFilterAsCellResultFeature.h" + +#include "RimEclipseCellColors.h" +#include "RimEclipsePropertyFilter.h" +#include "RimEclipseView.h" + +#include "RimGeoMechPropertyFilter.h" +#include "RimGeoMechResultDefinition.h" +#include "RimGeoMechView.h" + +#include "cafSelectionManager.h" + +#include + +CAF_CMD_SOURCE_INIT(RicApplyPropertyFilterAsCellResultFeature, "RicApplyPropertyFilterAsCellResultFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicApplyPropertyFilterAsCellResultFeature::isCommandEnabled() +{ + { + std::vector objects; + caf::SelectionManager::instance()->objectsByType(&objects); + + if (objects.size() == 1) + { + return true; + } + } + + { + std::vector objects; + caf::SelectionManager::instance()->objectsByType(&objects); + + if (objects.size() == 1) + { + return true; + } + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicApplyPropertyFilterAsCellResultFeature::onActionTriggered(bool isChecked) +{ + { + std::vector objects; + caf::SelectionManager::instance()->objectsByType(&objects); + + if (objects.size() == 1) + { + RimEclipsePropertyFilter* propertyFilter = objects[0]; + if (!propertyFilter) return; + + RimEclipseView* rimEclipseView = nullptr; + propertyFilter->firstAncestorOrThisOfType(rimEclipseView); + if (!rimEclipseView) return; + + rimEclipseView->cellResult()->simpleCopy(propertyFilter->resultDefinition()); + rimEclipseView->cellResult()->updateConnectedEditors(); + + rimEclipseView->scheduleCreateDisplayModelAndRedraw(); + + return; + } + } + + { + std::vector objects; + caf::SelectionManager::instance()->objectsByType(&objects); + + if (objects.size() == 1) + { + RimGeoMechPropertyFilter* propertyFilter = objects[0]; + if (!propertyFilter) return; + + RimGeoMechView* geoMechView = nullptr; + propertyFilter->firstAncestorOrThisOfType(geoMechView); + if (!geoMechView) return; + + geoMechView->cellResultResultDefinition()->setResultAddress(propertyFilter->resultDefinition()->resultAddress()); + geoMechView->cellResultResultDefinition()->updateConnectedEditors(); + + geoMechView->scheduleCreateDisplayModelAndRedraw(); + + return; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicApplyPropertyFilterAsCellResultFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Apply As Cell Result"); + actionToSetup->setIcon(QIcon(":/CellResult.png")); +} + diff --git a/ApplicationCode/Commands/EclipseCommands/RicApplyPropertyFilterAsCellResultFeature.h b/ApplicationCode/Commands/EclipseCommands/RicApplyPropertyFilterAsCellResultFeature.h new file mode 100644 index 0000000000..bfbe11beea --- /dev/null +++ b/ApplicationCode/Commands/EclipseCommands/RicApplyPropertyFilterAsCellResultFeature.h @@ -0,0 +1,36 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 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" + + +//================================================================================================== +/// +//================================================================================================== +class RicApplyPropertyFilterAsCellResultFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + virtual bool isCommandEnabled() override; + virtual void onActionTriggered(bool isChecked) override; + virtual void setupActionLook(QAction* actionToSetup) override; +}; + diff --git a/ApplicationCode/Commands/FlowCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/FlowCommands/CMakeLists_files.cmake index 56a32b4fd1..ad729ca6b4 100644 --- a/ApplicationCode/Commands/FlowCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/FlowCommands/CMakeLists_files.cmake @@ -7,12 +7,14 @@ endif() set (SOURCE_GROUP_HEADER_FILES ${CEE_CURRENT_LIST_DIR}RicShowWellAllocationPlotFeature.h ${CEE_CURRENT_LIST_DIR}RicAddStoredWellAllocationPlotFeature.h +${CEE_CURRENT_LIST_DIR}RicShowContributingWellsFromPlotFeature.h ${CEE_CURRENT_LIST_DIR}RicShowContributingWellsFeature.h ) set (SOURCE_GROUP_SOURCE_FILES ${CEE_CURRENT_LIST_DIR}RicShowWellAllocationPlotFeature.cpp ${CEE_CURRENT_LIST_DIR}RicAddStoredWellAllocationPlotFeature.cpp +${CEE_CURRENT_LIST_DIR}RicShowContributingWellsFromPlotFeature.cpp ${CEE_CURRENT_LIST_DIR}RicShowContributingWellsFeature.cpp ) diff --git a/ApplicationCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.cpp index cd567f1ac2..be7c8e1fae 100644 --- a/ApplicationCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.cpp @@ -25,6 +25,8 @@ #include "RimProject.h" #include "RimWellAllocationPlot.h" +#include "RiuMainPlotWindow.h" + #include "cafSelectionManager.h" #include "cvfAssert.h" @@ -76,6 +78,13 @@ void RicAddStoredWellAllocationPlotFeature::onActionTriggered(bool isChecked) wellAllocationPlot->loadDataAndUpdate(); flowPlotColl->updateConnectedEditors(); + + RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + if (mainPlotWindow) + { + mainPlotWindow->selectAsCurrentItem(wellAllocationPlot); + mainPlotWindow->setExpanded(wellAllocationPlot, true); + } } } } diff --git a/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeature.cpp index d13540ea69..56e023a898 100644 --- a/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeature.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeature.cpp @@ -18,18 +18,7 @@ #include "RicShowContributingWellsFeature.h" -#include "RiaApplication.h" - -#include "RimDefines.h" -#include "RimEclipseCellColors.h" -#include "RimEclipsePropertyFilter.h" -#include "RimEclipsePropertyFilterCollection.h" -#include "RimEclipseView.h" -#include "RimEclipseWell.h" -#include "RimEclipseWellCollection.h" -#include "RimWellAllocationPlot.h" - -#include "RiuMainWindow.h" +#include "cafCmdFeatureManager.h" #include @@ -40,12 +29,6 @@ CAF_CMD_SOURCE_INIT(RicShowContributingWellsFeature, "RicShowContributingWellsFe //-------------------------------------------------------------------------------------------------- bool RicShowContributingWellsFeature::isCommandEnabled() { - RimWellAllocationPlot* wellAllocationPlot = RiaApplication::instance()->activeWellAllocationPlot(); - if (!wellAllocationPlot) return false; - - RimEclipseView* activeView = dynamic_cast(RiaApplication::instance()->activeReservoirView()); - if (!activeView) return false; - return true; } @@ -54,56 +37,20 @@ bool RicShowContributingWellsFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicShowContributingWellsFeature::onActionTriggered(bool isChecked) { - RimWellAllocationPlot* wellAllocationPlot = RiaApplication::instance()->activeWellAllocationPlot(); - if (!wellAllocationPlot) return; + // First, shot the well allocation plot + // Then, use the feature to show contributing wells as this is based on the previous feature - RimEclipseView* activeView = dynamic_cast(RiaApplication::instance()->activeReservoirView()); + std::vector commandIds; + commandIds.push_back("RicShowWellAllocationPlotFeature"); + commandIds.push_back("RicShowContributingWellsFromPlotFeature"); - if (activeView) + for (auto commandId : commandIds) { - activeView->cellResult()->setResultType(RimDefines::FLOW_DIAGNOSTICS); - activeView->cellResult()->setResultVariable("MaxFractionTracer"); - activeView->cellResult()->loadDataAndUpdate(); - - activeView->cellResult()->updateConnectedEditors(); - - const std::vector contributingTracers = wellAllocationPlot->contributingTracerNames(); - - for (RimEclipseWell* well : activeView->wellCollection()->wells()) + auto* feature = caf::CmdFeatureManager::instance()->getCommandFeature(commandId); + if (feature) { - if (std::find(contributingTracers.begin(), contributingTracers.end(), well->name()) != contributingTracers.end() - || wellAllocationPlot->wellName() == well->name()) - { - well->showWell = true; - } - else - { - well->showWell = false; - } + feature->actionTriggered(false); } - - // Disable all existing property filters, and - // create a new property filter based on TOF for current well - - RimEclipsePropertyFilterCollection* propertyFilterCollection = activeView->eclipsePropertyFilterCollection(); - - for (RimEclipsePropertyFilter* f : propertyFilterCollection->propertyFilters()) - { - f->isActive = false; - } - - RimEclipsePropertyFilter* propertyFilter = new RimEclipsePropertyFilter(); - propertyFilterCollection->propertyFilters().push_back(propertyFilter); - - propertyFilter->resultDefinition()->setEclipseCase(activeView->eclipseCase()); - propertyFilter->resultDefinition()->setTofAndSelectTracer(wellAllocationPlot->wellName()); - propertyFilter->resultDefinition()->loadDataAndUpdate(); - - propertyFilterCollection->updateConnectedEditors(); - - RiuMainWindow::instance()->setExpanded(propertyFilterCollection, true); - - activeView->scheduleCreateDisplayModelAndRedraw(); } } @@ -112,6 +59,6 @@ void RicShowContributingWellsFeature::onActionTriggered(bool isChecked) //-------------------------------------------------------------------------------------------------- void RicShowContributingWellsFeature::setupActionLook(QAction* actionToSetup) { - //actionToSetup->setIcon(QIcon(":/new_icon16x16.png")); + actionToSetup->setIcon(QIcon(":/new_icon16x16.png")); actionToSetup->setText("Show Contributing Wells"); } diff --git a/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFromPlotFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFromPlotFeature.cpp new file mode 100644 index 0000000000..36aac7f968 --- /dev/null +++ b/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFromPlotFeature.cpp @@ -0,0 +1,117 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 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 "RicShowContributingWellsFromPlotFeature.h" + +#include "RiaApplication.h" + +#include "RimDefines.h" +#include "RimEclipseCellColors.h" +#include "RimEclipsePropertyFilter.h" +#include "RimEclipsePropertyFilterCollection.h" +#include "RimEclipseView.h" +#include "RimEclipseWell.h" +#include "RimEclipseWellCollection.h" +#include "RimWellAllocationPlot.h" + +#include "RiuMainWindow.h" + +#include + +CAF_CMD_SOURCE_INIT(RicShowContributingWellsFromPlotFeature, "RicShowContributingWellsFromPlotFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicShowContributingWellsFromPlotFeature::isCommandEnabled() +{ + RimWellAllocationPlot* wellAllocationPlot = RiaApplication::instance()->activeWellAllocationPlot(); + if (!wellAllocationPlot) return false; + + RimEclipseView* activeView = dynamic_cast(RiaApplication::instance()->activeReservoirView()); + if (!activeView) return false; + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicShowContributingWellsFromPlotFeature::onActionTriggered(bool isChecked) +{ + RimWellAllocationPlot* wellAllocationPlot = RiaApplication::instance()->activeWellAllocationPlot(); + if (!wellAllocationPlot) return; + + RimEclipseView* activeView = dynamic_cast(RiaApplication::instance()->activeReservoirView()); + + if (activeView) + { + activeView->cellResult()->setResultType(RimDefines::FLOW_DIAGNOSTICS); + activeView->cellResult()->setResultVariable("MaxFractionTracer"); + activeView->cellResult()->loadDataAndUpdate(); + + activeView->cellResult()->updateConnectedEditors(); + + const std::vector contributingTracers = wellAllocationPlot->contributingTracerNames(); + + for (RimEclipseWell* well : activeView->wellCollection()->wells()) + { + if (std::find(contributingTracers.begin(), contributingTracers.end(), well->name()) != contributingTracers.end() + || wellAllocationPlot->wellName() == well->name()) + { + well->showWell = true; + } + else + { + well->showWell = false; + } + } + + // Disable all existing property filters, and + // create a new property filter based on TOF for current well + + RimEclipsePropertyFilterCollection* propertyFilterCollection = activeView->eclipsePropertyFilterCollection(); + + for (RimEclipsePropertyFilter* f : propertyFilterCollection->propertyFilters()) + { + f->isActive = false; + } + + RimEclipsePropertyFilter* propertyFilter = new RimEclipsePropertyFilter(); + propertyFilterCollection->propertyFilters().push_back(propertyFilter); + + propertyFilter->resultDefinition()->setEclipseCase(activeView->eclipseCase()); + propertyFilter->resultDefinition()->setTofAndSelectTracer(wellAllocationPlot->wellName()); + propertyFilter->resultDefinition()->loadDataAndUpdate(); + + propertyFilterCollection->updateConnectedEditors(); + + RiuMainWindow::instance()->setExpanded(propertyFilterCollection, true); + + activeView->scheduleCreateDisplayModelAndRedraw(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicShowContributingWellsFromPlotFeature::setupActionLook(QAction* actionToSetup) +{ + //actionToSetup->setIcon(QIcon(":/new_icon16x16.png")); + actionToSetup->setText("Show Contributing Wells"); +} diff --git a/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFromPlotFeature.h b/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFromPlotFeature.h new file mode 100644 index 0000000000..bc4af31852 --- /dev/null +++ b/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFromPlotFeature.h @@ -0,0 +1,38 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 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" + + +//================================================================================================== +/// +//================================================================================================== +class RicShowContributingWellsFromPlotFeature : 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/FlowCommands/RicShowWellAllocationPlotFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp index 804f6df145..0c82744b55 100644 --- a/ApplicationCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp @@ -75,6 +75,6 @@ void RicShowWellAllocationPlotFeature::onActionTriggered(bool isChecked) //-------------------------------------------------------------------------------------------------- void RicShowWellAllocationPlotFeature::setupActionLook(QAction* actionToSetup) { - actionToSetup->setIcon(QIcon(":/new_icon16x16.png")); + actionToSetup->setIcon(QIcon(":/WellAllocPlot16x16.png")); actionToSetup->setText("Show Well Allocation Plot"); } diff --git a/ApplicationCode/Commands/RicDeleteItemFeature.cpp b/ApplicationCode/Commands/RicDeleteItemFeature.cpp index 8c315defb6..9e5e9b24fa 100644 --- a/ApplicationCode/Commands/RicDeleteItemFeature.cpp +++ b/ApplicationCode/Commands/RicDeleteItemFeature.cpp @@ -63,6 +63,10 @@ namespace caf bool isDeletable(PdmUiItem * uiItem) { + // Enable delete of well allocation plots + if (dynamic_cast(uiItem)) return true; + + // Disable delete of all sub objects of a well allocation plot caf::PdmObjectHandle* destinationObject = dynamic_cast(uiItem); if (destinationObject) { diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index 67734912e0..899d122eb0 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -84,6 +84,7 @@ ${CEE_CURRENT_LIST_DIR}RimEclipseInputCaseOpm.h ${CEE_CURRENT_LIST_DIR}RimIntersectionBox.h ${CEE_CURRENT_LIST_DIR}RimMultiSnapshotDefinition.h ${CEE_CURRENT_LIST_DIR}RimMdiWindowController.h +${CEE_CURRENT_LIST_DIR}RimPropertyFilter.h ${CEE_CURRENT_LIST_DIR}RimEllipseFractureTemplate.h ${CEE_CURRENT_LIST_DIR}RimFractureTemplateCollection.h ${CEE_CURRENT_LIST_DIR}RimFracture.h @@ -178,6 +179,7 @@ ${CEE_CURRENT_LIST_DIR}RimEclipseInputCaseOpm.cpp ${CEE_CURRENT_LIST_DIR}RimIntersectionBox.cpp ${CEE_CURRENT_LIST_DIR}RimMultiSnapshotDefinition.cpp ${CEE_CURRENT_LIST_DIR}RimMdiWindowController.cpp +${CEE_CURRENT_LIST_DIR}RimPropertyFilter.cpp ${CEE_CURRENT_LIST_DIR}RimEllipseFractureTemplate.cpp ${CEE_CURRENT_LIST_DIR}RimFractureTemplateCollection.cpp ${CEE_CURRENT_LIST_DIR}RimFracture.cpp diff --git a/ApplicationCode/ProjectDataModel/RimCellFilter.cpp b/ApplicationCode/ProjectDataModel/RimCellFilter.cpp index bc2bfb32c6..746c0f25b8 100644 --- a/ApplicationCode/ProjectDataModel/RimCellFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellFilter.cpp @@ -18,8 +18,6 @@ #include "RimCellFilter.h" -#include "cafAppEnum.h" - #include namespace caf @@ -47,8 +45,6 @@ RimCellFilter::RimCellFilter() CAF_PDM_InitField(&isActive, "Active", true, "Active", "", "", ""); isActive.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&m_selectedCategoryValues, "SelectedValues", "Values", "", "", ""); - CAF_PDM_InitFieldNoDefault(&filterMode, "FilterType", "Filter Type", "", "", ""); } @@ -67,14 +63,6 @@ caf::PdmFieldHandle* RimCellFilter::userDescriptionField() return &name; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimCellFilter::selectedCategoryValues() const -{ - return m_selectedCategoryValues; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -123,67 +111,3 @@ caf::PdmFieldHandle* RimCellFilter::objectToggleField() return &isActive; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QList RimCellFilter::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) -{ - QList options; - - if (&m_selectedCategoryValues == fieldNeedingOptions) - { - if (useOptionsOnly) *useOptionsOnly = true; - - if (m_categoryValues.size() == m_categoryNames.size()) - { - for (size_t i = 0; i < m_categoryValues.size(); i++) - { - int categoryValue = m_categoryValues[i]; - QString categoryName = m_categoryNames[i]; - - options.push_back(caf::PdmOptionItemInfo(categoryName, categoryValue)); - } - } - else - { - for (auto it : m_categoryValues) - { - QString str = QString::number(it); - options.push_back(caf::PdmOptionItemInfo(str, it)); - } - } - } - - return options; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimCellFilter::setCategoryValues(const std::vector& categoryValues) -{ - m_categoryValues = categoryValues; - m_categoryNames.clear(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimCellFilter::setCategoryNames(const std::vector& categoryNames) -{ - m_categoryNames = categoryNames; - - for (size_t i = 0; i < m_categoryNames.size(); i++) - { - m_categoryValues.push_back(static_cast(i)); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimCellFilter::clearCategories() -{ - m_categoryValues.clear(); - m_categoryNames.clear(); -} diff --git a/ApplicationCode/ProjectDataModel/RimCellFilter.h b/ApplicationCode/ProjectDataModel/RimCellFilter.h index f17c67e968..3a576780e3 100644 --- a/ApplicationCode/ProjectDataModel/RimCellFilter.h +++ b/ApplicationCode/ProjectDataModel/RimCellFilter.h @@ -20,7 +20,6 @@ #include "cafPdmField.h" #include "cafPdmObject.h" -#include "cafPdmPointer.h" #include "cafAppEnum.h" @@ -45,22 +44,9 @@ public: caf::PdmField isActive; caf::PdmField< caf::AppEnum< FilterModeType > > filterMode; - std::vector selectedCategoryValues() const; - void updateIconState(); protected: virtual caf::PdmFieldHandle* userDescriptionField(); virtual caf::PdmFieldHandle* objectToggleField(); - virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly); - - void setCategoryValues(const std::vector& categoryValues); - void setCategoryNames(const std::vector& categoryNames); - void clearCategories(); - -protected: - std::vector m_categoryValues; - std::vector m_categoryNames; - - caf::PdmField< std::vector > m_selectedCategoryValues; }; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index e0bb03e4c0..9bcc9ee998 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -197,6 +197,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection() else if (dynamic_cast(uiItem)) { commandIds << "RicEclipsePropertyFilterInsertFeature"; + commandIds << "RicApplyPropertyFilterAsCellResultFeature"; } else if (dynamic_cast(uiItem)) { @@ -205,6 +206,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection() else if (dynamic_cast(uiItem)) { commandIds << "RicGeoMechPropertyFilterInsertFeature"; + commandIds << "RicApplyPropertyFilterAsCellResultFeature"; } else if (dynamic_cast(uiItem)) { diff --git a/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.h b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.h index 9966e6d0e0..639a004280 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.h +++ b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.h @@ -20,7 +20,7 @@ #pragma once -#include "RimCellFilter.h" +#include "RimPropertyFilter.h" #include "cafPdmChildField.h" @@ -36,7 +36,7 @@ class RigCaseCellResultsData; /// /// //================================================================================================== -class RimEclipsePropertyFilter : public RimCellFilter +class RimEclipsePropertyFilter : public RimPropertyFilter { CAF_PDM_HEADER_INIT; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.h b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.h index 3551a31a6e..aad1331506 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.h @@ -19,7 +19,7 @@ #pragma once -#include "RimCellFilter.h" +#include "RimPropertyFilter.h" #include "cafPdmChildField.h" @@ -31,7 +31,7 @@ class RimGeoMechPropertyFilterCollection; /// /// //================================================================================================== -class RimGeoMechPropertyFilter : public RimCellFilter +class RimGeoMechPropertyFilter : public RimPropertyFilter { CAF_PDM_HEADER_INIT; diff --git a/ApplicationCode/ProjectDataModel/RimPropertyFilter.cpp b/ApplicationCode/ProjectDataModel/RimPropertyFilter.cpp new file mode 100644 index 0000000000..dac5f040ab --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimPropertyFilter.cpp @@ -0,0 +1,112 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- 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 "RimPropertyFilter.h" + + +CAF_PDM_SOURCE_INIT(RimPropertyFilter, "PropertyFilter"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPropertyFilter::RimPropertyFilter() +{ + CAF_PDM_InitObject("Property Filter", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_selectedCategoryValues, "SelectedValues", "Values", "", "", ""); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPropertyFilter::~RimPropertyFilter() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimPropertyFilter::selectedCategoryValues() const +{ + return m_selectedCategoryValues; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimPropertyFilter::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) +{ + QList options; + + if (&m_selectedCategoryValues == fieldNeedingOptions) + { + if (useOptionsOnly) *useOptionsOnly = true; + + if (m_categoryValues.size() == m_categoryNames.size()) + { + for (size_t i = 0; i < m_categoryValues.size(); i++) + { + int categoryValue = m_categoryValues[i]; + QString categoryName = m_categoryNames[i]; + + options.push_back(caf::PdmOptionItemInfo(categoryName, categoryValue)); + } + } + else + { + for (auto it : m_categoryValues) + { + QString str = QString::number(it); + options.push_back(caf::PdmOptionItemInfo(str, it)); + } + } + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPropertyFilter::setCategoryValues(const std::vector& categoryValues) +{ + m_categoryValues = categoryValues; + m_categoryNames.clear(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPropertyFilter::setCategoryNames(const std::vector& categoryNames) +{ + m_categoryNames = categoryNames; + + for (size_t i = 0; i < m_categoryNames.size(); i++) + { + m_categoryValues.push_back(static_cast(i)); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPropertyFilter::clearCategories() +{ + m_categoryValues.clear(); + m_categoryNames.clear(); +} diff --git a/ApplicationCode/ProjectDataModel/RimPropertyFilter.h b/ApplicationCode/ProjectDataModel/RimPropertyFilter.h new file mode 100644 index 0000000000..fc8e3ebacc --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimPropertyFilter.h @@ -0,0 +1,49 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- 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 "RimCellFilter.h" + + +//================================================================================================== +/// +/// +//================================================================================================== +class RimPropertyFilter : public RimCellFilter +{ + CAF_PDM_HEADER_INIT; +public: + RimPropertyFilter(); + virtual ~RimPropertyFilter(); + + std::vector selectedCategoryValues() const; + +protected: + void setCategoryValues(const std::vector& categoryValues); + void setCategoryNames(const std::vector& categoryNames); + void clearCategories(); + + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; + +protected: + caf::PdmField< std::vector > m_selectedCategoryValues; + + std::vector m_categoryValues; + std::vector m_categoryNames; +}; diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index e2f9925e76..e1fd6d00e9 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -553,8 +553,6 @@ void RiuMainWindow::createDockPanels() m_pdmUiPropertyView = new caf::PdmUiPropertyView(dockWidget); dockWidget->setWidget(m_pdmUiPropertyView); - m_pdmUiPropertyView->layout()->setContentsMargins(5,0,0,0); - addDockWidget(Qt::LeftDockWidgetArea, dockWidget); } diff --git a/ApplicationCode/UserInterface/RiuNightchartsWidget.cpp b/ApplicationCode/UserInterface/RiuNightchartsWidget.cpp index ba494aada8..59d3c70dd3 100644 --- a/ApplicationCode/UserInterface/RiuNightchartsWidget.cpp +++ b/ApplicationCode/UserInterface/RiuNightchartsWidget.cpp @@ -111,8 +111,7 @@ QSize RiuNightchartsWidget::sizeHint() const if ( m_showLegend ) { - QPainter painter; - int lineHeight = painter.fontMetrics().height(); + int lineHeight = this->fontMetrics().height(); int lineCount = m_chart.pieceCount(); int exactLegendHeight = (lineCount + lineCount-1) * lineHeight; @@ -186,8 +185,7 @@ void RiuNightchartsWidget::paintEvent(QPaintEvent* e) void RiuNightchartsWidget::addItem(const QString& name, const QColor& color, float value) { m_chart.addPiece(name, color, value); - QPainter painter; - int textWidth = painter.fontMetrics().width(name + " (00 %)"); + int textWidth = this->fontMetrics().width(name + " (00 %)"); m_maxNameWidth = textWidth > m_maxNameWidth ? textWidth: m_maxNameWidth; } diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 61812cba4a..df432fc289 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -321,6 +321,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) commandIds << "RicNewSimWellIntersectionFeature"; commandIds << "RicShowWellAllocationPlotFeature"; + commandIds << "RicShowContributingWellsFeature"; RiuSelectionItem* selItem = new RiuSimWellSelectionItem(eclipseWellSourceInfo->well(), m_currentPickPositionInDomainCoords, eclipseWellSourceInfo->branchIndex()); RiuSelectionManager::instance()->setSelectedItem(selItem, RiuSelectionManager::RUI_TEMPORARY); diff --git a/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp b/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp index f4582ef3b6..e8ad9e7c5a 100644 --- a/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp +++ b/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp @@ -171,7 +171,7 @@ void RiuWellAllocationPlot::contextMenuEvent(QContextMenuEvent* event) QMenu menu; QStringList commandIds; - commandIds << "RicShowContributingWellsFeature"; + commandIds << "RicShowContributingWellsFromPlotFeature"; RimContextCommandBuilder::appendCommandsToMenu(commandIds, &menu); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp index 3d66262da3..a940b6318b 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp @@ -45,14 +45,15 @@ #include "cafPdmUiOrdering.h" #include "cafSelectionManager.h" +#include #include #include #include -#include -#include #include -#include +#include +#include #include +#include #include @@ -179,7 +180,21 @@ void PdmUiLineEditor::configureAndUpdateUi(const QString& uiConfigName) if (!m_lineEdit.isNull()) { - m_lineEdit->setEnabled(!field()->isUiReadOnly(uiConfigName)); + bool isReadOnly = field()->isUiReadOnly(uiConfigName); + if (isReadOnly) + { + m_lineEdit->setReadOnly(true); + + m_lineEdit->setStyleSheet("QLineEdit {" + "color: #808080;" + "background-color: #F0F0F0;}"); + } + else + { + m_lineEdit->setReadOnly(false); + m_lineEdit->setStyleSheet(""); + } + m_lineEdit->setToolTip(field()->uiToolTip(uiConfigName)); { @@ -255,7 +270,9 @@ void PdmUiLineEditor::configureAndUpdateUi(const QString& uiConfigName) QWidget* PdmUiLineEditor::createEditorWidget(QWidget * parent) { m_lineEdit = new QLineEdit(parent); + connect(m_lineEdit, SIGNAL(editingFinished()), this, SLOT(slotEditingFinished())); + return m_lineEdit; } diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.cpp index dd20eeb9c8..7c9c83291c 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.cpp @@ -41,6 +41,7 @@ #include "cafPdmUiDefaultObjectEditor.h" #include +#include namespace caf @@ -53,12 +54,20 @@ namespace caf PdmUiPropertyView::PdmUiPropertyView(QWidget* parent, Qt::WindowFlags f) : QWidget (parent, f) { - m_layout = new QVBoxLayout(this); - m_layout->insertStretch(1, 1); - m_layout->setContentsMargins(0, 0, 0, 0); - m_layout->setSpacing(0); + QScrollArea* scrollArea = new QScrollArea(this); + scrollArea->setFrameStyle(QFrame::NoFrame); + scrollArea->setWidgetResizable(true); - setLayout(m_layout); + m_placeholder = new QWidget(); + scrollArea->setWidget(m_placeholder); + + m_placeHolderLayout = new QVBoxLayout(); + m_placeHolderLayout->setContentsMargins(5,0,0,0); + m_placeholder->setLayout(m_placeHolderLayout); + + QVBoxLayout* dummy = new QVBoxLayout(this); + dummy->setContentsMargins(0,0,0,0); + dummy->addWidget(scrollArea); m_currentObjectView = NULL; } @@ -123,12 +132,11 @@ void PdmUiPropertyView::showProperties( PdmObjectHandle* object) // Remove Widget from layout if (m_currentObjectView) { - layout()->removeWidget(m_currentObjectView->widget()); + this->m_placeHolderLayout->removeWidget(m_currentObjectView->widget()); delete m_currentObjectView; m_currentObjectView = NULL; } - //m_currentObjectView = PdmObjViewFactory::instance()->create(object->editorType(m_uiConfigName)); if (!m_currentObjectView) { PdmUiDefaultObjectEditor* defaultEditor = new PdmUiDefaultObjectEditor(); @@ -136,12 +144,15 @@ void PdmUiPropertyView::showProperties( PdmObjectHandle* object) } // Create widget to handle this - QWidget * page = NULL; - page = m_currentObjectView->getOrCreateWidget(this); + QWidget* propertyWidget = NULL; + propertyWidget = m_currentObjectView->getOrCreateWidget(m_placeholder); + + assert(propertyWidget); - assert(page); + this->m_placeHolderLayout->insertWidget(0, propertyWidget); - this->m_layout->insertWidget(0, page); + // Add stretch to make sure the property widget is not stretched + this->m_placeHolderLayout->insertStretch(-1, 1); } m_currentObjectView->setPdmObject(object); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.h index f73d87aa5c..0c9d77a7ac 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.h @@ -36,6 +36,7 @@ #pragma once + #include #include @@ -69,7 +70,8 @@ public: private: PdmUiObjectEditorHandle* m_currentObjectView; QString m_uiConfigName; - QVBoxLayout* m_layout; + QVBoxLayout* m_placeHolderLayout; + QWidget* m_placeholder; }; diff --git a/ThirdParty/nightcharts/nightcharts.cpp b/ThirdParty/nightcharts/nightcharts.cpp index ec712276be..a53053766b 100644 --- a/ThirdParty/nightcharts/nightcharts.cpp +++ b/ThirdParty/nightcharts/nightcharts.cpp @@ -37,7 +37,13 @@ Nightcharts::Nightcharts()//QPainter *painter) lX = cX+cW+20; lY = cY; shadows = true; + + // NOTE: This value is accumulated, and might end up with overflow + // Was originally uninitialized, and caused overflow issues and invalid drawing when running debug + // Suggest rewrite and use locally defined aggregatedAngle (see below for usage) + palpha = 0.0; } + Nightcharts::~Nightcharts() { pieces.clear(); @@ -143,6 +149,7 @@ int Nightcharts::draw(QPainter *painter) QPen pen; pen.setWidth(2); + double aggregatedAngle = 0.0; for (int i=0;isetPen(pen); pdegree = 3.6*pieces[i].pPerc; - painter->drawPie(cX,cY,cW,cH,palpha*16,pdegree*16); - palpha += pdegree; + painter->drawPie(cX,cY,cW,cH,aggregatedAngle*16,pdegree*16); + aggregatedAngle += pdegree; } } else if (this->ctype==Nightcharts::Dpie)