Several refactoring of well import wizard

Keep original copy of RimWellPathImport object as Xml instead of copy
using PdmObjectGroup
Added destructor for cleanup of wizard pages
Simplified info communication between pages
This commit is contained in:
Magne Sjaastad
2015-08-12 18:44:03 +02:00
parent c2fe5f3a16
commit 3c9e1bab5c
3 changed files with 219 additions and 157 deletions

View File

@@ -72,6 +72,7 @@
#include "cafSelectionManager.h"
#include "cvfTimer.h"
#include "cafPdmDefaultObjectFactory.h"
//==================================================================================================
@@ -1981,32 +1982,24 @@ void RiuMainWindow::slotImportWellPathsFromSSIHub()
wellPathsFolderPath += "_wellpaths";
QDir::root().mkpath(wellPathsFolderPath);
RimWellPathImport* copyOfWellPathImport = NULL;
// Create a copy of the object
// MODTODO: Verify that behaviour is correct
{
caf::PdmObjectGroup objGroup;
objGroup.addObject(app->project()->wellPathImport);
// Keep a copy of the import settings, and restore if cancel is pressed in the import wizard
QString copyOfOriginalObject = xmlObj(app->project()->wellPathImport())->writeObjectToXmlString();
std::vector<caf::PdmPointer<RimWellPathImport> > typedObjects;
objGroup.createCopyByType(&typedObjects, caf::PdmDefaultObjectFactory::instance());
if (typedObjects.size() == 1)
{
copyOfWellPathImport = typedObjects[0];
}
}
RiuWellImportWizard wellImportwizard(app->preferences()->ssihubAddress, wellPathsFolderPath, copyOfWellPathImport, this);
RimWellPathImport* wellPathObjectToBeDeleted = NULL;
RiuWellImportWizard wellImportwizard(app->preferences()->ssihubAddress, wellPathsFolderPath, app->project()->wellPathImport(), this);
// Get password/username from application cache
{
QString ssihubUsername = app->cacheDataObject("ssihub_username").toString();
QString ssihubPassword = app->cacheDataObject("ssihub_password").toString();
#ifdef _DEBUG
// Valid credentials for ssihubfake received in mail from H<>kon
ssihubUsername = "admin";
ssihubPassword = "resinsight";
#endif
wellImportwizard.setCredentials(ssihubUsername, ssihubPassword);
}
@@ -2019,18 +2012,13 @@ void RiuMainWindow::slotImportWellPathsFromSSIHub()
app->project()->createDisplayModelAndRedrawAllViews();
}
wellPathObjectToBeDeleted = app->project()->wellPathImport;
app->project()->wellPathImport = copyOfWellPathImport;
app->setCacheDataObject("ssihub_username", wellImportwizard.field("username"));
app->setCacheDataObject("ssihub_password", wellImportwizard.field("password"));
}
else
{
wellPathObjectToBeDeleted = copyOfWellPathImport;
xmlObj(app->project()->wellPathImport())->readObjectFromXmlString(copyOfOriginalObject, caf::PdmDefaultObjectFactory::instance());
}
delete wellPathObjectToBeDeleted;
}
//--------------------------------------------------------------------------------------------------