2020-07-12 16:58:35 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2020-09-06 17:00:02 +00:00
|
|
|
* Copyright (C) 2020 Roberto Fernandez Bautista <roberto.fer.bau@gmail.com>
|
2023-08-13 02:26:06 +00:00
|
|
|
* Copyright (C) 2020-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2020-07-12 16:58:35 +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 3 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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CADSTAR_ARCHIVE_PLUGIN_H_
|
|
|
|
#define CADSTAR_ARCHIVE_PLUGIN_H_
|
|
|
|
|
2023-12-19 17:39:26 +00:00
|
|
|
#include <pcb_io/pcb_io.h>
|
|
|
|
#include <pcb_io/pcb_io_mgr.h>
|
|
|
|
#include <pcb_io/common/plugin_common_layer_mapping.h>
|
2021-07-29 09:47:43 +00:00
|
|
|
#include <layer_ids.h> // PCB_LAYER_ID
|
2020-10-01 22:47:38 +00:00
|
|
|
|
2023-03-16 21:07:04 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2020-10-01 22:47:38 +00:00
|
|
|
|
2023-12-24 01:21:58 +00:00
|
|
|
class PCB_IO_CADSTAR_ARCHIVE : public PCB_IO, public LAYER_REMAPPABLE_PLUGIN
|
2020-07-12 16:58:35 +00:00
|
|
|
{
|
|
|
|
public:
|
2023-12-27 16:34:59 +00:00
|
|
|
const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const override
|
2023-08-13 02:26:06 +00:00
|
|
|
{
|
2023-12-27 16:34:59 +00:00
|
|
|
return IO_BASE::IO_FILE_DESC( _HKI( "CADSTAR PCB Archive files" ), { "cpa" } );
|
2023-08-13 02:26:06 +00:00
|
|
|
}
|
2020-07-12 16:58:35 +00:00
|
|
|
|
2023-12-27 16:34:59 +00:00
|
|
|
const IO_BASE::IO_FILE_DESC GetLibraryDesc() const override { return GetBoardFileDesc(); }
|
2023-08-13 02:26:06 +00:00
|
|
|
|
|
|
|
bool CanReadBoard( const wxString& aFileName ) const override;
|
2023-12-27 00:25:41 +00:00
|
|
|
bool CanReadLibrary( const wxString& aFileName ) const override;
|
2023-08-13 02:26:06 +00:00
|
|
|
bool CanReadFootprint( const wxString& aFileName ) const override;
|
2020-07-12 16:58:35 +00:00
|
|
|
|
2023-08-13 02:11:58 +00:00
|
|
|
BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
|
2023-12-27 17:06:23 +00:00
|
|
|
const STRING_UTF8_MAP* aProperties = nullptr, PROJECT* aProject = nullptr ) override;
|
2020-07-12 16:58:35 +00:00
|
|
|
|
2021-01-31 21:55:51 +00:00
|
|
|
std::vector<FOOTPRINT*> GetImportedCachedLibraryFootprints() override;
|
|
|
|
|
2020-10-01 22:47:38 +00:00
|
|
|
/**
|
2020-12-18 15:40:13 +00:00
|
|
|
* Return the automapped layers.
|
|
|
|
*
|
2020-10-09 16:58:21 +00:00
|
|
|
* @param aInputLayerDescriptionVector
|
2020-10-01 22:47:38 +00:00
|
|
|
* @return Auto-mapped layers
|
|
|
|
*/
|
2020-10-09 16:58:21 +00:00
|
|
|
static std::map<wxString, PCB_LAYER_ID> DefaultLayerMappingCallback(
|
2020-10-01 22:47:38 +00:00
|
|
|
const std::vector<INPUT_LAYER_DESC>& aInputLayerDescriptionVector );
|
|
|
|
|
|
|
|
/**
|
2020-12-18 15:40:13 +00:00
|
|
|
* Register a different handler to be called when mapping of Cadstar to KiCad layers occurs.
|
|
|
|
*
|
2020-10-09 16:58:21 +00:00
|
|
|
* @param aLayerMappingHandler
|
2020-10-01 22:47:38 +00:00
|
|
|
*/
|
2020-10-09 16:58:21 +00:00
|
|
|
void RegisterLayerMappingCallback( LAYER_MAPPING_HANDLER aLayerMappingHandler ) override;
|
2020-10-01 22:47:38 +00:00
|
|
|
|
2023-03-13 21:21:24 +00:00
|
|
|
void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
|
|
|
|
bool aBestEfforts, const STRING_UTF8_MAP* aProperties = nullptr ) override;
|
|
|
|
|
2023-08-28 20:38:46 +00:00
|
|
|
// default implementation of GetEnumeratedFootprint is fine (call FootprintLoad)
|
2023-03-13 21:21:24 +00:00
|
|
|
|
|
|
|
bool FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName,
|
|
|
|
const STRING_UTF8_MAP* aProperties = nullptr ) override;
|
|
|
|
|
|
|
|
FOOTPRINT* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
|
|
|
|
bool aKeepUUID = false,
|
|
|
|
const STRING_UTF8_MAP* aProperties = nullptr ) override;
|
|
|
|
|
|
|
|
long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CADSTAR Plugin is read-only
|
|
|
|
* @return Always false
|
|
|
|
*/
|
2023-12-27 00:25:41 +00:00
|
|
|
bool IsLibraryWritable( const wxString& aLibraryPath ) override { return false; }
|
2023-03-13 21:21:24 +00:00
|
|
|
|
2023-12-24 01:21:58 +00:00
|
|
|
PCB_IO_CADSTAR_ARCHIVE();
|
|
|
|
~PCB_IO_CADSTAR_ARCHIVE();
|
2020-07-12 16:58:35 +00:00
|
|
|
|
|
|
|
private:
|
2021-01-31 21:55:51 +00:00
|
|
|
void clearLoadedFootprints();
|
2023-03-13 21:21:24 +00:00
|
|
|
void ensureLoadedLibrary( const wxString& aLibraryPath );
|
|
|
|
|
|
|
|
typedef std::map<const wxString, std::unique_ptr<FOOTPRINT>> NAME_TO_FOOTPRINT_MAP;
|
|
|
|
|
|
|
|
std::map<wxString, NAME_TO_FOOTPRINT_MAP> m_cache;
|
|
|
|
std::map<wxString, long long> m_timestamps;
|
2021-01-31 21:55:51 +00:00
|
|
|
|
|
|
|
std::vector<FOOTPRINT*> m_loaded_footprints;
|
|
|
|
bool m_show_layer_mapping_warnings;
|
2023-08-13 02:26:06 +00:00
|
|
|
|
|
|
|
bool checkBoardHeader( const wxString& aFileName ) const;
|
2020-07-12 16:58:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CADSTAR_ARCHIVE_PLUGIN_H_
|