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.cpp
|
|
|
|
* @brief Helper functions and common defines between schematic and PCB Archive files
|
2020-07-30 22:42:56 +00:00
|
|
|
*/
|
2021-03-20 15:35:37 +00:00
|
|
|
#include <wx/filename.h>
|
2021-06-06 13:28:02 +00:00
|
|
|
#include <wx/log.h>
|
|
|
|
#include <wx/xml/xml.h>
|
2020-07-30 22:42:56 +00:00
|
|
|
|
2021-06-06 23:31:15 +00:00
|
|
|
#include <dsnlexer.h>
|
2020-08-29 18:09:48 +00:00
|
|
|
#include <plugins/cadstar/cadstar_archive_parser.h>
|
2021-06-06 23:11:35 +00:00
|
|
|
#include <eda_item.h>
|
2020-12-30 02:04:19 +00:00
|
|
|
#include <eda_text.h>
|
2021-03-20 15:35:37 +00:00
|
|
|
#include <macros.h>
|
2021-09-09 21:15:38 +00:00
|
|
|
#include <progress_reporter.h>
|
2021-09-01 18:24:42 +00:00
|
|
|
#include <string_utils.h>
|
2020-12-30 02:04:19 +00:00
|
|
|
#include <trigo.h>
|
2020-07-30 22:42:56 +00:00
|
|
|
|
2020-10-19 17:11:52 +00:00
|
|
|
// Ratio derived from CADSTAR default font. See doxygen comment in cadstar_archive_parser.h
|
2020-10-18 17:15:46 +00:00
|
|
|
const double CADSTAR_ARCHIVE_PARSER::TXT_HEIGHT_RATIO = ( 24.0 - 5.0 ) / 24.0;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
// Cadstar fields and their KiCad equivalent
|
|
|
|
const std::map<CADSTAR_ARCHIVE_PARSER::TEXT_FIELD_NAME, wxString>
|
2021-02-13 20:00:17 +00:00
|
|
|
CADSTAR_ARCHIVE_PARSER::CADSTAR_TO_KICAD_FIELDS =
|
2020-12-10 16:13:35 +00:00
|
|
|
{ { TEXT_FIELD_NAME::DESIGN_TITLE, wxT( "DESIGN_TITLE" ) },
|
|
|
|
{ TEXT_FIELD_NAME::SHORT_JOBNAME, wxT( "SHORT_JOBNAME" ) },
|
|
|
|
{ TEXT_FIELD_NAME::LONG_JOBNAME, wxT( "LONG_JOBNAME" ) },
|
|
|
|
{ TEXT_FIELD_NAME::NUM_OF_SHEETS, wxT( "##" ) },
|
|
|
|
{ TEXT_FIELD_NAME::SHEET_NUMBER, wxT( "#" ) },
|
|
|
|
{ TEXT_FIELD_NAME::SHEET_NAME, wxT( "SHEETNAME" ) },
|
|
|
|
{ TEXT_FIELD_NAME::VARIANT_NAME, wxT( "VARIANT_NAME" ) },
|
|
|
|
{ TEXT_FIELD_NAME::VARIANT_DESCRIPTION, wxT( "VARIANT_DESCRIPTION" ) },
|
|
|
|
{ TEXT_FIELD_NAME::REG_USER, wxT( "REG_USER" ) },
|
|
|
|
{ TEXT_FIELD_NAME::COMPANY_NAME, wxT( "COMPANY_NAME" ) },
|
|
|
|
{ TEXT_FIELD_NAME::CURRENT_USER, wxT( "CURRENT_USER" ) },
|
|
|
|
{ TEXT_FIELD_NAME::DATE, wxT( "DATE" ) },
|
|
|
|
{ TEXT_FIELD_NAME::TIME, wxT( "TIME" ) },
|
|
|
|
{ TEXT_FIELD_NAME::MACHINE_NAME, wxT( "MACHINE_NAME" ) } };
|
|
|
|
|
|
|
|
|
|
|
|
void CADSTAR_ARCHIVE_PARSER::FORMAT::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "FORMAT" ) );
|
|
|
|
|
|
|
|
Type = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
SomeInt = GetXmlAttributeIDLong( aNode, 1 );
|
|
|
|
Version = GetXmlAttributeIDLong( aNode, 2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::TIMESTAMP::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "TIMESTAMP" ) );
|
|
|
|
|
|
|
|
if( !GetXmlAttributeIDString( aNode, 0 ).ToLong( &Year )
|
|
|
|
|| !GetXmlAttributeIDString( aNode, 1 ).ToLong( &Month )
|
|
|
|
|| !GetXmlAttributeIDString( aNode, 2 ).ToLong( &Day )
|
|
|
|
|| !GetXmlAttributeIDString( aNode, 3 ).ToLong( &Hour )
|
|
|
|
|| !GetXmlAttributeIDString( aNode, 4 ).ToLong( &Minute )
|
|
|
|
|| !GetXmlAttributeIDString( aNode, 5 ).ToLong( &Second ) )
|
|
|
|
THROW_PARSING_IO_ERROR( wxT( "TIMESTAMP" ), wxString::Format( "HEADER" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::HEADER::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "HEADER" ) );
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
|
|
|
{
|
|
|
|
wxString nodeName = cNode->GetName();
|
|
|
|
|
|
|
|
if( nodeName == wxT( "FORMAT" ) )
|
|
|
|
{
|
2020-12-10 16:13:35 +00:00
|
|
|
Format.Parse( cNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
|
|
|
else if( nodeName == wxT( "JOBFILE" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
JobFile = GetXmlAttributeIDString( cNode, 0 );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( nodeName == wxT( "JOBTITLE" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
JobTitle = GetXmlAttributeIDString( cNode, 0 );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( nodeName == wxT( "GENERATOR" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
Generator = GetXmlAttributeIDString( cNode, 0 );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( nodeName == wxT( "RESOLUTION" ) )
|
|
|
|
{
|
|
|
|
XNODE* subNode = cNode->GetChildren();
|
2020-09-27 13:10:59 +00:00
|
|
|
|
2020-09-10 20:58:20 +00:00
|
|
|
if( ( subNode->GetName() == wxT( "METRIC" ) )
|
|
|
|
&& ( GetXmlAttributeIDString( subNode, 0 ) == wxT( "HUNDREDTH" ) )
|
|
|
|
&& ( GetXmlAttributeIDString( subNode, 1 ) == wxT( "MICRON" ) ) )
|
|
|
|
{
|
|
|
|
Resolution = RESOLUTION::HUNDREDTH_MICRON;
|
|
|
|
}
|
2020-09-27 13:10:59 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// TODO Need to find out if there are other possible resolutions. Logically
|
|
|
|
// there must be other base units that could be used, such as "IMPERIAL INCH"
|
|
|
|
// or "METRIC MM" but so far none of settings in CADSTAR generated a different
|
|
|
|
// output resolution to "HUNDREDTH MICRON"
|
2020-09-10 20:58:20 +00:00
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( subNode->GetName(), wxT( "HEADER->RESOLUTION" ) );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
|
|
|
else if( nodeName == wxT( "TIMESTAMP" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-12-10 16:13:35 +00:00
|
|
|
Timestamp.Parse( cNode, aContext );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), wxT( "HEADER" ) );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::VARIANT::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "VMASTER" ) || aNode->GetName() == wxT( "VARIANT" ) );
|
|
|
|
|
|
|
|
ID = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
|
|
|
|
if( aNode->GetName() == wxT( "VMASTER" ) )
|
|
|
|
{
|
|
|
|
Name = GetXmlAttributeIDString( aNode, 1 );
|
|
|
|
Description = GetXmlAttributeIDString( aNode, 2 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ParentID = GetXmlAttributeIDString( aNode, 1 );
|
|
|
|
Name = GetXmlAttributeIDString( aNode, 2 );
|
|
|
|
Description = GetXmlAttributeIDString( aNode, 3 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::VARIANT_HIERARCHY::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "VHIERARCHY" ) );
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
|
|
|
{
|
|
|
|
if( cNode->GetName() == wxT( "VMASTER" ) || cNode->GetName() == wxT( "VARIANT" ) )
|
|
|
|
{
|
|
|
|
VARIANT variant;
|
2020-12-10 16:13:35 +00:00
|
|
|
variant.Parse( cNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
Variants.insert( std::make_pair( variant.ID, variant ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), cNode->GetName() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::LINECODE::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "LINECODE" ) );
|
|
|
|
|
|
|
|
ID = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
Name = GetXmlAttributeIDString( aNode, 1 );
|
|
|
|
|
|
|
|
if( !GetXmlAttributeIDString( aNode, 2 ).ToLong( &Width ) )
|
|
|
|
THROW_PARSING_IO_ERROR( wxT( "Line Width" ), wxString::Format( "LINECODE -> %s", Name ) );
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
if( cNode->GetName() != wxT( "STYLE" ) )
|
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), wxString::Format( "LINECODE -> %s", Name ) );
|
|
|
|
|
|
|
|
wxString styleStr = GetXmlAttributeIDString( cNode, 0 );
|
|
|
|
|
|
|
|
if( styleStr == wxT( "SOLID" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
Style = LINESTYLE::SOLID;
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( styleStr == wxT( "DASH" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
Style = LINESTYLE::DASH;
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( styleStr == wxT( "DASHDOT" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
Style = LINESTYLE::DASHDOT;
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( styleStr == wxT( "DASHDOTDOT" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
Style = LINESTYLE::DASHDOTDOT;
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( styleStr == wxT( "DOT" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
Style = LINESTYLE::DOT;
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
THROW_UNKNOWN_PARAMETER_IO_ERROR( wxString::Format( "STYLE %s", styleStr ),
|
|
|
|
wxString::Format( "LINECODE -> %s", Name ) );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::HATCH::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "HATCH" ) );
|
|
|
|
|
|
|
|
Step = GetXmlAttributeIDLong( aNode, 0 );
|
|
|
|
LineWidth = GetXmlAttributeIDLong( aNode, 2 );
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
if( !cNode || cNode->GetName() != wxT( "ORIENT" ) )
|
|
|
|
THROW_MISSING_NODE_IO_ERROR( wxT( "ORIENT" ), wxT( "HATCH" ) );
|
|
|
|
|
|
|
|
OrientAngle = GetXmlAttributeIDLong( cNode, 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::HATCHCODE::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "HATCHCODE" ) );
|
|
|
|
|
|
|
|
ID = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
Name = GetXmlAttributeIDString( aNode, 1 );
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
wxString location = wxString::Format( "HATCHCODE -> %s", Name );
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
|
|
|
{
|
|
|
|
if( cNode->GetName() != wxT( "HATCH" ) )
|
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), location );
|
|
|
|
|
|
|
|
HATCH hatch;
|
2020-12-10 16:13:35 +00:00
|
|
|
hatch.Parse( cNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
Hatches.push_back( hatch );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::FONT::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "FONT" ) );
|
|
|
|
|
|
|
|
Name = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
Modifier1 = GetXmlAttributeIDLong( aNode, 1 );
|
|
|
|
Modifier2 = GetXmlAttributeIDLong( aNode, 2 );
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
|
|
|
{
|
|
|
|
wxString cNodeName = cNode->GetName();
|
|
|
|
|
|
|
|
if( cNodeName == wxT( "ITALIC" ) )
|
|
|
|
Italic = true;
|
|
|
|
else if( cNodeName == wxT( "KERNING" ) )
|
|
|
|
KerningPairs = true;
|
|
|
|
else
|
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::TEXTCODE::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "TEXTCODE" ) );
|
|
|
|
|
|
|
|
ID = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
Name = GetXmlAttributeIDString( aNode, 1 );
|
|
|
|
|
|
|
|
LineWidth = GetXmlAttributeIDLong( aNode, 2 );
|
|
|
|
Height = GetXmlAttributeIDLong( aNode, 3 );
|
|
|
|
Width = GetXmlAttributeIDLong( aNode, 4 );
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
if( cNode )
|
|
|
|
{
|
|
|
|
if( cNode->GetName() == wxT( "FONT" ) )
|
2020-12-10 16:13:35 +00:00
|
|
|
Font.Parse( cNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
else
|
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), aNode->GetName() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::ROUTEREASSIGN::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-10-12 19:24:11 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "ROUTEREASSIGN" ) );
|
|
|
|
|
|
|
|
LayerID = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
OptimalWidth = GetXmlAttributeIDLong( aNode, 1, false );
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
|
|
|
{
|
|
|
|
wxString cNodeName = cNode->GetName();
|
|
|
|
|
|
|
|
if( cNodeName == wxT( "NECKWIDTH" ) )
|
|
|
|
NeckedWidth = GetXmlAttributeIDLong( cNode, 0 );
|
|
|
|
else if( cNodeName == wxT( "SROUTEWIDTH" ) )
|
|
|
|
OptimalWidth = GetXmlAttributeIDLong( cNode, 0 );
|
|
|
|
else if( cNodeName == wxT( "MINWIDTH" ) )
|
|
|
|
MinWidth = GetXmlAttributeIDLong( cNode, 0 );
|
|
|
|
else if( cNodeName == wxT( "MAXWIDTH" ) )
|
|
|
|
MaxWidth = GetXmlAttributeIDLong( cNode, 0 );
|
|
|
|
else
|
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::ROUTECODE::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "ROUTECODE" ) );
|
|
|
|
|
2020-09-13 21:42:17 +00:00
|
|
|
ID = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
Name = GetXmlAttributeIDString( aNode, 1 );
|
|
|
|
OptimalWidth = GetXmlAttributeIDLong( aNode, 2, false );
|
2020-09-10 20:58:20 +00:00
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
|
|
|
{
|
|
|
|
wxString cNodeName = cNode->GetName();
|
|
|
|
|
|
|
|
if( cNodeName == wxT( "NECKWIDTH" ) )
|
2020-10-12 19:24:11 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
NeckedWidth = GetXmlAttributeIDLong( cNode, 0 );
|
2020-10-12 19:24:11 +00:00
|
|
|
}
|
2020-09-13 21:42:17 +00:00
|
|
|
else if( cNodeName == wxT( "SROUTEWIDTH" ) )
|
2020-10-12 19:24:11 +00:00
|
|
|
{
|
2020-09-13 21:42:17 +00:00
|
|
|
OptimalWidth = GetXmlAttributeIDLong( cNode, 0 );
|
2020-10-12 19:24:11 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "MINWIDTH" ) )
|
2020-10-12 19:24:11 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
MinWidth = GetXmlAttributeIDLong( cNode, 0 );
|
2020-10-12 19:24:11 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "MAXWIDTH" ) )
|
2020-10-12 19:24:11 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
MaxWidth = GetXmlAttributeIDLong( cNode, 0 );
|
2020-10-12 19:24:11 +00:00
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "ROUTEREASSIGN" ) )
|
|
|
|
{
|
|
|
|
ROUTEREASSIGN routereassign;
|
2020-12-10 16:13:35 +00:00
|
|
|
routereassign.Parse( cNode, aContext );
|
2020-10-12 19:24:11 +00:00
|
|
|
RouteReassigns.push_back( routereassign );
|
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else
|
2020-10-12 19:24:11 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
|
2020-10-12 19:24:11 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
double CADSTAR_ARCHIVE_PARSER::EVALUE::GetDouble()
|
|
|
|
{
|
|
|
|
return Base * std::pow( 10.0, Exponent );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::EVALUE::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-07-30 22:42:56 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
wxASSERT( aNode->GetName() == wxT( "E" ) );
|
|
|
|
|
|
|
|
if( ( !GetXmlAttributeIDString( aNode, 0 ).ToLong( &Base ) )
|
|
|
|
|| ( !GetXmlAttributeIDString( aNode, 1 ).ToLong( &Exponent ) ) )
|
|
|
|
{
|
|
|
|
THROW_PARSING_IO_ERROR( wxT( "Base and Exponent" ),
|
2020-09-19 22:05:02 +00:00
|
|
|
wxString::Format(
|
|
|
|
"%s->%s", aNode->GetParent()->GetName(), aNode->GetParent()->GetName() ) );
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::POINT::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "PT" ) );
|
|
|
|
|
|
|
|
x = GetXmlAttributeIDLong( aNode, 0 );
|
|
|
|
y = GetXmlAttributeIDLong( aNode, 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::LONGPOINT::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "PT" ) );
|
|
|
|
|
|
|
|
x = GetXmlAttributeIDLong( aNode, 0 );
|
|
|
|
y = GetXmlAttributeIDLong( aNode, 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CADSTAR_ARCHIVE_PARSER::VERTEX::IsVertex( XNODE* aNode )
|
|
|
|
{
|
|
|
|
wxString aNodeName = aNode->GetName();
|
|
|
|
|
|
|
|
if( aNodeName == wxT( "PT" ) || aNodeName == wxT( "ACWARC" ) || aNodeName == wxT( "CWARC" )
|
|
|
|
|| aNodeName == wxT( "CWSEMI" ) || aNodeName == wxT( "ACWSEMI" ) )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::VERTEX::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( IsVertex( aNode ) );
|
|
|
|
|
|
|
|
wxString aNodeName = aNode->GetName();
|
|
|
|
|
|
|
|
if( aNodeName == wxT( "PT" ) )
|
|
|
|
{
|
|
|
|
Type = VERTEX_TYPE::POINT;
|
|
|
|
Center.x = UNDEFINED_VALUE;
|
|
|
|
Center.y = UNDEFINED_VALUE;
|
2020-12-10 16:13:35 +00:00
|
|
|
End.Parse( aNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
|
|
|
else if( aNodeName == wxT( "ACWARC" ) || aNodeName == wxT( "CWARC" ) )
|
|
|
|
{
|
|
|
|
if( aNodeName == wxT( "ACWARC" ) )
|
|
|
|
Type = VERTEX_TYPE::ANTICLOCKWISE_ARC;
|
|
|
|
else
|
|
|
|
Type = VERTEX_TYPE::CLOCKWISE_ARC;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
std::vector<POINT> pts = ParseAllChildPoints( aNode, aContext, true, 2 );
|
2020-09-10 20:58:20 +00:00
|
|
|
|
|
|
|
Center = pts[0];
|
|
|
|
End = pts[1];
|
|
|
|
}
|
|
|
|
else if( aNodeName == wxT( "ACWSEMI" ) || aNodeName == wxT( "CWSEMI" ) )
|
|
|
|
{
|
|
|
|
if( aNodeName == wxT( "ACWSEMI" ) )
|
|
|
|
Type = VERTEX_TYPE::ANTICLOCKWISE_SEMICIRCLE;
|
|
|
|
else
|
|
|
|
Type = VERTEX_TYPE::CLOCKWISE_SEMICIRCLE;
|
|
|
|
|
|
|
|
Center.x = UNDEFINED_VALUE;
|
|
|
|
Center.y = UNDEFINED_VALUE;
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
std::vector<POINT> pts = ParseAllChildPoints( aNode, aContext, true, 1 );
|
2020-09-10 20:58:20 +00:00
|
|
|
|
|
|
|
End = pts[0];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxASSERT_MSG( true, wxT( "Unknown VERTEX type" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::CUTOUT::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "CUTOUT" ) );
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
Vertices = ParseAllChildVertices( aNode, aContext, true );
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CADSTAR_ARCHIVE_PARSER::SHAPE::IsShape( XNODE* aNode )
|
|
|
|
{
|
|
|
|
wxString aNodeName = aNode->GetName();
|
|
|
|
|
|
|
|
if( aNodeName == wxT( "OPENSHAPE" ) || aNodeName == wxT( "OUTLINE" )
|
|
|
|
|| aNodeName == wxT( "SOLID" ) || aNodeName == wxT( "HATCHED" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
return true;
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
return false;
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::SHAPE::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( IsShape( aNode ) );
|
|
|
|
|
|
|
|
wxString aNodeName = aNode->GetName();
|
|
|
|
|
|
|
|
if( aNodeName == wxT( "OPENSHAPE" ) )
|
|
|
|
{
|
|
|
|
Type = SHAPE_TYPE::OPENSHAPE;
|
2020-12-10 16:13:35 +00:00
|
|
|
Vertices = ParseAllChildVertices( aNode, aContext, true );
|
2020-09-10 20:58:20 +00:00
|
|
|
Cutouts.clear();
|
|
|
|
HatchCodeID = wxEmptyString;
|
|
|
|
}
|
|
|
|
else if( aNodeName == wxT( "OUTLINE" ) )
|
|
|
|
{
|
|
|
|
Type = SHAPE_TYPE::OUTLINE;
|
2020-12-10 16:13:35 +00:00
|
|
|
Vertices = ParseAllChildVertices( aNode, aContext, false );
|
|
|
|
Cutouts = ParseAllChildCutouts( aNode, aContext, false );
|
2020-09-10 20:58:20 +00:00
|
|
|
HatchCodeID = wxEmptyString;
|
|
|
|
}
|
|
|
|
else if( aNodeName == wxT( "SOLID" ) )
|
|
|
|
{
|
|
|
|
Type = SHAPE_TYPE::SOLID;
|
2020-12-10 16:13:35 +00:00
|
|
|
Vertices = ParseAllChildVertices( aNode, aContext, false );
|
|
|
|
Cutouts = ParseAllChildCutouts( aNode, aContext, false );
|
2020-09-10 20:58:20 +00:00
|
|
|
HatchCodeID = wxEmptyString;
|
|
|
|
}
|
|
|
|
else if( aNodeName == wxT( "HATCHED" ) )
|
|
|
|
{
|
|
|
|
Type = SHAPE_TYPE::HATCHED;
|
2020-12-10 16:13:35 +00:00
|
|
|
Vertices = ParseAllChildVertices( aNode, aContext, false );
|
|
|
|
Cutouts = ParseAllChildCutouts( aNode, aContext, false );
|
2020-09-10 20:58:20 +00:00
|
|
|
HatchCodeID = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
}
|
|
|
|
else
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
wxASSERT_MSG( true, wxT( "Unknown SHAPE type" ) );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
|
|
|
|
2020-09-27 13:10:59 +00:00
|
|
|
|
2020-09-10 20:58:20 +00:00
|
|
|
CADSTAR_ARCHIVE_PARSER::UNITS CADSTAR_ARCHIVE_PARSER::ParseUnits( XNODE* aNode )
|
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "UNITS" ) );
|
|
|
|
|
|
|
|
wxString unit = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
|
|
|
|
if( unit == wxT( "CENTIMETER" ) )
|
|
|
|
return UNITS::CENTIMETER;
|
|
|
|
else if( unit == wxT( "INCH" ) )
|
|
|
|
return UNITS::INCH;
|
|
|
|
else if( unit == wxT( "METER" ) )
|
|
|
|
return UNITS::METER;
|
|
|
|
else if( unit == wxT( "MICROMETRE" ) )
|
|
|
|
return UNITS::MICROMETRE;
|
|
|
|
else if( unit == wxT( "MM" ) )
|
|
|
|
return UNITS::MM;
|
|
|
|
else if( unit == wxT( "THOU" ) )
|
|
|
|
return UNITS::THOU;
|
|
|
|
else if( unit == wxT( "DESIGN" ) )
|
|
|
|
return UNITS::DESIGN;
|
|
|
|
else
|
|
|
|
THROW_UNKNOWN_PARAMETER_IO_ERROR( unit, wxT( "UNITS" ) );
|
|
|
|
|
|
|
|
return UNITS();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CADSTAR_ARCHIVE_PARSER::ANGUNITS CADSTAR_ARCHIVE_PARSER::ParseAngunits( XNODE* aNode )
|
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "ANGUNITS" ) );
|
|
|
|
|
|
|
|
wxString angUnitStr = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
|
|
|
|
if( angUnitStr == wxT( "DEGREES" ) )
|
|
|
|
return ANGUNITS::DEGREES;
|
|
|
|
else if( angUnitStr == wxT( "RADIANS" ) )
|
|
|
|
return ANGUNITS::RADIANS;
|
|
|
|
else
|
|
|
|
THROW_UNKNOWN_PARAMETER_IO_ERROR( angUnitStr, aNode->GetName() );
|
|
|
|
|
|
|
|
return ANGUNITS();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CADSTAR_ARCHIVE_PARSER::GRID::IsGrid( XNODE* aNode )
|
|
|
|
{
|
|
|
|
wxString aNodeName = aNode->GetName();
|
|
|
|
|
|
|
|
if( aNodeName == wxT( "FRACTIONALGRID" ) || aNodeName == wxT( "STEPGRID" ) )
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::GRID::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( IsGrid( aNode ) );
|
|
|
|
|
|
|
|
wxString aNodeName = aNode->GetName();
|
|
|
|
|
|
|
|
if( aNodeName == wxT( "FRACTIONALGRID" ) )
|
|
|
|
Type = GRID_TYPE::FRACTIONALGRID;
|
|
|
|
else if( aNodeName == wxT( "STEPGRID" ) )
|
|
|
|
Type = GRID_TYPE::STEPGRID;
|
|
|
|
else
|
|
|
|
wxASSERT_MSG( true, wxT( "Unknown Grid Type" ) );
|
|
|
|
|
|
|
|
Name = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
Param1 = GetXmlAttributeIDLong( aNode, 1 );
|
|
|
|
Param2 = GetXmlAttributeIDLong( aNode, 2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::GRIDS::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "GRIDS" ) );
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
|
|
|
{
|
|
|
|
wxString cNodeName = cNode->GetName();
|
|
|
|
|
|
|
|
if( cNodeName == wxT( "WORKINGGRID" ) )
|
|
|
|
{
|
|
|
|
XNODE* workingGridNode = cNode->GetChildren();
|
|
|
|
|
|
|
|
if( !GRID::IsGrid( workingGridNode ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR(
|
|
|
|
workingGridNode->GetName(), wxT( "GRIDS -> WORKINGGRID" ) );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-12-10 16:13:35 +00:00
|
|
|
WorkingGrid.Parse( workingGridNode, aContext );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "SCREENGRID" ) )
|
|
|
|
{
|
|
|
|
XNODE* screenGridNode = cNode->GetChildren();
|
|
|
|
|
|
|
|
if( !GRID::IsGrid( screenGridNode ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR(
|
|
|
|
screenGridNode->GetName(), wxT( "GRIDS -> SCREENGRID" ) );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-12-10 16:13:35 +00:00
|
|
|
ScreenGrid.Parse( screenGridNode, aContext );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
|
|
|
else if( GRID::IsGrid( cNode ) )
|
|
|
|
{
|
|
|
|
GRID userGrid;
|
2020-12-10 16:13:35 +00:00
|
|
|
userGrid.Parse( cNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
UserGrids.push_back( userGrid );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
bool CADSTAR_ARCHIVE_PARSER::SETTINGS::ParseSubNode( XNODE* aChildNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxString cNodeName = aChildNode->GetName();
|
|
|
|
|
|
|
|
if( cNodeName == wxT( "UNITS" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
Units = ParseUnits( aChildNode );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "UNITSPRECISION" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
UnitDisplPrecision = GetXmlAttributeIDLong( aChildNode, 0 );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "INTERLINEGAP" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
InterlineGap = GetXmlAttributeIDLong( aChildNode, 0 );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "BARLINEGAP" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
BarlineGap = GetXmlAttributeIDLong( aChildNode, 0 );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "ALLOWBARTEXT" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
AllowBarredText = true;
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "ANGULARPRECISION" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
AngularPrecision = GetXmlAttributeIDLong( aChildNode, 0 );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "DESIGNORIGIN" ) )
|
|
|
|
{
|
2020-12-10 16:13:35 +00:00
|
|
|
DesignOrigin.Parse( aChildNode->GetChildren(), aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "DESIGNAREA" ) )
|
|
|
|
{
|
2020-12-10 16:13:35 +00:00
|
|
|
std::vector<POINT> pts = ParseAllChildPoints( aChildNode, aContext, true, 2 );
|
2020-09-10 20:58:20 +00:00
|
|
|
DesignArea = std::make_pair( pts[0], pts[1] );
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "DESIGNREF" ) )
|
|
|
|
{
|
2020-12-10 16:13:35 +00:00
|
|
|
DesignOrigin.Parse( aChildNode->GetChildren(), aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "DESIGNLIMIT" ) )
|
|
|
|
{
|
2020-12-10 16:13:35 +00:00
|
|
|
DesignLimit.Parse( aChildNode->GetChildren(), aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::SETTINGS::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "SETTINGS" ) );
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
|
|
|
{
|
|
|
|
wxString cNodeName = cNode->GetName();
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
if( ParseSubNode( cNode, aContext ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
continue;
|
2020-09-10 20:58:20 +00:00
|
|
|
else
|
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, wxT( "SETTINGS" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-27 12:22:27 +00:00
|
|
|
wxString CADSTAR_ARCHIVE_PARSER::ParseTextFields( const wxString& aTextString,
|
|
|
|
PARSER_CONTEXT* aContext )
|
2020-12-10 16:13:35 +00:00
|
|
|
{
|
2020-12-30 23:19:43 +00:00
|
|
|
static const std::map<TEXT_FIELD_NAME, wxString> txtTokens =
|
2020-12-10 16:13:35 +00:00
|
|
|
{
|
|
|
|
{ TEXT_FIELD_NAME::DESIGN_TITLE, wxT( "DESIGN TITLE" ) },
|
|
|
|
{ TEXT_FIELD_NAME::SHORT_JOBNAME, wxT( "SHORT_JOBNAME" ) },
|
|
|
|
{ TEXT_FIELD_NAME::LONG_JOBNAME, wxT( "LONG_JOBNAME" ) },
|
|
|
|
{ TEXT_FIELD_NAME::NUM_OF_SHEETS, wxT( "NUM_OF_SHEETS" ) },
|
|
|
|
{ TEXT_FIELD_NAME::SHEET_NUMBER, wxT( "SHEET_NUMBER" ) },
|
|
|
|
{ TEXT_FIELD_NAME::SHEET_NAME, wxT( "SHEET_NAME" ) },
|
|
|
|
{ TEXT_FIELD_NAME::VARIANT_NAME, wxT( "VARIANT_NAME" ) },
|
|
|
|
{ TEXT_FIELD_NAME::VARIANT_DESCRIPTION, wxT( "VARIANT_DESCRIPTION" ) },
|
|
|
|
{ TEXT_FIELD_NAME::REG_USER, wxT( "REG_USER" ) },
|
|
|
|
{ TEXT_FIELD_NAME::COMPANY_NAME, wxT( "COMPANY_NAME" ) },
|
|
|
|
{ TEXT_FIELD_NAME::CURRENT_USER, wxT( "CURRENT_USER" ) },
|
|
|
|
{ TEXT_FIELD_NAME::DATE, wxT( "DATE" ) },
|
|
|
|
{ TEXT_FIELD_NAME::TIME, wxT( "TIME" ) },
|
|
|
|
{ TEXT_FIELD_NAME::MACHINE_NAME, wxT( "MACHINE_NAME" ) },
|
|
|
|
{ TEXT_FIELD_NAME::FROM_FILE, wxT( "FROM_FILE" ) },
|
|
|
|
{ TEXT_FIELD_NAME::DISTANCE, wxT( "DISTANCE" ) },
|
|
|
|
{ TEXT_FIELD_NAME::UNITS_SHORT, wxT( "UNITS SHORT" ) },
|
|
|
|
{ TEXT_FIELD_NAME::UNITS_ABBREV, wxT( "UNITS ABBREV" ) },
|
|
|
|
{ TEXT_FIELD_NAME::UNITS_FULL, wxT( "UNITS FULL" ) },
|
|
|
|
{ TEXT_FIELD_NAME::HYPERLINK, wxT( "HYPERLINK" ) }
|
|
|
|
};
|
2020-12-30 23:19:43 +00:00
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
wxString remainingStr = aTextString;
|
|
|
|
wxString returnStr;
|
|
|
|
|
|
|
|
while( remainingStr.size() > 0 )
|
|
|
|
{
|
|
|
|
//Find the start token
|
|
|
|
size_t startpos = remainingStr.Find( wxT( "<@" ) );
|
|
|
|
|
2020-12-30 23:19:43 +00:00
|
|
|
if( static_cast<int>( startpos ) == wxNOT_FOUND )
|
2020-12-10 16:13:35 +00:00
|
|
|
{
|
|
|
|
// No more fields to parse, add to return string
|
|
|
|
returnStr += remainingStr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( startpos > 0 )
|
|
|
|
returnStr += remainingStr.SubString( 0, startpos - 1 );
|
|
|
|
|
|
|
|
if( ( startpos + 2 ) >= remainingStr.size() )
|
|
|
|
break;
|
|
|
|
|
|
|
|
remainingStr = remainingStr.Mid( startpos + 2 );
|
|
|
|
|
|
|
|
//Find the expected token for the field
|
|
|
|
TEXT_FIELD_NAME foundField = TEXT_FIELD_NAME::NONE;
|
|
|
|
|
|
|
|
for( std::pair<TEXT_FIELD_NAME, wxString> txtF : txtTokens )
|
|
|
|
{
|
|
|
|
if( remainingStr.StartsWith( txtF.second ) )
|
|
|
|
{
|
|
|
|
foundField = txtF.first;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( foundField == TEXT_FIELD_NAME::NONE )
|
|
|
|
{
|
|
|
|
// Not a valid field, lets keep looking
|
|
|
|
returnStr += wxT( "<@" );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Now lets find the end token
|
|
|
|
size_t endpos = remainingStr.Find( wxT( "@>" ) );
|
|
|
|
|
2020-12-30 23:19:43 +00:00
|
|
|
if( static_cast<int>( endpos ) == wxNOT_FOUND )
|
2020-12-10 16:13:35 +00:00
|
|
|
{
|
|
|
|
// The field we found isn't valid as it doesn't have a termination
|
|
|
|
// Lets append the whole thing as plain text
|
|
|
|
returnStr += wxT( "<@" ) + remainingStr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t valueStart = txtTokens.at( foundField ).size();
|
|
|
|
wxString fieldValue = remainingStr.SubString( valueStart, endpos - 1 );
|
|
|
|
wxString address;
|
|
|
|
|
|
|
|
if( foundField == TEXT_FIELD_NAME::FROM_FILE || foundField == TEXT_FIELD_NAME::HYPERLINK )
|
|
|
|
{
|
|
|
|
// The first character should always be a double quotation mark
|
|
|
|
wxASSERT_MSG( fieldValue.at( 0 ) == '"', "Expected '\"' as the first character" );
|
|
|
|
|
|
|
|
size_t splitPos = fieldValue.find_first_of( '"', 1 );
|
|
|
|
address = fieldValue.SubString( 1, splitPos - 1 );
|
|
|
|
|
|
|
|
if( foundField == TEXT_FIELD_NAME::HYPERLINK )
|
|
|
|
{
|
|
|
|
// Assume the last two characters are "@>"
|
|
|
|
wxASSERT_MSG( remainingStr.EndsWith( wxT( "@>" ) ),
|
|
|
|
"Expected '@>' at the end of a hyperlink" );
|
|
|
|
|
|
|
|
fieldValue = remainingStr.SubString( valueStart + splitPos + 1,
|
|
|
|
remainingStr.Length() - 3 );
|
|
|
|
|
|
|
|
remainingStr = wxEmptyString;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fieldValue = fieldValue.Mid( splitPos + 1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch( foundField )
|
|
|
|
{
|
|
|
|
case TEXT_FIELD_NAME::DESIGN_TITLE:
|
|
|
|
case TEXT_FIELD_NAME::SHORT_JOBNAME:
|
|
|
|
case TEXT_FIELD_NAME::LONG_JOBNAME:
|
|
|
|
case TEXT_FIELD_NAME::VARIANT_NAME:
|
|
|
|
case TEXT_FIELD_NAME::VARIANT_DESCRIPTION:
|
|
|
|
case TEXT_FIELD_NAME::REG_USER:
|
|
|
|
case TEXT_FIELD_NAME::COMPANY_NAME:
|
|
|
|
case TEXT_FIELD_NAME::CURRENT_USER:
|
|
|
|
case TEXT_FIELD_NAME::DATE:
|
|
|
|
case TEXT_FIELD_NAME::TIME:
|
|
|
|
case TEXT_FIELD_NAME::MACHINE_NAME:
|
|
|
|
|
|
|
|
if( aContext->TextFieldToValuesMap.find( foundField )
|
|
|
|
!= aContext->TextFieldToValuesMap.end() )
|
|
|
|
{
|
|
|
|
aContext->InconsistentTextFields.insert( foundField );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aContext->TextFieldToValuesMap.insert( { foundField, fieldValue } );
|
|
|
|
}
|
|
|
|
|
2020-12-30 23:19:43 +00:00
|
|
|
KI_FALLTHROUGH;
|
2020-12-10 16:13:35 +00:00
|
|
|
|
|
|
|
case TEXT_FIELD_NAME::NUM_OF_SHEETS:
|
|
|
|
case TEXT_FIELD_NAME::SHEET_NUMBER:
|
|
|
|
case TEXT_FIELD_NAME::SHEET_NAME:
|
2021-02-13 20:00:17 +00:00
|
|
|
returnStr += wxT( "${" ) + CADSTAR_TO_KICAD_FIELDS.at( foundField ) + wxT( "}" );
|
2020-12-10 16:13:35 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TEXT_FIELD_NAME::DISTANCE:
|
|
|
|
case TEXT_FIELD_NAME::UNITS_SHORT:
|
|
|
|
case TEXT_FIELD_NAME::UNITS_ABBREV:
|
|
|
|
case TEXT_FIELD_NAME::UNITS_FULL:
|
|
|
|
// Just flatten the text for distances
|
|
|
|
returnStr += fieldValue;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TEXT_FIELD_NAME::FROM_FILE:
|
|
|
|
{
|
|
|
|
wxFileName fn( address );
|
|
|
|
wxString fieldFmt = wxT( "FROM_FILE_%s_%s" );
|
|
|
|
wxString fieldName = wxString::Format( fieldFmt, fn.GetName(), fn.GetExt() );
|
|
|
|
|
|
|
|
int version = 1;
|
|
|
|
|
|
|
|
while(
|
|
|
|
aContext->FilenamesToTextMap.find( fieldName )
|
|
|
|
!= aContext->FilenamesToTextMap.end()
|
|
|
|
&& aContext->FilenamesToTextMap.at( fieldName ) != fieldValue )
|
|
|
|
{
|
|
|
|
fieldName = wxString::Format( fieldFmt, fn.GetName(), fn.GetExt() )
|
|
|
|
+ wxString::Format( wxT( "_%d" ), version++ );
|
|
|
|
}
|
|
|
|
|
|
|
|
aContext->FilenamesToTextMap[fieldName] = fieldValue;
|
|
|
|
returnStr += wxT( "${" ) + fieldName + wxT( "}" );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TEXT_FIELD_NAME::HYPERLINK:
|
|
|
|
{
|
|
|
|
aContext->TextToHyperlinksMap[fieldValue] = address;
|
|
|
|
returnStr += ParseTextFields( fieldValue, aContext );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TEXT_FIELD_NAME::NONE:
|
|
|
|
wxFAIL_MSG( "We should have already covered this scenario above" );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if( ( endpos + 2 ) >= remainingStr.size() )
|
|
|
|
break;
|
|
|
|
|
2020-12-30 23:19:43 +00:00
|
|
|
remainingStr = remainingStr.Mid( endpos + 2 );
|
2020-12-10 16:13:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return returnStr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-10 20:58:20 +00:00
|
|
|
CADSTAR_ARCHIVE_PARSER::ALIGNMENT CADSTAR_ARCHIVE_PARSER::ParseAlignment( XNODE* aNode )
|
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "ALIGN" ) );
|
|
|
|
|
|
|
|
wxString alignmentStr = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
|
|
|
|
if( alignmentStr == wxT( "BOTTOMCENTER" ) )
|
|
|
|
return ALIGNMENT::BOTTOMCENTER;
|
|
|
|
else if( alignmentStr == wxT( "BOTTOMLEFT" ) )
|
|
|
|
return ALIGNMENT::BOTTOMLEFT;
|
|
|
|
else if( alignmentStr == wxT( "BOTTOMRIGHT" ) )
|
|
|
|
return ALIGNMENT::BOTTOMRIGHT;
|
|
|
|
else if( alignmentStr == wxT( "CENTERCENTER" ) )
|
|
|
|
return ALIGNMENT::CENTERCENTER;
|
|
|
|
else if( alignmentStr == wxT( "CENTERLEFT" ) )
|
|
|
|
return ALIGNMENT::CENTERLEFT;
|
|
|
|
else if( alignmentStr == wxT( "CENTERRIGHT" ) )
|
|
|
|
return ALIGNMENT::CENTERRIGHT;
|
|
|
|
else if( alignmentStr == wxT( "TOPCENTER" ) )
|
|
|
|
return ALIGNMENT::TOPCENTER;
|
|
|
|
else if( alignmentStr == wxT( "TOPLEFT" ) )
|
|
|
|
return ALIGNMENT::TOPLEFT;
|
|
|
|
else if( alignmentStr == wxT( "TOPRIGHT" ) )
|
|
|
|
return ALIGNMENT::TOPRIGHT;
|
|
|
|
else
|
|
|
|
THROW_UNKNOWN_PARAMETER_IO_ERROR( alignmentStr, wxT( "ALIGN" ) );
|
|
|
|
|
|
|
|
//shouldn't be here but avoids compiler warning
|
|
|
|
return ALIGNMENT::NO_ALIGNMENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CADSTAR_ARCHIVE_PARSER::JUSTIFICATION CADSTAR_ARCHIVE_PARSER::ParseJustification( XNODE* aNode )
|
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "JUSTIFICATION" ) );
|
|
|
|
|
|
|
|
wxString justificationStr = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
|
|
|
|
if( justificationStr == wxT( "LEFT" ) )
|
|
|
|
return JUSTIFICATION::LEFT;
|
|
|
|
else if( justificationStr == wxT( "RIGHT" ) )
|
|
|
|
return JUSTIFICATION::RIGHT;
|
|
|
|
else if( justificationStr == wxT( "CENTER" ) )
|
|
|
|
return JUSTIFICATION::CENTER;
|
|
|
|
else
|
|
|
|
THROW_UNKNOWN_PARAMETER_IO_ERROR( justificationStr, wxT( "JUSTIFICATION" ) );
|
|
|
|
|
|
|
|
return JUSTIFICATION::LEFT;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CADSTAR_ARCHIVE_PARSER::READABILITY CADSTAR_ARCHIVE_PARSER::ParseReadability( XNODE* aNode )
|
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "READABILITY" ) );
|
|
|
|
|
|
|
|
wxString readabilityStr = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
|
|
|
|
if( readabilityStr == wxT( "BOTTOM_TO_TOP" ) )
|
|
|
|
return READABILITY::BOTTOM_TO_TOP;
|
|
|
|
else if( readabilityStr == wxT( "TOP_TO_BOTTOM" ) )
|
|
|
|
return READABILITY::TOP_TO_BOTTOM;
|
|
|
|
else
|
|
|
|
THROW_UNKNOWN_PARAMETER_IO_ERROR( readabilityStr, wxT( "READABILITY" ) );
|
|
|
|
|
|
|
|
return READABILITY::BOTTOM_TO_TOP;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_LOCATION::ParseIdentifiers( XNODE* aNode,
|
|
|
|
PARSER_CONTEXT* aContext )
|
2020-09-13 21:42:17 +00:00
|
|
|
{
|
|
|
|
TextCodeID = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
LayerID = GetXmlAttributeIDString( aNode, 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
bool CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_LOCATION::ParseSubNode( XNODE* aChildNode,
|
|
|
|
PARSER_CONTEXT* aContext )
|
2020-09-13 21:42:17 +00:00
|
|
|
{
|
|
|
|
wxString cNodeName = aChildNode->GetName();
|
|
|
|
|
|
|
|
if( cNodeName == wxT( "PT" ) )
|
2020-12-10 16:13:35 +00:00
|
|
|
Position.Parse( aChildNode, aContext );
|
2020-09-13 21:42:17 +00:00
|
|
|
else if( cNodeName == wxT( "ORIENT" ) )
|
|
|
|
OrientAngle = GetXmlAttributeIDLong( aChildNode, 0 );
|
|
|
|
else if( cNodeName == wxT( "MIRROR" ) )
|
|
|
|
Mirror = true;
|
|
|
|
else if( cNodeName == wxT( "FIX" ) )
|
|
|
|
Fixed = true;
|
|
|
|
else if( cNodeName == wxT( "ALIGN" ) )
|
|
|
|
Alignment = ParseAlignment( aChildNode );
|
|
|
|
else if( cNodeName == wxT( "JUSTIFICATION" ) )
|
|
|
|
Justification = ParseJustification( aChildNode );
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_LOCATION::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "ATTRLOC" ) );
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
ParseIdentifiers( aNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
|
|
|
|
//Parse child nodes
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
|
|
|
{
|
2020-12-10 16:13:35 +00:00
|
|
|
if( ParseSubNode( cNode, aContext ) )
|
2020-09-13 21:42:17 +00:00
|
|
|
continue;
|
2020-09-10 20:58:20 +00:00
|
|
|
else
|
2020-09-13 21:42:17 +00:00
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), wxT( "ATTRLOC" ) );
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
2020-09-13 21:42:17 +00:00
|
|
|
|
|
|
|
if( !Position.IsFullySpecified() )
|
|
|
|
THROW_MISSING_NODE_IO_ERROR( wxT( "PT" ), wxT( "ATTRLOC" ) );
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::ATTRNAME::COLUMNORDER::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "COLUMNORDER" ) );
|
|
|
|
|
|
|
|
ID = GetXmlAttributeIDLong( aNode, 0 );
|
|
|
|
Order = GetXmlAttributeIDLong( aNode, 1 );
|
|
|
|
|
|
|
|
CheckNoChildNodes( aNode );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::ATTRNAME::COLUMNWIDTH::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "COLUMNWIDTH" ) );
|
|
|
|
|
|
|
|
ID = GetXmlAttributeIDLong( aNode, 0 );
|
|
|
|
Width = GetXmlAttributeIDLong( aNode, 1 );
|
|
|
|
|
|
|
|
CheckNoChildNodes( aNode );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::ATTRNAME::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "ATTRNAME" ) );
|
|
|
|
|
|
|
|
ID = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
Name = GetXmlAttributeIDString( aNode, 1 );
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
wxString location = wxString::Format( "ATTRNAME -> %s", Name );
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
|
|
|
{
|
|
|
|
wxString cNodeName = cNode->GetName();
|
|
|
|
|
|
|
|
if( cNodeName == wxT( "ATTROWNER" ) )
|
|
|
|
{
|
|
|
|
wxString attOwnerVal = GetXmlAttributeIDString( cNode, 0 );
|
|
|
|
|
|
|
|
if( attOwnerVal == wxT( "ALL_ITEMS" ) )
|
|
|
|
AttributeOwner = ATTROWNER::ALL_ITEMS;
|
|
|
|
else if( attOwnerVal == wxT( "AREA" ) )
|
|
|
|
AttributeOwner = ATTROWNER::AREA;
|
|
|
|
else if( attOwnerVal == wxT( "BOARD" ) )
|
|
|
|
AttributeOwner = ATTROWNER::BOARD;
|
|
|
|
else if( attOwnerVal == wxT( "COMPONENT" ) )
|
|
|
|
AttributeOwner = ATTROWNER::COMPONENT;
|
|
|
|
else if( attOwnerVal == wxT( "CONNECTION" ) )
|
|
|
|
AttributeOwner = ATTROWNER::CONNECTION;
|
|
|
|
else if( attOwnerVal == wxT( "COPPER" ) )
|
|
|
|
AttributeOwner = ATTROWNER::COPPER;
|
|
|
|
else if( attOwnerVal == wxT( "DOCSYMBOL" ) )
|
|
|
|
AttributeOwner = ATTROWNER::DOCSYMBOL;
|
|
|
|
else if( attOwnerVal == wxT( "FIGURE" ) )
|
|
|
|
AttributeOwner = ATTROWNER::FIGURE;
|
|
|
|
else if( attOwnerVal == wxT( "NET" ) )
|
|
|
|
AttributeOwner = ATTROWNER::NET;
|
|
|
|
else if( attOwnerVal == wxT( "NETCLASS" ) )
|
|
|
|
AttributeOwner = ATTROWNER::NETCLASS;
|
|
|
|
else if( attOwnerVal == wxT( "PART" ) )
|
|
|
|
AttributeOwner = ATTROWNER::PART;
|
|
|
|
else if( attOwnerVal == wxT( "PART_DEFINITION" ) )
|
|
|
|
AttributeOwner = ATTROWNER::PART_DEFINITION;
|
|
|
|
else if( attOwnerVal == wxT( "PIN" ) )
|
|
|
|
AttributeOwner = ATTROWNER::PIN;
|
2021-01-13 20:24:08 +00:00
|
|
|
else if( attOwnerVal == wxT( "SIGNALREF" ) )
|
|
|
|
AttributeOwner = ATTROWNER::SIGNALREF;
|
2020-09-13 21:42:17 +00:00
|
|
|
else if( attOwnerVal == wxT( "SYMBOL" ) )
|
|
|
|
AttributeOwner = ATTROWNER::SYMBOL;
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( attOwnerVal == wxT( "SYMDEF" ) )
|
|
|
|
AttributeOwner = ATTROWNER::SYMDEF;
|
|
|
|
else if( attOwnerVal == wxT( "TEMPLATE" ) )
|
|
|
|
AttributeOwner = ATTROWNER::TEMPLATE;
|
|
|
|
else if( attOwnerVal == wxT( "TESTPOINT" ) )
|
|
|
|
AttributeOwner = ATTROWNER::TESTPOINT;
|
|
|
|
else
|
|
|
|
THROW_UNKNOWN_PARAMETER_IO_ERROR( attOwnerVal, location );
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "ATTRUSAGE" ) )
|
|
|
|
{
|
|
|
|
wxString attUsageVal = GetXmlAttributeIDString( cNode, 0 );
|
|
|
|
|
|
|
|
if( attUsageVal == wxT( "BOTH" ) )
|
|
|
|
AttributeUsage = ATTRUSAGE::BOTH;
|
|
|
|
else if( attUsageVal == wxT( "COMPONENT" ) )
|
|
|
|
AttributeUsage = ATTRUSAGE::COMPONENT;
|
|
|
|
else if( attUsageVal == wxT( "PART_DEFINITION" ) )
|
|
|
|
AttributeUsage = ATTRUSAGE::PART_DEFINITION;
|
|
|
|
else if( attUsageVal == wxT( "PART_LIBRARY" ) )
|
|
|
|
AttributeUsage = ATTRUSAGE::PART_LIBRARY;
|
|
|
|
else if( attUsageVal == wxT( "SYMBOL" ) )
|
|
|
|
AttributeUsage = ATTRUSAGE::SYMBOL;
|
|
|
|
else
|
|
|
|
THROW_UNKNOWN_PARAMETER_IO_ERROR( attUsageVal, location );
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "NOTRANSFER" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
NoTransfer = true;
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "COLUMNORDER" ) )
|
|
|
|
{
|
|
|
|
COLUMNORDER cOrder;
|
2020-12-10 16:13:35 +00:00
|
|
|
cOrder.Parse( cNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
ColumnOrders.push_back( cOrder );
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "COLUMNWIDTH" ) )
|
|
|
|
{
|
|
|
|
COLUMNWIDTH cWidth;
|
2020-12-10 16:13:35 +00:00
|
|
|
cWidth.Parse( cNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
ColumnWidths.push_back( cWidth );
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "COLUMNINVISIBLE" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
ColumnInvisible = true;
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, location );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_VALUE::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "ATTR" ) );
|
|
|
|
|
|
|
|
AttributeID = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
Value = GetXmlAttributeIDString( aNode, 1 );
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
|
|
|
{
|
|
|
|
if( cNode->GetName() == wxT( "READONLY" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
ReadOnly = true;
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNode->GetName() == wxT( "ATTRLOC" ) )
|
|
|
|
{
|
2020-12-10 16:13:35 +00:00
|
|
|
AttributeLocation.Parse( cNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
HasLocation = true;
|
|
|
|
}
|
|
|
|
else
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), wxT( "ATTR" ) );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::TEXT_LOCATION::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "TEXTLOC" ) );
|
|
|
|
|
|
|
|
wxString attributeStr = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
bool attributeIDisSet = false;
|
|
|
|
|
|
|
|
if( attributeStr == wxT( "PART_NAME" ) )
|
|
|
|
{
|
|
|
|
AttributeID = PART_NAME_ATTRID;
|
|
|
|
attributeIDisSet = true;
|
|
|
|
}
|
|
|
|
else if( attributeStr == wxT( "COMP_NAME" ) )
|
|
|
|
{
|
|
|
|
AttributeID = COMPONENT_NAME_ATTRID;
|
|
|
|
attributeIDisSet = true;
|
|
|
|
}
|
|
|
|
else if( attributeStr == wxT( "COMP_NAME2" ) )
|
|
|
|
{
|
|
|
|
AttributeID = COMPONENT_NAME_2_ATTRID;
|
|
|
|
attributeIDisSet = true;
|
|
|
|
}
|
2020-09-13 21:42:17 +00:00
|
|
|
else if( attributeStr == wxT( "SYMBOL_NAME" ) )
|
|
|
|
{
|
|
|
|
AttributeID = SYMBOL_NAME_ATTRID;
|
|
|
|
attributeIDisSet = true;
|
|
|
|
}
|
|
|
|
else if( attributeStr == wxT( "LINK_ORIGIN" ) )
|
|
|
|
{
|
|
|
|
AttributeID = LINK_ORIGIN_ATTRID;
|
|
|
|
attributeIDisSet = true;
|
|
|
|
}
|
|
|
|
else if( attributeStr == wxT( "SIGNALNAME_ORIGIN" ) )
|
|
|
|
{
|
|
|
|
AttributeID = SIGNALNAME_ORIGIN_ATTRID;
|
|
|
|
attributeIDisSet = true;
|
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( attributeStr == wxT( "ATTRREF" ) )
|
|
|
|
{
|
|
|
|
//We will initialise when we parse all child nodes
|
|
|
|
attributeIDisSet = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
THROW_UNKNOWN_PARAMETER_IO_ERROR( attributeStr, wxT( "TEXTLOC" ) );
|
|
|
|
}
|
|
|
|
|
2020-09-20 21:08:46 +00:00
|
|
|
TextCodeID = GetXmlAttributeIDString( aNode, 1 );
|
|
|
|
LayerID = GetXmlAttributeIDString( aNode, 2, false );
|
2020-09-10 20:58:20 +00:00
|
|
|
|
|
|
|
//Parse child nodes
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
|
|
|
{
|
|
|
|
wxString cNodeName = cNode->GetName();
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
if( ParseSubNode( cNode, aContext ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-13 21:42:17 +00:00
|
|
|
continue;
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( !attributeIDisSet && cNodeName == wxT( "ATTRREF" ) )
|
|
|
|
{
|
|
|
|
AttributeID = GetXmlAttributeIDString( cNode, 0 );
|
|
|
|
attributeIDisSet = true;
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "ORIENT" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
OrientAngle = GetXmlAttributeIDLong( cNode, 0 );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "MIRROR" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
Mirror = true;
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "FIX" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
Fixed = true;
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "ALIGN" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
Alignment = ParseAlignment( cNode );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "JUSTIFICATION" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
Justification = ParseJustification( cNode );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, wxT( "TEXTLOC" ) );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
2020-09-13 21:42:17 +00:00
|
|
|
|
|
|
|
if( !Position.IsFullySpecified() )
|
|
|
|
THROW_MISSING_NODE_IO_ERROR( wxT( "PT" ), wxT( "TEXTLOC" ) );
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-13 20:00:17 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::CADSTAR_NETCLASS::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "NETCLASS" ) );
|
|
|
|
|
|
|
|
ID = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
Name = GetXmlAttributeIDString( aNode, 1 );
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
wxString location = wxString::Format( "NETCLASS -> %s", Name );
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
|
|
|
{
|
|
|
|
wxString cNodeName = cNode->GetName();
|
|
|
|
|
|
|
|
if( cNodeName == wxT( "ATTR" ) )
|
|
|
|
{
|
|
|
|
ATTRIBUTE_VALUE attribute_val;
|
2020-12-10 16:13:35 +00:00
|
|
|
attribute_val.Parse( cNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
Attributes.push_back( attribute_val );
|
|
|
|
}
|
|
|
|
else
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, location );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::SPCCLASSNAME::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "SPCCLASSNAME" ) );
|
|
|
|
|
|
|
|
ID = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
Name = GetXmlAttributeIDString( aNode, 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
bool CADSTAR_ARCHIVE_PARSER::CODEDEFS::ParseSubNode( XNODE* aChildNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxString nodeName = aChildNode->GetName();
|
|
|
|
|
|
|
|
if( nodeName == wxT( "LINECODE" ) )
|
|
|
|
{
|
|
|
|
LINECODE linecode;
|
2020-12-10 16:13:35 +00:00
|
|
|
linecode.Parse( aChildNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
LineCodes.insert( std::make_pair( linecode.ID, linecode ) );
|
|
|
|
}
|
|
|
|
else if( nodeName == wxT( "HATCHCODE" ) )
|
|
|
|
{
|
|
|
|
HATCHCODE hatchcode;
|
2020-12-10 16:13:35 +00:00
|
|
|
hatchcode.Parse( aChildNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
HatchCodes.insert( std::make_pair( hatchcode.ID, hatchcode ) );
|
|
|
|
}
|
|
|
|
else if( nodeName == wxT( "TEXTCODE" ) )
|
|
|
|
{
|
|
|
|
TEXTCODE textcode;
|
2020-12-10 16:13:35 +00:00
|
|
|
textcode.Parse( aChildNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
TextCodes.insert( std::make_pair( textcode.ID, textcode ) );
|
|
|
|
}
|
|
|
|
else if( nodeName == wxT( "ROUTECODE" ) )
|
|
|
|
{
|
|
|
|
ROUTECODE routecode;
|
2020-12-10 16:13:35 +00:00
|
|
|
routecode.Parse( aChildNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
RouteCodes.insert( std::make_pair( routecode.ID, routecode ) );
|
|
|
|
}
|
|
|
|
else if( nodeName == wxT( "ATTRNAME" ) )
|
|
|
|
{
|
|
|
|
ATTRNAME attrname;
|
2020-12-10 16:13:35 +00:00
|
|
|
attrname.Parse( aChildNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
AttributeNames.insert( std::make_pair( attrname.ID, attrname ) );
|
|
|
|
}
|
|
|
|
else if( nodeName == wxT( "NETCLASS" ) )
|
|
|
|
{
|
2021-02-13 20:00:17 +00:00
|
|
|
CADSTAR_NETCLASS netclass;
|
2020-12-10 16:13:35 +00:00
|
|
|
netclass.Parse( aChildNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
NetClasses.insert( std::make_pair( netclass.ID, netclass ) );
|
|
|
|
}
|
|
|
|
else if( nodeName == wxT( "SPCCLASSNAME" ) )
|
|
|
|
{
|
|
|
|
SPCCLASSNAME spcclassname;
|
2020-12-10 16:13:35 +00:00
|
|
|
spcclassname.Parse( aChildNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
SpacingClassNames.insert( std::make_pair( spcclassname.ID, spcclassname ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CADSTAR_ARCHIVE_PARSER::SWAP_RULE CADSTAR_ARCHIVE_PARSER::ParseSwapRule( XNODE* aNode )
|
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "SWAPRULE" ) );
|
|
|
|
|
|
|
|
SWAP_RULE retval;
|
|
|
|
wxString swapRuleStr = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
|
|
|
|
if( swapRuleStr == wxT( "NO_SWAP" ) )
|
|
|
|
retval = SWAP_RULE::NO_SWAP;
|
|
|
|
else if( swapRuleStr == wxT( "USE_SWAP_LAYER" ) )
|
|
|
|
retval = SWAP_RULE::USE_SWAP_LAYER;
|
|
|
|
else
|
|
|
|
THROW_UNKNOWN_PARAMETER_IO_ERROR( swapRuleStr, wxT( "SWAPRULE" ) );
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::REUSEBLOCK::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "REUSEBLOCK" ) );
|
|
|
|
|
|
|
|
ID = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
Name = GetXmlAttributeIDString( aNode, 1 );
|
|
|
|
FileName = GetXmlAttributeIDString( aNode, 2 );
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
|
|
|
{
|
|
|
|
wxString cNodeName = cNode->GetName();
|
|
|
|
|
|
|
|
if( cNodeName == wxT( "MIRROR" ) )
|
|
|
|
Mirror = true;
|
|
|
|
else if( cNodeName == wxT( "ORIENT" ) )
|
|
|
|
OrientAngle = GetXmlAttributeIDLong( cNode, 0 );
|
|
|
|
else
|
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, wxT( "REUSEBLOCK" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CADSTAR_ARCHIVE_PARSER::REUSEBLOCKREF::IsEmpty()
|
|
|
|
{
|
|
|
|
return ReuseBlockID == wxEmptyString && ItemReference == wxEmptyString;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::REUSEBLOCKREF::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "REUSEBLOCKREF" ) );
|
|
|
|
|
|
|
|
ReuseBlockID = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
ItemReference = GetXmlAttributeIDString( aNode, 1 );
|
|
|
|
|
|
|
|
CheckNoChildNodes( aNode );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::GROUP::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "GROUP" ) );
|
|
|
|
|
|
|
|
ID = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
Name = GetXmlAttributeIDString( aNode, 1 );
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
|
|
|
{
|
|
|
|
wxString cNodeName = cNode->GetName();
|
|
|
|
|
|
|
|
if( cNodeName == wxT( "FIX" ) )
|
|
|
|
Fixed = true;
|
2020-09-13 21:42:17 +00:00
|
|
|
else if( cNodeName == wxT( "TRANSFER" ) )
|
|
|
|
Transfer = true;
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "GROUPREF" ) )
|
|
|
|
GroupID = GetXmlAttributeIDString( cNode, 0 );
|
|
|
|
else if( cNodeName == wxT( "REUSEBLOCKREF" ) )
|
2020-12-10 16:13:35 +00:00
|
|
|
ReuseBlockRef.Parse( cNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
else
|
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, wxT( "GROUP" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::FIGURE::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "FIGURE" ) );
|
|
|
|
|
|
|
|
ID = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
LineCodeID = GetXmlAttributeIDString( aNode, 1 );
|
|
|
|
LayerID = GetXmlAttributeIDString( aNode, 2 );
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
bool shapeIsInitialised = false; // Stop more than one Shape Object
|
|
|
|
wxString location = wxString::Format( "Figure %s", ID );
|
|
|
|
|
|
|
|
if( !cNode )
|
|
|
|
THROW_MISSING_NODE_IO_ERROR( wxT( "Shape" ), location );
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
|
|
|
{
|
|
|
|
wxString cNodeName = cNode->GetName();
|
|
|
|
|
|
|
|
if( !shapeIsInitialised && Shape.IsShape( cNode ) )
|
|
|
|
{
|
2020-12-10 16:13:35 +00:00
|
|
|
Shape.Parse( cNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
shapeIsInitialised = true;
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "SWAPRULE" ) )
|
|
|
|
{
|
|
|
|
SwapRule = ParseSwapRule( cNode );
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "FIX" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
Fixed = true;
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "GROUPREF" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
|
|
|
|
2020-09-10 20:58:20 +00:00
|
|
|
GroupID = GetXmlAttributeIDString( cNode, 0 );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "REUSEBLOCKREF" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-12-10 16:13:35 +00:00
|
|
|
ReuseBlockRef.Parse( cNode, aContext );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "ATTR" ) )
|
|
|
|
{
|
|
|
|
ATTRIBUTE_VALUE attr;
|
2020-12-10 16:13:35 +00:00
|
|
|
attr.Parse( cNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
AttributeValues.insert( std::make_pair( attr.AttributeID, attr ) );
|
|
|
|
}
|
|
|
|
else
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, location );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::TEXT::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-12-27 17:37:25 +00:00
|
|
|
{
|
|
|
|
Parse( aNode, aContext, true );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CADSTAR_ARCHIVE_PARSER::TEXT::Parse( XNODE* aNode, PARSER_CONTEXT* aContext,
|
|
|
|
bool aParseFields )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "TEXT" ) );
|
|
|
|
|
|
|
|
ID = GetXmlAttributeIDString( aNode, 0 );
|
2020-12-27 17:37:25 +00:00
|
|
|
Text = GetXmlAttributeIDString( aNode, 1 );
|
|
|
|
|
|
|
|
if( aParseFields )
|
|
|
|
Text = ParseTextFields( Text, aContext );
|
|
|
|
|
2020-09-10 20:58:20 +00:00
|
|
|
TextCodeID = GetXmlAttributeIDString( aNode, 2 );
|
|
|
|
LayerID = GetXmlAttributeIDString( aNode, 3 );
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
if( !cNode )
|
|
|
|
THROW_MISSING_NODE_IO_ERROR( wxT( "PT" ), wxT( "TEXT" ) );
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
|
|
|
{
|
|
|
|
wxString cNodeName = cNode->GetName();
|
|
|
|
|
|
|
|
if( cNodeName == wxT( "PT" ) )
|
2020-12-10 16:13:35 +00:00
|
|
|
Position.Parse( cNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "ORIENT" ) )
|
|
|
|
OrientAngle = GetXmlAttributeIDLong( cNode, 0 );
|
|
|
|
else if( cNodeName == wxT( "MIRROR" ) )
|
|
|
|
Mirror = true;
|
|
|
|
else if( cNodeName == wxT( "FIX" ) )
|
|
|
|
Fixed = true;
|
|
|
|
else if( cNodeName == wxT( "SWAPRULE" ) )
|
|
|
|
SwapRule = ParseSwapRule( cNode );
|
|
|
|
else if( cNodeName == wxT( "ALIGN" ) )
|
|
|
|
Alignment = ParseAlignment( cNode );
|
|
|
|
else if( cNodeName == wxT( "JUSTIFICATION" ) )
|
|
|
|
Justification = ParseJustification( cNode );
|
|
|
|
else if( cNodeName == wxT( "GROUPREF" ) )
|
|
|
|
GroupID = GetXmlAttributeIDString( cNode, 0 );
|
|
|
|
else if( cNodeName == wxT( "REUSEBLOCKREF" ) )
|
2020-12-10 16:13:35 +00:00
|
|
|
ReuseBlockRef.Parse( cNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
else
|
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, wxT( "TEXT" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::SYMDEF::ParseIdentifiers( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "SYMDEF" ) );
|
|
|
|
|
|
|
|
ID = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
ReferenceName = GetXmlAttributeIDString( aNode, 1 );
|
|
|
|
Alternate = GetXmlAttributeIDString( aNode, 2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
bool CADSTAR_ARCHIVE_PARSER::SYMDEF::ParseSubNode( XNODE* aChildNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxString cNodeName = aChildNode->GetName();
|
|
|
|
|
|
|
|
if( cNodeName == wxT( "PT" ) )
|
|
|
|
{
|
2020-12-10 16:13:35 +00:00
|
|
|
Origin.Parse( aChildNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "STUB" ) )
|
|
|
|
{
|
|
|
|
Stub = true;
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "VERSION" ) )
|
|
|
|
{
|
|
|
|
Version = GetXmlAttributeIDLong( aChildNode, 0 );
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "FIGURE" ) )
|
|
|
|
{
|
|
|
|
FIGURE figure;
|
2020-12-10 16:13:35 +00:00
|
|
|
figure.Parse( aChildNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
Figures.insert( std::make_pair( figure.ID, figure ) );
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "TEXT" ) )
|
|
|
|
{
|
|
|
|
TEXT txt;
|
2020-12-10 16:13:35 +00:00
|
|
|
txt.Parse( aChildNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
Texts.insert( std::make_pair( txt.ID, txt ) );
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "TEXTLOC" ) )
|
|
|
|
{
|
|
|
|
TEXT_LOCATION textloc;
|
2020-12-10 16:13:35 +00:00
|
|
|
textloc.Parse( aChildNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
TextLocations.insert( std::make_pair( textloc.AttributeID, textloc ) );
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "ATTR" ) )
|
|
|
|
{
|
|
|
|
ATTRIBUTE_VALUE attrVal;
|
2020-12-10 16:13:35 +00:00
|
|
|
attrVal.Parse( aChildNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
AttributeValues.insert( std::make_pair( attrVal.AttributeID, attrVal ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::GATE::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "GATEDEFINITION" ) );
|
|
|
|
|
|
|
|
ID = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
Name = GetXmlAttributeIDString( aNode, 1 );
|
|
|
|
Alternate = GetXmlAttributeIDString( aNode, 2 );
|
|
|
|
PinCount = GetXmlAttributeIDLong( aNode, 3 );
|
|
|
|
|
|
|
|
CheckNoChildNodes( aNode );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CADSTAR_ARCHIVE_PARSER::PART::PIN_TYPE CADSTAR_ARCHIVE_PARSER::PART::GetPinType( XNODE* aNode )
|
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "PINTYPE" ) );
|
|
|
|
|
|
|
|
wxString pinTypeStr = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
|
|
|
|
std::map<wxString, PIN_TYPE> pinTypeMap = { { wxT( "INPUT" ), PIN_TYPE::INPUT },
|
|
|
|
{ wxT( "OUTPUT_OR" ), PIN_TYPE::OUTPUT_OR },
|
|
|
|
{ wxT( "OUTPUT_NOT_OR" ), PIN_TYPE::OUTPUT_NOT_OR },
|
|
|
|
{ wxT( "OUTPUT_NOT_NORM_OR" ), PIN_TYPE::OUTPUT_NOT_NORM_OR },
|
|
|
|
{ wxT( "POWER" ), PIN_TYPE::POWER }, { wxT( "GROUND" ), PIN_TYPE::GROUND },
|
|
|
|
{ wxT( "TRISTATE_BIDIR" ), PIN_TYPE::TRISTATE_BIDIR },
|
|
|
|
{ wxT( "TRISTATE_INPUT" ), PIN_TYPE::TRISTATE_INPUT },
|
|
|
|
{ wxT( "TRISTATE_DRIVER" ), PIN_TYPE::TRISTATE_DRIVER } };
|
|
|
|
|
|
|
|
if( pinTypeMap.find( pinTypeStr ) == pinTypeMap.end() )
|
|
|
|
THROW_UNKNOWN_PARAMETER_IO_ERROR( pinTypeStr, aNode->GetName() );
|
|
|
|
|
|
|
|
return pinTypeMap[pinTypeStr];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::PIN::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "PARTDEFINITIONPIN" ) );
|
|
|
|
|
|
|
|
ID = GetXmlAttributeIDLong( aNode, 0 );
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
|
|
|
{
|
|
|
|
wxString cNodeName = cNode->GetName();
|
|
|
|
|
|
|
|
if( cNodeName == wxT( "PINNAME" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
Name = GetXmlAttributeIDString( cNode, 0 );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "PINLABEL" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
Label = GetXmlAttributeIDString( cNode, 0 );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "PINSIGNAL" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
Signal = GetXmlAttributeIDString( cNode, 0 );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "PINTERM" ) )
|
|
|
|
{
|
|
|
|
TerminalGate = GetXmlAttributeIDString( cNode, 0 );
|
|
|
|
TerminalPin = GetXmlAttributeIDLong( cNode, 1 );
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "PINTYPE" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
Type = GetPinType( cNode );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "PINLOAD" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
Load = GetXmlAttributeIDLong( cNode, 0 );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "PINPOSITION" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
Position = (POSITION) GetXmlAttributeIDLong( cNode, 0 );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "PINIDENTIFIER" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
Identifier = GetXmlAttributeIDString( cNode, 0 );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::PART::PART_PIN::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "PARTPIN" ) );
|
2020-07-30 22:42:56 +00:00
|
|
|
|
2020-09-10 20:58:20 +00:00
|
|
|
ID = GetXmlAttributeIDLong( aNode, 0 );
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
2020-09-18 10:32:57 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
wxString cNodeName = cNode->GetName();
|
|
|
|
|
|
|
|
if( cNodeName == wxT( "PINNAME" ) )
|
|
|
|
Name = GetXmlAttributeIDString( cNode, 0 );
|
|
|
|
else if( cNodeName == wxT( "PINTYPE" ) )
|
|
|
|
Type = GetPinType( cNode );
|
|
|
|
else if( cNodeName == wxT( "PINIDENTIFIER" ) )
|
|
|
|
Identifier = GetXmlAttributeIDString( cNode, 0 );
|
|
|
|
else
|
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
|
2020-09-18 10:32:57 +00:00
|
|
|
}
|
2020-07-30 22:42:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::PIN_EQUIVALENCE::Parse( XNODE* aNode,
|
|
|
|
PARSER_CONTEXT* aContext )
|
2020-07-30 22:42:56 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
wxASSERT( aNode->GetName() == wxT( "PINEQUIVALENCE" ) );
|
2020-07-30 22:42:56 +00:00
|
|
|
|
2020-09-10 20:58:20 +00:00
|
|
|
wxXmlAttribute* xmlAttribute = aNode->GetAttributes();
|
|
|
|
|
|
|
|
for( ; xmlAttribute; xmlAttribute = xmlAttribute->GetNext() )
|
|
|
|
{
|
|
|
|
if( !IsValidAttribute( xmlAttribute ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
long pinId;
|
|
|
|
|
|
|
|
if( !xmlAttribute->GetValue().ToLong( &pinId ) )
|
|
|
|
THROW_UNKNOWN_PARAMETER_IO_ERROR( xmlAttribute->GetValue(), aNode->GetName() );
|
|
|
|
|
|
|
|
PinIDs.push_back( (PART_DEFINITION_PIN_ID) pinId );
|
|
|
|
}
|
|
|
|
|
|
|
|
CheckNoChildNodes( aNode );
|
2020-07-30 22:42:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::SWAP_GATE::Parse( XNODE* aNode,
|
|
|
|
PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "SWAPGATE" ) );
|
2020-08-31 22:09:29 +00:00
|
|
|
|
2020-09-10 20:58:20 +00:00
|
|
|
wxXmlAttribute* xmlAttribute = aNode->GetAttributes();
|
2020-08-31 22:09:29 +00:00
|
|
|
|
2020-09-10 20:58:20 +00:00
|
|
|
for( ; xmlAttribute; xmlAttribute = xmlAttribute->GetNext() )
|
|
|
|
{
|
|
|
|
if( !IsValidAttribute( xmlAttribute ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
long pinId;
|
|
|
|
|
|
|
|
if( !xmlAttribute->GetValue().ToLong( &pinId ) )
|
|
|
|
THROW_UNKNOWN_PARAMETER_IO_ERROR( xmlAttribute->GetValue(), aNode->GetName() );
|
|
|
|
|
|
|
|
PinIDs.push_back( (PART_DEFINITION_PIN_ID) pinId );
|
|
|
|
}
|
|
|
|
|
|
|
|
CheckNoChildNodes( aNode );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::SWAP_GROUP::Parse( XNODE* aNode,
|
|
|
|
PARSER_CONTEXT* aContext )
|
2020-08-31 22:09:29 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
wxASSERT( aNode->GetName() == wxT( "SWAPGROUP" ) );
|
2020-08-31 22:09:29 +00:00
|
|
|
|
2020-09-10 20:58:20 +00:00
|
|
|
GateName = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
|
|
|
{
|
|
|
|
wxString cNodeName = cNode->GetName();
|
|
|
|
|
|
|
|
if( cNodeName == wxT( "EXTERNAL" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
External = true;
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "SWAPGATE" ) )
|
|
|
|
{
|
|
|
|
SWAP_GATE swapGate;
|
2020-12-10 16:13:35 +00:00
|
|
|
swapGate.Parse( cNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
SwapGates.push_back( swapGate );
|
|
|
|
}
|
|
|
|
else
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
2020-08-31 22:09:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-07-30 22:42:56 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
wxASSERT( aNode->GetName() == wxT( "PARTDEFINITION" ) );
|
2020-07-30 22:42:56 +00:00
|
|
|
|
2020-09-10 20:58:20 +00:00
|
|
|
Name = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
2020-09-18 10:32:57 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
wxString cNodeName = cNode->GetName();
|
|
|
|
|
|
|
|
if( cNodeName == wxT( "HIDEPINNAMES" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
HidePinNames = true;
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "MAXPIN" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
MaxPinCount = GetXmlAttributeIDLong( cNode, 0 );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "GATEDEFINITION" ) )
|
|
|
|
{
|
|
|
|
GATE gate;
|
2020-12-10 16:13:35 +00:00
|
|
|
gate.Parse( cNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
GateSymbols.insert( std::make_pair( gate.ID, gate ) );
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "PARTDEFINITIONPIN" ) )
|
|
|
|
{
|
|
|
|
PIN pin;
|
2020-12-10 16:13:35 +00:00
|
|
|
pin.Parse( cNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
Pins.insert( std::make_pair( pin.ID, pin ) );
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "ATTR" ) )
|
|
|
|
{
|
|
|
|
ATTRIBUTE_VALUE attr;
|
2020-12-10 16:13:35 +00:00
|
|
|
attr.Parse( cNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
AttributeValues.insert( std::make_pair( attr.AttributeID, attr ) );
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "PINEQUIVALENCE" ) )
|
|
|
|
{
|
|
|
|
PIN_EQUIVALENCE pinEq;
|
2020-12-10 16:13:35 +00:00
|
|
|
pinEq.Parse( cNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
PinEquivalences.push_back( pinEq );
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "SWAPGROUP" ) )
|
|
|
|
{
|
|
|
|
SWAP_GROUP swapGroup;
|
2020-12-10 16:13:35 +00:00
|
|
|
swapGroup.Parse( cNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
SwapGroups.push_back( swapGroup );
|
|
|
|
}
|
|
|
|
else
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-18 10:32:57 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::PART::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "PART" ) );
|
|
|
|
|
|
|
|
ID = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
Name = GetXmlAttributeIDString( aNode, 1 );
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
2020-09-18 10:32:57 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
wxString cNodeName = cNode->GetName();
|
|
|
|
|
|
|
|
if( cNodeName == wxT( "VERSION" ) )
|
2020-09-26 13:27:03 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
Version = GetXmlAttributeIDLong( cNode, 0 );
|
2020-09-26 13:27:03 +00:00
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "HIDEPINNAMES" ) )
|
|
|
|
{
|
|
|
|
HidePinNames = true;
|
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "PARTDEFINITION" ) )
|
|
|
|
{
|
2020-12-10 16:13:35 +00:00
|
|
|
Definition.Parse( cNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "PARTPIN" ) )
|
|
|
|
{
|
|
|
|
PART_PIN pin;
|
2020-12-10 16:13:35 +00:00
|
|
|
pin.Parse( cNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
PartPins.insert( std::make_pair( pin.ID, pin ) );
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "ATTR" ) )
|
|
|
|
{
|
|
|
|
ATTRIBUTE_VALUE attr;
|
2020-12-10 16:13:35 +00:00
|
|
|
attr.Parse( cNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
AttributeValues.insert( std::make_pair( attr.AttributeID, attr ) );
|
|
|
|
}
|
|
|
|
else
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-18 10:32:57 +00:00
|
|
|
}
|
2020-07-30 22:42:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::PARTS::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-07-30 22:42:56 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
wxASSERT( aNode->GetName() == wxT( "PARTS" ) );
|
2020-07-30 22:42:56 +00:00
|
|
|
|
2020-09-10 20:58:20 +00:00
|
|
|
XNODE* cNode = aNode->GetChildren();
|
2020-07-30 22:42:56 +00:00
|
|
|
|
2020-09-10 20:58:20 +00:00
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
2020-07-30 22:42:56 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
wxString cNodeName = cNode->GetName();
|
|
|
|
|
|
|
|
if( cNodeName == wxT( "PART" ) )
|
|
|
|
{
|
|
|
|
PART part;
|
2020-12-10 16:13:35 +00:00
|
|
|
part.Parse( cNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
PartDefinitions.insert( std::make_pair( part.ID, part ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
|
|
|
|
}
|
2021-09-09 21:15:38 +00:00
|
|
|
|
|
|
|
aContext->CheckPointCallback();
|
2020-07-30 22:42:56 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::NET::JUNCTION::ParseIdentifiers( XNODE* aNode,
|
|
|
|
PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "JPT" ) );
|
|
|
|
|
2020-10-13 21:40:44 +00:00
|
|
|
ID = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
LayerID = GetXmlAttributeIDString( aNode, 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
bool CADSTAR_ARCHIVE_PARSER::NET::JUNCTION::ParseSubNode( XNODE* aChildNode,
|
|
|
|
PARSER_CONTEXT* aContext )
|
2020-10-13 21:40:44 +00:00
|
|
|
{
|
|
|
|
wxString cNodeName = aChildNode->GetName();
|
|
|
|
|
|
|
|
if( cNodeName == wxT( "PT" ) )
|
2020-12-10 16:13:35 +00:00
|
|
|
Location.Parse( aChildNode, aContext );
|
2020-10-13 21:40:44 +00:00
|
|
|
else if( cNodeName == wxT( "FIX" ) )
|
|
|
|
Fixed = true;
|
|
|
|
else if( cNodeName == wxT( "GROUPREF" ) )
|
|
|
|
GroupID = GetXmlAttributeIDString( aChildNode, 0 );
|
|
|
|
else if( cNodeName == wxT( "REUSEBLOCKREF" ) )
|
2020-12-10 16:13:35 +00:00
|
|
|
ReuseBlockRef.Parse( aChildNode, aContext );
|
2020-10-13 21:40:44 +00:00
|
|
|
else
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::NET::JUNCTION::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-10-13 21:40:44 +00:00
|
|
|
{
|
2020-12-10 16:13:35 +00:00
|
|
|
ParseIdentifiers( aNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
2020-07-30 22:42:56 +00:00
|
|
|
{
|
2020-12-10 16:13:35 +00:00
|
|
|
if( ParseSubNode( cNode, aContext ) )
|
2020-10-13 21:40:44 +00:00
|
|
|
continue;
|
2020-07-30 22:42:56 +00:00
|
|
|
else
|
2020-10-13 21:40:44 +00:00
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), aNode->GetName() );
|
2020-09-10 20:58:20 +00:00
|
|
|
}
|
|
|
|
}
|
2020-07-30 22:42:56 +00:00
|
|
|
|
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::NET::CONNECTION::ParseIdentifiers( XNODE* aNode,
|
|
|
|
PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "CONN" ) );
|
|
|
|
|
|
|
|
StartNode = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
EndNode = GetXmlAttributeIDString( aNode, 1 );
|
|
|
|
RouteCodeID = GetXmlAttributeIDString( aNode, 2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
bool CADSTAR_ARCHIVE_PARSER::NET::CONNECTION::ParseSubNode( XNODE* aChildNode,
|
|
|
|
PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxString cNodeName = aChildNode->GetName();
|
|
|
|
|
|
|
|
if( cNodeName == wxT( "FIX" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
Fixed = true;
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "HIDDEN" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
Hidden = true;
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "GROUPREF" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
GroupID = GetXmlAttributeIDString( aChildNode, 0 );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "REUSEBLOCKREF" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-12-10 16:13:35 +00:00
|
|
|
ReuseBlockRef.Parse( aChildNode, aContext );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "ATTR" ) )
|
|
|
|
{
|
|
|
|
ATTRIBUTE_VALUE attrVal;
|
2020-12-10 16:13:35 +00:00
|
|
|
attrVal.Parse( aChildNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
AttributeValues.insert( std::make_pair( attrVal.AttributeID, attrVal ) );
|
2020-07-30 22:42:56 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else
|
2020-07-30 22:42:56 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
return false;
|
|
|
|
}
|
2020-07-30 22:42:56 +00:00
|
|
|
|
2020-09-10 20:58:20 +00:00
|
|
|
return true;
|
|
|
|
}
|
2020-07-30 22:42:56 +00:00
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::NET::ParseIdentifiers( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "NET" ) );
|
|
|
|
|
|
|
|
ID = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
bool CADSTAR_ARCHIVE_PARSER::NET::ParseSubNode( XNODE* aChildNode, PARSER_CONTEXT* aContext )
|
2020-09-10 20:58:20 +00:00
|
|
|
{
|
|
|
|
wxString cNodeName = aChildNode->GetName();
|
|
|
|
|
|
|
|
if( cNodeName == wxT( "NETCODE" ) )
|
|
|
|
{
|
|
|
|
RouteCodeID = GetXmlAttributeIDString( aChildNode, 0 );
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "SIGNAME" ) )
|
|
|
|
{
|
|
|
|
Name = GetXmlAttributeIDString( aChildNode, 0 );
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "SIGNUM" ) )
|
|
|
|
{
|
|
|
|
SignalNum = GetXmlAttributeIDLong( aChildNode, 0 );
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "HIGHLIT" ) )
|
|
|
|
{
|
|
|
|
Highlight = true;
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "JPT" ) )
|
|
|
|
{
|
|
|
|
JUNCTION jpt;
|
2020-12-10 16:13:35 +00:00
|
|
|
jpt.Parse( aChildNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
Junctions.insert( std::make_pair( jpt.ID, jpt ) );
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "NETCLASSREF" ) )
|
|
|
|
{
|
|
|
|
NetClassID = GetXmlAttributeIDString( aChildNode, 0 );
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "SPACINGCLASS" ) )
|
|
|
|
{
|
|
|
|
SpacingClassID = GetXmlAttributeIDString( aChildNode, 0 );
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "ATTR" ) )
|
|
|
|
{
|
|
|
|
ATTRIBUTE_VALUE attrVal;
|
2020-12-10 16:13:35 +00:00
|
|
|
attrVal.Parse( aChildNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
AttributeValues.insert( std::make_pair( attrVal.AttributeID, attrVal ) );
|
2020-07-30 22:42:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
return false;
|
2020-07-30 22:42:56 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
|
|
|
|
return true;
|
2020-07-30 22:42:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-10 16:13:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::DOCUMENTATION_SYMBOL::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
2020-07-30 22:42:56 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
wxASSERT( aNode->GetName() == wxT( "DOCSYMBOL" ) );
|
|
|
|
|
|
|
|
ID = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
SymdefID = GetXmlAttributeIDString( aNode, 1 );
|
|
|
|
LayerID = GetXmlAttributeIDString( aNode, 2 );
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
bool originParsed = false;
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
|
|
|
{
|
|
|
|
wxString cNodeName = cNode->GetName();
|
|
|
|
|
|
|
|
if( !originParsed && cNodeName == wxT( "PT" ) )
|
|
|
|
{
|
2020-12-10 16:13:35 +00:00
|
|
|
Origin.Parse( cNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
originParsed = true;
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "GROUPREF" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
GroupID = GetXmlAttributeIDString( cNode, 0 );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "REUSEBLOCKREF" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-12-10 16:13:35 +00:00
|
|
|
ReuseBlockRef.Parse( cNode, aContext );
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "FIX" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
Fixed = true;
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "MIRROR" ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-10 20:58:20 +00:00
|
|
|
Mirror = true;
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-09-10 20:58:20 +00:00
|
|
|
else if( cNodeName == wxT( "READABILITY" ) )
|
|
|
|
{
|
|
|
|
Readability = ParseReadability( cNode );
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "ORIENT" ) )
|
|
|
|
{
|
|
|
|
OrientAngle = GetXmlAttributeIDLong( cNode, 0 );
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "ATTR" ) )
|
|
|
|
{
|
|
|
|
ATTRIBUTE_VALUE attr;
|
2020-12-10 16:13:35 +00:00
|
|
|
attr.Parse( cNode, aContext );
|
2020-09-10 20:58:20 +00:00
|
|
|
AttributeValues.insert( std::make_pair( attr.AttributeID, attr ) );
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "SCALE" ) )
|
|
|
|
{
|
|
|
|
ScaleRatioNumerator = GetXmlAttributeIDLong( cNode, 0 );
|
|
|
|
ScaleRatioDenominator = GetXmlAttributeIDLong( cNode, 1 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !originParsed )
|
|
|
|
THROW_MISSING_PARAMETER_IO_ERROR( wxT( "PT" ), aNode->GetName() );
|
2020-07-30 22:42:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-27 00:09:58 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::DFLTSETTINGS::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "DFLTSETTINGS" ) );
|
|
|
|
|
|
|
|
Color = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
|
|
|
{
|
|
|
|
wxString cNodeName = cNode->GetName();
|
|
|
|
|
|
|
|
if( cNodeName == wxT( "INVISIBLE" ) )
|
|
|
|
{
|
|
|
|
IsVisible = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CADSTAR_ARCHIVE_PARSER::ATTRCOL::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "ATTRCOL" ) );
|
|
|
|
|
|
|
|
AttributeID = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
Color = GetXmlAttributeIDString( aNode, 1 );
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
|
|
|
{
|
|
|
|
wxString cNodeName = cNode->GetName();
|
|
|
|
|
|
|
|
if( cNodeName == wxT( "INVISIBLE" ) )
|
|
|
|
{
|
|
|
|
IsVisible = false;
|
|
|
|
}
|
2021-04-03 12:35:37 +00:00
|
|
|
else if( cNodeName == wxT( "NOTPICKABLE" ) )
|
|
|
|
{
|
|
|
|
IsPickable = false;
|
|
|
|
}
|
2021-01-27 00:09:58 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CADSTAR_ARCHIVE_PARSER::ATTRCOLORS::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "ATTRCOLORS" ) );
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
|
|
|
{
|
|
|
|
wxString cNodeName = cNode->GetName();
|
|
|
|
|
|
|
|
if( cNodeName == wxT( "DFLTSETTINGS" ) )
|
|
|
|
{
|
|
|
|
DefaultSettings.Parse( cNode, aContext );
|
|
|
|
}
|
|
|
|
else if( cNodeName == wxT( "ATTRCOL" ) )
|
|
|
|
{
|
|
|
|
ATTRCOL attrcol;
|
|
|
|
attrcol.Parse( cNode, aContext );
|
|
|
|
AttributeColors.insert( { attrcol.AttributeID, attrcol } );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
|
|
|
|
}
|
2021-02-02 13:39:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CADSTAR_ARCHIVE_PARSER::PARTNAMECOL::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
|
|
|
{
|
|
|
|
wxASSERT( aNode->GetName() == wxT( "PARTNAMECOL" ) );
|
|
|
|
|
|
|
|
Color = GetXmlAttributeIDString( aNode, 0 );
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
|
|
|
{
|
|
|
|
wxString cNodeName = cNode->GetName();
|
|
|
|
|
|
|
|
if( cNodeName == wxT( "INVISIBLE" ) )
|
|
|
|
{
|
|
|
|
IsVisible = false;
|
|
|
|
}
|
2021-04-03 12:35:37 +00:00
|
|
|
else if( cNodeName == wxT( "NOTPICKABLE" ) )
|
|
|
|
{
|
|
|
|
IsPickable = false;
|
|
|
|
}
|
2021-02-02 13:39:40 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
|
|
|
|
}
|
2021-01-27 00:09:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-29 18:09:48 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::InsertAttributeAtEnd( XNODE* aNode, wxString aValue )
|
2020-07-30 22:42:56 +00:00
|
|
|
{
|
2020-09-02 21:48:18 +00:00
|
|
|
wxString result;
|
|
|
|
int numAttributes = 0;
|
2020-09-18 10:32:57 +00:00
|
|
|
|
2020-09-02 21:48:18 +00:00
|
|
|
if( aNode->GetAttribute( wxT( "numAttributes" ), &result ) )
|
2020-07-30 22:42:56 +00:00
|
|
|
{
|
2020-09-02 21:48:18 +00:00
|
|
|
numAttributes = wxAtoi( result );
|
|
|
|
aNode->DeleteAttribute( wxT( "numAttributes" ) );
|
|
|
|
++numAttributes;
|
2020-07-30 22:42:56 +00:00
|
|
|
}
|
|
|
|
|
2020-09-02 21:48:18 +00:00
|
|
|
aNode->AddAttribute( wxT( "numAttributes" ), wxString::Format( wxT( "%i" ), numAttributes ) );
|
|
|
|
|
|
|
|
wxString paramName = wxT( "attr" );
|
|
|
|
paramName << numAttributes;
|
|
|
|
|
2020-07-30 22:42:56 +00:00
|
|
|
aNode->AddAttribute( paramName, aValue );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
XNODE* CADSTAR_ARCHIVE_PARSER::LoadArchiveFile( const wxString& aFileName,
|
2021-09-09 21:15:38 +00:00
|
|
|
const wxString& aFileTypeIdentifier, PROGRESS_REPORTER* aProgressReporter )
|
2020-07-30 22:42:56 +00:00
|
|
|
{
|
|
|
|
KEYWORD emptyKeywords[1] = {};
|
2021-07-15 19:26:35 +00:00
|
|
|
XNODE * iNode = nullptr, *cNode = nullptr;
|
2020-07-30 22:42:56 +00:00
|
|
|
int tok;
|
|
|
|
bool cadstarFileCheckDone = false;
|
|
|
|
wxString str;
|
|
|
|
wxCSConv win1252( wxT( "windows-1252" ) );
|
|
|
|
wxMBConv* conv = &win1252; // Initial testing suggests file encoding to be Windows-1252
|
|
|
|
// More samples required.
|
2021-09-09 21:15:38 +00:00
|
|
|
|
|
|
|
// Open the file and get the file size
|
2020-07-30 22:42:56 +00:00
|
|
|
FILE* fp = wxFopen( aFileName, wxT( "rt" ) );
|
|
|
|
|
|
|
|
if( !fp )
|
|
|
|
THROW_IO_ERROR( wxString::Format( _( "Cannot open file '%s'" ), aFileName ) );
|
|
|
|
|
2021-09-14 17:15:43 +00:00
|
|
|
fseek( fp, 0L, SEEK_END );
|
|
|
|
long fileSize = ftell( fp );
|
|
|
|
rewind( fp );
|
|
|
|
|
2020-07-30 22:42:56 +00:00
|
|
|
DSNLEXER lexer( emptyKeywords, 0, fp, aFileName );
|
|
|
|
|
2021-10-17 12:06:23 +00:00
|
|
|
auto currentProgress = [&]() -> double
|
|
|
|
{
|
|
|
|
return static_cast<double>( ftell( fp ) ) / fileSize;
|
|
|
|
};
|
|
|
|
|
|
|
|
double previousReportedProgress = -1.0;
|
2021-09-09 21:15:38 +00:00
|
|
|
|
2020-07-30 22:42:56 +00:00
|
|
|
while( ( tok = lexer.NextTok() ) != DSN_EOF )
|
|
|
|
{
|
2021-10-17 12:06:23 +00:00
|
|
|
if( aProgressReporter && ( currentProgress() - previousReportedProgress ) > 0.01 )
|
2021-09-09 21:15:38 +00:00
|
|
|
{
|
|
|
|
if( !aProgressReporter->KeepRefreshing() )
|
|
|
|
THROW_IO_ERROR( _( "File import cancelled by user." ) );
|
|
|
|
|
2021-10-17 12:06:23 +00:00
|
|
|
aProgressReporter->SetCurrentProgress( currentProgress() );
|
|
|
|
previousReportedProgress = currentProgress();
|
2021-09-09 21:15:38 +00:00
|
|
|
}
|
|
|
|
|
2020-07-30 22:42:56 +00:00
|
|
|
if( tok == DSN_RIGHT )
|
|
|
|
{
|
|
|
|
cNode = iNode;
|
|
|
|
if( cNode )
|
|
|
|
{
|
|
|
|
iNode = cNode->GetParent();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//too many closing brackets
|
|
|
|
THROW_IO_ERROR( _( "The selected file is not valid or might be corrupt!" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( tok == DSN_LEFT )
|
|
|
|
{
|
|
|
|
tok = lexer.NextTok();
|
|
|
|
str = wxString( lexer.CurText(), *conv );
|
|
|
|
cNode = new XNODE( wxXML_ELEMENT_NODE, str );
|
|
|
|
|
|
|
|
if( iNode )
|
|
|
|
{
|
|
|
|
//we will add it as attribute as well as child node
|
|
|
|
InsertAttributeAtEnd( iNode, str );
|
|
|
|
iNode->AddChild( cNode );
|
|
|
|
}
|
|
|
|
else if( !cadstarFileCheckDone )
|
|
|
|
{
|
|
|
|
if( cNode->GetName() != aFileTypeIdentifier )
|
|
|
|
THROW_IO_ERROR( _( "The selected file is not valid or might be corrupt!" ) );
|
2020-09-18 10:32:57 +00:00
|
|
|
|
2020-07-30 22:42:56 +00:00
|
|
|
cadstarFileCheckDone = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
iNode = cNode;
|
|
|
|
}
|
|
|
|
else if( iNode )
|
|
|
|
{
|
|
|
|
str = wxString( lexer.CurText(), *conv );
|
|
|
|
//Insert even if string is empty
|
|
|
|
InsertAttributeAtEnd( iNode, str );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//not enough closing brackets
|
|
|
|
THROW_IO_ERROR( _( "The selected file is not valid or might be corrupt!" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-18 10:32:57 +00:00
|
|
|
// Not enough closing brackets
|
2021-07-15 19:26:35 +00:00
|
|
|
if( iNode != nullptr )
|
2020-07-30 22:42:56 +00:00
|
|
|
THROW_IO_ERROR( _( "The selected file is not valid or might be corrupt!" ) );
|
|
|
|
|
2020-09-18 10:32:57 +00:00
|
|
|
// Throw if no data was parsed
|
2020-07-30 22:42:56 +00:00
|
|
|
if( cNode )
|
|
|
|
return cNode;
|
|
|
|
else
|
|
|
|
THROW_IO_ERROR( _( "The selected file is not valid or might be corrupt!" ) );
|
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
return nullptr;
|
2020-07-30 22:42:56 +00:00
|
|
|
}
|
|
|
|
|
2020-09-02 21:48:18 +00:00
|
|
|
|
|
|
|
bool CADSTAR_ARCHIVE_PARSER::IsValidAttribute( wxXmlAttribute* aAttribute )
|
|
|
|
{
|
|
|
|
return aAttribute->GetName() != wxT( "numAttributes" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
wxString CADSTAR_ARCHIVE_PARSER::GetXmlAttributeIDString( XNODE* aNode, unsigned int aID,
|
|
|
|
bool aIsRequired )
|
2020-07-30 22:42:56 +00:00
|
|
|
{
|
|
|
|
wxString attrName, retVal;
|
|
|
|
attrName = "attr";
|
|
|
|
attrName << aID;
|
|
|
|
|
|
|
|
if( !aNode->GetAttribute( attrName, &retVal ) )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-13 21:42:17 +00:00
|
|
|
if( aIsRequired )
|
|
|
|
THROW_MISSING_PARAMETER_IO_ERROR( std::to_string( aID ), aNode->GetName() );
|
|
|
|
else
|
|
|
|
return wxEmptyString;
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-07-30 22:42:56 +00:00
|
|
|
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
long CADSTAR_ARCHIVE_PARSER::GetXmlAttributeIDLong( XNODE* aNode, unsigned int aID,
|
|
|
|
bool aIsRequired )
|
2020-07-30 22:42:56 +00:00
|
|
|
{
|
|
|
|
long retVal;
|
2020-09-13 21:42:17 +00:00
|
|
|
bool success = GetXmlAttributeIDString( aNode, aID, aIsRequired ).ToLong( &retVal );
|
2020-07-30 22:42:56 +00:00
|
|
|
|
2020-09-13 21:42:17 +00:00
|
|
|
if( !success )
|
2020-09-27 13:10:59 +00:00
|
|
|
{
|
2020-09-13 21:42:17 +00:00
|
|
|
if( aIsRequired )
|
|
|
|
THROW_PARSING_IO_ERROR( std::to_string( aID ), aNode->GetName() );
|
|
|
|
else
|
|
|
|
return UNDEFINED_VALUE;
|
2020-09-27 13:10:59 +00:00
|
|
|
}
|
2020-07-30 22:42:56 +00:00
|
|
|
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-29 18:09:48 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::CheckNoChildNodes( XNODE* aNode )
|
2020-07-30 22:42:56 +00:00
|
|
|
{
|
2020-08-31 22:09:29 +00:00
|
|
|
if( aNode && aNode->GetChildren() )
|
2020-07-30 22:42:56 +00:00
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( aNode->GetChildren()->GetName(), aNode->GetName() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-29 18:09:48 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::CheckNoNextNodes( XNODE* aNode )
|
2020-07-30 22:42:56 +00:00
|
|
|
{
|
2020-08-31 22:09:29 +00:00
|
|
|
if( aNode && aNode->GetNext() )
|
2020-07-30 22:42:56 +00:00
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( aNode->GetNext()->GetName(), aNode->GetParent()->GetName() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-15 19:26:35 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::ParseChildEValue( XNODE* aNode, PARSER_CONTEXT* aContext,
|
|
|
|
EVALUE& aValueToParse )
|
2020-07-30 22:42:56 +00:00
|
|
|
{
|
|
|
|
if( aNode->GetChildren()->GetName() == wxT( "E" ) )
|
2020-12-10 16:13:35 +00:00
|
|
|
aValueToParse.Parse( aNode->GetChildren(), aContext );
|
2020-07-30 22:42:56 +00:00
|
|
|
else
|
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( aNode->GetChildren()->GetName(), aNode->GetName() );
|
|
|
|
}
|
|
|
|
|
2020-09-06 17:00:02 +00:00
|
|
|
|
2020-08-29 18:09:48 +00:00
|
|
|
std::vector<CADSTAR_ARCHIVE_PARSER::POINT> CADSTAR_ARCHIVE_PARSER::ParseAllChildPoints(
|
2020-12-10 16:13:35 +00:00
|
|
|
XNODE* aNode, PARSER_CONTEXT* aContext, bool aTestAllChildNodes, int aExpectedNumPoints )
|
2020-07-30 22:42:56 +00:00
|
|
|
{
|
|
|
|
std::vector<POINT> retVal;
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
|
|
|
{
|
|
|
|
if( cNode->GetName() == wxT( "PT" ) )
|
|
|
|
{
|
|
|
|
POINT pt;
|
|
|
|
//TODO try.. catch + throw again with more detailed error information
|
2020-12-10 16:13:35 +00:00
|
|
|
pt.Parse( cNode, aContext );
|
2020-07-30 22:42:56 +00:00
|
|
|
retVal.push_back( pt );
|
|
|
|
}
|
|
|
|
else if( aTestAllChildNodes )
|
2020-09-18 10:32:57 +00:00
|
|
|
{
|
2020-07-30 22:42:56 +00:00
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), aNode->GetName() );
|
2020-09-18 10:32:57 +00:00
|
|
|
}
|
2020-07-30 22:42:56 +00:00
|
|
|
}
|
|
|
|
|
2020-09-19 22:05:02 +00:00
|
|
|
if( aExpectedNumPoints != UNDEFINED_VALUE
|
|
|
|
&& retVal.size() != static_cast<size_t>( aExpectedNumPoints ) )
|
2020-09-18 10:32:57 +00:00
|
|
|
{
|
2020-07-30 22:42:56 +00:00
|
|
|
THROW_IO_ERROR( wxString::Format(
|
2020-09-19 22:05:02 +00:00
|
|
|
_( "Unexpected number of points in '%s'. Found %d but expected %d." ),
|
|
|
|
aNode->GetName(), retVal.size(), aExpectedNumPoints ) );
|
2020-09-18 10:32:57 +00:00
|
|
|
}
|
2020-07-30 22:42:56 +00:00
|
|
|
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-29 18:09:48 +00:00
|
|
|
std::vector<CADSTAR_ARCHIVE_PARSER::VERTEX> CADSTAR_ARCHIVE_PARSER::ParseAllChildVertices(
|
2020-12-10 16:13:35 +00:00
|
|
|
XNODE* aNode, PARSER_CONTEXT* aContext, bool aTestAllChildNodes )
|
2020-07-30 22:42:56 +00:00
|
|
|
{
|
|
|
|
std::vector<VERTEX> retVal;
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
|
|
|
{
|
|
|
|
if( VERTEX::IsVertex( cNode ) )
|
|
|
|
{
|
|
|
|
VERTEX vertex;
|
|
|
|
//TODO try.. catch + throw again with more detailed error information
|
2020-12-10 16:13:35 +00:00
|
|
|
vertex.Parse( cNode, aContext );
|
2020-07-30 22:42:56 +00:00
|
|
|
retVal.push_back( vertex );
|
|
|
|
}
|
|
|
|
else if( aTestAllChildNodes )
|
2020-09-18 10:32:57 +00:00
|
|
|
{
|
2020-07-30 22:42:56 +00:00
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), aNode->GetName() );
|
2020-09-18 10:32:57 +00:00
|
|
|
}
|
2020-07-30 22:42:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-29 18:09:48 +00:00
|
|
|
std::vector<CADSTAR_ARCHIVE_PARSER::CUTOUT> CADSTAR_ARCHIVE_PARSER::ParseAllChildCutouts(
|
2020-12-10 16:13:35 +00:00
|
|
|
XNODE* aNode, PARSER_CONTEXT* aContext, bool aTestAllChildNodes )
|
2020-07-30 22:42:56 +00:00
|
|
|
{
|
|
|
|
std::vector<CUTOUT> retVal;
|
|
|
|
|
|
|
|
XNODE* cNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
for( ; cNode; cNode = cNode->GetNext() )
|
|
|
|
{
|
|
|
|
if( cNode->GetName() == wxT( "CUTOUT" ) )
|
|
|
|
{
|
|
|
|
CUTOUT cutout;
|
|
|
|
//TODO try.. catch + throw again with more detailed error information
|
2020-12-10 16:13:35 +00:00
|
|
|
cutout.Parse( cNode, aContext );
|
2020-07-30 22:42:56 +00:00
|
|
|
retVal.push_back( cutout );
|
|
|
|
}
|
|
|
|
else if( aTestAllChildNodes )
|
2020-09-18 10:32:57 +00:00
|
|
|
{
|
2020-07-30 22:42:56 +00:00
|
|
|
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), aNode->GetName() );
|
2020-09-18 10:32:57 +00:00
|
|
|
}
|
2020-07-30 22:42:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return retVal;
|
|
|
|
}
|
2020-12-30 02:04:19 +00:00
|
|
|
|
|
|
|
|
2021-09-09 21:15:38 +00:00
|
|
|
long CADSTAR_ARCHIVE_PARSER::GetNumberOfChildNodes( XNODE* aNode )
|
|
|
|
{
|
|
|
|
XNODE* childNodes = aNode->GetChildren();
|
|
|
|
long retval = 0;
|
|
|
|
|
|
|
|
for( ; childNodes; childNodes = childNodes->GetNext() )
|
|
|
|
retval++;
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
long CADSTAR_ARCHIVE_PARSER::GetNumberOfStepsForReporting( XNODE* aRootNode, std::vector<wxString> aSubNodeChildrenToCount )
|
|
|
|
{
|
|
|
|
XNODE* level1Node = aRootNode->GetChildren();
|
|
|
|
long retval = 0;
|
|
|
|
|
|
|
|
for( ; level1Node; level1Node = level1Node->GetNext() )
|
|
|
|
{
|
|
|
|
for( wxString childNodeName : aSubNodeChildrenToCount )
|
|
|
|
{
|
|
|
|
if( level1Node->GetName() == childNodeName )
|
|
|
|
retval += GetNumberOfChildNodes( level1Node );
|
|
|
|
}
|
|
|
|
|
|
|
|
retval++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-09-01 18:24:42 +00:00
|
|
|
wxString CADSTAR_ARCHIVE_PARSER::HandleTextOverbar( wxString aCadstarString )
|
|
|
|
{
|
|
|
|
wxString escapedText = aCadstarString;
|
|
|
|
|
|
|
|
escapedText.Replace( wxT( "'" ), wxT( "~" ) );
|
|
|
|
|
|
|
|
return ConvertToNewOverbarNotation( escapedText );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-30 02:04:19 +00:00
|
|
|
void CADSTAR_ARCHIVE_PARSER::FixTextPositionNoAlignment( EDA_TEXT* aKiCadTextItem )
|
|
|
|
{
|
|
|
|
if( !aKiCadTextItem->GetText().IsEmpty() )
|
|
|
|
{
|
2022-01-05 02:23:11 +00:00
|
|
|
VECTOR2I positionOffset( 0, aKiCadTextItem->GetInterline() );
|
2022-01-16 21:15:20 +00:00
|
|
|
RotatePoint( positionOffset, aKiCadTextItem->GetTextAngle() );
|
2020-12-30 02:04:19 +00:00
|
|
|
|
2021-04-09 19:11:12 +00:00
|
|
|
EDA_ITEM* textEdaItem = dynamic_cast<EDA_ITEM*>( aKiCadTextItem );
|
|
|
|
|
2021-04-14 01:53:43 +00:00
|
|
|
if( textEdaItem &&
|
|
|
|
( textEdaItem->Type() == LIB_TEXT_T || textEdaItem->Type() == LIB_FIELD_T ) )
|
2021-04-09 19:11:12 +00:00
|
|
|
{
|
|
|
|
// Y coordinate increases upwards in the symbol editor
|
|
|
|
positionOffset.y = -positionOffset.y;
|
|
|
|
}
|
|
|
|
|
2020-12-30 02:04:19 +00:00
|
|
|
//Count num of additional lines
|
|
|
|
wxString text = aKiCadTextItem->GetText();
|
|
|
|
int numExtraLines = text.Replace( "\n", "\n" );
|
|
|
|
numExtraLines -= text.at( text.size() - 1 ) == '\n'; // Ignore new line character at end
|
|
|
|
positionOffset.x *= numExtraLines;
|
|
|
|
positionOffset.y *= numExtraLines;
|
|
|
|
|
|
|
|
aKiCadTextItem->Offset( positionOffset );
|
|
|
|
}
|
|
|
|
}
|
2021-09-09 21:15:38 +00:00
|
|
|
|
|
|
|
void CADSTAR_ARCHIVE_PARSER::checkPoint()
|
|
|
|
{
|
|
|
|
if( m_progressReporter )
|
|
|
|
{
|
|
|
|
m_progressReporter->AdvanceProgress();
|
|
|
|
|
|
|
|
if( !m_progressReporter->KeepRefreshing() )
|
|
|
|
THROW_IO_ERROR( _( "File import cancelled by user." ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|