From: Konstantin Leontev Date: Fri, 30 Dec 2022 17:14:45 +0000 (+0300) Subject: [bos #32523][EDF] SALOME on Demand GUI. Added draft version of INFO dialog where... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e7901e43d086af894364b455782279b7517896d5;p=modules%2Fgui.git [bos #32523][EDF] SALOME on Demand GUI. Added draft version of INFO dialog where dependency tree shows as a list. --- diff --git a/src/LightApp/CMakeLists.txt b/src/LightApp/CMakeLists.txt index e42e7d7e4..16cc420b6 100644 --- a/src/LightApp/CMakeLists.txt +++ b/src/LightApp/CMakeLists.txt @@ -100,7 +100,7 @@ SET(_link_LIBRARIES ${OpenCASCADE_FoundationClasses_LIBRARIES} ${QT_LIBRARIES} ${HDF5_LIBRARIES} - CASCatch qtx suit std SalomeStyle SalomePrs CAM LogWindow ObjBrowser Event + CASCatch qtx suit std SalomeStyle SalomePrs CAM LogWindow ObjBrowser Event ${KERNEL_SalomeHDFPersist} ${KERNEL_SALOMELocalTrace} ) IF(SALOME_USE_SALOMEOBJECT) @@ -146,7 +146,7 @@ ENDIF() # --- headers --- # header files / to be processed by moc -SET(_moc_HEADERS +SET(_moc_HEADERS LightApp_AboutDlg.h LightApp_Application.h LightApp_DataModel.h @@ -164,6 +164,7 @@ SET(_moc_HEADERS LightApp_Study.h LightApp_SwitchOp.h LightApp_WgViewModel.h + LightApp_ExtInfoDlg.h ) IF(SALOME_USE_GLVIEWER) LIST(APPEND _moc_HEADERS LightApp_GLSelector.h) @@ -270,6 +271,7 @@ SET(_other_SOURCES LightApp_Study.cxx LightApp_SwitchOp.cxx LightApp_WgViewModel.cxx + LightApp_ExtInfoDlg.cxx ) IF(SALOME_USE_GLVIEWER) LIST(APPEND _other_SOURCES LightApp_GLSelector.cxx) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 49972104e..177d39d75 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -50,6 +50,7 @@ #include "LightApp_PreferencesDlg.h" #include "LightApp_ModuleDlg.h" #include "LightApp_AboutDlg.h" +#include "LightApp_ExtInfoDlg.h" #include "LightApp_ModuleAction.h" // temporary commented #include "LightApp_EventFilter.h" @@ -700,7 +701,7 @@ void LightApp_Application::createActions() foreach( QString aModule, aModuleList ) createHelpItems( aModule ); - + // f) Additional help items int id = LightApp_Application::UserID + FIRST_HELP_ID + 1000; @@ -743,6 +744,8 @@ void LightApp_Application::createActions() this, SLOT( onModuleAdding() ) ); connect( moduleAction, SIGNAL( removing( QString ) ), this, SLOT( onModuleRemoving( QString ) ) ); + connect( moduleAction, SIGNAL(showExtInfo()), + this, SLOT(onShowExtInfo())); // New window int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 ); @@ -1044,6 +1047,14 @@ void LightApp_Application::onModuleRemoving( const QString& title ) updateWindows(); } +/*!On show extension info action.*/ +void LightApp_Application::onShowExtInfo() +{ + // Show dialog with information about loaded salome extensions + LightApp_ExtInfoDlg dlg(desktop()); + dlg.exec(); +} + /*!Default module activation.*/ QString LightApp_Application::defaultModule() const { @@ -1131,16 +1142,16 @@ void LightApp_Application::onNewDoc() void LightApp_Application::onOpenDoc() { SUIT_Study* study = activeStudy(); - + if ( !checkExistingDoc( false ) ) return; - + QString aName = getFileName( true, QString(), getFileFilter( true ), QString(), 0 ); if ( aName.isNull() ) //Cancel return; - + onOpenDoc( aName ); - + if ( !study ) // new study will be create in THIS application { updateWindows(); @@ -1327,7 +1338,7 @@ protected: #else QString cmdLine = QString( "%1 %2 \"%3\"" ).arg( myBrowser, myParameters, myUrl ); // remove LD_LIBRARY_PATH from the environement before starting launcher to avoid bad interactions. - // (especially in the case of universal binaries) + // (especially in the case of universal binaries) env.remove("LD_LIBRARY_PATH"); #endif QProcess* proc = new QProcess(); @@ -2984,7 +2995,7 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) int vtkSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), vtkGroup ); pref->setItemProperty( "columns", 2, vtkSelectionGroup ); // .... -> preselection - int vtkPreselection = pref->addPreference( tr( "PREF_PRESELECTION" ), vtkSelectionGroup, + int vtkPreselection = pref->addPreference( tr( "PREF_PRESELECTION" ), vtkSelectionGroup, LightApp_Preferences::Selector, "VTKViewer", "preselection" ); aValuesList.clear(); anIndicesList.clear(); @@ -3009,7 +3020,7 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) int spacemousePref2 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_2" ), vtkSM, LightApp_Preferences::Selector, "VTKViewer", "spacemouse_func2_btn" ); - // .... -> dominant / combined switch + // .... -> dominant / combined switch int spacemousePref3 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_3" ), vtkSM, LightApp_Preferences::Selector, "VTKViewer", "spacemouse_func5_btn" ); // @@ -4374,7 +4385,7 @@ void LightApp_Application::loadDockWindowsState() aResMgr->value( "windows_visibility", modName, aDefaultVisibility ); bool hasDefaultVisibility = !aDefaultVisibility.isEmpty(); aResMgr->setWorkingMode( prevMode ); - + if( !storeWin && !storeTb && aDefaultState.isEmpty() && !hasDefaultVisibility) return; @@ -4399,13 +4410,13 @@ void LightApp_Application::loadDockWindowsState() QMap *tbMap = 0; QMap *dwMap = 0; - + QMap userTbMap, userDwMap; dockWindowsState( myWinVis[modName], userTbMap, userDwMap ); QMap defaultTbMap, defaultDwMap; if(hasDefaultVisibility) { - dockWindowsState( aDefaultVisibility, defaultTbMap, defaultDwMap); + dockWindowsState( aDefaultVisibility, defaultTbMap, defaultDwMap); } if(storeTb) { @@ -4427,9 +4438,9 @@ void LightApp_Application::loadDockWindowsState() if(tbMap) { QList tbList = findToolBars(); for ( QList::iterator tit = tbList.begin(); tit != tbList.end(); ++tit ) - { + { QToolBar* tb = *tit; - if ( tbMap->contains( tb->objectName() ) ) { + if ( tbMap->contains( tb->objectName() ) ) { tb->setVisible( (*tbMap)[tb->objectName()] ); } } @@ -4440,11 +4451,11 @@ void LightApp_Application::loadDockWindowsState() for ( QList::iterator dit = dwList.begin(); dit != dwList.end(); ++dit ) { QDockWidget* dw = *dit; - + QObject* po = Qtx::findParent( dw, "QMainWindow" ); if ( po != desktop() ) continue; - + if ( dwMap->contains( dw->objectName() ) ) dw->setVisible( (*dwMap)[dw->objectName()] ); } @@ -5152,7 +5163,7 @@ void LightApp_Application::onDesktopMessage( const QString& message ) } else if ( message.toLower().startsWith("register_module_in_study" ) ) { QString moduleName = message.split( sectionSeparator ).last(); - // Check name of current activating module name in order to avoid ciclik + // Check name of current activating module name in order to avoid ciclik // call because of messages if (!property("activateModule").toBool()) { CAM_Module* mod = module(moduleName); @@ -5215,7 +5226,7 @@ void LightApp_Application::onInfoPanelShown() } /*! - Internal method. + Internal method. Returns all top level toolbars. Note : Result list contains only main window toolbars, not including toolbars from viewers. */ diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index aae6c005e..8cfc7b647 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -265,6 +265,7 @@ protected slots: virtual void onModuleActivation( const QString& ); void onModuleAdding(); void onModuleRemoving( const QString& ); + void onShowExtInfo(); void onCloseView( SUIT_ViewManager* ); virtual void onStudyCreated( SUIT_Study* ); diff --git a/src/LightApp/LightApp_ExtInfoDlg.cxx b/src/LightApp/LightApp_ExtInfoDlg.cxx new file mode 100644 index 000000000..491565a93 --- /dev/null +++ b/src/LightApp/LightApp_ExtInfoDlg.cxx @@ -0,0 +1,182 @@ +// Copyright (C) 2007-2022 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, 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 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See https://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// File: LightApp_ExtInfoDlg.cxx +// Author: Konstantin Leontev +// +#include "LightApp_ExtInfoDlg.h" +#include "LightApp_Application.h" +#include "utilities.h" + +// Prevent slot compilation error +#pragma push_macro("slots") +#undef slots +#include "PyInterp_Utils.h" +#pragma pop_macro("slots") + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include // to get path to the file + +/*!Constructor.*/ +LightApp_ExtInfoDlg::LightApp_ExtInfoDlg(QWidget* parent) +: QtxDialog(parent, true, true, ButtonFlags::OK) +{ + MESSAGE("Start creating a dialog...\n"); + + setObjectName("salome_ext_info_dialog"); + QString capText = tr("EXT_INFO_CAPTION"); + setWindowTitle(capText); + setSizeGripEnabled(true); + setButtonPosition(ButtonPosition::Center, ButtonFlags::OK); + + auto extInfoWiget = getExtListWidget(mainFrame()); + auto extTreeWiget = getExtTreeWidget(mainFrame()); + + auto layout = new QHBoxLayout(mainFrame()); + layout->addWidget(extInfoWiget); + layout->addWidget(extTreeWiget); + layout->setStretch(0, 5); + layout->setStretch(1, 5); +} + +/*!Destructor.*/ +LightApp_ExtInfoDlg::~LightApp_ExtInfoDlg() +{ + //! Do nothing. +} + +/*! Return widget with info about installed extensions */ +QWidget* LightApp_ExtInfoDlg::getExtListWidget(QWidget* parent) const +{ + MESSAGE("Start to get modules info...\n"); + + auto extListWidget = new QWidget(parent); + auto app = dynamic_cast(SUIT_Session::session()->activeApplication()); + ASSERT(app); + if (!app) + { + return extListWidget; + } + + auto gridLayout = new QGridLayout(extListWidget); + gridLayout->setSpacing(5); + + // Import Python module that manages SALOME extensions + PyLockWrapper lck; // acquire GIL + PyObjWrapper extensionQuery = PyImport_ImportModule((char*)"SalomeOnDemandTK.extension_query"); + auto extRootDir = getenv("SALOME_APPLICATION_DIR"); + PyObjWrapper extInfoDict = PyObject_CallMethod(extensionQuery, (char*)"ext_info_dict", (char*)"s", extRootDir); + ASSERT(extInfoDict); + + if (extInfoDict) + { + PyObject *key = nullptr; + PyObject *value = nullptr; + Py_ssize_t pos = 0; + + while (PyDict_Next(extInfoDict, &pos, &key, &value)) + { + auto name = new QLabel(PyUnicode_AsUTF8(key), extListWidget); + auto size = new QLabel(PyUnicode_AsUTF8(value), extListWidget); + + gridLayout->addWidget(name , pos, 0); + gridLayout->addWidget(size , pos, 1); + + SCRUTE(name->text().toStdString()); + SCRUTE(size->text().toStdString()); + } + } + else + { + PyErr_Print(); + } + + return extListWidget; +} + +/*! Return widget with an image of dependency tree fot installed extensions */ +QWidget* LightApp_ExtInfoDlg::getExtTreeWidget(QWidget* parent) const +{ + MESSAGE("Start to get extensions dependency tree...\n"); + + auto extTreeWidget = new QWidget(parent); + auto app = dynamic_cast(SUIT_Session::session()->activeApplication()); + ASSERT(app); + if (!app) + { + return extTreeWidget; + } + + // TODO: replace this list with diagram + auto gridLayout = new QGridLayout(extTreeWidget); + gridLayout->setSpacing(5); + + // Import Python module that manages SALOME extensions + PyLockWrapper lck; // acquire GIL + PyObjWrapper extensionQuery = PyImport_ImportModule((char*)"SalomeOnDemandTK.extension_query"); + auto extRootDir = getenv("SALOME_APPLICATION_DIR"); + PyObjWrapper dependencyTree = PyObject_CallMethod(extensionQuery, (char*)"dependency_tree", (char*)"s", extRootDir); + ASSERT(dependencyTree); + + if (dependencyTree) + { + PyObject *extName = nullptr; + PyObject *dependantsList = nullptr; + Py_ssize_t pos = 0; + + // Iterate the tree + while (PyDict_Next(dependencyTree, &pos, &extName, &dependantsList)) + { + auto name = new QLabel(PyUnicode_AsUTF8(extName), extTreeWidget); + gridLayout->addWidget(name, pos, 0); + + SCRUTE(name->text().toStdString()); + + // Iterate a list of dependants + for (Py_ssize_t depPos = 0; depPos < PyList_Size(dependantsList); ++depPos) + { + auto dependant = PyList_GetItem(dependantsList, depPos); + auto dependantLabel = new QLabel(PyUnicode_AsUTF8(dependant), extTreeWidget); + gridLayout->addWidget(dependantLabel , pos, depPos + 1); + + SCRUTE(dependantLabel->text().toStdString()); + } + } + } + else + { + PyErr_Print(); + } + + return extTreeWidget; +} diff --git a/src/LightApp/LightApp_ExtInfoDlg.h b/src/LightApp/LightApp_ExtInfoDlg.h new file mode 100644 index 000000000..16183bc30 --- /dev/null +++ b/src/LightApp/LightApp_ExtInfoDlg.h @@ -0,0 +1,52 @@ +// Copyright (C) 2007-2022 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, 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 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See https://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// File: LightApp_ExtInfoDlg.h +// Author: Konstantin Leontev +// +#ifndef LIGHTAPP_EXTINFODLG_H +#define LIGHTAPP_EXTINFODLG_H + +#include "LightApp.h" + +#include + +class QLabel; + +/*! + \class LightApp_ExtInfoDlg + LightApp dialog with info about loaded extensions +*/ +class LIGHTAPP_EXPORT LightApp_ExtInfoDlg : public QtxDialog +{ + Q_OBJECT + +public: + LightApp_ExtInfoDlg(QWidget* = 0); + virtual ~LightApp_ExtInfoDlg(); + +private: + QWidget* getExtListWidget(QWidget* parent) const; + QWidget* getExtTreeWidget(QWidget* parent) const; +}; + +#endif diff --git a/src/LightApp/LightApp_ModuleAction.cxx b/src/LightApp/LightApp_ModuleAction.cxx index 592087f51..95bf1c54b 100644 --- a/src/LightApp/LightApp_ModuleAction.cxx +++ b/src/LightApp/LightApp_ModuleAction.cxx @@ -267,6 +267,7 @@ LightApp_ModuleAction::LightApp_ModuleAction( QtxResourceMgr* resMgr, QObject* p connect( this, SIGNAL( changed() ), this, SLOT( onChanged() ) ); connect( myAdd, SIGNAL( triggered( bool ) ), this, SIGNAL( adding() ) ); + connect( myInfo, SIGNAL( triggered( bool ) ), this, SIGNAL( showExtInfo() ) ); connect( mySet, SIGNAL( triggered( int ) ), this, SLOT( onTriggered( int ) ) ); connect( myCombo, SIGNAL( activatedId( int ) ), this, SLOT( onComboActivated( int ) ) ); connect( myMapper, SIGNAL( mapped( QString ) ), this, SIGNAL( removing( QString ) ) ); diff --git a/src/LightApp/LightApp_ModuleAction.h b/src/LightApp/LightApp_ModuleAction.h index 2bf77f589..060993f49 100644 --- a/src/LightApp/LightApp_ModuleAction.h +++ b/src/LightApp/LightApp_ModuleAction.h @@ -87,6 +87,7 @@ signals: void moduleActivated( const QString& ); void adding(); void removing( const QString& ); + void showExtInfo(); private: void update(); diff --git a/src/LightApp/resources/LightApp_msg_en.ts b/src/LightApp/resources/LightApp_msg_en.ts index 7efdd23bc..feeeb07bb 100644 --- a/src/LightApp/resources/LightApp_msg_en.ts +++ b/src/LightApp/resources/LightApp_msg_en.ts @@ -26,6 +26,10 @@ CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITASABOUT_MODULE_INFOS Modules information + + EXT_INFO_CAPTION + Extensions information + ABOUT_UNKNOWN_VERSION Unknown diff --git a/src/LightApp/resources/LightApp_msg_fr.ts b/src/LightApp/resources/LightApp_msg_fr.ts index 2653b5661..4f6e4f583 100644 --- a/src/LightApp/resources/LightApp_msg_fr.ts +++ b/src/LightApp/resources/LightApp_msg_fr.ts @@ -26,6 +26,10 @@ CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITASABOUT_MODULE_INFOS Modules + + EXT_INFO_CAPTION + Informations sur les extensions + ABOUT_UNKNOWN_VERSION Inconnue diff --git a/src/LightApp/resources/LightApp_msg_ja.ts b/src/LightApp/resources/LightApp_msg_ja.ts index 50e43b8f3..a14272bf9 100644 --- a/src/LightApp/resources/LightApp_msg_ja.ts +++ b/src/LightApp/resources/LightApp_msg_ja.ts @@ -26,6 +26,10 @@ CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITASABOUT_MODULE_INFOS モジュール情報 + + EXT_INFO_CAPTION + 内線情報 + ABOUT_UNKNOWN_VERSION 不明