mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4683 clang-format on all files in ApplicationCode
This commit is contained in:
@@ -2,17 +2,17 @@
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -24,8 +24,8 @@
|
||||
#include "RiaPreferences.h"
|
||||
#include "RiaQDateTimeTools.h"
|
||||
|
||||
#include "RimContextCommandBuilder.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimContextCommandBuilder.h"
|
||||
|
||||
#include "RiuQwtPlotCurve.h"
|
||||
#include "RiuQwtPlotTools.h"
|
||||
@@ -33,7 +33,6 @@
|
||||
|
||||
#include "cafCmdFeatureMenuBuilder.h"
|
||||
|
||||
|
||||
#include "cvfColor3.h"
|
||||
|
||||
#include "qwt_date_scale_draw.h"
|
||||
@@ -44,21 +43,20 @@
|
||||
#include "qwt_plot_layout.h"
|
||||
#include "qwt_scale_engine.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QContextMenuEvent>
|
||||
|
||||
#include <QMenu>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuResultQwtPlot::RiuResultQwtPlot(QWidget* parent)
|
||||
: RiuDockedQwtPlot(parent)
|
||||
RiuResultQwtPlot::RiuResultQwtPlot( QWidget* parent )
|
||||
: RiuDockedQwtPlot( parent )
|
||||
{
|
||||
setDefaults();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuResultQwtPlot::~RiuResultQwtPlot()
|
||||
{
|
||||
@@ -66,59 +64,67 @@ RiuResultQwtPlot::~RiuResultQwtPlot()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuResultQwtPlot::addCurve(const RimCase* rimCase, const QString& curveName, const cvf::Color3f& curveColor, const std::vector<QDateTime>& dateTimes, const std::vector<double>& timeHistoryValues)
|
||||
void RiuResultQwtPlot::addCurve( const RimCase* rimCase,
|
||||
const QString& curveName,
|
||||
const cvf::Color3f& curveColor,
|
||||
const std::vector<QDateTime>& dateTimes,
|
||||
const std::vector<double>& timeHistoryValues )
|
||||
{
|
||||
if (dateTimes.empty() || timeHistoryValues.empty())
|
||||
if ( dateTimes.empty() || timeHistoryValues.empty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RiuQwtPlotCurve* plotCurve = new RiuQwtPlotCurve("Curve 1");
|
||||
RiuQwtPlotCurve* plotCurve = new RiuQwtPlotCurve( "Curve 1" );
|
||||
|
||||
plotCurve->setSamplesFromDatesAndYValues(dateTimes, timeHistoryValues, false);
|
||||
plotCurve->setTitle(curveName);
|
||||
plotCurve->setSamplesFromDatesAndYValues( dateTimes, timeHistoryValues, false );
|
||||
plotCurve->setTitle( curveName );
|
||||
|
||||
plotCurve->setPen(QPen(QColor(curveColor.rByte(), curveColor.gByte(), curveColor.bByte())));
|
||||
plotCurve->setPen( QPen( QColor( curveColor.rByte(), curveColor.gByte(), curveColor.bByte() ) ) );
|
||||
|
||||
plotCurve->attach(this);
|
||||
m_plotCurves.push_back(plotCurve);
|
||||
plotCurve->attach( this );
|
||||
m_plotCurves.push_back( plotCurve );
|
||||
|
||||
this->setAxisScale( QwtPlot::xTop, QwtDate::toDouble(dateTimes.front()), QwtDate::toDouble(dateTimes.back()));
|
||||
this->applyFontSizes(false);
|
||||
this->setAxisScale( QwtPlot::xTop, QwtDate::toDouble( dateTimes.front() ), QwtDate::toDouble( dateTimes.back() ) );
|
||||
this->applyFontSizes( false );
|
||||
|
||||
this->replot();
|
||||
|
||||
int caseId = rimCase->caseId;
|
||||
|
||||
|
||||
m_caseNames[caseId] = rimCase->caseUserDescription;
|
||||
m_curveNames[caseId].push_back(curveName);
|
||||
m_curveData[caseId].push_back(timeHistoryValues);
|
||||
m_curveNames[caseId].push_back( curveName );
|
||||
m_curveData[caseId].push_back( timeHistoryValues );
|
||||
m_timeSteps[caseId] = dateTimes;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuResultQwtPlot::addCurve(const RimCase* rimCase, const QString& curveName, const cvf::Color3f& curveColor, const std::vector<double>& frameTimes, const std::vector<double>& timeHistoryValues)
|
||||
void RiuResultQwtPlot::addCurve( const RimCase* rimCase,
|
||||
const QString& curveName,
|
||||
const cvf::Color3f& curveColor,
|
||||
const std::vector<double>& frameTimes,
|
||||
const std::vector<double>& timeHistoryValues )
|
||||
{
|
||||
std::vector<QDateTime> dateTimes;
|
||||
|
||||
for (double frameTime : frameTimes)
|
||||
for ( double frameTime : frameTimes )
|
||||
{
|
||||
dateTimes.push_back(QwtDate::toDateTime(frameTime));
|
||||
dateTimes.push_back( QwtDate::toDateTime( frameTime ) );
|
||||
}
|
||||
|
||||
addCurve(rimCase, curveName, curveColor, dateTimes, timeHistoryValues);
|
||||
addCurve( rimCase, curveName, curveColor, dateTimes, timeHistoryValues );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuResultQwtPlot::deleteAllCurves()
|
||||
{
|
||||
for (size_t i = 0; i < m_plotCurves.size(); i++)
|
||||
for ( size_t i = 0; i < m_plotCurves.size(); i++ )
|
||||
{
|
||||
m_plotCurves[i]->detach();
|
||||
delete m_plotCurves[i];
|
||||
@@ -133,104 +139,105 @@ void RiuResultQwtPlot::deleteAllCurves()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QSize RiuResultQwtPlot::sizeHint() const
|
||||
{
|
||||
return QSize(100, 100);
|
||||
return QSize( 100, 100 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QSize RiuResultQwtPlot::minimumSizeHint() const
|
||||
{
|
||||
return QSize(0, 0);
|
||||
return QSize( 0, 0 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuResultQwtPlot::contextMenuEvent(QContextMenuEvent* event)
|
||||
void RiuResultQwtPlot::contextMenuEvent( QContextMenuEvent* event )
|
||||
{
|
||||
QMenu menu;
|
||||
QMenu menu;
|
||||
caf::CmdFeatureMenuBuilder menuBuilder;
|
||||
|
||||
menuBuilder << "RicNewGridTimeHistoryCurveFeature";
|
||||
|
||||
const int curveCount = this->itemList(QwtPlotItem::Rtti_PlotCurve).count();
|
||||
const int curveCount = this->itemList( QwtPlotItem::Rtti_PlotCurve ).count();
|
||||
|
||||
QAction* act = menu.addAction("Show Plot Data", this, SLOT(slotCurrentPlotDataInTextDialog()));
|
||||
act->setEnabled(curveCount > 0);
|
||||
QAction* act = menu.addAction( "Show Plot Data", this, SLOT( slotCurrentPlotDataInTextDialog() ) );
|
||||
act->setEnabled( curveCount > 0 );
|
||||
|
||||
menuBuilder.appendToMenu(&menu);
|
||||
menuBuilder.appendToMenu( &menu );
|
||||
|
||||
if (!menu.actions().empty())
|
||||
if ( !menu.actions().empty() )
|
||||
{
|
||||
menu.exec(event->globalPos());
|
||||
menu.exec( event->globalPos() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuResultQwtPlot::setDefaults()
|
||||
{
|
||||
RiuQwtPlotTools::setCommonPlotBehaviour(this);
|
||||
RiuQwtPlotTools::setCommonPlotBehaviour( this );
|
||||
|
||||
enableAxis(QwtPlot::xBottom, true);
|
||||
enableAxis(QwtPlot::yLeft, true);
|
||||
enableAxis(QwtPlot::xTop, false);
|
||||
enableAxis(QwtPlot::yRight, false);
|
||||
enableAxis( QwtPlot::xBottom, true );
|
||||
enableAxis( QwtPlot::yLeft, true );
|
||||
enableAxis( QwtPlot::xTop, false );
|
||||
enableAxis( QwtPlot::yRight, false );
|
||||
|
||||
QString dateFormat = RiaApplication::instance()->preferences()->dateFormat();
|
||||
QString timeFormat = RiaApplication::instance()->preferences()->timeFormat();
|
||||
|
||||
RiuQwtPlotTools::enableDateBasedBottomXAxis(this, dateFormat, timeFormat);
|
||||
|
||||
setAxisMaxMinor(QwtPlot::xBottom, 2);
|
||||
setAxisMaxMinor(QwtPlot::yLeft, 3);
|
||||
RiuQwtPlotTools::enableDateBasedBottomXAxis( this, dateFormat, timeFormat );
|
||||
|
||||
applyFontSizes(false);
|
||||
setAxisMaxMinor( QwtPlot::xBottom, 2 );
|
||||
setAxisMaxMinor( QwtPlot::yLeft, 3 );
|
||||
|
||||
// The legend will be deleted in the destructor of the plot or when
|
||||
applyFontSizes( false );
|
||||
|
||||
// The legend will be deleted in the destructor of the plot or when
|
||||
// another legend is inserted.
|
||||
QwtLegend* legend = new QwtLegend(this);
|
||||
this->insertLegend(legend, BottomLegend);
|
||||
QwtLegend* legend = new QwtLegend( this );
|
||||
this->insertLegend( legend, BottomLegend );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiuResultQwtPlot::asciiDataForUiSelectedCurves() const
|
||||
{
|
||||
QString out;
|
||||
|
||||
for (std::pair<int, QString> caseIdAndName : m_caseNames)
|
||||
|
||||
for ( std::pair<int, QString> caseIdAndName : m_caseNames )
|
||||
{
|
||||
int caseId = caseIdAndName.first;
|
||||
out += "Case: " + caseIdAndName.second;
|
||||
out += "\n";
|
||||
|
||||
for (size_t i = 0; i < m_timeSteps.at(caseId).size(); i++) //time steps & data points
|
||||
for ( size_t i = 0; i < m_timeSteps.at( caseId ).size(); i++ ) // time steps & data points
|
||||
{
|
||||
if (i == 0)
|
||||
if ( i == 0 )
|
||||
{
|
||||
out += "Date and time";
|
||||
for (QString curveName : m_curveNames.at(caseId))
|
||||
for ( QString curveName : m_curveNames.at( caseId ) )
|
||||
{
|
||||
out += "\t" + curveName;
|
||||
}
|
||||
}
|
||||
out += "\n";
|
||||
|
||||
QString dateString = RiaQDateTimeTools::toStringUsingApplicationLocale(m_timeSteps.at(caseId)[i], "yyyy-MM-dd hh:mm:ss ");
|
||||
QString dateString = RiaQDateTimeTools::toStringUsingApplicationLocale( m_timeSteps.at( caseId )[i],
|
||||
"yyyy-MM-dd hh:mm:ss " );
|
||||
|
||||
out += dateString;
|
||||
|
||||
for (size_t j = 0; j < m_curveData.at(caseId).size(); j++) // curves
|
||||
for ( size_t j = 0; j < m_curveData.at( caseId ).size(); j++ ) // curves
|
||||
{
|
||||
out += "\t" + QString::number(m_curveData.at(caseId)[j][i], 'g', 6);
|
||||
out += "\t" + QString::number( m_curveData.at( caseId )[j][i], 'g', 6 );
|
||||
}
|
||||
}
|
||||
out += "\n\n";
|
||||
@@ -240,15 +247,15 @@ QString RiuResultQwtPlot::asciiDataForUiSelectedCurves() const
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuResultQwtPlot::slotCurrentPlotDataInTextDialog()
|
||||
{
|
||||
QString outTxt = asciiDataForUiSelectedCurves();
|
||||
|
||||
RiuTextDialog* textDialog = new RiuTextDialog(this);
|
||||
textDialog->setMinimumSize(400, 600);
|
||||
textDialog->setWindowTitle("Result Plot Data");
|
||||
textDialog->setText(outTxt);
|
||||
RiuTextDialog* textDialog = new RiuTextDialog( this );
|
||||
textDialog->setMinimumSize( 400, 600 );
|
||||
textDialog->setWindowTitle( "Result Plot Data" );
|
||||
textDialog->setText( outTxt );
|
||||
textDialog->show();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user