diff --git a/src/Core/Internal/Context.cpp b/src/Core/Internal/Context.cpp index b7c338a7..20348e7d 100644 --- a/src/Core/Internal/Context.cpp +++ b/src/Core/Internal/Context.cpp @@ -1710,67 +1710,6 @@ void Context::clearSession() // annulation de la sélection m_selection_manager->clearSelection ( ); - //creation de la commande de destruction - Internal::CommandComposite* command = new Internal::CommandComposite(*this, TkUtil::UTF8String ("Destruction de tout, les commandes précédentes n'ont plus lieu d'être ! ", TkUtil::Charset::UTF_8)); - - // trace dans le script - TkUtil::UTF8String cmd (TkUtil::Charset::UTF_8); - cmd << getContextAlias() << ".clearSession()"; - command->setScriptCommand(cmd); - - // commande de destruction de toutes les entités maillages qui ont pu être construites - Mesh::CommandDestroyMesh* commandMesh = new Mesh::CommandDestroyMesh(*this); - - command->addCommand(commandMesh); - - // commande de destruction de toutes les entités topologiques qui ont pu être construites - std::vector ve; - std::vector blocks; - getTopoManager().getBlocks(blocks); - for (uint i=0; i cofaces; - getTopoManager().getCoFaces(cofaces); - for (uint i=0; i coedges; - getTopoManager().getCoEdges(coedges); - for (uint i=0; i vertices; - getTopoManager().getVertices(vertices); - for (uint i=0; iaddCommand(commandTopo); - - // commande de destruction de toutes les entités géométriques qui ont pu être construites - std::vector entities; - std::vector volumes = getGeomManager().getVolumesObj(); - for (uint i=0; i surfaces = getGeomManager().getSurfacesObj(); - for (uint i=0; i curves = getGeomManager().getCurvesObj(); - for (uint i=0; i vtx = getGeomManager().getVerticesObj(); - for (uint i=0; iaddCommand(commandGeom); - - // TODO [EB] Destruction des SysCoord - - // on passe au gestionnaire de commandes qui exécute la commande en // ou non - // et la stocke dans le gestionnaire de undo-redo si c'est une réussite - getCommandManager().addCommand(command, Utils::Command::DO); - m_command_manager->clear(); m_name_manager->clear(); m_geom_manager->clear(); diff --git a/src/Core/Topo/TopoManager.cpp b/src/Core/Topo/TopoManager.cpp index 39965cfe..db5a1c4b 100644 --- a/src/Core/Topo/TopoManager.cpp +++ b/src/Core/Topo/TopoManager.cpp @@ -148,6 +148,7 @@ void TopoManager::clear() m_edges.deleteAndClear(); m_coedges.deleteAndClear(); m_vertices.deleteAndClear(); + m_geom_associations.clear(); m_defaultNbMeshingEdges = 10; } /*----------------------------------------------------------------------------*/ diff --git a/src/QtComponents/QtEntitiesItemViewPanel.cpp b/src/QtComponents/QtEntitiesItemViewPanel.cpp index 187424a0..7511d74b 100644 --- a/src/QtComponents/QtEntitiesItemViewPanel.cpp +++ b/src/QtComponents/QtEntitiesItemViewPanel.cpp @@ -110,6 +110,11 @@ void QtEntitiesItemViewPanel::setMainWindow (QtMgx3DMainWindow* mainWindow) } // QtEntitiesItemViewPanel::setMainWindow +void QtEntitiesItemViewPanel::sessionCleared ( ) +{ +} // QtEntitiesItemViewPanel::sessionCleared + + Mgx3D::Internal::Context& QtEntitiesItemViewPanel::getContext ( ) { if (0 == _context) diff --git a/src/QtComponents/QtEntitiesPanel.cpp b/src/QtComponents/QtEntitiesPanel.cpp index 3b6ea670..e0463343 100644 --- a/src/QtComponents/QtEntitiesPanel.cpp +++ b/src/QtComponents/QtEntitiesPanel.cpp @@ -222,8 +222,7 @@ void QtEntitiesGroupTreeWidgetItem::setRepresentationMask (unsigned long mask) } // QtEntitiesGroupTreeWidgetItem::setRepresentationMask -DisplayRepresentation::display_type - QtEntitiesGroupTreeWidgetItem::getEntitiesType ( ) const +DisplayRepresentation::display_type QtEntitiesGroupTreeWidgetItem::getEntitiesType ( ) const { return _entitiesType; } // QtEntitiesGroupTreeWidgetItem::getEntitiesType @@ -328,6 +327,12 @@ const Entity* QtEntityTreeWidgetItem::getEntity ( ) const } // QtEntityTreeWidgetItem::getEntity +void QtEntityTreeWidgetItem::releaseEntity ( ) +{ + _entity = 0; +} // QtEntityTreeWidgetItem::releaseEntity + + unsigned long QtEntityTreeWidgetItem::getNativeRepresentationMask ( ) const { return _3dRep; @@ -1510,6 +1515,53 @@ void QtEntitiesPanel::updateEntryItems (DisplayRepresentation::display_type type } // QtEntitiesPanel::updateEntryItems +static void clearEntityTreeWidgetItemList (QTreeWidgetItem& entry) +{ + QList items = entry.takeChildren ( ); + for (int i = 0; i < items.size ( ); i++) + { + QtEntityTreeWidgetItem* entityItem = dynamic_cast(items.at (i)); + if (0 != entityItem) + entityItem->releaseEntity ( ); + delete items.at (i); + } // for (int i = 0; i < items.size ( ); i++) + entry.setCheckState (0, Qt::Unchecked); +} // clearEntityTreeWidgetItemList + + +void QtEntitiesPanel::sessionCleared ( ) +{ + CHECK_NULL_PTR_ERROR (_cadVolumesItem) + CHECK_NULL_PTR_ERROR (_cadSurfacesItem) + CHECK_NULL_PTR_ERROR (_cadCurvesItem) + CHECK_NULL_PTR_ERROR (_cadCloudsItem) + CHECK_NULL_PTR_ERROR (_topoBlocksItem) + CHECK_NULL_PTR_ERROR (_topoFacesItem) + CHECK_NULL_PTR_ERROR (_topoEdgesItem) + CHECK_NULL_PTR_ERROR (_topoVerticesItem) + CHECK_NULL_PTR_ERROR (_meshVolumesItem) + CHECK_NULL_PTR_ERROR (_meshSurfacesItem) + CHECK_NULL_PTR_ERROR (_meshLinesItem) + CHECK_NULL_PTR_ERROR (_meshCloudsItem) + CHECK_NULL_PTR_ERROR (_sysCoordItem) + CHECK_NULL_PTR_ERROR (_structuredMeshVolumesItem) + clearEntityTreeWidgetItemList (*_cadVolumesItem); + clearEntityTreeWidgetItemList (*_cadSurfacesItem); + clearEntityTreeWidgetItemList (*_cadCurvesItem); + clearEntityTreeWidgetItemList (*_cadCloudsItem); + clearEntityTreeWidgetItemList (*_topoBlocksItem); + clearEntityTreeWidgetItemList (*_topoFacesItem); + clearEntityTreeWidgetItemList (*_topoEdgesItem); + clearEntityTreeWidgetItemList (*_topoVerticesItem); + clearEntityTreeWidgetItemList (*_meshVolumesItem); + clearEntityTreeWidgetItemList (*_meshSurfacesItem); + clearEntityTreeWidgetItemList (*_meshLinesItem); + clearEntityTreeWidgetItemList (*_meshCloudsItem); + clearEntityTreeWidgetItemList (*_sysCoordItem); + clearEntityTreeWidgetItemList (*_structuredMeshVolumesItem); +} // QtEntitiesPanel::sessionCleared + + void QtEntitiesPanel::entitiesAddedToSelection (const vector& entities) { for (vector::const_iterator it = entities.begin ( ); diff --git a/src/QtComponents/QtGroupsPanel.cpp b/src/QtComponents/QtGroupsPanel.cpp index 73a2e909..7c76fd02 100644 --- a/src/QtComponents/QtGroupsPanel.cpp +++ b/src/QtComponents/QtGroupsPanel.cpp @@ -641,6 +641,18 @@ vector QtGroupsPanel::getSelectedGroups ( ) const } // QtGroupsPanel::getSelectedGroups +void QtGroupsPanel::sessionCleared ( ) +{ + // Rem : ça détruit également la vue multi-niveaux + for (vector::iterator itge = _groupsEntriesItems.begin ( ); itge != _groupsEntriesItems.end ( ); itge++) + { + QList items = (*itge)->takeChildren ( ); + for (int i = 0; i < items.size ( ); i++) + delete items.at (i); + } // for (vector::iterator itge = _groupsEntriesItems.begin ( ); itge != _groupsEntriesItems.end ( ); itge++) +} // QtGroupsPanel::sessionCleared + + void QtGroupsPanel::displaySelectedTypes (bool display) { if (true == getGraphicalWidget ( )->getRenderingManager ( ).displayLocked ( )) diff --git a/src/QtComponents/QtMgx3DMainWindow.cpp b/src/QtComponents/QtMgx3DMainWindow.cpp index 519ea90e..80992bb0 100644 --- a/src/QtComponents/QtMgx3DMainWindow.cpp +++ b/src/QtComponents/QtMgx3DMainWindow.cpp @@ -5395,7 +5395,7 @@ cout << __FILE__ << ' ' << __LINE__ << " QtMgx3DMainWindow::exitCallback" << end BEGIN_QT_TRY_CATCH_BLOCK - DISABLE_COMMAND_ACTIONS + DISABLE_COMMAND_ACTIONS DISABLE_GRAPHICAL_OPERATIONS getContext().redo(); @@ -5429,7 +5429,11 @@ cout << __FILE__ << ' ' << __LINE__ << " QtMgx3DMainWindow::exitCallback" << end BEGIN_QT_TRY_CATCH_BLOCK - getContext().clearSession(); + DISABLE_GRAPHICAL_OPERATIONS + + getContext ( ).clearSession ( ); + getGroupsPanel ( ).sessionCleared ( ); + getEntitiesPanel ( ).sessionCleared ( ); COMPLETE_QT_TRY_CATCH_BLOCK(true, this, getAppTitle()) } // QtMgx3DMainWindow::reinitializeCallback diff --git a/src/QtComponents/protected/QtComponents/QtEntitiesItemViewPanel.h b/src/QtComponents/protected/QtComponents/QtEntitiesItemViewPanel.h index 97fdc492..bec47743 100644 --- a/src/QtComponents/protected/QtComponents/QtEntitiesItemViewPanel.h +++ b/src/QtComponents/protected/QtComponents/QtEntitiesItemViewPanel.h @@ -25,14 +25,10 @@ class QtMgx3DMainWindow; /** - * \brief Panneau abstrait de l'IHM Magix 3D affichant des entités - * d'une session Magix 3D. - * L'affichage est ici a priori textuel et couplé à un affichage - * dans une fenêtre graphique 3D. + * \brief Panneau abstrait de l'IHM Magix 3D affichant des entités d'une session Magix 3D. + * L'affichage est ici a priori textuel et couplé à un affichage dans une fenêtre graphique 3D. * - *

L'objectif de cette classe non instanciable est de factoriser - * certains services des vues textuelles type QTreeWidget - * d'entités. + *

L'objectif de cette classe non instanciable est de factoriser certains services des vues textuelles type QTreeWidget d'entités. *

*/ class QtEntitiesItemViewPanel : public QtGroupBox @@ -45,9 +41,7 @@ class QtEntitiesItemViewPanel : public QtGroupBox * \param Nom du panneau. * \param Contexte Magix 3D du panneau */ - QtEntitiesItemViewPanel ( - QWidget* parent, QtMgx3DMainWindow* mainWindow, - const std::string& name, Internal::Context& context); + QtEntitiesItemViewPanel (QWidget* parent, QtMgx3DMainWindow* mainWindow, const std::string& name, Internal::Context& context); /** * RAS. @@ -73,6 +67,11 @@ class QtEntitiesItemViewPanel : public QtGroupBox */ virtual void setMainWindow (QtMgx3DMainWindow*); + /** + * A appeler lorsque la session est réinitialisée, doit réinitialiser le panneau. Ne fait rien par défaut, à surcharger. + */ + virtual void sessionCleared ( ); + /** * La gestion de la sélection. */ @@ -99,11 +98,8 @@ class QtEntitiesItemViewPanel : public QtGroupBox //@{ /** - * \param La fenêtre graphique à utiliser pour les affichages 3D, - * ou 0. - * \exception Une exception est levée si la fenêtre transmise en - * argument est non nulle et qu'une autre fenêtre est déjà - * affectée. + * \param La fenêtre graphique à utiliser pour les affichages 3D, ou 0. + * \exception Une exception est levée si la fenêtre transmise en argument est non nulle et qu'une autre fenêtre est déjà affectée. * \see getGraphicalWidget */ virtual void setGraphicalWidget (Qt3DGraphicalWidget* widget3D); @@ -129,22 +125,18 @@ class QtEntitiesItemViewPanel : public QtGroupBox virtual void setLogStream (TkUtil::LogOutputStream* stream); /** - * \param Ecrit le log transmis en argument dans le flux - * d'informations associé. + * \param Ecrit le log transmis en argument dans le flux d'informations associé. */ virtual void log (const TkUtil::Log& log); //@} // La gestion des informations à remonter à l'utilisateur. /** - * Appelé pour modifier les paramètres d'affichage - * (points/filaire/surfacique) des entités données en argument. Affiche une - * boite de dialogue de choix des types de représentation à utiliser, - * initialisé selon les entités transmises en argument, et effectue les + * Appelé pour modifier les paramètres d'affichage (points/filaire/surfacique) des entités données en argument. Affiche une + * boite de dialogue de choix des types de représentation à utiliser, initialisé selon les entités transmises en argument, et effectue les * modifications demandées. */ - virtual void changeRepresentationTypes ( - const std::vector& entities); + virtual void changeRepresentationTypes (const std::vector& entities); protected : diff --git a/src/QtComponents/protected/QtComponents/QtEntitiesPanel.h b/src/QtComponents/protected/QtComponents/QtEntitiesPanel.h index a64dfc90..bd3cde57 100644 --- a/src/QtComponents/protected/QtComponents/QtEntitiesPanel.h +++ b/src/QtComponents/protected/QtComponents/QtEntitiesPanel.h @@ -54,6 +54,11 @@ class QtEntityTreeWidgetItem : */ virtual ~QtEntityTreeWidgetItem ( ); + /** + * Oublie l'entité représentée. + */ + virtual void releaseEntity ( ); + /** * \return L'entité représentée. */ @@ -757,6 +762,11 @@ class QtEntitiesPanel :public QtEntitiesItemViewPanel, public Internal::Selectio */ virtual void updateEntryItems (Mgx3D::Utils::DisplayRepresentation::display_type type); + /** + * A appeler lorsque la session est réinitialisée, doit réinitialiser le panneau. Ne fait rien par défaut, à surcharger. + */ + virtual void sessionCleared ( ); + //@} /** diff --git a/src/QtComponents/protected/QtComponents/QtGroupsPanel.h b/src/QtComponents/protected/QtComponents/QtGroupsPanel.h index d8915db3..d2765295 100644 --- a/src/QtComponents/protected/QtComponents/QtGroupsPanel.h +++ b/src/QtComponents/protected/QtComponents/QtGroupsPanel.h @@ -396,6 +396,11 @@ class QtGroupsPanel : public QtEntitiesItemViewPanel, public Internal::Selection */ virtual std::vector getSelectedGroups ( ) const; + /** + * A appeler lorsque la session est réinitialisée, doit réinitialiser le panneau. Ne fait rien par défaut, à surcharger. + */ + virtual void sessionCleared ( ); + //@} // Les groupes représentés. /** @@ -760,7 +765,6 @@ class QtGroupsPanel : public QtEntitiesItemViewPanel, public Internal::Selection */ virtual void clearGroupCallback ( ); - /** * Appelé lorsque le menu popup est demandé au niveau de l'arborescence des types d'entités à afficher. Affiche ce menu popup à la position transmise en argument. */