kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #19757
Re: python - not handled enum ZoneConnection
In response to a message written on 13.08.2015, 20:55, from LordBlick:
Attached patch seems to fix:
- not finished python scripting issue - brings pad.GetZoneConnection() and in
example pad.SetZoneConnection(pcbnew.PAD_ZONE_CONN_FULL) to full workable.
- cleanup namespace pretty artistic disorder in enum ZoneConnection in
pcbnew/zones.h to self-explained names unification:
PAD_ZONE_CONN_UNDEFINED = -1
PAD_ZONE_CONN_NONE
PAD_ZONE_CONN_THERMAL
PAD_ZONE_CONN_FULL
PAD_ZONE_CONN_THT_THERMAL
I think that in so huge projects as KiCAD all variable names should be prefixed
with its functionality to prevent any mistake.
Seems, that UNDEFINED is not correct, so INHERITED will be better.
Improved patch on BZR6091 in attachment.
--
Best Regards,
LordBlick
--- pcbnew/zones_convert_to_polygons_aux_functions.cpp.old 2015-08-13 18:07:55.1439482075
+++ pcbnew/zones_convert_to_polygons_aux_functions.cpp 2015-08-13 20:00:15.1439488815
@@ -111,12 +111,12 @@
for( D_PAD* pad = module->Pads(); pad != NULL; pad = pad->Next() )
{
// Rejects non-standard pads with tht-only thermal reliefs
- if( aZone->GetPadConnection( pad ) == THT_THERMAL
+ if( aZone->GetPadConnection( pad ) == PAD_ZONE_CONN_THT_THERMAL
&& pad->GetAttribute() != PAD_STANDARD )
continue;
- if( aZone->GetPadConnection( pad ) != THERMAL_PAD
- && aZone->GetPadConnection( pad ) != THT_THERMAL )
+ if( aZone->GetPadConnection( pad ) != PAD_ZONE_CONN_THERMAL
+ && aZone->GetPadConnection( pad ) != PAD_ZONE_CONN_THT_THERMAL )
continue;
// check
--- pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp.old 2015-08-13 18:07:55.1439482075
+++ pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp 2015-08-13 20:00:15.1439488815
@@ -192,7 +192,7 @@
continue;
}
- if( GetPadConnection( pad ) == PAD_NOT_IN_ZONE )
+ if( GetPadConnection( pad ) == PAD_ZONE_CONN_NONE )
{
int gap = zone_clearance;
int thermalGap = GetThermalReliefGap( pad );
@@ -336,12 +336,12 @@
for( D_PAD* pad = module->Pads(); pad != NULL; pad = pad->Next() )
{
// Rejects non-standard pads with tht-only thermal reliefs
- if( GetPadConnection( pad ) == THT_THERMAL
+ if( GetPadConnection( pad ) == PAD_ZONE_CONN_THT_THERMAL
&& pad->GetAttribute() != PAD_STANDARD )
continue;
- if( GetPadConnection( pad ) != THERMAL_PAD
- && GetPadConnection( pad ) != THT_THERMAL )
+ if( GetPadConnection( pad ) != PAD_ZONE_CONN_THERMAL
+ && GetPadConnection( pad ) != PAD_ZONE_CONN_THT_THERMAL )
continue;
if( !pad->IsOnLayer( GetLayer() ) )
--- pcbnew/zones.h.old 2015-08-13 18:07:55.1439482075
+++ pcbnew/zones.h 2015-08-13 20:00:15.1439488815
@@ -53,11 +53,11 @@
/// How pads are covered by copper in zone
enum ZoneConnection {
- UNDEFINED_CONNECTION = -1,
- PAD_NOT_IN_ZONE, ///< Pads are not covered
- THERMAL_PAD, ///< Use thermal relief for pads
- PAD_IN_ZONE, ///< pads are covered by copper
- THT_THERMAL ///< Thermal relief only for THT pads
+ PAD_ZONE_CONN_INHERITED = -1,
+ PAD_ZONE_CONN_NONE, ///< Pads are not covered
+ PAD_ZONE_CONN_THERMAL, ///< Use thermal relief for pads
+ PAD_ZONE_CONN_FULL, ///< pads are covered by copper
+ PAD_ZONE_CONN_THT_THERMAL ///< Thermal relief only for THT pads
};
class ZONE_CONTAINER;
--- pcbnew/pcb_parser.cpp.old 2015-08-13 18:07:55.1439482075
+++ pcbnew/pcb_parser.cpp 2015-08-13 20:00:15.1439488815
@@ -2619,15 +2619,15 @@
switch( token )
{
case T_yes:
- zone->SetPadConnection( PAD_IN_ZONE );
+ zone->SetPadConnection( PAD_ZONE_CONN_FULL );
break;
case T_no:
- zone->SetPadConnection( PAD_NOT_IN_ZONE );
+ zone->SetPadConnection( PAD_ZONE_CONN_NONE );
break;
case T_thru_hole_only:
- zone->SetPadConnection( THT_THERMAL );
+ zone->SetPadConnection( PAD_ZONE_CONN_THT_THERMAL );
break;
case T_clearance:
--- pcbnew/legacy_plugin.cpp.old 2015-08-13 18:07:55.1439482075
+++ pcbnew/legacy_plugin.cpp 2015-08-13 20:00:15.1439488815
@@ -2662,10 +2662,10 @@
ZoneConnection popt;
switch( *padoption )
{
- case 'I': popt = PAD_IN_ZONE; break;
- case 'T': popt = THERMAL_PAD; break;
- case 'H': popt = THT_THERMAL; break;
- case 'X': popt = PAD_NOT_IN_ZONE; break;
+ case 'I': popt = PAD_ZONE_CONN_FULL; break;
+ case 'T': popt = PAD_ZONE_CONN_THERMAL; break;
+ case 'H': popt = PAD_ZONE_CONN_THT_THERMAL; break;
+ case 'X': popt = PAD_ZONE_CONN_NONE; break;
default:
m_error.Printf( wxT( "Bad ZClearance padoption for CZONE_CONTAINER '%s'" ),
@@ -3762,7 +3762,7 @@
if( me->GetLocalClearance() != 0 )
fprintf( m_fp, ".LocalClearance %s\n", fmtBIU( me->GetLocalClearance( ) ).c_str() );
- if( me->GetZoneConnection() != UNDEFINED_CONNECTION )
+ if( me->GetZoneConnection() != PAD_ZONE_CONN_INHERITED )
fprintf( m_fp, ".ZoneConnection %d\n", me->GetZoneConnection() );
if( me->GetThermalWidth() != 0 )
@@ -3827,7 +3827,7 @@
if( me->GetLocalClearance() != 0 )
fprintf( m_fp, ".LocalClearance %s\n", fmtBIU( me->GetLocalClearance( ) ).c_str() );
- if( me->GetZoneConnection() != UNDEFINED_CONNECTION )
+ if( me->GetZoneConnection() != PAD_ZONE_CONN_INHERITED )
fprintf( m_fp, ".ZoneConnection %d\n", me->GetZoneConnection() );
if( me->GetThermalWidth() != 0 )
@@ -4003,10 +4003,10 @@
switch( me->GetPadConnection() )
{
default:
- case PAD_IN_ZONE: padoption = 'I'; break;
- case THERMAL_PAD: padoption = 'T'; break;
- case THT_THERMAL: padoption = 'H'; break; // H is for 'hole' since it reliefs holes only
- case PAD_NOT_IN_ZONE: padoption = 'X'; break;
+ case PAD_ZONE_CONN_FULL: padoption = 'I'; break;
+ case PAD_ZONE_CONN_THERMAL: padoption = 'T'; break;
+ case PAD_ZONE_CONN_THT_THERMAL: padoption = 'H'; break; // H is for 'hole' since it reliefs holes only
+ case PAD_ZONE_CONN_NONE: padoption = 'X'; break;
}
fprintf( m_fp, "ZClearance %s %c\n",
--- pcbnew/kicad_plugin.cpp.old 2015-08-13 18:07:55.1439482075
+++ pcbnew/kicad_plugin.cpp 2015-08-13 20:00:15.1439488815
@@ -1052,7 +1052,7 @@
m_out->Print( aNestLevel+1, "(clearance %s)\n",
FMT_IU( aModule->GetLocalClearance() ).c_str() );
- if( aModule->GetZoneConnection() != UNDEFINED_CONNECTION )
+ if( aModule->GetZoneConnection() != PAD_ZONE_CONN_INHERITED )
m_out->Print( aNestLevel+1, "(zone_connect %d)\n", aModule->GetZoneConnection() );
if( aModule->GetThermalWidth() != 0 )
@@ -1310,7 +1310,7 @@
if( aPad->GetLocalClearance() != 0 )
StrPrintf( &output, " (clearance %s)", FMT_IU( aPad->GetLocalClearance() ).c_str() );
- if( aPad->GetZoneConnection() != UNDEFINED_CONNECTION )
+ if( aPad->GetZoneConnection() != PAD_ZONE_CONN_INHERITED )
StrPrintf( &output, " (zone_connect %d)", aPad->GetZoneConnection() );
if( aPad->GetThermalWidth() != 0 )
@@ -1497,18 +1497,18 @@
switch( aZone->GetPadConnection() )
{
default:
- case THERMAL_PAD: // Default option not saved or loaded.
- break;
-
- case THT_THERMAL:
+ case PAD_ZONE_CONN_THERMAL: // Default option not saved or loaded.
+ break;
+
+ case PAD_ZONE_CONN_THT_THERMAL:
m_out->Print( 0, " thru_hole_only" );
break;
- case PAD_IN_ZONE:
+ case PAD_ZONE_CONN_FULL:
m_out->Print( 0, " yes" );
break;
- case PAD_NOT_IN_ZONE:
+ case PAD_ZONE_CONN_NONE:
m_out->Print( 0, " no" );
break;
}
--- pcbnew/eagle_plugin.cpp.old 2015-08-13 18:07:55.1439482075
+++ pcbnew/eagle_plugin.cpp 2015-08-13 20:00:15.1439488815
@@ -2611,7 +2611,7 @@
// missing == yes per DTD.
bool thermals = !p.thermals || *p.thermals;
- zone->SetPadConnection( thermals ? THERMAL_PAD : PAD_IN_ZONE );
+ zone->SetPadConnection( thermals ? PAD_ZONE_CONN_THERMAL : PAD_ZONE_CONN_FULL );
int rank = p.rank ? *p.rank : 0;
zone->SetPriority( rank );
--- pcbnew/class_zone_settings.cpp.old 2015-08-13 18:07:55.1439482075
+++ pcbnew/class_zone_settings.cpp 2015-08-13 20:00:15.1439488815
@@ -56,7 +56,7 @@
// thickness of the copper bridge in thermal reliefs:
m_ThermalReliefCopperBridge = Mils2iu( ZONE_THERMAL_RELIEF_COPPER_WIDTH_MIL );
- m_PadConnection = THERMAL_PAD; // How pads are covered by copper in zone
+ m_PadConnection = PAD_ZONE_CONN_THERMAL; // How pads are covered by copper in zone
m_Zone_45_Only = false;
--- pcbnew/class_zone.cpp.old 2015-08-13 18:07:55.1439482075
+++ pcbnew/class_zone.cpp 2015-08-13 20:00:15.1439488815
@@ -781,7 +781,7 @@
ZoneConnection ZONE_CONTAINER::GetPadConnection( D_PAD* aPad ) const
{
- if( aPad == NULL || aPad->GetZoneConnection() == UNDEFINED_CONNECTION )
+ if( aPad == NULL || aPad->GetZoneConnection() == PAD_ZONE_CONN_INHERITED )
return m_PadConnection;
else
return aPad->GetZoneConnection();
--- pcbnew/class_pad.cpp.old 2015-08-13 18:07:55.1439482075
+++ pcbnew/class_pad.cpp 2015-08-13 20:00:15.1439488815
@@ -74,7 +74,7 @@
m_LocalSolderMaskMargin = 0;
m_LocalSolderPasteMargin = 0;
m_LocalSolderPasteMarginRatio = 0.0;
- m_ZoneConnection = UNDEFINED_CONNECTION; // Use parent setting by default
+ m_ZoneConnection = PAD_ZONE_CONN_INHERITED; // Use parent setting by default
m_ThermalWidth = 0; // Use parent setting by default
m_ThermalGap = 0; // Use parent setting by default
@@ -585,7 +585,7 @@
{
MODULE* module = (MODULE*) GetParent();
- if( m_ZoneConnection == UNDEFINED_CONNECTION && module )
+ if( m_ZoneConnection == PAD_ZONE_CONN_INHERITED && module )
return module->GetZoneConnection();
else
return m_ZoneConnection;
--- pcbnew/class_module.cpp.old 2015-08-13 18:07:55.1439482075
+++ pcbnew/class_module.cpp 2015-08-13 20:00:15.1439488815
@@ -67,7 +67,7 @@
m_LocalSolderMaskMargin = 0;
m_LocalSolderPasteMargin = 0;
m_LocalSolderPasteMarginRatio = 0.0;
- m_ZoneConnection = UNDEFINED_CONNECTION; // Use zone setting by default
+ m_ZoneConnection = PAD_ZONE_CONN_INHERITED; // Use zone setting by default
m_ThermalWidth = 0; // Use zone setting by default
m_ThermalGap = 0; // Use zone setting by default
--- pcbnew/scripting/pcbnew.i.old 2015-08-13 18:07:55.1439482075
+++ pcbnew/scripting/pcbnew.i 2015-08-13 20:00:15.1439488815
@@ -89,6 +89,7 @@
#include <class_module.h>
#include <class_track.h>
#include <class_zone.h>
+ #include <zones.h>
#include <layers_id_colors_and_visibility.h>
#include <class_pad.h>
#include <pad_shapes.h>
@@ -127,6 +128,7 @@
%include <class_module.h>
%include <class_track.h>
%include <class_zone.h>
+%include <zones.h>
%include <layers_id_colors_and_visibility.h>
%include <class_pad.h>
%include <pad_shapes.h>
--- pcbnew/dialogs/dialog_pad_properties.cpp.old 2015-08-13 18:07:55.1439482075
+++ pcbnew/dialogs/dialog_pad_properties.cpp 2015-08-13 20:00:15.1439488815
@@ -433,19 +433,19 @@
switch( m_dummyPad->GetZoneConnection() )
{
default:
- case UNDEFINED_CONNECTION:
+ case PAD_ZONE_CONN_INHERITED:
m_ZoneConnectionChoice->SetSelection( 0 );
break;
- case PAD_IN_ZONE:
+ case PAD_ZONE_CONN_FULL:
m_ZoneConnectionChoice->SetSelection( 1 );
break;
- case THERMAL_PAD:
+ case PAD_ZONE_CONN_THERMAL:
m_ZoneConnectionChoice->SetSelection( 2 );
break;
- case PAD_NOT_IN_ZONE:
+ case PAD_ZONE_CONN_NONE:
m_ZoneConnectionChoice->SetSelection( 3 );
break;
}
@@ -996,19 +996,19 @@
{
default:
case 0:
- aPad->SetZoneConnection( UNDEFINED_CONNECTION );
+ aPad->SetZoneConnection( PAD_ZONE_CONN_INHERITED );
break;
case 1:
- aPad->SetZoneConnection( PAD_IN_ZONE );
+ aPad->SetZoneConnection( PAD_ZONE_CONN_FULL );
break;
case 2:
- aPad->SetZoneConnection( THERMAL_PAD );
+ aPad->SetZoneConnection( PAD_ZONE_CONN_THERMAL );
break;
case 3:
- aPad->SetZoneConnection( PAD_NOT_IN_ZONE );
+ aPad->SetZoneConnection( PAD_ZONE_CONN_NONE );
break;
}
--- pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp.old 2015-08-13 18:07:55.1439482075
+++ pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp 2015-08-13 20:00:16.1439488816
@@ -169,19 +169,19 @@
switch( m_CurrentModule->GetZoneConnection() )
{
default:
- case UNDEFINED_CONNECTION:
+ case PAD_ZONE_CONN_INHERITED:
m_ZoneConnectionChoice->SetSelection( 0 );
break;
- case PAD_IN_ZONE:
+ case PAD_ZONE_CONN_FULL:
m_ZoneConnectionChoice->SetSelection( 1 );
break;
- case THERMAL_PAD:
+ case PAD_ZONE_CONN_THERMAL:
m_ZoneConnectionChoice->SetSelection( 2 );
break;
- case PAD_NOT_IN_ZONE:
+ case PAD_ZONE_CONN_NONE:
m_ZoneConnectionChoice->SetSelection( 3 );
break;
}
@@ -581,19 +581,19 @@
{
default:
case 0:
- m_CurrentModule->SetZoneConnection( UNDEFINED_CONNECTION );
+ m_CurrentModule->SetZoneConnection( PAD_ZONE_CONN_INHERITED );
break;
case 1:
- m_CurrentModule->SetZoneConnection( PAD_IN_ZONE );
+ m_CurrentModule->SetZoneConnection( PAD_ZONE_CONN_FULL );
break;
case 2:
- m_CurrentModule->SetZoneConnection( THERMAL_PAD );
+ m_CurrentModule->SetZoneConnection( PAD_ZONE_CONN_THERMAL );
break;
case 3:
- m_CurrentModule->SetZoneConnection( PAD_NOT_IN_ZONE );
+ m_CurrentModule->SetZoneConnection( PAD_ZONE_CONN_NONE );
break;
}
--- pcbnew/dialogs/dialog_copper_zones.cpp.old 2015-08-13 18:07:55.1439482075
+++ pcbnew/dialogs/dialog_copper_zones.cpp 2015-08-13 20:00:16.1439488816
@@ -183,27 +183,27 @@
switch( m_settings.GetPadConnection() )
{
- case THT_THERMAL: // Thermals only for THT pads
+ case PAD_ZONE_CONN_THT_THERMAL: // Thermals only for THT pads
m_PadInZoneOpt->SetSelection( 2 );
break;
- case PAD_NOT_IN_ZONE: // Pads are not covered
+ case PAD_ZONE_CONN_NONE: // Pads are not covered
m_PadInZoneOpt->SetSelection( 3 );
break;
default:
- case THERMAL_PAD: // Use thermal relief for pads
+ case PAD_ZONE_CONN_THERMAL: // Use thermal relief for pads
m_PadInZoneOpt->SetSelection( 1 );
break;
- case PAD_IN_ZONE: // pads are covered by copper
+ case PAD_ZONE_CONN_FULL: // pads are covered by copper
m_PadInZoneOpt->SetSelection( 0 );
break;
}
// Antipad and spokes are significant only for thermals
- if( m_settings.GetPadConnection() != THERMAL_PAD &&
- m_settings.GetPadConnection() != THT_THERMAL )
+ if( m_settings.GetPadConnection() != PAD_ZONE_CONN_THERMAL &&
+ m_settings.GetPadConnection() != PAD_ZONE_CONN_THT_THERMAL )
{
m_AntipadSizeValue->Enable( false );
m_CopperWidthValue->Enable( false );
@@ -346,22 +346,22 @@
{
case 3:
// Pads are not covered
- m_settings.SetPadConnection( PAD_NOT_IN_ZONE );
+ m_settings.SetPadConnection( PAD_ZONE_CONN_NONE );
break;
case 2:
// Use thermal relief for THT pads
- m_settings.SetPadConnection( THT_THERMAL );
+ m_settings.SetPadConnection( PAD_ZONE_CONN_THT_THERMAL );
break;
case 1:
// Use thermal relief for pads
- m_settings.SetPadConnection( THERMAL_PAD );
+ m_settings.SetPadConnection( PAD_ZONE_CONN_THERMAL );
break;
case 0:
// pads are covered by copper
- m_settings.SetPadConnection( PAD_IN_ZONE );
+ m_settings.SetPadConnection( PAD_ZONE_CONN_FULL );
break;
}
References