-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// Created: 10/22/2004 3:23:45 PM
// Author: Sergey LITONIN
-#ifdef WNT
+#ifdef WIN32
// E.A. : On windows with python 2.6, there is a conflict
// E.A. : between pymath.h and Standard_math.h which define
// E.A. : some same symbols : acosh, asinh, ...
{
connect( desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
+ connect( desktop(), SIGNAL( message( const QString& ) ),
+ this, SLOT( onLoadDocMessage( const QString& ) ), Qt::UniqueConnection );
+ myIsSiman = false; // default
}
/*!Destructor.
/*!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=(.+)");
}
else {
QRegExp rxp ("--pyscript=\\[(.+)\\]");
+ QRegExp rxl ("--siman-study=(.+)");
if ( rxp.indexIn( QString(qApp->argv()[i]) ) >= 0 && rxp.capturedTexts().count() > 1 ) {
+ // pyscript
QStringList dictList = rxp.capturedTexts()[1].split("},", QString::SkipEmptyParts);
for (int k = 0; k < dictList.count(); ++k) {
QRegExp rxd ("[\\s]*\\{?([^\\{\\}]+)\\}?[\\s]*");
}
}
}
+#ifdef WITH_SIMANIO
+ if ( rxl.indexIn( QString(qApp->argv()[i]) ) >= 0 && rxl.capturedTexts().count() > 1 ) {
+ // siman
+ loadStudy = rxl.capturedTexts()[1];
+ myIsSiman = true;
+ }
+#endif
}
}
// Here pyfiles elements are: "script_name": [list_of_"arg"s]
// For example: "/absolute/path/to/my_script.py": ["1", "2"]
+ 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() ) {
if (!args.isEmpty()) {
args = "args:"+args;
}
+
+ script.remove( QRegExp("^python.*[\\s]+") );
QString cmd = script+" "+args;
QString command = QString( "execfile(r\"%1\")" ).arg(cmd.trimmed());
pyConsole->exec(command);
}
}
}
+ } else {
+ LightApp_Application::start();
+ SALOME_EventFilter::Init();
}
}
Qt::CTRL+Qt::Key_L, desk, false, this, SLOT( onLoadDoc() ) );
//SRN: BugID IPAL9021: End
+#ifdef WITH_SIMANIO
+ if (myIsSiman) {
+ // check-in operations 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() ) );
+ }
+#endif
int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
createMenu( FileLoadId, fileMenu, 0 ); //SRN: BugID IPAL9021, add a menu item "Load"
+#ifdef WITH_SIMANIO
+ 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 );
+ }
+#endif
createMenu( DumpStudyId, fileMenu, 10, -1 );
createMenu( separator(), fileMenu, -1, 10, -1 );
createMenu( LoadScriptId, fileMenu, 10, -1 );
// import Python module that manages SALOME plugins
PyGILState_STATE gstate = PyGILState_Ensure();
- PyObject* pluginsmanager=PyImport_ImportModule((char*)"salome_pluginsmanager");
- PyObject* res=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",0,"salome",tr("MEN_DESK_PLUGINS_TOOLS").toStdString().c_str(),tr("MEN_DESK_PLUGINS").toStdString().c_str());
- if(res==NULL)
+ PyObjWrapper pluginsmanager = PyImport_ImportModule((char*)"salome_pluginsmanager");
+ PyObjWrapper res = PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",0,"salome",tr("MEN_DESK_PLUGINS_TOOLS").toStdString().c_str(),tr("MEN_DESK_PLUGINS").toStdString().c_str());
+ if ( !res )
PyErr_Print();
- Py_XDECREF(res);
- Py_XDECREF(pluginsmanager);
PyGILState_Release(gstate);
// end of SALOME plugins loading
if ( desk ) {
connect( desk, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
+ connect( desk, SIGNAL( message( const QString& ) ),
+ this, SLOT( onLoadDocMessage( const QString& ) ), Qt::UniqueConnection );
}
}
return res;
}
+/*!SLOT. Load document with a name, specified in \a aMessage.*/
+void SalomeApp_Application::onLoadDocMessage(const QString& aMessage)
+{
+ if (aMessage.indexOf("simanCheckoutDone ") == 0) {
+#ifdef WITH_SIMANIO
+ onLoadDoc(aMessage.section(' ', 1));
+#else
+ printf( "****************************************************************\n" );
+ printf( "* Warning: SALOME is built without SIMAN support.\n" );
+ printf( "****************************************************************\n" );
+#endif
+ }
+}
+
/*!SLOT. Copy objects to study maneger from selection maneger..*/
void SalomeApp_Application::onCopy()
{
QString anInitialPath = "";
if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
anInitialPath = QDir::currentPath();
+
+#ifdef WITH_SIMANIO
+ // 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();
+ }
+#endif
QString aFile = SUIT_FileDlg::getFileName( desktop(), anInitialPath, filtersList, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), true, true );
updateActions();
}
+/*!Public SLOT. On SIMAN check in operation.*/
+void SalomeApp_Application::onCheckIn()
+{
+#ifdef WITH_SIMANIO
+ setMenuShown(SimanCheckInId, false); // check in may be performed only once
+ setMenuShown(SimanLocalCheckInId, false);
+ SALOMEDSClient_StudyManager* aMgr = studyMgr();
+ aMgr->GetSimanStudy()->CheckIn("");
+#else
+ printf( "****************************************************************\n" );
+ printf( "* Warning: SALOME is built without SIMAN support.\n" );
+ printf( "****************************************************************\n" );
+#endif
+}
+
+/*!Public SLOT. On SIMAN local check in operation.*/
+void SalomeApp_Application::onLocalCheckIn()
+{
+#ifdef WITH_SIMANIO
+ // 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());
+#else
+ printf( "****************************************************************\n" );
+ printf( "* Warning: SALOME is built without SIMAN support.\n" );
+ printf( "****************************************************************\n" );
+#endif
+}
+
/*!Gets file filter.
*\retval QString "(*.hdf)"
*/
SALOME_View* aView = dynamic_cast<SALOME_View*>( theViewModel );
- if (theList.isEmpty() || !aView || !aStudy)
+ if (theList.isEmpty() || !aStudy)
return;
for ( DataObjectList::iterator itr = theList.begin(); itr != theList.end(); ++itr ) {
LightApp_Displayer* aDisplayer = anObjModule->displayer();
if(aDisplayer) {
if( aDisplayer->canBeDisplayed(obj->entry(), theViewModel->getType()) ) {
- if(aDisplayer->IsDisplayed(obj->entry(),aView))
+ if(aView && aDisplayer->IsDisplayed(obj->entry(),aView))
anObjState = Qtx::ShownState;
else
anObjState = Qtx::HiddenState;
}
+ aStudy->setVisibilityState( obj->entry(), anObjState );
}
- aStudy->setVisibilityState( obj->entry(), anObjState );
}
}
}