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." ) );
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." ) );
165 _(
"The CADSTAR design has been imported successfully.\n" 166 "Please review the import errors and warnings (if any)." ) );
171 std::vector<FOOTPRINT*> retval;
173 for( std::pair<SYMDEF_ID, FOOTPRINT*> fpPair :
m_libraryMap )
175 retval.push_back( static_cast<FOOTPRINT*>( fpPair.second->Clone() ) );
183 const wxString& aCadstarLayerName,
189 _(
"The CADSTAR layer '%s' has no KiCad equivalent. All elements on this " 190 "layer have been mapped to KiCad layer '%s' instead." ),
191 aCadstarLayerName,
LSET::Name( aKiCadLayer ) ) );
202 _(
"The CADSTAR layer '%s' has been assumed to be a technical layer. All " 203 "elements on this layer have been mapped to KiCad layer '%s'." ),
204 aCadstarLayerName,
LSET::Name( aKiCadLayer ) ) );
211 int aDielectricSublayer )
223 if( !aCadstarLayer.
Name.IsEmpty() )
237 LAYER_ID ElecLayerID = wxEmptyString;
240 std::vector<LAYER_ID> ConstructionLayers;
245 bool IsInitialised() {
return !ElecLayerID.IsEmpty() || ConstructionLayers.size() > 0; };
248 std::vector<LAYER_BLOCK> cadstarBoardStackup;
249 LAYER_BLOCK currentBlock;
260 if( currentBlock.IsInitialised() )
262 cadstarBoardStackup.push_back( currentBlock );
263 currentBlock = LAYER_BLOCK();
266 currentBlock.ElecLayerID = cadstarLayerID;
270 currentBlock.ConstructionLayers.push_back( cadstarLayerID );
274 if( currentBlock.IsInitialised() )
275 cadstarBoardStackup.push_back( currentBlock );
281 if( cadstarBoardStackup.back().ConstructionLayers.size() > 0 )
283 cadstarBoardStackup.push_back( LAYER_BLOCK() );
290 LAYER_BLOCK bottomLayer = cadstarBoardStackup.back();
291 cadstarBoardStackup.pop_back();
293 LAYER_BLOCK secondToLastLayer = cadstarBoardStackup.back();
294 cadstarBoardStackup.pop_back();
296 LAYER_BLOCK dummyLayer;
297 LAYER_ID lastConstruction = secondToLastLayer.ConstructionLayers.back();
299 if( secondToLastLayer.ConstructionLayers.size() > 1 )
302 secondToLastLayer.ConstructionLayers.pop_back();
311 dummyLayer.ConstructionLayers.push_back( lastConstruction );
312 cadstarBoardStackup.push_back( secondToLastLayer );
313 cadstarBoardStackup.push_back( dummyLayer );
314 cadstarBoardStackup.push_back( bottomLayer );
319 wxASSERT( cadstarBoardStackup.back().ConstructionLayers.size() == 0 );
323 BOARD_STACKUP& stackup = boardDesignSettings.GetStackupDescriptor();
330 size_t stackIndex = 0;
336 LAYER_ID layerID = cadstarBoardStackup.at( stackIndex ).ElecLayerID;
338 if( layerID.IsEmpty() )
341 item->SetThickness( 0 );
349 switch( copperLayer.
Type )
365 wxFAIL_MSG( wxT(
"Unexpected Layer type. Was expecting an electrical type" ) );
371 m_layermap.insert( { copperLayer.
ID, item->GetBrdLayerId() } );
376 LAYER_BLOCK layerBlock = cadstarBoardStackup.at( stackIndex );
377 LAYER_BLOCK layerBlockBelow = cadstarBoardStackup.at( stackIndex + 1 );
379 if( layerBlock.ConstructionLayers.size() == 0 )
385 int dielectricId = stackIndex + 1;
386 item->SetDielectricLayerId( dielectricId );
391 if( layerBlock.ElecLayerID.IsEmpty() )
400 if( layerBlockBelow.ElecLayerID.IsEmpty() )
411 LAYER copperLayerBelow =
429 int dielectricSublayer = 0;
431 for(
LAYER_ID constructionLaID : layerBlock.ConstructionLayers )
435 if( dielectricSublayer )
436 item->AddDielectricPrms( dielectricSublayer );
440 m_layermap.insert( { dielectricLayer.
ID, item->GetBrdLayerId() } );
441 ++dielectricSublayer;
448 item->SetColor( wxT(
"White" ) );
452 item->SetColor( wxT(
"Green" ) );
457 boardDesignSettings.SetBoardThickness( thickness );
458 boardDesignSettings.m_HasStackup =
true;
460 int numElecAndPowerLayers = 0;
463 int currentDocLayer = 0;
471 wxString layerName = curLayer.
Name.Lower();
483 if( numElecAndPowerLayers > 0 )
484 kicadLayerID = aBack;
486 kicadLayerID = aFront;
497 case LOG_LEVEL::WARN:
503 switch( curLayer.
Type )
518 ++numElecAndPowerLayers;
526 if( currentDocLayer >= docLayers.size() )
529 kicadLayerID = docLayers.at( currentDocLayer++ );
547 if( layerName.Contains( wxT(
"glue" ) ) || layerName.Contains( wxT(
"adhesive" ) ) )
551 else if( layerName.Contains( wxT(
"silk" ) ) || layerName.Contains( wxT(
"legend" ) ) )
555 else if( layerName.Contains( wxT(
"assembly" ) ) || layerName.Contains( wxT(
"fabrication" ) ) )
559 else if( layerName.Contains( wxT(
"resist" ) ) || layerName.Contains( wxT(
"mask" ) ) )
563 else if( layerName.Contains( wxT(
"paste" ) ) )
594 wxFAIL_MSG( wxT(
"Unknown CADSTAR Layer Sub-type" ) );
600 wxFAIL_MSG( wxT(
"Unknown CADSTAR Layer Type" ) );
615 std::vector<INPUT_LAYER_DESC> inputLayers;
616 std::map<wxString, LAYER_ID> cadstarLayerNameMap;
618 for( std::pair<LAYER_ID, PCB_LAYER_ID> layerPair :
m_layermap )
636 inputLayers.push_back( iLdesc );
637 cadstarLayerNameMap.insert( { curLayer->
Name, curLayer->
ID } );
641 if( inputLayers.size() == 0 )
647 for( std::pair<wxString, PCB_LAYER_ID> layerPair : reMappedLayers )
651 wxFAIL_MSG( wxT(
"Unexpected Layer ID" ) );
655 LAYER_ID cadstarLayerID = cadstarLayerNameMap.at( layerPair.first );
656 m_layermap.at( cadstarLayerID ) = layerPair.second;
657 enabledLayers |=
LSET( layerPair.second );
671 [&]( wxString aID,
int* aVal )
673 if( spacingCodes.find( aID ) == spacingCodes.end() )
674 wxLogWarning(
_(
"Design rule %s was not found. This was ignored." ) );
692 auto applyNetClassRule = [&]( wxString aID,
NETCLASS* aNetClassPtr,
693 void (
NETCLASS::*aFunc )( int ) ) {
695 applyRule( aID, &value );
698 ( aNetClassPtr->*aFunc )( value );
703 wxLogWarning(
_(
"KiCad design rules are different from CADSTAR ones. Only the compatible " 704 "design rules were imported. It is recommended that you review the design " 705 "rules that have been applied." ) );
716 ( wxT(
" (" ) + component.
Alternate + wxT(
")" ) ) :
724 if( component.
Figures.size() > 0 )
727 componentLayer = firstFigure.
LayerID;
729 else if( component.
Texts.size() > 0 )
731 TEXT firstText = component.
Texts.begin()->second;
732 componentLayer = firstText.
LayerID;
742 libID.
Parse( fpName,
true );
751 m_libraryMap.insert( std::make_pair( key, footprint ) );
759 for( std::pair<FIGURE_ID, FIGURE> figPair : aComponent.
Figures )
761 FIGURE& fig = figPair.second;
777 int totalCopperPads = 0;
812 pad->SetLayerSet(
LSET( 1, copperLayer ) );
826 pad->SetSize( { anchorSize, anchorSize } );
827 pad->SetPosition( anchorPos );
828 pad->SetLocalCoord();
829 pad->SetLocked(
true );
835 pad->AddPrimitivePoly( shapePolys, 0,
true );
866 for( std::pair<COMP_AREA_ID, COMPONENT_AREA> areaPair : aComponent.
ComponentAreas )
872 int lineThickness = 0;
897 libName << wxT(
" (" ) << aComponent.
Alternate << wxT(
")" );
901 "have a KiCad equivalent. The area is neither a via nor " 902 "route keepout area. The area was not imported." ),
903 area.
ID, libName ) );
912 for( std::pair<PAD_ID, COMPONENT_PAD> padPair : aComponent.
ComponentPads )
929 switch( aCadstarPad.
Side )
944 wxFAIL_MSG( wxT(
"Unknown Pad type" ) );
948 pad->SetLocalSolderMaskMargin( 0 );
949 pad->SetLocalSolderPasteMargin( 0 );
950 pad->SetLocalSolderPasteMarginRatio( 0.0 );
951 bool complexPadErrorLogged =
false;
953 for(
auto& reassign : csPadcode.
Reassigns )
958 if( shape.
Size == 0 )
960 padLayerSet.reset( kiLayer );
968 if( std::abs(
pad->GetLocalSolderMaskMargin() ) < std::abs( newMargin ) )
969 pad->SetLocalSolderMaskMargin( newMargin );
973 if( std::abs(
pad->GetLocalSolderPasteMargin() ) < std::abs( newMargin ) )
974 pad->SetLocalSolderPasteMargin( newMargin );
980 if( !complexPadErrorLogged )
982 complexPadErrorLogged =
true;
986 _(
"The CADSTAR pad definition '%s' is a complex pad stack, " 987 "which is not supported in KiCad. Please review the " 988 "imported pads as they may require manual correction." ),
995 pad->SetLayerSet( padLayerSet );
1002 pad->SetNumber( wxEmptyString );
1027 wxPoint padOffset = { 0, 0 };
1028 wxPoint drillOffset = { 0, 0 };
1047 pad->SetRoundRectRadiusRatio( 0.5 );
1048 pad->SetChamferRectRatio( 0.0 );
1066 pad->SetChamferRectRatio( 0.5 );
1067 pad->SetSize( { sizeOfSquare, sizeOfSquare } );
1088 pad->SetChamferRectRatio( 0.25 );
1124 wxFAIL_MSG( wxT(
"Unknown Pad Shape" ) );
1159 pad->SetDrillSize( { 0, 0 } );
1164 LSET lset =
pad->GetLayerSet();
1167 if( lset.size() > 0 )
1173 pad->SetPosition( { 0, 0 } );
1174 pad->SetPos0( { 0, 0 } );
1175 pad->TransformShapeWithClearanceToPolygon( padOutline, layer, 0, maxError,
1183 padShape->
Move( padOffset - drillOffset );
1184 padShape->
Rotate( wxPoint( 0, 0 ),
1189 if( editedPadOutline.
Contains( { 0, 0 } ) )
1192 pad->SetSize( wxSize( { 4, 4 } ) );
1194 pad->AddPrimitive( padShape );
1195 padOffset = { 0, 0 };
1202 drillOffset = { 0, 0 };
1207 _(
"The CADSTAR pad definition '%s' has the hole shape outside the " 1208 "pad shape. The hole has been moved to the center of the pad." ),
1214 wxFAIL_MSG( wxT(
"No copper layers defined in the pad?" ) );
1216 pad->SetOffset( drillOffset );
1221 pad->SetOffset( drillOffset );
1235 pad->SetLocked(
true );
1240 wxLogError(
_(
"The CADSTAR pad definition '%s' has import errors: %s" ),
1252 const PAD_ID aCadstarPadID )
1254 size_t index = aCadstarPadID - (long) 1;
1256 if( !( index < aFootprint->Pads().size() ) )
1259 (
long) aCadstarPadID,
1263 return aFootprint->
Pads().at( index );
1269 for( std::pair<GROUP_ID, GROUP> groupPair :
Layout.
Groups )
1271 GROUP& csGroup = groupPair.second;
1283 for( std::pair<GROUP_ID, GROUP> groupPair :
Layout.
Groups )
1285 GROUP& csGroup = groupPair.second;
1287 if( !csGroup.
GroupID.IsEmpty() )
1298 "map (parent group ID=%s, Name=%s)." ),
1307 parentGroup->
AddItem( kiCadGroup );
1316 for( std::pair<BOARD_ID, CADSTAR_BOARD> boardPair :
Layout.
Boards )
1325 if( !board.
GroupID.IsEmpty() )
1337 for( std::pair<FIGURE_ID, FIGURE> figPair :
Layout.
Figures )
1339 FIGURE& fig = figPair.second;
1354 for( std::pair<TEXT_ID, TEXT> txtPair :
Layout.
Texts )
1356 TEXT& csTxt = txtPair.second;
1368 switch( csDim.
Type )
1370 case DIMENSION::TYPE::LINEARDIM:
1373 case DIMENSION::SUBTYPE::ANGLED:
1374 wxLogWarning(
wxString::Format(
_(
"Dimension ID %s is an angled dimension, which " 1375 "has no KiCad equivalent. An aligned dimension " 1376 "was loaded instead." ),
1379 case DIMENSION::SUBTYPE::DIRECT:
1380 case DIMENSION::SUBTYPE::ORTHOGONAL:
1382 if( csDim.
Line.
Style == DIMENSION::LINE::STYLE::EXTERNAL )
1385 _(
"Dimension ID %s has 'External' style in CADSTAR. External " 1386 "dimension styles are not yet supported in KiCad. The dimension " 1387 "object was imported with an internal dimension style instead." ),
1393 if( csDim.
Subtype == DIMENSION::SUBTYPE::ORTHOGONAL )
1417 VECTOR2I crossbarVector = crossbarEnd - crossbarStart;
1419 double height = 0.0;
1421 if( csDim.
Subtype == DIMENSION::SUBTYPE::ORTHOGONAL )
1424 height = heightVector.
y;
1426 height = heightVector.
x;
1430 double angle = crossbarVector.
Angle() + ( M_PI / 2 );
1431 height = heightVector.
x * cos(
angle ) + heightVector.
y * sin(
angle );
1441 wxLogError(
_(
"Unexpected Dimension type (ID %s). This was not imported." ),
1447 case DIMENSION::TYPE::LEADERDIM:
1450 if( csDim.
Line.
Style == DIMENSION::LINE::STYLE::INTERNAL )
1554 wxPoint endPoint = csDim.
Line.
End + endOffset;
1574 case DIMENSION::TYPE::ANGLEDIM:
1576 wxLogError(
_(
"Dimension %s is an angular dimension which has no KiCad equivalent. " 1577 "The object was not imported." ),
1587 for( std::pair<AREA_ID, AREA> areaPair :
Layout.
Areas )
1589 AREA& area = areaPair.second;
1593 int lineThickness = 0;
1616 wxLogWarning(
wxString::Format(
_(
"The CADSTAR area '%s' is marked as a placement " 1617 "area in CADSTAR. Placement areas are not " 1618 "supported in KiCad. Only the supported elements " 1619 "for the area were imported." ),
1626 "equivalent. Pure Placement areas are not supported." ),
1653 "(Symdef ID: '%s')" ),
1658 FOOTPRINT* libFootprint = fpIter->second;
1677 for( std::pair<PART_DEFINITION_PIN_ID, PART::DEFINITION::PIN> pinPair :
1680 PART::DEFINITION::PIN
pin = pinPair.second;
1681 wxString pinName =
pin.Name;
1683 if( pinName.empty() )
1684 pinName =
pin.Identifier;
1686 if( pinName.empty() )
1699 for( std::pair<PAD_ID, PADEXCEPTION> padPair : comp.
PadExceptions )
1704 if( !padEx.
PadCode.IsEmpty() )
1719 wxString padNumber = kiPad->
GetNumber();
1731 footprint->
SetValue( wxEmptyString );
1747 if( !comp.
PartID.IsEmpty() && comp.
PartID != wxT(
"NO_PART" ) )
1759 for( std::pair<DOCUMENTATION_SYMBOL_ID, DOCUMENTATION_SYMBOL> docPair :
1770 "library (Symdef ID: '%s')" ),
1774 SYMDEF_PCB& docSymDefinition = ( *docSymIter ).second;
1775 wxPoint moveVector =
1781 bool mirrorInvert = docSymInstance.
Mirror;
1786 if( !docSymDefinition.
Alternate.IsEmpty() )
1787 groupName += wxT(
" (" ) + docSymDefinition.
Alternate + wxT(
")" );
1795 for( std::pair<FIGURE_ID, FIGURE> figPair : docSymDefinition.
Figures )
1797 FIGURE fig = figPair.second;
1801 m_board, groupID, moveVector, rotationAngle, scalingFactor,
1802 centreOfTransform, mirrorInvert );
1806 for( std::pair<TEXT_ID, TEXT> textPair : docSymDefinition.
Texts )
1808 TEXT txt = textPair.second;
1810 rotationAngle, scalingFactor, centreOfTransform, mirrorInvert );
1820 TEMPLATE& csTemplate = tempPair.second;
1822 int zonelinethickness = 0;
1832 if( !( csTemplate.
NetID.IsEmpty() || csTemplate.
NetID == wxT(
"NONE" ) ) )
1838 _(
"The CADSTAR template '%s' has the setting 'Allow in No Routing Areas' " 1839 "enabled. This setting has no KiCad equivalent, so it has been ignored." ),
1840 csTemplate.
Name ) );
1846 _(
"The CADSTAR template '%s' has the setting 'Box Isolated Pins' " 1847 "enabled. This setting has no KiCad equivalent, so it has been ignored." ),
1848 csTemplate.
Name ) );
1854 _(
"The CADSTAR template '%s' has the setting 'Automatic Repour' " 1855 "enabled. This setting has no KiCad equivalent, so it has been ignored." ),
1856 csTemplate.
Name ) );
1865 _(
"The CADSTAR template '%s' has a non-zero value defined for the " 1866 "'Sliver Width' setting. There is no KiCad equivalent for " 1867 "this, so this setting was ignored." ),
1868 csTemplate.
Name ) );
1875 _(
"The CADSTAR template '%s' has different settings for 'Retain Poured Copper " 1876 "- Disjoint' and 'Retain Poured Copper - Isolated'. KiCad does not " 1877 "distinguish between these two settings. The setting for disjoint copper " 1878 "has been applied as the minimum island area of the KiCad Zone." ),
1879 csTemplate.
Name ) );
1882 long long minIslandArea = -1;
1909 if( csTemplate.
Pouring.
FillType == TEMPLATE::POURING::COPPER_FILL_TYPE::HATCHED )
1926 _(
"The CADSTAR template '%s' has different settings for thermal relief " 1927 "in pads and vias. KiCad only supports one single setting for both. The " 1928 "setting for pads has been applied." ),
1929 csTemplate.
Name ) );
1940 if( spokeWidth < minThickness )
1943 _(
"The CADSTAR template '%s' has thermal reliefs in the original design " 1944 "but the spoke width (%.2f mm) is thinner than the minimum thickness of " 1945 "the zone (%.2f mm). KiCad requires the minimum thickness of the zone " 1946 "to be preserved. Therefore the minimum thickness has been applied as " 1947 "the new spoke width and will be applied next time the zones are " 1952 spokeWidth = minThickness;
1975 NET_ID netid = wxEmptyString;
1977 for( std::pair<NET_ID, NET_PCB> netPair :
Layout.
Nets )
1981 if( net.
Name == powerPlaneLayerName )
1988 if( netid.IsEmpty() )
1990 wxLogError(
_(
"The CADSTAR layer '%s' is defined as a power plane layer. However no " 1991 "net with such name exists. The layer has been loaded but no copper " 1992 "zone was created." ),
1993 powerPlaneLayerName );
1997 for( std::pair<BOARD_ID, CADSTAR_BOARD> boardPair :
Layout.
Boards )
2022 for( std::pair<COPPER_ID, COPPER> copPair :
Layout.
Coppers )
2024 COPPER& csCopper = copPair.second;
2050 shape->GetEnd(), copperWidth, ARC_HIGH_DEF,
2056 copperWidth, ARC_HIGH_DEF,
2069 rawPolys.
Inflate( copperWidth / 2, 32 );
2095 _(
"The CADSTAR design contains COPPER elements, which have no direct KiCad " 2096 "equivalent. These have been imported as a KiCad Zone if solid or hatch " 2097 "filled, or as a KiCad Track if the shape was an unfilled outline (open or " 2162 fillePolys.
Fracture( SHAPE_POLY_SET::POLYGON_MODE::PM_STRICTLY_SIMPLE );
2173 for( std::pair<NET_ID, NET_PCB> netPair :
Layout.
Nets )
2176 wxString netnameForErrorReporting = net.
Name;
2178 std::map<NETELEMENT_ID, long> netelementSizes;
2180 if( netnameForErrorReporting.IsEmpty() )
2183 for( std::pair<NETELEMENT_ID, NET_PCB::VIA> viaPair : net.
Vias )
2189 netelementSizes.insert( { viaPair.first, viaSize } );
2192 for( std::pair<NETELEMENT_ID, NET_PCB::PIN> pinPair : net.
Pins )
2194 NET_PCB::PIN
pin = pinPair.second;
2197 if( footprint ==
nullptr )
2200 _(
"The net '%s' references component ID '%s' which does not exist. " 2201 "This has been ignored." ),
2202 netnameForErrorReporting,
pin.ComponentID ) );
2204 else if( (
pin.PadID - (
long) 1 ) > footprint->
Pads().size() )
2206 wxLogWarning(
wxString::Format(
_(
"The net '%s' references non-existent pad index" 2207 " '%d' in component '%s'. This has been " 2209 netnameForErrorReporting,
2228 if( assocPads.find(
pin.PadID ) != assocPads.end() )
2230 for(
PAD_ID copperPadID : assocPads.at(
pin.PadID ) )
2239 int padsize = std::min(
pad->GetSizeX(),
pad->GetSizeY() );
2240 netelementSizes.insert( { pinPair.first, padsize } );
2248 auto getJunctionSize =
2249 [&](
NETELEMENT_ID aJptNetElemId,
const NET_PCB::CONNECTION_PCB& aConnectionToIgnore ) ->
int 2253 for( NET_PCB::CONNECTION_PCB connection : net.
Connections )
2255 if( connection.Route.RouteVertices.size() == 0 )
2258 if( connection.StartNode == aConnectionToIgnore.StartNode
2259 && connection.EndNode == aConnectionToIgnore.EndNode )
2264 if( connection.StartNode == aJptNetElemId )
2266 int s =
getKiCadLength( connection.Route.RouteVertices.front().RouteWidth );
2267 jptsize = std::max( jptsize, s );
2269 else if( connection.EndNode == aJptNetElemId )
2271 int s =
getKiCadLength( connection.Route.RouteVertices.back().RouteWidth );
2272 jptsize = std::max( jptsize, s );
2280 NET_PCB::ROUTE_VERTEX vertex = aConnectionToIgnore.Route.RouteVertices.front();
2282 if( aConnectionToIgnore.EndNode == aJptNetElemId )
2283 vertex = aConnectionToIgnore.Route.RouteVertices.back();
2291 for( NET_PCB::CONNECTION_PCB connection : net.
Connections )
2293 int startSize = std::numeric_limits<int>::max();
2294 int endSize = std::numeric_limits<int>::max();
2296 if( netelementSizes.find( connection.StartNode ) != netelementSizes.end() )
2297 startSize = netelementSizes.at( connection.StartNode );
2299 startSize = getJunctionSize( connection.StartNode, connection );
2301 if( netelementSizes.find( connection.EndNode ) != netelementSizes.end() )
2302 endSize = netelementSizes.at( connection.EndNode );
2304 endSize = getJunctionSize( connection.EndNode, connection );
2309 if( !connection.Unrouted )
2318 auto findAndReplaceTextField =
2357 wxString varValue = txtvalue.second;
2359 txtVars.insert( { varName, varValue } );
2364 wxString varName = txtvalue.first;
2365 wxString varValue = txtvalue.second;
2367 txtVars.insert( { varName, varValue } );
2372 wxLogError(
_(
"Text Variables could not be set as there is no project loaded." ) );
2380 for( std::pair<ATTRIBUTE_ID, ATTRIBUTE_VALUE> attrPair : aComponent.
AttributeValues )
2391 for( std::pair<ATTRIBUTE_ID, TEXT_LOCATION> textlocPair : aComponent.
TextLocations )
2398 attrval = wxEmptyString;
2402 attrval = wxT(
"${REFERENCE}" );
2417 const NET_PCB::ROUTE& aCadstarRoute,
2418 long aStartWidth,
long aEndWidth )
2420 if( aCadstarRoute.RouteVertices.size() == 0 )
2423 std::vector<PCB_SHAPE*> shapes;
2424 std::vector<NET_PCB::ROUTE_VERTEX> routeVertices = aCadstarRoute.RouteVertices;
2427 if( aStartWidth < routeVertices.front().RouteWidth )
2429 NET_PCB::ROUTE_VERTEX newFrontVertex = aCadstarRoute.RouteVertices.front();
2430 newFrontVertex.RouteWidth = aStartWidth;
2431 newFrontVertex.Vertex.End = aCadstarRoute.StartPoint;
2432 routeVertices.insert( routeVertices.begin(), newFrontVertex );
2436 if( aEndWidth < routeVertices.back().RouteWidth )
2438 NET_PCB::ROUTE_VERTEX newBackVertex = aCadstarRoute.RouteVertices.back();
2439 newBackVertex.RouteWidth = aEndWidth;
2440 routeVertices.push_back( newBackVertex );
2443 POINT prevEnd = aCadstarRoute.StartPoint;
2445 for(
const NET_PCB::ROUTE_VERTEX& v : routeVertices )
2451 shapes.push_back( shape );
2452 prevEnd = v.Vertex.End;
2475 via->SetLocked( aCadstarVia.Fixed );
2479 wxLogError(
_(
"The CADSTAR via code '%s' has different shape from a circle defined. " 2480 "KiCad only supports circular vias so this via type has been changed to " 2481 "be a via with circular shape of %.2f mm diameter." ),
2488 bool start_layer_outside =
2491 bool end_layer_outside =
2495 if( start_layer_outside && end_layer_outside )
2499 else if( ( !start_layer_outside ) && ( !end_layer_outside ) )
2513 return via->GetWidth();
2519 const LAYER_ID& aCadstarLayerOverride,
const wxPoint& aMoveVector,
2520 const double& aRotationAngle,
const double& aScalingFactor,
const wxPoint& aTransformCentre,
2521 const bool& aMirrorInvert )
2524 aContainer->
Add( txt );
2528 RotatePoint( &rotatedTextPos, aTransformCentre, aRotationAngle );
2530 KiROUND( (
double) ( rotatedTextPos.x - aTransformCentre.x ) * aScalingFactor );
2532 KiROUND( (
double) ( rotatedTextPos.y - aTransformCentre.y ) * aScalingFactor );
2533 rotatedTextPos += aTransformCentre;
2545 wxSize unscaledTextSize;
2550 if( unscaledTextSize.x == 0 )
2605 wxFAIL_MSG( wxT(
"Unknown Alignment - needs review!" ) );
2610 txt->
Flip( aTransformCentre,
true );
2614 if( aScalingFactor != 1.0 )
2616 wxSize scaledTextSize;
2617 scaledTextSize.x =
KiROUND( (
double) unscaledTextSize.x * aScalingFactor );
2618 scaledTextSize.y =
KiROUND( (
double) unscaledTextSize.y * aScalingFactor );
2624 txt->
Move( aMoveVector );
2629 LAYER_ID layersToDrawOn = aCadstarLayerOverride;
2631 if( layersToDrawOn.IsEmpty() )
2632 layersToDrawOn = aCadstarText.
LayerID;
2644 newtxt = static_cast<PCB_TEXT*>( txt->
Duplicate() );
2647 if( !aCadstarGroupID.IsEmpty() )
2658 if( !aCadstarGroupID.IsEmpty() )
2667 const int& aLineThickness,
2668 const wxString& aShapeName,
2671 const wxPoint& aMoveVector,
2672 const double& aRotationAngle,
2673 const double& aScalingFactor,
2674 const wxPoint& aTransformCentre,
2675 const bool& aMirrorInvert )
2677 switch( aCadstarShape.
Type )
2683 aContainer, aCadstarGroupID, aMoveVector, aRotationAngle,
2684 aScalingFactor, aTransformCentre, aMirrorInvert );
2686 aContainer, aCadstarGroupID, aMoveVector, aRotationAngle,
2687 aScalingFactor, aTransformCentre, aMirrorInvert );
2693 _(
"The shape for '%s' is Hatch filled in CADSTAR, which has no KiCad equivalent. " 2694 "Using solid fill instead." ),
2709 aCadstarShape, -1, aContainer, aMoveVector, aRotationAngle, aScalingFactor,
2710 aTransformCentre, aMirrorInvert );
2712 shapePolys.
Fracture( SHAPE_POLY_SET::POLYGON_MODE::PM_STRICTLY_SIMPLE );
2719 if( !aCadstarGroupID.IsEmpty() )
2729 const int& aLineThickness,
2732 const wxPoint& aMoveVector,
2733 const double& aRotationAngle,
2734 const double& aScalingFactor,
2735 const wxPoint& aTransformCentre,
2736 const bool& aMirrorInvert )
2738 for(
CUTOUT cutout : aCutouts )
2741 aCadstarGroupID, aMoveVector, aRotationAngle, aScalingFactor,
2742 aTransformCentre, aMirrorInvert );
2749 const int& aLineThickness,
2752 const wxPoint& aMoveVector,
2753 const double& aRotationAngle,
2754 const double& aScalingFactor,
2755 const wxPoint& aTransformCentre,
2756 const bool& aMirrorInvert )
2759 aCadstarGroupID, aMoveVector,
2760 aRotationAngle, aScalingFactor,
2761 aTransformCentre, aMirrorInvert );
2765 shape->SetWidth( aLineThickness );
2766 shape->SetLayer( aKiCadLayer );
2767 shape->SetParent( aContainer );
2774 const std::vector<VERTEX>& aCadstarVertices,
2777 const wxPoint& aMoveVector,
2778 const double& aRotationAngle,
2779 const double& aScalingFactor,
2780 const wxPoint& aTransformCentre,
2781 const bool& aMirrorInvert )
2783 std::vector<PCB_SHAPE*> drawSegments;
2785 if( aCadstarVertices.size() < 2 )
2787 return drawSegments;
2789 const VERTEX* prev = &aCadstarVertices.at( 0 );
2792 for(
size_t i = 1; i < aCadstarVertices.size(); i++ )
2794 cur = &aCadstarVertices.at( i );
2796 aMoveVector, aRotationAngle, aScalingFactor,
2797 aTransformCentre, aMirrorInvert ) );
2801 return drawSegments;
2806 const VERTEX& aCadstarVertex,
2809 const wxPoint& aMoveVector,
2810 const double& aRotationAngle,
2811 const double& aScalingFactor,
2812 const wxPoint& aTransformCentre,
2813 const bool& aMirrorInvert )
2817 double arcStartAngle, arcEndAngle, arcAngle;
2821 wxPoint centerPoint;
2826 centerPoint = ( startPoint + endPoint ) / 2;
2833 switch( aCadstarVertex.
Type )
2844 shape->
SetEnd( endPoint );
2865 arcAngle = arcEndAngle - arcStartAngle;
2879 shape->
Flip( aTransformCentre,
true );
2881 if( aScalingFactor != 1.0 )
2883 shape->
Move( -aTransformCentre );
2884 shape->
Scale( aScalingFactor );
2885 shape->
Move( aTransformCentre );
2888 if( aRotationAngle != 0.0 )
2889 shape->
Rotate( aTransformCentre, aRotationAngle );
2891 if( aMoveVector != wxPoint{ 0, 0 } )
2892 shape->
Move( aMoveVector );
2894 if(
isFootprint( aContainer ) && shape !=
nullptr )
2895 static_cast<FP_SHAPE*>( shape )->SetLocalCoord();
2897 if( !aCadstarGroupID.IsEmpty() )
2905 const int& aLineThickness,
2924 for(
int i = 0; i < polygon.
HoleCount( 0 ); i++ )
2932 const int& aLineThickness,
2934 const wxPoint& aMoveVector,
2935 const double& aRotationAngle,
2936 const double& aScalingFactor,
2937 const wxPoint& aTransformCentre,
2938 const bool& aMirrorInvert )
2943 aContainer, noGroup, aMoveVector,
2944 aRotationAngle, aScalingFactor,
2945 aTransformCentre, aMirrorInvert );
2956 noGroup, aMoveVector,
2957 aRotationAngle, aScalingFactor,
2958 aTransformCentre, aMirrorInvert );
2969 if( aLineThickness > 0 )
2971 polySet.
Inflate( aLineThickness / 2, 32,
2972 SHAPE_POLY_SET::CORNER_STRATEGY::ROUND_ALL_CORNERS );
2980 for(
int j = 0; j < polySet.
HoleCount( i ); ++j )
2997 switch( shape->GetShape() )
3001 if( shape->GetClass() == wxT(
"MGRAPHIC" ) )
3006 if( shape->EndsSwapped() )
3013 SHAPE_ARC arc( shape->GetCenter(), shape->GetStart(), shape->GetArcAngle() / 10.0 );
3015 if( shape->EndsSwapped() )
3023 if( shape->GetClass() == wxT(
"MGRAPHIC" ) )
3031 lineChain.
Append( shape->GetStartX(), shape->GetStartY() );
3032 lineChain.
Append( shape->GetEndX(), shape->GetEndY() );
3037 wxFAIL_MSG( wxT(
"Drawsegment type is unexpected. Ignored." ) );
3057 const std::vector<PCB_SHAPE*> aShapes,
3060 int aWidthOverride )
3062 std::vector<PCB_TRACK*> tracks;
3074 if( aTrack->GetLength() != 0 )
3076 tracks.push_back( aTrack );
3087 switch( shape->GetShape() )
3090 if( shape->GetClass() == wxT(
"MGRAPHIC" ) )
3098 track =
new PCB_ARC( aParentContainer, &arc );
3102 SHAPE_ARC arc( shape->GetStart(), shape->GetArcMid(), shape->GetEnd(), 0 );
3104 if( shape->EndsSwapped() )
3107 track =
new PCB_ARC( aParentContainer, &arc );
3111 if( shape->GetClass() == wxT(
"MGRAPHIC" ) )
3114 track =
new PCB_TRACK( aParentContainer );
3120 track =
new PCB_TRACK( aParentContainer );
3121 track->
SetStart( shape->GetStart() );
3122 track->
SetEnd( shape->GetEnd() );
3127 wxFAIL_MSG( wxT(
"Drawsegment type is unexpected. Ignored." ) );
3131 if( aWidthOverride == -1 )
3132 track->
SetWidth( shape->GetWidth() );
3137 track->
SetLayer( shape->GetLayer() );
3141 if( aNet !=
nullptr )
3149 if( prevTrack !=
nullptr )
3151 int offsetAmount = ( track->
GetWidth() / 2 ) - ( prevTrack->
GetWidth() / 2 );
3153 if( offsetAmount > 0 )
3156 wxPoint newStart = track->
GetStart();
3160 else if( offsetAmount < 0 )
3163 wxPoint newEnd = prevTrack->
GetEnd();
3165 prevTrack->
SetEnd( newEnd );
3175 synthTrack->SetStart( prevTrack->
GetEnd() );
3176 synthTrack->SetEnd( track->
GetStart() );
3177 synthTrack->SetWidth( minWidth );
3178 synthTrack->SetLocked( track->
IsLocked() );
3179 synthTrack->SetNet( track->
GetNet() );
3180 synthTrack->SetLayer( track->
GetLayer() );
3181 addTrack( synthTrack );
3186 addTrack( prevTrack );
3201 const wxString& aAttributeValue )
3214 aFootprint->
SetValue( aAttributeValue );
3215 txt = &aFootprint->
Value();
3219 txt =
new FP_TEXT( aFootprint );
3220 aFootprint->
Add( txt );
3221 txt->
SetText( aAttributeValue );
3234 aFootprint->
SetValue( aAttributeValue );
3235 txt = &aFootprint->
Value();
3240 txt =
new FP_TEXT( aFootprint );
3241 aFootprint->
Add( txt );
3242 txt->
SetText( aAttributeValue );
3251 txt->
SetPos0( rotatedTextPos );
3257 if( aCadstarAttrLoc.
Mirror )
3269 if( txtSize.x == 0 )
3327 wxFAIL_MSG( wxT(
"Unknown Alignment - needs review!" ) );
3335 const wxPoint& aRefPoint,
3336 const long& aOffsetAmount )
3338 VECTOR2I v( *aPointToOffset - aRefPoint );
3344 aPointToOffset->x = offsetted.
x;
3345 aPointToOffset->y = offsetted.
y;
3349 *aPointToOffset = aRefPoint;
3431 const std::map<ATTRIBUTE_ID, ATTRIBUTE_VALUE>& aCadstarAttributeMap )
3433 wxCHECK( aCadstarAttributeMap.find( aCadstarAttributeID ) != aCadstarAttributeMap.end(),
3436 return aCadstarAttributeMap.at( aCadstarAttributeID ).Value;
3453 const PART_ID& aCadstarPartID )
3489 if( hcode.
Hatches.size() < 1 )
3502 if( hcode.
Hatches.size() < 1 )
3514 if( hcode.
Hatches.size() < 1 )
3539 if( hcode.
Hatches.size() != 2 )
3542 _(
"The CADSTAR Hatching code '%s' has %d hatches defined. " 3543 "KiCad only supports 2 hatches (crosshatching) 90 degrees apart. " 3544 "The imported hatching is crosshatched." ),
3549 if( hcode.
Hatches.at( 0 ).LineWidth != hcode.
Hatches.at( 1 ).LineWidth )
3552 _(
"The CADSTAR Hatching code '%s' has different line widths for each " 3553 "hatch. KiCad only supports one width for the hatching. The imported " 3554 "hatching uses the width defined in the first hatch definition, i.e. " 3564 _(
"The CADSTAR Hatching code '%s' has different step sizes for each " 3565 "hatch. KiCad only supports one step size for the hatching. The imported " 3566 "hatching uses the step size defined in the first hatching definition, " 3573 if( abs( hcode.
Hatches.at( 0 ).OrientAngle - hcode.
Hatches.at( 1 ).OrientAngle )
3577 _(
"The hatches in CADSTAR Hatching code '%s' have an angle " 3578 "difference of %.1f degrees. KiCad only supports hatching 90 " 3579 "degrees apart. The imported hatching has two hatches 90 " 3580 "degrees apart, oriented %.1f degrees from horizontal." ),
3583 - hcode.
Hatches.at( 1 ).OrientAngle ) ),
3612 wxString prefix = wxEmptyString;
3613 wxString suffix = wxEmptyString;
3614 size_t startpos = aCadstarDim.
Text.
Text.Find( wxT(
"<@DISTANCE" ) );
3616 if( startpos != wxNOT_FOUND )
3619 wxString remainingStr = aCadstarDim.
Text.
Text.Mid( startpos );
3620 size_t endpos = remainingStr.Find(
"@>" );
3624 if( suffix.StartsWith( wxT(
"mm" ) ) )
3627 suffix = suffix.Mid( 2 );
3645 switch( dimensionUnits )
3651 "is not supported in KiCad. Millimeters were " 3652 "applied instead." ),
3668 wxFAIL_MSG( wxT(
"We should have handled design units before coming here!" ) );
3675 std::map<TEMPLATE_ID, std::set<TEMPLATE_ID>> winningOverlaps;
3683 int retval = std::max( aZoneA->
GetLocalClearance(), aZoneB->GetLocalClearance() );
3692 [&](
ZONE* aLowerZone,
ZONE* aHigherZone ) ->
double 3695 intersectShape.
Inflate( inflateValue( aLowerZone, aHigherZone ) , 32 );
3704 lowerZoneFill.BooleanSubtract( lowerZoneOutline,
3707 double leftOverArea = lowerZoneFill.Area();
3709 return leftOverArea;
3712 auto intersectionAreaOfZoneOutlines =
3713 [&](
ZONE* aZoneA,
ZONE* aZoneB ) ->
double 3716 outLineA.
Inflate( inflateValue( aZoneA, aZoneB ), 32 );
3719 outLineB.
Inflate( inflateValue( aZoneA, aZoneB ), 32 );
3723 return outLineA.Area();
3727 auto isLowerPriority =
3730 return winningOverlaps[b].count( a ) > 0;
3733 for( std::map<TEMPLATE_ID, ZONE*>::iterator it1 =
m_zonesMap.begin();
3737 ZONE* thisZone = it1->second;
3742 for( std::map<TEMPLATE_ID, ZONE*>::iterator it2 = it1;
3746 ZONE* otherZone = it2->second;
3748 if( thisTemplate.
ID == otherTemplate.
ID )
3757 if( intersectionAreaOfZoneOutlines( thisZone, otherZone ) == 0 )
3766 if( thisZonePolyFill.
Area() > 0.0 && otherZonePolyFill.
Area() > 0.0 )
3769 double areaThis = errorArea( thisZone, otherZone );
3771 double areaOther = errorArea( otherZone, thisZone );
3773 if( areaThis > areaOther )
3776 winningOverlaps[thisTemplate.
ID].insert( otherTemplate.
ID );
3781 winningOverlaps[otherTemplate.
ID].insert( thisTemplate.
ID );
3784 else if( thisZonePolyFill.
Area() > 0.0 )
3787 winningOverlaps[thisTemplate.
ID].insert( otherTemplate.
ID );
3789 else if( otherZonePolyFill.
Area() > 0.0 )
3792 winningOverlaps[otherTemplate.
ID].insert( thisTemplate.
ID );
3798 if( intersectionAreaOfZoneOutlines( thisZone, otherZone ) != 0 )
3801 winningOverlaps[otherTemplate.
ID].insert( thisTemplate.
ID );
3803 winningOverlaps[thisTemplate.
ID].insert( otherTemplate.
ID );
3812 std::set<TEMPLATE_ID> intersectingIDs;
3814 for(
const std::pair<
TEMPLATE_ID, std::set<TEMPLATE_ID>>& idPair : winningOverlaps )
3816 intersectingIDs.insert( idPair.first );
3817 intersectingIDs.insert( idPair.second.begin(), idPair.second.end() );
3821 std::vector<TEMPLATE_ID> sortedIDs;
3825 sortedIDs.push_back(
id );
3829 std::sort( sortedIDs.begin(), sortedIDs.end(), isLowerPriority );
3835 if( prevID.IsEmpty() )
3841 wxASSERT( !isLowerPriority(
id, prevID ) );
3843 int newPriority =
m_zonesMap.at( prevID )->GetPriority();
3846 if( isLowerPriority( prevID,
id ) )
3849 m_zonesMap.at(
id )->SetPriority( newPriority );
3854 for(
const std::pair<
TEMPLATE_ID, std::set<TEMPLATE_ID>>& idPair : winningOverlaps )
3858 for(
const TEMPLATE_ID& losingID : idPair.second )
3861 >
m_zonesMap.at( winningID )->GetPriority() )
3901 if( aCadstarNetID.IsEmpty() )
3907 return m_netMap.at( aCadstarNetID );
3914 wxString newName = csNet.Name;
3916 if( csNet.Name.IsEmpty() )
3918 if( csNet.Pins.size() > 0 )
3922 NET_PCB::PIN firstPin = ( *csNet.Pins.begin() ).second;
3925 newName = wxT(
"Net-(" );
3927 newName << wxT(
"-Pad" ) <<
wxString::Format( wxT(
"%ld" ), firstPin.PadID );
3928 newName << wxT(
")" );
3932 wxFAIL_MSG( wxT(
"A net with no pins associated?" ) );
3933 newName = wxT(
"csNet-" );
3939 && csNet.NetClassID != wxT(
"NONE" ) )
3941 wxLogMessage(
_(
"The CADSTAR design contains nets with a 'Net Class' assigned. KiCad " 3942 "does not have an equivalent to CADSTAR's Net Class so these elements " 3943 "were not imported. Note: KiCad's version of 'Net Class' is closer to " 3944 "CADSTAR's 'Net Route Code' (which has been imported for all nets)." ) );
3949 && csNet.SpacingClassID != wxT(
"NONE" ) )
3951 wxLogWarning(
_(
"The CADSTAR design contains nets with a 'Spacing Class' assigned. " 3952 "KiCad does not have an equivalent to CADSTAR's Spacing Class so " 3953 "these elements were not imported. Please review the design rules as " 3954 "copper pours will affected by this." ) );
3959 NETCLASSPTR netclass;
3961 std::tuple<ROUTECODE_ID, NETCLASS_ID, SPACING_CLASS_ID> key = { csNet.RouteCodeID,
3963 csNet.SpacingClassID };
3971 wxString netClassName;
3975 netClassName += wxT(
"Route code: " ) + rc.
Name;
3977 if( !csNet.NetClassID.IsEmpty() )
3980 netClassName += wxT(
" | Net class: " ) + nc.
Name;
3983 if( !csNet.SpacingClassID.IsEmpty() )
3986 netClassName += wxT(
" | Spacing class: " ) + sp.
Name;
3990 netclass->SetName( netClassName );
3996 netclass->Add( newName );
3999 m_netMap.insert( { aCadstarNetID, netInfo } );
4008 bool aDetectMaxLayer )
4061 switch( layer.Type )
4122 parentGroup->AddItem( aKiCadItem );
4127 const wxString& aName )
4129 wxString groupName = aName;
4139 docSymGroup->
SetName( groupName );
4141 m_groupMap.insert( { groupID, docSymGroup } );
void SetMirrored(bool isMirrored)
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.
std::vector< VERTEX > Vertices
COPPERCODE getCopperCode(const COPPERCODE_ID &aCadstaCopperCodeID)
COMPONENT_ID VariantParentComponentID
int getKiCadLength(long long aCadstarLength)
LAYER_ID LayerID
Move all objects in the Symdef to this layer.
bool AddItem(BOARD_ITEM *aItem)
Add item to group.
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.
void addAttribute(const ATTRIBUTE_LOCATION &aCadstarAttrLoc, const ATTRIBUTE_ID &aCadstarAttributeID, FOOTPRINT *aFootprint, const wxString &aAttributeValue)
Adds a CADSTAR Attribute to a KiCad footprint.
int getKiCadHatchCodeGap(const HATCHCODE_ID &aCadstarHatchcodeID)
virtual void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT)=0
Adds an item to the container.
void SetIslandRemovalMode(ISLAND_REMOVAL_MODE aRemove)
void applyDimensionSettings(const DIMENSION &aCadstarDim, PCB_DIMENSION_BASE *aKiCadDim)
std::vector< PAD_ID > AssociatedPadIDs
virtual std::map< wxString, wxString > & GetTextVars() const
virtual void SetMaxProgress(int aMaxProgress)=0
Fix the value that gives the 100 percent progress bar length (inside the current virtual zone).
std::map< ROUTECODE_ID, ROUTECODE > RouteCodes
void SetHatchThickness(int aThickness)
T NormalizeAngleNeg(T Angle)
Normalize angle to be in the 0.0 .. -360.0 range: angle is in 1/10 degrees.
void SetLocked(bool aLocked) override
Create a duplicate of this item with linked list members set to NULL.
POURING Pouring
Copper pour settings (e.g. relief / hatching /etc.)
PADCODE_ID PadCode
If not empty, override padcode.
virtual void BeginPhase(int aPhase)=0
Initialize the aPhase virtual zone of the dialog progress bar.
bool HasFilledPolysForLayer(PCB_LAYER_ID aLayer) const
Inbuilt layer type (cannot be assigned to user layers)
int OutlineCount() const
Return the number of vertices in a given outline/hole.
Inbuilt layer type (cannot be assigned to user layers)
Inbuilt layer type (cannot be assigned to user layers)
long LeaderAngle
Only for TYPE=LEADERLINE subnode "LEADERANG".
void SetZoneName(const wxString &aName)
bool ThermalReliefOnVias
false when subnode "NOVIARELIEF" is present
static const double TXT_HEIGHT_RATIO
CADSTAR fonts are drawn on a 24x24 integer matrix, where the each axis goes from 0 to 24.
NETINFO_ITEM * getKiCadNet(const NET_ID &aCadstarNetID)
Searches m_netMap and returns the NETINFO_ITEM pointer if exists.
Container for project specific data.
std::map< PART_DEFINITION_PIN_ID, PIN > Pins
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
std::map< NETELEMENT_ID, PIN > Pins
void SetHeight(int aHeight)
Set the distance from the feature points to the crossbar line.
bool PCBonlyPad
From CADSTAR Help: "The PCB Only Pad property can be used to stop ECO Update, Back Annotation,...
void SetDoNotAllowTracks(bool aEnable)
std::pair< POINT, POINT > DesignArea
COPPERCODE_ID CopperCodeID
From CADSTAR Help: "Copper Code is for selecting the width of the line used to draw the outline and f...
void SetFilled(bool aFlag)
double getAngleDegrees(const long long &aCadstarAngle)
long Offset
Offset from the measurement point.
void SetEnd(const wxPoint &aEnd)
wxString ReferenceName
This is the name which identifies the symbol in the library Multiple components may exist with the sa...
ZONE * getZoneFromCadstarShape(const SHAPE &aCadstarShape, const int &aLineThickness, BOARD_ITEM_CONTAINER *aParentContainer)
virtual void SetPosition(const wxPoint &aPos) override
std::vector< HATCH > Hatches
long SignalNum
This is undefined if the net has been given a name.
const wxPoint & GetEnd() const
std::map< COMPONENT_ID, FOOTPRINT * > m_componentMap
Map between Cadstar and KiCad components on the board.
void BooleanAdd(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset difference For aFastMode meaning, see function booleanOp.
Manage layers needed to make a physical board.
std::map< ATTRIBUTE_ID, ATTRNAME > AttributeNames
bool NoVias
From CADSTAR Help: "Check this button to specify that any area created by the Rectangle,...
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
void SetUnitsFormat(const DIM_UNITS_FORMAT aFormat)
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
double getAngleTenthDegree(const long long &aCadstarAngle)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
long ScaleRatioNumerator
Documentation symbols can be arbitrarily scaled when added to a design.
void Scale(double aScale)
void SetHatchStyle(ZONE_BORDER_DISPLAY_STYLE aStyle)
TEXT_FIELD_NAME
These are special fields in text objects enclosed between the tokens '<@' and '>' such as <@[FIELD_NA...
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 wxPoint &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const wxPoint &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
std::map< COMP_AREA_ID, COMPONENT_AREA > ComponentAreas
std::map< VARIANT_ID, VARIANT > Variants
void SetEnd(const wxPoint &aEnd)
NETINFO_ITEM * GetNet() const
Return #NET_INFO object for a given item.
wxPoint getKiCadPoint(const wxPoint &aCadstarPoint)
Scales, offsets and inverts y axis to make the point usable directly in KiCad.
void SetTextAngle(double aAngle) override
A set of BOARD_ITEMs (i.e., without duplicates).
std::map< LINECODE_ID, LINECODE > LineCodes
void SetPolyShape(const SHAPE_POLY_SET &aShape)
wxString getAttributeValue(const ATTRIBUTE_ID &aCadstarAttributeID, const std::map< ATTRIBUTE_ID, ATTRIBUTE_VALUE > &aCadstarAttributeMap)
LAYER_MAPPING_HANDLER m_layerMappingHandler
Callback to get layer mapping.
EXTENSION_LINE ExtensionLineParams
Not applicable to TYPE=LEADERDIM.
void SetTextAngle(double aAngle) override
void SetLayerSet(LSET aLayerSet) override
COPPERCODE_ID CopperCodeID
SHAPE_POLY_SET * Outline()
std::map< AREA_ID, AREA > Areas
#define COMPONENT_NAME_2_ATTRID
Component Name 2 Attribute ID - typically used for indicating the placement of designators in placeme...
bool BoxIsolatedPins
true when subnode "BOXPINS" is present
wxPoint m_designCenter
Used for calculating the required offset to apply to the Cadstar design so that it fits in KiCad canv...
bool Contains(PCB_LAYER_ID aLayer)
See if the layer set contains a PCB layer.
bool NoTracks
From CADSTAR Help: "Check this button to specify that any area created by the Rectangle,...
bool EndsSwapped() const
Have the start and end points been swapped since they were set?
Filled closed shape (hatch fill).
Smd pad, appears on the solder paste layer (default)
void SetTextPos(const wxPoint &aPoint)
PCB_GROUP * getKiCadGroup(const GROUP_ID &aCadstarGroupID)
LAYERPAIR getLayerPair(const LAYERPAIR_ID &aCadstarLayerPairID)
PHYSICAL_LAYER_ID PhysicalLayerStart
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
std::map< FIGURE_ID, FIGURE > Figures
void SetText(const wxString &aNewText)
Set the override text - has no effect if m_overrideValue == false.
double GetArcAngle() const
double GetTextAngle() const
void SetCopperLayerCount(int aCount)
bool calculateZonePriorities(PCB_LAYER_ID &aLayer)
Tries to make a best guess as to the zone priorities based on the pour status.
std::map< TRUNK_ID, TRUNK > Trunks
long ScaleRatioDenominator
Documentation symbols can be arbitrarily scaled when added to a design.
long PAD_ID
Pad identifier (pin) in the PCB.
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
void remapUnsureLayers()
Callback m_layerMappingHandler for layers we aren't sure of.
SHAPE_LINE_CHAIN & Hole(int aOutline, int aHole)
Return the aIndex-th subpolygon in the set.
const wxPoint & GetStart0() const
double Area()
Count the number of arc shapes present.
std::map< COPPERCODE_ID, COPPERCODE > CopperCodes
std::map< MATERIAL_ID, MATERIAL > Materials
std::vector< CONNECTION_PCB > Connections
#define COMPONENT_NAME_ATTRID
Component Name Attribute ID - typically used for placement of designators on silk screen.
bool m_doneSpacingClassWarning
Used by getKiCadNet() to avoid multiple duplicate warnings.
std::map< SYMDEF_ID, FOOTPRINT * > m_libraryMap
Map between Cadstar and KiCad components in the library.
wxString Name
Designator e.g. "C1", "R1", etc.
std::map< VIACODE_ID, VIACODE > ViaCodes
void SetArcAngleAndEnd(double aAngle, bool aCheckNegativeAngle=false)
Set the end point from the angle center and start.
ROUTECODE getRouteCode(const ROUTECODE_ID &aCadstarRouteCodeID)
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
From CADSTAR Help: "Area is for creating areas within which, and nowhere else, certain operations are...
const SHAPE_POLY_SET & GetFilledPolysList(PCB_LAYER_ID aLayer) const
bool HasLocation
Flag to know if this ATTRIBUTE_VALUE has a location i.e.
STYLE Style
Subnode="DIMLINETYPE".
long MinIsolatedCopper
The value is the length of one side of a notional square.
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
ALIGNMENT Alignment
In CADSTAR The default alignment for a TEXT object (when "(No Alignment()" is selected) Bottom Left o...
void checkAndLogHatchCode(const HATCHCODE_ID &aCadstarHatchcodeID)
void SetTextSize(const wxSize &aNewSize)
std::set< HATCHCODE_ID > m_hatchcodesTested
Used by checkAndLogHatchCode() to avoid multiple duplicate warnings.
virtual void SetLocked(bool aLocked)
Modify the 'lock' status for of the item.
void loadComponentAttributes(const COMPONENT &aComponent, FOOTPRINT *aFootprint)
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 loadDocumentationSymbols()
bool SetLayerType(PCB_LAYER_ID aLayer, LAYER_T aLayerType)
Change the type of the layer given by aLayer.
void NORMALIZE_ANGLE_180(T &Angle)
std::map< TEXT_ID, TEXT > Texts
void RotatePoint(int *pX, int *pY, double angle)
VARIANT_HIERARCHY VariantHierarchy
LAYER_ID LayerID
ID on which to draw this [param1].
A logical library item identifier and consists of various portions much like a URI.
bool Routing
From CADSTAR Help: "Area can be used to place routes during Automatic Routing.
std::map< wxString, wxString > FilenamesToTextMap
CADSTAR doesn't have user defined text fields but does allow loading text from a file.
void logBoardStackupWarning(const wxString &aCadstarLayerName, const PCB_LAYER_ID &aKiCadLayer)
virtual void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate this object.
std::map< LAYER_ID, LAYER > Layers
void loadLibraryPads(const SYMDEF_PCB &aComponent, FOOTPRINT *aFootprint)
virtual bool IsLocked() const
int PointCount() const
Return the number of points (vertices) in this line chain.
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
void SetPriority(unsigned aPriority)
std::map< LAYERPAIR_ID, LAYERPAIR > LayerPairs
Default vias to use between pairs of layers.
void SetExtensionOffset(int aOffset)
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
An orthogonal dimension is like an aligned dimension, but the extension lines are locked to the X or ...
void SetFillMode(ZONE_FILL_MODE aFillMode)
long Thickness
Note: Units of length are defined in file header.
int BuildBoardThicknessFromStackup() const
POINT Origin
Origin of the component (this is used as the reference point when placing the component in the design...
long MaxPhysicalLayer
Should equal number of copper layers.
std::map< TEMPLATE_ID, TEMPLATE > Templates
wxString Name
This name can be different to the PART name.
ALIGNMENT Alignment
In CADSTAR The default alignment for a TEXT object (when "(No Alignment()" is selected) Bottom Left o...
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
This file contains miscellaneous commonly used macros and functions.
UNITS Units
Units to display for linear dimensions.
void SetLineThickness(int aWidth)
For better understanding of the points that make a dimension:
wxString HatchCodeID
Only Applicable for HATCHED Type.
std::vector< FOOTPRINT * > GetLoadedLibraryFootpints() const
Return a copy of the loaded library footprints (caller owns the objects)
void SetIsRuleArea(bool aEnable)
ATTRIBUTE_LOCATION AttributeLocation
wxPoint GetCenter0() const
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...
From CADSTAR Help: "Area is for creating areas within which, and nowhere else, certain operations are...
long ReliefWidth
if undefined inherits from design
void SetStart(const wxPoint &aStart)
wxPoint GetArcMid0() const
int GetLineThickness(PCB_LAYER_ID aLayer) const
Return the default graphic segment thickness from the layer class for the given layer.
A shape of copper in the component footprint.
LAYER_TYPE getLayerType(const LAYER_ID aCadstarLayerID)
std::map< NET_ID, NET_PCB > Nets
Contains tracks and vias.
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void drawCadstarText(const TEXT &aCadstarText, BOARD_ITEM_CONTAINER *aContainer, const GROUP_ID &aCadstarGroupID=wxEmptyString, const LAYER_ID &aCadstarLayerOverride=wxEmptyString, const wxPoint &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const wxPoint &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
virtual void Move(const wxPoint &aMoveVector) override
Move this object.
virtual void SetVisible(bool aVisible)
std::map< GROUP_ID, PCB_GROUP * > m_groupMap
Map between Cadstar and KiCad groups.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
void Parse()
Parses the file.
void SetLayerName(const wxString &aName)
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
virtual const wxPoint & GetStart() const
The dimension's origin is the first feature point for the dimension.
long UnitDisplPrecision
Number of decimal points to display for linear dimensions.
like PAD_PTH, but not plated
std::map< LAYER_ID, CADSTAR_PAD_SHAPE > Reassigns
void loadLibraryAreas(const SYMDEF_PCB &aComponent, FOOTPRINT *aFootprint)
PAD * getKiCadPad(const COMPONENT_PAD &aCadstarPad, FOOTPRINT *aParent)
bool m_doneNetClassWarning
Used by getKiCadNet() to avoid multiple duplicate warnings.
double getPolarAngle(const wxPoint &aPoint)
Inherits from design units (assumed Assignments->Technology->Units)
LSET is a set of PCB_LAYER_IDs.
pads are covered by copper
Represents a point in x,y coordinates.
int m_numCopperLayers
Number of layers in the design.
virtual void SetText(const wxString &aText)
PART getPart(const PART_ID &aCadstarPartID)
void SetHatchGap(int aStep)
void Move(const VECTOR2I &aVector) override
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 wxPoint &aMoveVector={ 0, 0 }, const double &aRotationAngle=0.0, const double &aScalingFactor=1.0, const wxPoint &aTransformCentre={ 0, 0 }, const bool &aMirrorInvert=false)
Uses PCB_SHAPE to draw the vertices on m_board object.
long ThermalReliefPadsAngle
Orientation for the thermal reliefs.
PAD_SIDE Side
See PAD_SIDE.
void initStackupItem(const LAYER &aCadstarLayer, BOARD_STACKUP_ITEM *aKiCadItem, int aDielectricSublayer)
bool AllowInNoRouting
true when subnode "IGNORETRN" is present
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
HATCHCODE_ID HatchCodeID
Only for FillType = HATCHED.
std::map< PAD_ID, COMPONENT_PAD > ComponentPads
void SetDoNotAllowPads(bool aEnable)
void loadLibraryCoppers(const SYMDEF_PCB &aComponent, FOOTPRINT *aFootprint)
void SetClearance(int aClearance)
Represent a set of closed polygons.
std::map< PART_ID, PART > PartDefinitions
DIMENSION_ID ID
Some ID (doesn't seem to be used) subnode="DIMREF".
constexpr double PCB_IU_PER_MM
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
SHAPE_LINE_CHAIN & Outline(int aIndex)
int GetLocalClearance(wxString *aSource) const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
bool Placement
From CADSTAR Help: "Auto Placement can place components within this area.
virtual void SetEnd(const wxPoint &aPoint)
bool isFootprint(BOARD_ITEM_CONTAINER *aContainer)
GROUP_ID GroupID
If not empty, this GROUP is part of another GROUP.
long Precision
Number of decimal points to display in the measurement [param3].
LINECODE_ID LineCodeID
param0
long LeaderLineLength
Only for TYPE=LEADERLINE Length of the angled part of the leader line [param5].
int loadNetVia(const NET_ID &aCadstarNetID, const NET_PCB::VIA &aCadstarVia)
Load via and return via size.
long Width
Defaults to 0 if using system fonts or, if using CADSTAR font, default to equal height (1:1 aspect ra...
Inbuilt layer type (cannot be assigned to user layers)
Loads a cpa file into a KiCad BOARD object.
std::set< PADCODE_ID > m_padcodesTested
Used by getKiCadPad() to avoid multiple duplicate warnings.
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
PCB_LAYER_ID getKiCadCopperLayerID(unsigned int aLayerNum, bool aDetectMaxLayer=true)
TECHNOLOGY_SECTION Technology
std::map< PADCODE_ID, PADCODE > PadCodes
The highest PHYSICAL_LAYER_ID currently defined (i.e.
A collection of nets and the parameters used to route or test these nets.
void SetPrefix(const wxString &aPrefix)
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Changes the name of the layer given by aLayer.
bool ThermalReliefOnPads
false when subnode "NOPINRELIEF" is present
std::map< SYMDEF_ID, SYMDEF_PCB > ComponentDefinitions
void SetExtensionHeight(int aHeight)
std::map< NETCLASS_ID, CADSTAR_NETCLASS > NetClasses
std::vector< COMPONENT_COPPER > ComponentCoppers
const wxString & GetNumber() const
void SetStart(const wxPoint &aStart)
void SetDoNotAllowVias(bool aEnable)
void applyRouteOffset(wxPoint *aPointToOffset, const wxPoint &aRefPoint, const long &aOffsetAmount)
CADSTAR's Post Processor does an action called "Route Offset" which is applied when a route is wider ...
void SetWidth(int aWidth)
SYMDEF_ID SymdefID
Normally documentation symbols only have TEXT, FIGURE and TEXT_LOCATION objects which are all drawn o...
NETCLASSES & GetNetClasses() const
static LSET AllLayersMask()
void SetSuffix(const wxString &aSuffix)
void SetMaterial(const wxString &aName, int aDielectricSubLayer=0)
Handle a list of polygons defining a copper zone.
int m_ViasMinAnnularWidth
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())
int getKiCadHatchCodeThickness(const HATCHCODE_ID &aCadstarHatchcodeID)
void Load(BOARD *aBoard, PROJECT *aProject)
Loads a CADSTAR PCB Archive file into the KiCad BOARD object given.