2016-07-06 09:22:56 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2016 CERN
|
2024-01-26 13:59:07 +00:00
|
|
|
* Copyright (C) 2016-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
2016-07-06 09:22:56 +00:00
|
|
|
*
|
|
|
|
* @author Wayne Stambaugh <stambaughw@gmail.com>
|
|
|
|
*
|
|
|
|
* 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2022-11-06 16:51:52 +00:00
|
|
|
#include <string_utf8_map.h>
|
2023-08-26 19:28:53 +00:00
|
|
|
#include <unordered_set>
|
2016-07-06 09:22:56 +00:00
|
|
|
|
2023-09-08 02:29:40 +00:00
|
|
|
#include <ki_exception.h>
|
2023-12-19 17:39:26 +00:00
|
|
|
#include <sch_io/sch_io.h>
|
|
|
|
#include <sch_io/sch_io_mgr.h>
|
2020-10-01 08:52:03 +00:00
|
|
|
#include <wx/translation.h>
|
2023-08-26 19:28:53 +00:00
|
|
|
#include <wx/filename.h>
|
|
|
|
#include <wx/dir.h>
|
2016-07-06 09:22:56 +00:00
|
|
|
|
2023-04-11 08:53:35 +00:00
|
|
|
#define FMT_UNIMPLEMENTED wxT( "Plugin \"%s\" does not implement the \"%s\" function." )
|
|
|
|
#define NOT_IMPLEMENTED( aCaller ) \
|
|
|
|
THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED, \
|
|
|
|
GetName().GetData(), \
|
2017-01-27 15:56:36 +00:00
|
|
|
wxString::FromUTF8( aCaller ).GetData() ) );
|
|
|
|
|
|
|
|
|
2023-12-27 16:34:59 +00:00
|
|
|
const IO_BASE::IO_FILE_DESC SCH_IO::GetSchematicFileDesc() const
|
2023-08-26 19:28:53 +00:00
|
|
|
{
|
2023-12-27 16:34:59 +00:00
|
|
|
return IO_BASE::IO_FILE_DESC( wxEmptyString, {} );
|
2023-08-26 19:28:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-12-19 17:39:26 +00:00
|
|
|
bool SCH_IO::CanReadSchematicFile( const wxString& aFileName ) const
|
2023-08-26 19:28:53 +00:00
|
|
|
{
|
|
|
|
const std::vector<std::string>& exts = GetSchematicFileDesc().m_FileExtensions;
|
|
|
|
|
|
|
|
wxString fileExt = wxFileName( aFileName ).GetExt().MakeLower();
|
|
|
|
|
|
|
|
for( const std::string& ext : exts )
|
|
|
|
{
|
|
|
|
if( fileExt == wxString( ext ).Lower() )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-12-19 17:39:26 +00:00
|
|
|
void SCH_IO::SaveLibrary( const wxString& aFileName, const STRING_UTF8_MAP* aProperties )
|
2017-01-27 15:56:36 +00:00
|
|
|
{
|
2023-04-11 08:53:35 +00:00
|
|
|
NOT_IMPLEMENTED( __FUNCTION__ );
|
2017-01-27 15:56:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-12-19 17:39:26 +00:00
|
|
|
SCH_SHEET* SCH_IO::LoadSchematicFile( const wxString& aFileName, SCHEMATIC* aSchematic,
|
2023-08-26 19:28:53 +00:00
|
|
|
SCH_SHEET* aAppendToMe, const STRING_UTF8_MAP* aProperties )
|
2016-07-06 09:22:56 +00:00
|
|
|
{
|
2023-04-11 08:53:35 +00:00
|
|
|
NOT_IMPLEMENTED( __FUNCTION__ );
|
2016-07-06 09:22:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-12-19 17:39:26 +00:00
|
|
|
void SCH_IO::SaveSchematicFile( const wxString& aFileName, SCH_SHEET* aSheet, SCHEMATIC* aSchematic,
|
2024-01-26 13:59:07 +00:00
|
|
|
const STRING_UTF8_MAP* aProperties )
|
2016-07-06 09:22:56 +00:00
|
|
|
{
|
2023-12-19 17:39:26 +00:00
|
|
|
// not pure virtual so that plugins only have to implement subset of the SCH_IO interface.
|
2023-04-11 08:53:35 +00:00
|
|
|
NOT_IMPLEMENTED( __FUNCTION__ );
|
2016-07-06 09:22:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-12-19 17:39:26 +00:00
|
|
|
void SCH_IO::EnumerateSymbolLib( wxArrayString& aAliasNameList,
|
2024-01-26 13:59:07 +00:00
|
|
|
const wxString& aLibraryPath,
|
|
|
|
const STRING_UTF8_MAP* aProperties )
|
2016-07-06 09:22:56 +00:00
|
|
|
{
|
2023-12-19 17:39:26 +00:00
|
|
|
// not pure virtual so that plugins only have to implement subset of the SCH_IO interface.
|
2023-04-11 08:53:35 +00:00
|
|
|
NOT_IMPLEMENTED( __FUNCTION__ );
|
2016-07-06 09:22:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-12-19 17:39:26 +00:00
|
|
|
void SCH_IO::EnumerateSymbolLib( std::vector<LIB_SYMBOL*>& aSymbolList,
|
2024-01-26 13:59:07 +00:00
|
|
|
const wxString& aLibraryPath,
|
|
|
|
const STRING_UTF8_MAP* aProperties )
|
2017-02-24 16:09:27 +00:00
|
|
|
{
|
2023-12-19 17:39:26 +00:00
|
|
|
// not pure virtual so that plugins only have to implement subset of the SCH_IO interface.
|
2023-04-11 08:53:35 +00:00
|
|
|
NOT_IMPLEMENTED( __FUNCTION__ );
|
2017-02-24 16:09:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-12-19 17:39:26 +00:00
|
|
|
LIB_SYMBOL* SCH_IO::LoadSymbol( const wxString& aLibraryPath, const wxString& aSymbolName,
|
2024-01-26 13:59:07 +00:00
|
|
|
const STRING_UTF8_MAP* aProperties )
|
2016-07-06 09:22:56 +00:00
|
|
|
{
|
2023-12-19 17:39:26 +00:00
|
|
|
// not pure virtual so that plugins only have to implement subset of the SCH_IO interface.
|
2023-04-11 08:53:35 +00:00
|
|
|
NOT_IMPLEMENTED( __FUNCTION__ );
|
2016-07-06 09:22:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-12-19 17:39:26 +00:00
|
|
|
void SCH_IO::SaveSymbol( const wxString& aLibraryPath, const LIB_SYMBOL* aSymbol,
|
2024-01-26 13:59:07 +00:00
|
|
|
const STRING_UTF8_MAP* aProperties )
|
2016-07-06 09:22:56 +00:00
|
|
|
{
|
2023-12-19 17:39:26 +00:00
|
|
|
// not pure virtual so that plugins only have to implement subset of the SCH_IO interface.
|
2023-04-11 08:53:35 +00:00
|
|
|
NOT_IMPLEMENTED( __FUNCTION__ );
|
2016-07-06 09:22:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-12-19 17:39:26 +00:00
|
|
|
void SCH_IO::DeleteSymbol( const wxString& aLibraryPath, const wxString& aSymbolName,
|
2024-01-26 13:59:07 +00:00
|
|
|
const STRING_UTF8_MAP* aProperties )
|
2016-07-06 09:22:56 +00:00
|
|
|
{
|
2023-12-19 17:39:26 +00:00
|
|
|
// not pure virtual so that plugins only have to implement subset of the SCH_IO interface.
|
2023-04-11 08:53:35 +00:00
|
|
|
NOT_IMPLEMENTED( __FUNCTION__ );
|
2016-07-06 09:22:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-12-27 00:25:41 +00:00
|
|
|
void SCH_IO::GetLibraryOptions( STRING_UTF8_MAP* aListToAppendTo ) const
|
2016-07-06 09:22:56 +00:00
|
|
|
{
|
2023-12-27 00:25:41 +00:00
|
|
|
// Get base options first
|
|
|
|
IO_BASE::GetLibraryOptions( aListToAppendTo );
|
2016-07-06 09:22:56 +00:00
|
|
|
|
2023-05-28 20:09:20 +00:00
|
|
|
// Empty for most plugins
|
|
|
|
//
|
|
|
|
// To add a new option override and use example code below:
|
|
|
|
//
|
|
|
|
//(*aListToAppendTo)["new_option_name"] = UTF8( _(
|
|
|
|
// "A nice descrtiption with possibility for <b>bold</b> and other formatting."
|
|
|
|
// ) );
|
2016-07-06 09:22:56 +00:00
|
|
|
}
|
2017-06-21 12:41:00 +00:00
|
|
|
|
|
|
|
|
2023-12-19 17:39:26 +00:00
|
|
|
const wxString& SCH_IO::GetError() const
|
2017-06-21 12:41:00 +00:00
|
|
|
{
|
2023-12-19 17:39:26 +00:00
|
|
|
// not pure virtual so that plugins only have to implement subset of the SCH_IO interface.
|
2023-04-11 08:53:35 +00:00
|
|
|
NOT_IMPLEMENTED( __FUNCTION__ );
|
2017-06-21 12:41:00 +00:00
|
|
|
}
|