2020-07-01 22:30:40 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020 BeagleBoard Foundation
|
2023-03-30 11:49:23 +00:00
|
|
|
* Copyright (C) 2020-2023 KiCad Developers, see AUTHORS.TXT for contributors.
|
2020-07-01 22:30:40 +00:00
|
|
|
*
|
|
|
|
* 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-3.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 3 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2021-02-26 13:49:40 +00:00
|
|
|
* @brief Pcbnew PLUGIN for FABMASTER ASCII *.txt / *.fab format.
|
2020-07-01 22:30:40 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "fabmaster_plugin.h"
|
|
|
|
#include <board.h>
|
2021-08-14 20:05:21 +00:00
|
|
|
#include <progress_reporter.h>
|
2020-07-01 22:30:40 +00:00
|
|
|
#include <common.h>
|
|
|
|
#include <macros.h>
|
|
|
|
|
|
|
|
|
|
|
|
FABMASTER_PLUGIN::FABMASTER_PLUGIN()
|
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
m_board = nullptr;
|
|
|
|
m_props = nullptr;
|
2020-07-01 22:30:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FABMASTER_PLUGIN::~FABMASTER_PLUGIN()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const wxString FABMASTER_PLUGIN::PluginName() const
|
|
|
|
{
|
|
|
|
return wxT( "Fabmaster" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const wxString FABMASTER_PLUGIN::GetFileExtension() const
|
|
|
|
{
|
|
|
|
return wxT( "txt" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOARD* FABMASTER_PLUGIN::Load( const wxString &aFileName, BOARD *aAppendToMe,
|
2022-11-06 16:51:52 +00:00
|
|
|
const STRING_UTF8_MAP* aProperties, PROJECT *aProject,
|
2021-06-23 22:53:08 +00:00
|
|
|
PROGRESS_REPORTER* aProgressReporter )
|
2020-07-01 22:30:40 +00:00
|
|
|
{
|
|
|
|
m_props = aProperties;
|
|
|
|
|
|
|
|
m_board = aAppendToMe ? aAppendToMe : new BOARD();
|
|
|
|
|
|
|
|
// Give the filename to the board if it's new
|
|
|
|
if( !aAppendToMe )
|
|
|
|
m_board->SetFileName( aFileName );
|
|
|
|
|
2021-06-23 23:21:11 +00:00
|
|
|
if( aProgressReporter )
|
|
|
|
{
|
|
|
|
aProgressReporter->Report( wxString::Format( _( "Loading %s..." ), aFileName ) );
|
|
|
|
|
|
|
|
if( !aProgressReporter->KeepRefreshing() )
|
2022-02-05 02:06:25 +00:00
|
|
|
THROW_IO_ERROR( _( "Open cancelled by user." ) );
|
2021-06-23 23:21:11 +00:00
|
|
|
}
|
|
|
|
|
2020-07-01 22:30:40 +00:00
|
|
|
if( !m_fabmaster.Read( aFileName.ToStdString() ) )
|
|
|
|
{
|
2021-01-18 18:12:45 +00:00
|
|
|
std::string readerr;
|
2020-07-01 22:30:40 +00:00
|
|
|
|
|
|
|
readerr = _( "Could not read file " ) + aFileName.ToStdString();
|
|
|
|
THROW_IO_ERROR( readerr );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_fabmaster.Process();
|
2021-06-23 23:21:11 +00:00
|
|
|
m_fabmaster.LoadBoard( m_board, aProgressReporter );
|
|
|
|
|
2020-07-01 22:30:40 +00:00
|
|
|
return m_board;
|
|
|
|
}
|