mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2349 Elm Props: Use caf::FilePath instead of QString
This commit is contained in:
parent
efaaab1dc6
commit
a97dd087d6
@ -55,10 +55,10 @@ void RicImportElementPropertyFeature::onActionTriggered(bool isChecked)
|
||||
defaultDir = QFileInfo(fileNames.last()).absolutePath();
|
||||
}
|
||||
|
||||
std::vector<QString> fileNamesStd;
|
||||
std::vector<caf::FilePath> filePaths;
|
||||
for (QString filename : fileNames)
|
||||
{
|
||||
fileNamesStd.push_back(filename);
|
||||
filePaths.push_back(caf::FilePath(filename));
|
||||
}
|
||||
|
||||
app->setLastUsedDialogDirectory("ELM_PROPS", defaultDir);
|
||||
@ -71,7 +71,7 @@ void RicImportElementPropertyFeature::onActionTriggered(bool isChecked)
|
||||
|
||||
if (activeGmv->geoMechCase())
|
||||
{
|
||||
activeGmv->geoMechCase()->addElementPropertyFiles(fileNamesStd);
|
||||
activeGmv->geoMechCase()->addElementPropertyFiles(filePaths);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,9 @@ RimGeoMechCase::RimGeoMechCase(void)
|
||||
CAF_PDM_InitField(&m_frictionAngleDeg, "FrctionAngleDeg", 30.0, "Friction Angle [Deg]", "", "Used to calculate the SE:SFI result", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_elementPropertyFileNames, "ElementPropertyFileNames", "Element Property Files", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_elementPropertyFileNameUiSelection, "ElementPropertyFileNameSelection", "", "", "", "");
|
||||
m_elementPropertyFileNameUiSelection.xmlCapability()->disableIO();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -172,7 +175,12 @@ bool RimGeoMechCase::openGeoMechCase(std::string* errorMessage)
|
||||
|
||||
if (m_geoMechCaseData.notNull())
|
||||
{
|
||||
geoMechData()->femPartResults()->addElementPropertyFiles(m_elementPropertyFileNames);
|
||||
std::vector<QString> fileNames;
|
||||
for (const caf::FilePath& fileName : m_elementPropertyFileNames.v())
|
||||
{
|
||||
fileNames.push_back(fileName.path());
|
||||
}
|
||||
geoMechData()->femPartResults()->addElementPropertyFiles(fileNames);
|
||||
}
|
||||
|
||||
return fileOpenSuccess;
|
||||
@ -189,9 +197,9 @@ void RimGeoMechCase::updateFilePathsFromProjectPath(const QString& newProjectPat
|
||||
// Update filename and folder paths when opening project from a different file location
|
||||
m_caseFileName = RimTools::relocateFile(m_caseFileName(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths);
|
||||
|
||||
for (QString& fileName : m_elementPropertyFileNames.v())
|
||||
for (caf::FilePath& fileName : m_elementPropertyFileNames.v())
|
||||
{
|
||||
fileName = RimTools::relocateFile(fileName, newProjectPath, oldProjectPath, &foundFile, &searchedPaths);
|
||||
fileName = RimTools::relocateFile(fileName.path(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths);
|
||||
}
|
||||
|
||||
#if 0 // Output the search path for debugging
|
||||
@ -330,15 +338,15 @@ void RimGeoMechCase::setFormationNames(RimFormationNames* formationNames)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechCase::addElementPropertyFiles(const std::vector<QString>& fileNames)
|
||||
void RimGeoMechCase::addElementPropertyFiles(const std::vector<caf::FilePath>& fileNames)
|
||||
{
|
||||
std::vector<QString> newFileNames;
|
||||
|
||||
for (const QString& newFileNameToPossiblyAdd : fileNames)
|
||||
for (const caf::FilePath& newFileNameToPossiblyAdd : fileNames)
|
||||
{
|
||||
bool fileAlreadyAdded = false;
|
||||
|
||||
for (const QString& existingFileName : m_elementPropertyFileNames.v())
|
||||
for (const caf::FilePath& existingFileName : m_elementPropertyFileNames())
|
||||
{
|
||||
if (existingFileName == newFileNameToPossiblyAdd)
|
||||
{
|
||||
@ -348,7 +356,7 @@ void RimGeoMechCase::addElementPropertyFiles(const std::vector<QString>& fileNam
|
||||
}
|
||||
if (!fileAlreadyAdded)
|
||||
{
|
||||
newFileNames.push_back(newFileNameToPossiblyAdd);
|
||||
newFileNames.push_back(newFileNameToPossiblyAdd.path());
|
||||
m_elementPropertyFileNames.v().push_back(newFileNameToPossiblyAdd);
|
||||
}
|
||||
}
|
||||
@ -521,6 +529,23 @@ void RimGeoMechCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
|
||||
caseGroup->add(&m_frictionAngleDeg);
|
||||
|
||||
caf::PdmUiGroup* elmPropGroup = uiOrdering.addNewGroup("Element Properties");
|
||||
elmPropGroup->add(&m_elementPropertyFileNames);
|
||||
elmPropGroup->add(&m_elementPropertyFileNameUiSelection);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo> RimGeoMechCase::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
|
||||
if (fieldNeedingOptions == &m_elementPropertyFileNameUiSelection)
|
||||
{
|
||||
for (const caf::FilePath& fileName : m_elementPropertyFileNames.v())
|
||||
{
|
||||
options.push_back(caf::PdmOptionItemInfo(fileName.path(), fileName.path() , true, QIcon()));
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "RimCase.h"
|
||||
|
||||
#include "cafFilePath.h"
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
@ -69,7 +70,7 @@ public:
|
||||
|
||||
virtual void setFormationNames(RimFormationNames* formationNames) override;
|
||||
|
||||
void addElementPropertyFiles(const std::vector<QString>& filenames);
|
||||
void addElementPropertyFiles(const std::vector<caf::FilePath>& filenames);
|
||||
|
||||
// Fields:
|
||||
caf::PdmChildArrayField<RimGeoMechView*> geoMechViews;
|
||||
@ -80,16 +81,20 @@ private:
|
||||
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
|
||||
|
||||
virtual void updateFormationNamesData() override;
|
||||
|
||||
virtual void initAfterRead();
|
||||
virtual void initAfterRead() override;
|
||||
static QString subStringOfDigits(const QString& timeStepString, int numberOfDigitsToFind);
|
||||
|
||||
private:
|
||||
cvf::ref<RigGeoMechCaseData> m_geoMechCaseData;
|
||||
caf::PdmField<QString> m_caseFileName;
|
||||
caf::PdmField<double> m_cohesion;
|
||||
caf::PdmField<double> m_frictionAngleDeg;
|
||||
caf::PdmField<std::vector<QString> > m_elementPropertyFileNames;
|
||||
cvf::ref<RigGeoMechCaseData> m_geoMechCaseData;
|
||||
caf::PdmField<QString> m_caseFileName;
|
||||
caf::PdmField<double> m_cohesion;
|
||||
caf::PdmField<double> m_frictionAngleDeg;
|
||||
caf::PdmField<std::vector<caf::FilePath>> m_elementPropertyFileNames;
|
||||
caf::PdmField<std::vector<QString> > m_elementPropertyFileNameUiSelection;
|
||||
caf::PdmField<bool> m_closeElementPropertyFileCommand;
|
||||
caf::PdmField<bool> m_reloadElementPropertyFileCommand;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user