From c5725437c65d2a0eccf22bc475503aa5a042d7d9 Mon Sep 17 00:00:00 2001 From: charras Date: Sat, 24 Jan 2009 19:30:39 +0000 Subject: [PATCH] Zones not attached to a net are now allowed. Not sure it is a good idea, but a lot of users want this. --- pcbnew/dialog_copper_zones.cpp | 67 ++++++++++++------- pcbnew/drc.cpp | 7 +- pcbnew/zones_by_polygon.cpp | 19 +++--- .../zones_convert_brd_items_to_polygons.cpp | 30 +-------- pcbnew/zones_test_and_combine_areas.cpp | 4 +- 5 files changed, 63 insertions(+), 64 deletions(-) diff --git a/pcbnew/dialog_copper_zones.cpp b/pcbnew/dialog_copper_zones.cpp index c19fb35ba6..108705f808 100644 --- a/pcbnew/dialog_copper_zones.cpp +++ b/pcbnew/dialog_copper_zones.cpp @@ -69,18 +69,18 @@ void dialog_copper_zone::OnInitDialog( wxInitDialogEvent& event ) if( g_Zone_45_Only ) m_OrientEdgesOpt->SetSelection( 1 ); - m_FillModeCtrl->SetSelection(m_Zone_Setting->m_FillMode ? 1 : 0); + m_FillModeCtrl->SetSelection( m_Zone_Setting->m_FillMode ? 1 : 0 ); AddUnitSymbol( *m_ClearanceValueTitle, g_UnitMetric ); msg = ReturnStringFromValue( g_UnitMetric, - m_Zone_Setting->m_ZoneClearance, - m_Parent->m_InternalUnits ); + m_Zone_Setting->m_ZoneClearance, + m_Parent->m_InternalUnits ); m_ZoneClearanceCtrl->SetValue( msg ); AddUnitSymbol( *m_MinThicknessValueTitle, g_UnitMetric ); msg = ReturnStringFromValue( g_UnitMetric, - m_Zone_Setting->m_ZoneMinThickness, - m_Parent->m_InternalUnits ); + m_Zone_Setting->m_ZoneMinThickness, + m_Parent->m_InternalUnits ); m_ZoneMinThicknessCtrl->SetValue( msg ); switch( m_Zone_Setting->m_Zone_Pad_Options ) @@ -113,11 +113,11 @@ void dialog_copper_zone::OnInitDialog( wxInitDialogEvent& event ) AddUnitSymbol( *m_AntipadSizeText, g_UnitMetric ); AddUnitSymbol( *m_CopperBridgeWidthText, g_UnitMetric ); PutValueInLocalUnits( *m_AntipadSizeValue, - m_Zone_Setting->m_ThermalReliefGapValue, - PCB_INTERNAL_UNIT ); + m_Zone_Setting->m_ThermalReliefGapValue, + PCB_INTERNAL_UNIT ); PutValueInLocalUnits( *m_CopperWidthValue, - m_Zone_Setting->m_ThermalReliefCopperBridgeValue, - PCB_INTERNAL_UNIT ); + m_Zone_Setting->m_ThermalReliefCopperBridgeValue, + PCB_INTERNAL_UNIT ); switch( m_Zone_Setting->m_Zone_HatchingStyle ) { @@ -158,17 +158,20 @@ void dialog_copper_zone::OnInitDialog( wxInitDialogEvent& event ) m_NetSortingOption->SetSelection( m_NetSorting ); - wxString NetNameFilter = wxT( "N_0*" ); + wxString NetNameFilter = wxT( "N_0*" ); if( m_Config ) { NetNameFilter = m_Config->Read( ZONE_NET_FILTER_STRING_KEY ); } + // Build list of nets: m_NetNameFilter->SetValue( NetNameFilter ); wxArrayString ListNetName; - m_Parent->GetBoard()->ReturnSortedNetnamesList( ListNetName, - m_NetSorting == 0 ? BOARD::ALPHA_SORT : BOARD::PAD_CNT_SORT ); + m_Parent->GetBoard()->ReturnSortedNetnamesList( + ListNetName, + m_NetSorting == + 0 ? BOARD::ALPHA_SORT : BOARD::PAD_CNT_SORT ); if( m_NetSorting != 0 ) { @@ -183,6 +186,7 @@ void dialog_copper_zone::OnInitDialog( wxInitDialogEvent& event ) } } + ListNetName.Insert( wxT( "" ), 0 ); m_ListNetNameSelection->InsertItems( ListNetName, 0 ); // Select net: @@ -265,7 +269,7 @@ bool dialog_copper_zone::AcceptOptions( bool aPromptForErrors, bool aUseExportab if( m_Config ) { m_Config->Write( ZONE_NET_OUTLINES_HATCH_OPTION_KEY, - (long) m_Zone_Setting->m_Zone_HatchingStyle ); + (long) m_Zone_Setting->m_Zone_HatchingStyle ); wxString Filter = m_NetNameFilter->GetValue(); m_Config->Write( ZONE_NET_FILTER_STRING_KEY, Filter ); } @@ -279,10 +283,11 @@ bool dialog_copper_zone::AcceptOptions( bool aPromptForErrors, bool aUseExportab txtvalue = m_ZoneMinThicknessCtrl->GetValue(); m_Zone_Setting->m_ZoneMinThickness = ReturnValueFromString( g_UnitMetric, txtvalue, m_Parent->m_InternalUnits ); - if ( m_Zone_Setting->m_ZoneMinThickness < 10 ) + if( m_Zone_Setting->m_ZoneMinThickness < 10 ) { DisplayError( this, - _( "Error :\nyou must choose a copper min thickness value bigger than 0.001 inch or 0.0254 mm)" ) ); + _( + "Error :\nyou must choose a copper min thickness value bigger than 0.001 inch or 0.0254 mm)" ) ); return false; } @@ -292,20 +297,22 @@ bool dialog_copper_zone::AcceptOptions( bool aPromptForErrors, bool aUseExportab g_Zone_45_Only = TRUE; m_Zone_Setting->m_ThermalReliefGapValue = ReturnValueFromTextCtrl( *m_AntipadSizeValue, - PCB_INTERNAL_UNIT ); + PCB_INTERNAL_UNIT ); m_Zone_Setting->m_ThermalReliefCopperBridgeValue = ReturnValueFromTextCtrl( *m_CopperWidthValue, PCB_INTERNAL_UNIT ); m_Config->Write( ZONE_THERMAL_RELIEF_GAP_STRING_KEY, - (long) m_Zone_Setting->m_ThermalReliefGapValue ); + (long) m_Zone_Setting->m_ThermalReliefGapValue ); m_Config->Write( ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY, (long) m_Zone_Setting->m_ThermalReliefCopperBridgeValue ); if( m_Zone_Setting->m_ThermalReliefCopperBridgeValue <= m_Zone_Setting->m_ZoneMinThickness ) { - DisplayError( this, _( "Error :\nyou must choose a copper bridge value for thermal reliefs bigger than the min zone thickness" ) ); + DisplayError( this, + _( + "Error :\nyou must choose a copper bridge value for thermal reliefs bigger than the min zone thickness" ) ); return false; } @@ -333,17 +340,29 @@ bool dialog_copper_zone::AcceptOptions( bool aPromptForErrors, bool aUseExportab return false; } + if ( ii == 0 ) // the not connected option was selected: this is not a good practice: warn: + { + if( ! IsOK( this, _( + "You have chosen the \"not connected\" option. This will create insulated copper islands. Are you sure ?") ) + ) + return false; + } + wxString net_name = m_ListNetNameSelection->GetString( ii ); - /* Search net_code for this net */ - EQUIPOT* net; g_Zone_Default_Setting.m_NetcodeSelection = 0; - for( net = m_Parent->GetBoard()->m_Equipots; net; net = net->Next() ) + + /* Search net_code for this net, if a net was selected */ + if( m_ListNetNameSelection->GetSelection() > 0 ) { - if( net->GetNetname() == net_name ) + EQUIPOT* net; + for( net = m_Parent->GetBoard()->m_Equipots; net; net = net->Next() ) { - g_Zone_Default_Setting.m_NetcodeSelection = net->GetNet(); - break; + if( net->GetNetname() == net_name ) + { + g_Zone_Default_Setting.m_NetcodeSelection = net->GetNet(); + break; + } } } diff --git a/pcbnew/drc.cpp b/pcbnew/drc.cpp index b1f8514308..5c0d42beb8 100644 --- a/pcbnew/drc.cpp +++ b/pcbnew/drc.cpp @@ -314,18 +314,21 @@ void DRC::testUnconnected() } } - +/**********************************************/ void DRC::testZones(bool adoTestFillSegments) +/**********************************************/ { // Test copper areas for valide netcodes // if a netcode is < 0 the netname was not found when reading a netlist + // if a netcode is == 0 the netname is void, and the zone is not connected. + // This is allowed, but i am not sure this is a good idea for( int ii = 0; ii < m_pcb->GetAreaCount(); ii++ ) { ZONE_CONTAINER* Area_To_Test = m_pcb->GetArea( ii ); if( ! Area_To_Test->IsOnCopperLayer() ) continue; - if( Area_To_Test->GetNet() <= 0 ) + if( Area_To_Test->GetNet() < 0 ) { m_currentMarker = fillMarker( Area_To_Test, DRCE_NON_EXISTANT_NET_FOR_ZONE_OUTLINE, m_currentMarker ); diff --git a/pcbnew/zones_by_polygon.cpp b/pcbnew/zones_by_polygon.cpp index ed99200104..ee3f99c72b 100644 --- a/pcbnew/zones_by_polygon.cpp +++ b/pcbnew/zones_by_polygon.cpp @@ -971,15 +971,18 @@ int BOARD::SetAreasNetCodesFromNetNames( void ) continue; } - const EQUIPOT* net = FindNet( GetArea( ii )->m_Netname ); - if( net ) + if ( GetArea( ii )->GetNet() != 0 ) // i.e. if this zone is connected to a net { - GetArea( ii )->SetNet( net->GetNet() ); - } - else - { - error_count++; - GetArea( ii )->SetNet( -1 ); //keep Net Name ane set m_NetCode to -1 : error flag + const EQUIPOT* net = FindNet( GetArea( ii )->m_Netname ); + if( net ) + { + GetArea( ii )->SetNet( net->GetNet() ); + } + else + { + error_count++; + GetArea( ii )->SetNet( -1 ); //keep Net Name ane set m_NetCode to -1 : error flag + } } } diff --git a/pcbnew/zones_convert_brd_items_to_polygons.cpp b/pcbnew/zones_convert_brd_items_to_polygons.cpp index c3d44fa13d..ba0d3bb3ae 100644 --- a/pcbnew/zones_convert_brd_items_to_polygons.cpp +++ b/pcbnew/zones_convert_brd_items_to_polygons.cpp @@ -306,24 +306,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) #define REMOVE_UNUSED_THERMAL_STUBS // Can be commented to skip unused thermal stubs calculations #ifdef REMOVE_UNUSED_THERMAL_STUBS - /* First, Create the list of filled areas begin and end indexes. - * Because a zone creates more than one filled sub area, - * we must handle all start and end points of all sub areas - * for TestPointInsidePolygon, to search if a point is in a filled area in zone - */ - std::vector filled_areas_begin_end_index_list; - unsigned int indexstart = 0, indexend; - for( indexend = 0; indexend < m_FilledPolysList.size(); indexend++ ) - { - if( m_FilledPolysList[indexend].end_contour ) // end of a filled sub-area found - { - filled_areas_begin_end_index_list.push_back( indexstart ); - filled_areas_begin_end_index_list.push_back( indexend ); - indexstart = indexend + 1; - } - } - - /* Second, Add the main (corrected) polygon (i.e. the filled area using only one outline) + /* Add the main (corrected) polygon (i.e. the filled area using only one outline) * in GroupA in Bool_Engine to do a BOOL_A_SUB_B operation * All areas to remove will be put in GroupB in Bool_Engine */ @@ -385,16 +368,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) // translate point ptTest[i] += pad->ReturnShapePos(); - bool inside = false; - for( unsigned idx = 0; - idx < filled_areas_begin_end_index_list.size() && inside == false; - idx += 2 ) - { - indexstart = filled_areas_begin_end_index_list[idx]; - indexend = filled_areas_begin_end_index_list[idx + 1]; - inside = TestPointInsidePolygon( m_FilledPolysList, indexstart, - indexend, ptTest[i].x, ptTest[i].y ); - } + bool inside = HitTestFilledArea( ptTest[i] ); if( inside == false ) { diff --git a/pcbnew/zones_test_and_combine_areas.cpp b/pcbnew/zones_test_and_combine_areas.cpp index a252d7f35f..1d85deee88 100644 --- a/pcbnew/zones_test_and_combine_areas.cpp +++ b/pcbnew/zones_test_and_combine_areas.cpp @@ -825,7 +825,7 @@ int BOARD::Test_Drc_Areas_Outlines_To_Areas_Outlines( ZONE_CONTAINER* aArea_To_E continue; // Test for same net - if( Area_Ref->GetNet() == Area_To_Test->GetNet() && Area_Ref->GetNet() > 0 ) + if( Area_Ref->GetNet() == Area_To_Test->GetNet() && Area_Ref->GetNet() >= 0 ) continue; // test for some corners of Area_Ref inside Area_To_Test @@ -998,7 +998,7 @@ bool DRC::doEdgeZoneDrc( ZONE_CONTAINER* aArea, int aCornerIndex ) continue; // Test for same net - if( ( aArea->GetNet() == Area_To_Test->GetNet() ) && (aArea->GetNet() > 0) ) + if( ( aArea->GetNet() == Area_To_Test->GetNet() ) && (aArea->GetNet() >= 0) ) continue; // test for ending line inside Area_To_Test