| 5 | { |
| 6 | |
| 7 | std::pair<bool, int> filterHistoryActionsVector( HistoryActionsVector& historyVector, |
| 8 | HistoryStackFilter filteringCondition, size_t firstRedoIndex /*= 0*/, bool deepFiltering /*= true */ ) |
| 9 | { |
| 10 | bool needSignal = false; |
| 11 | int redoDecrease = 0; |
| 12 | for ( int i = ( int )historyVector.size() - 1; i >= 0; --i ) |
| 13 | { |
| 14 | if ( filteringCondition( historyVector[i] ) ) |
| 15 | { |
| 16 | if ( i < firstRedoIndex ) ++redoDecrease; |
| 17 | historyVector.erase( historyVector.begin() + i ); |
| 18 | needSignal = true; |
| 19 | } |
| 20 | else if ( deepFiltering ) |
| 21 | { |
| 22 | auto combinedAction = std::dynamic_pointer_cast< CombinedHistoryAction >( historyVector[i] ); |
| 23 | if ( !combinedAction ) |
| 24 | continue; |
| 25 | |
| 26 | needSignal = combinedAction->filter( filteringCondition ) || needSignal; |
| 27 | if ( combinedAction->empty() ) |
| 28 | { |
| 29 | if ( i < firstRedoIndex ) ++redoDecrease; |
| 30 | historyVector.erase( historyVector.begin() + i ); |
| 31 | needSignal = true; |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | return { needSignal, redoDecrease }; |
| 36 | } |
| 37 | |
| 38 | } //namespace MR |