mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
#739 First crude but working version of Summary plotting
This commit is contained in:
parent
a33929505d
commit
31e8009a6e
@ -7,10 +7,12 @@ endif()
|
||||
|
||||
set (SOURCE_GROUP_HEADER_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RicNewSummaryPlotFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFeature.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RicNewSummaryPlotFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFeature.cpp
|
||||
|
||||
)
|
||||
|
||||
|
@ -0,0 +1,89 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicNewSummaryCurveFeature.h"
|
||||
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
#include "cvfAssert.h"
|
||||
#include "RimSummaryPlotCollection.h"
|
||||
#include "RimMainPlotCollection.h"
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RiuMainWindow.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicNewSummaryCurveFeature, "RicNewSummaryCurveFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicNewSummaryCurveFeature::isCommandEnabled()
|
||||
{
|
||||
return (selectedSummaryPlot());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewSummaryCurveFeature::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 = selectedSummaryPlot();
|
||||
if (plot)
|
||||
{
|
||||
RimSummaryCurve* newCurve = new RimSummaryCurve();
|
||||
plot->addCurve(newCurve);
|
||||
plot->updateConnectedEditors();
|
||||
|
||||
RiuMainWindow::instance()->selectAsCurrentItem(newCurve);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewSummaryCurveFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("New Summary Curve");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryPlot* RicNewSummaryCurveFeature::selectedSummaryPlot() const
|
||||
{
|
||||
std::vector<RimSummaryPlot*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
return selection.size() > 0 ? selection[0] : NULL;
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RimSummaryPlot;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicNewSummaryCurveFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled();
|
||||
virtual void onActionTriggered( bool isChecked );
|
||||
virtual void setupActionLook( QAction* actionToSetup );
|
||||
|
||||
private:
|
||||
RimSummaryPlot* selectedSummaryPlot() const;
|
||||
};
|
@ -41,6 +41,9 @@
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
#include "RimScriptCollection.h"
|
||||
#include "RimSummaryPlotCollection.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RimViewController.h"
|
||||
#include "RimViewLinker.h"
|
||||
#include "RimWellLogCurve.h"
|
||||
@ -244,6 +247,10 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
|
||||
{
|
||||
commandIds << "RicNewWellLogPlotFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimSummaryPlotCollection*>(uiItem))
|
||||
{
|
||||
commandIds << "RicNewSummaryPlotFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimWellLogPlot*>(uiItem))
|
||||
{
|
||||
commandIds << "RicNewWellLogPlotTrackFeature";
|
||||
@ -260,6 +267,15 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
|
||||
commandIds << "RicExportToLasFileFeature";
|
||||
commandIds << "RicDeleteItemFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimSummaryPlot*>(uiItem))
|
||||
{
|
||||
commandIds << "RicNewSummaryCurveFeature";
|
||||
commandIds << "RicDeleteItemFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimSummaryCurve*>(uiItem))
|
||||
{
|
||||
commandIds << "RicDeleteItemFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimWellLogFileChannel*>(uiItem))
|
||||
{
|
||||
commandIds << "RicAddWellLogToPlotFeature";
|
||||
|
@ -89,6 +89,7 @@ RimPlotCurve::RimPlotCurve()
|
||||
|
||||
m_qwtPlotCurve = new RiuLineSegmentQwtPlotCurve;
|
||||
|
||||
m_parentQwtPlot = NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "cafPdmUiListEditor.h"
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
#include "RiuLineSegmentQwtPlotCurve.h"
|
||||
#include "qwt_date.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimSummaryCurve, "SummaryCurve");
|
||||
|
||||
@ -128,7 +129,7 @@ QString RimSummaryCurve::createCurveAutoName()
|
||||
void RimSummaryCurve::zoomAllParentPlot()
|
||||
{
|
||||
// Todo
|
||||
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -186,9 +187,7 @@ RifReaderEclipseSummary* RimSummaryCurve::summaryReader()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -197,6 +196,8 @@ void RimSummaryCurve::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrderin
|
||||
void RimSummaryCurve::curveData(std::vector<QDateTime>* timeSteps, std::vector<double>* values)
|
||||
{
|
||||
RifReaderEclipseSummary* reader = summaryReader();
|
||||
|
||||
if (!reader) return;
|
||||
|
||||
if (timeSteps)
|
||||
{
|
||||
|
@ -44,8 +44,8 @@ RimSummaryPlot::RimSummaryPlot()
|
||||
|
||||
CAF_PDM_InitField(&m_userName, "PlotDescription", QString("Summary Plot"), "Name", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&curves, "SummaryCurves", "", "", "", "");
|
||||
curves.uiCapability()->setUiHidden(true);
|
||||
CAF_PDM_InitFieldNoDefault(&m_curves, "SummaryCurves", "", "", "", "");
|
||||
m_curves.uiCapability()->setUiHidden(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -55,19 +55,7 @@ RimSummaryPlot::~RimSummaryPlot()
|
||||
{
|
||||
deletePlotWidget();
|
||||
|
||||
curves.deleteAllChildObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* RimSummaryPlot::createPlotWidget(QWidget* parent)
|
||||
{
|
||||
assert(m_viewer.isNull());
|
||||
|
||||
m_viewer = new RiuResultQwtPlot(parent);
|
||||
|
||||
return m_viewer;
|
||||
m_curves.deleteAllChildObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -90,19 +78,56 @@ RiuResultQwtPlot* RimSummaryPlot::viewer()
|
||||
return m_viewer;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::addCurve(RimSummaryCurve* curve)
|
||||
{
|
||||
if (curve)
|
||||
{
|
||||
m_curves.push_back(curve);
|
||||
if (m_viewer)
|
||||
{
|
||||
curve->setParentQwtPlot(m_viewer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
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()
|
||||
{
|
||||
m_viewer->deleteAllCurves();
|
||||
updateViewerWidget();
|
||||
|
||||
for (size_t i = 0; i < curves.size(); i++)
|
||||
for (size_t i = 0; i < m_curves.size(); i++)
|
||||
{
|
||||
RimSummaryCurve* curve = curves[i];
|
||||
RimSummaryCurve* curve = m_curves[i];
|
||||
|
||||
curve->loadDataAndUpdate();
|
||||
}
|
||||
|
||||
// Todo: Update zoom
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -123,10 +148,15 @@ void RimSummaryPlot::updateViewerWidget()
|
||||
if (!m_viewer)
|
||||
{
|
||||
m_viewer = new RiuResultQwtPlot(RiuMainWindow::instance());
|
||||
for (size_t cIdx = 0; cIdx < m_curves.size(); ++cIdx )
|
||||
{
|
||||
m_curves[cIdx]->setParentQwtPlot(m_viewer);
|
||||
}
|
||||
|
||||
|
||||
RiuMainWindow::instance()->addViewer(m_viewer, std::vector<int>());
|
||||
RiuMainWindow::instance()->setActiveViewer(m_viewer);
|
||||
|
||||
}
|
||||
|
||||
//updateViewerWidgetWindowTitle();
|
||||
@ -152,8 +182,8 @@ void RimSummaryPlot::updateViewerWidget()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryPlot::detachAllCurves()
|
||||
{
|
||||
for (size_t cIdx = 0; cIdx < curves.size(); ++cIdx)
|
||||
for (size_t cIdx = 0; cIdx < m_curves.size(); ++cIdx)
|
||||
{
|
||||
curves[cIdx]->detachQwtCurve();
|
||||
m_curves[cIdx]->detachQwtCurve();
|
||||
}
|
||||
}
|
||||
|
@ -46,22 +46,25 @@ public:
|
||||
void setDescription(const QString& description);
|
||||
void loadDataAndUpdate();
|
||||
RiuResultQwtPlot* viewer();
|
||||
void addCurve(RimSummaryCurve* curve);
|
||||
|
||||
|
||||
caf::PdmChildArrayField<RimSummaryCurve*> curves;
|
||||
|
||||
protected:
|
||||
// Overridden PDM methods
|
||||
virtual caf::PdmFieldHandle* objectToggleField() { return &m_showWindow; }
|
||||
virtual caf::PdmFieldHandle* userDescriptionField() { return &m_userName; }
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
|
||||
private:
|
||||
void updateViewerWidget();
|
||||
|
||||
void detachAllCurves();
|
||||
|
||||
QWidget* createPlotWidget(QWidget* parent);
|
||||
void deletePlotWidget();
|
||||
|
||||
caf::PdmChildArrayField<RimSummaryCurve*> m_curves;
|
||||
|
||||
caf::PdmField<bool> m_showWindow;
|
||||
caf::PdmField<QString> m_userName;
|
||||
|
||||
|
@ -98,15 +98,19 @@ RifReaderEclipseSummary* RimSummaryPlotCollection::createSummaryFileReader(const
|
||||
std::string headerFile;
|
||||
bool isFormatted = false;
|
||||
RifEclipseSummaryTools::findSummaryHeaderFile(eclipseCase.toStdString(), &headerFile, &isFormatted);
|
||||
|
||||
if (headerFile.empty()) return nullptr;
|
||||
|
||||
std::vector<std::string> dataFiles = RifEclipseSummaryTools::findSummaryDataFiles(eclipseCase.toStdString());
|
||||
|
||||
if (!dataFiles.size()) return nullptr;
|
||||
|
||||
RifReaderEclipseSummary* reader = new RifReaderEclipseSummary;
|
||||
if (!reader->open(headerFile, dataFiles))
|
||||
{
|
||||
delete reader;
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -46,7 +46,6 @@ RimWellLogCurve::RimWellLogCurve()
|
||||
m_qwtPlotCurve->setXAxis(QwtPlot::xTop);
|
||||
m_qwtPlotCurve->setYAxis(QwtPlot::yLeft);
|
||||
|
||||
m_parentQwtPlot = NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user