From: Frederic Pons Date: Wed, 17 Apr 2024 11:41:46 +0000 (+0200) Subject: GUITHARE #21125: allow GUITHARE to open an input deck from command line X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b6286e27e9517ad164fc83462663af9da0436bc7;p=modules%2Fgui.git GUITHARE #21125: allow GUITHARE to open an input deck from command line --- diff --git a/src/LightApp/LightApp_Study.cxx b/src/LightApp/LightApp_Study.cxx index a42d7bfd0..f9a12fd9e 100644 --- a/src/LightApp/LightApp_Study.cxx +++ b/src/LightApp/LightApp_Study.cxx @@ -113,6 +113,25 @@ bool LightApp_Study::openDocument( const QString& theFileName ) return res; } +bool LightApp_Study::openEmptyDocument( ) +{ + setRoot( new LightApp_RootObject( this ) ); // create myRoot + + // update loaded data models: call open() and update() on them. + ModelList dm_s; + dataModels( dm_s ); + QListIterator it( dm_s ); + while ( it.hasNext() ) + openDataModel( studyName(), it.next() ); + // this will build a SUIT_DataObject-s tree under myRoot member field + // passing "false" in order NOT to rebuild existing data models' trees - it was done in previous step + // but tree that corresponds to not-loaded data models will be updated any way. + ((LightApp_Application*)application())->updateObjectBrowser( false ); + + emit opened( this ); + return true; +} + /*! Loads document */ diff --git a/src/LightApp/LightApp_Study.h b/src/LightApp/LightApp_Study.h index 142bdbcc6..bd3eeb08d 100644 --- a/src/LightApp/LightApp_Study.h +++ b/src/LightApp/LightApp_Study.h @@ -46,6 +46,7 @@ public: virtual bool createDocument( const QString& ); virtual bool openDocument( const QString& ); + virtual bool openEmptyDocument(); virtual bool loadDocument( const QString& ); virtual bool saveDocument(); diff --git a/src/SUIT/SUIT_Application.cxx b/src/SUIT/SUIT_Application.cxx index e4bf4f882..5235837e4 100755 --- a/src/SUIT/SUIT_Application.cxx +++ b/src/SUIT/SUIT_Application.cxx @@ -145,6 +145,15 @@ bool SUIT_Application::useFile( const QString& theFileName ) return status; } +bool SUIT_Application::useDatFile() +{ + createEmptyStudy(); + SUIT_Study* study = activeStudy(); + + return study->openEmptyDocument(); +} + + /*! Creates new empty Study if active Study = 0 */ diff --git a/src/SUIT/SUIT_Application.h b/src/SUIT/SUIT_Application.h index 4d81b4f42..ad8a3ea1d 100755 --- a/src/SUIT/SUIT_Application.h +++ b/src/SUIT/SUIT_Application.h @@ -83,6 +83,7 @@ public: //! Opens document into active Study. If Study is empty - creates it. virtual bool useFile( const QString& theFileName); + virtual bool useDatFile( ); //! Creates new empty Study if active Study = 0 virtual void createEmptyStudy(); diff --git a/src/SUIT/SUIT_Session.cxx b/src/SUIT/SUIT_Session.cxx index 3dff0ed3a..b1aa20ecb 100755 --- a/src/SUIT/SUIT_Session.cxx +++ b/src/SUIT/SUIT_Session.cxx @@ -144,10 +144,12 @@ SUIT_Application* SUIT_Session::startApplication( const QString& name, int /*arg } // Prepare Resource Manager for the new application if it doesn't exist yet + bool firstRun = false; if ( !myResMgr ) { myResMgr = createResourceMgr( appName ); myResMgr->loadLanguage(); + firstRun = true; } //jfa 22.06.2005:SUIT_Application* app = crtInst( args, argv ); @@ -182,17 +184,25 @@ SUIT_Application* SUIT_Session::startApplication( const QString& name, int /*arg if ( !myBTimer ) { - QString anHDFName; - QStringList anArgs = QCoreApplication::arguments(); - QStringList::const_iterator anArgsIt = anArgs.constBegin(); - for ( ; anArgsIt != anArgs.constEnd(); anArgsIt++ ) + QString anHDFName, aDatName; + if (firstRun) { - QString anArg = *anArgsIt; - QFileInfo aFileInfo( anArg ); - if ( aFileInfo.exists() && aFileInfo.suffix().toLower() == "hdf" ) + QStringList anArgs = QCoreApplication::arguments(); + QStringList::const_iterator anArgsIt = anArgs.constBegin(); + for ( ; anArgsIt != anArgs.constEnd(); anArgsIt++ ) { - anHDFName = anArg; - break; + QString anArg = *anArgsIt; + QFileInfo aFileInfo( anArg ); + if ( aFileInfo.exists() && aFileInfo.suffix().toLower() == "hdf" ) + { + anHDFName = anArg; + break; + } + else if ( aFileInfo.exists() && aFileInfo.suffix().toLower() == "dat" ) + { + aDatName = anArg; + break; + } } } @@ -209,6 +219,10 @@ SUIT_Application* SUIT_Session::startApplication( const QString& name, int /*arg for ( ; aFoldersIt != aFolders.constEnd(); ++aFoldersIt ) Qtx::rmDir( (*aFoldersIt).absoluteFilePath() ); } + else if ( !aDatName.isEmpty() && app ) + { + app->useDatFile(); + } else { //Try to restore backup diff --git a/src/SUIT/SUIT_Study.cxx b/src/SUIT/SUIT_Study.cxx index 91ec41e40..5929bc937 100755 --- a/src/SUIT/SUIT_Study.cxx +++ b/src/SUIT/SUIT_Study.cxx @@ -135,6 +135,15 @@ bool SUIT_Study::openDocument( const QString& fileName ) return true; } +bool SUIT_Study::openEmptyDocument( ) +{ + myName = ""; + myIsSaved = true; + myIsModified = false; + + return true; +} + /*! * Save document as \a fileName. Set file name. */ diff --git a/src/SUIT/SUIT_Study.h b/src/SUIT/SUIT_Study.h index fafba19ee..87875239c 100755 --- a/src/SUIT/SUIT_Study.h +++ b/src/SUIT/SUIT_Study.h @@ -53,6 +53,7 @@ public: virtual void closeDocument( bool = true ); virtual bool openDocument( const QString& ); + virtual bool openEmptyDocument( ); virtual bool createDocument( const QString& ); bool saveDocument();