From bf4192132b6001ab7f22cdc94993d58f611c9f02 Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 14 Feb 2013 12:20:31 +0000 Subject: [PATCH] Merge from BR_siman_phase1 14/02/2013 --- src/SalomeApp/SalomeApp_Application.cxx | 84 ++++++++++++++++++++- src/SalomeApp/SalomeApp_Application.h | 8 +- src/SalomeApp/resources/SalomeApp_msg_en.ts | 24 ++++++ src/SalomeApp/resources/SalomeApp_msg_fr.ts | 25 ++++++ src/Session/Session_Session_i.cxx | 9 +++ 5 files changed, 145 insertions(+), 5 deletions(-) diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index f36c4796d..bf44620c0 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -163,6 +163,11 @@ SalomeApp_Application::SalomeApp_Application() { connect( desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ), this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection ); + // used for simanCheckoutDone signal processing + connect( desktop(), SIGNAL( message( const QString& ) ), + this, SLOT( onLoadDocMessage( const QString& ) ), Qt::UniqueConnection ); + + myIsSiman = false; // default } /*!Destructor. @@ -177,16 +182,14 @@ SalomeApp_Application::~SalomeApp_Application() /*!Start application.*/ void SalomeApp_Application::start() { - LightApp_Application::start(); - - SALOME_EventFilter::Init(); - + // process the command line options before start: to createActions in accordance to the options static bool isFirst = true; if ( isFirst ) { isFirst = false; QString hdffile; QStringList pyfiles; + QString loadStudy; for (int i = 1; i < qApp->argc(); i++) { QRegExp rxs ("--study-hdf=(.+)"); @@ -202,14 +205,27 @@ void SalomeApp_Application::start() if ( rxp.indexIn( QString(qApp->argv()[i]) ) >= 0 && rxp.capturedTexts().count() > 1 ) { QStringList files = rxp.capturedTexts()[1].split(",",QString::SkipEmptyParts); pyfiles += files; + } else { + QRegExp rxl ("--siman-study=(.+)"); + if ( rxl.indexIn( QString(qApp->argv()[i]) ) >= 0 && rxl.capturedTexts().count() > 1 ) { + loadStudy = rxl.capturedTexts()[1]; + myIsSiman = true; + } } } } + LightApp_Application::start(); + SALOME_EventFilter::Init(); + if ( !hdffile.isEmpty() ) // open hdf file given as parameter onOpenDoc( hdffile ); else if ( pyfiles.count() > 0 ) // create new study onNewDoc(); + else if (!loadStudy.isEmpty()) {// load study by name + if (onLoadDoc(loadStudy)) + updateObjectBrowser(true); + } // import/execute python scripts if ( pyfiles.count() > 0 && activeStudy() ) { @@ -258,6 +274,9 @@ void SalomeApp_Application::start() } } } + } else { + LightApp_Application::start(); + SALOME_EventFilter::Init(); } } @@ -306,6 +325,15 @@ void SalomeApp_Application::createActions() Qt::CTRL+Qt::Key_L, desk, false, this, SLOT( onLoadDoc() ) ); //SRN: BugID IPAL9021: End + if (myIsSiman) { // check in operation for SIMAN study + createAction( SimanCheckInId, tr( "TOT_SIMAN_CHECK_IN" ), QIcon(), + tr( "MEN_SIMAN_CHECK_IN" ), tr( "PRP_SIMAN_CHECK_IN" ), + 0, desk, false, this, SLOT( onCheckIn() ) ); + createAction( SimanLocalCheckInId, tr( "TOT_SIMAN_LOCAL_CHECK_IN" ), QIcon(), + tr( "MEN_SIMAN_LOCAL_CHECK_IN" ), tr( "PRP_SIMAN_LOCAL_CHECK_IN" ), + 0, desk, false, this, SLOT( onLocalCheckIn() ) ); + } + int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 ); @@ -315,6 +343,12 @@ void SalomeApp_Application::createActions() createMenu( FileLoadId, fileMenu, 0 ); //SRN: BugID IPAL9021, add a menu item "Load" + if (myIsSiman) { // check in operation for SIMAN study + // last argument "5" locates this just after "Save As" but certain constant is bad => insert after the separator + createMenu( SimanCheckInId, fileMenu, 5); + createMenu( SimanLocalCheckInId, fileMenu, 5); + createMenu( separator(), fileMenu, 5 ); + } createMenu( DumpStudyId, fileMenu, 10, -1 ); createMenu( separator(), fileMenu, -1, 10, -1 ); createMenu( LoadScriptId, fileMenu, 10, -1 ); @@ -350,6 +384,9 @@ void SalomeApp_Application::setDesktop( SUIT_Desktop* desk ) if ( desk ) { connect( desk, SIGNAL( windowActivated( SUIT_ViewWindow* ) ), this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection ); + // used for simanCheckoutDone signal processing + connect( desk, SIGNAL( message( const QString& ) ), + this, SLOT( onLoadDocMessage( const QString& ) ), Qt::UniqueConnection ); } } @@ -477,6 +514,14 @@ bool SalomeApp_Application::onLoadDoc( const QString& aName ) return res; } +/*!SLOT. Load document with a name, specified in \a aMessage.*/ +void SalomeApp_Application::onLoadDocMessage(const QString& aMessage) +{ + if (aMessage.indexOf("simanCheckoutDone ") == 0) { + onLoadDoc(aMessage.section(' ', 1)); + } +} + /*!SLOT. Copy objects to study maneger from selection maneger..*/ void SalomeApp_Application::onCopy() { @@ -826,6 +871,15 @@ void SalomeApp_Application::onLoadScript( ) QString anInitialPath = ""; if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() ) anInitialPath = QDir::currentPath(); + + // MPV: if it is SIMAN study, make the initial path as the path to the Siman scripts storage + if (myIsSiman) { + SALOMEDSClient_StudyManager* aMgr = studyMgr(); + aMgr->GetSimanStudy()->StudyId(); + anInitialPath = QString(QDir::separator()) + "tmp" + QDir::separator() + "SimanSalome" + QDir::separator() + + aMgr->GetSimanStudy()->StudyId().c_str() + QDir::separator() + + aMgr->GetSimanStudy()->ScenarioId().c_str() + QDir::separator() + aMgr->GetSimanStudy()->UserId().c_str(); + } QString aFile = SUIT_FileDlg::getFileName( desktop(), anInitialPath, filtersList, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), true, true ); @@ -852,6 +906,28 @@ void SalomeApp_Application::onSaveGUIState() updateActions(); } +/*!Public SLOT. On SIMAN check in operation.*/ +void SalomeApp_Application::onCheckIn() +{ + setMenuShown(SimanCheckInId, false); // check in may be performed only once + setMenuShown(SimanLocalCheckInId, false); + SALOMEDSClient_StudyManager* aMgr = studyMgr(); + aMgr->GetSimanStudy()->CheckIn(""); +} + +/*!Public SLOT. On SIMAN local check in operation.*/ +void SalomeApp_Application::onLocalCheckIn() +{ + // get the active module + CAM_Module* aModule = activeModule(); + if (!aModule) return; // there is no active module + + setMenuShown(SimanCheckInId, false); // check in may be performed only once + setMenuShown(SimanLocalCheckInId, false); + SALOMEDSClient_StudyManager* aMgr = studyMgr(); + aMgr->GetSimanStudy()->CheckIn(aModule->name().toLatin1().data()); +} + /*!Gets file filter. *\retval QString "(*.hdf)" */ diff --git a/src/SalomeApp/SalomeApp_Application.h b/src/SalomeApp/SalomeApp_Application.h index fbd778537..05efd1d37 100644 --- a/src/SalomeApp/SalomeApp_Application.h +++ b/src/SalomeApp/SalomeApp_Application.h @@ -69,7 +69,8 @@ class SALOMEAPP_EXPORT SalomeApp_Application : public LightApp_Application public: enum { MenuToolsId = 5 }; enum { DumpStudyId = LightApp_Application::UserID, LoadScriptId, PropertiesId, - CatalogGenId, RegDisplayId, SaveGUIStateId, FileLoadId, UserID }; + CatalogGenId, RegDisplayId, SaveGUIStateId, FileLoadId, UserID, + SimanCheckInId, SimanLocalCheckInId }; typedef enum { WT_NoteBook = LightApp_Application::WT_User } WindowTypes; @@ -123,6 +124,7 @@ public slots: virtual void onNewWithScript(); virtual bool onLoadDoc( const QString& ); virtual void onCloseDoc( bool ask = true); + virtual void onLoadDocMessage(const QString&); virtual void onExit(); virtual void onCopy(); @@ -133,6 +135,9 @@ public slots: const QString& theStudyName, bool theIsStudySaved ); + virtual void onCheckIn(); + virtual void onLocalCheckIn(); + protected slots: void onStudyCreated( SUIT_Study* ); void onStudySaved( SUIT_Study* ); @@ -191,6 +196,7 @@ private: private: SalomeApp_NoteBook* myNoteBook; QMap myExtActions; // Map + bool myIsSiman; // application corresponds to the siman study flag signals: void dumpedStudyClosed( const QString& theDumpScript, diff --git a/src/SalomeApp/resources/SalomeApp_msg_en.ts b/src/SalomeApp/resources/SalomeApp_msg_en.ts index 285ff023b..ee092821e 100644 --- a/src/SalomeApp/resources/SalomeApp_msg_en.ts +++ b/src/SalomeApp/resources/SalomeApp_msg_en.ts @@ -344,6 +344,30 @@ Do you want to reload it ? ACTIVATE_MODULE_OP_SCRIPT Load &Script... + + TOT_SIMAN_CHECK_IN + Check In + + + MEN_SIMAN_CHECK_IN + Check In + + + PRP_SIMAN_CHECK_IN + Check In + + + TOT_SIMAN_LOCAL_CHECK_IN + Check In for module + + + MEN_SIMAN_LOCAL_CHECK_IN + Check In for module + + + PRP_SIMAN_LOCAL_CHECK_IN + Check In for module + SalomeApp_StudyPropertiesDlg diff --git a/src/SalomeApp/resources/SalomeApp_msg_fr.ts b/src/SalomeApp/resources/SalomeApp_msg_fr.ts index fdfb53ee3..e8cf54aeb 100755 --- a/src/SalomeApp/resources/SalomeApp_msg_fr.ts +++ b/src/SalomeApp/resources/SalomeApp_msg_fr.ts @@ -344,6 +344,31 @@ Voulez-vous le recharger ? ACTIVATE_MODULE_OP_SCRIPT Charger un &script... + + TOT_SIMAN_CHECK_IN + Check In + + + MEN_SIMAN_CHECK_IN + Check In + + + PRP_SIMAN_CHECK_IN + Check In + + + TOT_SIMAN_LOCAL_CHECK_IN + Check In pour la module + + + MEN_SIMAN_LOCAL_CHECK_IN + Check In pour la module + + + PRP_SIMAN_LOCAL_CHECK_IN + Check In pour la module" + + SalomeApp_StudyPropertiesDlg diff --git a/src/Session/Session_Session_i.cxx b/src/Session/Session_Session_i.cxx index a075efc13..076352e79 100755 --- a/src/Session/Session_Session_i.cxx +++ b/src/Session/Session_Session_i.cxx @@ -303,8 +303,17 @@ void SALOME_Session_i::emitMessage(const char* theMessage) if ( SUIT_Session::session()->activeApplication()->desktop() ) { ProcessVoidEvent( new TEvent(theMessage) ); } + else { + MESSAGE("try to emit message '"<