From f2d99c777637d6eafb20fc161f78c2f5159c2533 Mon Sep 17 00:00:00 2001 From: Charles PIGNEROL <> Date: Tue, 14 Jan 2025 15:26:52 +0100 Subject: [PATCH] Supplement issue#163 : possibility of inserting into the python console a list made up of all the selected entities. --- src/QtComponents/QtMgx3DPythonConsole.cpp | 26 ++++++++++++++----- .../QtComponents/QtMgx3DPythonConsole.h | 5 +++- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/QtComponents/QtMgx3DPythonConsole.cpp b/src/QtComponents/QtMgx3DPythonConsole.cpp index 5f79503..ab39283 100644 --- a/src/QtComponents/QtMgx3DPythonConsole.cpp +++ b/src/QtComponents/QtMgx3DPythonConsole.cpp @@ -79,11 +79,14 @@ namespace QtComponents QtMgx3DPythonConsole::QtMgx3DPythonConsole (QWidget* parent, QtMgx3DMainWindow* mainWindow, const string& title) : QtPythonConsole (parent, title), _mgxUserScriptingManager (0), _mainWindow (mainWindow), _graphicalWidget (0), _cmdMgrPolicy ((CommandManagerIfc::POLICY)-1), + _insertSelectedEntitiesAction (0), _insertSelectedVolumesAction (0), _insertSelectedSurfacesAction (0), _insertSelectedCurvesAction (0), _insertSelectedGeomVerticesAction (0), _insertSelectedBlocksAction (0), _insertSelectedFacesAction (0), _insertSelectedEdgesAction (0), _insertSelectedTopoVerticesAction (0), _insertSelectedMeshVolumesAction (0), _insertSelectedMeshSurfacesAction (0), _insertSelectedLinesAction (0), _insertSelectedCloudsAction (0) { hideResult ("proxy of getSelectionManager ( ); - if (0 != sm) - { - vector entities = sm->getEntities (type); - const string entitiesNames = Internal::entitiesToPythonList(entities); - insertPlainText (entitiesNames.c_str ( )); - } // if (0 != sm) + if (0 == sm) + return; + + const vector entities = Entity::undefined == type ? sm->getEntities ( ) : sm->getEntities (type); + const string entitiesNames = Internal::entitiesToPythonList(entities); + + insertPlainText (entitiesNames.c_str ( )); } // QtMgx3DPythonConsole::insertSelectionCallback @@ -444,6 +449,8 @@ QMenu* QtMgx3DPythonConsole::createPopupMenu ( ) menu->addSeparator ( ); QMenu* entry = new QMenu ("Insérer sélection", menu); menu->addMenu (entry); + entry->addAction (&insertSelectedEntitiesAction ( )); + entry->addSeparator ( ); entry->addAction (&insertSelectedVolumesAction ( )); entry->addAction (&insertSelectedSurfacesAction ( )); entry->addAction (&insertSelectedCurvesAction ( )); @@ -464,6 +471,13 @@ QMenu* QtMgx3DPythonConsole::createPopupMenu ( ) } // QtMgx3DPythonConsole::createPopupMenu +QAction& QtMgx3DPythonConsole::insertSelectedEntitiesAction ( ) +{ + CHECK_NULL_PTR_ERROR (_insertSelectedEntitiesAction) + return *_insertSelectedEntitiesAction; +} // QtMgx3DPythonConsole::insertSelectedEntitiesAction + + QAction& QtMgx3DPythonConsole::insertSelectedVolumesAction ( ) { CHECK_NULL_PTR_ERROR (_insertSelectedVolumesAction) diff --git a/src/QtComponents/protected/QtComponents/QtMgx3DPythonConsole.h b/src/QtComponents/protected/QtComponents/QtMgx3DPythonConsole.h index cdf6d39..4d2940f 100644 --- a/src/QtComponents/protected/QtComponents/QtMgx3DPythonConsole.h +++ b/src/QtComponents/protected/QtComponents/QtMgx3DPythonConsole.h @@ -115,6 +115,7 @@ class QtMgx3DPythonConsole : public QtPythonConsole /** * Insère à l'emplacement du curseur la sélection courante correspondant au type transmis en argument. + * Si type vaut Entity::undefined insère alors toutes les entités sélectionnées, quelque soit leur type. */ virtual void insertSelectionCallback (Utils::Entity::objectType type); @@ -128,6 +129,7 @@ class QtMgx3DPythonConsole : public QtPythonConsole virtual QMenu* createPopupMenu ( ); /** Les actions d'insertion de la sélection courante. */ + virtual QAction& insertSelectedEntitiesAction ( ); virtual QAction& insertSelectedVolumesAction ( ); virtual QAction& insertSelectedSurfacesAction ( ); virtual QAction& insertSelectedCurvesAction ( ); @@ -174,7 +176,8 @@ class QtMgx3DPythonConsole : public QtPythonConsole Mgx3D::Utils::CommandManagerIfc::POLICY _cmdMgrPolicy; /** Les actions d'insertion de la sélection courante. */ - QAction *_insertSelectedVolumesAction, *_insertSelectedSurfacesAction, *_insertSelectedCurvesAction, *_insertSelectedGeomVerticesAction, + QAction *_insertSelectedEntitiesAction, + *_insertSelectedVolumesAction, *_insertSelectedSurfacesAction, *_insertSelectedCurvesAction, *_insertSelectedGeomVerticesAction, *_insertSelectedBlocksAction, *_insertSelectedFacesAction, *_insertSelectedEdgesAction, *_insertSelectedTopoVerticesAction, *_insertSelectedMeshVolumesAction, *_insertSelectedMeshSurfacesAction, *_insertSelectedLinesAction, *_insertSelectedCloudsAction; }; // class QtMgx3DPythonConsole