Merge pull request #5760 from OPM/summary-data-python

Python support for summary data
This commit is contained in:
Magne Sjaastad
2020-04-07 10:37:53 +02:00
committed by GitHub
47 changed files with 1077 additions and 258 deletions

View File

@@ -424,8 +424,13 @@ void RiaGuiApplication::initialize()
RiuPlotMainWindow* plotMainWindow = getOrCreateMainPlotWindow();
plotMainWindow->hideAllDockWidgets();
RiaLogging::setLoggerInstance( new RiuMessagePanelLogger( m_mainWindow->messagePanel() ) );
RiaLogging::loggerInstance()->setLevel( RI_LL_DEBUG );
{
auto logger = new RiuMessagePanelLogger;
logger->addMessagePanel( m_mainWindow->messagePanel() );
logger->addMessagePanel( m_mainPlotWindow->messagePanel() );
RiaLogging::setLoggerInstance( logger );
RiaLogging::loggerInstance()->setLevel( RI_LL_DEBUG );
}
m_socketServer = new RiaSocketServer( this );
}
@@ -1643,7 +1648,7 @@ int RiaGuiApplication::applicationResolution()
//--------------------------------------------------------------------------------------------------
void RiaGuiApplication::startMonitoringWorkProgress( caf::UiProcess* uiProcess )
{
m_mainWindow->processMonitor()->startMonitorWorkProcess( m_workerProcess );
m_mainWindow->processMonitor()->startMonitorWorkProcess( uiProcess );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -41,14 +41,6 @@ const DateTimeSpan RiaQDateTimeTools::TIMESPAN_HALFYEAR = DateTimeSpan( 0, 6, 0
const DateTimeSpan RiaQDateTimeTools::TIMESPAN_YEAR = DateTimeSpan( 1, 0, 0 );
const DateTimeSpan RiaQDateTimeTools::TIMESPAN_DECADE = DateTimeSpan( 10, 0, 0 );
const QString RiaQDateTimeTools::TIMESPAN_DAY_NAME = "Day";
const QString RiaQDateTimeTools::TIMESPAN_WEEK_NAME = "Week";
const QString RiaQDateTimeTools::TIMESPAN_MONTH_NAME = "Month";
const QString RiaQDateTimeTools::TIMESPAN_QUARTER_NAME = "Quarter";
const QString RiaQDateTimeTools::TIMESPAN_HALFYEAR_NAME = "Half Year";
const QString RiaQDateTimeTools::TIMESPAN_YEAR_NAME = "Year";
const QString RiaQDateTimeTools::TIMESPAN_DECADE_NAME = "Decade";
namespace caf
{
template <>
@@ -70,6 +62,21 @@ void caf::AppEnum<RiaQDateTimeTools::TimeFormatComponents>::setUp()
addItem( RiaQDateTimeTools::TIME_FORMAT_HOUR_MINUTE_SECOND, "HOUR_MINUTE_SECONDS", "Hour, Minutes and Seconds" );
setDefault( RiaQDateTimeTools::TIME_FORMAT_NONE );
}
template <>
void caf::AppEnum<RiaQDateTimeTools::DateTimePeriod>::setUp()
{
addItem( RiaQDateTimeTools::DateTimePeriod::NONE, "NONE", "None" );
addItem( RiaQDateTimeTools::DateTimePeriod::DAY, "DAY", "Day" );
addItem( RiaQDateTimeTools::DateTimePeriod::WEEK, "WEEK", "Week" );
addItem( RiaQDateTimeTools::DateTimePeriod::MONTH, "MONTH", "Month" );
addItem( RiaQDateTimeTools::DateTimePeriod::QUARTER, "QUARTER", "Quarter," );
addItem( RiaQDateTimeTools::DateTimePeriod::HALFYEAR, "HALFYEAR", "Half Year" );
addItem( RiaQDateTimeTools::DateTimePeriod::YEAR, "YEAR,", "Year," );
addItem( RiaQDateTimeTools::DateTimePeriod::DECADE, "DECADE", "Decade" );
setDefault( RiaQDateTimeTools::DateTimePeriod::NONE );
}
} // namespace caf
//--------------------------------------------------------------------------------------------------
@@ -188,7 +195,7 @@ QDateTime RiaQDateTimeTools::subtractSpan( const QDateTime& dt, DateTimeSpan spa
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QDateTime RiaQDateTimeTools::addPeriod( const QDateTime& dt, DateTimePeriod period )
QDateTime RiaQDateTimeTools::addPeriod( const QDateTime& dt, RiaQDateTimeTools::DateTimePeriod period )
{
return addSpan( dt, timeSpan( period ) );
}
@@ -196,7 +203,7 @@ QDateTime RiaQDateTimeTools::addPeriod( const QDateTime& dt, DateTimePeriod peri
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QDateTime RiaQDateTimeTools::subtractPeriod( const QDateTime& dt, DateTimePeriod period )
QDateTime RiaQDateTimeTools::subtractPeriod( const QDateTime& dt, RiaQDateTimeTools::DateTimePeriod period )
{
return subtractSpan( dt, timeSpan( period ) );
}
@@ -266,23 +273,23 @@ bool RiaQDateTimeTools::lessThan( const QDateTime& dt1, const QDateTime& dt2 )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const DateTimeSpan RiaQDateTimeTools::timeSpan( DateTimePeriod period )
const DateTimeSpan RiaQDateTimeTools::timeSpan( RiaQDateTimeTools::DateTimePeriod period )
{
switch ( period )
{
case DateTimePeriod::DAY:
case RiaQDateTimeTools::DateTimePeriod::DAY:
return TIMESPAN_DAY;
case DateTimePeriod::WEEK:
case RiaQDateTimeTools::DateTimePeriod::WEEK:
return TIMESPAN_WEEK;
case DateTimePeriod::MONTH:
case RiaQDateTimeTools::DateTimePeriod::MONTH:
return TIMESPAN_MONTH;
case DateTimePeriod::QUARTER:
case RiaQDateTimeTools::DateTimePeriod::QUARTER:
return TIMESPAN_QUARTER;
case DateTimePeriod::HALFYEAR:
case RiaQDateTimeTools::DateTimePeriod::HALFYEAR:
return TIMESPAN_HALFYEAR;
case DateTimePeriod::YEAR:
case RiaQDateTimeTools::DateTimePeriod::YEAR:
return TIMESPAN_YEAR;
case DateTimePeriod::DECADE:
case RiaQDateTimeTools::DateTimePeriod::DECADE:
return TIMESPAN_DECADE;
}
CVF_ASSERT( false );
@@ -292,7 +299,7 @@ const DateTimeSpan RiaQDateTimeTools::timeSpan( DateTimePeriod period )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QDateTime RiaQDateTimeTools::truncateTime( const QDateTime& dt, DateTimePeriod period )
QDateTime RiaQDateTimeTools::truncateTime( const QDateTime& dt, RiaQDateTimeTools::DateTimePeriod period )
{
int y = dt.date().year();
int m = dt.date().month();
@@ -301,19 +308,19 @@ QDateTime RiaQDateTimeTools::truncateTime( const QDateTime& dt, DateTimePeriod p
switch ( period )
{
case DateTimePeriod::DAY:
case RiaQDateTimeTools::DateTimePeriod::DAY:
return createUtcDateTime( QDate( y, m, d ) );
case DateTimePeriod::WEEK:
case RiaQDateTimeTools::DateTimePeriod::WEEK:
return createUtcDateTime( QDate( y, m, d ).addDays( -dow + 1 ) );
case DateTimePeriod::MONTH:
case RiaQDateTimeTools::DateTimePeriod::MONTH:
return createUtcDateTime( QDate( y, m, 1 ) );
case DateTimePeriod::QUARTER:
case RiaQDateTimeTools::DateTimePeriod::QUARTER:
return createUtcDateTime( QDate( y, ( ( m - 1 ) / 3 ) * 3 + 1, 1 ) );
case DateTimePeriod::HALFYEAR:
case RiaQDateTimeTools::DateTimePeriod::HALFYEAR:
return createUtcDateTime( QDate( y, ( ( m - 1 ) / 6 ) * 6 + 1, 1 ) );
case DateTimePeriod::YEAR:
case RiaQDateTimeTools::DateTimePeriod::YEAR:
return createUtcDateTime( QDate( y, 1, 1 ) );
case DateTimePeriod::DECADE:
case RiaQDateTimeTools::DateTimePeriod::DECADE:
return createUtcDateTime( QDate( ( y / 10 ) * 10, 1, 1 ) );
}
CVF_ASSERT( false );
@@ -323,44 +330,24 @@ QDateTime RiaQDateTimeTools::truncateTime( const QDateTime& dt, DateTimePeriod p
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<DateTimePeriod> RiaQDateTimeTools::dateTimePeriods()
std::vector<RiaQDateTimeTools::DateTimePeriod> RiaQDateTimeTools::dateTimePeriods()
{
return std::vector<DateTimePeriod>( {
DateTimePeriod::NONE,
DateTimePeriod::DAY,
DateTimePeriod::WEEK,
DateTimePeriod::MONTH,
DateTimePeriod::QUARTER,
DateTimePeriod::HALFYEAR,
DateTimePeriod::YEAR,
DateTimePeriod::DECADE,
} );
std::vector<DateTimePeriod> allPeriods;
for ( size_t i = 0; i < DateTimePeriodEnum::size(); i++ )
{
allPeriods.push_back( DateTimePeriodEnum::fromIndex( i ) );
}
return allPeriods;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaQDateTimeTools::dateTimePeriodName( DateTimePeriod period )
QString RiaQDateTimeTools::dateTimePeriodName( RiaQDateTimeTools::DateTimePeriod period )
{
switch ( period )
{
case DateTimePeriod::DAY:
return TIMESPAN_DAY_NAME;
case DateTimePeriod::WEEK:
return TIMESPAN_WEEK_NAME;
case DateTimePeriod::MONTH:
return TIMESPAN_MONTH_NAME;
case DateTimePeriod::QUARTER:
return TIMESPAN_QUARTER_NAME;
case DateTimePeriod::HALFYEAR:
return TIMESPAN_HALFYEAR_NAME;
case DateTimePeriod::YEAR:
return TIMESPAN_YEAR_NAME;
case DateTimePeriod::DECADE:
return TIMESPAN_DECADE_NAME;
default:
return "None";
}
return DateTimePeriodEnum::uiText( period );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -18,6 +18,8 @@
#pragma once
#include "cafAppEnum.h"
#include <qglobal.h>
#include <qnamespace.h>
@@ -40,21 +42,6 @@ namespace caf
class PdmOptionItemInfo;
};
//==================================================================================================
//
//==================================================================================================
enum class DateTimePeriod
{
NONE = -1,
DAY,
WEEK,
MONTH,
QUARTER,
HALFYEAR,
YEAR,
DECADE
};
//==================================================================================================
//
//==================================================================================================
@@ -90,13 +77,18 @@ public:
TIME_FORMAT_SIZE
};
static const QString TIMESPAN_DAY_NAME;
static const QString TIMESPAN_WEEK_NAME;
static const QString TIMESPAN_MONTH_NAME;
static const QString TIMESPAN_QUARTER_NAME;
static const QString TIMESPAN_HALFYEAR_NAME;
static const QString TIMESPAN_YEAR_NAME;
static const QString TIMESPAN_DECADE_NAME;
enum class DateTimePeriod
{
NONE = -1,
DAY,
WEEK,
MONTH,
QUARTER,
HALFYEAR,
YEAR,
DECADE
};
using DateTimePeriodEnum = caf::AppEnum<DateTimePeriod>;
static Qt::TimeSpec currentTimeSpec();
@@ -109,8 +101,8 @@ public:
static QDateTime addYears( const QDateTime& dt, double years );
static QDateTime addSpan( const QDateTime& dt, DateTimeSpan span );
static QDateTime subtractSpan( const QDateTime& dt, DateTimeSpan span );
static QDateTime addPeriod( const QDateTime& dt, DateTimePeriod period );
static QDateTime subtractPeriod( const QDateTime& dt, DateTimePeriod period );
static QDateTime addPeriod( const QDateTime& dt, RiaQDateTimeTools::DateTimePeriod period );
static QDateTime subtractPeriod( const QDateTime& dt, RiaQDateTimeTools::DateTimePeriod period );
static QDateTime epoch();
@@ -121,11 +113,11 @@ public:
static bool lessThan( const QDateTime& dt1, const QDateTime& dt2 );
static const DateTimeSpan timeSpan( DateTimePeriod period );
static QDateTime truncateTime( const QDateTime& dt, DateTimePeriod period );
static const DateTimeSpan timeSpan( RiaQDateTimeTools::DateTimePeriod period );
static QDateTime truncateTime( const QDateTime& dt, RiaQDateTimeTools::DateTimePeriod period );
static std::vector<DateTimePeriod> dateTimePeriods();
static QString dateTimePeriodName( DateTimePeriod period );
static std::vector<RiaQDateTimeTools::DateTimePeriod> dateTimePeriods();
static QString dateTimePeriodName( RiaQDateTimeTools::DateTimePeriod period );
// This function uses C locale to make sure the text representation of a date is stable, independent of the locale
// settings on local machine. Required for stable regression testing.

View File

@@ -67,7 +67,7 @@ void RiaTimeHistoryCurveResampler::setCurveData( const std::vector<double>& valu
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaTimeHistoryCurveResampler::resampleAndComputePeriodEndValues( DateTimePeriod period )
void RiaTimeHistoryCurveResampler::resampleAndComputePeriodEndValues( RiaQDateTimeTools::DateTimePeriod period )
{
computePeriodEndValues( period );
}
@@ -75,7 +75,7 @@ void RiaTimeHistoryCurveResampler::resampleAndComputePeriodEndValues( DateTimePe
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaTimeHistoryCurveResampler::resampleAndComputeWeightedMeanValues( DateTimePeriod period )
void RiaTimeHistoryCurveResampler::resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod period )
{
computeWeightedMeanValues( period );
}
@@ -99,8 +99,9 @@ const std::vector<double>& RiaTimeHistoryCurveResampler::resampledValues() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<time_t>
RiaTimeHistoryCurveResampler::timeStepsFromTimeRange( DateTimePeriod period, time_t minTime, time_t maxTime )
std::vector<time_t> RiaTimeHistoryCurveResampler::timeStepsFromTimeRange( RiaQDateTimeTools::DateTimePeriod period,
time_t minTime,
time_t maxTime )
{
if ( minTime > maxTime ) return std::vector<time_t>();
@@ -123,7 +124,7 @@ std::vector<time_t>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaTimeHistoryCurveResampler::computeWeightedMeanValues( DateTimePeriod period )
void RiaTimeHistoryCurveResampler::computeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod period )
{
size_t origDataSize = m_originalValues.second.size();
size_t oi = 0;
@@ -196,7 +197,7 @@ void RiaTimeHistoryCurveResampler::computeWeightedMeanValues( DateTimePeriod per
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaTimeHistoryCurveResampler::computePeriodEndValues( DateTimePeriod period )
void RiaTimeHistoryCurveResampler::computePeriodEndValues( RiaQDateTimeTools::DateTimePeriod period )
{
size_t origDataSize = m_originalValues.second.size();
size_t oi = 0;
@@ -245,9 +246,9 @@ void RiaTimeHistoryCurveResampler::clearData()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaTimeHistoryCurveResampler::computeResampledTimeSteps( DateTimePeriod period )
void RiaTimeHistoryCurveResampler::computeResampledTimeSteps( RiaQDateTimeTools::DateTimePeriod period )
{
CVF_ASSERT( period != DateTimePeriod::NONE && m_originalValues.second.size() > 0 );
CVF_ASSERT( period != RiaQDateTimeTools::DateTimePeriod::NONE && m_originalValues.second.size() > 0 );
auto firstOriginalTimeStep = QDT::fromTime_t( m_originalValues.second.front() );
auto lastOriginalTimeStep = QDT::fromTime_t( m_originalValues.second.back() );
@@ -268,7 +269,8 @@ void RiaTimeHistoryCurveResampler::computeResampledTimeSteps( DateTimePeriod per
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QDateTime RiaTimeHistoryCurveResampler::firstResampledTimeStep( const QDateTime& firstTimeStep, DateTimePeriod period )
QDateTime RiaTimeHistoryCurveResampler::firstResampledTimeStep( const QDateTime& firstTimeStep,
RiaQDateTimeTools::DateTimePeriod period )
{
QDateTime truncatedTime = QDT::truncateTime( firstTimeStep, period );

View File

@@ -35,21 +35,22 @@ public:
void setCurveData( const std::vector<double>& values, const std::vector<time_t>& timeSteps );
void resampleAndComputePeriodEndValues( DateTimePeriod period );
void resampleAndComputeWeightedMeanValues( DateTimePeriod period );
void resampleAndComputePeriodEndValues( RiaQDateTimeTools::DateTimePeriod period );
void resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod period );
const std::vector<time_t>& resampledTimeSteps() const;
const std::vector<double>& resampledValues() const;
static std::vector<time_t> timeStepsFromTimeRange( DateTimePeriod period, time_t minTime, time_t maxTime );
static std::vector<time_t>
timeStepsFromTimeRange( RiaQDateTimeTools::DateTimePeriod period, time_t minTime, time_t maxTime );
private:
void computeWeightedMeanValues( DateTimePeriod period );
void computePeriodEndValues( DateTimePeriod period );
void computeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod period );
void computePeriodEndValues( RiaQDateTimeTools::DateTimePeriod period );
void clearData();
void computeResampledTimeSteps( DateTimePeriod period );
static QDateTime firstResampledTimeStep( const QDateTime& firstTimestep, DateTimePeriod period );
void computeResampledTimeSteps( RiaQDateTimeTools::DateTimePeriod period );
static QDateTime firstResampledTimeStep( const QDateTime& firstTimestep, RiaQDateTimeTools::DateTimePeriod period );
inline double interpolatedValue( time_t t, time_t t1, double v1, time_t t2, double v2 );
private:

View File

@@ -63,8 +63,8 @@ public:
{
auto allTabs = tabs();
CVF_ASSERT( tabIndex < (int)allTabs.size() );
DateTimePeriod timePeriod = allTabs[tabIndex];
if ( timePeriod == DateTimePeriod::NONE )
RiaQDateTimeTools::DateTimePeriod timePeriod = allTabs[tabIndex];
if ( timePeriod == RiaQDateTimeTools::DateTimePeriod::NONE )
{
return "No Resampling";
}
@@ -78,7 +78,7 @@ public:
{
CVF_ASSERT( m_summaryPlot.notNull() && "Need to check that provider is valid" );
DateTimePeriod timePeriod = indexToPeriod( tabIndex );
RiaQDateTimeTools::DateTimePeriod timePeriod = indexToPeriod( tabIndex );
if ( m_summaryPlot->containsResamplableCurves() )
{
@@ -88,25 +88,25 @@ public:
}
else
{
return m_summaryPlot->asciiDataForSummaryPlotExport( DateTimePeriod::NONE, true );
return m_summaryPlot->asciiDataForSummaryPlotExport( RiaQDateTimeTools::DateTimePeriod::NONE, true );
}
}
int tabCount() const override { return (int)tabs().size(); }
private:
static DateTimePeriod indexToPeriod( int tabIndex )
static RiaQDateTimeTools::DateTimePeriod indexToPeriod( int tabIndex )
{
auto allTabs = tabs();
CVF_ASSERT( tabIndex < (int)allTabs.size() );
DateTimePeriod timePeriod = allTabs[tabIndex];
RiaQDateTimeTools::DateTimePeriod timePeriod = allTabs[tabIndex];
return timePeriod;
}
static std::vector<DateTimePeriod> tabs()
static std::vector<RiaQDateTimeTools::DateTimePeriod> tabs()
{
std::vector<DateTimePeriod> dateTimePeriods = RiaQDateTimeTools::dateTimePeriods();
dateTimePeriods.erase( std::remove( dateTimePeriods.begin(), dateTimePeriods.end(), DateTimePeriod::DECADE ),
std::vector<RiaQDateTimeTools::DateTimePeriod> dateTimePeriods = RiaQDateTimeTools::dateTimePeriods();
dateTimePeriods.erase( std::remove( dateTimePeriods.begin(), dateTimePeriods.end(), RiaQDateTimeTools::DateTimePeriod::DECADE ),
dateTimePeriods.end() );
return dateTimePeriods;
}

View File

@@ -104,12 +104,13 @@ RicResampleDialogResult RicResampleDialog::openDialog( QWidget* parent /*= 0*/,
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicResampleDialog::setPeriodOptions( const std::vector<DateTimePeriod>& dateTimePeriods )
void RicResampleDialog::setPeriodOptions( const std::vector<RiaQDateTimeTools::DateTimePeriod>& dateTimePeriods )
{
QStringList s;
for ( auto& period : dateTimePeriods )
{
QString text = period != DateTimePeriod::NONE ? RiaQDateTimeTools::dateTimePeriodName( period ) : "No Resampling";
QString text = period != RiaQDateTimeTools::DateTimePeriod::NONE ? RiaQDateTimeTools::dateTimePeriodName( period )
: "No Resampling";
m_timePeriodCombo->addItem( text, QVariant( (int)period ) );
}
}
@@ -117,10 +118,10 @@ void RicResampleDialog::setPeriodOptions( const std::vector<DateTimePeriod>& dat
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
DateTimePeriod RicResampleDialog::selectedDateTimePeriod() const
RiaQDateTimeTools::DateTimePeriod RicResampleDialog::selectedDateTimePeriod() const
{
int currIndex = m_timePeriodCombo->currentIndex();
return (DateTimePeriod)m_timePeriodCombo->itemData( currIndex ).toInt();
return (RiaQDateTimeTools::DateTimePeriod)m_timePeriodCombo->itemData( currIndex ).toInt();
}
//--------------------------------------------------------------------------------------------------

View File

@@ -49,8 +49,8 @@ public:
static RicResampleDialogResult openDialog( QWidget* parent = nullptr, const QString& caption = QString() );
private:
void setPeriodOptions( const std::vector<DateTimePeriod>& dateTimePeriods );
DateTimePeriod selectedDateTimePeriod() const;
void setPeriodOptions( const std::vector<RiaQDateTimeTools::DateTimePeriod>& dateTimePeriods );
RiaQDateTimeTools::DateTimePeriod selectedDateTimePeriod() const;
private slots:
void slotDialogOkClicked();
@@ -69,12 +69,12 @@ private:
class RicResampleDialogResult
{
public:
RicResampleDialogResult( bool ok, DateTimePeriod period )
RicResampleDialogResult( bool ok, RiaQDateTimeTools::DateTimePeriod period )
: ok( ok )
, period( period )
{
}
bool ok;
DateTimePeriod period;
};
bool ok;
RiaQDateTimeTools::DateTimePeriod period;
};

View File

@@ -172,7 +172,7 @@ bool RicAsciiExportSummaryPlotFeature::exportTextToFile( const QString& fileName
//--------------------------------------------------------------------------------------------------
bool RicAsciiExportSummaryPlotFeature::exportAsciiForSummaryPlot( const QString& fileName,
const RimSummaryPlot* summaryPlot,
DateTimePeriod resamplingPeriod,
RiaQDateTimeTools::DateTimePeriod resamplingPeriod,
bool showTimeAsLongString )
{
QString text = summaryPlot->description();

View File

@@ -44,6 +44,6 @@ protected:
private:
static bool exportAsciiForSummaryPlot( const QString& fileName,
const RimSummaryPlot* selectedSummaryPlots,
DateTimePeriod resamplingPeriod,
RiaQDateTimeTools::DateTimePeriod resamplingPeriod,
bool showTimeAsLongString );
};

View File

@@ -0,0 +1,18 @@
import rips
resinsight = rips.Instance.find()
project = resinsight.project
summary_cases = project.descendants(rips.SummaryCase)
# Assumes at least one summery case loaded
firstCase = summary_cases[0]
vector_name = "FOPT"
summary_data = firstCase.summary_vector_values(vector_name)
print("Data for summary vector " + vector_name)
print(summary_data.values)
time_steps = firstCase.available_time_steps()
print(time_steps.values)

View File

@@ -362,7 +362,12 @@ def _call_pdm_method(self, method_name, **kwargs):
for key, value in kwargs.items():
pb2_params.parameters[snake_to_camel(key)] = self.__convert_to_grpc_value(value)
request = PdmObject_pb2.PdmObjectMethodRequest(object=self._pb2_object, method=method_name, params=pb2_params)
return self._pdm_object_stub.CallPdmObjectMethod(request)
pb2_object = self._pdm_object_stub.CallPdmObjectMethod(request)
child_class_definition = class_from_keyword(pb2_object.class_keyword)
pdm_object = child_class_definition(pb2_object=pb2_object, channel=self.channel())
return pdm_object
@add_method(PdmObject)
def update(self):

View File

@@ -527,12 +527,19 @@ grpc::Status RiaGrpcPdmObjectService::CallPdmObjectMethod( grpc::ServerContext*
copyPdmObjectFromRipsToCaf( &( request->params() ), method.get() );
caf::PdmObjectHandle* result = method->execute();
copyPdmObjectFromCafToRips( result, reply );
if ( !method->resultIsPersistent() )
if ( result )
{
delete result;
copyPdmObjectFromCafToRips( result, reply );
if ( !method->resultIsPersistent() )
{
delete result;
}
return grpc::Status::OK;
}
else
{
return grpc::Status( grpc::NOT_FOUND, "No result returned from Method" );
}
return grpc::Status::OK;
}
return grpc::Status( grpc::NOT_FOUND, "Could not find Method" );
}

View File

@@ -1361,6 +1361,8 @@ void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q
itemCollection->add( mainPlotCollection->multiPlotCollection() );
}
}
uiTreeOrdering.add( scriptCollection() );
}
else
{

View File

@@ -174,11 +174,11 @@ double RimSimWellInViewTools::extractValueForTimeStep( RifSummaryReaderInterface
resampler.setCurveData( values, timeSteps );
if ( RiaSummaryTools::hasAccumulatedData( addr ) )
{
resampler.resampleAndComputePeriodEndValues( DateTimePeriod::DAY );
resampler.resampleAndComputePeriodEndValues( RiaQDateTimeTools::DateTimePeriod::DAY );
}
else
{
resampler.resampleAndComputeWeightedMeanValues( DateTimePeriod::DAY );
resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::DAY );
}
// Find the data point which best matches the selected time step

View File

@@ -160,9 +160,9 @@ void RimEnsembleStatisticsCase::calculate( const std::vector<RimSummaryCase*> su
RiaTimeHistoryCurveResampler resampler;
resampler.setCurveData( values, timeSteps );
if ( RiaSummaryTools::hasAccumulatedData( inputAddress ) )
resampler.resampleAndComputePeriodEndValues( DateTimePeriod::DAY );
resampler.resampleAndComputePeriodEndValues( RiaQDateTimeTools::DateTimePeriod::DAY );
else
resampler.resampleAndComputeWeightedMeanValues( DateTimePeriod::DAY );
resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::DAY );
if ( allTimeSteps.empty() ) allTimeSteps = resampler.resampledTimeSteps();
caseAndTimeStepValues.push_back(

View File

@@ -99,18 +99,18 @@ class CurvesData
{
public:
CurvesData()
: resamplePeriod( DateTimePeriod::NONE )
: resamplePeriod( RiaQDateTimeTools::DateTimePeriod::NONE )
{
}
void clear()
{
resamplePeriod = DateTimePeriod::NONE;
resamplePeriod = RiaQDateTimeTools::DateTimePeriod::NONE;
caseNames.clear();
timeSteps.clear();
allCurveData.clear();
}
DateTimePeriod resamplePeriod;
RiaQDateTimeTools::DateTimePeriod resamplePeriod;
std::vector<QString> caseNames;
std::vector<std::vector<time_t>> timeSteps;
std::vector<std::vector<CurveData>> allCurveData;
@@ -129,10 +129,10 @@ void populateSummaryCurvesData( std::vector<RimSummaryCurve*> curves, SummaryCur
void populateTimeHistoryCurvesData( std::vector<RimGridTimeHistoryCurve*> curves, CurvesData* curvesData );
void populateAsciiDataCurvesData( std::vector<RimAsciiDataCurve*> curves, CurvesData* curvesData );
void prepareCaseCurvesForExport( DateTimePeriod period,
ResampleAlgorithm algorithm,
const CurvesData& inputCurvesData,
CurvesData* resultCurvesData );
void prepareCaseCurvesForExport( RiaQDateTimeTools::DateTimePeriod period,
ResampleAlgorithm algorithm,
const CurvesData& inputCurvesData,
CurvesData* resultCurvesData );
void appendToExportDataForCase( QString& out, const std::vector<time_t>& timeSteps, const std::vector<CurveData>& curveData );
void appendToExportData( QString& out, const std::vector<CurvesData>& curvesData, bool showTimeAsLongString );
@@ -335,13 +335,14 @@ RiuQwtPlotWidget* RimSummaryPlot::viewer()
//--------------------------------------------------------------------------------------------------
QString RimSummaryPlot::asciiDataForPlotExport() const
{
return asciiDataForSummaryPlotExport( DateTimePeriod::YEAR, false );
return asciiDataForSummaryPlotExport( RiaQDateTimeTools::DateTimePeriod::YEAR, false );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimSummaryPlot::asciiDataForSummaryPlotExport( DateTimePeriod resamplingPeriod, bool showTimeAsLongString ) const
QString RimSummaryPlot::asciiDataForSummaryPlotExport( RiaQDateTimeTools::DateTimePeriod resamplingPeriod,
bool showTimeAsLongString ) const
{
QString out;
RiaTimeHistoryCurveResampler resampler;
@@ -2185,16 +2186,16 @@ void populateSummaryCurvesData( std::vector<RimSummaryCurve*> curves, SummaryCur
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void prepareCaseCurvesForExport( DateTimePeriod period,
ResampleAlgorithm algorithm,
const CurvesData& inputCurvesData,
CurvesData* resultCurvesData )
void prepareCaseCurvesForExport( RiaQDateTimeTools::DateTimePeriod period,
ResampleAlgorithm algorithm,
const CurvesData& inputCurvesData,
CurvesData* resultCurvesData )
{
RiaTimeHistoryCurveResampler resampler;
resultCurvesData->clear();
if ( period != DateTimePeriod::NONE )
if ( period != RiaQDateTimeTools::DateTimePeriod::NONE )
{
// Prepare result data
resultCurvesData->resamplePeriod = period;
@@ -2276,7 +2277,7 @@ void appendToExportData( QString& out, const std::vector<CurvesData>& curvesData
{
CurvesData data = concatCurvesData( curvesData );
if ( data.resamplePeriod != DateTimePeriod::NONE )
if ( data.resamplePeriod != RiaQDateTimeTools::DateTimePeriod::NONE )
{
time_t minTimeStep = std::numeric_limits<time_t>::max();
time_t maxTimeStep = 0;
@@ -2328,40 +2329,40 @@ void appendToExportData( QString& out, const std::vector<CurvesData>& curvesData
{
default:
// Fall through to NONE
case DateTimePeriod::NONE:
case RiaQDateTimeTools::DateTimePeriod::NONE:
timeText = timseStepUtc.toString( "yyyy-MM-dd hh:mm:ss " );
break;
case DateTimePeriod::DAY:
case RiaQDateTimeTools::DateTimePeriod::DAY:
timeText = oneDayEarlier.toString( "yyyy-MM-dd " );
break;
case DateTimePeriod::WEEK:
case RiaQDateTimeTools::DateTimePeriod::WEEK:
{
timeText = oneDayEarlier.toString( "yyyy" );
int weekNumber = oneDayEarlier.date().weekNumber();
timeText += QString( "-W%1" ).arg( weekNumber, 2, 10, zeroChar );
break;
}
case DateTimePeriod::MONTH:
case RiaQDateTimeTools::DateTimePeriod::MONTH:
timeText = oneDayEarlier.toString( "yyyy-MM" );
break;
case DateTimePeriod::QUARTER:
case RiaQDateTimeTools::DateTimePeriod::QUARTER:
{
int quarterNumber = oneDayEarlier.date().month() / 3;
timeText = oneDayEarlier.toString( "yyyy" );
timeText += QString( "-Q%1" ).arg( quarterNumber );
break;
}
case DateTimePeriod::HALFYEAR:
case RiaQDateTimeTools::DateTimePeriod::HALFYEAR:
{
int halfYearNumber = oneDayEarlier.date().month() / 6;
timeText = oneDayEarlier.toString( "yyyy" );
timeText += QString( "-H%1" ).arg( halfYearNumber );
break;
}
case DateTimePeriod::YEAR:
case RiaQDateTimeTools::DateTimePeriod::YEAR:
timeText = oneDayEarlier.toString( "yyyy" );
break;
case DateTimePeriod::DECADE:
case RiaQDateTimeTools::DateTimePeriod::DECADE:
timeText = oneDayEarlier.toString( "yyyy" );
break;
}
@@ -2417,8 +2418,8 @@ CurvesData concatCurvesData( const std::vector<CurvesData>& curvesData )
{
CVF_ASSERT( !curvesData.empty() );
DateTimePeriod period = curvesData.front().resamplePeriod;
CurvesData resultCurvesData;
RiaQDateTimeTools::DateTimePeriod period = curvesData.front().resamplePeriod;
CurvesData resultCurvesData;
resultCurvesData.resamplePeriod = period;

View File

@@ -116,7 +116,8 @@ public:
RiuQwtPlotWidget* viewer() override;
QString asciiDataForPlotExport() const override;
QString asciiDataForSummaryPlotExport( DateTimePeriod resamplingPeriod, bool showTimeAsLongString ) const;
QString asciiDataForSummaryPlotExport( RiaQDateTimeTools::DateTimePeriod resamplingPeriod,
bool showTimeAsLongString ) const;
std::vector<RimSummaryCurve*> summaryAndEnsembleCurves() const;
std::set<RiaSummaryCurveDefinition> summaryAndEnsembleCurveDefinitions() const;

View File

@@ -1,10 +1,22 @@
set (SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimcSummaryPlotCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimcSummaryCase.h
${CMAKE_CURRENT_LIST_DIR}/RimcSummaryResampleData.h
${CMAKE_CURRENT_LIST_DIR}/RimcDataContainerDouble.h
${CMAKE_CURRENT_LIST_DIR}/RimcDataContainerString.h
${CMAKE_CURRENT_LIST_DIR}/RimcDataContainerTime.h
)
set (SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimcSummaryPlotCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimcSummaryCase.cpp
${CMAKE_CURRENT_LIST_DIR}/RimcSummaryResampleData.cpp
${CMAKE_CURRENT_LIST_DIR}/RimcDataContainerDouble.cpp
${CMAKE_CURRENT_LIST_DIR}/RimcDataContainerString.cpp
${CMAKE_CURRENT_LIST_DIR}/RimcDataContainerTime.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@@ -0,0 +1,34 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020- Equinor 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 "RimcDataContainerDouble.h"
#include "cafPdmFieldIOScriptability.h"
#include "cafPdmObjectScriptability.h"
CAF_PDM_SOURCE_INIT( RimcDataContainerDouble, "DataContainerFloat" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimcDataContainerDouble::RimcDataContainerDouble()
{
CAF_PDM_InitScriptableObject( "Data Container Float", "", "", "" );
CAF_PDM_InitScriptableFieldWithIONoDefault( &m_doubleValues, "values", "Float Values", "", "", "" );
}

View File

@@ -0,0 +1,35 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020- Equinor 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 "cafPdmField.h"
#include "cafPdmObject.h"
//==================================================================================================
///
//==================================================================================================
class RimcDataContainerDouble : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimcDataContainerDouble();
caf::PdmField<std::vector<double>> m_doubleValues;
};

View File

@@ -0,0 +1,34 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020- Equinor 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 "RimcDataContainerString.h"
#include "cafPdmFieldIOScriptability.h"
#include "cafPdmObjectScriptability.h"
CAF_PDM_SOURCE_INIT( RimcDataContainerString, "DataContainerString" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimcDataContainerString::RimcDataContainerString()
{
CAF_PDM_InitScriptableObject( "Data Container String", "", "", "" );
CAF_PDM_InitScriptableFieldWithIONoDefault( &m_stringValues, "values", "String Values", "", "", "" );
}

View File

@@ -0,0 +1,37 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020- Equinor 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 "cafPdmField.h"
#include "cafPdmObject.h"
#include <QString>
//==================================================================================================
///
//==================================================================================================
class RimcDataContainerString : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimcDataContainerString();
caf::PdmField<std::vector<QString>> m_stringValues;
};

View File

@@ -0,0 +1,34 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020- Equinor 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 "RimcDataContainerTime.h"
#include "cafPdmFieldIOScriptability.h"
#include "cafPdmObjectScriptability.h"
CAF_PDM_SOURCE_INIT( RimcDataContainerTime, "DataContainerTime" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimcDataContainerTime::RimcDataContainerTime()
{
CAF_PDM_InitScriptableObject( "Data Container Time", "", "", "" );
CAF_PDM_InitScriptableFieldWithIONoDefault( &m_timeValues, "values", "Time Values", "", "", "" );
}

View File

@@ -0,0 +1,37 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020- Equinor 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 "cafPdmField.h"
#include "cafPdmObject.h"
#include <ctime>
//==================================================================================================
///
//==================================================================================================
class RimcDataContainerTime : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimcDataContainerTime();
caf::PdmField<std::vector<time_t>> m_timeValues;
};

View File

@@ -0,0 +1,261 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020- Equinor 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 "RimcSummaryCase.h"
#include "RiaQDateTimeTools.h"
#include "RiaSummaryTools.h"
#include "RiaTimeHistoryCurveResampler.h"
#include "RifSummaryReaderInterface.h"
#include "RimSummaryCase.h"
#include "RimcDataContainerDouble.h"
#include "RimcDataContainerString.h"
#include "RimcDataContainerTime.h"
#include "RimcSummaryResampleData.h"
#include "cafPdmFieldIOScriptability.h"
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimSummaryCase, RimSummaryCase_summaryVectorValues, "summaryVectorValues" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCase_summaryVectorValues::RimSummaryCase_summaryVectorValues( caf::PdmObjectHandle* self )
: caf::PdmObjectMethod( self )
{
CAF_PDM_InitObject( "Create Summary Plot", "", "", "Create a new Summary Plot" );
CAF_PDM_InitScriptableFieldWithIONoDefault( &m_addressString,
"Address",
"",
"",
"",
"Formatted address specifying the summary vector" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmObjectHandle* RimSummaryCase_summaryVectorValues::execute()
{
QStringList addressStrings = m_addressString().split( ";", QString::SkipEmptyParts );
auto* summaryCase = self<RimSummaryCase>();
RifSummaryReaderInterface* sumReader = summaryCase->summaryReader();
auto adr = RifEclipseSummaryAddress::fromEclipseTextAddress( m_addressString().toStdString() );
std::vector<double> values;
bool isOk = sumReader->values( adr, &values );
if ( isOk )
{
auto dataObject = new RimcDataContainerDouble();
dataObject->m_doubleValues = values;
return dataObject;
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimSummaryCase_summaryVectorValues::resultIsPersistent() const
{
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::unique_ptr<caf::PdmObjectHandle> RimSummaryCase_summaryVectorValues::defaultResult() const
{
return std::unique_ptr<caf::PdmObjectHandle>( new RimcDataContainerDouble );
}
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimSummaryCase, RimSummaryCase_availableAddresses, "availableAddresses" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCase_availableAddresses::RimSummaryCase_availableAddresses( caf::PdmObjectHandle* self )
: caf::PdmObjectMethod( self )
{
CAF_PDM_InitObject( "Available Addresses", "", "", "" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmObjectHandle* RimSummaryCase_availableAddresses::execute()
{
auto* summaryCase = self<RimSummaryCase>();
RifSummaryReaderInterface* sumReader = summaryCase->summaryReader();
const std::set<RifEclipseSummaryAddress>& addresses = sumReader->allResultAddresses();
std::vector<QString> adr;
for ( const auto& a : addresses )
{
adr.push_back( QString::fromStdString( a.uiText() ) );
}
auto dataObject = new RimcDataContainerString();
dataObject->m_stringValues = adr;
return dataObject;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimSummaryCase_availableAddresses::resultIsPersistent() const
{
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::unique_ptr<caf::PdmObjectHandle> RimSummaryCase_availableAddresses::defaultResult() const
{
return std::unique_ptr<caf::PdmObjectHandle>( new RimcDataContainerString );
}
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimSummaryCase, RimSummaryCase_availableTimeSteps, "availableTimeSteps" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCase_availableTimeSteps::RimSummaryCase_availableTimeSteps( caf::PdmObjectHandle* self )
: caf::PdmObjectMethod( self )
{
CAF_PDM_InitObject( "Available TimeSteps", "", "", "" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmObjectHandle* RimSummaryCase_availableTimeSteps::execute()
{
auto* summaryCase = self<RimSummaryCase>();
RifSummaryReaderInterface* sumReader = summaryCase->summaryReader();
RifEclipseSummaryAddress adr;
auto timeValues = sumReader->timeSteps( adr );
auto dataObject = new RimcDataContainerTime();
dataObject->m_timeValues = timeValues;
return dataObject;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimSummaryCase_availableTimeSteps::resultIsPersistent() const
{
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::unique_ptr<caf::PdmObjectHandle> RimSummaryCase_availableTimeSteps::defaultResult() const
{
return std::unique_ptr<caf::PdmObjectHandle>( new RimcDataContainerTime );
}
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimSummaryCase, RimSummaryCase_resampleValues, "resampleValues" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCase_resampleValues::RimSummaryCase_resampleValues( caf::PdmObjectHandle* self )
: caf::PdmObjectMethod( self )
{
CAF_PDM_InitObject( "Resample Values", "", "", "" );
CAF_PDM_InitScriptableFieldWithIONoDefault( &m_addressString,
"Address",
"",
"",
"",
"Formatted address specifying the summary vector" );
CAF_PDM_InitScriptableFieldWithIONoDefault( &m_resamplingPeriod, "ResamplingPeriod", "", "", "", "Resampling Period" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmObjectHandle* RimSummaryCase_resampleValues::execute()
{
QStringList addressStrings = m_addressString().split( ";", QString::SkipEmptyParts );
auto* summaryCase = self<RimSummaryCase>();
RifSummaryReaderInterface* sumReader = summaryCase->summaryReader();
auto adr = RifEclipseSummaryAddress::fromEclipseTextAddress( m_addressString().toStdString() );
std::vector<double> values;
bool isOk = sumReader->values( adr, &values );
if ( !isOk ) return nullptr;
auto timeValues = sumReader->timeSteps( adr );
QString periodString = m_resamplingPeriod().trimmed();
RiaQDateTimeTools::DateTimePeriod period = RiaQDateTimeTools::DateTimePeriodEnum::fromText( periodString );
RiaTimeHistoryCurveResampler resampler;
resampler.setCurveData( values, timeValues );
if ( RiaSummaryTools::hasAccumulatedData( adr ) )
{
resampler.resampleAndComputePeriodEndValues( period );
}
else
{
resampler.resampleAndComputeWeightedMeanValues( period );
}
auto dataObject = new RimcSummaryResampleData();
dataObject->m_timeValues = resampler.resampledTimeSteps();
dataObject->m_doubleValues = resampler.resampledValues();
return dataObject;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimSummaryCase_resampleValues::resultIsPersistent() const
{
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::unique_ptr<caf::PdmObjectHandle> RimSummaryCase_resampleValues::defaultResult() const
{
return std::unique_ptr<caf::PdmObjectHandle>( new RimcSummaryResampleData );
}

View File

@@ -0,0 +1,94 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020- Equinor 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 "cafPdmField.h"
#include "cafPdmObjectHandle.h"
#include "cafPdmObjectMethod.h"
#include <QString>
#include <memory>
//==================================================================================================
///
//==================================================================================================
class RimSummaryCase_summaryVectorValues : public caf::PdmObjectMethod
{
CAF_PDM_HEADER_INIT;
public:
RimSummaryCase_summaryVectorValues( caf::PdmObjectHandle* self );
caf::PdmObjectHandle* execute();
bool resultIsPersistent() const override;
std::unique_ptr<PdmObjectHandle> defaultResult() const override;
private:
caf::PdmField<QString> m_addressString;
};
//==================================================================================================
///
//==================================================================================================
class RimSummaryCase_availableAddresses : public caf::PdmObjectMethod
{
CAF_PDM_HEADER_INIT;
public:
RimSummaryCase_availableAddresses( caf::PdmObjectHandle* self );
caf::PdmObjectHandle* execute();
bool resultIsPersistent() const override;
std::unique_ptr<PdmObjectHandle> defaultResult() const override;
};
//==================================================================================================
///
//==================================================================================================
class RimSummaryCase_availableTimeSteps : public caf::PdmObjectMethod
{
CAF_PDM_HEADER_INIT;
public:
RimSummaryCase_availableTimeSteps( caf::PdmObjectHandle* self );
caf::PdmObjectHandle* execute();
bool resultIsPersistent() const override;
std::unique_ptr<PdmObjectHandle> defaultResult() const override;
};
//==================================================================================================
///
//==================================================================================================
class RimSummaryCase_resampleValues : public caf::PdmObjectMethod
{
CAF_PDM_HEADER_INIT;
public:
RimSummaryCase_resampleValues( caf::PdmObjectHandle* self );
caf::PdmObjectHandle* execute();
bool resultIsPersistent() const override;
std::unique_ptr<PdmObjectHandle> defaultResult() const override;
private:
caf::PdmField<QString> m_addressString;
caf::PdmField<QString> m_resamplingPeriod;
};

View File

@@ -16,6 +16,8 @@
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RimSummaryCaseCollection.h"
#include "RimSummaryPlotCollection.h"

View File

@@ -0,0 +1,35 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020- Equinor 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 "RimcSummaryResampleData.h"
#include "cafPdmFieldIOScriptability.h"
#include "cafPdmObjectScriptability.h"
CAF_PDM_SOURCE_INIT( RimcSummaryResampleData, "ResampleData" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimcSummaryResampleData::RimcSummaryResampleData()
{
CAF_PDM_InitScriptableObject( "Resample Data", "", "", "" );
CAF_PDM_InitScriptableFieldWithIONoDefault( &m_timeValues, "TimeSteps", "Time Steps", "", "", "" );
CAF_PDM_InitScriptableFieldWithIONoDefault( &m_doubleValues, "Values", "Values", "", "", "" );
}

View File

@@ -0,0 +1,38 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020- Equinor 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 "cafPdmField.h"
#include "cafPdmObject.h"
#include <ctime>
//==================================================================================================
///
//==================================================================================================
class RimcSummaryResampleData : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimcSummaryResampleData();
caf::PdmField<std::vector<double>> m_doubleValues;
caf::PdmField<std::vector<time_t>> m_timeValues;
};

View File

@@ -35,7 +35,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_Resampling_NoPeriod )
RiaTimeHistoryCurveResampler resampler;
resampler.setCurveData( dataValues, toTime_tVector( timeStrings ) );
resampler.resampleAndComputeWeightedMeanValues( DateTimePeriod::MONTH );
resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::MONTH );
EXPECT_EQ( 1, (int)resampler.resampledTimeSteps().size() );
EXPECT_EQ( toTime_t( "2018-03-01" ), resampler.resampledTimeSteps()[0] );
@@ -52,7 +52,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_Resampling_Decade )
RiaTimeHistoryCurveResampler resampler;
resampler.setCurveData( dataValues, toTime_tVector( timeStrings ) );
resampler.resampleAndComputeWeightedMeanValues( DateTimePeriod::DECADE );
resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::DECADE );
EXPECT_EQ( 4, (int)resampler.resampledTimeSteps().size() );
EXPECT_EQ( toTime_t( "1990-01-01" ), resampler.resampledTimeSteps()[0] );
@@ -72,7 +72,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_Resampling_Year )
RiaTimeHistoryCurveResampler resampler;
resampler.setCurveData( dataValues, toTime_tVector( timeStrings ) );
resampler.resampleAndComputeWeightedMeanValues( DateTimePeriod::YEAR );
resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::YEAR );
EXPECT_EQ( 5, (int)resampler.resampledTimeSteps().size() );
EXPECT_EQ( toTime_t( "2015-01-01" ), resampler.resampledTimeSteps()[0] );
@@ -93,7 +93,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_Resampling_HalfYear )
RiaTimeHistoryCurveResampler resampler;
resampler.setCurveData( dataValues, toTime_tVector( timeStrings ) );
resampler.resampleAndComputeWeightedMeanValues( DateTimePeriod::HALFYEAR );
resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::HALFYEAR );
EXPECT_EQ( 5, (int)resampler.resampledTimeSteps().size() );
EXPECT_EQ( toTime_t( "2016-07-01" ), resampler.resampledTimeSteps()[0] );
@@ -114,7 +114,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_Resampling_Quarter )
RiaTimeHistoryCurveResampler resampler;
resampler.setCurveData( dataValues, toTime_tVector( timeStrings ) );
resampler.resampleAndComputeWeightedMeanValues( DateTimePeriod::QUARTER );
resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::QUARTER );
EXPECT_EQ( 7, (int)resampler.resampledTimeSteps().size() );
EXPECT_EQ( toTime_t( "2016-10-01" ), resampler.resampledTimeSteps()[0] );
@@ -137,7 +137,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_Resampling_Month )
RiaTimeHistoryCurveResampler resampler;
resampler.setCurveData( dataValues, toTime_tVector( timeStrings ) );
resampler.resampleAndComputeWeightedMeanValues( DateTimePeriod::MONTH );
resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::MONTH );
EXPECT_EQ( 6, (int)resampler.resampledTimeSteps().size() );
EXPECT_EQ( toTime_t( "2017-10-01" ), resampler.resampledTimeSteps()[0] );
@@ -159,7 +159,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_Resampling_Week )
RiaTimeHistoryCurveResampler resampler;
resampler.setCurveData( dataValues, toTime_tVector( timeStrings ) );
resampler.resampleAndComputeWeightedMeanValues( DateTimePeriod::WEEK );
resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::WEEK );
EXPECT_EQ( 10, (int)resampler.resampledTimeSteps().size() );
EXPECT_EQ( toTime_t( "2017-11-06" ), resampler.resampledTimeSteps()[0] );
@@ -185,7 +185,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_Resampling_NoSampleCrossingPeriodBounda
RiaTimeHistoryCurveResampler resampler;
resampler.setCurveData( dataValues, toTime_tVector( timeStrings ) );
resampler.resampleAndComputeWeightedMeanValues( DateTimePeriod::YEAR );
resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::YEAR );
EXPECT_EQ( 1, (int)resampler.resampledTimeSteps().size() );
EXPECT_EQ( toTime_t( "2018-01-01" ), resampler.resampledTimeSteps()[0] );
@@ -202,7 +202,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_WeightedMean_SingleSample )
RiaTimeHistoryCurveResampler resampler;
resampler.setCurveData( dataValues, toTime_tVector( timeStrings ) );
resampler.resampleAndComputeWeightedMeanValues( DateTimePeriod::MONTH );
resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::MONTH );
EXPECT_EQ( 1, (int)resampler.resampledTimeSteps().size() );
EXPECT_EQ( toTime_t( "2018-03-01" ), resampler.resampledTimeSteps()[0] );
@@ -222,7 +222,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_WeightedMean_Days )
RiaTimeHistoryCurveResampler resampler;
resampler.setCurveData( dataValues, toTime_tVector( timeStrings ) );
resampler.resampleAndComputeWeightedMeanValues( DateTimePeriod::DAY );
resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::DAY );
EXPECT_EQ( 5, (int)resampler.resampledTimeSteps().size() );
EXPECT_EQ( toTime_t( "2018-02-03" ), resampler.resampledTimeSteps()[0] );
@@ -256,7 +256,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_WeightedMean_Decade )
RiaTimeHistoryCurveResampler resampler;
resampler.setCurveData( dataValues, toTime_tVector( timeStrings ) );
resampler.resampleAndComputeWeightedMeanValues( DateTimePeriod::DECADE );
resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::DECADE );
EXPECT_EQ( 3, (int)resampler.resampledTimeSteps().size() );
EXPECT_EQ( tp0, resampler.resampledTimeSteps()[0] );
@@ -287,7 +287,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_WeightedMean_SamplesStartBeforePeriod )
RiaTimeHistoryCurveResampler resampler;
resampler.setCurveData( dataValues, toTime_tVector( timeStrings ) );
resampler.resampleAndComputeWeightedMeanValues( DateTimePeriod::MONTH );
resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::MONTH );
EXPECT_EQ( 3, (int)resampler.resampledTimeSteps().size() );
EXPECT_EQ( tp0, resampler.resampledTimeSteps()[0] );
@@ -320,7 +320,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_WeightedMean_SamplesStartBeforePeriod_T
RiaTimeHistoryCurveResampler resampler;
resampler.setCurveData( dataValues, toTime_tVector( timeStrings ) );
resampler.resampleAndComputeWeightedMeanValues( DateTimePeriod::MONTH );
resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::MONTH );
EXPECT_EQ( 3, (int)resampler.resampledTimeSteps().size() );
EXPECT_EQ( tp0, resampler.resampledTimeSteps()[0] );
@@ -349,7 +349,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_WeightedMean_SamplesStartAndEndMatchPer
RiaTimeHistoryCurveResampler resampler;
resampler.setCurveData( dataValues, toTime_tVector( timeStrings ) );
resampler.resampleAndComputeWeightedMeanValues( DateTimePeriod::MONTH );
resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::MONTH );
EXPECT_EQ( 2, (int)resampler.resampledTimeSteps().size() );
EXPECT_EQ( toTime_t( "2018-02-01" ), resampler.resampledTimeSteps().front() );
@@ -379,7 +379,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_WeightedMean_SamplesStartMatchPeriodSta
RiaTimeHistoryCurveResampler resampler;
resampler.setCurveData( dataValues, toTime_tVector( timeStrings ) );
resampler.resampleAndComputeWeightedMeanValues( DateTimePeriod::MONTH );
resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::MONTH );
EXPECT_EQ( 3, (int)resampler.resampledTimeSteps().size() );
EXPECT_EQ( tp0, resampler.resampledTimeSteps()[0] );
@@ -409,7 +409,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_WeightedMean_MultipleSamplesInLastPerio
RiaTimeHistoryCurveResampler resampler;
resampler.setCurveData( dataValues, toTime_tVector( timeStrings ) );
resampler.resampleAndComputeWeightedMeanValues( DateTimePeriod::MONTH );
resampler.resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod::MONTH );
EXPECT_EQ( 2, (int)resampler.resampledTimeSteps().size() );
EXPECT_EQ( tp0, resampler.resampledTimeSteps()[0] );
@@ -433,7 +433,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_PeriodEndValues_SingleSample )
RiaTimeHistoryCurveResampler resampler;
resampler.setCurveData( dataValues, toTime_tVector( timeStrings ) );
resampler.resampleAndComputePeriodEndValues( DateTimePeriod::MONTH );
resampler.resampleAndComputePeriodEndValues( RiaQDateTimeTools::DateTimePeriod::MONTH );
EXPECT_EQ( 1, (int)resampler.resampledTimeSteps().size() );
EXPECT_EQ( toTime_t( "2018-03-01" ), resampler.resampledTimeSteps()[0] );
@@ -459,7 +459,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_PeriodEndValues_SamplesStartBeforePerio
RiaTimeHistoryCurveResampler resampler;
resampler.setCurveData( dataValues, toTime_tVector( timeStrings ) );
resampler.resampleAndComputePeriodEndValues( DateTimePeriod::MONTH );
resampler.resampleAndComputePeriodEndValues( RiaQDateTimeTools::DateTimePeriod::MONTH );
EXPECT_EQ( 3, (int)resampler.resampledTimeSteps().size() );
EXPECT_EQ( tp0, resampler.resampledTimeSteps()[0] );
@@ -486,7 +486,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_PeriodEndValues_SamplesStartMatchPeriod
RiaTimeHistoryCurveResampler resampler;
resampler.setCurveData( dataValues, toTime_tVector( timeStrings ) );
resampler.resampleAndComputePeriodEndValues( DateTimePeriod::MONTH );
resampler.resampleAndComputePeriodEndValues( RiaQDateTimeTools::DateTimePeriod::MONTH );
EXPECT_EQ( 3, (int)resampler.resampledTimeSteps().size() );
EXPECT_EQ( toTime_t( "2018-02-01" ), resampler.resampledTimeSteps()[0] );
@@ -509,7 +509,7 @@ TEST( RiaTimeHistoryCurveResampler, Test_PeriodEndValues_SamplesStartAndEndMatch
RiaTimeHistoryCurveResampler resampler;
resampler.setCurveData( dataValues, toTime_tVector( timeStrings ) );
resampler.resampleAndComputePeriodEndValues( DateTimePeriod::MONTH );
resampler.resampleAndComputePeriodEndValues( RiaQDateTimeTools::DateTimePeriod::MONTH );
EXPECT_EQ( 2, (int)resampler.resampledTimeSteps().size() );
EXPECT_EQ( toTime_t( "2018-02-01" ), resampler.resampledTimeSteps().front() );

View File

@@ -108,6 +108,14 @@ QString RiuDockWidgetTools::plotMainWindowPropertyEditorName()
return "plotMainWindow_dockPropertyEditor";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiuDockWidgetTools::plotMainWindowMessagesName()
{
return "plotMainWindow_dockMessages";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -48,6 +48,7 @@ public:
static QString plotMainWindowProjectTreeName();
static QString plotMainWindowPropertyEditorName();
static QString plotMainWindowMessagesName();
static QAction* toggleActionForWidget( const QObject* parent, const QString& dockWidgetName );

View File

@@ -137,12 +137,19 @@ void RiuMessagePanel::slotClearMessages()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuMessagePanelLogger::RiuMessagePanelLogger( RiuMessagePanel* messagePanel )
: m_messagePanel( messagePanel )
, m_logLevel( RI_LL_WARNING )
RiuMessagePanelLogger::RiuMessagePanelLogger()
: m_logLevel( RI_LL_WARNING )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMessagePanelLogger::addMessagePanel( RiuMessagePanel* messagePanel )
{
m_messagePanel.push_back( messagePanel );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -201,8 +208,11 @@ void RiuMessagePanelLogger::writeToMessagePanel( RILogLevel messageLevel, const
return;
}
if ( m_messagePanel )
for ( auto panel : m_messagePanel )
{
m_messagePanel->addMessage( messageLevel, message );
if ( panel )
{
panel->addMessage( messageLevel, message );
}
}
}

View File

@@ -57,7 +57,9 @@ private:
class RiuMessagePanelLogger : public RiaLogger
{
public:
explicit RiuMessagePanelLogger( RiuMessagePanel* messagePanel );
explicit RiuMessagePanelLogger();
void addMessagePanel( RiuMessagePanel* messagePanel );
int level() const override;
void setLevel( int logLevel ) override;
@@ -71,6 +73,6 @@ private:
void writeToMessagePanel( RILogLevel messageLevel, const char* message );
private:
QPointer<RiuMessagePanel> m_messagePanel;
int m_logLevel;
std::vector<QPointer<RiuMessagePanel>> m_messagePanel;
int m_logLevel;
};

View File

@@ -44,6 +44,7 @@
#include "RiuDockWidgetTools.h"
#include "RiuDragDrop.h"
#include "RiuMdiSubWindow.h"
#include "RiuMessagePanel.h"
#include "RiuMultiPlotPage.h"
#include "RiuToolTipMenu.h"
#include "RiuTreeViewEventFilter.h"
@@ -463,6 +464,15 @@ void RiuPlotMainWindow::createDockPanels()
addDockWidget( Qt::LeftDockWidgetArea, dockWidget );
}
{
QDockWidget* dockWidget = new QDockWidget( "Messages", this );
dockWidget->setObjectName( RiuDockWidgetTools::plotMainWindowMessagesName() );
m_messagePanel = new RiuMessagePanel( dockWidget );
dockWidget->setWidget( m_messagePanel );
addDockWidget( Qt::BottomDockWidgetArea, dockWidget );
dockWidget->hide();
}
setCorner( Qt::BottomLeftCorner, Qt::LeftDockWidgetArea );
setCorner( Qt::BottomRightCorner, Qt::BottomDockWidgetArea );
@@ -675,6 +685,14 @@ RicSummaryCurveCalculatorDialog* RiuPlotMainWindow::summaryCurveCalculatorDialog
return m_summaryCurveCalculatorDialog;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuMessagePanel* RiuPlotMainWindow::messagePanel()
{
return m_messagePanel;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -28,14 +28,14 @@
#include <memory>
class QMdiSubWindow;
class RiuViewer;
struct RimMdiWindowGeometry;
class QMdiSubWindow;
class RiuViewer;
class RimViewWindow;
class RicSummaryPlotEditorDialog;
class RicSummaryCurveCalculatorDialog;
class RiuMessagePanel;
namespace caf
{
@@ -91,6 +91,8 @@ public:
RicSummaryPlotEditorDialog* summaryCurveCreatorDialog();
RicSummaryCurveCalculatorDialog* summaryCurveCalculatorDialog();
RiuMessagePanel* messagePanel();
protected:
void closeEvent( QCloseEvent* event ) override;
void keyPressEvent( QKeyEvent* ) override;
@@ -124,6 +126,7 @@ private:
RiuMdiArea* m_mdiArea;
caf::PdmPointer<RimViewWindow> m_activePlotViewWindow;
QPointer<RiuMessagePanel> m_messagePanel;
QMenu* m_windowMenu;

View File

@@ -17,7 +17,10 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RiaApplication.h"
#include "RiaGuiApplication.h"
#include "RiuMessagePanel.h"
#include "RiuPlotMainWindow.h"
#include "RiuProcessMonitor.h"
#include "cafUiProcess.h"
@@ -149,6 +152,12 @@ void RiuProcessMonitor::addStringToLog( const QString& sTxt )
m_textEdit->insertPlainText( sTxt );
m_textEdit->ensureCursorVisible();
RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow();
if ( mainPlotWindow && mainPlotWindow->messagePanel() )
{
mainPlotWindow->messagePanel()->addMessage( RI_LL_INFO, sTxt );
}
}
//--------------------------------------------------------------------------------------------------

View File

@@ -33,6 +33,7 @@
// for more details.
//
//##################################################################################################
#include "cafPdmObjectMethod.h"
using namespace caf;
@@ -47,32 +48,34 @@ PdmObjectMethodFactory* PdmObjectMethodFactory::instance()
}
//--------------------------------------------------------------------------------------------------
///
/// Check the object and the inheritance stack for the specified method name
//--------------------------------------------------------------------------------------------------
std::shared_ptr<PdmObjectMethod> PdmObjectMethodFactory::createMethod( PdmObjectHandle* self, const QString& methodName )
{
QString className = self->xmlCapability()->classKeyword();
auto classIt = m_factoryMap.find( className );
if ( classIt != m_factoryMap.end() )
auto stack = self->xmlCapability()->classInheritanceStack();
for ( auto className : stack )
{
auto methodIt = classIt->second.find( methodName );
if ( methodIt != classIt->second.end() )
auto classIt = m_factoryMap.find( className );
if ( classIt != m_factoryMap.end() )
{
return methodIt->second->create( self );
auto methodIt = classIt->second.find( methodName );
if ( methodIt != classIt->second.end() )
{
return methodIt->second->create( self );
}
}
}
return std::shared_ptr<PdmObjectMethod>();
}
//--------------------------------------------------------------------------------------------------
///
/// Return the methods registered for the className. Does not investigate the inheritance stack
//--------------------------------------------------------------------------------------------------
std::vector<QString> PdmObjectMethodFactory::registeredMethodNames( const PdmObjectHandle* self ) const
std::vector<QString> caf::PdmObjectMethodFactory::registeredMethodNames( const QString& className ) const
{
std::vector<QString> methods;
QString className = self->xmlCapability()->classKeyword();
auto classIt = m_factoryMap.find( className );
auto classIt = m_factoryMap.find( className );
if ( classIt != m_factoryMap.end() )
{
for ( auto methodPair : classIt->second )

View File

@@ -117,7 +117,7 @@ public:
return true;
}
std::vector<QString> registeredMethodNames( const PdmObjectHandle* self ) const;
std::vector<QString> registeredMethodNames( const QString& className ) const;
private:
PdmObjectMethodFactory() = default;

View File

@@ -235,59 +235,57 @@ QString PdmPythonGenerator::generate( PdmObjectFactory* factory ) const
}
}
}
for ( QString methodName : PdmObjectMethodFactory::instance()->registeredMethodNames( object.get() ) )
{
std::shared_ptr<PdmObjectMethod> method =
PdmObjectMethodFactory::instance()->createMethod( object.get(), methodName );
std::vector<PdmFieldHandle*> arguments;
method->fields( arguments );
QString methodComment = method->uiCapability()->uiWhatsThis();
QString snake_method_name = camelToSnakeCase( methodName );
QStringList inputArgumentStrings;
QStringList outputArgumentStrings;
QStringList argumentComments;
outputArgumentStrings.push_back( QString( "\"%1\"" ).arg( methodName ) );
QString returnComment( "Data object" );
if ( method->resultIsPersistent() )
{
returnComment = method->defaultResult()->xmlCapability()->classKeyword();
}
for ( auto field : arguments )
{
bool isList = field->xmlCapability()->isVectorField();
QString defaultValue = isList ? "[]" : "None";
auto scriptability = field->capability<PdmFieldScriptability>();
auto argumentName = camelToSnakeCase( scriptability->scriptFieldName() );
auto dataType = dataTypeString( field, false );
if ( isList ) dataType = "List of " + dataType;
inputArgumentStrings.push_back( QString( "%1=%2" ).arg( argumentName ).arg( defaultValue ) );
outputArgumentStrings.push_back( QString( "%1=%1" ).arg( argumentName ) );
argumentComments.push_back( QString( "%1 (%2): %3" )
.arg( argumentName )
.arg( dataType )
.arg( field->uiCapability()->uiWhatsThis() ) );
}
QString fullComment = QString( " \"\"\"\n %1\n Arguments:\n "
"%2\n Returns:\n %3\n \"\"\"" )
.arg( methodComment )
.arg( argumentComments.join( "\n " ) )
.arg( returnComment );
QString methodCode = QString( " def %1(self, %2):\n%3\n return "
"self._call_pdm_method(%4)\n" )
.arg( snake_method_name )
.arg( inputArgumentStrings.join( ", " ) )
.arg( fullComment )
.arg( outputArgumentStrings.join( ", " ) );
classMethodsGenerated[field->ownerClass()][snake_method_name] = methodCode;
}
}
}
for ( QString methodName : PdmObjectMethodFactory::instance()->registeredMethodNames( classKeyword ) )
{
std::shared_ptr<PdmObjectMethod> method =
PdmObjectMethodFactory::instance()->createMethod( object.get(), methodName );
std::vector<PdmFieldHandle*> arguments;
method->fields( arguments );
QString methodComment = method->uiCapability()->uiWhatsThis();
QString snake_method_name = camelToSnakeCase( methodName );
if ( classMethodsGenerated[classKeyword][snake_method_name].count() ) continue;
QStringList inputArgumentStrings;
QStringList outputArgumentStrings;
QStringList argumentComments;
outputArgumentStrings.push_back( QString( "\"%1\"" ).arg( methodName ) );
QString returnComment = method->defaultResult()->xmlCapability()->classKeyword();
for ( auto field : arguments )
{
bool isList = field->xmlCapability()->isVectorField();
QString defaultValue = isList ? "[]" : "None";
auto scriptability = field->capability<PdmFieldScriptability>();
auto argumentName = camelToSnakeCase( scriptability->scriptFieldName() );
auto dataType = dataTypeString( field, false );
if ( isList ) dataType = "List of " + dataType;
inputArgumentStrings.push_back( QString( "%1=%2" ).arg( argumentName ).arg( defaultValue ) );
outputArgumentStrings.push_back( QString( "%1=%1" ).arg( argumentName ) );
argumentComments.push_back(
QString( "%1 (%2): %3" ).arg( argumentName ).arg( dataType ).arg( field->uiCapability()->uiWhatsThis() ) );
}
QString fullComment = QString( " \"\"\"\n %1\n Arguments:\n "
"%2\n Returns:\n %3\n \"\"\"" )
.arg( methodComment )
.arg( argumentComments.join( "\n " ) )
.arg( returnComment );
QString methodCode = QString( " def %1(self, %2):\n%3\n return "
"self._call_pdm_method(%4)\n" )
.arg( snake_method_name )
.arg( inputArgumentStrings.join( ", " ) )
.arg( fullComment )
.arg( outputArgumentStrings.join( ", " ) );
classMethodsGenerated[classKeyword][snake_method_name] = methodCode;
}
}
}
@@ -412,6 +410,7 @@ QString PdmPythonGenerator::dataTypeString( const PdmFieldHandle* field, bool us
std::map<QString, QString> builtins = {{QString::fromStdString( typeid( double ).name() ), "float"},
{QString::fromStdString( typeid( float ).name() ), "float"},
{QString::fromStdString( typeid( int ).name() ), "int"},
{QString::fromStdString( typeid( time_t ).name() ), "time"},
{QString::fromStdString( typeid( QString ).name() ), "str"}};
bool foundBuiltin = false;

View File

@@ -146,7 +146,7 @@ public:
"Enter some small number here",
"This is a place you can enter a small integer value if you want" );
CAF_PDM_InitField( &m_textField, "TextField", QString( "<EFBFBD><EFBFBD><EFBFBD> Test text end" ), "TextField", "", "Tooltip", "WhatsThis" );
CAF_PDM_InitField( &m_textField, "TextField", QString( "<EFBFBD><EFBFBD><EFBFBD> Test text end" ), "TextField", "", "Tooltip", "WhatsThis" );
CAF_PDM_InitFieldNoDefault( &m_simpleObjPtrField, "SimpleObjPtrField", "SimpleObjPtrField", "", "Tooltip", "WhatsThis" );
CAF_PDM_InitFieldNoDefault( &m_simpleObjPtrField2, "SimpleObjPtrField2", "SimpleObjPtrField2", "", "Tooltip", "WhatsThis" );
m_simpleObjPtrField2 = new SimpleObj;
@@ -191,6 +191,7 @@ public:
"Script comment test" );
CAF_PDM_InitScriptableFieldWithIONoDefault( &m_texts, "Texts", "Some words", "", "", "" );
CAF_PDM_InitScriptableFieldWithIONoDefault( &m_numbers, "Numbers", "Some words", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_testEnumField, "TestEnumValue", "An Enum", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_simpleObjectsField,
"SimpleObjects",
@@ -202,7 +203,9 @@ public:
~InheritedDemoObj() { m_simpleObjectsField.deleteAllChildObjects(); }
caf::PdmField<std::vector<QString>> m_texts;
caf::PdmField<std::vector<QString>> m_texts;
caf::PdmField<std::vector<double>> m_numbers;
caf::PdmField<caf::AppEnum<TestEnumType>> m_testEnumField;
caf::PdmChildArrayField<SimpleObj*> m_simpleObjectsField;
};
@@ -248,4 +251,19 @@ TEST( PdmScriptingTest, BasicUse )
std::unique_ptr<caf::PdmCodeGenerator> generator( caf::PdmCodeGeneratorFactory::instance()->create( fileExt ) );
auto generatedText = generator->generate( caf::PdmDefaultObjectFactory::instance() );
auto string = generatedText.toStdString();
}
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
TEST( PdmScriptingTest, CheckIsVector )
{
InheritedDemoObj obj;
auto isVector = obj.m_numbers.xmlCapability()->isVectorField();
EXPECT_TRUE( isVector );
// auto xmlCap = obj.xmlCapability();
// auto string = xmlCap->writeObjectToXmlString();
}

View File

@@ -26,7 +26,6 @@ set( PROJECT_FILES
cafPdmObjectGroup.h
cafPdmObject.cpp
cafPdmObject.h
cafPdmField.h
)
add_library( ${PROJECT_NAME}

View File

@@ -31,6 +31,7 @@ set( PROJECT_FILES
cafPdmChildField.h
cafPdmChildField.inl
cafPdmDataValueField.h
cafPdmField.h
cafPdmFieldCapability.h
cafPdmFieldHandle.cpp
cafPdmFieldHandle.h

View File

@@ -134,6 +134,31 @@ private:
};
template <typename DataType> class PdmField;
template < typename DataType>
class PdmFieldXmlCap< PdmField<std::vector<DataType>> > : public PdmXmlFieldHandle
{
typedef PdmField<std::vector<DataType>> FieldType;
public:
PdmFieldXmlCap(FieldType* field, bool giveOwnership) : PdmXmlFieldHandle(field, giveOwnership)
{
m_field = field;
m_dataTypeName = QString("%1").arg(typeid(DataType).name());
}
// Xml Serializing
public:
void readFieldData(QXmlStreamReader& xmlStream, PdmObjectFactory* objectFactory) override;
void writeFieldData(QXmlStreamWriter& xmlStream) const override;
bool resolveReferences() override;
bool isVectorField() const;
private:
FieldType* m_field;
};
template<typename FieldType>

View File

@@ -449,4 +449,52 @@ bool caf::PdmFieldXmlCap< caf::PdmChildArrayField<DataType*> >::isVectorField()
return true;
}
//==================================================================================================
/// XML Implementation for PdmFieldXmlCap<std::vector<DataType>> methods
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template < typename DataType>
bool caf::PdmFieldXmlCap<caf::PdmField<std::vector<DataType>>>::isVectorField() const
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename DataType >
void caf::PdmFieldXmlCap<caf::PdmField<std::vector<DataType>>>::readFieldData(QXmlStreamReader& xmlStream,
PdmObjectFactory* objectFactory)
{
this->assertValid();
typename FieldType::FieldDataType value;
PdmFieldReader<typename FieldType::FieldDataType>::readFieldData(value, xmlStream, objectFactory);
m_field->setValue(value);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename DataType >
void caf::PdmFieldXmlCap<caf::PdmField<std::vector<DataType>>>::writeFieldData(QXmlStreamWriter& xmlStream) const
{
this->assertValid();
PdmFieldWriter<typename FieldType::FieldDataType>::writeFieldData(m_field->value(), xmlStream);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template < typename DataType>
bool caf::PdmFieldXmlCap<caf::PdmField<std::vector<DataType>>>::resolveReferences()
{
return true;
}
} // End namespace caf