#include <HYDROData_River.h>
#include <HYDROData_Stream.h>
-#include <CAM_Application.h>
-#include <CAM_DataObject.h>
#include <CAM_Module.h>
#include <CAM_Study.h>
#include <LightApp_DataObject.h>
#include <LightApp_Study.h>
-#include <SUIT_DataObject.h>
#include <SUIT_DataBrowser.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Study.h>
static HYDROData_SequenceOfObjects myCopyingObjects;
+const int ENTRY_COLUMN = 2;
+
+
HYDROGUI_DataModel::HYDROGUI_DataModel( CAM_Module* theModule )
: LightApp_DataModel( theModule )
{
const int aStudyId = theStudy->id();
Data_DocError res = DocError_UnknownProblem;
- if( theFileList.count() == 2 )
+ if( theFileList.count() >= 2 )
{
QString aTmpDir = theFileList[0];
- QString aFileName = theFileList[1];
+ QString aDataFileName = theFileList[1];
+ QString aStatesFileName = theFileList.count() == 3 ? theFileList[2] : "";
myStudyURL = theURL;
- QString aFullPath = SUIT_Tools::addSlash( aTmpDir ) + aFileName;
+ QString aDataFullPath = SUIT_Tools::addSlash( aTmpDir ) + aDataFileName;
+ QString aStatesFullPath = aStatesFileName.isEmpty() ? "" : SUIT_Tools::addSlash( aTmpDir ) + aStatesFileName;
try
{
- res = HYDROData_Document::Load( (char*)aFullPath.toLatin1().constData(), aStudyId );
+ res = HYDROData_Document::Load( (char*)aDataFullPath.toLatin1().constData(), aStudyId );
}
catch(...)
{
module()->application()->putInfo( tr( "LOAD_ERROR" ) );
return false;
}
+
+ if( !aStatesFullPath.isEmpty() )
+ {
+ QFile aFile( aStatesFullPath );
+ if( aFile.open( QFile::ReadOnly ) )
+ {
+ myStates = aFile.readAll();
+ aFile.close();
+ }
+ }
}
// if the document open was successful, the data model update happens
LightApp_DataModel::save( theFileList );
QString aTmpDir;
- QString aFileName;
SUIT_ResourceMgr* resMgr = module()->application()->resourceMgr();
bool isMultiFile = false;
if( resMgr )
isMultiFile = resMgr->booleanValue( "Study", "multi_file", false );
- // save data to temporary files
+ // save module data to temporary files
LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( module()->application()->activeStudy() );
aTmpDir = aStudy->GetTmpDir( myStudyURL.toLatin1().constData(), isMultiFile ).c_str();
- aFileName = SUIT_Tools::file( myStudyURL, false ) + "_HYDRO.cbf";
-
- QString aFullPath = aTmpDir + aFileName;
- Data_DocError res = getDocument()->Save( (char*)aFullPath.toLatin1().constData() );
+
+ // save OCAF data to a temporary file
+ QString aDataFileName = SUIT_Tools::file( myStudyURL, false ) + "_HYDRO.cbf";
+ QString aDataFullPath = aTmpDir + aDataFileName;
+ Data_DocError res = getDocument()->Save( (char*)aDataFullPath.toLatin1().constData() );
if( res != DocError_OK )
{
module()->application()->putInfo( tr( "SAVE_ERROR" ) );
return false;
}
+ // save tree state data to a temporary file
+ LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( module()->application() );
+ QByteArray aStatesData = anApp->objectBrowser()->getOpenStates( ENTRY_COLUMN );
+ QString aStatesFileName = SUIT_Tools::file( myStudyURL, false ) + "_HYDRO_tree_states.txt";
+ QString aStatesFullPath = aTmpDir + aStatesFileName;
+ QFile aFile( aStatesFullPath );
+ if( aFile.open( QFile::WriteOnly ) )
+ {
+ aFile.write( aStatesData );
+ aFile.close();
+ }
+
+ // add temporary files to the list
theFileList.append( aTmpDir );
- theFileList.append( aFileName );
+ theFileList.append( aDataFileName );
+ theFileList.append( aStatesFileName );
return true;
}
HYDROGUI_DataModelSync aSync( aNewRootObj );
SUIT_DataObject* aRoot = root();
- if( !aRoot )
+ bool isNewDoc = aRoot==0;
+ if( isNewDoc )
aRoot = createRootModuleObject( aStudyRoot );
::synchronize < suitPtr, suitPtr, HYDROGUI_DataModelSync >
( aNewRootObj, aRoot, aSync );
+
+
+ if( !myStates.isEmpty() )
+ {
+ LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( module()->application() );
+ anApp->objectBrowser()->updateTree();
+ anApp->objectBrowser()->setOpenStates( myStates, ENTRY_COLUMN );
+ myStates.clear();
+ }
}
HYDROGUI_DataObject* HYDROGUI_DataModel::getDataObject( const Handle(HYDROData_Entity)& theModelObject )