X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FNewGeom%2FNewGeom_DataModel.cpp;h=3b494373ff98b1190a2c8f83ca88cf7727db2103;hb=24f1ad2fd93475684288c899fb4fffcf05f6c21e;hp=371fe7a4bc854fa2fb27589d9356269057f04a0d;hpb=18b02d3f18f6db1fb45d8510fdcdf064c17164d3;p=modules%2Fshaper.git diff --git a/src/NewGeom/NewGeom_DataModel.cpp b/src/NewGeom/NewGeom_DataModel.cpp index 371fe7a4b..3b494373f 100644 --- a/src/NewGeom/NewGeom_DataModel.cpp +++ b/src/NewGeom/NewGeom_DataModel.cpp @@ -1,30 +1,64 @@ - #include "NewGeom_DataModel.h" +#include "NewGeom_Module.h" + +#include + +#include +#include +#include +#include -NewGeom_DataModel::NewGeom_DataModel( CAM_Module* theModule ) - : LightApp_DataModel(theModule) + +NewGeom_DataModel::NewGeom_DataModel(NewGeom_Module* theModule) + : LightApp_DataModel(theModule), myModule(theModule) { } - + NewGeom_DataModel::~NewGeom_DataModel() { } -bool NewGeom_DataModel::open( const QString& thePath, CAM_Study* theStudy, QStringList theFiles ) +bool NewGeom_DataModel::open(const QString& thePath, CAM_Study* theStudy, QStringList theFiles) { + LightApp_DataModel::open( thePath, theStudy, theFiles ); + if (theFiles.size() == 0) + return false; + + QString aFile = theFiles.first(); + + SessionPtr aMgr = ModelAPI_Session::get(); + aMgr->load(qPrintable(aFile)); + myModule->setIsOpened(true); + myStudyPath = aFile; return true; } -bool NewGeom_DataModel::save( QStringList& theFiles ) +bool NewGeom_DataModel::save(QStringList& theFiles) { + LightApp_DataModel::save( theFiles ); + XGUI_Workshop* aWorkShop = myModule->workshop(); + std::list aFileNames; + + LightApp_Study* aStudy = dynamic_cast( myModule->application()->activeStudy() ); + std::string aTmpDir = aStudy->GetTmpDir(qPrintable(myStudyPath), true ); + theFiles.append(QString(aTmpDir.c_str())); + + aWorkShop->saveDocument(QString(aTmpDir.c_str()), aFileNames); + std::list::iterator aIt; + for (aIt = aFileNames.begin(); aIt != aFileNames.end(); ++aIt) { + QString aName((*aIt).c_str()); + aName.replace(QChar('\\'), QChar('/')); + int aN = aName.lastIndexOf('/'); + theFiles.append(aName.right(aName.length() - aN - 1)); + } return true; } -bool NewGeom_DataModel::saveAs( const QString& thePath, CAM_Study* theStudy, QStringList& theFiles ) +bool NewGeom_DataModel::saveAs(const QString& thePath, CAM_Study* theStudy, QStringList& theFiles) { myStudyPath = thePath; - return save( theFiles ); + return save(theFiles); } bool NewGeom_DataModel::close() @@ -32,21 +66,22 @@ bool NewGeom_DataModel::close() return LightApp_DataModel::close(); } -bool NewGeom_DataModel::create( CAM_Study* theStudy ) +bool NewGeom_DataModel::create(CAM_Study* theStudy) { return true; } bool NewGeom_DataModel::isModified() const { - return false; + SessionPtr aMgr = ModelAPI_Session::get(); + return aMgr->isModified(); } bool NewGeom_DataModel::isSaved() const { - return true; + return !isModified(); } -void NewGeom_DataModel::update( LightApp_DataObject* theObj, LightApp_Study* theStudy ) +void NewGeom_DataModel::update(LightApp_DataObject* theObj, LightApp_Study* theStudy) { }