1 #include "NewGeom_DataModel.h"
2 #include "NewGeom_Module.h"
4 #include <XGUI_Workshop.h>
6 #include <LightApp_Study.h>
7 #include <CAM_Application.h>
8 #include <SUIT_Tools.h>
13 NewGeom_DataModel::NewGeom_DataModel(NewGeom_Module* theModule)
14 : LightApp_DataModel(theModule), myModule(theModule)
18 NewGeom_DataModel::~NewGeom_DataModel()
22 bool NewGeom_DataModel::open(const QString& thePath, CAM_Study* theStudy, QStringList theFiles)
24 LightApp_DataModel::open( thePath, theStudy, theFiles );
25 if (theFiles.size() == 0)
28 QString aFile = theFiles.first();
30 SessionPtr aMgr = ModelAPI_Session::get();
31 aMgr->load(qPrintable(aFile));
32 myModule->setIsOpened(true);
37 bool NewGeom_DataModel::save(QStringList& theFiles)
39 LightApp_DataModel::save( theFiles );
40 XGUI_Workshop* aWorkShop = myModule->workshop();
41 std::list<std::string> aFileNames;
43 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( myModule->application()->activeStudy() );
44 std::string aTmpDir = aStudy->GetTmpDir(qPrintable(myStudyPath), true );
45 theFiles.append(QString(aTmpDir.c_str()));
47 aWorkShop->saveDocument(QString(aTmpDir.c_str()), aFileNames);
48 std::list<std::string>::iterator aIt;
49 for (aIt = aFileNames.begin(); aIt != aFileNames.end(); ++aIt) {
50 QString aName((*aIt).c_str());
51 aName.replace(QChar('\\'), QChar('/'));
52 int aN = aName.lastIndexOf('/');
53 theFiles.append(aName.right(aName.length() - aN - 1));
58 bool NewGeom_DataModel::saveAs(const QString& thePath, CAM_Study* theStudy, QStringList& theFiles)
60 myStudyPath = thePath;
61 return save(theFiles);
64 bool NewGeom_DataModel::close()
66 return LightApp_DataModel::close();
69 bool NewGeom_DataModel::create(CAM_Study* theStudy)
74 bool NewGeom_DataModel::isModified() const
76 SessionPtr aMgr = ModelAPI_Session::get();
77 return aMgr->isModified();
80 bool NewGeom_DataModel::isSaved() const
85 void NewGeom_DataModel::update(LightApp_DataObject* theObj, LightApp_Study* theStudy)