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 =
764 [&]( wxString aID, std::shared_ptr<NETCLASS>& aNetClassPtr )
767 applyRule( aID, &value );
770 aNetClassPtr->SetClearance( value );
773 applyNetClassRule(
"T_T", bds.
m_NetSettings->m_DefaultNetClass );
775 wxLogWarning(
_(
"KiCad design rules are different from CADSTAR ones. Only the compatible "
776 "design rules were imported. It is recommended that you review the design "
777 "rules that have been applied." ) );
793 if( component.
Figures.size() > 0 )
796 componentLayer = firstFigure.
LayerID;
798 else if( component.
Texts.size() > 0 )
800 TEXT firstText = component.
Texts.begin()->second;
801 componentLayer = firstText.
LayerID;
824 m_libraryMap.insert( std::make_pair( key, footprint ) );
832 for( std::pair<FIGURE_ID, FIGURE> figPair : aComponent.
Figures )
834 FIGURE& fig = figPair.second;
838 wxString::Format( wxT(
"Component %s:%s -> Figure %s" ),
850 int totalCopperPads = 0;
883 std::unique_ptr<PAD>
pad = std::make_unique<PAD>( aFootprint );
884 pad->SetKeepTopBottom(
false );
885 pad->SetAttribute( PAD_ATTRIB::SMD );
886 pad->SetLayerSet(
LSET( 1, copperLayer ) );
888 ? wxString::Format( wxT(
"%ld" ), anchorPad.
ID )
898 if( anchorSize <= 0 )
901 pad->SetShape( PAD_SHAPE::CUSTOM );
902 pad->SetAnchorPadShape( PAD_SHAPE::CIRCLE );
903 pad->SetSize( { anchorSize, anchorSize } );
904 pad->SetPosition( anchorPos );
909 shapePolys.
Move( -anchorPos );
910 pad->AddPrimitivePoly( shapePolys, 0,
true );
921 aFootprint->
Add(
pad.release(), ADD_MODE::APPEND );
930 wxString::Format( wxT(
"Component %s:%s -> Copper element" ),
941 for( std::pair<COMP_AREA_ID, COMPONENT_AREA> areaPair : aComponent.
ComponentAreas )
947 int lineThickness = 0;
950 aFootprint->
Add( zone, ADD_MODE::APPEND );
972 libName << wxT(
" (" ) << aComponent.
Alternate << wxT(
")" );
975 wxString::Format(
_(
"The CADSTAR area '%s' in library component '%s' does not "
976 "have a KiCad equivalent. The area is neither a via nor "
977 "route keepout area. The area was not imported." ),
978 area.
ID, libName ) );
987 for( std::pair<PAD_ID, COMPONENT_PAD> padPair : aComponent.
ComponentPads )
990 aFootprint->
Add(
pad, ADD_MODE::APPEND );
1001 std::unique_ptr<PAD>
pad = std::make_unique<PAD>( aParent );
1004 switch( aCadstarPad.
Side )
1019 wxFAIL_MSG( wxT(
"Unknown Pad type" ) );
1022 pad->SetAttribute( PAD_ATTRIB::SMD );
1023 pad->SetLocalSolderMaskMargin( 0 );
1024 pad->SetLocalSolderPasteMargin( 0 );
1025 pad->SetLocalSolderPasteMarginRatio( 0.0 );
1026 bool complexPadErrorLogged =
false;
1028 for(
auto& reassign : csPadcode.
Reassigns )
1033 if( shape.
Size == 0 )
1035 padLayerSet.reset( kiLayer );
1044 pad->SetLocalSolderMaskMargin( newMargin );
1049 pad->SetLocalSolderPasteMargin( newMargin );
1055 if( !complexPadErrorLogged )
1057 complexPadErrorLogged =
true;
1061 _(
"The CADSTAR pad definition '%s' is a complex pad stack, "
1062 "which is not supported in KiCad. Please review the "
1063 "imported pads as they may require manual correction." ),
1070 pad->SetLayerSet( padLayerSet );
1077 pad->SetNumber( wxT(
"" ) );
1082 ? wxString::Format( wxT(
"%ld" ), aCadstarPad.
ID )
1094 pad->SetAttribute( PAD_ATTRIB::SMD );
1109 pad->SetShape( PAD_SHAPE::CIRCLE );
1115 pad->SetShape( PAD_SHAPE::CHAMFERED_RECT );
1120 pad->SetChamferPositions( RECT_CHAMFER_POSITIONS::RECT_CHAMFER_BOTTOM_LEFT
1121 | RECT_CHAMFER_POSITIONS::RECT_CHAMFER_TOP_LEFT );
1122 pad->SetRoundRectRadiusRatio( 0.5 );
1123 pad->SetChamferRectRatio( 0.0 );
1130 pad->SetShape( PAD_SHAPE::CIRCLE );
1140 pad->SetShape( PAD_SHAPE::RECTANGLE );
1141 pad->SetChamferRectRatio( 0.5 );
1142 pad->SetSize( { sizeOfSquare, sizeOfSquare } );
1150 pad->SetShape( PAD_SHAPE::OVAL );
1161 pad->SetShape( PAD_SHAPE::CHAMFERED_RECT );
1162 pad->SetChamferPositions( RECT_CHAMFER_POSITIONS::RECT_CHAMFER_ALL );
1163 pad->SetChamferRectRatio( 0.25 );
1169 pad->SetShape( PAD_SHAPE::RECTANGLE );
1180 pad->SetShape( PAD_SHAPE::ROUNDRECT );
1193 pad->SetShape( PAD_SHAPE::RECTANGLE );
1199 wxFAIL_MSG( wxT(
"Unknown Pad Shape" ) );
1212 pad->SetDrillShape( PAD_DRILL_SHAPE_T::PAD_DRILL_SHAPE_OBLONG );
1219 pad->SetDrillShape( PAD_DRILL_SHAPE_T::PAD_DRILL_SHAPE_CIRCLE );
1228 pad->SetAttribute( PAD_ATTRIB::PTH );
1230 pad->SetAttribute( PAD_ATTRIB::NPTH );
1234 pad->SetDrillSize( { 0, 0 } );
1239 LSET lset =
pad->GetLayerSet();
1242 if( lset.size() > 0 )
1248 pad->SetPosition( { 0, 0 } );
1249 pad->TransformShapeToPolygon( padOutline, layer, 0, maxError,
ERROR_INSIDE );
1252 padShape->
SetShape( SHAPE_T::POLY );
1256 padShape->
Move( padOffset - drillOffset );
1261 if( editedPadOutline.
Contains( { 0, 0 } ) )
1263 pad->SetAnchorPadShape( PAD_SHAPE::RECTANGLE );
1265 pad->SetShape( PAD_SHAPE::CUSTOM );
1266 pad->AddPrimitive( padShape );
1267 padOffset = { 0, 0 };
1274 drillOffset = { 0, 0 };
1279 _(
"The CADSTAR pad definition '%s' has the hole shape outside the "
1280 "pad shape. The hole has been moved to the center of the pad." ),
1286 wxFAIL_MSG( wxT(
"No copper layers defined in the pad?" ) );
1288 pad->SetOffset( drillOffset );
1293 pad->SetOffset( drillOffset );
1309 wxLogError(
_(
"The CADSTAR pad definition '%s' has import errors: %s" ),
1316 pad->SetKeepTopBottom(
false );
1318 return pad.release();
1323 const PAD_ID aCadstarPadID )
1325 size_t index = aCadstarPadID - (long) 1;
1327 if( !( index < aFootprint->Pads().size() ) )
1329 THROW_IO_ERROR( wxString::Format(
_(
"Unable to find pad index '%d' in footprint '%s'." ),
1330 (
long) aCadstarPadID,
1334 return aFootprint->
Pads().at( index );
1340 for( std::pair<GROUP_ID, GROUP> groupPair :
Layout.
Groups )
1342 GROUP& csGroup = groupPair.second;
1354 for( std::pair<GROUP_ID, GROUP> groupPair :
Layout.
Groups )
1356 GROUP& csGroup = groupPair.second;
1358 if( !csGroup.
GroupID.IsEmpty() )
1362 THROW_IO_ERROR( wxString::Format(
_(
"Unable to find group ID %s in the group "
1368 THROW_IO_ERROR( wxString::Format(
_(
"Unable to find sub group %s in the group "
1369 "map (parent group ID=%s, Name=%s)." ),
1378 parentGroup->
AddItem( kiCadGroup );
1387 for( std::pair<BOARD_ID, CADSTAR_BOARD> boardPair :
Layout.
Boards )
1393 wxString::Format( wxT(
"BOARD %s" ), board.
ID ),
1396 if( !board.
GroupID.IsEmpty() )
1408 for( std::pair<FIGURE_ID, FIGURE> figPair :
Layout.
Figures )
1410 FIGURE& fig = figPair.second;
1413 wxString::Format( wxT(
"FIGURE %s" ), fig.
ID ),
1425 for( std::pair<TEXT_ID, TEXT> txtPair :
Layout.
Texts )
1427 TEXT& csTxt = txtPair.second;
1439 switch( csDim.
Type )
1441 case DIMENSION::TYPE::LINEARDIM:
1444 case DIMENSION::SUBTYPE::ANGLED:
1445 wxLogWarning( wxString::Format(
_(
"Dimension ID %s is an angled dimension, which "
1446 "has no KiCad equivalent. An aligned dimension "
1447 "was loaded instead." ),
1450 case DIMENSION::SUBTYPE::DIRECT:
1451 case DIMENSION::SUBTYPE::ORTHOGONAL:
1453 if( csDim.
Line.
Style == DIMENSION::LINE::STYLE::EXTERNAL )
1455 wxLogWarning( wxString::Format(
1456 _(
"Dimension ID %s has 'External' style in CADSTAR. External "
1457 "dimension styles are not yet supported in KiCad. The dimension "
1458 "object was imported with an internal dimension style instead." ),
1464 if( csDim.
Subtype == DIMENSION::SUBTYPE::ORTHOGONAL )
1488 VECTOR2I crossbarVector = crossbarEnd - crossbarStart;
1490 double height = 0.0;
1492 if( csDim.
Subtype == DIMENSION::SUBTYPE::ORTHOGONAL )
1495 height = heightVector.
y;
1497 height = heightVector.
x;
1503 height = heightVector.
x * angle.
Cos() + heightVector.
y * angle.
Sin();
1513 wxLogError(
_(
"Unexpected Dimension type (ID %s). This was not imported." ),
1519 case DIMENSION::TYPE::LEADERDIM:
1522 if( csDim.
Line.
Style == DIMENSION::LINE::STYLE::INTERNAL )
1646 case DIMENSION::TYPE::ANGLEDIM:
1648 wxLogError(
_(
"Dimension %s is an angular dimension which has no KiCad equivalent. "
1649 "The object was not imported." ),
1659 for( std::pair<AREA_ID, AREA> areaPair :
Layout.
Areas )
1661 AREA& area = areaPair.second;
1665 int lineThickness = 0;
1688 wxLogWarning( wxString::Format(
_(
"The CADSTAR area '%s' is marked as a placement "
1689 "area in CADSTAR. Placement areas are not "
1690 "supported in KiCad. Only the supported elements "
1691 "for the area were imported." ),
1697 wxLogError( wxString::Format(
_(
"The CADSTAR area '%s' does not have a KiCad "
1698 "equivalent. Pure Placement areas are not supported." ),
1724 THROW_IO_ERROR( wxString::Format(
_(
"Unable to find component '%s' in the library"
1725 "(Symdef ID: '%s')" ),
1730 FOOTPRINT* libFootprint = fpIter->second;
1749 for( std::pair<PART_DEFINITION_PIN_ID, PART::DEFINITION::PIN> pinPair :
1752 PART::DEFINITION::PIN
pin = pinPair.second;
1753 wxString pinName =
pin.Name;
1755 if( pinName.empty() )
1756 pinName =
pin.Identifier;
1758 if( pinName.empty() )
1759 pinName = wxString::Format( wxT(
"%ld" ),
pin.ID );
1771 for( std::pair<PAD_ID, PADEXCEPTION> padPair : comp.
PadExceptions )
1780 if( !padEx.
PadCode.IsEmpty() )
1795 wxString padNumber = kiPad->
GetNumber();
1810 footprint->
SetValue( wxEmptyString );
1826 if( !comp.
PartID.IsEmpty() && comp.
PartID != wxT(
"NO_PART" ) )
1838 for( std::pair<DOCUMENTATION_SYMBOL_ID, DOCUMENTATION_SYMBOL> docPair :
1848 THROW_IO_ERROR( wxString::Format(
_(
"Unable to find documentation symbol in the "
1849 "library (Symdef ID: '%s')" ),
1853 SYMDEF_PCB& docSymDefinition = ( *docSymIter ).second;
1860 bool mirrorInvert = docSymInstance.
Mirror;
1865 if( !docSymDefinition.
Alternate.IsEmpty() )
1866 groupName += wxT(
" (" ) + docSymDefinition.
Alternate + wxT(
")" );
1874 for( std::pair<FIGURE_ID, FIGURE> figPair : docSymDefinition.
Figures )
1876 FIGURE fig = figPair.second;
1878 wxString::Format( wxT(
"DOCUMENTATION SYMBOL %s, FIGURE %s" ),
1880 m_board, groupID, moveVector, rotationAngle, scalingFactor,
1881 centreOfTransform, mirrorInvert );
1885 for( std::pair<TEXT_ID, TEXT> textPair : docSymDefinition.
Texts )
1887 TEXT txt = textPair.second;
1889 rotationAngle, scalingFactor, centreOfTransform, mirrorInvert );
1899 TEMPLATE& csTemplate = tempPair.second;
1901 int zonelinethickness = 0;
1911 if( !( csTemplate.
NetID.IsEmpty() || csTemplate.
NetID == wxT(
"NONE" ) ) )
1916 wxLogWarning( wxString::Format(
1917 _(
"The CADSTAR template '%s' has the setting 'Allow in No Routing Areas' "
1918 "enabled. This setting has no KiCad equivalent, so it has been ignored." ),
1919 csTemplate.
Name ) );
1924 wxLogWarning( wxString::Format(
1925 _(
"The CADSTAR template '%s' has the setting 'Box Isolated Pins' "
1926 "enabled. This setting has no KiCad equivalent, so it has been ignored." ),
1927 csTemplate.
Name ) );
1932 wxLogWarning( wxString::Format(
1933 _(
"The CADSTAR template '%s' has the setting 'Automatic Repour' "
1934 "enabled. This setting has no KiCad equivalent, so it has been ignored." ),
1935 csTemplate.
Name ) );
1943 wxLogWarning( wxString::Format(
1944 _(
"The CADSTAR template '%s' has a non-zero value defined for the "
1945 "'Sliver Width' setting. There is no KiCad equivalent for "
1946 "this, so this setting was ignored." ),
1947 csTemplate.
Name ) );
1953 wxLogWarning( wxString::Format(
1954 _(
"The CADSTAR template '%s' has different settings for 'Retain Poured Copper "
1955 "- Disjoint' and 'Retain Poured Copper - Isolated'. KiCad does not "
1956 "distinguish between these two settings. The setting for disjoint copper "
1957 "has been applied as the minimum island area of the KiCad Zone." ),
1958 csTemplate.
Name ) );
1961 long long minIslandArea = -1;
1988 if( csTemplate.
Pouring.
FillType == TEMPLATE::POURING::COPPER_FILL_TYPE::HATCHED )
1990 zone->
SetFillMode( ZONE_FILL_MODE::HATCH_PATTERN );
2004 wxLogWarning( wxString::Format(
2005 _(
"The CADSTAR template '%s' has different settings for thermal relief "
2006 "in pads and vias. KiCad only supports one single setting for both. The "
2007 "setting for pads has been applied." ),
2008 csTemplate.
Name ) );
2019 if( spokeWidth < minThickness )
2021 wxLogWarning( wxString::Format(
2022 _(
"The CADSTAR template '%s' has thermal reliefs in the original design "
2023 "but the spoke width (%.2f mm) is thinner than the minimum thickness of "
2024 "the zone (%.2f mm). KiCad requires the minimum thickness of the zone "
2025 "to be preserved. Therefore the minimum thickness has been applied as "
2026 "the new spoke width and will be applied next time the zones are "
2031 spokeWidth = minThickness;
2054 NET_ID netid = wxEmptyString;
2056 for( std::pair<NET_ID, NET_PCB> netPair :
Layout.
Nets )
2060 if( net.
Name == powerPlaneLayerName )
2067 if( netid.IsEmpty() )
2069 wxLogError(
_(
"The CADSTAR layer '%s' is defined as a power plane layer. However no "
2070 "net with such name exists. The layer has been loaded but no copper "
2071 "zone was created." ),
2072 powerPlaneLayerName );
2076 for( std::pair<BOARD_ID, CADSTAR_BOARD> boardPair :
Layout.
Boards )
2081 int defaultLineThicknesss = bds.
GetLineThickness( PCB_LAYER_ID::Edge_Cuts );
2101 for( std::pair<COPPER_ID, COPPER> copPair :
Layout.
Coppers )
2103 COPPER& csCopper = copPair.second;
2126 if( shape->GetShape() == SHAPE_T::ARC )
2130 ERROR_LOC::ERROR_INSIDE );
2136 ERROR_LOC::ERROR_INSIDE );
2171 _(
"The CADSTAR design contains COPPER elements, which have no direct KiCad "
2172 "equivalent. These have been imported as a KiCad Zone if solid or hatch "
2173 "filled, or as a KiCad Track if the shape was an unfilled outline (open or "
2221 zone->
SetFillMode( ZONE_FILL_MODE::HATCH_PATTERN );
2247 for( std::pair<NET_ID, NET_PCB> netPair :
Layout.
Nets )
2250 wxString netnameForErrorReporting = net.
Name;
2252 std::map<NETELEMENT_ID, long> netelementSizes;
2254 if( netnameForErrorReporting.IsEmpty() )
2255 netnameForErrorReporting = wxString::Format( wxT(
"$%ld" ), net.
SignalNum );
2257 for( std::pair<NETELEMENT_ID, NET_PCB::VIA> viaPair : net.
Vias )
2259 NET_PCB::VIA
via = viaPair.second;
2263 netelementSizes.insert( { viaPair.first, viaSize } );
2266 for( std::pair<NETELEMENT_ID, NET_PCB::PIN> pinPair : net.
Pins )
2268 NET_PCB::PIN
pin = pinPair.second;
2271 if( footprint ==
nullptr )
2273 wxLogWarning( wxString::Format(
2274 _(
"The net '%s' references component ID '%s' which does not exist. "
2275 "This has been ignored." ),
2276 netnameForErrorReporting,
pin.ComponentID ) );
2278 else if( (
pin.PadID - (
long) 1 ) > footprint->
Pads().size() )
2280 wxLogWarning( wxString::Format(
_(
"The net '%s' references non-existent pad index"
2281 " '%d' in component '%s'. This has been "
2283 netnameForErrorReporting,
2302 if( assocPads.find(
pin.PadID ) != assocPads.end() )
2304 for(
PAD_ID copperPadID : assocPads.at(
pin.PadID ) )
2313 int padsize = std::min(
pad->GetSizeX(),
pad->GetSizeY() );
2314 netelementSizes.insert( { pinPair.first, padsize } );
2322 auto getJunctionSize =
2323 [&](
NETELEMENT_ID aJptNetElemId,
const NET_PCB::CONNECTION_PCB& aConnectionToIgnore ) ->
int
2327 for( NET_PCB::CONNECTION_PCB connection : net.
Connections )
2329 if( connection.Route.RouteVertices.size() == 0 )
2332 if( connection.StartNode == aConnectionToIgnore.StartNode
2333 && connection.EndNode == aConnectionToIgnore.EndNode )
2338 if( connection.StartNode == aJptNetElemId )
2340 int s =
getKiCadLength( connection.Route.RouteVertices.front().RouteWidth );
2341 jptsize = std::max( jptsize, s );
2343 else if( connection.EndNode == aJptNetElemId )
2345 int s =
getKiCadLength( connection.Route.RouteVertices.back().RouteWidth );
2346 jptsize = std::max( jptsize, s );
2354 NET_PCB::ROUTE_VERTEX vertex = aConnectionToIgnore.Route.RouteVertices.front();
2356 if( aConnectionToIgnore.EndNode == aJptNetElemId )
2357 vertex = aConnectionToIgnore.Route.RouteVertices.back();
2365 for( NET_PCB::CONNECTION_PCB connection : net.
Connections )
2367 int startSize = std::numeric_limits<int>::max();
2368 int endSize = std::numeric_limits<int>::max();
2370 if( netelementSizes.find( connection.StartNode ) != netelementSizes.end() )
2371 startSize = netelementSizes.at( connection.StartNode );
2373 startSize = getJunctionSize( connection.StartNode, connection );
2375 if( netelementSizes.find( connection.EndNode ) != netelementSizes.end() )
2376 endSize = netelementSizes.at( connection.EndNode );
2378 endSize = getJunctionSize( connection.EndNode, connection );
2383 if( !connection.Unrouted )
2392 auto findAndReplaceTextField =
2431 wxString varValue = txtvalue.second;
2433 txtVars.insert( { varName, varValue } );
2438 wxString varName = txtvalue.first;
2439 wxString varValue = txtvalue.second;
2441 txtVars.insert( { varName, varValue } );
2446 wxLogError(
_(
"Text Variables could not be set as there is no project loaded." ) );
2454 for( std::pair<ATTRIBUTE_ID, ATTRIBUTE_VALUE> attrPair : aComponent.
AttributeValues )
2465 for( std::pair<ATTRIBUTE_ID, TEXT_LOCATION> textlocPair : aComponent.
TextLocations )
2472 attrval = wxEmptyString;
2476 attrval = wxT(
"${REFERENCE}" );
2491 const NET_PCB::ROUTE& aCadstarRoute,
2492 long aStartWidth,
long aEndWidth )
2494 if( aCadstarRoute.RouteVertices.size() == 0 )
2497 std::vector<PCB_SHAPE*> shapes;
2498 std::vector<NET_PCB::ROUTE_VERTEX> routeVertices = aCadstarRoute.RouteVertices;
2501 if( aStartWidth < routeVertices.front().RouteWidth )
2503 NET_PCB::ROUTE_VERTEX newFrontVertex = aCadstarRoute.RouteVertices.front();
2504 newFrontVertex.RouteWidth = aStartWidth;
2505 newFrontVertex.Vertex.End = aCadstarRoute.StartPoint;
2506 routeVertices.insert( routeVertices.begin(), newFrontVertex );
2510 if( aEndWidth < routeVertices.back().RouteWidth )
2512 NET_PCB::ROUTE_VERTEX newBackVertex = aCadstarRoute.RouteVertices.back();
2513 newBackVertex.RouteWidth = aEndWidth;
2514 routeVertices.push_back( newBackVertex );
2517 POINT prevEnd = aCadstarRoute.StartPoint;
2519 for(
const NET_PCB::ROUTE_VERTEX& v : routeVertices )
2525 shapes.push_back( shape );
2526 prevEnd = v.Vertex.End;
2531 wxLogError(
_(
"The CADSTAR design contains teardrops. This importer does not yet "
2532 "support them, so the teardrops in the design have been ignored." ) );
2548 const NET_ID& aCadstarNetID,
const NET_PCB::VIA& aCadstarVia )
2558 via->SetLocked( aCadstarVia.Fixed );
2562 wxLogError(
_(
"The CADSTAR via code '%s' has different shape from a circle defined. "
2563 "KiCad only supports circular vias so this via type has been changed to "
2564 "be a via with circular shape of %.2f mm diameter." ),
2571 bool start_layer_outside =
2574 bool end_layer_outside =
2578 if( start_layer_outside && end_layer_outside )
2580 via->SetViaType( VIATYPE::THROUGH );
2582 else if( ( !start_layer_outside ) && ( !end_layer_outside ) )
2584 via->SetViaType( VIATYPE::BLIND_BURIED );
2588 via->SetViaType( VIATYPE::MICROVIA );
2596 return via->GetWidth();
2603 const double& aRotationAngle,
const double& aScalingFactor,
2604 const VECTOR2I& aTransformCentre,
const bool& aMirrorInvert )
2607 aContainer->
Add( txt );
2612 RotatePoint( rotatedTextPos, aTransformCentre, rotationAngle );
2614 KiROUND( (
double) ( rotatedTextPos.
x - aTransformCentre.
x ) * aScalingFactor );
2616 KiROUND( (
double) ( rotatedTextPos.
y - aTransformCentre.
y ) * aScalingFactor );
2617 rotatedTextPos += aTransformCentre;
2676 wxFAIL_MSG( wxT(
"Unknown Alignment - needs review!" ) );
2681 txt->
Flip( aTransformCentre,
true );
2685 if( aScalingFactor != 1.0 )
2691 scaledTextSize.
x =
KiROUND( (
double) unscaledTextSize.
x * aScalingFactor );
2692 scaledTextSize.
y =
KiROUND( (
double) unscaledTextSize.
y * aScalingFactor );
2698 txt->
Move( aMoveVector );
2703 LAYER_ID layersToDrawOn = aCadstarLayerOverride;
2705 if( layersToDrawOn.IsEmpty() )
2706 layersToDrawOn = aCadstarText.
LayerID;
2721 if( !aCadstarGroupID.IsEmpty() )
2732 if( !aCadstarGroupID.IsEmpty() )
2741 const int& aLineThickness,
2742 const wxString& aShapeName,
2746 const double& aRotationAngle,
2747 const double& aScalingFactor,
2749 const bool& aMirrorInvert )
2751 auto drawAsOutline = [&]()
2754 aContainer, aCadstarGroupID, aMoveVector, aRotationAngle,
2755 aScalingFactor, aTransformCentre, aMirrorInvert );
2757 aCadstarGroupID, aMoveVector, aRotationAngle, aScalingFactor,
2758 aTransformCentre, aMirrorInvert );
2761 switch( aCadstarShape.
Type )
2771 wxLogWarning( wxString::Format(
2772 _(
"The shape for '%s' is Hatch filled in CADSTAR, which has no KiCad equivalent. "
2773 "Using solid fill instead." ),
2779 if( aCadstarShape.
Vertices.size() < 3 )
2790 aMoveVector, aRotationAngle,
2791 aScalingFactor, aTransformCentre,
2799 aContainer->
Add( shape, ADD_MODE::APPEND );
2801 if( !aCadstarGroupID.IsEmpty() )
2811 const int& aLineThickness,
2815 const double& aRotationAngle,
2816 const double& aScalingFactor,
2818 const bool& aMirrorInvert )
2820 for(
CUTOUT cutout : aCutouts )
2823 aCadstarGroupID, aMoveVector, aRotationAngle, aScalingFactor,
2824 aTransformCentre, aMirrorInvert );
2831 const int& aLineThickness,
2835 const double& aRotationAngle,
2836 const double& aScalingFactor,
2838 const bool& aMirrorInvert )
2841 aCadstarGroupID, aMoveVector,
2842 aRotationAngle, aScalingFactor,
2843 aTransformCentre, aMirrorInvert );
2847 shape->SetStroke(
STROKE_PARAMS( aLineThickness, PLOT_DASH_TYPE::SOLID ) );
2848 shape->SetLayer( aKiCadLayer );
2849 shape->SetParent( aContainer );
2850 aContainer->
Add( shape, ADD_MODE::APPEND );
2856 const std::vector<VERTEX>& aCadstarVertices,
2860 const double& aRotationAngle,
2861 const double& aScalingFactor,
2863 const bool& aMirrorInvert )
2865 std::vector<PCB_SHAPE*> shapes;
2867 if( aCadstarVertices.size() < 2 )
2871 const VERTEX* prev = &aCadstarVertices.at( 0 );
2874 for(
size_t i = 1; i < aCadstarVertices.size(); i++ )
2876 cur = &aCadstarVertices.at( i );
2878 aMoveVector, aRotationAngle, aScalingFactor,
2879 aTransformCentre, aMirrorInvert ) );
2888 const VERTEX& aCadstarVertex,
2892 const double& aRotationAngle,
2893 const double& aScalingFactor,
2895 const bool& aMirrorInvert )
2907 centerPoint = ( startPoint + endPoint ) / 2;
2914 switch( aCadstarVertex.
Type )
2918 shape =
new PCB_SHAPE( aContainer, SHAPE_T::SEGMENT );
2921 shape->
SetEnd( endPoint );
2932 shape =
new PCB_SHAPE( aContainer, SHAPE_T::ARC );
2937 EDA_ANGLE arcStartAngle( startPoint - centerPoint );
2938 EDA_ANGLE arcEndAngle( endPoint - centerPoint );
2939 EDA_ANGLE arcAngle = ( arcEndAngle - arcStartAngle ).Normalize();
2954 shape->
Flip( aTransformCentre,
true );
2956 if( aScalingFactor != 1.0 )
2958 shape->
Move( -1*aTransformCentre );
2959 shape->
Scale( aScalingFactor );
2960 shape->
Move( aTransformCentre );
2963 if( aRotationAngle != 0.0 )
2966 if( aMoveVector !=
VECTOR2I{ 0, 0 } )
2967 shape->
Move( aMoveVector );
2969 if( !aCadstarGroupID.IsEmpty() )
2977 const int& aLineThickness,
2980 ZONE* zone =
new ZONE( aParentContainer );
2984 zone->
SetFillMode( ZONE_FILL_MODE::HATCH_PATTERN );
2985 zone->
SetHatchStyle( ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL );
2996 for(
int i = 0; i < polygon.
HoleCount( 0 ); i++ )
3004 const int& aLineThickness,
3007 const double& aRotationAngle,
3008 const double& aScalingFactor,
3010 const bool& aMirrorInvert )
3015 aContainer, noGroup, aMoveVector,
3016 aRotationAngle, aScalingFactor,
3017 aTransformCentre, aMirrorInvert );
3028 noGroup, aMoveVector,
3029 aRotationAngle, aScalingFactor,
3030 aTransformCentre, aMirrorInvert );
3041 if( aLineThickness > 0 )
3049 for(
int j = 0; j < polySet.
HoleCount( i ); ++j )
3066 switch( shape->GetShape() )
3070 SHAPE_ARC arc( shape->GetCenter(), shape->GetStart(), shape->GetArcAngle() );
3072 if( shape->EndsSwapped() )
3079 case SHAPE_T::SEGMENT:
3080 lineChain.
Append( shape->GetStartX(), shape->GetStartY() );
3081 lineChain.
Append( shape->GetEndX(), shape->GetEndY() );
3085 wxFAIL_MSG( wxT(
"Drawsegment type is unexpected. Ignored." ) );
3105 const std::vector<PCB_SHAPE*>& aShapes,
3108 int aWidthOverride )
3110 std::vector<PCB_TRACK*> tracks;
3122 if( aTrack->GetLength() != 0 )
3124 tracks.push_back( aTrack );
3125 aParentContainer->
Add( aTrack, ADD_MODE::APPEND );
3135 switch( shape->GetShape() )
3139 SHAPE_ARC arc( shape->GetStart(), shape->GetArcMid(), shape->GetEnd(), 0 );
3141 if( shape->EndsSwapped() )
3144 track =
new PCB_ARC( aParentContainer, &arc );
3148 case SHAPE_T::SEGMENT:
3149 track =
new PCB_TRACK( aParentContainer );
3150 track->
SetStart( shape->GetStart() );
3151 track->
SetEnd( shape->GetEnd() );
3155 wxFAIL_MSG( wxT(
"Drawsegment type is unexpected. Ignored." ) );
3159 if( aWidthOverride == -1 )
3160 track->
SetWidth( shape->GetWidth() );
3164 if( aLayerOverride == PCB_LAYER_ID::UNDEFINED_LAYER )
3165 track->
SetLayer( shape->GetLayer() );
3169 if( aNet !=
nullptr )
3177 if( prevTrack !=
nullptr )
3179 int offsetAmount = ( track->
GetWidth() / 2 ) - ( prevTrack->
GetWidth() / 2 );
3181 if( offsetAmount > 0 )
3188 else if( offsetAmount < 0 )
3193 prevTrack->
SetEnd( newEnd );
3209 addTrack( synthTrack );
3214 addTrack( prevTrack );
3229 const wxString& aAttributeValue )
3242 aFootprint->
SetValue( aAttributeValue );
3243 txt = &aFootprint->
Value();
3248 aFootprint->
Add( txt );
3249 txt->
SetText( aAttributeValue );
3262 aFootprint->
SetValue( aAttributeValue );
3263 txt = &aFootprint->
Value();
3269 aFootprint->
Add( txt );
3270 txt->
SetText( aAttributeValue );
3280 if( aCadstarAttrLoc.
Mirror )
3338 wxFAIL_MSG( wxT(
"Unknown Alignment - needs review!" ) );
3347 const long& aOffsetAmount )
3349 VECTOR2I v( *aPointToOffset - aRefPoint );
3355 aPointToOffset->
x = offsetted.
x;
3356 aPointToOffset->
y = offsetted.
y;
3360 *aPointToOffset = aRefPoint;
3378 if( textSize.
x == 0 )
3383 if( textSize.
x == 0 || textSize.
y == 0 )
3476 const std::map<ATTRIBUTE_ID, ATTRIBUTE_VALUE>& aCadstarAttributeMap )
3478 wxCHECK( aCadstarAttributeMap.find( aCadstarAttributeID ) != aCadstarAttributeMap.end(),
3481 return aCadstarAttributeMap.at( aCadstarAttributeID ).Value;
3498 const PART_ID& aCadstarPartID )
3533 if( hcode.
Hatches.size() < 1 )
3546 if( hcode.
Hatches.size() < 1 )
3558 if( hcode.
Hatches.size() < 1 )
3583 if( hcode.
Hatches.size() != 2 )
3585 wxLogWarning( wxString::Format(
3586 _(
"The CADSTAR Hatching code '%s' has %d hatches defined. "
3587 "KiCad only supports 2 hatches (crosshatching) 90 degrees apart. "
3588 "The imported hatching is crosshatched." ),
3593 if( hcode.
Hatches.at( 0 ).LineWidth != hcode.
Hatches.at( 1 ).LineWidth )
3595 wxLogWarning( wxString::Format(
3596 _(
"The CADSTAR Hatching code '%s' has different line widths for each "
3597 "hatch. KiCad only supports one width for the hatching. The imported "
3598 "hatching uses the width defined in the first hatch definition, i.e. "
3607 wxLogWarning( wxString::Format(
3608 _(
"The CADSTAR Hatching code '%s' has different step sizes for each "
3609 "hatch. KiCad only supports one step size for the hatching. The imported "
3610 "hatching uses the step size defined in the first hatching definition, "
3617 if( abs( hcode.
Hatches.at( 0 ).OrientAngle - hcode.
Hatches.at( 1 ).OrientAngle )
3620 wxLogWarning( wxString::Format(
3621 _(
"The hatches in CADSTAR Hatching code '%s' have an angle "
3622 "difference of %.1f degrees. KiCad only supports hatching 90 "
3623 "degrees apart. The imported hatching has two hatches 90 "
3624 "degrees apart, oriented %.1f degrees from horizontal." ),
3653 wxString prefix = wxEmptyString;
3654 wxString suffix = wxEmptyString;
3655 size_t startpos = aCadstarDim.
Text.
Text.Find( wxT(
"<@DISTANCE" ) );
3657 if( startpos != wxNOT_FOUND )
3660 wxString remainingStr = aCadstarDim.
Text.
Text.Mid( startpos );
3661 size_t endpos = remainingStr.Find(
"@>" );
3665 if( suffix.StartsWith( wxT(
"mm" ) ) )
3668 suffix = suffix.Mid( 2 );
3686 switch( dimensionUnits )
3691 wxLogWarning( wxString::Format(
_(
"Dimension ID %s uses a type of unit that "
3692 "is not supported in KiCad. Millimeters were "
3693 "applied instead." ),
3697 aKiCadDim->
SetUnitsMode( DIM_UNITS_MODE::MILLIMETRES );
3709 wxFAIL_MSG( wxT(
"We should have handled design units before coming here!" ) );
3716 std::map<TEMPLATE_ID, std::set<TEMPLATE_ID>> winningOverlaps;
3724 int retval = std::max( aZoneA->
GetLocalClearance(), aZoneB->GetLocalClearance() );
3733 [&](
ZONE* aLowerZone,
ZONE* aHigherZone ) ->
double
3736 intersectShape.
Inflate( inflateValue( aLowerZone, aHigherZone ),
3746 double leftOverArea = lowerZoneFill.
Area();
3748 return leftOverArea;
3751 auto intersectionAreaOfZoneOutlines =
3752 [&](
ZONE* aZoneA,
ZONE* aZoneB ) ->
double
3764 return outLineA.
Area();
3768 auto isLowerPriority =
3771 return winningOverlaps[b].count( a ) > 0;
3774 for( std::map<TEMPLATE_ID, ZONE*>::iterator it1 =
m_zonesMap.begin();
3778 ZONE* thisZone = it1->second;
3783 for( std::map<TEMPLATE_ID, ZONE*>::iterator it2 = it1;
3787 ZONE* otherZone = it2->second;
3789 if( thisTemplate.
ID == otherTemplate.
ID )
3798 if( intersectionAreaOfZoneOutlines( thisZone, otherZone ) == 0 )
3807 if( thisZonePolyFill.
Area() > 0.0 && otherZonePolyFill.
Area() > 0.0 )
3810 double areaThis = errorArea( thisZone, otherZone );
3812 double areaOther = errorArea( otherZone, thisZone );
3814 if( areaThis > areaOther )
3817 winningOverlaps[thisTemplate.
ID].insert( otherTemplate.
ID );
3822 winningOverlaps[otherTemplate.
ID].insert( thisTemplate.
ID );
3825 else if( thisZonePolyFill.
Area() > 0.0 )
3828 winningOverlaps[thisTemplate.
ID].insert( otherTemplate.
ID );
3830 else if( otherZonePolyFill.
Area() > 0.0 )
3833 winningOverlaps[otherTemplate.
ID].insert( thisTemplate.
ID );
3839 if( intersectionAreaOfZoneOutlines( thisZone, otherZone ) != 0 )
3842 winningOverlaps[otherTemplate.
ID].insert( thisTemplate.
ID );
3844 winningOverlaps[thisTemplate.
ID].insert( otherTemplate.
ID );
3853 std::set<TEMPLATE_ID> intersectingIDs;
3855 for(
const std::pair<
TEMPLATE_ID, std::set<TEMPLATE_ID>>& idPair : winningOverlaps )
3857 intersectingIDs.insert( idPair.first );
3858 intersectingIDs.insert( idPair.second.begin(), idPair.second.end() );
3862 std::vector<TEMPLATE_ID> sortedIDs;
3866 sortedIDs.push_back(
id );
3870 std::sort( sortedIDs.begin(), sortedIDs.end(), isLowerPriority );
3876 if( prevID.IsEmpty() )
3882 wxASSERT( !isLowerPriority(
id, prevID ) );
3884 int newPriority =
m_zonesMap.at( prevID )->GetAssignedPriority();
3887 if( isLowerPriority( prevID,
id ) )
3890 m_zonesMap.at(
id )->SetAssignedPriority( newPriority );
3895 for(
const std::pair<
TEMPLATE_ID, std::set<TEMPLATE_ID>>& idPair : winningOverlaps )
3899 for(
const TEMPLATE_ID& losingID : idPair.second )
3901 if(
m_zonesMap.at( losingID )->GetAssignedPriority()
3902 >
m_zonesMap.at( winningID )->GetAssignedPriority() )
3936 if( aCadstarNetID.IsEmpty() )
3942 return m_netMap.at( aCadstarNetID );
3949 wxString newName = csNet.
Name;
3951 if( csNet.
Name.IsEmpty() )
3953 if( csNet.
Pins.size() > 0 )
3957 NET_PCB::PIN firstPin = ( *csNet.
Pins.begin() ).second;
3960 newName = wxT(
"Net-(" );
3962 newName << wxT(
"-Pad" ) << wxString::Format( wxT(
"%ld" ), firstPin.PadID );
3963 newName << wxT(
")" );
3967 wxFAIL_MSG( wxT(
"A net with no pins associated?" ) );
3968 newName = wxT(
"csNet-" );
3969 newName << wxString::Format( wxT(
"%i" ), csNet.
SignalNum );
3976 wxLogMessage(
_(
"The CADSTAR design contains nets with a 'Net Class' assigned. KiCad "
3977 "does not have an equivalent to CADSTAR's Net Class so these elements "
3978 "were not imported. Note: KiCad's version of 'Net Class' is closer to "
3979 "CADSTAR's 'Net Route Code' (which has been imported for all nets)." ) );
3986 wxLogWarning(
_(
"The CADSTAR design contains nets with a 'Spacing Class' assigned. "
3987 "KiCad does not have an equivalent to CADSTAR's Spacing Class so "
3988 "these elements were not imported. Please review the design rules as "
3989 "copper pours will affected by this." ) );
3995 std::shared_ptr<NETCLASS> netclass;
3997 std::tuple<ROUTECODE_ID, NETCLASS_ID, SPACING_CLASS_ID> key = { csNet.
RouteCodeID,
4007 wxString netClassName;
4010 netClassName += wxT(
"Route code: " ) + rc.
Name;
4015 netClassName += wxT(
" | Net class: " ) + nc.
Name;
4021 netClassName += wxT(
" | Spacing class: " ) + sp.
Name;
4024 netclass.reset(
new NETCLASS( *netSettings->m_DefaultNetClass ) );
4025 netclass->SetName( netClassName );
4026 netSettings->m_NetClasses[ netClassName ] = netclass;
4033 std::make_unique<EDA_COMBINED_MATCHER>( newName,
CTX_NETCLASS ),
4039 m_netMap.insert( { aCadstarNetID, netInfo } );
4048 bool aDetectMaxLayer )
4051 return PCB_LAYER_ID::B_Cu;
4055 case 1:
return PCB_LAYER_ID::F_Cu;
4056 case 2:
return PCB_LAYER_ID::In1_Cu;
4057 case 3:
return PCB_LAYER_ID::In2_Cu;
4058 case 4:
return PCB_LAYER_ID::In3_Cu;
4059 case 5:
return PCB_LAYER_ID::In4_Cu;
4060 case 6:
return PCB_LAYER_ID::In5_Cu;
4061 case 7:
return PCB_LAYER_ID::In6_Cu;
4062 case 8:
return PCB_LAYER_ID::In7_Cu;
4063 case 9:
return PCB_LAYER_ID::In8_Cu;
4064 case 10:
return PCB_LAYER_ID::In9_Cu;
4065 case 11:
return PCB_LAYER_ID::In10_Cu;
4066 case 12:
return PCB_LAYER_ID::In11_Cu;
4067 case 13:
return PCB_LAYER_ID::In12_Cu;
4068 case 14:
return PCB_LAYER_ID::In13_Cu;
4069 case 15:
return PCB_LAYER_ID::In14_Cu;
4070 case 16:
return PCB_LAYER_ID::In15_Cu;
4071 case 17:
return PCB_LAYER_ID::In16_Cu;
4072 case 18:
return PCB_LAYER_ID::In17_Cu;
4073 case 19:
return PCB_LAYER_ID::In18_Cu;
4074 case 20:
return PCB_LAYER_ID::In19_Cu;
4075 case 21:
return PCB_LAYER_ID::In20_Cu;
4076 case 22:
return PCB_LAYER_ID::In21_Cu;
4077 case 23:
return PCB_LAYER_ID::In22_Cu;
4078 case 24:
return PCB_LAYER_ID::In23_Cu;
4079 case 25:
return PCB_LAYER_ID::In24_Cu;
4080 case 26:
return PCB_LAYER_ID::In25_Cu;
4081 case 27:
return PCB_LAYER_ID::In26_Cu;
4082 case 28:
return PCB_LAYER_ID::In27_Cu;
4083 case 29:
return PCB_LAYER_ID::In28_Cu;
4084 case 30:
return PCB_LAYER_ID::In29_Cu;
4085 case 31:
return PCB_LAYER_ID::In30_Cu;
4086 case 32:
return PCB_LAYER_ID::B_Cu;
4089 return PCB_LAYER_ID::UNDEFINED_LAYER;
4101 switch( layer.
Type )
4122 return PCB_LAYER_ID::UNDEFINED_LAYER;
4126 PCB_LAYER_ID::UNDEFINED_LAYER );
4139 return LSET( 4, PCB_LAYER_ID::Dwgs_User, PCB_LAYER_ID::Cmts_User, PCB_LAYER_ID::Eco1_User,
4140 PCB_LAYER_ID::Eco2_User );
4148 ^ (
LSET( PCB_LAYER_ID::Rescue ) );
4162 parentGroup->
AddItem( aKiCadItem );
4167 const wxString& aName )
4169 wxString groupName = aName;
4174 groupName = aName + wxT(
"_" ) + wxString::Format( wxT(
"%i" ), ++num );
4179 docSymGroup->
SetName( groupName );
4181 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.
#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.
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
PCB_SHAPE * getShapeFromVertex(const POINT &aCadstarStartPoint, const VERTEX &aCadstarVertex, BOARD_ITEM_CONTAINER *aContainer=nullptr, const GROUP_ID &aCadstarGroupID=wxEmptyString, const VECTOR2I &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
Returns a pointer to a PCB_SHAPE object.
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.
bool isLayerSet(const LAYER_ID &aCadstarLayerID)
LAYERPAIR getLayerPair(const LAYERPAIR_ID &aCadstarLayerPairID)
void drawCadstarShape(const SHAPE &aCadstarShape, const PCB_LAYER_ID &aKiCadLayer, const int &aLineThickness, const wxString &aShapeName, BOARD_ITEM_CONTAINER *aContainer, const GROUP_ID &aCadstarGroupID=wxEmptyString, const VECTOR2I &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
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)
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 drawCadstarVerticesAsShapes(const std::vector< VERTEX > &aCadstarVertices, const PCB_LAYER_ID &aKiCadLayer, const int &aLineThickness, BOARD_ITEM_CONTAINER *aContainer, const GROUP_ID &aCadstarGroupID=wxEmptyString, const VECTOR2I &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
Uses PCB_SHAPE to draw the vertices on m_board object.
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 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)
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 drawCadstarCutoutsAsShapes(const std::vector< CUTOUT > &aCutouts, const PCB_LAYER_ID &aKiCadLayer, const int &aLineThickness, BOARD_ITEM_CONTAINER *aContainer, const GROUP_ID &aCadstarGroupID=wxEmptyString, const VECTOR2I &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
Uses PCB_SHAPEs to draw the cutouts on m_board object.
NETINFO_ITEM * getKiCadNet(const NET_ID &aCadstarNetID)
Searches m_netMap and returns the NETINFO_ITEM pointer if exists.
SHAPE_POLY_SET getPolySetFromCadstarShape(const SHAPE &aCadstarShape, const int &aLineThickness=-1, BOARD_ITEM_CONTAINER *aContainer=nullptr, const VECTOR2I &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
Returns a SHAPE_POLY_SET object from a Cadstar SHAPE.
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 drawCadstarText(const TEXT &aCadstarText, BOARD_ITEM_CONTAINER *aContainer, const GROUP_ID &aCadstarGroupID=wxEmptyString, const LAYER_ID &aCadstarLayerOverride=wxEmptyString, const VECTOR2I &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
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)
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 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const VECTOR2I &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
Returns a vector of pointers to PCB_SHAPE objects.
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 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 SetFilled(bool aFlag)
void SetPolyShape(const SHAPE_POLY_SET &aShape)
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,...
void SetTextSize(VECTOR2I aNewSize)
const EDA_ANGLE & GetTextAngle() const
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.
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
bool Contains(PCB_LAYER_ID aLayer)
See if the layer set contains a PCB layer.
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Handle the data for a net.
void SetNetClass(const std::shared_ptr< NETCLASS > &aNetClass)
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)
bool AddItem(BOARD_ITEM *aItem)
Add item to group.
void SetLocked(bool aLocked) override
virtual void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
virtual void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
virtual 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, bool aFlipLeftRight) override
Flip this object, i.e.
virtual void SetPosition(const VECTOR2I &aPos) override
void Move(const VECTOR2I &aMoveVector) override
Move this object.
void SetWidth(int aWidth)
void SetEnd(const VECTOR2I &aEnd)
void SetStart(const VECTOR2I &aStart)
const VECTOR2I & GetStart() const
const VECTOR2I & GetEnd() 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 BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset difference For aFastMode meaning, see function booleanOp.
void Fracture(POLYGON_MODE aFastMode)
Convert a set of polygons with holes to a single outline with "slits"/"fractures" connecting the oute...
void ClearArcs()
Removes all arc references from all the outlines and holes in the polyset.