1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 #include "NewGeom_DataModel.h"
4 #include "NewGeom_Module.h"
6 #include <XGUI_Workshop.h>
8 #include <ModelAPI_Session.h>
10 #include <LightApp_Study.h>
11 #include <CAM_Application.h>
12 #include <SUIT_Tools.h>
17 NewGeom_DataModel::NewGeom_DataModel(NewGeom_Module* theModule)
18 : LightApp_DataModel(theModule), myModule(theModule)
22 NewGeom_DataModel::~NewGeom_DataModel()
26 bool NewGeom_DataModel::open(const QString& thePath, CAM_Study* theStudy, QStringList theFiles)
28 LightApp_DataModel::open( thePath, theStudy, theFiles );
29 if (theFiles.size() == 0)
32 QString aFile = theFiles.first();
34 SessionPtr aMgr = ModelAPI_Session::get();
35 aMgr->load(qPrintable(aFile));
36 myModule->setIsOpened(true);
41 bool NewGeom_DataModel::save(QStringList& theFiles)
43 LightApp_DataModel::save( theFiles );
44 XGUI_Workshop* aWorkShop = myModule->workshop();
45 std::list<std::string> aFileNames;
47 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( myModule->application()->activeStudy() );
48 std::string aTmpDir = aStudy->GetTmpDir(qPrintable(myStudyPath), true );
49 theFiles.append(QString(aTmpDir.c_str()));
51 aWorkShop->saveDocument(QString(aTmpDir.c_str()), aFileNames);
52 std::list<std::string>::iterator aIt;
53 for (aIt = aFileNames.begin(); aIt != aFileNames.end(); ++aIt) {
54 QString aName((*aIt).c_str());
55 aName.replace(QChar('\\'), QChar('/'));
56 int aN = aName.lastIndexOf('/');
57 theFiles.append(aName.right(aName.length() - aN - 1));
62 bool NewGeom_DataModel::saveAs(const QString& thePath, CAM_Study* theStudy, QStringList& theFiles)
64 myStudyPath = thePath;
65 return save(theFiles);
68 bool NewGeom_DataModel::close()
70 myModule->workshop()->closeDocument();
71 return LightApp_DataModel::close();
74 bool NewGeom_DataModel::create(CAM_Study* theStudy)
79 bool NewGeom_DataModel::isModified() const
81 SessionPtr aMgr = ModelAPI_Session::get();
82 return aMgr->isModified();
85 bool NewGeom_DataModel::isSaved() const
90 void NewGeom_DataModel::update(LightApp_DataObject* theObj, LightApp_Study* theStudy)