2020-09-08 19:51:22 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2021-01-31 20:47:36 +00:00
|
|
|
* Copyright (C) 2020-2021 Roberto Fernandez Bautista <roberto.fer.bau@gmail.com>
|
|
|
|
* Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2020-09-08 19:51:22 +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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file cadstar_sch_archive_loader.h
|
|
|
|
* @brief Loads a csa file into a KiCad SCHEMATIC object
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CADSTAR_SCH_ARCHIVE_LOADER_H_
|
|
|
|
#define CADSTAR_SCH_ARCHIVE_LOADER_H_
|
|
|
|
|
2023-12-19 17:39:26 +00:00
|
|
|
#include <sch_io/cadstar/cadstar_sch_archive_parser.h>
|
2020-09-08 19:51:22 +00:00
|
|
|
|
2021-08-18 20:38:14 +00:00
|
|
|
#include <layer_ids.h> // SCH_LAYER_ID
|
2023-11-25 13:05:45 +00:00
|
|
|
#include <plotters/plotter.h> // LINE_STYLE
|
2021-08-18 20:38:14 +00:00
|
|
|
#include <pin_type.h> // ELECTRICAL_PINTYPE
|
2023-03-05 14:54:36 +00:00
|
|
|
|
2023-03-16 20:17:40 +00:00
|
|
|
#include <memory>
|
2023-03-05 14:54:36 +00:00
|
|
|
#include <map>
|
|
|
|
|
2020-10-24 14:45:37 +00:00
|
|
|
#include <wx/filename.h>
|
2023-03-05 14:54:36 +00:00
|
|
|
#include <wx/string.h>
|
2020-09-20 21:08:46 +00:00
|
|
|
|
2023-03-16 20:17:40 +00:00
|
|
|
struct CADSTAR_PART_ENTRY;
|
2020-11-26 18:11:06 +00:00
|
|
|
class BUS_ALIAS;
|
2020-09-20 21:08:46 +00:00
|
|
|
class EDA_TEXT;
|
2023-09-07 16:09:53 +00:00
|
|
|
class SPIN_STYLE;
|
2021-06-10 18:51:46 +00:00
|
|
|
class LIB_SYMBOL;
|
2023-03-05 14:54:36 +00:00
|
|
|
class REPORTER;
|
2021-06-10 14:10:55 +00:00
|
|
|
class SCH_SYMBOL;
|
2020-09-27 02:35:24 +00:00
|
|
|
class SCH_ITEM;
|
2020-09-20 21:08:46 +00:00
|
|
|
class SCH_FIELD;
|
2020-09-23 20:39:11 +00:00
|
|
|
class SCH_GLOBALLABEL;
|
|
|
|
class SCH_HIERLABEL;
|
|
|
|
class SCH_SHEET;
|
2020-11-22 19:55:21 +00:00
|
|
|
class SCH_SHEET_PATH;
|
2020-09-27 02:35:24 +00:00
|
|
|
class SCH_TEXT;
|
2020-09-20 21:08:46 +00:00
|
|
|
class SCHEMATIC;
|
2020-09-08 19:51:22 +00:00
|
|
|
|
|
|
|
class CADSTAR_SCH_ARCHIVE_LOADER : public CADSTAR_SCH_ARCHIVE_PARSER
|
|
|
|
{
|
|
|
|
public:
|
2021-09-01 19:12:56 +00:00
|
|
|
// Size of tiny net labels when none present in original design
|
|
|
|
const int SMALL_LABEL_SIZE = KiROUND( (double) SCH_IU_PER_MM * 0.4 );
|
2023-01-10 21:25:28 +00:00
|
|
|
const double ARC_ACCURACY = SCH_IU_PER_MM * 0.01; // 0.01mm
|
2021-09-01 19:12:56 +00:00
|
|
|
|
2024-05-03 16:35:47 +00:00
|
|
|
explicit CADSTAR_SCH_ARCHIVE_LOADER( const wxString& aFilename, REPORTER* aReporter,
|
2021-09-09 21:15:38 +00:00
|
|
|
PROGRESS_REPORTER* aProgressReporter ) :
|
|
|
|
CADSTAR_SCH_ARCHIVE_PARSER( aFilename )
|
2020-09-08 19:51:22 +00:00
|
|
|
{
|
2021-09-09 21:15:38 +00:00
|
|
|
m_schematic = nullptr;
|
|
|
|
m_rootSheet = nullptr;
|
2021-02-13 20:00:17 +00:00
|
|
|
m_designCenter.x = 0;
|
|
|
|
m_designCenter.y = 0;
|
2021-09-09 21:15:38 +00:00
|
|
|
m_reporter = aReporter;
|
|
|
|
m_progressReporter = aProgressReporter;
|
2024-05-09 14:23:28 +00:00
|
|
|
m_fileName = aFilename;
|
2023-03-07 21:38:15 +00:00
|
|
|
|
|
|
|
// Assume that the PCB footprint library name will be the same as the schematic filename
|
|
|
|
wxFileName schFilename( Filename );
|
|
|
|
m_footprintLibName = schFilename.GetName();
|
2020-09-08 19:51:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
~CADSTAR_SCH_ARCHIVE_LOADER()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-03-07 21:38:15 +00:00
|
|
|
std::vector<LIB_SYMBOL*> LoadPartsLib( const wxString& aFilename );
|
|
|
|
|
2023-02-26 16:27:25 +00:00
|
|
|
const std::vector<LIB_SYMBOL*>& GetLoadedSymbols() const { return m_loadedSymbols; }
|
|
|
|
|
2023-03-07 21:38:15 +00:00
|
|
|
void SetFpLibName( const wxString& aLibName ) { m_footprintLibName = aLibName; };
|
|
|
|
|
|
|
|
|
2020-09-08 19:51:22 +00:00
|
|
|
/**
|
2023-02-26 16:27:25 +00:00
|
|
|
* @brief Loads a CADSTAR Schematic Archive file into the KiCad SCHEMATIC object given
|
2020-10-24 14:45:37 +00:00
|
|
|
* @param aSchematic Schematic to add the design onto
|
|
|
|
* @param aRootSheet Root sheet to add the design onto
|
2020-09-08 19:51:22 +00:00
|
|
|
*/
|
2023-02-26 16:27:25 +00:00
|
|
|
void Load( SCHEMATIC* aSchematic, SCH_SHEET* aRootSheet );
|
2020-09-08 19:51:22 +00:00
|
|
|
|
2024-05-09 14:23:28 +00:00
|
|
|
static wxString CreateLibName( const wxFileName& aFileName, const SCH_SHEET* aRootSheet );
|
2020-09-08 19:51:22 +00:00
|
|
|
|
|
|
|
private:
|
2020-09-23 20:39:11 +00:00
|
|
|
typedef std::pair<BLOCK_ID, TERMINAL_ID> BLOCK_PIN_ID;
|
2021-03-28 18:47:48 +00:00
|
|
|
typedef std::pair<PART_ID, GATE_ID> PART_GATE_ID;
|
2021-02-13 20:00:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Map between a terminal ID in a symbol definition to the pin number that should
|
|
|
|
* be imported into KiCad.
|
|
|
|
*/
|
2023-03-05 22:21:48 +00:00
|
|
|
typedef std::map<TERMINAL_ID, wxString> TERMINAL_TO_PINNUM_MAP;
|
|
|
|
|
|
|
|
typedef std::map<wxString, TERMINAL_ID> PINNUM_TO_TERMINAL_MAP;
|
2020-09-23 20:39:11 +00:00
|
|
|
|
2023-03-07 21:38:15 +00:00
|
|
|
REPORTER* m_reporter;
|
|
|
|
SCHEMATIC* m_schematic;
|
|
|
|
SCH_SHEET* m_rootSheet;
|
2024-05-09 14:23:28 +00:00
|
|
|
wxFileName m_fileName;
|
2023-03-07 21:38:15 +00:00
|
|
|
wxString m_footprintLibName; ///< Name of the footprint library to prepend all footprints with
|
2023-03-05 14:54:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Required for calculating the offset to apply to the Cadstar design so that it fits
|
|
|
|
* in the KiCad canvas
|
|
|
|
*/
|
|
|
|
VECTOR2I m_designCenter;
|
|
|
|
|
|
|
|
std::map<LAYER_ID, SCH_SHEET*> m_sheetMap; ///< Cadstar->KiCad Sheets
|
|
|
|
std::map<BLOCK_PIN_ID, SCH_HIERLABEL*> m_sheetPinMap; ///< Cadstar->KiCad Sheet Pins
|
|
|
|
std::map<PART_ID, LIB_SYMBOL*> m_partMap; ///< Cadstar->KiCad Parts
|
2023-03-05 22:21:48 +00:00
|
|
|
std::map<SYMBOL_ID, SCH_SYMBOL*> m_powerSymMap; ///< Cadstar->KiCad Power Symbols
|
2023-03-05 14:54:36 +00:00
|
|
|
std::map<wxString, LIB_SYMBOL*> m_powerSymLibMap; ///< NetName->KiCad Power Lib Symbol
|
|
|
|
std::map<SYMBOL_ID, SCH_GLOBALLABEL*> m_globalLabelsMap; ///< Cadstar->KiCad Global Labels
|
|
|
|
std::map<BUS_ID, std::shared_ptr<BUS_ALIAS>> m_busesMap; ///< Cadstar->KiCad Buses
|
|
|
|
std::map<PART_ID, TERMINAL_TO_PINNUM_MAP> m_pinNumsMap; ///< Cadstar Part->KiCad Pin number map
|
2023-03-05 22:21:48 +00:00
|
|
|
std::map<SYMDEF_ID, PINNUM_TO_TERMINAL_MAP> m_symDefTerminalsMap;
|
|
|
|
|
2023-03-12 19:15:04 +00:00
|
|
|
/**
|
|
|
|
* Cache storing symbol names and alternates to symdef IDs
|
|
|
|
*/
|
|
|
|
std::map<std::pair<wxString, wxString>, SYMDEF_ID> m_SymDefNamesCache;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Cache storing symbol names (default alternate) to symdef IDs
|
|
|
|
*/
|
|
|
|
std::map<wxString, SYMDEF_ID> m_DefaultSymDefNamesCache;
|
|
|
|
|
2023-03-05 22:21:48 +00:00
|
|
|
/**
|
|
|
|
* Cadstar->KiCad Lib Symbols loaded so far. Note that in CADSTAR each symbol represents just a
|
|
|
|
* gate, so the LIB_SYMBOLs contained here are not imported directly - they are just an interim
|
|
|
|
* step.
|
|
|
|
*/
|
|
|
|
std::map<SYMDEF_ID, std::unique_ptr<const LIB_SYMBOL>> m_symDefMap;
|
2023-03-05 14:54:36 +00:00
|
|
|
|
2023-02-26 16:27:25 +00:00
|
|
|
std::vector<LIB_SYMBOL*> m_loadedSymbols; ///< Loaded symbols so far
|
2021-03-28 18:47:48 +00:00
|
|
|
std::map<PART_GATE_ID, SYMDEF_ID> m_partSymbolsMap; ///< Map holding the symbols loaded so far
|
|
|
|
/// for a particular PART_ID and GATE_ID
|
2020-09-19 22:05:02 +00:00
|
|
|
|
|
|
|
void loadSheets();
|
2020-09-23 20:39:11 +00:00
|
|
|
void loadHierarchicalSheetPins();
|
2020-09-20 21:08:46 +00:00
|
|
|
void loadPartsLibrary();
|
|
|
|
void loadSchematicSymbolInstances();
|
2020-09-26 13:27:03 +00:00
|
|
|
void loadBusses();
|
2020-09-23 20:39:11 +00:00
|
|
|
void loadNets();
|
2020-09-26 18:23:13 +00:00
|
|
|
void loadFigures();
|
2020-09-27 02:35:24 +00:00
|
|
|
void loadTexts();
|
2020-09-27 12:19:51 +00:00
|
|
|
void loadDocumentationSymbols();
|
2020-12-13 17:28:00 +00:00
|
|
|
void loadTextVariables();
|
2020-09-19 22:05:02 +00:00
|
|
|
|
2023-03-07 21:38:15 +00:00
|
|
|
std::unique_ptr<LIB_SYMBOL> loadLibPart( const CADSTAR_PART_ENTRY& aPart );
|
|
|
|
|
|
|
|
void copySymbolItems( std::unique_ptr<LIB_SYMBOL>& aSourceSym,
|
|
|
|
std::unique_ptr<LIB_SYMBOL>& aDestSym, int aDestUnit,
|
|
|
|
bool aOverrideFields = true );
|
|
|
|
|
2020-09-20 21:08:46 +00:00
|
|
|
//Helper Functions for loading sheets
|
2024-05-03 16:35:47 +00:00
|
|
|
void loadSheetAndChildSheets( const LAYER_ID& aCadstarSheetID, const VECTOR2I& aPosition,
|
|
|
|
const VECTOR2I& aSheetSize, const SCH_SHEET_PATH& aParentSheet );
|
2020-09-27 12:19:51 +00:00
|
|
|
|
2024-05-03 16:35:47 +00:00
|
|
|
void loadChildSheets( const LAYER_ID& aCadstarSheetID, const SCH_SHEET_PATH& aSheet );
|
2020-09-27 12:19:51 +00:00
|
|
|
|
2020-09-19 22:05:02 +00:00
|
|
|
std::vector<LAYER_ID> findOrphanSheets();
|
2020-09-27 12:19:51 +00:00
|
|
|
|
2024-05-03 16:35:47 +00:00
|
|
|
int getSheetNumber( const LAYER_ID& aCadstarSheetID );
|
2020-09-27 12:19:51 +00:00
|
|
|
|
2024-05-03 16:35:47 +00:00
|
|
|
void loadItemOntoKiCadSheet( const LAYER_ID& aCadstarSheetID, SCH_ITEM* aItem );
|
2020-09-19 22:05:02 +00:00
|
|
|
|
2020-09-23 20:39:11 +00:00
|
|
|
//Helper Functions for loading library items
|
2023-03-05 22:21:48 +00:00
|
|
|
const LIB_SYMBOL* loadSymdef( const SYMDEF_ID& aSymdefID );
|
|
|
|
|
2023-03-07 21:38:15 +00:00
|
|
|
void loadSymbolGateAndPartFields( const SYMDEF_ID& aSymdefID, const PART& aCadstarPart,
|
2023-03-05 22:21:48 +00:00
|
|
|
const GATE_ID& aGateID, LIB_SYMBOL* aSymbol );
|
2020-09-27 12:19:51 +00:00
|
|
|
|
2023-03-07 21:38:15 +00:00
|
|
|
void setFootprintOnSymbol( std::unique_ptr<LIB_SYMBOL>& aKiCadSymbol,
|
|
|
|
const wxString& aFootprintName,
|
|
|
|
const wxString& aFootprintAlternate );
|
|
|
|
|
2020-09-23 20:39:11 +00:00
|
|
|
void loadLibrarySymbolShapeVertices( const std::vector<VERTEX>& aCadstarVertices,
|
2024-04-12 21:00:41 +00:00
|
|
|
const VECTOR2I& aSymbolOrigin, LIB_SYMBOL* aSymbol,
|
2021-08-29 18:55:47 +00:00
|
|
|
int aGateNumber, int aLineThickness );
|
2020-09-27 12:19:51 +00:00
|
|
|
|
2021-01-27 00:09:58 +00:00
|
|
|
void applyToLibraryFieldAttribute( const ATTRIBUTE_LOCATION& aCadstarAttrLoc,
|
2024-04-12 21:00:41 +00:00
|
|
|
const VECTOR2I& aSymbolOrigin, SCH_FIELD* aKiCadField );
|
2020-09-23 20:39:11 +00:00
|
|
|
|
|
|
|
//Helper Functions for loading symbols in schematic
|
2021-06-10 18:51:46 +00:00
|
|
|
SCH_SYMBOL* loadSchematicSymbol( const SYMBOL& aCadstarSymbol, const LIB_SYMBOL& aKiCadPart,
|
2022-01-18 02:26:40 +00:00
|
|
|
EDA_ANGLE& aComponentOrientation );
|
2020-09-27 12:19:51 +00:00
|
|
|
|
2023-03-05 22:21:48 +00:00
|
|
|
|
2020-09-27 12:19:51 +00:00
|
|
|
void loadSymbolFieldAttribute( const ATTRIBUTE_LOCATION& aCadstarAttrLoc,
|
2022-01-18 02:26:40 +00:00
|
|
|
const EDA_ANGLE& aComponentOrientation, bool aIsMirrored,
|
2021-01-27 00:09:58 +00:00
|
|
|
SCH_FIELD* aKiCadField );
|
2020-09-27 12:19:51 +00:00
|
|
|
|
2022-01-18 02:26:40 +00:00
|
|
|
int getComponentOrientation( const EDA_ANGLE& aOrientAngle, EDA_ANGLE& aReturnedOrientation );
|
2020-09-20 21:08:46 +00:00
|
|
|
|
2020-09-23 20:39:11 +00:00
|
|
|
//Helper functions for loading nets
|
2020-09-27 12:19:51 +00:00
|
|
|
POINT getLocationOfNetElement( const NET_SCH& aNet, const NETELEMENT_ID& aNetElementID );
|
|
|
|
|
2020-09-23 20:39:11 +00:00
|
|
|
wxString getNetName( const NET_SCH& aNet );
|
2020-09-19 22:05:02 +00:00
|
|
|
|
2020-09-26 18:23:13 +00:00
|
|
|
//Helper functions for loading figures / graphical items
|
|
|
|
void loadShapeVertices( const std::vector<VERTEX>& aCadstarVertices,
|
2022-01-01 06:04:08 +00:00
|
|
|
LINECODE_ID aCadstarLineCodeID, LAYER_ID aCadstarSheetID,
|
|
|
|
SCH_LAYER_ID aKiCadSchLayerID, const VECTOR2I& aMoveVector = { 0, 0 },
|
2022-01-18 02:26:40 +00:00
|
|
|
const EDA_ANGLE& aRotation = ANGLE_0,
|
|
|
|
const double& aScalingFactor = 1.0,
|
|
|
|
const VECTOR2I& aTransformCentre = { 0, 0 },
|
|
|
|
const bool& aMirrorInvert = false );
|
2020-09-27 12:19:51 +00:00
|
|
|
|
2020-09-27 02:35:24 +00:00
|
|
|
void loadFigure( const FIGURE& aCadstarFigure, const LAYER_ID& aCadstarSheetIDOverride,
|
2022-01-01 06:04:08 +00:00
|
|
|
SCH_LAYER_ID aKiCadSchLayerID, const VECTOR2I& aMoveVector = { 0, 0 },
|
2022-01-18 02:26:40 +00:00
|
|
|
const EDA_ANGLE& aRotation = ANGLE_0, const double& aScalingFactor = 1.0,
|
2022-01-01 06:04:08 +00:00
|
|
|
const VECTOR2I& aTransformCentre = { 0, 0 },
|
|
|
|
const bool& aMirrorInvert = false );
|
2020-09-27 12:19:51 +00:00
|
|
|
|
|
|
|
//Helper functions for loading text elements
|
2023-03-12 20:17:52 +00:00
|
|
|
void applyTextCodeIfExists( EDA_TEXT* aKiCadTextItem, const TEXTCODE_ID& aCadstarTextCodeID );
|
|
|
|
|
2021-04-02 18:50:30 +00:00
|
|
|
void applyTextSettings( EDA_TEXT* aKiCadTextItem,
|
|
|
|
const TEXTCODE_ID& aCadstarTextCodeID,
|
|
|
|
const ALIGNMENT& aCadstarAlignment,
|
|
|
|
const JUSTIFICATION& aCadstarJustification,
|
|
|
|
const long long aCadstarOrientAngle = 0,
|
2024-04-27 12:47:56 +00:00
|
|
|
bool aMirrored = false );
|
2021-04-02 18:50:30 +00:00
|
|
|
|
2020-09-27 12:19:51 +00:00
|
|
|
SCH_TEXT* getKiCadSchText( const TEXT& aCadstarTextElement );
|
|
|
|
|
2020-09-26 18:23:13 +00:00
|
|
|
|
2020-09-23 20:39:11 +00:00
|
|
|
//Helper Functions for obtaining CADSTAR elements from the parsed structures
|
2020-09-20 21:08:46 +00:00
|
|
|
SYMDEF_ID getSymDefFromName( const wxString& aSymdefName, const wxString& aSymDefAlternate );
|
2021-01-27 00:09:58 +00:00
|
|
|
bool isAttributeVisible( const ATTRIBUTE_ID& aCadstarAttributeID );
|
2020-09-27 12:19:51 +00:00
|
|
|
|
|
|
|
int getLineThickness( const LINECODE_ID& aCadstarLineCodeID );
|
2023-11-25 13:05:45 +00:00
|
|
|
LINE_STYLE getLineStyle( const LINECODE_ID& aCadstarLineCodeID );
|
2020-09-27 12:19:51 +00:00
|
|
|
PART getPart( const PART_ID& aCadstarPartID );
|
|
|
|
ROUTECODE getRouteCode( const ROUTECODE_ID& aCadstarRouteCodeID );
|
|
|
|
TEXTCODE getTextCode( const TEXTCODE_ID& aCadstarTextCodeID );
|
2021-09-01 19:12:56 +00:00
|
|
|
int getTextHeightFromTextCode( const TEXTCODE_ID& aCadstarTextCodeID );
|
2020-09-27 12:19:51 +00:00
|
|
|
wxString getAttributeName( const ATTRIBUTE_ID& aCadstarAttributeID );
|
|
|
|
|
2022-01-24 13:40:39 +00:00
|
|
|
PART::DEFINITION::PIN getPartDefinitionPin( const PART& aCadstarPart, const GATE_ID& aGateID,
|
|
|
|
const TERMINAL_ID& aTerminalID );
|
2020-09-19 22:05:02 +00:00
|
|
|
|
2020-09-27 13:10:59 +00:00
|
|
|
//Helper Functions for obtaining individual elements as KiCad elements:
|
2023-02-22 21:00:37 +00:00
|
|
|
ELECTRICAL_PINTYPE getKiCadPinType( const CADSTAR_PIN_TYPE& aPinType );
|
2021-02-02 15:37:10 +00:00
|
|
|
|
2022-01-24 13:40:39 +00:00
|
|
|
int getKiCadUnitNumberFromGate( const GATE_ID& aCadstarGateID );
|
2023-09-07 16:09:53 +00:00
|
|
|
SPIN_STYLE getSpinStyle( const long long& aCadstarOrientation, bool aMirror );
|
|
|
|
SPIN_STYLE getSpinStyle( const EDA_ANGLE& aOrientation );
|
2022-01-24 13:40:39 +00:00
|
|
|
ALIGNMENT mirrorX( const ALIGNMENT& aCadstarAlignment );
|
|
|
|
ALIGNMENT rotate180( const ALIGNMENT& aCadstarAlignment );
|
2020-09-27 02:35:24 +00:00
|
|
|
|
2020-09-27 13:10:59 +00:00
|
|
|
//General Graphical manipulation functions
|
2021-05-28 15:19:04 +00:00
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
LIB_SYMBOL* getScaledLibPart( const LIB_SYMBOL* aSymbol, long long aScalingFactorNumerator,
|
|
|
|
long long aScalingFactorDenominator );
|
2021-05-28 15:19:04 +00:00
|
|
|
|
2021-06-10 18:51:46 +00:00
|
|
|
void fixUpLibraryPins( LIB_SYMBOL* aSymbolToFix, int aGateNumber );
|
2021-05-28 18:39:08 +00:00
|
|
|
|
2023-02-19 03:40:07 +00:00
|
|
|
std::pair<VECTOR2I, VECTOR2I> getFigureExtentsKiCad( const FIGURE& aCadstarFigure );
|
2020-09-19 22:05:02 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I getKiCadPoint( const VECTOR2I& aCadstarPoint );
|
2020-09-19 22:05:02 +00:00
|
|
|
|
2023-01-10 21:25:28 +00:00
|
|
|
VECTOR2I getKiCadLibraryPoint( const VECTOR2I& aCadstarPoint, const VECTOR2I& aCadstarCentre );
|
2020-09-20 21:08:46 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I applyTransform( const VECTOR2I& aPoint, const VECTOR2I& aMoveVector = { 0, 0 },
|
2022-01-18 02:26:40 +00:00
|
|
|
const EDA_ANGLE& aRotation = ANGLE_0,
|
|
|
|
const double& aScalingFactor = 1.0,
|
|
|
|
const VECTOR2I& aTransformCentre = { 0, 0 },
|
|
|
|
const bool& aMirrorInvert = false );
|
2020-09-19 22:05:02 +00:00
|
|
|
|
2023-02-26 22:37:05 +00:00
|
|
|
void checkDesignLimits();
|
|
|
|
|
2020-09-19 22:05:02 +00:00
|
|
|
int getKiCadLength( long long aCadstarLength )
|
|
|
|
{
|
2021-02-18 18:02:49 +00:00
|
|
|
int mod = aCadstarLength % KiCadUnitDivider;
|
|
|
|
int absmod = sign( mod ) * mod;
|
|
|
|
int offset = 0;
|
|
|
|
|
|
|
|
// Round half-way cases away from zero
|
|
|
|
if( absmod >= KiCadUnitDivider / 2 )
|
|
|
|
offset = sign( aCadstarLength );
|
|
|
|
|
|
|
|
return ( aCadstarLength / KiCadUnitDivider ) + offset;
|
2020-09-19 22:05:02 +00:00
|
|
|
}
|
|
|
|
|
2022-01-18 02:26:40 +00:00
|
|
|
EDA_ANGLE getAngle( const long long& aCadstarAngle )
|
2020-09-19 22:05:02 +00:00
|
|
|
{
|
2020-11-22 01:50:04 +00:00
|
|
|
// CADSTAR v6 (which outputted Schematic Format Version 8) and earlier used 1/10 degree
|
|
|
|
// as the unit for angles/orientations. It is assumed that CADSTAR version 7 (i.e. Schematic
|
|
|
|
// Format Version 9 and later) is the version that introduced 1/1000 degree for angles.
|
|
|
|
if( Header.Format.Version > 8 )
|
|
|
|
{
|
2022-01-18 02:26:40 +00:00
|
|
|
return EDA_ANGLE( (double) aCadstarAngle / 1000.0, DEGREES_T );
|
2020-11-22 01:50:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-18 02:26:40 +00:00
|
|
|
return EDA_ANGLE( (double) aCadstarAngle, TENTHS_OF_A_DEGREE_T );
|
2020-11-22 01:50:04 +00:00
|
|
|
}
|
2020-09-19 22:05:02 +00:00
|
|
|
}
|
|
|
|
|
2022-01-18 02:26:40 +00:00
|
|
|
long long getCadstarAngle( const EDA_ANGLE& aAngle )
|
2021-04-02 18:50:30 +00:00
|
|
|
{
|
2022-01-18 02:26:40 +00:00
|
|
|
// CADSTAR v6 (which outputted Schematic Format Version 8) and earlier used 1/10 degree
|
|
|
|
// as the unit for angles/orientations. It is assumed that CADSTAR version 7 (i.e. Schematic
|
|
|
|
// Format Version 9 and later) is the version that introduced 1/1000 degree for angles.
|
|
|
|
if( Header.Format.Version > 8 )
|
|
|
|
{
|
|
|
|
return KiROUND( aAngle.AsDegrees() * 1000.0 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return aAngle.AsTenthsOfADegree();
|
|
|
|
}
|
2021-04-02 18:50:30 +00:00
|
|
|
}
|
|
|
|
|
2020-09-20 21:08:46 +00:00
|
|
|
/**
|
2020-10-24 14:45:37 +00:00
|
|
|
* @brief
|
|
|
|
* @param aPoint
|
2020-09-20 21:08:46 +00:00
|
|
|
* @return Radius of polar representation of the point
|
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
double getPolarRadius( const VECTOR2I& aPoint );
|
2020-09-20 21:08:46 +00:00
|
|
|
|
2023-03-05 22:21:48 +00:00
|
|
|
|
2024-04-12 21:00:41 +00:00
|
|
|
static SCH_FIELD* addNewFieldToSymbol( const wxString& aFieldName,
|
2023-03-07 21:38:15 +00:00
|
|
|
std::unique_ptr<LIB_SYMBOL>& aKiCadSymbol );
|
2023-03-05 22:21:48 +00:00
|
|
|
|
2020-09-08 19:51:22 +00:00
|
|
|
}; // CADSTAR_SCH_ARCHIVE_LOADER
|
|
|
|
|
|
|
|
|
|
|
|
#endif // CADSTAR_SCH_ARCHIVE_LOADER_H_
|