1 #include "NewGeom_DataModel.h"
2 #include "NewGeom_Module.h"
4 #include <XGUI_Workshop.h>
6 #include <ModelAPI_Session.h>
8 #include <LightApp_Study.h>
9 #include <CAM_Application.h>
10 #include <SUIT_Tools.h>
15 NewGeom_DataModel::NewGeom_DataModel(NewGeom_Module* theModule)
16 : LightApp_DataModel(theModule), myModule(theModule)
20 NewGeom_DataModel::~NewGeom_DataModel()
24 bool NewGeom_DataModel::open(const QString& thePath, CAM_Study* theStudy, QStringList theFiles)
26 LightApp_DataModel::open( thePath, theStudy, theFiles );
27 if (theFiles.size() == 0)
30 QString aFile = theFiles.first();
32 SessionPtr aMgr = ModelAPI_Session::get();
33 aMgr->load(qPrintable(aFile));
34 myModule->setIsOpened(true);
39 bool NewGeom_DataModel::save(QStringList& theFiles)
41 LightApp_DataModel::save( theFiles );
42 XGUI_Workshop* aWorkShop = myModule->workshop();
43 std::list<std::string> aFileNames;
45 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( myModule->application()->activeStudy() );
46 std::string aTmpDir = aStudy->GetTmpDir(qPrintable(myStudyPath), true );
47 theFiles.append(QString(aTmpDir.c_str()));
49 aWorkShop->saveDocument(QString(aTmpDir.c_str()), aFileNames);
50 std::list<std::string>::iterator aIt;
51 for (aIt = aFileNames.begin(); aIt != aFileNames.end(); ++aIt) {
52 QString aName((*aIt).c_str());
53 aName.replace(QChar('\\'), QChar('/'));
54 int aN = aName.lastIndexOf('/');
55 theFiles.append(aName.right(aName.length() - aN - 1));
60 bool NewGeom_DataModel::saveAs(const QString& thePath, CAM_Study* theStudy, QStringList& theFiles)
62 myStudyPath = thePath;
63 return save(theFiles);
66 bool NewGeom_DataModel::close()
68 return LightApp_DataModel::close();
71 bool NewGeom_DataModel::create(CAM_Study* theStudy)
76 bool NewGeom_DataModel::isModified() const
78 SessionPtr aMgr = ModelAPI_Session::get();
79 return aMgr->isModified();
82 bool NewGeom_DataModel::isSaved() const
87 void NewGeom_DataModel::update(LightApp_DataObject* theObj, LightApp_Study* theStudy)