diff --git a/ApplicationCode/Commands/GridCrossPlotCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/GridCrossPlotCommands/CMakeLists_files.cmake index 09048d42df..a8b8cefa56 100644 --- a/ApplicationCode/Commands/GridCrossPlotCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/GridCrossPlotCommands/CMakeLists_files.cmake @@ -2,11 +2,13 @@ set (SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RicCreateGridCrossPlotFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicCreateGridCrossPlotCurveSetFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSwapGridCrossPlotCurveSetAxesFeature.h ) set (SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RicCreateGridCrossPlotFeature.cpp -${CMAKE_CURRENT_LIST_DIR}/RicCreateGridCrossPlotCurveSetFeature.cpp) +${CMAKE_CURRENT_LIST_DIR}/RicCreateGridCrossPlotCurveSetFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSwapGridCrossPlotCurveSetAxesFeature.cpp) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES} diff --git a/ApplicationCode/Commands/GridCrossPlotCommands/RicCreateGridCrossPlotCurveSetFeature.h b/ApplicationCode/Commands/GridCrossPlotCommands/RicCreateGridCrossPlotCurveSetFeature.h index 376a622ad8..d27e7d496b 100644 --- a/ApplicationCode/Commands/GridCrossPlotCommands/RicCreateGridCrossPlotCurveSetFeature.h +++ b/ApplicationCode/Commands/GridCrossPlotCommands/RicCreateGridCrossPlotCurveSetFeature.h @@ -19,8 +19,6 @@ #include "cafCmdFeature.h" -#include - //================================================================================================== /// //================================================================================================== diff --git a/ApplicationCode/Commands/GridCrossPlotCommands/RicSwapGridCrossPlotCurveSetAxesFeature.cpp b/ApplicationCode/Commands/GridCrossPlotCommands/RicSwapGridCrossPlotCurveSetAxesFeature.cpp new file mode 100644 index 0000000000..065dd37b76 --- /dev/null +++ b/ApplicationCode/Commands/GridCrossPlotCommands/RicSwapGridCrossPlotCurveSetAxesFeature.cpp @@ -0,0 +1,61 @@ +#include "RicSwapGridCrossPlotCurveSetAxesFeature.h" + +#include "RimGridCrossPlot.h" +#include "RimGridCrossPlotCurveSet.h" + +#include + +#include + +CAF_CMD_SOURCE_INIT(RicSwapGridCrossPlotCurveSetAxesFeature, "RicSwapGridCrossPlotCurveSetAxesFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicSwapGridCrossPlotCurveSetAxesFeature::isCommandEnabled() +{ + if (caf::SelectionManager::instance()->selectedItemOfType()) + { + return true; + } + else if (caf::SelectionManager::instance()->selectedItemOfType()) + { + auto plot = caf::SelectionManager::instance()->selectedItemOfType(); + if (!plot->curveSets().empty()) + return true; + } + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSwapGridCrossPlotCurveSetAxesFeature::onActionTriggered(bool isChecked) +{ + if (caf::SelectionManager::instance()->selectedItemOfType()) + { + auto curveSet = caf::SelectionManager::instance()->selectedItemOfType(); + curveSet->swapAxisProperties(true); + } + else if (caf::SelectionManager::instance()->selectedItemOfType()) + { + auto plot = caf::SelectionManager::instance()->selectedItemOfType(); + plot->swapAllAxisProperties(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSwapGridCrossPlotCurveSetAxesFeature::setupActionLook(QAction* actionToSetup) +{ + if (caf::SelectionManager::instance()->selectedItemOfType()) + { + actionToSetup->setText("Swap Axis Properties"); + } + else + { + actionToSetup->setText("Swap Axis Properties for all Data Sets in Plot"); + } + actionToSetup->setIcon(QIcon(":/Swap.png")); +} diff --git a/ApplicationCode/Commands/GridCrossPlotCommands/RicSwapGridCrossPlotCurveSetAxesFeature.h b/ApplicationCode/Commands/GridCrossPlotCommands/RicSwapGridCrossPlotCurveSetAxesFeature.h new file mode 100644 index 0000000000..2a3fb57377 --- /dev/null +++ b/ApplicationCode/Commands/GridCrossPlotCommands/RicSwapGridCrossPlotCurveSetAxesFeature.h @@ -0,0 +1,38 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2019- 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 RicSwapGridCrossPlotCurveSetAxesFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + bool isCommandEnabled() override; + void onActionTriggered(bool isChecked) override; + void setupActionLook(QAction* actionToSetup) override; +}; + + + + + diff --git a/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.cpp b/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.cpp index 202563c022..2d9748d253 100644 --- a/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.cpp +++ b/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.cpp @@ -487,6 +487,7 @@ void RimGridCrossPlot::updatePlot() { m_qwtPlot->insertLegend(nullptr); } + m_qwtPlot->updateLegendSizesToMatchPlot(); m_qwtPlot->replot(); } } @@ -507,6 +508,18 @@ void RimGridCrossPlot::updateCurveNamesAndPlotTitle() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridCrossPlot::swapAllAxisProperties() +{ + for (auto curveSet : m_crossPlotCurveSets) + { + curveSet->swapAxisProperties(false); + } + loadDataAndUpdate(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.h b/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.h index 98b8b19f1d..1005619d42 100644 --- a/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.h +++ b/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.h @@ -69,6 +69,7 @@ public: void detachAllCurves(); void performAutoNameUpdate() override; void updateCurveNamesAndPlotTitle(); + void swapAllAxisProperties(); RiuGridCrossQwtPlot* qwtPlot() const; public: diff --git a/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotCurveSet.cpp b/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotCurveSet.cpp index d31d507fbc..89caba5adc 100644 --- a/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotCurveSet.cpp @@ -79,7 +79,7 @@ RimGridCrossPlotCurveSet::RimGridCrossPlotCurveSet() CAF_PDM_InitField(&m_timeStep, "TimeStep", -1, "Time Step", "", "", ""); m_timeStep.uiCapability()->setUiEditorTypeName(caf::PdmUiComboBoxEditor::uiEditorTypeName()); - CAF_PDM_InitFieldNoDefault(&m_cellFilterView, "VisibleCellView", "Filter by Cells Visible in 3d View", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_cellFilterView, "VisibleCellView", "Filter by 3d View Visibility", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_grouping, "Grouping", "Group Data by", "", "", ""); @@ -87,11 +87,13 @@ RimGridCrossPlotCurveSet::RimGridCrossPlotCurveSet() m_xAxisProperty = new RimEclipseResultDefinition; m_xAxisProperty.uiCapability()->setUiHidden(true); m_xAxisProperty.uiCapability()->setUiTreeChildrenHidden(true); + m_xAxisProperty->setLabelsOnTop(true); CAF_PDM_InitFieldNoDefault(&m_yAxisProperty, "YAxisProperty", "Y-Axis Property", "", "", ""); m_yAxisProperty = new RimEclipseResultDefinition; m_yAxisProperty.uiCapability()->setUiHidden(true); m_yAxisProperty.uiCapability()->setUiTreeChildrenHidden(true); + m_yAxisProperty->setLabelsOnTop(true); CAF_PDM_InitFieldNoDefault(&m_groupingProperty, "GroupingProperty", "Data Grouping Property", "", "", ""); m_groupingProperty = new RimEclipseCellColors; @@ -115,6 +117,7 @@ RimGridCrossPlotCurveSet::RimGridCrossPlotCurveSet() void RimGridCrossPlotCurveSet::setCellFilterView(RimGridView* cellFilterView) { m_cellFilterView = cellFilterView; + m_groupingProperty->setReservoirView(dynamic_cast(m_cellFilterView())); } //-------------------------------------------------------------------------------------------------- @@ -534,7 +537,7 @@ void RimGridCrossPlotCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUi caf::PdmUiGroup* xAxisGroup = uiOrdering.addNewGroup("X-Axis Property"); m_xAxisProperty->uiOrdering(uiConfigName, *xAxisGroup); - caf::PdmUiGroup* yAxisGroup = uiOrdering.addNewGroup("Y-Axis Property"); + caf::PdmUiGroup* yAxisGroup = uiOrdering.addNewGroup("Y-Axis Property", false); m_yAxisProperty->uiOrdering(uiConfigName, *yAxisGroup); } @@ -599,6 +602,7 @@ void RimGridCrossPlotCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* chang } else if (changedField == &m_cellFilterView) { + m_groupingProperty->setReservoirView(dynamic_cast(m_cellFilterView())); loadDataAndUpdate(true); } else if (changedField == &m_isChecked) @@ -767,6 +771,21 @@ bool RimGridCrossPlotCurveSet::groupingEnabled() const return false; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridCrossPlotCurveSet::swapAxisProperties(bool updatePlot) +{ + RimEclipseResultDefinition* xAxisProperties = m_xAxisProperty(); + RimEclipseResultDefinition* yAxisProperties = m_yAxisProperty(); + + m_xAxisProperty.removeChildObject(xAxisProperties); + m_yAxisProperty.removeChildObject(yAxisProperties); + m_yAxisProperty = xAxisProperties; + m_xAxisProperty = yAxisProperties; + loadDataAndUpdate(updatePlot); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotCurveSet.h b/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotCurveSet.h index dc99632759..414ad6118c 100644 --- a/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotCurveSet.h +++ b/ApplicationCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotCurveSet.h @@ -113,6 +113,7 @@ public: void updateLegend(); bool groupingByCategoryResult() const; bool groupingEnabled() const; + void swapAxisProperties(bool updatePlot); protected: void initAfterRead() override; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 06ccdc9483..9716312ae0 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -60,6 +60,7 @@ #include "RimGridCollection.h" #include "RimGridCrossPlot.h" #include "RimGridCrossPlotCollection.h" +#include "RimGridCrossPlotCurveSet.h" #include "RimIdenticalGridCaseGroup.h" #include "RimIntersection.h" #include "RimIntersectionBox.h" @@ -472,6 +473,11 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() else if (dynamic_cast(uiItem)) { menuBuilder << "RicCreateGridCrossPlotCurveSetFeature"; + menuBuilder << "RicSwapGridCrossPlotCurveSetAxesFeature"; + } + else if (dynamic_cast(uiItem)) + { + menuBuilder << "RicSwapGridCrossPlotCurveSetAxesFeature"; } else if (dynamic_cast(uiItem)) // This is also the definition for RimSummaryCrossPlot { diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp index 3e2ac2d643..d07d767ffe 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp @@ -76,6 +76,7 @@ CAF_PDM_SOURCE_INIT(RimEclipseResultDefinition, "ResultDefinition"); //-------------------------------------------------------------------------------------------------- RimEclipseResultDefinition::RimEclipseResultDefinition() : m_diffResultOptionsEnabled(false) + , m_labelsOnTop(false) { CAF_PDM_InitObject("Result Definition", "", "", ""); @@ -1172,6 +1173,14 @@ void RimEclipseResultDefinition::setDiffResultOptionsEnabled(bool enabled) m_diffResultOptionsEnabled = true; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseResultDefinition::setLabelsOnTop(bool labelsOnTop) +{ + m_labelsOnTop = labelsOnTop; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1302,6 +1311,19 @@ void RimEclipseResultDefinition::defineUiOrdering(QString uiConfigName, caf::Pdm m_resultVariableUiField.uiCapability()->setUiName(resultPropertyLabel); } + if (m_labelsOnTop) + { + std::vector fields; + this->fields(fields); + for (auto field : fields) + { + if (field->uiCapability()) + { + field->uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP); + } + } + } + uiOrdering.skipRemainingFields(true); } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.h b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.h index 2c1b3cc3c7..9a3ca569de 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.h @@ -121,6 +121,7 @@ public: void updateUiFieldsFromActiveResult(); void setDiffResultOptionsEnabled(bool enabled); + void setLabelsOnTop(bool labelsOnTop); protected: virtual void updateLegendCategorySettings() {}; @@ -214,5 +215,6 @@ private: private: bool m_diffResultOptionsEnabled; + bool m_labelsOnTop; }; diff --git a/ApplicationCode/Resources/ResInsight.qrc b/ApplicationCode/Resources/ResInsight.qrc index 3254f48c2e..3bdb84287b 100644 --- a/ApplicationCode/Resources/ResInsight.qrc +++ b/ApplicationCode/Resources/ResInsight.qrc @@ -148,6 +148,7 @@ ReachCircle16x16.png 2DMapProjection16x16.png Ruler24x24.png + Swap.png fs_CellFace.glsl diff --git a/ApplicationCode/Resources/Swap.png b/ApplicationCode/Resources/Swap.png new file mode 100644 index 0000000000..5b87cfd9a6 Binary files /dev/null and b/ApplicationCode/Resources/Swap.png differ diff --git a/ApplicationCode/UserInterface/RiuGridCrossQwtPlot.cpp b/ApplicationCode/UserInterface/RiuGridCrossQwtPlot.cpp index 09b0029870..be7c5e27df 100644 --- a/ApplicationCode/UserInterface/RiuGridCrossQwtPlot.cpp +++ b/ApplicationCode/UserInterface/RiuGridCrossQwtPlot.cpp @@ -83,6 +83,41 @@ void RiuGridCrossQwtPlot::removeCurveSetLegend(RimGridCrossPlotCurveSet* curveSe this->updateLegendLayout(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuGridCrossQwtPlot::updateLegendSizesToMatchPlot() +{ + RimGridCrossPlot* crossPlot = dynamic_cast(ownerPlotDefinition()); + if (!crossPlot) return; + + bool anyLegendResized = false; + + for (RimGridCrossPlotCurveSet* curveSet : crossPlot->curveSets()) + { + if (!curveSet->isChecked() || !curveSet->legendConfig()->showLegend()) continue; + + auto pairIt = m_legendWidgets.find(curveSet); + if (pairIt != m_legendWidgets.end()) + { + RiuCvfOverlayItemWidget* overlayWidget = pairIt->second; + if (overlayWidget->isVisible()) + { + caf::TitledOverlayFrame* overlayItem = curveSet->legendConfig()->titledOverlayFrame(); + if (resizeOverlayItemToFitPlot(overlayItem)) + { + anyLegendResized = true; + overlayWidget->updateFromOverlayItem(overlayItem); + } + } + } + } + if (anyLegendResized) + { + updateLegendLayout(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -146,35 +181,7 @@ void RiuGridCrossQwtPlot::updateLegendLayout() void RiuGridCrossQwtPlot::resizeEvent(QResizeEvent* e) { QwtPlot::resizeEvent(e); - - RimGridCrossPlot* crossPlot = dynamic_cast(ownerPlotDefinition()); - if (!crossPlot) return; - - bool anyLegendResized = false; - - for (RimGridCrossPlotCurveSet* curveSet : crossPlot->curveSets()) - { - if (!curveSet->isChecked() || !curveSet->legendConfig()->showLegend()) continue; - - auto pairIt = m_legendWidgets.find(curveSet); - if (pairIt != m_legendWidgets.end()) - { - RiuCvfOverlayItemWidget* overlayWidget = pairIt->second; - if (overlayWidget->isVisible()) - { - caf::TitledOverlayFrame* overlayItem = curveSet->legendConfig()->titledOverlayFrame(); - if (resizeOverlayItemToFitPlot(overlayItem)) - { - anyLegendResized = true; - overlayWidget->updateFromOverlayItem(overlayItem); - } - } - } - } - if (anyLegendResized) - { - updateLegendLayout(); - } + updateLegendSizesToMatchPlot(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuGridCrossQwtPlot.h b/ApplicationCode/UserInterface/RiuGridCrossQwtPlot.h index 1bf75a85fe..edae0892be 100644 --- a/ApplicationCode/UserInterface/RiuGridCrossQwtPlot.h +++ b/ApplicationCode/UserInterface/RiuGridCrossQwtPlot.h @@ -46,7 +46,7 @@ public: void addOrUpdateCurveSetLegend(RimGridCrossPlotCurveSet* curveSetToShowLegendFor); void removeCurveSetLegend(RimGridCrossPlotCurveSet* curveSetToShowLegendFor); - + void updateLegendSizesToMatchPlot(); protected: void updateLayout() override; void updateLegendLayout(); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.cpp index b6c65b0fd8..a4b737a092 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.cpp @@ -320,6 +320,10 @@ QMinimizePanel* groupBoxLayout->setContentsMargins(0, 0, 0, 0); groupBoxLayout->setHorizontalSpacing(0); } + else + { + groupBoxLayout->setContentsMargins(6, 6, 6, 6); + } groupBox->contentFrame()->setLayout(groupBoxLayout); connect(groupBox, SIGNAL(expandedChanged(bool)), this, SLOT(groupBoxExpandedStateToggled(bool)));