diff --git a/3d-viewer/3d_rendering/opengl/layer_triangles.cpp b/3d-viewer/3d_rendering/opengl/layer_triangles.cpp index 505067e2ad..0112913284 100644 --- a/3d-viewer/3d_rendering/opengl/layer_triangles.cpp +++ b/3d-viewer/3d_rendering/opengl/layer_triangles.cpp @@ -588,7 +588,7 @@ void OPENGL_RENDER_LIST::DrawAllCameraCulledSubtractLayer( bool aDrawMiddle, void OPENGL_RENDER_LIST::ApplyScalePosition( float aZposition, float aZscale ) { - wxASSERT( aZscale > FLT_EPSILON ); + wxCHECK2( aZscale > FLT_EPSILON, aZscale = FLT_EPSILON + 1 ); m_zPositionTransformation = aZposition; m_zScaleTransformation = aZscale; diff --git a/common/wildcards_and_files_ext.cpp b/common/wildcards_and_files_ext.cpp index ce5694592e..dfc2e858fe 100644 --- a/common/wildcards_and_files_ext.cpp +++ b/common/wildcards_and_files_ext.cpp @@ -366,6 +366,11 @@ wxString AltiumCircuitMakerPcbFileWildcard() return _( "Altium Circuit Maker PCB files" ) + AddFileExtListToFilter( { "CMPcbDoc" } ); } +wxString SolidworksPcbFileWildcard() +{ + return _( "Solidworks PCB files" ) + AddFileExtListToFilter( { "SWPcbDoc" } ); +} + wxString FabmasterPcbFileWildcard() { return _( "Fabmaster PCB files" ) + AddFileExtListToFilter( { "txt", "fab" } ); diff --git a/include/wildcards_and_files_ext.h b/include/wildcards_and_files_ext.h index 3ee1872dd0..6d06c12521 100644 --- a/include/wildcards_and_files_ext.h +++ b/include/wildcards_and_files_ext.h @@ -227,6 +227,7 @@ extern wxString CadstarPcbArchiveFileWildcard(); extern wxString AltiumDesignerPcbFileWildcard(); extern wxString AltiumCircuitStudioPcbFileWildcard(); extern wxString AltiumCircuitMakerPcbFileWildcard(); +extern wxString SolidworksPcbFileWildcard(); extern wxString FabmasterPcbFileWildcard(); extern wxString PdfFileWildcard(); extern wxString PSFileWildcard(); diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index eb0e0c9def..198aef057c 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -117,6 +117,9 @@ bool AskLoadBoardFileName( PCB_EDIT_FRAME* aParent, int* aCtl, wxString* aFileNa // Import Altium Designer board files. { AltiumDesignerPcbFileWildcard(), IO_MGR::ALTIUM_DESIGNER }, + // Import Solidworks PCB (based on Altium) board files. + { SolidworksPcbFileWildcard(), IO_MGR::SOLIDWORKS_PCB }, + // Import Cadstar PCB Archive board files. { CadstarPcbArchiveFileWildcard(), IO_MGR::CADSTAR_PCB_ARCHIVE }, diff --git a/pcbnew/io_mgr.cpp b/pcbnew/io_mgr.cpp index 195ad59a65..80eb885429 100644 --- a/pcbnew/io_mgr.cpp +++ b/pcbnew/io_mgr.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -206,6 +207,9 @@ static IO_MGR::REGISTER_PLUGIN registerAltiumCircuitStudioPlugin( IO_MGR::ALTIUM wxT( "Altium Circuit Studio" ), []() -> PLUGIN* { return new ALTIUM_CIRCUIT_STUDIO_PLUGIN; } ); static IO_MGR::REGISTER_PLUGIN registerAltiumCircuitMakerPlugin( IO_MGR::ALTIUM_CIRCUIT_MAKER, + wxT( "Solidworks PCB" ), + []() -> PLUGIN* { return new SOLIDWORKS_PCB_PLUGIN; } ); +static IO_MGR::REGISTER_PLUGIN registerSolidworksPCBPlugin( IO_MGR::SOLIDWORKS_PCB, wxT( "Altium Circuit Maker" ), []() -> PLUGIN* { return new ALTIUM_CIRCUIT_MAKER_PLUGIN; } ); static IO_MGR::REGISTER_PLUGIN registerCadstarArchivePlugin( IO_MGR::CADSTAR_PCB_ARCHIVE, diff --git a/pcbnew/io_mgr.h b/pcbnew/io_mgr.h index 12854c85c9..10b775fde5 100644 --- a/pcbnew/io_mgr.h +++ b/pcbnew/io_mgr.h @@ -60,6 +60,7 @@ public: ALTIUM_DESIGNER, ALTIUM_CIRCUIT_STUDIO, ALTIUM_CIRCUIT_MAKER, + SOLIDWORKS_PCB, CADSTAR_PCB_ARCHIVE, GEDA_PCB, ///< Geda PCB file formats. // add your type here. diff --git a/pcbnew/plugins/altium/CMakeLists.txt b/pcbnew/plugins/altium/CMakeLists.txt index a89fc05183..24c57a6f34 100644 --- a/pcbnew/plugins/altium/CMakeLists.txt +++ b/pcbnew/plugins/altium/CMakeLists.txt @@ -8,6 +8,7 @@ set( ALTIUM2PCBNEW_SRCS altium_parser_pcb.cpp altium_pcb.cpp altium_rule_transformer.cpp + solidworks_pcb_plugin.cpp ) add_library( altium2pcbnew STATIC ${ALTIUM2PCBNEW_SRCS} ) @@ -19,3 +20,7 @@ target_link_libraries( altium2pcbnew target_include_directories( altium2pcbnew PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ) + +target_include_directories( altium2pcbnew PRIVATE + $ + ) diff --git a/pcbnew/plugins/altium/altium_pcb.cpp b/pcbnew/plugins/altium/altium_pcb.cpp index 9290b9b7e1..44e8dbde65 100644 --- a/pcbnew/plugins/altium/altium_pcb.cpp +++ b/pcbnew/plugins/altium/altium_pcb.cpp @@ -50,6 +50,7 @@ #include #include #include +#include constexpr double BOLD_FACTOR = 1.75; // CSS font-weight-normal is 400; bold is 700 @@ -500,9 +501,14 @@ void ALTIUM_PCB::Parse( const ALTIUM_COMPOUND_FILE& altiumPcbFi const CFB::COMPOUND_FILE_ENTRY* file = altiumPcbFile.FindStream( mappedFile ); if( file != nullptr ) + { fp( altiumPcbFile, file ); + } else if( isRequired ) - wxLogError( _( "File not found: '%s'." ), FormatPath( mappedFile ) ); + { + wxLogError( _( "File not found: '%s' for directory '%s'." ), FormatPath( mappedFile ), + magic_enum::enum_name( directory ) ); + } } // fixup zone priorities since Altium stores them in the opposite order diff --git a/pcbnew/plugins/altium/solidworks_pcb_plugin.cpp b/pcbnew/plugins/altium/solidworks_pcb_plugin.cpp new file mode 100644 index 0000000000..5ce5d6f6fe --- /dev/null +++ b/pcbnew/plugins/altium/solidworks_pcb_plugin.cpp @@ -0,0 +1,135 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors. + * + * 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 . + */ + +#include + +#include +#include +#include "plugins/altium/altium_parser.h" + +#include + +#include +#include + +SOLIDWORKS_PCB_PLUGIN::SOLIDWORKS_PCB_PLUGIN() +{ + m_board = nullptr; + m_props = nullptr; +} + + +SOLIDWORKS_PCB_PLUGIN::~SOLIDWORKS_PCB_PLUGIN() +{ +} + + +const wxString SOLIDWORKS_PCB_PLUGIN::PluginName() const +{ + return wxT( "Solidworks PCB" ); +} + + +const wxString SOLIDWORKS_PCB_PLUGIN::GetFileExtension() const +{ + return wxT( "SWPcbDoc" ); +} + + +BOARD* SOLIDWORKS_PCB_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, + const STRING_UTF8_MAP* aProperties, PROJECT* aProject, + PROGRESS_REPORTER* aProgressReporter ) +{ + 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 ); + + // clang-format off + const std::map mapping = { + { ALTIUM_PCB_DIR::FILE_HEADER, "FileHeader" }, + { ALTIUM_PCB_DIR::ARCS6, "D2864697BB2D411B857EBD69D74447" }, + { ALTIUM_PCB_DIR::BOARD6, "21CE7E3D9BFF41679BACA1184CAF54" }, + { ALTIUM_PCB_DIR::BOARDREGIONS, "67075A4119214CE4AB174F9B1A9A41" }, + { ALTIUM_PCB_DIR::CLASSES6, "1122D4F14A924F9CA5C2060AF370E0" }, + { ALTIUM_PCB_DIR::COMPONENTS6, "208CAE8E44BD43D5B3CCA426D9331B" }, + { ALTIUM_PCB_DIR::COMPONENTBODIES6, "6DDF94E6CB364893BED31C189F9AF3" }, + { ALTIUM_PCB_DIR::DIMENSIONS6, "6148AE8C77B042798B46830E96BB24" }, + { ALTIUM_PCB_DIR::FILLS6, "5944DE0E258C41E2B0B382AC964048" }, + { ALTIUM_PCB_DIR::MODELS, "874F98A7E25A48EDAD394EB891E503" }, + { ALTIUM_PCB_DIR::NETS6, "0201837ACD434D55B34BBC68B75BAB" }, + { ALTIUM_PCB_DIR::PADS6, "E4D0C33E25824886ABC7FEEAE7B521" }, + { ALTIUM_PCB_DIR::POLYGONS6, "7ABD4252549749DD8DB16804819AC3" }, + { ALTIUM_PCB_DIR::REGIONS6, "6B3892541AB94CD999291D590B5C86" }, // probably wrong; in as a placeholder + { ALTIUM_PCB_DIR::RULES6, "7009830ADF65423FA6CCB73A77E710" }, + { ALTIUM_PCB_DIR::SHAPEBASEDREGIONS6, "91241C66300E4490965070BA56F6F7" }, + { ALTIUM_PCB_DIR::TEXTS6, "4AF3D139533041489C2A57BBF9890D" }, + { ALTIUM_PCB_DIR::TRACKS6, "5D0C6E18E16A4BBFAA256C24B79EAE" }, + { ALTIUM_PCB_DIR::VIAS6, "2AF5387F097242D3A1095B6FAC3397" }, + { ALTIUM_PCB_DIR::WIDESTRINGS6, "9B378679AF85466C8673A41EE46393" } + + /* + * Understood but not needed: + * 04A8F96E0E4C478C813AE57CACCD0F - Legacy text storage + * 01F1BD1AA06E4D6A9D1ABF0BBFF4A4 - Fwd/Back compatibility messages + * + * Not yet used by KiCad: + * 7C01505E39124E67BCCAB1883B8FB7 - Design Rule Checker Options6 + * 63B31A3709B54882BFA96424906BE8 - EmbeddedFonts6 + * 8B83C7E94C1D419B9B2D5505479820 - Pin Swap Options6 + * F78C10230A794F5C93ACB50AC693B2 - Advanced Placer Options6 + * + * No data yet on: + * 1C0DB1ED572645BEB65D029D20406C + * 2AA5C1C72BF14315A47DD931B84A79 + * 6468C28D32CC4867AB374091CC8431 + * 6B3892541AB94CD999291D590B5C86 + * 8675F4105E444E6D9B2BEE6273769D + * B983FCC2B6DE46E0B94006B6393235 + * D6551D22B6DB44659C3F32F7E1949D + * + * Not yet identified: + * D06DD2E4A51C4A3EA96D9ED8C8F3F3 + * F9C465994DE840579ED19E820C19C2 + * + * Region-like objects that don't map cleanly (maybe Solidworks sketches?) + * 84958494F3F54075975C4E199DB8EB + * 2E731D36D1F049428744F0661F3E44 + */ + }; + // clang-format on + + ALTIUM_COMPOUND_FILE altiumPcbFile( aFileName ); + + try + { + // Parse File + ALTIUM_PCB pcb( m_board, aProgressReporter ); + pcb.Parse( altiumPcbFile, mapping ); + } + catch( CFB::CFBException& exception ) + { + THROW_IO_ERROR( exception.what() ); + } + + return m_board; +} diff --git a/pcbnew/plugins/altium/solidworks_pcb_plugin.h b/pcbnew/plugins/altium/solidworks_pcb_plugin.h new file mode 100644 index 0000000000..39aaa93bbc --- /dev/null +++ b/pcbnew/plugins/altium/solidworks_pcb_plugin.h @@ -0,0 +1,52 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors. + * + * 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 . + */ + +#ifndef KICAD_SOLIDWORKS_PCB_PLUGIN_H +#define KICAD_SOLIDWORKS_PCB_PLUGIN_H + + +#include + +class SOLIDWORKS_PCB_PLUGIN : public PLUGIN +{ +public: + const wxString PluginName() const override; + + BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe, const STRING_UTF8_MAP* aProperties, + PROJECT* aProject = nullptr, + PROGRESS_REPORTER* aProgressReporter = nullptr ) override; + + const wxString GetFileExtension() const override; + + long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override + { + return 0; + } + + SOLIDWORKS_PCB_PLUGIN(); + ~SOLIDWORKS_PCB_PLUGIN(); + +private: + const STRING_UTF8_MAP* m_props; + BOARD* m_board; +}; + + + +#endif //KICAD_SOLIDWORKS_PCB_PLUGIN_H