: SALOME_StudyEditor()
{
_salomeApp = salomeApp;
- updateActiveStudy();
-}
-
-/**
- * This updates the editor with the current active study. If the
- * active study id is identical to the study id currently associated
- * to this object, then no update is performed.
- */
-int SALOME_AppStudyEditor::updateActiveStudy() {
- int activeStudyId = SALOME_AppStudyEditor::getActiveStudyId(_salomeApp);
- if ( activeStudyId != this->getStudyId() ) {
- this->setStudyById(activeStudyId);
- }
- return activeStudyId;
-}
-
-// GUI context only
-int SALOME_AppStudyEditor::getActiveStudyId(SalomeApp_Application * salomeApp) {
- SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*> (salomeApp->activeStudy());
- _PTR(Study) aCStudy = appStudy->studyDS();
- int studyId = aCStudy->StudyId();
- return studyId;
}
SALOMEDS::SObject_ptr SALOME_AppStudyEditor::IObjectToSObject(const Handle(SALOME_InteractiveObject)& iobject) {
class SALOMEGUIHELPERS_EXPORT SALOME_AppStudyEditor: public SALOME_StudyEditor {
public:
SALOME_AppStudyEditor(SalomeApp_Application * salomeApp);
- int updateActiveStudy();
SALOMEDS::SObject_ptr IObjectToSObject(const Handle(SALOME_InteractiveObject)& iobject);
SALOME_StudyEditor::SObjectList * getSelectedObjects();
- static int getActiveStudyId(SalomeApp_Application * salomeApp);
-
private:
SalomeApp_Application * _salomeApp;
* process, i.e. the SALOME_SessionServer embedding the
* SalomeApp_Application.
*/
- int getActiveStudyId() {
+ bool isActiveStudy() {
SALOME::Session_var aSession = KERNEL::getSalomeSession();
if ( CORBA::is_nil(aSession) ) {
INFOS("ERR: can't request for active study because the session is NULL");
- return -1;
+ return false;
}
- return aSession->GetActiveStudyId();
+ return true;
}
/**
* defined in the SALOME session, returns null otherwise.
*/
SALOMEDS::Study_ptr getActiveStudy() {
- return KERNEL::getStudyById(getActiveStudyId());
+ if ( isActiveStudy() )
+ return KERNEL::getStudy();
}
// retrieve the SALOMEDS::Study servant first and the to
// request this servant to get the SObject given its entry.
//
- _PTR(Study) studyClient = appStudy->studyDS();
- SALOMEDS::Study_var study = KERNEL::getStudyManager()->GetStudyByID(studyClient->StudyId());
+ SALOMEDS::Study_var study = KERNEL::getStudy();
SALOMEDS::SObject_ptr sobject = study->FindObjectID(iobject->getEntry());
return sobject;
}
// of the attribute of a SObject is a CORBA servant that handles the
// data to work with
SALOMEGUIHELPERS_EXPORT SALOMEDS::Study_ptr getActiveStudy();
- SALOMEGUIHELPERS_EXPORT int getActiveStudyId();
+ SALOMEGUIHELPERS_EXPORT bool isActiveStudy();
// Another way to get the active study (to be converted in
// SALOMEDS::Study):
void StandardApp_Module::createStudyComponent(SUIT_Study* theStudy) {
SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
- CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
- SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
- SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(theStudy->id());
+ CORBA::Object_var aStudyObject = aNamingService->Resolve("/Study");
+ SALOMEDS::Study_var aDSStudy = SALOMEDS::Study::_narrow(aStudyObject);
SALOMEDS::SComponent_var aFather = aDSStudy->FindComponent(QCHARSTAR(moduleName()));
if (aFather->_is_nil())
"....................",
"...................."};
-int LightApp_Application::lastStudyId = 0;
-
// Markers used to parse array with dockable windows and toolbars state.
// For more details please see the qdockarealayout.cpp && qtoolbararealayout.cpp
// in the Qt source code.
}
}
-/*!
- \return last global id of study
-*/
-int LightApp_Application::studyId()
-{
- return LightApp_Application::lastStudyId;
-}
-
/*!Create new instance of LightApp_Application.*/
extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication()
{
/*!
Gets window.
\param flag - key for window
- \param studyId - study id
Flag used how identificator of window in windows list.
*/
-QWidget* LightApp_Application::getWindow( const int flag, const int )
+QWidget* LightApp_Application::getWindow( const int flag)
{
QWidget* wid = dockWindow( flag );
if ( !wid )
*/
SUIT_Study* LightApp_Application::createNewStudy()
{
- LightApp_Application::lastStudyId++;
-
LightApp_Study* aStudy = new LightApp_Study( this );
// Set up processing of major study-related events
virtual SUIT_ViewManager* createViewManager( const QString& vmType, QWidget* w );
virtual SUIT_ViewManager* createViewManager( SUIT_ViewModel* );
- QWidget* getWindow( const int, const int = -1 );
+ QWidget* getWindow( const int );
QWidget* dockWindow( const int ) const;
void removeDockWindow( const int );
void insertDockWindow( const int, QWidget* );
void setDefaultStudyName( const QString& theName );
- static int studyId();
-
virtual bool event( QEvent* );
virtual bool checkDataObject( LightApp_DataObject* theObj );
static LightApp_Preferences* _prefs_;
- static int lastStudyId;
QStringList myUserWmTypes;
};
*/
bool LightApp_Study::createDocument( const QString& theStr )
{
- setStudyName( QString( "Study%1" ).arg( LightApp_Application::studyId() ) );
-
// create myRoot
setRoot( new LightApp_RootObject( this ) );
</message>
<message>
<source>STUDYCLOSE_DESCRIPTION</source>
- <translation>You already have an active study in your session. It has to be closed before working with another study.</translation>
+ <translation>The current study has unsaved changes. Would you like to save before closing it?</translation>
</message>
<message>
<source>APPCLOSE_SAVE</source>
- <translation>&Save && Close</translation>
+ <translation>&Yes</translation>
</message>
<message>
<source>APPCLOSE_CLOSE</source>
- <translation>Close &w/o saving</translation>
+ <translation>&No</translation>
</message>
<message>
<source>APPCLOSE_CANCEL</source>
</message>
<message>
<source>STUDYCLOSE_DESCRIPTION</source>
- <translation>Une étude est déjà ouverte. Elle doit être fermée avant d'en ouvrir une autre.</translation>
+ <translation>Une étude a des modifications non enregistrées. Voulez-vous les sauvegarder avant de fermer?</translation>
</message>
<message>
<source>APPCLOSE_SAVE</source>
- <translation>&Sauvegarder && Fermer</translation>
+ <translation>&Oui</translation>
</message>
<message>
<source>APPCLOSE_CLOSE</source>
- <translation>&Fermer sans sauvegarder</translation>
+ <translation>&Non</translation>
</message>
<message>
<source>APPCLOSE_CANCEL</source>
</message>
<message>
<source>STUDYCLOSE_DESCRIPTION</source>
- <translation>既存のスタディを閉じる必要があります。閉じますか?
-</translation>
+ <translation type="unfinished">The current study has unsaved changes. Would you like to save before closing it?</translation>
</message>
<message>
<source>APPCLOSE_SAVE</source>
- <translation>保存して閉じる(&S)</translation>
+ <translation>はい(&Y)</translation>
</message>
<message>
<source>APPCLOSE_CLOSE</source>
- <translation>保存せずに閉じる(&C)</translation>
+ <translation>いいえ(&N)</translation>
</message>
<message>
<source>APPCLOSE_CANCEL</source>
SALOME GUI modules.
*/
-PyModuleHelper::InterpMap PyModuleHelper::myInterpMap;
LightApp_Module* PyModuleHelper::myInitModule = 0;
/*!
/*!
\brief Initialize python subinterpreter (one per study).
\internal
- \param studyId study ID
*/
-void PyModuleHelper::initInterp( int studyId )
+void PyModuleHelper::initInterp()
{
FuncMsg fmsg( "--- PyModuleHelper::initInterp()" );
- // check study Id
- if ( !studyId ) {
- // Error! Study Id must not be 0!
- myInterp = 0;
- return;
- }
-
QMutexLocker ml( &myInitMutex );
- // try to find the subinterpreter
- if ( myInterpMap.contains( studyId ) ) {
- // found!
- myInterp = myInterpMap[ studyId ];
- return;
- }
-
myInterp = new SALOME_PYQT_PyInterp();
myInterp->initialize();
- myInterpMap[ studyId ] = myInterp;
#ifndef GUI_DISABLE_CORBA
if ( !SUIT_PYTHON::initialized ) {
}
// ... then call a method
int embedded = 1;
- PyObjWrapper aRes( PyObject_CallMethod( aMod, (char*)"salome_init", (char*)"ii", studyId, embedded ) );
+ PyObjWrapper aRes( PyObject_CallMethod( aMod, (char*)"salome_init", (char*)"ii", embedded ) );
if ( !aRes ) {
// Error!
PyErr_Print();
LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( app->activeStudy() );
if ( !aStudy )
return;
- int aStudyId = aStudy ? aStudy->id() : 0;
// initialize Python subinterpreter (on per study) and put it in <myInterp> variable
- initInterp( aStudyId );
+ initInterp();
if ( !myInterp )
return; // Error
// get study Id
LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( study );
- int aStudyId = aStudy ? aStudy->id() : 0;
+ if ( !aStudy )
+ return;
// initialize Python subinterpreter (on per study) and put it in <myInterp> variable
- initInterp( aStudyId );
+ initInterp();
if ( !myInterp ) {
myLastActivateStatus = false;
return; // Error
// get study Id
LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( study );
- int aStudyId = aStudy ? aStudy->id() : 0;
+ if ( !aStudy )
+ return;
// initialize Python subinterpreter (on per study) and put it in <myInterp> variable
- initInterp( aStudyId );
+ initInterp();
if ( !myInterp ) {
myLastActivateStatus = false;
return; // Error
// Get study Id
// get study Id
LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( theStudy );
- int aStudyId = aStudy ? aStudy->id() : 0;
+ if ( !aStudy )
+ return;
// check that Python subinterpreter is initialized and Python module is imported
if ( !myInterp || !myPyModule ) {
}
// then call Python module's deactivate() method
if ( PyObject_HasAttrString( myPyModule , (char*)"closeStudy" ) ) {
- PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"closeStudy", (char*)"i", aStudyId ) );
+ PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"closeStudy", (char*)"i" ) );
if( !res ) {
PyErr_Print();
}
// get study Id
LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( study );
- int id = aStudy ? aStudy->id() : 0;
-
- fmsg.message( QString( "study id = %1" ).arg( id ) );
+ if ( !aStudy )
+ return;
// initialize Python subinterpreter (on per study) and put it in <myInterp> variable
- initInterp( id );
+ initInterp();
if ( !myInterp )
return; // Error
// call Python module's activeStudyChanged() method
if ( PyObject_HasAttrString( myPyModule, (char*)"activeStudyChanged" ) ) {
- PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"activeStudyChanged", (char*)"i", id ) );
+ PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"activeStudyChanged", (char*)"i" ) );
if( !res ) {
PyErr_Print();
}
return; // Error
if ( PyObject_HasAttrString( myPyModule, (char*)"OnGUIEvent" ) ) {
- PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"OnGUIEvent", (char*)"i", id ) );
+ PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"OnGUIEvent", (char*)"i" ) );
if( !res ) {
PyErr_Print();
}
class XmlHandler;
class InitLocker;
- typedef QMap<int, PyInterp_Interp*> InterpMap;
-
- static InterpMap myInterpMap; //!< study to Python subinterpreter map
static LightApp_Module* myInitModule; //!< Python GUI being initialized (not zero only during the initialization)
LightApp_Module* myModule; //!< GUI module
void onObjectBrowserClicked(SUIT_DataObject*, int);
private:
- void initInterp( int );
+ void initInterp();
void importModule();
void setWorkSpace();
\brief updateSelection update selection flag (not used)
\sa getActiveStudy()
*/
-void SalomePyQt::updateObjBrowser( const int studyId, bool updateSelection )
+void SalomePyQt::updateObjBrowser( bool updateSelection )
{
class TEvent: public SALOME_Event
{
- int myStudyId;
bool myUpdateSelection;
public:
- TEvent( const int studyId, bool updateSelection )
- : myStudyId( studyId ), myUpdateSelection( updateSelection ) {}
+ TEvent( bool updateSelection )
+ : myUpdateSelection( updateSelection ) {}
virtual void Execute()
{
if ( SUIT_Session::session() ) {
- if ( getActiveStudy() && myStudyId <= 0 )
- myStudyId = getActiveStudy()->id();
- if ( myStudyId > 0 ) {
+ if ( getActiveStudy() ) {
QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
QList<SUIT_Application*>::Iterator it;
for( it = apps.begin(); it != apps.end(); ++it ) {
LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( *it );
- if ( anApp && anApp->activeStudy() && anApp->activeStudy()->id() == myStudyId ) {
+ if ( anApp && anApp->activeStudy() ) {
anApp->updateObjectBrowser();
return;
}
}
}
};
- ProcessVoidEvent( new TEvent( studyId, updateSelection ) );
+ ProcessVoidEvent( new TEvent( updateSelection ) );
}
static const QString getActiveComponent();
static PyObject* getActivePythonModule();
static bool activateModule( const QString& );
- static void updateObjBrowser( const int = 0, bool = true );
+ static void updateObjBrowser( bool = true );
static bool isModified();
static void setModified( bool );
static const QString getActiveComponent() /ReleaseGIL/ ;
static SIP_PYOBJECT getActivePythonModule() /ReleaseGIL/ ;
static bool activateModule( const QString& ) /ReleaseGIL/ ;
- static void updateObjBrowser( const int = 0, bool = true ) /ReleaseGIL/ ;
+ static void updateObjBrowser( bool = true ) /ReleaseGIL/ ;
static bool isModified() /ReleaseGIL/ ;
static void setModified( bool ) /ReleaseGIL/ ;
{
QString studyName;
- std::vector<std::string> List = studyMgr()->GetOpenStudies();
-
// rnv: According to the single-study approach on the server side
// can be only one study. So if it is exists connect to them,
// overwise show warning message: "No active study on the server"
return;
*/
- if(List.size() <= 0) {
+ if(!activeStudy()) {
SUIT_MessageBox::warning( desktop(),
QObject::tr("WRN_WARNING"),
QObject::tr("WRN_NO_STUDY_ON SERV") );
return;
}
- studyName = List[0].c_str();
+ studyName = activeStudy()->studyName();
#ifndef WIN32
// this code replaces marker of windows drive and path become invalid therefore
/*!SLOT. Parse message for desktop.*/
void SalomeApp_Application::onDesktopMessage( const QString& message )
{
- if (message.indexOf("studyCreated:") == 0) {
- // Enable 'Connect' action
+ if (message.indexOf("studyCreated") == 0) {
updateCommandsStatus();
}
- else if (message.indexOf("studyClosed:") == 0) {
- /* message also contains ID of the closed study,
- but as soon as SALOME is mono-study application for the moment,
- this ID is not needed now.*/
- //long aStudyId = message.section(':', 1).toLong();
+ if (message.indexOf("studyCleared") == 0) {
// Disconnect GUI from active study, because it was closed on DS side.
closeActiveDoc( false );
// Disable 'Connect' action
{
_PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
try {
- studyMgr()->Copy(so);
+ stdDS->Copy(so);
onSelectionChanged();
}
catch(...) {
{
_PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
try {
- studyMgr()->Paste(so);
+ stdDS->Paste(so);
updateObjectBrowser( true );
updateActions(); //SRN: BugID IPAL9377, case 3
}
_PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
if ( so ) {
- canCopy = canCopy || studyMgr()->CanCopy(so);
- canPaste = canPaste || studyMgr()->CanPaste(so);
+ canCopy = canCopy || stdDS->CanCopy(so);
+ canPaste = canPaste || stdDS->CanPaste(so);
}
}
}
// Connect study menu
a = action( ConnectId );
if( a )
- a->setEnabled( !activeStudy() && studyMgr()->GetOpenStudies().size() > 0 );
+ a->setEnabled( !activeStudy() );
// Disconnect study menu
a = action( DisconnectId );
if ( QFileInfo( aName ).exists() ) {
if ( choice == OpenNew ) { // The document isn't already open.
bool exist = false;
- std::vector<std::string> lst = studyMgr()->GetOpenStudies();
- for ( uint i = 0; i < lst.size() && !exist; i++ ) {
- if ( aName == QString( lst[i].c_str() ) )
- exist = true;
- }
- // The document already exists in the study manager.
+ SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
+ if ( aName == study->studyDS()->Name().c_str() )
+ exist = true;
+ // The document already exists in the study.
// Do you want to reload it?
if ( exist ) {
int answer = SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_DOC_ALREADYEXIST" ).arg( aName ),
{
case OpenRefresh:
{
- _PTR(Study) aStudy = studyMgr()->GetStudyByName( aName.toStdString() );
+ SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
+ _PTR(Study) aStudy = study->studyDS();
if ( aStudy )
{
- studyMgr()->Close( aStudy );
+ aStudy->Clear();
choice = OpenNew;
}
}
}
/*!Create and return SALOMEDS_StudyManager.*/
-SALOMEDSClient_StudyManager* SalomeApp_Application::studyMgr()
+SALOMEDSClient_Study* SalomeApp_Application::getStudy()
{
- static _PTR(StudyManager) _sm;
- if(!_sm) _sm = ClientFactory::StudyManager();
- return _sm.get();
+ static _PTR(Study) _study;
+ if(!_study) {
+ CORBA::Object_var aSObject = namingService()->Resolve("/Study");
+ SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(aSObject);
+ _study = ClientFactory::Study(aStudy);
+ }
+ return _study.get();
}
/*!Create and return SALOME_NamingService.*/
bool SalomeApp_Application::checkExistingDoc()
{
bool result = LightApp_Application::checkExistingDoc();
- if ( result && !activeStudy() ) {
+ /*if ( result && !activeStudy() ) {
SALOMEDSClient_StudyManager* aMgr = studyMgr();
if ( aMgr ) {
std::vector<std::string> List = studyMgr()->GetOpenStudies();
result = false;
}
}
- }
+ }*/ // NB!!!
return result;
}
virtual bool checkExistingDoc();
static CORBA::ORB_var orb();
- static SALOMEDSClient_StudyManager* studyMgr();
+ static SALOMEDSClient_Study* getStudy();
static SALOME_NamingService* namingService();
static SALOME_LifeCycleCORBA* lcc();
if ( !CORBA::is_nil(aComponent) && aComponent->hasObjectInfo() ) {
LightApp_RootObject* aRoot = dynamic_cast<LightApp_RootObject*>( root() );
if ( aRoot && aRoot->study() ) {
- CORBA::String_var data = aComponent->getObjectInfo( aRoot->study()->id(), entry().toLatin1().constData());
+ CORBA::String_var data = aComponent->getObjectInfo( entry().toLatin1().constData());
QString objInfo = data.in();
QStringList l;
l << name();
if (CORBA::is_nil(theComponent) || CORBA::is_nil(theComponent->GetStudy()))
return aStreamFile._retn();
- const int studyId = theComponent->GetStudy()->StudyId();
-
// Get a temporary directory to store a file
//std::string aTmpDir = isMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir();
- if (myMap.count(studyId)) {
- std::string componentName (theComponent->ComponentDataType());
-
- // Error somewhere outside - Save() called with
- // wrong SComponent instance
- if ( myComponentName != componentName )
- return aStreamFile._retn();
+ std::string componentName (theComponent->ComponentDataType());
- const ListOfFiles& listOfFiles = myMap[studyId];
+ // Error somewhere outside - Save() called with
+ // wrong SComponent instance
+ if ( myComponentName != componentName )
+ return aStreamFile._retn();
- // listOfFiles must contain temporary directory name in its first item
- // and names of files (relatively the temporary directory) in the others
- const int n = listOfFiles.size() - 1;
+ // listOfFiles must contain temporary directory name in its first item
+ // and names of files (relatively the temporary directory) in the others
+ const int n = myListOfFiles.size() - 1;
- if (n > 0) { // there are some files, containing persistent data of the component
- std::string aTmpDir = listOfFiles[0];
+ if (n > 0) { // there are some files, containing persistent data of the component
+ std::string aTmpDir = myListOfFiles[0];
- // Create a list to store names of created files
- SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
- aSeq->length(n);
- for (int i = 0; i < n; i++)
- aSeq[i] = CORBA::string_dup(listOfFiles[i + 1].c_str());
+ // Create a list to store names of created files
+ SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
+ aSeq->length(n);
+ for (int i = 0; i < n; i++)
+ aSeq[i] = CORBA::string_dup(myListOfFiles[i + 1].c_str());
- // Convert a file to the byte stream
- aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.c_str(), aSeq.in(), isMultiFile);
+ // Convert a file to the byte stream
+ aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.c_str(), aSeq.in(), isMultiFile);
- // Remove the files and tmp directory, created by the component storage procedure
- if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true);
- }
+ // Remove the files and tmp directory, created by the component storage procedure
+ if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true);
}
return aStreamFile._retn();
if ( myComponentName != componentName )
return false;
- const int studyId = theComponent->GetStudy()->StudyId();
-
// Create a temporary directory for the component's data files
std::string aTmpDir = isMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir();
for (int i = 1; i < n; i++)
listOfFiles[i] = std::string(aSeq[i - 1]);
- SetListOfFiles(listOfFiles, studyId);
+ SetListOfFiles(listOfFiles);
return true;
}
-SalomeApp_Engine_i::ListOfFiles SalomeApp_Engine_i::GetListOfFiles (const int theStudyId)
+SalomeApp_Engine_i::ListOfFiles SalomeApp_Engine_i::GetListOfFiles()
{
- ListOfFiles aListOfFiles;
-
- if (myMap.find(theStudyId) != myMap.end())
- {
- aListOfFiles = myMap[theStudyId];
- }
-
- return aListOfFiles;
+ return myListOfFiles;
}
-void SalomeApp_Engine_i::SetListOfFiles (const ListOfFiles& theListOfFiles,
- const int theStudyId)
+void SalomeApp_Engine_i::SetListOfFiles (const ListOfFiles& theListOfFiles)
{
- myMap[theStudyId] = theListOfFiles;
+ myListOfFiles = theListOfFiles;
}
/*!
* DumpPython implementation for light modules
*/
-Engines::TMPFile* SalomeApp_Engine_i::DumpPython(CORBA::Object_ptr theStudy,
- CORBA::Boolean isPublished,
- CORBA::Boolean isMultiFile,
- CORBA::Boolean& isValidScript)
+Engines::TMPFile* SalomeApp_Engine_i::DumpPython(CORBA::Boolean isPublished,
+ CORBA::Boolean isMultiFile,
+ CORBA::Boolean& isValidScript)
{
MESSAGE("SalomeApp_Engine_i::DumpPython(): myComponentName = "<<
myComponentName << ", this = " << this);
aStreamFile[0] = '\0';
isValidScript = true;
- if (CORBA::is_nil(theStudy))
- return aStreamFile._retn();
-
- SALOMEDS::Study_var studyDS = SALOMEDS::Study::_narrow( theStudy );
- const int studyId = studyDS->StudyId();
-
- if (!myMap.count(studyId))
- return aStreamFile._retn();
-
- ListOfFiles listOfFiles = myMap[studyId];
-
// listOfFiles must contain temporary directory name in its first item
// and names of files (relatively the temporary directory) in the others
- if ( listOfFiles.size() < 2 )
+ if ( myListOfFiles.size() < 2 )
return aStreamFile._retn();
// there are some files, containing persistent data of the component
- QString aTmpPath( listOfFiles.front().c_str() );
+ QString aTmpPath( myListOfFiles.front().c_str() );
QDir aTmpDir( aTmpPath );
if ( !aTmpDir.exists() )
return aStreamFile._retn();
QStringList aFilePaths;
QList<qint64> aFileSizes;
qint64 aBuffSize = 0;
- ListOfFiles::const_iterator aFIt = listOfFiles.begin();
- ListOfFiles::const_iterator aFEnd = listOfFiles.end();
+ ListOfFiles::const_iterator aFIt = myListOfFiles.begin();
+ ListOfFiles::const_iterator aFEnd = myListOfFiles.end();
aFIt++;
for (; aFIt != aFEnd; aFIt++){
QString aFileName( (*aFIt).c_str() );
const char* theURL,
bool isMultiFile );
- virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
- CORBA::Boolean isPublished,
+ virtual Engines::TMPFile* DumpPython(CORBA::Boolean isPublished,
CORBA::Boolean isMultiFile,
CORBA::Boolean& isValidScript);
public:
typedef std::vector<std::string> ListOfFiles;
- ListOfFiles GetListOfFiles (const int theStudyId);
- void SetListOfFiles (const ListOfFiles& theListOfFiles,
- const int theStudyId);
+ ListOfFiles GetListOfFiles ();
+ void SetListOfFiles (const ListOfFiles& theListOfFiles);
static std::string EngineIORForComponent( const char* theComponentName,
bool toCreate );
static PortableServer::POA_var poa();
static SALOME_NamingService* namingService();
private:
- typedef std::map<int, ListOfFiles> MapOfListOfFiles;
- MapOfListOfFiles myMap;
+ ListOfFiles myListOfFiles;
std::string myComponentName;
};
}
#endif
-/*!
- Gets study id.
-*/
-int SalomeApp_Study::id() const
-{
- int id = -1;
- if ( studyDS() )
- id = studyDS()->StudyId();
- return id;
-}
-
/*!
Get study name.
*/
MESSAGE( "createDocument" );
// initialize myStudyDS, read HDF file
- QString aName = newStudyName();
+ QString aName = studyName();
_PTR(Study) study;
bool showError = !application()->property("open_study_from_command_line").isValid() ||
!application()->property("open_study_from_command_line").toBool();
try {
- study = _PTR(Study)( SalomeApp_Application::studyMgr()->NewStudy( aName.toUtf8().data() ) );
+ study = _PTR(Study)( SalomeApp_Application::getStudy() );
}
catch(const SALOME_Exception& ex) {
application()->putInfo(tr(ex.what()));
{
MESSAGE( "openDocument" );
- // initialize myStudyDS, read HDF file
- _PTR(Study) study;
- bool showError = !application()->property("open_study_from_command_line").isValid() ||
+ // read HDF file
+ bool res = false;
+ bool showError = !application()->property("open_study_from_command_line").isValid() ||
!application()->property("open_study_from_command_line").toBool();
try {
- study = _PTR(Study) ( SalomeApp_Application::studyMgr()->Open( theFileName.toUtf8().data() ) );
+ res = studyDS()->Open( theFileName.toUtf8().data() );
}
catch(const SALOME_Exception& ex) {
application()->putInfo(tr(ex.what()));
SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
tr("ERR_ERROR"), tr(ex.what()));
return false;
- }
+ }
catch(...) {
application()->putInfo(tr("OPEN_DOCUMENT_PROBLEM"));
if ( showError )
return false;
}
- if ( !study )
+ if ( !res)
return false;
- setStudyDS( study );
-
setRoot( new SalomeApp_RootObject( this ) ); // create myRoot
// update loaded data models: call open() and update() on them.
myStudyDS->attach(myObserver->_this(),true);
#endif
- bool res = CAM_Study::openDocument( theFileName );
+ res = CAM_Study::openDocument( theFileName );
emit opened( this );
- study->IsSaved(true);
+ studyDS()->IsSaved(true);
bool restore = application()->resourceMgr()->booleanValue( "Study", "store_visual_state", true );
if ( restore ) {
MESSAGE( "loadDocument" );
// obtain myStudyDS from StudyManager
- _PTR(Study) study ( SalomeApp_Application::studyMgr()->GetStudyByName( theStudyName.toUtf8().data() ) );
+ _PTR(Study) study = studyDS();
if ( !study )
return false;
bool isMultiFile = resMgr->booleanValue( "Study", "multi_file", false );
bool isAscii = resMgr->booleanValue( "Study", "ascii_file", false );
bool res = (isAscii ?
- SalomeApp_Application::studyMgr()->SaveAsASCII( theFileName.toUtf8().data(), studyDS(), isMultiFile ) :
- SalomeApp_Application::studyMgr()->SaveAs ( theFileName.toUtf8().data(), studyDS(), isMultiFile ))
+ studyDS()->SaveAsASCII( theFileName.toUtf8().data(), isMultiFile ) :
+ studyDS()->SaveAs ( theFileName.toUtf8().data(), isMultiFile ))
&& CAM_Study::saveDocumentAs( theFileName );
res = res && saveStudyData(theFileName);
bool isMultiFile = resMgr->booleanValue( "Study", "multi_file", false );
bool isAscii = resMgr->booleanValue( "Study", "ascii_file", false );
bool res = (isAscii ?
- SalomeApp_Application::studyMgr()->SaveASCII( studyDS(), isMultiFile ) :
- SalomeApp_Application::studyMgr()->Save ( studyDS(), isMultiFile )) && CAM_Study::saveDocument();
+ studyDS()->SaveASCII( isMultiFile ) :
+ studyDS()->Save ( isMultiFile )) && CAM_Study::saveDocument();
res = res && saveStudyData(studyName());
if ( res )
SUIT_Desktop* desk = SUIT_Session::session()->activeApplication()->desktop();
bool isBlocked = desk->signalsBlocked();
desk->blockSignals( true );
- SalomeApp_Application::studyMgr()->Close( studyPtr );
+ studyDS()->Clear();
desk->blockSignals( isBlocked );
#ifndef DISABLE_PYCONSOLE
SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
return false;
}
-/*!
- Create new study name.
-*/
-QString SalomeApp_Study::newStudyName() const
-{
- std::vector<std::string> studies = SalomeApp_Application::studyMgr()->GetOpenStudies();
- QString prefix( "Study%1" ), newName, curName;
- int i = 1, j, n = studies.size();
- while ( newName.isEmpty() ){
- curName = prefix.arg( i );
- for ( j = 0 ; j < n; j++ ){
- if ( !strcmp( studies[j].c_str(), curName.toLatin1() ) )
- break;
- }
- if ( j == n )
- newName = curName;
- else
- i++;
- }
- return newName;
-}
-
/*!
Note that this method does not create or activate SalomeApp_Engine_i instance,
therefore it can be called safely for any kind of module, but for full
// Issue 21377 - using separate engine for each type of light module
SalomeApp_Engine_i* aDefaultEngine = SalomeApp_Engine_i::GetInstance( theModuleName, false );
if (aDefaultEngine)
- return aDefaultEngine->GetListOfFiles(id());
+ return aDefaultEngine->GetListOfFiles();
std::vector<std::string> aListOfFiles;
return aListOfFiles;
// Issue 21377 - using separate engine for each type of light module
SalomeApp_Engine_i* aDefaultEngine = SalomeApp_Engine_i::GetInstance( theModuleName, false );
if (aDefaultEngine)
- aDefaultEngine->SetListOfFiles(theListOfFiles, id());
+ aDefaultEngine->SetListOfFiles(theListOfFiles);
}
/*!
*/
void SalomeApp_Study::updateFromNotebook( const QString& theFileName, bool isSaved )
{
- setStudyName(theFileName);
- studyDS()->Name(theFileName.toStdString());
+// setStudyName(theFileName);
+// studyDS()->Name(theFileName.toStdString()); NB!!!
setIsSaved( isSaved );
}
#endif
SalomeApp_Study( SUIT_Application* );
virtual ~SalomeApp_Study();
- virtual int id() const;
virtual QString studyName() const;
virtual bool createDocument( const QString& );
void onNoteBookVarUpdate( QString theVarName );
#endif
-private:
- QString newStudyName() const;
-
private:
_PTR(Study) myStudyDS;
Observer_i* myObserver;
SALOME_NamingService &NS = *SINGLETON_<SALOME_NamingService>::Instance();
ASSERT( SINGLETON_<SALOME_NamingService>::IsAlreadyExisting() );
NS.init_orb( orb );
- CORBA::Object_var obj = NS.Resolve( "/myStudyManager" );
- SALOMEDS::StudyManager_var studyManager = SALOMEDS::StudyManager::_narrow( obj );
- if ( !CORBA::is_nil( studyManager ) ) {
- MESSAGE( "/myStudyManager is found" );
- studyManager->ping();
- MESSAGE( "StudyManager was activated" );
+ CORBA::Object_var obj = NS.Resolve( "/myStudy" );
+ SALOMEDS::Study_var study = SALOMEDS::Study::_narrow( obj );
+ if ( !CORBA::is_nil( study ) ) {
+ MESSAGE( "/myStudy is found" );
+ study->ping();
+ MESSAGE( "Study was activated" );
setStep( ++current * myAttempts );
break;
}
}
case 4: // Session
{
- NamingService_WaitForServerReadiness(_NS,"/myStudyManager");
+ NamingService_WaitForServerReadiness(_NS,"/Study");
std::string containerName = "/Containers/";
containerName = containerName + Kernel_Utils::GetHostname();
containerName = containerName + "/FactoryServer";
// counted objects, they will be deleted by the POA when they are no
// longer needed.
- ClientFactory::createStudyManager(_orb,_root_poa);
+// ClientFactory::createStudyManager(_orb,_root_poa);
}
catch(CORBA::SystemException&) {
INFOS( "Caught CORBA::SystemException." );