Code cleanup.

A placement-area is a rule-area sub-type.  We don't
need to say rule-area-placement each time.

Also removes some dead code, and simplifies some
damage-propagation logic.
This commit is contained in:
Jeff Young 2025-06-07 17:22:08 +01:00
parent bccb3534f4
commit d81e9e6cd1
14 changed files with 286 additions and 469 deletions

View File

@ -386,43 +386,43 @@ ZONE_BORDER_DISPLAY_STYLE FromProtoEnum( types::ZoneBorderStyle aValue )
template<> template<>
types::PlacementRuleSourceType ToProtoEnum( RULE_AREA_PLACEMENT_SOURCE_TYPE aValue ) types::PlacementRuleSourceType ToProtoEnum( PLACEMENT_SOURCE_T aValue )
{ {
switch( aValue ) switch( aValue )
{ {
case RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME: case PLACEMENT_SOURCE_T::SHEETNAME:
return types::PlacementRuleSourceType::PRST_SHEET_NAME; return types::PlacementRuleSourceType::PRST_SHEET_NAME;
case RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS: case PLACEMENT_SOURCE_T::COMPONENT_CLASS:
return types::PlacementRuleSourceType::PRST_COMPONENT_CLASS; return types::PlacementRuleSourceType::PRST_COMPONENT_CLASS;
case RULE_AREA_PLACEMENT_SOURCE_TYPE::GROUP_PLACEMENT: case PLACEMENT_SOURCE_T::GROUP_PLACEMENT:
return types::PlacementRuleSourceType::PRST_GROUP; return types::PlacementRuleSourceType::PRST_GROUP;
default: default:
wxCHECK_MSG( false, types::PlacementRuleSourceType::PRST_UNKNOWN, wxCHECK_MSG( false, types::PlacementRuleSourceType::PRST_UNKNOWN,
"Unhandled case in ToProtoEnum<RULE_AREA_PLACEMENT_SOURCE_TYPE>"); "Unhandled case in ToProtoEnum<PLACEMENT_SOURCE_T>");
} }
} }
template<> template<>
RULE_AREA_PLACEMENT_SOURCE_TYPE FromProtoEnum( types::PlacementRuleSourceType aValue ) PLACEMENT_SOURCE_T FromProtoEnum( types::PlacementRuleSourceType aValue )
{ {
switch( aValue ) switch( aValue )
{ {
case types::PlacementRuleSourceType::PRST_UNKNOWN: case types::PlacementRuleSourceType::PRST_UNKNOWN:
case types::PlacementRuleSourceType::PRST_SHEET_NAME: case types::PlacementRuleSourceType::PRST_SHEET_NAME:
return RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME; return PLACEMENT_SOURCE_T::SHEETNAME;
case types::PlacementRuleSourceType::PRST_COMPONENT_CLASS: case types::PlacementRuleSourceType::PRST_COMPONENT_CLASS:
return RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS; return PLACEMENT_SOURCE_T::COMPONENT_CLASS;
case types::PlacementRuleSourceType::PRST_GROUP: case types::PlacementRuleSourceType::PRST_GROUP:
return RULE_AREA_PLACEMENT_SOURCE_TYPE::GROUP_PLACEMENT; return PLACEMENT_SOURCE_T::GROUP_PLACEMENT;
default: default:
wxCHECK_MSG( false, RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME, wxCHECK_MSG( false, PLACEMENT_SOURCE_T::SHEETNAME,
"Unhandled case in FromProtoEnum<types::PlacementRuleSourceType>" ); "Unhandled case in FromProtoEnum<types::PlacementRuleSourceType>" );
} }
} }

View File

@ -78,7 +78,6 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
char* text; char* text;
int netcode = -1; int netcode = -1;
bool multiHighlight = false; bool multiHighlight = false;
PAD* pad = nullptr;
BOARD* pcb = GetBoard(); BOARD* pcb = GetBoard();
CROSS_PROBING_SETTINGS& crossProbingSettings = GetPcbNewSettings()->m_CrossProbing; CROSS_PROBING_SETTINGS& crossProbingSettings = GetPcbNewSettings()->m_CrossProbing;

View File

@ -122,11 +122,11 @@ DIALOG_MULTICHANNEL_GENERATE_RULE_AREAS::DIALOG_MULTICHANNEL_GENERATE_RULE_AREAS
for( RULE_AREA& ruleArea : raData->m_areas ) for( RULE_AREA& ruleArea : raData->m_areas )
{ {
if( ruleArea.m_sourceType == RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME ) if( ruleArea.m_sourceType == PLACEMENT_SOURCE_T::SHEETNAME )
sheetRowIdx++; sheetRowIdx++;
else if( ruleArea.m_sourceType == RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS ) else if( ruleArea.m_sourceType == PLACEMENT_SOURCE_T::COMPONENT_CLASS )
componentClassRowIdx++; componentClassRowIdx++;
else if( ruleArea.m_sourceType == RULE_AREA_PLACEMENT_SOURCE_TYPE::GROUP_PLACEMENT ) else if( ruleArea.m_sourceType == PLACEMENT_SOURCE_T::GROUP_PLACEMENT )
groupIdx++; groupIdx++;
} }
@ -145,7 +145,7 @@ DIALOG_MULTICHANNEL_GENERATE_RULE_AREAS::DIALOG_MULTICHANNEL_GENERATE_RULE_AREAS
for( RULE_AREA& ruleArea : raData->m_areas ) for( RULE_AREA& ruleArea : raData->m_areas )
{ {
if( ruleArea.m_sourceType == RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME ) if( ruleArea.m_sourceType == PLACEMENT_SOURCE_T::SHEETNAME )
{ {
m_sheetGrid->SetCellValue( sheetRowIdx, 1, ruleArea.m_sheetPath ); m_sheetGrid->SetCellValue( sheetRowIdx, 1, ruleArea.m_sheetPath );
m_sheetGrid->SetCellValue( sheetRowIdx, 2, ruleArea.m_sheetName ); m_sheetGrid->SetCellValue( sheetRowIdx, 2, ruleArea.m_sheetName );
@ -155,7 +155,7 @@ DIALOG_MULTICHANNEL_GENERATE_RULE_AREAS::DIALOG_MULTICHANNEL_GENERATE_RULE_AREAS
ruleArea.m_generateEnabled ? wxT( "1" ) : wxT( "" ) ); ruleArea.m_generateEnabled ? wxT( "1" ) : wxT( "" ) );
sheetRowIdx++; sheetRowIdx++;
} }
else if( ruleArea.m_sourceType == RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS ) else if( ruleArea.m_sourceType == PLACEMENT_SOURCE_T::COMPONENT_CLASS )
{ {
m_componentClassGrid->SetCellValue( componentClassRowIdx, 1, m_componentClassGrid->SetCellValue( componentClassRowIdx, 1,
ruleArea.m_componentClass ); ruleArea.m_componentClass );
@ -219,12 +219,12 @@ bool DIALOG_MULTICHANNEL_GENERATE_RULE_AREAS::TransferDataFromWindow()
{ {
wxString enabled; wxString enabled;
if( raData->m_areas[i].m_sourceType == RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME ) if( raData->m_areas[i].m_sourceType == PLACEMENT_SOURCE_T::SHEETNAME )
{ {
enabled = m_sheetGrid->GetCellValue( sheetRowIdx, 0 ); enabled = m_sheetGrid->GetCellValue( sheetRowIdx, 0 );
sheetRowIdx++; sheetRowIdx++;
} }
else if( raData->m_areas[i].m_sourceType == RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS ) else if( raData->m_areas[i].m_sourceType == PLACEMENT_SOURCE_T::COMPONENT_CLASS )
{ {
enabled = m_componentClassGrid->GetCellValue( componentClassRowIdx, 0 ); enabled = m_componentClassGrid->GetCellValue( componentClassRowIdx, 0 );
componentClassRowIdx++; componentClassRowIdx++;

View File

@ -63,28 +63,28 @@ private:
void OnGroupClicked( wxCommandEvent& event ); void OnGroupClicked( wxCommandEvent& event );
private: private:
BOARD* m_board; BOARD* m_board;
UNIT_BINDER m_outlineHatchPitch; UNIT_BINDER m_outlineHatchPitch;
PCB_BASE_FRAME* m_parent; PCB_BASE_FRAME* m_parent;
ZONE_SETTINGS m_zonesettings; ///< the working copy of zone settings ZONE_SETTINGS m_zonesettings; ///< the working copy of zone settings
ZONE_SETTINGS* m_ptr; ///< the pointer to the zone settings of the zone to edit ZONE_SETTINGS* m_ptr; ///< the pointer to the zone settings of the zone to edit
bool m_isFpEditor; bool m_isFpEditor;
CONVERT_SETTINGS* m_convertSettings; CONVERT_SETTINGS* m_convertSettings;
wxRadioButton* m_rbCenterline; wxRadioButton* m_rbCenterline;
wxRadioButton* m_rbBoundingHull; wxRadioButton* m_rbBoundingHull;
wxStaticText* m_gapLabel; wxStaticText* m_gapLabel;
wxTextCtrl* m_gapCtrl; wxTextCtrl* m_gapCtrl;
wxStaticText* m_gapUnits; wxStaticText* m_gapUnits;
UNIT_BINDER* m_gap; UNIT_BINDER* m_gap;
wxCheckBox* m_cbDeleteOriginals; wxCheckBox* m_cbDeleteOriginals;
// The name of a rule area source that is not now found on the board (e.g. after a netlist // The name of a rule area source that is not now found on the board (e.g. after a netlist
// update). This is used to re-populate the zone settings if the selection is not changed. // update). This is used to re-populate the zone settings if the selection is not changed.
bool m_notFoundPlacementSource; bool m_notFoundPlacementSource;
wxString m_notFoundPlacementSourceName; wxString m_notFoundPlacementSourceName;
RULE_AREA_PLACEMENT_SOURCE_TYPE m_originalPlacementSourceType; PLACEMENT_SOURCE_T m_originalPlacementSourceType;
RULE_AREA_PLACEMENT_SOURCE_TYPE m_lastPlacementSourceType; PLACEMENT_SOURCE_T m_lastPlacementSourceType;
PANEL_RULE_AREA_PROPERTIES_KEEPOUT_BASE* m_keepoutProperties; PANEL_RULE_AREA_PROPERTIES_KEEPOUT_BASE* m_keepoutProperties;
PANEL_RULE_AREA_PROPERTIES_PLACEMENT_BASE* m_placementProperties; PANEL_RULE_AREA_PROPERTIES_PLACEMENT_BASE* m_placementProperties;
@ -116,8 +116,8 @@ DIALOG_RULE_AREA_PROPERTIES::DIALOG_RULE_AREA_PROPERTIES( PCB_BASE_FRAME* aPar
m_gap( nullptr ), m_gap( nullptr ),
m_cbDeleteOriginals( nullptr ), m_cbDeleteOriginals( nullptr ),
m_notFoundPlacementSource( false ), m_notFoundPlacementSource( false ),
m_originalPlacementSourceType( RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME ), m_originalPlacementSourceType( PLACEMENT_SOURCE_T::SHEETNAME ),
m_lastPlacementSourceType( RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME ) m_lastPlacementSourceType( PLACEMENT_SOURCE_T::SHEETNAME )
{ {
m_parent = aParent; m_parent = aParent;
@ -215,19 +215,19 @@ DIALOG_RULE_AREA_PROPERTIES::~DIALOG_RULE_AREA_PROPERTIES()
void DIALOG_RULE_AREA_PROPERTIES::OnSheetNameClicked( wxCommandEvent& event ) void DIALOG_RULE_AREA_PROPERTIES::OnSheetNameClicked( wxCommandEvent& event )
{ {
m_lastPlacementSourceType = RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME; m_lastPlacementSourceType = PLACEMENT_SOURCE_T::SHEETNAME;
} }
void DIALOG_RULE_AREA_PROPERTIES::OnComponentClassClicked( wxCommandEvent& event ) void DIALOG_RULE_AREA_PROPERTIES::OnComponentClassClicked( wxCommandEvent& event )
{ {
m_lastPlacementSourceType = RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS; m_lastPlacementSourceType = PLACEMENT_SOURCE_T::COMPONENT_CLASS;
} }
void DIALOG_RULE_AREA_PROPERTIES::OnGroupClicked( wxCommandEvent& event ) void DIALOG_RULE_AREA_PROPERTIES::OnGroupClicked( wxCommandEvent& event )
{ {
m_lastPlacementSourceType = RULE_AREA_PLACEMENT_SOURCE_TYPE::GROUP_PLACEMENT; m_lastPlacementSourceType = PLACEMENT_SOURCE_T::GROUP_PLACEMENT;
} }
@ -261,7 +261,7 @@ bool DIALOG_RULE_AREA_PROPERTIES::TransferDataToWindow()
m_placementProperties->m_GroupRb->SetValue( false ); m_placementProperties->m_GroupRb->SetValue( false );
m_placementProperties->m_groupCombo->Clear(); m_placementProperties->m_groupCombo->Clear();
wxString curSourceName = m_zonesettings.GetRuleAreaPlacementSource(); wxString curSourceName = m_zonesettings.GetPlacementAreaSource();
// Load schematic sheet and component class lists // Load schematic sheet and component class lists
if( m_board ) if( m_board )
@ -318,43 +318,39 @@ bool DIALOG_RULE_AREA_PROPERTIES::TransferDataToWindow()
} }
}; };
if( m_zonesettings.GetRuleAreaPlacementSourceType() if( m_zonesettings.GetPlacementAreaSourceType() == PLACEMENT_SOURCE_T::SHEETNAME )
== RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME )
{ {
if( m_zonesettings.GetRuleAreaPlacementEnabled() ) if( m_zonesettings.GetPlacementAreaEnabled() )
m_placementProperties->m_SheetRb->SetValue( true ); m_placementProperties->m_SheetRb->SetValue( true );
setupCurrentSourceSelection( m_placementProperties->m_sheetCombo ); setupCurrentSourceSelection( m_placementProperties->m_sheetCombo );
m_originalPlacementSourceType = RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME; m_originalPlacementSourceType = PLACEMENT_SOURCE_T::SHEETNAME;
m_lastPlacementSourceType = RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME; m_lastPlacementSourceType = PLACEMENT_SOURCE_T::SHEETNAME;
} }
else if( m_zonesettings.GetRuleAreaPlacementSourceType() else if( m_zonesettings.GetPlacementAreaSourceType() == PLACEMENT_SOURCE_T::COMPONENT_CLASS )
== RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS )
{ {
if( m_zonesettings.GetRuleAreaPlacementEnabled() ) if( m_zonesettings.GetPlacementAreaEnabled() )
m_placementProperties->m_ComponentsRb->SetValue( true ); m_placementProperties->m_ComponentsRb->SetValue( true );
setupCurrentSourceSelection( m_placementProperties->m_componentClassCombo ); setupCurrentSourceSelection( m_placementProperties->m_componentClassCombo );
m_originalPlacementSourceType = RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS; m_originalPlacementSourceType = PLACEMENT_SOURCE_T::COMPONENT_CLASS;
m_lastPlacementSourceType = RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS; m_lastPlacementSourceType = PLACEMENT_SOURCE_T::COMPONENT_CLASS;
} }
else else
{ {
if( m_zonesettings.GetRuleAreaPlacementEnabled() ) if( m_zonesettings.GetPlacementAreaEnabled() )
m_placementProperties->m_GroupRb->SetValue( true ); m_placementProperties->m_GroupRb->SetValue( true );
setupCurrentSourceSelection( m_placementProperties->m_groupCombo ); setupCurrentSourceSelection( m_placementProperties->m_groupCombo );
m_originalPlacementSourceType = RULE_AREA_PLACEMENT_SOURCE_TYPE::GROUP_PLACEMENT; m_originalPlacementSourceType = PLACEMENT_SOURCE_T::GROUP_PLACEMENT;
m_lastPlacementSourceType = RULE_AREA_PLACEMENT_SOURCE_TYPE::GROUP_PLACEMENT; m_lastPlacementSourceType = PLACEMENT_SOURCE_T::GROUP_PLACEMENT;
} }
// Handle most-useful notebook page selection // Handle most-useful notebook page selection
m_areaPropertiesNb->SetSelection( 0 ); m_areaPropertiesNb->SetSelection( 0 );
if( !m_zonesettings.HasKeepoutParametersSet() && m_zonesettings.GetRuleAreaPlacementEnabled() ) if( !m_zonesettings.HasKeepoutParametersSet() && m_zonesettings.GetPlacementAreaEnabled() )
{
m_areaPropertiesNb->SetSelection( 1 ); m_areaPropertiesNb->SetSelection( 1 );
}
m_cbLocked->SetValue( m_zonesettings.m_Locked ); m_cbLocked->SetValue( m_zonesettings.m_Locked );
@ -430,52 +426,53 @@ bool DIALOG_RULE_AREA_PROPERTIES::TransferDataFromWindow()
m_zonesettings.SetDoNotAllowFootprints( m_keepoutProperties->m_cbFootprintsCtrl->GetValue() ); m_zonesettings.SetDoNotAllowFootprints( m_keepoutProperties->m_cbFootprintsCtrl->GetValue() );
// Set placement parameters // Set placement parameters
m_zonesettings.SetRuleAreaPlacementEnabled( false ); m_zonesettings.SetPlacementAreaEnabled( false );
m_zonesettings.SetRuleAreaPlacementSource( wxEmptyString ); m_zonesettings.SetPlacementAreaSource( wxEmptyString );
auto setPlacementSource = [this]( RULE_AREA_PLACEMENT_SOURCE_TYPE sourceType ) auto setPlacementSource =
{ [this]( PLACEMENT_SOURCE_T sourceType )
m_zonesettings.SetRuleAreaPlacementSourceType( sourceType );
wxComboBox* cb;
if( sourceType == RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME )
cb = m_placementProperties->m_sheetCombo;
else if( sourceType == RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS )
cb = m_placementProperties->m_componentClassCombo;
else
cb = m_placementProperties->m_groupCombo;
int selectedSourceIdx = cb->GetSelection();
if( selectedSourceIdx != wxNOT_FOUND )
{
if( selectedSourceIdx == 0 && m_notFoundPlacementSource
&& m_originalPlacementSourceType == sourceType )
{ {
m_zonesettings.SetRuleAreaPlacementSource( m_notFoundPlacementSourceName ); m_zonesettings.SetPlacementAreaSourceType( sourceType );
}
else wxComboBox* cb;
{
m_zonesettings.SetRuleAreaPlacementSource( cb->GetString( selectedSourceIdx ) ); if( sourceType == PLACEMENT_SOURCE_T::SHEETNAME )
} cb = m_placementProperties->m_sheetCombo;
} else if( sourceType == PLACEMENT_SOURCE_T::COMPONENT_CLASS )
}; cb = m_placementProperties->m_componentClassCombo;
else
cb = m_placementProperties->m_groupCombo;
int selectedSourceIdx = cb->GetSelection();
if( selectedSourceIdx != wxNOT_FOUND )
{
if( selectedSourceIdx == 0 && m_notFoundPlacementSource
&& m_originalPlacementSourceType == sourceType )
{
m_zonesettings.SetPlacementAreaSource( m_notFoundPlacementSourceName );
}
else
{
m_zonesettings.SetPlacementAreaSource( cb->GetString( selectedSourceIdx ) );
}
}
};
if( m_placementProperties->m_SheetRb->GetValue() ) if( m_placementProperties->m_SheetRb->GetValue() )
{ {
m_zonesettings.SetRuleAreaPlacementEnabled( true ); m_zonesettings.SetPlacementAreaEnabled( true );
setPlacementSource( RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME ); setPlacementSource( PLACEMENT_SOURCE_T::SHEETNAME );
} }
else if( m_placementProperties->m_ComponentsRb->GetValue() ) else if( m_placementProperties->m_ComponentsRb->GetValue() )
{ {
m_zonesettings.SetRuleAreaPlacementEnabled( true ); m_zonesettings.SetPlacementAreaEnabled( true );
setPlacementSource( RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS ); setPlacementSource( PLACEMENT_SOURCE_T::COMPONENT_CLASS );
} }
else if( m_placementProperties->m_GroupRb->GetValue() ) else if( m_placementProperties->m_GroupRb->GetValue() )
{ {
m_zonesettings.SetRuleAreaPlacementEnabled( true ); m_zonesettings.SetPlacementAreaEnabled( true );
setPlacementSource( RULE_AREA_PLACEMENT_SOURCE_TYPE::GROUP_PLACEMENT ); setPlacementSource( PLACEMENT_SOURCE_T::GROUP_PLACEMENT );
} }
else else
{ {

View File

@ -2632,21 +2632,18 @@ void PCB_IO_KICAD_SEXPR::format( const ZONE* aZone ) const
// Multichannel settings // Multichannel settings
m_out->Print( "(placement" ); m_out->Print( "(placement" );
KICAD_FORMAT::FormatBool( m_out, "enabled", aZone->GetRuleAreaPlacementEnabled() ); KICAD_FORMAT::FormatBool( m_out, "enabled", aZone->GetPlacementAreaEnabled() );
switch( aZone->GetRuleAreaPlacementSourceType() ) switch( aZone->GetPlacementAreaSourceType() )
{ {
case RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME: case PLACEMENT_SOURCE_T::SHEETNAME:
m_out->Print( "(sheetname %s)", m_out->Print( "(sheetname %s)", m_out->Quotew( aZone->GetPlacementAreaSource() ).c_str() );
m_out->Quotew( aZone->GetRuleAreaPlacementSource() ).c_str() );
break; break;
case RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS: case PLACEMENT_SOURCE_T::COMPONENT_CLASS:
m_out->Print( "(component_class %s)", m_out->Print( "(component_class %s)", m_out->Quotew( aZone->GetPlacementAreaSource() ).c_str() );
m_out->Quotew( aZone->GetRuleAreaPlacementSource() ).c_str() );
break; break;
case RULE_AREA_PLACEMENT_SOURCE_TYPE::GROUP_PLACEMENT: case PLACEMENT_SOURCE_T::GROUP_PLACEMENT:
m_out->Print( "(group %s)", m_out->Print( "(group %s)", m_out->Quotew( aZone->GetPlacementAreaSource() ).c_str() );
m_out->Quotew( aZone->GetRuleAreaPlacementSource() ).c_str() );
break; break;
} }

View File

@ -7230,25 +7230,23 @@ ZONE* PCB_IO_KICAD_SEXPR_PARSER::parseZONE( BOARD_ITEM_CONTAINER* aParent )
{ {
case T_sheetname: case T_sheetname:
{ {
zone->SetRuleAreaPlacementSourceType( zone->SetPlacementAreaSourceType( PLACEMENT_SOURCE_T::SHEETNAME );
RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME );
NeedSYMBOL(); NeedSYMBOL();
zone->SetRuleAreaPlacementSource( FromUTF8() ); zone->SetPlacementAreaSource( FromUTF8() );
break; break;
} }
case T_component_class: case T_component_class:
{ {
zone->SetRuleAreaPlacementSourceType( zone->SetPlacementAreaSourceType( PLACEMENT_SOURCE_T::COMPONENT_CLASS );
RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS );
NeedSYMBOL(); NeedSYMBOL();
zone->SetRuleAreaPlacementSource( FromUTF8() ); zone->SetPlacementAreaSource( FromUTF8() );
break; break;
} }
case T_group: case T_group:
{ {
zone->SetRuleAreaPlacementSourceType( RULE_AREA_PLACEMENT_SOURCE_TYPE::GROUP_PLACEMENT ); zone->SetPlacementAreaSourceType( PLACEMENT_SOURCE_T::GROUP_PLACEMENT );
NeedSYMBOL(); NeedSYMBOL();
zone->SetRuleAreaPlacementSource( FromUTF8() ); zone->SetPlacementAreaSource( FromUTF8() );
break; break;
} }
case T_enabled: case T_enabled:
@ -7256,9 +7254,9 @@ ZONE* PCB_IO_KICAD_SEXPR_PARSER::parseZONE( BOARD_ITEM_CONTAINER* aParent )
token = NextTok(); token = NextTok();
if( token == T_yes ) if( token == T_yes )
zone->SetRuleAreaPlacementEnabled( true ); zone->SetPlacementAreaEnabled( true );
else if( token == T_no ) else if( token == T_no )
zone->SetRuleAreaPlacementEnabled( false ); zone->SetPlacementAreaEnabled( false );
else else
Expecting( "yes or no" ); Expecting( "yes or no" );

View File

@ -95,20 +95,16 @@ bool MULTICHANNEL_TOOL::identifyComponentsInRuleArea( ZONE* aRul
wxString ruleText; wxString ruleText;
switch( aRuleArea->GetRuleAreaPlacementSourceType() ) switch( aRuleArea->GetPlacementAreaSourceType() )
{ {
case RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME: case PLACEMENT_SOURCE_T::SHEETNAME:
{ ruleText = wxT( "A.memberOfSheetOrChildren('" ) + aRuleArea->GetPlacementAreaSource() + wxT( "')" );
ruleText = wxT( "A.memberOfSheetOrChildren('" ) + aRuleArea->GetRuleAreaPlacementSource()
+ wxT( "')" );
break; break;
} case PLACEMENT_SOURCE_T::COMPONENT_CLASS:
case RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS: ruleText = wxT( "A.hasComponentClass('" ) + aRuleArea->GetPlacementAreaSource() + wxT( "')" );
ruleText = wxT( "A.hasComponentClass('" ) + aRuleArea->GetRuleAreaPlacementSource()
+ wxT( "')" );
break; break;
case RULE_AREA_PLACEMENT_SOURCE_TYPE::GROUP_PLACEMENT: case PLACEMENT_SOURCE_T::GROUP_PLACEMENT:
ruleText = wxT( "A.memberOfGroup('" ) + aRuleArea->GetRuleAreaPlacementSource() + wxT( "')" ); ruleText = wxT( "A.memberOfGroup('" ) + aRuleArea->GetPlacementAreaSource() + wxT( "')" );
break; break;
} }
@ -328,7 +324,7 @@ void MULTICHANNEL_TOOL::QuerySheetsAndComponentClasses()
{ {
RULE_AREA ent; RULE_AREA ent;
ent.m_sourceType = RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME; ent.m_sourceType = PLACEMENT_SOURCE_T::SHEETNAME;
ent.m_generateEnabled = false; ent.m_generateEnabled = false;
ent.m_sheetPath = sheet.first; ent.m_sheetPath = sheet.first;
ent.m_sheetName = sheet.second; ent.m_sheetName = sheet.second;
@ -343,7 +339,7 @@ void MULTICHANNEL_TOOL::QuerySheetsAndComponentClasses()
{ {
RULE_AREA ent; RULE_AREA ent;
ent.m_sourceType = RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS; ent.m_sourceType = PLACEMENT_SOURCE_T::COMPONENT_CLASS;
ent.m_generateEnabled = false; ent.m_generateEnabled = false;
ent.m_componentClass = compClass; ent.m_componentClass = compClass;
ent.m_components = queryComponentsInComponentClass( ent.m_componentClass ); ent.m_components = queryComponentsInComponentClass( ent.m_componentClass );
@ -357,7 +353,7 @@ void MULTICHANNEL_TOOL::QuerySheetsAndComponentClasses()
{ {
RULE_AREA ent; RULE_AREA ent;
ent.m_sourceType = RULE_AREA_PLACEMENT_SOURCE_TYPE::GROUP_PLACEMENT; ent.m_sourceType = PLACEMENT_SOURCE_T::GROUP_PLACEMENT;
ent.m_generateEnabled = false; ent.m_generateEnabled = false;
ent.m_groupName = groupName; ent.m_groupName = groupName;
ent.m_components = queryComponentsInGroup( ent.m_groupName ); ent.m_components = queryComponentsInGroup( ent.m_groupName );
@ -377,7 +373,7 @@ void MULTICHANNEL_TOOL::FindExistingRuleAreas()
{ {
if( !zone->GetIsRuleArea() ) if( !zone->GetIsRuleArea() )
continue; continue;
if( !zone->GetRuleAreaPlacementEnabled() ) if( !zone->GetPlacementAreaEnabled() )
continue; continue;
RULE_AREA area; RULE_AREA area;
@ -430,7 +426,7 @@ int MULTICHANNEL_TOOL::repeatLayout( const TOOL_EVENT& aEvent )
if( !zone->GetIsRuleArea() ) if( !zone->GetIsRuleArea() )
return nullptr; return nullptr;
if( !zone->GetRuleAreaPlacementEnabled() ) if( !zone->GetPlacementAreaEnabled() )
return nullptr; return nullptr;
return zone; return zone;
@ -1107,7 +1103,7 @@ int MULTICHANNEL_TOOL::AutogenerateRuleAreas( const TOOL_EVENT& aEvent )
{ {
if( !zone->GetIsRuleArea() ) if( !zone->GetIsRuleArea() )
continue; continue;
if( !zone->GetRuleAreaPlacementEnabled() ) if( !zone->GetPlacementAreaEnabled() )
continue; continue;
std::set<FOOTPRINT*> components; std::set<FOOTPRINT*> components;
@ -1120,27 +1116,22 @@ int MULTICHANNEL_TOOL::AutogenerateRuleAreas( const TOOL_EVENT& aEvent )
{ {
if( components == ra.m_components ) if( components == ra.m_components )
{ {
if( zone->GetRuleAreaPlacementSourceType() if( zone->GetPlacementAreaSourceType() == PLACEMENT_SOURCE_T::SHEETNAME )
== RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME )
{
wxLogTrace(
traceMultichannelTool,
wxT( "Placement rule area for sheet '%s' already exists as '%s'\n" ),
ra.m_sheetPath, zone->GetZoneName() );
}
else if( zone->GetRuleAreaPlacementSourceType()
== RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS )
{ {
wxLogTrace( traceMultichannelTool, wxLogTrace( traceMultichannelTool,
wxT( "Placement rule area for component class '%s' already exists " wxT( "Placement rule area for sheet '%s' already exists as '%s'\n" ),
"as '%s'\n" ), ra.m_sheetPath, zone->GetZoneName() );
}
else if( zone->GetPlacementAreaSourceType() == PLACEMENT_SOURCE_T::COMPONENT_CLASS )
{
wxLogTrace( traceMultichannelTool,
wxT( "Placement rule area for component class '%s' already exists as '%s'\n" ),
ra.m_componentClass, zone->GetZoneName() ); ra.m_componentClass, zone->GetZoneName() );
} }
else else
{ {
wxLogTrace( traceMultichannelTool, wxLogTrace( traceMultichannelTool,
wxT( "Placement rule area for group '%s' already exists " wxT( "Placement rule area for group '%s' already exists as '%s'\n" ),
"as '%s'\n" ),
ra.m_groupName, zone->GetZoneName() ); ra.m_groupName, zone->GetZoneName() );
} }
@ -1150,8 +1141,7 @@ int MULTICHANNEL_TOOL::AutogenerateRuleAreas( const TOOL_EVENT& aEvent )
} }
} }
wxLogTrace( traceMultichannelTool, wxLogTrace( traceMultichannelTool, wxT( "%d placement areas found\n" ), (int) m_areas.m_areas.size() );
wxT( "%d placement areas found\n" ), (int) m_areas.m_areas.size() );
BOARD_COMMIT commit( GetManager(), true ); BOARD_COMMIT commit( GetManager(), true );
@ -1170,48 +1160,39 @@ int MULTICHANNEL_TOOL::AutogenerateRuleAreas( const TOOL_EVENT& aEvent )
std::unique_ptr<ZONE> newZone( new ZONE( board() ) ); std::unique_ptr<ZONE> newZone( new ZONE( board() ) );
if( ra.m_sourceType == RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME ) if( ra.m_sourceType == PLACEMENT_SOURCE_T::SHEETNAME )
{ newZone->SetZoneName( wxString::Format( wxT( "auto-placement-area-%s" ), ra.m_sheetPath ) );
newZone->SetZoneName( else if( ra.m_sourceType == PLACEMENT_SOURCE_T::COMPONENT_CLASS )
wxString::Format( wxT( "auto-placement-area-%s" ), ra.m_sheetPath ) ); newZone->SetZoneName( wxString::Format( wxT( "auto-placement-area-%s" ), ra.m_componentClass ) );
}
else if( ra.m_sourceType == RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS )
{
newZone->SetZoneName(
wxString::Format( wxT( "auto-placement-area-%s" ), ra.m_componentClass ) );
}
else else
{
newZone->SetZoneName( wxString::Format( wxT( "auto-placement-area-%s" ), ra.m_groupName ) ); newZone->SetZoneName( wxString::Format( wxT( "auto-placement-area-%s" ), ra.m_groupName ) );
}
wxLogTrace( traceMultichannelTool, wxT( "Generated rule area '%s' (%d components)\n" ), wxLogTrace( traceMultichannelTool, wxT( "Generated rule area '%s' (%d components)\n" ),
newZone->GetZoneName(), (int) ra.m_components.size() ); newZone->GetZoneName(), (int) ra.m_components.size() );
newZone->SetIsRuleArea( true ); newZone->SetIsRuleArea( true );
newZone->SetLayerSet( LSET::AllCuMask() ); newZone->SetLayerSet( LSET::AllCuMask() );
newZone->SetRuleAreaPlacementEnabled( true ); newZone->SetPlacementAreaEnabled( true );
newZone->SetDoNotAllowZoneFills( false ); newZone->SetDoNotAllowZoneFills( false );
newZone->SetDoNotAllowVias( false ); newZone->SetDoNotAllowVias( false );
newZone->SetDoNotAllowTracks( false ); newZone->SetDoNotAllowTracks( false );
newZone->SetDoNotAllowPads( false ); newZone->SetDoNotAllowPads( false );
newZone->SetDoNotAllowFootprints( false ); newZone->SetDoNotAllowFootprints( false );
if( ra.m_sourceType == RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME ) if( ra.m_sourceType == PLACEMENT_SOURCE_T::SHEETNAME )
{ {
newZone->SetRuleAreaPlacementSourceType( RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME ); newZone->SetPlacementAreaSourceType( PLACEMENT_SOURCE_T::SHEETNAME );
newZone->SetRuleAreaPlacementSource( ra.m_sheetPath ); newZone->SetPlacementAreaSource( ra.m_sheetPath );
} }
else if( ra.m_sourceType == RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS ) else if( ra.m_sourceType == PLACEMENT_SOURCE_T::COMPONENT_CLASS )
{ {
newZone->SetRuleAreaPlacementSourceType( newZone->SetPlacementAreaSourceType( PLACEMENT_SOURCE_T::COMPONENT_CLASS );
RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS ); newZone->SetPlacementAreaSource( ra.m_componentClass );
newZone->SetRuleAreaPlacementSource( ra.m_componentClass );
} }
else else
{ {
newZone->SetRuleAreaPlacementSourceType( RULE_AREA_PLACEMENT_SOURCE_TYPE::GROUP_PLACEMENT ); newZone->SetPlacementAreaSourceType( PLACEMENT_SOURCE_T::GROUP_PLACEMENT );
newZone->SetRuleAreaPlacementSource( ra.m_groupName ); newZone->SetPlacementAreaSource( ra.m_groupName );
} }
newZone->AddPolygon( raOutline ); newZone->AddPolygon( raOutline );

View File

@ -74,20 +74,20 @@ struct RULE_AREA_COMPAT_DATA
struct RULE_AREA struct RULE_AREA
{ {
RULE_AREA_PLACEMENT_SOURCE_TYPE m_sourceType = RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME; PLACEMENT_SOURCE_T m_sourceType = PLACEMENT_SOURCE_T::SHEETNAME;
ZONE* m_oldArea = nullptr; ZONE* m_oldArea = nullptr;
ZONE* m_area = nullptr; ZONE* m_area = nullptr;
std::set<FOOTPRINT*> m_raFootprints; std::set<FOOTPRINT*> m_raFootprints;
std::set<FOOTPRINT*> m_components; std::set<FOOTPRINT*> m_components;
bool m_existsAlready = false; bool m_existsAlready = false;
bool m_generateEnabled = false; bool m_generateEnabled = false;
wxString m_sheetPath; wxString m_sheetPath;
wxString m_sheetName; wxString m_sheetName;
wxString m_ruleName; wxString m_ruleName;
wxString m_componentClass; wxString m_componentClass;
KIID m_group; KIID m_group;
wxString m_groupName; wxString m_groupName;
VECTOR2I m_center; VECTOR2I m_center;
}; };

View File

@ -57,8 +57,8 @@ ZONE::ZONE( BOARD_ITEM_CONTAINER* aParent ) :
m_cornerRadius( 0 ), m_cornerRadius( 0 ),
m_priority( 0 ), m_priority( 0 ),
m_isRuleArea( false ), m_isRuleArea( false ),
m_ruleAreaPlacementEnabled( false ), m_placementAreaEnabled( false ),
m_ruleAreaPlacementSourceType( RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME ), m_placementAreaSourceType( PLACEMENT_SOURCE_T::SHEETNAME ),
m_teardropType( TEARDROP_TYPE::TD_NONE ), m_teardropType( TEARDROP_TYPE::TD_NONE ),
m_PadConnection( ZONE_CONNECTION::NONE ), m_PadConnection( ZONE_CONNECTION::NONE ),
m_ZoneClearance( 0 ), m_ZoneClearance( 0 ),
@ -73,7 +73,6 @@ ZONE::ZONE( BOARD_ITEM_CONTAINER* aParent ) :
m_hatchOrientation( ANGLE_0 ), m_hatchOrientation( ANGLE_0 ),
m_hatchSmoothingLevel( 0 ), m_hatchSmoothingLevel( 0 ),
m_hatchHoleMinArea( 0 ), m_hatchHoleMinArea( 0 ),
m_CornerSelection( nullptr ),
m_area( 0.0 ), m_area( 0.0 ),
m_outlinearea( 0.0 ) m_outlinearea( 0.0 )
{ {
@ -96,8 +95,7 @@ ZONE::ZONE( BOARD_ITEM_CONTAINER* aParent ) :
ZONE::ZONE( const ZONE& aZone ) : ZONE::ZONE( const ZONE& aZone ) :
BOARD_CONNECTED_ITEM( aZone ), BOARD_CONNECTED_ITEM( aZone ),
m_Poly( nullptr ), m_Poly( nullptr )
m_CornerSelection( nullptr )
{ {
InitDataFromSrcInCopyCtor( aZone ); InitDataFromSrcInCopyCtor( aZone );
} }
@ -123,7 +121,6 @@ void ZONE::CopyFrom( const BOARD_ITEM* aOther )
ZONE::~ZONE() ZONE::~ZONE()
{ {
delete m_Poly; delete m_Poly;
delete m_CornerSelection;
if( BOARD* board = GetBoard() ) if( BOARD* board = GetBoard() )
board->IncrementTimeStamp(); board->IncrementTimeStamp();
@ -148,9 +145,9 @@ void ZONE::InitDataFromSrcInCopyCtor( const ZONE& aZone )
m_zoneName = aZone.m_zoneName; m_zoneName = aZone.m_zoneName;
m_priority = aZone.m_priority; m_priority = aZone.m_priority;
m_isRuleArea = aZone.m_isRuleArea; m_isRuleArea = aZone.m_isRuleArea;
m_ruleAreaPlacementEnabled = aZone.m_ruleAreaPlacementEnabled; m_placementAreaEnabled = aZone.m_placementAreaEnabled;
m_ruleAreaPlacementSourceType = aZone.m_ruleAreaPlacementSourceType; m_placementAreaSourceType = aZone.m_placementAreaSourceType;
m_ruleAreaPlacementSource = aZone.m_ruleAreaPlacementSource; m_placementAreaSource = aZone.m_placementAreaSource;
SetLayerSet( aZone.GetLayerSet() ); SetLayerSet( aZone.GetLayerSet() );
m_doNotAllowZoneFills = aZone.m_doNotAllowZoneFills; m_doNotAllowZoneFills = aZone.m_doNotAllowZoneFills;
@ -182,10 +179,6 @@ void ZONE::InitDataFromSrcInCopyCtor( const ZONE& aZone )
m_hatchBorderAlgorithm = aZone.m_hatchBorderAlgorithm; m_hatchBorderAlgorithm = aZone.m_hatchBorderAlgorithm;
m_hatchHoleMinArea = aZone.m_hatchHoleMinArea; m_hatchHoleMinArea = aZone.m_hatchHoleMinArea;
// For corner moving, corner index to drag, or nullptr if no selection
delete m_CornerSelection;
m_CornerSelection = nullptr;
aZone.GetLayerSet().RunOnLayers( aZone.GetLayerSet().RunOnLayers(
[&]( PCB_LAYER_ID layer ) [&]( PCB_LAYER_ID layer )
{ {
@ -256,11 +249,10 @@ void ZONE::Serialize( google::protobuf::Any& aContainer ) const
ra->set_keepout_tracks( m_doNotAllowTracks ); ra->set_keepout_tracks( m_doNotAllowTracks );
ra->set_keepout_vias( m_doNotAllowVias ); ra->set_keepout_vias( m_doNotAllowVias );
ra->set_placement_enabled( m_ruleAreaPlacementEnabled ); ra->set_placement_enabled( m_placementAreaEnabled );
ra->set_placement_source( m_ruleAreaPlacementSource.ToUTF8() ); ra->set_placement_source( m_placementAreaSource.ToUTF8() );
ra->set_placement_source_type( ra->set_placement_source_type( ToProtoEnum<PLACEMENT_SOURCE_T,
ToProtoEnum<RULE_AREA_PLACEMENT_SOURCE_TYPE, types::PlacementRuleSourceType>( types::PlacementRuleSourceType>( m_placementAreaSourceType ) );
m_ruleAreaPlacementSourceType ) );
} }
else else
{ {
@ -360,10 +352,9 @@ bool ZONE::Deserialize( const google::protobuf::Any& aContainer )
m_doNotAllowTracks = ra.keepout_tracks(); m_doNotAllowTracks = ra.keepout_tracks();
m_doNotAllowVias = ra.keepout_vias(); m_doNotAllowVias = ra.keepout_vias();
m_ruleAreaPlacementEnabled = ra.placement_enabled(); m_placementAreaEnabled = ra.placement_enabled();
m_ruleAreaPlacementSource = wxString::FromUTF8( ra.placement_source() ); m_placementAreaSource = wxString::FromUTF8( ra.placement_source() );
m_ruleAreaPlacementSourceType = m_placementAreaSourceType = FromProtoEnum<PLACEMENT_SOURCE_T>( ra.placement_source_type() );
FromProtoEnum<RULE_AREA_PLACEMENT_SOURCE_TYPE>( ra.placement_source_type() );
} }
else else
{ {
@ -433,11 +424,8 @@ bool ZONE::HigherPriority( const ZONE* aOther ) const
{ {
// Teardrops are always higher priority than regular zones, so if one zone is a teardrop // Teardrops are always higher priority than regular zones, so if one zone is a teardrop
// and the other is not, then return higher priority as the teardrop // and the other is not, then return higher priority as the teardrop
if( ( m_teardropType == TEARDROP_TYPE::TD_NONE ) if( ( m_teardropType == TEARDROP_TYPE::TD_NONE ) ^ ( aOther->m_teardropType == TEARDROP_TYPE::TD_NONE ) )
^ ( aOther->m_teardropType == TEARDROP_TYPE::TD_NONE ) )
{
return static_cast<int>( m_teardropType ) > static_cast<int>( aOther->m_teardropType ); return static_cast<int>( m_teardropType ) > static_cast<int>( aOther->m_teardropType );
}
if( m_priority != aOther->m_priority ) if( m_priority != aOther->m_priority )
return m_priority > aOther->m_priority; return m_priority > aOther->m_priority;
@ -485,9 +473,8 @@ VECTOR2I ZONE::GetPosition() const
PCB_LAYER_ID ZONE::GetLayer() const PCB_LAYER_ID ZONE::GetLayer() const
{ {
if( m_layerSet.count() == 1 ) if( m_layerSet.count() == 1 )
{
return GetFirstLayer(); return GetFirstLayer();
}
return UNDEFINED_LAYER; return UNDEFINED_LAYER;
} }
@ -495,18 +482,14 @@ PCB_LAYER_ID ZONE::GetLayer() const
PCB_LAYER_ID ZONE::GetFirstLayer() const PCB_LAYER_ID ZONE::GetFirstLayer() const
{ {
if( m_layerSet.count() == 0 ) if( m_layerSet.count() == 0 )
{
return UNDEFINED_LAYER; return UNDEFINED_LAYER;
}
const LSEQ uiLayers = m_layerSet.UIOrder(); const LSEQ uiLayers = m_layerSet.UIOrder();
// This can't use m_layerSet.count() because it's possible to have a zone on // This can't use m_layerSet.count() because it's possible to have a zone on
// a rescue layer that is not in the UI order. // a rescue layer that is not in the UI order.
if( uiLayers.size() ) if( uiLayers.size() )
{
return uiLayers[0]; return uiLayers[0];
}
// If it's not in the UI set at all, just return the first layer in the set. // If it's not in the UI set at all, just return the first layer in the set.
// (we know the count > 0) // (we know the count > 0)
@ -563,10 +546,8 @@ void ZONE::SetLayerSet( const LSET& aLayerSet )
const ZONE_LAYER_PROPERTIES& ZONE::LayerProperties( PCB_LAYER_ID aLayer ) const const ZONE_LAYER_PROPERTIES& ZONE::LayerProperties( PCB_LAYER_ID aLayer ) const
{ {
wxCHECK_MSG( m_layerProperties.contains( aLayer ), m_layerProperties.at( GetFirstLayer() ), wxCHECK_MSG( m_layerProperties.contains( aLayer ), m_layerProperties.at( GetFirstLayer() ),
"Attempt to retrieve properties for layer " "Zone has no layer " + std::string( magic_enum::enum_name( aLayer ) ) );
+ std::string( magic_enum::enum_name( aLayer ) )
+ " from a "
"zone that does not contain it" );
return m_layerProperties.at( aLayer ); return m_layerProperties.at( aLayer );
} }
@ -581,12 +562,9 @@ void ZONE::SetLayerProperties( const std::map<PCB_LAYER_ID, ZONE_LAYER_PROPERTIE
const std::optional<VECTOR2I>& ZONE::HatchingOffset( PCB_LAYER_ID aLayer ) const const std::optional<VECTOR2I>& ZONE::HatchingOffset( PCB_LAYER_ID aLayer ) const
{ {
wxCHECK_MSG( m_layerProperties.contains( aLayer ), wxCHECK_MSG( m_layerProperties.contains( aLayer ), m_layerProperties.at( GetFirstLayer() ).hatching_offset,
m_layerProperties.at( GetFirstLayer() ).hatching_offset, "Zone has no layer " + std::string( magic_enum::enum_name( aLayer ) ) );
"Attempt to retrieve properties for layer "
+ std::string( magic_enum::enum_name( aLayer ) )
+ " from a "
"zone that does not contain it" );
return m_layerProperties.at( aLayer ).hatching_offset; return m_layerProperties.at( aLayer ).hatching_offset;
} }
@ -837,11 +815,6 @@ void ZONE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>&
{ {
wxString msg = GetFriendlyName(); wxString msg = GetFriendlyName();
// Display Cutout instead of Outline for holes inside a zone (i.e. when num contour !=0).
// Check whether the selected corner is in a hole; i.e., in any contour but the first one.
if( m_CornerSelection != nullptr && m_CornerSelection->m_contour > 0 )
msg << wxT( " " ) << _( "Cutout" );
aList.emplace_back( _( "Type" ), msg ); aList.emplace_back( _( "Type" ), msg );
if( GetIsRuleArea() ) if( GetIsRuleArea() )
@ -866,11 +839,8 @@ void ZONE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>&
if( !msg.IsEmpty() ) if( !msg.IsEmpty() )
aList.emplace_back( _( "Restrictions" ), msg ); aList.emplace_back( _( "Restrictions" ), msg );
if( GetRuleAreaPlacementEnabled() ) if( GetPlacementAreaEnabled() )
{ aList.emplace_back( _( "Placement source" ), UnescapeString( GetPlacementAreaSource() ) );
aList.emplace_back( _( "Placement source" ),
UnescapeString( GetRuleAreaPlacementSource() ) );
}
} }
else if( IsOnCopperLayer() ) else if( IsOnCopperLayer() )
{ {
@ -883,8 +853,7 @@ void ZONE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>&
} }
// Display priority level // Display priority level
aList.emplace_back( _( "Priority" ), aList.emplace_back( _( "Priority" ), wxString::Format( wxT( "%d" ), GetAssignedPriority() ) );
wxString::Format( wxT( "%d" ), GetAssignedPriority() ) );
} }
if( aFrame->GetName() == PCB_EDIT_FRAME_NAME ) if( aFrame->GetName() == PCB_EDIT_FRAME_NAME )
@ -943,10 +912,8 @@ void ZONE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>&
if( !source.IsEmpty() ) if( !source.IsEmpty() )
{ {
aList.emplace_back( wxString::Format( _( "Min Clearance: %s" ), aList.emplace_back( wxString::Format( _( "Min Clearance: %s" ), aFrame->MessageTextFromValue( clearance ) ),
aFrame->MessageTextFromValue( clearance ) ), wxString::Format( _( "(from %s)" ), source ) );
wxString::Format( _( "(from %s)" ),
source ) );
} }
if( !m_FilledPolysList.empty() ) if( !m_FilledPolysList.empty() )
@ -1034,9 +1001,7 @@ void ZONE::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
std::map<PCB_LAYER_ID, SHAPE_POLY_SET> fillsCopy; std::map<PCB_LAYER_ID, SHAPE_POLY_SET> fillsCopy;
for( auto& [oldLayer, shapePtr] : m_FilledPolysList ) for( auto& [oldLayer, shapePtr] : m_FilledPolysList )
{
fillsCopy[oldLayer] = *shapePtr; fillsCopy[oldLayer] = *shapePtr;
}
std::map<PCB_LAYER_ID, ZONE_LAYER_PROPERTIES> layerPropertiesCopy; std::map<PCB_LAYER_ID, ZONE_LAYER_PROPERTIES> layerPropertiesCopy;
@ -1171,61 +1136,44 @@ wxString ZONE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull )
layers.size() - 2 ); layers.size() - 2 );
} }
// Check whether the selected contour is a hole (contour index > 0) if( GetIsRuleArea() )
if( m_CornerSelection != nullptr && m_CornerSelection->m_contour > 0 )
{ {
if( GetIsRuleArea() ) if( GetZoneName().IsEmpty() )
return wxString::Format( _( "Rule Area Cutout %s" ), layerDesc );
else
return wxString::Format( _( "Zone Cutout %s" ), layerDesc );
}
else
{
if( GetIsRuleArea() )
{ {
if( GetZoneName().IsEmpty() ) return wxString::Format( _( "Rule Area %s" ),
{
return wxString::Format( _( "Rule Area %s" ),
layerDesc );
}
else
{
return wxString::Format( _( "Rule Area '%s' %s" ),
GetZoneName(),
layerDesc );
}
}
else if( IsTeardropArea() )
{
return wxString::Format( _( "Teardrop %s %s" ),
GetNetnameMsg(),
layerDesc ); layerDesc );
} }
else else
{ {
if( GetZoneName().IsEmpty() ) return wxString::Format( _( "Rule Area '%s' %s" ),
{ GetZoneName(),
return wxString::Format( _( "Zone %s %s, priority %d" ), layerDesc );
GetNetnameMsg(), }
layerDesc, }
GetAssignedPriority() ); else if( IsTeardropArea() )
} {
else return wxString::Format( _( "Teardrop %s %s" ),
{ GetNetnameMsg(),
return wxString::Format( _( "Zone '%s' %s %s, priority %d" ), layerDesc );
GetZoneName(), }
GetNetnameMsg(), else
layerDesc, {
GetAssignedPriority() ); if( GetZoneName().IsEmpty() )
} {
return wxString::Format( _( "Zone %s %s, priority %d" ),
GetNetnameMsg(),
layerDesc,
GetAssignedPriority() );
}
else
{
return wxString::Format( _( "Zone '%s' %s %s, priority %d" ),
GetZoneName(),
GetNetnameMsg(),
layerDesc,
GetAssignedPriority() );
} }
} }
}
int ZONE::GetBorderHatchPitch() const
{
return m_borderHatchPitch;
} }
@ -1242,12 +1190,6 @@ void ZONE::SetBorderDisplayStyle( ZONE_BORDER_DISPLAY_STYLE aBorderHatchStyle,
} }
void ZONE::SetBorderHatchPitch( int aPitch )
{
m_borderHatchPitch = aPitch;
}
void ZONE::UnHatchBorder() void ZONE::UnHatchBorder()
{ {
m_borderHatchLines.clear(); m_borderHatchLines.clear();
@ -1689,13 +1631,13 @@ bool ZONE::operator==( const ZONE& aOther ) const
if( GetDoNotAllowPads() != other.GetDoNotAllowPads() ) if( GetDoNotAllowPads() != other.GetDoNotAllowPads() )
return false; return false;
if( GetRuleAreaPlacementEnabled() != other.GetRuleAreaPlacementEnabled() ) if( GetPlacementAreaEnabled() != other.GetPlacementAreaEnabled() )
return false; return false;
if( GetRuleAreaPlacementSourceType() != other.GetRuleAreaPlacementSourceType() ) if( GetPlacementAreaSourceType() != other.GetPlacementAreaSourceType() )
return false; return false;
if( GetRuleAreaPlacementSource() != other.GetRuleAreaPlacementSource() ) if( GetPlacementAreaSource() != other.GetPlacementAreaSource() )
return false; return false;
} }
else else
@ -1848,15 +1790,14 @@ static struct ZONE_DESC
.Map( ISLAND_REMOVAL_MODE::AREA, _HKI( "Below area limit" ) ); .Map( ISLAND_REMOVAL_MODE::AREA, _HKI( "Below area limit" ) );
} }
ENUM_MAP<RULE_AREA_PLACEMENT_SOURCE_TYPE>& rapstMap = ENUM_MAP<PLACEMENT_SOURCE_T>& rapstMap = ENUM_MAP<PLACEMENT_SOURCE_T>::Instance();
ENUM_MAP<RULE_AREA_PLACEMENT_SOURCE_TYPE>::Instance();
if( rapstMap.Choices().GetCount() == 0 ) if( rapstMap.Choices().GetCount() == 0 )
{ {
rapstMap.Undefined( RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME ); rapstMap.Undefined( PLACEMENT_SOURCE_T::SHEETNAME );
rapstMap.Map( RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME, _HKI( "Sheet Name" ) ) rapstMap.Map( PLACEMENT_SOURCE_T::SHEETNAME, _HKI( "Sheet Name" ) )
.Map( RULE_AREA_PLACEMENT_SOURCE_TYPE::COMPONENT_CLASS, _HKI( "Component Class" ) ) .Map( PLACEMENT_SOURCE_T::COMPONENT_CLASS, _HKI( "Component Class" ) )
.Map( RULE_AREA_PLACEMENT_SOURCE_TYPE::GROUP_PLACEMENT, _HKI( "Group" ) ); .Map( PLACEMENT_SOURCE_T::GROUP_PLACEMENT, _HKI( "Group" ) );
} }
PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance(); PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
@ -1971,20 +1912,20 @@ static struct ZONE_DESC
const wxString groupPlacement = _HKI( "Placement" ); const wxString groupPlacement = _HKI( "Placement" );
propMgr.AddProperty( new PROPERTY<ZONE, bool>( _HKI( "Enable" ), propMgr.AddProperty( new PROPERTY<ZONE, bool>( _HKI( "Enable" ),
&ZONE::SetRuleAreaPlacementEnabled, &ZONE::SetPlacementAreaEnabled,
&ZONE::GetRuleAreaPlacementEnabled ), &ZONE::GetPlacementAreaEnabled ),
groupPlacement ) groupPlacement )
.SetAvailableFunc( isRuleArea ); .SetAvailableFunc( isRuleArea );
propMgr.AddProperty( new PROPERTY_ENUM<ZONE, RULE_AREA_PLACEMENT_SOURCE_TYPE>( propMgr.AddProperty( new PROPERTY_ENUM<ZONE, PLACEMENT_SOURCE_T>( _HKI( "Source Type" ),
_HKI( "Source Type" ), &ZONE::SetRuleAreaPlacementSourceType, &ZONE::SetPlacementAreaSourceType,
&ZONE::GetRuleAreaPlacementSourceType ), &ZONE::GetPlacementAreaSourceType ),
groupPlacement ) groupPlacement )
.SetAvailableFunc( isRuleArea ); .SetAvailableFunc( isRuleArea );
propMgr.AddProperty( new PROPERTY<ZONE, wxString>( _HKI( "Source Name" ), propMgr.AddProperty( new PROPERTY<ZONE, wxString>( _HKI( "Source Name" ),
&ZONE::SetRuleAreaPlacementSource, &ZONE::SetPlacementAreaSource,
&ZONE::GetRuleAreaPlacementSource ), &ZONE::GetPlacementAreaSource ),
groupPlacement ) groupPlacement )
.SetAvailableFunc( isRuleArea ); .SetAvailableFunc( isRuleArea );
@ -2003,7 +1944,6 @@ static struct ZONE_DESC
.SetAvailableFunc( isCopperZone ) .SetAvailableFunc( isCopperZone )
.SetWriteableFunc( isHatchedFill ); .SetWriteableFunc( isHatchedFill );
// TODO: Switch to translated
auto atLeastMinWidthValidator = auto atLeastMinWidthValidator =
[]( const wxAny&& aValue, EDA_ITEM* aZone ) -> VALIDATOR_RESULT []( const wxAny&& aValue, EDA_ITEM* aZone ) -> VALIDATOR_RESULT
{ {
@ -2012,10 +1952,7 @@ static struct ZONE_DESC
wxCHECK( zone, std::nullopt ); wxCHECK( zone, std::nullopt );
if( val < zone->GetMinThickness() ) if( val < zone->GetMinThickness() )
{ return std::make_unique<VALIDATION_ERROR_MSG>( _( "Cannot be less than zone minimum width" ) );
return std::make_unique<VALIDATION_ERROR_MSG>(
_( "Cannot be less than zone minimum width" ) );
}
return std::nullopt; return std::nullopt;
}; };
@ -2067,12 +2004,12 @@ static struct ZONE_DESC
const wxString groupElectrical = _HKI( "Electrical" ); const wxString groupElectrical = _HKI( "Electrical" );
auto clearanceOverride = new PROPERTY<ZONE, std::optional<int>>( _HKI( "Clearance" ), auto clearance = new PROPERTY<ZONE, std::optional<int>>( _HKI( "Clearance" ),
&ZONE::SetLocalClearance, &ZONE::GetLocalClearance, &ZONE::SetLocalClearance, &ZONE::GetLocalClearance,
PROPERTY_DISPLAY::PT_SIZE ); PROPERTY_DISPLAY::PT_SIZE );
clearanceOverride->SetAvailableFunc( isCopperZone ); clearance->SetAvailableFunc( isCopperZone );
constexpr int maxClearance = pcbIUScale.mmToIU( ZONE_CLEARANCE_MAX_VALUE_MM ); constexpr int maxClearance = pcbIUScale.mmToIU( ZONE_CLEARANCE_MAX_VALUE_MM );
clearanceOverride->SetValidator( PROPERTY_VALIDATORS::RangeIntValidator<0, maxClearance> ); clearance->SetValidator( PROPERTY_VALIDATORS::RangeIntValidator<0, maxClearance> );
auto minWidth = new PROPERTY<ZONE, int>( _HKI( "Minimum Width" ), auto minWidth = new PROPERTY<ZONE, int>( _HKI( "Minimum Width" ),
&ZONE::SetMinThickness, &ZONE::GetMinThickness, &ZONE::SetMinThickness, &ZONE::GetMinThickness,
@ -2097,7 +2034,7 @@ static struct ZONE_DESC
thermalSpokeWidth->SetAvailableFunc( isCopperZone ); thermalSpokeWidth->SetAvailableFunc( isCopperZone );
thermalSpokeWidth->SetValidator( atLeastMinWidthValidator ); thermalSpokeWidth->SetValidator( atLeastMinWidthValidator );
propMgr.AddProperty( clearanceOverride, groupElectrical ); propMgr.AddProperty( clearance, groupElectrical );
propMgr.AddProperty( minWidth, groupElectrical ); propMgr.AddProperty( minWidth, groupElectrical );
propMgr.AddProperty( padConnections, groupElectrical ); propMgr.AddProperty( padConnections, groupElectrical );
propMgr.AddProperty( thermalGap, groupElectrical ); propMgr.AddProperty( thermalGap, groupElectrical );
@ -2105,7 +2042,7 @@ static struct ZONE_DESC
} }
} _ZONE_DESC; } _ZONE_DESC;
IMPLEMENT_ENUM_TO_WXANY( RULE_AREA_PLACEMENT_SOURCE_TYPE ) IMPLEMENT_ENUM_TO_WXANY( PLACEMENT_SOURCE_T )
IMPLEMENT_ENUM_TO_WXANY( ZONE_CONNECTION ) IMPLEMENT_ENUM_TO_WXANY( ZONE_CONNECTION )
IMPLEMENT_ENUM_TO_WXANY( ZONE_FILL_MODE ) IMPLEMENT_ENUM_TO_WXANY( ZONE_FILL_MODE )
IMPLEMENT_ENUM_TO_WXANY( ISLAND_REMOVAL_MODE ) IMPLEMENT_ENUM_TO_WXANY( ISLAND_REMOVAL_MODE )

View File

@ -183,19 +183,7 @@ public:
* @return the zone's clearance in internal units. * @return the zone's clearance in internal units.
*/ */
std::optional<int> GetLocalClearance() const override; std::optional<int> GetLocalClearance() const override;
void SetLocalClearance( std::optional<int> aClearance ) { m_ZoneClearance = aClearance.value_or( 0 ); };
/**
* Set the local clearance for this zone.
*
* @param aClearance is the clearance in internal units, or std::nullopt to clear it.
*/
void SetLocalClearance( std::optional<int> aClearance )
{
if( aClearance )
m_ZoneClearance = aClearance.value();
else
m_ZoneClearance = 0;
}
/** /**
* Return any local clearances set in the "classic" (ie: pre-rule) system. * Return any local clearances set in the "classic" (ie: pre-rule) system.
@ -313,16 +301,10 @@ public:
int GetMinThickness() const { return m_ZoneMinThickness; } int GetMinThickness() const { return m_ZoneMinThickness; }
void SetMinThickness( int aMinThickness ) void SetMinThickness( int aMinThickness )
{ {
if( m_ZoneMinThickness != aMinThickness
|| ( m_fillMode == ZONE_FILL_MODE::HATCH_PATTERN
&& ( m_hatchThickness < aMinThickness || m_hatchGap < aMinThickness ) ) )
{
SetNeedRefill( true );
}
m_ZoneMinThickness = aMinThickness; m_ZoneMinThickness = aMinThickness;
m_hatchThickness = std::max( m_hatchThickness, aMinThickness ); m_hatchThickness = std::max( m_hatchThickness, aMinThickness );
m_hatchGap = std::max( m_hatchGap, aMinThickness ); m_hatchGap = std::max( m_hatchGap, aMinThickness );
SetNeedRefill( true );
} }
int GetHatchThickness() const { return m_hatchThickness; } int GetHatchThickness() const { return m_hatchThickness; }
@ -346,33 +328,6 @@ public:
int GetHatchBorderAlgorithm() const { return m_hatchBorderAlgorithm; } int GetHatchBorderAlgorithm() const { return m_hatchBorderAlgorithm; }
void SetHatchBorderAlgorithm( int aAlgo ) { m_hatchBorderAlgorithm = aAlgo; } void SetHatchBorderAlgorithm( int aAlgo ) { m_hatchBorderAlgorithm = aAlgo; }
int GetSelectedCorner() const
{
// Transform relative indices to global index
int globalIndex = -1;
if( m_CornerSelection )
m_Poly->GetGlobalIndex( *m_CornerSelection, globalIndex );
return globalIndex;
}
void SetSelectedCorner( int aCorner )
{
SHAPE_POLY_SET::VERTEX_INDEX selectedCorner;
// If the global index of the corner is correct, assign it to m_CornerSelection
if( m_Poly->GetRelativeIndices( aCorner, &selectedCorner ) )
{
if( m_CornerSelection == nullptr )
m_CornerSelection = new SHAPE_POLY_SET::VERTEX_INDEX;
*m_CornerSelection = selectedCorner;
}
else
throw( std::out_of_range( "aCorner-th vertex does not exist" ) );
}
/// ///
int GetLocalFlags() const { return m_localFlgs; } int GetLocalFlags() const { return m_localFlgs; }
void SetLocalFlags( int aFlags ) { m_localFlgs = aFlags; } void SetLocalFlags( int aFlags ) { m_localFlgs = aFlags; }
@ -385,7 +340,7 @@ public:
// @copydoc BOARD_ITEM::GetEffectiveShape // @copydoc BOARD_ITEM::GetEffectiveShape
virtual std::shared_ptr<SHAPE> virtual std::shared_ptr<SHAPE>
GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER, GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
FLASHING aFlash = FLASHING::DEFAULT ) const override; FLASHING aFlash = FLASHING::DEFAULT ) const override;
/** /**
* Test if a point is near an outline edge or a corner of this zone. * Test if a point is near an outline edge or a corner of this zone.
@ -607,26 +562,6 @@ public:
return m_Poly->CVertex( index ); return m_Poly->CVertex( index );
} }
void SetCornerPosition( int aCornerIndex, const VECTOR2I& new_pos )
{
SHAPE_POLY_SET::VERTEX_INDEX relativeIndices;
// Convert global to relative indices
if( m_Poly->GetRelativeIndices( aCornerIndex, &relativeIndices ) )
{
if( m_Poly->CVertex( relativeIndices ).x != new_pos.x
|| m_Poly->CVertex( relativeIndices ).y != new_pos.y )
{
SetNeedRefill( true );
m_Poly->SetVertex( relativeIndices, new_pos );
}
}
else
{
throw( std::out_of_range( "aCornerIndex-th vertex does not exist" ) );
}
}
/** /**
* Create a new hole on the zone; i.e., a new contour on the zone's outline. * Create a new hole on the zone; i.e., a new contour on the zone's outline.
*/ */
@ -763,18 +698,17 @@ public:
*/ */
bool GetIsRuleArea() const { return m_isRuleArea; } bool GetIsRuleArea() const { return m_isRuleArea; }
void SetIsRuleArea( bool aEnable ) { m_isRuleArea = aEnable; } void SetIsRuleArea( bool aEnable ) { m_isRuleArea = aEnable; }
bool GetRuleAreaPlacementEnabled() const { return m_ruleAreaPlacementEnabled ; } bool GetPlacementAreaEnabled() const { return m_placementAreaEnabled; }
void SetRuleAreaPlacementEnabled( bool aEnabled ) { m_ruleAreaPlacementEnabled = aEnabled; } void SetPlacementAreaEnabled( bool aEnabled ) { m_placementAreaEnabled = aEnabled; }
wxString GetRuleAreaPlacementSource() const { return m_ruleAreaPlacementSource; } wxString GetPlacementAreaSource() const { return m_placementAreaSource; }
void SetRuleAreaPlacementSource( const wxString& aSource ) { m_ruleAreaPlacementSource = aSource; } void SetPlacementAreaSource( const wxString& aSource ) { m_placementAreaSource = aSource; }
RULE_AREA_PLACEMENT_SOURCE_TYPE GetRuleAreaPlacementSourceType() const PLACEMENT_SOURCE_T GetPlacementAreaSourceType() const
{ {
return m_ruleAreaPlacementSourceType; return m_placementAreaSourceType;
} }
void SetRuleAreaPlacementSourceType( RULE_AREA_PLACEMENT_SOURCE_TYPE aType ) void SetPlacementAreaSourceType( PLACEMENT_SOURCE_T aType )
{ { m_placementAreaSourceType = aType;
m_ruleAreaPlacementSourceType = aType;
} }
bool GetDoNotAllowZoneFills() const { return m_doNotAllowZoneFills; } bool GetDoNotAllowZoneFills() const { return m_doNotAllowZoneFills; }
@ -802,7 +736,8 @@ public:
/** /**
* @return the zone hatch pitch in iu. * @return the zone hatch pitch in iu.
*/ */
int GetBorderHatchPitch() const; int GetBorderHatchPitch() const { return m_borderHatchPitch; }
void SetBorderHatchPitch( int aPitch ) { m_borderHatchPitch = aPitch; }
/** /**
* @return the default hatch pitch in internal units. * @return the default hatch pitch in internal units.
@ -821,13 +756,6 @@ public:
void SetBorderDisplayStyle( ZONE_BORDER_DISPLAY_STYLE aBorderHatchStyle, int aBorderHatchPitch, void SetBorderDisplayStyle( ZONE_BORDER_DISPLAY_STYLE aBorderHatchStyle, int aBorderHatchPitch,
bool aRebuilBorderdHatch ); bool aRebuilBorderdHatch );
/**
* Set the hatch pitch parameter for the zone.
*
* @param aPitch is the hatch pitch in iu.
*/
void SetBorderHatchPitch( int aPitch );
/** /**
* Clear the zone's hatch. * Clear the zone's hatch.
*/ */
@ -837,7 +765,7 @@ public:
* Compute the hatch lines depending on the hatch parameters and stores it in the zone's * Compute the hatch lines depending on the hatch parameters and stores it in the zone's
* attribute m_borderHatchLines. * attribute m_borderHatchLines.
*/ */
void HatchBorder(); void HatchBorder();
const std::vector<SEG>& GetHatchLines() const { return m_borderHatchLines; } const std::vector<SEG>& GetHatchLines() const { return m_borderHatchLines; }
@ -897,15 +825,15 @@ protected:
/** /**
* Placement rule area data * Placement rule area data
*/ */
bool m_ruleAreaPlacementEnabled; bool m_placementAreaEnabled;
RULE_AREA_PLACEMENT_SOURCE_TYPE m_ruleAreaPlacementSourceType; PLACEMENT_SOURCE_T m_placementAreaSourceType;
wxString m_ruleAreaPlacementSource; wxString m_placementAreaSource;
/* A zone outline can be a teardrop zone with different rules for priority /* A zone outline can be a teardrop zone with different rules for priority
* (always bigger priority than copper zones) and never removed from a * (always bigger priority than copper zones) and never removed from a
* copper zone having the same netcode * copper zone having the same netcode
*/ */
TEARDROP_TYPE m_teardropType; TEARDROP_TYPE m_teardropType;
/* For keepout zones only: /* For keepout zones only:
* what is not allowed inside the keepout ( pads, tracks and vias ) * what is not allowed inside the keepout ( pads, tracks and vias )
@ -927,10 +855,10 @@ protected:
* When island removal mode is set to AREA, islands below this area will be removed. * When island removal mode is set to AREA, islands below this area will be removed.
* If this value is negative, all islands will be removed. * If this value is negative, all islands will be removed.
*/ */
long long int m_minIslandArea; long long int m_minIslandArea;
/** True when a zone was filled, false after deleting the filled areas. */ /** True when a zone was filled, false after deleting the filled areas. */
bool m_isFilled; bool m_isFilled;
/** /**
* False when a zone was refilled, true after changes in zone params. * False when a zone was refilled, true after changes in zone params.
@ -942,14 +870,7 @@ protected:
int m_thermalReliefGap; // Width of the gap in thermal reliefs. int m_thermalReliefGap; // Width of the gap in thermal reliefs.
int m_thermalReliefSpokeWidth; // Width of the copper bridge in thermal reliefs. int m_thermalReliefSpokeWidth; // Width of the copper bridge in thermal reliefs.
ZONE_FILL_MODE m_fillMode; // fill with POLYGONS vs HATCH_PATTERN
/**
* How to fill areas:
*
* ZONE_FILL_MODE::POLYGONS => use solid polygons
* ZONE_FILL_MODE::HATCH_PATTERN => use a grid pattern as shape
*/
ZONE_FILL_MODE m_fillMode;
int m_hatchThickness; // thickness of lines (if 0 -> solid shape) int m_hatchThickness; // thickness of lines (if 0 -> solid shape)
int m_hatchGap; // gap between lines (0 -> solid shape int m_hatchGap; // gap between lines (0 -> solid shape
EDA_ANGLE m_hatchOrientation; // orientation of grid lines EDA_ANGLE m_hatchOrientation; // orientation of grid lines
@ -961,10 +882,6 @@ protected:
double m_hatchHoleMinArea; // min size before holes are dropped (ratio) double m_hatchHoleMinArea; // min size before holes are dropped (ratio)
int m_hatchBorderAlgorithm; // 0 = use min zone thickness int m_hatchBorderAlgorithm; // 0 = use min zone thickness
// 1 = use hatch thickness // 1 = use hatch thickness
/// The index of the corner being moved or nullptr if no corner is selected.
SHAPE_POLY_SET::VERTEX_INDEX* m_CornerSelection;
int m_localFlgs; // Variable used in polygon calculations. int m_localFlgs; // Variable used in polygon calculations.
/* set of filled polygons used to draw a zone as a filled area. /* set of filled polygons used to draw a zone as a filled area.
@ -994,7 +911,7 @@ protected:
double m_outlinearea; // The outline zone area double m_outlinearea; // The outline zone area
/// Lock used for multi-threaded filling on multi-layer zones /// Lock used for multi-threaded filling on multi-layer zones
std::mutex m_lock; std::mutex m_lock;
}; };
@ -1002,7 +919,7 @@ protected:
DECLARE_ENUM_TO_WXANY( ZONE_CONNECTION ) DECLARE_ENUM_TO_WXANY( ZONE_CONNECTION )
DECLARE_ENUM_TO_WXANY( ZONE_FILL_MODE ) DECLARE_ENUM_TO_WXANY( ZONE_FILL_MODE )
DECLARE_ENUM_TO_WXANY( ISLAND_REMOVAL_MODE ) DECLARE_ENUM_TO_WXANY( ISLAND_REMOVAL_MODE )
DECLARE_ENUM_TO_WXANY( RULE_AREA_PLACEMENT_SOURCE_TYPE ) DECLARE_ENUM_TO_WXANY( PLACEMENT_SOURCE_T )
#endif #endif
#endif // ZONE_H #endif // ZONE_H

View File

@ -81,7 +81,7 @@ ZONE_SETTINGS::ZONE_SETTINGS()
m_minIslandArea = 10 * pcbIUScale.IU_PER_MM * pcbIUScale.IU_PER_MM; m_minIslandArea = 10 * pcbIUScale.IU_PER_MM * pcbIUScale.IU_PER_MM;
SetIsRuleArea( false ); SetIsRuleArea( false );
SetRuleAreaPlacementSourceType( RULE_AREA_PLACEMENT_SOURCE_TYPE::SHEETNAME ); SetPlacementAreaSourceType( PLACEMENT_SOURCE_T::SHEETNAME );
SetDoNotAllowZoneFills( false ); SetDoNotAllowZoneFills( false );
SetDoNotAllowVias( true ); SetDoNotAllowVias( true );
SetDoNotAllowTracks( true ); SetDoNotAllowTracks( true );
@ -89,7 +89,7 @@ ZONE_SETTINGS::ZONE_SETTINGS()
SetDoNotAllowFootprints( false ); SetDoNotAllowFootprints( false );
m_TeardropType = TEARDROP_TYPE::TD_NONE; m_TeardropType = TEARDROP_TYPE::TD_NONE;
m_ruleAreaPlacementEnabled = false; m_placementAreaEnabled = false;
} }
@ -116,9 +116,9 @@ bool ZONE_SETTINGS::operator==( const ZONE_SETTINGS& aOther ) const
if( m_cornerSmoothingType != aOther.m_cornerSmoothingType ) return false; if( m_cornerSmoothingType != aOther.m_cornerSmoothingType ) return false;
if( m_cornerRadius != aOther.m_cornerRadius ) return false; if( m_cornerRadius != aOther.m_cornerRadius ) return false;
if( m_isRuleArea != aOther.m_isRuleArea ) return false; if( m_isRuleArea != aOther.m_isRuleArea ) return false;
if( m_ruleAreaPlacementEnabled != aOther.m_ruleAreaPlacementEnabled ) return false; if( m_placementAreaEnabled != aOther.m_placementAreaEnabled ) return false;
if( m_ruleAreaPlacementSourceType != aOther.m_ruleAreaPlacementSourceType ) return false; if( m_placementAreaSourceType != aOther.m_placementAreaSourceType ) return false;
if( m_ruleAreaPlacementSource != aOther.m_ruleAreaPlacementSource ) return false; if( m_placementAreaSource != aOther.m_placementAreaSource ) return false;
if( m_keepoutDoNotAllowZoneFills != aOther.m_keepoutDoNotAllowZoneFills ) return false; if( m_keepoutDoNotAllowZoneFills != aOther.m_keepoutDoNotAllowZoneFills ) return false;
if( m_keepoutDoNotAllowVias != aOther.m_keepoutDoNotAllowVias ) return false; if( m_keepoutDoNotAllowVias != aOther.m_keepoutDoNotAllowVias ) return false;
if( m_keepoutDoNotAllowTracks != aOther.m_keepoutDoNotAllowTracks ) return false; if( m_keepoutDoNotAllowTracks != aOther.m_keepoutDoNotAllowTracks ) return false;
@ -166,9 +166,9 @@ ZONE_SETTINGS& ZONE_SETTINGS::operator << ( const ZONE& aSource )
m_cornerSmoothingType = aSource.GetCornerSmoothingType(); m_cornerSmoothingType = aSource.GetCornerSmoothingType();
m_cornerRadius = aSource.GetCornerRadius(); m_cornerRadius = aSource.GetCornerRadius();
m_isRuleArea = aSource.GetIsRuleArea(); m_isRuleArea = aSource.GetIsRuleArea();
m_ruleAreaPlacementEnabled = aSource.GetRuleAreaPlacementEnabled(); m_placementAreaEnabled = aSource.GetPlacementAreaEnabled();
m_ruleAreaPlacementSourceType = aSource.GetRuleAreaPlacementSourceType(); m_placementAreaSourceType = aSource.GetPlacementAreaSourceType();
m_ruleAreaPlacementSource = aSource.GetRuleAreaPlacementSource(); m_placementAreaSource = aSource.GetPlacementAreaSource();
m_keepoutDoNotAllowZoneFills = aSource.GetDoNotAllowZoneFills(); m_keepoutDoNotAllowZoneFills = aSource.GetDoNotAllowZoneFills();
m_keepoutDoNotAllowVias = aSource.GetDoNotAllowVias(); m_keepoutDoNotAllowVias = aSource.GetDoNotAllowVias();
m_keepoutDoNotAllowTracks = aSource.GetDoNotAllowTracks(); m_keepoutDoNotAllowTracks = aSource.GetDoNotAllowTracks();
@ -212,9 +212,9 @@ void ZONE_SETTINGS::ExportSetting( ZONE& aTarget, bool aFullExport ) const
aTarget.SetCornerSmoothingType( m_cornerSmoothingType ); aTarget.SetCornerSmoothingType( m_cornerSmoothingType );
aTarget.SetCornerRadius( m_cornerRadius ); aTarget.SetCornerRadius( m_cornerRadius );
aTarget.SetIsRuleArea( GetIsRuleArea() ); aTarget.SetIsRuleArea( GetIsRuleArea() );
aTarget.SetRuleAreaPlacementEnabled( GetRuleAreaPlacementEnabled() ); aTarget.SetPlacementAreaEnabled( GetPlacementAreaEnabled() );
aTarget.SetRuleAreaPlacementSourceType( GetRuleAreaPlacementSourceType() ); aTarget.SetPlacementAreaSourceType( GetPlacementAreaSourceType() );
aTarget.SetRuleAreaPlacementSource( GetRuleAreaPlacementSource() ); aTarget.SetPlacementAreaSource( GetPlacementAreaSource() );
aTarget.SetDoNotAllowZoneFills( GetDoNotAllowZoneFills() ); aTarget.SetDoNotAllowZoneFills( GetDoNotAllowZoneFills() );
aTarget.SetDoNotAllowVias( GetDoNotAllowVias() ); aTarget.SetDoNotAllowVias( GetDoNotAllowVias() );
aTarget.SetDoNotAllowTracks( GetDoNotAllowTracks() ); aTarget.SetDoNotAllowTracks( GetDoNotAllowTracks() );
@ -273,9 +273,9 @@ void ZONE_SETTINGS::CopyFrom( const ZONE_SETTINGS& aOther, bool aCopyFull )
m_cornerSmoothingType = aOther.m_cornerSmoothingType; m_cornerSmoothingType = aOther.m_cornerSmoothingType;
m_cornerRadius = aOther.m_cornerRadius; m_cornerRadius = aOther.m_cornerRadius;
m_isRuleArea = aOther.m_isRuleArea; m_isRuleArea = aOther.m_isRuleArea;
m_ruleAreaPlacementEnabled = aOther.m_ruleAreaPlacementEnabled; m_placementAreaEnabled = aOther.m_placementAreaEnabled;
m_ruleAreaPlacementSourceType = aOther.m_ruleAreaPlacementSourceType; m_placementAreaSourceType = aOther.m_placementAreaSourceType;
m_ruleAreaPlacementSource = aOther.m_ruleAreaPlacementSource; m_placementAreaSource = aOther.m_placementAreaSource;
m_keepoutDoNotAllowZoneFills = aOther.m_keepoutDoNotAllowZoneFills; m_keepoutDoNotAllowZoneFills = aOther.m_keepoutDoNotAllowZoneFills;
m_keepoutDoNotAllowVias = aOther.m_keepoutDoNotAllowVias; m_keepoutDoNotAllowVias = aOther.m_keepoutDoNotAllowVias;
m_keepoutDoNotAllowTracks = aOther.m_keepoutDoNotAllowTracks; m_keepoutDoNotAllowTracks = aOther.m_keepoutDoNotAllowTracks;

View File

@ -71,7 +71,7 @@ enum class ISLAND_REMOVAL_MODE
AREA AREA
}; };
enum class RULE_AREA_PLACEMENT_SOURCE_TYPE enum class PLACEMENT_SOURCE_T
{ {
SHEETNAME = 0, SHEETNAME = 0,
COMPONENT_CLASS, COMPONENT_CLASS,
@ -146,9 +146,9 @@ private:
/** /**
* Placement rule area data * Placement rule area data
*/ */
bool m_ruleAreaPlacementEnabled; bool m_placementAreaEnabled;
RULE_AREA_PLACEMENT_SOURCE_TYPE m_ruleAreaPlacementSourceType; PLACEMENT_SOURCE_T m_placementAreaSourceType;
wxString m_ruleAreaPlacementSource; wxString m_placementAreaSource;
bool m_keepoutDoNotAllowZoneFills; bool m_keepoutDoNotAllowZoneFills;
bool m_keepoutDoNotAllowVias; bool m_keepoutDoNotAllowVias;
@ -233,39 +233,30 @@ public:
/** /**
* Accessors to parameters used in Rule Area zones: * Accessors to parameters used in Rule Area zones:
*/ */
bool GetIsRuleArea() const { return m_isRuleArea; } bool GetPlacementAreaEnabled() const { return m_placementAreaEnabled; }
bool GetRuleAreaPlacementEnabled() const { return m_ruleAreaPlacementEnabled; } PLACEMENT_SOURCE_T GetPlacementAreaSourceType() const { return m_placementAreaSourceType; }
RULE_AREA_PLACEMENT_SOURCE_TYPE GetRuleAreaPlacementSourceType() const wxString GetPlacementAreaSource() const { return m_placementAreaSource; }
{ bool GetIsRuleArea() const { return m_isRuleArea; }
return m_ruleAreaPlacementSourceType;
}
wxString GetRuleAreaPlacementSource() const { return m_ruleAreaPlacementSource; }
bool GetDoNotAllowZoneFills() const { return m_keepoutDoNotAllowZoneFills; } bool GetDoNotAllowZoneFills() const { return m_keepoutDoNotAllowZoneFills; }
bool GetDoNotAllowVias() const { return m_keepoutDoNotAllowVias; } bool GetDoNotAllowVias() const { return m_keepoutDoNotAllowVias; }
bool GetDoNotAllowTracks() const { return m_keepoutDoNotAllowTracks; } bool GetDoNotAllowTracks() const { return m_keepoutDoNotAllowTracks; }
bool GetDoNotAllowPads() const { return m_keepoutDoNotAllowPads; } bool GetDoNotAllowPads() const { return m_keepoutDoNotAllowPads; }
bool GetDoNotAllowFootprints() const { return m_keepoutDoNotAllowFootprints; } bool GetDoNotAllowFootprints() const { return m_keepoutDoNotAllowFootprints; }
void SetIsRuleArea( bool aEnable ) { m_isRuleArea = aEnable; } void SetPlacementAreaEnabled( bool aEnabled ) { m_placementAreaEnabled = aEnabled; }
void SetRuleAreaPlacementEnabled( bool aEnabled ) { m_ruleAreaPlacementEnabled = aEnabled; } void SetPlacementAreaSourceType( PLACEMENT_SOURCE_T aType ) { m_placementAreaSourceType = aType; }
void SetRuleAreaPlacementSourceType( RULE_AREA_PLACEMENT_SOURCE_TYPE aType ) void SetPlacementAreaSource( const wxString& aSource ) { m_placementAreaSource = aSource; }
{ void SetIsRuleArea( bool aEnable ) { m_isRuleArea = aEnable; }
m_ruleAreaPlacementSourceType = aType;
}
void SetRuleAreaPlacementSource( const wxString& aSource )
{
m_ruleAreaPlacementSource = aSource;
}
void SetDoNotAllowZoneFills( bool aEnable ) { m_keepoutDoNotAllowZoneFills = aEnable; } void SetDoNotAllowZoneFills( bool aEnable ) { m_keepoutDoNotAllowZoneFills = aEnable; }
void SetDoNotAllowVias( bool aEnable ) { m_keepoutDoNotAllowVias = aEnable; } void SetDoNotAllowVias( bool aEnable ) { m_keepoutDoNotAllowVias = aEnable; }
void SetDoNotAllowTracks( bool aEnable ) { m_keepoutDoNotAllowTracks = aEnable; } void SetDoNotAllowTracks( bool aEnable ) { m_keepoutDoNotAllowTracks = aEnable; }
void SetDoNotAllowPads( bool aEnable ) { m_keepoutDoNotAllowPads = aEnable; } void SetDoNotAllowPads( bool aEnable ) { m_keepoutDoNotAllowPads = aEnable; }
void SetDoNotAllowFootprints( bool aEnable ) { m_keepoutDoNotAllowFootprints = aEnable; } void SetDoNotAllowFootprints( bool aEnable ) { m_keepoutDoNotAllowFootprints = aEnable; }
ISLAND_REMOVAL_MODE GetIslandRemovalMode() const { return m_removeIslands; } ISLAND_REMOVAL_MODE GetIslandRemovalMode() const { return m_removeIslands; }
void SetIslandRemovalMode( ISLAND_REMOVAL_MODE aRemove ) { m_removeIslands = aRemove; } void SetIslandRemovalMode( ISLAND_REMOVAL_MODE aRemove ) { m_removeIslands = aRemove; }
long long int GetMinIslandArea() const { return m_minIslandArea; } long long int GetMinIslandArea() const { return m_minIslandArea; }
void SetMinIslandArea( long long int aArea ) { m_minIslandArea = aArea; } void SetMinIslandArea( long long int aArea ) { m_minIslandArea = aArea; }
}; };

View File

@ -82,13 +82,13 @@ bool ZONE::IsSame( const ZONE& aZoneToCompare )
if( GetDoNotAllowFootprints() != aZoneToCompare.GetDoNotAllowFootprints() ) if( GetDoNotAllowFootprints() != aZoneToCompare.GetDoNotAllowFootprints() )
return false; return false;
if( GetRuleAreaPlacementEnabled() != aZoneToCompare.GetRuleAreaPlacementEnabled() ) if( GetPlacementAreaEnabled() != aZoneToCompare.GetPlacementAreaEnabled() )
return false; return false;
if( GetRuleAreaPlacementSourceType() != aZoneToCompare.GetRuleAreaPlacementSourceType() ) if( GetPlacementAreaSourceType() != aZoneToCompare.GetPlacementAreaSourceType() )
return false; return false;
if( GetRuleAreaPlacementSource() != aZoneToCompare.GetRuleAreaPlacementSource() ) if( GetPlacementAreaSource() != aZoneToCompare.GetPlacementAreaSource() )
return false; return false;
if( m_ZoneClearance != aZoneToCompare.m_ZoneClearance ) if( m_ZoneClearance != aZoneToCompare.m_ZoneClearance )

View File

@ -209,7 +209,7 @@ BOOST_AUTO_TEST_CASE( ZoneBorderStyle )
BOOST_AUTO_TEST_CASE( PlacementRuleSourceType ) BOOST_AUTO_TEST_CASE( PlacementRuleSourceType )
{ {
testEnums<RULE_AREA_PLACEMENT_SOURCE_TYPE, kiapi::board::types::PlacementRuleSourceType>(); testEnums<PLACEMENT_SOURCE_T, kiapi::board::types::PlacementRuleSourceType>();
} }
BOOST_AUTO_TEST_CASE( TeardropType ) BOOST_AUTO_TEST_CASE( TeardropType )