///////////////////////////////////////////////////////////////////////////////// // // 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 "RimSummaryPlot.h" #include "RimSummaryCurve.h" #include "RimSummaryPlotCollection.h" #include "RiuResultQwtPlot.h" #include "RiuSelectionColors.h" #include "cvfBase.h" #include "cvfColor3.h" #include #include "RiuMainWindow.h" CAF_PDM_SOURCE_INIT(RimSummaryPlot, "GraphPlot"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RimSummaryPlot::RimSummaryPlot() { CAF_PDM_InitObject("Graph", ":/WellLogPlot16x16.png", "", ""); CAF_PDM_InitField(&m_showWindow, "ShowWindow", true, "Show Summary Plot", "", "", ""); m_showWindow.uiCapability()->setUiHidden(true); CAF_PDM_InitField(&m_userName, "PlotDescription", QString("Summary Plot"), "Name", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_curves, "SummaryCurves", "", "", "", ""); m_curves.uiCapability()->setUiHidden(true); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RimSummaryPlot::~RimSummaryPlot() { deletePlotWidget(); m_curves.deleteAllChildObjects(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::deletePlotWidget() { if (m_qwtPlot) { m_qwtPlot->deleteLater(); m_qwtPlot = NULL; } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RiuResultQwtPlot* RimSummaryPlot::viewer() { return m_qwtPlot; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::addCurve(RimSummaryCurve* curve) { if (curve) { m_curves.push_back(curve); if (m_qwtPlot) { curve->setParentQwtPlot(m_qwtPlot); } } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { if (changedField == &m_showWindow) { if (m_showWindow) { loadDataAndUpdate(); } else { updateViewerWidget(); } uiCapability()->updateUiIconFromToggleField(); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::loadDataAndUpdate() { updateViewerWidget(); for (size_t i = 0; i < m_curves.size(); i++) { RimSummaryCurve* curve = m_curves[i]; curve->loadDataAndUpdate(); } // Todo: Update zoom } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::setDescription(const QString& description) { m_userName = description; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::updateViewerWidget() { if (m_showWindow()) { if (!m_qwtPlot) { m_qwtPlot = new RiuResultQwtPlot(RiuMainWindow::instance()); for (size_t cIdx = 0; cIdx < m_curves.size(); ++cIdx ) { m_curves[cIdx]->setParentQwtPlot(m_qwtPlot); } RiuMainWindow::instance()->addViewer(m_qwtPlot, std::vector()); RiuMainWindow::instance()->setActiveViewer(m_qwtPlot); } //updateViewerWidgetWindowTitle(); } else { if (m_qwtPlot) { //windowGeometry = RiuMainWindow::instance()->windowGeometryForViewer(m_viewer); RiuMainWindow::instance()->removeViewer(m_qwtPlot); detachAllCurves(); delete m_qwtPlot; m_qwtPlot = NULL; } } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::detachAllCurves() { for (size_t cIdx = 0; cIdx < m_curves.size(); ++cIdx) { m_curves[cIdx]->detachQwtCurve(); } }