2020-08-23 19:01:08 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020 Thomas Pointhuber <thomas.pointhuber@gmx.at>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _SCH_ALTIUM_PLUGIN_H_
|
|
|
|
#define _SCH_ALTIUM_PLUGIN_H_
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <sch_io_mgr.h>
|
|
|
|
#include <wx/filename.h>
|
2020-10-17 13:35:22 +00:00
|
|
|
#include <wx/gdicmn.h>
|
2020-08-23 19:01:08 +00:00
|
|
|
|
2020-10-23 15:02:56 +00:00
|
|
|
#include "altium_parser_sch.h"
|
|
|
|
|
2020-10-17 12:33:30 +00:00
|
|
|
|
2020-08-23 19:01:08 +00:00
|
|
|
class SCH_COMPONENT;
|
2020-10-27 14:51:19 +00:00
|
|
|
class SCH_SHEET;
|
2020-10-26 17:26:49 +00:00
|
|
|
class TITLE_BLOCK;
|
2020-08-23 19:01:08 +00:00
|
|
|
|
|
|
|
namespace CFB
|
|
|
|
{
|
|
|
|
class CompoundFileReader;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
class SCH_ALTIUM_PLUGIN : public SCH_PLUGIN
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SCH_ALTIUM_PLUGIN();
|
|
|
|
~SCH_ALTIUM_PLUGIN();
|
|
|
|
|
|
|
|
const wxString GetName() const override;
|
|
|
|
|
|
|
|
const wxString GetFileExtension() const override;
|
|
|
|
|
|
|
|
const wxString GetLibraryFileExtension() const override;
|
|
|
|
|
|
|
|
int GetModifyHash() const override;
|
|
|
|
|
|
|
|
SCH_SHEET* Load( const wxString& aFileName, SCHEMATIC* aSchematic,
|
2020-11-05 23:19:47 +00:00
|
|
|
SCH_SHEET* aAppendToMe = nullptr,
|
|
|
|
const PROPERTIES* aProperties = nullptr ) override;
|
2020-08-23 19:01:08 +00:00
|
|
|
|
|
|
|
bool CheckHeader( const wxString& aFileName ) override;
|
|
|
|
|
|
|
|
// unimplemented functions. Will trigger a not_implemented IO error.
|
|
|
|
//void SaveLibrary( const wxString& aFileName, const PROPERTIES* aProperties = NULL ) override;
|
|
|
|
|
|
|
|
//void Save( const wxString& aFileName, SCH_SCREEN* aSchematic, KIWAY* aKiway,
|
|
|
|
// const PROPERTIES* aProperties = NULL ) override;
|
|
|
|
|
|
|
|
//void EnumerateSymbolLib( wxArrayString& aAliasNameList, const wxString& aLibraryPath,
|
|
|
|
// const PROPERTIES* aProperties = NULL ) override;
|
|
|
|
|
|
|
|
//LIB_PART* LoadSymbol( const wxString& aLibraryPath, const wxString& aAliasName,
|
|
|
|
// const PROPERTIES* aProperties = NULL ) override;
|
|
|
|
|
|
|
|
//void SaveSymbol( const wxString& aLibraryPath, const LIB_PART* aSymbol,
|
|
|
|
// const PROPERTIES* aProperties = NULL ) override;
|
|
|
|
|
|
|
|
//void DeleteAlias( const wxString& aLibraryPath, const wxString& aAliasName,
|
|
|
|
// const PROPERTIES* aProperties = NULL ) override;
|
|
|
|
|
|
|
|
//void DeleteSymbol( const wxString& aLibraryPath, const wxString& aAliasName,
|
|
|
|
// const PROPERTIES* aProperties = NULL ) override;
|
|
|
|
|
|
|
|
//void CreateSymbolLib( const wxString& aLibraryPath,
|
|
|
|
// const PROPERTIES* aProperties = NULL ) override;
|
|
|
|
|
|
|
|
// bool DeleteSymbolLib( const wxString& aLibraryPath,
|
|
|
|
// const PROPERTIES* aProperties = NULL ) override;
|
|
|
|
|
|
|
|
//bool IsSymbolLibWritable( const wxString& aLibraryPath ) override;
|
|
|
|
|
|
|
|
//void SymbolLibOptions( PROPERTIES* aListToAppendTo ) const override;
|
|
|
|
|
|
|
|
wxString getLibName();
|
|
|
|
wxFileName getLibFileName();
|
|
|
|
|
|
|
|
void ParseAltiumSch( const wxString& aFileName );
|
|
|
|
void Parse( const CFB::CompoundFileReader& aReader );
|
|
|
|
|
|
|
|
private:
|
2020-10-23 15:20:07 +00:00
|
|
|
bool IsComponentPartVisible( int aOwnerindex, int aOwnerpartdisplaymode ) const;
|
2020-10-23 15:02:56 +00:00
|
|
|
|
2020-10-27 14:51:19 +00:00
|
|
|
void ParseComponent( int aIndex, const std::map<wxString, wxString>& aProperties );
|
2020-08-23 19:01:08 +00:00
|
|
|
void ParsePin( const std::map<wxString, wxString>& aProperties );
|
2020-10-17 11:52:47 +00:00
|
|
|
void ParseLabel( const std::map<wxString, wxString>& aProperties );
|
2020-10-10 14:56:19 +00:00
|
|
|
void ParseBezier( const std::map<wxString, wxString>& aProperties );
|
|
|
|
void ParsePolyline( const std::map<wxString, wxString>& aProperties );
|
2020-10-10 14:22:53 +00:00
|
|
|
void ParsePolygon( const std::map<wxString, wxString>& aProperties );
|
2020-10-14 19:15:09 +00:00
|
|
|
void ParseRoundRectangle( const std::map<wxString, wxString>& aProperties );
|
2020-10-10 16:41:19 +00:00
|
|
|
void ParseArc( const std::map<wxString, wxString>& aProperties );
|
|
|
|
void ParseLine( const std::map<wxString, wxString>& aProperties );
|
2020-08-23 19:01:08 +00:00
|
|
|
void ParseRectangle( const std::map<wxString, wxString>& aProperties );
|
2020-10-27 14:51:19 +00:00
|
|
|
void ParseSheetSymbol( int aIndex, const std::map<wxString, wxString>& aProperties );
|
|
|
|
void ParseSheetEntry( const std::map<wxString, wxString>& aProperties );
|
2020-10-24 16:40:16 +00:00
|
|
|
void ParsePowerPort( const std::map<wxString, wxString>& aProperties );
|
2020-10-27 13:07:42 +00:00
|
|
|
void ParsePort( const ASCH_PORT& aElem );
|
2020-10-14 19:23:36 +00:00
|
|
|
void ParseNoERC( const std::map<wxString, wxString>& aProperties );
|
2020-08-23 19:01:08 +00:00
|
|
|
void ParseNetLabel( const std::map<wxString, wxString>& aProperties );
|
|
|
|
void ParseBus( const std::map<wxString, wxString>& aProperties );
|
|
|
|
void ParseWire( const std::map<wxString, wxString>& aProperties );
|
2020-10-09 15:21:27 +00:00
|
|
|
void ParseJunction( const std::map<wxString, wxString>& aProperties );
|
2020-10-17 12:33:30 +00:00
|
|
|
void ParseSheet( const std::map<wxString, wxString>& aProperties );
|
2020-10-27 14:51:19 +00:00
|
|
|
void ParseSheetName( const std::map<wxString, wxString>& aProperties );
|
|
|
|
void ParseFileName( const std::map<wxString, wxString>& aProperties );
|
2020-08-23 19:01:08 +00:00
|
|
|
void ParseDesignator( const std::map<wxString, wxString>& aProperties );
|
2020-10-17 14:03:46 +00:00
|
|
|
void ParseBusEntry( const std::map<wxString, wxString>& aProperties );
|
2020-10-26 17:26:49 +00:00
|
|
|
void ParseParameter( const std::map<wxString, wxString>& aProperties );
|
2020-08-23 19:01:08 +00:00
|
|
|
|
|
|
|
private:
|
2020-11-05 23:19:47 +00:00
|
|
|
SCH_SHEET* m_rootSheet; // The root sheet of the schematic being loaded..
|
|
|
|
SCH_SHEET* m_currentSheet; // The current sheet of the schematic being loaded..
|
|
|
|
SCHEMATIC* m_schematic; // Passed to Load(), the schematic object being loaded
|
|
|
|
wxString m_libName; // Library name to save symbols
|
2020-08-23 19:01:08 +00:00
|
|
|
|
2020-11-05 23:19:47 +00:00
|
|
|
SCH_PLUGIN::SCH_PLUGIN_RELEASER m_pi; // Plugin to create KiCad symbol library.
|
|
|
|
std::unique_ptr<PROPERTIES> m_properties; // Library plugin properties.
|
2020-08-23 19:01:08 +00:00
|
|
|
|
2020-11-05 23:19:47 +00:00
|
|
|
std::unique_ptr<TITLE_BLOCK> m_currentTitleBlock; // Will be assigned at the end of parsing
|
|
|
|
// a sheet
|
2020-10-26 17:26:49 +00:00
|
|
|
|
2020-11-05 23:19:47 +00:00
|
|
|
wxPoint m_sheetOffset;
|
|
|
|
std::unique_ptr<ASCH_SHEET> m_altiumSheet;
|
|
|
|
std::map<int, SCH_COMPONENT*> m_components;
|
|
|
|
std::map<int, SCH_SHEET*> m_sheets;
|
|
|
|
std::map<int, LIB_PART*> m_symbols; // every component has its unique symbol
|
2020-10-23 15:02:56 +00:00
|
|
|
|
2020-11-05 23:19:47 +00:00
|
|
|
std::map<wxString, LIB_PART*> m_powerSymbols;
|
2020-10-24 16:40:16 +00:00
|
|
|
|
2020-11-05 23:19:47 +00:00
|
|
|
std::map<int, ASCH_COMPONENT> m_altiumComponents;
|
|
|
|
std::vector<ASCH_PORT> m_altiumPortsCurrentSheet; // we require all connections first
|
2020-08-23 19:01:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _SCH_ALTIUM_PLUGIN_H_
|