From 96e6c9dd06e80bf945aaa196dfac373859774d08 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Sat, 6 May 2023 18:13:39 +0200 Subject: [PATCH] Fix a sync problem between the EquiWidget and the SelectionWidget. --- hurricane/src/viewer/CellWidget.cpp | 29 ++++++++++++++++--------- hurricane/src/viewer/SelectionModel.cpp | 2 +- tramontana/src/EquipotentialsWidget.cpp | 28 ++++++++++-------------- 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/hurricane/src/viewer/CellWidget.cpp b/hurricane/src/viewer/CellWidget.cpp index cffabcde..8cd3c6f8 100644 --- a/hurricane/src/viewer/CellWidget.cpp +++ b/hurricane/src/viewer/CellWidget.cpp @@ -2683,7 +2683,8 @@ namespace Hurricane { } else selected = false; - if ( (--_delaySelectionChanged == 0) and selected ) emit selectionChanged( _selectors ); + if ( (--_delaySelectionChanged == 0) and selected ) + emit selectionChanged( _selectors ); } @@ -2708,7 +2709,8 @@ namespace Hurricane { // } else // selected = false; - if ( (--_delaySelectionChanged == 0) and selected ) emit selectionChanged( _selectors ); + if ( (--_delaySelectionChanged == 0) and selected ) + emit selectionChanged( _selectors ); } @@ -2733,7 +2735,8 @@ namespace Hurricane { // } else // selected = false; - if ( (--_delaySelectionChanged == 0) and selected ) emit selectionChanged( _selectors ); + if ( (--_delaySelectionChanged == 0) and selected ) + emit selectionChanged( _selectors ); } @@ -2758,7 +2761,8 @@ namespace Hurricane { // } else // selected = false; - if ( (--_delaySelectionChanged == 0) and selected ) emit selectionChanged( _selectors ); + if ( (--_delaySelectionChanged == 0) and selected ) + emit selectionChanged( _selectors ); } @@ -2819,7 +2823,7 @@ namespace Hurricane { if ( (--_delaySelectionChanged == 0) and selected ) { if ( _state->showSelection() ) _redrawManager.refresh (); - emit selectionChanged(_selectors); + emit selectionChanged(_selectors); } } @@ -2857,7 +2861,8 @@ namespace Hurricane { } _selectionHasChanged = true; - if ( (_delaySelectionChanged == 0) and unselected ) emit selectionChanged( _selectors ); + if ( (_delaySelectionChanged == 0) and unselected ) + emit selectionChanged( _selectors ); } @@ -2869,7 +2874,8 @@ namespace Hurricane { unselect( Occurrence( component )); } } - if ( --_delaySelectionChanged == 0 ) emit selectionChanged( _selectors ); + if ( --_delaySelectionChanged == 0 ) + emit selectionChanged( _selectors ); } @@ -2881,7 +2887,8 @@ namespace Hurricane { unselect( occurrence ); } } - if ( --_delaySelectionChanged == 0 ) emit selectionChanged( _selectors ); + if ( --_delaySelectionChanged == 0 ) + emit selectionChanged( _selectors ); } @@ -2893,7 +2900,8 @@ namespace Hurricane { unselect( occurrence ); } } - if ( --_delaySelectionChanged == 0 ) emit selectionChanged( _selectors ); + if ( --_delaySelectionChanged == 0 ) + emit selectionChanged( _selectors ); } @@ -2904,7 +2912,8 @@ namespace Hurricane { _state->getSelection().clear (); _unselectAll (); - if ( --_delaySelectionChanged == 0 ) emit selectionChanged(_selectors); + if ( --_delaySelectionChanged == 0 ) + emit selectionChanged(_selectors); } diff --git a/hurricane/src/viewer/SelectionModel.cpp b/hurricane/src/viewer/SelectionModel.cpp index cc5dafbe..91646922 100644 --- a/hurricane/src/viewer/SelectionModel.cpp +++ b/hurricane/src/viewer/SelectionModel.cpp @@ -91,8 +91,8 @@ namespace Hurricane { { if (not _cellWidget) return; + if (not isCumulative()) clear (); beginResetModel(); - if (not isCumulative()) _selection.clear (); for ( Selector* selector : selection ) { if (not selector->isInModel(_cellWidget)) { diff --git a/tramontana/src/EquipotentialsWidget.cpp b/tramontana/src/EquipotentialsWidget.cpp index 5d7ef6b6..0f08d8ff 100644 --- a/tramontana/src/EquipotentialsWidget.cpp +++ b/tramontana/src/EquipotentialsWidget.cpp @@ -191,26 +191,22 @@ namespace Tramontana { _forceReselect = false; } - SelectedEquiSet::iterator remove; - SelectedEquiSet::iterator isel = _selecteds.begin (); + SelectedEquiSet::iterator isel = _selecteds.begin (); while ( isel != _selecteds.end() ) { - switch ( isel->getAccesses() ) { - case 1: break; - case 64: - emit equipotentialSelect ( isel->getEqui()->getFlatComponents() ); - break; - case 0: - emit equipotentialUnselect ( isel->getEqui()->getFlatComponents() ); - remove = isel; - ++isel; - _selecteds.erase( remove ); - continue; - default: - cerr << Bug( "EquipotentialsWidget::updateSelecteds(): invalid code %d" - , isel->getAccesses()) << endl; + SelectedEquiSet::iterator remove = isel++; + if (remove->getAccesses() == 0) { + emit equipotentialUnselect ( remove->getEqui()->getFlatComponents() ); + _selecteds.erase( remove ); + } + } + isel = _selecteds.begin (); + while ( isel != _selecteds.end() ) { + if (isel->getAccesses() == 64) { + emit equipotentialSelect ( isel->getEqui()->getFlatComponents() ); } ++isel; } + isel = _selecteds.begin (); if (_cellWidget) _cellWidget->closeRefreshSession (); }