Clean up UI for resetting unit groups
By default, we want to maintain unit groups for symbols between annotations. But it may be desired to reset them in case the annotation is mixed up and you want a graphical reannotation. This provides a checkbox to make it clear that we do not reset groups by default but you can if you want to. Fixes https://gitlab.com/kicad/code/kicad/-/issues/14259
This commit is contained in:
+37
-5
@@ -22,6 +22,7 @@
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
|
||||
#include <confirm.h>
|
||||
#include <project/project_file.h>
|
||||
@@ -228,7 +229,8 @@ std::unordered_set<SCH_SYMBOL*> getInferredSymbols( const SCH_SELECTION& aSelect
|
||||
void SCH_EDIT_FRAME::AnnotateSymbols( SCH_COMMIT* aCommit, ANNOTATE_SCOPE_T aAnnotateScope,
|
||||
ANNOTATE_ORDER_T aSortOption, ANNOTATE_ALGO_T aAlgoOption,
|
||||
bool aRecursive, int aStartNumber, bool aResetAnnotation,
|
||||
bool aRepairTimestamps, REPORTER& aReporter )
|
||||
bool aRegroupUnits, bool aRepairTimestamps,
|
||||
REPORTER& aReporter )
|
||||
{
|
||||
SCH_SELECTION_TOOL* selTool = m_toolManager->GetTool<SCH_SELECTION_TOOL>();
|
||||
SCH_SELECTION& selection = selTool->GetSelection();
|
||||
@@ -296,10 +298,10 @@ void SCH_EDIT_FRAME::AnnotateSymbols( SCH_COMMIT* aCommit, ANNOTATE_SCOPE_T aAn
|
||||
}
|
||||
}
|
||||
|
||||
// Collect all the sets that must be annotated together. When resetting annotations, we skip
|
||||
// this step because we want fresh groupings based on symbol placement, not the potentially
|
||||
// incorrect groupings from existing reference designators.
|
||||
if( !aResetAnnotation )
|
||||
// Collect all the sets that must be annotated together. When regrouping, we skip this step
|
||||
// to allow fresh groupings based on symbol placement. When resetting without regrouping, we
|
||||
// collect locked symbols but then check for unit conflicts (duplicate units within a ref).
|
||||
if( !aRegroupUnits )
|
||||
{
|
||||
switch( aAnnotateScope )
|
||||
{
|
||||
@@ -324,6 +326,36 @@ void SCH_EDIT_FRAME::AnnotateSymbols( SCH_COMMIT* aCommit, ANNOTATE_SCOPE_T aAn
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// When resetting annotations, check for and remove groups with unit conflicts (duplicate
|
||||
// units within the same reference designator). These will get fresh assignments.
|
||||
if( aResetAnnotation )
|
||||
{
|
||||
std::vector<wxString> conflictingRefs;
|
||||
|
||||
for( auto& [refBase, refList] : lockedSymbols )
|
||||
{
|
||||
std::set<int> seenUnits;
|
||||
bool hasConflict = false;
|
||||
|
||||
for( const SCH_REFERENCE& ref : refList )
|
||||
{
|
||||
if( seenUnits.count( ref.GetUnit() ) )
|
||||
{
|
||||
hasConflict = true;
|
||||
break;
|
||||
}
|
||||
|
||||
seenUnits.insert( ref.GetUnit() );
|
||||
}
|
||||
|
||||
if( hasConflict )
|
||||
conflictingRefs.push_back( refBase );
|
||||
}
|
||||
|
||||
for( const wxString& ref : conflictingRefs )
|
||||
lockedSymbols.erase( ref );
|
||||
}
|
||||
}
|
||||
|
||||
// Store previous annotations for building info messages
|
||||
|
||||
Reference in New Issue
Block a user