#include "LIGHTGUI_DataModel.h"
#include "LIGHTGUI_DataObject.h"
-#include <SalomeApp_Study.h>
+#include <LightApp_Study.h>
#include <SUIT_Tools.h>
#include <SUIT_DataObjectIterator.h>
+#include <CAM_Module.h>
+#include <CAM_Application.h>
#include <qstring.h>
#include <qfile.h>
+#include <vector.h>
+#include <string.h>
+
//=================================================================================
// function : LIGHTGUI_DataModel()
// purpose : constructor
//=================================================================================
LIGHTGUI_DataModel::LIGHTGUI_DataModel ( CAM_Module* theModule )
- : SalomeApp_DataModel( theModule ),
+ : LightApp_DataModel( theModule ),
myFileName( "" ),
myStudyURL( "" )
{
//=================================================================================
bool LIGHTGUI_DataModel::open ( const QString& theURL, CAM_Study* study )
{
- SalomeApp_Study* aDoc = dynamic_cast<SalomeApp_Study*>( study );
+ LightApp_Study* aDoc = dynamic_cast<LightApp_Study*>( study );
if ( !aDoc )
return false;
- SalomeApp_DataModel::open( theURL, study );
+ LightApp_DataModel::open( theURL, aDoc );
- // Get list of files, created for this module by SalomeApp_Engine_i::Load().
- std::vector<std::string> aListOfFiles = GetListOfFiles();
+ // Get list of files, created for this module by LightApp_Engine_i::Load().
+ std::vector<std::string> aListOfFiles = aDoc->GetListOfFiles();
// The first list item contains path to a temporary
// directory, where the persistent files was placed
QString aTmpDir ( aListOfFiles[0] );
// This module operates with a single persistent file
- if ( aListOfFiles.size() == 2 ) {
- myStudyURL = theURL;
- QString aFileName ( aListOfFiles[1] );
- QString aFullPath = SUIT_Tools::addSlash( aTmpDir ) + aFileName;
+ if ( aListOfFiles.size() == 2 ) {
+ myStudyURL = theURL;
+ QString aFileName ( aListOfFiles[1] );
+ QString aFullPath = SUIT_Tools::addSlash( aTmpDir ) + aFileName;
- loadFile( aFullPath, study );
- }
+ loadFile( aFullPath, aDoc );
+ }
// Remove the files and temporary directory, created
- // for this module by SalomeApp_Engine_i::Load()
+ // for this module by LightApp_Engine_i::Load()
bool isMultiFile = false; // TODO: decide, how to access this parameter
- RemoveTemporaryFiles( isMultiFile );
+ aDoc->RemoveTemporaryFiles( isMultiFile );
}
return true;
// 1. Save data to temporary files
bool isMultiFile = false; // TODO: decide, how to access this parameter
- QString aTmpDir ( SalomeApp_DataModel::GetTmpDir( myStudyURL.latin1(), isMultiFile ) );
+ LightApp_DataModel::save();
+
+ LightApp_Study* study = dynamic_cast<LightApp_Study*>( module()->application()->activeStudy() );
+
+ QString aTmpDir = study->GetTmpDir( myStudyURL.latin1(), isMultiFile );
QString aFileName = SUIT_Tools::file( myStudyURL, false ) + "_LIGHTGUI.txt";
QString aFullPath = aTmpDir + aFileName;
dumpFile( aFullPath );
std::vector<std::string> aListOfFiles ( 2 );
aListOfFiles[0] = aTmpDir.latin1();
aListOfFiles[1] = aFileName.latin1();
- SetListOfFiles( aListOfFiles );
+ study->SetListOfFiles( aListOfFiles );
return true;
}
//=================================================================================
bool LIGHTGUI_DataModel::close()
{
+ LightApp_DataModel::close();
return true;
}
// function : update()
// purpose : updates data model
//=================================================================================
-void LIGHTGUI_DataModel::update ( SalomeApp_DataObject*, SalomeApp_Study* )
+void LIGHTGUI_DataModel::update ( LightApp_DataObject*, LightApp_Study* )
{
// Nothing to do here: we always keep the data tree in the up-to-date state
- // The only goal of this method is to hide default behavior from SalomApp_DataModel
+ // The only goal of this method is to hide default behavior from LightApp_DataModel
return;
}
{
if ( !studyRoot )
return;
-
+
LIGHTGUI_ModuleObject* modelRoot = new LIGHTGUI_ModuleObject( this, studyRoot );
- CAM_DataObject* aParaObject, aLineObject;
+ LIGHTGUI_DataObject* aParaObject;
+ LIGHTGUI_DataObject* aLineObject;
aParaObject = new LIGHTGUI_DataObject ( "", modelRoot );
for ( ; it1 != it2; ++it1 ) {
if ( (*it1).stripWhiteSpace().isEmpty() ) {
aParaObject = new LIGHTGUI_DataObject ( *it1, modelRoot );
- }
+ }
else {
aLineObject = new LIGHTGUI_DataObject ( *it1, aParaObject );
}