-// Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
+// Copyright (C) 2007-2024 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 <QtxMap.h>
#include <LogWindow.h>
+#include <SalomeApprc_utils.h>
#ifndef DISABLE_GLVIEWER
#include <GLViewer_Viewer.h>
#include <QMimeData>
#include <QShortcut>
#include <QRegExp>
-#include <QMutex>
-#include <QMutexLocker>
#include <utilities.h>
if ( objectBrowser()->root() != activeStudy()->root() )
objectBrowser()->setRoot( activeStudy()->root() );
updateObjectBrowser( true );
+
+ // expand SHAPERSTUDY data after leaving Shaper module
+ // bos #40645 [CEA] Automatically expand tree in Object Browser
+ if (actName == "Shaper") {
+ SUIT_AbstractModel* aModel = dynamic_cast<SUIT_AbstractModel*>(objectBrowser()->model());
+ LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
+ if (aModel && aStudy) {
+ DataObjectList aComps;
+ aStudy->root()->children(aComps);
+ for(auto aCompSUIT : aComps){
+ LightApp_DataObject* aComp = dynamic_cast<LightApp_DataObject*>( aCompSUIT );
+ if ( aComp && aComp->componentDataType() == "SHAPERSTUDY") {
+ QModelIndex anIndex = aModel->index(aComp);
+ objectBrowser()->treeView()->expand(anIndex);
+ break;
+ }
+ }
+ }
+ }
}
if ( activeModule() ) activeModule()->updateModuleVisibilityState();
LightApp_ModuleAction* moduleAction = qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
// a. regular modules were added in createActions() method
// b. here we add custom modules (manually added by the user)
- if ( HAS_SALOME_ON_DEMAND )
+ if ( HAS_SALOME_ON_DEMAND && QString::compare(getenv("SALOME_ON_DEMAND"),"HIDE", Qt::CaseInsensitive) != 0)
{
+ // Update rc file
+ updateSalomeApprc();
+
QStringList modList = resourceMgr()->stringValue( "launch", "user_modules" ).split( ";", QString::SkipEmptyParts );
foreach ( QString aModule, modList )
- addUserModule( aModule, resourceMgr()->stringValue( "user_modules", aModule ) );
+ addUserModule( aModule, resourceMgr()->stringValue( "user_modules", aModule ), true );
}
else
{
}
}
+/*!
+ Update rc file with SALOME_APPLICATION_DIR or with SALOME_MODULES.
+*/
+void LightApp_Application::updateSalomeApprc()
+{
+ SUIT_ResourceMgr* resMgr = resourceMgr();
+ auto extRootDir = getenv(salomeAppDir);
+
+ QString salomemodules(getenv("SALOME_MODULES"));
+ if(salomemodules.isEmpty())
+ UpdateCompInfo_with_salomeappdir( QDir(extRootDir), resMgr );
+ else
+ UpdateCompInfo_with_salomemodules(salomemodules, QDir(extRootDir), resMgr);
+}
+
/*!On module activation action.*/
void LightApp_Application::onModuleActivation( const QString& modTitle )
{
// but I didn't compare the performance for each case.
PyLockWrapper lck; // acquire GIL
PyObjWrapper extensionUnpacker = PyImport_ImportModule((char*)"SalomeOnDemandTK.extension_unpacker");
+ PyObjWrapper runSalomeOnDemand = PyImport_ImportModule((char*)"runSalomeOnDemand");
// Loop via selected extensions files
foreach(QString path, paths)
continue;
}
+ PyObjWrapper pKeys = PyDict_Keys(unpackedModules);
// Iterate all the components (modules) for this extension
- for (Py_ssize_t pos = 0; pos < PyList_Size(unpackedModules); ++pos)
+ for (Py_ssize_t pos = 0; pos < PyDict_Size(unpackedModules); ++pos)
{
- auto moduleNameItem = PyList_GetItem(unpackedModules, pos);
+ auto moduleNameItem = PyList_GetItem(pKeys, pos);
+ auto interactiveItem = PyDict_GetItem(unpackedModules, moduleNameItem);
+
QString moduleName(PyUnicode_AsUTF8(moduleNameItem));
SCRUTE(moduleName.toStdString());
-
- addUserModule(moduleName, SalomeExtDir, true);
+ addUserModule(moduleName, SalomeExtDir, PyObject_IsTrue(interactiveItem));
}
// Add an extension to GUI
+ QFileInfo extFileInfo(path);
+ QString extName = extFileInfo.baseName();
if (moduleAction)
{
- QFileInfo extFileInfo(path);
- QString extName = extFileInfo.baseName();
moduleAction->insertExtension(extName);
}
+
+ // Update environment of salome
+ PyObjWrapper update_env = PyObject_CallMethod(
+ runSalomeOnDemand, (char*)"set_selext_env", (char*)"ss", extRootDir, extName.toStdString().c_str());
+ if (!update_env)
+ {
+ SUIT_MessageBox::warning(desktop(), tr("WRN_WARNING"), tr("WRN_FAILED_UPDATE_ENV").arg(extName + "_env.py") );
+ continue;
+ }
}
// Udate actions only once after all of them were already inserted
/*Add user module.*/
bool LightApp_Application::addUserModule( const QString& name, const QString& root, bool interactive )
{
+ if ( name == "KERNEL" || name == "GUI" )
+ return false; // skip KERNEL and GUI modules
+
if ( name.isEmpty() || root.isEmpty() )
return false;
// need to do that again.
// TODO: Maybe it's better to return ModuleInfo from appendModuleInfo() and check status.
const QString title = resMgr->stringValue(name, "name", QString()).trimmed();
- if (resMgr->booleanValue(name, "gui", false) || !title.isEmpty())
+ if (resMgr->booleanValue(name, "gui", false) || !title.isEmpty() && interactive)
{
// Append module to the menu / toolbar
LightApp_ModuleAction* moduleAction = qobject_cast<LightApp_ModuleAction*>(action(ModulesListId));
return result;
}
-/*!
- Log GUI action
-*/
-void LightApp_Application::logUserEvent(const QString& eventDescription)
-{
- static QString _gui_log_file_ = "Not initialized";
- static QMutex aGUILogMutex;
- if (_gui_log_file_ == "Not initialized") {
- std::cout << "!!!***aaajfa***!!! _gui_log_file_ initialization" << std::endl;
- _gui_log_file_ = "";
- QStringList args = QApplication::arguments();
- for (int i = 1; i < args.count(); i++) {
- QRegExp rxs ("--gui-log-file=(.+)");
- if (rxs.indexIn( args[i] ) >= 0 && rxs.capturedTexts().count() > 1) {
- QString file = rxs.capturedTexts()[1];
- QFileInfo fi ( file );
- if (!fi.isDir()) {
- if (fi.dir().exists()) {
- _gui_log_file_ = fi.absoluteFilePath();
- if (fi.exists()) {
- QFile file (_gui_log_file_);
- file.remove();
- }
- }
- }
- break;
- }
- }
- }
- if (_gui_log_file_ != "") {
- std::cout << "!!!***aaajfa***!!! log User Event: " << eventDescription.toStdString() << std::endl;
- QMutexLocker aLocker (&aGUILogMutex);
- QFile file (_gui_log_file_);
- if (file.open(QFile::Append)) {
- QTextStream stream( &file );
- stream << eventDescription << endl;
- file.close();
- }
- }
-}
-
#ifndef DISABLE_PYCONSOLE
PyConsole_Interp* LightApp_Application::getPyInterp()