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, 2024 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
385 if( m_processReferences && ref.GetRef() != fpData.m_ref && !skip )
386 {
388 msg.Printf( _( "Change %s reference designator to '%s'." ),
389 ref.GetRef(),
390 fpData.m_ref );
391
392 if( !m_dryRun )
393 {
394 commit.Modify( symbol, screen );
395 symbol->SetRef( &ref.GetSheetPath(), fpData.m_ref );
396 }
397
399 }
400
401 if( m_processFootprints && oldFootprint != fpData.m_footprint && !skip )
402 {
404 msg.Printf( _( "Change %s footprint assignment from '%s' to '%s'." ),
405 ref.GetRef(),
406 EscapeHTML( oldFootprint ),
407 EscapeHTML( fpData.m_footprint ) );
408
409 if( !m_dryRun )
410 {
411 commit.Modify( symbol, screen );
412 symbol->SetFootprintFieldText( fpData.m_footprint );
413 }
414
416 }
417
418 if( m_processValues && oldValue != fpData.m_value && !skip )
419 {
421 msg.Printf( _( "Change %s value from '%s' to '%s'." ),
422 ref.GetRef(),
423 EscapeHTML( oldValue ),
424 EscapeHTML( fpData.m_value ) );
425
426 if( !m_dryRun )
427 {
428 commit.Modify( symbol, screen );
429 symbol->SetValueFieldText( fpData.m_value );
430 }
431
433 }
434
435 if( m_processAttributes && oldDNP != fpData.m_DNP && !skip )
436 {
438 msg.Printf( _( "Change %s 'Do not populate' from '%s' to '%s'." ),
439 ref.GetRef(),
440 boolString( oldDNP ),
441 boolString( fpData.m_DNP ) );
442
443 if( !m_dryRun )
444 {
445 commit.Modify( symbol, screen );
446 symbol->SetDNP( fpData.m_DNP );
447 }
448
450 }
451
452 if( m_processAttributes && oldExBOM != fpData.m_excludeFromBOM && !skip )
453 {
455 msg.Printf( _( "Change %s 'Exclude from bill of materials' from '%s' to '%s'." ),
456 ref.GetRef(),
457 boolString( oldExBOM ),
458 boolString( fpData.m_excludeFromBOM ) );
459
460 if( !m_dryRun )
461 {
462 commit.Modify( symbol, screen );
463 symbol->SetExcludedFromBOM( fpData.m_excludeFromBOM );
464 }
465
467 }
468
470 {
471 for( const std::pair<const wxString, wxString>& entry : fpData.m_pinMap )
472 {
473 const wxString& pinNumber = entry.first;
474 const wxString& shortNetName = entry.second;
475 SCH_PIN* pin = symbol->GetPin( pinNumber );
476
477 if( !pin )
478 {
479 msg.Printf( _( "Cannot find %s pin '%s'." ),
480 ref.GetRef(),
481 EscapeHTML( pinNumber ) );
483
484 continue;
485 }
486
487 SCH_CONNECTION* connection = pin->Connection( &ref.GetSheetPath() );
488
489 if( connection && connection->Name( true ) != shortNetName )
490 {
491 processNetNameChange( &commit, ref.GetRef(), pin, connection,
492 connection->Name( true ), shortNetName );
493 }
494 }
495 }
496
498 {
499 // Need to handle three cases: existing field, new field, deleted field
500 for( const std::pair<const wxString, wxString>& field : fpData.m_fieldsMap )
501 {
502 const wxString& fpFieldName = field.first;
503 const wxString& fpFieldValue = field.second;
504 SCH_FIELD* symField = symbol->FindField( fpFieldName );
505
506 // Skip fields that are individually controlled
507 if( fpFieldName == GetCanonicalFieldName( REFERENCE_FIELD )
508 || fpFieldName == GetCanonicalFieldName( VALUE_FIELD )
509 || fpFieldName == GetCanonicalFieldName( FOOTPRINT_FIELD ) )
510 {
511 continue;
512 }
513
514 // 1. Existing fields has changed value
515 // PCB Field value is checked against the shown text because this is the value
516 // with all the variables resolved. The footprints field value gets the symbol's
517 // resolved value when the PCB is updated from the schematic.
518 if( symField
519 && symField->GetShownText( &ref.GetSheetPath(), false ) != fpFieldValue )
520 {
522 msg.Printf( _( "Change %s field '%s' value to '%s'." ),
523 ref.GetRef(),
524 EscapeHTML( symField->GetCanonicalName() ),
525 EscapeHTML( fpFieldValue ) );
526
527 if( !m_dryRun )
528 {
529 commit.Modify( symbol, screen );
530 symField->SetText( fpFieldValue );
531 }
532
534 }
535
536 // 2. New field has been added to footprint and needs to be added to symbol
537 if( symField == nullptr )
538 {
540 msg.Printf( _( "Add %s field '%s' with value '%s'." ),
541 ref.GetRef(),
542 EscapeHTML( fpFieldName ),
543 EscapeHTML( fpFieldValue ) );
544
545 if( !m_dryRun )
546 {
547 commit.Modify( symbol, screen );
548
549 SCH_FIELD newField( VECTOR2I( 0, 0 ), symbol->GetFieldCount(), symbol,
550 fpFieldName );
551 newField.SetText( fpFieldValue );
552 symbol->AddField( newField );
553 }
554
556 }
557 }
558
559 // 3. Existing field has been deleted from footprint and needs to be deleted from symbol
560 // Check all symbol fields for existence in the footprint field map
561 for( SCH_FIELD& field : symbol->GetFields() )
562 {
563 // Never delete mandatory fields
564 if( field.IsMandatory() )
565 continue;
566
567 if( fpData.m_fieldsMap.find( field.GetCanonicalName() )
568 == fpData.m_fieldsMap.end() )
569 {
570 // Field not found in footprint field map, delete it
572 msg.Printf( _( "Delete %s field '%s.'" ),
573 ref.GetRef(),
574 EscapeHTML( field.GetCanonicalName() ) );
575
576 if( !m_dryRun )
577 {
578 commit.Modify( symbol, screen );
579 symbol->RemoveField( &field );
580 }
581
583 }
584 }
585 }
586
587 // TODO: back-annotate netclass changes?
588 }
589
590 if( !m_dryRun )
591 {
594
595 commit.Push( _( "Update Schematic from PCB" ) );
596 }
597}
598
599
601{
603
604 // Initial orientation from the pin
605 switch( aPin->GetLibPin()->GetOrientation() )
606 {
607 default:
610 case PIN_ORIENTATION::PIN_DOWN: spin = SPIN_STYLE::UP; break;
612 }
613
614 // Reorient based on the actual symbol orientation now
615 struct ORIENT
616 {
617 int flag;
618 int n_rots;
619 int mirror_x;
620 int mirror_y;
621 }
622 orientations[] =
623 {
624 { SYM_ORIENT_0, 0, 0, 0 },
625 { SYM_ORIENT_90, 1, 0, 0 },
626 { SYM_ORIENT_180, 2, 0, 0 },
627 { SYM_ORIENT_270, 3, 0, 0 },
628 { SYM_MIRROR_X + SYM_ORIENT_0, 0, 1, 0 },
629 { SYM_MIRROR_X + SYM_ORIENT_90, 1, 1, 0 },
630 { SYM_MIRROR_Y, 0, 0, 1 },
631 { SYM_MIRROR_X + SYM_ORIENT_270, 3, 1, 0 },
632 { SYM_MIRROR_Y + SYM_ORIENT_0, 0, 0, 1 },
633 { SYM_MIRROR_Y + SYM_ORIENT_90, 1, 0, 1 },
634 { SYM_MIRROR_Y + SYM_ORIENT_180, 2, 0, 1 },
635 { SYM_MIRROR_Y + SYM_ORIENT_270, 3, 0, 1 }
636 };
637
638 ORIENT o = orientations[ 0 ];
639
640 const SCH_SYMBOL* parentSymbol = static_cast<const SCH_SYMBOL*>( aPin->GetParentSymbol() );
641
642 if( !parentSymbol )
643 return spin;
644
645 int symbolOrientation = parentSymbol->GetOrientation();
646
647 for( const ORIENT& i : orientations )
648 {
649 if( i.flag == symbolOrientation )
650 {
651 o = i;
652 break;
653 }
654 }
655
656 for( int i = 0; i < o.n_rots; i++ )
657 spin = spin.RotateCCW();
658
659 if( o.mirror_x )
660 spin = spin.MirrorX();
661
662 if( o.mirror_y )
663 spin = spin.MirrorY();
664
665 return spin;
666}
667
668
669void addConnections( SCH_ITEM* aItem, const SCH_SHEET_PATH& aSheetPath,
670 std::set<SCH_ITEM*>& connectedItems )
671{
672 if( connectedItems.insert( aItem ).second )
673 {
674 for( SCH_ITEM* connectedItem : aItem->ConnectedItems( aSheetPath ) )
675 addConnections( connectedItem, aSheetPath, connectedItems );
676 }
677}
678
679
680void BACK_ANNOTATE::processNetNameChange( SCH_COMMIT* aCommit, const wxString& aRef, SCH_PIN* aPin,
681 const SCH_CONNECTION* aConnection,
682 const wxString& aOldName, const wxString& aNewName )
683{
684 wxString msg;
685
686 // Find a physically-connected driver. We can't use the SCH_CONNECTION's m_driver because
687 // it has already been resolved by merging subgraphs with the same label, etc., and our
688 // name change may cause that resolution to change.
689
690 std::set<SCH_ITEM*> connectedItems;
691 SCH_ITEM* driver = nullptr;
693
694 addConnections( aPin, aConnection->Sheet(), connectedItems );
695
696 for( SCH_ITEM* item : connectedItems )
697 {
699
700 if( priority > driverPriority )
701 {
702 driver = item;
703 driverPriority = priority;
704 }
705 }
706
707 switch( driver->Type() )
708 {
709 case SCH_LABEL_T:
711 case SCH_HIER_LABEL_T:
712 case SCH_SHEET_PIN_T:
714
715 msg.Printf( _( "Change %s pin %s net label from '%s' to '%s'." ),
716 aRef,
717 EscapeHTML( aPin->GetShownNumber() ),
718 EscapeHTML( aOldName ),
719 EscapeHTML( aNewName ) );
720
721 if( !m_dryRun )
722 {
723 aCommit->Modify( driver, aConnection->Sheet().LastScreen() );
724 static_cast<SCH_LABEL_BASE*>( driver )->SetText( aNewName );
725 }
726
728 break;
729
730 case SCH_PIN_T:
731 {
732 SCH_PIN* schPin = static_cast<SCH_PIN*>( driver );
733 SPIN_STYLE spin = orientLabel( schPin );
734
735 if( schPin->IsGlobalPower() )
736 {
737 msg.Printf( _( "Net %s cannot be changed to %s because it is driven by a power pin." ),
738 EscapeHTML( aOldName ),
739 EscapeHTML( aNewName ) );
740
742 break;
743 }
744
746 msg.Printf( _( "Add label '%s' to %s pin %s net." ),
747 EscapeHTML( aNewName ),
748 aRef,
749 EscapeHTML( aPin->GetShownNumber() ) );
750
751 if( !m_dryRun )
752 {
754 SCH_LABEL* label = new SCH_LABEL( driver->GetPosition(), aNewName );
755 label->SetParent( &m_frame->Schematic() );
756 label->SetTextSize( VECTOR2I( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) );
757 label->SetSpinStyle( spin );
758 label->SetFlags( IS_NEW );
759
760 SCH_SCREEN* screen = aConnection->Sheet().LastScreen();
761 aCommit->Add( label, screen );
762 }
763
765 }
766 break;
767
768 default:
769 break;
770 }
771}
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:81
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:243
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:404
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:129
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:314
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
Revert the commit by restoring the modified items state.
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
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:1252
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
Definition: sch_field.cpp:209
void SetText(const wxString &aText) override
Definition: sch_field.cpp:1212
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:166
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:280
const SYMBOL * GetParentSymbol() const
Definition: sch_item.cpp:166
virtual void SetSpinStyle(SPIN_STYLE aSpinStyle)
Definition: sch_label.cpp:297
wxString GetShownNumber() const
Definition: sch_pin.cpp:505
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.h:191
SCH_PIN * GetLibPin() const
Definition: sch_pin.h:82
PIN_ORIENTATION GetOrientation() const
Definition: sch_pin.cpp:258
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:104
int GetFieldCount() const
Return the number of fields in this symbol.
Definition: sch_symbol.h:606
void SetValueFieldText(const wxString &aValue)
Definition: sch_symbol.cpp:917
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:779
void SetFootprintFieldText(const wxString &aFootprint)
Definition: sch_symbol.cpp:933
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.
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:987
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:154
bool GetExcludedFromBoard() const
Definition: symbol.h:148
bool GetExcludedFromBOM() const
Definition: symbol.h:142
bool GetDNP() const
Set or clear the 'Do Not Populate' flaga.
Definition: symbol.h:153
void SetExcludedFromBOM(bool aExcludeFromBOM)
Set or clear the exclude from schematic bill of materials flag.
Definition: symbol.h:141
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: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:83
@ SYM_MIRROR_Y
Definition: sch_symbol.h:85
@ SYM_ORIENT_180
Definition: sch_symbol.h:82
@ SYM_MIRROR_X
Definition: sch_symbol.h:84
@ SYM_ORIENT_90
Definition: sch_symbol.h:81
@ SYM_ORIENT_0
Definition: sch_symbol.h:80
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
wxString GetCanonicalFieldName(int idx)
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ 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:691
Definition of file extensions used in Kicad.