CADSTAR PCB Archive Importer: Load Component Copper and Component Areas
This commit is contained in:
parent
c1dec964be
commit
6a82f23981
|
@ -457,6 +457,8 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadComponentLibrary()
|
||||||
|
|
||||||
m->SetFPID( libID );
|
m->SetFPID( libID );
|
||||||
loadLibraryFigures( component, m );
|
loadLibraryFigures( component, m );
|
||||||
|
loadLibraryCoppers( component, m );
|
||||||
|
loadLibraryAreas( component, m );
|
||||||
loadLibraryPads( component, m );
|
loadLibraryPads( component, m );
|
||||||
|
|
||||||
mLibraryMap.insert( std::make_pair( key, m ) );
|
mLibraryMap.insert( std::make_pair( key, m ) );
|
||||||
|
@ -469,12 +471,70 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryFigures( const SYMDEF& aComponent, M
|
||||||
for( std::pair<FIGURE_ID, FIGURE> figPair : aComponent.Figures )
|
for( std::pair<FIGURE_ID, FIGURE> figPair : aComponent.Figures )
|
||||||
{
|
{
|
||||||
FIGURE& fig = figPair.second;
|
FIGURE& fig = figPair.second;
|
||||||
drawCadstarShape( fig.Shape, getKiCadLayer( fig.LayerID ), fig.LineCodeID,
|
drawCadstarShape( fig.Shape, getKiCadLayer( fig.LayerID ),
|
||||||
|
getLineThickness( fig.LineCodeID ),
|
||||||
wxString::Format( "Component %s:%s -> Figure %s", aComponent.ReferenceName,
|
wxString::Format( "Component %s:%s -> Figure %s", aComponent.ReferenceName,
|
||||||
aComponent.Alternate, fig.ID ),
|
aComponent.Alternate, fig.ID ),
|
||||||
aModule );
|
aModule );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//TODO process addition to a group
|
|
||||||
|
void CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryCoppers( const SYMDEF& aComponent, MODULE* aModule )
|
||||||
|
{
|
||||||
|
for( COMPONENT_COPPER compCopper : aComponent.ComponentCoppers )
|
||||||
|
{
|
||||||
|
int lineThickness = getKiCadLength( getCopperCode( compCopper.CopperCodeID ).CopperWidth );
|
||||||
|
|
||||||
|
drawCadstarShape( compCopper.Shape, getKiCadLayer( compCopper.LayerID ), lineThickness,
|
||||||
|
wxString::Format( "Component %s:%s -> Copper element", aComponent.ReferenceName,
|
||||||
|
aComponent.Alternate ),
|
||||||
|
aModule );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CADSTAR_PCB_ARCHIVE_LOADER::loadLibraryAreas( const SYMDEF& aComponent, MODULE* aModule )
|
||||||
|
{
|
||||||
|
for( std::pair<COMP_AREA_ID, COMPONENT_AREA> areaPair : aComponent.ComponentAreas )
|
||||||
|
{
|
||||||
|
COMPONENT_AREA& area = areaPair.second;
|
||||||
|
|
||||||
|
if( area.NoVias || area.NoTracks )
|
||||||
|
{
|
||||||
|
ZONE_CONTAINER* zone =
|
||||||
|
getZoneFromCadstarShape( area.Shape, getLineThickness( area.LineCodeID ), aModule );
|
||||||
|
|
||||||
|
aModule->Add( zone, ADD_MODE::APPEND );
|
||||||
|
|
||||||
|
if( isLayerSet( area.LayerID ) )
|
||||||
|
zone->SetLayerSet( getKiCadLayerSet( area.LayerID ) );
|
||||||
|
else
|
||||||
|
zone->SetLayer( getKiCadLayer( area.LayerID ) );
|
||||||
|
|
||||||
|
zone->SetIsKeepout( true ); //import all CADSTAR areas as Keepout zones
|
||||||
|
zone->SetDoNotAllowPads( false ); //no CADSTAR equivalent
|
||||||
|
zone->SetZoneName( area.ID );
|
||||||
|
|
||||||
|
//There is no distinction between tracks and copper pours in CADSTAR Keepout zones
|
||||||
|
zone->SetDoNotAllowTracks( area.NoTracks );
|
||||||
|
zone->SetDoNotAllowCopperPour( area.NoTracks );
|
||||||
|
|
||||||
|
zone->SetDoNotAllowVias( area.NoVias );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxString libName = aComponent.ReferenceName;
|
||||||
|
|
||||||
|
if( !aComponent.Alternate.IsEmpty() )
|
||||||
|
libName << wxT( " (" ) << aComponent.Alternate << wxT( ")" );
|
||||||
|
|
||||||
|
wxLogError(
|
||||||
|
wxString::Format( _( "The CADSTAR area '%s' in library component '%s' does not "
|
||||||
|
"have a KiCad equivalent. The area is neither a via or"
|
||||||
|
"route keepout area. The area was not imported. " ),
|
||||||
|
area.ID, libName ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -679,8 +739,9 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadBoards()
|
||||||
{
|
{
|
||||||
BOARD& board = boardPair.second;
|
BOARD& board = boardPair.second;
|
||||||
GROUP_ID boardGroup = createUniqueGroupID( wxT( "Board" ) );
|
GROUP_ID boardGroup = createUniqueGroupID( wxT( "Board" ) );
|
||||||
drawCadstarShape( board.Shape, PCB_LAYER_ID::Edge_Cuts, board.LineCodeID,
|
drawCadstarShape( board.Shape, PCB_LAYER_ID::Edge_Cuts,
|
||||||
wxString::Format( "BOARD %s", board.ID ), mBoard, boardGroup );
|
getLineThickness( board.LineCodeID ), wxString::Format( "BOARD %s", board.ID ),
|
||||||
|
mBoard, boardGroup );
|
||||||
|
|
||||||
if( !board.GroupID.IsEmpty() )
|
if( !board.GroupID.IsEmpty() )
|
||||||
{
|
{
|
||||||
|
@ -697,8 +758,9 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadFigures()
|
||||||
for( std::pair<FIGURE_ID, FIGURE> figPair : Layout.Figures )
|
for( std::pair<FIGURE_ID, FIGURE> figPair : Layout.Figures )
|
||||||
{
|
{
|
||||||
FIGURE& fig = figPair.second;
|
FIGURE& fig = figPair.second;
|
||||||
drawCadstarShape( fig.Shape, getKiCadLayer( fig.LayerID ), fig.LineCodeID,
|
drawCadstarShape( fig.Shape, getKiCadLayer( fig.LayerID ),
|
||||||
wxString::Format( "FIGURE %s", fig.ID ), mBoard, fig.GroupID );
|
getLineThickness( fig.LineCodeID ), wxString::Format( "FIGURE %s", fig.ID ), mBoard,
|
||||||
|
fig.GroupID );
|
||||||
|
|
||||||
//TODO process "swaprule" (doesn't seem to apply to Layout Figures?)
|
//TODO process "swaprule" (doesn't seem to apply to Layout Figures?)
|
||||||
//TODO process re-use block when KiCad Supports it
|
//TODO process re-use block when KiCad Supports it
|
||||||
|
@ -793,8 +855,8 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadAreas()
|
||||||
|
|
||||||
if( area.NoVias || area.NoTracks || area.Keepout )
|
if( area.NoVias || area.NoTracks || area.Keepout )
|
||||||
{
|
{
|
||||||
ZONE_CONTAINER* zone =
|
ZONE_CONTAINER* zone = getZoneFromCadstarShape(
|
||||||
getZoneFromCadstarShape( area.Shape, getLineThickness( area.LineCodeID ) );
|
area.Shape, getLineThickness( area.LineCodeID ), mBoard );
|
||||||
|
|
||||||
mBoard->Add( zone, ADD_MODE::APPEND );
|
mBoard->Add( zone, ADD_MODE::APPEND );
|
||||||
|
|
||||||
|
@ -925,11 +987,11 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadDocumentationSymbols()
|
||||||
for( std::pair<FIGURE_ID, FIGURE> figPair : docSymDefinition.Figures )
|
for( std::pair<FIGURE_ID, FIGURE> figPair : docSymDefinition.Figures )
|
||||||
{
|
{
|
||||||
FIGURE fig = figPair.second;
|
FIGURE fig = figPair.second;
|
||||||
drawCadstarShape( fig.Shape, layer, fig.LineCodeID,
|
drawCadstarShape( fig.Shape, layer, getLineThickness( fig.LineCodeID ),
|
||||||
wxString::Format( "DOCUMENTATION SYMBOL %s, FIGURE %s",
|
wxString::Format( "DOCUMENTATION SYMBOL %s, FIGURE %s",
|
||||||
docSymDefinition.ReferenceName, fig.ID ),
|
docSymDefinition.ReferenceName, fig.ID ),
|
||||||
mBoard, groupID, moveVector, rotationAngle, scalingFactor, centreOfTransform,
|
mBoard, groupID, moveVector, rotationAngle, scalingFactor,
|
||||||
mirrorInvert );
|
centreOfTransform, mirrorInvert );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -950,7 +1012,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadTemplates()
|
||||||
TEMPLATE& csTemplate = tempPair.second;
|
TEMPLATE& csTemplate = tempPair.second;
|
||||||
|
|
||||||
ZONE_CONTAINER* zone = getZoneFromCadstarShape(
|
ZONE_CONTAINER* zone = getZoneFromCadstarShape(
|
||||||
csTemplate.Shape, getLineThickness( csTemplate.LineCodeID ) );
|
csTemplate.Shape, getLineThickness( csTemplate.LineCodeID ), mBoard );
|
||||||
|
|
||||||
mBoard->Add( zone, ADD_MODE::APPEND );
|
mBoard->Add( zone, ADD_MODE::APPEND );
|
||||||
|
|
||||||
|
@ -1075,7 +1137,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadTemplates()
|
||||||
int defaultLineThicknesss =
|
int defaultLineThicknesss =
|
||||||
mBoard->GetDesignSettings().GetLineThickness( PCB_LAYER_ID::Edge_Cuts );
|
mBoard->GetDesignSettings().GetLineThickness( PCB_LAYER_ID::Edge_Cuts );
|
||||||
ZONE_CONTAINER* zone =
|
ZONE_CONTAINER* zone =
|
||||||
getZoneFromCadstarShape( board.Shape, defaultLineThicknesss );
|
getZoneFromCadstarShape( board.Shape, defaultLineThicknesss, mBoard );
|
||||||
|
|
||||||
mBoard->Add( zone, ADD_MODE::APPEND );
|
mBoard->Add( zone, ADD_MODE::APPEND );
|
||||||
|
|
||||||
|
@ -1155,7 +1217,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadCoppers()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ZONE_CONTAINER* zone = getZoneFromCadstarShape( csCopper.Shape,
|
ZONE_CONTAINER* zone = getZoneFromCadstarShape( csCopper.Shape,
|
||||||
getKiCadLength( getCopperCode( csCopper.CopperCodeID ).CopperWidth ) );
|
getKiCadLength( getCopperCode( csCopper.CopperCodeID ).CopperWidth ), mBoard );
|
||||||
|
|
||||||
mBoard->Add( zone, ADD_MODE::APPEND );
|
mBoard->Add( zone, ADD_MODE::APPEND );
|
||||||
|
|
||||||
|
@ -1489,24 +1551,22 @@ void CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText( const TEXT& aCadstarText,
|
||||||
|
|
||||||
|
|
||||||
void CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarShape( const SHAPE& aCadstarShape,
|
void CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarShape( const SHAPE& aCadstarShape,
|
||||||
const PCB_LAYER_ID& aKiCadLayer, const LINECODE_ID& aCadstarLinecodeID,
|
const PCB_LAYER_ID& aKiCadLayer, const int& aLineThickness, const wxString& aShapeName,
|
||||||
const wxString& aShapeName, BOARD_ITEM_CONTAINER* aContainer,
|
BOARD_ITEM_CONTAINER* aContainer, const GROUP_ID& aCadstarGroupID,
|
||||||
const GROUP_ID& aCadstarGroupID, const wxPoint& aMoveVector, const double& aRotationAngle,
|
const wxPoint& aMoveVector, const double& aRotationAngle, const double& aScalingFactor,
|
||||||
const double& aScalingFactor, const wxPoint& aTransformCentre, const bool& aMirrorInvert )
|
const wxPoint& aTransformCentre, const bool& aMirrorInvert )
|
||||||
{
|
{
|
||||||
int lineThickness = getLineThickness( aCadstarLinecodeID );
|
|
||||||
|
|
||||||
switch( aCadstarShape.Type )
|
switch( aCadstarShape.Type )
|
||||||
{
|
{
|
||||||
case SHAPE_TYPE::OPENSHAPE:
|
case SHAPE_TYPE::OPENSHAPE:
|
||||||
case SHAPE_TYPE::OUTLINE:
|
case SHAPE_TYPE::OUTLINE:
|
||||||
///TODO update this when Polygons in KiCad can be defined with no fill
|
///TODO update this when Polygons in KiCad can be defined with no fill
|
||||||
drawCadstarVerticesAsSegments( aCadstarShape.Vertices, aKiCadLayer, lineThickness,
|
drawCadstarVerticesAsSegments( aCadstarShape.Vertices, aKiCadLayer, aLineThickness,
|
||||||
|
aContainer, aCadstarGroupID, aMoveVector, aRotationAngle, aScalingFactor,
|
||||||
|
aTransformCentre, aMirrorInvert );
|
||||||
|
drawCadstarCutoutsAsSegments( aCadstarShape.Cutouts, aKiCadLayer, aLineThickness,
|
||||||
aContainer, aCadstarGroupID, aMoveVector, aRotationAngle, aScalingFactor,
|
aContainer, aCadstarGroupID, aMoveVector, aRotationAngle, aScalingFactor,
|
||||||
aTransformCentre, aMirrorInvert );
|
aTransformCentre, aMirrorInvert );
|
||||||
drawCadstarCutoutsAsSegments( aCadstarShape.Cutouts, aKiCadLayer, lineThickness, aContainer,
|
|
||||||
aCadstarGroupID, aMoveVector, aRotationAngle, aScalingFactor, aTransformCentre,
|
|
||||||
aMirrorInvert );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SHAPE_TYPE::HATCHED:
|
case SHAPE_TYPE::HATCHED:
|
||||||
|
@ -1530,7 +1590,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarShape( const SHAPE& aCadstarShape,
|
||||||
|
|
||||||
ds->SetPolyShape( getPolySetFromCadstarShape( aCadstarShape, -1, aContainer, aMoveVector,
|
ds->SetPolyShape( getPolySetFromCadstarShape( aCadstarShape, -1, aContainer, aMoveVector,
|
||||||
aRotationAngle, aScalingFactor, aTransformCentre, aMirrorInvert ) );
|
aRotationAngle, aScalingFactor, aTransformCentre, aMirrorInvert ) );
|
||||||
ds->SetWidth( lineThickness );
|
ds->SetWidth( aLineThickness );
|
||||||
ds->SetLayer( aKiCadLayer );
|
ds->SetLayer( aKiCadLayer );
|
||||||
aContainer->Add( ds, ADD_MODE::APPEND );
|
aContainer->Add( ds, ADD_MODE::APPEND );
|
||||||
|
|
||||||
|
@ -1698,9 +1758,9 @@ DRAWSEGMENT* CADSTAR_PCB_ARCHIVE_LOADER::getDrawSegmentFromVertex( const POINT&
|
||||||
|
|
||||||
|
|
||||||
ZONE_CONTAINER* CADSTAR_PCB_ARCHIVE_LOADER::getZoneFromCadstarShape(
|
ZONE_CONTAINER* CADSTAR_PCB_ARCHIVE_LOADER::getZoneFromCadstarShape(
|
||||||
const SHAPE& aCadstarShape, const int& aLineThickness )
|
const SHAPE& aCadstarShape, const int& aLineThickness, BOARD_ITEM_CONTAINER* aParentContainer )
|
||||||
{
|
{
|
||||||
ZONE_CONTAINER* zone = new ZONE_CONTAINER( mBoard );
|
ZONE_CONTAINER* zone = new ZONE_CONTAINER( aParentContainer, isModule( aParentContainer ) );
|
||||||
|
|
||||||
if( aCadstarShape.Type == SHAPE_TYPE::HATCHED )
|
if( aCadstarShape.Type == SHAPE_TYPE::HATCHED )
|
||||||
{
|
{
|
||||||
|
|
|
@ -123,6 +123,8 @@ private:
|
||||||
void logBoardStackupWarning(
|
void logBoardStackupWarning(
|
||||||
const wxString& aCadstarLayerName, const PCB_LAYER_ID& aKiCadLayer );
|
const wxString& aCadstarLayerName, const PCB_LAYER_ID& aKiCadLayer );
|
||||||
void loadLibraryFigures( const SYMDEF& aComponent, MODULE* aModule );
|
void loadLibraryFigures( const SYMDEF& aComponent, MODULE* aModule );
|
||||||
|
void loadLibraryCoppers( const SYMDEF& aComponent, MODULE* aModule );
|
||||||
|
void loadLibraryAreas( const SYMDEF& aComponent, MODULE* aModule );
|
||||||
void loadLibraryPads( const SYMDEF& aComponent, MODULE* aModule );
|
void loadLibraryPads( const SYMDEF& aComponent, MODULE* aModule );
|
||||||
void loadComponentAttributes( const COMPONENT& aComponent, MODULE* aModule );
|
void loadComponentAttributes( const COMPONENT& aComponent, MODULE* aModule );
|
||||||
void loadNetTracks( const NET_ID& aCadstarNetID, const NET::ROUTE& aCadstarRoute );
|
void loadNetTracks( const NET_ID& aCadstarNetID, const NET::ROUTE& aCadstarRoute );
|
||||||
|
@ -154,7 +156,7 @@ private:
|
||||||
* @brief
|
* @brief
|
||||||
* @param aCadstarShape
|
* @param aCadstarShape
|
||||||
* @param aCadstarLayerID KiCad layer to draw on
|
* @param aCadstarLayerID KiCad layer to draw on
|
||||||
* @param aCadstarLinecodeID Thickness of line to draw with
|
* @param aLineThickness Thickness of line to draw with
|
||||||
* @param aShapeName for reporting warnings/errors to the user
|
* @param aShapeName for reporting warnings/errors to the user
|
||||||
* @param aContainer to draw on (e.g. mBoard)
|
* @param aContainer to draw on (e.g. mBoard)
|
||||||
* @param aCadstarGroupID to add the shape to
|
* @param aCadstarGroupID to add the shape to
|
||||||
|
@ -165,11 +167,10 @@ private:
|
||||||
* @param aMirrorInvert if true, mirrors the shape
|
* @param aMirrorInvert if true, mirrors the shape
|
||||||
*/
|
*/
|
||||||
void drawCadstarShape( const SHAPE& aCadstarShape, const PCB_LAYER_ID& aKiCadLayer,
|
void drawCadstarShape( const SHAPE& aCadstarShape, const PCB_LAYER_ID& aKiCadLayer,
|
||||||
const LINECODE_ID& aCadstarLinecodeID, const wxString& aShapeName,
|
const int& aLineThickness, const wxString& aShapeName, BOARD_ITEM_CONTAINER* aContainer,
|
||||||
BOARD_ITEM_CONTAINER* aContainer, const GROUP_ID& aCadstarGroupID = wxEmptyString,
|
const GROUP_ID& aCadstarGroupID = wxEmptyString, const wxPoint& aMoveVector = { 0, 0 },
|
||||||
const wxPoint& aMoveVector = { 0, 0 }, const double& aRotationAngle = 0.0,
|
const double& aRotationAngle = 0.0, const double& aScalingFactor = 1.0,
|
||||||
const double& aScalingFactor = 1.0, const wxPoint& aTransformCentre = { 0, 0 },
|
const wxPoint& aTransformCentre = { 0, 0 }, const bool& aMirrorInvert = false );
|
||||||
const bool& aMirrorInvert = false );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Uses DRAWSEGMENT to draw the cutouts on mBoard object
|
* @brief Uses DRAWSEGMENT to draw the cutouts on mBoard object
|
||||||
|
@ -253,10 +254,11 @@ private:
|
||||||
* @brief
|
* @brief
|
||||||
* @param aCadstarShape
|
* @param aCadstarShape
|
||||||
* @param aLineThickness Thickness of line to draw with
|
* @param aLineThickness Thickness of line to draw with
|
||||||
|
* @param aParentContainer Parent object (e.g. mBoard or a MODULE pointer)
|
||||||
* @return Pointer to ZONE_CONTAINER. Caller owns the object.
|
* @return Pointer to ZONE_CONTAINER. Caller owns the object.
|
||||||
*/
|
*/
|
||||||
ZONE_CONTAINER* getZoneFromCadstarShape(
|
ZONE_CONTAINER* getZoneFromCadstarShape( const SHAPE& aCadstarShape, const int& aLineThickness,
|
||||||
const SHAPE& aCadstarShape, const int& aLineThickness );
|
BOARD_ITEM_CONTAINER* aParentContainer );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns a SHAPE_POLY_SET object from a Cadstar SHAPE
|
* @brief Returns a SHAPE_POLY_SET object from a Cadstar SHAPE
|
||||||
|
|
Loading…
Reference in New Issue