Moved building of time step names for UI to case

This commit is contained in:
Magne Sjaastad 2015-09-21 11:20:07 +02:00
parent c32f4cabfe
commit 06e8bc2ec5
6 changed files with 65 additions and 32 deletions

View File

@ -40,6 +40,9 @@ public:
virtual void updateFilePathsFromProjectPath(const QString& projectPath, const QString& oldProjectPath) = 0;
virtual caf::PdmFieldHandle* userDescriptionField() { return &caseUserDescription; }
virtual QStringList timeStepStrings() { return QStringList(); }
protected:
static QString relocateFile(const QString& fileName, const QString& newProjectPath, const QString& oldProjectPath,
bool* foundFile, std::vector<QString>* searchedPaths);

View File

@ -408,3 +408,35 @@ std::vector<RimView*> RimEclipseCase::views()
}
return views;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QStringList RimEclipseCase::timeStepStrings()
{
QStringList stringList;
std::vector<QDateTime> timeStepDates = results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->timeStepDates(0);
bool showHoursAndMinutes = false;
for (size_t i = 0; i < timeStepDates.size(); i++)
{
if (timeStepDates[i].time().hour() != 0.0 || timeStepDates[i].time().minute() != 0.0)
{
showHoursAndMinutes = true;
}
}
QString formatString = "dd.MMM yyyy";
if (showHoursAndMinutes)
{
formatString += " - hh:mm";
}
for (size_t i = 0; i < timeStepDates.size(); i++)
{
stringList += timeStepDates[i].toString(formatString);
}
return stringList;
}

View File

@ -85,7 +85,8 @@ public:
RimIdenticalGridCaseGroup* parentGridCaseGroup();
virtual std::vector<RimView*> views();
virtual QStringList timeStepStrings();
// Overridden methods from PdmObject
public:

View File

@ -23,6 +23,8 @@
#include "RiaPreferences.h"
#include "RifOdbReader.h"
#include "RigGeoMechCaseData.h"
#include "RigFemPartResultsCollection.h"
#include <QFile>
CAF_PDM_SOURCE_INIT(RimGeoMechCase, "ResInsightGeoMechCase");
@ -129,3 +131,19 @@ void RimGeoMechCase::initAfterRead()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QStringList RimGeoMechCase::timeStepStrings()
{
QStringList stringList;
std::vector<std::string> stepNames = geoMechData()->femPartResults()->stepNames();
for (size_t i = 0; i < stepNames.size(); i++)
{
stringList += QString::fromStdString(stepNames[i]);
}
return stringList;
}

View File

@ -56,6 +56,9 @@ public:
virtual void updateFilePathsFromProjectPath(const QString& projectPath, const QString& oldProjectPath);
virtual std::vector<RimView*> views();
virtual QStringList timeStepStrings();
// Fields:
caf::PdmChildArrayField<RimGeoMechView*> geoMechViews;

View File

@ -799,12 +799,11 @@ void RiuMainWindow::refreshAnimationActions()
m_animationToolBar->connectAnimationControl(animationControl);
QStringList timeStepStrings;
int currentTimeStepIndex = 0;
RiaApplication* app = RiaApplication::instance();
bool enableAnimControls = false;
RimView * activeView = app->activeReservoirView();
RimView * activeView = RiaApplication::instance()->activeReservoirView();
if (activeView &&
activeView->viewer() &&
activeView->viewer()->frameCount())
@ -818,27 +817,7 @@ void RiuMainWindow::refreshAnimationActions()
{
if (activeRiv->isTimeStepDependentDataVisible())
{
std::vector<QDateTime> timeStepDates = activeRiv->currentGridCellResults()->cellResults()->timeStepDates(0);
bool showHoursAndMinutes = false;
for (size_t i = 0; i < timeStepDates.size(); i++)
{
if (timeStepDates[i].time().hour() != 0.0 || timeStepDates[i].time().minute() != 0.0)
{
showHoursAndMinutes = true;
}
}
QString formatString = "dd.MMM yyyy";
if (showHoursAndMinutes)
{
formatString += " - hh:mm";
}
for (size_t i = 0; i < timeStepDates.size(); i++)
{
timeStepStrings += timeStepDates[i].toString(formatString);
}
currentTimeStepIndex = RiaApplication::instance()->activeReservoirView()->currentTimeStep();
timeStepStrings = activeRiv->eclipseCase()->timeStepStrings();
}
else
{
@ -853,16 +832,13 @@ void RiuMainWindow::refreshAnimationActions()
{
if (activeGmv->isTimeStepDependentDataVisible())
{
std::vector<std::string> stepNames = activeGmv->geoMechCase()->geoMechData()->femPartResults()->stepNames();
for (size_t i = 0; i < stepNames.size(); i++)
{
timeStepStrings += QString::fromStdString(stepNames[i]);
}
currentTimeStepIndex = RiaApplication::instance()->activeReservoirView()->currentTimeStep();
activeGmv->geoMechCase()->timeStepStrings();
}
}
}
currentTimeStepIndex = activeView->currentTimeStep();
// Animation control is only relevant for more than one time step
if (timeStepStrings.size() < 2)
@ -870,7 +846,7 @@ void RiuMainWindow::refreshAnimationActions()
enableAnimControls = false;
}
m_animationToolBar->setFrameRate(app->activeReservoirView()->maximumFrameRate());
m_animationToolBar->setFrameRate(activeView->maximumFrameRate());
}
m_animationToolBar->setTimeStepStrings(timeStepStrings);