2020-07-30 22:42:56 +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-07-30 22:42:56 +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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2020-08-29 18:09:48 +00:00
|
|
|
* @file cadstar_archive_parser.h
|
|
|
|
* @brief Helper functions and common defines between schematic and PCB Archive files
|
2020-07-30 22:42:56 +00:00
|
|
|
*/
|
|
|
|
|
2020-09-06 17:00:02 +00:00
|
|
|
#ifndef CADSTAR_ARCHIVE_PARSER_H_
|
|
|
|
#define CADSTAR_ARCHIVE_PARSER_H_
|
2020-07-30 22:42:56 +00:00
|
|
|
|
2021-06-06 23:31:15 +00:00
|
|
|
#include <richio.h>
|
|
|
|
#include <wx/gdicmn.h>
|
2021-09-11 19:02:59 +00:00
|
|
|
#include <functional>
|
2021-06-06 23:11:35 +00:00
|
|
|
#include <map>
|
|
|
|
#include <set>
|
2020-07-30 22:42:56 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <xnode.h>
|
|
|
|
|
2021-11-29 20:33:07 +00:00
|
|
|
#include <math/vector2d.h>
|
|
|
|
|
2021-04-05 13:24:57 +00:00
|
|
|
// THROW_IO_ERROR definitions to ensure consistent wording is used in the error messages
|
2020-07-30 22:42:56 +00:00
|
|
|
|
|
|
|
#define THROW_MISSING_NODE_IO_ERROR( nodename, location ) \
|
|
|
|
THROW_IO_ERROR( wxString::Format( _( "Missing node '%s' in '%s'" ), nodename, location ) )
|
|
|
|
|
|
|
|
#define THROW_UNKNOWN_NODE_IO_ERROR( nodename, location ) \
|
|
|
|
THROW_IO_ERROR( wxString::Format( _( "Unknown node '%s' in '%s'" ), nodename, location ) )
|
|
|
|
|
|
|
|
#define THROW_MISSING_PARAMETER_IO_ERROR( param, location ) \
|
|
|
|
THROW_IO_ERROR( wxString::Format( _( "Missing Parameter '%s' in '%s'" ), param, location ) )
|
|
|
|
|
|
|
|
#define THROW_UNKNOWN_PARAMETER_IO_ERROR( param, location ) \
|
|
|
|
THROW_IO_ERROR( wxString::Format( _( "Unknown Parameter '%s' in '%s'" ), param, location ) )
|
|
|
|
|
|
|
|
#define THROW_PARSING_IO_ERROR( param, location ) \
|
|
|
|
THROW_IO_ERROR( wxString::Format( _( "Unable to parse '%s' in '%s'" ), param, location ) )
|
|
|
|
|
2020-09-10 20:58:20 +00:00
|
|
|
//=================================
|
|
|
|
// MACRO DEFINITIONS
|
|
|
|
//=================================
|
|
|
|
#define UNDEFINED_LAYER_ID ( LAYER_ID ) wxEmptyString
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Component Name Attribute ID - typically used for placement of designators on silk screen.
|
|
|
|
*/
|
|
|
|
#define COMPONENT_NAME_ATTRID ( ATTRIBUTE_ID ) wxT( "__COMPONENT_NAME__" )
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Component Name 2 Attribute ID - typically used for indicating the placement of designators in
|
|
|
|
* placement drawings.
|
|
|
|
*/
|
|
|
|
#define COMPONENT_NAME_2_ATTRID ( ATTRIBUTE_ID ) wxT( "__COMPONENT_NAME_2__" )
|
2020-09-13 21:42:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Symbol Name attribute ID - used for placement of designators on the schematic
|
|
|
|
*/
|
|
|
|
#define SYMBOL_NAME_ATTRID ( ATTRIBUTE_ID ) wxT( "__SYMBOL_NAME__" )
|
|
|
|
#define LINK_ORIGIN_ATTRID ( ATTRIBUTE_ID ) wxT( "__LINK_ORIGIN__" )
|
|
|
|
#define SIGNALNAME_ORIGIN_ATTRID ( ATTRIBUTE_ID ) wxT( "__SIGNALNAME_ORIGIN__" )
|
2020-09-10 20:58:20 +00:00
|
|
|
#define PART_NAME_ATTRID ( ATTRIBUTE_ID ) wxT( "__PART_NAME__" )
|
|
|
|
|
2020-12-30 02:04:19 +00:00
|
|
|
class EDA_TEXT;
|
2021-06-06 13:28:02 +00:00
|
|
|
class wxXmlAttribute;
|
2021-09-09 21:15:38 +00:00
|
|
|
class PROGRESS_REPORTER;
|
2021-11-29 20:33:07 +00:00
|
|
|
class SHAPE_LINE_CHAIN;
|
|
|
|
class SHAPE_POLY_SET;
|
2023-02-26 17:16:34 +00:00
|
|
|
class SHAPE_ARC;
|
2020-09-10 20:58:20 +00:00
|
|
|
|
2020-07-30 22:42:56 +00:00
|
|
|
/**
|
|
|
|
* @brief Helper functions and common structures for CADSTAR PCB and Schematic archive files.
|
2020-09-06 17:00:02 +00:00
|
|
|
*/
|
2020-08-29 18:09:48 +00:00
|
|
|
class CADSTAR_ARCHIVE_PARSER
|
2020-07-30 22:42:56 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-09-09 21:15:38 +00:00
|
|
|
CADSTAR_ARCHIVE_PARSER() { m_progressReporter = nullptr; }
|
|
|
|
|
2023-02-27 22:55:20 +00:00
|
|
|
virtual ~CADSTAR_ARCHIVE_PARSER() {}
|
|
|
|
|
2021-09-09 21:15:38 +00:00
|
|
|
|
2020-09-10 20:58:20 +00:00
|
|
|
typedef wxString LINECODE_ID;
|
|
|
|
typedef wxString HATCHCODE_ID;
|
|
|
|
typedef wxString ROUTECODE_ID;
|
|
|
|
typedef wxString NETCLASS_ID;
|
|
|
|
typedef wxString SPACING_CLASS_ID;
|
|
|
|
typedef wxString TEXTCODE_ID;
|
|
|
|
typedef wxString LAYER_ID; ///< ID of a Sheet (if schematic) or board Layer (if PCB)
|
|
|
|
typedef wxString VARIANT_ID;
|
|
|
|
typedef wxString ATTRIBUTE_ID;
|
|
|
|
typedef wxString SYMDEF_ID;
|
|
|
|
typedef wxString PART_ID;
|
|
|
|
typedef wxString GATE_ID;
|
|
|
|
typedef long TERMINAL_ID; ///< Terminal is the pin identifier in the schematic
|
|
|
|
typedef long PART_DEFINITION_PIN_ID; ///< Pin identifier in the part definition
|
|
|
|
typedef long PART_PIN_ID; ///< Pin identifier in the part
|
|
|
|
typedef wxString TEXT_ID;
|
|
|
|
typedef wxString FIGURE_ID;
|
|
|
|
typedef wxString GROUP_ID;
|
|
|
|
typedef wxString REUSEBLOCK_ID;
|
|
|
|
typedef wxString NET_ID;
|
|
|
|
typedef wxString NETELEMENT_ID;
|
|
|
|
typedef wxString DOCUMENTATION_SYMBOL_ID;
|
2021-01-27 00:09:58 +00:00
|
|
|
typedef wxString COLOR_ID;
|
2020-09-10 20:58:20 +00:00
|
|
|
|
2020-07-30 22:42:56 +00:00
|
|
|
static const long UNDEFINED_VALUE = -1;
|
|
|
|
|
2020-10-18 17:15:46 +00:00
|
|
|
/**
|
|
|
|
* CADSTAR fonts are drawn on a 24x24 integer matrix, where the each axis goes from 0 to 24.
|
|
|
|
* The characters can each specify a width of between 12 and 24, but the height is fixed at 24.
|
2020-10-24 12:05:15 +00:00
|
|
|
*
|
2020-10-18 17:15:46 +00:00
|
|
|
* The default CADSTAR font uses y=5 as the starting point for capital letters, leaving space
|
|
|
|
* for the tails of letters such as "g", "p", "y", "q", etc.
|
2020-10-24 12:05:15 +00:00
|
|
|
*
|
2020-10-18 17:15:46 +00:00
|
|
|
* The font height in CADSTAR corresponds to the full 24 point height. In KiCad it only
|
|
|
|
* corresponds to the height above the guide line, meaning the overall text height will be
|
|
|
|
* larger in KiCad.
|
|
|
|
*/
|
|
|
|
static const double TXT_HEIGHT_RATIO;
|
2021-01-13 02:12:59 +00:00
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
/**
|
2021-04-05 13:24:57 +00:00
|
|
|
* These are special fields in text objects enclosed between the tokens '<@' and '@>' such as
|
2020-12-10 16:13:35 +00:00
|
|
|
* <@[FIELD_NAME][FIELD_VALUE]@>. For example: "<@DESIGN TITLEProject Title@>"
|
|
|
|
*/
|
|
|
|
enum class TEXT_FIELD_NAME
|
|
|
|
{
|
|
|
|
DESIGN_TITLE,
|
|
|
|
SHORT_JOBNAME,
|
|
|
|
LONG_JOBNAME,
|
|
|
|
NUM_OF_SHEETS,
|
|
|
|
SHEET_NUMBER,
|
|
|
|
SHEET_NAME,
|
|
|
|
VARIANT_NAME,
|
|
|
|
VARIANT_DESCRIPTION,
|
|
|
|
REG_USER,
|
|
|
|
COMPANY_NAME,
|
|
|
|
CURRENT_USER,
|
|
|
|
DATE,
|
|
|
|
TIME,
|
|
|
|
MACHINE_NAME,
|
|
|
|
FROM_FILE,
|
|
|
|
DISTANCE,
|
|
|
|
UNITS_SHORT,
|
|
|
|
UNITS_ABBREV,
|
|
|
|
UNITS_FULL,
|
|
|
|
HYPERLINK,
|
|
|
|
NONE ///< Synthetic for flagging
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2021-02-13 20:00:17 +00:00
|
|
|
* Map between CADSTAR fields and KiCad text variables. This is used as a lookup table when
|
|
|
|
* parsing CADSTAR text fields. Most variables have a similar name in KiCad as in CADSTAR.
|
2020-12-10 16:13:35 +00:00
|
|
|
*/
|
2021-02-13 20:00:17 +00:00
|
|
|
static const std::map<TEXT_FIELD_NAME, wxString> CADSTAR_TO_KICAD_FIELDS;
|
2020-12-10 16:13:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
struct PARSER_CONTEXT
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* CADSTAR doesn't have user defined text fields but does allow loading text from a
|
|
|
|
* file. This map stores all the text items that exist in the original CADSTAR design. They
|
2021-01-13 02:12:59 +00:00
|
|
|
* will be replaced by a text variable of the form ${FROM_FILE_[filename]_[extension]}
|
2020-12-10 16:13:35 +00:00
|
|
|
*/
|
|
|
|
std::map<wxString, wxString> FilenamesToTextMap;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* KiCad doesn't support hyperlinks but we use this map to display warning messages
|
|
|
|
* after import. First element = Display Text. Second element = Hyperlink
|
|
|
|
*/
|
|
|
|
std::map<wxString, wxString> TextToHyperlinksMap;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Values for the text field elements used in the CADSTAR design extracted from the
|
|
|
|
* text element instances
|
|
|
|
*/
|
|
|
|
std::map<TEXT_FIELD_NAME, wxString> TextFieldToValuesMap;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Text fields need to be updated in CADSTAR and it is possible that they are not
|
2021-04-05 13:24:57 +00:00
|
|
|
* consistent across text elements.
|
2020-12-10 16:13:35 +00:00
|
|
|
*/
|
|
|
|
std::set<TEXT_FIELD_NAME> InconsistentTextFields;
|
2021-09-09 21:15:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback function to report progress
|
|
|
|
*/
|
|
|
|
std::function<void()> CheckPointCallback = []() {};
|
2020-12-10 16:13:35 +00:00
|
|
|
};
|
2020-09-10 20:58:20 +00:00
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
/**
|
|
|
|
* @brief Replaces CADSTAR fields for the equivalent in KiCad and stores the field values
|
|
|
|
* in aParserContext
|
|
|
|
* @param aTextString Text string to parse
|
|
|
|
* @param aParserContext PARSER_CONTEXT in which to store the values of the found fields
|
2021-01-13 02:12:59 +00:00
|
|
|
* @return
|
2020-12-10 16:13:35 +00:00
|
|
|
*/
|
2021-07-27 12:22:27 +00:00
|
|
|
static wxString ParseTextFields( const wxString& aTextString, PARSER_CONTEXT* aParserContext );
|
2020-12-10 16:13:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
struct PARSER
|
|
|
|
{
|
|
|
|
virtual void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) = 0;
|
2021-01-13 02:12:59 +00:00
|
|
|
|
|
|
|
virtual ~PARSER() {};
|
2020-12-10 16:13:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct FORMAT : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxString Type;
|
|
|
|
long SomeInt; ///< It is unclear what this parameter is used for
|
|
|
|
long Version; ///< Archive version number (e.g. for PCB: 19=> CADSTAR 17.0 archive,
|
|
|
|
///< 20=> CADSTAR 18.0 archive, 21 => CADSTAR 2018.0 / 2019.0 / 2020.0,
|
|
|
|
///< etc.)
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct TIMESTAMP : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
long Year;
|
|
|
|
long Month;
|
|
|
|
long Day;
|
|
|
|
long Hour;
|
|
|
|
long Minute;
|
|
|
|
long Second;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//Note: there are possibly several other resolutions, but HUNDREDTH MICRON is only one known
|
|
|
|
enum class RESOLUTION
|
|
|
|
{
|
|
|
|
HUNDREDTH_MICRON
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct HEADER : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
FORMAT Format;
|
|
|
|
wxString JobFile;
|
|
|
|
wxString JobTitle;
|
|
|
|
wxString Generator;
|
|
|
|
RESOLUTION Resolution;
|
|
|
|
TIMESTAMP Timestamp;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct VARIANT : PARSER ///< Nodename = "VARIANT" or "VMASTER" (master variant
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
VARIANT_ID ID = wxEmptyString;
|
|
|
|
VARIANT_ID ParentID = wxEmptyString; ///< if empty, then this one is the master
|
|
|
|
wxString Name = wxEmptyString;
|
|
|
|
wxString Description = wxEmptyString;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct VARIANT_HIERARCHY : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
std::map<VARIANT_ID, VARIANT> Variants;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum class LINESTYLE
|
|
|
|
{
|
|
|
|
SOLID,
|
|
|
|
DASH,
|
|
|
|
DASHDOT,
|
|
|
|
DASHDOTDOT,
|
|
|
|
DOT
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct LINECODE : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
LINECODE_ID ID;
|
|
|
|
wxString Name;
|
|
|
|
long Width;
|
|
|
|
LINESTYLE Style;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct HATCH : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
long Step;
|
|
|
|
long LineWidth;
|
|
|
|
long OrientAngle; ///< 1/1000 of a Degree
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct HATCHCODE : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
HATCHCODE_ID ID;
|
|
|
|
wxString Name;
|
|
|
|
std::vector<HATCH> Hatches;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static const long FONT_NORMAL = 400;
|
|
|
|
static const long FONT_BOLD = 700;
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct FONT : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxString Name = wxT( "CADSTAR" );
|
|
|
|
long Modifier1 = FONT_NORMAL; ///< It seems this is related to weight. 400=Normal, 700=Bold.
|
|
|
|
long Modifier2 = 0; ///< It seems this is always 0 regardless of settings
|
|
|
|
bool KerningPairs =
|
|
|
|
false; ///< From CADSTAR Help: "Kerning Pairs is for causing the system to
|
|
|
|
///< automatically reduce the spacing between certain pairs of
|
|
|
|
///< characters in order to improve the appearance of the text"
|
|
|
|
bool Italic = false;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct TEXTCODE : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
TEXTCODE_ID ID;
|
|
|
|
wxString Name;
|
|
|
|
long LineWidth;
|
|
|
|
long Height;
|
|
|
|
long Width; ///< Defaults to 0 if using system fonts or, if using CADSTAR font, default to
|
|
|
|
///< equal height (1:1 aspect ratio). Allows for system fonts to be rendered in
|
|
|
|
///< a different aspect ratio.
|
|
|
|
FONT Font;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct ROUTEREASSIGN : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
2020-10-12 19:24:11 +00:00
|
|
|
LAYER_ID LayerID;
|
|
|
|
long OptimalWidth;
|
|
|
|
long MinWidth;
|
|
|
|
long MaxWidth;
|
|
|
|
long NeckedWidth;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-10-12 19:24:11 +00:00
|
|
|
};
|
2020-09-10 20:58:20 +00:00
|
|
|
|
2020-10-12 19:24:11 +00:00
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct ROUTECODE : PARSER
|
2020-10-12 19:24:11 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
ROUTECODE_ID ID;
|
|
|
|
wxString Name;
|
|
|
|
long OptimalWidth;
|
|
|
|
long MinWidth;
|
|
|
|
long MaxWidth;
|
|
|
|
long NeckedWidth;
|
|
|
|
|
2020-10-12 19:24:11 +00:00
|
|
|
std::vector<ROUTEREASSIGN> RouteReassigns;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-07-30 22:42:56 +00:00
|
|
|
/**
|
|
|
|
* @brief Represents a floating value in E notation
|
|
|
|
*/
|
2020-12-10 16:13:35 +00:00
|
|
|
struct EVALUE : PARSER
|
2020-07-30 22:42:56 +00:00
|
|
|
{
|
|
|
|
long Base = 0;
|
|
|
|
long Exponent = 0;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-07-30 22:42:56 +00:00
|
|
|
double GetDouble();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Represents a point in x,y coordinates
|
|
|
|
*/
|
2020-12-10 16:13:35 +00:00
|
|
|
struct POINT : wxPoint, PARSER
|
2020-07-30 22:42:56 +00:00
|
|
|
{
|
2021-11-29 20:33:07 +00:00
|
|
|
POINT() : wxPoint( UNDEFINED_VALUE, UNDEFINED_VALUE ) {}
|
|
|
|
POINT( int aX, int aY ) : wxPoint( aX, aY ) {}
|
2020-07-30 22:42:56 +00:00
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-07-30 22:42:56 +00:00
|
|
|
};
|
|
|
|
|
2020-09-06 17:00:02 +00:00
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct LONGPOINT : PARSER
|
2020-08-31 22:09:29 +00:00
|
|
|
{
|
|
|
|
long x = UNDEFINED_VALUE;
|
|
|
|
long y = UNDEFINED_VALUE;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-08-31 22:09:29 +00:00
|
|
|
};
|
|
|
|
|
2020-07-30 22:42:56 +00:00
|
|
|
|
2021-11-29 20:33:07 +00:00
|
|
|
struct TRANSFORM
|
|
|
|
{
|
|
|
|
virtual wxPoint Apply( POINT aCadstarPoint ) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-07-30 22:42:56 +00:00
|
|
|
enum class VERTEX_TYPE
|
|
|
|
{
|
|
|
|
POINT,
|
|
|
|
CLOCKWISE_ARC,
|
|
|
|
CLOCKWISE_SEMICIRCLE,
|
|
|
|
ANTICLOCKWISE_ARC,
|
|
|
|
ANTICLOCKWISE_SEMICIRCLE
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Represents a vertex in a shape. E.g. A circle is made by two semicircles with the same
|
|
|
|
* center point.
|
|
|
|
*/
|
2020-12-10 16:13:35 +00:00
|
|
|
struct VERTEX : PARSER
|
2020-07-30 22:42:56 +00:00
|
|
|
{
|
2021-11-29 20:33:07 +00:00
|
|
|
VERTEX( VERTEX_TYPE aType = VERTEX_TYPE::POINT, POINT aEnd = POINT(), POINT aCenter = POINT() ) :
|
|
|
|
Type( aType ), End( aEnd ), Center( aCenter )
|
|
|
|
{}
|
|
|
|
|
2020-07-30 22:42:56 +00:00
|
|
|
VERTEX_TYPE Type;
|
|
|
|
POINT End;
|
2021-11-29 20:33:07 +00:00
|
|
|
POINT Center;
|
2020-07-30 22:42:56 +00:00
|
|
|
|
|
|
|
static bool IsVertex( XNODE* aNode );
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2021-11-29 20:33:07 +00:00
|
|
|
|
|
|
|
void AppendToChain( SHAPE_LINE_CHAIN* aChainToAppendTo,
|
2023-01-10 21:25:28 +00:00
|
|
|
const std::function<VECTOR2I( const VECTOR2I& )> aCadstarToKicadPointCallback,
|
|
|
|
double aAccuracy ) const;
|
2023-02-26 17:16:34 +00:00
|
|
|
|
|
|
|
SHAPE_ARC BuildArc( const VECTOR2I& aPrevPoint,
|
|
|
|
const std::function<VECTOR2I( const VECTOR2I& )>
|
|
|
|
aCadstarToKicadPointCallback ) const;
|
2020-07-30 22:42:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Represents a cutout in a closed shape (e.g. OUTLINE)
|
|
|
|
*/
|
2020-12-10 16:13:35 +00:00
|
|
|
struct CUTOUT : PARSER
|
2020-07-30 22:42:56 +00:00
|
|
|
{
|
|
|
|
std::vector<VERTEX> Vertices;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-07-30 22:42:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum class SHAPE_TYPE
|
|
|
|
{
|
2020-08-09 22:01:28 +00:00
|
|
|
OPENSHAPE, ///< Unfilled open shape. Cannot have cutouts.
|
|
|
|
OUTLINE, ///< Unfilled closed shape.
|
|
|
|
SOLID, ///< Filled closed shape (solid fill).
|
|
|
|
HATCHED ///< Filled closed shape (hatch fill).
|
2020-07-30 22:42:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct SHAPE : PARSER
|
2020-07-30 22:42:56 +00:00
|
|
|
{
|
|
|
|
SHAPE_TYPE Type;
|
|
|
|
std::vector<VERTEX> Vertices;
|
|
|
|
std::vector<CUTOUT> Cutouts; ///< Not Applicable to OPENSHAPE Type
|
|
|
|
wxString HatchCodeID; ///< Only Applicable for HATCHED Type
|
|
|
|
|
|
|
|
static bool IsShape( XNODE* aNode );
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2021-11-29 20:33:07 +00:00
|
|
|
|
|
|
|
SHAPE_LINE_CHAIN OutlineAsChain( const std::function<VECTOR2I( const VECTOR2I& )>
|
2023-01-10 21:25:28 +00:00
|
|
|
aCadstarToKicadPointCallback,
|
|
|
|
double aAccuracy ) const;
|
2021-11-29 20:33:07 +00:00
|
|
|
|
|
|
|
SHAPE_POLY_SET ConvertToPolySet( const std::function<VECTOR2I( const VECTOR2I& )>
|
2023-01-10 21:25:28 +00:00
|
|
|
aCadstarToKicadPointCallback,
|
|
|
|
double aAccuracy ) const;
|
2020-07-30 22:42:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-09-10 20:58:20 +00:00
|
|
|
enum class UNITS
|
|
|
|
{
|
|
|
|
DESIGN, ///< Inherits from design units (assumed Assignments->Technology->Units)
|
|
|
|
THOU,
|
|
|
|
INCH,
|
|
|
|
MICROMETRE,
|
|
|
|
MM,
|
|
|
|
CENTIMETER,
|
|
|
|
METER
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static UNITS ParseUnits( XNODE* aNode );
|
|
|
|
|
|
|
|
|
|
|
|
enum class ANGUNITS
|
|
|
|
{
|
|
|
|
DEGREES,
|
|
|
|
RADIANS
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static ANGUNITS ParseAngunits( XNODE* aNode );
|
|
|
|
|
|
|
|
|
|
|
|
enum class GRID_TYPE
|
|
|
|
{
|
|
|
|
FRACTIONALGRID, ///< Param1 = Units, Param2 = Divisor. The grid is equal in X and Y
|
|
|
|
///< dimensions with a step size equal to Param1/Param2
|
|
|
|
STEPGRID ///< Param1 = X Step, Param2 = Y Step. A standard x,y grid.
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct GRID : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
GRID_TYPE Type;
|
|
|
|
wxString Name;
|
|
|
|
long Param1; ///< Either Units or X step, depending on Type (see GRID_TYPE for
|
|
|
|
///< more details)
|
2021-02-17 17:02:57 +00:00
|
|
|
long Param2; ///< Either Divisor or Y step, depending on Type (see GRID_TYPE for
|
2020-09-10 20:58:20 +00:00
|
|
|
///< more details)
|
|
|
|
|
|
|
|
static bool IsGrid( XNODE* aNode );
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct GRIDS : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
GRID WorkingGrid;
|
|
|
|
GRID ScreenGrid; ///< From CADSTAR Help: "There is one Screen Grid, which is
|
|
|
|
///< visible as dots on the screen. You cannot specify your
|
|
|
|
///< own name for the Screen Grid. The visibility and colour
|
|
|
|
///< of the dots representing the Screen Grid is set up by
|
|
|
|
///< the Highlight category on the Colours dialog.
|
|
|
|
///<
|
|
|
|
///< The type of Screen grid displayed(Lined or Points) is
|
|
|
|
///< set up on the Display dialog within Options(File menu)."
|
|
|
|
std::vector<GRID> UserGrids; ///< List of predefined grids created by the user
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct SETTINGS : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
UNITS Units; ///< Units to display for linear dimensions
|
|
|
|
long UnitDisplPrecision; ///< Number of decimal points to display for linear dimensions
|
|
|
|
long InterlineGap; ///< For CADSTAR font only, distance between lines of text,
|
|
|
|
///< expressed as a percentage of the text height (accepted
|
|
|
|
///< values are 0-100)
|
|
|
|
long BarlineGap; ///< For CADSTAR font only, distance between top bar and
|
|
|
|
///< character, expressed as a percentage of the text height
|
|
|
|
///< (accepted values are 0-100)
|
|
|
|
bool AllowBarredText = false; ///< Specifies if barring is allowed in the design
|
|
|
|
long AngularPrecision; ///< Number of decimal points to display for angular dimensions
|
|
|
|
|
|
|
|
LONGPOINT DesignOrigin;
|
|
|
|
std::pair<POINT, POINT> DesignArea;
|
|
|
|
LONGPOINT DesignRef; ///< Appears to be 0,0 always
|
|
|
|
LONGPOINT DesignLimit;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
bool ParseSubNode( XNODE* aChildNode, PARSER_CONTEXT* aContext );
|
|
|
|
virtual void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
|
2020-09-10 20:58:20 +00:00
|
|
|
/**
|
|
|
|
* @brief From CADSTAR Help: "Text Alignment enables you to define the position of an alignment
|
|
|
|
* origin for all text items in CADSTAR. The alignment origin is a point on or within the text
|
|
|
|
* boundary and defines how the text is displayed.
|
|
|
|
*
|
|
|
|
* For example, with an alignment of bottom-right the origin will be positioned at the bottom
|
2020-10-01 13:39:34 +00:00
|
|
|
* right of the text boundary. This makes it easier to right-align several text items
|
2020-09-10 20:58:20 +00:00
|
|
|
* regardless of the length of text displayed.
|
|
|
|
*
|
|
|
|
* Text Alignment applies to all CADSTAR text. [...]
|
|
|
|
*
|
|
|
|
* Note: Unaligned text operates in the way CADSTAR text always has. In most cases this behaves
|
|
|
|
* as Bottom Left alignment, but there are a few exceptions, e.g. pin names. Also unaligned
|
|
|
|
* multiline text has an origin Bottom Left of the first line."
|
2020-10-01 13:39:34 +00:00
|
|
|
*
|
2020-09-10 20:58:20 +00:00
|
|
|
* See also JUSTIFICATION
|
|
|
|
*/
|
|
|
|
enum class ALIGNMENT
|
|
|
|
{
|
|
|
|
NO_ALIGNMENT, ///< NO_ALIGNMENT has different meaning depending on the object type
|
|
|
|
TOPLEFT,
|
|
|
|
TOPCENTER,
|
|
|
|
TOPRIGHT,
|
|
|
|
CENTERLEFT,
|
|
|
|
CENTERCENTER,
|
|
|
|
CENTERRIGHT,
|
|
|
|
BOTTOMLEFT,
|
|
|
|
BOTTOMCENTER,
|
|
|
|
BOTTOMRIGHT
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static ALIGNMENT ParseAlignment( XNODE* aNode );
|
|
|
|
|
|
|
|
/**
|
2020-10-01 13:39:34 +00:00
|
|
|
* @brief From CADSTAR Help: "Multi Line Text can also be justified as Left, Centre or Right.
|
|
|
|
* This does not affect the text alignment. Note: Justification of single line text has no
|
2020-09-10 20:58:20 +00:00
|
|
|
* effect."
|
|
|
|
*
|
|
|
|
* This only affects multiline text
|
|
|
|
*
|
|
|
|
* See also ALIGNMENT
|
|
|
|
*/
|
|
|
|
enum class JUSTIFICATION
|
|
|
|
{
|
|
|
|
LEFT,
|
|
|
|
CENTER,
|
|
|
|
RIGHT
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static JUSTIFICATION ParseJustification( XNODE* aNode );
|
|
|
|
|
|
|
|
/**
|
2021-04-05 13:24:57 +00:00
|
|
|
* @brief Sets the readability direction of text. From CADSTAR Help: "Horizontal text will
|
2020-09-10 20:58:20 +00:00
|
|
|
* always be displayed from left to right (i.e. never upside down). Vertical text can be set as
|
|
|
|
* readable from either the left or right edge of the design."
|
|
|
|
*
|
|
|
|
* I.e. Vertical text can either be rotated 90 degrees clockwise or 90 degrees anticlockwise from
|
|
|
|
* horizontal. This does not impact vertical text
|
|
|
|
*/
|
|
|
|
enum class READABILITY
|
|
|
|
{
|
|
|
|
BOTTOM_TO_TOP, ///< When text is vertical, show it rotated 90 degrees anticlockwise
|
|
|
|
TOP_TO_BOTTOM ///< When text is vertical, show it rotated 90 degrees clockwise
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static READABILITY ParseReadability( XNODE* aNode );
|
|
|
|
|
|
|
|
|
|
|
|
enum class ATTROWNER
|
|
|
|
{
|
|
|
|
ALL_ITEMS,
|
|
|
|
AREA,
|
|
|
|
BOARD,
|
|
|
|
COMPONENT,
|
|
|
|
CONNECTION,
|
|
|
|
COPPER,
|
|
|
|
DOCSYMBOL,
|
|
|
|
FIGURE,
|
|
|
|
NET,
|
|
|
|
NETCLASS,
|
|
|
|
PART, ///< Only library Attributes
|
|
|
|
PART_DEFINITION, ///< Only library Attributes
|
|
|
|
PIN,
|
2021-01-13 20:24:08 +00:00
|
|
|
SIGNALREF,
|
2020-09-13 21:42:17 +00:00
|
|
|
SYMBOL,
|
2020-09-10 20:58:20 +00:00
|
|
|
SYMDEF,
|
|
|
|
TEMPLATE,
|
|
|
|
TESTPOINT
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum class ATTRUSAGE
|
|
|
|
{
|
|
|
|
BOTH, ///< From CADSTAR Help: Assigned to both Schematic symbols and PCB components,
|
|
|
|
///< and displayed on Schematic and PCB designs.
|
|
|
|
COMPONENT, ///< From CADSTAR Help: Assigned to PCB components and displayed on PCB designs
|
|
|
|
PART_DEFINITION, ///< From CADSTAR Help: Assigned to Parts library Definitions and displayed
|
|
|
|
///< by the Library searcher
|
|
|
|
PART_LIBRARY, ///< From CADSTAR Help: Only used by non-Cadstar applications
|
|
|
|
SYMBOL, ///< From CADSTAR Help: Assigned to Schematic Symbols and displayed on
|
|
|
|
///< Schematic Designs
|
|
|
|
UNDEFINED ///< Note: It seems that some attribute have no "ATTRUSAGE" defined. It appears
|
2021-04-05 13:24:57 +00:00
|
|
|
///< that the attributes that fall under this category are the ones associated
|
2020-09-10 20:58:20 +00:00
|
|
|
///< with the design itself (i.e. not inherited from the library)
|
|
|
|
};
|
|
|
|
|
2020-09-13 21:42:17 +00:00
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct ATTRIBUTE_LOCATION : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
TEXTCODE_ID TextCodeID;
|
|
|
|
LAYER_ID LayerID;
|
|
|
|
POINT Position;
|
|
|
|
long OrientAngle = 0;
|
|
|
|
bool Mirror = false;
|
|
|
|
bool Fixed = false;
|
|
|
|
JUSTIFICATION Justification =
|
|
|
|
JUSTIFICATION::LEFT; ///< Note: Justification has no effect on single lines of text
|
|
|
|
ALIGNMENT Alignment = ALIGNMENT::
|
|
|
|
NO_ALIGNMENT; ///< In CADSTAR The default alignment for a TEXT object (when
|
|
|
|
///< "(No Alignment()" is selected) Bottom Left of the *first line*.
|
|
|
|
///< Note that this is different from BOTTOM_LEFT (which is bottom
|
|
|
|
///< left of the whole text block)
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void ParseIdentifiers( XNODE* aNode, PARSER_CONTEXT* aContext );
|
|
|
|
bool ParseSubNode( XNODE* aChildNode, PARSER_CONTEXT* aContext );
|
|
|
|
virtual void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief NOTE from CADSTAR help: To convert a Part Definition Attribute into a hyperlink, prefix
|
|
|
|
* the attribute name with "Link "
|
|
|
|
*/
|
2020-12-10 16:13:35 +00:00
|
|
|
struct ATTRNAME : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
2020-12-10 16:13:35 +00:00
|
|
|
struct COLUMNORDER : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
long ID;
|
|
|
|
long Order;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct COLUMNWIDTH : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
long ID;
|
|
|
|
long Width;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ATTRIBUTE_ID ID;
|
|
|
|
wxString Name; ///< Parenthesis aren't permitted in user attributes in CADSTAR. Any
|
|
|
|
///< Attributes in Parenthesis indicate an internal CADSTAR attribute
|
|
|
|
///< Examples: "(PartDescription)" "(PartDefinitionNameStem)",etc.
|
|
|
|
///TODO: create a list of all CADSTAR internal attribute names.
|
|
|
|
ATTROWNER AttributeOwner = ATTROWNER::ALL_ITEMS;
|
|
|
|
ATTRUSAGE AttributeUsage = ATTRUSAGE::UNDEFINED;
|
|
|
|
bool NoTransfer = false; ///< True="All Design Types", False="Current Design Type"
|
|
|
|
///< "All Design Types" Description from CADSTAR Help:
|
2021-04-05 13:24:57 +00:00
|
|
|
///< "The selected attribute name will be available when
|
2020-09-10 20:58:20 +00:00
|
|
|
///< any design is displayed"
|
|
|
|
///< "Current Design Type" From CADSTAR Help: This
|
|
|
|
///< restricts the availability of the selected attribute
|
|
|
|
///< name to the current design.
|
|
|
|
std::vector<COLUMNORDER> ColumnOrders;
|
|
|
|
std::vector<COLUMNWIDTH> ColumnWidths;
|
|
|
|
bool ColumnInvisible = false;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct ATTRIBUTE_VALUE : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
ATTRIBUTE_ID AttributeID;
|
|
|
|
wxString Value;
|
|
|
|
bool ReadOnly = false;
|
|
|
|
bool HasLocation = false; ///< Flag to know if this ATTRIBUTE_VALUE has a location
|
|
|
|
///< i.e. is displayed
|
|
|
|
ATTRIBUTE_LOCATION AttributeLocation;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Corresponds to CADSTAR "origin". This is used for setting a location of an attribute
|
|
|
|
* e.g. Designator (called Component Name in CADSTAR), Part Name (name of component in the
|
|
|
|
* library), etc. The atom identifier is "TEXTLOC"
|
|
|
|
*/
|
|
|
|
struct TEXT_LOCATION : ATTRIBUTE_LOCATION
|
|
|
|
{
|
|
|
|
TEXT_LOCATION()
|
|
|
|
{
|
|
|
|
// The default alignment for TEXT_LOCATION (when "NO_ALIGNMENT" is selected) is
|
|
|
|
// Bottom left, matching CADSTAR's default behaviour
|
|
|
|
Alignment = ALIGNMENT::BOTTOMLEFT;
|
|
|
|
}
|
|
|
|
ATTRIBUTE_ID AttributeID;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-02-13 20:00:17 +00:00
|
|
|
struct CADSTAR_NETCLASS : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
NETCLASS_ID ID;
|
|
|
|
wxString Name;
|
|
|
|
std::vector<ATTRIBUTE_VALUE> Attributes;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct SPCCLASSNAME : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
SPACING_CLASS_ID ID;
|
|
|
|
wxString Name;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct CODEDEFS : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
std::map<LINECODE_ID, LINECODE> LineCodes;
|
|
|
|
std::map<HATCHCODE_ID, HATCHCODE> HatchCodes;
|
|
|
|
std::map<TEXTCODE_ID, TEXTCODE> TextCodes;
|
|
|
|
std::map<ROUTECODE_ID, ROUTECODE> RouteCodes;
|
|
|
|
std::map<ATTRIBUTE_ID, ATTRNAME> AttributeNames;
|
2021-02-13 20:00:17 +00:00
|
|
|
std::map<NETCLASS_ID, CADSTAR_NETCLASS> NetClasses;
|
2020-09-10 20:58:20 +00:00
|
|
|
std::map<SPACING_CLASS_ID, SPCCLASSNAME> SpacingClassNames;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
bool ParseSubNode( XNODE* aChildNode, PARSER_CONTEXT* aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Corresponds to "Display when" Item property. From CADSTAR
|
|
|
|
* Help: "This parameter enables you to make the visibility of
|
|
|
|
* a component outline/area (or an area of component copper, or
|
|
|
|
* a string of component text) dependent on the current mirror
|
|
|
|
* status of the component.
|
2020-10-01 13:39:34 +00:00
|
|
|
*
|
2020-09-10 20:58:20 +00:00
|
|
|
* For example, you may require a string of component text to
|
|
|
|
* be displayed only when the component is mirrored."
|
|
|
|
*/
|
|
|
|
enum class SWAP_RULE
|
|
|
|
{
|
|
|
|
NO_SWAP, ///< Display when Unmirrored
|
|
|
|
USE_SWAP_LAYER, ///< Display when Mirrored
|
|
|
|
BOTH ///< Always display (Mirrored and Unmirrored)
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static SWAP_RULE ParseSwapRule( XNODE* aNode );
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct REUSEBLOCK : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
REUSEBLOCK_ID ID;
|
|
|
|
wxString Name;
|
|
|
|
wxString FileName; ///< Filename of the reuse block (usually a .pcb). Used for reloading
|
|
|
|
bool Mirror = false;
|
|
|
|
long OrientAngle = 0;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief References an element from a design reuse block
|
|
|
|
*/
|
2020-12-10 16:13:35 +00:00
|
|
|
struct REUSEBLOCKREF : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
REUSEBLOCK_ID ReuseBlockID = wxEmptyString;
|
|
|
|
wxString ItemReference = wxEmptyString; ///< For Components, this references the designator
|
|
|
|
///< in the reuse file.
|
|
|
|
///< For net elements (such as vias, routes, etc.),
|
|
|
|
///< coppers and templates, this parameter is blank.
|
|
|
|
|
|
|
|
bool IsEmpty(); ///< Determines if this is empty (i.e. no design reuse associated)
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct GROUP : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
GROUP_ID ID;
|
|
|
|
wxString Name;
|
2020-09-19 22:05:02 +00:00
|
|
|
bool Fixed = false;
|
|
|
|
bool Transfer = false; ///< If true, the group is transferred to PCB
|
|
|
|
GROUP_ID GroupID = wxEmptyString; ///< If not empty, this GROUP
|
|
|
|
///< is part of another GROUP
|
2020-09-10 20:58:20 +00:00
|
|
|
REUSEBLOCKREF ReuseBlockRef;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct FIGURE : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
FIGURE_ID ID;
|
|
|
|
LINECODE_ID LineCodeID;
|
|
|
|
LAYER_ID LayerID;
|
|
|
|
SHAPE Shape; //< Uses the component's coordinate frame if within a component
|
|
|
|
//< definition, otherwise uses the design's coordinate frame.
|
|
|
|
GROUP_ID GroupID = wxEmptyString; ///< If not empty, this FIGURE is part of a group
|
|
|
|
REUSEBLOCKREF ReuseBlockRef;
|
|
|
|
SWAP_RULE SwapRule = SWAP_RULE::BOTH; ///< Only applicable to Figures in Components
|
|
|
|
bool Fixed = false;
|
|
|
|
std::map<ATTRIBUTE_ID, ATTRIBUTE_VALUE> AttributeValues;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct TEXT : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
TEXT_ID ID;
|
|
|
|
wxString Text; //TODO: Need to lex/parse to identify design fields and hyperlinks
|
|
|
|
TEXTCODE_ID TextCodeID;
|
|
|
|
LAYER_ID LayerID;
|
|
|
|
POINT Position;
|
|
|
|
long OrientAngle = 0;
|
|
|
|
bool Mirror = false;
|
|
|
|
bool Fixed = false;
|
|
|
|
SWAP_RULE SwapRule = SWAP_RULE::BOTH;
|
|
|
|
JUSTIFICATION Justification =
|
|
|
|
JUSTIFICATION::LEFT; ///< Note: Justification has no effect on single lines of text
|
|
|
|
ALIGNMENT Alignment = ALIGNMENT::
|
|
|
|
NO_ALIGNMENT; ///< In CADSTAR The default alignment for a TEXT object (when
|
|
|
|
///< "(No Alignment()" is selected) Bottom Left of the *first line*.
|
|
|
|
///< Note that this is different from BOTTOM_LEFT (which is bottom
|
|
|
|
///< left of the whole text block)
|
|
|
|
GROUP_ID GroupID = wxEmptyString; ///< If not empty, this FIGURE is part of a group
|
|
|
|
REUSEBLOCKREF ReuseBlockRef;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-12-27 17:37:25 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext, bool aParseFields );
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct SYMDEF : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
SYMDEF_ID ID;
|
|
|
|
wxString ReferenceName; ///< This is the name which identifies the symbol in the library
|
|
|
|
///< Multiple components may exist with the same ReferenceName.
|
|
|
|
wxString Alternate; ///< This is in addition to ReferenceName. It allows defining
|
|
|
|
///< different versions, views etc. of the same basic symbol.
|
|
|
|
POINT Origin; ///< Origin of the component (this is used as the reference point
|
|
|
|
///< when placing the component in the design)
|
|
|
|
bool Stub = false; ///< When the CADSTAR Archive file is exported without the
|
|
|
|
///< component library, if components on the board are still
|
|
|
|
///< exported, the Reference and Alternate names will still be
|
|
|
|
///< exported but the content is replaced with a "STUB" atom,
|
|
|
|
///< requiring access to the original library for component
|
|
|
|
///< definition.
|
|
|
|
long Version = UNDEFINED_VALUE; ///< Version is a sequential integer number to identify
|
|
|
|
///< discrepancies between the library and the design.
|
|
|
|
|
|
|
|
std::map<FIGURE_ID, FIGURE> Figures;
|
|
|
|
std::map<TEXT_ID, TEXT> Texts;
|
|
|
|
std::map<ATTRIBUTE_ID, TEXT_LOCATION> TextLocations; ///< This contains location of
|
|
|
|
///< any attributes, including
|
|
|
|
///< designator position
|
|
|
|
std::map<ATTRIBUTE_ID, ATTRIBUTE_VALUE> AttributeValues; ///< These attributes might also
|
|
|
|
///< have a location
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void ParseIdentifiers( XNODE* aNode, PARSER_CONTEXT* aContext );
|
|
|
|
bool ParseSubNode( XNODE* aChildNode, PARSER_CONTEXT* aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct PART : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
enum class PIN_TYPE
|
|
|
|
{
|
2021-04-05 13:24:57 +00:00
|
|
|
UNCOMMITTED, ///< Uncommitted pin (default)
|
2020-09-10 20:58:20 +00:00
|
|
|
INPUT, ///< Input pin
|
|
|
|
OUTPUT_OR, ///< Output pin OR tieable
|
|
|
|
OUTPUT_NOT_OR, ///< Output pin not OR tieable
|
|
|
|
OUTPUT_NOT_NORM_OR, ///< Output pin not normally OR tieable
|
|
|
|
POWER, ///< Power pin
|
|
|
|
GROUND, ///< Ground pin
|
|
|
|
TRISTATE_BIDIR, ///< Tristate bi-directional driver pin
|
|
|
|
TRISTATE_INPUT, ///< Tristate input pin
|
|
|
|
TRISTATE_DRIVER ///< Tristate output pin
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static PIN_TYPE GetPinType( XNODE* aNode );
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct DEFINITION : PARSER ///< "PARTDEFINITION" node name
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
2020-12-10 16:13:35 +00:00
|
|
|
struct GATE : PARSER ///< "GATEDEFINITION" node name
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
GATE_ID ID; ///< Usually "A", "B", "C", etc.
|
|
|
|
wxString Name; ///< Symbol name in the symbol library
|
|
|
|
wxString Alternate; ///< Symbol alternate name in the symbol library
|
|
|
|
long PinCount; ///< Number of pins (terminals) in the symbol
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct PIN : PARSER ///< "PARTDEFINITIONPIN" node name
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @brief Positioning of pin names can be in one of four quadrants
|
|
|
|
*/
|
|
|
|
enum class POSITION
|
|
|
|
{
|
|
|
|
TOP_RIGHT = 0, ///< Default
|
|
|
|
TOP_LEFT = 1,
|
|
|
|
BOTTOM_LEFT = 2,
|
|
|
|
BOTTOM_RIGHT = 3
|
|
|
|
};
|
|
|
|
|
2021-02-02 15:35:45 +00:00
|
|
|
PART_DEFINITION_PIN_ID ID = UNDEFINED_VALUE;
|
2020-11-18 23:26:27 +00:00
|
|
|
|
|
|
|
wxString Identifier = wxEmptyString; ///< This should match a pad identifier
|
|
|
|
///< in the component footprint
|
|
|
|
///< subnode="PINIDENTIFIER". It is assumed
|
2021-01-13 02:12:59 +00:00
|
|
|
///< that this could be empty in earlier
|
2020-11-18 23:26:27 +00:00
|
|
|
///< versions of CADSTAR
|
2020-09-10 20:58:20 +00:00
|
|
|
wxString Name = wxEmptyString; ///< Can be empty. If empty the pin name
|
Fix various typos
Found via `codespell -q 3 -S *.po,./thirdparty,./Documentation/changelogs -L aactual,acount,aline,alocation,alog,anormal,anumber,aother,apoints,aparent,aray,ba,busses,dout,einstance,leaded,modul,ontext,ot,overide,serie,te,,tesselate,tesselator,tht`
2022-07-03 04:20:05 +00:00
|
|
|
///< displayed will be Identifier
|
2020-09-10 20:58:20 +00:00
|
|
|
///< (subnode="PINNAME")
|
2021-01-13 02:12:59 +00:00
|
|
|
///< This seems to be equivalent to "Pin
|
2020-11-18 23:26:27 +00:00
|
|
|
///< Number" in KiCad.
|
2020-09-10 20:58:20 +00:00
|
|
|
wxString Label = wxEmptyString; ///< This Can be empty (subnode=
|
|
|
|
///< "PINLABEL")
|
|
|
|
///< From CADSTAR Help: "Pin
|
|
|
|
///< Labels are an optional replacement
|
|
|
|
///< for the free text sometimes placed
|
|
|
|
///< in schematic symbols. Using Pin
|
|
|
|
///< Labels instead has the advantage of
|
|
|
|
///< associating each piece of label
|
|
|
|
///< text with a particular pin. This
|
|
|
|
///< means that the text remains
|
|
|
|
///< correctly placed after any Gate and
|
|
|
|
///< Pin Swaps are Back Annotated to the
|
|
|
|
///< Schematic design."
|
2021-01-13 02:12:59 +00:00
|
|
|
///< This seems to be equivalent to "Pin
|
2020-11-18 23:26:27 +00:00
|
|
|
///< Name" in KiCad.
|
2020-09-10 20:58:20 +00:00
|
|
|
wxString Signal = wxEmptyString; ///< Usually for Power/Ground pins,
|
|
|
|
///< (subnode="PINSIGNAL")
|
|
|
|
GATE_ID TerminalGate; ///< (subnode="PINTERM", param0)
|
|
|
|
TERMINAL_ID TerminalPin; ///< (subnode="PINTERM", param1)
|
|
|
|
PIN_TYPE Type = PIN_TYPE::UNCOMMITTED; ///< subnode="PINTYPE"
|
|
|
|
long Load = UNDEFINED_VALUE; ///< The electrical current expected on
|
|
|
|
///< the pin (It is unclear what the units
|
|
|
|
///< are, but only accepted values are
|
|
|
|
///< integers) subnode ="PINLOAD"
|
|
|
|
POSITION Position =
|
|
|
|
POSITION::TOP_RIGHT; ///< The pin names will use these positions when
|
|
|
|
///< the symbol is added to a schematic design
|
|
|
|
///< subnode="PINPOSITION"
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct PIN_EQUIVALENCE : PARSER ///< "PINEQUIVALENCE" Node name
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
std::vector<PART_DEFINITION_PIN_ID> PinIDs; ///< All the pins in this vector are
|
|
|
|
///< equivalent and can be swapped with
|
|
|
|
///< each other
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct SWAP_GATE : PARSER ///< "SWAPGATE" Node name (represents an "Element")
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
std::vector<PART_DEFINITION_PIN_ID> PinIDs; ///< The pins in this vector
|
|
|
|
///< describe a "gate"
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct SWAP_GROUP : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxString GateName =
|
|
|
|
wxEmptyString; ///< Optional. If not empty, should match the Name
|
|
|
|
///< attribute of one of the gates defined in the
|
|
|
|
///< part definition
|
|
|
|
|
|
|
|
bool External = false; ///< Determines if this swap group is external (and internal)
|
|
|
|
///< or internal only. External Gate swapping allows Gates on
|
|
|
|
///< different components with the same Part Definition to
|
|
|
|
///< swap with one another.
|
|
|
|
///<
|
|
|
|
///< The external swapping groups must be at the root level
|
|
|
|
///< (i.e. they cannot be contained by other swapping groups)
|
|
|
|
|
|
|
|
std::vector<SWAP_GATE> SwapGates; ///< Each of the elements in this vector can be
|
|
|
|
///< swapped with each other - i.e. *all* of the
|
|
|
|
///< pins in each swap gate can be swapped with
|
|
|
|
///< *all* in another swap gate defined in this
|
|
|
|
///< vector
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
2020-09-26 13:27:03 +00:00
|
|
|
wxString Name; ///< This name can be different to the PART name
|
|
|
|
bool HidePinNames =
|
2021-04-05 13:24:57 +00:00
|
|
|
false; ///< Specifies whether to display the pin names/identifier in
|
2020-09-26 13:27:03 +00:00
|
|
|
///< the schematic symbol or not. E.g. it is useful to display
|
|
|
|
///< pin name information for integrated circuits but less so
|
|
|
|
///< for resistors and capacitors. (subnode HIDEPINNAMES)
|
2020-09-10 20:58:20 +00:00
|
|
|
|
|
|
|
long MaxPinCount =
|
|
|
|
UNDEFINED_VALUE; ///< Optional parameter which is used for specifying the number
|
|
|
|
///< of electrical pins on the PCB component symbol to be
|
|
|
|
///< used in the part definition (this should not include
|
|
|
|
///< mechanical pins for fixing etc.). This value must be less
|
|
|
|
///< than or equal to than the number of pins on the PCB
|
|
|
|
///< Component symbol.
|
|
|
|
|
|
|
|
std::map<GATE_ID, GATE> GateSymbols;
|
|
|
|
std::map<PART_DEFINITION_PIN_ID, PIN> Pins;
|
|
|
|
std::map<ATTRIBUTE_ID, ATTRIBUTE_VALUE> AttributeValues; ///< Some attributes are
|
|
|
|
///< defined within the part
|
|
|
|
///< definition, whilst others
|
|
|
|
///< are defined in the part
|
|
|
|
std::vector<PIN_EQUIVALENCE> PinEquivalences;
|
|
|
|
std::vector<SWAP_GROUP> SwapGroups;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct PART_PIN : PARSER ///< "PARTPIN" node name
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
PART_PIN_ID ID;
|
|
|
|
wxString Name = wxEmptyString;
|
|
|
|
PIN_TYPE Type = PIN_TYPE::UNCOMMITTED;
|
|
|
|
wxString Identifier = wxEmptyString;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
PART_ID ID;
|
|
|
|
wxString Name;
|
|
|
|
long Version;
|
|
|
|
DEFINITION Definition;
|
|
|
|
std::map<PART_PIN_ID, PART_PIN> PartPins; ///< It is unclear why there are two "Pin"
|
|
|
|
///< structures in CPA files... PART_PIN seems to
|
|
|
|
///< be a reduced version of PART::DEFINITION::PIN
|
|
|
|
///< Therefore, PART_PIN is only included for
|
|
|
|
///< completeness of the parser, but won't be used
|
|
|
|
|
2021-04-05 13:24:57 +00:00
|
|
|
bool HidePinNames = false; ///< This seems to be a duplicate of DEFINITION::HidePinNames
|
2020-09-26 13:27:03 +00:00
|
|
|
///< Possibly only used in older file formats?
|
2020-09-10 20:58:20 +00:00
|
|
|
|
|
|
|
std::map<ATTRIBUTE_ID, ATTRIBUTE_VALUE> AttributeValues; ///< Some attributes are defined
|
|
|
|
///< within the part definition,
|
|
|
|
///< whilst others are defined in
|
|
|
|
///< the part itself
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct PARTS : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
std::map<PART_ID, PART> PartDefinitions;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct NET : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
2020-12-10 16:13:35 +00:00
|
|
|
struct JUNCTION : PARSER ///< "JPT" nodename.
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
NETELEMENT_ID ID; ///< First character is "J"
|
|
|
|
LAYER_ID LayerID;
|
|
|
|
POINT Location;
|
|
|
|
GROUP_ID GroupID = wxEmptyString; ///< If not empty, this JUCTION is part of a
|
|
|
|
///< group
|
|
|
|
REUSEBLOCKREF ReuseBlockRef;
|
|
|
|
bool Fixed = false;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void ParseIdentifiers( XNODE* aNode, PARSER_CONTEXT* aContext );
|
|
|
|
bool ParseSubNode( XNODE* aChildNode, PARSER_CONTEXT* aContext );
|
|
|
|
virtual void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct CONNECTION : PARSER ///< "CONN" nodename
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
NETELEMENT_ID StartNode;
|
|
|
|
NETELEMENT_ID EndNode;
|
|
|
|
ROUTECODE_ID RouteCodeID;
|
|
|
|
|
|
|
|
bool Fixed = false;
|
|
|
|
bool Hidden = false;
|
|
|
|
GROUP_ID GroupID = wxEmptyString; ///< If not empty, this connection is part of a group
|
|
|
|
REUSEBLOCKREF ReuseBlockRef;
|
|
|
|
|
|
|
|
std::map<ATTRIBUTE_ID, ATTRIBUTE_VALUE> AttributeValues; ///< It is possible to add
|
|
|
|
///< attributes solely to a
|
|
|
|
///< particular connection
|
2020-12-10 16:13:35 +00:00
|
|
|
void ParseIdentifiers( XNODE* aNode, PARSER_CONTEXT* aContext );
|
|
|
|
bool ParseSubNode( XNODE* aChildNode, PARSER_CONTEXT* aContext );
|
2020-09-27 21:09:16 +00:00
|
|
|
|
|
|
|
virtual ~CONNECTION() {}
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
NET_ID ID;
|
|
|
|
ROUTECODE_ID RouteCodeID = wxEmptyString; ///< "NETCODE" subnode
|
|
|
|
long SignalNum = UNDEFINED_VALUE; ///< This is undefined if the net has been
|
|
|
|
///< given a name. "SIGNUM" subnode.
|
|
|
|
wxString Name = wxEmptyString; ///< This is undefined (wxEmptyString) if the net
|
|
|
|
///< is unnamed. "SIGNAME" subnode
|
|
|
|
bool Highlight = false;
|
|
|
|
|
|
|
|
std::map<NETELEMENT_ID, JUNCTION> Junctions;
|
|
|
|
std::map<ATTRIBUTE_ID, ATTRIBUTE_VALUE> AttributeValues;
|
|
|
|
|
|
|
|
NETCLASS_ID NetClassID =
|
|
|
|
wxEmptyString; ///< The net might not have a net class, in which case it will be
|
|
|
|
///< wxEmptyString ("NETCLASSREF" subnode)
|
|
|
|
SPACING_CLASS_ID SpacingClassID =
|
|
|
|
wxEmptyString; ///< The net might not have a spacing class, in which case it will
|
|
|
|
///< be wxEmptyString ("SPACINGCLASS" subnode)
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void ParseIdentifiers( XNODE* aNode, PARSER_CONTEXT* aContext );
|
|
|
|
bool ParseSubNode( XNODE* aChildNode, PARSER_CONTEXT* aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
struct DOCUMENTATION_SYMBOL : PARSER
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
DOCUMENTATION_SYMBOL_ID ID;
|
|
|
|
|
|
|
|
SYMDEF_ID SymdefID; ///< Normally documentation symbols only have TEXT, FIGURE and
|
|
|
|
///< TEXT_LOCATION objects which are all drawn on the "(Undefined)"
|
|
|
|
///< Layer. When used in the design, the user has to specify which
|
|
|
|
///< layer to draw it on.
|
|
|
|
LAYER_ID LayerID; ///< Move all objects in the Symdef to this layer.
|
|
|
|
POINT Origin; ///< Origin of the component (this is used as the reference point
|
|
|
|
///< when placing the component in the design)
|
|
|
|
|
|
|
|
GROUP_ID GroupID = wxEmptyString; ///< If not empty, this component is part of a group
|
|
|
|
REUSEBLOCKREF ReuseBlockRef;
|
|
|
|
long OrientAngle = 0;
|
|
|
|
bool Mirror = false;
|
|
|
|
bool Fixed = false;
|
|
|
|
READABILITY Readability = READABILITY::BOTTOM_TO_TOP;
|
|
|
|
|
|
|
|
long ScaleRatioNumerator = 1; ///< Documentation symbols can be arbitrarily scaled when
|
|
|
|
///< added to a design
|
|
|
|
long ScaleRatioDenominator = 1; ///< Documentation symbols can be arbitrarily scaled when
|
|
|
|
///< added to a design
|
|
|
|
|
|
|
|
std::map<ATTRIBUTE_ID, ATTRIBUTE_VALUE> AttributeValues;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
2020-09-10 20:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-01-27 00:09:58 +00:00
|
|
|
struct DFLTSETTINGS : PARSER
|
|
|
|
{
|
|
|
|
COLOR_ID Color;
|
|
|
|
bool IsVisible = true;
|
|
|
|
|
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct ATTRCOL : PARSER
|
|
|
|
{
|
|
|
|
ATTRIBUTE_ID AttributeID;
|
|
|
|
COLOR_ID Color;
|
|
|
|
bool IsVisible = true;
|
2021-04-03 12:35:37 +00:00
|
|
|
bool IsPickable = true;
|
2021-01-27 00:09:58 +00:00
|
|
|
|
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct ATTRCOLORS : PARSER
|
|
|
|
{
|
|
|
|
DFLTSETTINGS DefaultSettings;
|
|
|
|
std::map<ATTRIBUTE_ID, ATTRCOL> AttributeColors;
|
|
|
|
|
2022-06-03 21:05:59 +00:00
|
|
|
bool IsVisible = true; // unclear what this represents - maybe all attributes are hidden?
|
|
|
|
|
2021-01-27 00:09:58 +00:00
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-02-02 13:39:40 +00:00
|
|
|
struct PARTNAMECOL : PARSER
|
|
|
|
{
|
2021-04-03 12:35:37 +00:00
|
|
|
COLOR_ID Color;
|
|
|
|
bool IsVisible = true;
|
|
|
|
bool IsPickable = true;
|
2021-02-02 13:39:40 +00:00
|
|
|
|
|
|
|
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
|
|
|
};
|
|
|
|
|
2020-09-10 20:58:20 +00:00
|
|
|
///////////////////////
|
|
|
|
// HELPER FUNCTIONS: //
|
|
|
|
///////////////////////
|
|
|
|
|
|
|
|
|
2020-07-30 22:42:56 +00:00
|
|
|
static void InsertAttributeAtEnd( XNODE* aNode, wxString aValue );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Reads a CADSTAR Archive file (S-parameter format)
|
2020-10-01 13:39:34 +00:00
|
|
|
* @param aFileName
|
2020-07-30 22:42:56 +00:00
|
|
|
* @param aFileTypeIdentifier Identifier of the first node in the file to check against.
|
|
|
|
E.g. "CADSTARPCB"
|
2021-09-09 21:15:38 +00:00
|
|
|
* @param aProgressReporter Pointer to a Progress Reporter to report progress to.
|
2020-10-01 13:39:34 +00:00
|
|
|
* @return XNODE pointing to the top of the tree for further parsing. Each node has the first
|
|
|
|
* element as the node's name and subsequent elements as node attributes ("attr0",
|
2020-07-30 22:42:56 +00:00
|
|
|
* "attr1", "attr2", etc.). Caller is responsible for deleting to avoid memory leaks.
|
|
|
|
* @throws IO_ERROR
|
|
|
|
*/
|
2021-09-09 21:15:38 +00:00
|
|
|
static XNODE* LoadArchiveFile( const wxString& aFileName, const wxString& aFileTypeIdentifier,
|
|
|
|
PROGRESS_REPORTER* aProgressReporter = nullptr );
|
2020-07-30 22:42:56 +00:00
|
|
|
|
2020-09-02 21:48:18 +00:00
|
|
|
/**
|
2020-10-01 13:39:34 +00:00
|
|
|
* @brief
|
|
|
|
* @param aAttribute
|
|
|
|
* @return
|
2020-09-02 21:48:18 +00:00
|
|
|
*/
|
|
|
|
static bool IsValidAttribute( wxXmlAttribute* aAttribute );
|
|
|
|
|
2020-07-30 22:42:56 +00:00
|
|
|
/**
|
2020-10-01 13:39:34 +00:00
|
|
|
* @brief
|
|
|
|
* @param aNode
|
|
|
|
* @param aID
|
2020-09-13 21:42:17 +00:00
|
|
|
* @param aIsRequired Prevents exception throwing if false.
|
2020-09-10 20:58:20 +00:00
|
|
|
* @return returns the value (wxString) of attribute "attrX" in aNode where 'X' is aID
|
2020-07-30 22:42:56 +00:00
|
|
|
* @throws IO_ERROR if attribute does not exist
|
|
|
|
*/
|
2020-09-19 22:05:02 +00:00
|
|
|
static wxString GetXmlAttributeIDString(
|
|
|
|
XNODE* aNode, unsigned int aID, bool aIsRequired = true );
|
2020-07-30 22:42:56 +00:00
|
|
|
|
|
|
|
/**
|
2020-10-01 13:39:34 +00:00
|
|
|
* @brief
|
|
|
|
* @param aNode
|
|
|
|
* @param aID
|
2020-09-13 21:42:17 +00:00
|
|
|
* @param aIsRequired Prevents exception throwing if false.
|
2020-09-10 20:58:20 +00:00
|
|
|
* @return returns the value (long) of attribute "attrX" in aNode where 'X' is aID
|
2020-07-30 22:42:56 +00:00
|
|
|
* @throws IO_ERROR if attribute does not exist
|
|
|
|
*/
|
2020-09-13 21:42:17 +00:00
|
|
|
static long GetXmlAttributeIDLong( XNODE* aNode, unsigned int aID, bool aIsRequired = true );
|
2020-07-30 22:42:56 +00:00
|
|
|
|
|
|
|
/**
|
2020-10-01 13:39:34 +00:00
|
|
|
* @brief
|
|
|
|
* @param aNode
|
2020-07-30 22:42:56 +00:00
|
|
|
* @throw IO_ERROR if a child node was found
|
|
|
|
*/
|
|
|
|
static void CheckNoChildNodes( XNODE* aNode );
|
|
|
|
|
|
|
|
/**
|
2020-10-01 13:39:34 +00:00
|
|
|
* @brief
|
|
|
|
* @param aNode
|
2020-07-30 22:42:56 +00:00
|
|
|
* @throw IO_ERROR if a node adjacent to aNode was found
|
|
|
|
*/
|
|
|
|
static void CheckNoNextNodes( XNODE* aNode );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief
|
|
|
|
* @param aNode with a child node containing an EVALUE
|
2020-10-01 13:39:34 +00:00
|
|
|
* @param aValueToParse
|
2020-07-30 22:42:56 +00:00
|
|
|
* @throw IO_ERROR if unable to parse or node is not an EVALUE
|
|
|
|
*/
|
2020-12-10 16:13:35 +00:00
|
|
|
static void ParseChildEValue( XNODE* aNode, PARSER_CONTEXT* aContext, EVALUE& aValueToParse );
|
2020-07-30 22:42:56 +00:00
|
|
|
|
|
|
|
/**
|
2021-04-05 13:24:57 +00:00
|
|
|
* @brief if no children are present, it just returns an empty
|
2020-07-30 22:42:56 +00:00
|
|
|
* vector (without throwing an exception)
|
|
|
|
* @param aNode containing a series of POINT objects
|
|
|
|
* @param aTestAllChildNodes
|
|
|
|
* @param aExpectedNumPoints if UNDEFINED_VALUE (i.e. -1), this is check is disabled
|
|
|
|
* @return std::vector containing all POINT objects
|
|
|
|
* @throw IO_ERROR if one of the following:
|
|
|
|
* - Unable to parse a POINT object
|
|
|
|
* - aTestAllChildNodes is true and one of the child nodes is not a valid POINT object
|
|
|
|
* - aExpectedNumPoints is non-negative and the number of POINT objects found is different
|
|
|
|
*/
|
2020-12-10 16:13:35 +00:00
|
|
|
static std::vector<POINT> ParseAllChildPoints( XNODE* aNode, PARSER_CONTEXT* aContext,
|
|
|
|
bool aTestAllChildNodes = false, int aExpectedNumPoints = UNDEFINED_VALUE );
|
2020-07-30 22:42:56 +00:00
|
|
|
|
|
|
|
/**
|
2021-04-05 13:24:57 +00:00
|
|
|
* @brief if no children are present, it just returns an empty
|
2020-07-30 22:42:56 +00:00
|
|
|
* vector (without throwing an exception)
|
|
|
|
* @param aNode containing a series of VERTEX objects
|
|
|
|
* @param aTestAllChildNodes
|
|
|
|
* @param aExpectedNumPoints if -1, this is check is disabled
|
|
|
|
* @return std::vector containing all VERTEX objects
|
|
|
|
* @throw IO_ERROR if one of the following:
|
|
|
|
* - Unable to parse a VERTEX object
|
|
|
|
* - aTestAllChildNodes is true and one of the child nodes is not a valid VERTEX object
|
|
|
|
*/
|
|
|
|
static std::vector<VERTEX> ParseAllChildVertices(
|
2020-12-10 16:13:35 +00:00
|
|
|
XNODE* aNode, PARSER_CONTEXT* aContext, bool aTestAllChildNodes = false );
|
2020-07-30 22:42:56 +00:00
|
|
|
|
|
|
|
/**
|
2021-04-05 13:24:57 +00:00
|
|
|
* @brief if no children are present, it just returns an empty
|
2020-07-30 22:42:56 +00:00
|
|
|
* vector (without throwing an exception)
|
|
|
|
* @param aNode containing a series of CUTOUT objects
|
|
|
|
* @param aTestAllChildNodes
|
|
|
|
* @param aExpectedNumPoints if -1, this is check is disabled
|
|
|
|
* @return std::vector containing all CUTOUT objects
|
|
|
|
* @throw IO_ERROR if one of the following:
|
|
|
|
* - Unable to parse a CUTOUT object
|
|
|
|
* - aTestAllChildNodes is true and one of the child nodes is not a valid CUTOUT object
|
|
|
|
*/
|
|
|
|
static std::vector<CUTOUT> ParseAllChildCutouts(
|
2020-12-10 16:13:35 +00:00
|
|
|
XNODE* aNode, PARSER_CONTEXT* aContext, bool aTestAllChildNodes = false );
|
2020-12-30 02:04:19 +00:00
|
|
|
|
2021-09-09 21:15:38 +00:00
|
|
|
static long GetNumberOfChildNodes( XNODE* aNode );
|
|
|
|
|
|
|
|
static long GetNumberOfStepsForReporting( XNODE* aRootNode,
|
|
|
|
std::vector<wxString> aSubNodeChildrenToCount );
|
|
|
|
|
2021-09-01 18:24:42 +00:00
|
|
|
/**
|
|
|
|
* @brief Convert a string with CADSTAR overbar characters to equivalent in KiCad
|
|
|
|
* @param aCadstarString Input string
|
|
|
|
* @return KiCad string with overbar characters
|
|
|
|
*/
|
|
|
|
static wxString HandleTextOverbar( wxString aCadstarString );
|
|
|
|
|
2020-12-30 02:04:19 +00:00
|
|
|
/**
|
|
|
|
* Corrects the position of a text element that had NO_ALIGNMENT in CADSTAR. Assumes that the
|
|
|
|
* provided text element has been initialised with a position and orientation.
|
|
|
|
* @param aKiCadTextItem a Kicad item to correct
|
|
|
|
*/
|
|
|
|
static void FixTextPositionNoAlignment( EDA_TEXT* aKiCadTextItem );
|
|
|
|
|
2021-01-27 00:09:58 +00:00
|
|
|
static wxString generateLibName( const wxString& aRefName, const wxString& aAlternateName )
|
|
|
|
{
|
|
|
|
return aRefName
|
|
|
|
+ ( ( aAlternateName.size() > 0 ) ? ( wxT( " (" ) + aAlternateName + wxT( ")" ) )
|
|
|
|
: wxT( "" ) );
|
|
|
|
}
|
|
|
|
|
2021-09-09 21:15:38 +00:00
|
|
|
|
2021-02-13 20:00:17 +00:00
|
|
|
protected:
|
2021-09-09 21:15:38 +00:00
|
|
|
void checkPoint(); ///< Updates m_progressReporter or throws if user cancelled
|
|
|
|
|
|
|
|
PARSER_CONTEXT m_context;
|
|
|
|
PROGRESS_REPORTER* m_progressReporter; // optional; may be nullptr
|
2021-02-13 20:00:17 +00:00
|
|
|
|
|
|
|
|
2020-09-06 17:00:02 +00:00
|
|
|
}; // class CADSTAR_ARCHIVE_PARSER
|
2020-07-30 22:42:56 +00:00
|
|
|
|
2020-09-06 17:00:02 +00:00
|
|
|
#endif // CADSTAR_ARCHIVE_PARSER_H_
|