diff --git a/eeschema/annotate.cpp b/eeschema/annotate.cpp index 4a6e5bcac3..281c5bf5ad 100644 --- a/eeschema/annotate.cpp +++ b/eeschema/annotate.cpp @@ -305,34 +305,9 @@ void SCH_EDIT_FRAME::AnnotateSymbols( ANNOTATE_SCOPE_T aAnnotateScope, // example: IC1 become IC, and 1 references.SplitReferences(); - switch( aSortOption ) - { - default: - case SORT_BY_X_POSITION: references.SortByXCoordinate(); break; - case SORT_BY_Y_POSITION: references.SortByYCoordinate(); break; - } - - bool useSheetNum = false; - int idStep = 100; - - switch( aAlgoOption ) - { - default: - case INCREMENTAL_BY_REF: - break; - - case SHEET_NUMBER_X_100: - useSheetNum = true; - break; - - case SHEET_NUMBER_X_1000: - useSheetNum = true; - idStep = 1000; - break; - } - - // Recalculate and update reference numbers in schematic - references.Annotate( useSheetNum, idStep, aStartNumber, lockedSymbols, additionalRefs ); + // Annotate all of the references we've collected by our options + references.AnnotateByOptions( aSortOption, aAlgoOption, aStartNumber, lockedSymbols, + additionalRefs, false ); for( size_t i = 0; i < references.GetCount(); i++ ) { diff --git a/eeschema/component_references_lister.cpp b/eeschema/component_references_lister.cpp index d96d5cef95..442d3656d3 100644 --- a/eeschema/component_references_lister.cpp +++ b/eeschema/component_references_lister.cpp @@ -401,6 +401,40 @@ void SCH_REFERENCE_LIST::ReannotateDuplicates( const SCH_REFERENCE_LIST& aAdditi } +void SCH_REFERENCE_LIST::AnnotateByOptions( ANNOTATE_ORDER_T aSortOption, + ANNOTATE_ALGO_T aAlgoOption, + int aStartNumber, + SCH_MULTI_UNIT_REFERENCE_MAP aLockedUnitMap, + const SCH_REFERENCE_LIST& aAdditionalRefs, + bool aStartAtCurrent ) +{ + switch( aSortOption ) + { + default: + case SORT_BY_X_POSITION: SortByXCoordinate(); break; + case SORT_BY_Y_POSITION: SortByYCoordinate(); break; + } + + bool useSheetNum = false; + int idStep = 100; + + switch( aAlgoOption ) + { + default: + case INCREMENTAL_BY_REF: break; + + case SHEET_NUMBER_X_100: useSheetNum = true; break; + + case SHEET_NUMBER_X_1000: + useSheetNum = true; + idStep = 1000; + break; + } + + Annotate( useSheetNum, idStep, aStartNumber, aLockedUnitMap, aAdditionalRefs, aStartAtCurrent ); +} + + void SCH_REFERENCE_LIST::Annotate( bool aUseSheetNum, int aSheetIntervalId, int aStartNumber, SCH_MULTI_UNIT_REFERENCE_MAP aLockedUnitMap, const SCH_REFERENCE_LIST& aAdditionalRefs, bool aStartAtCurrent ) diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index b2d92f8619..9bfc9e56cf 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -77,36 +77,6 @@ enum SYMBOL_ORIENTATION_T }; -/** Schematic annotation scope options. */ -enum ANNOTATE_SCOPE_T -{ - ANNOTATE_ALL, ///< Annotate the full schematic - ANNOTATE_CURRENT_SHEET, ///< Annotate the current sheet - ANNOTATE_SELECTION ///< Annotate the selection -}; - - -/** Schematic annotation order options. */ -enum ANNOTATE_ORDER_T -{ - SORT_BY_X_POSITION, ///< Annotate by X position from left to right. - SORT_BY_Y_POSITION, ///< Annotate by Y position from top to bottom. - UNSORTED, ///< Annotate by position of symbol in the schematic sheet - ///< object list. -}; - - -/** Schematic annotation type options. */ -enum ANNOTATE_ALGO_T -{ - INCREMENTAL_BY_REF, ///< Annotate incrementally using the first free reference number. - SHEET_NUMBER_X_100, ///< Annotate using the first free reference number starting at - ///< the sheet number * 100. - SHEET_NUMBER_X_1000, ///< Annotate using the first free reference number starting at - ///< the sheet number * 1000. -}; - - /// Schematic search type used by the socket link with Pcbnew enum SCH_SEARCH_T { diff --git a/eeschema/sch_reference_list.h b/eeschema/sch_reference_list.h index a18ebfa17e..81ca16281c 100644 --- a/eeschema/sch_reference_list.h +++ b/eeschema/sch_reference_list.h @@ -35,6 +35,37 @@ #include #include + +/** Schematic annotation scope options. */ +enum ANNOTATE_SCOPE_T +{ + ANNOTATE_ALL, ///< Annotate the full schematic + ANNOTATE_CURRENT_SHEET, ///< Annotate the current sheet + ANNOTATE_SELECTION ///< Annotate the selection +}; + + +/** Schematic annotation order options. */ +enum ANNOTATE_ORDER_T +{ + SORT_BY_X_POSITION, ///< Annotate by X position from left to right. + SORT_BY_Y_POSITION, ///< Annotate by Y position from top to bottom. + UNSORTED, ///< Annotate by position of symbol in the schematic sheet + ///< object list. +}; + + +/** Schematic annotation type options. */ +enum ANNOTATE_ALGO_T +{ + INCREMENTAL_BY_REF, ///< Annotate incrementally using the first free reference number. + SHEET_NUMBER_X_100, ///< Annotate using the first free reference number starting at + ///< the sheet number * 100. + SHEET_NUMBER_X_1000, ///< Annotate using the first free reference number starting at + ///< the sheet number * 1000. +}; + + /** * A helper to define a symbol's reference designator in a schematic. * @@ -313,6 +344,29 @@ public: */ void ReannotateDuplicates( const SCH_REFERENCE_LIST& aAdditionalReferences ); + + /** + * Annotate the references by the provided options. + * + * @param aSortOption Define the annotation order. See #ANNOTATE_ORDER_T. + * @param aAlgoOption Define the annotation style. See #ANNOTATE_ALGO_T. + * @param aStartNumber The start number for non-sheet-based annotation styles. + * @param appendUndo True if the annotation operation should be added to an existing undo, + * false if it should be separately undo-able. + * @param aLockedUnitMap A SCH_MULTI_UNIT_REFERENCE_MAP of reference designator wxStrings + * to SCH_REFERENCE_LISTs. May be an empty map. If not empty, any multi-unit parts + * found in this map will be annotated as a group rather than individually. + * @param aAdditionalReferences Additional references to check for duplicates + * @param aStartAtCurrent Use m_numRef for each reference as the start number (overrides + * aStartNumber) + */ + void AnnotateByOptions( enum ANNOTATE_ORDER_T aSortOption, + enum ANNOTATE_ALGO_T aAlgoOption, + int aStartNumber, + SCH_MULTI_UNIT_REFERENCE_MAP aLockedUnitMap, + const SCH_REFERENCE_LIST& aAdditionalRefs, + bool aStartAtCurrent ); + /** * Set the reference designators in the list that have not been annotated. *