68 long long maxDesignSizekicad = std::numeric_limits<int>::max();
70 if( designSizeXkicad > maxDesignSizekicad || designSizeYkicad > maxDesignSizekicad )
73 _(
"The design is too large and cannot be imported into KiCad. \n"
74 "Please reduce the maximum design size in CADSTAR by navigating to: \n"
75 "Design Tab -> Properties -> Design Options -> Maximum Design Size. \n"
76 "Current Design size: %.2f, %.2f millimeters. \n"
77 "Maximum permitted design size: %.2f, %.2f millimeters.\n" ),
91 _(
"The selected file indicates that nets might be out of synchronisation "
92 "with the schematic. It is recommended that you carry out an 'Align Nets' "
93 "procedure in CADSTAR and re-import, to avoid inconsistencies between the "
94 "PCB and the schematic. " ) );
131 wxLogError( wxString::Format(
_(
"Unable to determine zone fill priorities for layer "
132 "'%s'. A best attempt has been made but it is "
133 "possible that DRC errors exist and that manual "
134 "editing of the zone priorities is required." ),
145 _(
"The CADSTAR design contains Trunk routing elements, which have no KiCad "
146 "equivalent. These elements were not loaded." ) );
151 wxLogWarning( wxString::Format(
152 _(
"The CADSTAR design contains variants which has no KiCad equivalent. Only "
153 "the variant '%s' was loaded." ),
160 _(
"The CADSTAR design contains re-use blocks which has no KiCad equivalent. The "
161 "re-use block information has been discarded during the import." ) );
164 wxLogWarning(
_(
"CADSTAR fonts are different to the ones in KiCad. This will likely result "
165 "in alignment issues that may cause DRC errors. Please review the imported "
166 "text elements carefully and correct manually if required." ) );
169 _(
"The CADSTAR design has been imported successfully.\n"
170 "Please review the import errors and warnings (if any)." ) );
175 std::vector<FOOTPRINT*> retval;
177 for( std::pair<SYMDEF_ID, FOOTPRINT*> fpPair :
m_libraryMap )
179 retval.push_back(
static_cast<FOOTPRINT*
>( fpPair.second->Clone() ) );
195 for( std::pair<SYMDEF_ID, FOOTPRINT*> libItem :
m_libraryMap )
216 std::vector<std::unique_ptr<FOOTPRINT>> retval;
220 footprint->SetParent(
nullptr );
221 retval.emplace_back( footprint );
239 wxLogWarning( wxString::Format(
240 _(
"The CADSTAR layer '%s' has no KiCad equivalent. All elements on this "
241 "layer have been mapped to KiCad layer '%s' instead." ),
242 aCadstarLayerName,
LSET::Name( aKiCadLayer ) ) );
252 wxLogMessage( wxString::Format(
253 _(
"The CADSTAR layer '%s' has been assumed to be a technical layer. All "
254 "elements on this layer have been mapped to KiCad layer '%s'." ),
255 aCadstarLayerName,
LSET::Name( aKiCadLayer ) ) );
262 int aDielectricSublayer )
274 if( !aCadstarLayer.
Name.IsEmpty() )
288 LAYER_ID ElecLayerID = wxEmptyString;
291 std::vector<LAYER_ID> ConstructionLayers;
296 bool IsInitialised() {
return !ElecLayerID.IsEmpty() || ConstructionLayers.size() > 0; };
299 std::vector<LAYER_BLOCK> cadstarBoardStackup;
300 LAYER_BLOCK currentBlock;
312 if( currentBlock.IsInitialised() )
314 cadstarBoardStackup.push_back( currentBlock );
315 currentBlock = LAYER_BLOCK();
318 currentBlock.ElecLayerID = cadstarLayerID;
325 wxLogWarning( wxString::Format(
_(
"The CADSTAR construction layer '%s' is on "
326 "the outer surface of the board. It has been "
328 cadstarLayer.
Name ) );
332 currentBlock.ConstructionLayers.push_back( cadstarLayerID );
337 if( currentBlock.IsInitialised() )
338 cadstarBoardStackup.push_back( currentBlock );
343 if( cadstarBoardStackup.back().ConstructionLayers.size() > 0 )
345 for(
const LAYER_ID& layerID : cadstarBoardStackup.back().ConstructionLayers )
349 wxLogWarning( wxString::Format(
_(
"The CADSTAR construction layer '%s' is on "
350 "the outer surface of the board. It has been "
352 cadstarLayer.
Name ) );
355 cadstarBoardStackup.back().ConstructionLayers.clear();
361 LAYER_BLOCK bottomLayer = cadstarBoardStackup.back();
362 cadstarBoardStackup.pop_back();
364 LAYER_BLOCK secondToLastLayer = cadstarBoardStackup.back();
365 cadstarBoardStackup.pop_back();
367 LAYER_BLOCK dummyLayer;
369 if( secondToLastLayer.ConstructionLayers.size() > 0 )
371 LAYER_ID lastConstruction = secondToLastLayer.ConstructionLayers.back();
373 if( secondToLastLayer.ConstructionLayers.size() > 1 )
377 secondToLastLayer.ConstructionLayers.pop_back();
386 dummyLayer.ConstructionLayers.push_back( lastConstruction );
389 cadstarBoardStackup.push_back( secondToLastLayer );
390 cadstarBoardStackup.push_back( dummyLayer );
391 cadstarBoardStackup.push_back( bottomLayer );
396 wxASSERT( cadstarBoardStackup.back().ConstructionLayers.size() == 0 );
407 size_t stackIndex = 0;
411 if( item->GetType() == BOARD_STACKUP_ITEM_TYPE::BS_ITEM_TYPE_COPPER )
413 LAYER_ID layerID = cadstarBoardStackup.at( stackIndex ).ElecLayerID;
415 if( layerID.IsEmpty() )
418 item->SetThickness( 0 );
424 LAYER_T copperType = LAYER_T::LT_SIGNAL;
426 switch( copperLayer.
Type )
429 copperType = LAYER_T::LT_JUMPER;
433 copperType = LAYER_T::LT_SIGNAL;
437 copperType = LAYER_T::LT_POWER;
442 wxFAIL_MSG( wxT(
"Unexpected Layer type. Was expecting an electrical type" ) );
448 m_layermap.insert( { copperLayer.
ID, item->GetBrdLayerId() } );
451 else if( item->GetType() == BOARD_STACKUP_ITEM_TYPE::BS_ITEM_TYPE_DIELECTRIC )
453 LAYER_BLOCK layerBlock = cadstarBoardStackup.at( stackIndex );
454 LAYER_BLOCK layerBlockBelow = cadstarBoardStackup.at( stackIndex + 1 );
456 if( layerBlock.ConstructionLayers.size() == 0 )
462 int dielectricId = stackIndex + 1;
463 item->SetDielectricLayerId( dielectricId );
468 if( layerBlock.ElecLayerID.IsEmpty() )
477 if( layerBlockBelow.ElecLayerID.IsEmpty() )
488 LAYER copperLayerBelow =
506 int dielectricSublayer = 0;
508 for(
LAYER_ID constructionLaID : layerBlock.ConstructionLayers )
512 if( dielectricSublayer )
513 item->AddDielectricPrms( dielectricSublayer );
517 m_layermap.insert( { dielectricLayer.
ID, item->GetBrdLayerId() } );
518 ++dielectricSublayer;
523 else if( item->GetType() == BOARD_STACKUP_ITEM_TYPE::BS_ITEM_TYPE_SILKSCREEN )
525 item->SetColor( wxT(
"White" ) );
527 else if( item->GetType() == BOARD_STACKUP_ITEM_TYPE::BS_ITEM_TYPE_SOLDERMASK )
529 item->SetColor( wxT(
"Green" ) );
537 int numElecLayersProcessed = 0;
540 int currentDocLayer = 0;
547 PCB_LAYER_ID kicadLayerID = PCB_LAYER_ID::UNDEFINED_LAYER;
548 wxString layerName = curLayer.
Name.Lower();
561 kicadLayerID = aBack;
563 kicadLayerID = aFront;
567 case LOG_LEVEL::NONE:
574 case LOG_LEVEL::WARN:
580 switch( curLayer.
Type )
588 THROW_IO_ERROR( wxString::Format(
_(
"Unexpected layer '%s' in layer stack." ),
595 ++numElecLayersProcessed;
603 if( currentDocLayer >= docLayers.size() )
606 kicadLayerID = docLayers.at( currentDocLayer++ );
614 selectLayerID( PCB_LAYER_ID::F_Fab, PCB_LAYER_ID::B_Fab, LOG_LEVEL::NONE );
618 selectLayerID( PCB_LAYER_ID::F_CrtYd, PCB_LAYER_ID::B_CrtYd, LOG_LEVEL::NONE );
624 if( layerName.Contains( wxT(
"glue" ) ) || layerName.Contains( wxT(
"adhesive" ) ) )
626 selectLayerID( PCB_LAYER_ID::F_Adhes, PCB_LAYER_ID::B_Adhes, LOG_LEVEL::MSG );
628 else if( layerName.Contains( wxT(
"silk" ) ) || layerName.Contains( wxT(
"legend" ) ) )
630 selectLayerID( PCB_LAYER_ID::F_SilkS, PCB_LAYER_ID::B_SilkS, LOG_LEVEL::MSG );
632 else if( layerName.Contains( wxT(
"assembly" ) ) || layerName.Contains( wxT(
"fabrication" ) ) )
634 selectLayerID( PCB_LAYER_ID::F_Fab, PCB_LAYER_ID::B_Fab, LOG_LEVEL::MSG );
636 else if( layerName.Contains( wxT(
"resist" ) ) || layerName.Contains( wxT(
"mask" ) ) )
638 selectLayerID( PCB_LAYER_ID::F_Mask, PCB_LAYER_ID::B_Mask, LOG_LEVEL::MSG );
640 else if( layerName.Contains( wxT(
"paste" ) ) )
642 selectLayerID( PCB_LAYER_ID::F_Paste, PCB_LAYER_ID::B_Paste, LOG_LEVEL::MSG );
647 selectLayerID( PCB_LAYER_ID::Eco1_User, PCB_LAYER_ID::Eco2_User,
653 selectLayerID( PCB_LAYER_ID::F_Paste, PCB_LAYER_ID::B_Paste, LOG_LEVEL::MSG );
657 selectLayerID( PCB_LAYER_ID::F_SilkS, PCB_LAYER_ID::B_SilkS, LOG_LEVEL::MSG );
661 selectLayerID( PCB_LAYER_ID::F_Mask, PCB_LAYER_ID::B_Mask, LOG_LEVEL::MSG );
667 selectLayerID( PCB_LAYER_ID::Eco1_User, PCB_LAYER_ID::Eco2_User, LOG_LEVEL::WARN );
671 wxFAIL_MSG( wxT(
"Unknown CADSTAR Layer Sub-type" ) );
677 wxFAIL_MSG( wxT(
"Unknown CADSTAR Layer Type" ) );
692 std::vector<INPUT_LAYER_DESC> inputLayers;
693 std::map<wxString, LAYER_ID> cadstarLayerNameMap;
695 for( std::pair<LAYER_ID, PCB_LAYER_ID> layerPair :
m_layermap )
707 inputLayers.push_back( iLdesc );
708 cadstarLayerNameMap.insert( { curLayer->
Name, curLayer->
ID } );
712 if( inputLayers.size() == 0 )
718 for( std::pair<wxString, PCB_LAYER_ID> layerPair : reMappedLayers )
720 if( layerPair.second == PCB_LAYER_ID::UNDEFINED_LAYER )
722 wxFAIL_MSG( wxT(
"Unexpected Layer ID" ) );
726 LAYER_ID cadstarLayerID = cadstarLayerNameMap.at( layerPair.first );
727 m_layermap.at( cadstarLayerID ) = layerPair.second;
728 enabledLayers |=
LSET( { layerPair.second } );
742 [&]( wxString aID,
int* aVal )
744 if( spacingCodes.find( aID ) == spacingCodes.end() )
745 wxLogWarning(
_(
"Design rule %s was not found. This was ignored." ) );
763 auto applyNetClassRule = [&]( wxString aID,
const std::shared_ptr<NETCLASS>& aNetClassPtr )
766 applyRule( aID, &value );
769 aNetClassPtr->SetClearance( value );
772 applyNetClassRule(
"T_T", bds.
m_NetSettings->GetDefaultNetclass() );
774 wxLogWarning(
_(
"KiCad design rules are different from CADSTAR ones. Only the compatible "
775 "design rules were imported. It is recommended that you review the design "
776 "rules that have been applied." ) );
792 if( component.
Figures.size() > 0 )
795 componentLayer = firstFigure.
LayerID;
797 else if( component.
Texts.size() > 0 )
799 TEXT firstText = component.
Texts.begin()->second;
800 componentLayer = firstText.
LayerID;
823 m_libraryMap.insert( std::make_pair( key, footprint ) );
831 for( std::pair<FIGURE_ID, FIGURE> figPair : aComponent.
Figures )
833 FIGURE& fig = figPair.second;
840 wxString::Format( wxT(
"Component %s:%s -> Figure %s" ),
853 bool compCopperError =
false;
860 LSET remainingLayers = layers;
862 if( !compCopperError && copperLayers.count() > 1 && compCopper.
AssociatedPadIDs.size() > 0 )
865 wxLogError(
_(
"Footprint definition '%s' has component copper associated to a pad on "
866 "multiple layers. Custom padstacks are not supported in KiCad. The "
867 "copper items have been imported as graphical elements." ),
870 compCopperError =
true;
899 std::unique_ptr<PAD>
pad = std::make_unique<PAD>( aFootprint );
900 pad->SetAttribute( PAD_ATTRIB::SMD );
901 pad->SetLayerSet( copperLayers );
903 ? wxString::Format( wxT(
"%ld" ), anchorPad.
ID )
913 if( anchorSize <= 0 )
919 pad->SetPosition( anchorPos );
923 shapePolys.
Move( -anchorPos );
935 aFootprint->
Add(
pad.release(), ADD_MODE::APPEND );
940 remainingLayers ^= copperLayers;
943 if( remainingLayers.any() )
948 wxString::Format( wxT(
"Component %s:%s -> Copper element" ),
960 for( std::pair<COMP_AREA_ID, COMPONENT_AREA> areaPair : aComponent.
ComponentAreas )
966 int lineThickness = 0;
969 aFootprint->
Add( zone, ADD_MODE::APPEND );
991 libName << wxT(
" (" ) << aComponent.
Alternate << wxT(
")" );
994 wxString::Format(
_(
"The CADSTAR area '%s' in library component '%s' does not "
995 "have a KiCad equivalent. The area is neither a via nor "
996 "route keepout area. The area was not imported." ),
997 area.
ID, libName ) );
1006 for( std::pair<PAD_ID, COMPONENT_PAD> padPair : aComponent.
ComponentPads )
1009 aFootprint->
Add(
pad, ADD_MODE::APPEND );
1020 std::unique_ptr<PAD>
pad = std::make_unique<PAD>( aParent );
1023 switch( aCadstarPad.
Side )
1038 wxFAIL_MSG( wxT(
"Unknown Pad type" ) );
1041 pad->SetAttribute( PAD_ATTRIB::SMD );
1042 pad->SetLocalSolderMaskMargin( 0 );
1043 pad->SetLocalSolderPasteMargin( 0 );
1044 pad->SetLocalSolderPasteMarginRatio( 0.0 );
1045 bool complexPadErrorLogged =
false;
1047 for(
auto& reassign : csPadcode.
Reassigns )
1052 if( shape.
Size == 0 )
1054 padLayerSet.
reset( kiLayer );
1062 std::optional<int> localMargin =
pad->GetLocalSolderMaskMargin();
1064 if( !localMargin.has_value() )
1065 pad->SetLocalSolderMaskMargin( newMargin );
1067 pad->SetLocalSolderMaskMargin( newMargin );
1071 std::optional<int> localMargin =
pad->GetLocalSolderPasteMargin();
1073 if( !localMargin.has_value() )
1074 pad->SetLocalSolderPasteMargin( newMargin );
1076 pad->SetLocalSolderPasteMargin( newMargin );
1082 if( !complexPadErrorLogged )
1084 complexPadErrorLogged =
true;
1088 _(
"The CADSTAR pad definition '%s' is a complex pad stack, "
1089 "which is not supported in KiCad. Please review the "
1090 "imported pads as they may require manual correction." ),
1097 pad->SetLayerSet( padLayerSet );
1104 pad->SetNumber( wxT(
"" ) );
1109 ? wxString::Format( wxT(
"%ld" ), aCadstarPad.
ID )
1121 pad->SetAttribute( PAD_ATTRIB::SMD );
1149 RECT_CHAMFER_POSITIONS::RECT_CHAMFER_BOTTOM_LEFT
1150 | RECT_CHAMFER_POSITIONS::RECT_CHAMFER_TOP_LEFT );
1232 wxFAIL_MSG( wxT(
"Unknown Pad Shape" ) );
1245 pad->SetDrillShape( PAD_DRILL_SHAPE::OBLONG );
1252 pad->SetDrillShape( PAD_DRILL_SHAPE::CIRCLE );
1261 pad->SetAttribute( PAD_ATTRIB::PTH );
1263 pad->SetAttribute( PAD_ATTRIB::NPTH );
1267 pad->SetDrillSize( { 0, 0 } );
1272 LSET lset =
pad->GetLayerSet();
1275 if( lset.size() > 0 )
1281 pad->SetPosition( { 0, 0 } );
1282 pad->TransformShapeToPolygon( padOutline, layer, 0, maxError,
ERROR_INSIDE );
1285 padShape->
SetShape( SHAPE_T::POLY );
1289 padShape->
Move( padOffset - drillOffset );
1294 if( editedPadOutline.
Contains( { 0, 0 } ) )
1300 padOffset = { 0, 0 };
1307 drillOffset = { 0, 0 };
1312 _(
"The CADSTAR pad definition '%s' has the hole shape outside the "
1313 "pad shape. The hole has been moved to the center of the pad." ),
1319 wxFAIL_MSG( wxT(
"No copper layers defined in the pad?" ) );
1342 wxLogError(
_(
"The CADSTAR pad definition '%s' has import errors: %s" ),
1349 return pad.release();
1354 const PAD_ID aCadstarPadID )
1356 size_t index = aCadstarPadID - (long) 1;
1358 if( !( index < aFootprint->Pads().size() ) )
1360 THROW_IO_ERROR( wxString::Format(
_(
"Unable to find pad index '%d' in footprint '%s'." ),
1361 (
long) aCadstarPadID,
1365 return aFootprint->
Pads().at( index );
1371 for( std::pair<GROUP_ID, GROUP> groupPair :
Layout.
Groups )
1373 GROUP& csGroup = groupPair.second;
1385 for( std::pair<GROUP_ID, GROUP> groupPair :
Layout.
Groups )
1387 GROUP& csGroup = groupPair.second;
1389 if( !csGroup.
GroupID.IsEmpty() )
1393 THROW_IO_ERROR( wxString::Format(
_(
"Unable to find group ID %s in the group "
1399 THROW_IO_ERROR( wxString::Format(
_(
"Unable to find sub group %s in the group "
1400 "map (parent group ID=%s, Name=%s)." ),
1409 parentGroup->
AddItem( kiCadGroup );
1418 for( std::pair<BOARD_ID, CADSTAR_BOARD> boardPair :
Layout.
Boards )
1424 wxString::Format( wxT(
"BOARD %s" ), board.
ID ),
1427 if( !board.
GroupID.IsEmpty() )
1439 for( std::pair<FIGURE_ID, FIGURE> figPair :
Layout.
Figures )
1441 FIGURE& fig = figPair.second;
1448 wxString::Format( wxT(
"FIGURE %s" ), fig.
ID ),
1461 for( std::pair<TEXT_ID, TEXT> txtPair :
Layout.
Texts )
1463 TEXT& csTxt = txtPair.second;
1475 switch( csDim.
Type )
1477 case DIMENSION::TYPE::LINEARDIM:
1480 case DIMENSION::SUBTYPE::ANGLED:
1481 wxLogWarning( wxString::Format(
_(
"Dimension ID %s is an angled dimension, which "
1482 "has no KiCad equivalent. An aligned dimension "
1483 "was loaded instead." ),
1486 case DIMENSION::SUBTYPE::DIRECT:
1487 case DIMENSION::SUBTYPE::ORTHOGONAL:
1489 if( csDim.
Line.
Style == DIMENSION::LINE::STYLE::EXTERNAL )
1491 wxLogWarning( wxString::Format(
1492 _(
"Dimension ID %s has 'External' style in CADSTAR. External "
1493 "dimension styles are not yet supported in KiCad. The dimension "
1494 "object was imported with an internal dimension style instead." ),
1500 if( csDim.
Subtype == DIMENSION::SUBTYPE::ORTHOGONAL )
1524 VECTOR2I crossbarVector = crossbarEnd - crossbarStart;
1526 double height = 0.0;
1528 if( csDim.
Subtype == DIMENSION::SUBTYPE::ORTHOGONAL )
1531 height = heightVector.
y;
1533 height = heightVector.
x;
1539 height = heightVector.
x * angle.
Cos() + heightVector.
y * angle.
Sin();
1549 wxLogError(
_(
"Unexpected Dimension type (ID %s). This was not imported." ),
1555 case DIMENSION::TYPE::LEADERDIM:
1558 if( csDim.
Line.
Style == DIMENSION::LINE::STYLE::INTERNAL )
1682 case DIMENSION::TYPE::ANGLEDIM:
1684 wxLogError(
_(
"Dimension %s is an angular dimension which has no KiCad equivalent. "
1685 "The object was not imported." ),
1695 for( std::pair<AREA_ID, AREA> areaPair :
Layout.
Areas )
1697 AREA& area = areaPair.second;
1701 int lineThickness = 0;
1724 wxLogWarning( wxString::Format(
_(
"The CADSTAR area '%s' is marked as a placement "
1725 "area in CADSTAR. Placement areas are not "
1726 "supported in KiCad. Only the supported elements "
1727 "for the area were imported." ),
1733 wxLogError( wxString::Format(
_(
"The CADSTAR area '%s' does not have a KiCad "
1734 "equivalent. Pure Placement areas are not supported." ),
1760 THROW_IO_ERROR( wxString::Format(
_(
"Unable to find component '%s' in the library"
1761 "(Symdef ID: '%s')" ),
1766 FOOTPRINT* libFootprint = fpIter->second;
1785 for( std::pair<PART_DEFINITION_PIN_ID, PART::DEFINITION::PIN> pinPair :
1788 PART::DEFINITION::PIN
pin = pinPair.second;
1789 wxString pinName =
pin.Name;
1791 if( pinName.empty() )
1792 pinName =
pin.Identifier;
1794 if( pinName.empty() )
1795 pinName = wxString::Format( wxT(
"%ld" ),
pin.ID );
1807 for( std::pair<PAD_ID, PADEXCEPTION> padPair : comp.
PadExceptions )
1816 if( !padEx.
PadCode.IsEmpty() )
1831 wxString padNumber = kiPad->
GetNumber();
1846 footprint->
SetValue( wxEmptyString );
1862 if( !comp.
PartID.IsEmpty() && comp.
PartID != wxT(
"NO_PART" ) )
1874 for( std::pair<DOCUMENTATION_SYMBOL_ID, DOCUMENTATION_SYMBOL> docPair :
1884 THROW_IO_ERROR( wxString::Format(
_(
"Unable to find documentation symbol in the "
1885 "library (Symdef ID: '%s')" ),
1889 SYMDEF_PCB& docSymDefinition = ( *docSymIter ).second;
1896 bool mirrorInvert = docSymInstance.
Mirror;
1901 if( !docSymDefinition.
Alternate.IsEmpty() )
1902 groupName += wxT(
" (" ) + docSymDefinition.
Alternate + wxT(
")" );
1910 for( std::pair<FIGURE_ID, FIGURE> figPair : docSymDefinition.
Figures )
1912 FIGURE fig = figPair.second;
1914 wxString::Format( wxT(
"DOCUMENTATION SYMBOL %s, FIGURE %s" ),
1916 m_board, groupID, moveVector, rotationAngle, scalingFactor,
1917 centreOfTransform, mirrorInvert );
1921 for( std::pair<TEXT_ID, TEXT> textPair : docSymDefinition.
Texts )
1923 TEXT txt = textPair.second;
1925 rotationAngle, scalingFactor, centreOfTransform, mirrorInvert );
1935 TEMPLATE& csTemplate = tempPair.second;
1937 int zonelinethickness = 0;
1947 if( !( csTemplate.
NetID.IsEmpty() || csTemplate.
NetID == wxT(
"NONE" ) ) )
1952 wxLogWarning( wxString::Format(
1953 _(
"The CADSTAR template '%s' has the setting 'Allow in No Routing Areas' "
1954 "enabled. This setting has no KiCad equivalent, so it has been ignored." ),
1955 csTemplate.
Name ) );
1960 wxLogWarning( wxString::Format(
1961 _(
"The CADSTAR template '%s' has the setting 'Box Isolated Pins' "
1962 "enabled. This setting has no KiCad equivalent, so it has been ignored." ),
1963 csTemplate.
Name ) );
1968 wxLogWarning( wxString::Format(
1969 _(
"The CADSTAR template '%s' has the setting 'Automatic Repour' "
1970 "enabled. This setting has no KiCad equivalent, so it has been ignored." ),
1971 csTemplate.
Name ) );
1979 wxLogWarning( wxString::Format(
1980 _(
"The CADSTAR template '%s' has a non-zero value defined for the "
1981 "'Sliver Width' setting. There is no KiCad equivalent for "
1982 "this, so this setting was ignored." ),
1983 csTemplate.
Name ) );
1989 wxLogWarning( wxString::Format(
1990 _(
"The CADSTAR template '%s' has different settings for 'Retain Poured Copper "
1991 "- Disjoint' and 'Retain Poured Copper - Isolated'. KiCad does not "
1992 "distinguish between these two settings. The setting for disjoint copper "
1993 "has been applied as the minimum island area of the KiCad Zone." ),
1994 csTemplate.
Name ) );
1997 long long minIslandArea = -1;
2024 if( csTemplate.
Pouring.
FillType == TEMPLATE::POURING::COPPER_FILL_TYPE::HATCHED )
2026 zone->
SetFillMode( ZONE_FILL_MODE::HATCH_PATTERN );
2040 wxLogWarning( wxString::Format(
2041 _(
"The CADSTAR template '%s' has different settings for thermal relief "
2042 "in pads and vias. KiCad only supports one single setting for both. The "
2043 "setting for pads has been applied." ),
2044 csTemplate.
Name ) );
2055 if( spokeWidth < minThickness )
2057 wxLogWarning( wxString::Format(
2058 _(
"The CADSTAR template '%s' has thermal reliefs in the original design "
2059 "but the spoke width (%.2f mm) is thinner than the minimum thickness of "
2060 "the zone (%.2f mm). KiCad requires the minimum thickness of the zone "
2061 "to be preserved. Therefore the minimum thickness has been applied as "
2062 "the new spoke width and will be applied next time the zones are "
2067 spokeWidth = minThickness;
2090 NET_ID netid = wxEmptyString;
2092 for( std::pair<NET_ID, NET_PCB> netPair :
Layout.
Nets )
2096 if( net.
Name == powerPlaneLayerName )
2103 if( netid.IsEmpty() )
2105 wxLogError(
_(
"The CADSTAR layer '%s' is defined as a power plane layer. However no "
2106 "net with such name exists. The layer has been loaded but no copper "
2107 "zone was created." ),
2108 powerPlaneLayerName );
2112 for( std::pair<BOARD_ID, CADSTAR_BOARD> boardPair :
Layout.
Boards )
2117 int defaultLineThicknesss = bds.
GetLineThickness( PCB_LAYER_ID::Edge_Cuts );
2137 for( std::pair<COPPER_ID, COPPER> copPair :
Layout.
Coppers )
2139 COPPER& csCopper = copPair.second;
2162 if( shape->GetShape() == SHAPE_T::ARC )
2166 ERROR_LOC::ERROR_INSIDE );
2172 ERROR_LOC::ERROR_INSIDE );
2206 _(
"The CADSTAR design contains COPPER elements, which have no direct KiCad "
2207 "equivalent. These have been imported as a KiCad Zone if solid or hatch "
2208 "filled, or as a KiCad Track if the shape was an unfilled outline (open or "
2256 zone->
SetFillMode( ZONE_FILL_MODE::HATCH_PATTERN );
2282 for( std::pair<NET_ID, NET_PCB> netPair :
Layout.
Nets )
2285 wxString netnameForErrorReporting = net.
Name;
2287 std::map<NETELEMENT_ID, long> netelementSizes;
2289 if( netnameForErrorReporting.IsEmpty() )
2290 netnameForErrorReporting = wxString::Format( wxT(
"$%ld" ), net.
SignalNum );
2292 for( std::pair<NETELEMENT_ID, NET_PCB::VIA> viaPair : net.
Vias )
2294 NET_PCB::VIA
via = viaPair.second;
2298 netelementSizes.insert( { viaPair.first, viaSize } );
2301 for( std::pair<NETELEMENT_ID, NET_PCB::PIN> pinPair : net.
Pins )
2303 NET_PCB::PIN
pin = pinPair.second;
2306 if( footprint ==
nullptr )
2308 wxLogWarning( wxString::Format(
2309 _(
"The net '%s' references component ID '%s' which does not exist. "
2310 "This has been ignored." ),
2311 netnameForErrorReporting,
pin.ComponentID ) );
2313 else if( (
pin.PadID - (
long) 1 ) > footprint->
Pads().size() )
2315 wxLogWarning( wxString::Format(
_(
"The net '%s' references non-existent pad index"
2316 " '%d' in component '%s'. This has been "
2318 netnameForErrorReporting,
2337 if( assocPads.find(
pin.PadID ) != assocPads.end() )
2339 for(
PAD_ID copperPadID : assocPads.at(
pin.PadID ) )
2348 int padsize = std::min(
pad->GetSizeX(),
pad->GetSizeY() );
2349 netelementSizes.insert( { pinPair.first, padsize } );
2357 auto getJunctionSize =
2358 [&](
NETELEMENT_ID aJptNetElemId,
const NET_PCB::CONNECTION_PCB& aConnectionToIgnore ) ->
int
2360 int jptsize = std::numeric_limits<int>::max();
2362 for( NET_PCB::CONNECTION_PCB connection : net.
Connections )
2364 if( connection.Route.RouteVertices.size() == 0 )
2367 if( connection.StartNode == aConnectionToIgnore.StartNode
2368 && connection.EndNode == aConnectionToIgnore.EndNode )
2373 if( connection.StartNode == aJptNetElemId )
2375 int s =
getKiCadLength( connection.Route.RouteVertices.front().RouteWidth );
2376 jptsize = std::max( jptsize, s );
2378 else if( connection.EndNode == aJptNetElemId )
2380 int s =
getKiCadLength( connection.Route.RouteVertices.back().RouteWidth );
2381 jptsize = std::max( jptsize, s );
2385 if( jptsize == std::numeric_limits<int>::max()
2386 && !aConnectionToIgnore.Route.RouteVertices.empty() )
2390 NET_PCB::ROUTE_VERTEX vertex = aConnectionToIgnore.Route.RouteVertices.front();
2392 if( aConnectionToIgnore.EndNode == aJptNetElemId )
2393 vertex = aConnectionToIgnore.Route.RouteVertices.back();
2401 for( NET_PCB::CONNECTION_PCB connection : net.
Connections )
2403 int startSize = std::numeric_limits<int>::max();
2404 int endSize = std::numeric_limits<int>::max();
2406 if( netelementSizes.find( connection.StartNode ) != netelementSizes.end() )
2407 startSize = netelementSizes.at( connection.StartNode );
2409 startSize = getJunctionSize( connection.StartNode, connection );
2411 if( netelementSizes.find( connection.EndNode ) != netelementSizes.end() )
2412 endSize = netelementSizes.at( connection.EndNode );
2414 endSize = getJunctionSize( connection.EndNode, connection );
2419 if( !connection.Unrouted )
2428 auto findAndReplaceTextField =
2467 wxString varValue = txtvalue.second;
2469 txtVars.insert( { varName, varValue } );
2474 wxString varName = txtvalue.first;
2475 wxString varValue = txtvalue.second;
2477 txtVars.insert( { varName, varValue } );
2482 wxLogError(
_(
"Text Variables could not be set as there is no project loaded." ) );
2490 for( std::pair<ATTRIBUTE_ID, ATTRIBUTE_VALUE> attrPair : aComponent.
AttributeValues )
2501 for( std::pair<ATTRIBUTE_ID, TEXT_LOCATION> textlocPair : aComponent.
TextLocations )
2508 attrval = wxEmptyString;
2512 attrval = wxT(
"${REFERENCE}" );
2527 const NET_PCB::ROUTE& aCadstarRoute,
2528 long aStartWidth,
long aEndWidth )
2530 if( aCadstarRoute.RouteVertices.size() == 0 )
2533 std::vector<PCB_SHAPE*> shapes;
2534 std::vector<NET_PCB::ROUTE_VERTEX> routeVertices = aCadstarRoute.RouteVertices;
2537 if( aStartWidth < routeVertices.front().RouteWidth )
2539 NET_PCB::ROUTE_VERTEX newFrontVertex = aCadstarRoute.RouteVertices.front();
2540 newFrontVertex.RouteWidth = aStartWidth;
2541 newFrontVertex.Vertex.End = aCadstarRoute.StartPoint;
2542 routeVertices.insert( routeVertices.begin(), newFrontVertex );
2546 if( aEndWidth < routeVertices.back().RouteWidth )
2548 NET_PCB::ROUTE_VERTEX newBackVertex = aCadstarRoute.RouteVertices.back();
2549 newBackVertex.RouteWidth = aEndWidth;
2550 routeVertices.push_back( newBackVertex );
2553 POINT prevEnd = aCadstarRoute.StartPoint;
2555 for(
const NET_PCB::ROUTE_VERTEX& v : routeVertices )
2561 shapes.push_back( shape );
2562 prevEnd = v.Vertex.End;
2567 wxLogError(
_(
"The CADSTAR design contains teardrops. This importer does not yet "
2568 "support them, so the teardrops in the design have been ignored." ) );
2584 const NET_ID& aCadstarNetID,
const NET_PCB::VIA& aCadstarVia )
2594 via->SetLocked( aCadstarVia.Fixed );
2598 wxLogError(
_(
"The CADSTAR via code '%s' has different shape from a circle defined. "
2599 "KiCad only supports circular vias so this via type has been changed to "
2600 "be a via with circular shape of %.2f mm diameter." ),
2607 bool start_layer_outside =
2610 bool end_layer_outside =
2614 if( start_layer_outside && end_layer_outside )
2616 via->SetViaType( VIATYPE::THROUGH );
2618 else if( ( !start_layer_outside ) && ( !end_layer_outside ) )
2620 via->SetViaType( VIATYPE::BLIND_BURIED );
2624 via->SetViaType( VIATYPE::MICROVIA );
2639 const LAYER_ID& aCadstarLayerOverride,
2641 double aRotationAngle,
double aScalingFactor,
2643 bool aMirrorInvert )
2646 aContainer->
Add( txt );
2651 RotatePoint( rotatedTextPos, aTransformCentre, rotationAngle );
2652 rotatedTextPos.
x =
KiROUND( ( rotatedTextPos.
x - aTransformCentre.
x ) * aScalingFactor );
2653 rotatedTextPos.
y =
KiROUND( ( rotatedTextPos.
y - aTransformCentre.
y ) * aScalingFactor );
2654 rotatedTextPos += aTransformCentre;
2713 wxFAIL_MSG( wxT(
"Unknown Alignment - needs review!" ) );
2717 txt->
Flip( aTransformCentre, FLIP_DIRECTION::LEFT_RIGHT );
2720 if( aScalingFactor != 1.0 )
2726 scaledTextSize.
x =
KiROUND( (
double) unscaledTextSize.
x * aScalingFactor );
2727 scaledTextSize.
y =
KiROUND( (
double) unscaledTextSize.
y * aScalingFactor );
2733 txt->
Move( aMoveVector );
2738 LAYER_ID layersToDrawOn = aCadstarLayerOverride;
2740 if( layersToDrawOn.IsEmpty() )
2741 layersToDrawOn = aCadstarText.
LayerID;
2752 if( !aCadstarGroupID.IsEmpty() )
2763 if( !aCadstarGroupID.IsEmpty() )
2773 const wxString& aShapeName,
2777 double aRotationAngle,
double aScalingFactor,
2779 bool aMirrorInvert )
2781 auto drawAsOutline = [&]()
2784 aContainer, aCadstarGroupID, aMoveVector, aRotationAngle,
2785 aScalingFactor, aTransformCentre, aMirrorInvert );
2787 aCadstarGroupID, aMoveVector, aRotationAngle, aScalingFactor,
2788 aTransformCentre, aMirrorInvert );
2791 switch( aCadstarShape.
Type )
2801 wxLogWarning( wxString::Format(
2802 _(
"The shape for '%s' is Hatch filled in CADSTAR, which has no KiCad equivalent. "
2803 "Using solid fill instead." ),
2809 if( aCadstarShape.
Vertices.size() < 3 )
2820 aMoveVector, aRotationAngle,
2821 aScalingFactor, aTransformCentre,
2829 aContainer->
Add( shape, ADD_MODE::APPEND );
2831 if( !aCadstarGroupID.IsEmpty() )
2845 double aRotationAngle,
2846 double aScalingFactor,
2848 bool aMirrorInvert )
2850 for(
const CUTOUT& cutout : aCutouts )
2853 aCadstarGroupID, aMoveVector, aRotationAngle, aScalingFactor,
2854 aTransformCentre, aMirrorInvert );
2865 double aRotationAngle,
2866 double aScalingFactor,
2868 bool aMirrorInvert )
2871 aCadstarGroupID, aMoveVector,
2872 aRotationAngle, aScalingFactor,
2873 aTransformCentre, aMirrorInvert );
2877 shape->SetStroke(
STROKE_PARAMS( aLineThickness, LINE_STYLE::SOLID ) );
2878 shape->SetLayer( aKiCadLayer );
2879 shape->SetParent( aContainer );
2880 aContainer->
Add( shape, ADD_MODE::APPEND );
2885std::vector<PCB_SHAPE*>
2890 double aRotationAngle,
double aScalingFactor,
2892 bool aMirrorInvert )
2894 std::vector<PCB_SHAPE*> shapes;
2896 if( aCadstarVertices.size() < 2 )
2900 const VERTEX* prev = &aCadstarVertices.at( 0 );
2903 for(
size_t i = 1; i < aCadstarVertices.size(); i++ )
2905 cur = &aCadstarVertices.at( i );
2907 aMoveVector, aRotationAngle, aScalingFactor,
2908 aTransformCentre, aMirrorInvert ) );
2917 const VERTEX& aCadstarVertex,
2921 double aRotationAngle,
2922 double aScalingFactor,
2924 bool aMirrorInvert )
2936 centerPoint = ( startPoint + endPoint ) / 2;
2943 switch( aCadstarVertex.
Type )
2947 shape =
new PCB_SHAPE( aContainer, SHAPE_T::SEGMENT );
2950 shape->
SetEnd( endPoint );
2961 shape =
new PCB_SHAPE( aContainer, SHAPE_T::ARC );
2966 EDA_ANGLE arcStartAngle( startPoint - centerPoint );
2967 EDA_ANGLE arcEndAngle( endPoint - centerPoint );
2968 EDA_ANGLE arcAngle = ( arcEndAngle - arcStartAngle ).Normalize();
2983 shape->
Flip( aTransformCentre, FLIP_DIRECTION::LEFT_RIGHT );
2985 if( aScalingFactor != 1.0 )
2987 shape->
Move( -1*aTransformCentre );
2988 shape->
Scale( aScalingFactor );
2989 shape->
Move( aTransformCentre );
2992 if( aRotationAngle != 0.0 )
2995 if( aMoveVector !=
VECTOR2I{ 0, 0 } )
2996 shape->
Move( aMoveVector );
2998 if( !aCadstarGroupID.IsEmpty() )
3006 const int& aLineThickness,
3009 ZONE* zone =
new ZONE( aParentContainer );
3013 zone->
SetFillMode( ZONE_FILL_MODE::HATCH_PATTERN );
3014 zone->
SetHatchStyle( ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL );
3025 for(
int i = 0; i < polygon.
HoleCount( 0 ); i++ )
3036 double aRotationAngle,
3037 double aScalingFactor,
3039 bool aMirrorInvert )
3044 aContainer, noGroup, aMoveVector,
3045 aRotationAngle, aScalingFactor,
3046 aTransformCentre, aMirrorInvert );
3057 noGroup, aMoveVector,
3058 aRotationAngle, aScalingFactor,
3059 aTransformCentre, aMirrorInvert );
3070 if( aLineThickness > 0 )
3078 for(
int j = 0; j < polySet.
HoleCount( i ); ++j )
3095 switch( shape->GetShape() )
3099 SHAPE_ARC arc( shape->GetCenter(), shape->GetStart(), shape->GetArcAngle() );
3101 if( shape->EndsSwapped() )
3108 case SHAPE_T::SEGMENT:
3109 lineChain.
Append( shape->GetStartX(), shape->GetStartY() );
3110 lineChain.
Append( shape->GetEndX(), shape->GetEndY() );
3114 wxFAIL_MSG( wxT(
"Drawsegment type is unexpected. Ignored." ) );
3134 const std::vector<PCB_SHAPE*>& aShapes,
3137 int aWidthOverride )
3139 std::vector<PCB_TRACK*> tracks;
3151 if( aTrack->GetLength() != 0 )
3153 tracks.push_back( aTrack );
3154 aParentContainer->
Add( aTrack, ADD_MODE::APPEND );
3164 switch( shape->GetShape() )
3168 SHAPE_ARC arc( shape->GetStart(), shape->GetArcMid(), shape->GetEnd(), 0 );
3170 if( shape->EndsSwapped() )
3173 track =
new PCB_ARC( aParentContainer, &arc );
3177 case SHAPE_T::SEGMENT:
3178 track =
new PCB_TRACK( aParentContainer );
3179 track->
SetStart( shape->GetStart() );
3180 track->
SetEnd( shape->GetEnd() );
3184 wxFAIL_MSG( wxT(
"Drawsegment type is unexpected. Ignored." ) );
3188 if( aWidthOverride == -1 )
3189 track->
SetWidth( shape->GetWidth() );
3193 if( aLayerOverride == PCB_LAYER_ID::UNDEFINED_LAYER )
3194 track->
SetLayer( shape->GetLayer() );
3198 if( aNet !=
nullptr )
3206 if( prevTrack !=
nullptr )
3208 int offsetAmount = ( track->
GetWidth() / 2 ) - ( prevTrack->
GetWidth() / 2 );
3210 if( offsetAmount > 0 )
3217 else if( offsetAmount < 0 )
3222 prevTrack->
SetEnd( newEnd );
3238 addTrack( synthTrack );
3243 addTrack( prevTrack );
3258 const wxString& aAttributeValue )
3271 aFootprint->
SetValue( aAttributeValue );
3272 txt = &aFootprint->
Value();
3277 aFootprint->
Add( txt );
3278 txt->
SetText( aAttributeValue );
3291 aFootprint->
SetValue( aAttributeValue );
3292 txt = &aFootprint->
Value();
3298 aFootprint->
Add( txt );
3299 txt->
SetText( aAttributeValue );
3309 if( aCadstarAttrLoc.
Mirror )
3367 wxFAIL_MSG( wxT(
"Unknown Alignment - needs review!" ) );
3376 const long& aOffsetAmount )
3378 VECTOR2I v( *aPointToOffset - aRefPoint );
3384 aPointToOffset->
x = offsetted.
x;
3385 aPointToOffset->
y = offsetted.
y;
3389 *aPointToOffset = aRefPoint;
3407 if( textSize.
x == 0 )
3412 if( textSize.
x == 0 || textSize.
y == 0 )
3505 const std::map<ATTRIBUTE_ID, ATTRIBUTE_VALUE>& aCadstarAttributeMap )
3507 wxCHECK( aCadstarAttributeMap.find( aCadstarAttributeID ) != aCadstarAttributeMap.end(),
3510 return aCadstarAttributeMap.at( aCadstarAttributeID ).Value;
3527 const PART_ID& aCadstarPartID )
3562 if( hcode.
Hatches.size() < 1 )
3575 if( hcode.
Hatches.size() < 1 )
3587 if( hcode.
Hatches.size() < 1 )
3612 if( hcode.
Hatches.size() != 2 )
3614 wxLogWarning( wxString::Format(
3615 _(
"The CADSTAR Hatching code '%s' has %d hatches defined. "
3616 "KiCad only supports 2 hatches (crosshatching) 90 degrees apart. "
3617 "The imported hatching is crosshatched." ),
3622 if( hcode.
Hatches.at( 0 ).LineWidth != hcode.
Hatches.at( 1 ).LineWidth )
3624 wxLogWarning( wxString::Format(
3625 _(
"The CADSTAR Hatching code '%s' has different line widths for each "
3626 "hatch. KiCad only supports one width for the hatching. The imported "
3627 "hatching uses the width defined in the first hatch definition, i.e. "
3636 wxLogWarning( wxString::Format(
3637 _(
"The CADSTAR Hatching code '%s' has different step sizes for each "
3638 "hatch. KiCad only supports one step size for the hatching. The imported "
3639 "hatching uses the step size defined in the first hatching definition, "
3646 if( abs( hcode.
Hatches.at( 0 ).OrientAngle - hcode.
Hatches.at( 1 ).OrientAngle )
3649 wxLogWarning( wxString::Format(
3650 _(
"The hatches in CADSTAR Hatching code '%s' have an angle "
3651 "difference of %.1f degrees. KiCad only supports hatching 90 "
3652 "degrees apart. The imported hatching has two hatches 90 "
3653 "degrees apart, oriented %.1f degrees from horizontal." ),
3682 wxString prefix = wxEmptyString;
3683 wxString suffix = wxEmptyString;
3684 size_t startpos = aCadstarDim.
Text.
Text.Find( wxT(
"<@DISTANCE" ) );
3686 if( startpos != wxNOT_FOUND )
3689 wxString remainingStr = aCadstarDim.
Text.
Text.Mid( startpos );
3690 size_t endpos = remainingStr.Find(
"@>" );
3694 if( suffix.StartsWith( wxT(
"mm" ) ) )
3697 suffix = suffix.Mid( 2 );
3715 switch( dimensionUnits )
3720 wxLogWarning( wxString::Format(
_(
"Dimension ID %s uses a type of unit that "
3721 "is not supported in KiCad. Millimeters were "
3722 "applied instead." ),
3726 aKiCadDim->
SetUnitsMode( DIM_UNITS_MODE::MILLIMETRES );
3738 wxFAIL_MSG( wxT(
"We should have handled design units before coming here!" ) );
3745 std::map<TEMPLATE_ID, std::set<TEMPLATE_ID>> winningOverlaps;
3754 aZoneB->GetLocalClearance().value() );
3763 [&](
ZONE* aLowerZone,
ZONE* aHigherZone ) ->
double
3766 intersectShape.
Inflate( inflateValue( aLowerZone, aHigherZone ),
3776 double leftOverArea = lowerZoneFill.
Area();
3778 return leftOverArea;
3781 auto intersectionAreaOfZoneOutlines =
3782 [&](
ZONE* aZoneA,
ZONE* aZoneB ) ->
double
3785 outLineA.
Inflate( inflateValue( aZoneA, aZoneB ), CORNER_STRATEGY::ROUND_ALL_CORNERS,
3789 outLineB.
Inflate( inflateValue( aZoneA, aZoneB ), CORNER_STRATEGY::ROUND_ALL_CORNERS,
3794 return outLineA.
Area();
3798 auto isLowerPriority =
3801 return winningOverlaps[b].count( a ) > 0;
3804 for( std::map<TEMPLATE_ID, ZONE*>::iterator it1 =
m_zonesMap.begin();
3808 ZONE* thisZone = it1->second;
3813 for( std::map<TEMPLATE_ID, ZONE*>::iterator it2 = it1;
3817 ZONE* otherZone = it2->second;
3819 if( thisTemplate.
ID == otherTemplate.
ID )
3828 if( intersectionAreaOfZoneOutlines( thisZone, otherZone ) == 0 )
3837 if( thisZonePolyFill.
Area() > 0.0 && otherZonePolyFill.
Area() > 0.0 )
3840 double areaThis = errorArea( thisZone, otherZone );
3842 double areaOther = errorArea( otherZone, thisZone );
3844 if( areaThis > areaOther )
3847 winningOverlaps[thisTemplate.
ID].insert( otherTemplate.
ID );
3852 winningOverlaps[otherTemplate.
ID].insert( thisTemplate.
ID );
3855 else if( thisZonePolyFill.
Area() > 0.0 )
3858 winningOverlaps[thisTemplate.
ID].insert( otherTemplate.
ID );
3860 else if( otherZonePolyFill.
Area() > 0.0 )
3863 winningOverlaps[otherTemplate.
ID].insert( thisTemplate.
ID );
3869 if( intersectionAreaOfZoneOutlines( thisZone, otherZone ) != 0 )
3872 winningOverlaps[otherTemplate.
ID].insert( thisTemplate.
ID );
3874 winningOverlaps[thisTemplate.
ID].insert( otherTemplate.
ID );
3883 std::set<TEMPLATE_ID> intersectingIDs;
3885 for(
const std::pair<
TEMPLATE_ID, std::set<TEMPLATE_ID>>& idPair : winningOverlaps )
3887 intersectingIDs.insert( idPair.first );
3888 intersectingIDs.insert( idPair.second.begin(), idPair.second.end() );
3892 std::vector<TEMPLATE_ID> sortedIDs;
3896 sortedIDs.push_back(
id );
3900 std::sort( sortedIDs.begin(), sortedIDs.end(), isLowerPriority );
3906 if( prevID.IsEmpty() )
3912 wxASSERT( !isLowerPriority(
id, prevID ) );
3914 int newPriority =
m_zonesMap.at( prevID )->GetAssignedPriority();
3917 if( isLowerPriority( prevID,
id ) )
3920 m_zonesMap.at(
id )->SetAssignedPriority( newPriority );
3925 for(
const std::pair<
TEMPLATE_ID, std::set<TEMPLATE_ID>>& idPair : winningOverlaps )
3929 for(
const TEMPLATE_ID& losingID : idPair.second )
3931 if(
m_zonesMap.at( losingID )->GetAssignedPriority()
3932 >
m_zonesMap.at( winningID )->GetAssignedPriority() )
3966 if( aCadstarNetID.IsEmpty() )
3972 return m_netMap.at( aCadstarNetID );
3979 wxString newName = csNet.
Name;
3981 if( csNet.
Name.IsEmpty() )
3983 if( csNet.
Pins.size() > 0 )
3987 NET_PCB::PIN firstPin = ( *csNet.
Pins.begin() ).second;
3990 newName = wxT(
"Net-(" );
3992 newName << wxT(
"-Pad" ) << wxString::Format( wxT(
"%ld" ), firstPin.PadID );
3993 newName << wxT(
")" );
3997 wxFAIL_MSG( wxT(
"A net with no pins associated?" ) );
3998 newName = wxT(
"csNet-" );
3999 newName << wxString::Format( wxT(
"%i" ), csNet.
SignalNum );
4006 wxLogMessage(
_(
"The CADSTAR design contains nets with a 'Net Class' assigned. KiCad "
4007 "does not have an equivalent to CADSTAR's Net Class so these elements "
4008 "were not imported. Note: KiCad's version of 'Net Class' is closer to "
4009 "CADSTAR's 'Net Route Code' (which has been imported for all nets)." ) );
4016 wxLogWarning(
_(
"The CADSTAR design contains nets with a 'Spacing Class' assigned. "
4017 "KiCad does not have an equivalent to CADSTAR's Spacing Class so "
4018 "these elements were not imported. Please review the design rules as "
4019 "copper pours will affected by this." ) );
4025 std::shared_ptr<NETCLASS> netclass;
4027 std::tuple<ROUTECODE_ID, NETCLASS_ID, SPACING_CLASS_ID> key = { csNet.
RouteCodeID,
4037 wxString netClassName;
4040 netClassName += wxT(
"Route code: " ) + rc.
Name;
4045 netClassName += wxT(
" | Net class: " ) + nc.
Name;
4051 netClassName += wxT(
" | Spacing class: " ) + sp.
Name;
4054 netclass.reset(
new NETCLASS( *netSettings->GetDefaultNetclass() ) );
4055 netclass->SetName( netClassName );
4056 netSettings->SetNetclass( netClassName, netclass );
4062 newName, netclass->GetName() );
4066 m_netMap.insert( { aCadstarNetID, netInfo } );
4075 bool aDetectMaxLayer )
4078 return PCB_LAYER_ID::B_Cu;
4082 case 1:
return PCB_LAYER_ID::F_Cu;
4083 case 2:
return PCB_LAYER_ID::In1_Cu;
4084 case 3:
return PCB_LAYER_ID::In2_Cu;
4085 case 4:
return PCB_LAYER_ID::In3_Cu;
4086 case 5:
return PCB_LAYER_ID::In4_Cu;
4087 case 6:
return PCB_LAYER_ID::In5_Cu;
4088 case 7:
return PCB_LAYER_ID::In6_Cu;
4089 case 8:
return PCB_LAYER_ID::In7_Cu;
4090 case 9:
return PCB_LAYER_ID::In8_Cu;
4091 case 10:
return PCB_LAYER_ID::In9_Cu;
4092 case 11:
return PCB_LAYER_ID::In10_Cu;
4093 case 12:
return PCB_LAYER_ID::In11_Cu;
4094 case 13:
return PCB_LAYER_ID::In12_Cu;
4095 case 14:
return PCB_LAYER_ID::In13_Cu;
4096 case 15:
return PCB_LAYER_ID::In14_Cu;
4097 case 16:
return PCB_LAYER_ID::In15_Cu;
4098 case 17:
return PCB_LAYER_ID::In16_Cu;
4099 case 18:
return PCB_LAYER_ID::In17_Cu;
4100 case 19:
return PCB_LAYER_ID::In18_Cu;
4101 case 20:
return PCB_LAYER_ID::In19_Cu;
4102 case 21:
return PCB_LAYER_ID::In20_Cu;
4103 case 22:
return PCB_LAYER_ID::In21_Cu;
4104 case 23:
return PCB_LAYER_ID::In22_Cu;
4105 case 24:
return PCB_LAYER_ID::In23_Cu;
4106 case 25:
return PCB_LAYER_ID::In24_Cu;
4107 case 26:
return PCB_LAYER_ID::In25_Cu;
4108 case 27:
return PCB_LAYER_ID::In26_Cu;
4109 case 28:
return PCB_LAYER_ID::In27_Cu;
4110 case 29:
return PCB_LAYER_ID::In28_Cu;
4111 case 30:
return PCB_LAYER_ID::In29_Cu;
4112 case 31:
return PCB_LAYER_ID::In30_Cu;
4113 case 32:
return PCB_LAYER_ID::B_Cu;
4116 return PCB_LAYER_ID::UNDEFINED_LAYER;
4128 switch( layer.
Type )
4149 return PCB_LAYER_ID::UNDEFINED_LAYER;
4153 PCB_LAYER_ID::UNDEFINED_LAYER );
4166 return LSET( { PCB_LAYER_ID::Dwgs_User,
4167 PCB_LAYER_ID::Cmts_User,
4168 PCB_LAYER_ID::Eco1_User,
4169 PCB_LAYER_ID::Eco2_User } )
4177 |
LSET( { PCB_LAYER_ID::Dwgs_User,
4178 PCB_LAYER_ID::Cmts_User,
4179 PCB_LAYER_ID::Eco1_User,
4180 PCB_LAYER_ID::Eco2_User } )
4196 parentGroup->
AddItem( aKiCadItem );
4201 const wxString& aName )
4203 wxString groupName = aName;
4208 groupName = aName + wxT(
"_" ) + wxString::Format( wxT(
"%i" ), ++num );
4213 docSymGroup->
SetName( groupName );
4215 m_groupMap.insert( { groupID, docSymGroup } );
constexpr int ARC_HIGH_DEF
constexpr double PCB_IU_PER_MM
constexpr EDA_IU_SCALE pcbIUScale
LAYER_T
The allowed types of layers, same as Specctra DSN spec.
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
#define COMPONENT_NAME_2_ATTRID
Component Name 2 Attribute ID - typically used for indicating the placement of designators in placeme...
#define COMPONENT_NAME_ATTRID
Component Name Attribute ID - typically used for placement of designators on silk screen.
Loads a cpa file into a KiCad BOARD object.
BASE_SET & reset(size_t pos)
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
NETINFO_ITEM * GetNet() const
Return #NET_INFO object for a given item.
void SetNet(NETINFO_ITEM *aNetInfo)
Set a NET_INFO object for the item.
Container for design settings for a BOARD object.
std::shared_ptr< NET_SETTINGS > m_NetSettings
int m_CopperEdgeClearance
BOARD_STACKUP & GetStackupDescriptor()
void SetBoardThickness(int aThickness)
int GetLineThickness(PCB_LAYER_ID aLayer) const
Return the default graphic segment thickness from the layer class for the given layer.
ZONE_SETTINGS & GetDefaultZoneSettings()
int m_ViasMinAnnularWidth
Abstract interface for BOARD_ITEMs capable of storing other items inside.
virtual void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false)=0
Adds an item to the container.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
virtual void SetLocked(bool aLocked)
virtual BOARD_ITEM * Duplicate() const
Create a copy of this BOARD_ITEM.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
virtual bool IsLocked() const
Manage one layer needed to make a physical board.
void SetThickness(int aThickness, int aDielectricSubLayer=0)
void SetMaterial(const wxString &aName, int aDielectricSubLayer=0)
void SetLossTangent(double aTg, int aDielectricSubLayer=0)
void SetEpsilonR(double aEpsilon, int aDielectricSubLayer=0)
void SetLayerName(const wxString &aName)
Manage layers needed to make a physical board.
void RemoveAll()
Delete all items in list and clear the list.
const std::vector< BOARD_STACKUP_ITEM * > & GetList() const
int BuildBoardThicknessFromStackup() const
void BuildDefaultStackupList(const BOARD_DESIGN_SETTINGS *aSettings, int aActiveCopperLayersCount=0)
Create a default stackup, according to the current BOARD_DESIGN_SETTINGS settings.
Information pertinent to a Pcbnew printed circuit board.
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Changes the name of the layer given by aLayer.
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
void SetCopperLayerCount(int aCount)
bool SetLayerType(PCB_LAYER_ID aLayer, LAYER_T aLayerType)
Change the type of the layer given by aLayer.
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
@ ANTICLOCKWISE_SEMICIRCLE
static const std::map< TEXT_FIELD_NAME, wxString > CADSTAR_TO_KICAD_FIELDS
Map between CADSTAR fields and KiCad text variables.
TEXT_FIELD_NAME
These are special fields in text objects enclosed between the tokens '<@' and '>' such as <@[FIELD_NA...
@ NO_ALIGNMENT
NO_ALIGNMENT has different meaning depending on the object type.
static const long UNDEFINED_VALUE
static wxString ParseTextFields(const wxString &aTextString, PARSER_CONTEXT *aParserContext)
Replaces CADSTAR fields for the equivalent in KiCad and stores the field values in aParserContext.
wxString LAYER_ID
ID of a Sheet (if schematic) or board Layer (if PCB)
static void FixTextPositionNoAlignment(EDA_TEXT *aKiCadTextItem)
Corrects the position of a text element that had NO_ALIGNMENT in CADSTAR.
@ OUTLINE
Unfilled closed shape.
@ OPENSHAPE
Unfilled open shape. Cannot have cutouts.
@ SOLID
Filled closed shape (solid fill).
@ HATCHED
Filled closed shape (hatch fill).
static const double TXT_HEIGHT_RATIO
CADSTAR fonts are drawn on a 24x24 integer matrix, where the each axis goes from 0 to 24.
void checkPoint()
Updates m_progressReporter or throws if user cancelled.
@ DESIGN
Inherits from design units (assumed Assignments->Technology->Units)
PROGRESS_REPORTER * m_progressReporter
std::map< TEMPLATE_ID, ZONE * > m_zonesMap
Map between Cadstar and KiCad zones.
std::map< std::tuple< ROUTECODE_ID, NETCLASS_ID, SPACING_CLASS_ID >, std::shared_ptr< NETCLASS > > m_netClassMap
Map between Cadstar and KiCad classes.
bool m_doneCopperWarning
Used by loadCoppers() to avoid multiple duplicate warnings.
std::set< PADCODE_ID > m_padcodesTested
Used by getKiCadPad() to avoid multiple duplicate warnings.
int getKiCadLength(long long aCadstarLength)
void initStackupItem(const LAYER &aCadstarLayer, BOARD_STACKUP_ITEM *aKiCadItem, int aDielectricSublayer)
int m_numCopperLayers
Number of layers in the design.
std::vector< LAYER_ID > m_powerPlaneLayers
List of layers that are marked as power plane in CADSTAR.
void drawCadstarText(const TEXT &aCadstarText, BOARD_ITEM_CONTAINER *aContainer, const GROUP_ID &aCadstarGroupID=wxEmptyString, const LAYER_ID &aCadstarLayerOverride=wxEmptyString, const VECTOR2I &aMoveVector={ 0, 0 }, double aRotationAngle=0.0, double aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, bool aMirrorInvert=false)
bool isLayerSet(const LAYER_ID &aCadstarLayerID)
LAYERPAIR getLayerPair(const LAYERPAIR_ID &aCadstarLayerPairID)
FOOTPRINT * getFootprintFromCadstarID(const COMPONENT_ID &aCadstarComponentID)
PADCODE getPadCode(const PADCODE_ID &aCadstarPadCodeID)
int loadNetVia(const NET_ID &aCadstarNetID, const NET_PCB::VIA &aCadstarVia)
Load via and return via size.
EDA_ANGLE getAngle(const long long &aCadstarAngle)
std::vector< PCB_SHAPE * > getShapesFromVertices(const std::vector< VERTEX > &aCadstarVertices, BOARD_ITEM_CONTAINER *aContainer=nullptr, const GROUP_ID &aCadstarGroupID=wxEmptyString, const VECTOR2I &aMoveVector={ 0, 0 }, double aRotationAngle=0.0, double aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, bool aMirrorInvert=false)
Returns a vector of pointers to PCB_SHAPE objects.
void applyTextCode(EDA_TEXT *aKiCadText, const TEXTCODE_ID &aCadstarTextCodeID)
Apply cadstar textcode parameters to a KiCad text object.
std::map< COMPONENT_ID, FOOTPRINT * > m_componentMap
Map between Cadstar and KiCad components on the board.
SHAPE_LINE_CHAIN getLineChainFromShapes(const std::vector< PCB_SHAPE * > &aShapes)
Returns a SHAPE_LINE_CHAIN object from a series of PCB_SHAPE objects.
void applyDimensionSettings(const DIMENSION &aCadstarDim, PCB_DIMENSION_BASE *aKiCadDim)
void loadNetTracks(const NET_ID &aCadstarNetID, const NET_PCB::ROUTE &aCadstarRoute, long aStartWidth=std::numeric_limits< long >::max(), long aEndWidth=std::numeric_limits< long >::max())
ZONE * getZoneFromCadstarShape(const SHAPE &aCadstarShape, const int &aLineThickness, BOARD_ITEM_CONTAINER *aParentContainer)
PCB_LAYER_ID getKiCadCopperLayerID(unsigned int aLayerNum, bool aDetectMaxLayer=true)
std::vector< PCB_TRACK * > makeTracksFromShapes(const std::vector< PCB_SHAPE * > &aShapes, BOARD_ITEM_CONTAINER *aParentContainer, NETINFO_ITEM *aNet=nullptr, PCB_LAYER_ID aLayerOverride=UNDEFINED_LAYER, int aWidthOverride=-1)
Returns a vector of pointers to TRACK/ARC objects.
VIACODE getViaCode(const VIACODE_ID &aCadstarViaCodeID)
VECTOR2I m_designCenter
Used for calculating the required offset to apply to the Cadstar design so that it fits in KiCad canv...
void Load(BOARD *aBoard, PROJECT *aProject)
Loads a CADSTAR PCB Archive file into the KiCad BOARD object given.
void drawCadstarCutoutsAsShapes(const std::vector< CUTOUT > &aCutouts, const PCB_LAYER_ID &aKiCadLayer, int aLineThickness, BOARD_ITEM_CONTAINER *aContainer, const GROUP_ID &aCadstarGroupID=wxEmptyString, const VECTOR2I &aMoveVector={ 0, 0 }, double aRotationAngle=0.0, double aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, bool aMirrorInvert=false)
Uses PCB_SHAPEs to draw the cutouts on m_board object.
void logBoardStackupWarning(const wxString &aCadstarLayerName, const PCB_LAYER_ID &aKiCadLayer)
std::vector< FOOTPRINT * > GetLoadedLibraryFootpints() const
Return a copy of the loaded library footprints (caller owns the objects)
PCB_SHAPE * getShapeFromVertex(const POINT &aCadstarStartPoint, const VERTEX &aCadstarVertex, BOARD_ITEM_CONTAINER *aContainer=nullptr, const GROUP_ID &aCadstarGroupID=wxEmptyString, const VECTOR2I &aMoveVector={ 0, 0 }, double aRotationAngle=0.0, double aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, bool aMirrorInvert=false)
Returns a pointer to a PCB_SHAPE object.
void checkAndLogHatchCode(const HATCHCODE_ID &aCadstarHatchcodeID)
bool m_doneSpacingClassWarning
Used by getKiCadNet() to avoid multiple duplicate warnings.
int m_numNets
Number of nets loaded so far.
void loadDocumentationSymbols()
void loadLibraryPads(const SYMDEF_PCB &aComponent, FOOTPRINT *aFootprint)
void loadComponentLibrary()
PAD * getKiCadPad(const COMPONENT_PAD &aCadstarPad, FOOTPRINT *aParent)
void drawCadstarShape(const SHAPE &aCadstarShape, const PCB_LAYER_ID &aKiCadLayer, int aLineThickness, const wxString &aShapeName, BOARD_ITEM_CONTAINER *aContainer, const GROUP_ID &aCadstarGroupID=wxEmptyString, const VECTOR2I &aMoveVector={ 0, 0 }, double aRotationAngle=0.0, double aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, bool aMirrorInvert=false)
NETINFO_ITEM * getKiCadNet(const NET_ID &aCadstarNetID)
Searches m_netMap and returns the NETINFO_ITEM pointer if exists.
void logBoardStackupMessage(const wxString &aCadstarLayerName, const PCB_LAYER_ID &aKiCadLayer)
int getLineThickness(const LINECODE_ID &aCadstarLineCodeID)
bool m_doneTearDropWarning
std::map< NET_ID, NETINFO_ITEM * > m_netMap
Map between Cadstar and KiCad Nets.
void loadComponentAttributes(const COMPONENT &aComponent, FOOTPRINT *aFootprint)
PCB_GROUP * getKiCadGroup(const GROUP_ID &aCadstarGroupID)
bool m_logLayerWarnings
Used in loadBoardStackup()
HATCHCODE getHatchCode(const HATCHCODE_ID &aCadstarHatchcodeID)
void loadLibraryCoppers(const SYMDEF_PCB &aComponent, FOOTPRINT *aFootprint)
LAYER_TYPE getLayerType(const LAYER_ID aCadstarLayerID)
void loadLibraryFigures(const SYMDEF_PCB &aComponent, FOOTPRINT *aFootprint)
TEXTCODE getTextCode(const TEXTCODE_ID &aCadstarTextCodeID)
wxString getAttributeName(const ATTRIBUTE_ID &aCadstarAttributeID)
wxString getAttributeValue(const ATTRIBUTE_ID &aCadstarAttributeID, const std::map< ATTRIBUTE_ID, ATTRIBUTE_VALUE > &aCadstarAttributeMap)
void applyRouteOffset(VECTOR2I *aPointToOffset, const VECTOR2I &aRefPoint, const long &aOffsetAmount)
CADSTAR's Post Processor does an action called "Route Offset" which is applied when a route is wider ...
VECTOR2I getKiCadPoint(const VECTOR2I &aCadstarPoint)
Scales, offsets and inverts y axis to make the point usable directly in KiCad.
void remapUnsureLayers()
Callback m_layerMappingHandler for layers we aren't sure of.
double getAngleTenthDegree(const long long &aCadstarAngle)
LSET getKiCadLayerSet(const LAYER_ID &aCadstarLayerID)
void addToGroup(const GROUP_ID &aCadstarGroupID, BOARD_ITEM *aKiCadItem)
std::map< SYMDEF_ID, FOOTPRINT * > m_libraryMap
Map between Cadstar and KiCad components in the library.
COPPERCODE getCopperCode(const COPPERCODE_ID &aCadstaCopperCodeID)
SHAPE_POLY_SET getPolySetFromCadstarShape(const SHAPE &aCadstarShape, int aLineThickness=-1, BOARD_ITEM_CONTAINER *aContainer=nullptr, const VECTOR2I &aMoveVector={ 0, 0 }, double aRotationAngle=0.0, double aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, bool aMirrorInvert=false)
Returns a SHAPE_POLY_SET object from a Cadstar SHAPE.
std::map< PAD_ID, std::vector< PAD_ID > > ASSOCIATED_COPPER_PADS
Map of pad anchor points (first) to copper pads (second).
EDA_ANGLE getHatchCodeAngle(const HATCHCODE_ID &aCadstarHatchcodeID)
int getKiCadHatchCodeThickness(const HATCHCODE_ID &aCadstarHatchcodeID)
PCB_LAYER_ID getKiCadLayer(const LAYER_ID &aCadstarLayerID)
std::set< HATCHCODE_ID > m_hatchcodesTested
Used by checkAndLogHatchCode() to avoid multiple duplicate warnings.
void loadLibraryAreas(const SYMDEF_PCB &aComponent, FOOTPRINT *aFootprint)
GROUP_ID createUniqueGroupID(const wxString &aName)
Adds a new PCB_GROUP* to m_groupMap.
int getKiCadHatchCodeGap(const HATCHCODE_ID &aCadstarHatchcodeID)
std::vector< std::unique_ptr< FOOTPRINT > > LoadLibrary()
Parse a CADSTAR PCB Archive and load the footprints contained within.
ROUTECODE getRouteCode(const ROUTECODE_ID &aCadstarRouteCodeID)
void drawCadstarVerticesAsShapes(const std::vector< VERTEX > &aCadstarVertices, const PCB_LAYER_ID &aKiCadLayer, int aLineThickness, BOARD_ITEM_CONTAINER *aContainer, const GROUP_ID &aCadstarGroupID=wxEmptyString, const VECTOR2I &aMoveVector={ 0, 0 }, double aRotationAngle=0.0, double aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, bool aMirrorInvert=false)
Uses PCB_SHAPE to draw the vertices on m_board object.
void addAttribute(const ATTRIBUTE_LOCATION &aCadstarAttrLoc, const ATTRIBUTE_ID &aCadstarAttributeID, FOOTPRINT *aFootprint, const wxString &aAttributeValue)
Adds a CADSTAR Attribute to a KiCad footprint.
std::map< GROUP_ID, PCB_GROUP * > m_groupMap
Map between Cadstar and KiCad groups.
bool calculateZonePriorities(PCB_LAYER_ID &aLayer)
Tries to make a best guess as to the zone priorities based on the pour status.
std::map< LAYER_ID, PCB_LAYER_ID > m_layermap
Map between Cadstar and KiCad Layers.
PAD *& getPadReference(FOOTPRINT *aFootprint, const PAD_ID aCadstarPadID)
bool m_doneNetClassWarning
Used by getKiCadNet() to avoid multiple duplicate warnings.
double getAngleDegrees(const long long &aCadstarAngle)
PART getPart(const PART_ID &aCadstarPartID)
LAYER_MAPPING_HANDLER m_layerMappingHandler
Callback to get layer mapping.
std::map< SYMDEF_ID, ASSOCIATED_COPPER_PADS > m_librarycopperpads
Associated copper pads (if any) for each component library definition.
long PAD_ID
Pad identifier (pin) in the PCB.
@ LAYERSUBTYPE_SOLDERRESIST
@ LAYERSUBTYPE_SILKSCREEN
void Parse(bool aLibrary=false)
Parses the file.
int KiCadUnitMultiplier
Use this value to convert units in this CPA file to KiCad units.
@ UNDEFINED
Only used for error detection.
@ ALLELEC
Inbuilt layer type (cannot be assigned to user layers)
@ ALLDOC
Inbuilt layer type (cannot be assigned to user layers)
@ NONELEC
This type has subtypes.
@ NOLAYER
Inbuilt layer type (cannot be assigned to user layers)
@ JUMPERLAYER
Inbuilt layer type (cannot be assigned to user layers)
@ ALLLAYER
Inbuilt layer type (cannot be assigned to user layers)
@ ASSCOMPCOPP
Inbuilt layer type (cannot be assigned to user layers)
@ ROUNDED_RECT
Keyword "ROUNDED".
@ MAXIMUM
The highest PHYSICAL_LAYER_ID currently defined (i.e.
@ MINIMUM
PHYSICAL_LAYER_ID 1 (i.e.
@ THROUGH_HOLE
All physical layers currently defined.
EDA_ANGLE NormalizeNegative()
void SetCenter(const VECTOR2I &aCenter)
SHAPE_POLY_SET & GetPolyShape()
void SetPolyShape(const SHAPE_POLY_SET &aShape)
virtual void SetFilled(bool aFlag)
void SetStart(const VECTOR2I &aStart)
void SetShape(SHAPE_T aShape)
void SetEnd(const VECTOR2I &aEnd)
void SetArcAngleAndEnd(const EDA_ANGLE &aAngle, bool aCheckNegativeAngle=false)
Set the end point from the angle center and start.
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
const EDA_ANGLE & GetTextAngle() const
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
virtual const wxString & GetText() const
Return the string associated with the text object.
void SetTextPos(const VECTOR2I &aPoint)
void SetMirrored(bool isMirrored)
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
virtual void SetVisible(bool aVisible)
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
void SetKeepUpright(bool aKeepUpright)
virtual void SetText(const wxString &aText)
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
int GetTextThickness() const
VECTOR2I GetTextSize() const
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
A logical library item identifier and consists of various portions much like a URI.
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
const UTF8 & GetLibItemName() const
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
LSET is a set of PCB_LAYER_IDs.
static LSET AllBoardTechMask()
Return a mask holding board technical layers (no CU layer) on both side.
static LSET AllLayersMask()
static LSET UserDefinedLayers()
Return a mask with all of the allowable user defined layers.
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
bool Contains(PCB_LAYER_ID aLayer) const
See if the layer set contains a PCB layer.
Handle the data for a net.
void SetNetClass(const std::shared_ptr< NETCLASS > &aNetClass)
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
const wxString & GetNumber() const
void SetNumber(const wxString &aNumber)
Set the pad number (note that it can be alphanumeric, such as the array reference "AA12").
void SetUnitsFormat(const DIM_UNITS_FORMAT aFormat)
void SetPrefix(const wxString &aPrefix)
void SetExtensionOffset(int aOffset)
void SetSuffix(const wxString &aSuffix)
void SetLineThickness(int aWidth)
virtual const VECTOR2I & GetStart() const
The dimension's origin is the first feature point for the dimension.
virtual void SetEnd(const VECTOR2I &aPoint)
void SetPrecision(DIM_PRECISION aPrecision)
virtual void SetStart(const VECTOR2I &aPoint)
void SetOverrideText(const wxString &aValue)
void SetUnitsMode(DIM_UNITS_MODE aMode)
For better understanding of the points that make a dimension:
void SetExtensionHeight(int aHeight)
void SetHeight(int aHeight)
Set the distance from the feature points to the crossbar line.
A leader is a dimension-like object pointing to a specific point.
An orthogonal dimension is like an aligned dimension, but the extension lines are locked to the X or ...
void SetOrientation(DIR aOrientation)
Set the orientation of the dimension line (so, perpendicular to the feature lines).
A set of BOARD_ITEMs (i.e., without duplicates).
void SetName(const wxString &aName)
virtual bool AddItem(BOARD_ITEM *aItem)
Add item to group.
void SetLocked(bool aLocked) override
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void Move(const VECTOR2I &aMoveVector) override
Move this object.
void Scale(double aScale)
void SetStroke(const STROKE_PARAMS &aStroke) override
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
virtual void SetPosition(const VECTOR2I &aPos) override
void Move(const VECTOR2I &aMoveVector) override
Move this object.
void SetEnd(const VECTOR2I &aEnd)
void SetStart(const VECTOR2I &aStart)
const VECTOR2I & GetStart() const
const VECTOR2I & GetEnd() const
virtual void SetWidth(int aWidth)
virtual int GetWidth() const
virtual void SetNumPhases(int aNumPhases)=0
Set the number of phases.
virtual void BeginPhase(int aPhase)=0
Initialize the aPhase virtual zone of the dialog progress bar.
virtual void SetMaxProgress(int aMaxProgress)=0
Fix the value that gives the 100 percent progress bar length (inside the current virtual zone).
Container for project specific data.
virtual std::map< wxString, wxString > & GetTextVars() const
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
virtual const VECTOR2I GetPoint(int aIndex) const override
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
int PointCount() const
Return the number of points (vertices) in this line chain.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
Represent a set of closed polygons.
void BooleanAdd(const SHAPE_POLY_SET &b)
Perform boolean polyset union.
void ClearArcs()
Removes all arc references from all the outlines and holes in the polyset.
double Area()
Return the area of this poly set.
void Fracture()
Convert a set of polygons with holes to a single outline with "slits"/"fractures" connecting the oute...
void Inflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError, bool aSimplify=false)
Perform outline inflation/deflation.
int HoleCount(int aOutline) const
Returns the number of holes in a given outline.
int AddHole(const SHAPE_LINE_CHAIN &aHole, int aOutline=-1)
Adds a new hole to the given outline (default: last) and returns its index.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
SHAPE_LINE_CHAIN & Hole(int aOutline, int aHole)
Return the reference to aHole-th hole in the aIndex-th outline.
void BooleanIntersection(const SHAPE_POLY_SET &b)
Perform boolean polyset intersection.
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
int OutlineCount() const
Return the number of outlines in the set.
void Move(const VECTOR2I &aVector) override
bool Contains(const VECTOR2I &aP, int aSubpolyIndex=-1, int aAccuracy=0, bool aUseBBoxCaches=false) const
Return true if a given subpolygon contains the point aP.
void BooleanSubtract(const SHAPE_POLY_SET &b)
Perform boolean polyset difference.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
Simple container to manage line stroke parameters.
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
EDA_ANGLE m_HatchOrientation
Handle a list of polygons defining a copper zone.
void SetHatchThickness(int aThickness)
void SetNeedRefill(bool aNeedRefill)
void SetDoNotAllowPads(bool aEnable)
std::optional< int > GetLocalClearance() const override
void SetLocalClearance(std::optional< int > aClearance)
void AddPolygon(std::vector< VECTOR2I > &aPolygon)
Add a polygon to the zone outline.
const std::shared_ptr< SHAPE_POLY_SET > & GetFilledPolysList(PCB_LAYER_ID aLayer) const
void SetMinThickness(int aMinThickness)
void SetHatchOrientation(const EDA_ANGLE &aStep)
void SetDoNotAllowCopperPour(bool aEnable)
void SetThermalReliefSpokeWidth(int aThermalReliefSpokeWidth)
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
SHAPE_POLY_SET * Outline()
void SetHatchStyle(ZONE_BORDER_DISPLAY_STYLE aStyle)
SHAPE_POLY_SET * GetFill(PCB_LAYER_ID aLayer)
void SetIsRuleArea(bool aEnable)
void SetDoNotAllowTracks(bool aEnable)
void SetFilledPolysList(PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPolysList)
Set the list of filled polygons.
void SetIsFilled(bool isFilled)
void SetFillMode(ZONE_FILL_MODE aFillMode)
bool HasFilledPolysForLayer(PCB_LAYER_ID aLayer) const
void SetLayerSet(const LSET &aLayerSet) override
void SetDoNotAllowVias(bool aEnable)
void SetThermalReliefGap(int aThermalReliefGap)
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
void SetDoNotAllowFootprints(bool aEnable)
void SetAssignedPriority(unsigned aPriority)
void SetPadConnection(ZONE_CONNECTION aPadConnection)
void SetZoneName(const wxString &aName)
void SetIslandRemovalMode(ISLAND_REMOVAL_MODE aRemove)
void SetMinIslandArea(long long int aArea)
void SetHatchGap(int aStep)
void TransformArcToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc)
Convert arc to multiple straight segments.
void TransformOvalToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a oblong shape to a polygon, using multiple segments.
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_180
#define DEFAULT_SIZE_TEXT
This is the "default-of-the-default" hardcoded text size; individual application define their own def...
#define THROW_IO_ERROR(msg)
PCB_LAYER_ID
A quick note on layer IDs:
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
constexpr int Mils2IU(const EDA_IU_SCALE &aIuScale, int mils)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Class to handle a set of BOARD_ITEMs.
ALIGNMENT Alignment
In CADSTAR The default alignment for a TEXT object (when "(No Alignment()" is selected) Bottom Left o...
ATTRIBUTE_LOCATION AttributeLocation
bool HasLocation
Flag to know if this ATTRIBUTE_VALUE has a location i.e.
std::map< SPACING_CLASS_ID, SPCCLASSNAME > SpacingClassNames
std::map< LINECODE_ID, LINECODE > LineCodes
std::map< NETCLASS_ID, CADSTAR_NETCLASS > NetClasses
std::map< HATCHCODE_ID, HATCHCODE > HatchCodes
std::map< ATTRIBUTE_ID, ATTRNAME > AttributeNames
std::map< ROUTECODE_ID, ROUTECODE > RouteCodes
std::map< TEXTCODE_ID, TEXTCODE > TextCodes
Represents a cutout in a closed shape (e.g.
std::vector< VERTEX > Vertices
long ScaleRatioNumerator
Documentation symbols can be arbitrarily scaled when added to a design.
long ScaleRatioDenominator
Documentation symbols can be arbitrarily scaled when added to a design.
POINT Origin
Origin of the component (this is used as the reference point when placing the component in the design...
LAYER_ID LayerID
Move all objects in the Symdef to this layer.
SYMDEF_ID SymdefID
Normally documentation symbols only have TEXT, FIGURE and TEXT_LOCATION objects which are all drawn o...
GROUP_ID GroupID
If not empty, this GROUP is part of another GROUP.
std::vector< HATCH > Hatches
ROUTECODE_ID RouteCodeID
"NETCODE" subnode
wxString Name
This is undefined (wxEmptyString) if the net is unnamed.
NETCLASS_ID NetClassID
The net might not have a net class, in which case it will be wxEmptyString ("NETCLASSREF" subnode)
SPACING_CLASS_ID SpacingClassID
The net might not have a spacing class, in which case it will be wxEmptyString ("SPACINGCLASS" subnod...
long SignalNum
This is undefined if the net has been given a name.
std::map< TEXT_FIELD_NAME, wxString > TextFieldToValuesMap
Values for the text field elements used in the CADSTAR design extracted from the text element instanc...
std::map< wxString, wxString > FilenamesToTextMap
CADSTAR doesn't have user defined text fields but does allow loading text from a file.
std::set< TEXT_FIELD_NAME > InconsistentTextFields
Text fields need to be updated in CADSTAR and it is possible that they are not consistent across text...
std::map< PART_ID, PART > PartDefinitions
wxString Name
This name can be different to the PART name.
std::map< PART_DEFINITION_PIN_ID, PIN > Pins
Represents a point in x,y coordinates.
UNITS Units
Units to display for linear dimensions.
std::pair< POINT, POINT > DesignArea
long UnitDisplPrecision
Number of decimal points to display for linear dimensions.
std::vector< VERTEX > Vertices
wxString HatchCodeID
Only Applicable for HATCHED Type.
std::vector< CUTOUT > Cutouts
Not Applicable to OPENSHAPE Type.
std::map< FIGURE_ID, FIGURE > Figures
POINT Origin
Origin of the component (this is used as the reference point when placing the component in the design...
wxString Alternate
This is in addition to ReferenceName.
std::map< TEXT_ID, TEXT > Texts
wxString ReferenceName
This is the name which identifies the symbol in the library Multiple components may exist with the sa...
wxString BuildLibName() const
long Width
Defaults to 0 if using system fonts or, if using CADSTAR font, default to equal height (1:1 aspect ra...
Corresponds to CADSTAR "origin".
ALIGNMENT Alignment
In CADSTAR The default alignment for a TEXT object (when "(No Alignment()" is selected) Bottom Left o...
std::map< VARIANT_ID, VARIANT > Variants
< Nodename = "VARIANT" or "VMASTER" (master variant
Represents a vertex in a shape.
From CADSTAR Help: "Area is for creating areas within which, and nowhere else, certain operations are...
bool Keepout
From CADSTAR Help: "Auto Placement cannot place components within this area.
bool Placement
From CADSTAR Help: "Auto Placement can place components within this area.
bool NoVias
From CADSTAR Help: "No vias will be placed within this area by the automatic router.
bool Routing
From CADSTAR Help: "Area can be used to place routes during Automatic Routing.
bool NoTracks
From CADSTAR Help: "Area cannot be used to place routes during automatic routing.
TECHNOLOGY_SECTION Technology
GROUP_ID GroupID
Normally CADSTAR_BOARD cannot be part of a reuseblock, but included for completeness.
long OrientAngle
1/1000 of a Degree
std::map< COPPERCODE_ID, COPPERCODE > CopperCodes
std::map< PADCODE_ID, PADCODE > PadCodes
std::map< VIACODE_ID, VIACODE > ViaCodes
std::map< SPACINGCODE_ID, SPACINGCODE > SpacingCodes
Spacing Design Rules.
std::map< LAYERPAIR_ID, LAYERPAIR > LayerPairs
Default vias to use between pairs of layers.
From CADSTAR Help: "Area is for creating areas within which, and nowhere else, certain operations are...
bool NoVias
From CADSTAR Help: "Check this button to specify that any area created by the Rectangle,...
bool NoTracks
From CADSTAR Help: "Check this button to specify that any area created by the Rectangle,...
A shape of copper in the component footprint.
std::vector< PAD_ID > AssociatedPadIDs
COPPERCODE_ID CopperCodeID
bool PCBonlyPad
From CADSTAR Help: "The PCB Only Pad property can be used to stop ECO Update, Back Annotation,...
PAD_EXITS Exits
See PAD_EXITS.
POINT Position
Pad position within the component's coordinate frame.
wxString Identifier
This is an identifier that is displayed to the user.
PAD_SIDE Side
See PAD_SIDE.
wxString Name
Designator e.g. "C1", "R1", etc.
POINT Origin
Origin of the component (this is used as the reference point when placing the component in the design...
std::map< ATTRIBUTE_ID, ATTRIBUTE_VALUE > AttributeValues
std::map< PAD_ID, PADEXCEPTION > PadExceptions
Override pad definitions for this instance.
std::map< ATTRIBUTE_ID, TEXT_LOCATION > TextLocations
This contains location of any attributes, including designator position.
COMPONENT_ID VariantParentComponentID
COPPERCODE_ID CopperCodeID
TEMPLATE_ID PouredTemplateID
If not empty, it means this COPPER is part of a poured template.
long Offset
Offset from the measurement point.
long Overshoot
Overshoot of the extension line past the arrow line.
long LeaderLineExtensionLength
Only for TYPE=LEADERLINE Length of the horizontal part of the leader line [param6].
LINECODE_ID LineCodeID
param0
long LeaderLineLength
Only for TYPE=LEADERLINE Length of the angled part of the leader line [param5].
long LeaderAngle
Only for TYPE=LEADERLINE subnode "LEADERANG".
STYLE Style
Subnode="DIMLINETYPE".
Linear, leader (radius/diameter) or angular dimension.
LAYER_ID LayerID
ID on which to draw this [param1].
EXTENSION_LINE ExtensionLineParams
Not applicable to TYPE=LEADERDIM.
DIMENSION_ID ID
Some ID (doesn't seem to be used) subnode="DIMREF".
long Precision
Number of decimal points to display in the measurement [param3].
std::vector< LAYER_ID > LayerStack
std::map< MATERIAL_ID, MATERIAL > Materials
std::map< LAYER_ID, LAYER > Layers
PHYSICAL_LAYER_ID PhysicalLayerStart
PHYSICAL_LAYER_ID PhysicalLayerEnd
long Thickness
Note: Units of length are defined in file header.
std::map< TEMPLATE_ID, TEMPLATE > Templates
std::map< BOARD_ID, CADSTAR_BOARD > Boards
Normally CADSTAR only allows one board but.
std::map< TEXT_ID, TEXT > Texts
std::map< NET_ID, NET_PCB > Nets
Contains tracks and vias.
std::map< FIGURE_ID, FIGURE > Figures
VARIANT_HIERARCHY VariantHierarchy
std::map< COMPONENT_ID, COMPONENT > Components
std::map< COPPER_ID, COPPER > Coppers
std::map< DOCUMENTATION_SYMBOL_ID, DOCUMENTATION_SYMBOL > DocumentationSymbols
std::map< TRUNK_ID, TRUNK > Trunks
std::map< DIMENSION_ID, DIMENSION > Dimensions
std::map< REUSEBLOCK_ID, REUSEBLOCK > ReuseBlocks
std::map< AREA_ID, AREA > Areas
std::map< GROUP_ID, GROUP > Groups
std::map< SYMDEF_ID, SYMDEF_PCB > ComponentDefinitions
std::vector< CONNECTION_PCB > Connections
std::map< NETELEMENT_ID, VIA > Vias
std::map< NETELEMENT_ID, PIN > Pins
std::map< NETELEMENT_ID, JUNCTION_PCB > Junctions
long ReliefWidth
if undefined inherits from design
std::map< LAYER_ID, CADSTAR_PAD_SHAPE > Reassigns
long ReliefClearance
if undefined inherits from design
PADCODE_ID PadCode
If not empty, override padcode.
std::map< PAD_ID, COMPONENT_PAD > ComponentPads
std::vector< COMPONENT_COPPER > ComponentCoppers
std::map< COMP_AREA_ID, COMPONENT_AREA > ComponentAreas
long MinRouteWidth
Manufacturing Design Rule. Corresponds to "Thin Route Width".
long MaxPhysicalLayer
Should equal number of copper layers.
long AdditionalIsolation
This is the gap to apply in routes and pads in addition to the existing pad-to-copper or route-to-cop...
bool ThermalReliefOnVias
false when subnode "NOVIARELIEF" is present
HATCHCODE_ID HatchCodeID
Only for FillType = HATCHED.
bool ThermalReliefOnPads
false when subnode "NOPINRELIEF" is present
long ThermalReliefPadsAngle
Orientation for the thermal reliefs.
long MinDisjointCopper
The value is the length of one side of a notional square.
bool AutomaticRepour
true when subnode "REGENERATE" is present
bool AllowInNoRouting
true when subnode "IGNORETRN" is present
bool BoxIsolatedPins
true when subnode "BOXPINS" is present
long ClearanceWidth
Specifies the space around pads when pouring (i.e.
COPPERCODE_ID ReliefCopperCodeID
From CADSTAR Help: "Relief Copper Code is for selecting the width of line used to draw the thermal re...
COPPER_FILL_TYPE FillType
Assume solid fill.
COPPERCODE_ID CopperCodeID
From CADSTAR Help: "Copper Code is for selecting the width of the line used to draw the outline and f...
long ThermalReliefViasAngle
Disabled when !ThermalReliefOnVias (param6)
long MinIsolatedCopper
The value is the length of one side of a notional square.
long SliverWidth
Minimum width of copper that may be created.
Templates are CADSTAR's equivalent to a "filled zone".
POURING Pouring
Copper pour settings (e.g. relief / hatching /etc.)
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
double DEG2RAD(double deg)
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
VECTOR2< int32_t > VECTOR2I