From 0d233e256881a09998742f58ae7615725a0906bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 11 May 2018 10:34:09 +0200 Subject: [PATCH] #2895 Fix performance related to case name in plot tracking text --- .../ProjectDataModel/RimPlotCurve.cpp | 4 +- .../UserInterface/CMakeLists_files.cmake | 2 + .../UserInterface/RiuRimQwtPlotCurve.cpp | 38 +++++++++++++++++++ .../UserInterface/RiuRimQwtPlotCurve.h | 36 ++++++++++++++++++ .../UserInterface/RiuSummaryQwtPlot.cpp | 20 +++------- 5 files changed, 83 insertions(+), 17 deletions(-) create mode 100644 ApplicationCode/UserInterface/RiuRimQwtPlotCurve.cpp create mode 100644 ApplicationCode/UserInterface/RiuRimQwtPlotCurve.h diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp index 833c8820f3..15aedc2069 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp @@ -25,7 +25,7 @@ #include "RimSummaryCurveFilter.h" #include "RimSummaryPlot.h" -#include "RiuLineSegmentQwtPlotCurve.h" +#include "RiuRimQwtPlotCurve.h" #include "cafPdmUiComboBoxEditor.h" @@ -110,7 +110,7 @@ RimPlotCurve::RimPlotCurve() CAF_PDM_InitField(&m_showLegend, "ShowLegend", true, "Contribute To Legend", "", "", ""); - m_qwtPlotCurve = new RiuLineSegmentQwtPlotCurve; + m_qwtPlotCurve = new RiuRimQwtPlotCurve(this); m_parentQwtPlot = nullptr; } diff --git a/ApplicationCode/UserInterface/CMakeLists_files.cmake b/ApplicationCode/UserInterface/CMakeLists_files.cmake index 0702225453..29557d6499 100644 --- a/ApplicationCode/UserInterface/CMakeLists_files.cmake +++ b/ApplicationCode/UserInterface/CMakeLists_files.cmake @@ -7,6 +7,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuFemResultTextBuilder.h ${CMAKE_CURRENT_LIST_DIR}/RiuGeoQuestNavigation.h ${CMAKE_CURRENT_LIST_DIR}/RiuInterfaceToViewWindow.h ${CMAKE_CURRENT_LIST_DIR}/RiuLineSegmentQwtPlotCurve.h +${CMAKE_CURRENT_LIST_DIR}/RiuRimQwtPlotCurve.h ${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindow.h ${CMAKE_CURRENT_LIST_DIR}/RiuMainWindow.h ${CMAKE_CURRENT_LIST_DIR}/RiuMainWindowBase.h @@ -80,6 +81,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuFemResultTextBuilder.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuGeoQuestNavigation.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuInterfaceToViewWindow.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuLineSegmentQwtPlotCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuRimQwtPlotCurve.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindow.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuMainWindow.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuMainWindowBase.cpp diff --git a/ApplicationCode/UserInterface/RiuRimQwtPlotCurve.cpp b/ApplicationCode/UserInterface/RiuRimQwtPlotCurve.cpp new file mode 100644 index 0000000000..56914e98d7 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuRimQwtPlotCurve.cpp @@ -0,0 +1,38 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- 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 "RiuRimQwtPlotCurve.h" +#include "RimPlotCurve.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuRimQwtPlotCurve::RiuRimQwtPlotCurve(RimPlotCurve* ownerRimCurve, const QString &title /*= QString::null*/) + : RiuLineSegmentQwtPlotCurve(title) + , m_ownerRimCurve(ownerRimCurve) +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPlotCurve * RiuRimQwtPlotCurve::ownerRimCurve() +{ + return m_ownerRimCurve; +} diff --git a/ApplicationCode/UserInterface/RiuRimQwtPlotCurve.h b/ApplicationCode/UserInterface/RiuRimQwtPlotCurve.h new file mode 100644 index 0000000000..a8cebb632a --- /dev/null +++ b/ApplicationCode/UserInterface/RiuRimQwtPlotCurve.h @@ -0,0 +1,36 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- 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 "RiuLineSegmentQwtPlotCurve.h" + +#include "cafPdmPointer.h" + +class RimPlotCurve; + +class RiuRimQwtPlotCurve: public RiuLineSegmentQwtPlotCurve +{ +public: + explicit RiuRimQwtPlotCurve(RimPlotCurve* ownerRimCurve, const QString &title = QString::null); + + RimPlotCurve * ownerRimCurve(); + +private: + caf::PdmPointer m_ownerRimCurve; +}; + diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp index 11df480f36..f9f3ccb412 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp @@ -60,6 +60,8 @@ #include "RimMainPlotCollection.h" #include "RimSummaryPlotCollection.h" #include "RimSummaryCase.h" +#include "RiuRimQwtPlotCurve.h" +#include "RimSummaryCurve.h" #include @@ -75,23 +77,11 @@ public: //-------------------------------------------------------------------------------------------------- virtual QString curveInfoText(QwtPlotCurve* curve) override { - RimProject* project = RiaApplication::instance()->project(); + RiuRimQwtPlotCurve* riuCurve = dynamic_cast(curve); RimSummaryCurve* sumCurve = nullptr; - - // Lookup RimSummaryCurve from QwtPlotCurve - for (auto const plot : project->mainPlotCollection->summaryPlotCollection()->summaryPlots()) + if (riuCurve) { - for (auto const curveSet : plot->ensembleCurveSetCollection()->curveSets()) - { - for (auto const currSumCurve : curveSet->curves()) - { - if (currSumCurve->qwtPlotCurve() == curve) - { - sumCurve = currSumCurve; - break; - } - } - } + sumCurve = dynamic_cast(riuCurve->ownerRimCurve()); } return sumCurve && sumCurve->summaryCaseY() ? sumCurve->summaryCaseY()->caseName() : "";