mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1440 Build time step format string on open
This commit is contained in:
parent
07e1acac15
commit
15848a82dc
@ -422,6 +422,51 @@ void RimEclipseCase::setReservoirData(RigEclipseCaseData* eclipseCase)
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEclipseCase::createTimeStepFormatString()
|
||||
{
|
||||
std::vector<QDateTime> timeStepDates = this->timeStepDates();
|
||||
|
||||
bool hasHoursAndMinutesInTimesteps = false;
|
||||
bool hasSecondsInTimesteps = false;
|
||||
bool hasMillisecondsInTimesteps = false;
|
||||
for (size_t i = 0; i < timeStepDates.size(); i++)
|
||||
{
|
||||
if (timeStepDates[i].time().msec() != 0.0)
|
||||
{
|
||||
hasMillisecondsInTimesteps = true;
|
||||
hasSecondsInTimesteps = true;
|
||||
hasHoursAndMinutesInTimesteps = true;
|
||||
break;
|
||||
}
|
||||
else if (timeStepDates[i].time().second() != 0.0)
|
||||
{
|
||||
hasHoursAndMinutesInTimesteps = true;
|
||||
hasSecondsInTimesteps = true;
|
||||
}
|
||||
else if (timeStepDates[i].time().hour() != 0.0 || timeStepDates[i].time().minute() != 0.0)
|
||||
{
|
||||
hasHoursAndMinutesInTimesteps = true;
|
||||
}
|
||||
}
|
||||
|
||||
m_timeStepFormatString = "dd.MMM yyyy";
|
||||
if (hasHoursAndMinutesInTimesteps)
|
||||
{
|
||||
m_timeStepFormatString += " - hh:mm";
|
||||
if (hasSecondsInTimesteps)
|
||||
{
|
||||
m_timeStepFormatString += ":ss";
|
||||
if (hasMillisecondsInTimesteps)
|
||||
{
|
||||
m_timeStepFormatString += ".zzz";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -516,6 +561,8 @@ bool RimEclipseCase::openReserviorCase()
|
||||
if (results->cellResults()) results->cellResults()->createPlaceholderResultEntries();
|
||||
}
|
||||
|
||||
createTimeStepFormatString();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -556,45 +603,6 @@ QString RimEclipseCase::timeStepName(int frameIdx)
|
||||
std::vector<QDateTime> timeStepDates = this->timeStepDates();
|
||||
CVF_ASSERT(frameIdx < static_cast<int>(timeStepDates.size()));
|
||||
|
||||
if (m_timeStepFormatString.isEmpty())
|
||||
{
|
||||
bool hasHoursAndMinutesInTimesteps = false;
|
||||
bool hasSecondsInTimesteps = false;
|
||||
bool hasMillisecondsInTimesteps = false;
|
||||
for (size_t i = 0; i < timeStepDates.size(); i++)
|
||||
{
|
||||
if (timeStepDates[i].time().msec() != 0.0)
|
||||
{
|
||||
hasMillisecondsInTimesteps = true;
|
||||
hasSecondsInTimesteps = true;
|
||||
hasHoursAndMinutesInTimesteps = true;
|
||||
break;
|
||||
}
|
||||
else if (timeStepDates[i].time().second() != 0.0) {
|
||||
hasHoursAndMinutesInTimesteps = true;
|
||||
hasSecondsInTimesteps = true;
|
||||
}
|
||||
else if (timeStepDates[i].time().hour() != 0.0 || timeStepDates[i].time().minute() != 0.0)
|
||||
{
|
||||
hasHoursAndMinutesInTimesteps = true;
|
||||
}
|
||||
}
|
||||
|
||||
m_timeStepFormatString = "dd.MMM yyyy";
|
||||
if (hasHoursAndMinutesInTimesteps)
|
||||
{
|
||||
m_timeStepFormatString += " - hh:mm";
|
||||
if (hasSecondsInTimesteps)
|
||||
{
|
||||
m_timeStepFormatString += ":ss";
|
||||
if (hasMillisecondsInTimesteps)
|
||||
{
|
||||
m_timeStepFormatString += ".zzz";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QDateTime date = timeStepDates.at(frameIdx);
|
||||
|
||||
return date.toString(m_timeStepFormatString);
|
||||
|
@ -99,9 +99,6 @@ public:
|
||||
void reloadDataAndUpdate();
|
||||
virtual void reloadEclipseGridFile() = 0;
|
||||
|
||||
// Overridden methods from PdmObject
|
||||
public:
|
||||
|
||||
protected:
|
||||
virtual void initAfterRead();
|
||||
virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue );
|
||||
@ -114,14 +111,15 @@ protected:
|
||||
void setReservoirData(RigEclipseCaseData* eclipseCase);
|
||||
|
||||
private:
|
||||
cvf::ref<RigEclipseCaseData> m_rigEclipseCase;
|
||||
void createTimeStepFormatString();
|
||||
|
||||
private:
|
||||
cvf::ref<RigEclipseCaseData> m_rigEclipseCase;
|
||||
QString m_timeStepFormatString;
|
||||
std::map<QString , cvf::Color3f> m_wellToColorMap;
|
||||
|
||||
caf::PdmChildField<RimReservoirCellResultsStorage*> m_matrixModelResults;
|
||||
caf::PdmChildField<RimReservoirCellResultsStorage*> m_fractureModelResults;
|
||||
QString m_timeStepFormatString;
|
||||
|
||||
std::map<QString , cvf::Color3f> m_wellToColorMap;
|
||||
|
||||
// Obsolete fields
|
||||
protected:
|
||||
|
Loading…
Reference in New Issue
Block a user