From 8c0a95c093a444b668304f630fe68f6fd4216445 Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 18 Oct 2012 06:48:49 +0000 Subject: [PATCH] Initial integration of SimanIO support and SIMAN study interfaces --- src/SalomeApp/SalomeApp_Application.cxx | 74 +++++++++++++++++++-- src/SalomeApp/SalomeApp_Application.h | 7 +- src/SalomeApp/resources/SalomeApp_msg_en.ts | 24 +++++++ src/SalomeApp/resources/SalomeApp_msg_fr.ts | 25 +++++++ src/Session/Session_Session_i.cxx | 6 +- 5 files changed, 128 insertions(+), 8 deletions(-) diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index d446757b2..3c71409b5 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -161,7 +161,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 setNoteBook(0); } @@ -177,16 +181,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 +204,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 +273,9 @@ void SalomeApp_Application::start() } } } + } else { + LightApp_Application::start(); + SALOME_EventFilter::Init(); } } @@ -311,6 +329,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 ); @@ -320,6 +347,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 "4" 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( NoteBookId, fileMenu, 10, -1 ); createMenu( separator(), fileMenu, -1, 10, -1 ); @@ -356,6 +389,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 ); } } @@ -483,6 +519,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() { @@ -881,6 +925,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 c72468cfe..e5ddc2995 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, NoteBookId, UserID }; + CatalogGenId, RegDisplayId, SaveGUIStateId, FileLoadId, NoteBookId, UserID, + SimanCheckInId, SimanLocalCheckInId }; protected: enum { OpenRefresh = LightApp_Application::OpenReload + 1 }; @@ -120,11 +121,14 @@ 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(); virtual void onPaste(); void onSaveGUIState();// called from VISU + virtual void onCheckIn(); + virtual void onLocalCheckIn(); protected slots: void onStudyCreated( SUIT_Study* ); @@ -179,6 +183,7 @@ private: private: SalomeApp_NoteBookDlg* myNoteBook; QMap myExtActions; // Map + bool myIsSiman; // application corresponds to the siman study flag }; #ifdef WIN32 diff --git a/src/SalomeApp/resources/SalomeApp_msg_en.ts b/src/SalomeApp/resources/SalomeApp_msg_en.ts index c248a811d..4e398cec7 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 dc4f87c52..44dddf897 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..413f3ab7b 100755 --- a/src/Session/Session_Session_i.cxx +++ b/src/Session/Session_Session_i.cxx @@ -302,9 +302,9 @@ void SALOME_Session_i::emitMessage(const char* theMessage) if ( SUIT_Session::session()->activeApplication() ) { if ( SUIT_Session::session()->activeApplication()->desktop() ) { ProcessVoidEvent( new TEvent(theMessage) ); - } - } - } + } else MESSAGE("try to emit message '"<