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 The 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 std::string& fieldValue = field.second.back().first;
190
191 if( !fieldName )
192 continue;
193
194 fieldsMap[getStr( fieldName.get() )] = wxString::FromUTF8( 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 =
380 []( bool b ) -> wxString
381 {
382 return b ? _( "true" ) : _( "false" );
383 };
384 if( !m_dryRun )
385 commit.Modify( symbol, screen );
386
387 if( m_processReferences && ref.GetRef() != fpData.m_ref && !skip )
388 {
390 msg.Printf( _( "Change %s reference designator to '%s'." ),
391 ref.GetRef(),
392 fpData.m_ref );
393
394 if( !m_dryRun )
395 symbol->SetRef( &ref.GetSheetPath(), fpData.m_ref );
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 EscapeHTML( oldFootprint ),
406 EscapeHTML( fpData.m_footprint ) );
407
408 if( !m_dryRun )
409 symbol->SetFootprintFieldText( fpData.m_footprint );
410
412 }
413
414 if( m_processValues && oldValue != fpData.m_value && !skip )
415 {
417 msg.Printf( _( "Change %s value from '%s' to '%s'." ),
418 ref.GetRef(),
419 EscapeHTML( oldValue ),
420 EscapeHTML( fpData.m_value ) );
421
422 if( !m_dryRun )
423 symbol->SetValueFieldText( fpData.m_value );
424
426 }
427
428 if( m_processAttributes && oldDNP != fpData.m_DNP && !skip )
429 {
431 msg.Printf( _( "Change %s 'Do not populate' from '%s' to '%s'." ),
432 ref.GetRef(),
433 boolString( oldDNP ),
434 boolString( fpData.m_DNP ) );
435
436 if( !m_dryRun )
437 symbol->SetDNP( fpData.m_DNP );
438
440 }
441
442 if( m_processAttributes && oldExBOM != fpData.m_excludeFromBOM && !skip )
443 {
445 msg.Printf( _( "Change %s 'Exclude from bill of materials' from '%s' to '%s'." ),
446 ref.GetRef(),
447 boolString( oldExBOM ),
448 boolString( fpData.m_excludeFromBOM ) );
449
450 if( !m_dryRun )
451 symbol->SetExcludedFromBOM( fpData.m_excludeFromBOM );
452
454 }
455
457 {
458 for( const std::pair<const wxString, wxString>& entry : fpData.m_pinMap )
459 {
460 const wxString& pinNumber = entry.first;
461 const wxString& shortNetName = entry.second;
462 SCH_PIN* pin = symbol->GetPin( pinNumber );
463
464 if( !pin )
465 {
466 msg.Printf( _( "Cannot find %s pin '%s'." ),
467 ref.GetRef(),
468 EscapeHTML( pinNumber ) );
470
471 continue;
472 }
473
474 SCH_CONNECTION* connection = pin->Connection( &ref.GetSheetPath() );
475
476 if( connection && connection->Name( true ) != shortNetName )
477 {
478 processNetNameChange( &commit, ref.GetRef(), pin, connection,
479 connection->Name( true ), shortNetName );
480 }
481 }
482 }
483
485 {
486 // Need to handle three cases: existing field, new field, deleted field
487 for( const std::pair<const wxString, wxString>& field : fpData.m_fieldsMap )
488 {
489 const wxString& fpFieldName = field.first;
490 const wxString& fpFieldValue = field.second;
491 SCH_FIELD* symField = symbol->FindField( fpFieldName );
492
493 // Skip fields that are individually controlled
494 if( fpFieldName == GetCanonicalFieldName( REFERENCE_FIELD )
495 || fpFieldName == GetCanonicalFieldName( VALUE_FIELD ) )
496 {
497 continue;
498 }
499
500 // 1. Existing fields has changed value
501 // PCB Field value is checked against the shown text because this is the value
502 // with all the variables resolved. The footprints field value gets the symbol's
503 // resolved value when the PCB is updated from the schematic.
504 if( symField
505 && symField->GetShownText( &ref.GetSheetPath(), false ) != fpFieldValue )
506 {
508 msg.Printf( _( "Change %s field '%s' value to '%s'." ),
509 ref.GetRef(),
510 EscapeHTML( symField->GetCanonicalName() ),
511 EscapeHTML( fpFieldValue ) );
512
513 if( !m_dryRun )
514 symField->SetText( fpFieldValue );
515
517 }
518
519 // 2. New field has been added to footprint and needs to be added to symbol
520 if( symField == nullptr )
521 {
523 msg.Printf( _( "Add %s field '%s' with value '%s'." ),
524 ref.GetRef(),
525 EscapeHTML( fpFieldName ),
526 EscapeHTML( fpFieldValue ) );
527
528 if( !m_dryRun )
529 {
530 SCH_FIELD newField( symbol->GetPosition(), symbol->GetFieldCount(), symbol,
531 fpFieldName );
532 newField.SetText( fpFieldValue );
533 newField.SetVisible( false ); // Don't clutter up the schematic
534 symbol->AddField( newField );
535 }
536
538 }
539 }
540
541 // 3. Existing field has been deleted from footprint and needs to be deleted from symbol
542 // Check all symbol fields for existence in the footprint field map
543 for( int ii = symbol->GetFieldCount() - 1; ii >= 0; --ii )
544 {
545 SCH_FIELD* field = symbol->GetFieldById( ii );
546
547 if( !field )
548 continue;
549
550 // Never delete mandatory fields
551 if( field->IsMandatory() )
552 continue;
553
554 if( fpData.m_fieldsMap.find( field->GetCanonicalName() )
555 == fpData.m_fieldsMap.end() )
556 {
557 // Field not found in footprint field map, delete it
559 msg.Printf( _( "Delete %s field '%s.'" ),
560 ref.GetRef(),
561 EscapeHTML( field->GetCanonicalName() ) );
562
563 if( !m_dryRun )
564 symbol->RemoveField( field );
565
567 }
568 }
569 }
570
571 // TODO: back-annotate netclass changes?
572 }
573
574 if( !m_dryRun )
575 {
578
579 commit.Push( _( "Update Schematic from PCB" ) );
580 }
581}
582
583
585{
587
588 // Initial orientation from the pin
589 switch( aPin->GetLibPin()->GetOrientation() )
590 {
591 default:
594 case PIN_ORIENTATION::PIN_DOWN: spin = SPIN_STYLE::UP; break;
596 }
597
598 // Reorient based on the actual symbol orientation now
599 struct ORIENT
600 {
601 int flag;
602 int n_rots;
603 int mirror_x;
604 int mirror_y;
605 }
606 orientations[] =
607 {
608 { SYM_ORIENT_0, 0, 0, 0 },
609 { SYM_ORIENT_90, 1, 0, 0 },
610 { SYM_ORIENT_180, 2, 0, 0 },
611 { SYM_ORIENT_270, 3, 0, 0 },
612 { SYM_MIRROR_X + SYM_ORIENT_0, 0, 1, 0 },
613 { SYM_MIRROR_X + SYM_ORIENT_90, 1, 1, 0 },
614 { SYM_MIRROR_Y, 0, 0, 1 },
615 { SYM_MIRROR_X + SYM_ORIENT_270, 3, 1, 0 },
616 { SYM_MIRROR_Y + SYM_ORIENT_0, 0, 0, 1 },
617 { SYM_MIRROR_Y + SYM_ORIENT_90, 1, 0, 1 },
618 { SYM_MIRROR_Y + SYM_ORIENT_180, 2, 0, 1 },
619 { SYM_MIRROR_Y + SYM_ORIENT_270, 3, 0, 1 }
620 };
621
622 ORIENT o = orientations[ 0 ];
623
624 const SCH_SYMBOL* parentSymbol = static_cast<const SCH_SYMBOL*>( aPin->GetParentSymbol() );
625
626 if( !parentSymbol )
627 return spin;
628
629 int symbolOrientation = parentSymbol->GetOrientation();
630
631 for( const ORIENT& i : orientations )
632 {
633 if( i.flag == symbolOrientation )
634 {
635 o = i;
636 break;
637 }
638 }
639
640 for( int i = 0; i < o.n_rots; i++ )
641 spin = spin.RotateCCW();
642
643 if( o.mirror_x )
644 spin = spin.MirrorX();
645
646 if( o.mirror_y )
647 spin = spin.MirrorY();
648
649 return spin;
650}
651
652
653void addConnections( SCH_ITEM* aItem, const SCH_SHEET_PATH& aSheetPath,
654 std::set<SCH_ITEM*>& connectedItems )
655{
656 if( connectedItems.insert( aItem ).second )
657 {
658 for( SCH_ITEM* connectedItem : aItem->ConnectedItems( aSheetPath ) )
659 addConnections( connectedItem, aSheetPath, connectedItems );
660 }
661}
662
663
664void BACK_ANNOTATE::processNetNameChange( SCH_COMMIT* aCommit, const wxString& aRef, SCH_PIN* aPin,
665 const SCH_CONNECTION* aConnection,
666 const wxString& aOldName, const wxString& aNewName )
667{
668 wxString msg;
669
670 // Find a physically-connected driver. We can't use the SCH_CONNECTION's m_driver because
671 // it has already been resolved by merging subgraphs with the same label, etc., and our
672 // name change may cause that resolution to change.
673
674 std::set<SCH_ITEM*> connectedItems;
675 SCH_ITEM* driver = nullptr;
677
678 addConnections( aPin, aConnection->Sheet(), connectedItems );
679
680 for( SCH_ITEM* item : connectedItems )
681 {
683
684 if( priority > driverPriority )
685 {
686 driver = item;
687 driverPriority = priority;
688 }
689 }
690
691 switch( driver->Type() )
692 {
693 case SCH_LABEL_T:
695 case SCH_HIER_LABEL_T:
696 case SCH_SHEET_PIN_T:
698
699 msg.Printf( _( "Change %s pin %s net label from '%s' to '%s'." ),
700 aRef,
701 EscapeHTML( aPin->GetShownNumber() ),
702 EscapeHTML( aOldName ),
703 EscapeHTML( aNewName ) );
704
705 if( !m_dryRun )
706 {
707 aCommit->Modify( driver, aConnection->Sheet().LastScreen() );
708 static_cast<SCH_LABEL_BASE*>( driver )->SetText( aNewName );
709 }
710
712 break;
713
714 case SCH_PIN_T:
715 {
716 SCH_PIN* schPin = static_cast<SCH_PIN*>( driver );
717 SPIN_STYLE spin = orientLabel( schPin );
718
719 if( schPin->IsGlobalPower() )
720 {
721 msg.Printf( _( "Net %s cannot be changed to %s because it is driven by a power pin." ),
722 EscapeHTML( aOldName ),
723 EscapeHTML( aNewName ) );
724
726 break;
727 }
728
730 msg.Printf( _( "Add label '%s' to %s pin %s net." ),
731 EscapeHTML( aNewName ),
732 aRef,
733 EscapeHTML( aPin->GetShownNumber() ) );
734
735 if( !m_dryRun )
736 {
738 SCH_LABEL* label = new SCH_LABEL( driver->GetPosition(), aNewName );
739 label->SetParent( &m_frame->Schematic() );
740 label->SetTextSize( VECTOR2I( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) );
741 label->SetSpinStyle( spin );
742 label->SetFlags( IS_NEW );
743
744 SCH_SCREEN* screen = aConnection->Sheet().LastScreen();
745 aCommit->Add( label, screen );
746 }
747
749 }
750 break;
751
752 default:
753 break;
754 }
755}
const char * name
Definition: DXF_plotter.cpp:59
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)
Modify a given item in the model.
Definition: commit.h:108
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
Definition: commit.h:80
PRIORITY GetDriverPriority()
Implement a lexical analyzer for the SPECCTRA DSN file format.
Definition: dsnlexer.h:81
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:244
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:127
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:104
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:130
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition: eda_text.cpp:524
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:377
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:55
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:65
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:113
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:406
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:527
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition: project.cpp:140
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:72
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:109
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:100
These are loaded from Eeschema settings but then overwritten by the project settings.
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:312
SCH_SHEET_LIST Hierarchy() const override
Return the full schematic flattened hierarchical sheet list.
Definition: schematic.cpp:214
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
Definition: sch_commit.cpp:432
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:51
bool IsMandatory() const
Definition: sch_field.cpp:1507
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:1254
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
Definition: sch_field.cpp:213
void SetText(const wxString &aText) override
Definition: sch_field.cpp:1214
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:167
const SCH_ITEM_VEC & ConnectedItems(const SCH_SHEET_PATH &aPath)
Retrieve the set of items connected to this item on the given sheet.
Definition: sch_item.cpp:277
const SYMBOL * GetParentSymbol() const
Definition: sch_item.cpp:166
virtual void SetSpinStyle(SPIN_STYLE aSpinStyle)
Definition: sch_label.cpp:296
wxString GetShownNumber() const
Definition: sch_pin.cpp:518
bool IsGlobalPower() const
Return whether this pin forms a global power connection: i.e., is part of a power symbol and of type ...
Definition: sch_pin.cpp:367
SCH_PIN * GetLibPin() const
Definition: sch_pin.h:81
PIN_ORIENTATION GetOrientation() const
Definition: sch_pin.cpp:260
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:77
int GetFieldCount() const
Return the number of fields in this symbol.
Definition: sch_symbol.h:574
void SetValueFieldText(const wxString &aValue)
Definition: sch_symbol.cpp:884
void RemoveField(const wxString &aFieldName)
Remove a user field from the symbol.
Definition: sch_symbol.cpp:976
SCH_FIELD * FindField(const wxString &aFieldName, bool aIncludeDefaultFields=true, bool aCaseInsensitive=false)
Search for a SCH_FIELD with aFieldName.
Definition: sch_symbol.cpp:989
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:746
void SetFootprintFieldText(const wxString &aFootprint)
Definition: sch_symbol.cpp:900
VECTOR2I GetPosition() const override
Definition: sch_symbol.h:774
SCH_FIELD * GetFieldById(int aFieldId)
Return a field in this symbol.
Definition: sch_symbol.cpp:918
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add a field to the symbol.
Definition: sch_symbol.cpp:969
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
int GetOrientation() const override
Get the display symbol orientation.
SPIN_STYLE MirrorX()
Mirror the label spin style across the X axis or simply swaps up and bottom.
Definition: sch_label.cpp:123
SPIN_STYLE MirrorY()
Mirror the label spin style across the Y axis or simply swaps left and right.
Definition: sch_label.cpp:139
SPIN_STYLE RotateCCW()
Definition: sch_label.cpp:107
void SetDNP(bool aDNP)
Definition: symbol.h:187
bool GetExcludedFromBoard() const
Definition: symbol.h:181
bool GetExcludedFromBOM() const
Definition: symbol.h:175
bool GetDNP() const
Set or clear the 'Do Not Populate' flag.
Definition: symbol.h:186
void SetExcludedFromBOM(bool aExcludeFromBOM)
Set or clear the exclude from schematic bill of materials flag.
Definition: symbol.h:174
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
Definition: utf8.h:72
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:195
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
@ PIN_UP
The pin extends upwards from the connection point: Probably on the bottom side of the symbol.
@ PIN_RIGHT
The pin extends rightwards from the connection point.
@ PIN_LEFT
The pin extends leftwards from the connection point: Probably on the right side of the symbol.
@ PIN_DOWN
The pin extends downwards from the connection: Probably on the top side of the symbol.
void Scan(PTREE *aTree, DSNLEXER *aLexer)
Fill an empty PTREE with information from a KiCad s-expression stream.
Definition: ptree.cpp:84
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.
wxString EscapeHTML(const wxString &aString)
Return a new wxString escaped for embedding in HTML.
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
@ SYM_ORIENT_270
Definition: symbol.h:42
@ SYM_MIRROR_Y
Definition: symbol.h:44
@ SYM_ORIENT_180
Definition: symbol.h:41
@ SYM_MIRROR_X
Definition: symbol.h:43
@ SYM_ORIENT_90
Definition: symbol.h:40
@ SYM_ORIENT_0
Definition: symbol.h:39
wxString GetCanonicalFieldName(int idx)
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
@ SCH_LABEL_T
Definition: typeinfo.h:167
@ SCH_HIER_LABEL_T
Definition: typeinfo.h:169
@ SCH_SHEET_PIN_T
Definition: typeinfo.h:173
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:168
@ SCH_PIN_T
Definition: typeinfo.h:153
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:695
Definition of file extensions used in Kicad.