30#include <api/schematic/schematic_types.pb.h>
61#include <wx/tokenzr.h>
75 wxFileName::Rmdir(
m_dir, wxPATH_RMDIR_RECURSIVE );
78 void Load(
const wxString& aPath )
87 m_dir = wxFileName::CreateTempFileName( wxFileName::GetTempDir() + wxFileName::GetPathSeparator()
88 + wxS(
"ref_suffix" ) );
89 wxRemoveFile(
m_dir );
90 wxFileName::Mkdir(
m_dir );
92 for(
const wxString&
name : { wxS(
"issue13212" ), wxS(
"issue13212_subsheet_1" ),
93 wxS(
"issue13212_subsheet_2" ) } )
97 BOOST_REQUIRE( wxCopyFile( src.GetFullPath(), dst.GetFullPath() ) );
108 std::vector<SCH_SHEET_PATH>
PathsOf(
const wxString& aFile )
const
110 std::vector<SCH_SHEET_PATH> paths;
114 if(
path.Last()->GetFileName() == aFile )
115 paths.push_back(
path );
122 std::vector<SCH_SHEET_PATH>
SuffixChannels(
const wxString& aFirst = wxS(
"_M1" ),
123 const wxString& aSecond = wxS(
"_M2" ),
124 const wxString& aFile = wxS(
"issue13212_subsheet_2.kicad_sch" ) )
126 std::vector<SCH_SHEET_PATH> channels =
PathsOf( aFile );
131 m_schematic->Settings().m_AnnotateReusedSheetSuffixes =
true;
139 Load( wxS(
"legacy_hierarchy/legacy_hierarchy" ) );
140 return SuffixChannels( wxS(
"_V" ), wxS(
"_H" ), wxS(
"ampli_ht.kicad_sch" ) );
145 std::vector<SCH_SHEET*> sheets;
148 sheets.push_back(
static_cast<SCH_SHEET*
>( item ) );
150 std::sort( sheets.begin(), sheets.end(),
153 return a->GetName() < b->GetName();
187 bool aResetAnnotation )
189 m_schematic->Settings().m_AnnotateReusedSheetSuffixes =
true;
254 count +=
static_cast<SCH_MARKER*
>( item )->GetRCItem()->GetErrorCode() == aCode;
275 field.
SetName( wxS(
"reference suffix" ) );
280 for(
const wxString& bad : { wxS(
"_M 1" ), wxS(
"_M?" ), wxS(
"_M1,_M2" ), wxS(
"2" ) } )
283 const std::set<wxString> inUse = { wxS(
"_M1" ), wxS(
"_M3" ), wxS(
"_M09" ), wxS(
"_K01" ), wxS(
"_A" ),
284 wxS(
"_AY" ), wxS(
"_b" ), wxS(
"_z" ), wxS(
"_LEFT" ), wxS(
"_N2X" ),
285 wxS(
"_1ZZ" ), wxS(
"_1AAA" ), wxS(
"_W0" ),
286 wxS(
"_W18446744073709551615" ) };
298 std::vector<SCH_SHEET_PATH> channels = SuffixChannels();
299 SCH_SYMBOL* symbol = FirstSymbol( channels[0] );
301 const KIID_PATH paths[2] = { channels[0].Path(), channels[1].Path() };
303 symbol->
SetRef( &channels[0], wxS(
"R91" ) );
304 symbol->
SetRef( &channels[1], wxS(
"R92" ) );
307 auto storesComposed =
308 [](
const wxString& aFile )
312 return text.Contains( wxS(
"(reference \"R91_M1\")" ) )
313 &&
text.Contains( wxS(
"(reference \"R92_M2\")" ) );
317 io.
SaveSchematicFile( RootFile().GetFullPath(), m_schematic->GetTopLevelSheets()[0], m_schematic.get() );
318 io.
SaveSchematicFile( channels[0].LastScreen()->GetFileName(), channels[0].Last(), m_schematic.get() );
319 BOOST_CHECK( storesComposed( channels[0].LastScreen()->GetFileName() ) );
328 BOOST_CHECK( storesComposed( downgraded.GetFullPath() ) );
334 std::optional<SCH_SHEET_PATH> first = m_schematic->Hierarchy().GetSheetPathByKIIDPath( paths[0] );
335 std::optional<SCH_SHEET_PATH> second = m_schematic->Hierarchy().GetSheetPathByKIIDPath( paths[1] );
340 BOOST_CHECK_EQUAL( first->Last()->GetRefSuffix( m_schematic->Hierarchy()[0] ), wxS(
"_M1" ) );
341 BOOST_CHECK( m_schematic->GetRefSuffix( *first ).IsEmpty() );
344 io.
SaveSchematicFile( first->LastScreen()->GetFileName(), first->Last(), m_schematic.get() );
346 BOOST_REQUIRE( wxFFile( first->LastScreen()->GetFileName(), wxS(
"rb" ) ).ReadAll( &plainFile ) );
347 BOOST_CHECK( plainFile.Contains( wxS(
"(reference \"R91\")" ) ) );
348 BOOST_CHECK( plainFile.Contains( wxS(
"(reference \"R92\")" ) ) );
349 BOOST_CHECK( !plainFile.Contains( wxS(
"(reference \"R91_M1\")" ) ) );
351 m_schematic->Settings().m_AnnotateReusedSheetSuffixes =
true;
352 m_schematic->RefreshRefSuffixes();
362 auto sheet = std::make_unique<SCH_SHEET>( &host );
363 std::map<std::string, UTF8> props{ {
"hierarchical_sheet_load",
"1" } };
365 sheet->SetFileName( RootFile().GetFullPath() );
370 std::set<wxString> refs;
381 if( item->m_Uuid == uuid
389 BOOST_CHECK( refs == std::set<wxString>( { wxS(
"R91" ), wxS(
"R92" ) } ) );
395 Load( wxS(
"issue25112/issue25112" ) );
399 std::vector<SCH_SHEET*> outer = SubSheets( root.
LastScreen() );
402 std::vector<SCH_SHEET*> inner = SubSheets( outer[0]->GetScreen() );
405 AddSuffixField( outer[0], wxS(
"_M1" ) );
406 AddSuffixField( outer[1], wxS(
"_M2" ) );
409 AddSuffixField( inner[0], wxS(
"_${CH}" ) );
410 m_schematic->Settings().m_AnnotateReusedSheetSuffixes =
true;
411 m_schematic->RefreshHierarchy();
413 std::set<wxString> composed;
418 if(
path.Last() == inner[0] ||
path.Last() == inner[1] )
419 composed.insert( m_schematic->GetRefSuffix(
path ) );
421 if(
path.Last() == inner[0] &&
path.at(
path.size() - 2 ) == outer[0] )
425 BOOST_CHECK( composed == std::set<wxString>( { wxS(
"_M1_a" ), wxS(
"_M1" ), wxS(
"_M2_b" ), wxS(
"_M2" ) } ) );
429 rooted.
push_back( &m_schematic->Root() );
431 for(
size_t i = 0; i < leaf.
size(); i++ )
432 rooted.push_back( leaf.
at( i ) );
434 BOOST_REQUIRE_NE( rooted.GetCurrentHash(), leaf.
GetCurrentHash() );
438 m_schematic->AddVariant( wxS(
"Alt" ) );
439 outer[0]->SetFieldText( wxS(
"CH" ), wxS(
"x" ), &root, wxS(
"Alt" ) );
440 m_schematic->SetCurrentVariant( wxS(
"Alt" ) );
441 m_schematic->RefreshHierarchy();
444 outer[1]->SetFieldText( wxS(
"Reference Suffix" ), wxS(
"_X" ), &root, wxS(
"Alt" ) );
449 stale.
m_Fields[wxS(
"Reference Suffix" )] = wxS(
"_STALE" );
450 outer[1]->AddVariant( root, stale );
456 m_schematic->Project().GetTextVars()[wxS(
"LOT" )] = wxS(
"7" );
458 outer[1]->GetField( wxS(
"Reference Suffix" ) )
459 ->SetText( wxS(
"_${ERC_WARNING_CH}${LOT}${REVISION}${Sheetfile}" ) );
461 BOOST_CHECK_EQUAL( outer[1]->GetRefSuffix( root ), wxS(
"_a${LOT}${REVISION}${Sheetfile}" ) );
468 manager.
SetEnvironment( m_schematic.get(),
nullptr,
nullptr,
nullptr,
nullptr );
473 outer[0]->GetField( wxS(
"CH" ) )->SetText( wxS(
"c" ) );
483 Load( wxS(
"issue13212" ) );
485 std::vector<SCH_SHEET_PATH> channels = SuffixChannels();
486 SCH_SYMBOL* symbol = FirstSymbol( channels[0] );
487 wxString base = symbol->
GetBaseRef( &channels[0] );
493 channels[0].UpdateAllScreenReferences();
497 m_schematic->RebuildConnectivity();
502 wxString prefix = wxS(
"(" ) + symbol->
GetRef( &channel ) + wxS(
"-" );
503 BOOST_CHECK( std::ranges::any_of( names, [&](
const wxString& n ) {
return n.Contains( prefix ); } ) );
510 Load( wxS(
"issue13212" ) );
512 std::vector<SCH_SHEET_PATH> channels = SuffixChannels();
513 SCH_SYMBOL* symbol = FirstSymbol( channels[1] );
521 { &refs[1], wxS(
"R7_M2" ) } }, true );
523 { &refs[1], wxS(
"R1_M2" ) } }, true );
543 m_schematic->Settings().m_AnnotateReusedSheetSuffixes =
true;
544 m_schematic->SetCurrentSheet( channels[1] );
548 kiapi::schematic::types::SchematicSymbolInstance proto;
553 m_schematic->Settings().m_AnnotateReusedSheetSuffixes =
false;
554 symbol->
SetRef( &channels[1], wxS(
"R5_M2" ) );
561 m_schematic->Settings().m_AnnotateReusedSheetSuffixes =
true;
562 m_schematic->RefreshHierarchy();
568 kiapi::common::commands::ItemStatus status;
569 symbol->
SetRef( &channels[0], wxS(
"R8_B" ) );
581 m_schematic->Settings().m_AnnotateReusedSheetSuffixes =
true;
585 std::vector<SCH_SHEET_PATH> channels = SuffixChannels();
586 const KIID_PATH firstPath = channels[0].Path();
590 m_schematic->Settings().m_AnnotateReusedSheetSuffixes =
false;
592 m_schematic->RefreshHierarchy();
596 m_schematic->RefreshHierarchy();
602 m_schematic->Settings().m_AnnotateReusedSheetSuffixes =
false;
603 m_schematic->RefreshRefSuffixes();
605 m_schematic->Settings().m_AnnotateReusedSheetSuffixes =
true;
606 m_schematic->RefreshRefSuffixes();
609 std::optional<SCH_SHEET_PATH>
path = m_schematic->Hierarchy().GetSheetPathByKIIDPath( firstPath );
612 FirstSymbol( *path )->SetRef( &*
path, wxS(
"R99" ) );
619 std::vector<SCH_SHEET_PATH> channels = LoadAmpliChannels();
623 m_schematic->Settings().m_AnnotateReusedSheetSuffixes =
false;
627 channels[0].LastScreen()->Append( unitA );
629 unitA->
SetRef( &channels[0], wxS(
"U777" ) );
630 unitA->
SetRef( &channels[1], wxS(
"U778" ) );
631 unitB->
SetRef( &root, wxS(
"U777_V2" ) );
636 m_schematic->Settings().m_AnnotateReusedSheetSuffixes =
true;
637 m_schematic->RefreshHierarchy();
650 Load( wxS(
"issue13212" ) );
652 std::vector<SCH_SHEET_PATH> channels = SuffixChannels();
653 SCH_SYMBOL* symbol = FirstSymbol( channels[0] );
660 std::set<wxString> bases;
665 bases.insert(
static_cast<SCH_SYMBOL*
>( item )->GetBaseRef( &
path ) );
668 BOOST_CHECK( bases == std::set<wxString>( { wxS(
"R1" ), wxS(
"R2" ), wxS(
"R3" ), wxS(
"R4" ), wxS(
"R5" ),
669 wxS(
"R6" ), wxS(
"R7" ) } ) );
675 AnnotatePlaced( symbol, channels );
684 Load( wxS(
"issue13212" ) );
685 std::vector<SCH_SHEET_PATH> channels = SuffixChannels();
686 SCH_SYMBOL* symbol = FirstSymbol( channels[0] );
689 m_schematic->Settings().m_AnnotateReusedSheetSuffixes =
false;
690 m_schematic->RefreshRefSuffixes();
692 BOOST_CHECK_EQUAL( channels[0].Last()->GetRefSuffix( m_schematic->Hierarchy()[0] ), wxS(
"_M1" ) );
694 BOOST_CHECK( m_schematic->GetRefSuffix( channels[0] ).IsEmpty() );
697 symbol->
SetRef( &channels[0], wxS(
"R?" ) );
708 m_schematic->Settings().m_AnnotateReusedSheetSuffixes =
true;
709 m_schematic->RefreshRefSuffixes();
716 Load( wxS(
"issue13212" ) );
717 std::vector<SCH_SHEET_PATH> channels = SuffixChannels();
719 SCH_SYMBOL* channel = FirstSymbol( channels[0] );
720 SCH_SYMBOL* other = FindSymbol( root, wxS(
"R1" ) );
723 other->
SetRef( &root, wxS(
"R1_M2" ) );
724 m_schematic->Settings().m_AnnotateReusedSheetSuffixes =
false;
725 m_schematic->RefreshRefSuffixes();
735 BOOST_CHECK_NE( channel->
GetRef( &channels[0] ), channel->
GetRef( &channels[1] ) );
745 Load( wxS(
"issue13212" ) );
747 std::vector<SCH_SHEET_PATH> channels = SuffixChannels();
749 SCH_SYMBOL* channel = FirstSymbol( channels[0] );
750 SCH_SYMBOL* other = FindSymbol( root, wxS(
"R1" ) );
753 other->
SetRef( &root, wxS(
"R1_M2" ) );
758 AnnotateSelection( { channel }, channels[0] );
769 Load( wxS(
"issue13212" ) );
771 for(
const SCH_SHEET_PATH&
path : PathsOf( wxS(
"issue13212_subsheet_2.kicad_sch" ) ) )
774 std::vector<SCH_SHEET_PATH> channels = SuffixChannels( wxS(
"_A" ), wxS(
"${CH}" ) );
775 std::vector<SCH_SHEET_PATH> singles = PathsOf( wxS(
"issue13212_subsheet_1.kicad_sch" ) );
776 BOOST_REQUIRE( !singles.empty() && m_schematic->GetRefSuffix( channels[1] ) == wxS(
"2" ) );
779 SCH_SYMBOL* channel = FirstSymbol( channels[0] );
782 channel->
SetRef( &channels[0], wxS(
"R91" ) );
783 channel->
SetRef( &channels[1], wxS(
"R92" ) );
784 other->
SetRef( &single, wxS(
"R912" ) );
785 AnnotateSelection( { channel }, channels[0] );
787 BOOST_CHECK_NE( channel->
GetRef( &channels[1] ), other->
GetRef( &single ) );
791 m_schematic->RefreshHierarchy();
793 channel->
SetRef( &channels[0], wxS(
"R91" ) );
794 channel->
SetRef( &channels[1], wxS(
"R91" ) );
795 other->
SetRef( &single, wxS(
"R91A1" ) );
799 channel->
SetRef( &channels[1], wxS(
"R92" ) );
802 BOOST_CHECK_NE( channel->
GetRef( &channels[1] ), other->
GetRef( &single ) );
808 std::vector<SCH_SHEET_PATH> channels = LoadAmpliChannels();
809 SCH_SYMBOL* x = FindSymbol( channels[0], wxS(
"R203_V" ) );
810 SCH_SYMBOL* y = FindSymbol( channels[0], wxS(
"R213_V" ) );
811 SCH_SYMBOL* unitA = FindSymbol( channels[0], wxS(
"U201_V" ), 1 );
812 SCH_SYMBOL* unitB = FindSymbol( channels[0], wxS(
"U201_V" ), 2 );
816 x->
SetRef( &channels[1], wxS(
"R213" ) );
817 y->
SetRef( &channels[1], wxS(
"R203" ) );
818 AnnotateSelection( { x }, channels[1] );
821 BOOST_CHECK_NE( x->
GetRef( &channels[1] ), y->
GetRef( &channels[1] ) );
824 x->
SetRef( &channels[1], wxS(
"U201" ) );
825 AnnotateSelection( { unitA, unitB }, channels[0] );
828 BOOST_CHECK_NE( unitA->
GetBaseRef( &channels[0] ), wxS(
"U201" ) );
833 unitA->
SetRef( &channel, wxS(
"U1" ) );
834 unitB->
SetRef( &channel, wxS(
"U?" ) );
838 m_schematic->Settings().m_AnnotateStartNum = 0;
839 AnnotatePlaced( unitB, channels );
851 std::map<wxString, std::set<int>> packages;
856 packages[symbol->GetRef( &channel )].insert( symbol->GetUnitSelection( &channel ) );
861 for(
const auto& [package, units] : packages )
862 BOOST_CHECK_MESSAGE( !package.Contains( wxS(
"?" ) ) && units == std::set<int>( { 1, 2 } ), package );
869 std::vector<SCH_SHEET_PATH> channels = LoadAmpliChannels();
870 SCH_SYMBOL* unitA = FindSymbol( channels[0], wxS(
"U201_V" ), 1 );
871 SCH_SYMBOL* unitB = FindSymbol( channels[0], wxS(
"U201_V" ), 2 );
875 unitA->
SetRef( &channels[1], wxS(
"U9_H" ) );
876 unitB->
SetRef( &channels[0], wxS(
"U9_H" ) );
877 unitA->
SetRef( &channels[0], wxS(
"U8_H" ) );
878 unitB->
SetRef( &channels[1], wxS(
"U8_H" ) );
880 m_schematic->Hierarchy().StripRefSuffixes();
887 channels[1].Last()->GetField( wxS(
"Reference Suffix" ) )->SetText( wxS(
"_H2_V" ) );
888 m_schematic->RefreshHierarchy();
889 unitA->
SetRef( &channels[1], wxS(
"U9" ) );
890 unitB->
SetRef( &channels[0], wxS(
"U9_H2_V" ) );
892 unitB->
SetRef( &channels[1], wxS(
"U7" ) );
893 unitA->
SetRef( &channels[0], wxS(
"U7_H2" ) );
900 m_schematic->SetTopLevelSheets( { m_schematic->GetTopLevelSheets()[0], other } );
910 std::vector<SCH_SHEET_PATH> channels = LoadAmpliChannels();
911 SCH_SYMBOL* unitA = FindSymbol( channels[0], wxS(
"U201_V" ), 1 );
912 SCH_SYMBOL* unitB = FindSymbol( channels[0], wxS(
"U201_V" ), 2 );
913 SCH_SYMBOL* low = FindSymbol( channels[0], wxS(
"R212_V" ) );
918 const wxString netFile = temp.
PathStr() + wxS(
"/netlist.net" );
919 const wxString xmlFile = temp.
PathStr() + wxS(
"/netlist.xml" );
922 [](
const wxString& aFile )
930 low->
SetRef( &channels[0], wxS(
"R30" ) );
932 BOOST_CHECK( read( netFile ).Contains( wxS(
"; R30_V,\n\tR201_V,\n\tR208_V,\n\tR301_H," ) ) );
935 m_schematic->Settings().m_AnnotateReusedSheetSuffixes =
true;
941 if( !symbol->
GetRef( &channels[0] ).StartsWith( wxS(
"#" ) ) )
956 unitA->
SetRef( &channels[0], wxS(
"U8" ) );
957 unitB->
SetRef( &channels[1], wxS(
"U8" ) );
958 unitA->
SetRef( &channels[1], wxS(
"U9" ) );
959 unitB->
SetRef( &channels[0], wxS(
"U9" ) );
970 const wxString ref =
static_cast<SCH_SYMBOL*
>( item )->GetRef( &
path );
972 if( !ref.StartsWith( wxS(
"#" ) ) )
978 [](
const wxString& aText,
const wxString& aPattern )
980 std::set<wxString> refs;
981 wxRegEx re( aPattern, wxRE_ADVANCED );
982 wxString rest = aText;
986 while( re.Matches( rest ) && re.GetMatch( &start, &len, 0 ) )
988 refs.insert( re.GetMatch( rest, 1 ) );
989 rest = rest.Mid( start + len );
1006 wxString allegro = read( netFile );
1007 allegro = allegro.Mid( allegro.Find( wxS(
"$PACKAGES\n" ) ) + 10 );
1008 BOOST_CHECK( refsIn( allegro.Left( allegro.Find( wxS(
"$" ) ) ), wxS(
"(?:; |\\n\\t)([^,\\s]+)" ) ) ==
expected );
1018 std::set<wxString> listed;
1022 wxStringTokenizer tokens( bom.
GetValue( row, 0 ), wxS(
", " ), wxTOKEN_STRTOK );
1024 while( tokens.HasMoreTokens() )
1025 listed.insert( tokens.GetNextToken() );
1031 channels[1].Last()->GetField( wxS(
"Reference Suffix" ) )->SetText( wxS(
"_Z" ) );
1032 m_schematic->RefreshHierarchy();
1039 int comp =
netlist.Find( wxS(
"(comp (ref \"U9_V\")" ) );
1043 block = block.Left( block.Find( wxS(
"(comp " ) ) );
1044 BOOST_CHECK( block.Contains( wxS(
"(tstamps \"" ) + channels[1].PathAsString() + wxS(
"\")" ) ) );
KICAD_PLUGIN_EXPORT SCENEGRAPH * Load(char const *aFileName)
Read a model file and creates a generic display structure.
bool ApplySymbolInstance(kiapi::common::commands::ItemStatus *aStatus, SCH_SYMBOL *aSymbol, const kiapi::schematic::types::SchematicSymbolInstance &aInput, const SCH_SHEET_PATH &aPath, SCHEMATIC *aSchematic)
Apply placement-specific data to an aSymbol at aPath: reference, unit, and the per-placement attribut...
bool PackSymbol(kiapi::schematic::types::SchematicSymbolInstance *aOutput, const SCH_SYMBOL *aInput, const SCH_SHEET_PATH &aPath, const SCHEMATIC *aSchematic)
std::vector< BACKANNOTATE_REF > ResolveBackannotatedRefs(const std::vector< std::pair< const SCH_REFERENCE *, wxString > > &aRequests, bool aShareBases)
Turn the references footprints carry into the base references of their schematic instances.
bool IsContentModified() const
void SetContentModified(bool aModified=true)
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
EE_TYPE OfType(KICAD_T aType) const
Runs the electrical rules checks and adds a SCH_MARKER for each violation.
void RunTests(DS_PROXY_VIEW_ITEM *aDrawingSheet, SCH_EDIT_FRAME *aEditFrame, KIFACE *aCvPcb, PROJECT *aProject, PROGRESS_REPORTER *aProgressReporter)
void SetGroupingEnabled(bool aGroup)
void AddColumn(const wxString &aFieldName, const wxString &aLabel, bool aAddedByUser) override
wxString GetValue(int aRow, int aCol) override
int GetNumberRows() override
A generic fixture for loading schematics and associated settings for qa tests.
SETTINGS_MANAGER m_manager
std::unique_ptr< SCHEMATIC > m_schematic
virtual void LoadSchematic(const wxFileName &aFn)
wxString PathStr() const
Get the path to the temporary directory as a wxString.
Generate a netlist compatible with Allegro.
bool WriteNetlist(const wxString &aOutFileName, unsigned aNetlistOptions, REPORTER &aReporter)
Write to specified output file.
Generate the KiCad netlist format supported by Pcbnew.
void Format(OUTPUTFORMATTER *aOutputFormatter, int aCtl)
Output this s-expression netlist into aOutputFormatter.
Generate a generic XML based netlist file.
A singleton reporter that reports to nowhere.
static std::vector< SCH_SHEET * > SubSheets(SCH_SCREEN *aScreen)
void AnnotateAll(bool aResetAnnotation=false)
int CountErcMarkers(int aCode)
std::vector< SCH_SHEET_PATH > LoadAmpliChannels()
void Annotate(SCH_REFERENCE_LIST &aRefs, const SCH_MULTI_UNIT_REFERENCE_MAP &aLocked, ANNOTATE_SCOPE_T aScope, bool aResetAnnotation)
std::vector< SCH_SHEET_PATH > SuffixChannels(const wxString &aFirst=wxS("_M1"), const wxString &aSecond=wxS("_M2"), const wxString &aFile=wxS("issue13212_subsheet_2.kicad_sch"))
wxFileName RootFile() const
static SCH_SYMBOL * FirstSymbol(const SCH_SHEET_PATH &aPath)
void AnnotateSelection(const std::vector< SCH_SYMBOL * > &aSymbols, const SCH_SHEET_PATH &aPath)
std::vector< SCH_SHEET_PATH > PathsOf(const wxString &aFile) const
static void AddSuffixField(SCH_SHEET *aSheet, const wxString &aText)
static SCH_SYMBOL * FindSymbol(const SCH_SHEET_PATH &aPath, const wxString &aRef, int aUnit=1)
void AnnotatePlaced(SCH_SYMBOL *aSymbol, const std::vector< SCH_SHEET_PATH > &aChannels)
void Load(const wxString &aPath)
~REF_SUFFIX_FIXTURE() override
Holds all the data relating to one schematic.
void Reset()
Initialize this schematic to a blank one, unloading anything existing.
SCH_SHEET_LIST Hierarchy() const
Return the full schematic flattened hierarchical sheet list.
Commit for the schematic and symbol editors.
void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
One UI operation's hierarchy index.
std::vector< wxString > NetNames() const
bool Replace(const EDA_SEARCH_DATA &aSearchData, void *aAuxData=nullptr) override
Perform a text replace using the find and replace criteria in aSearchData on items that support text ...
void SetOrdinal(int aOrdinal, FIELD_T aType)
virtual const wxString & GetText() const override
Return the string associated with the text object.
wxString GetShownText(const SCH_SHEET_PATH *aPath, RESOLUTION_CONTEXT aContext, const wxString &aVariantName=wxEmptyString, int aDepth=0) const
void SetName(const wxString &aName)
void SetText(const wxString &aText) override
A SCH_IO derivation for loading schematic files using the new s-expression file format.
void SaveSchematicFile(const wxString &aFileName, SCH_SHEET *aSheet, SCHEMATIC *aSchematic, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Write aSchematic to a storage file in a format that this SCH_IO implementation knows about,...
SCH_SHEET * LoadSchematicFile(const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load information from some input file format that this SCH_IO implementation knows about,...
Base class for any item which can be embedded within the SCHEMATIC container class,...
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
void SortByReferenceOnly()
Sort the list of references by reference.
int CheckAnnotation(ANNOTATION_ERROR_HANDLER aErrorHandler)
Check for annotations errors.
A helper to define a symbol's reference designator in a schematic.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
EE_RTREE & Items()
Get the full RTree, usually for iterating.
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void GetMultiUnitSymbols(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, SYMBOL_FILTER aSymbolFilter) const
Add a SCH_REFERENCE_LIST object to aRefList for each same-reference set of multi-unit parts in the li...
void AddNewSymbolInstances(const SCH_SHEET_PATH &aPrefixSheetPath, const wxString &aProjectName, bool aStripRefSuffixes=false)
Attempt to add new symbol instances for all symbols in this list of sheet paths prefixed with aPrefix...
void GetSymbols(SCH_REFERENCE_LIST &aReferences, SYMBOL_FILTER aSymbolFilter, 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...
void AppendSymbol(SCH_REFERENCE_LIST &aReferences, SCH_SYMBOL *aSymbol, SYMBOL_FILTER aSymbolFilter, bool aForceIncludeOrphanSymbols=false) const
Append a SCH_REFERENCE object to aReferences based on aSymbol.
size_t GetCurrentHash() const
SCH_SCREEN * LastScreen()
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.
void AppendMultiUnitSymbol(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, SCH_SYMBOL *aSymbol, SYMBOL_FILTER aSymbolFilter) const
Append a SCH_REFERENCE_LIST object to aRefList based on aSymbol, storing same-reference set of multi-...
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
size_t size() const
Forwarded method from std::vector.
Variant information for a schematic sheet.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
static wxString NextRefSuffix(const wxString &aSuffix, const std::set< wxString > &aInUse, const std::function< bool(const wxString &)> &aIsTaken=nullptr)
Return the suffix a pasted copy of a sheet should take.
bool HasHierarchyChanges(const SCH_SHEET &aOther) const
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add aFieldName to the list of fields.
void SetRefProp(const wxString &aRef)
wxString BaseRefFromUser(const SCH_SHEET_PATH &aSheet, const wxString &aText, wxString &aBase, const SCHEMATIC *aSchematic=nullptr) const
Convert a reference typed on aSheet to the base reference.
wxString GetBaseRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
void SetRefLacksSuffix(const KIID_PATH &aPath, bool aLacksSuffix=true)
Flag the reference loaded for aPath as saved without its sheet suffix.
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the base reference for the given sheet path for this symbol.
void ClearAnnotation(const SCH_SHEET_PATH *aSheetPath, bool aResetPrefix)
Clear exiting symbol annotation.
bool GetInstance(SCH_SYMBOL_INSTANCE &aInstance, const KIID_PATH &aSheetPath, bool aTestFromEnd=false) const
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
wxString GetPrefix() const
void SetExcludedFromBoard(bool aEnable, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
void RebuildRows() override
std::map< wxString, wxString > m_Fields
const std::vector< DOWNGRADE_TARGET > & GetDowngradeTargets()
Supported downgrade targets, newest first.
@ ERCE_REF_SUFFIX_MISMATCH
Saved reference lacks the suffix of its reused sheet.
@ ERCE_DUPLICATE_REFERENCE
More than one symbol with the same reference.
@ ERCE_DUPLICATE_SHEET_SUFFIX
Two uses of one sheet file share a reference suffix.
@ ERCE_DIFFERENT_UNIT_VALUE
Units of same symbol have different values.
static const std::string KiCadSchematicFileExtension
std::string GetEeschemaTestDataDir()
Get the configured location of Eeschema test data.
void SaveSchematicForTarget(SCH_SHEET *aSheet, SCHEMATIC *aSchematic, const wxString &aPath, const DOWNGRADE_TARGET &aTarget)
Save a schematic sheet file stamped for the target, using the writer for that version.
static void LoadSchematic(SCHEMATIC *aSchematic, SCH_SHEET *aRootSheet, const wxString &aFileName, REPORTER *aReporter)
std::set< const SCH_SCREEN * > AnnotateReferences(SCH_REFERENCE_LIST &aRefs, SCH_MULTI_UNIT_REFERENCE_MAP aLocked, const SCHEMATIC &aSchematic, ANNOTATE_SCOPE_T aScope, ANNOTATE_ORDER_T aSortOption, ANNOTATE_ALGO_T aAlgoOption, int aStartNumber, bool aResetAnnotation, const std::function< void(SCH_REFERENCE &)> &aBeforeAnnotate)
Annotate aRefs, the references in aScope, around every other symbol of aSchematic.
void AnnotateNewSymbol(SCH_SYMBOL *aSymbol, const std::vector< SCH_SHEET_PATH > &aPaths, SCH_REFERENCE_LIST &aExistingRefs, const SCHEMATIC_SETTINGS &aSettings, SCH_SHEET_LIST *aHierarchy)
Annotate a newly placed symbol on each of aPaths in turn, avoiding aExistingRefs and adding the resul...
std::optional< std::pair< SCH_SHEET_PATH, SCH_SHEET_PATH > > FindRefSuffixCollision(const SCH_REFERENCE_LIST &aRefs, const SCHEMATIC &aSchematic)
Find two instances of a reused sheet that aRefs reaches and that compose the same reference suffix.
@ UNSORTED
Annotate by position of symbol in the schematic sheet object list.
@ SORT_BY_X_POSITION
Annotate by X position from left to right.
ANNOTATE_SCOPE_T
Schematic annotation scope options.
@ ANNOTATE_SELECTION
Annotate the selection.
@ ANNOTATE_ALL
Annotate the full schematic.
@ INCREMENTAL_BY_REF
Annotate incrementally using the first free reference number.
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
std::map< wxString, SCH_REFERENCE_LIST > SCH_MULTI_UNIT_REFERENCE_MAP
Container to map reference designators for multi-unit parts.
@ SYMBOL_FILTER_NON_POWER
static std::vector< std::string > split(const std::string &aStr, const std::string &aDelim)
Split the input string into a vector of output strings.
An older KiCad release we can export a project back to.
EDA_SEARCH_MATCH_MODE matchMode
A simple container for schematic symbol instance information.
wxString GetDefaultFieldName(FIELD_T aFieldId, TRANSLATION aTranslation)
Return a default symbol field name for a mandatory field type.
@ SHEET_REF_SUFFIX
Optional sheet field appended to the references of the sheet's symbols.
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_CHECK(res.column_datatype(0)==SQL_NUMERIC||res.column_datatype(0)==SQL_DECIMAL)
BOOST_REQUIRE_EQUAL(rows.size(), 1)
BOOST_CHECK_EQUAL(std::any_cast< std::string >(rows[0].at("val")), "12345678901234567.89")
BOOST_REQUIRE(res.columns()==1)
BOOST_AUTO_TEST_SUITE_END()
IbisParser parser & reporter
VECTOR3I expected(15, 30, 45)
BOOST_AUTO_TEST_CASE(SuffixTextRules)
BOOST_TEST_CONTEXT("Test Clearance")
wxString GetFieldValidationErrorMessage(FIELD_T aFieldId, const wxString &aValue)
Return the error message if aValue is invalid for aFieldId.
Custom text control validator definitions.
Definition of file extensions used in Kicad.