Skip to content

Commit

Permalink
Supplement issue#163 : possibility of inserting into the python conso…
Browse files Browse the repository at this point in the history
…le a list made up of all the selected entities.
Charles PIGNEROL committed Jan 14, 2025
1 parent 68ab970 commit f2d99c7
Showing 2 changed files with 24 additions and 7 deletions.
26 changes: 20 additions & 6 deletions src/QtComponents/QtMgx3DPythonConsole.cpp
Original file line number Diff line number Diff line change
@@ -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 <Swig Object of type");
_insertSelectedEntitiesAction = new QAction (UTF8TOQSTRING (UTF8String ("Toutes entités", Charset::UTF_8)), this);
QObject::connect (_insertSelectedEntitiesAction, &QAction::triggered, this, [this]( ){ insertSelectionCallback (Utils::Entity::undefined); });
_insertSelectedVolumesAction = new QAction (UTF8TOQSTRING (UTF8String ("Volumes Géométriques", Charset::UTF_8)), this);
QObject::connect (_insertSelectedVolumesAction, &QAction::triggered, this, [this]( ){ insertSelectionCallback (Utils::Entity::GeomVolume); });
_insertSelectedSurfacesAction = new QAction (UTF8TOQSTRING (UTF8String ("Surfaces Géométriques", Charset::UTF_8)), this);
@@ -114,6 +117,7 @@ QtMgx3DPythonConsole::QtMgx3DPythonConsole (QWidget* parent, QtMgx3DMainWindow*
QtMgx3DPythonConsole::QtMgx3DPythonConsole (const QtMgx3DPythonConsole&)
: QtPythonConsole (0, ""),
_mgxUserScriptingManager (0), _mainWindow (0), _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)
@@ -427,12 +431,13 @@ void QtMgx3DPythonConsole::saveConsoleScript (const string filePath, Charset cha
void QtMgx3DPythonConsole::insertSelectionCallback (Utils::Entity::objectType type)
{
SelectionManagerIfc* sm = 0 == getMainWindow ( ) ? 0 : getMainWindow ( )->getSelectionManager ( );
if (0 != sm)
{
vector<Utils::Entity*> entities = sm->getEntities (type);
const string entitiesNames = Internal::entitiesToPythonList<Entity>(entities);
insertPlainText (entitiesNames.c_str ( ));
} // if (0 != sm)
if (0 == sm)
return;

const vector<Utils::Entity*> entities = Entity::undefined == type ? sm->getEntities ( ) : sm->getEntities (type);
const string entitiesNames = Internal::entitiesToPythonList<Entity>(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)
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f2d99c7

Please sign in to comment.