Commit f20bf0d2 authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: more about keepout areas: remove keepout for pads option and add...

Pcbnew: more about keepout areas: remove keepout for pads option and add keepout for copper zones option.
Export keepout to Specctra DSN file.
parent 018b0800
......@@ -49,6 +49,7 @@ comment
company
connect
connect_pads
copperpour
crossbar
date
descr
......
......@@ -58,10 +58,10 @@ ZONE_CONTAINER::ZONE_CONTAINER( BOARD* aBoard ) :
m_priority = 0;
m_smoothedPoly = NULL;
m_cornerSmoothingType = ZONE_SETTINGS::SMOOTHING_NONE;
m_isKeepout = false;
m_doNotAllowPads = true; // has meaning only if m_isKeepout == true
m_doNotAllowVias = true; // has meaning only if m_isKeepout == true
m_doNotAllowTracks = true; // has meaning only if m_isKeepout == true
SetIsKeepout( false );
SetDoNotAllowCopperPour( false ); // has meaning only if m_isKeepout == true
SetDoNotAllowVias( true ); // has meaning only if m_isKeepout == true
SetDoNotAllowTracks( true ); // has meaning only if m_isKeepout == true
m_cornerRadius = 0;
utility = 0; // flags used in polygon calculations
utility2 = 0; // flags used in polygon calculations
......@@ -92,7 +92,7 @@ ZONE_CONTAINER::ZONE_CONTAINER( const ZONE_CONTAINER& aZone ) :
m_FillSegmList = aZone.m_FillSegmList;
m_isKeepout = aZone.m_isKeepout;
m_doNotAllowPads = aZone.m_doNotAllowPads;
m_doNotAllowCopperPour = aZone.m_doNotAllowCopperPour;
m_doNotAllowVias = aZone.m_doNotAllowVias;
m_doNotAllowTracks = aZone.m_doNotAllowTracks;
......
......@@ -539,12 +539,12 @@ public:
* Accessors to parameters used in Keepout zones:
*/
bool GetIsKeepout() const { return m_isKeepout; }
bool GetDoNotAllowPads() const { return m_doNotAllowPads; }
bool GetDoNotAllowCopperPour() const { return m_doNotAllowCopperPour; }
bool GetDoNotAllowVias() const { return m_doNotAllowVias; }
bool GetDoNotAllowTracks() const { return m_doNotAllowTracks; }
void SetIsKeepout( bool aEnable ) { m_isKeepout = aEnable; }
void SetDoNotAllowPads( bool aEnable ) { m_doNotAllowPads = aEnable; }
void SetDoNotAllowCopperPour( bool aEnable ) { m_doNotAllowCopperPour = aEnable; }
void SetDoNotAllowVias( bool aEnable ) { m_doNotAllowVias = aEnable; }
void SetDoNotAllowTracks( bool aEnable ) { m_doNotAllowTracks = aEnable; }
......@@ -605,7 +605,7 @@ private:
/* For keepout zones only:
* what is not allowed inside the keepout ( pads, tracks and vias )
*/
bool m_doNotAllowPads;
bool m_doNotAllowCopperPour;
bool m_doNotAllowVias;
bool m_doNotAllowTracks;
......
......@@ -64,7 +64,7 @@ ZONE_SETTINGS::ZONE_SETTINGS()
m_cornerRadius = 0;
SetIsKeepout( false );
SetDoNotAllowPads( false );
SetDoNotAllowCopperPour( false );
SetDoNotAllowVias( true );
SetDoNotAllowTracks( true );
}
......@@ -86,7 +86,7 @@ ZONE_SETTINGS& ZONE_SETTINGS::operator << ( const ZONE_CONTAINER& aSource )
m_cornerSmoothingType = aSource.GetCornerSmoothingType();
m_cornerRadius = aSource.GetCornerRadius();
m_isKeepout = aSource.GetIsKeepout();
m_keepoutDoNotAllowPads = aSource.GetDoNotAllowPads();
m_keepoutDoNotAllowCopperPour = aSource.GetDoNotAllowCopperPour();
m_keepoutDoNotAllowVias = aSource.GetDoNotAllowVias();
m_keepoutDoNotAllowTracks = aSource.GetDoNotAllowTracks();
......@@ -107,7 +107,7 @@ void ZONE_SETTINGS::ExportSetting( ZONE_CONTAINER& aTarget, bool aFullExport ) c
aTarget.SetCornerSmoothingType( m_cornerSmoothingType );
aTarget.SetCornerRadius( m_cornerRadius );
aTarget.SetIsKeepout( GetIsKeepout() );
aTarget.SetDoNotAllowPads( GetDoNotAllowPads() );
aTarget.SetDoNotAllowCopperPour( GetDoNotAllowCopperPour() );
aTarget.SetDoNotAllowVias( GetDoNotAllowVias() );
aTarget.SetDoNotAllowTracks( GetDoNotAllowTracks() );
......
......@@ -65,7 +65,7 @@ private:
/* For keepout zones only:
* what is not allowed inside the keepout ( pads, tracks and vias )
*/
bool m_keepoutDoNotAllowPads;
bool m_keepoutDoNotAllowCopperPour;
bool m_keepoutDoNotAllowVias;
bool m_keepoutDoNotAllowTracks;
......@@ -115,12 +115,12 @@ public:
* Accessors to parameters used in Keepout zones:
*/
const bool GetIsKeepout() const { return m_isKeepout; }
const bool GetDoNotAllowPads() const { return m_keepoutDoNotAllowPads; }
const bool GetDoNotAllowCopperPour() const { return m_keepoutDoNotAllowCopperPour; }
const bool GetDoNotAllowVias() const { return m_keepoutDoNotAllowVias; }
const bool GetDoNotAllowTracks() const { return m_keepoutDoNotAllowTracks; }
void SetIsKeepout( bool aEnable ) { m_isKeepout = aEnable; }
void SetDoNotAllowPads( bool aEnable ) { m_keepoutDoNotAllowPads = aEnable; }
void SetDoNotAllowCopperPour( bool aEnable ) { m_keepoutDoNotAllowCopperPour = aEnable; }
void SetDoNotAllowVias( bool aEnable ) { m_keepoutDoNotAllowVias = aEnable; }
void SetDoNotAllowTracks( bool aEnable ) { m_keepoutDoNotAllowTracks = aEnable; }
};
......
......@@ -175,7 +175,7 @@ void DIALOG_KEEPOUT_AREA_PROPERTIES::initDialog()
// Init keepout parameters:
m_cbTracksCtrl->SetValue( m_zonesettings.GetDoNotAllowTracks() );
m_cbViasCtrl->SetValue( m_zonesettings.GetDoNotAllowVias() );
m_cbPadsCtrl->SetValue( m_zonesettings.GetDoNotAllowPads() );
m_cbCopperPourCtrl->SetValue( m_zonesettings.GetDoNotAllowCopperPour() );
}
void DIALOG_KEEPOUT_AREA_PROPERTIES::OnCancelClick( wxCommandEvent& event )
......@@ -208,12 +208,12 @@ bool DIALOG_KEEPOUT_AREA_PROPERTIES::AcceptOptionsForKeepOut()
m_zonesettings.SetIsKeepout( true );
m_zonesettings.SetDoNotAllowTracks( m_cbTracksCtrl->GetValue() );
m_zonesettings.SetDoNotAllowVias( m_cbViasCtrl->GetValue() );
m_zonesettings.SetDoNotAllowPads( m_cbPadsCtrl->GetValue() );
m_zonesettings.SetDoNotAllowCopperPour( m_cbCopperPourCtrl->GetValue() );
// Test for not allowed items: should have at least one item not allowed:
if( ! m_zonesettings.GetDoNotAllowTracks() &&
! m_zonesettings.GetDoNotAllowVias() &&
! m_zonesettings.GetDoNotAllowPads() )
! m_zonesettings.GetDoNotAllowCopperPour() )
{
DisplayError( NULL,
_("Tracks, vias and pads are allowed. The keepout is useless" ) );
......
......@@ -67,8 +67,8 @@ DIALOG_KEEPOUT_AREA_PROPERTIES_BASE::DIALOG_KEEPOUT_AREA_PROPERTIES_BASE( wxWind
m_cbViasCtrl = new wxCheckBox( this, wxID_ANY, _("No Vias"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizerCutoutOpts->Add( m_cbViasCtrl, 0, wxTOP|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_cbPadsCtrl = new wxCheckBox( this, wxID_ANY, _("No Pads"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizerCutoutOpts->Add( m_cbPadsCtrl, 0, wxALL|wxEXPAND, 5 );
m_cbCopperPourCtrl = new wxCheckBox( this, wxID_ANY, _("No Copper Pour"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizerCutoutOpts->Add( m_cbCopperPourCtrl, 0, wxALL|wxEXPAND, 5 );
bSizerRight->Add( sbSizerCutoutOpts, 0, wxEXPAND|wxALL, 5 );
......
......@@ -723,7 +723,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">No Pads</property>
<property name="label">No Copper Pour</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
......@@ -731,7 +731,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_cbPadsCtrl</property>
<property name="name">m_cbCopperPourCtrl</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
......
......@@ -49,7 +49,7 @@ class DIALOG_KEEPOUT_AREA_PROPERTIES_BASE : public DIALOG_SHIM
wxRadioBox* m_OutlineAppearanceCtrl;
wxCheckBox* m_cbTracksCtrl;
wxCheckBox* m_cbViasCtrl;
wxCheckBox* m_cbPadsCtrl;
wxCheckBox* m_cbCopperPourCtrl;
wxStaticLine* m_staticline1;
wxStdDialogButtonSizer* m_sdbSizerButtons;
wxButton* m_sdbSizerButtonsOK;
......
......@@ -1011,10 +1011,10 @@ void PCB_IO::format( ZONE_CONTAINER* aZone, int aNestLevel ) const
if( aZone->GetIsKeepout() )
{
m_out->Print( aNestLevel+1, "(keepout (tracks %s) (vias %s) (pads %s))\n",
m_out->Print( aNestLevel+1, "(keepout (tracks %s) (vias %s) (copperpour %s))\n",
aZone->GetDoNotAllowTracks() ? "not_allowed" : "allowed",
aZone->GetDoNotAllowVias() ? "not_allowed" : "allowed",
aZone->GetDoNotAllowPads() ? "not_allowed" : "allowed" );
aZone->GetDoNotAllowCopperPour() ? "not_allowed" : "allowed" );
}
m_out->Print( aNestLevel+1, "(fill" );
......
......@@ -2223,10 +2223,10 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
data = strtok( NULL, delims );
zc->SetDoNotAllowVias( data && *data == 'N' );
}
else if( !strcmp( data, "pads" ) )
else if( !strcmp( data, "copperpour" ) )
{
data = strtok( NULL, delims );
zc->SetDoNotAllowPads( data && *data == 'N' );
zc->SetDoNotAllowCopperPour( data && *data == 'N' );
}
data = strtok( NULL, delims );
......@@ -3596,10 +3596,10 @@ void LEGACY_PLUGIN::saveZONE_CONTAINER( const ZONE_CONTAINER* me ) const
if( me->GetIsKeepout() )
{
fprintf( m_fp, "ZKeepout tracks %c vias %c pads %c\n",
fprintf( m_fp, "ZKeepout tracks %c vias %c copperpour %c\n",
me->GetDoNotAllowTracks() ? 'N' : 'Y',
me->GetDoNotAllowVias() ? 'N' : 'Y',
me->GetDoNotAllowPads() ? 'N' : 'Y' );
me->GetDoNotAllowCopperPour() ? 'N' : 'Y' );
}
fprintf( m_fp, "ZSmoothing %d %s\n",
......
......@@ -2490,16 +2490,16 @@ ZONE_CONTAINER* PCB_PARSER::parseZONE_CONTAINER() throw( IO_ERROR, PARSE_ERROR )
zone->SetDoNotAllowVias( token == T_not_allowed );
break;
case T_pads:
case T_copperpour:
token = NextTok();
if( token != T_allowed && token != T_not_allowed )
Expecting( "allowed or not_allowed" );
zone->SetDoNotAllowPads( token == T_not_allowed );
zone->SetDoNotAllowCopperPour( token == T_not_allowed );
break;
default:
Expecting( "tracks, vias or pads" );
Expecting( "tracks, vias or copperpour" );
}
NeedRIGHT();
......
......@@ -1135,7 +1135,8 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IO_ERROR )
}
//-----<zone containers become planes>--------------------------------
//-----<zone containers (not keepout areas) become planes>--------------------------------
// Note: only zones are output here, keepout areas be be created later
{
int netlessZones = 0;
......@@ -1146,6 +1147,9 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IO_ERROR )
{
ZONE_CONTAINER* item = (ZONE_CONTAINER*) items[i];
if( item->GetIsKeepout() )
continue;
COPPER_PLANE* plane = new COPPER_PLANE( pcb->structure );
pcb->structure->planes.push_back( plane );
......@@ -1214,7 +1218,80 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IO_ERROR )
}
}
// keepouts could go here, there are none in Kicad at this time.
//-----<zone containers flagged keepout areas become keepout>--------------------------------
{
static const KICAD_T scanZONEs[] = { PCB_ZONE_AREA_T, EOT };
items.Collect( aBoard, scanZONEs );
for( int i=0; i<items.GetCount(); ++i )
{
ZONE_CONTAINER* item = (ZONE_CONTAINER*) items[i];
if( ! item->GetIsKeepout() )
continue;
// keepout areas have a type. types are
// T_place_keepout, T_via_keepout, T_wire_keepout,
// T_bend_keepout, T_elongate_keepout, T_keepout.
// Pcbnew knows only T_keepout, T_via_keepout and T_wire_keepout
DSN_T keepout_type;
if( item->GetDoNotAllowVias() && item->GetDoNotAllowTracks() )
keepout_type = T_keepout;
else if( item->GetDoNotAllowVias() )
keepout_type = T_via_keepout;
else if( item->GetDoNotAllowTracks() )
keepout_type = T_wire_keepout;
else
keepout_type = T_keepout;
KEEPOUT* keepout = new KEEPOUT( pcb->structure, keepout_type );
pcb->structure->keepouts.push_back( keepout );
PATH* mainPolygon = new PATH( keepout, T_polygon );
keepout->SetShape( mainPolygon );
mainPolygon->layer_id = layerIds[ kicadLayer2pcb[ item->GetLayer() ] ];
int count = item->m_Poly->corner.size();
int ndx = 0; // used in 2 for() loops below
for( ; ndx<count; ++ndx )
{
wxPoint point( item->m_Poly->corner[ndx].x,
item->m_Poly->corner[ndx].y );
mainPolygon->AppendPoint( mapPt(point) );
// this was the end of the main polygon
if( item->m_Poly->corner[ndx].end_contour )
break;
}
WINDOW* window = 0;
PATH* cutout = 0;
// handle the cutouts
for( ++ndx; ndx<count; ++ndx )
{
if( item->m_Poly->corner[ndx-1].end_contour )
{
window = new WINDOW( keepout );
keepout->AddWindow( window );
cutout = new PATH( window, T_polygon );
window->SetShape( cutout );
cutout->layer_id = layerIds[ kicadLayer2pcb[ item->GetLayer() ] ];
}
wxASSERT( window );
wxASSERT( cutout );
wxPoint point(item->m_Poly->corner[ndx].x,
item->m_Poly->corner[ndx].y );
cutout->AppendPoint( mapPt(point) );
}
}
}
//-----<build the images, components, and netlist>-----------------------
{
......
......@@ -353,20 +353,20 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
}
}
// Add zones outlines having an higher priority
// Add zones outlines having an higher priority and keepout
for( int ii = 0; ii < GetBoard()->GetAreaCount(); ii++ )
{
ZONE_CONTAINER* zone = GetBoard()->GetArea( ii );
if( zone->GetLayer() != GetLayer() )
continue;
if( zone->GetIsKeepout() )
if( !zone->GetIsKeepout() && zone->GetPriority() <= GetPriority() )
continue;
if( zone->GetPriority() <= GetPriority() )
if( zone->GetIsKeepout() && ! zone->GetDoNotAllowCopperPour() )
continue;
// A highter priority zone is found: remove its area
// A highter priority zone or keepout area is found: remove its area
item_boundingbox = zone->GetBoundingBox();
if( !item_boundingbox.Intersects( zone_boundingbox ) )
continue;
......@@ -377,13 +377,17 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
// the zone will be connected to the current zone, but filled areas
// will use different parameters (clearance, thermal shapes )
bool addclearance = GetNet() != zone->GetNet();
int clearance = zone_clearance;
if( zone->GetIsKeepout() )
addclearance = false;
{
addclearance = true;
clearance = m_ZoneMinThickness / 2;
}
zone->TransformShapeWithClearanceToPolygon(
cornerBufferPolysToSubstract,
zone_clearance, s_CircleToSegmentsCount,
clearance, s_CircleToSegmentsCount,
s_Correction, addclearance );
}
......
......@@ -5,7 +5,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
* Copyright (C) 2009 Jean-Pierre Charras <jp.charras@wanadoo.fr>
* Copyright (C) 2007 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......@@ -79,7 +79,7 @@ bool ZONE_CONTAINER::IsSame( const ZONE_CONTAINER& aZoneToCompare )
if( GetIsKeepout() )
{
if( GetDoNotAllowPads() != aZoneToCompare.GetDoNotAllowPads() )
if( GetDoNotAllowCopperPour() != aZoneToCompare.GetDoNotAllowCopperPour() )
return false;
if( GetDoNotAllowVias() != aZoneToCompare.GetDoNotAllowVias() )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment