CADSTAR Schematic / PCB Archive Importers: Add missing import warnings and fix code formatting

This commit is contained in:
Roberto Fernandez Bautista 2020-09-27 14:10:59 +01:00
parent 5e2e692ad8
commit 93242eb3ad
7 changed files with 294 additions and 38 deletions

View File

@ -65,30 +65,44 @@ void CADSTAR_ARCHIVE_PARSER::HEADER::Parse( XNODE* aNode )
Format.Parse( cNode ); Format.Parse( cNode );
} }
else if( nodeName == wxT( "JOBFILE" ) ) else if( nodeName == wxT( "JOBFILE" ) )
{
JobFile = GetXmlAttributeIDString( cNode, 0 ); JobFile = GetXmlAttributeIDString( cNode, 0 );
}
else if( nodeName == wxT( "JOBTITLE" ) ) else if( nodeName == wxT( "JOBTITLE" ) )
{
JobTitle = GetXmlAttributeIDString( cNode, 0 ); JobTitle = GetXmlAttributeIDString( cNode, 0 );
}
else if( nodeName == wxT( "GENERATOR" ) ) else if( nodeName == wxT( "GENERATOR" ) )
{
Generator = GetXmlAttributeIDString( cNode, 0 ); Generator = GetXmlAttributeIDString( cNode, 0 );
}
else if( nodeName == wxT( "RESOLUTION" ) ) else if( nodeName == wxT( "RESOLUTION" ) )
{ {
XNODE* subNode = cNode->GetChildren(); XNODE* subNode = cNode->GetChildren();
if( ( subNode->GetName() == wxT( "METRIC" ) ) if( ( subNode->GetName() == wxT( "METRIC" ) )
&& ( GetXmlAttributeIDString( subNode, 0 ) == wxT( "HUNDREDTH" ) ) && ( GetXmlAttributeIDString( subNode, 0 ) == wxT( "HUNDREDTH" ) )
&& ( GetXmlAttributeIDString( subNode, 1 ) == wxT( "MICRON" ) ) ) && ( GetXmlAttributeIDString( subNode, 1 ) == wxT( "MICRON" ) ) )
{ {
Resolution = RESOLUTION::HUNDREDTH_MICRON; Resolution = RESOLUTION::HUNDREDTH_MICRON;
} }
else // TODO Need to find out if there are other possible resolutions. Logically else
// 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 // TODO Need to find out if there are other possible resolutions. Logically
// output resolution to "HUNDREDTH MICRON" // 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"
THROW_UNKNOWN_NODE_IO_ERROR( subNode->GetName(), wxT( "HEADER->RESOLUTION" ) ); THROW_UNKNOWN_NODE_IO_ERROR( subNode->GetName(), wxT( "HEADER->RESOLUTION" ) );
}
} }
else if( nodeName == wxT( "TIMESTAMP" ) ) else if( nodeName == wxT( "TIMESTAMP" ) )
{
Timestamp.Parse( cNode ); Timestamp.Parse( cNode );
}
else else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), wxT( "HEADER" ) ); THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), wxT( "HEADER" ) );
}
} }
} }
@ -153,18 +167,30 @@ void CADSTAR_ARCHIVE_PARSER::LINECODE::Parse( XNODE* aNode )
wxString styleStr = GetXmlAttributeIDString( cNode, 0 ); wxString styleStr = GetXmlAttributeIDString( cNode, 0 );
if( styleStr == wxT( "SOLID" ) ) if( styleStr == wxT( "SOLID" ) )
{
Style = LINESTYLE::SOLID; Style = LINESTYLE::SOLID;
}
else if( styleStr == wxT( "DASH" ) ) else if( styleStr == wxT( "DASH" ) )
{
Style = LINESTYLE::DASH; Style = LINESTYLE::DASH;
}
else if( styleStr == wxT( "DASHDOT" ) ) else if( styleStr == wxT( "DASHDOT" ) )
{
Style = LINESTYLE::DASHDOT; Style = LINESTYLE::DASHDOT;
}
else if( styleStr == wxT( "DASHDOTDOT" ) ) else if( styleStr == wxT( "DASHDOTDOT" ) )
{
Style = LINESTYLE::DASHDOTDOT; Style = LINESTYLE::DASHDOTDOT;
}
else if( styleStr == wxT( "DOT" ) ) else if( styleStr == wxT( "DOT" ) )
{
Style = LINESTYLE::DOT; Style = LINESTYLE::DOT;
}
else else
{
THROW_UNKNOWN_PARAMETER_IO_ERROR( wxString::Format( "STYLE %s", styleStr ), THROW_UNKNOWN_PARAMETER_IO_ERROR( wxString::Format( "STYLE %s", styleStr ),
wxString::Format( "LINECODE -> %s", Name ) ); wxString::Format( "LINECODE -> %s", Name ) );
}
} }
@ -395,9 +421,13 @@ bool CADSTAR_ARCHIVE_PARSER::SHAPE::IsShape( XNODE* aNode )
if( aNodeName == wxT( "OPENSHAPE" ) || aNodeName == wxT( "OUTLINE" ) if( aNodeName == wxT( "OPENSHAPE" ) || aNodeName == wxT( "OUTLINE" )
|| aNodeName == wxT( "SOLID" ) || aNodeName == wxT( "HATCHED" ) ) || aNodeName == wxT( "SOLID" ) || aNodeName == wxT( "HATCHED" ) )
{
return true; return true;
}
else else
{
return false; return false;
}
} }
@ -436,9 +466,12 @@ void CADSTAR_ARCHIVE_PARSER::SHAPE::Parse( XNODE* aNode )
HatchCodeID = GetXmlAttributeIDString( aNode, 0 ); HatchCodeID = GetXmlAttributeIDString( aNode, 0 );
} }
else else
{
wxASSERT_MSG( true, wxT( "Unknown SHAPE type" ) ); wxASSERT_MSG( true, wxT( "Unknown SHAPE type" ) );
}
} }
CADSTAR_ARCHIVE_PARSER::UNITS CADSTAR_ARCHIVE_PARSER::ParseUnits( XNODE* aNode ) CADSTAR_ARCHIVE_PARSER::UNITS CADSTAR_ARCHIVE_PARSER::ParseUnits( XNODE* aNode )
{ {
wxASSERT( aNode->GetName() == wxT( "UNITS" ) ); wxASSERT( aNode->GetName() == wxT( "UNITS" ) );
@ -528,20 +561,28 @@ void CADSTAR_ARCHIVE_PARSER::GRIDS::Parse( XNODE* aNode )
XNODE* workingGridNode = cNode->GetChildren(); XNODE* workingGridNode = cNode->GetChildren();
if( !GRID::IsGrid( workingGridNode ) ) if( !GRID::IsGrid( workingGridNode ) )
{
THROW_UNKNOWN_NODE_IO_ERROR( THROW_UNKNOWN_NODE_IO_ERROR(
workingGridNode->GetName(), wxT( "GRIDS -> WORKINGGRID" ) ); workingGridNode->GetName(), wxT( "GRIDS -> WORKINGGRID" ) );
}
else else
{
WorkingGrid.Parse( workingGridNode ); WorkingGrid.Parse( workingGridNode );
}
} }
else if( cNodeName == wxT( "SCREENGRID" ) ) else if( cNodeName == wxT( "SCREENGRID" ) )
{ {
XNODE* screenGridNode = cNode->GetChildren(); XNODE* screenGridNode = cNode->GetChildren();
if( !GRID::IsGrid( screenGridNode ) ) if( !GRID::IsGrid( screenGridNode ) )
{
THROW_UNKNOWN_NODE_IO_ERROR( THROW_UNKNOWN_NODE_IO_ERROR(
screenGridNode->GetName(), wxT( "GRIDS -> SCREENGRID" ) ); screenGridNode->GetName(), wxT( "GRIDS -> SCREENGRID" ) );
}
else else
{
ScreenGrid.Parse( screenGridNode ); ScreenGrid.Parse( screenGridNode );
}
} }
else if( GRID::IsGrid( cNode ) ) else if( GRID::IsGrid( cNode ) )
{ {
@ -558,17 +599,29 @@ bool CADSTAR_ARCHIVE_PARSER::SETTINGS::ParseSubNode( XNODE* aChildNode )
wxString cNodeName = aChildNode->GetName(); wxString cNodeName = aChildNode->GetName();
if( cNodeName == wxT( "UNITS" ) ) if( cNodeName == wxT( "UNITS" ) )
{
Units = ParseUnits( aChildNode ); Units = ParseUnits( aChildNode );
}
else if( cNodeName == wxT( "UNITSPRECISION" ) ) else if( cNodeName == wxT( "UNITSPRECISION" ) )
{
UnitDisplPrecision = GetXmlAttributeIDLong( aChildNode, 0 ); UnitDisplPrecision = GetXmlAttributeIDLong( aChildNode, 0 );
}
else if( cNodeName == wxT( "INTERLINEGAP" ) ) else if( cNodeName == wxT( "INTERLINEGAP" ) )
{
InterlineGap = GetXmlAttributeIDLong( aChildNode, 0 ); InterlineGap = GetXmlAttributeIDLong( aChildNode, 0 );
}
else if( cNodeName == wxT( "BARLINEGAP" ) ) else if( cNodeName == wxT( "BARLINEGAP" ) )
{
BarlineGap = GetXmlAttributeIDLong( aChildNode, 0 ); BarlineGap = GetXmlAttributeIDLong( aChildNode, 0 );
}
else if( cNodeName == wxT( "ALLOWBARTEXT" ) ) else if( cNodeName == wxT( "ALLOWBARTEXT" ) )
{
AllowBarredText = true; AllowBarredText = true;
}
else if( cNodeName == wxT( "ANGULARPRECISION" ) ) else if( cNodeName == wxT( "ANGULARPRECISION" ) )
{
AngularPrecision = GetXmlAttributeIDLong( aChildNode, 0 ); AngularPrecision = GetXmlAttributeIDLong( aChildNode, 0 );
}
else if( cNodeName == wxT( "DESIGNORIGIN" ) ) else if( cNodeName == wxT( "DESIGNORIGIN" ) )
{ {
DesignOrigin.Parse( aChildNode->GetChildren() ); DesignOrigin.Parse( aChildNode->GetChildren() );
@ -606,8 +659,7 @@ void CADSTAR_ARCHIVE_PARSER::SETTINGS::Parse( XNODE* aNode )
wxString cNodeName = cNode->GetName(); wxString cNodeName = cNode->GetName();
if( ParseSubNode( cNode ) ) if( ParseSubNode( cNode ) )
{ continue;
}
else else
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, wxT( "SETTINGS" ) ); THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, wxT( "SETTINGS" ) );
} }
@ -829,7 +881,9 @@ void CADSTAR_ARCHIVE_PARSER::ATTRNAME::Parse( XNODE* aNode )
THROW_UNKNOWN_PARAMETER_IO_ERROR( attUsageVal, location ); THROW_UNKNOWN_PARAMETER_IO_ERROR( attUsageVal, location );
} }
else if( cNodeName == wxT( "NOTRANSFER" ) ) else if( cNodeName == wxT( "NOTRANSFER" ) )
{
NoTransfer = true; NoTransfer = true;
}
else if( cNodeName == wxT( "COLUMNORDER" ) ) else if( cNodeName == wxT( "COLUMNORDER" ) )
{ {
COLUMNORDER cOrder; COLUMNORDER cOrder;
@ -843,9 +897,13 @@ void CADSTAR_ARCHIVE_PARSER::ATTRNAME::Parse( XNODE* aNode )
ColumnWidths.push_back( cWidth ); ColumnWidths.push_back( cWidth );
} }
else if( cNodeName == wxT( "COLUMNINVISIBLE" ) ) else if( cNodeName == wxT( "COLUMNINVISIBLE" ) )
{
ColumnInvisible = true; ColumnInvisible = true;
}
else else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, location ); THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, location );
}
} }
} }
@ -862,14 +920,18 @@ void CADSTAR_ARCHIVE_PARSER::ATTRIBUTE_VALUE::Parse( XNODE* aNode )
for( ; cNode; cNode = cNode->GetNext() ) for( ; cNode; cNode = cNode->GetNext() )
{ {
if( cNode->GetName() == wxT( "READONLY" ) ) if( cNode->GetName() == wxT( "READONLY" ) )
{
ReadOnly = true; ReadOnly = true;
}
else if( cNode->GetName() == wxT( "ATTRLOC" ) ) else if( cNode->GetName() == wxT( "ATTRLOC" ) )
{ {
AttributeLocation.Parse( cNode ); AttributeLocation.Parse( cNode );
HasLocation = true; HasLocation = true;
} }
else else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), wxT( "ATTR" ) ); THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), wxT( "ATTR" ) );
}
} }
} }
@ -932,24 +994,38 @@ void CADSTAR_ARCHIVE_PARSER::TEXT_LOCATION::Parse( XNODE* aNode )
wxString cNodeName = cNode->GetName(); wxString cNodeName = cNode->GetName();
if( ParseSubNode( cNode ) ) if( ParseSubNode( cNode ) )
{
continue; continue;
}
else if( !attributeIDisSet && cNodeName == wxT( "ATTRREF" ) ) else if( !attributeIDisSet && cNodeName == wxT( "ATTRREF" ) )
{ {
AttributeID = GetXmlAttributeIDString( cNode, 0 ); AttributeID = GetXmlAttributeIDString( cNode, 0 );
attributeIDisSet = true; attributeIDisSet = true;
} }
else if( cNodeName == wxT( "ORIENT" ) ) else if( cNodeName == wxT( "ORIENT" ) )
{
OrientAngle = GetXmlAttributeIDLong( cNode, 0 ); OrientAngle = GetXmlAttributeIDLong( cNode, 0 );
}
else if( cNodeName == wxT( "MIRROR" ) ) else if( cNodeName == wxT( "MIRROR" ) )
{
Mirror = true; Mirror = true;
}
else if( cNodeName == wxT( "FIX" ) ) else if( cNodeName == wxT( "FIX" ) )
{
Fixed = true; Fixed = true;
}
else if( cNodeName == wxT( "ALIGN" ) ) else if( cNodeName == wxT( "ALIGN" ) )
{
Alignment = ParseAlignment( cNode ); Alignment = ParseAlignment( cNode );
}
else if( cNodeName == wxT( "JUSTIFICATION" ) ) else if( cNodeName == wxT( "JUSTIFICATION" ) )
{
Justification = ParseJustification( cNode ); Justification = ParseJustification( cNode );
}
else else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, wxT( "TEXTLOC" ) ); THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, wxT( "TEXTLOC" ) );
}
} }
if( !Position.IsFullySpecified() ) if( !Position.IsFullySpecified() )
@ -978,7 +1054,9 @@ void CADSTAR_ARCHIVE_PARSER::NETCLASS::Parse( XNODE* aNode )
Attributes.push_back( attribute_val ); Attributes.push_back( attribute_val );
} }
else else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, location ); THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, location );
}
} }
} }
@ -1162,11 +1240,18 @@ void CADSTAR_ARCHIVE_PARSER::FIGURE::Parse( XNODE* aNode )
SwapRule = ParseSwapRule( cNode ); SwapRule = ParseSwapRule( cNode );
} }
else if( cNodeName == wxT( "FIX" ) ) else if( cNodeName == wxT( "FIX" ) )
{
Fixed = true; Fixed = true;
}
else if( cNodeName == wxT( "GROUPREF" ) ) else if( cNodeName == wxT( "GROUPREF" ) )
{
GroupID = GetXmlAttributeIDString( cNode, 0 ); GroupID = GetXmlAttributeIDString( cNode, 0 );
}
else if( cNodeName == wxT( "REUSEBLOCKREF" ) ) else if( cNodeName == wxT( "REUSEBLOCKREF" ) )
{
ReuseBlockRef.Parse( cNode ); ReuseBlockRef.Parse( cNode );
}
else if( cNodeName == wxT( "ATTR" ) ) else if( cNodeName == wxT( "ATTR" ) )
{ {
ATTRIBUTE_VALUE attr; ATTRIBUTE_VALUE attr;
@ -1174,7 +1259,9 @@ void CADSTAR_ARCHIVE_PARSER::FIGURE::Parse( XNODE* aNode )
AttributeValues.insert( std::make_pair( attr.AttributeID, attr ) ); AttributeValues.insert( std::make_pair( attr.AttributeID, attr ) );
} }
else else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, location ); THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, location );
}
} }
} }
@ -1330,26 +1417,42 @@ void CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::PIN::Parse( XNODE* aNode )
wxString cNodeName = cNode->GetName(); wxString cNodeName = cNode->GetName();
if( cNodeName == wxT( "PINNAME" ) ) if( cNodeName == wxT( "PINNAME" ) )
{
Name = GetXmlAttributeIDString( cNode, 0 ); Name = GetXmlAttributeIDString( cNode, 0 );
}
else if( cNodeName == wxT( "PINLABEL" ) ) else if( cNodeName == wxT( "PINLABEL" ) )
{
Label = GetXmlAttributeIDString( cNode, 0 ); Label = GetXmlAttributeIDString( cNode, 0 );
}
else if( cNodeName == wxT( "PINSIGNAL" ) ) else if( cNodeName == wxT( "PINSIGNAL" ) )
{
Signal = GetXmlAttributeIDString( cNode, 0 ); Signal = GetXmlAttributeIDString( cNode, 0 );
}
else if( cNodeName == wxT( "PINTERM" ) ) else if( cNodeName == wxT( "PINTERM" ) )
{ {
TerminalGate = GetXmlAttributeIDString( cNode, 0 ); TerminalGate = GetXmlAttributeIDString( cNode, 0 );
TerminalPin = GetXmlAttributeIDLong( cNode, 1 ); TerminalPin = GetXmlAttributeIDLong( cNode, 1 );
} }
else if( cNodeName == wxT( "PINTYPE" ) ) else if( cNodeName == wxT( "PINTYPE" ) )
{
Type = GetPinType( cNode ); Type = GetPinType( cNode );
}
else if( cNodeName == wxT( "PINLOAD" ) ) else if( cNodeName == wxT( "PINLOAD" ) )
{
Load = GetXmlAttributeIDLong( cNode, 0 ); Load = GetXmlAttributeIDLong( cNode, 0 );
}
else if( cNodeName == wxT( "PINPOSITION" ) ) else if( cNodeName == wxT( "PINPOSITION" ) )
{
Position = (POSITION) GetXmlAttributeIDLong( cNode, 0 ); Position = (POSITION) GetXmlAttributeIDLong( cNode, 0 );
}
else if( cNodeName == wxT( "PINIDENTIFIER" ) ) else if( cNodeName == wxT( "PINIDENTIFIER" ) )
{
Identifier = GetXmlAttributeIDString( cNode, 0 ); Identifier = GetXmlAttributeIDString( cNode, 0 );
}
else else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() ); THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
}
} }
} }
@ -1437,7 +1540,9 @@ void CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::SWAP_GROUP::Parse( XNODE* aNode )
wxString cNodeName = cNode->GetName(); wxString cNodeName = cNode->GetName();
if( cNodeName == wxT( "EXTERNAL" ) ) if( cNodeName == wxT( "EXTERNAL" ) )
{
External = true; External = true;
}
else if( cNodeName == wxT( "SWAPGATE" ) ) else if( cNodeName == wxT( "SWAPGATE" ) )
{ {
SWAP_GATE swapGate; SWAP_GATE swapGate;
@ -1445,7 +1550,9 @@ void CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::SWAP_GROUP::Parse( XNODE* aNode )
SwapGates.push_back( swapGate ); SwapGates.push_back( swapGate );
} }
else else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() ); THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
}
} }
} }
@ -1463,9 +1570,13 @@ void CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::Parse( XNODE* aNode )
wxString cNodeName = cNode->GetName(); wxString cNodeName = cNode->GetName();
if( cNodeName == wxT( "HIDEPINNAMES" ) ) if( cNodeName == wxT( "HIDEPINNAMES" ) )
{
HidePinNames = true; HidePinNames = true;
}
else if( cNodeName == wxT( "MAXPIN" ) ) else if( cNodeName == wxT( "MAXPIN" ) )
{
MaxPinCount = GetXmlAttributeIDLong( cNode, 0 ); MaxPinCount = GetXmlAttributeIDLong( cNode, 0 );
}
else if( cNodeName == wxT( "GATEDEFINITION" ) ) else if( cNodeName == wxT( "GATEDEFINITION" ) )
{ {
GATE gate; GATE gate;
@ -1497,7 +1608,9 @@ void CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::Parse( XNODE* aNode )
SwapGroups.push_back( swapGroup ); SwapGroups.push_back( swapGroup );
} }
else else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() ); THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
}
} }
} }
@ -1540,7 +1653,9 @@ void CADSTAR_ARCHIVE_PARSER::PART::Parse( XNODE* aNode )
AttributeValues.insert( std::make_pair( attr.AttributeID, attr ) ); AttributeValues.insert( std::make_pair( attr.AttributeID, attr ) );
} }
else else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() ); THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
}
} }
} }
@ -1610,13 +1725,21 @@ bool CADSTAR_ARCHIVE_PARSER::NET::CONNECTION::ParseSubNode( XNODE* aChildNode )
wxString cNodeName = aChildNode->GetName(); wxString cNodeName = aChildNode->GetName();
if( cNodeName == wxT( "FIX" ) ) if( cNodeName == wxT( "FIX" ) )
{
Fixed = true; Fixed = true;
}
else if( cNodeName == wxT( "HIDDEN" ) ) else if( cNodeName == wxT( "HIDDEN" ) )
{
Hidden = true; Hidden = true;
}
else if( cNodeName == wxT( "GROUPREF" ) ) else if( cNodeName == wxT( "GROUPREF" ) )
{
GroupID = GetXmlAttributeIDString( aChildNode, 0 ); GroupID = GetXmlAttributeIDString( aChildNode, 0 );
}
else if( cNodeName == wxT( "REUSEBLOCKREF" ) ) else if( cNodeName == wxT( "REUSEBLOCKREF" ) )
{
ReuseBlockRef.Parse( aChildNode ); ReuseBlockRef.Parse( aChildNode );
}
else if( cNodeName == wxT( "ATTR" ) ) else if( cNodeName == wxT( "ATTR" ) )
{ {
ATTRIBUTE_VALUE attrVal; ATTRIBUTE_VALUE attrVal;
@ -1710,13 +1833,21 @@ void CADSTAR_ARCHIVE_PARSER::DOCUMENTATION_SYMBOL::Parse( XNODE* aNode )
originParsed = true; originParsed = true;
} }
else if( cNodeName == wxT( "GROUPREF" ) ) else if( cNodeName == wxT( "GROUPREF" ) )
{
GroupID = GetXmlAttributeIDString( cNode, 0 ); GroupID = GetXmlAttributeIDString( cNode, 0 );
}
else if( cNodeName == wxT( "REUSEBLOCKREF" ) ) else if( cNodeName == wxT( "REUSEBLOCKREF" ) )
{
ReuseBlockRef.Parse( cNode ); ReuseBlockRef.Parse( cNode );
}
else if( cNodeName == wxT( "FIX" ) ) else if( cNodeName == wxT( "FIX" ) )
{
Fixed = true; Fixed = true;
}
else if( cNodeName == wxT( "MIRROR" ) ) else if( cNodeName == wxT( "MIRROR" ) )
{
Mirror = true; Mirror = true;
}
else if( cNodeName == wxT( "READABILITY" ) ) else if( cNodeName == wxT( "READABILITY" ) )
{ {
Readability = ParseReadability( cNode ); Readability = ParseReadability( cNode );
@ -1815,7 +1946,6 @@ XNODE* CADSTAR_ARCHIVE_PARSER::LoadArchiveFile(
} }
else if( !cadstarFileCheckDone ) else if( !cadstarFileCheckDone )
{ {
if( cNode->GetName() != aFileTypeIdentifier ) if( cNode->GetName() != aFileTypeIdentifier )
THROW_IO_ERROR( _( "The selected file is not valid or might be corrupt!" ) ); THROW_IO_ERROR( _( "The selected file is not valid or might be corrupt!" ) );
@ -1865,10 +1995,12 @@ wxString CADSTAR_ARCHIVE_PARSER::GetXmlAttributeIDString(
attrName << aID; attrName << aID;
if( !aNode->GetAttribute( attrName, &retVal ) ) if( !aNode->GetAttribute( attrName, &retVal ) )
{
if( aIsRequired ) if( aIsRequired )
THROW_MISSING_PARAMETER_IO_ERROR( std::to_string( aID ), aNode->GetName() ); THROW_MISSING_PARAMETER_IO_ERROR( std::to_string( aID ), aNode->GetName() );
else else
return wxEmptyString; return wxEmptyString;
}
return retVal; return retVal;
} }
@ -1881,10 +2013,12 @@ long CADSTAR_ARCHIVE_PARSER::GetXmlAttributeIDLong(
bool success = GetXmlAttributeIDString( aNode, aID, aIsRequired ).ToLong( &retVal ); bool success = GetXmlAttributeIDString( aNode, aID, aIsRequired ).ToLong( &retVal );
if( !success ) if( !success )
{
if( aIsRequired ) if( aIsRequired )
THROW_PARSING_IO_ERROR( std::to_string( aID ), aNode->GetName() ); THROW_PARSING_IO_ERROR( std::to_string( aID ), aNode->GetName() );
else else
return UNDEFINED_VALUE; return UNDEFINED_VALUE;
}
return retVal; return retVal;
} }

View File

@ -87,7 +87,28 @@ void CADSTAR_SCH_ARCHIVE_LOADER::Load( ::SCHEMATIC* aSchematic, ::SCH_SHEET* aRo
loadFigures(); loadFigures();
loadTexts(); loadTexts();
loadDocumentationSymbols(); loadDocumentationSymbols();
// TODO Load other elements!
if( Schematic.VariantHierarchy.Variants.size() > 0 )
{
wxLogWarning(
_( "The CADSTAR design contains variants which has no KiCad equivalent. All "
"components have been loaded on top of each other. " ) );
}
if( Schematic.Groups.size() > 0 )
{
wxLogWarning(
_( "The CADSTAR design contains grouped items which has no KiCad equivalent. Any "
"grouped items have been ungrouped." ) );
}
if( Schematic.ReuseBlocks.size() > 0 )
{
wxLogWarning(
_( "The CADSTAR design contains re-use blocks which has no KiCad equivalent. The "
"re-use block information has been discarded during the import." ) );
}
// For all sheets, centre all elements and re calculate the page size: // For all sheets, centre all elements and re calculate the page size:
for( std::pair<LAYER_ID, SCH_SHEET*> sheetPair : mSheetMap ) for( std::pair<LAYER_ID, SCH_SHEET*> sheetPair : mSheetMap )

View File

@ -177,14 +177,13 @@ private:
PART::DEFINITION::PIN getPartDefinitionPin( PART::DEFINITION::PIN getPartDefinitionPin(
const PART& aCadstarPart, const GATE_ID& aGateID, const TERMINAL_ID& aTerminalID ); const PART& aCadstarPart, const GATE_ID& aGateID, const TERMINAL_ID& aTerminalID );
// Helper Functions for obtaining individual elements as KiCad elements: //Helper Functions for obtaining individual elements as KiCad elements:
int getKiCadUnitNumberFromGate( const GATE_ID& aCadstarGateID ); int getKiCadUnitNumberFromGate( const GATE_ID& aCadstarGateID );
LABEL_SPIN_STYLE getSpinStyle( const long long& aCadstarOrientation, bool aMirror ); LABEL_SPIN_STYLE getSpinStyle( const long long& aCadstarOrientation, bool aMirror );
LABEL_SPIN_STYLE getSpinStyleDeciDeg( const double& aOrientationDeciDeg ); LABEL_SPIN_STYLE getSpinStyleDeciDeg( const double& aOrientationDeciDeg );
// General Graphical manipulation functions //General Graphical manipulation functions
std::pair<wxPoint, wxSize> getFigureExtentsKiCad( const FIGURE& aCadstarFigure ); std::pair<wxPoint, wxSize> getFigureExtentsKiCad( const FIGURE& aCadstarFigure );
wxPoint getKiCadPoint( wxPoint aCadstarPoint ); wxPoint getKiCadPoint( wxPoint aCadstarPoint );

View File

@ -54,9 +54,13 @@ void CADSTAR_SCH_ARCHIVE_PARSER::Parse()
} }
} }
else if( cNode->GetName() == wxT( "ASSIGNMENTS" ) ) else if( cNode->GetName() == wxT( "ASSIGNMENTS" ) )
{
Assignments.Parse( cNode ); Assignments.Parse( cNode );
}
else if( cNode->GetName() == wxT( "LIBRARY" ) ) else if( cNode->GetName() == wxT( "LIBRARY" ) )
{
Library.Parse( cNode ); Library.Parse( cNode );
}
else if( cNode->GetName() == wxT( "DEFAULTS" ) ) else if( cNode->GetName() == wxT( "DEFAULTS" ) )
{ {
// No design information here (no need to parse) // No design information here (no need to parse)
@ -64,11 +68,17 @@ void CADSTAR_SCH_ARCHIVE_PARSER::Parse()
// In future some of this could be converted to KiCad but limited value // In future some of this could be converted to KiCad but limited value
} }
else if( cNode->GetName() == wxT( "PARTS" ) ) else if( cNode->GetName() == wxT( "PARTS" ) )
{
Parts.Parse( cNode ); Parts.Parse( cNode );
}
else if( cNode->GetName() == wxT( "SHEETS" ) ) else if( cNode->GetName() == wxT( "SHEETS" ) )
{
Sheets.Parse( cNode ); Sheets.Parse( cNode );
}
else if( cNode->GetName() == wxT( "SCHEMATIC" ) ) else if( cNode->GetName() == wxT( "SCHEMATIC" ) )
{
Schematic.Parse( cNode ); Schematic.Parse( cNode );
}
else if( cNode->GetName() == wxT( "DISPLAY" ) ) else if( cNode->GetName() == wxT( "DISPLAY" ) )
{ {
// No design information here (no need to parse) // No design information here (no need to parse)
@ -178,7 +188,9 @@ void CADSTAR_SCH_ARCHIVE_PARSER::TERMINAL_SHAPE::Parse( XNODE* aNode )
OrientAngle = GetXmlAttributeIDLong( aNode->GetChildren(), 0 ); OrientAngle = GetXmlAttributeIDLong( aNode->GetChildren(), 0 );
} }
else else
{
THROW_UNKNOWN_NODE_IO_ERROR( aNode->GetChildren()->GetName(), aNode->GetName() ); THROW_UNKNOWN_NODE_IO_ERROR( aNode->GetChildren()->GetName(), aNode->GetName() );
}
CheckNoNextNodes( aNode->GetChildren() ); CheckNoNextNodes( aNode->GetChildren() );
} }
@ -247,20 +259,30 @@ void CADSTAR_SCH_ARCHIVE_PARSER::ASSIGNMENTS_SCM::Parse( XNODE* aNode )
for( ; cNode; cNode = cNode->GetNext() ) for( ; cNode; cNode = cNode->GetNext() )
{ {
if( cNode->GetName() == wxT( "CODEDEFS" ) ) if( cNode->GetName() == wxT( "CODEDEFS" ) )
{
Codedefs.Parse( cNode ); Codedefs.Parse( cNode );
}
else if( cNode->GetName() == wxT( "SETTINGS" ) ) else if( cNode->GetName() == wxT( "SETTINGS" ) )
{ {
settingsParsed = true; settingsParsed = true;
Settings.Parse( cNode ); Settings.Parse( cNode );
} }
else if( cNode->GetName() == wxT( "GRIDS" ) ) else if( cNode->GetName() == wxT( "GRIDS" ) )
{
Grids.Parse( cNode ); Grids.Parse( cNode );
}
else if( cNode->GetName() == wxT( "NETCLASSEDITATTRIBSETTINGS" ) ) else if( cNode->GetName() == wxT( "NETCLASSEDITATTRIBSETTINGS" ) )
{
NetclassEditAttributeSettings = true; NetclassEditAttributeSettings = true;
}
else if( cNode->GetName() == wxT( "SPCCLASSEDITATTRIBSETTINGS" ) ) else if( cNode->GetName() == wxT( "SPCCLASSEDITATTRIBSETTINGS" ) )
{
SpacingclassEditAttributeSettings = true; SpacingclassEditAttributeSettings = true;
}
else else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), aNode->GetName() ); THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), aNode->GetName() );
}
} }
if( !settingsParsed ) if( !settingsParsed )
@ -332,7 +354,9 @@ void CADSTAR_SCH_ARCHIVE_PARSER::SYMDEF_SCM::Parse( XNODE* aNode )
wxString cNodeName = cNode->GetName(); wxString cNodeName = cNode->GetName();
if( ParseSubNode( cNode ) ) if( ParseSubNode( cNode ) )
{
continue; continue;
}
else if( cNodeName == wxT( "TERMINAL" ) ) else if( cNodeName == wxT( "TERMINAL" ) )
{ {
TERMINAL term; TERMINAL term;
@ -420,14 +444,18 @@ void CADSTAR_SCH_ARCHIVE_PARSER::COMP::Parse( XNODE* aNode )
for( ; cNode; cNode = cNode->GetNext() ) for( ; cNode; cNode = cNode->GetNext() )
{ {
if( cNode->GetName() == wxT( "READONLY" ) ) if( cNode->GetName() == wxT( "READONLY" ) )
{
ReadOnly = true; ReadOnly = true;
}
else if( cNode->GetName() == wxT( "ATTRLOC" ) ) else if( cNode->GetName() == wxT( "ATTRLOC" ) )
{ {
AttrLoc.Parse( cNode ); AttrLoc.Parse( cNode );
HasLocation = true; HasLocation = true;
} }
else else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), wxT( "ATTR" ) ); THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), wxT( "ATTR" ) );
}
} }
} }
@ -443,14 +471,18 @@ void CADSTAR_SCH_ARCHIVE_PARSER::PARTREF::Parse( XNODE* aNode )
for( ; cNode; cNode = cNode->GetNext() ) for( ; cNode; cNode = cNode->GetNext() )
{ {
if( cNode->GetName() == wxT( "READONLY" ) ) if( cNode->GetName() == wxT( "READONLY" ) )
{
ReadOnly = true; ReadOnly = true;
}
else if( cNode->GetName() == wxT( "ATTRLOC" ) ) else if( cNode->GetName() == wxT( "ATTRLOC" ) )
{ {
AttrLoc.Parse( cNode ); AttrLoc.Parse( cNode );
HasLocation = true; HasLocation = true;
} }
else else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), wxT( "ATTR" ) ); THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), wxT( "ATTR" ) );
}
} }
} }
@ -472,7 +504,9 @@ void CADSTAR_SCH_ARCHIVE_PARSER::SYMPINNAME_LABEL::Parse( XNODE* aNode )
HasLocation = true; HasLocation = true;
} }
else else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), wxT( "ATTR" ) ); THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), wxT( "ATTR" ) );
}
} }
} }
@ -494,7 +528,9 @@ void CADSTAR_SCH_ARCHIVE_PARSER::SYMBOL::PIN_NUM::Parse( XNODE* aNode )
HasLocation = true; HasLocation = true;
} }
else else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), wxT( "ATTR" ) ); THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), wxT( "ATTR" ) );
}
} }
} }
@ -520,7 +556,9 @@ void CADSTAR_SCH_ARCHIVE_PARSER::SYMBOLVARIANT::Parse( XNODE* aNode )
Reference = GetXmlAttributeIDString( cNode, 0 ); Reference = GetXmlAttributeIDString( cNode, 0 );
} }
else else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() ); THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
}
} }
} }
@ -582,32 +620,46 @@ void CADSTAR_SCH_ARCHIVE_PARSER::SYMBOL::Parse( XNODE* aNode )
HasPartRef = true; HasPartRef = true;
} }
else if( cNodeName == wxT( "PARTNAMENOTVISIBLE" ) ) else if( cNodeName == wxT( "PARTNAMENOTVISIBLE" ) )
{
PartNameVisible = false; PartNameVisible = false;
}
else if( cNodeName == wxT( "VSYMMASTER" ) ) else if( cNodeName == wxT( "VSYMMASTER" ) )
{ {
VariantParentSymbolID = GetXmlAttributeIDString( aNode, 0 ); VariantParentSymbolID = GetXmlAttributeIDString( aNode, 0 );
VariantID = GetXmlAttributeIDString( aNode, 1 ); VariantID = GetXmlAttributeIDString( aNode, 1 );
} }
else if( cNodeName == wxT( "GROUPREF" ) ) else if( cNodeName == wxT( "GROUPREF" ) )
{
GroupID = GetXmlAttributeIDString( cNode, 0 ); GroupID = GetXmlAttributeIDString( cNode, 0 );
}
else if( cNodeName == wxT( "REUSEBLOCKREF" ) ) else if( cNodeName == wxT( "REUSEBLOCKREF" ) )
{
ReuseBlockRef.Parse( cNode ); ReuseBlockRef.Parse( cNode );
}
else if( cNodeName == wxT( "SIGNALREFERENCELINK" ) ) else if( cNodeName == wxT( "SIGNALREFERENCELINK" ) )
{
SigRefLink.Parse( cNode ); SigRefLink.Parse( cNode );
}
else if( cNodeName == wxT( "ORIENT" ) ) else if( cNodeName == wxT( "ORIENT" ) )
{ {
OrientAngle = GetXmlAttributeIDLong( cNode, 0 ); OrientAngle = GetXmlAttributeIDLong( cNode, 0 );
} }
else if( cNodeName == wxT( "MIRROR" ) ) else if( cNodeName == wxT( "MIRROR" ) )
{
Mirror = true; Mirror = true;
}
else if( cNodeName == wxT( "FIX" ) ) else if( cNodeName == wxT( "FIX" ) )
{
Fixed = true; Fixed = true;
}
else if( cNodeName == wxT( "READABILITY" ) ) else if( cNodeName == wxT( "READABILITY" ) )
{ {
Readability = ParseReadability( cNode ); Readability = ParseReadability( cNode );
} }
else if( cNodeName == wxT( "GATE" ) ) else if( cNodeName == wxT( "GATE" ) )
{
GateID = GetXmlAttributeIDString( cNode, 0 ); GateID = GetXmlAttributeIDString( cNode, 0 );
}
else if( cNodeName == wxT( "SYMBOLVARIANT" ) ) else if( cNodeName == wxT( "SYMBOLVARIANT" ) )
{ {
IsSymbolVariant = true; IsSymbolVariant = true;
@ -702,11 +754,15 @@ void CADSTAR_SCH_ARCHIVE_PARSER::BUS::Parse( XNODE* aNode )
HasBusLabel = true; HasBusLabel = true;
} }
else else
{
THROW_UNKNOWN_NODE_IO_ERROR( subNode->GetName(), cNode->GetName() ); THROW_UNKNOWN_NODE_IO_ERROR( subNode->GetName(), cNode->GetName() );
}
} }
} }
else else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() ); THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
}
} }
} }
@ -724,9 +780,10 @@ void CADSTAR_SCH_ARCHIVE_PARSER::BLOCK::Parse( XNODE* aNode )
{ {
wxString cNodeName = cNode->GetName(); wxString cNodeName = cNode->GetName();
if( cNodeName == wxT( "CLONE" ) ) if( cNodeName == wxT( "CLONE" ) )
{
Type = TYPE::CLONE; Type = TYPE::CLONE;
}
else if( cNodeName == wxT( "PARENT" ) ) else if( cNodeName == wxT( "PARENT" ) )
{ {
Type = TYPE::PARENT; Type = TYPE::PARENT;
@ -750,7 +807,9 @@ void CADSTAR_SCH_ARCHIVE_PARSER::BLOCK::Parse( XNODE* aNode )
HasBlockLabel = true; HasBlockLabel = true;
} }
else else
{
THROW_UNKNOWN_NODE_IO_ERROR( subNode->GetName(), cNode->GetName() ); THROW_UNKNOWN_NODE_IO_ERROR( subNode->GetName(), cNode->GetName() );
}
} }
} }
else if( cNodeName == wxT( "TERMINAL" ) ) else if( cNodeName == wxT( "TERMINAL" ) )
@ -766,7 +825,9 @@ void CADSTAR_SCH_ARCHIVE_PARSER::BLOCK::Parse( XNODE* aNode )
Figures.insert( std::make_pair( figure.ID, figure ) ); Figures.insert( std::make_pair( figure.ID, figure ) );
} }
else else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() ); THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
}
} }
} }
@ -792,7 +853,9 @@ void CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::SYM_TERM::Parse( XNODE* aNode )
HasNetLabel = true; HasNetLabel = true;
} }
else else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() ); THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
}
} }
} }
@ -836,7 +899,9 @@ void CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::BUS_TERM::Parse( XNODE* aNode )
} }
} }
else else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() ); THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
}
} }
if( !firstPointParsed || !secondPointParsed ) if( !firstPointParsed || !secondPointParsed )
@ -864,7 +929,9 @@ void CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::BLOCK_TERM::Parse( XNODE* aNode )
HasNetLabel = true; HasNetLabel = true;
} }
else else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() ); THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
}
} }
} }
@ -881,19 +948,29 @@ void CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::CONNECTION_SCH::Parse( XNODE* aNode )
wxString cNodeName = cNode->GetName(); wxString cNodeName = cNode->GetName();
if( ParseSubNode( cNode ) ) if( ParseSubNode( cNode ) )
{
continue; continue;
}
else if( cNodeName == wxT( "PATH" ) ) else if( cNodeName == wxT( "PATH" ) )
{ {
Path = ParseAllChildPoints( cNode, true ); Path = ParseAllChildPoints( cNode, true );
} }
else if( cNodeName == wxT( "GROUPREF" ) ) else if( cNodeName == wxT( "GROUPREF" ) )
{
GroupID = GetXmlAttributeIDString( cNode, 0 ); GroupID = GetXmlAttributeIDString( cNode, 0 );
}
else if( cNodeName == wxT( "REUSEBLOCKREF" ) ) else if( cNodeName == wxT( "REUSEBLOCKREF" ) )
{
ReuseBlockRef.Parse( cNode ); ReuseBlockRef.Parse( cNode );
}
else if( cNodeName == wxT( "CONLINECODE" ) ) else if( cNodeName == wxT( "CONLINECODE" ) )
{
ConnectionLineCode = GetXmlAttributeIDString( cNode, 0 ); ConnectionLineCode = GetXmlAttributeIDString( cNode, 0 );
}
else else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, wxT( "CONN" ) ); THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, wxT( "CONN" ) );
}
} }
} }

View File

@ -54,6 +54,7 @@ public:
typedef wxString BLOCK_ID; typedef wxString BLOCK_ID;
typedef wxString SHEET_NAME; typedef wxString SHEET_NAME;
enum class TERMINAL_SHAPE_TYPE enum class TERMINAL_SHAPE_TYPE
{ {
ANNULUS, ANNULUS,
@ -74,6 +75,7 @@ public:
UNDEFINED ///< Only used for error checking (not a real shape) UNDEFINED ///< Only used for error checking (not a real shape)
}; };
static TERMINAL_SHAPE_TYPE ParseTermShapeType( const wxString& aShapeStr ); static TERMINAL_SHAPE_TYPE ParseTermShapeType( const wxString& aShapeStr );

View File

@ -55,6 +55,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::Load( ::BOARD* aBoard )
long long maxDesignSizekicad = std::numeric_limits<int>::max(); long long maxDesignSizekicad = std::numeric_limits<int>::max();
if( designSizeXkicad > maxDesignSizekicad || designSizeYkicad > maxDesignSizekicad ) if( designSizeXkicad > maxDesignSizekicad || designSizeYkicad > maxDesignSizekicad )
{
THROW_IO_ERROR( wxString::Format( THROW_IO_ERROR( wxString::Format(
_( "The design is too large and cannot be imported into KiCad. \n" _( "The design is too large and cannot be imported into KiCad. \n"
"Please reduce the maximum design size in CADSTAR by navigating to: \n" "Please reduce the maximum design size in CADSTAR by navigating to: \n"
@ -65,17 +66,20 @@ void CADSTAR_PCB_ARCHIVE_LOADER::Load( ::BOARD* aBoard )
(double) designSizeYkicad / PCB_IU_PER_MM, (double) designSizeYkicad / PCB_IU_PER_MM,
(double) maxDesignSizekicad / PCB_IU_PER_MM, (double) maxDesignSizekicad / PCB_IU_PER_MM,
(double) maxDesignSizekicad / PCB_IU_PER_MM ) ); (double) maxDesignSizekicad / PCB_IU_PER_MM ) );
}
mDesignCenter = mDesignCenter =
( Assignments.Technology.DesignArea.first + Assignments.Technology.DesignArea.second ) ( Assignments.Technology.DesignArea.first + Assignments.Technology.DesignArea.second )
/ 2; / 2;
if( Layout.NetSynch == NETSYNCH::WARNING ) if( Layout.NetSynch == NETSYNCH::WARNING )
{
wxLogWarning( wxLogWarning(
_( "The selected file indicates that nets might be out of synchronisation " _( "The selected file indicates that nets might be out of synchronisation "
"with the schematic. It is recommended that you carry out an 'Align Nets' " "with the schematic. It is recommended that you carry out an 'Align Nets' "
"procedure in CADSTAR and re-import, to avoid inconsistencies between the " "procedure in CADSTAR and re-import, to avoid inconsistencies between the "
"PCB and the schematic. " ) ); "PCB and the schematic. " ) );
}
loadBoardStackup(); loadBoardStackup();
loadDesignRules(); loadDesignRules();
@ -93,9 +97,18 @@ void CADSTAR_PCB_ARCHIVE_LOADER::Load( ::BOARD* aBoard )
loadNets(); loadNets();
if( Layout.VariantHierarchy.Variants.size() > 0 ) if( Layout.VariantHierarchy.Variants.size() > 0 )
{
wxLogWarning( wxLogWarning(
_( "The CADSTAR design contains variants which has no KiCad equivalent. All " _( "The CADSTAR design contains variants which has no KiCad equivalent. All "
"components have been loaded on top of each other. " ) ); "components have been loaded on top of each other. " ) );
}
if( Layout.ReuseBlocks.size() > 0 )
{
wxLogWarning(
_( "The CADSTAR design contains re-use blocks which has no KiCad equivalent. The "
"re-use block information has been discarded during the import." ) );
}
wxLogMessage( wxLogMessage(
_( "The CADSTAR design has been imported successfully.\n" _( "The CADSTAR design has been imported successfully.\n"
@ -405,14 +418,12 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadDesignRules()
BOARD_DESIGN_SETTINGS& ds = mBoard->GetDesignSettings(); BOARD_DESIGN_SETTINGS& ds = mBoard->GetDesignSettings();
std::map<SPACINGCODE_ID, SPACINGCODE>& spacingCodes = Assignments.Codedefs.SpacingCodes; std::map<SPACINGCODE_ID, SPACINGCODE>& spacingCodes = Assignments.Codedefs.SpacingCodes;
auto applyRule = auto applyRule = [&]( wxString aID, int* aVal ) {
[&]( wxString aID, int* aVal ) if( spacingCodes.find( aID ) == spacingCodes.end() )
{ wxLogWarning( _( "Design rule %s was not found. This was ignored." ) );
if( spacingCodes.find( aID ) == spacingCodes.end() ) else
wxLogWarning( _( "Design rule %s was not found. This was ignored." ) ); *aVal = getKiCadLength( spacingCodes.at( aID ).Spacing );
else };
*aVal = getKiCadLength( spacingCodes.at( aID ).Spacing );
};
//Note: for details on the different spacing codes see SPACINGCODE::ID //Note: for details on the different spacing codes see SPACINGCODE::ID
@ -422,16 +433,14 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadDesignRules()
ds.m_TrackMinWidth = Assignments.Technology.MinRouteWidth; ds.m_TrackMinWidth = Assignments.Technology.MinRouteWidth;
auto applyNetClassRule = auto applyNetClassRule = [&]( wxString aID, ::NETCLASS* aNetClassPtr,
[&]( wxString aID, ::NETCLASS* aNetClassPtr, void (::NETCLASS::*aFunc)(int) ) void ( ::NETCLASS::*aFunc )( int ) ) {
{ int value = -1;
int value = -1; applyRule( aID, &value );
applyRule(aID, &value);
if( value != -1 ) if( value != -1 )
(aNetClassPtr->*aFunc)(value); ( aNetClassPtr->*aFunc )( value );
};
};
applyNetClassRule( "T_T", ds.GetDefault(), &::NETCLASS::SetClearance ); applyNetClassRule( "T_T", ds.GetDefault(), &::NETCLASS::SetClearance );
@ -519,7 +528,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryAreas( const SYMDEF_PCB& aComponent,
else else
zone->SetLayer( getKiCadLayer( area.LayerID ) ); zone->SetLayer( getKiCadLayer( area.LayerID ) );
zone->SetIsRuleArea( true ); //import all CADSTAR areas as Keepout zones zone->SetIsRuleArea( true ); //import all CADSTAR areas as Keepout zones
zone->SetDoNotAllowPads( false ); //no CADSTAR equivalent zone->SetDoNotAllowPads( false ); //no CADSTAR equivalent
zone->SetZoneName( area.ID ); zone->SetZoneName( area.ID );
@ -878,7 +887,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadAreas()
else else
zone->SetLayer( getKiCadLayer( area.LayerID ) ); zone->SetLayer( getKiCadLayer( area.LayerID ) );
zone->SetIsRuleArea( true ); //import all CADSTAR areas as Keepout zones zone->SetIsRuleArea( true ); //import all CADSTAR areas as Keepout zones
zone->SetDoNotAllowPads( false ); //no CADSTAR equivalent zone->SetDoNotAllowPads( false ); //no CADSTAR equivalent
zone->SetZoneName( area.Name ); zone->SetZoneName( area.Name );

View File

@ -54,14 +54,20 @@ void CADSTAR_PCB_ARCHIVE_PARSER::Parse()
} }
if( Header.Format.Type != wxT( "LAYOUT" ) ) if( Header.Format.Type != wxT( "LAYOUT" ) )
{
if( Header.Format.Type == wxT( "LIBRARY" ) ) if( Header.Format.Type == wxT( "LIBRARY" ) )
{
THROW_IO_ERROR( THROW_IO_ERROR(
"The selected file is a CADSTAR Library file (as opposed to a Layout " "The selected file is a CADSTAR Library file (as opposed to a Layout "
"file). CADSTAR libraries cannot yet be imported into KiCad." ); "file). CADSTAR libraries cannot yet be imported into KiCad." );
}
else else
{
THROW_IO_ERROR( THROW_IO_ERROR(
"The selected file is an unknown CADSTAR format so cannot be " "The selected file is an unknown CADSTAR format so cannot be "
"imported into KiCad." ); "imported into KiCad." );
}
}
} }
else if( cNode->GetName() == wxT( "ASSIGNMENTS" ) ) else if( cNode->GetName() == wxT( "ASSIGNMENTS" ) )
{ {
@ -313,8 +319,10 @@ void CADSTAR_PCB_ARCHIVE_PARSER::MATERIAL::Parse( XNODE* aNode )
XNODE* iNode = aNode->GetChildren(); XNODE* iNode = aNode->GetChildren();
if( !iNode ) if( !iNode )
{
THROW_MISSING_PARAMETER_IO_ERROR( THROW_MISSING_PARAMETER_IO_ERROR(
wxT( "RESISTIVITY" ), wxString::Format( "MATERIAL %s", Name ) ); wxT( "RESISTIVITY" ), wxString::Format( "MATERIAL %s", Name ) );
}
for( ; iNode; iNode = iNode->GetNext() ) for( ; iNode; iNode = iNode->GetNext() )
{ {
@ -1388,13 +1396,13 @@ void CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::Parse( XNODE* aNode )
LayerID = GetXmlAttributeIDString( aNode, 1 ); LayerID = GetXmlAttributeIDString( aNode, 1 );
wxString subTypeStr = GetXmlAttributeIDString( aNode, 2 ); wxString subTypeStr = GetXmlAttributeIDString( aNode, 2 );
std::map<wxString, SUBTYPE> subTypeMap = { { wxT( "DIMENSION_ORTHOGONAL" ), std::map<wxString, SUBTYPE> subTypeMap = {
SUBTYPE::ORTHOGONAL }, { wxT( "DIMENSION_ORTHOGONAL" ), SUBTYPE::ORTHOGONAL },
{ wxT( "DIMENSION_DIRECT" ), SUBTYPE::DIRECT }, { wxT( "DIMENSION_DIRECT" ), SUBTYPE::DIRECT },
{ wxT( "DIMENSION_ANGLED" ), SUBTYPE::ANGLED }, { wxT( "DIMENSION_ANGLED" ), SUBTYPE::ANGLED },
{ wxT( "DIMENSION_DIAMETER" ), SUBTYPE::DIAMETER }, { wxT( "DIMENSION_DIAMETER" ), SUBTYPE::DIAMETER },
{ wxT( "DIMENSION_RADIUS" ), SUBTYPE::RADIUS }, { wxT( "DIMENSION_RADIUS" ), SUBTYPE::RADIUS },
{ wxT( "DIMENSION_ANGULAR" ), SUBTYPE::ANGULAR } }; { wxT( "DIMENSION_ANGULAR" ), SUBTYPE::ANGULAR } };
if( subTypeMap.find( subTypeStr ) == subTypeMap.end() ) if( subTypeMap.find( subTypeStr ) == subTypeMap.end() )
THROW_UNKNOWN_PARAMETER_IO_ERROR( subTypeStr, aNode->GetName() ); THROW_UNKNOWN_PARAMETER_IO_ERROR( subTypeStr, aNode->GetName() );
@ -1500,7 +1508,9 @@ void CADSTAR_PCB_ARCHIVE_PARSER::SYMDEF_PCB::Parse( XNODE* aNode )
wxString cNodeName = cNode->GetName(); wxString cNodeName = cNode->GetName();
if( ParseSubNode( cNode ) ) if( ParseSubNode( cNode ) )
{
continue; continue;
}
else if( cNodeName == wxT( "SYMHEIGHT" ) ) else if( cNodeName == wxT( "SYMHEIGHT" ) )
{ {
SymHeight = GetXmlAttributeIDLong( cNode, 0 ); SymHeight = GetXmlAttributeIDLong( cNode, 0 );
@ -1724,7 +1734,9 @@ void CADSTAR_PCB_ARCHIVE_PARSER::PIN_ATTRIBUTE::Parse( XNODE* aNode )
AttributeValues.insert( std::make_pair( attrVal.AttributeID, attrVal ) ); AttributeValues.insert( std::make_pair( attrVal.AttributeID, attrVal ) );
} }
else if( cNodeName == wxT( "TESTLAND" ) ) else if( cNodeName == wxT( "TESTLAND" ) )
{
TestlandSide = ParseTestlandSide( cNode ); TestlandSide = ParseTestlandSide( cNode );
}
else else
{ {
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() ); THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
@ -2001,7 +2013,9 @@ void CADSTAR_PCB_ARCHIVE_PARSER::NET_PCB::CONNECTION_PCB::Parse( XNODE* aNode )
wxString cNodeName = cNode->GetName(); wxString cNodeName = cNode->GetName();
if( ParseSubNode( cNode ) ) if( ParseSubNode( cNode ) )
{
continue; continue;
}
else if( !Unrouted && !routeParsed && cNodeName == wxT( "ROUTE" ) ) else if( !Unrouted && !routeParsed && cNodeName == wxT( "ROUTE" ) )
{ {
Route.Parse( cNode ); Route.Parse( cNode );