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

View File

@ -87,7 +87,28 @@ void CADSTAR_SCH_ARCHIVE_LOADER::Load( ::SCHEMATIC* aSchematic, ::SCH_SHEET* aRo
loadFigures();
loadTexts();
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( std::pair<LAYER_ID, SCH_SHEET*> sheetPair : mSheetMap )

View File

@ -184,7 +184,6 @@ private:
//General Graphical manipulation functions
std::pair<wxPoint, wxSize> getFigureExtentsKiCad( const FIGURE& aCadstarFigure );
wxPoint getKiCadPoint( wxPoint aCadstarPoint );

View File

@ -54,9 +54,13 @@ void CADSTAR_SCH_ARCHIVE_PARSER::Parse()
}
}
else if( cNode->GetName() == wxT( "ASSIGNMENTS" ) )
{
Assignments.Parse( cNode );
}
else if( cNode->GetName() == wxT( "LIBRARY" ) )
{
Library.Parse( cNode );
}
else if( cNode->GetName() == wxT( "DEFAULTS" ) )
{
// 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
}
else if( cNode->GetName() == wxT( "PARTS" ) )
{
Parts.Parse( cNode );
}
else if( cNode->GetName() == wxT( "SHEETS" ) )
{
Sheets.Parse( cNode );
}
else if( cNode->GetName() == wxT( "SCHEMATIC" ) )
{
Schematic.Parse( cNode );
}
else if( cNode->GetName() == wxT( "DISPLAY" ) )
{
// 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 );
}
else
{
THROW_UNKNOWN_NODE_IO_ERROR( aNode->GetChildren()->GetName(), aNode->GetName() );
}
CheckNoNextNodes( aNode->GetChildren() );
}
@ -247,21 +259,31 @@ void CADSTAR_SCH_ARCHIVE_PARSER::ASSIGNMENTS_SCM::Parse( XNODE* aNode )
for( ; cNode; cNode = cNode->GetNext() )
{
if( cNode->GetName() == wxT( "CODEDEFS" ) )
{
Codedefs.Parse( cNode );
}
else if( cNode->GetName() == wxT( "SETTINGS" ) )
{
settingsParsed = true;
Settings.Parse( cNode );
}
else if( cNode->GetName() == wxT( "GRIDS" ) )
{
Grids.Parse( cNode );
}
else if( cNode->GetName() == wxT( "NETCLASSEDITATTRIBSETTINGS" ) )
{
NetclassEditAttributeSettings = true;
}
else if( cNode->GetName() == wxT( "SPCCLASSEDITATTRIBSETTINGS" ) )
{
SpacingclassEditAttributeSettings = true;
}
else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), aNode->GetName() );
}
}
if( !settingsParsed )
THROW_MISSING_NODE_IO_ERROR( wxT( "SETTINGS" ), wxT( "ASSIGNMENTS" ) );
@ -332,7 +354,9 @@ void CADSTAR_SCH_ARCHIVE_PARSER::SYMDEF_SCM::Parse( XNODE* aNode )
wxString cNodeName = cNode->GetName();
if( ParseSubNode( cNode ) )
{
continue;
}
else if( cNodeName == wxT( "TERMINAL" ) )
{
TERMINAL term;
@ -420,16 +444,20 @@ void CADSTAR_SCH_ARCHIVE_PARSER::COMP::Parse( XNODE* aNode )
for( ; cNode; cNode = cNode->GetNext() )
{
if( cNode->GetName() == wxT( "READONLY" ) )
{
ReadOnly = true;
}
else if( cNode->GetName() == wxT( "ATTRLOC" ) )
{
AttrLoc.Parse( cNode );
HasLocation = true;
}
else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), wxT( "ATTR" ) );
}
}
}
void CADSTAR_SCH_ARCHIVE_PARSER::PARTREF::Parse( XNODE* aNode )
@ -443,16 +471,20 @@ void CADSTAR_SCH_ARCHIVE_PARSER::PARTREF::Parse( XNODE* aNode )
for( ; cNode; cNode = cNode->GetNext() )
{
if( cNode->GetName() == wxT( "READONLY" ) )
{
ReadOnly = true;
}
else if( cNode->GetName() == wxT( "ATTRLOC" ) )
{
AttrLoc.Parse( cNode );
HasLocation = true;
}
else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), wxT( "ATTR" ) );
}
}
}
void CADSTAR_SCH_ARCHIVE_PARSER::SYMPINNAME_LABEL::Parse( XNODE* aNode )
@ -472,9 +504,11 @@ void CADSTAR_SCH_ARCHIVE_PARSER::SYMPINNAME_LABEL::Parse( XNODE* aNode )
HasLocation = true;
}
else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), wxT( "ATTR" ) );
}
}
}
void CADSTAR_SCH_ARCHIVE_PARSER::SYMBOL::PIN_NUM::Parse( XNODE* aNode )
@ -494,9 +528,11 @@ void CADSTAR_SCH_ARCHIVE_PARSER::SYMBOL::PIN_NUM::Parse( XNODE* aNode )
HasLocation = true;
}
else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNode->GetName(), wxT( "ATTR" ) );
}
}
}
void CADSTAR_SCH_ARCHIVE_PARSER::SYMBOLVARIANT::Parse( XNODE* aNode )
@ -520,9 +556,11 @@ void CADSTAR_SCH_ARCHIVE_PARSER::SYMBOLVARIANT::Parse( XNODE* aNode )
Reference = GetXmlAttributeIDString( cNode, 0 );
}
else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
}
}
}
void CADSTAR_SCH_ARCHIVE_PARSER::SIGNALREFERENCELINK::Parse( XNODE* aNode )
@ -582,32 +620,46 @@ void CADSTAR_SCH_ARCHIVE_PARSER::SYMBOL::Parse( XNODE* aNode )
HasPartRef = true;
}
else if( cNodeName == wxT( "PARTNAMENOTVISIBLE" ) )
{
PartNameVisible = false;
}
else if( cNodeName == wxT( "VSYMMASTER" ) )
{
VariantParentSymbolID = GetXmlAttributeIDString( aNode, 0 );
VariantID = GetXmlAttributeIDString( aNode, 1 );
}
else if( cNodeName == wxT( "GROUPREF" ) )
{
GroupID = GetXmlAttributeIDString( cNode, 0 );
}
else if( cNodeName == wxT( "REUSEBLOCKREF" ) )
{
ReuseBlockRef.Parse( cNode );
}
else if( cNodeName == wxT( "SIGNALREFERENCELINK" ) )
{
SigRefLink.Parse( cNode );
}
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( "READABILITY" ) )
{
Readability = ParseReadability( cNode );
}
else if( cNodeName == wxT( "GATE" ) )
{
GateID = GetXmlAttributeIDString( cNode, 0 );
}
else if( cNodeName == wxT( "SYMBOLVARIANT" ) )
{
IsSymbolVariant = true;
@ -702,13 +754,17 @@ void CADSTAR_SCH_ARCHIVE_PARSER::BUS::Parse( XNODE* aNode )
HasBusLabel = true;
}
else
{
THROW_UNKNOWN_NODE_IO_ERROR( subNode->GetName(), cNode->GetName() );
}
}
}
else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
}
}
}
void CADSTAR_SCH_ARCHIVE_PARSER::BLOCK::Parse( XNODE* aNode )
@ -724,9 +780,10 @@ void CADSTAR_SCH_ARCHIVE_PARSER::BLOCK::Parse( XNODE* aNode )
{
wxString cNodeName = cNode->GetName();
if( cNodeName == wxT( "CLONE" ) )
{
Type = TYPE::CLONE;
}
else if( cNodeName == wxT( "PARENT" ) )
{
Type = TYPE::PARENT;
@ -750,9 +807,11 @@ void CADSTAR_SCH_ARCHIVE_PARSER::BLOCK::Parse( XNODE* aNode )
HasBlockLabel = true;
}
else
{
THROW_UNKNOWN_NODE_IO_ERROR( subNode->GetName(), cNode->GetName() );
}
}
}
else if( cNodeName == wxT( "TERMINAL" ) )
{
TERMINAL term;
@ -766,9 +825,11 @@ void CADSTAR_SCH_ARCHIVE_PARSER::BLOCK::Parse( XNODE* aNode )
Figures.insert( std::make_pair( figure.ID, figure ) );
}
else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
}
}
}
void CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::SYM_TERM::Parse( XNODE* aNode )
@ -792,9 +853,11 @@ void CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::SYM_TERM::Parse( XNODE* aNode )
HasNetLabel = true;
}
else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
}
}
}
void CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::BUS_TERM::Parse( XNODE* aNode )
@ -836,8 +899,10 @@ void CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::BUS_TERM::Parse( XNODE* aNode )
}
}
else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
}
}
if( !firstPointParsed || !secondPointParsed )
THROW_MISSING_NODE_IO_ERROR( wxT( "PT" ), aNode->GetName() );
@ -864,9 +929,11 @@ void CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::BLOCK_TERM::Parse( XNODE* aNode )
HasNetLabel = true;
}
else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
}
}
}
void CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::CONNECTION_SCH::Parse( XNODE* aNode )
@ -881,21 +948,31 @@ void CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::CONNECTION_SCH::Parse( XNODE* aNode )
wxString cNodeName = cNode->GetName();
if( ParseSubNode( cNode ) )
{
continue;
}
else if( cNodeName == wxT( "PATH" ) )
{
Path = ParseAllChildPoints( cNode, true );
}
else if( cNodeName == wxT( "GROUPREF" ) )
{
GroupID = GetXmlAttributeIDString( cNode, 0 );
}
else if( cNodeName == wxT( "REUSEBLOCKREF" ) )
{
ReuseBlockRef.Parse( cNode );
}
else if( cNodeName == wxT( "CONLINECODE" ) )
{
ConnectionLineCode = GetXmlAttributeIDString( cNode, 0 );
}
else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, wxT( "CONN" ) );
}
}
}
void CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::Parse( XNODE* aNode )

View File

@ -54,6 +54,7 @@ public:
typedef wxString BLOCK_ID;
typedef wxString SHEET_NAME;
enum class TERMINAL_SHAPE_TYPE
{
ANNULUS,
@ -74,6 +75,7 @@ public:
UNDEFINED ///< Only used for error checking (not a real shape)
};
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();
if( designSizeXkicad > maxDesignSizekicad || designSizeYkicad > maxDesignSizekicad )
{
THROW_IO_ERROR( wxString::Format(
_( "The design is too large and cannot be imported into KiCad. \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) maxDesignSizekicad / PCB_IU_PER_MM,
(double) maxDesignSizekicad / PCB_IU_PER_MM ) );
}
mDesignCenter =
( Assignments.Technology.DesignArea.first + Assignments.Technology.DesignArea.second )
/ 2;
if( Layout.NetSynch == NETSYNCH::WARNING )
{
wxLogWarning(
_( "The selected file indicates that nets might be out of synchronisation "
"with the schematic. It is recommended that you carry out an 'Align Nets' "
"procedure in CADSTAR and re-import, to avoid inconsistencies between the "
"PCB and the schematic. " ) );
}
loadBoardStackup();
loadDesignRules();
@ -93,9 +97,18 @@ void CADSTAR_PCB_ARCHIVE_LOADER::Load( ::BOARD* aBoard )
loadNets();
if( Layout.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( 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(
_( "The CADSTAR design has been imported successfully.\n"
@ -405,9 +418,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadDesignRules()
BOARD_DESIGN_SETTINGS& ds = mBoard->GetDesignSettings();
std::map<SPACINGCODE_ID, SPACINGCODE>& spacingCodes = Assignments.Codedefs.SpacingCodes;
auto applyRule =
[&]( wxString aID, int* aVal )
{
auto applyRule = [&]( wxString aID, int* aVal ) {
if( spacingCodes.find( aID ) == spacingCodes.end() )
wxLogWarning( _( "Design rule %s was not found. This was ignored." ) );
else
@ -422,15 +433,13 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadDesignRules()
ds.m_TrackMinWidth = Assignments.Technology.MinRouteWidth;
auto applyNetClassRule =
[&]( wxString aID, ::NETCLASS* aNetClassPtr, void (::NETCLASS::*aFunc)(int) )
{
auto applyNetClassRule = [&]( wxString aID, ::NETCLASS* aNetClassPtr,
void ( ::NETCLASS::*aFunc )( int ) ) {
int value = -1;
applyRule( aID, &value );
if( value != -1 )
( aNetClassPtr->*aFunc )( value );
};
applyNetClassRule( "T_T", ds.GetDefault(), &::NETCLASS::SetClearance );

View File

@ -54,15 +54,21 @@ void CADSTAR_PCB_ARCHIVE_PARSER::Parse()
}
if( Header.Format.Type != wxT( "LAYOUT" ) )
{
if( Header.Format.Type == wxT( "LIBRARY" ) )
{
THROW_IO_ERROR(
"The selected file is a CADSTAR Library file (as opposed to a Layout "
"file). CADSTAR libraries cannot yet be imported into KiCad." );
}
else
{
THROW_IO_ERROR(
"The selected file is an unknown CADSTAR format so cannot be "
"imported into KiCad." );
}
}
}
else if( cNode->GetName() == wxT( "ASSIGNMENTS" ) )
{
Assignments.Parse( cNode );
@ -313,8 +319,10 @@ void CADSTAR_PCB_ARCHIVE_PARSER::MATERIAL::Parse( XNODE* aNode )
XNODE* iNode = aNode->GetChildren();
if( !iNode )
{
THROW_MISSING_PARAMETER_IO_ERROR(
wxT( "RESISTIVITY" ), wxString::Format( "MATERIAL %s", Name ) );
}
for( ; iNode; iNode = iNode->GetNext() )
{
@ -1388,8 +1396,8 @@ void CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::Parse( XNODE* aNode )
LayerID = GetXmlAttributeIDString( aNode, 1 );
wxString subTypeStr = GetXmlAttributeIDString( aNode, 2 );
std::map<wxString, SUBTYPE> subTypeMap = { { wxT( "DIMENSION_ORTHOGONAL" ),
SUBTYPE::ORTHOGONAL },
std::map<wxString, SUBTYPE> subTypeMap = {
{ wxT( "DIMENSION_ORTHOGONAL" ), SUBTYPE::ORTHOGONAL },
{ wxT( "DIMENSION_DIRECT" ), SUBTYPE::DIRECT },
{ wxT( "DIMENSION_ANGLED" ), SUBTYPE::ANGLED },
{ wxT( "DIMENSION_DIAMETER" ), SUBTYPE::DIAMETER },
@ -1500,7 +1508,9 @@ void CADSTAR_PCB_ARCHIVE_PARSER::SYMDEF_PCB::Parse( XNODE* aNode )
wxString cNodeName = cNode->GetName();
if( ParseSubNode( cNode ) )
{
continue;
}
else if( cNodeName == wxT( "SYMHEIGHT" ) )
{
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 ) );
}
else if( cNodeName == wxT( "TESTLAND" ) )
{
TestlandSide = ParseTestlandSide( cNode );
}
else
{
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();
if( ParseSubNode( cNode ) )
{
continue;
}
else if( !Unrouted && !routeParsed && cNodeName == wxT( "ROUTE" ) )
{
Route.Parse( cNode );