-// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#include <SALOMEDS_Tool.hxx>
+#include <SALOMEconfig.h>
+#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
+
std::unique_ptr<SALOME_NamingService_Abstract> SalomeApp_Application::_ns;
/*!Internal class that updates object browser item properties */
bool myPrevState;
bool& myLock; //! External 'Lock state' boolean flag
};
+
+ /*!
+ \brief Dynamic property manager
+ */
+ class PropertyMgr
+ {
+ QObject* myObject;
+ QString myProperty;
+ public:
+ PropertyMgr(QObject* object, const QString& property, const QVariant& value)
+ : myObject(object), myProperty(property)
+ {
+ myObject->setProperty(qPrintable(myProperty), value);
+ }
+ ~PropertyMgr()
+ {
+ myObject->setProperty(qPrintable(myProperty), QVariant());
+ }
+ };
}
/*!Constructor.*/
LightApp_Application::start();
SALOME_EventFilter::Init();
- setProperty("open_study_from_command_line", true);
- if ( !hdffile.isEmpty() ) // open hdf file given as parameter
+ if ( !hdffile.isEmpty() )
+ {
+ // open hdf file given as parameter
+ PropertyMgr propm( this, "open_study_from_command_line", true );
onOpenDoc( hdffile );
- setProperty("open_study_from_command_line", QVariant());
+ }
#ifndef DISABLE_PYCONSOLE
// import/execute python scripts
script.remove( QRegExp("^python.*[\\s]+") );
QString command = QString( "exec(open(\"%1\", \"rb\").read(), args=(%2))" ).arg(script).arg(args.join(","));
+ PropertyMgr propm( this, "IsLoadedScript", true );
pyConsole->exec(command);
}
} // end for loop on pyfiles QStringList
{
onNewDoc();
- QString command = QString("exec(open(\"%1\", \"rb\").read())").arg(aFile);
-
#ifndef DISABLE_PYCONSOLE
+ QString command = QString("exec(open(\"%1\", \"rb\").read())").arg(aFile);
PyConsole_Console* pyConsole = pythonConsole();
-
+ PropertyMgr propm( this, "IsLoadedScript", true );
if ( pyConsole )
pyConsole->exec( command );
#endif
if ( !aFile.isEmpty() )
{
-
- QString command = QString("exec(compile(open('%1', 'rb').read(), '%1', 'exec'))").arg(aFile);
-
#ifndef DISABLE_PYCONSOLE
+ QString command = QString("exec(compile(open('%1', 'rb').read(), '%1', 'exec'))").arg(aFile);
PyConsole_Console* pyConsole = pythonConsole();
-
+ PropertyMgr propm( this, "IsLoadedScript", true );
if ( pyConsole )
- pyConsole->exec( command );
+ pyConsole->exec(command);
#endif
}
}
#ifndef DISABLE_PYCONSOLE
PyConsole_Console* pyConsole = app->pythonConsole();
- if ( pyConsole )
+ if ( pyConsole ) {
+ PropertyMgr propm( this, "IsLoadedScript", true );
pyConsole->execAndWait( command );
+ }
#endif
// remove temporary directory
PyConsole_Interp* SalomeApp_Application::createPyInterp()
{
- return new SalomeApp_PyInterp;
+ return new SalomeApp_PyInterp( resourceMgr() );
}
#endif // DISABLE_PYCONSOLE
onDesktopMessage("register_module_in_study/Shaper");
}
}
+
+void SalomeApp_Application::addCatalogue( const QString& moduleName, const QString& catalogue )
+{
+ CORBA::Object_var obj = namingService()->Resolve( "/Kernel/ModulCatalog" );
+ SALOME_ModuleCatalog::ModuleCatalog_var moduleCatalogue = SALOME_ModuleCatalog::ModuleCatalog::_narrow( obj );
+ QFileInfo fi( catalogue );
+ if ( !CORBA::is_nil( moduleCatalogue ) && fi.isFile() )
+ {
+ SALOME_ModuleCatalog::ListOfComponents_var known = moduleCatalogue->GetComponentList();
+ bool loaded = false;
+ for ( int i = 0; i < (int)known->length() && !loaded; i++ )
+ loaded = QString( known[i].in() ) == moduleName;
+ if ( !loaded )
+ moduleCatalogue->ImportXmlCatalogFile( catalogue.toUtf8().constData() );
+ }
+}