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 );
}
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
// 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"
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" ) );
}
}
}
@ -153,18 +167,30 @@ 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 ) );
}
}
@ -395,9 +421,13 @@ 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;
}
}
@ -436,9 +466,12 @@ 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 )
{
wxASSERT( aNode->GetName() == wxT( "UNITS" ) );
@ -528,20 +561,28 @@ 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 ) )
{
@ -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,9 +897,13 @@ 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 );
}
}
}
@ -862,14 +920,18 @@ 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" ) );
}
}
}
@ -932,24 +994,38 @@ 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() )
@ -978,7 +1054,9 @@ void CADSTAR_ARCHIVE_PARSER::NETCLASS::Parse( XNODE* aNode )
Attributes.push_back( attribute_val );
}
else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, location );
}
}
}
@ -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,7 +1259,9 @@ void CADSTAR_ARCHIVE_PARSER::FIGURE::Parse( XNODE* aNode )
AttributeValues.insert( std::make_pair( attr.AttributeID, attr ) );
}
else
{
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();
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() );
}
}
}
@ -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,7 +1550,9 @@ void CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::SWAP_GROUP::Parse( XNODE* aNode )
SwapGates.push_back( swapGate );
}
else
{
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();
if( cNodeName == wxT( "HIDEPINNAMES" ) )
{
HidePinNames = true;
}
else if( cNodeName == wxT( "MAXPIN" ) )
{
MaxPinCount = GetXmlAttributeIDLong( cNode, 0 );
}
else if( cNodeName == wxT( "GATEDEFINITION" ) )
{
GATE gate;
@ -1497,7 +1608,9 @@ void CADSTAR_ARCHIVE_PARSER::PART::DEFINITION::Parse( XNODE* aNode )
SwapGroups.push_back( swapGroup );
}
else
{
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 ) );
}
else
{
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();
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

@ -177,14 +177,13 @@ private:
PART::DEFINITION::PIN getPartDefinitionPin(
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 );
LABEL_SPIN_STYLE getSpinStyle( const long long& aCadstarOrientation, bool aMirror );
LABEL_SPIN_STYLE getSpinStyleDeciDeg( const double& aOrientationDeciDeg );
// General Graphical manipulation functions
//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,20 +259,30 @@ 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 )
@ -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,14 +444,18 @@ 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" ) );
}
}
}
@ -443,14 +471,18 @@ 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" ) );
}
}
}
@ -472,7 +504,9 @@ void CADSTAR_SCH_ARCHIVE_PARSER::SYMPINNAME_LABEL::Parse( XNODE* aNode )
HasLocation = true;
}
else
{
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;
}
else
{
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 );
}
else
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
}
}
}
@ -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,11 +754,15 @@ 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() );
}
}
}
@ -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,7 +807,9 @@ 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" ) )
@ -766,7 +825,9 @@ 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() );
}
}
}
@ -792,7 +853,9 @@ void CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::SYM_TERM::Parse( XNODE* aNode )
HasNetLabel = true;
}
else
{
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
{
THROW_UNKNOWN_NODE_IO_ERROR( cNodeName, aNode->GetName() );
}
}
if( !firstPointParsed || !secondPointParsed )
@ -864,7 +929,9 @@ void CADSTAR_SCH_ARCHIVE_PARSER::NET_SCH::BLOCK_TERM::Parse( XNODE* aNode )
HasNetLabel = true;
}
else
{
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();
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" ) );
}
}
}

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,14 +418,12 @@ 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 )
{
if( spacingCodes.find( aID ) == spacingCodes.end() )
wxLogWarning( _( "Design rule %s was not found. This was ignored." ) );
else
*aVal = getKiCadLength( spacingCodes.at( aID ).Spacing );
};
auto applyRule = [&]( wxString aID, int* aVal ) {
if( spacingCodes.find( aID ) == spacingCodes.end() )
wxLogWarning( _( "Design rule %s was not found. This was ignored." ) );
else
*aVal = getKiCadLength( spacingCodes.at( aID ).Spacing );
};
//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;
auto applyNetClassRule =
[&]( wxString aID, ::NETCLASS* aNetClassPtr, void (::NETCLASS::*aFunc)(int) )
{
int value = -1;
applyRule(aID, &value);
auto applyNetClassRule = [&]( wxString aID, ::NETCLASS* aNetClassPtr,
void ( ::NETCLASS::*aFunc )( int ) ) {
int value = -1;
applyRule( aID, &value );
if( value != -1 )
(aNetClassPtr->*aFunc)(value);
};
if( value != -1 )
( aNetClassPtr->*aFunc )( value );
};
applyNetClassRule( "T_T", ds.GetDefault(), &::NETCLASS::SetClearance );
@ -519,7 +528,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryAreas( const SYMDEF_PCB& aComponent,
else
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->SetZoneName( area.ID );
@ -878,7 +887,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadAreas()
else
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->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( "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" ) )
{
@ -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,13 +1396,13 @@ 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 },
{ wxT( "DIMENSION_DIRECT" ), SUBTYPE::DIRECT },
{ wxT( "DIMENSION_ANGLED" ), SUBTYPE::ANGLED },
{ wxT( "DIMENSION_DIAMETER" ), SUBTYPE::DIAMETER },
{ wxT( "DIMENSION_RADIUS" ), SUBTYPE::RADIUS },
{ wxT( "DIMENSION_ANGULAR" ), SUBTYPE::ANGULAR } };
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 },
{ wxT( "DIMENSION_RADIUS" ), SUBTYPE::RADIUS },
{ wxT( "DIMENSION_ANGULAR" ), SUBTYPE::ANGULAR } };
if( subTypeMap.find( subTypeStr ) == subTypeMap.end() )
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();
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 );