KiCad PCB EDA Suite
Loading...
Searching...
No Matches
backannotate.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2019 Alexander Shuklin <[email protected]>
5 * Copyright (C) 2004-2023 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25
26#include <backannotate.h>
27#include <boost/property_tree/ptree.hpp>
28#include <confirm.h>
29#include <dsnlexer.h>
30#include <ptree.h>
31#include <reporter.h>
32#include <sch_edit_frame.h>
33#include <sch_sheet_path.h>
34#include <sch_label.h>
35#include <schematic.h>
36#include <sch_commit.h>
37#include <string_utils.h>
38#include <kiface_base.h>
40#include <connection_graph.h>
41#include <wx/log.h>
42
43
44BACK_ANNOTATE::BACK_ANNOTATE( SCH_EDIT_FRAME* aFrame, REPORTER& aReporter, bool aRelinkFootprints,
45 bool aProcessFootprints, bool aProcessValues,
46 bool aProcessReferences, bool aProcessNetNames,
47 bool aProcessAttributes, bool aProcessOtherFields,
48 bool aDryRun ) :
49 m_reporter( aReporter ),
50 m_matchByReference( aRelinkFootprints ),
51 m_processFootprints( aProcessFootprints ),
52 m_processValues( aProcessValues ),
53 m_processReferences( aProcessReferences ),
54 m_processNetNames( aProcessNetNames ),
55 m_processAttributes( aProcessAttributes ),
56 m_processOtherFields( aProcessOtherFields ),
57 m_dryRun( aDryRun ),
58 m_frame( aFrame ),
59 m_changesCount( 0 )
60{
61}
62
63
65{
66}
67
68
69bool BACK_ANNOTATE::BackAnnotateSymbols( const std::string& aNetlist )
70{
72
75 {
76 m_reporter.ReportTail( _( "Select at least one property to back annotate." ),
78 return false;
79 }
80
81 getPcbModulesFromString( aNetlist );
82
84 sheets.GetSymbols( m_refs, false );
86
89
91
92 return true;
93}
94
95
96bool BACK_ANNOTATE::FetchNetlistFromPCB( std::string& aNetlist )
97{
98 if( Kiface().IsSingle() )
99 {
100 DisplayErrorMessage( m_frame, _( "Cannot fetch PCB netlist because Schematic Editor is opened "
101 "in stand-alone mode.\n"
102 "You must launch the KiCad project manager and create "
103 "a project." ) );
104 return false;
105 }
106
107 KIWAY_PLAYER* frame = m_frame->Kiway().Player( FRAME_PCB_EDITOR, false );
108
109 if( !frame )
110 {
111 wxFileName fn( m_frame->Prj().GetProjectFullName() );
112 fn.SetExt( FILEEXT::PcbFileExtension );
113
114 frame = m_frame->Kiway().Player( FRAME_PCB_EDITOR, true );
115 frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
116 }
117
119 return true;
120}
121
122
124{
125 std::string nullPayload;
126
128}
129
130
131void BACK_ANNOTATE::getPcbModulesFromString( const std::string& aPayload )
132{
133 auto getStr = []( const PTREE& pt ) -> wxString
134 {
135 return UTF8( pt.front().first );
136 };
137
138 DSNLEXER lexer( aPayload, From_UTF8( __func__ ) );
139 PTREE doc;
140
141 // NOTE: KiCad's PTREE scanner constructs a property *name* tree, not a property tree.
142 // Every token in the s-expr is stored as a property name; the property's value is then
143 // either the nested s-exprs or an empty PTREE; there are *no* literal property values.
144
145 Scan( &doc, &lexer );
146
147 PTREE& tree = doc.get_child( "pcb_netlist" );
148 wxString msg;
149 m_pcbFootprints.clear();
150
151 for( const std::pair<const std::string, PTREE>& item : tree )
152 {
153 wxString path, value, footprint;
154 bool dnp = false, exBOM = false;
155 std::map<wxString, wxString> pinNetMap, fieldsMap;
156 wxASSERT( item.first == "ref" );
157 wxString ref = getStr( item.second );
158
159 try
160 {
162 path = ref;
163 else
164 path = getStr( item.second.get_child( "timestamp" ) );
165
166 if( path == "" )
167 {
168 msg.Printf( _( "Footprint '%s' has no assigned symbol." ), ref );
170 continue;
171 }
172
173 footprint = getStr( item.second.get_child( "fpid" ) );
174 value = getStr( item.second.get_child( "value" ) );
175
176 // Get child PTREE of fields
177 boost::optional<const PTREE&> fields = item.second.get_child_optional( "fields" );
178
179 // Parse each field out of the fields string
180 if( fields )
181 {
182 for( const std::pair<const std::string, PTREE>& field : fields.get() )
183 {
184 if( field.first != "field" )
185 continue;
186
187 // Fields are of the format "(field (name "name") "12345")
188 const auto& fieldName = field.second.get_child_optional( "name" );
189 const auto& fieldValue = field.second.back().first;
190
191 if( !fieldName )
192 continue;
193
194 fieldsMap[getStr( fieldName.get() )] = fieldValue;
195 }
196 }
197
198
199 // Get DNP and Exclude from BOM out of the properties if they exist
200 for( const auto& child : item.second )
201 {
202 if( child.first != "property" )
203 continue;
204
205 auto property = child.second;
206 auto name = property.get_child_optional( "name" );
207
208 if( !name )
209 continue;
210
211 if( name.get().front().first == "dnp" )
212 {
213 dnp = true;
214 }
215 else if( name.get().front().first == "exclude_from_bom" )
216 {
217 exBOM = true;
218 }
219 }
220
221 boost::optional<const PTREE&> nets = item.second.get_child_optional( "nets" );
222
223 if( nets )
224 {
225 for( const std::pair<const std::string, PTREE>& pin_net : nets.get() )
226 {
227 wxASSERT( pin_net.first == "pin_net" );
228 wxString pinNumber = UTF8( pin_net.second.front().first );
229 wxString netName = UTF8( pin_net.second.back().first );
230 pinNetMap[ pinNumber ] = netName;
231 }
232 }
233 }
234 catch( ... )
235 {
236 wxLogWarning( "Cannot parse PCB netlist for back-annotation." );
237 }
238
239 // Use lower_bound for not to iterate over map twice
240 auto nearestItem = m_pcbFootprints.lower_bound( path );
241
242 if( nearestItem != m_pcbFootprints.end() && nearestItem->first == path )
243 {
244 // Module with this path already exists - generate error
245 msg.Printf( _( "Footprints '%s' and '%s' linked to same symbol." ),
246 nearestItem->second->m_ref,
247 ref );
249 }
250 else
251 {
252 // Add footprint to the map
253 auto data = std::make_shared<PCB_FP_DATA>( ref, footprint, value, dnp, exBOM,
254 pinNetMap, fieldsMap );
255 m_pcbFootprints.insert( nearestItem, std::make_pair( path, data ) );
256 }
257 }
258}
259
260
262{
263 for( std::pair<const wxString, std::shared_ptr<PCB_FP_DATA>>& fpData : m_pcbFootprints )
264 {
265 const wxString& pcbPath = fpData.first;
266 auto& pcbData = fpData.second;
267 int refIndex;
268 bool foundInMultiunit = false;
269
270 for( std::pair<const wxString, SCH_REFERENCE_LIST>& item : m_multiUnitsRefs )
271 {
272 SCH_REFERENCE_LIST& refList = item.second;
273
275 refIndex = refList.FindRef( pcbPath );
276 else
277 refIndex = refList.FindRefByFullPath( pcbPath );
278
279 if( refIndex >= 0 )
280 {
281 // If footprint linked to multi unit symbol, we add all symbol's units to
282 // the change list
283 foundInMultiunit = true;
284
285 for( size_t i = 0; i < refList.GetCount(); ++i )
286 {
287 refList[ i ].GetSymbol()->ClearFlags(SKIP_STRUCT );
288 m_changelist.emplace_back( CHANGELIST_ITEM( refList[i], pcbData ) );
289 }
290
291 break;
292 }
293 }
294
295 if( foundInMultiunit )
296 continue;
297
299 refIndex = m_refs.FindRef( pcbPath );
300 else
301 refIndex = m_refs.FindRefByFullPath( pcbPath );
302
303 if( refIndex >= 0 )
304 {
305 m_refs[ refIndex ].GetSymbol()->ClearFlags( SKIP_STRUCT );
306 m_changelist.emplace_back( CHANGELIST_ITEM( m_refs[refIndex], pcbData ) );
307 }
308 else
309 {
310 // Haven't found linked symbol in multiunits or common refs. Generate error
311 wxString msg = wxString::Format( _( "Cannot find symbol for footprint '%s'." ),
312 pcbData->m_ref );
314 }
315 }
316}
317
319{
321
322 std::sort( m_changelist.begin(), m_changelist.end(),
323 []( const CHANGELIST_ITEM& a, const CHANGELIST_ITEM& b )
324 {
325 return SCH_REFERENCE_LIST::sortByTimeStamp( a.first, b.first );
326 } );
327
328 size_t i = 0;
329
330 for( const std::pair<SCH_REFERENCE, std::shared_ptr<PCB_FP_DATA>>& item : m_changelist )
331 {
332 // Refs and changelist are both sorted by paths, so we just go over m_refs and
333 // generate errors before we will find m_refs member to which item linked
334 while( i < m_refs.GetCount() && m_refs[i].GetPath() != item.first.GetPath() )
335 {
336 const SCH_REFERENCE& ref = m_refs[i];
337
338 if( ref.GetSymbol()->GetExcludedFromBoard() )
339 {
340 wxString msg = wxString::Format( _( "Footprint '%s' is not present on PCB. "
341 "Corresponding symbols in schematic must be "
342 "manually deleted (if desired)." ),
343 m_refs[i].GetRef() );
345 }
346
347 ++i;
348 }
349
350 ++i;
351 }
352
353 if( m_matchByReference && !m_frame->ReadyToNetlist( _( "Re-linking footprints requires a fully "
354 "annotated schematic." ) ) )
355 {
356 m_reporter.ReportTail( _( "Footprint re-linking cancelled by user." ), RPT_SEVERITY_ERROR );
357 }
358}
359
360
362{
363 SCH_COMMIT commit( m_frame );
364 wxString msg;
365
366 // Apply changes from change list
367 for( CHANGELIST_ITEM& item : m_changelist )
368 {
369 SCH_REFERENCE& ref = item.first;
370 PCB_FP_DATA& fpData = *item.second;
371 SCH_SYMBOL* symbol = ref.GetSymbol();
372 SCH_SCREEN* screen = ref.GetSheetPath().LastScreen();
373 wxString oldFootprint = ref.GetFootprint();
374 wxString oldValue = ref.GetValue();
375 bool oldDNP = ref.GetSymbol()->GetDNP();
376 bool oldExBOM = ref.GetSymbol()->GetExcludedFromBOM();
377 bool skip = ( ref.GetSymbol()->GetFlags() & SKIP_STRUCT ) > 0;
378
379 auto boolString = []( bool b ) -> wxString
380 {
381 return b ? _( "true" ) : _( "false" );
382 };
383
384 if( m_processReferences && ref.GetRef() != fpData.m_ref && !skip )
385 {
387 msg.Printf( _( "Change '%s' reference designator to '%s'." ),
388 ref.GetRef(),
389 fpData.m_ref );
390
391 if( !m_dryRun )
392 {
393 commit.Modify( symbol, screen );
394 symbol->SetRef( &ref.GetSheetPath(), fpData.m_ref );
395 }
396
398 }
399
400 if( m_processFootprints && oldFootprint != fpData.m_footprint && !skip )
401 {
403 msg.Printf( _( "Change %s footprint assignment from '%s' to '%s'." ),
404 ref.GetRef(),
405 oldFootprint,
406 fpData.m_footprint );
407
408 if( !m_dryRun )
409 {
410 commit.Modify( symbol, screen );
411 symbol->SetFootprintFieldText( fpData.m_footprint );
412 }
413
415 }
416
417 if( m_processValues && oldValue != fpData.m_value && !skip )
418 {
420 msg.Printf( _( "Change %s value from '%s' to '%s'." ),
421 ref.GetRef(),
422 oldValue,
423 fpData.m_value );
424
425 if( !m_dryRun )
426 {
427 commit.Modify( symbol, screen );
428 symbol->SetValueFieldText( fpData.m_value );
429 }
430
432 }
433
434 if( m_processAttributes && oldDNP != fpData.m_DNP && !skip )
435 {
437 msg.Printf( _( "Change %s 'Do not populate' from '%s' to '%s'." ), ref.GetRef(),
438 boolString( oldDNP ), boolString( fpData.m_DNP ) );
439
440 if( !m_dryRun )
441 {
442 commit.Modify( symbol, screen );
443 symbol->SetDNP( fpData.m_DNP );
444 }
445
447 }
448
449 if( m_processAttributes && oldExBOM != fpData.m_excludeFromBOM && !skip )
450 {
452 msg.Printf( _( "Change %s 'Exclude from bill of materials' from '%s' to '%s'." ),
453 ref.GetRef(), boolString( oldExBOM ),
454 boolString( fpData.m_excludeFromBOM ) );
455
456 if( !m_dryRun )
457 {
458 commit.Modify( symbol, screen );
459 symbol->SetExcludedFromBOM( fpData.m_excludeFromBOM );
460 }
461
463 }
464
466 {
467 for( const std::pair<const wxString, wxString>& entry : fpData.m_pinMap )
468 {
469 const wxString& pinNumber = entry.first;
470 const wxString& shortNetName = entry.second;
471 SCH_PIN* pin = symbol->GetPin( pinNumber );
472
473 if( !pin )
474 {
475 msg.Printf( _( "Cannot find %s pin '%s'." ),
476 ref.GetRef(),
477 pinNumber );
479
480 continue;
481 }
482
483 SCH_CONNECTION* connection = pin->Connection( &ref.GetSheetPath() );
484
485 if( connection && connection->Name( true ) != shortNetName )
486 {
487 processNetNameChange( &commit, ref.GetRef(), pin, connection,
488 connection->Name( true ), shortNetName );
489 }
490 }
491 }
492
494 {
495 // Need to handle three cases: existing field, new field, deleted field
496 for( const std::pair<const wxString, wxString>& field : fpData.m_fieldsMap )
497 {
498 const wxString& fpFieldName = field.first;
499 const wxString& fpFieldValue = field.second;
500 SCH_FIELD* symField = symbol->FindField( fpFieldName );
501
502 // Skip fields that are individually controlled
503 if( fpFieldName == GetCanonicalFieldName( REFERENCE_FIELD )
504 || fpFieldName == GetCanonicalFieldName( VALUE_FIELD )
505 || fpFieldName == GetCanonicalFieldName( FOOTPRINT_FIELD ) )
506 {
507 continue;
508 }
509
510 // 1. Existing fields has changed value
511 // PCB Field value is checked against the shown text because this is the value
512 // with all the variables resolved. The footprints field value gets the symbol's
513 // resolved value when the PCB is updated from the schematic.
514 if( symField
515 && symField->GetShownText( &ref.GetSheetPath(), false ) != fpFieldValue )
516 {
518 msg.Printf( _( "Change field '%s' value to '%s'." ),
519 symField->GetCanonicalName(), fpFieldValue );
520
521 if( !m_dryRun )
522 {
523 commit.Modify( symbol, screen );
524 symField->SetText( fpFieldValue );
525 }
526
528 }
529
530 // 2. New field has been added to footprint and needs to be added to symbol
531 if( symField == nullptr )
532 {
534 msg.Printf( _( "Add field '%s' with value '%s'." ), fpFieldName, fpFieldValue );
535
536 if( !m_dryRun )
537 {
538 commit.Modify( symbol, screen );
539
540 SCH_FIELD newField( VECTOR2I( 0, 0 ), symbol->GetFieldCount(), symbol,
541 fpFieldName );
542 newField.SetText( fpFieldValue );
543 symbol->AddField( newField );
544 }
545
547 }
548 }
549
550 // 3. Existing field has been deleted from footprint and needs to be deleted from symbol
551 // Check all symbol fields for existence in the footprint field map
552 for( SCH_FIELD& field : symbol->GetFields() )
553 {
554 // Never delete mandatory fields
555 if( field.GetId() < MANDATORY_FIELDS )
556 continue;
557
558 if( fpData.m_fieldsMap.find( field.GetCanonicalName() )
559 == fpData.m_fieldsMap.end() )
560 {
561 // Field not found in footprint field map, delete it
563 msg.Printf( _( "Delete field '%s.'" ), field.GetCanonicalName() );
564
565 if( !m_dryRun )
566 {
567 commit.Modify( symbol, screen );
568 symbol->RemoveField( &field );
569 }
570
572 }
573 }
574 }
575
576 // TODO: back-annotate netclass changes?
577 }
578
579 if( !m_dryRun )
580 {
583
584 commit.Push( _( "Update Schematic from PCB" ) );
585 }
586}
587
588
590{
592
593 // Initial orientation from the pin
594 switch( aPin->GetLibPin()->GetOrientation() )
595 {
597 case PIN_ORIENTATION::PIN_DOWN: spin = SPIN_STYLE::UP; break;
600 }
601
602 // Reorient based on the actual symbol orientation now
603 struct ORIENT
604 {
605 int flag;
606 int n_rots;
607 int mirror_x;
608 int mirror_y;
609 }
610 orientations[] =
611 {
612 { SYM_ORIENT_0, 0, 0, 0 },
613 { SYM_ORIENT_90, 1, 0, 0 },
614 { SYM_ORIENT_180, 2, 0, 0 },
615 { SYM_ORIENT_270, 3, 0, 0 },
616 { SYM_MIRROR_X + SYM_ORIENT_0, 0, 1, 0 },
617 { SYM_MIRROR_X + SYM_ORIENT_90, 1, 1, 0 },
618 { SYM_MIRROR_Y, 0, 0, 1 },
619 { SYM_MIRROR_X + SYM_ORIENT_270, 3, 1, 0 },
620 { SYM_MIRROR_Y + SYM_ORIENT_0, 0, 0, 1 },
621 { SYM_MIRROR_Y + SYM_ORIENT_90, 1, 0, 1 },
622 { SYM_MIRROR_Y + SYM_ORIENT_180, 2, 0, 1 },
623 { SYM_MIRROR_Y + SYM_ORIENT_270, 3, 0, 1 }
624 };
625
626 ORIENT o = orientations[ 0 ];
627
628 SCH_SYMBOL* parentSymbol = aPin->GetParentSymbol();
629
630 if( !parentSymbol )
631 return spin;
632
633 int symbolOrientation = parentSymbol->GetOrientation();
634
635 for( auto& i : orientations )
636 {
637 if( i.flag == symbolOrientation )
638 {
639 o = i;
640 break;
641 }
642 }
643
644 for( int i = 0; i < o.n_rots; i++ )
645 spin = spin.RotateCCW();
646
647 if( o.mirror_x )
648 spin = spin.MirrorX();
649
650 if( o.mirror_y )
651 spin = spin.MirrorY();
652
653 return spin;
654}
655
656
657void addConnections( SCH_ITEM* aItem, const SCH_SHEET_PATH& aSheetPath,
658 std::set<SCH_ITEM*>& connectedItems )
659{
660 if( connectedItems.insert( aItem ).second )
661 {
662 for( SCH_ITEM* connectedItem : aItem->ConnectedItems( aSheetPath ) )
663 addConnections( connectedItem, aSheetPath, connectedItems );
664 }
665}
666
667
668void BACK_ANNOTATE::processNetNameChange( SCH_COMMIT* aCommit, const wxString& aRef, SCH_PIN* aPin,
669 const SCH_CONNECTION* aConnection,
670 const wxString& aOldName, const wxString& aNewName )
671{
672 wxString msg;
673
674 // Find a physically-connected driver. We can't use the SCH_CONNECTION's m_driver because
675 // it has already been resolved by merging subgraphs with the same label, etc., and our
676 // name change may cause that resolution to change.
677
678 std::set<SCH_ITEM*> connectedItems;
679 SCH_ITEM* driver = nullptr;
681
682 addConnections( aPin, aConnection->Sheet(), connectedItems );
683
684 for( SCH_ITEM* item : connectedItems )
685 {
687
688 if( priority > driverPriority )
689 {
690 driver = item;
691 driverPriority = priority;
692 }
693 }
694
695 switch( driver->Type() )
696 {
697 case SCH_LABEL_T:
699 case SCH_HIER_LABEL_T:
700 case SCH_SHEET_PIN_T:
702
703 msg.Printf( _( "Change %s pin %s net label from '%s' to '%s'." ),
704 aRef,
705 aPin->GetShownNumber(),
706 aOldName,
707 aNewName );
708
709 if( !m_dryRun )
710 {
711 aCommit->Modify( driver, aConnection->Sheet().LastScreen() );
712 static_cast<SCH_LABEL_BASE*>( driver )->SetText( aNewName );
713 }
714
716 break;
717
718 case SCH_PIN_T:
719 {
720 SCH_PIN* schPin = static_cast<SCH_PIN*>( driver );
721 SPIN_STYLE spin = orientLabel( schPin );
722
723 if( schPin->IsGlobalPower() )
724 {
725 msg.Printf( _( "Net %s cannot be changed to %s because it is driven by a power pin." ),
726 aOldName,
727 aNewName );
728
730 break;
731 }
732
734 msg.Printf( _( "Add label '%s' to %s pin %s net." ),
735 aNewName,
736 aRef,
737 aPin->GetShownNumber() );
738
739 if( !m_dryRun )
740 {
742 SCH_LABEL* label = new SCH_LABEL( driver->GetPosition(), aNewName );
743 label->SetParent( &m_frame->Schematic() );
744 label->SetTextSize( VECTOR2I( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) );
745 label->SetSpinStyle( spin );
746 label->SetFlags( IS_NEW );
747
748 SCH_SCREEN* screen = aConnection->Sheet().LastScreen();
749 aCommit->Add( label, screen );
750 }
751
753 }
754 break;
755
756 default:
757 break;
758 }
759}
const char * name
Definition: DXF_plotter.cpp:57
void addConnections(SCH_ITEM *aItem, const SCH_SHEET_PATH &aSheetPath, std::set< SCH_ITEM * > &connectedItems)
static SPIN_STYLE orientLabel(SCH_PIN *aPin)
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
bool BackAnnotateSymbols(const std::string &aNetlist)
Run back annotation algorithm.
SCH_MULTI_UNIT_REFERENCE_MAP m_multiUnitsRefs
Definition: backannotate.h:155
std::deque< CHANGELIST_ITEM > m_changelist
Definition: backannotate.h:156
bool m_processReferences
Definition: backannotate.h:147
BACK_ANNOTATE(SCH_EDIT_FRAME *aFrame, REPORTER &aReporter, bool aRelinkFootprints, bool aProcessFootprints, bool aProcessValues, bool aProcessReferences, bool aProcessNetNames, bool aProcessAttributes, bool aProcessOtherFields, bool aDryRun)
bool m_processFootprints
Definition: backannotate.h:145
bool m_processOtherFields
Definition: backannotate.h:150
void getPcbModulesFromString(const std::string &aPayload)
Parse netlist sent over KiWay express mail interface and fill m_pcbModules.
SCH_EDIT_FRAME * m_frame
Definition: backannotate.h:157
bool m_processValues
Definition: backannotate.h:146
void checkForUnusedSymbols()
Check if some symbols are not represented in PCB footprints and vice versa.
SCH_REFERENCE_LIST m_refs
Definition: backannotate.h:154
bool FetchNetlistFromPCB(std::string &aNetlist)
Get netlist from the Pcbnew.
PCB_FOOTPRINTS_MAP m_pcbFootprints
Definition: backannotate.h:153
std::pair< SCH_REFERENCE, std::shared_ptr< PCB_FP_DATA > > CHANGELIST_ITEM
Definition: backannotate.h:88
void processNetNameChange(SCH_COMMIT *aCommit, const wxString &aRef, SCH_PIN *aPin, const SCH_CONNECTION *aConnection, const wxString &aOldName, const wxString &aNewName)
REPORTER & m_reporter
Definition: backannotate.h:142
bool m_processAttributes
Definition: backannotate.h:149
bool m_processNetNames
Definition: backannotate.h:148
bool m_matchByReference
Definition: backannotate.h:144
void getChangeList()
void PushNewLinksToPCB()
void applyChangelist()
Apply changelist to the schematic.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
Definition: commit.h:105
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Notify observers that aItem has been added.
Definition: commit.h:80
PRIORITY GetDriverPriority()
Implement a lexical analyzer for the SPECCTRA DSN file format.
Definition: dsnlexer.h:80
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:239
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:123
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:100
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:126
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition: eda_text.cpp:374
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:67
virtual bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
Open a project or set of files given by aFileList.
Definition: kiway_player.h:115
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:432
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:553
PIN_ORIENTATION GetOrientation() const
Definition: lib_pin.h:68
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition: project.cpp:129
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:71
virtual REPORTER & ReportHead(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Places the report at the beginning of the list for objects that support ordering.
Definition: reporter.h:108
virtual REPORTER & ReportTail(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Places the report at the end of the list, for objects that support report ordering.
Definition: reporter.h:99
These settings were stored in SCH_BASE_FRAME previously.
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:287
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:100
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
Definition: sch_commit.cpp:393
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
SCH_SHEET_PATH Sheet() const
wxString Name(bool aIgnoreSheet=false) const
Schematic editor (Eeschema) main window.
bool ReadyToNetlist(const wxString &aAnnotateMessage)
Check if we are ready to write a netlist file for the current schematic.
SCHEMATIC & Schematic() const
void RecalculateConnections(SCH_COMMIT *aCommit, SCH_CLEANUP_FLAGS aCleanupFlags)
Generate the connection data for the entire schematic hierarchy.
void UpdateNetHighlightStatus()
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:52
wxString GetCanonicalName() const
Get a non-language-specific name for a field which can be used for storage, variable look-up,...
Definition: sch_field.cpp:1039
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
Definition: sch_field.cpp:188
void SetText(const wxString &aText) override
Definition: sch_field.cpp:996
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:165
SCH_ITEM_SET & ConnectedItems(const SCH_SHEET_PATH &aPath)
Retrieve the set of items connected to this item on the given sheet.
Definition: sch_item.cpp:197
virtual void SetSpinStyle(SPIN_STYLE aSpinStyle)
Definition: sch_label.cpp:337
wxString GetShownNumber() const
Definition: sch_pin.cpp:118
bool IsGlobalPower() const
Definition: sch_pin.cpp:297
LIB_PIN * GetLibPin() const
Definition: sch_pin.h:59
SCH_SYMBOL * GetParentSymbol() const
Definition: sch_pin.cpp:207
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
void SortByTimeStamp()
Sort the flat list by Time Stamp (sheet path + timestamp).
int FindRef(const wxString &aPath) const
Search the list for a symbol with a given reference.
size_t GetCount() const
int FindRefByFullPath(const wxString &aFullPath) const
Search the list for a symbol with the given KIID path (as string).
A helper to define a symbol's reference designator in a schematic.
const SCH_SHEET_PATH & GetSheetPath() const
const wxString GetFootprint() const
SCH_SYMBOL * GetSymbol() const
wxString GetRef() const
const wxString GetValue() const
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void GetMultiUnitSymbols(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols=true) const
Add a SCH_REFERENCE_LIST object to aRefList for each same-reference set of multi-unit parts in the li...
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SCH_SCREEN * LastScreen()
Schematic symbol object.
Definition: sch_symbol.h:109
int GetFieldCount() const
Return the number of fields in this symbol.
Definition: sch_symbol.h:588
void SetDNP(bool aDNP)
Definition: sch_symbol.h:868
void SetValueFieldText(const wxString &aValue)
Definition: sch_symbol.cpp:931
void RemoveField(const wxString &aFieldName)
Remove a user field from the symbol.
SCH_FIELD * FindField(const wxString &aFieldName, bool aIncludeDefaultFields=true, bool aCaseInsensitive=false)
Search for a SCH_FIELD with aFieldName.
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
Definition: sch_symbol.cpp:793
void SetFootprintFieldText(const wxString &aFootprint)
Definition: sch_symbol.cpp:947
bool GetExcludedFromBOM() const
Definition: sch_symbol.h:861
void SetExcludedFromBOM(bool aIncludeInBOM)
Definition: sch_symbol.h:862
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add a field to the symbol.
int GetOrientation() const
Get the display symbol orientation.
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
bool GetExcludedFromBoard() const
Definition: sch_symbol.h:864
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
bool GetDNP() const
Definition: sch_symbol.h:867
SPIN_STYLE MirrorX()
Mirror the label spin style across the X axis or simply swaps up and bottom.
Definition: sch_label.cpp:172
SPIN_STYLE MirrorY()
Mirror the label spin style across the Y axis or simply swaps left and right.
Definition: sch_label.cpp:188
SPIN_STYLE RotateCCW()
Definition: sch_label.cpp:156
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
Definition: utf8.h:71
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:305
This file is part of the common library.
#define _(s)
#define IS_NEW
New item, just created.
#define SKIP_STRUCT
flag indicating that the structure should be ignored
@ FRAME_PCB_EDITOR
Definition: frame_type.h:42
@ MAIL_PCB_UPDATE_LINKS
Definition: mail_type.h:52
@ MAIL_PCB_GET_NETLIST
Definition: mail_type.h:51
void Scan(PTREE *aTree, DSNLEXER *aLexer)
Fill an empty PTREE with information from a KiCad s-expression stream.
Definition: ptree.cpp:86
boost::property_tree::ptree PTREE
Definition: ptree.h:52
@ RPT_SEVERITY_WARNING
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_ACTION
@ NO_CLEANUP
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
@ SYM_ORIENT_270
Definition: sch_symbol.h:88
@ SYM_MIRROR_Y
Definition: sch_symbol.h:90
@ SYM_ORIENT_180
Definition: sch_symbol.h:87
@ SYM_MIRROR_X
Definition: sch_symbol.h:89
@ SYM_ORIENT_90
Definition: sch_symbol.h:86
@ SYM_ORIENT_0
Definition: sch_symbol.h:85
wxString From_UTF8(const char *cstring)
Container for Pcbnew footprint data.Map to hold NETLIST footprints data.
Definition: backannotate.h:62
std::map< wxString, wxString > m_pinMap
Definition: backannotate.h:81
std::map< wxString, wxString > m_fieldsMap
Definition: backannotate.h:82
wxString GetCanonicalFieldName(int idx)
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ MANDATORY_FIELDS
The first 5 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
@ SCH_LABEL_T
Definition: typeinfo.h:155
@ SCH_HIER_LABEL_T
Definition: typeinfo.h:157
@ SCH_SHEET_PIN_T
Definition: typeinfo.h:161
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:156
@ SCH_PIN_T
Definition: typeinfo.h:163
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588
Definition of file extensions used in Kicad.