diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 51816a9c01..3c6c144e74 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -351,7 +351,6 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi { //printf("Create well path collection for oil field %i in loadProject.\n", oilFieldIdx); oilField->wellPathCollection = new RimWellPathCollection(); - oilField->wellPathCollection->setProject(m_project); } if (oilField->wellPathCollection) oilField->wellPathCollection->readWellPathFiles(); @@ -474,7 +473,6 @@ void RiaApplication::addWellPathsToModel(QList wellPathFilePaths) { //printf("Create well path collection.\n"); oilField->wellPathCollection = new RimWellPathCollection(); - oilField->wellPathCollection->setProject(m_project); m_project->updateConnectedEditors(); } @@ -497,7 +495,6 @@ void RiaApplication::addWellLogsToModel(const QList& wellLogFilePaths) if (oilField->wellPathCollection == NULL) { oilField->wellPathCollection = new RimWellPathCollection(); - oilField->wellPathCollection->setProject(m_project); m_project->updateConnectedEditors(); } diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 58226c7018..da7e75beb5 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -306,7 +306,6 @@ void RimProject::initAfterRead() { RimOilField* oilField = oilFields[oilFieldIdx]; if (oilField == NULL || oilField->wellPathCollection == NULL) continue; - oilField->wellPathCollection->setProject(this); } } diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.cpp b/ApplicationCode/ProjectDataModel/RimWellPath.cpp index b813e3a6a8..e6d0797d55 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPath.cpp @@ -91,7 +91,6 @@ RimWellPath::RimWellPath() m_wellLogFile.uiCapability()->setUiHidden(true); m_wellPath = NULL; - m_project = NULL; } @@ -148,7 +147,9 @@ RivWellPathPartMgr* RimWellPath::partMgr() { if (m_wellPathPartMgr.isNull()) { - m_wellPathPartMgr = new RivWellPathPartMgr(m_wellPathCollection, this); + RimWellPathCollection* wpColl; + this->firstAnchestorOrThisOfType(wpColl); + if (wpColl) m_wellPathPartMgr = new RivWellPathPartMgr(wpColl, this); } return m_wellPathPartMgr.p(); @@ -161,7 +162,10 @@ RivWellPathPartMgr* RimWellPath::partMgr() void RimWellPath::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { partMgr()->scheduleGeometryRegen(); - if (m_project) m_project->createDisplayModelAndRedrawAllViews(); + + RimProject* proj; + this->firstAnchestorOrThisOfType(proj); + if (proj) proj->createDisplayModelAndRedrawAllViews(); } @@ -177,7 +181,7 @@ caf::PdmFieldHandle* RimWellPath::objectToggleField() //-------------------------------------------------------------------------------------------------- /// Read JSON or ascii file containing well path data //-------------------------------------------------------------------------------------------------- -bool RimWellPath::readWellPathFile(QString* errorMessage) +bool RimWellPath::readWellPathFile(QString* errorMessage, RifWellPathAsciiFileReader* asciiReader) { QFileInfo fileInf(filepath()); @@ -189,7 +193,7 @@ bool RimWellPath::readWellPathFile(QString* errorMessage) } else { - this->readAsciiWellPathFile(); + this->readAsciiWellPathFile(asciiReader); } return true; @@ -254,9 +258,11 @@ void RimWellPath::readJsonWellPathFile() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellPath::readAsciiWellPathFile() +void RimWellPath::readAsciiWellPathFile(RifWellPathAsciiFileReader* asciiReader) { - RifWellPathAsciiFileReader::WellData wpData = m_wellPathCollection->asciiFileReader()->readWellData(filepath(), wellPathIndexInFile()); + CVF_ASSERT(asciiReader); + + RifWellPathAsciiFileReader::WellData wpData = asciiReader->readWellData(filepath(), wellPathIndexInFile()); this->name = wpData.m_name; setWellPathGeometry(wpData.m_wellPathGeometry.p()); diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.h b/ApplicationCode/ProjectDataModel/RimWellPath.h index 18e814d095..2d38dd0917 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.h +++ b/ApplicationCode/ProjectDataModel/RimWellPath.h @@ -49,8 +49,6 @@ public: RimWellPath(); virtual ~RimWellPath(); - void setProject(RimProject* project) { m_project = project; } - void setCollection(RimWellPathCollection* collection) { m_wellPathCollection = collection; } void setLogFileInfo(RimWellLogFile* logFileInfo); virtual caf::PdmFieldHandle* userDescriptionField(); @@ -74,7 +72,7 @@ public: RigWellPath* wellPathGeometry() { return m_wellPath.p(); } RivWellPathPartMgr* partMgr(); - bool readWellPathFile(QString * errorMessage); + bool readWellPathFile(QString * errorMessage, RifWellPathAsciiFileReader* asciiReader); void updateFilePathsFromProjectPath(); @@ -83,7 +81,7 @@ private: void setWellPathGeometry(RigWellPath* wellPathModel) { m_wellPath = wellPathModel; } void readJsonWellPathFile(); - void readAsciiWellPathFile(); + void readAsciiWellPathFile(RifWellPathAsciiFileReader* asciiReader); QString surveyType() { return m_surveyType; } void setSurveyType(QString surveyType); @@ -104,6 +102,4 @@ private: cvf::ref m_wellPath; cvf::ref m_wellPathPartMgr; - caf::PdmPointer m_wellPathCollection; - RimProject* m_project; }; diff --git a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp index b2459dd78d..d48ec74914 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp @@ -82,7 +82,6 @@ RimWellPathCollection::RimWellPathCollection() wellPaths.uiCapability()->setUiHidden(true); m_wellPathCollectionPartManager = new RivWellPathCollectionPartMgr(this); - m_project = NULL; m_asciiFileReader = new RifWellPathAsciiFileReader; } @@ -107,20 +106,6 @@ void RimWellPathCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedF } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimWellPathCollection::setProject( RimProject* project ) -{ - m_project = project; - for (size_t wellPathIdx = 0; wellPathIdx < wellPaths.size(); wellPathIdx++) - { - wellPaths[wellPathIdx]->setProject(m_project); - wellPaths[wellPathIdx]->setCollection(this); - } -} - - //-------------------------------------------------------------------------------------------------- /// Read JSON files containing well path data //-------------------------------------------------------------------------------------------------- @@ -133,7 +118,7 @@ void RimWellPathCollection::readWellPathFiles() if (!wellPaths[wpIdx]->filepath().isEmpty()) { QString errorMessage; - if (!wellPaths[wpIdx]->readWellPathFile(&errorMessage)) + if (!wellPaths[wpIdx]->readWellPathFile(&errorMessage, this->asciiFileReader())) { QMessageBox::warning(RiuMainWindow::instance(), "File open error", @@ -203,8 +188,6 @@ void RimWellPathCollection::addWellPaths( QStringList filePaths ) if (fi.suffix().compare("json") == 0) { RimWellPath* wellPath = new RimWellPath(); - wellPath->setProject(m_project); - wellPath->setCollection(this); wellPath->filepath = filePath; wellPathArray.push_back(wellPath); } @@ -215,8 +198,6 @@ void RimWellPathCollection::addWellPaths( QStringList filePaths ) for (size_t i = 0; i < wellPathCount; ++i) { RimWellPath* wellPath = new RimWellPath(); - wellPath->setProject(m_project); - wellPath->setCollection(this); wellPath->filepath = filePath; wellPath->wellPathIndexInFile = static_cast(i); wellPathArray.push_back(wellPath); @@ -239,7 +220,7 @@ void RimWellPathCollection::readAndAddWellPaths(std::vector& wellP for (size_t wpIdx = 0; wpIdx < wellPathArray.size(); wpIdx++) { RimWellPath* wellPath = wellPathArray[wpIdx]; - wellPath->readWellPathFile(NULL); + wellPath->readWellPathFile(NULL, this->asciiFileReader()); progress.setProgressDescription(QString("Reading file %1").arg(wellPath->name)); @@ -249,7 +230,7 @@ void RimWellPathCollection::readAndAddWellPaths(std::vector& wellP { existingWellPath->filepath = wellPath->filepath; existingWellPath->wellPathIndexInFile = wellPath->wellPathIndexInFile; - existingWellPath->readWellPathFile(NULL); + existingWellPath->readWellPathFile(NULL, this->asciiFileReader()); delete wellPath; } @@ -279,7 +260,6 @@ void RimWellPathCollection::addWellLogs(const QStringList& filePaths) if (!wellPath) { wellPath = new RimWellPath(); - wellPath->setCollection(this); wellPaths.push_back(wellPath); } @@ -322,7 +302,9 @@ caf::PdmFieldHandle* RimWellPathCollection::objectToggleField() void RimWellPathCollection::scheduleGeometryRegenAndRedrawViews() { m_wellPathCollectionPartManager->scheduleGeometryRegen(); - if (m_project) m_project->createDisplayModelAndRedrawAllViews(); + RimProject* proj; + this->firstAnchestorOrThisOfType(proj); + if (proj) proj->createDisplayModelAndRedrawAllViews(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellPathCollection.h b/ApplicationCode/ProjectDataModel/RimWellPathCollection.h index 27f6b661d5..19f4cbe079 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathCollection.h +++ b/ApplicationCode/ProjectDataModel/RimWellPathCollection.h @@ -102,7 +102,6 @@ private: void readAndAddWellPaths(std::vector& wellPathArray); void sortWellsByName(); - caf::PdmPointer m_project; cvf::ref m_wellPathCollectionPartManager; RifWellPathAsciiFileReader* m_asciiFileReader;