KiCad PCB EDA Suite
Loading...
Searching...
No Matches
fabmaster_plugin.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2020 BeagleBoard Foundation
5 * Copyright (C) 2020-2023 KiCad Developers, see AUTHORS.TXT for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-3.0.html
20 * or you may search the http://www.gnu.org website for the version 3 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
29#include "fabmaster_plugin.h"
30#include <board.h>
31#include <progress_reporter.h>
32#include <common.h>
33#include <macros.h>
34
35
37{
38 m_board = nullptr;
39 m_props = nullptr;
40}
41
42
44{
45}
46
47
48const wxString FABMASTER_PLUGIN::PluginName() const
49{
50 return wxT( "Fabmaster" );
51}
52
53
55{
56 return PLUGIN_FILE_DESC( _HKI( "Fabmaster PCB files" ), { "txt", "fab" } );
57}
58
59
60BOARD* FABMASTER_PLUGIN::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
61 const STRING_UTF8_MAP* aProperties, PROJECT* aProject,
62 PROGRESS_REPORTER* aProgressReporter )
63{
64 m_props = aProperties;
65
66 m_board = aAppendToMe ? aAppendToMe : new BOARD();
67
68 // Give the filename to the board if it's new
69 if( !aAppendToMe )
70 m_board->SetFileName( aFileName );
71
72 if( aProgressReporter )
73 {
74 aProgressReporter->Report( wxString::Format( _( "Loading %s..." ), aFileName ) );
75
76 if( !aProgressReporter->KeepRefreshing() )
77 THROW_IO_ERROR( _( "Open cancelled by user." ) );
78 }
79
80 if( !m_fabmaster.Read( aFileName.ToStdString() ) )
81 {
82 std::string readerr;
83
84 readerr = _( "Could not read file " ) + aFileName.ToStdString();
85 THROW_IO_ERROR( readerr );
86 }
87
89 m_fabmaster.LoadBoard( m_board, aProgressReporter );
90
91 return m_board;
92}
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:276
void SetFileName(const wxString &aFileName)
Definition: board.h:311
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const STRING_UTF8_MAP *aProperties=nullptr, PROJECT *aProject=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr) override
Load information from some input file format that this PLUGIN implementation knows about into either ...
PLUGIN_FILE_DESC GetBoardFileDesc() const override
Returns board file description for the PLUGIN.
const wxString PluginName() const override
Return a brief hard coded name for this PLUGIN.
const STRING_UTF8_MAP * m_props
FABMASTER_PLUGIN()
Pcbnew PLUGIN for FABMASTER ASCII *.txt / *.fab format.
bool Read(const std::string &aFile)
bool LoadBoard(BOARD *aBoard, PROGRESS_REPORTER *aProgressReporter)
A progress reporter interface for use in multi-threaded environments.
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
virtual void Report(const wxString &aMessage)=0
Display aMessage in the progress bar dialog.
Container for project specific data.
Definition: project.h:62
A name/value tuple with unique names and optional values.
The common library.
#define _HKI(x)
#define _(s)
Pcbnew PLUGIN for Fabmaster (Allegro) ASCII format.
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:39
This file contains miscellaneous commonly used macros and functions.
Container that describes file type info.