2013-07-03 07:27:52 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2023-05-05 13:21:56 +00:00
|
|
|
* Copyright (C) 2004-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2013-07-03 07:27:52 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2013-12-13 16:27:30 +00:00
|
|
|
#include <algorithm>
|
2008-12-10 16:49:53 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <confirm.h>
|
2018-02-17 11:43:56 +00:00
|
|
|
#include <reporter.h>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2020-05-13 02:00:37 +00:00
|
|
|
#include <schematic.h>
|
2023-06-09 21:41:33 +00:00
|
|
|
#include <sch_commit.h>
|
2024-05-03 18:11:16 +00:00
|
|
|
#include <erc/erc_settings.h>
|
2016-02-15 20:16:54 +00:00
|
|
|
#include <sch_reference_list.h>
|
2021-06-15 13:24:55 +00:00
|
|
|
#include <symbol_library.h>
|
2021-04-11 15:24:11 +00:00
|
|
|
#include <tools/ee_selection.h>
|
|
|
|
#include <tools/ee_selection_tool.h>
|
|
|
|
#include <tool/tool_manager.h>
|
2021-11-29 13:41:02 +00:00
|
|
|
#include <dialog_erc.h>
|
2018-02-17 11:43:56 +00:00
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
void SCH_EDIT_FRAME::mapExistingAnnotation( std::map<wxString, wxString>& aMap )
|
2018-02-17 11:43:56 +00:00
|
|
|
{
|
|
|
|
SCH_REFERENCE_LIST references;
|
|
|
|
|
2020-11-15 16:08:31 +00:00
|
|
|
Schematic().GetSheets().GetSymbols( references );
|
2018-02-17 11:43:56 +00:00
|
|
|
|
|
|
|
for( size_t i = 0; i < references.GetCount(); i++ )
|
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_SYMBOL* symbol = references[ i ].GetSymbol();
|
2020-03-03 17:52:09 +00:00
|
|
|
SCH_SHEET_PATH* curr_sheetpath = &references[ i ].GetSheetPath();
|
2021-01-19 23:50:18 +00:00
|
|
|
KIID_PATH curr_full_uuid = curr_sheetpath->Path();
|
2018-02-17 11:43:56 +00:00
|
|
|
|
2021-01-19 23:50:18 +00:00
|
|
|
curr_full_uuid.push_back( symbol->m_Uuid );
|
2020-03-03 17:52:09 +00:00
|
|
|
|
2022-07-14 16:55:24 +00:00
|
|
|
wxString ref = symbol->GetRef( curr_sheetpath, true );
|
2021-01-19 23:50:18 +00:00
|
|
|
|
|
|
|
if( symbol->IsAnnotated( curr_sheetpath ) )
|
2020-03-03 17:52:09 +00:00
|
|
|
aMap[ curr_full_uuid.AsString() ] = ref;
|
2018-02-17 11:43:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-04-29 00:02:42 +00:00
|
|
|
void SCH_EDIT_FRAME::DeleteAnnotation( ANNOTATE_SCOPE_T aAnnotateScope, bool aRecursive )
|
2008-02-26 01:07:38 +00:00
|
|
|
{
|
2023-04-29 00:02:42 +00:00
|
|
|
|
|
|
|
SCH_SHEET_LIST sheets = Schematic().GetSheets();
|
|
|
|
SCH_SCREEN* screen = GetScreen();
|
|
|
|
SCH_SHEET_PATH currentSheet = GetCurrentSheet();
|
2023-06-09 21:41:33 +00:00
|
|
|
SCH_COMMIT commit( this );
|
2023-04-29 00:02:42 +00:00
|
|
|
|
2021-04-11 15:24:11 +00:00
|
|
|
auto clearSymbolAnnotation =
|
2022-04-13 22:37:42 +00:00
|
|
|
[&]( EDA_ITEM* aItem, SCH_SCREEN* aScreen, SCH_SHEET_PATH* aSheet, bool aResetPrefixes )
|
2021-04-11 15:24:11 +00:00
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( aItem );
|
2023-04-29 00:02:42 +00:00
|
|
|
commit.Modify( aItem, aScreen );
|
2021-04-11 15:24:11 +00:00
|
|
|
|
2022-04-13 22:37:42 +00:00
|
|
|
symbol->ClearAnnotation( aSheet, aResetPrefixes );
|
2021-04-11 15:24:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
auto clearSheetAnnotation =
|
2022-04-13 22:37:42 +00:00
|
|
|
[&]( SCH_SCREEN* aScreen, SCH_SHEET_PATH* aSheet, bool aResetPrefixes )
|
2020-07-13 11:21:40 +00:00
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
for( SCH_ITEM* item : aScreen->Items().OfType( SCH_SYMBOL_T ) )
|
2022-04-13 22:37:42 +00:00
|
|
|
clearSymbolAnnotation( item, aScreen, aSheet, aResetPrefixes );
|
2020-07-13 11:21:40 +00:00
|
|
|
};
|
|
|
|
|
2021-04-11 15:24:11 +00:00
|
|
|
switch( aAnnotateScope )
|
2008-04-21 06:34:56 +00:00
|
|
|
{
|
2021-04-11 15:24:11 +00:00
|
|
|
case ANNOTATE_ALL:
|
2010-12-31 19:47:39 +00:00
|
|
|
{
|
2022-04-25 17:10:33 +00:00
|
|
|
for( const SCH_SHEET_PATH& sheet : sheets )
|
2022-04-14 16:55:08 +00:00
|
|
|
clearSheetAnnotation( sheet.LastScreen(), nullptr, false );
|
2021-04-11 15:24:11 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ANNOTATE_CURRENT_SHEET:
|
|
|
|
{
|
2022-04-13 22:37:42 +00:00
|
|
|
clearSheetAnnotation( screen, ¤tSheet, false );
|
2022-04-25 17:10:33 +00:00
|
|
|
|
|
|
|
if( aRecursive )
|
|
|
|
{
|
|
|
|
SCH_SHEET_LIST subSheets;
|
|
|
|
|
|
|
|
std::vector<SCH_ITEM*> tempSubSheets;
|
|
|
|
currentSheet.LastScreen()->GetSheets( &tempSubSheets );
|
|
|
|
|
|
|
|
for( SCH_ITEM* item : tempSubSheets )
|
|
|
|
{
|
|
|
|
SCH_SHEET_PATH subSheetPath = currentSheet;
|
|
|
|
subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
|
|
|
|
|
|
|
|
sheets.GetSheetsWithinPath( subSheets, subSheetPath );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( SCH_SHEET_PATH sheet : subSheets )
|
|
|
|
clearSheetAnnotation( sheet.LastScreen(), &sheet, false );
|
|
|
|
}
|
|
|
|
|
2021-04-11 15:24:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case ANNOTATE_SELECTION:
|
|
|
|
{
|
|
|
|
EE_SELECTION_TOOL* selTool = m_toolManager->GetTool<EE_SELECTION_TOOL>();
|
|
|
|
EE_SELECTION& selection = selTool->RequestSelection();
|
2022-04-25 17:10:33 +00:00
|
|
|
SCH_SHEET_LIST selectedSheets;
|
2021-04-11 15:24:11 +00:00
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection.Items() )
|
|
|
|
{
|
2021-06-10 14:10:55 +00:00
|
|
|
if( item->Type() == SCH_SYMBOL_T )
|
2022-04-13 22:37:42 +00:00
|
|
|
clearSymbolAnnotation( item, screen, ¤tSheet, false );
|
2022-04-25 17:10:33 +00:00
|
|
|
|
|
|
|
if( item->Type() == SCH_SHEET_T && aRecursive )
|
|
|
|
{
|
|
|
|
SCH_SHEET_PATH subSheetPath = currentSheet;
|
|
|
|
subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
|
|
|
|
|
|
|
|
sheets.GetSheetsWithinPath( selectedSheets, subSheetPath );
|
|
|
|
}
|
2021-04-11 15:24:11 +00:00
|
|
|
}
|
2022-04-25 17:10:33 +00:00
|
|
|
|
|
|
|
for( SCH_SHEET_PATH sheet : selectedSheets )
|
|
|
|
clearSheetAnnotation( sheet.LastScreen(), &sheet, false );
|
|
|
|
|
2021-04-11 15:24:11 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-04-21 06:34:56 +00:00
|
|
|
}
|
|
|
|
|
2010-12-31 19:47:39 +00:00
|
|
|
// Update the references for the sheet that is currently being displayed.
|
2020-05-13 02:00:37 +00:00
|
|
|
GetCurrentSheet().UpdateAllScreenReferences();
|
2018-10-18 09:50:43 +00:00
|
|
|
|
2021-11-29 13:41:02 +00:00
|
|
|
wxWindow* erc_dlg = wxWindow::FindWindowByName( DIALOG_ERC_WINDOW_NAME );
|
|
|
|
|
|
|
|
if( erc_dlg )
|
|
|
|
static_cast<DIALOG_ERC*>( erc_dlg )->UpdateAnnotationWarning();
|
|
|
|
|
2023-04-29 00:02:42 +00:00
|
|
|
commit.Push( _( "Delete Annotation" ) );
|
|
|
|
|
2020-08-13 21:30:30 +00:00
|
|
|
// Must go after OnModify() so the connectivity graph has been updated
|
|
|
|
UpdateNetHighlightStatus();
|
2008-02-26 01:07:38 +00:00
|
|
|
}
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2022-08-24 10:30:27 +00:00
|
|
|
std::unordered_set<SCH_SYMBOL*> getInferredSymbols( const EE_SELECTION& aSelection )
|
|
|
|
{
|
|
|
|
std::unordered_set<SCH_SYMBOL*> symbols;
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : aSelection )
|
|
|
|
{
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case SCH_FIELD_T:
|
|
|
|
{
|
|
|
|
SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
|
|
|
|
|
|
|
|
if( field->GetId() == REFERENCE_FIELD && field->GetParent()->Type() == SCH_SYMBOL_T )
|
|
|
|
symbols.insert( static_cast<SCH_SYMBOL*>( field->GetParent() ) );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SCH_SYMBOL_T:
|
|
|
|
symbols.insert( static_cast<SCH_SYMBOL*>( item ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return symbols;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-09 21:41:33 +00:00
|
|
|
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 )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2021-04-11 15:24:11 +00:00
|
|
|
EE_SELECTION_TOOL* selTool = m_toolManager->GetTool<EE_SELECTION_TOOL>();
|
2023-01-23 21:49:23 +00:00
|
|
|
EE_SELECTION& selection = selTool->GetSelection();
|
2021-04-11 15:24:11 +00:00
|
|
|
|
2011-01-01 17:28:21 +00:00
|
|
|
SCH_REFERENCE_LIST references;
|
2020-07-13 11:21:40 +00:00
|
|
|
SCH_SCREENS screens( Schematic().Root() );
|
|
|
|
SCH_SHEET_LIST sheets = Schematic().GetSheets();
|
2021-04-11 15:24:11 +00:00
|
|
|
SCH_SHEET_PATH currentSheet = GetCurrentSheet();
|
2010-12-31 19:47:39 +00:00
|
|
|
|
2022-04-25 17:10:33 +00:00
|
|
|
|
2022-08-24 10:30:27 +00:00
|
|
|
// Store the selected sheets relative to the full hierarchy so we get the correct sheet numbers
|
2022-04-25 17:10:33 +00:00
|
|
|
SCH_SHEET_LIST selectedSheets;
|
2022-07-12 03:45:21 +00:00
|
|
|
|
2022-04-25 17:10:33 +00:00
|
|
|
for( EDA_ITEM* item : selection )
|
2022-07-12 03:45:21 +00:00
|
|
|
{
|
2022-04-25 17:10:33 +00:00
|
|
|
if( item->Type() == SCH_SHEET_T )
|
|
|
|
{
|
|
|
|
SCH_SHEET_PATH subSheetPath = currentSheet;
|
|
|
|
subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
|
|
|
|
|
|
|
|
sheets.GetSheetsWithinPath( selectedSheets, subSheetPath );
|
|
|
|
}
|
2022-07-12 03:45:21 +00:00
|
|
|
}
|
2022-04-25 17:10:33 +00:00
|
|
|
|
|
|
|
|
2022-08-24 10:30:27 +00:00
|
|
|
// Like above, store subsheets relative to full hierarchy for recursive annotation from current
|
|
|
|
// sheet
|
2022-04-25 17:10:33 +00:00
|
|
|
SCH_SHEET_LIST subSheets;
|
|
|
|
|
|
|
|
std::vector<SCH_ITEM*> tempSubSheets;
|
|
|
|
currentSheet.LastScreen()->GetSheets( &tempSubSheets );
|
|
|
|
|
|
|
|
for( SCH_ITEM* item : tempSubSheets )
|
|
|
|
{
|
|
|
|
SCH_SHEET_PATH subSheetPath = currentSheet;
|
|
|
|
subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
|
|
|
|
|
|
|
|
sheets.GetSheetsWithinPath( subSheets, subSheetPath );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-24 10:30:27 +00:00
|
|
|
std::unordered_set<SCH_SYMBOL*> selectedSymbols;
|
|
|
|
|
|
|
|
if( aAnnotateScope == ANNOTATE_SELECTION )
|
|
|
|
selectedSymbols = getInferredSymbols( selection );
|
|
|
|
|
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
// Map of locked symbols
|
|
|
|
SCH_MULTI_UNIT_REFERENCE_MAP lockedSymbols;
|
2015-03-23 11:45:31 +00:00
|
|
|
|
2018-02-17 11:43:56 +00:00
|
|
|
// Map of previous annotation for building info messages
|
2020-03-03 17:52:09 +00:00
|
|
|
std::map<wxString, wxString> previousAnnotation;
|
2018-02-17 11:43:56 +00:00
|
|
|
|
2022-08-24 10:30:27 +00:00
|
|
|
// Test for and replace duplicate time stamps in symbols and sheets. Duplicate time stamps
|
|
|
|
// can happen with old schematics, schematic conversions, or manual editing of files.
|
2011-05-20 19:21:09 +00:00
|
|
|
if( aRepairTimestamps )
|
2009-04-25 10:12:30 +00:00
|
|
|
{
|
2010-12-31 19:47:39 +00:00
|
|
|
int count = screens.ReplaceDuplicateTimeStamps();
|
|
|
|
|
|
|
|
if( count )
|
2009-04-25 10:12:30 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
2010-12-31 19:47:39 +00:00
|
|
|
msg.Printf( _( "%d duplicate time stamps were found and replaced." ), count );
|
2020-03-04 09:48:18 +00:00
|
|
|
aReporter.ReportTail( msg, RPT_SEVERITY_WARNING );
|
2009-04-25 10:12:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-27 14:52:32 +00:00
|
|
|
// Collect all the sets that must be annotated together.
|
|
|
|
switch( aAnnotateScope )
|
2015-03-23 11:45:31 +00:00
|
|
|
{
|
2021-04-27 14:52:32 +00:00
|
|
|
case ANNOTATE_ALL:
|
|
|
|
sheets.GetMultiUnitSymbols( lockedSymbols );
|
|
|
|
break;
|
2021-04-11 15:24:11 +00:00
|
|
|
|
2021-04-27 14:52:32 +00:00
|
|
|
case ANNOTATE_CURRENT_SHEET:
|
|
|
|
currentSheet.GetMultiUnitSymbols( lockedSymbols );
|
2023-06-28 21:29:43 +00:00
|
|
|
|
|
|
|
if( aRecursive )
|
|
|
|
subSheets.GetMultiUnitSymbols( lockedSymbols );
|
|
|
|
|
2021-04-27 14:52:32 +00:00
|
|
|
break;
|
2021-04-11 15:24:11 +00:00
|
|
|
|
2021-04-27 14:52:32 +00:00
|
|
|
case ANNOTATE_SELECTION:
|
2022-08-24 10:30:27 +00:00
|
|
|
for( SCH_SYMBOL* symbol : selectedSymbols )
|
|
|
|
currentSheet.AppendMultiUnitSymbol( lockedSymbols, symbol );
|
|
|
|
|
2023-06-28 21:29:43 +00:00
|
|
|
if( aRecursive )
|
|
|
|
selectedSheets.GetMultiUnitSymbols( lockedSymbols );
|
|
|
|
|
2021-04-27 14:52:32 +00:00
|
|
|
break;
|
2015-03-23 11:45:31 +00:00
|
|
|
}
|
|
|
|
|
2018-02-17 11:43:56 +00:00
|
|
|
// Store previous annotations for building info messages
|
|
|
|
mapExistingAnnotation( previousAnnotation );
|
|
|
|
|
2011-01-02 18:56:44 +00:00
|
|
|
// Set sheet number and number of sheets.
|
2011-01-01 17:28:21 +00:00
|
|
|
SetSheetNumberAndCount();
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
// Build symbol list
|
2021-04-11 15:24:11 +00:00
|
|
|
switch( aAnnotateScope )
|
|
|
|
{
|
|
|
|
case ANNOTATE_ALL:
|
2020-11-15 16:08:31 +00:00
|
|
|
sheets.GetSymbols( references );
|
2021-04-11 15:24:11 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ANNOTATE_CURRENT_SHEET:
|
2022-08-24 10:30:27 +00:00
|
|
|
currentSheet.GetSymbols( references );
|
2022-04-25 17:10:33 +00:00
|
|
|
|
|
|
|
if( aRecursive )
|
2022-08-24 10:30:27 +00:00
|
|
|
subSheets.GetSymbolsWithinPath( references, currentSheet, false, true );
|
2022-04-25 17:10:33 +00:00
|
|
|
|
2021-04-11 15:24:11 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ANNOTATE_SELECTION:
|
2022-08-24 10:30:27 +00:00
|
|
|
for( SCH_SYMBOL* symbol : selectedSymbols )
|
|
|
|
currentSheet.AppendSymbol( references, symbol, false, true );
|
2022-04-25 17:10:33 +00:00
|
|
|
|
|
|
|
if( aRecursive )
|
2022-08-24 10:30:27 +00:00
|
|
|
selectedSheets.GetSymbolsWithinPath( references, currentSheet, false, true );
|
2022-04-25 17:10:33 +00:00
|
|
|
|
2021-04-11 15:24:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-04-17 21:23:22 +00:00
|
|
|
// Remove annotation only updates the "new" flag to indicate to the algorithm
|
|
|
|
// that these references must be reannotated, but keeps the original reference
|
|
|
|
// so that we can reannotate multi-unit symbols together.
|
|
|
|
if( aResetAnnotation )
|
2023-01-23 21:16:38 +00:00
|
|
|
references.RemoveAnnotation();
|
2022-04-17 21:23:22 +00:00
|
|
|
|
2021-04-11 15:24:11 +00:00
|
|
|
// Build additional list of references to be used during reannotation
|
|
|
|
// to avoid duplicate designators (no additional references when annotating
|
|
|
|
// the full schematic)
|
|
|
|
SCH_REFERENCE_LIST additionalRefs;
|
|
|
|
|
|
|
|
if( aAnnotateScope != ANNOTATE_ALL )
|
|
|
|
{
|
|
|
|
SCH_REFERENCE_LIST allRefs;
|
|
|
|
sheets.GetSymbols( allRefs );
|
|
|
|
|
|
|
|
for( size_t i = 0; i < allRefs.GetCount(); i++ )
|
|
|
|
{
|
|
|
|
if( !references.Contains( allRefs[i] ) )
|
|
|
|
additionalRefs.AddItem( allRefs[i] );
|
|
|
|
}
|
|
|
|
}
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2021-03-29 10:46:05 +00:00
|
|
|
// Break full symbol reference into name (prefix) and number:
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
// example: IC1 become IC, and 1
|
2011-01-05 19:16:55 +00:00
|
|
|
references.SplitReferences();
|
2008-04-25 10:32:16 +00:00
|
|
|
|
2022-07-19 16:13:30 +00:00
|
|
|
// Annotate all of the references we've collected by our options
|
|
|
|
references.AnnotateByOptions( aSortOption, aAlgoOption, aStartNumber, lockedSymbols,
|
|
|
|
additionalRefs, false );
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2018-02-17 11:43:56 +00:00
|
|
|
for( size_t i = 0; i < references.GetCount(); i++ )
|
2011-01-02 18:56:44 +00:00
|
|
|
{
|
2020-07-13 11:21:40 +00:00
|
|
|
SCH_REFERENCE& ref = references[i];
|
2021-06-10 14:10:55 +00:00
|
|
|
SCH_SYMBOL* symbol = ref.GetSymbol();
|
2020-07-13 11:21:40 +00:00
|
|
|
SCH_SHEET_PATH* sheet = &ref.GetSheetPath();
|
|
|
|
|
2023-06-09 16:24:49 +00:00
|
|
|
aCommit->Modify( symbol, sheet->LastScreen() );
|
2020-07-13 11:21:40 +00:00
|
|
|
ref.Annotate();
|
2020-03-03 17:52:09 +00:00
|
|
|
|
2020-07-13 11:21:40 +00:00
|
|
|
KIID_PATH full_uuid = sheet->Path();
|
2020-11-15 16:08:31 +00:00
|
|
|
full_uuid.push_back( symbol->m_Uuid );
|
2020-03-03 17:52:09 +00:00
|
|
|
|
2020-07-13 11:21:40 +00:00
|
|
|
wxString prevRef = previousAnnotation[ full_uuid.AsString() ];
|
2020-11-15 16:08:31 +00:00
|
|
|
wxString newRef = symbol->GetRef( sheet );
|
2020-03-03 17:52:09 +00:00
|
|
|
|
2020-11-15 16:08:31 +00:00
|
|
|
if( symbol->GetUnitCount() > 1 )
|
2023-11-12 23:42:36 +00:00
|
|
|
newRef << symbol->SubReference( symbol->GetUnitSelection( sheet ) );
|
2020-03-03 17:52:09 +00:00
|
|
|
|
|
|
|
wxString msg;
|
2011-01-02 18:56:44 +00:00
|
|
|
|
2018-02-17 11:43:56 +00:00
|
|
|
if( prevRef.Length() )
|
|
|
|
{
|
|
|
|
if( newRef == prevRef )
|
|
|
|
continue;
|
|
|
|
|
2020-11-15 16:08:31 +00:00
|
|
|
if( symbol->GetUnitCount() > 1 )
|
2021-07-05 12:40:38 +00:00
|
|
|
{
|
|
|
|
msg.Printf( _( "Updated %s (unit %s) from %s to %s." ),
|
2024-04-05 21:35:32 +00:00
|
|
|
symbol->GetValue( true, sheet, false ),
|
2023-11-12 23:42:36 +00:00
|
|
|
symbol->SubReference( symbol->GetUnit(), false ),
|
2020-07-13 11:21:40 +00:00
|
|
|
prevRef,
|
|
|
|
newRef );
|
2021-07-05 12:40:38 +00:00
|
|
|
}
|
2018-02-17 11:43:56 +00:00
|
|
|
else
|
2021-07-05 12:40:38 +00:00
|
|
|
{
|
|
|
|
msg.Printf( _( "Updated %s from %s to %s." ),
|
2024-04-05 21:35:32 +00:00
|
|
|
symbol->GetValue( true, sheet, false ),
|
2020-07-13 11:21:40 +00:00
|
|
|
prevRef,
|
|
|
|
newRef );
|
2021-07-05 12:40:38 +00:00
|
|
|
}
|
2018-02-17 11:43:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-15 16:08:31 +00:00
|
|
|
if( symbol->GetUnitCount() > 1 )
|
2021-07-05 12:40:38 +00:00
|
|
|
{
|
|
|
|
msg.Printf( _( "Annotated %s (unit %s) as %s." ),
|
2024-04-05 21:35:32 +00:00
|
|
|
symbol->GetValue( true, sheet, false ),
|
2023-11-12 23:42:36 +00:00
|
|
|
symbol->SubReference( symbol->GetUnit(), false ),
|
2020-02-20 12:11:04 +00:00
|
|
|
newRef );
|
2021-07-05 12:40:38 +00:00
|
|
|
}
|
2018-02-17 11:43:56 +00:00
|
|
|
else
|
2021-07-05 12:40:38 +00:00
|
|
|
{
|
|
|
|
msg.Printf( _( "Annotated %s as %s." ),
|
2024-04-05 21:35:32 +00:00
|
|
|
symbol->GetValue( true, sheet, false ),
|
2020-02-20 12:11:04 +00:00
|
|
|
newRef );
|
2021-07-05 12:40:38 +00:00
|
|
|
}
|
2018-02-17 11:43:56 +00:00
|
|
|
}
|
2011-01-05 19:16:55 +00:00
|
|
|
|
2020-03-04 09:48:18 +00:00
|
|
|
aReporter.Report( msg, RPT_SEVERITY_ACTION );
|
2011-01-02 18:56:44 +00:00
|
|
|
}
|
|
|
|
|
2018-02-17 11:43:56 +00:00
|
|
|
// Final control (just in case ... ).
|
2021-01-24 22:25:32 +00:00
|
|
|
if( !CheckAnnotate(
|
|
|
|
[ &aReporter ]( ERCE_T , const wxString& aMsg, SCH_REFERENCE* , SCH_REFERENCE* )
|
|
|
|
{
|
|
|
|
aReporter.Report( aMsg, RPT_SEVERITY_ERROR );
|
|
|
|
},
|
2022-04-25 17:10:33 +00:00
|
|
|
aAnnotateScope, aRecursive ) )
|
2021-01-24 22:25:32 +00:00
|
|
|
{
|
2020-03-04 09:48:18 +00:00
|
|
|
aReporter.ReportTail( _( "Annotation complete." ), RPT_SEVERITY_ACTION );
|
2021-01-24 22:25:32 +00:00
|
|
|
}
|
2018-02-17 11:43:56 +00:00
|
|
|
|
2011-01-06 16:55:18 +00:00
|
|
|
// Update on screen references, that can be modified by previous calculations:
|
2020-05-13 02:00:37 +00:00
|
|
|
GetCurrentSheet().UpdateAllScreenReferences();
|
2011-01-06 16:55:18 +00:00
|
|
|
SetSheetNumberAndCount();
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2021-11-29 13:41:02 +00:00
|
|
|
wxWindow* erc_dlg = wxWindow::FindWindowByName( DIALOG_ERC_WINDOW_NAME );
|
|
|
|
|
|
|
|
if( erc_dlg )
|
|
|
|
static_cast<DIALOG_ERC*>( erc_dlg )->UpdateAnnotationWarning();
|
|
|
|
|
2018-08-03 12:18:26 +00:00
|
|
|
SyncView();
|
2018-10-18 09:50:43 +00:00
|
|
|
GetCanvas()->Refresh();
|
|
|
|
OnModify();
|
2020-08-13 21:30:30 +00:00
|
|
|
|
|
|
|
// Must go after OnModify() so the connectivity graph has been updated
|
|
|
|
UpdateNetHighlightStatus();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-11 15:24:11 +00:00
|
|
|
int SCH_EDIT_FRAME::CheckAnnotate( ANNOTATION_ERROR_HANDLER aErrorHandler,
|
2022-04-25 17:10:33 +00:00
|
|
|
ANNOTATE_SCOPE_T aAnnotateScope,
|
|
|
|
bool aRecursive )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2020-11-15 16:08:31 +00:00
|
|
|
SCH_REFERENCE_LIST referenceList;
|
2020-10-24 18:45:52 +00:00
|
|
|
constexpr bool includePowerSymbols = false;
|
2022-04-25 17:10:33 +00:00
|
|
|
SCH_SHEET_LIST sheets = Schematic().GetSheets();
|
|
|
|
SCH_SHEET_PATH currentSheet = GetCurrentSheet();
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2020-11-15 16:08:31 +00:00
|
|
|
// Build the list of symbols
|
2021-04-11 15:24:11 +00:00
|
|
|
switch( aAnnotateScope )
|
|
|
|
{
|
|
|
|
case ANNOTATE_ALL:
|
|
|
|
Schematic().GetSheets().GetSymbols( referenceList );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ANNOTATE_CURRENT_SHEET:
|
|
|
|
GetCurrentSheet().GetSymbols( referenceList, includePowerSymbols );
|
2022-04-25 17:10:33 +00:00
|
|
|
|
|
|
|
if( aRecursive )
|
|
|
|
{
|
|
|
|
SCH_SHEET_LIST subSheets;
|
|
|
|
|
|
|
|
std::vector<SCH_ITEM*> tempSubSheets;
|
|
|
|
currentSheet.LastScreen()->GetSheets( &tempSubSheets );
|
|
|
|
|
|
|
|
for( SCH_ITEM* item : tempSubSheets )
|
|
|
|
{
|
|
|
|
SCH_SHEET_PATH subSheetPath = currentSheet;
|
|
|
|
subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
|
|
|
|
|
|
|
|
sheets.GetSheetsWithinPath( subSheets, subSheetPath );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( SCH_SHEET_PATH sheet : subSheets )
|
|
|
|
sheet.GetSymbols( referenceList, includePowerSymbols );
|
|
|
|
}
|
|
|
|
|
2021-04-11 15:24:11 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ANNOTATE_SELECTION:
|
|
|
|
EE_SELECTION_TOOL* selTool = m_toolManager->GetTool<EE_SELECTION_TOOL>();
|
|
|
|
EE_SELECTION& selection = selTool->RequestSelection();
|
2022-08-24 10:30:27 +00:00
|
|
|
|
|
|
|
for( SCH_SYMBOL* symbol : getInferredSymbols( selection ) )
|
|
|
|
GetCurrentSheet().AppendSymbol( referenceList, symbol, false, true );
|
2022-04-25 17:10:33 +00:00
|
|
|
|
|
|
|
if( aRecursive )
|
|
|
|
{
|
|
|
|
SCH_SHEET_LIST selectedSheets;
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection.Items() )
|
|
|
|
{
|
|
|
|
if( item->Type() == SCH_SHEET_T )
|
|
|
|
{
|
|
|
|
SCH_SHEET_PATH subSheetPath = currentSheet;
|
|
|
|
subSheetPath.push_back( static_cast<SCH_SHEET*>( item ) );
|
|
|
|
|
|
|
|
sheets.GetSheetsWithinPath( selectedSheets, subSheetPath );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for( SCH_SHEET_PATH sheet : selectedSheets )
|
|
|
|
sheet.GetSymbols( referenceList, includePowerSymbols );
|
|
|
|
}
|
|
|
|
|
2021-04-11 15:24:11 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-02-26 01:07:38 +00:00
|
|
|
|
2020-02-04 10:50:23 +00:00
|
|
|
// Empty schematic does not need annotation
|
2020-11-15 16:08:31 +00:00
|
|
|
if( referenceList.GetCount() == 0 )
|
2020-02-04 10:50:23 +00:00
|
|
|
return 0;
|
|
|
|
|
2021-01-24 22:25:32 +00:00
|
|
|
return referenceList.CheckAnnotation( aErrorHandler );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|