KiCad PCB EDA Suite
SCH_ALTIUM_PLUGIN Class Reference

SCH_ALTIUM_PLUGIN is a SCH_PLUGIN derivation for loading Altium .SchDoc schematic files. More...

#include <sch_altium_plugin.h>

Inheritance diagram for SCH_ALTIUM_PLUGIN:
SCH_PLUGIN

Public Member Functions

 SCH_ALTIUM_PLUGIN ()
 
 ~SCH_ALTIUM_PLUGIN ()
 
const wxString GetName () const override
 Return a brief hard coded name for this SCH_PLUGIN. More...
 
void SetReporter (REPORTER *aReporter) override
 Set an optional reporter for warnings/errors. More...
 
const wxString GetFileExtension () const override
 Return the file extension for the SCH_PLUGIN. More...
 
const wxString GetLibraryFileExtension () const override
 Return the library file extension for the SCH_PLUGIN object. More...
 
int GetModifyHash () const override
 Return the modification hash from the library cache. More...
 
SCH_SHEETLoad (const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aAppendToMe=nullptr, const PROPERTIES *aProperties=nullptr) override
 Load information from some input file format that this SCH_PLUGIN implementation knows about, into either a new SCH_SHEET or an existing one. More...
 
bool CheckHeader (const wxString &aFileName) override
 Return true if the first line in aFileName begins with the expected header. More...
 
wxString getLibName ()
 
wxFileName getLibFileName ()
 
void ParseAltiumSch (const wxString &aFileName)
 
void Parse (const CFB::CompoundFileReader &aReader)
 
virtual void SaveLibrary (const wxString &aFileName, const PROPERTIES *aProperties=nullptr)
 
virtual void Save (const wxString &aFileName, SCH_SHEET *aSheet, SCHEMATIC *aSchematic, const PROPERTIES *aProperties=nullptr)
 Write aSchematic to a storage file in a format that this SCH_PLUGIN implementation knows about, or it can be used to write a portion of aSchematic to a special kind of export file. More...
 
virtual void EnumerateSymbolLib (wxArrayString &aSymbolNameList, const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr)
 Populate a list of LIB_PART alias names contained within the library aLibraryPath. More...
 
virtual void EnumerateSymbolLib (std::vector< LIB_PART * > &aSymbolList, const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr)
 Populate a list of LIB_PART aliases contained within the library aLibraryPath. More...
 
virtual LIB_PARTLoadSymbol (const wxString &aLibraryPath, const wxString &aPartName, const PROPERTIES *aProperties=nullptr)
 Load a LIB_PART object having aPartName from the aLibraryPath containing a library format that this SCH_PLUGIN knows about. More...
 
virtual void SaveSymbol (const wxString &aLibraryPath, const LIB_PART *aSymbol, const PROPERTIES *aProperties=nullptr)
 Write aSymbol to an existing library located at aLibraryPath. More...
 
virtual void DeleteSymbol (const wxString &aLibraryPath, const wxString &aSymbolName, const PROPERTIES *aProperties=nullptr)
 Delete the entire LIB_PART associated with aAliasName from the library aLibraryPath. More...
 
virtual void CreateSymbolLib (const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr)
 Create a new empty symbol library at aLibraryPath. More...
 
virtual bool DeleteSymbolLib (const wxString &aLibraryPath, const PROPERTIES *aProperties=nullptr)
 Delete an existing symbol library and returns true if successful, or if library does not exist returns false, or throws an exception if library exists but is read only or cannot be deleted for some other reason. More...
 
virtual bool IsSymbolLibWritable (const wxString &aLibraryPath)
 Return true if the library at aLibraryPath is writable. More...
 
virtual void SymbolLibOptions (PROPERTIES *aListToAppendTo) const
 Append supported SCH_PLUGIN options to aListToAppenTo along with internationalized descriptions. More...
 
virtual const wxString & GetError () const
 Return an error string to the caller. More...
 

Private Member Functions

bool IsComponentPartVisible (int aOwnerindex, int aOwnerpartdisplaymode) const
 
void ParseComponent (int aIndex, const std::map< wxString, wxString > &aProperties)
 
void ParsePin (const std::map< wxString, wxString > &aProperties)
 
void ParseLabel (const std::map< wxString, wxString > &aProperties)
 
void ParseBezier (const std::map< wxString, wxString > &aProperties)
 
void ParsePolyline (const std::map< wxString, wxString > &aProperties)
 
void ParsePolygon (const std::map< wxString, wxString > &aProperties)
 
void ParseRoundRectangle (const std::map< wxString, wxString > &aProperties)
 
void ParseArc (const std::map< wxString, wxString > &aProperties)
 
void ParseLine (const std::map< wxString, wxString > &aProperties)
 
void ParseRectangle (const std::map< wxString, wxString > &aProperties)
 
void ParseSheetSymbol (int aIndex, const std::map< wxString, wxString > &aProperties)
 
void ParseSheetEntry (const std::map< wxString, wxString > &aProperties)
 
void ParsePowerPort (const std::map< wxString, wxString > &aProperties)
 
void ParsePort (const ASCH_PORT &aElem)
 
void ParseNoERC (const std::map< wxString, wxString > &aProperties)
 
void ParseNetLabel (const std::map< wxString, wxString > &aProperties)
 
void ParseBus (const std::map< wxString, wxString > &aProperties)
 
void ParseWire (const std::map< wxString, wxString > &aProperties)
 
void ParseJunction (const std::map< wxString, wxString > &aProperties)
 
void ParseSheet (const std::map< wxString, wxString > &aProperties)
 
void ParseSheetName (const std::map< wxString, wxString > &aProperties)
 
void ParseFileName (const std::map< wxString, wxString > &aProperties)
 
void ParseDesignator (const std::map< wxString, wxString > &aProperties)
 
void ParseBusEntry (const std::map< wxString, wxString > &aProperties)
 
void ParseParameter (const std::map< wxString, wxString > &aProperties)
 

Private Attributes

REPORTERm_reporter
 
SCH_SHEETm_rootSheet
 
SCH_SHEETm_currentSheet
 
SCHEMATICm_schematic
 
wxString m_libName
 
SCH_PLUGIN::SCH_PLUGIN_RELEASER m_pi
 
std::unique_ptr< PROPERTIESm_properties
 
std::unique_ptr< TITLE_BLOCKm_currentTitleBlock
 
wxPoint m_sheetOffset
 
std::unique_ptr< ASCH_SHEETm_altiumSheet
 
std::map< int, SCH_COMPONENT * > m_components
 
std::map< int, SCH_SHEET * > m_sheets
 
std::map< int, LIB_PART * > m_symbols
 
std::map< wxString, LIB_PART * > m_powerSymbols
 
std::map< int, ASCH_COMPONENTm_altiumComponents
 
std::vector< ASCH_PORTm_altiumPortsCurrentSheet
 

Detailed Description

SCH_ALTIUM_PLUGIN is a SCH_PLUGIN derivation for loading Altium .SchDoc schematic files.

As with all SCH_PLUGINs there is no UI dependencies i.e. windowing calls allowed.

Definition at line 50 of file sch_altium_plugin.h.

Constructor & Destructor Documentation

◆ SCH_ALTIUM_PLUGIN()

SCH_ALTIUM_PLUGIN::SCH_ALTIUM_PLUGIN ( )

Definition at line 79 of file sch_altium_plugin.cpp.

80 {
81  m_rootSheet = nullptr;
82  m_currentSheet = nullptr;
83  m_schematic = nullptr;
84 
86 }
static REPORTER & GetInstance()
Definition: reporter.cpp:163
SCH_SHEET * m_currentSheet

References WXLOG_REPORTER::GetInstance(), m_currentSheet, m_reporter, m_rootSheet, and m_schematic.

◆ ~SCH_ALTIUM_PLUGIN()

SCH_ALTIUM_PLUGIN::~SCH_ALTIUM_PLUGIN ( )

Definition at line 89 of file sch_altium_plugin.cpp.

90 {
91 }

Member Function Documentation

◆ CheckHeader()

bool SCH_ALTIUM_PLUGIN::CheckHeader ( const wxString &  aFileName)
overridevirtual

Return true if the first line in aFileName begins with the expected header.

Parameters
aFileNameis the name of the file to use as input

Reimplemented from SCH_PLUGIN.

Definition at line 118 of file sch_altium_plugin.cpp.

119 {
120  // TODO
121 
122  return true;
123 }

◆ CreateSymbolLib()

void SCH_PLUGIN::CreateSymbolLib ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = nullptr 
)
virtualinherited

Create a new empty symbol library at aLibraryPath.

It is an error to attempt to create an existing library or to attempt to create on a "read only" location.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several footprints.
aPropertiesis an associative array that can be used to tell the library create function anything special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Exceptions
IO_ERRORif there is a problem finding the library, or creating it.

Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.

Definition at line 110 of file sch_plugin.cpp.

111 {
112  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
113  not_implemented( this, __FUNCTION__ );
114 }
static void not_implemented(const SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented.
Definition: sch_plugin.cpp:37

References not_implemented().

◆ DeleteSymbol()

void SCH_PLUGIN::DeleteSymbol ( const wxString &  aLibraryPath,
const wxString &  aSymbolName,
const PROPERTIES aProperties = nullptr 
)
virtualinherited

Delete the entire LIB_PART associated with aAliasName from the library aLibraryPath.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several symbols.
aSymbolNameis the name of a LIB_PART associated with it's root LIB_PART object to delete from the specified library.
aPropertiesis an associative array that can be used to tell the library delete function anything special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Exceptions
IO_ERRORif there is a problem finding the alias or the library or deleting it.

Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.

Definition at line 102 of file sch_plugin.cpp.

104 {
105  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
106  not_implemented( this, __FUNCTION__ );
107 }
static void not_implemented(const SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented.
Definition: sch_plugin.cpp:37

References not_implemented().

Referenced by SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer().

◆ DeleteSymbolLib()

bool SCH_PLUGIN::DeleteSymbolLib ( const wxString &  aLibraryPath,
const PROPERTIES aProperties = nullptr 
)
virtualinherited

Delete an existing symbol library and returns true if successful, or if library does not exist returns false, or throws an exception if library exists but is read only or cannot be deleted for some other reason.

Parameters
aLibraryPathis a locator for the "library", usually a directory or file which will contain symbols.
aPropertiesis an associative array that can be used to tell the library delete implementation function anything special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Returns
true if library deleted or false if library did not exist.
Exceptions
IO_ERRORif there is a problem deleting an existing library.

Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.

Definition at line 117 of file sch_plugin.cpp.

118 {
119  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
120  not_implemented( this, __FUNCTION__ );
121  return false;
122 }
static void not_implemented(const SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented.
Definition: sch_plugin.cpp:37

References not_implemented().

◆ EnumerateSymbolLib() [1/2]

void SCH_PLUGIN::EnumerateSymbolLib ( wxArrayString &  aSymbolNameList,
const wxString &  aLibraryPath,
const PROPERTIES aProperties = nullptr 
)
virtualinherited

Populate a list of LIB_PART alias names contained within the library aLibraryPath.

Parameters
aSymbolNameListis an array to populate with the LIB_PART names associated with the library.
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing one or more LIB_PART objects.
aPropertiesis an associative array that can be used to tell the plugin anything needed about how to perform with respect to aLibraryPath. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Exceptions
IO_ERRORif the library cannot be found, the part library cannot be loaded.

Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.

Definition at line 67 of file sch_plugin.cpp.

70 {
71  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
72  not_implemented( this, __FUNCTION__ );
73 }
static void not_implemented(const SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented.
Definition: sch_plugin.cpp:37

References not_implemented().

◆ EnumerateSymbolLib() [2/2]

void SCH_PLUGIN::EnumerateSymbolLib ( std::vector< LIB_PART * > &  aSymbolList,
const wxString &  aLibraryPath,
const PROPERTIES aProperties = nullptr 
)
virtualinherited

Populate a list of LIB_PART aliases contained within the library aLibraryPath.

Note
It is the responsibility of the caller to delete the returned object from the heap. Failure to do this will result in memory leaks.
Parameters
aSymbolListis an array to populate with the LIB_PART pointers associated with the library.
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing one or more LIB_PART objects.
aPropertiesis an associative array that can be used to tell the plugin anything needed about how to perform with respect to aLibraryPath. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Exceptions
IO_ERRORif the library cannot be found, the part library cannot be loaded.

Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.

Definition at line 76 of file sch_plugin.cpp.

79 {
80  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
81  not_implemented( this, __FUNCTION__ );
82 }
static void not_implemented(const SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented.
Definition: sch_plugin.cpp:37

References not_implemented().

◆ GetError()

const wxString & SCH_PLUGIN::GetError ( ) const
virtualinherited

Return an error string to the caller.

This is useful for schematic loaders that can load partial schematics where throwing an exception would be problematic such as the KiCad legacy plugin.

Returns
an unformatted string containing errors if any.

Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.

Definition at line 177 of file sch_plugin.cpp.

178 {
179  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
180  not_implemented( this, __FUNCTION__ );
181  static wxString error;
182  return error;
183 }
static void not_implemented(const SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented.
Definition: sch_plugin.cpp:37

References not_implemented().

Referenced by TEST_SCH_SHEET_LIST_FIXTURE::loadSchematic(), and TEST_NETLISTS_FIXTURE::loadSchematic().

◆ GetFileExtension()

const wxString SCH_ALTIUM_PLUGIN::GetFileExtension ( ) const
overridevirtual

Return the file extension for the SCH_PLUGIN.

Implements SCH_PLUGIN.

Definition at line 100 of file sch_altium_plugin.cpp.

101 {
102  return "SchDoc";
103 }

Referenced by ParseFileName().

◆ getLibFileName()

wxFileName SCH_ALTIUM_PLUGIN::getLibFileName ( )

Definition at line 150 of file sch_altium_plugin.cpp.

151 {
153 
154  return fn;
155 }
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:123
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:75
const std::string KiCadSymbolLibFileExtension

References getLibName(), PROJECT::GetProjectPath(), KiCadSymbolLibFileExtension, m_schematic, and SCHEMATIC::Prj().

Referenced by Load(), Parse(), and ParsePowerPort().

◆ getLibName()

wxString SCH_ALTIUM_PLUGIN::getLibName ( )

Definition at line 126 of file sch_altium_plugin.cpp.

127 {
128  if( m_libName.IsEmpty() )
129  {
130  // Try to come up with a meaningful name
132 
133  if( m_libName.IsEmpty() )
134  {
135  wxFileName fn( m_rootSheet->GetFileName() );
136  m_libName = fn.GetName();
137  }
138 
139  if( m_libName.IsEmpty() )
140  m_libName = "noname";
141 
142  m_libName += "-altium-import";
144  }
145 
146  return m_libName;
147 }
static UTF8 FixIllegalChars(const UTF8 &aLibItemName, bool aLib=false)
Replace illegal LIB_ID item name characters with underscores '_'.
Definition: lib_id.cpp:347
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:315
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:75
virtual const wxString GetProjectName() const
Return the short name of the project.
Definition: project.cpp:129

References LIB_ID::FixIllegalChars(), SCH_SHEET::GetFileName(), PROJECT::GetProjectName(), m_libName, m_rootSheet, m_schematic, and SCHEMATIC::Prj().

Referenced by getLibFileName(), Load(), ParseComponent(), and ParsePowerPort().

◆ GetLibraryFileExtension()

const wxString SCH_ALTIUM_PLUGIN::GetLibraryFileExtension ( ) const
overridevirtual

Return the library file extension for the SCH_PLUGIN object.

Implements SCH_PLUGIN.

Definition at line 106 of file sch_altium_plugin.cpp.

107 {
108  return "SchLib";
109 }

◆ GetModifyHash()

int SCH_ALTIUM_PLUGIN::GetModifyHash ( ) const
overridevirtual

Return the modification hash from the library cache.

Note
This is temporary until the new s-expr file format is implement. The new file format will embed symbols instead of referencing them from the library. This function can be removed when the new file format is implemented.
Returns
the modification hash of the library cache.

Implements SCH_PLUGIN.

Definition at line 112 of file sch_altium_plugin.cpp.

113 {
114  return 0;
115 }

◆ GetName()

const wxString SCH_ALTIUM_PLUGIN::GetName ( ) const
overridevirtual

Return a brief hard coded name for this SCH_PLUGIN.

Implements SCH_PLUGIN.

Definition at line 94 of file sch_altium_plugin.cpp.

95 {
96  return "Altium";
97 }

◆ IsComponentPartVisible()

bool SCH_ALTIUM_PLUGIN::IsComponentPartVisible ( int  aOwnerindex,
int  aOwnerpartdisplaymode 
) const
private

Definition at line 485 of file sch_altium_plugin.cpp.

486 {
487  const auto& component = m_altiumComponents.find( aOwnerindex );
488 
489  if( component == m_altiumComponents.end() )
490  return false;
491 
492  return component->second.displaymode == aOwnerpartdisplaymode;
493 }
std::map< int, ASCH_COMPONENT > m_altiumComponents

References m_altiumComponents.

Referenced by ParseArc(), ParseBezier(), ParseLine(), ParsePin(), ParsePolygon(), ParsePolyline(), ParseRectangle(), and ParseRoundRectangle().

◆ IsSymbolLibWritable()

bool SCH_PLUGIN::IsSymbolLibWritable ( const wxString &  aLibraryPath)
virtualinherited

Return true if the library at aLibraryPath is writable.

(Often system libraries are read only because of where they are installed.)

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several symbols.
Exceptions
IO_ERRORif no library at aLibraryPath exists.

Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.

Definition at line 125 of file sch_plugin.cpp.

126 {
127  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
128  not_implemented( this, __FUNCTION__ );
129  return false;
130 }
static void not_implemented(const SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented.
Definition: sch_plugin.cpp:37

References not_implemented().

◆ Load()

SCH_SHEET * SCH_ALTIUM_PLUGIN::Load ( const wxString &  aFileName,
SCHEMATIC aSchematic,
SCH_SHEET aAppendToMe = nullptr,
const PROPERTIES aProperties = nullptr 
)
overridevirtual

Load information from some input file format that this SCH_PLUGIN implementation knows about, into either a new SCH_SHEET or an existing one.

This may be used to load an entire new SCH_SHEET, or to augment an existing one if aAppendToMe is not NULL.

Parameters
aFileNameis the name of the file to use as input and may be foreign in nature or native in nature.
aKiwayis the KIWAY object used to access the component libraries loaded by the project.
aAppendToMeis an existing SCH_SHEET to append to, but if NULL then this means "do not append, rather load anew".
aPropertiesis an associative array that can be used to tell the loader how to load the file, because it can take any number of additional named arguments that the plugin is known to support. These are tuning parameters for the import or load. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Returns
the successfully loaded schematic, or the same one as aAppendToMe if aAppendToMe was not NULL, and the caller owns it.
Exceptions
IO_ERRORif there is a problem loading, and its contents should say what went wrong, using line number and character offsets of the input file if possible.
Note
No check is being done here to see if the existing symbol library exists so this will overwrite the existing one.

Reimplemented from SCH_PLUGIN.

Definition at line 158 of file sch_altium_plugin.cpp.

160 {
161  wxASSERT( !aFileName || aSchematic != NULL );
162 
163  wxFileName fileName( aFileName );
164  fileName.SetExt( KiCadSchematicFileExtension );
165  m_schematic = aSchematic;
166 
167  // Delete on exception, if I own m_rootSheet, according to aAppendToMe
168  std::unique_ptr<SCH_SHEET> deleter( aAppendToMe ? nullptr : m_rootSheet );
169 
170  if( aAppendToMe )
171  {
172  wxCHECK_MSG( aSchematic->IsValid(), nullptr, "Can't append to a schematic with no root!" );
173  m_rootSheet = &aSchematic->Root();
174  }
175  else
176  {
177  m_rootSheet = new SCH_SHEET( aSchematic );
178  m_rootSheet->SetFileName( fileName.GetFullPath() );
179  }
180 
181  if( !m_rootSheet->GetScreen() )
182  {
183  SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
184  screen->SetFileName( aFileName );
185  m_rootSheet->SetScreen( screen );
186  }
187 
188  SYMBOL_LIB_TABLE* libTable = m_schematic->Prj().SchSymbolLibTable();
189 
190  wxCHECK_MSG( libTable, NULL, "Could not load symbol lib table." );
191 
192  m_pi.set( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD ) );
193 
196  if( !libTable->HasLibrary( getLibName() ) )
197  {
198  // Create a new empty symbol library.
199  m_pi->CreateSymbolLib( getLibFileName().GetFullPath() );
200  wxString libTableUri = "${KIPRJMOD}/" + getLibFileName().GetFullName();
201 
202  // Add the new library to the project symbol library table.
203  libTable->InsertRow( new SYMBOL_LIB_TABLE_ROW( getLibName(), libTableUri,
204  wxString( "KiCad" ) ) );
205 
206  // Save project symbol library table.
207  wxFileName fn( m_schematic->Prj().GetProjectPath(),
209 
210  // So output formatter goes out of scope and closes the file before reloading.
211  {
212  FILE_OUTPUTFORMATTER formatter( fn.GetFullPath() );
213  libTable->Format( &formatter, 0 );
214  }
215 
216  // Reload the symbol library table.
218  m_schematic->Prj().SchSymbolLibTable();
219  }
220 
222  ParseAltiumSch( aFileName );
223 
224  m_pi->SaveLibrary( getLibFileName().GetFullPath() );
225 
226  SCH_SCREENS allSheets( m_rootSheet );
227  allSheets.UpdateSymbolLinks(); // Update all symbol library links for all sheets.
228 
229  return m_rootSheet;
230 }
static const wxString & GetSymbolLibTableFileName()
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_PLUGIN obje...
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
bool InsertRow(LIB_TABLE_ROW *aRow, bool doReplace=false)
Adds aRow if it does not already exist or if doReplace is true.
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:156
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
Definition: schematic.h:108
void set(SCH_PLUGIN *aPlugin)
Definition: sch_io_mgr.h:501
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:123
virtual void SetElem(ELEM_T aIndex, _ELEM *aElem)
Definition: project.cpp:259
void SetFileName(wxString aFilename)
Definition: sch_sheet.h:321
#define NULL
wxFileName getLibFileName()
virtual void Format(OUTPUTFORMATTER *aOutput, int aIndentLevel) const override
Generate the table in s-expression format to aOutput with an indention level of aIndentLevel.
SCH_SHEET * m_currentSheet
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:75
SCH_SHEET & Root() const
Definition: schematic.h:92
const std::string KiCadSchematicFileExtension
Used for text file output.
Definition: richio.h:453
void ParseAltiumSch(const wxString &aFileName)
void SetFileName(const wxString &aFileName)
Definition: sch_screen.h:131
SCH_PLUGIN::SCH_PLUGIN_RELEASER m_pi
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:549

References PROJECT::ELEM_SYMBOL_LIB_TABLE, SYMBOL_LIB_TABLE::Format(), getLibFileName(), getLibName(), PROJECT::GetProjectPath(), SCH_SHEET::GetScreen(), SYMBOL_LIB_TABLE::GetSymbolLibTableFileName(), LIB_TABLE::HasLibrary(), LIB_TABLE::InsertRow(), SCHEMATIC::IsValid(), KiCadSchematicFileExtension, m_currentSheet, m_pi, m_rootSheet, m_schematic, NULL, ParseAltiumSch(), SCHEMATIC::Prj(), SCHEMATIC::Root(), SCH_PLUGIN::SCH_PLUGIN_RELEASER::set(), PROJECT::SetElem(), SCH_SCREEN::SetFileName(), SCH_SHEET::SetFileName(), SCH_SHEET::SetScreen(), and SCH_SCREENS::UpdateSymbolLinks().

◆ LoadSymbol()

LIB_PART * SCH_PLUGIN::LoadSymbol ( const wxString &  aLibraryPath,
const wxString &  aPartName,
const PROPERTIES aProperties = nullptr 
)
virtualinherited

Load a LIB_PART object having aPartName from the aLibraryPath containing a library format that this SCH_PLUGIN knows about.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several symbols.
aPartNameis the name of the LIB_PART to load.
aPropertiesis an associative array that can be used to tell the loader implementation to do something special, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Returns
the part created on the heap if found caller shares it or NULL if not found.
Exceptions
IO_ERRORif the library cannot be found or read. No exception is thrown in the case where aAliasName cannot be found.

Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.

Definition at line 85 of file sch_plugin.cpp.

87 {
88  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
89  not_implemented( this, __FUNCTION__ );
90  return NULL;
91 }
static void not_implemented(const SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented.
Definition: sch_plugin.cpp:37
#define NULL

References not_implemented(), and NULL.

Referenced by SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer().

◆ Parse()

void SCH_ALTIUM_PLUGIN::Parse ( const CFB::CompoundFileReader &  aReader)

Definition at line 282 of file sch_altium_plugin.cpp.

283 {
284  const CFB::COMPOUND_FILE_ENTRY* file = FindStream( aReader, "FileHeader" );
285 
286  if( file == nullptr )
287  THROW_IO_ERROR( "FileHeader not found" );
288 
289  ALTIUM_PARSER reader( aReader, file );
290 
291  if( reader.GetRemainingBytes() <= 0 )
292  {
293  THROW_IO_ERROR( "FileHeader does not contain any data" );
294  }
295  else
296  {
297  std::map<wxString, wxString> properties = reader.ReadProperties();
298 
299  int recordId = ALTIUM_PARSER::PropertiesReadInt( properties, "RECORD", 0 );
300  ALTIUM_SCH_RECORD record = static_cast<ALTIUM_SCH_RECORD>( recordId );
301 
302  if( record != ALTIUM_SCH_RECORD::HEADER )
303  THROW_IO_ERROR( "Header expected" );
304  }
305 
306  // Prepare some local variables
307  wxASSERT( m_altiumPortsCurrentSheet.empty() );
308  wxASSERT( !m_currentTitleBlock );
309 
310  m_currentTitleBlock = std::make_unique<TITLE_BLOCK>();
311 
312  // index is required required to resolve OWNERINDEX
313  for( int index = 0; reader.GetRemainingBytes() > 0; index++ )
314  {
315  std::map<wxString, wxString> properties = reader.ReadProperties();
316 
317  int recordId = ALTIUM_PARSER::PropertiesReadInt( properties, "RECORD", 0 );
318  ALTIUM_SCH_RECORD record = static_cast<ALTIUM_SCH_RECORD>( recordId );
319 
320  // see: https://github.com/vadmium/python-altium/blob/master/format.md
321  switch( record )
322  {
324  THROW_IO_ERROR( "Header already parsed" );
326  ParseComponent( index, properties );
327  break;
329  ParsePin( properties );
330  break;
332  break;
334  ParseLabel( properties );
335  break;
337  ParseBezier( properties );
338  break;
340  ParsePolyline( properties );
341  break;
343  ParsePolygon( properties );
344  break;
346  break;
348  break;
350  ParseRoundRectangle( properties );
351  break;
353  break;
355  ParseArc( properties );
356  break;
358  ParseLine( properties );
359  break;
361  ParseRectangle( properties );
362  break;
364  ParseSheetSymbol( index, properties );
365  break;
367  ParseSheetEntry( properties );
368  break;
370  ParsePowerPort( properties );
371  break;
373  // Ports are parsed after the sheet was parsed
374  // This is required because we need all electrical connection points before placing.
375  m_altiumPortsCurrentSheet.emplace_back( properties );
376  break;
378  ParseNoERC( properties );
379  break;
381  ParseNetLabel( properties );
382  break;
384  ParseBus( properties );
385  break;
387  ParseWire( properties );
388  break;
390  break;
392  ParseJunction( properties );
393  break;
395  break;
397  ParseSheet( properties );
398  break;
400  ParseSheetName( properties );
401  break;
403  ParseFileName( properties );
404  break;
406  ParseDesignator( properties );
407  break;
409  ParseBusEntry( properties );
410  break;
412  break;
414  ParseParameter( properties );
415  break;
417  break;
419  break;
421  break;
423  break;
425  break;
427  break;
429  break;
431  break;
433  break;
435  break;
437  break;
439  break;
440  default:
441  m_reporter->Report( wxString::Format( _( "Unknown Record id: %d." ), recordId ),
443  break;
444  }
445  }
446 
447  if( reader.HasParsingError() )
448  THROW_IO_ERROR( "stream was not parsed correctly!" );
449 
450  if( reader.GetRemainingBytes() != 0 )
451  THROW_IO_ERROR( "stream is not fully parsed" );
452 
453  // assign LIB_PART -> COMPONENT
454  for( auto component : m_components )
455  {
456  auto kpart = m_symbols.find( component.first );
457 
458  if( kpart == m_symbols.end() )
459  THROW_IO_ERROR( "every component should have a symbol attached" );
460 
461  m_pi->SaveSymbol( getLibFileName().GetFullPath(), new LIB_PART( *( kpart->second ) ),
462  m_properties.get() );
463 
464  component.second->SetLibSymbol( kpart->second );
465  }
466 
467  // Handle title blocks
469  m_currentTitleBlock.reset();
470 
471  // Handle Ports
472  for( const ASCH_PORT& port : m_altiumPortsCurrentSheet )
473  ParsePort( port );
474 
476 
477  m_components.clear();
478  m_symbols.clear();
479 
480  // Otherwise we cannot save the imported sheet?
482 }
void ParsePort(const ASCH_PORT &aElem)
std::unique_ptr< PROPERTIES > m_properties
void SetModified()
Definition: eda_item.cpp:63
static int PropertiesReadInt(const std::map< wxString, wxString > &aProperties, const wxString &aKey, int aDefault)
void ParseLabel(const std::map< wxString, wxString > &aProperties)
void ParseBezier(const std::map< wxString, wxString > &aProperties)
void ParsePowerPort(const std::map< wxString, wxString > &aProperties)
void ParseJunction(const std::map< wxString, wxString > &aProperties)
void ParseParameter(const std::map< wxString, wxString > &aProperties)
void ParseRoundRectangle(const std::map< wxString, wxString > &aProperties)
void ParseBusEntry(const std::map< wxString, wxString > &aProperties)
void ParseSheet(const std::map< wxString, wxString > &aProperties)
void ParsePolygon(const std::map< wxString, wxString > &aProperties)
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
void ParseRectangle(const std::map< wxString, wxString > &aProperties)
void ParsePolyline(const std::map< wxString, wxString > &aProperties)
const CFB::COMPOUND_FILE_ENTRY * FindStream(const CFB::CompoundFileReader &aReader, const char *aStreamName)
std::vector< ASCH_PORT > m_altiumPortsCurrentSheet
void ParseLine(const std::map< wxString, wxString > &aProperties)
wxFileName getLibFileName()
void ParseSheetEntry(const std::map< wxString, wxString > &aProperties)
Define a library symbol object.
Definition: lib_symbol.h:93
void ParseFileName(const std::map< wxString, wxString > &aProperties)
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: sch_screen.h:140
void ParseNoERC(const std::map< wxString, wxString > &aProperties)
SCH_SHEET * m_currentSheet
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
void ParseComponent(int aIndex, const std::map< wxString, wxString > &aProperties)
void ParseSheetSymbol(int aIndex, const std::map< wxString, wxString > &aProperties)
#define _(s)
Definition: 3d_actions.cpp:33
void ParseWire(const std::map< wxString, wxString > &aProperties)
void ParseSheetName(const std::map< wxString, wxString > &aProperties)
std::map< int, LIB_PART * > m_symbols
void ParseArc(const std::map< wxString, wxString > &aProperties)
void ParseBus(const std::map< wxString, wxString > &aProperties)
void ParseDesignator(const std::map< wxString, wxString > &aProperties)
void ParsePin(const std::map< wxString, wxString > &aProperties)
std::map< int, SCH_COMPONENT * > m_components
SCH_PLUGIN::SCH_PLUGIN_RELEASER m_pi
void ParseNetLabel(const std::map< wxString, wxString > &aProperties)
ALTIUM_SCH_RECORD
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
std::unique_ptr< TITLE_BLOCK > m_currentTitleBlock

References _, ARC, BEZIER, BUS, BUS_ENTRY, COMPONENT, DESIGNATOR, ELLIPSE, ELLIPTICAL_ARC, FILE_NAME, FindStream(), Format(), getLibFileName(), ALTIUM_PARSER::GetRemainingBytes(), SCH_SHEET::GetScreen(), ALTIUM_PARSER::HasParsingError(), HEADER, IEEE_SYMBOL, IMAGE, IMPLEMENTATION, IMPLEMENTATION_LIST, JUNCTION, LABEL, LINE, m_altiumPortsCurrentSheet, m_components, m_currentSheet, m_currentTitleBlock, m_pi, m_properties, m_reporter, m_symbols, NET_LABEL, NO_ERC, PARAMETER, ParseArc(), ParseBezier(), ParseBus(), ParseBusEntry(), ParseComponent(), ParseDesignator(), ParseFileName(), ParseJunction(), ParseLabel(), ParseLine(), ParseNetLabel(), ParseNoERC(), ParseParameter(), ParsePin(), ParsePolygon(), ParsePolyline(), ParsePort(), ParsePowerPort(), ParseRectangle(), ParseRoundRectangle(), ParseSheet(), ParseSheetEntry(), ParseSheetName(), ParseSheetSymbol(), ParseWire(), PIECHART, PIN, POLYGON, POLYLINE, PORT, POWER_PORT, ALTIUM_PARSER::PropertiesReadInt(), ALTIUM_PARSER::ReadProperties(), RECORD_209, RECORD_215, RECORD_216, RECORD_217, RECORD_218, RECORD_226, RECORD_46, RECORD_47, RECORD_48, RECTANGLE, REPORTER::Report(), ROUND_RECTANGLE, RPT_SEVERITY_ERROR, EDA_ITEM::SetModified(), SCH_SCREEN::SetTitleBlock(), SHEET, SHEET_ENTRY, SHEET_NAME, SHEET_SYMBOL, TEMPLATE, TEXT_FRAME, THROW_IO_ERROR, WARNING_SIGN, and WIRE.

Referenced by ParseAltiumSch().

◆ ParseAltiumSch()

void SCH_ALTIUM_PLUGIN::ParseAltiumSch ( const wxString &  aFileName)

Definition at line 240 of file sch_altium_plugin.cpp.

241 {
242  // Open file
243  FILE* fp = wxFopen( aFileName, "rb" );
244 
245  if( fp == nullptr )
246  {
247  m_reporter->Report( wxString::Format( _( "Cannot open file '%s'." ), aFileName ),
249  return;
250  }
251 
252  fseek( fp, 0, SEEK_END );
253  long len = ftell( fp );
254 
255  if( len < 0 )
256  {
257  fclose( fp );
258  THROW_IO_ERROR( "Reading error, cannot determine length of file" );
259  }
260 
261  std::unique_ptr<unsigned char[]> buffer( new unsigned char[len] );
262  fseek( fp, 0, SEEK_SET );
263 
264  size_t bytesRead = fread( buffer.get(), sizeof( unsigned char ), len, fp );
265  fclose( fp );
266 
267  if( static_cast<size_t>( len ) != bytesRead )
268  THROW_IO_ERROR( "Reading error" );
269 
270  try
271  {
272  CFB::CompoundFileReader reader( buffer.get(), bytesRead );
273  Parse( reader );
274  }
275  catch( CFB::CFBException& exception )
276  {
277  THROW_IO_ERROR( exception.what() );
278  }
279 }
void Parse(const CFB::CompoundFileReader &aReader)
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
#define _(s)
Definition: 3d_actions.cpp:33
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38

References _, Format(), m_reporter, Parse(), REPORTER::Report(), RPT_SEVERITY_ERROR, and THROW_IO_ERROR.

Referenced by Load().

◆ ParseArc()

void SCH_ALTIUM_PLUGIN::ParseArc ( const std::map< wxString, wxString > &  aProperties)
private

Definition at line 1104 of file sch_altium_plugin.cpp.

1105 {
1106  ASCH_ARC elem( aProperties );
1107 
1108  if( elem.ownerpartid == ALTIUM_COMPONENT_NONE )
1109  {
1110  m_reporter->Report( _( "Arc drawing is not possible for now on schematic." ),
1112  }
1113  else
1114  {
1115  const auto& symbol = m_symbols.find( elem.ownerindex );
1116  if( symbol == m_symbols.end() )
1117  {
1118  // TODO: e.g. can depend on Template (RECORD=39
1119  m_reporter->Report( wxString::Format( _( "Arc has non-existent ownerindex %d." ),
1120  elem.ownerindex ),
1122  return;
1123  }
1124 
1125  if( !IsComponentPartVisible( elem.ownerindex, elem.ownerpartdisplaymode ) )
1126  return;
1127 
1128  const auto& component = m_components.at( symbol->first );
1129 
1130  if( elem.startAngle == 0 && ( elem.endAngle == 0 || elem.endAngle == 360 ) )
1131  {
1132  LIB_CIRCLE* circle = new LIB_CIRCLE( symbol->second );
1133  symbol->second->AddDrawItem( circle );
1134 
1135  circle->SetUnit( elem.ownerpartid );
1136 
1137  circle->SetPosition( GetRelativePosition( elem.center + m_sheetOffset, component ) );
1138  circle->SetRadius( elem.radius );
1139  circle->SetWidth( elem.lineWidth );
1140  }
1141  else
1142  {
1143  LIB_ARC* arc = new LIB_ARC( symbol->second );
1144  symbol->second->AddDrawItem( arc );
1145 
1146  arc->SetUnit( elem.ownerpartid );
1147 
1148  // TODO: correct?
1149  arc->SetPosition( GetRelativePosition( elem.center + m_sheetOffset, component ) );
1150  arc->SetRadius( elem.radius );
1151  arc->SetFirstRadiusAngle( elem.startAngle * 10. );
1152  arc->SetSecondRadiusAngle( elem.endAngle * 10. );
1153  }
1154  }
1155 }
void SetFirstRadiusAngle(int aAngle)
Definition: lib_arc.h:86
const wxPoint GetRelativePosition(const wxPoint &aPosition, const SCH_COMPONENT *aComponent)
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
void SetRadius(int aRadius)
Definition: lib_circle.h:83
void SetSecondRadiusAngle(int aAngle)
Definition: lib_arc.h:89
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
void SetUnit(int aUnit)
Definition: lib_item.h:259
#define _(s)
Definition: 3d_actions.cpp:33
void SetRadius(int aRadius)
Definition: lib_arc.h:83
std::map< int, LIB_PART * > m_symbols
void SetWidth(int aWidth) override
Definition: lib_circle.h:81
void SetPosition(const wxPoint &aPosition) override
Definition: lib_item.h:213
const int ALTIUM_COMPONENT_NONE
std::map< int, SCH_COMPONENT * > m_components
bool IsComponentPartVisible(int aOwnerindex, int aOwnerpartdisplaymode) const

References _, ALTIUM_COMPONENT_NONE, ASCH_ARC::center, ASCH_ARC::endAngle, Format(), GetRelativePosition(), IsComponentPartVisible(), ASCH_ARC::lineWidth, m_components, m_reporter, m_sheetOffset, m_symbols, ASCH_ARC::ownerindex, ASCH_ARC::ownerpartdisplaymode, ASCH_ARC::ownerpartid, ASCH_ARC::radius, REPORTER::Report(), RPT_SEVERITY_ERROR, RPT_SEVERITY_WARNING, LIB_ARC::SetFirstRadiusAngle(), LIB_ITEM::SetPosition(), LIB_CIRCLE::SetRadius(), LIB_ARC::SetRadius(), LIB_ARC::SetSecondRadiusAngle(), LIB_ITEM::SetUnit(), LIB_CIRCLE::SetWidth(), and ASCH_ARC::startAngle.

Referenced by Parse().

◆ ParseBezier()

void SCH_ALTIUM_PLUGIN::ParseBezier ( const std::map< wxString, wxString > &  aProperties)
private

Definition at line 779 of file sch_altium_plugin.cpp.

780 {
781  ASCH_BEZIER elem( aProperties );
782 
783  if( elem.points.size() < 2 )
784  {
785  m_reporter->Report( wxString::Format( _( "Bezier has %d control points. At least 2 are "
786  "expected." ),
787  static_cast<int>( elem.points.size() ) ),
789  return;
790  }
791 
792  if( elem.ownerpartid == ALTIUM_COMPONENT_NONE )
793  {
794  for( size_t i = 0; i + 1 < elem.points.size(); i += 3 )
795  {
796  if( i + 2 == elem.points.size() )
797  {
798  // special case: single line
799  SCH_LINE* line = new SCH_LINE( elem.points.at( i ) + m_sheetOffset,
801 
802  line->SetEndPoint( elem.points.at( i + 1 ) + m_sheetOffset );
803  line->SetLineWidth( elem.lineWidth );
805 
806  line->SetFlags( IS_NEW );
807  m_currentSheet->GetScreen()->Append( line );
808  }
809  else
810  {
811  // simulate bezier using line segments
812  std::vector<wxPoint> bezierPoints;
813  std::vector<wxPoint> polyPoints;
814  for( size_t j = i; j < elem.points.size() && j < i + 4; j++ )
815  {
816  bezierPoints.push_back( elem.points.at( j ) + m_sheetOffset );
817  }
818 
819  BEZIER_POLY converter( bezierPoints );
820  converter.GetPoly( polyPoints );
821 
822  for( size_t k = 0; k + 1 < polyPoints.size(); k++ )
823  {
824  SCH_LINE* line = new SCH_LINE( polyPoints.at( k ) + m_sheetOffset,
826 
827  line->SetEndPoint( polyPoints.at( k + 1 ) + m_sheetOffset );
828  line->SetLineWidth( elem.lineWidth );
829 
830  line->SetFlags( IS_NEW );
831  m_currentSheet->GetScreen()->Append( line );
832  }
833  }
834  }
835  }
836  else
837  {
838  const auto& symbol = m_symbols.find( elem.ownerindex );
839 
840  if( symbol == m_symbols.end() )
841  {
842  // TODO: e.g. can depend on Template (RECORD=39
843  m_reporter->Report( wxString::Format( _( "Bezier has non-existent ownerindex %d." ),
844  elem.ownerindex ),
846  return;
847  }
848 
849  if( !IsComponentPartVisible( elem.ownerindex, elem.ownerpartdisplaymode ) )
850  return;
851 
852  const auto& component = m_components.at( symbol->first );
853 
854  for( size_t i = 0; i + 1 < elem.points.size(); i += 3 )
855  {
856  if( i + 2 == elem.points.size() )
857  {
858  // special case: single line
859  LIB_POLYLINE* line = new LIB_POLYLINE( symbol->second );
860  symbol->second->AddDrawItem( line );
861 
862  line->SetUnit( elem.ownerpartid );
863 
864  for( size_t j = i; j < elem.points.size() && j < i + 2; j++ )
865  {
866  line->AddPoint( GetRelativePosition( elem.points.at( j ) + m_sheetOffset,
867  component ) );
868  }
869 
870  line->SetWidth( elem.lineWidth );
871  }
872  else
873  {
874  // bezier always has maximum of 4 control points
875  LIB_BEZIER* bezier = new LIB_BEZIER( symbol->second );
876  symbol->second->AddDrawItem( bezier );
877 
878  bezier->SetUnit( elem.ownerpartid );
879 
880  for( size_t j = i; j < elem.points.size() && j < i + 4; j++ )
881  {
882  bezier->AddPoint( GetRelativePosition( elem.points.at( j ) + m_sheetOffset,
883  component ) );
884  }
885 
886  bezier->SetWidth( elem.lineWidth );
887  }
888  }
889  }
890 }
void SetLineWidth(const int aSize)
Definition: sch_line.cpp:271
const wxPoint GetRelativePosition(const wxPoint &aPosition, const SCH_COMPONENT *aComponent)
void SetWidth(int aWidth) override
Definition: lib_polyline.h:97
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
void SetEndPoint(const wxPoint &aPosition)
Definition: sch_line.h:94
void SetLineStyle(const PLOT_DASH_TYPE aStyle)
Definition: sch_line.cpp:239
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:203
void AddPoint(const wxPoint &aPoint)
SCH_SHEET * m_currentSheet
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
void SetUnit(int aUnit)
Definition: lib_item.h:259
Bezier curves to polygon converter.
Definition: bezier_curves.h:36
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:128
#define _(s)
Definition: 3d_actions.cpp:33
std::map< int, LIB_PART * > m_symbols
const int ALTIUM_COMPONENT_NONE
void SetWidth(int aWidth) override
Definition: lib_bezier.h:83
std::map< int, SCH_COMPONENT * > m_components
#define IS_NEW
New item, just created.
Definition: eda_item.h:107
void AddPoint(const wxPoint &aPoint)
Definition: lib_bezier.h:54
bool IsComponentPartVisible(int aOwnerindex, int aOwnerpartdisplaymode) const
Define a bezier curve graphic body item.
Definition: lib_bezier.h:34

References _, LIB_POLYLINE::AddPoint(), LIB_BEZIER::AddPoint(), ALTIUM_COMPONENT_NONE, SCH_SCREEN::Append(), Format(), BEZIER_POLY::GetPoly(), GetRelativePosition(), SCH_SHEET::GetScreen(), IS_NEW, IsComponentPartVisible(), LAYER_NOTES, ASCH_BEZIER::lineWidth, m_components, m_currentSheet, m_reporter, m_sheetOffset, m_symbols, ASCH_BEZIER::ownerindex, ASCH_BEZIER::ownerpartdisplaymode, ASCH_BEZIER::ownerpartid, ASCH_BEZIER::points, REPORTER::Report(), RPT_SEVERITY_WARNING, SCH_LINE::SetEndPoint(), EDA_ITEM::SetFlags(), SCH_LINE::SetLineStyle(), SCH_LINE::SetLineWidth(), LIB_ITEM::SetUnit(), LIB_BEZIER::SetWidth(), LIB_POLYLINE::SetWidth(), and SOLID.

Referenced by Parse().

◆ ParseBus()

void SCH_ALTIUM_PLUGIN::ParseBus ( const std::map< wxString, wxString > &  aProperties)
private

Definition at line 1832 of file sch_altium_plugin.cpp.

1833 {
1834  ASCH_BUS elem( aProperties );
1835 
1836  for( size_t i = 0; i + 1 < elem.points.size(); i++ )
1837  {
1838  SCH_LINE* bus =
1839  new SCH_LINE( elem.points.at( i ) + m_sheetOffset, SCH_LAYER_ID::LAYER_BUS );
1840  bus->SetEndPoint( elem.points.at( i + 1 ) + m_sheetOffset );
1841  bus->SetLineWidth( elem.lineWidth );
1842 
1843  bus->SetFlags( IS_NEW );
1844  m_currentSheet->GetScreen()->Append( bus );
1845  }
1846 }
void SetLineWidth(const int aSize)
Definition: sch_line.cpp:271
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
void SetEndPoint(const wxPoint &aPosition)
Definition: sch_line.h:94
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:203
SCH_SHEET * m_currentSheet
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:128
#define IS_NEW
New item, just created.
Definition: eda_item.h:107

References SCH_SCREEN::Append(), SCH_SHEET::GetScreen(), IS_NEW, LAYER_BUS, ASCH_BUS::lineWidth, m_currentSheet, m_sheetOffset, ASCH_BUS::points, SCH_LINE::SetEndPoint(), EDA_ITEM::SetFlags(), and SCH_LINE::SetLineWidth().

Referenced by Parse().

◆ ParseBusEntry()

void SCH_ALTIUM_PLUGIN::ParseBusEntry ( const std::map< wxString, wxString > &  aProperties)
private

Definition at line 2062 of file sch_altium_plugin.cpp.

2063 {
2064  ASCH_BUS_ENTRY elem( aProperties );
2065 
2066  SCH_BUS_WIRE_ENTRY* busWireEntry = new SCH_BUS_WIRE_ENTRY( elem.location + m_sheetOffset );
2067 
2068  wxPoint vector = elem.corner - elem.location;
2069  busWireEntry->SetSize( { vector.x, vector.y } );
2070 
2071  busWireEntry->SetFlags( IS_NEW );
2072  m_currentSheet->GetScreen()->Append( busWireEntry );
2073 }
void SetSize(const wxSize &aSize)
Definition: sch_bus_entry.h:64
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:203
SCH_SHEET * m_currentSheet
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:128
Class for a wire to bus entry.
#define IS_NEW
New item, just created.
Definition: eda_item.h:107

References SCH_SCREEN::Append(), ASCH_BUS_ENTRY::corner, SCH_SHEET::GetScreen(), IS_NEW, ASCH_BUS_ENTRY::location, m_currentSheet, m_sheetOffset, EDA_ITEM::SetFlags(), and SCH_BUS_ENTRY_BASE::SetSize().

Referenced by Parse().

◆ ParseComponent()

void SCH_ALTIUM_PLUGIN::ParseComponent ( int  aIndex,
const std::map< wxString, wxString > &  aProperties 
)
private

Definition at line 496 of file sch_altium_plugin.cpp.

498 {
499  auto pair = m_altiumComponents.insert( { aIndex, ASCH_COMPONENT( aProperties ) } );
500  const ASCH_COMPONENT& elem = pair.first->second;
501 
502  // TODO: this is a hack until we correctly apply all transformations to every element
503  wxString name = wxString::Format( "%d%s_%s",
504  elem.orientation,
505  elem.isMirrored ? "_mirrored" : "",
506  elem.libreference );
508 
509  LIB_PART* kpart = new LIB_PART( wxEmptyString );
510  kpart->SetName( name );
511  kpart->SetDescription( elem.componentdescription );
512  kpart->SetLibId( libId );
513  m_symbols.insert( { aIndex, kpart } );
514 
515  // each component has its own symbol for now
516  SCH_COMPONENT* component = new SCH_COMPONENT();
517 
518  component->SetPosition( elem.location + m_sheetOffset );
519  //component->SetOrientation( elem.orientation ); // TODO: keep it simple for now, and only set position
520  component->SetLibId( libId );
521  //component->SetLibSymbol( kpart ); // this has to be done after parsing the LIB_PART!
522 
523  component->SetUnit( elem.currentpartid );
524 
525  m_currentSheet->GetScreen()->Append( component );
526 
527  m_components.insert( { aIndex, component } );
528 }
void SetLibId(const LIB_ID &aName)
Definition: sch_symbol.cpp:229
void SetPosition(const wxPoint &aPosition) override
Definition: sch_symbol.h:642
std::map< int, ASCH_COMPONENT > m_altiumComponents
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
LIB_ID AltiumToKiCadLibID(wxString aLibName, wxString aLibReference)
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
void SetDescription(const wxString &aDescription)
Definition: lib_symbol.h:136
Define a library symbol object.
Definition: lib_symbol.h:93
void SetUnit(int aUnit)
Change the unit number to aUnit.
Definition: sch_symbol.cpp:322
SCH_SHEET * m_currentSheet
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
wxString componentdescription
const char * name
Definition: DXF_plotter.cpp:59
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:128
std::map< int, LIB_PART * > m_symbols
Schematic symbol object.
Definition: sch_symbol.h:78
virtual void SetName(const wxString &aName)
Definition: lib_symbol.cpp:314
std::map< int, SCH_COMPONENT * > m_components
void SetLibId(const LIB_ID &aLibId)
Definition: lib_symbol.h:132

References AltiumToKiCadLibID(), SCH_SCREEN::Append(), ASCH_COMPONENT::componentdescription, ASCH_COMPONENT::currentpartid, Format(), getLibName(), SCH_SHEET::GetScreen(), ASCH_COMPONENT::isMirrored, ASCH_COMPONENT::libreference, ASCH_COMPONENT::location, m_altiumComponents, m_components, m_currentSheet, m_sheetOffset, m_symbols, name, ASCH_COMPONENT::orientation, LIB_PART::SetDescription(), LIB_PART::SetLibId(), SCH_COMPONENT::SetLibId(), LIB_PART::SetName(), SCH_COMPONENT::SetPosition(), and SCH_COMPONENT::SetUnit().

Referenced by Parse().

◆ ParseDesignator()

void SCH_ALTIUM_PLUGIN::ParseDesignator ( const std::map< wxString, wxString > &  aProperties)
private

Definition at line 2029 of file sch_altium_plugin.cpp.

2030 {
2031  ASCH_DESIGNATOR elem( aProperties );
2032 
2033  const auto& symbol = m_symbols.find( elem.ownerindex );
2034  if( symbol == m_symbols.end() )
2035  {
2036  // TODO: e.g. can depend on Template (RECORD=39
2037  m_reporter->Report( wxString::Format( _( "Designator has non-existent ownerindex %d." ),
2038  elem.ownerindex ),
2040  return;
2041  }
2042 
2043  const auto& component = m_components.at( symbol->first );
2044 
2045  SCH_SHEET_PATH sheetpath;
2047 
2048  component->SetRef( &sheetpath, elem.text );
2049 
2050  SCH_FIELD* refField = component->GetField( REFERENCE_FIELD );
2051 
2052  refField->SetPosition( elem.location + m_sheetOffset );
2053  refField->SetVisible( true );
2054 
2057 
2058  SetFieldOrientation( *refField, elem.orientation );
2059 }
Field Reference of part, i.e. "IC21".
Instances are attached to a symbol or sheet and provide a place for the component's value,...
Definition: sch_field.h:50
void SetVisible(bool aVisible)
Definition: eda_text.h:192
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
void SetFieldOrientation(SCH_FIELD &aField, ASCH_RECORD_ORIENTATION aOrientation)
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:209
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SCH_SHEET * m_currentSheet
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
bool LocatePathOfScreen(SCH_SCREEN *aScreen, SCH_SHEET_PATH *aList)
Search the existing hierarchy for an instance of screen loaded from aFileName.
Definition: sch_sheet.cpp:665
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:208
#define _(s)
Definition: 3d_actions.cpp:33
std::map< int, LIB_PART * > m_symbols
std::map< int, SCH_COMPONENT * > m_components
void SetPosition(const wxPoint &aPosition) override
Definition: sch_field.cpp:664

References _, Format(), SCH_SHEET::GetScreen(), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, SCH_SHEET::LocatePathOfScreen(), ASCH_DESIGNATOR::location, m_components, m_currentSheet, m_reporter, m_rootSheet, m_sheetOffset, m_symbols, ASCH_DESIGNATOR::orientation, ASCH_DESIGNATOR::ownerindex, REFERENCE_FIELD, REPORTER::Report(), RPT_SEVERITY_WARNING, SetFieldOrientation(), EDA_TEXT::SetHorizJustify(), SCH_FIELD::SetPosition(), EDA_TEXT::SetVertJustify(), EDA_TEXT::SetVisible(), and ASCH_DESIGNATOR::text.

Referenced by Parse().

◆ ParseFileName()

void SCH_ALTIUM_PLUGIN::ParseFileName ( const std::map< wxString, wxString > &  aProperties)
private

Definition at line 1995 of file sch_altium_plugin.cpp.

1996 {
1997  ASCH_FILE_NAME elem( aProperties );
1998 
1999  const auto& sheet = m_sheets.find( elem.ownerindex );
2000  if( sheet == m_sheets.end() )
2001  {
2002  wxLogError( wxString::Format( "File Name has non-existent ownerindex %d",
2003  elem.ownerindex ) );
2004  return;
2005  }
2006 
2007  SCH_FIELD& filenameField = sheet->second->GetFields()[SHEETFILENAME];
2008 
2009  filenameField.SetPosition( elem.location + m_sheetOffset );
2010 
2011  // If last symbols are ".sChDoC", change them to ".kicad_sch"
2012  if( ( elem.text.Right( GetFileExtension().length() + 1 ).Lower() ) == ( "." + GetFileExtension().Lower() ))
2013  {
2014  elem.text.RemoveLast( GetFileExtension().length() );
2015  elem.text += KiCadSchematicFileExtension;
2016  }
2017 
2018  filenameField.SetText( elem.text );
2019 
2020  filenameField.SetVisible( !elem.isHidden );
2021 
2024 
2025  SetFieldOrientation( filenameField, elem.orientation );
2026 }
Instances are attached to a symbol or sheet and provide a place for the component's value,...
Definition: sch_field.h:50
void SetVisible(bool aVisible)
Definition: eda_text.h:192
std::map< int, SCH_SHEET * > m_sheets
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:121
void SetFieldOrientation(SCH_FIELD &aField, ASCH_RECORD_ORIENTATION aOrientation)
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:209
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:208
const wxString GetFileExtension() const override
Return the file extension for the SCH_PLUGIN.
const std::string KiCadSchematicFileExtension
void SetPosition(const wxPoint &aPosition) override
Definition: sch_field.cpp:664

References Format(), GetFileExtension(), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, ASCH_FILE_NAME::isHidden, KiCadSchematicFileExtension, ASCH_FILE_NAME::location, m_sheetOffset, m_sheets, ASCH_FILE_NAME::orientation, ASCH_FILE_NAME::ownerindex, SetFieldOrientation(), EDA_TEXT::SetHorizJustify(), SCH_FIELD::SetPosition(), EDA_TEXT::SetText(), EDA_TEXT::SetVertJustify(), EDA_TEXT::SetVisible(), SHEETFILENAME, and ASCH_FILE_NAME::text.

Referenced by Parse().

◆ ParseJunction()

void SCH_ALTIUM_PLUGIN::ParseJunction ( const std::map< wxString, wxString > &  aProperties)
private

Definition at line 1866 of file sch_altium_plugin.cpp.

1867 {
1868  ASCH_JUNCTION elem( aProperties );
1869 
1870  SCH_JUNCTION* junction = new SCH_JUNCTION( elem.location + m_sheetOffset );
1871 
1872  junction->SetFlags( IS_NEW );
1873  m_currentSheet->GetScreen()->Append( junction );
1874 }
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:203
SCH_SHEET * m_currentSheet
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:128
#define IS_NEW
New item, just created.
Definition: eda_item.h:107

References SCH_SCREEN::Append(), SCH_SHEET::GetScreen(), IS_NEW, ASCH_JUNCTION::location, m_currentSheet, m_sheetOffset, and EDA_ITEM::SetFlags().

Referenced by Parse().

◆ ParseLabel()

void SCH_ALTIUM_PLUGIN::ParseLabel ( const std::map< wxString, wxString > &  aProperties)
private

Definition at line 718 of file sch_altium_plugin.cpp.

719 {
720  ASCH_LABEL elem( aProperties );
721 
722  // TODO: text variable support
723  if( elem.ownerpartid == ALTIUM_COMPONENT_NONE )
724  {
725  SCH_TEXT* text = new SCH_TEXT( elem.location + m_sheetOffset, elem.text );
726 
727  SetEdaTextJustification( text, elem.justification );
728 
729  size_t fontId = static_cast<int>( elem.fontId );
730 
731  if( m_altiumSheet && fontId > 0 && fontId <= m_altiumSheet->fonts.size() )
732  {
733  const ASCH_SHEET_FONT& font = m_altiumSheet->fonts.at( fontId - 1 );
734  text->SetItalic( font.italic );
735  text->SetBold( font.bold );
736  text->SetTextSize( { font.size / 2, font.size / 2 } );
737  }
738 
739  text->SetFlags( IS_NEW );
741  }
742  else
743  {
744  const auto& symbol = m_symbols.find( elem.ownerindex );
745 
746  if( symbol == m_symbols.end() )
747  {
748  // TODO: e.g. can depend on Template (RECORD=39
749  m_reporter->Report( wxString::Format( _( "Label has non-existent ownerindex %d." ),
750  elem.ownerindex ),
752  return;
753  }
754 
755  const auto& component = m_components.at( symbol->first );
756 
757  LIB_TEXT* text = new LIB_TEXT( symbol->second );
758  symbol->second->AddDrawItem( text );
759 
760  text->SetUnit( elem.ownerpartid );
761 
762  text->SetPosition( GetRelativePosition( elem.location + m_sheetOffset, component ) );
763  text->SetText( elem.text );
764  SetEdaTextJustification( text, elem.justification );
765 
766  size_t fontId = static_cast<int>( elem.fontId );
767 
768  if( m_altiumSheet && fontId > 0 && fontId <= m_altiumSheet->fonts.size() )
769  {
770  const ASCH_SHEET_FONT& font = m_altiumSheet->fonts.at( fontId - 1 );
771  text->SetItalic( font.italic );
772  text->SetBold( font.bold );
773  text->SetTextSize( { font.size / 2, font.size / 2 } );
774  }
775  }
776 }
void SetEdaTextJustification(EDA_TEXT *text, ASCH_LABEL_JUSTIFICATION justification)
Define a symbol library graphical text item.
Definition: lib_text.h:39
const wxPoint GetRelativePosition(const wxPoint &aPosition, const SCH_COMPONENT *aComponent)
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
std::unique_ptr< ASCH_SHEET > m_altiumSheet
SCH_SHEET * m_currentSheet
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:128
#define _(s)
Definition: 3d_actions.cpp:33
std::map< int, LIB_PART * > m_symbols
const int ALTIUM_COMPONENT_NONE
std::map< int, SCH_COMPONENT * > m_components
#define IS_NEW
New item, just created.
Definition: eda_item.h:107

References _, ALTIUM_COMPONENT_NONE, SCH_SCREEN::Append(), ASCH_SHEET_FONT::bold, ASCH_LABEL::fontId, fonts, Format(), GetRelativePosition(), SCH_SHEET::GetScreen(), IS_NEW, ASCH_SHEET_FONT::italic, ASCH_LABEL::justification, ASCH_LABEL::location, m_altiumSheet, m_components, m_currentSheet, m_reporter, m_sheetOffset, m_symbols, ASCH_LABEL::ownerindex, ASCH_LABEL::ownerpartid, REPORTER::Report(), RPT_SEVERITY_WARNING, SetEdaTextJustification(), ASCH_SHEET_FONT::size, ASCH_LABEL::text, and text.

Referenced by Parse().

◆ ParseLine()

void SCH_ALTIUM_PLUGIN::ParseLine ( const std::map< wxString, wxString > &  aProperties)
private

Definition at line 1158 of file sch_altium_plugin.cpp.

1159 {
1160  ASCH_LINE elem( aProperties );
1161 
1162  if( elem.ownerpartid == ALTIUM_COMPONENT_NONE )
1163  {
1164  // close polygon
1165  SCH_LINE* line = new SCH_LINE( elem.point1 + m_sheetOffset, SCH_LAYER_ID::LAYER_NOTES );
1166  line->SetEndPoint( elem.point2 + m_sheetOffset );
1167  line->SetLineWidth( elem.lineWidth );
1168  line->SetLineStyle( PLOT_DASH_TYPE::SOLID ); // TODO?
1169 
1170  line->SetFlags( IS_NEW );
1171  m_currentSheet->GetScreen()->Append( line );
1172  }
1173  else
1174  {
1175  const auto& symbol = m_symbols.find( elem.ownerindex );
1176 
1177  if( symbol == m_symbols.end() )
1178  {
1179  // TODO: e.g. can depend on Template (RECORD=39
1180  m_reporter->Report( wxString::Format( _( "Line has non-existent ownerindex %d." ),
1181  elem.ownerindex ),
1183  return;
1184  }
1185 
1186  if( !IsComponentPartVisible( elem.ownerindex, elem.ownerpartdisplaymode ) )
1187  return;
1188 
1189  const auto& component = m_components.at( symbol->first );
1190 
1191  LIB_POLYLINE* line = new LIB_POLYLINE( symbol->second );
1192  symbol->second->AddDrawItem( line );
1193 
1194  line->SetUnit( elem.ownerpartid );
1195 
1196  line->AddPoint( GetRelativePosition( elem.point1 + m_sheetOffset, component ) );
1197  line->AddPoint( GetRelativePosition( elem.point2 + m_sheetOffset, component ) );
1198 
1199  line->SetWidth( elem.lineWidth );
1200  }
1201 }
void SetLineWidth(const int aSize)
Definition: sch_line.cpp:271
const wxPoint GetRelativePosition(const wxPoint &aPosition, const SCH_COMPONENT *aComponent)
void SetWidth(int aWidth) override
Definition: lib_polyline.h:97
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
void SetEndPoint(const wxPoint &aPosition)
Definition: sch_line.h:94
void SetLineStyle(const PLOT_DASH_TYPE aStyle)
Definition: sch_line.cpp:239
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:203
void AddPoint(const wxPoint &aPoint)
SCH_SHEET * m_currentSheet
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
void SetUnit(int aUnit)
Definition: lib_item.h:259
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:128
#define _(s)
Definition: 3d_actions.cpp:33
std::map< int, LIB_PART * > m_symbols
const int ALTIUM_COMPONENT_NONE
std::map< int, SCH_COMPONENT * > m_components
#define IS_NEW
New item, just created.
Definition: eda_item.h:107
bool IsComponentPartVisible(int aOwnerindex, int aOwnerpartdisplaymode) const

References _, LIB_POLYLINE::AddPoint(), ALTIUM_COMPONENT_NONE, SCH_SCREEN::Append(), Format(), GetRelativePosition(), SCH_SHEET::GetScreen(), IS_NEW, IsComponentPartVisible(), LAYER_NOTES, ASCH_LINE::lineWidth, m_components, m_currentSheet, m_reporter, m_sheetOffset, m_symbols, ASCH_LINE::ownerindex, ASCH_LINE::ownerpartdisplaymode, ASCH_LINE::ownerpartid, ASCH_LINE::point1, ASCH_LINE::point2, REPORTER::Report(), RPT_SEVERITY_WARNING, SCH_LINE::SetEndPoint(), EDA_ITEM::SetFlags(), SCH_LINE::SetLineStyle(), SCH_LINE::SetLineWidth(), LIB_ITEM::SetUnit(), LIB_POLYLINE::SetWidth(), and SOLID.

Referenced by Parse().

◆ ParseNetLabel()

void SCH_ALTIUM_PLUGIN::ParseNetLabel ( const std::map< wxString, wxString > &  aProperties)
private

Definition at line 1803 of file sch_altium_plugin.cpp.

1804 {
1805  ASCH_NET_LABEL elem( aProperties );
1806 
1807  SCH_LABEL* label = new SCH_LABEL( elem.location + m_sheetOffset, elem.text );
1808 
1809  switch( elem.orientation )
1810  {
1813  break;
1816  break;
1819  break;
1822  break;
1823  default:
1824  break;
1825  }
1826 
1827  label->SetFlags( IS_NEW );
1828  m_currentSheet->GetScreen()->Append( label );
1829 }
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:203
SCH_SHEET * m_currentSheet
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:128
virtual void SetLabelSpinStyle(LABEL_SPIN_STYLE aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:248
#define IS_NEW
New item, just created.
Definition: eda_item.h:107

References SCH_SCREEN::Append(), LABEL_SPIN_STYLE::BOTTOM, DOWNWARDS, SCH_SHEET::GetScreen(), IS_NEW, LABEL_SPIN_STYLE::LEFT, LEFTWARDS, ASCH_NET_LABEL::location, m_currentSheet, m_sheetOffset, ASCH_NET_LABEL::orientation, LABEL_SPIN_STYLE::RIGHT, RIGHTWARDS, EDA_ITEM::SetFlags(), SCH_TEXT::SetLabelSpinStyle(), ASCH_NET_LABEL::text, LABEL_SPIN_STYLE::UP, and UPWARDS.

Referenced by Parse().

◆ ParseNoERC()

void SCH_ALTIUM_PLUGIN::ParseNoERC ( const std::map< wxString, wxString > &  aProperties)
private

Definition at line 1789 of file sch_altium_plugin.cpp.

1790 {
1791  ASCH_NO_ERC elem( aProperties );
1792 
1793  if( elem.isActive )
1794  {
1795  SCH_NO_CONNECT* noConnect = new SCH_NO_CONNECT( elem.location + m_sheetOffset );
1796 
1797  noConnect->SetFlags( IS_NEW );
1798  m_currentSheet->GetScreen()->Append( noConnect );
1799  }
1800 }
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:203
SCH_SHEET * m_currentSheet
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:128
#define IS_NEW
New item, just created.
Definition: eda_item.h:107

References SCH_SCREEN::Append(), SCH_SHEET::GetScreen(), IS_NEW, ASCH_NO_ERC::isActive, ASCH_NO_ERC::location, m_currentSheet, m_sheetOffset, and EDA_ITEM::SetFlags().

Referenced by Parse().

◆ ParseParameter()

void SCH_ALTIUM_PLUGIN::ParseParameter ( const std::map< wxString, wxString > &  aProperties)
private

Definition at line 2076 of file sch_altium_plugin.cpp.

2077 {
2078  ASCH_PARAMETER elem( aProperties );
2079 
2080  // TODO: fill in replacements from variant, sheet and project
2081  altium_override_map_t stringReplacement = {
2082  { "Comment", "${VALUE}" },
2083  { "Value", "${Altium_Value}" },
2084  };
2085 
2086  if( elem.ownerindex <= 0 && elem.ownerpartid == ALTIUM_COMPONENT_NONE )
2087  {
2088  // This is some sheet parameter
2089  if( elem.text == "*" )
2090  return; // indicates parameter not set?
2091 
2092  SCH_SHEET_PATH sheetpath;
2094 
2095  if( elem.name == "SheetNumber" )
2096  m_rootSheet->SetPageNumber( sheetpath, elem.text );
2097  else if( elem.name == "Title" )
2098  m_currentTitleBlock->SetTitle( elem.text );
2099  else if( elem.name == "Revision" )
2100  m_currentTitleBlock->SetRevision( elem.text );
2101  else if( elem.name == "Date" )
2102  m_currentTitleBlock->SetDate( elem.text );
2103  else if( elem.name == "CompanyName" )
2104  m_currentTitleBlock->SetCompany( elem.text );
2105  // TODO: parse other parameters
2106  // TODO: handle parameters in labels
2107  }
2108  else
2109  {
2110  const auto& symbol = m_symbols.find( elem.ownerindex );
2111  if( symbol == m_symbols.end() )
2112  {
2113  // TODO: e.g. can depend on Template (RECORD=39
2114  return;
2115  }
2116 
2117  const auto& component = m_components.at( symbol->first );
2118 
2119  // TODO: location not correct?
2120  const wxPoint position = elem.location + m_sheetOffset;
2121 
2122  SCH_FIELD* field = nullptr;
2123  if( elem.name == "Comment" )
2124  {
2125  field = component->GetField( VALUE_FIELD );
2126  field->SetPosition( position );
2127  }
2128  else
2129  {
2130  int fieldIdx = component->GetFieldCount();
2131  wxString fieldName = elem.name.IsSameAs( "Value", false ) ? "Altium_Value" : elem.name;
2132  field = component->AddField( { position, fieldIdx, component, fieldName } );
2133  }
2134 
2135  wxString kicadText = AltiumSpecialStringsToKiCadVariables( elem.text, stringReplacement );
2136  field->SetText( kicadText );
2137 
2138  field->SetVisible( !elem.isHidden );
2140 
2141  switch( elem.orientation )
2142  {
2143  case ASCH_RECORD_ORIENTATION::RIGHTWARDS: field->SetTextAngle( 0 ); break;
2144  case ASCH_RECORD_ORIENTATION::UPWARDS: field->SetTextAngle( 90 ); break;
2145  case ASCH_RECORD_ORIENTATION::LEFTWARDS: field->SetTextAngle( 180 ); break;
2146  case ASCH_RECORD_ORIENTATION::DOWNWARDS: field->SetTextAngle( 270 ); break;
2147  default:
2148  break;
2149  }
2150  }
2151 }
Instances are attached to a symbol or sheet and provide a place for the component's value,...
Definition: sch_field.h:50
void SetVisible(bool aVisible)
Definition: eda_text.h:192
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
void SetPageNumber(const SCH_SHEET_PATH &aInstance, const wxString &aPageNumber)
Set the page number for the sheet instance aInstance.
Definition: sch_sheet.cpp:1135
std::map< wxString, wxString, CASE_INSENSITIVE_COMPARATOR > altium_override_map_t
Field Value of part, i.e. "3.3K".
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:121
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SCH_SHEET * m_currentSheet
bool LocatePathOfScreen(SCH_SCREEN *aScreen, SCH_SHEET_PATH *aList)
Search the existing hierarchy for an instance of screen loaded from aFileName.
Definition: sch_sheet.cpp:665
wxString AltiumSpecialStringsToKiCadVariables(const wxString &aString, const altium_override_map_t &aOverride)
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:208
std::map< int, LIB_PART * > m_symbols
const int ALTIUM_COMPONENT_NONE
virtual void SetTextAngle(double aAngle)
Definition: eda_text.h:174
std::map< int, SCH_COMPONENT * > m_components
void SetPosition(const wxPoint &aPosition) override
Definition: sch_field.cpp:664
std::unique_ptr< TITLE_BLOCK > m_currentTitleBlock

References ALTIUM_COMPONENT_NONE, AltiumSpecialStringsToKiCadVariables(), DOWNWARDS, SCH_SHEET::GetScreen(), GR_TEXT_HJUSTIFY_LEFT, ASCH_PARAMETER::isHidden, LEFTWARDS, SCH_SHEET::LocatePathOfScreen(), ASCH_PARAMETER::location, m_components, m_currentSheet, m_currentTitleBlock, m_rootSheet, m_sheetOffset, m_symbols, ASCH_PARAMETER::name, ASCH_PARAMETER::orientation, ASCH_PARAMETER::ownerindex, ASCH_PARAMETER::ownerpartid, RIGHTWARDS, EDA_TEXT::SetHorizJustify(), SCH_SHEET::SetPageNumber(), SCH_FIELD::SetPosition(), EDA_TEXT::SetText(), EDA_TEXT::SetTextAngle(), EDA_TEXT::SetVisible(), ASCH_PARAMETER::text, UPWARDS, and VALUE_FIELD.

Referenced by Parse().

◆ ParsePin()

void SCH_ALTIUM_PLUGIN::ParsePin ( const std::map< wxString, wxString > &  aProperties)
private

Definition at line 531 of file sch_altium_plugin.cpp.

532 {
533  ASCH_PIN elem( aProperties );
534 
535  const auto& symbol = m_symbols.find( elem.ownerindex );
536 
537  if( symbol == m_symbols.end() )
538  {
539  // TODO: e.g. can depend on Template (RECORD=39
540  m_reporter->Report( wxString::Format( _( "Pin has non-existent ownerindex %d." ),
541  elem.ownerindex ),
543  return;
544  }
545 
546  if( !IsComponentPartVisible( elem.ownerindex, elem.ownerpartdisplaymode ) )
547  return;
548 
549  const auto& component = m_components.at( symbol->first );
550 
551  LIB_PIN* pin = new LIB_PIN( symbol->second );
552  symbol->second->AddDrawItem( pin );
553 
554  pin->SetUnit( elem.ownerpartid );
555 
556  pin->SetName( elem.name );
557  pin->SetNumber( elem.designator );
558  pin->SetLength( elem.pinlength );
559 
560  wxPoint pinLocation = elem.location; // the location given is not the connection point!
561 
562  switch( elem.orientation )
563  {
565  pin->SetOrientation( DrawPinOrient::PIN_LEFT );
566  pinLocation.x += elem.pinlength;
567  break;
569  pin->SetOrientation( DrawPinOrient::PIN_DOWN );
570  pinLocation.y -= elem.pinlength;
571  break;
573  pin->SetOrientation( DrawPinOrient::PIN_RIGHT );
574  pinLocation.x -= elem.pinlength;
575  break;
577  pin->SetOrientation( DrawPinOrient::PIN_UP );
578  pinLocation.y += elem.pinlength;
579  break;
580  default:
581  m_reporter->Report( _( "Pin has unexpected orientation." ), RPT_SEVERITY_WARNING );
582  break;
583  }
584 
585  // TODO: position can be sometimes off a little bit!
586  pin->SetPosition( GetRelativePosition( pinLocation + m_sheetOffset, component ) );
587  // TODO: the following fix is even worse for now?
588  // pin->SetPosition( GetRelativePosition( elem.kicadLocation, component ) );
589 
590  switch( elem.electrical )
591  {
593  pin->SetType( ELECTRICAL_PINTYPE::PT_INPUT );
594  break;
596  pin->SetType( ELECTRICAL_PINTYPE::PT_BIDI );
597  break;
600  break;
603  break;
606  break;
609  break;
612  break;
615  break;
617  default:
619  m_reporter->Report( _( "Pin has unexpected electrical type." ), RPT_SEVERITY_WARNING );
620  break;
621  }
622 
623  if( elem.symbolOuterEdge == ASCH_PIN_SYMBOL_OUTEREDGE::UNKNOWN )
624  m_reporter->Report( _( "Pin has unexpected outer edge type." ), RPT_SEVERITY_WARNING );
625 
626  if( elem.symbolInnerEdge == ASCH_PIN_SYMBOL_INNEREDGE::UNKNOWN )
627  m_reporter->Report( _( "Pin has unexpected inner edge type." ), RPT_SEVERITY_WARNING );
628 
629  if( elem.symbolOuterEdge == ASCH_PIN_SYMBOL_OUTEREDGE::NEGATED )
630  {
631  switch( elem.symbolInnerEdge )
632  {
635  break;
636  default:
637  pin->SetShape( GRAPHIC_PINSHAPE::INVERTED );
638  break;
639  }
640  }
641  else if( elem.symbolOuterEdge == ASCH_PIN_SYMBOL_OUTEREDGE::LOW_INPUT )
642  {
643  switch( elem.symbolInnerEdge )
644  {
646  pin->SetShape( GRAPHIC_PINSHAPE::CLOCK_LOW );
647  break;
648  default:
649  pin->SetShape( GRAPHIC_PINSHAPE::INPUT_LOW );
650  break;
651  }
652  }
653  else if( elem.symbolOuterEdge == ASCH_PIN_SYMBOL_OUTEREDGE::LOW_OUTPUT )
654  {
655  pin->SetShape( GRAPHIC_PINSHAPE::OUTPUT_LOW );
656  }
657  else
658  {
659  switch( elem.symbolInnerEdge )
660  {
662  pin->SetShape( GRAPHIC_PINSHAPE::CLOCK );
663  break;
664  default:
665  pin->SetShape( GRAPHIC_PINSHAPE::LINE ); // nothing to do
666  break;
667  }
668  }
669 }
power input (GND, VCC for ICs). Must be connected to a power output.
pin for passive components: must be connected, and can be connected to any pin
unknown electrical properties: creates always a warning when connected
Definition: lib_pin.h:50
const wxPoint GetRelativePosition(const wxPoint &aPosition, const SCH_COMPONENT *aComponent)
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
#define _(s)
Definition: 3d_actions.cpp:33
usual pin input: must be connected
std::map< int, LIB_PART * > m_symbols
input or output (like port for a microprocessor)
std::map< int, SCH_COMPONENT * > m_components
bool IsComponentPartVisible(int aOwnerindex, int aOwnerpartdisplaymode) const

References _, BIDI, CLOCK, CLOCK_LOW, ASCH_PIN::designator, DOWNWARDS, ASCH_PIN::electrical, Format(), GetRelativePosition(), INPUT, INPUT_LOW, INVERTED, INVERTED_CLOCK, IsComponentPartVisible(), LEFTWARDS, LINE, ASCH_PIN::location, LOW_INPUT, LOW_OUTPUT, m_components, m_reporter, m_sheetOffset, m_symbols, ASCH_PIN::name, NEGATED, OPEN_COLLECTOR, OPEN_EMITTER, ASCH_PIN::orientation, OUTPUT, OUTPUT_LOW, ASCH_PIN::ownerindex, ASCH_PIN::ownerpartdisplaymode, ASCH_PIN::ownerpartid, PASSIVE, pin, PIN_DOWN, PIN_LEFT, PIN_RIGHT, PIN_UP, ASCH_PIN::pinlength, POWER, PT_BIDI, PT_INPUT, PT_OPENCOLLECTOR, PT_OPENEMITTER, PT_OUTPUT, PT_PASSIVE, PT_POWER_IN, PT_TRISTATE, PT_UNSPECIFIED, REPORTER::Report(), RIGHTWARDS, RPT_SEVERITY_WARNING, ASCH_PIN::symbolInnerEdge, ASCH_PIN::symbolOuterEdge, TRISTATE, UNKNOWN, and UPWARDS.

Referenced by Parse().

◆ ParsePolygon()

void SCH_ALTIUM_PLUGIN::ParsePolygon ( const std::map< wxString, wxString > &  aProperties)
private

Definition at line 954 of file sch_altium_plugin.cpp.

955 {
956  ASCH_POLYGON elem( aProperties );
957 
958  if( elem.ownerpartid == ALTIUM_COMPONENT_NONE )
959  {
960  // TODO: we cannot fill this polygon, only draw it for now
961  for( size_t i = 0; i + 1 < elem.points.size(); i++ )
962  {
963  SCH_LINE* line =
964  new SCH_LINE( elem.points.at( i ) + m_sheetOffset, SCH_LAYER_ID::LAYER_NOTES );
965  line->SetEndPoint( elem.points.at( i + 1 ) + m_sheetOffset );
966  line->SetLineWidth( elem.lineWidth );
968 
969  line->SetFlags( IS_NEW );
970  m_currentSheet->GetScreen()->Append( line );
971  }
972 
973  // close polygon
974  SCH_LINE* line =
975  new SCH_LINE( elem.points.front() + m_sheetOffset, SCH_LAYER_ID::LAYER_NOTES );
976  line->SetEndPoint( elem.points.back() + m_sheetOffset );
977  line->SetLineWidth( elem.lineWidth );
979 
980  line->SetFlags( IS_NEW );
981  m_currentSheet->GetScreen()->Append( line );
982  }
983  else
984  {
985  const auto& symbol = m_symbols.find( elem.ownerindex );
986 
987  if( symbol == m_symbols.end() )
988  {
989  // TODO: e.g. can depend on Template (RECORD=39
990  m_reporter->Report( wxString::Format( _( "Polygon has non-existent ownerindex %d." ),
991  elem.ownerindex ),
993  return;
994  }
995 
996  if( !IsComponentPartVisible( elem.ownerindex, elem.ownerpartdisplaymode ) )
997  return;
998 
999  const auto& component = m_components.at( symbol->first );
1000 
1001  LIB_POLYLINE* line = new LIB_POLYLINE( symbol->second );
1002  symbol->second->AddDrawItem( line );
1003 
1004  line->SetUnit( elem.ownerpartid );
1005 
1006  for( wxPoint& point : elem.points )
1007  line->AddPoint( GetRelativePosition( point + m_sheetOffset, component ) );
1008 
1009  line->AddPoint( GetRelativePosition( elem.points.front() + m_sheetOffset, component ) );
1010 
1011  line->SetWidth( elem.lineWidth );
1012 
1013  if( !elem.isSolid )
1015  else if( elem.color == elem.areacolor )
1017  else
1019  }
1020 }
void SetLineWidth(const int aSize)
Definition: sch_line.cpp:271
void SetFillMode(FILL_TYPE aFillMode)
Definition: lib_item.h:265
const wxPoint GetRelativePosition(const wxPoint &aPosition, const SCH_COMPONENT *aComponent)
void SetWidth(int aWidth) override
Definition: lib_polyline.h:97
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
void SetEndPoint(const wxPoint &aPosition)
Definition: sch_line.h:94
void SetLineStyle(const PLOT_DASH_TYPE aStyle)
Definition: sch_line.cpp:239
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:203
void AddPoint(const wxPoint &aPoint)
SCH_SHEET * m_currentSheet
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
void SetUnit(int aUnit)
Definition: lib_item.h:259
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:128
#define _(s)
Definition: 3d_actions.cpp:33
std::map< int, LIB_PART * > m_symbols
const int ALTIUM_COMPONENT_NONE
std::map< int, SCH_COMPONENT * > m_components
#define IS_NEW
New item, just created.
Definition: eda_item.h:107
bool IsComponentPartVisible(int aOwnerindex, int aOwnerpartdisplaymode) const

References _, LIB_POLYLINE::AddPoint(), ALTIUM_COMPONENT_NONE, SCH_SCREEN::Append(), ASCH_POLYGON::areacolor, ASCH_POLYGON::color, FILLED_SHAPE, FILLED_WITH_BG_BODYCOLOR, Format(), GetRelativePosition(), SCH_SHEET::GetScreen(), IS_NEW, IsComponentPartVisible(), ASCH_POLYGON::isSolid, LAYER_NOTES, ASCH_POLYGON::lineWidth, m_components, m_currentSheet, m_reporter, m_sheetOffset, m_symbols, NO_FILL, ASCH_POLYGON::ownerindex, ASCH_POLYGON::ownerpartdisplaymode, ASCH_POLYGON::ownerpartid, ASCH_POLYGON::points, REPORTER::Report(), RPT_SEVERITY_WARNING, SCH_LINE::SetEndPoint(), LIB_ITEM::SetFillMode(), EDA_ITEM::SetFlags(), SCH_LINE::SetLineStyle(), SCH_LINE::SetLineWidth(), LIB_ITEM::SetUnit(), LIB_POLYLINE::SetWidth(), and SOLID.

Referenced by Parse().

◆ ParsePolyline()

void SCH_ALTIUM_PLUGIN::ParsePolyline ( const std::map< wxString, wxString > &  aProperties)
private

Definition at line 893 of file sch_altium_plugin.cpp.

894 {
895  ASCH_POLYLINE elem( aProperties );
896 
897  if( elem.ownerpartid == ALTIUM_COMPONENT_NONE )
898  {
900  switch( elem.linestyle )
901  {
902  default:
907  }
908 
909  for( size_t i = 0; i + 1 < elem.points.size(); i++ )
910  {
911  SCH_LINE* line = new SCH_LINE( elem.points.at( i ) + m_sheetOffset,
913 
914  line->SetEndPoint( elem.points.at( i + 1 ) + m_sheetOffset );
915  line->SetLineWidth( elem.lineWidth );
916  line->SetLineStyle( dashType );
917 
918  line->SetFlags( IS_NEW );
919  m_currentSheet->GetScreen()->Append( line );
920  }
921  }
922  else
923  {
924  const auto& symbol = m_symbols.find( elem.ownerindex );
925  if( symbol == m_symbols.end() )
926  {
927  // TODO: e.g. can depend on Template (RECORD=39
928  m_reporter->Report( wxString::Format( _( "Polyline has non-existent ownerindex %d." ),
929  elem.ownerindex ),
931  return;
932  }
933 
934  if( !IsComponentPartVisible( elem.ownerindex, elem.ownerpartdisplaymode ) )
935  return;
936 
937  const auto& component = m_components.at( symbol->first );
938 
939  LIB_POLYLINE* line = new LIB_POLYLINE( symbol->second );
940  symbol->second->AddDrawItem( line );
941 
942  line->SetUnit( elem.ownerpartid );
943 
944  for( wxPoint& point : elem.points )
945  {
946  line->AddPoint( GetRelativePosition( point + m_sheetOffset, component ) );
947  }
948 
949  line->SetWidth( elem.lineWidth );
950  }
951 }
void SetLineWidth(const int aSize)
Definition: sch_line.cpp:271
const wxPoint GetRelativePosition(const wxPoint &aPosition, const SCH_COMPONENT *aComponent)
void SetWidth(int aWidth) override
Definition: lib_polyline.h:97
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
void SetEndPoint(const wxPoint &aPosition)
Definition: sch_line.h:94
void SetLineStyle(const PLOT_DASH_TYPE aStyle)
Definition: sch_line.cpp:239
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:203
void AddPoint(const wxPoint &aPoint)
SCH_SHEET * m_currentSheet
PLOT_DASH_TYPE
Dashed line types.
Definition: plotter.h:104
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
void SetUnit(int aUnit)
Definition: lib_item.h:259
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:128
#define _(s)
Definition: 3d_actions.cpp:33
std::map< int, LIB_PART * > m_symbols
const int ALTIUM_COMPONENT_NONE
std::map< int, SCH_COMPONENT * > m_components
#define IS_NEW
New item, just created.
Definition: eda_item.h:107
bool IsComponentPartVisible(int aOwnerindex, int aOwnerpartdisplaymode) const

References _, LIB_POLYLINE::AddPoint(), ALTIUM_COMPONENT_NONE, SCH_SCREEN::Append(), DASH, DASH_DOTTED, DASHDOT, DASHED, DEFAULT, DOT, DOTTED, Format(), GetRelativePosition(), SCH_SHEET::GetScreen(), IS_NEW, IsComponentPartVisible(), LAYER_NOTES, ASCH_POLYLINE::linestyle, ASCH_POLYLINE::lineWidth, m_components, m_currentSheet, m_reporter, m_sheetOffset, m_symbols, ASCH_POLYLINE::ownerindex, ASCH_POLYLINE::ownerpartdisplaymode, ASCH_POLYLINE::ownerpartid, ASCH_POLYLINE::points, REPORTER::Report(), RPT_SEVERITY_WARNING, SCH_LINE::SetEndPoint(), EDA_ITEM::SetFlags(), SCH_LINE::SetLineStyle(), SCH_LINE::SetLineWidth(), LIB_ITEM::SetUnit(), LIB_POLYLINE::SetWidth(), and SOLID.

Referenced by Parse().

◆ ParsePort()

void SCH_ALTIUM_PLUGIN::ParsePort ( const ASCH_PORT aElem)
private

Definition at line 1674 of file sch_altium_plugin.cpp.

1675 {
1676  // Get both connection points where we could connect to
1677  wxPoint start = aElem.location + m_sheetOffset;
1678  wxPoint end = start;
1679 
1680  switch( aElem.style )
1681  {
1682  default:
1684  case ASCH_PORT_STYLE::LEFT:
1687  end.x += aElem.width;
1688  break;
1690  case ASCH_PORT_STYLE::TOP:
1693  end.y -= aElem.width;
1694  break;
1695  }
1696 
1697  // Check which connection points exists in the schematic
1698  SCH_SCREEN* screen = m_currentSheet->GetScreen();
1699 
1700  bool startIsWireTerminal = screen->IsTerminalPoint( start, LAYER_WIRE );
1701  bool startIsBusTerminal = screen->IsTerminalPoint( start, LAYER_BUS );
1702 
1703  bool endIsWireTerminal = screen->IsTerminalPoint( end, LAYER_WIRE );
1704  bool endIsBusTerminal = screen->IsTerminalPoint( end, LAYER_BUS );
1705 
1706  // check if any of the points is a terminal point
1707  // TODO: there seems a problem to detect approximated connections towards component pins?
1708  bool connectionFound = startIsWireTerminal
1709  || startIsBusTerminal
1710  || endIsWireTerminal
1711  || endIsBusTerminal;
1712 
1713  if( !connectionFound )
1714  {
1715  wxLogError( wxString::Format( "There is a Port for \"%s\", but no connections towards it?",
1716  aElem.name ) );
1717  }
1718 
1719  // Select label position. In case both match, we will add a line later.
1720  wxPoint position = ( startIsWireTerminal || startIsBusTerminal ) ? start : end;
1721 
1722  SCH_TEXT* const label = new SCH_GLOBALLABEL( position, aElem.name );
1723  // TODO: detect correct label type depending on sheet settings, etc.
1724  // label = new SCH_HIERLABEL( elem.location + m_sheetOffset, elem.name );
1725 
1726  switch( aElem.iotype )
1727  {
1728  default:
1731  break;
1734  break;
1737  break;
1740  break;
1741  }
1742 
1743  switch( aElem.style )
1744  {
1745  default:
1747  case ASCH_PORT_STYLE::LEFT:
1750  if( ( startIsWireTerminal || startIsBusTerminal ) )
1752  else
1754  break;
1756  case ASCH_PORT_STYLE::TOP:
1759  if( ( startIsWireTerminal || startIsBusTerminal ) )
1761  else
1763  break;
1764  }
1765 
1766  label->SetFlags( IS_NEW );
1767  m_currentSheet->GetScreen()->Append( label );
1768 
1769  // This is a hack, for the case both connection points are valid: add a small wire
1770  if( ( startIsWireTerminal && endIsWireTerminal ) || !connectionFound )
1771  {
1772  SCH_LINE* wire = new SCH_LINE( start, SCH_LAYER_ID::LAYER_WIRE );
1773  wire->SetEndPoint( end );
1774  wire->SetLineWidth( Mils2iu( 2 ) );
1775  wire->SetFlags( IS_NEW );
1776  m_currentSheet->GetScreen()->Append( wire );
1777  }
1778  else if( startIsBusTerminal && endIsBusTerminal )
1779  {
1780  SCH_LINE* wire = new SCH_LINE( start, SCH_LAYER_ID::LAYER_BUS );
1781  wire->SetEndPoint( end );
1782  wire->SetLineWidth( Mils2iu( 2 ) );
1783  wire->SetFlags( IS_NEW );
1784  m_currentSheet->GetScreen()->Append( wire );
1785  }
1786 }
wxPoint location
void SetShape(PINSHEETLABEL_SHAPE aShape)
Definition: sch_text.h:219
bool IsTerminalPoint(const wxPoint &aPosition, int aLayer) const
Test if aPosition is a connection point on aLayer.
Definition: sch_screen.cpp:457
void SetLineWidth(const int aSize)
Definition: sch_line.cpp:271
ASCH_PORT_STYLE style
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
void SetEndPoint(const wxPoint &aPosition)
Definition: sch_line.h:94
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:203
SCH_SHEET * m_currentSheet
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
ASCH_PORT_IOTYPE iotype
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:128
virtual void SetLabelSpinStyle(LABEL_SPIN_STYLE aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:248
#define IS_NEW
New item, just created.
Definition: eda_item.h:107

References SCH_SCREEN::Append(), BIDI, LABEL_SPIN_STYLE::BOTTOM, BOTTOM, Format(), SCH_SHEET::GetScreen(), INPUT, ASCH_PORT::iotype, IS_NEW, SCH_SCREEN::IsTerminalPoint(), LAYER_BUS, LAYER_WIRE, LABEL_SPIN_STYLE::LEFT, LEFT, LEFT_RIGHT, ASCH_PORT::location, m_currentSheet, m_sheetOffset, ASCH_PORT::name, NONE_HORIZONTAL, NONE_VERTICAL, OUTPUT, PS_BIDI, PS_INPUT, PS_OUTPUT, PS_UNSPECIFIED, LABEL_SPIN_STYLE::RIGHT, RIGHT, SCH_LINE::SetEndPoint(), EDA_ITEM::SetFlags(), SCH_TEXT::SetLabelSpinStyle(), SCH_LINE::SetLineWidth(), SCH_TEXT::SetShape(), ASCH_PORT::style, TOP, TOP_BOTTOM, UNSPECIFIED, LABEL_SPIN_STYLE::UP, and ASCH_PORT::width.

Referenced by Parse().

◆ ParsePowerPort()

void SCH_ALTIUM_PLUGIN::ParsePowerPort ( const std::map< wxString, wxString > &  aProperties)
private

Definition at line 1578 of file sch_altium_plugin.cpp.

1579 {
1580  ASCH_POWER_PORT elem( aProperties );
1581 
1582  LIB_ID libId = AltiumToKiCadLibID( getLibName(), elem.text );
1583 
1584  LIB_PART* kpart = nullptr;
1585 
1586  const auto& symbol = m_powerSymbols.find( elem.text );
1587  if( symbol != m_powerSymbols.end() )
1588  {
1589  kpart = symbol->second; // cache hit
1590  }
1591  else
1592  {
1593  kpart = new LIB_PART( wxEmptyString );
1594  kpart->SetPower();
1595  kpart->SetName( elem.text );
1596  kpart->GetReferenceField().SetText( "#PWR" );
1597  kpart->GetValueField().SetText( elem.text );
1598  kpart->GetValueField().SetVisible( true ); // TODO: why does this not work?
1599  kpart->SetDescription( wxString::Format( _( "Power symbol creates a global label with name '%s'" ),
1600  elem.text ) );
1601  kpart->SetKeyWords( "power-flag" );
1602  kpart->SetLibId( libId );
1603 
1604  // generate graphic
1605  LIB_PIN* pin = new LIB_PIN( kpart );
1606  kpart->AddDrawItem( pin );
1607 
1608  pin->SetName( elem.text );
1609  pin->SetPosition( { 0, 0 } );
1610  pin->SetLength( 0 );
1611 
1612  // marks the pin as a global label
1614  pin->SetVisible( false );
1615 
1616  wxPoint valueFieldPos = HelperGeneratePowerPortGraphics( kpart, elem.style, m_reporter );
1617 
1618  kpart->GetValueField().SetPosition( valueFieldPos );
1619 
1620  // this has to be done after parsing the LIB_PART!
1621  m_pi->SaveSymbol( getLibFileName().GetFullPath(), kpart, m_properties.get() );
1622  m_powerSymbols.insert( { elem.text, kpart } );
1623  }
1624 
1625  SCH_SHEET_PATH sheetpath;
1627 
1628  // each component has its own symbol for now
1629  SCH_COMPONENT* component = new SCH_COMPONENT();
1630  component->SetRef( &sheetpath, "#PWR?" );
1631  component->SetValue( elem.text );
1632  component->SetLibId( libId );
1633  component->SetLibSymbol( new LIB_PART( *kpart ) );
1634 
1635  SCH_FIELD* valueField = component->GetField( VALUE_FIELD );
1636 
1637  // TODO: Why do I need to set those a second time?
1638  valueField->SetVisible( true );
1639  valueField->SetPosition( kpart->GetValueField().GetPosition() );
1640 
1641  component->SetPosition( elem.location + m_sheetOffset );
1642 
1643  switch( elem.orientation )
1644  {
1647  valueField->SetTextAngle( -900. );
1649  break;
1652  valueField->SetTextAngle( -1800. );
1654  break;
1657  valueField->SetTextAngle( -2700. );
1659  break;
1662  valueField->SetTextAngle( 0. );
1664  break;
1665  default:
1666  m_reporter->Report( _( "Pin has unexpected orientation." ), RPT_SEVERITY_WARNING );
1667  break;
1668  }
1669 
1670  m_currentSheet->GetScreen()->Append( component );
1671 }
power input (GND, VCC for ICs). Must be connected to a power output.
Instances are attached to a symbol or sheet and provide a place for the component's value,...
Definition: sch_field.h:50
std::unique_ptr< PROPERTIES > m_properties
void SetLibSymbol(LIB_PART *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
Definition: sch_symbol.cpp:248
void SetLibId(const LIB_ID &aName)
Definition: sch_symbol.cpp:229
void SetPower()
Definition: lib_symbol.cpp:420
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:693
wxPoint GetPosition() const override
Definition: lib_field.h:180
void SetVisible(bool aVisible)
Definition: eda_text.h:192
LIB_FIELD & GetValueField()
Return reference to the value field.
Definition: lib_symbol.cpp:975
void SetPosition(const wxPoint &aPosition) override
Definition: sch_symbol.h:642
wxPoint HelperGeneratePowerPortGraphics(LIB_PART *aKPart, ASCH_POWER_PORT_STYLE aStyle, REPORTER *aReporter)
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
LIB_ID AltiumToKiCadLibID(wxString aLibName, wxString aLibReference)
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
std::map< wxString, LIB_PART * > m_powerSymbols
LIB_FIELD & GetReferenceField()
Return reference to the reference designator field.
Definition: lib_symbol.cpp:983
Field Value of part, i.e. "3.3K".
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:121
void AddDrawItem(LIB_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
Definition: lib_symbol.cpp:655
wxFileName getLibFileName()
void SetDescription(const wxString &aDescription)
Definition: lib_symbol.h:136
Define a library symbol object.
Definition: lib_symbol.h:93
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SCH_SHEET * m_currentSheet
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
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:482
bool LocatePathOfScreen(SCH_SCREEN *aScreen, SCH_SHEET_PATH *aList)
Search the existing hierarchy for an instance of screen loaded from aFileName.
Definition: sch_sheet.cpp:665
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:128
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:208
#define _(s)
Definition: 3d_actions.cpp:33
void SetKeyWords(const wxString &aKeyWords)
Definition: lib_symbol.h:149
Schematic symbol object.
Definition: sch_symbol.h:78
virtual void SetName(const wxString &aName)
Definition: lib_symbol.cpp:314
void SetPosition(const wxPoint &aPosition) override
Definition: lib_item.h:213
virtual void SetTextAngle(double aAngle)
Definition: eda_text.h:174
void SetValue(const SCH_SHEET_PATH *sheet, const wxString &aValue)
Definition: sch_symbol.cpp:614
SCH_PLUGIN::SCH_PLUGIN_RELEASER m_pi
void SetLibId(const LIB_ID &aLibId)
Definition: lib_symbol.h:132
void SetPosition(const wxPoint &aPosition) override
Definition: sch_field.cpp:664
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...

References _, LIB_PART::AddDrawItem(), AltiumToKiCadLibID(), SCH_SCREEN::Append(), CMP_ORIENT_0, CMP_ORIENT_180, CMP_ORIENT_270, CMP_ORIENT_90, DOWNWARDS, Format(), SCH_COMPONENT::GetField(), getLibFileName(), getLibName(), LIB_FIELD::GetPosition(), LIB_PART::GetReferenceField(), SCH_SHEET::GetScreen(), LIB_PART::GetValueField(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, HelperGeneratePowerPortGraphics(), LEFTWARDS, SCH_SHEET::LocatePathOfScreen(), ASCH_POWER_PORT::location, m_currentSheet, m_pi, m_powerSymbols, m_properties, m_reporter, m_rootSheet, m_sheetOffset, ASCH_POWER_PORT::orientation, pin, PT_POWER_IN, REPORTER::Report(), RIGHTWARDS, RPT_SEVERITY_WARNING, LIB_PART::SetDescription(), EDA_TEXT::SetHorizJustify(), LIB_PART::SetKeyWords(), LIB_PART::SetLibId(), SCH_COMPONENT::SetLibId(), SCH_COMPONENT::SetLibSymbol(), LIB_PART::SetName(), SCH_COMPONENT::SetOrientation(), SCH_FIELD::SetPosition(), LIB_ITEM::SetPosition(), SCH_COMPONENT::SetPosition(), LIB_PART::SetPower(), SCH_COMPONENT::SetRef(), EDA_TEXT::SetText(), EDA_TEXT::SetTextAngle(), SCH_COMPONENT::SetValue(), EDA_TEXT::SetVisible(), ASCH_POWER_PORT::style, ASCH_POWER_PORT::text, UPWARDS, and VALUE_FIELD.

Referenced by Parse().

◆ ParseRectangle()

void SCH_ALTIUM_PLUGIN::ParseRectangle ( const std::map< wxString, wxString > &  aProperties)
private

Definition at line 1204 of file sch_altium_plugin.cpp.

1205 {
1206  ASCH_RECTANGLE elem( aProperties );
1207 
1208  wxPoint sheetTopRight = elem.topRight + m_sheetOffset;
1209  wxPoint sheetBottomLeft = elem.bottomLeft + m_sheetOffset;
1210 
1211  if( elem.ownerpartid == ALTIUM_COMPONENT_NONE )
1212  {
1213  const wxPoint topLeft = { sheetBottomLeft.x, sheetTopRight.y };
1214  const wxPoint bottomRight = { sheetTopRight.x, sheetBottomLeft.y };
1215 
1216  // TODO: we cannot fill this rectangle, only draw it for now
1217  SCH_LINE* lineTop = new SCH_LINE( sheetTopRight, SCH_LAYER_ID::LAYER_NOTES );
1218  lineTop->SetEndPoint( topLeft );
1219  lineTop->SetLineWidth( elem.lineWidth );
1220  lineTop->SetLineStyle( PLOT_DASH_TYPE::SOLID );
1221  lineTop->SetFlags( IS_NEW );
1222  m_currentSheet->GetScreen()->Append( lineTop );
1223 
1224  SCH_LINE* lineBottom = new SCH_LINE( sheetBottomLeft, SCH_LAYER_ID::LAYER_NOTES );
1225  lineBottom->SetEndPoint( bottomRight );
1226  lineBottom->SetLineWidth( elem.lineWidth );
1227  lineBottom->SetLineStyle( PLOT_DASH_TYPE::SOLID );
1228  lineBottom->SetFlags( IS_NEW );
1229  m_currentSheet->GetScreen()->Append( lineBottom );
1230 
1231  SCH_LINE* lineRight = new SCH_LINE( sheetTopRight, SCH_LAYER_ID::LAYER_NOTES );
1232  lineRight->SetEndPoint( bottomRight );
1233  lineRight->SetLineWidth( elem.lineWidth );
1234  lineRight->SetLineStyle( PLOT_DASH_TYPE::SOLID );
1235  lineRight->SetFlags( IS_NEW );
1236  m_currentSheet->GetScreen()->Append( lineRight );
1237 
1238  SCH_LINE* lineLeft = new SCH_LINE( sheetBottomLeft, SCH_LAYER_ID::LAYER_NOTES );
1239  lineLeft->SetEndPoint( topLeft );
1240  lineLeft->SetLineWidth( elem.lineWidth );
1241  lineLeft->SetLineStyle( PLOT_DASH_TYPE::SOLID );
1242  lineLeft->SetFlags( IS_NEW );
1243  m_currentSheet->GetScreen()->Append( lineLeft );
1244  }
1245  else
1246  {
1247  const auto& symbol = m_symbols.find( elem.ownerindex );
1248 
1249  if( symbol == m_symbols.end() )
1250  {
1251  // TODO: e.g. can depend on Template (RECORD=39
1252  m_reporter->Report( wxString::Format( _( "Rectangle has non-existent ownerindex %d." ),
1253  elem.ownerindex ),
1255  return;
1256  }
1257 
1258  if( !IsComponentPartVisible( elem.ownerindex, elem.ownerpartdisplaymode ) )
1259  return;
1260 
1261  const auto& component = m_components.at( symbol->first );
1262 
1263  LIB_RECTANGLE* rect = new LIB_RECTANGLE( symbol->second );
1264  symbol->second->AddDrawItem( rect );
1265 
1266  rect->SetUnit( elem.ownerpartid );
1267 
1268  rect->SetPosition( GetRelativePosition( sheetTopRight, component ) );
1269  rect->SetEnd( GetRelativePosition( sheetBottomLeft, component ) );
1270  rect->SetWidth( elem.lineWidth );
1271 
1272  if( !elem.isSolid )
1274  else if( elem.color == elem.areacolor )
1276  else
1278  }
1279 }
void SetLineWidth(const int aSize)
Definition: sch_line.cpp:271
void SetFillMode(FILL_TYPE aFillMode)
Definition: lib_item.h:265
const wxPoint GetRelativePosition(const wxPoint &aPosition, const SCH_COMPONENT *aComponent)
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
void SetEndPoint(const wxPoint &aPosition)
Definition: sch_line.h:94
void SetLineStyle(const PLOT_DASH_TYPE aStyle)
Definition: sch_line.cpp:239
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:203
void SetWidth(int aWidth) override
Definition: lib_rectangle.h:79
SCH_SHEET * m_currentSheet
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
void SetUnit(int aUnit)
Definition: lib_item.h:259
void SetEnd(const wxPoint &aEnd)
Definition: lib_rectangle.h:81
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:128
#define _(s)
Definition: 3d_actions.cpp:33
std::map< int, LIB_PART * > m_symbols
void SetPosition(const wxPoint &aPosition) override
Definition: lib_item.h:213
const int ALTIUM_COMPONENT_NONE
std::map< int, SCH_COMPONENT * > m_components
#define IS_NEW
New item, just created.
Definition: eda_item.h:107
bool IsComponentPartVisible(int aOwnerindex, int aOwnerpartdisplaymode) const

References _, ALTIUM_COMPONENT_NONE, SCH_SCREEN::Append(), ASCH_RECTANGLE::areacolor, ASCH_RECTANGLE::bottomLeft, ASCH_RECTANGLE::color, FILLED_SHAPE, FILLED_WITH_BG_BODYCOLOR, Format(), GetRelativePosition(), SCH_SHEET::GetScreen(), IS_NEW, IsComponentPartVisible(), ASCH_RECTANGLE::isSolid, LAYER_NOTES, ASCH_RECTANGLE::lineWidth, m_components, m_currentSheet, m_reporter, m_sheetOffset, m_symbols, NO_FILL, ASCH_RECTANGLE::ownerindex, ASCH_RECTANGLE::ownerpartdisplaymode, ASCH_RECTANGLE::ownerpartid, REPORTER::Report(), RPT_SEVERITY_WARNING, LIB_RECTANGLE::SetEnd(), SCH_LINE::SetEndPoint(), LIB_ITEM::SetFillMode(), EDA_ITEM::SetFlags(), SCH_LINE::SetLineStyle(), SCH_LINE::SetLineWidth(), LIB_ITEM::SetPosition(), LIB_ITEM::SetUnit(), LIB_RECTANGLE::SetWidth(), SOLID, and ASCH_RECTANGLE::topRight.

Referenced by Parse().

◆ ParseRoundRectangle()

void SCH_ALTIUM_PLUGIN::ParseRoundRectangle ( const std::map< wxString, wxString > &  aProperties)
private

Definition at line 1023 of file sch_altium_plugin.cpp.

1024 {
1025  ASCH_ROUND_RECTANGLE elem( aProperties );
1026 
1027  wxPoint sheetTopRight = elem.topRight + m_sheetOffset;
1028  wxPoint sheetBottomLeft = elem.bottomLeft + m_sheetOffset;
1029 
1030  if( elem.ownerpartid == ALTIUM_COMPONENT_NONE )
1031  {
1032  const wxPoint topLeft = { sheetBottomLeft.x, sheetTopRight.y };
1033  const wxPoint bottomRight = { sheetTopRight.x, sheetBottomLeft.y };
1034 
1035  // TODO: we cannot fill this rectangle, only draw it for now
1036  // TODO: misses rounded edges
1037  SCH_LINE* lineTop = new SCH_LINE( sheetTopRight, SCH_LAYER_ID::LAYER_NOTES );
1038  lineTop->SetEndPoint( topLeft );
1039  lineTop->SetLineWidth( elem.lineWidth );
1040  lineTop->SetLineStyle( PLOT_DASH_TYPE::SOLID );
1041  lineTop->SetFlags( IS_NEW );
1042  m_currentSheet->GetScreen()->Append( lineTop );
1043 
1044  SCH_LINE* lineBottom = new SCH_LINE( sheetBottomLeft, SCH_LAYER_ID::LAYER_NOTES );
1045  lineBottom->SetEndPoint( bottomRight );
1046  lineBottom->SetLineWidth( elem.lineWidth );
1047  lineBottom->SetLineStyle( PLOT_DASH_TYPE::SOLID );
1048  lineBottom->SetFlags( IS_NEW );
1049  m_currentSheet->GetScreen()->Append( lineBottom );
1050 
1051  SCH_LINE* lineRight = new SCH_LINE( sheetTopRight, SCH_LAYER_ID::LAYER_NOTES );
1052  lineRight->SetEndPoint( bottomRight );
1053  lineRight->SetLineWidth( elem.lineWidth );
1054  lineRight->SetLineStyle( PLOT_DASH_TYPE::SOLID );
1055  lineRight->SetFlags( IS_NEW );
1056  m_currentSheet->GetScreen()->Append( lineRight );
1057 
1058  SCH_LINE* lineLeft = new SCH_LINE( sheetBottomLeft, SCH_LAYER_ID::LAYER_NOTES );
1059  lineLeft->SetEndPoint( topLeft );
1060  lineLeft->SetLineWidth( elem.lineWidth );
1061  lineLeft->SetLineStyle( PLOT_DASH_TYPE::SOLID );
1062  lineLeft->SetFlags( IS_NEW );
1063  m_currentSheet->GetScreen()->Append( lineLeft );
1064  }
1065  else
1066  {
1067  const auto& symbol = m_symbols.find( elem.ownerindex );
1068 
1069  if( symbol == m_symbols.end() )
1070  {
1071  // TODO: e.g. can depend on Template (RECORD=39
1072  m_reporter->Report( wxString::Format( _( "Rounded rectangle has non-existent "
1073  "ownerindex %d." ),
1074  elem.ownerindex ),
1076  return;
1077  }
1078 
1079  if( !IsComponentPartVisible( elem.ownerindex, elem.ownerpartdisplaymode ) )
1080  return;
1081 
1082  const auto& component = m_components.at( symbol->first );
1083 
1084  // TODO: misses rounded edges
1085  LIB_RECTANGLE* rect = new LIB_RECTANGLE( symbol->second );
1086  symbol->second->AddDrawItem( rect );
1087 
1088  rect->SetUnit( elem.ownerpartid );
1089 
1090  rect->SetPosition( GetRelativePosition( elem.topRight + m_sheetOffset, component ) );
1091  rect->SetEnd( GetRelativePosition( elem.bottomLeft + m_sheetOffset, component ) );
1092  rect->SetWidth( elem.lineWidth );
1093 
1094  if( !elem.isSolid )
1096  else if( elem.color == elem.areacolor )
1098  else
1100  }
1101 }
void SetLineWidth(const int aSize)
Definition: sch_line.cpp:271
void SetFillMode(FILL_TYPE aFillMode)
Definition: lib_item.h:265
const wxPoint GetRelativePosition(const wxPoint &aPosition, const SCH_COMPONENT *aComponent)
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
void SetEndPoint(const wxPoint &aPosition)
Definition: sch_line.h:94
void SetLineStyle(const PLOT_DASH_TYPE aStyle)
Definition: sch_line.cpp:239
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:203
void SetWidth(int aWidth) override
Definition: lib_rectangle.h:79
SCH_SHEET * m_currentSheet
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
void SetUnit(int aUnit)
Definition: lib_item.h:259
void SetEnd(const wxPoint &aEnd)
Definition: lib_rectangle.h:81
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:128
#define _(s)
Definition: 3d_actions.cpp:33
std::map< int, LIB_PART * > m_symbols
void SetPosition(const wxPoint &aPosition) override
Definition: lib_item.h:213
const int ALTIUM_COMPONENT_NONE
std::map< int, SCH_COMPONENT * > m_components
#define IS_NEW
New item, just created.
Definition: eda_item.h:107
bool IsComponentPartVisible(int aOwnerindex, int aOwnerpartdisplaymode) const

References _, ALTIUM_COMPONENT_NONE, SCH_SCREEN::Append(), ASCH_ROUND_RECTANGLE::areacolor, ASCH_ROUND_RECTANGLE::bottomLeft, ASCH_ROUND_RECTANGLE::color, FILLED_SHAPE, FILLED_WITH_BG_BODYCOLOR, Format(), GetRelativePosition(), SCH_SHEET::GetScreen(), IS_NEW, IsComponentPartVisible(), ASCH_ROUND_RECTANGLE::isSolid, LAYER_NOTES, ASCH_ROUND_RECTANGLE::lineWidth, m_components, m_currentSheet, m_reporter, m_sheetOffset, m_symbols, NO_FILL, ASCH_ROUND_RECTANGLE::ownerindex, ASCH_ROUND_RECTANGLE::ownerpartdisplaymode, ASCH_ROUND_RECTANGLE::ownerpartid, REPORTER::Report(), RPT_SEVERITY_WARNING, LIB_RECTANGLE::SetEnd(), SCH_LINE::SetEndPoint(), LIB_ITEM::SetFillMode(), EDA_ITEM::SetFlags(), SCH_LINE::SetLineStyle(), SCH_LINE::SetLineWidth(), LIB_ITEM::SetPosition(), LIB_ITEM::SetUnit(), LIB_RECTANGLE::SetWidth(), SOLID, and ASCH_ROUND_RECTANGLE::topRight.

Referenced by Parse().

◆ ParseSheet()

void SCH_ALTIUM_PLUGIN::ParseSheet ( const std::map< wxString, wxString > &  aProperties)
private

Definition at line 1877 of file sch_altium_plugin.cpp.

1878 {
1879  m_altiumSheet = std::make_unique<ASCH_SHEET>( aProperties );
1880 
1881  PAGE_INFO pageInfo;
1882 
1883  bool isPortrait = m_altiumSheet->sheetOrientation == ASCH_SHEET_WORKSPACEORIENTATION::PORTRAIT;
1884  switch( m_altiumSheet->sheetSize )
1885  {
1886  default:
1887  case ASCH_SHEET_SIZE::A4:
1888  pageInfo.SetType( "A4", isPortrait );
1889  break;
1890  case ASCH_SHEET_SIZE::A3:
1891  pageInfo.SetType( "A3", isPortrait );
1892  break;
1893  case ASCH_SHEET_SIZE::A2:
1894  pageInfo.SetType( "A2", isPortrait );
1895  break;
1896  case ASCH_SHEET_SIZE::A1:
1897  pageInfo.SetType( "A1", isPortrait );
1898  break;
1899  case ASCH_SHEET_SIZE::A0:
1900  pageInfo.SetType( "A0", isPortrait );
1901  break;
1902  case ASCH_SHEET_SIZE::A:
1903  pageInfo.SetType( "A", isPortrait );
1904  break;
1905  case ASCH_SHEET_SIZE::B:
1906  pageInfo.SetType( "B", isPortrait );
1907  break;
1908  case ASCH_SHEET_SIZE::C:
1909  pageInfo.SetType( "C", isPortrait );
1910  break;
1911  case ASCH_SHEET_SIZE::D:
1912  pageInfo.SetType( "D", isPortrait );
1913  break;
1914  case ASCH_SHEET_SIZE::E:
1915  pageInfo.SetType( "E", isPortrait );
1916  break;
1918  pageInfo.SetType( "USLetter", isPortrait );
1919  break;
1921  pageInfo.SetType( "USLegal", isPortrait );
1922  break;
1924  pageInfo.SetType( "A3", isPortrait ); // TODO: use User
1925  break;
1927  pageInfo.SetType( "A", isPortrait );
1928  break;
1930  pageInfo.SetType( "B", isPortrait );
1931  break;
1933  pageInfo.SetType( "C", isPortrait );
1934  break;
1936  pageInfo.SetType( "D", isPortrait );
1937  break;
1939  pageInfo.SetType( "E", isPortrait );
1940  break;
1941  }
1942 
1943  m_currentSheet->GetScreen()->SetPageSettings( pageInfo );
1944 
1945  m_sheetOffset = { 0, pageInfo.GetHeightIU() };
1946 }
bool SetType(const wxString &aStandardPageDescriptionName, bool aIsPortrait=false)
Set the name of the page type and also the sizes and margins commonly associated with that type name.
Definition: page_info.cpp:119
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: sch_screen.h:129
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:53
std::unique_ptr< ASCH_SHEET > m_altiumSheet
SCH_SHEET * m_currentSheet

References A, A0, A1, A2, A3, A4, B, C, D, E, SCH_SHEET::GetScreen(), LEGAL, LETTER, m_altiumSheet, m_currentSheet, m_sheetOffset, ORCAD_A, ORCAD_B, ORCAD_C, ORCAD_D, ORCAD_E, PORTRAIT, SCH_SCREEN::SetPageSettings(), PAGE_INFO::SetType(), and TABLOID.

Referenced by Parse().

◆ ParseSheetEntry()

void SCH_ALTIUM_PLUGIN::ParseSheetEntry ( const std::map< wxString, wxString > &  aProperties)
private

Definition at line 1305 of file sch_altium_plugin.cpp.

1306 {
1307  ASCH_SHEET_ENTRY elem( aProperties );
1308 
1309  const auto& sheet = m_sheets.find( elem.ownerindex );
1310  if( sheet == m_sheets.end() )
1311  {
1312  wxLogError( wxString::Format( "Sheet Entry has non-existent ownerindex %d",
1313  elem.ownerindex ) );
1314  return;
1315  }
1316 
1317  SCH_SHEET_PIN* sheetPin = new SCH_SHEET_PIN( sheet->second );
1318  sheet->second->AddPin( sheetPin );
1319 
1320  sheetPin->SetText( elem.name );
1322  //sheetPin->SetLabelSpinStyle( getSpinStyle( term.OrientAngle, false ) );
1323  //sheetPin->SetPosition( getKiCadPoint( term.Position ) );
1324 
1325  wxPoint pos = sheet->second->GetPosition();
1326  wxSize size = sheet->second->GetSize();
1327 
1328  switch( elem.side )
1329  {
1330  default:
1332  sheetPin->SetPosition( { pos.x, pos.y + elem.distanceFromTop } );
1334  sheetPin->SetEdge( SHEET_SIDE::SHEET_LEFT_SIDE );
1335  break;
1337  sheetPin->SetPosition( { pos.x + size.x, pos.y + elem.distanceFromTop } );
1340  break;
1342  sheetPin->SetPosition( { pos.x + elem.distanceFromTop, pos.y } );
1344  sheetPin->SetEdge( SHEET_SIDE::SHEET_TOP_SIDE );
1345  break;
1347  sheetPin->SetPosition( { pos.x + elem.distanceFromTop, pos.y + size.y } );
1350  break;
1351  }
1352 
1353  switch( elem.iotype )
1354  {
1355  default:
1358  break;
1361  break;
1364  break;
1367  break;
1368  }
1369 }
void SetShape(PINSHEETLABEL_SHAPE aShape)
Definition: sch_text.h:219
std::map< int, SCH_SHEET * > m_sheets
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:121
void SetEdge(SHEET_SIDE aEdge)
void SetLabelSpinStyle(LABEL_SPIN_STYLE aSpinStyle) override
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:1397
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:65
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
void SetPosition(const wxPoint &aPosition) override

References BIDI, LABEL_SPIN_STYLE::BOTTOM, BOTTOM, ASCH_SHEET_ENTRY::distanceFromTop, Format(), INPUT, ASCH_SHEET_ENTRY::iotype, LABEL_SPIN_STYLE::LEFT, LEFT, m_sheets, ASCH_SHEET_ENTRY::name, OUTPUT, ASCH_SHEET_ENTRY::ownerindex, PS_BIDI, PS_INPUT, PS_OUTPUT, PS_UNSPECIFIED, LABEL_SPIN_STYLE::RIGHT, RIGHT, SCH_SHEET_PIN::SetEdge(), SCH_HIERLABEL::SetLabelSpinStyle(), SCH_SHEET_PIN::SetPosition(), SCH_TEXT::SetShape(), EDA_TEXT::SetText(), SHEET_BOTTOM_SIDE, SHEET_LEFT_SIDE, SHEET_RIGHT_SIDE, SHEET_TOP_SIDE, ASCH_SHEET_ENTRY::side, TOP, UNSPECIFIED, and LABEL_SPIN_STYLE::UP.

Referenced by Parse().

◆ ParseSheetName()

void SCH_ALTIUM_PLUGIN::ParseSheetName ( const std::map< wxString, wxString > &  aProperties)
private

Definition at line 1970 of file sch_altium_plugin.cpp.

1971 {
1972  ASCH_SHEET_NAME elem( aProperties );
1973 
1974  const auto& sheet = m_sheets.find( elem.ownerindex );
1975  if( sheet == m_sheets.end() )
1976  {
1977  wxLogError( wxString::Format( "Sheet Name has non-existent ownerindex %d",
1978  elem.ownerindex ) );
1979  return;
1980  }
1981 
1982  SCH_FIELD& sheetNameField = sheet->second->GetFields()[SHEETNAME];
1983 
1984  sheetNameField.SetPosition( elem.location + m_sheetOffset );
1985  sheetNameField.SetText( elem.text );
1986  sheetNameField.SetVisible( !elem.isHidden );
1987 
1990 
1991  SetFieldOrientation( sheetNameField, elem.orientation );
1992 }
Instances are attached to a symbol or sheet and provide a place for the component's value,...
Definition: sch_field.h:50
void SetVisible(bool aVisible)
Definition: eda_text.h:192
std::map< int, SCH_SHEET * > m_sheets
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:121
void SetFieldOrientation(SCH_FIELD &aField, ASCH_RECORD_ORIENTATION aOrientation)
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:209
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:208
void SetPosition(const wxPoint &aPosition) override
Definition: sch_field.cpp:664

References Format(), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, ASCH_SHEET_NAME::isHidden, ASCH_SHEET_NAME::location, m_sheetOffset, m_sheets, ASCH_SHEET_NAME::orientation, ASCH_SHEET_NAME::ownerindex, SetFieldOrientation(), EDA_TEXT::SetHorizJustify(), SCH_FIELD::SetPosition(), EDA_TEXT::SetText(), EDA_TEXT::SetVertJustify(), EDA_TEXT::SetVisible(), SHEETNAME, and ASCH_SHEET_NAME::text.

Referenced by Parse().

◆ ParseSheetSymbol()

void SCH_ALTIUM_PLUGIN::ParseSheetSymbol ( int  aIndex,
const std::map< wxString, wxString > &  aProperties 
)
private

Definition at line 1282 of file sch_altium_plugin.cpp.

1284 {
1285  ASCH_SHEET_SYMBOL elem( aProperties );
1286 
1287  SCH_SHEET* sheet = new SCH_SHEET( m_currentSheet, elem.location + m_sheetOffset );
1288  SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
1289 
1290  sheet->SetSize( elem.size );
1291 
1292  sheet->SetBorderColor( GetColorFromInt( elem.color ) );
1293  if( elem.isSolid )
1294  sheet->SetBackgroundColor( GetColorFromInt( elem.areacolor ) );
1295 
1296  sheet->SetScreen( screen );
1297 
1298  sheet->SetFlags( IS_NEW );
1299  m_currentSheet->GetScreen()->Append( sheet );
1300 
1301  m_sheets.insert( { aIndex, sheet } );
1302 }
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:156
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
std::map< int, SCH_SHEET * > m_sheets
COLOR4D GetColorFromInt(int color)
void SetBackgroundColor(KIGFX::COLOR4D aColor)
Definition: sch_sheet.h:115
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:203
void SetBorderColor(KIGFX::COLOR4D aColor)
Definition: sch_sheet.h:112
SCH_SHEET * m_currentSheet
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
void SetSize(const wxSize &aSize)
Definition: sch_sheet.h:106
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:128
#define IS_NEW
New item, just created.
Definition: eda_item.h:107

References SCH_SCREEN::Append(), ASCH_SHEET_SYMBOL::areacolor, ASCH_SHEET_SYMBOL::color, GetColorFromInt(), SCH_SHEET::GetScreen(), IS_NEW, ASCH_SHEET_SYMBOL::isSolid, ASCH_SHEET_SYMBOL::location, m_currentSheet, m_schematic, m_sheetOffset, m_sheets, SCH_SHEET::SetBackgroundColor(), SCH_SHEET::SetBorderColor(), EDA_ITEM::SetFlags(), SCH_SHEET::SetScreen(), SCH_SHEET::SetSize(), and ASCH_SHEET_SYMBOL::size.

Referenced by Parse().

◆ ParseWire()

void SCH_ALTIUM_PLUGIN::ParseWire ( const std::map< wxString, wxString > &  aProperties)
private

Definition at line 1849 of file sch_altium_plugin.cpp.

1850 {
1851  ASCH_WIRE elem( aProperties );
1852 
1853  for( size_t i = 0; i + 1 < elem.points.size(); i++ )
1854  {
1855  SCH_LINE* wire =
1856  new SCH_LINE( elem.points.at( i ) + m_sheetOffset, SCH_LAYER_ID::LAYER_WIRE );
1857  wire->SetEndPoint( elem.points.at( i + 1 ) + m_sheetOffset );
1858  wire->SetLineWidth( elem.lineWidth );
1859 
1860  wire->SetFlags( IS_NEW );
1861  m_currentSheet->GetScreen()->Append( wire );
1862  }
1863 }
void SetLineWidth(const int aSize)
Definition: sch_line.cpp:271
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
void SetEndPoint(const wxPoint &aPosition)
Definition: sch_line.h:94
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:203
SCH_SHEET * m_currentSheet
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:128
#define IS_NEW
New item, just created.
Definition: eda_item.h:107

References SCH_SCREEN::Append(), SCH_SHEET::GetScreen(), IS_NEW, LAYER_WIRE, ASCH_WIRE::lineWidth, m_currentSheet, m_sheetOffset, ASCH_WIRE::points, SCH_LINE::SetEndPoint(), EDA_ITEM::SetFlags(), and SCH_LINE::SetLineWidth().

Referenced by Parse().

◆ Save()

void SCH_PLUGIN::Save ( const wxString &  aFileName,
SCH_SHEET aSheet,
SCHEMATIC aSchematic,
const PROPERTIES aProperties = nullptr 
)
virtualinherited

Write aSchematic to a storage file in a format that this SCH_PLUGIN implementation knows about, or it can be used to write a portion of aSchematic to a special kind of export file.

Parameters
aFileNameis the name of a file to save to on disk.
aSheetis the class SCH_SHEET in memory document tree from which to extract information when writing to aFileName. The caller continues to own the SCHEMATIC, and the plugin should refrain from modifying the SCHEMATIC if possible.
aSchematicis the SCHEMATIC object used to access any schematic-wide or project information needed to save the document.
aPropertiesis an associative array that can be used to tell the saver how to save the file, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL. Set the #PropSaveCurrentSheetOnly property to only save the current sheet. Otherwise, all hierarchical sheets are saved.
Exceptions
IO_ERRORif there is a problem saving or exporting.

Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.

Definition at line 59 of file sch_plugin.cpp.

61 {
62  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
63  not_implemented( this, __FUNCTION__ );
64 }
static void not_implemented(const SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented.
Definition: sch_plugin.cpp:37

References not_implemented().

◆ SaveLibrary()

void SCH_PLUGIN::SaveLibrary ( const wxString &  aFileName,
const PROPERTIES aProperties = nullptr 
)
virtualinherited

Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.

Definition at line 45 of file sch_plugin.cpp.

46 {
47  not_implemented( this, __FUNCTION__ );
48 }
static void not_implemented(const SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented.
Definition: sch_plugin.cpp:37

References not_implemented().

◆ SaveSymbol()

void SCH_PLUGIN::SaveSymbol ( const wxString &  aLibraryPath,
const LIB_PART aSymbol,
const PROPERTIES aProperties = nullptr 
)
virtualinherited

Write aSymbol to an existing library located at aLibraryPath.

If a LIB_PART by the same name already exists or there are any conflicting alias names, the new LIB_PART will silently overwrite any existing aliases and/or part because libraries cannot have duplicate alias names. It is the responsibility of the caller to check the library for conflicts before saving.

Parameters
aLibraryPathis a locator for the "library", usually a directory, file, or URL containing several symbols.
aSymbolis what to store in the library. The library is refreshed and the caller must update any LIB_PART pointers that may have changed.
aPropertiesis an associative array that can be used to tell the saver how to save the symbol, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Exceptions
IO_ERRORif there is a problem saving.

Reimplemented in SCH_LEGACY_PLUGIN, and SCH_SEXPR_PLUGIN.

Definition at line 94 of file sch_plugin.cpp.

96 {
97  // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
98  not_implemented( this, __FUNCTION__ );
99 }
static void not_implemented(const SCH_PLUGIN *aPlugin, const char *aCaller)
Function not_implemented throws an IO_ERROR and complains of an API function not being implemented.
Definition: sch_plugin.cpp:37

References not_implemented().

Referenced by SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer().

◆ SetReporter()

void SCH_ALTIUM_PLUGIN::SetReporter ( REPORTER aReporter)
inlineoverridevirtual

Set an optional reporter for warnings/errors.

Reimplemented from SCH_PLUGIN.

Definition at line 58 of file sch_altium_plugin.h.

58 { m_reporter = aReporter; }

References m_reporter.

◆ SymbolLibOptions()

void SCH_PLUGIN::SymbolLibOptions ( PROPERTIES aListToAppendTo) const
virtualinherited

Append supported SCH_PLUGIN options to aListToAppenTo along with internationalized descriptions.

Options are typically appended so that a derived SCH_PLUGIN can call its base class function by the same name first, thus inheriting options declared there. (Some base class options could pertain to all Symbol*() functions in all derived SCH_PLUGINs.) Note that since aListToAppendTo is a PROPERTIES object, all options will be unique and last guy wins.

Parameters
aListToAppendToholds a tuple of
option
This eventually is what shows up into the fp-lib-table "options" field, possibly combined with others.
internationalized description
The internationalized description is displayed in DIALOG_FP_SCH_PLUGIN_OPTIONS. It may be multi-line and be quite explanatory of the option.

In the future perhaps aListToAppendTo evolves to something capable of also holding a wxValidator for the cells in said dialog: http://forums.wxwidgets.org/viewtopic.php?t=23277&p=104180. This would require a 3 column list, and introducing wx GUI knowledge to SCH_PLUGIN, which has been avoided to date.

Definition at line 133 of file sch_plugin.cpp.

134 {
135  // disable all these in another couple of months, after everyone has seen them:
136 #if 1
137  (*aListToAppendTo)["debug_level"] = UTF8( _(
138  "Enable <b>debug</b> logging for Symbol*() functions in this SCH_PLUGIN."
139  ) );
140 
141  (*aListToAppendTo)["read_filter_regex"] = UTF8( _(
142  "Regular expression <b>symbol name</b> filter."
143  ) );
144 
145  (*aListToAppendTo)["enable_transaction_logging"] = UTF8( _(
146  "Enable transaction logging. The mere presence of this option turns on the "
147  "logging, no need to set a Value."
148  ) );
149 
150  (*aListToAppendTo)["username"] = UTF8( _(
151  "User name for <b>login</b> to some special library server."
152  ) );
153 
154  (*aListToAppendTo)["password"] = UTF8( _(
155  "Password for <b>login</b> to some special library server."
156  ) );
157 #endif
158 
159 #if 1
160  // Suitable for a C++ to python SCH_PLUGIN::Footprint*() adapter, move it to the adapter
161  // if and when implemented.
162  (*aListToAppendTo)["python_symbol_plugin"] = UTF8( _(
163  "Enter the python symbol which implements the SCH_PLUGIN::Symbol*() functions."
164  ) );
165 #endif
166 }
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
Definition: utf8.h:70
#define _(s)
Definition: 3d_actions.cpp:33

References _.

Member Data Documentation

◆ m_altiumComponents

std::map<int, ASCH_COMPONENT> SCH_ALTIUM_PLUGIN::m_altiumComponents
private

Definition at line 160 of file sch_altium_plugin.h.

Referenced by IsComponentPartVisible(), and ParseComponent().

◆ m_altiumPortsCurrentSheet

std::vector<ASCH_PORT> SCH_ALTIUM_PLUGIN::m_altiumPortsCurrentSheet
private

Definition at line 161 of file sch_altium_plugin.h.

Referenced by Parse().

◆ m_altiumSheet

std::unique_ptr<ASCH_SHEET> SCH_ALTIUM_PLUGIN::m_altiumSheet
private

Definition at line 153 of file sch_altium_plugin.h.

Referenced by ParseLabel(), and ParseSheet().

◆ m_components

◆ m_currentSheet

◆ m_currentTitleBlock

std::unique_ptr<TITLE_BLOCK> SCH_ALTIUM_PLUGIN::m_currentTitleBlock
private

Definition at line 149 of file sch_altium_plugin.h.

Referenced by Parse(), and ParseParameter().

◆ m_libName

wxString SCH_ALTIUM_PLUGIN::m_libName
private

Definition at line 144 of file sch_altium_plugin.h.

Referenced by getLibName().

◆ m_pi

SCH_PLUGIN::SCH_PLUGIN_RELEASER SCH_ALTIUM_PLUGIN::m_pi
private

Definition at line 146 of file sch_altium_plugin.h.

Referenced by Load(), Parse(), and ParsePowerPort().

◆ m_powerSymbols

std::map<wxString, LIB_PART*> SCH_ALTIUM_PLUGIN::m_powerSymbols
private

Definition at line 158 of file sch_altium_plugin.h.

Referenced by ParsePowerPort().

◆ m_properties

std::unique_ptr<PROPERTIES> SCH_ALTIUM_PLUGIN::m_properties
private

Definition at line 147 of file sch_altium_plugin.h.

Referenced by Parse(), and ParsePowerPort().

◆ m_reporter

◆ m_rootSheet

SCH_SHEET* SCH_ALTIUM_PLUGIN::m_rootSheet
private

◆ m_schematic

SCHEMATIC* SCH_ALTIUM_PLUGIN::m_schematic
private

◆ m_sheetOffset

◆ m_sheets

std::map<int, SCH_SHEET*> SCH_ALTIUM_PLUGIN::m_sheets
private

◆ m_symbols


The documentation for this class was generated from the following files: