diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index 46fdebb4bf..7b9433a062 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -133,6 +133,7 @@ list( APPEND REFERENCED_CMAKE_FILES Commands/OctaveScriptCommands/CMakeLists_files.cmake Commands/ViewLink/CMakeLists_files.cmake Commands/WellLogCommands/CMakeLists_files.cmake + Commands/SummaryPlotCommands/CMakeLists_files.cmake Commands/WellPathCommands/CMakeLists_files.cmake Commands/CrossSectionCommands/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake new file mode 100644 index 0000000000..f31218322c --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake @@ -0,0 +1,29 @@ + +# 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}RicNewSummaryPlotFeature.h +) + +set (SOURCE_GROUP_SOURCE_FILES +${CEE_CURRENT_LIST_DIR}RicNewSummaryPlotFeature.cpp + +) + +list(APPEND CODE_HEADER_FILES +${SOURCE_GROUP_HEADER_FILES} +) + +list(APPEND CODE_SOURCE_FILES +${SOURCE_GROUP_SOURCE_FILES} +) + +list(APPEND QT_MOC_HEADERS +) + + +source_group( "CommandFeature\\SummaryPlot" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.cpp new file mode 100644 index 0000000000..56c3a69736 --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.cpp @@ -0,0 +1,70 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RicNewSummaryPlotFeature.h" + +#include "RimProject.h" +#include "RimSummaryPlot.h" + +#include "RiaApplication.h" + +#include + +#include "cvfAssert.h" +#include "RimSummaryPlotCollection.h" +#include "RimMainPlotCollection.h" + + +CAF_CMD_SOURCE_INIT(RicNewSummaryPlotFeature, "RicNewSummaryPlotFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicNewSummaryPlotFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewSummaryPlotFeature::onActionTriggered(bool isChecked) +{ + RimProject* project = RiaApplication::instance()->project(); + CVF_ASSERT(project); + + RimMainPlotCollection* mainPlotColl = project->mainPlotCollection(); + CVF_ASSERT(mainPlotColl); + + RimSummaryPlotCollection* summaryPlotColl = mainPlotColl->summaryPlotCollection(); + CVF_ASSERT(summaryPlotColl); + + RimSummaryPlot* plot = new RimSummaryPlot(); + summaryPlotColl->m_summaryPlots().push_back(plot); + + plot->setDescription(QString("Well Log Plot %1").arg(summaryPlotColl->m_summaryPlots.size())); + summaryPlotColl->updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewSummaryPlotFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("New Summary Plot"); +} diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.h b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.h new file mode 100644 index 0000000000..84e29e5f56 --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.h @@ -0,0 +1,35 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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" + +//================================================================================================== +/// +//================================================================================================== +class RicNewSummaryPlotFeature : 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/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index 9e8067c291..51cfcd272d 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -76,6 +76,10 @@ ${CEE_CURRENT_LIST_DIR}RimCrossSection.h ${CEE_CURRENT_LIST_DIR}RimCrossSectionCollection.h ${CEE_CURRENT_LIST_DIR}RimContextCommandBuilder.h ${CEE_CURRENT_LIST_DIR}RimGridCollection.h +${CEE_CURRENT_LIST_DIR}RimSummaryPlotCollection.h +${CEE_CURRENT_LIST_DIR}RimSummaryPlot.h +${CEE_CURRENT_LIST_DIR}RimSummaryCurve.h + ) set (SOURCE_GROUP_SOURCE_FILES @@ -150,6 +154,9 @@ ${CEE_CURRENT_LIST_DIR}RimCrossSection.cpp ${CEE_CURRENT_LIST_DIR}RimCrossSectionCollection.cpp ${CEE_CURRENT_LIST_DIR}RimContextCommandBuilder.cpp ${CEE_CURRENT_LIST_DIR}RimGridCollection.cpp +${CEE_CURRENT_LIST_DIR}RimSummaryPlotCollection.cpp +${CEE_CURRENT_LIST_DIR}RimSummaryPlot.cpp +${CEE_CURRENT_LIST_DIR}RimSummaryCurve.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 5ceea5fe05..c75935dbbb 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -77,6 +77,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection() if (uiItems.size() == 0) { commandIds << "RicNewWellLogPlotFeature"; + commandIds << "RicNewSummaryPlotFeature"; } else if (uiItems.size() > 1) { diff --git a/ApplicationCode/ProjectDataModel/RimMainPlotCollection.cpp b/ApplicationCode/ProjectDataModel/RimMainPlotCollection.cpp index feac205cde..921d2fabe5 100644 --- a/ApplicationCode/ProjectDataModel/RimMainPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimMainPlotCollection.cpp @@ -19,10 +19,13 @@ #include "RimMainPlotCollection.h" #include "RimWellLogPlotCollection.h" +#include "RimSummaryPlotCollection.h" #include "RiuMainWindow.h" #include "cafPdmUiTreeView.h" +#include "RiuProjectPropertyView.h" +#include "RimProject.h" CAF_PDM_SOURCE_INIT(RimMainPlotCollection, "MainPlotCollection"); @@ -33,13 +36,20 @@ RimMainPlotCollection::RimMainPlotCollection() { CAF_PDM_InitObject("Plots", "", "", ""); - CAF_PDM_InitField(&show, "Show", true, "Show plots", "", "", ""); + CAF_PDM_InitField(&show, "Show", true, "Show 2D Plot Window", "", "", ""); show.uiCapability()->setUiHidden(true); CAF_PDM_InitFieldNoDefault(&m_wellLogPlotCollection, "WellLogPlotCollection", "", "", "", ""); m_wellLogPlotCollection.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_summaryPlotCollection, "SummaryPlotCollection", "Summary Plots", "", "", ""); + m_summaryPlotCollection.uiCapability()->setUiHidden(true); + m_wellLogPlotCollection = new RimWellLogPlotCollection(); + m_summaryPlotCollection = new RimSummaryPlotCollection(); + + //m_plotMainWindow = NULL; + //m_plotManagerMainWindow = NULL; } //-------------------------------------------------------------------------------------------------- @@ -48,6 +58,10 @@ RimMainPlotCollection::RimMainPlotCollection() RimMainPlotCollection::~RimMainPlotCollection() { if (m_wellLogPlotCollection()) delete m_wellLogPlotCollection(); + if (m_summaryPlotCollection()) delete m_summaryPlotCollection(); + + //m_plotManagerMainWindow->close(); + //m_plotManagerMainWindow->deleteLater(); } //-------------------------------------------------------------------------------------------------- @@ -55,8 +69,62 @@ RimMainPlotCollection::~RimMainPlotCollection() //-------------------------------------------------------------------------------------------------- void RimMainPlotCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { +#if 0 + if (changedField == &showWindow) + { + if (showWindow) + { + showPlotWindow(); + } + else + { + hidePlotWindow(); + } + } + #endif +} +#if 0 +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimMainPlotCollection::showPlotWindow() +{ + if (!m_plotManagerMainWindow) + { + m_plotManagerMainWindow = new QMainWindow; + m_plotManagerMainWindow->setDockNestingEnabled(true); + + m_plotMainWindow = new QMainWindow; + m_plotMainWindow->setDockNestingEnabled(true); + + // NOTE! setCentralWidget takes ownership of widget + m_plotManagerMainWindow->setCentralWidget(m_plotMainWindow); + + { + QDockWidget* dockWidget = new QDockWidget("Plots", m_plotManagerMainWindow); + dockWidget->setObjectName("dockWidget"); + + RiuMainWindow* mainWindow = RiuMainWindow::instance(); + + RiuProjectAndPropertyView* projPropView = new RiuProjectAndPropertyView(dockWidget); + dockWidget->setWidget(projPropView); + + RimProject* proj = NULL; + this->firstAnchestorOrThisOfType(proj); + + projPropView->setPdmItem(this); + + m_plotManagerMainWindow->addDockWidget(Qt::LeftDockWidgetArea, dockWidget); + } + } + + m_plotMainWindow->show(); + + m_plotManagerMainWindow->showNormal(); + m_plotManagerMainWindow->raise(); } +#endif //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -72,3 +140,124 @@ RimWellLogPlotCollection* RimMainPlotCollection::wellLogPlotCollection() { return m_wellLogPlotCollection(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryPlotCollection* RimMainPlotCollection::summaryPlotCollection() +{ + return m_summaryPlotCollection(); +} + +#if 0 +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimMainPlotCollection::createDockWindowsForAllPlots() +{ + for (size_t i = 0; i < m_graphPlots.size(); i++) + { + if (!dockWidgetFromPlot(m_graphPlots[i])) + { + createPlotDockWidget(m_graphPlots[i]); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QDockWidget* RimMainPlotCollection::dockWidgetFromPlot(RimSummaryPlot* graphPlot) +{ + foreach(QDockWidget* dockW, m_plotViewDockWidgets) + { + if (dockW && dockW->widget() == graphPlot->widget()) + { + return dockW; + } + } + + return NULL; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimMainPlotCollection::createPlotDockWidget(RimSummaryPlot* graphPlot) +{ + assert(m_plotMainWindow != NULL); + + QDockWidget* dockWidget = new QDockWidget(QString("Plot Widget Tree (%1)").arg(m_plotViewDockWidgets.size() + 1), m_plotMainWindow); + dockWidget->setObjectName("dockWidget"); + // dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); + + QWidget* widget = graphPlot->createPlotWidget(m_plotMainWindow); + + dockWidget->setWidget(widget); + + m_plotMainWindow->addDockWidget(Qt::RightDockWidgetArea, dockWidget); + + m_plotViewDockWidgets.push_back(dockWidget); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimMainPlotCollection::eraseDockWidget(RimSummaryPlot* graphPlot) +{ + QDockWidget* dockW = dockWidgetFromPlot(graphPlot); + if (dockW) + { + m_plotMainWindow->removeDockWidget(dockW); + dockW->setWidget(NULL); + dockW->deleteLater(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimMainPlotCollection::redrawAllPlots() +{ + for (size_t i = 0; i < m_graphPlots.size(); i++) + { + m_graphPlots[i]->redrawAllCurves(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QMainWindow* RimMainPlotCollection::windowWithGraphPlots() +{ + return m_plotMainWindow; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimMainPlotCollection::initAfterRead() +{ + if (show()) + { + showPlotWindow(); + } + else + { + hidePlotWindow(); + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimMainPlotCollection::hidePlotWindow() +{ + if (m_plotManagerMainWindow) + { + m_plotManagerMainWindow->hide(); + } +} +#endif \ No newline at end of file diff --git a/ApplicationCode/ProjectDataModel/RimMainPlotCollection.h b/ApplicationCode/ProjectDataModel/RimMainPlotCollection.h index 6cd50243dc..b9de518b2d 100644 --- a/ApplicationCode/ProjectDataModel/RimMainPlotCollection.h +++ b/ApplicationCode/ProjectDataModel/RimMainPlotCollection.h @@ -23,7 +23,15 @@ #include "cafPdmField.h" #include "cafPdmChildField.h" +#include +#include + + class RimWellLogPlotCollection; +class RimSummaryPlotCollection; +class RimSummaryPlot; +class RifReaderEclipseSummary; +class RimEclipseResultCase; //================================================================================================== @@ -38,16 +46,38 @@ public: virtual ~RimMainPlotCollection(); RimWellLogPlotCollection* wellLogPlotCollection(); + RimSummaryPlotCollection* summaryPlotCollection(); + #if 0 + // Separate Window stuff + void showPlotWindow(); + void hidePlotWindow(); + + void redrawAllPlots(); + void createDockWindowsForAllPlots(); + QMainWindow* windowWithGraphPlots(); +private: + + QDockWidget* dockWidgetFromPlot(RimSummaryPlot* graphPlot); + void createPlotDockWidget(RimSummaryPlot* graphPlot); + void eraseDockWidget(RimSummaryPlot* graphPlot); + +private: + QMainWindow* m_plotManagerMainWindow; // Outer main Window + QMainWindow* m_plotMainWindow; // Inner main window + + std::vector > m_plotViewDockWidgets; // ChildPlotWidgets + #endif protected: // Overridden PDM methods - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); - -private: virtual caf::PdmFieldHandle* objectToggleField(); - -private: + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); + //virtual void initAfterRead(); + + caf::PdmChildField m_wellLogPlotCollection; + caf::PdmChildField m_summaryPlotCollection; + caf::PdmField show; }; diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index f93e1e77cd..c210fa63ec 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -38,6 +38,7 @@ #include "RimMainPlotCollection.h" #include "RimOilField.h" #include "RimScriptCollection.h" +#include "RimSummaryPlotCollection.h" #include "RimView.h" #include "RimViewLinker.h" #include "RimViewLinkerCollection.h" @@ -728,6 +729,10 @@ void RimProject::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QS { uiTreeOrdering.add(mainPlotCollection->wellLogPlotCollection()); } + if (mainPlotCollection->summaryPlotCollection()) + { + uiTreeOrdering.add(mainPlotCollection->summaryPlotCollection()); + } } uiTreeOrdering.add(scriptCollection()); diff --git a/ApplicationCode/ProjectDataModel/RimSummaryCurve.cpp b/ApplicationCode/ProjectDataModel/RimSummaryCurve.cpp new file mode 100644 index 0000000000..9d928ace01 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimSummaryCurve.cpp @@ -0,0 +1,169 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RimSummaryCurve.h" + +#include "RiaApplication.h" +#include "RifReaderEclipseSummary.h" +#include "RimDefines.h" +#include "RimEclipseResultCase.h" +#include "RimProject.h" +#include "RimSummaryPlot.h" +#include "RimSummaryPlotCollection.h" +#include "RiuResultQwtPlot.h" + +#include "cafPdmUiComboBoxEditor.h" +#include "cafPdmUiListEditor.h" +#include "cafPdmUiTreeOrdering.h" + +CAF_PDM_SOURCE_INIT(RimSummaryCurve, "SummaryCurve"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCurve::RimSummaryCurve() +{ + CAF_PDM_InitObject("Summary Curve", ":/WellLogCurve16x16.png", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_eclipseCase, "ReferencedEclipseCase", "Eclipse Case", "", "", ""); + m_eclipseCase.uiCapability()->setUiChildrenHidden(true); + + // TODO: Implement setUiTreeHidden + //m_eclipseCase.uiCapability()->setUiHidden(true); + + CAF_PDM_InitFieldNoDefault(&m_variableName, "SummaryVariableName", "Variable Name", "", "", ""); + + m_variableName.uiCapability()->setUiEditorTypeName(caf::PdmUiComboBoxEditor::uiEditorTypeName()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCurve::~RimSummaryCurve() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimSummaryCurve::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) +{ + QList optionList; + if (fieldNeedingOptions == &m_variableName) + { + if (m_eclipseCase) + { + RifReaderEclipseSummary* reader = summaryReader(); + if (reader) + { + std::vector varNames = reader->variableNames(); + + for (size_t i = 0; i < varNames.size(); i++) + { + std::string name = varNames[i]; + + QString s = QString::fromStdString(name); + optionList.push_back(caf::PdmOptionItemInfo(s, s)); + } + } + + optionList.push_front(caf::PdmOptionItemInfo(RimDefines::undefinedResultName(), RimDefines::undefinedResultName())); + + if (useOptionsOnly) *useOptionsOnly = true; + } + } + else if (fieldNeedingOptions == &m_eclipseCase) + { + RimProject* proj = RiaApplication::instance()->project(); + std::vector cases; + + proj->allCases(cases); + + for (size_t i = 0; i < cases.size(); i++) + { + RimCase* rimCase = cases[i]; + + optionList.push_back(caf::PdmOptionItemInfo(rimCase->caseUserDescription(), QVariant::fromValue(caf::PdmPointer(rimCase)))); + } + + if (optionList.size() > 0) + { + optionList.push_front(caf::PdmOptionItemInfo("None", QVariant::fromValue(caf::PdmPointer(NULL)))); + } + } + + return optionList; + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + if (changedField == &m_variableName) + { + RimSummaryPlot* summaryPlot = NULL; + this->firstAnchestorOrThisOfType(summaryPlot); + if (summaryPlot) + { + //summaryPlot->redrawAllCurves(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifReaderEclipseSummary* RimSummaryCurve::summaryReader() +{ + RimSummaryPlotCollection* plotCollection = NULL; + this->firstAnchestorOrThisOfType(plotCollection); + + return plotCollection->getOrCreateSummaryFileReader(m_eclipseCase); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCurve::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/) +{ + // TODO: Used to hide the entry for a case in the tree view as we have no + // setUiTreeHidden(true) + uiTreeOrdering.setForgetRemainingFields(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCurve::curveData(std::vector* timeSteps, std::vector* values) +{ + RifReaderEclipseSummary* reader = summaryReader(); + + if (timeSteps) + { + std::vector times = reader->timeSteps(); + *timeSteps = RifReaderEclipseSummary::fromTimeT(times); + } + + if (values) + { + std::string keyword = m_variableName().toStdString(); + reader->values(keyword, values); + } +} diff --git a/ApplicationCode/ProjectDataModel/RimSummaryCurve.h b/ApplicationCode/ProjectDataModel/RimSummaryCurve.h new file mode 100644 index 0000000000..8fe787f983 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimSummaryCurve.h @@ -0,0 +1,60 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "cafPdmField.h" +#include "cafPdmObject.h" +#include "cafPdmPointer.h" +#include "cafPdmPtrField.h" + + +class RimEclipseResultCase; +class RifReaderEclipseSummary; +class RiuLineSegmentQwtPlotCurve; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimSummaryCurve : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; +public: + RimSummaryCurve(); + virtual ~RimSummaryCurve(); + + caf::PdmPtrField m_eclipseCase; + + caf::PdmField m_variableName; + + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly); + + void curveData(std::vector* timeSteps, std::vector* values); + +private: + RifReaderEclipseSummary* summaryReader(); + + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); + virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = ""); + +private: + RiuLineSegmentQwtPlotCurve* m_qwtPlotCurve; + +}; diff --git a/ApplicationCode/ProjectDataModel/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/RimSummaryPlot.cpp new file mode 100644 index 0000000000..d9a7c96acb --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimSummaryPlot.cpp @@ -0,0 +1,166 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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(&curves, "SummaryCurves", "", "", "", ""); + curves.uiCapability()->setUiHidden(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryPlot::~RimSummaryPlot() +{ + deletePlotWidget(); + + curves.deleteAllChildObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QWidget* RimSummaryPlot::createPlotWidget(QWidget* parent) +{ + assert(m_viewer.isNull()); + + m_viewer = new RiuResultQwtPlot(parent); + + return m_viewer; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlot::deletePlotWidget() +{ + if (m_viewer) + { + m_viewer->deleteLater(); + m_viewer = NULL; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuResultQwtPlot* RimSummaryPlot::viewer() +{ + return m_viewer; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlot::loadDataAndUpdate() +{ + m_viewer->deleteAllCurves(); + + for (size_t i = 0; i < curves.size(); i++) + { + RimSummaryCurve* curve = curves[i]; + + std::vector dateTimes; + std::vector values; + + curve->curveData(&dateTimes, &values); + + cvf::Color3f curveColor = RiuSelectionColors::curveColorFromTable(); + + m_viewer->addCurve(curve->m_variableName(), curveColor, dateTimes, values); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlot::setDescription(const QString& description) +{ + m_userName = description; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlot::updateViewerWidget() +{ + if (m_showWindow()) + { + if (!m_viewer) + { + m_viewer = new RiuResultQwtPlot(RiuMainWindow::instance()); + + + RiuMainWindow::instance()->addViewer(m_viewer, std::vector()); + RiuMainWindow::instance()->setActiveViewer(m_viewer); + } + + //updateViewerWidgetWindowTitle(); + } + else + { + if (m_viewer) + { + //windowGeometry = RiuMainWindow::instance()->windowGeometryForViewer(m_viewer); + + RiuMainWindow::instance()->removeViewer(m_viewer); + detachAllCurves(); + + delete m_viewer; + m_viewer = NULL; + + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlot::detachAllCurves() +{ + for (size_t cIdx = 0; cIdx < curves.size(); ++cIdx) + { + //curves[cIdx]->detachQwtCurve(); + } +} diff --git a/ApplicationCode/ProjectDataModel/RimSummaryPlot.h b/ApplicationCode/ProjectDataModel/RimSummaryPlot.h new file mode 100644 index 0000000000..f7d4768003 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimSummaryPlot.h @@ -0,0 +1,67 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "cafPdmChildArrayField.h" +#include "cafAppEnum.h" + +#include + +class RiuResultQwtPlot; +class RimSummaryCurve; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimSummaryPlot : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimSummaryPlot(); + virtual ~RimSummaryPlot(); + + void setDescription(const QString& description); + void loadDataAndUpdate(); + RiuResultQwtPlot* viewer(); + + caf::PdmChildArrayField curves; + +protected: + // Overridden PDM methods + virtual caf::PdmFieldHandle* objectToggleField() { return &m_showWindow; } + virtual caf::PdmFieldHandle* userDescriptionField() { return &m_userName; } + +private: + void updateViewerWidget(); + + void detachAllCurves(); + + QWidget* createPlotWidget(QWidget* parent); + void deletePlotWidget(); + + caf::PdmField m_showWindow; + caf::PdmField m_userName; + + QPointer m_viewer; +}; diff --git a/ApplicationCode/ProjectDataModel/RimSummaryPlotCollection.cpp b/ApplicationCode/ProjectDataModel/RimSummaryPlotCollection.cpp new file mode 100644 index 0000000000..4c717d58f7 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimSummaryPlotCollection.cpp @@ -0,0 +1,117 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RimSummaryPlotCollection.h" + +#include "RifEclipseSummaryTools.h" +#include "RifReaderEclipseSummary.h" + +#include "RimEclipseResultCase.h" +#include "RimSummaryPlot.h" +#include "RimProject.h" + +#include "RiuProjectPropertyView.h" + +#include +#include "RiuMainWindow.h" + + +CAF_PDM_SOURCE_INIT(RimSummaryPlotCollection, "RimGraphPlotCollection"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryPlotCollection::RimSummaryPlotCollection() +{ + CAF_PDM_InitObject("Summary Plots", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_summaryPlots, "SummaryPlots", "Summary Plots", "", "", ""); + m_summaryPlots.uiCapability()->setUiHidden(true); + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryPlotCollection::~RimSummaryPlotCollection() +{ + m_summaryPlots.deleteAllChildObjects(); + + for (auto it = m_summaryFileReaders.begin(); it != m_summaryFileReaders.end(); it++) + { + delete it->second; + } + m_summaryFileReaders.clear(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifReaderEclipseSummary* RimSummaryPlotCollection::getOrCreateSummaryFileReader(const QString& eclipseCase) +{ + auto it = m_summaryFileReaders.find(eclipseCase); + if (it != m_summaryFileReaders.end()) + { + return it->second; + } + else + { + return createSummaryFileReader(eclipseCase); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifReaderEclipseSummary* RimSummaryPlotCollection::getOrCreateSummaryFileReader(const RimEclipseResultCase* eclipseCase) +{ + if (!eclipseCase) return NULL; + + QString caseName = eclipseCase->gridFileName(); + QString caseNameWithNoExtension = caseName.remove(".egrid", Qt::CaseInsensitive); + + QString caseNameAbsPath = caseNameWithNoExtension.replace("/", "\\"); + + return this->getOrCreateSummaryFileReader(caseNameAbsPath); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifReaderEclipseSummary* RimSummaryPlotCollection::createSummaryFileReader(const QString& eclipseCase) +{ + std::string headerFile; + bool isFormatted = false; + RifEclipseSummaryTools::findSummaryHeaderFile(eclipseCase.toStdString(), &headerFile, &isFormatted); + + std::vector dataFiles = RifEclipseSummaryTools::findSummaryDataFiles(eclipseCase.toStdString()); + + RifReaderEclipseSummary* reader = new RifReaderEclipseSummary; + if (!reader->open(headerFile, dataFiles)) + { + delete reader; + + return NULL; + } + else + { + m_summaryFileReaders.insert(std::make_pair(eclipseCase, reader)); + return reader; + } +} + diff --git a/ApplicationCode/ProjectDataModel/RimSummaryPlotCollection.h b/ApplicationCode/ProjectDataModel/RimSummaryPlotCollection.h new file mode 100644 index 0000000000..c26f3b1d94 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimSummaryPlotCollection.h @@ -0,0 +1,55 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "cafPdmChildArrayField.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" + +#include +#include + +class RimSummaryPlot; +class RicDropEnabledMainWindow; +class RifReaderEclipseSummary; +class RimEclipseResultCase; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimSummaryPlotCollection : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; +public: + RimSummaryPlotCollection(); + virtual ~RimSummaryPlotCollection(); + + RifReaderEclipseSummary* getOrCreateSummaryFileReader(const RimEclipseResultCase* eclipseCase); + + caf::PdmChildArrayField m_summaryPlots; + +private: + RifReaderEclipseSummary* createSummaryFileReader(const QString& eclipseCase); + RifReaderEclipseSummary* getOrCreateSummaryFileReader(const QString& eclipseCase); + +private: + // Map from path to case to summary file reader objects + std::map m_summaryFileReaders; +}; diff --git a/ApplicationCode/ProjectDataModel/RimWellLogCurve.h b/ApplicationCode/ProjectDataModel/RimWellLogCurve.h index 31b427596b..e06ff8ffac 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogCurve.h @@ -36,7 +36,71 @@ class RiuLineSegmentQwtPlotCurve; class QwtPlotCurve; class QString; +#if 0 +class RimPlotCurve : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; +public: + enum LineStyleEnum + { + STYLE_NONE, + STYLE_SOLID, + STYLE_DASH, + STYLE_DOT, + STYLE_DASH_DOT + }; + enum PointSymbolEnum + { + SYMBOL_NONE, + SYMBOL_ELLIPSE, + SYMBOL_RECT, + SYMBOL_DIAMOND, + SYMBOL_TRIANGLE, + SYMBOL_CROSS, + SYMBOL_XCROSS + }; +public: + RimPlotCurve(); + virtual ~RimPlotCurve(); + + void setColor(const cvf::Color3f& color); + void detachQwtCurve(); + + bool isCurveVisible() const; + + QwtPlotCurve* plotCurve() const; + + QString name() const { return m_curveName; } + void updateCurveName(); + void updatePlotTitle(); + +protected: + void updatePlotConfiguration(); + void updateCurveVisibility(); + void updateOptionSensitivity(); + void updateCurveAppearance(); +protected: + + // Overridden PDM methods + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); + virtual caf::PdmFieldHandle* objectToggleField(); + virtual caf::PdmFieldHandle* userDescriptionField(); +protected: + RiuLineSegmentQwtPlotCurve* m_qwtPlotCurve; + + caf::PdmField m_showCurve; + caf::PdmField m_curveName; + caf::PdmField m_customCurveName; + + caf::PdmField m_autoName; + caf::PdmField m_curveColor; + caf::PdmField m_curveThickness; + + caf::PdmField< caf::AppEnum< PointSymbolEnum > > m_pointSymbol; + caf::PdmField< caf::AppEnum< LineStyleEnum > > m_lineStyle; +}; +#endif //================================================================================================== /// ///