ResInsight/ApplicationCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp

160 lines
5.1 KiB
C++
Raw Normal View History

2017-03-15 14:15:04 -05:00
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 "RicShowPlotDataFeature.h"
#include "RiaApplication.h"
#include "RimProject.h"
#include "RimSummaryCrossPlot.h"
2017-03-15 14:15:04 -05:00
#include "RimSummaryPlot.h"
#include "RimWellLogPlot.h"
2018-04-26 23:28:08 -05:00
#include "RiuPlotMainWindow.h"
#include "RiuTextDialog.h"
2017-03-15 14:15:04 -05:00
#include "cafSelectionManagerTools.h"
2017-03-15 14:15:04 -05:00
#include <QAction>
2017-03-15 14:15:04 -05:00
CAF_CMD_SOURCE_INIT(RicShowPlotDataFeature, "RicShowPlotDataFeature");
//--------------------------------------------------------------------------------------------------
///
///
/// RicShowPlotDataFeature
///
///
//--------------------------------------------------------------------------------------------------
2017-03-15 14:15:04 -05:00
bool RicShowPlotDataFeature::isCommandEnabled()
{
auto selectedSummaryPlots = caf::selectedObjectsByType<RimSummaryPlot*>();
if (selectedSummaryPlots.size() > 0)
{
for (auto c : selectedSummaryPlots)
{
if (dynamic_cast<RimSummaryCrossPlot*>(c))
{
return false;
}
}
return true;
}
2017-03-15 14:15:04 -05:00
auto wellLogPlots = caf::selectedObjectsByType<RimWellLogPlot*>();
if (wellLogPlots.size() > 0) return true;
2017-03-15 14:15:04 -05:00
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicShowPlotDataFeature::onActionTriggered(bool isChecked)
{
this->disableModelChangeContribution();
std::vector<RimSummaryPlot*> selectedSummaryPlots = caf::selectedObjectsByType<RimSummaryPlot*>();
std::vector<RimWellLogPlot*> wellLogPlots = caf::selectedObjectsByType<RimWellLogPlot*>();
2017-03-15 14:15:04 -05:00
if (selectedSummaryPlots.size() == 0 && wellLogPlots.size() == 0)
{
CVF_ASSERT(false);
return;
}
2018-04-26 23:28:08 -05:00
RiuPlotMainWindow* plotwindow = RiaApplication::instance()->mainPlotWindow();
2017-03-15 14:15:04 -05:00
CVF_ASSERT(plotwindow);
for (RimSummaryPlot* summaryPlot : selectedSummaryPlots)
{
QString title = summaryPlot->description();
if (summaryPlot->containsResamplableCurves())
{
RicShowPlotDataFeature::showTabbedTextWindow(title, [summaryPlot](DateTimePeriod period) { return summaryPlot->asciiDataForPlotExport(period); });
}
else
{
QString text = summaryPlot->asciiDataForPlotExport();
RicShowPlotDataFeature::showTextWindow(title, text);
}
2017-03-15 14:15:04 -05:00
}
for (RimWellLogPlot* wellLogPlot : wellLogPlots)
{
QString title = wellLogPlot->description();
QString text = wellLogPlot->asciiDataForPlotExport();
RicShowPlotDataFeature::showTextWindow(title, text);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicShowPlotDataFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Show Plot Data");
actionToSetup->setIcon(QIcon(":/PlotWindow24x24.png"));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicShowPlotDataFeature::showTabbedTextWindow(const QString& title, std::function<QString(DateTimePeriod)> textProvider)
{
RiuPlotMainWindow* plotwindow = RiaApplication::instance()->mainPlotWindow();
CVF_ASSERT(plotwindow);
RiuShowTabbedPlotDataDialog* textWiget = new RiuShowTabbedPlotDataDialog();
textWiget->setMinimumSize(800, 600);
textWiget->setWindowTitle(title);
textWiget->setDescription(title);
textWiget->setTextProvider(textProvider);
textWiget->show();
plotwindow->addToTemporaryWidgets(textWiget);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-03-15 14:15:04 -05:00
void RicShowPlotDataFeature::showTextWindow(const QString& title, const QString& text)
{
2018-04-26 23:28:08 -05:00
RiuPlotMainWindow* plotwindow = RiaApplication::instance()->mainPlotWindow();
2017-03-15 14:15:04 -05:00
CVF_ASSERT(plotwindow);
RiuTextDialog* textWiget = new RiuTextDialog();
2017-03-15 14:15:04 -05:00
textWiget->setMinimumSize(400, 600);
textWiget->setWindowTitle(title);
textWiget->setText(text);
2017-03-15 14:15:04 -05:00
textWiget->show();
plotwindow->addToTemporaryWidgets(textWiget);
}