code cleaning in zones functions

This commit is contained in:
charras 2008-10-23 10:26:06 +00:00
parent cbdf6a9009
commit ffca523980
26 changed files with 1710 additions and 1108 deletions

View File

@ -43,6 +43,7 @@ set(CVPCB_EXTRA_SRCS
../pcbnew/class_text_mod.cpp
../pcbnew/class_track.cpp
../pcbnew/class_zone.cpp
../pcbnew/class_zone_setting.cpp
../pcbnew/classpcb.cpp
../pcbnew/collectors.cpp
../pcbnew/ioascii.cpp

View File

@ -17,6 +17,7 @@ LIBVIEWER3D = ../3d-viewer/3d-viewer.a
OBJECTS = $(TARGET).o \
class_cvpcb.o\
class_zone.o\
class_zone_setting.o\
memoire.o \
cvframe.o\
listboxes.o\
@ -81,6 +82,9 @@ class_mire.o: ../pcbnew/class_mire.cpp ../pcbnew/class_mire.h $(COMMON)
class_zone.o: ../pcbnew/class_zone.cpp ../pcbnew/class_zone.h $(COMMON)
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp
class_zone_setting.o: ../pcbnew/class_zone_setting.cpp ../pcbnew/class_zone_setting.h $(COMMON)
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp
class_cotation.o: ../pcbnew/class_cotation.cpp ../pcbnew/class_cotation.h $(COMMON)
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp

View File

@ -419,8 +419,8 @@ void WinEDA_SchematicFrame::SetToolbars()
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_BUS_WIRES_ORIENT,
g_HVLines );
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_BUS_WIRES_ORIENT,
g_HVLines ? _( "Snap Grid (OFF)" ) :
_( "Snap Grid (ON)" ) );
g_HVLines ? _( "Allows any direction for wires and busses" ) :
_( "Allows horizontal and vertical wires and busses only" ) );
}
DisplayUnitsMsg();

View File

@ -48,6 +48,7 @@ set(GERBVIEW_EXTRA_SRCS
../pcbnew/class_pcb_text.cpp
../pcbnew/class_track.cpp
../pcbnew/class_zone.cpp
../pcbnew/class_zone_setting.cpp
../pcbnew/classpcb.cpp
../pcbnew/collectors.cpp
../pcbnew/sel_layer.cpp

View File

@ -13,6 +13,7 @@ OBJECTS= \
$(TARGET).o\
classpcb.o\
class_zone.o\
class_zone_setting.o\
select_layers_to_pcb.o\
sel_layer.o\
lay2plot.o\
@ -78,6 +79,9 @@ class_marker.o: ../pcbnew/class_marker.cpp ../pcbnew/class_marker.h $(COMMON)
class_zone.o: ../pcbnew/class_zone.cpp ../pcbnew/class_zone.h $(COMMON)
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp
class_zone_setting.o: ../pcbnew/class_zone_setting.cpp ../pcbnew/class_zone_setting.h $(COMMON)
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp
class_drawsegment.o: ../pcbnew/class_drawsegment.cpp ../pcbnew/class_drawsegment.h $(DEPEND)
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp

View File

@ -158,7 +158,6 @@ public:
int m_PcbTextWidth; // current Pcb (not module) Text width
wxSize m_PcbTextSize; // current Pcb (not module) Text size
int m_TrackClearence; // track to track and track to pads clearance
int m_ZoneClearence; // zone to track and zone to pads clearance
int m_MaskMargin; // Solder mask margin
// Color options for screen display of the Printed Board:

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -32,6 +32,7 @@ set(PCBNEW_SRCS
class_text_mod.cpp
class_track.cpp
class_zone.cpp
class_zone_setting.cpp
clean.cpp
# cleaningoptions_dialog.cpp
collectors.cpp

View File

@ -12,7 +12,6 @@
#include "pcbnew.h"
#include "trigo.h"
#include "zones.h"
#include "autorout.h"
/************************/
@ -25,16 +24,10 @@ ZONE_CONTAINER::ZONE_CONTAINER( BOARD* parent ) :
{
m_NetCode = -1; // Net number for fast comparisons
m_CornerSelection = -1;
m_ZoneClearance = g_DesignSettings.m_ZoneClearence; // a reasonnable clerance value
m_GridFillValue = g_GridRoutingSize; // a reasonnable grid used for filling
m_PadOption = g_Zone_Pad_Options;
utility = 0; // flags used in polygon calculations
utility2 = 0; // flags used in polygon calculations
m_Poly = new CPolyLine(); // Outlines
m_ArcToSegmentsCount = g_Zone_Arc_Approximation; // Use 16 or 32segment to convert a circle to a polygon
m_DrawOptions = 0;
m_ThermalReliefGapValue = g_ThermalReliefGapValue; // tickness of the gap in thermal reliefs
m_ThermalReliefCopperBridgeValue = g_ThermalReliefCopperBridgeValue; // tickness of the copper bridge in thermal reliefs
g_Zone_Default_Setting.ExportSetting(*this);
}
@ -941,3 +934,21 @@ void ZONE_CONTAINER::Copy( ZONE_CONTAINER* src )
m_PadOption = src->m_PadOption;
m_Poly->SetHatch( src->m_Poly->GetHatchStyle() );
}
/**
* Function SetNetNameFromNetCode
* Fin the nat name corresponding to the net code.
* @param aPcb: the curren board
* @return bool - true if net found, else false
*/
bool ZONE_CONTAINER::SetNetNameFromNetCode( void )
{
EQUIPOT* net;
if ( m_Parent && (net = ((BOARD*)m_Parent)->FindNet( GetNet()) ) )
{
m_Netname = net->m_Netname;
return true;
}
return false;
}

View File

@ -9,6 +9,7 @@
#include "PolyLine.h"
/************************/
/* class ZONE_CONTAINER */
/************************/
@ -21,19 +22,13 @@
class ZONE_CONTAINER : public BOARD_ITEM
{
public:
enum m_PadInZone { // How pads are covered by copper in zone
PAD_NOT_IN_ZONE, // Pads are not covered
THERMAL_PAD, // Use thermal relief for pads
PAD_IN_ZONE // pads are covered by copper
};
wxString m_Netname; // Net Name
CPolyLine* m_Poly; // outlines
int m_CornerSelection; // For corner moving, corner index to drag, or -1 if no selection
int m_ZoneClearance; // clearance value
int m_GridFillValue; // Grid used for filling, 0 = use polygonal areas to fill
int m_ArcToSegmentsCount; // number of segments to convert a cirlce to a polygon (uses 16 or 32)
m_PadInZone m_PadOption; // see m_PadInZone
int m_PadOption; //
int m_ThermalReliefGapValue; // tickness of the gap in thermal reliefs
int m_ThermalReliefCopperBridgeValue; // tickness of the copper bridge in thermal reliefs
int utility, utility2; // flags used in polygon calculations
@ -143,6 +138,13 @@ public:
void SetNet( int anet_code );
/**
* Function SetNetNameFromNetCode
* Fin the nat name corresponding to the net code.
* @return bool - true if net found, else false
*/
bool SetNetNameFromNetCode( void);
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
@ -286,6 +288,11 @@ public:
{
m_Poly->AppendCorner( position.x, position.y );
}
int GetHatchStyle() const
{
return m_Poly->GetHatchStyle();
}
};

View File

@ -0,0 +1,79 @@
/******************************************************/
/* class ZONE_SETTING used to handle zones parameters */
/******************************************************/
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
/* For compilers that support precompilation:
*/
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "fctsys.h"
#include "PolyLine.h"
#include "common.h"
#include "pcbnew.h"
#include "zones.h"
#include "class_zone.h"
ZONE_SETTING::ZONE_SETTING( void )
{
m_GridFillValue = 250; // Grid value for filling zone by segments, 0 to used polygons to fill
m_ZoneClearance = 200; // Clearance value
m_NetcodeSelection = 0; // Net code selection for the current zone
m_CurrentZone_Layer = 0; // Layer used to create the current zone
m_Zone_HatchingStyle = CPolyLine::DIAGONAL_EDGE; // Option to show the zone area (outlines only, short hatches or full hatches
m_ArcToSegmentsCount = 16; /* Option to select number of segments to approximate a circle
* 16 or 32 segments */
m_FilledAreasShowMode = 0; // Used to select draw options for filled areas in a zone (currently normal =0, sketch = 1)
m_ThermalReliefGapValue = 200; // tickness of the gap in thermal reliefs
m_ThermalReliefCopperBridgeValue = 200; // tickness of the copper bridge in thermal reliefs
m_Zone_Pad_Options = THERMAL_PAD; // How pads are covered by copper in zone
}
/** function ImportSetting
* copy settings from a given zone
* @param aSource: the given zone
*/
void ZONE_SETTING::ImportSetting( const ZONE_CONTAINER& aSource )
{
m_GridFillValue = aSource.m_GridFillValue;
m_ZoneClearance = aSource.m_ZoneClearance;
m_NetcodeSelection = aSource.GetNet();
m_CurrentZone_Layer = aSource.GetLayer();
m_Zone_HatchingStyle = aSource.GetHatchStyle();
m_ArcToSegmentsCount = aSource.m_ArcToSegmentsCount;
m_FilledAreasShowMode = aSource.m_DrawOptions;
m_ThermalReliefGapValue = aSource.m_ThermalReliefGapValue;
m_ThermalReliefCopperBridgeValue = aSource.m_ThermalReliefCopperBridgeValue;
m_Zone_Pad_Options = aSource.m_PadOption;
}
/** function ExportSetting
* copy settings to a given zone
* @param aTarget: the given zone
* Note: parameters NOT exported (because they cannot be safely exported):
* m_NetcodeSelection
*/
void ZONE_SETTING::ExportSetting( ZONE_CONTAINER& aTarget )
{
aTarget.m_GridFillValue = m_GridFillValue;
aTarget.m_ZoneClearance = m_ZoneClearance;
aTarget.SetNet(m_NetcodeSelection);
aTarget.SetLayer(m_CurrentZone_Layer);
aTarget.m_Poly->SetHatch(m_Zone_HatchingStyle);
aTarget.m_ArcToSegmentsCount = m_ArcToSegmentsCount;
aTarget.m_DrawOptions = m_FilledAreasShowMode;
aTarget.m_ThermalReliefGapValue = m_ThermalReliefGapValue;
aTarget.m_ThermalReliefCopperBridgeValue = m_ThermalReliefCopperBridgeValue;
aTarget.m_PadOption = m_Zone_Pad_Options;
}

View File

@ -0,0 +1,48 @@
/****************************************************************/
/* class ZONE_SETTING used to handle zones parameters in dialogs */
/****************************************************************/
#ifndef ZONE_SETTING_H
#define ZONE_SETTING_H
#ifndef eda_global
#define eda_global extern
#endif
/*************************************************/
/* Class ZONE_SETTING to handle zones parameters */
/*************************************************/
class ZONE_SETTING
{
public:
int m_GridFillValue; // Grid value for filling zone by segments, 0 to used polygons to fill
int m_ZoneClearance; // Clearance value
int m_NetcodeSelection; // Net code selection for the current zone
int m_CurrentZone_Layer; // Layer used to create the current zone
int m_Zone_HatchingStyle; // Option to show the zone area (outlines only, short hatches or full hatches
int m_ArcToSegmentsCount; /* Option to select number of segments to approximate a circle
* 16 or 32 segments */
int m_FilledAreasShowMode; // Used to select draw options for filled areas in a zone (currently normal =0, sketch = 1)
long m_ThermalReliefGapValue; // tickness of the gap in thermal reliefs
long m_ThermalReliefCopperBridgeValue; // tickness of the copper bridge in thermal reliefs
int m_Zone_Pad_Options; // How pads are covered by copper in zone
public:
ZONE_SETTING( void );
/** function ImportSetting
* copy settings from a given zone
* @param aSource: the given zone
*/
void ImportSetting( const ZONE_CONTAINER& aSource );
/** function ExportSetting
* copy settings to a given zone
* @param aTarget: the given zone
*/
void ExportSetting( ZONE_CONTAINER& aTarget );
};
#endif // ifndef ZONE_SETTING_H

View File

@ -157,7 +157,6 @@ EDA_BoardDesignSettings::EDA_BoardDesignSettings()
m_PcbTextWidth = 100; // current Pcb (not module) Text width
m_PcbTextSize = wxSize( 500, 500 ); // current Pcb (not module) Text size
m_TrackClearence = 100; // track to track and track to pads clearance
m_ZoneClearence = 150; // zone to track and zone to pads clearance
m_MaskMargin = 150; // Solder mask margin
/* Color options for screen display of the Printed Board: */
m_PcbGridColor = DARKGRAY; // Grid color

View File

@ -35,27 +35,29 @@
/************************************************************************************************/
dialog_copper_zone::dialog_copper_zone( WinEDA_PcbFrame* parent, ZONE_CONTAINER * zone_container )
:dialog_copper_zone_frame(parent)
dialog_copper_zone::dialog_copper_zone( WinEDA_PcbFrame* parent, ZONE_SETTING* zone_setting ) :
dialog_copper_zone_frame( parent )
/************************************************************************************************/
{
m_Parent = parent;
m_Zone_Container = zone_container;
m_NetSorting =1; // 0 = alphabetic sort, 1 = pad count sort
m_Zone_Setting = zone_setting;
m_NetSorting = 1; // 0 = alphabetic sort, 1 = pad count sort
if( m_Parent->m_Parent->m_EDA_Config )
{
m_NetSorting = m_Parent->m_Parent->m_EDA_Config->Read( ZONE_NET_SORT_OPTION_KEY, 1l );
}
SetReturnCode(ZONE_ABORT); // Will be changed on buttons click
SetReturnCode( ZONE_ABORT ); // Will be changed on buttons click
}
/*****************************************************************/
void dialog_copper_zone::OnInitDialog( wxInitDialogEvent& event )
/*****************************************************************/
// Initialise all dialog options and values in wxTextCtrl
{
BOARD* board = m_Parent->m_Pcb;
BOARD* board = m_Parent->m_Pcb;
SetFont( *g_DialogFont );
@ -67,11 +69,9 @@ void dialog_copper_zone::OnInitDialog( wxInitDialogEvent& event )
msg = _( "Grid :" ) + ReturnUnitSymbol( g_UnitMetric );
m_GridCtrl->SetLabel( msg );
if( g_DesignSettings.m_ZoneClearence == 0 )
g_DesignSettings.m_ZoneClearence = g_DesignSettings.m_TrackClearence;
msg = ReturnStringFromValue( g_UnitMetric,
g_DesignSettings.m_ZoneClearence,
m_Parent->m_InternalUnits );
m_Zone_Setting->m_ZoneClearance,
m_Parent->m_InternalUnits );
m_ZoneClearanceCtrl->SetValue( msg );
if( g_Zone_45_Only )
@ -80,120 +80,89 @@ void dialog_copper_zone::OnInitDialog( wxInitDialogEvent& event )
static const int GridList[4] = { 25, 50, 100, 250 };
int selection = 0;
int grid_routing = g_GridRoutingSize;
if( m_Zone_Container )
grid_routing = m_Zone_Container->m_GridFillValue;
int grid_routing = m_Zone_Setting->m_GridFillValue;
for( unsigned ii = 0; ii < 4; ii++ )
{
msg = ReturnStringFromValue( g_UnitMetric,
GridList[ii],
m_Parent->m_InternalUnits );
GridList[ii],
m_Parent->m_InternalUnits );
m_GridCtrl->SetString( ii, msg );
if( grid_routing == GridList[ii] )
selection = ii;
}
if( grid_routing == 0 ) // No Grid: fill with polygons
selection = 4;
if( grid_routing == 0 ) // No Grid: fill with polygons
selection = 4;
m_GridCtrl->SetSelection( selection );
if( m_Zone_Container )
msg = ReturnStringFromValue( g_UnitMetric,
m_Zone_Setting->m_ZoneClearance,
m_Parent->m_InternalUnits );
m_ZoneClearanceCtrl->SetValue( msg );
switch( m_Zone_Setting->m_Zone_Pad_Options )
{
msg = ReturnStringFromValue( g_UnitMetric,
m_Zone_Container->m_ZoneClearance,
m_Parent->m_InternalUnits );
m_ZoneClearanceCtrl->SetValue( msg );
case PAD_NOT_IN_ZONE: // Pads are not covered
m_PadInZoneOpt->SetSelection( 2 );
break;
switch( m_Zone_Container->m_PadOption )
{
case ZONE_CONTAINER::PAD_NOT_IN_ZONE: // Pads are not covered
m_PadInZoneOpt->SetSelection( 2 );
break;
case ZONE_CONTAINER::THERMAL_PAD: // Use thermal relief for pads
m_PadInZoneOpt->SetSelection( 1 );
break;
case ZONE_CONTAINER::PAD_IN_ZONE: // pads are covered by copper
m_PadInZoneOpt->SetSelection( 0 );
break;
}
g_Zone_Hatching = m_Zone_Container->m_Poly->GetHatchStyle();
g_Zone_Arc_Approximation = m_Zone_Container->m_ArcToSegmentsCount;
g_FilledAreasShowMode = m_Zone_Container->m_DrawOptions;
if ( g_FilledAreasShowMode == 1)
m_ShowFilledAreasInSketchOpt->SetValue(true);
case THERMAL_PAD: // Use thermal relief for pads
m_PadInZoneOpt->SetSelection( 1 );
break;
case PAD_IN_ZONE: // pads are covered by copper
m_PadInZoneOpt->SetSelection( 0 );
break;
}
if( m_Zone_Setting->m_FilledAreasShowMode == 1 )
m_ShowFilledAreasInSketchOpt->SetValue( true );
if( m_Zone_Setting->m_Zone_Pad_Options != THERMAL_PAD )
{
m_AntipadSizeValue->Enable( false );
m_CopperWidthValue->Enable( false );
}
else
{
switch( g_Zone_Pad_Options )
{
case ZONE_CONTAINER::PAD_NOT_IN_ZONE: // Pads are not covered
m_PadInZoneOpt->SetSelection( 2 );
break;
case ZONE_CONTAINER::THERMAL_PAD: // Use thermal relief for pads
m_PadInZoneOpt->SetSelection( 1 );
break;
case ZONE_CONTAINER::PAD_IN_ZONE: // pads are covered by copper
m_PadInZoneOpt->SetSelection( 0 );
break;
}
g_Zone_Hatching = m_Parent->m_Parent->m_EDA_Config->Read( ZONE_NET_OUTLINES_HATCH_OPTION_KEY,
(long) CPolyLine::DIAGONAL_EDGE );
m_AntipadSizeValue->Enable( true );
m_CopperWidthValue->Enable( true );
}
if ( g_Zone_Pad_Options != ZONE_CONTAINER::THERMAL_PAD )
{
m_AntipadSizeValue->Enable(false);
m_CopperWidthValue->Enable(false);
}
else
{
m_AntipadSizeValue->Enable(true);
m_CopperWidthValue->Enable(true);
}
if( m_Zone_Container )
{
g_ThermalReliefGapValue = m_Zone_Container->m_ThermalReliefGapValue;
g_ThermalReliefCopperBridgeValue = m_Zone_Container->m_ThermalReliefCopperBridgeValue;
}
else
{
m_Parent->m_Parent->m_EDA_Config->Read( ZONE_THERMAL_RELIEF_GAP_STRING_KEY, &g_ThermalReliefGapValue );
m_Parent->m_Parent->m_EDA_Config->Read( ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY, &g_ThermalReliefCopperBridgeValue );
}
AddUnitSymbol( *m_AntipadSizeText, g_UnitMetric );
AddUnitSymbol( *m_CopperBridgeWidthText, g_UnitMetric );
PutValueInLocalUnits( *m_AntipadSizeValue, g_ThermalReliefGapValue, PCB_INTERNAL_UNIT );
PutValueInLocalUnits( *m_CopperWidthValue, g_ThermalReliefCopperBridgeValue, PCB_INTERNAL_UNIT );
PutValueInLocalUnits( *m_AntipadSizeValue,
m_Zone_Setting->m_ThermalReliefGapValue,
PCB_INTERNAL_UNIT );
PutValueInLocalUnits( *m_CopperWidthValue,
m_Zone_Setting->m_ThermalReliefCopperBridgeValue,
PCB_INTERNAL_UNIT );
switch( g_Zone_Hatching )
switch( m_Zone_Setting->m_Zone_HatchingStyle )
{
case CPolyLine::NO_HATCH:
m_OutlineAppearanceCtrl->SetSelection(0);
m_OutlineAppearanceCtrl->SetSelection( 0 );
break;
case CPolyLine::DIAGONAL_EDGE:
m_OutlineAppearanceCtrl->SetSelection(1);
m_OutlineAppearanceCtrl->SetSelection( 1 );
break;
case CPolyLine::DIAGONAL_FULL:
m_OutlineAppearanceCtrl->SetSelection(2);
m_OutlineAppearanceCtrl->SetSelection( 2 );
break;
}
m_ArcApproximationOpt->SetSelection( g_Zone_Arc_Approximation == 32 ? 1 : 0 );
m_ArcApproximationOpt->SetSelection( m_Zone_Setting->m_ArcToSegmentsCount == 32 ? 1 : 0 );
/* build copper layers list */
int layer_cnt = board->GetCopperLayerCount();
for( int ii = 0; ii < board->GetCopperLayerCount(); ii++ )
{
int layer_number = COPPER_LAYER_N;
int layer_number = COPPER_LAYER_N;
if( layer_cnt <= 1 || ii < layer_cnt - 1 )
layer_number = ii;
@ -205,39 +174,32 @@ void dialog_copper_zone::OnInitDialog( wxInitDialogEvent& event )
msg = board->GetLayerName( layer_number ).Trim();
m_LayerSelectionCtrl->InsertItems( 1, &msg, ii );
if( m_Zone_Container )
{
if( m_Zone_Container->GetLayer() == layer_number )
m_LayerSelectionCtrl->SetSelection( ii );
}
else
{
if( ((PCB_SCREEN*)(m_Parent->GetScreen()))->m_Active_Layer == layer_number )
m_LayerSelectionCtrl->SetSelection( ii );
}
if( m_Zone_Setting->m_CurrentZone_Layer == layer_number )
m_LayerSelectionCtrl->SetSelection( ii );
}
m_NetSortingOption->SetSelection(m_NetSorting);
m_NetSortingOption->SetSelection( m_NetSorting );
wxString NetNameFilter;
wxString NetNameFilter;
if( m_Parent->m_Parent->m_EDA_Config )
{
NetNameFilter = m_Parent->m_Parent->m_EDA_Config->Read( ZONE_NET_FILTER_STRING_KEY, wxT("N_0*") );
NetNameFilter =
m_Parent->m_Parent->m_EDA_Config->Read( ZONE_NET_FILTER_STRING_KEY, wxT( "N_0*" ) );
}
m_NetNameFilter->SetValue(NetNameFilter);
m_NetNameFilter->SetValue( NetNameFilter );
wxArrayString ListNetName;
m_Parent->m_Pcb->ReturnSortedNetnamesList( ListNetName,
m_NetSorting == 0 ? BOARD::ALPHA_SORT : BOARD::PAD_CNT_SORT );
if ( m_NetSorting != 0 )
if( m_NetSorting != 0 )
{
wxString Filter = m_NetNameFilter->GetValue();
wxString Filter = m_NetNameFilter->GetValue();
for( unsigned ii = 0; ii < ListNetName.GetCount(); ii++ )
{
if( ListNetName[ii].Matches(Filter.GetData() ) )
if( ListNetName[ii].Matches( Filter.GetData() ) )
{
ListNetName. RemoveAt(ii);
ListNetName.RemoveAt( ii );
ii--;
}
}
@ -246,9 +208,7 @@ void dialog_copper_zone::OnInitDialog( wxInitDialogEvent& event )
m_ListNetNameSelection->InsertItems( ListNetName, 0 );
// Select net:
int net_select = g_HightLigth_NetCode;
if( m_Zone_Container )
net_select = m_Zone_Container->GetNet();
int net_select = m_Zone_Setting->m_NetcodeSelection;
if( net_select > 0 )
{
@ -266,9 +226,9 @@ void dialog_copper_zone::OnInitDialog( wxInitDialogEvent& event )
}
}
}
if (GetSizer())
if( GetSizer() )
{
GetSizer()->SetSizeHints(this);
GetSizer()->SetSizeHints( this );
}
Center();
}
@ -283,8 +243,9 @@ void dialog_copper_zone::OnButtonCancelClick( wxCommandEvent& event )
/********************************************************************************************/
bool dialog_copper_zone::AcceptOptions(bool aPromptForErrors, bool aUseExportableSetupOnly)
bool dialog_copper_zone::AcceptOptions( bool aPromptForErrors, bool aUseExportableSetupOnly )
/********************************************************************************************/
/** Function dialog_copper_zone::AcceptOptions(
* @return false if incorrect options, true if Ok.
* @param aPromptForErrors = true to prompt user on incorrectparams
@ -294,84 +255,90 @@ bool dialog_copper_zone::AcceptOptions(bool aPromptForErrors, bool aUseExportabl
switch( m_PadInZoneOpt->GetSelection() )
{
case 2:
g_Zone_Pad_Options = ZONE_CONTAINER::PAD_NOT_IN_ZONE; // Pads are not covered
m_Zone_Setting->m_Zone_Pad_Options = PAD_NOT_IN_ZONE; // Pads are not covered
break;
case 1:
g_Zone_Pad_Options = ZONE_CONTAINER::THERMAL_PAD; // Use thermal relief for pads
m_Zone_Setting->m_Zone_Pad_Options = THERMAL_PAD; // Use thermal relief for pads
break;
case 0:
g_Zone_Pad_Options = ZONE_CONTAINER::PAD_IN_ZONE; // pads are covered by copper
m_Zone_Setting->m_Zone_Pad_Options = PAD_IN_ZONE; // pads are covered by copper
break;
}
switch( m_OutlineAppearanceCtrl->GetSelection() )
switch( m_OutlineAppearanceCtrl->GetSelection() )
{
case 0:
g_Zone_Hatching = CPolyLine::NO_HATCH;
m_Zone_Setting->m_Zone_HatchingStyle = CPolyLine::NO_HATCH;
break;
case 1:
g_Zone_Hatching = CPolyLine::DIAGONAL_EDGE;
m_Zone_Setting->m_Zone_HatchingStyle = CPolyLine::DIAGONAL_EDGE;
break;
case 2:
g_Zone_Hatching = CPolyLine::DIAGONAL_FULL;
m_Zone_Setting->m_Zone_HatchingStyle = CPolyLine::DIAGONAL_FULL;
break;
}
g_Zone_Arc_Approximation = m_ArcApproximationOpt->GetSelection() == 1 ? 32 : 16;
m_Zone_Setting->m_ArcToSegmentsCount = m_ArcApproximationOpt->GetSelection() == 1 ? 32 : 16;
if( m_Parent->m_Parent->m_EDA_Config )
{
m_Parent->m_Parent->m_EDA_Config->Write( ZONE_NET_OUTLINES_HATCH_OPTION_KEY, (long)g_Zone_Hatching);
m_Parent->m_Parent->m_EDA_Config->Write( ZONE_NET_OUTLINES_HATCH_OPTION_KEY,
(long) m_Zone_Setting->m_Zone_HatchingStyle );
}
switch( m_GridCtrl->GetSelection() )
{
case 0:
g_GridRoutingSize = 25;
m_Zone_Setting->m_GridFillValue = 25;
break;
case 1:
g_GridRoutingSize = 50;
m_Zone_Setting->m_GridFillValue = 50;
break;
default:
case 2:
g_GridRoutingSize = 100;
m_Zone_Setting->m_GridFillValue = 100;
break;
case 3:
g_GridRoutingSize = 250;
m_Zone_Setting->m_GridFillValue = 250;
break;
case 4:
g_GridRoutingSize = 0;
m_Zone_Setting->m_GridFillValue = 0;
DisplayInfo( this, wxT(
"You are using No grid for filling zones\nThis is currently in development and for tests only.\n Do not use for production"));
"You are using No grid for filling zones\nThis is currently in development and for tests only.\n Do not use for production" ) );
break;
}
wxString txtvalue = m_ZoneClearanceCtrl->GetValue();
g_DesignSettings.m_ZoneClearence =
m_Zone_Setting->m_ZoneClearance =
ReturnValueFromString( g_UnitMetric, txtvalue, m_Parent->m_InternalUnits );
if( m_OrientEdgesOpt->GetSelection() == 0 )
g_Zone_45_Only = FALSE;
else
g_Zone_45_Only = TRUE;
g_FilledAreasShowMode = m_ShowFilledAreasInSketchOpt->IsChecked() ? 1 : 0;
m_Zone_Setting->m_FilledAreasShowMode = m_ShowFilledAreasInSketchOpt->IsChecked() ? 1 : 0;
g_ThermalReliefGapValue = ReturnValueFromTextCtrl( *m_AntipadSizeValue, PCB_INTERNAL_UNIT );
g_ThermalReliefCopperBridgeValue = ReturnValueFromTextCtrl( *m_CopperWidthValue, PCB_INTERNAL_UNIT );
m_Zone_Setting->m_ThermalReliefGapValue = ReturnValueFromTextCtrl( *m_AntipadSizeValue,
PCB_INTERNAL_UNIT );
m_Zone_Setting->m_ThermalReliefCopperBridgeValue = ReturnValueFromTextCtrl(
*m_CopperWidthValue,
PCB_INTERNAL_UNIT );
m_Parent->m_Parent->m_EDA_Config->Write( ZONE_THERMAL_RELIEF_GAP_STRING_KEY, (long) g_ThermalReliefGapValue );
m_Parent->m_Parent->m_EDA_Config->Write( ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY, (long)g_ThermalReliefCopperBridgeValue );
m_Parent->m_Parent->m_EDA_Config->Write( ZONE_THERMAL_RELIEF_GAP_STRING_KEY,
(long) m_Zone_Setting->m_ThermalReliefGapValue );
m_Parent->m_Parent->m_EDA_Config->Write( ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY,
(long) m_Zone_Setting->m_ThermalReliefCopperBridgeValue );
// If we use only exportable to others zones parameters, exit here:
if ( aUseExportableSetupOnly )
if( aUseExportableSetupOnly )
return true;
/* Get the layer selection for this zone */
@ -383,7 +350,7 @@ bool dialog_copper_zone::AcceptOptions(bool aPromptForErrors, bool aUseExportabl
}
g_CurrentZone_Layer = m_LayerId[ii];
m_Zone_Setting->m_CurrentZone_Layer = m_LayerId[ii];
/* Get the net name selection for this zone */
@ -398,12 +365,12 @@ bool dialog_copper_zone::AcceptOptions(bool aPromptForErrors, bool aUseExportabl
/* Search net_code for this net */
EQUIPOT* net;
g_NetcodeSelection = 0;
g_Zone_Default_Setting.m_NetcodeSelection = 0;
for( net = m_Parent->m_Pcb->m_Equipots; net; net = net->Next() )
{
if( net->m_Netname == net_name )
{
g_NetcodeSelection = net->GetNet();
g_Zone_Default_Setting.m_NetcodeSelection = net->GetNet();
break;
}
}
@ -411,22 +378,24 @@ bool dialog_copper_zone::AcceptOptions(bool aPromptForErrors, bool aUseExportabl
return true;
}
/***************************************************************************/
void dialog_copper_zone::OnNetSortingOptionSelected( wxCommandEvent& event )
/***************************************************************************/
{
wxArrayString ListNetName;
m_NetSorting = m_NetSortingOption->GetSelection();
m_Parent->m_Pcb->ReturnSortedNetnamesList( ListNetName,
m_NetSorting == 0 ? BOARD::ALPHA_SORT : BOARD::PAD_CNT_SORT );
if ( m_NetSorting != 0 )
if( m_NetSorting != 0 )
{
wxString Filter = m_NetNameFilter->GetValue();
for (unsigned ii = 0; ii < ListNetName.GetCount(); ii ++ )
wxString Filter = m_NetNameFilter->GetValue();
for( unsigned ii = 0; ii < ListNetName.GetCount(); ii++ )
{
if ( ListNetName[ii].Matches(Filter.GetData() ) )
if( ListNetName[ii].Matches( Filter.GetData() ) )
{
ListNetName. RemoveAt(ii);
ListNetName.RemoveAt( ii );
ii--;
}
}
@ -436,14 +405,12 @@ void dialog_copper_zone::OnNetSortingOptionSelected( wxCommandEvent& event )
if( m_Parent->m_Parent->m_EDA_Config )
{
m_Parent->m_Parent->m_EDA_Config->Write( ZONE_NET_SORT_OPTION_KEY, (long) m_NetSorting );
m_Parent->m_Parent->m_EDA_Config->Write( ZONE_NET_FILTER_STRING_KEY, m_NetNameFilter->GetValue() );
m_Parent->m_Parent->m_EDA_Config->Write( ZONE_NET_FILTER_STRING_KEY,
m_NetNameFilter->GetValue() );
}
// Select and isplay current zone net name in listbox:
int net_select = g_HightLigth_NetCode;
if( m_Zone_Container )
net_select = m_Zone_Container->GetNet();
int net_select = m_Zone_Setting->m_NetcodeSelection;
if( net_select > 0 )
{
EQUIPOT* equipot = m_Parent->m_Pcb->FindNet( net_select );
@ -460,7 +427,6 @@ void dialog_copper_zone::OnNetSortingOptionSelected( wxCommandEvent& event )
}
}
}
}
@ -468,40 +434,25 @@ void dialog_copper_zone::OnNetSortingOptionSelected( wxCommandEvent& event )
void dialog_copper_zone::OnButtonOkClick( wxCommandEvent& event )
/*****************************************************************/
{
if ( AcceptOptions(true) )
if( AcceptOptions( true ) )
EndModal( ZONE_OK );
}
/****************************************************************************/
void dialog_copper_zone::OnRemoveFillZoneButtonClick( wxCommandEvent& event )
/****************************************************************************/
{
m_Parent->Delete_Zone_Fill( NULL, NULL, m_Zone_Container->m_TimeStamp );
m_Zone_Container->m_FilledPolysList.clear();
m_Parent->DrawPanel->Refresh();
}
/******************************************************************************/
void dialog_copper_zone::ExportSetupToOtherCopperZones( wxCommandEvent& event )
/******************************************************************************/
{
if ( !AcceptOptions(true, true) )
if( !AcceptOptions( true, true ) )
return;
// Export to others zones:
BOARD * pcb = m_Parent->m_Pcb;
BOARD* pcb = m_Parent->m_Pcb;
for( int ii = 0; ii < pcb->GetAreaCount(); ii++ )
{
ZONE_CONTAINER* zone = pcb->GetArea(ii);
zone->m_Poly->SetHatch( g_Zone_Hatching );
zone->m_PadOption = g_Zone_Pad_Options;
zone->m_ZoneClearance = g_DesignSettings.m_ZoneClearence;
zone->m_GridFillValue = g_GridRoutingSize;
zone->m_ArcToSegmentsCount = g_Zone_Arc_Approximation;
zone->m_DrawOptions = g_FilledAreasShowMode;
zone->m_ThermalReliefGapValue = g_ThermalReliefGapValue;
zone->m_ThermalReliefCopperBridgeValue = g_ThermalReliefCopperBridgeValue;
m_Parent->GetScreen()->SetModify();;
ZONE_CONTAINER* zone = pcb->GetArea( ii );
m_Zone_Setting->ExportSetting( *zone );
m_Parent->GetScreen()->SetModify();
}
}
@ -510,17 +461,16 @@ void dialog_copper_zone::ExportSetupToOtherCopperZones( wxCommandEvent& event )
void dialog_copper_zone::OnPadsInZoneClick( wxCommandEvent& event )
/******************************************************************/
{
switch ( m_PadInZoneOpt->GetSelection() )
switch( m_PadInZoneOpt->GetSelection() )
{
default:
m_AntipadSizeValue->Enable(false);
m_CopperWidthValue->Enable(false);
break;
case 1:
m_AntipadSizeValue->Enable(true);
m_CopperWidthValue->Enable(true);
break;
default:
m_AntipadSizeValue->Enable( false );
m_CopperWidthValue->Enable( false );
break;
case 1:
m_AntipadSizeValue->Enable( true );
m_CopperWidthValue->Enable( true );
break;
}
}

View File

@ -11,17 +11,16 @@ class dialog_copper_zone: public dialog_copper_zone_frame
{
public:
WinEDA_PcbFrame* m_Parent;
ZONE_CONTAINER * m_Zone_Container;
ZONE_SETTING * m_Zone_Setting;
long m_NetSorting;
int m_LayerId[LAYER_COUNT]; // Handle the real layer number from layer name position in m_LayerSelectionCtrl
public:
dialog_copper_zone( WinEDA_PcbFrame* parent, ZONE_CONTAINER * zone_container);
dialog_copper_zone( WinEDA_PcbFrame* parent, ZONE_SETTING * zone_setting);
void OnInitDialog( wxInitDialogEvent& event );
void OnButtonOkClick( wxCommandEvent& event );
void OnButtonCancelClick( wxCommandEvent& event );
bool AcceptOptions(bool aPromptForErrors, bool aUseExportableSetupOnly = false);
void OnRemoveFillZoneButtonClick( wxCommandEvent& event );
void OnNetSortingOptionSelected( wxCommandEvent& event );
void ExportSetupToOtherCopperZones( wxCommandEvent& event );
void OnPadsInZoneClick( wxCommandEvent& event );

View File

@ -15,7 +15,6 @@ BEGIN_EVENT_TABLE( dialog_copper_zone_frame, wxDialog )
EVT_BUTTON( wxID_BUTTON_EXPORT, dialog_copper_zone_frame::_wxFB_ExportSetupToOtherCopperZones )
EVT_BUTTON( wxID_OK, dialog_copper_zone_frame::_wxFB_OnButtonOkClick )
EVT_BUTTON( wxID_CANCEL, dialog_copper_zone_frame::_wxFB_OnButtonCancelClick )
EVT_BUTTON( wxID_BUTTON_UNFILL, dialog_copper_zone_frame::_wxFB_OnRemoveFillZoneButtonClick )
EVT_RADIOBOX( ID_NET_SORTING_OPTION, dialog_copper_zone_frame::_wxFB_OnNetSortingOptionSelected )
END_EVENT_TABLE()
@ -155,9 +154,6 @@ dialog_copper_zone_frame::dialog_copper_zone_frame( wxWindow* parent, wxWindowID
m_ButtonCancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
m_RightBoxSizer->Add( m_ButtonCancel, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
m_UnFillZoneButton = new wxButton( this, wxID_BUTTON_UNFILL, _("Remove Filling"), wxDefaultPosition, wxDefaultSize, 0 );
m_RightBoxSizer->Add( m_UnFillZoneButton, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
m_RightBoxSizer->Add( 5, 20, 0, wxEXPAND, 5 );

View File

@ -1012,58 +1012,6 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxALIGN_CENTER_HORIZONTAL</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="bg"></property>
<property name="context_help"></property>
<property name="default">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_BUTTON_UNFILL</property>
<property name="label">Remove Filling</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">m_UnFillZoneButton</property>
<property name="permission">protected</property>
<property name="pos"></property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnRemoveFillZoneButtonClick</event>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>

View File

@ -41,7 +41,6 @@ class dialog_copper_zone_frame : public wxDialog
void _wxFB_ExportSetupToOtherCopperZones( wxCommandEvent& event ){ ExportSetupToOtherCopperZones( event ); }
void _wxFB_OnButtonOkClick( wxCommandEvent& event ){ OnButtonOkClick( event ); }
void _wxFB_OnButtonCancelClick( wxCommandEvent& event ){ OnButtonCancelClick( event ); }
void _wxFB_OnRemoveFillZoneButtonClick( wxCommandEvent& event ){ OnRemoveFillZoneButtonClick( event ); }
void _wxFB_OnNetSortingOptionSelected( wxCommandEvent& event ){ OnNetSortingOptionSelected( event ); }
@ -55,7 +54,6 @@ class dialog_copper_zone_frame : public wxDialog
ID_RADIOBOX_OUTLINES_OPTION,
wxID_ARC_APPROX,
wxID_BUTTON_EXPORT,
wxID_BUTTON_UNFILL,
ID_NET_SORTING_OPTION,
ID_TEXTCTRL_NETNAMES_FILTER,
ID_NETNAME_SELECTION,
@ -79,7 +77,6 @@ class dialog_copper_zone_frame : public wxDialog
wxButton* m_OkButton;
wxButton* m_ButtonCancel;
wxButton* m_UnFillZoneButton;
wxRadioBox* m_NetSortingOption;
wxStaticText* m_staticText5;
@ -95,7 +92,6 @@ class dialog_copper_zone_frame : public wxDialog
virtual void ExportSetupToOtherCopperZones( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonOkClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonCancelClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnRemoveFillZoneButtonClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnNetSortingOptionSelected( wxCommandEvent& event ){ event.Skip(); }

View File

@ -352,7 +352,7 @@ int WinEDA_BasePcbFrame::ReadSetup( FILE* File, int* LineNum )
if( stricmp( Line, "ZoneClearence" ) == 0 )
{
g_DesignSettings.m_ZoneClearence = atoi( data );
g_Zone_Default_Setting.m_ZoneClearance = atoi( data );
continue;
}
@ -543,7 +543,7 @@ static int WriteSetup( FILE* aFile, WinEDA_BasePcbFrame* aFrame, BOARD* aBoard )
}
fprintf( aFile, "TrackClearence %d\n", g_DesignSettings.m_TrackClearence );
fprintf( aFile, "ZoneClearence %d\n", g_DesignSettings.m_ZoneClearence );
fprintf( aFile, "ZoneClearence %d\n", g_Zone_Default_Setting.m_ZoneClearance );
fprintf( aFile, "DrawSegmWidth %d\n", g_DesignSettings.m_DrawSegmentWidth );
fprintf( aFile, "EdgeSegmWidth %d\n", g_DesignSettings.m_EdgeSegmentWidth );

View File

@ -57,6 +57,7 @@ OBJECTS= $(TARGET).o classpcb.o\
class_drc_item.o\
class_board.o\
class_zone.o\
class_zone_setting.o\
drawframe.o\
drawpanel.o\
track.o \

View File

@ -47,7 +47,7 @@ int ZONE_CONTAINER::Fill_Zone( WinEDA_PcbFrame* frame, wxDC* DC, bool verbose )
g_GridRoutingSize = 25;
// Set the g_DesignSettings.m_TrackClearence (used to fill board map) to the max of m_TrackClearence and m_ZoneClearence
g_DesignSettings.m_TrackClearence = max ( g_DesignSettings.m_TrackClearence, g_DesignSettings.m_ZoneClearence);
g_DesignSettings.m_TrackClearence = max ( g_DesignSettings.m_TrackClearence, m_ZoneClearance);
// In order to avoid ends of segments used to fill the zone, and to the clearence the radius of ends
// which is g_GridRoutingSize/2

View File

@ -10,12 +10,14 @@
#define eda_global extern
#endif
#include "class_zone_setting.h"
// keys used to store net sort option in config file :
#define ZONE_NET_OUTLINES_HATCH_OPTION_KEY wxT( "Zone_Ouline_Hatch_Opt" )
#define ZONE_NET_SORT_OPTION_KEY wxT( "Zone_NetSort_Opt" )
#define ZONE_NET_FILTER_STRING_KEY wxT( "Zone_Filter_Opt" )
#define ZONE_THERMAL_RELIEF_GAP_STRING_KEY wxT( "Zone_TH_Gap" )
#define ZONE_NET_OUTLINES_HATCH_OPTION_KEY wxT( "Zone_Ouline_Hatch_Opt" )
#define ZONE_NET_SORT_OPTION_KEY wxT( "Zone_NetSort_Opt" )
#define ZONE_NET_FILTER_STRING_KEY wxT( "Zone_Filter_Opt" )
#define ZONE_THERMAL_RELIEF_GAP_STRING_KEY wxT( "Zone_TH_Gap" )
#define ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY wxT( "Zone_TH_Copper_Width" )
enum zone_cmd {
@ -24,44 +26,29 @@ enum zone_cmd {
};
enum { // How pads are covered by copper in zone
PAD_NOT_IN_ZONE, // Pads are not covered
THERMAL_PAD, // Use thermal relief for pads
PAD_IN_ZONE // pads are covered by copper
};
/************************************************/
/* variables used in zone dialogs and functions */
/************************************************/
/* parametre grid size for automatic routing and zone filling */
/* parametre grid size for automatic routing */
#if defined MAIN
int g_GridRoutingSize = 250;
int g_GridRoutingSize = 250;
#else
extern int g_GridRoutingSize;
extern int g_GridRoutingSize;
#endif
// @todo: make a class like ZONE_GENERAL_SETTING instead of many global variables
eda_global bool g_Zone_45_Only
#ifdef MAIN
= FALSE
#endif
;
eda_global int g_NetcodeSelection; // Net code selection for the current zone
eda_global int g_CurrentZone_Layer; // Layer used to create the current zone
eda_global int g_Zone_Hatching; // Option to show the zone area (outlines only, short hatches or full hatches
eda_global int g_Zone_Arc_Approximation; // Option to select number of segments to approximate a circle
// 16 or 32 segments
eda_global int g_FilledAreasShowMode; // Used to select draw options for filled areas in a zone (currently normal =0, sketch = 1)
eda_global long g_ThermalReliefGapValue // tickness of the gap in thermal reliefs
#ifdef MAIN
= 200
#endif
;
eda_global long g_ThermalReliefCopperBridgeValue // tickness of the copper bridge in thermal reliefs
#ifdef MAIN
= 200
#endif
;
eda_global ZONE_CONTAINER::m_PadInZone g_Zone_Pad_Options
#ifdef MAIN
= ZONE_CONTAINER::THERMAL_PAD
#endif
;
eda_global ZONE_SETTING g_Zone_Default_Setting; // Default setting used when creating a new zone
#endif // ifndef ZONES_H

View File

@ -19,18 +19,15 @@
using namespace std;
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "pcbnew.h"
#include "autorout.h"
#include "zones.h"
#include "id.h"
#include "protos.h"
#include "zones.h"
bool verbose = false; // false if zone outline diags must not be shown
// Outline creation:
@ -70,12 +67,7 @@ void WinEDA_PcbFrame::Add_Similar_Zone( wxDC* DC, ZONE_CONTAINER* zone_container
s_CurrentZone = zone_container;
/* set zones setup to the current zone */
g_Zone_Hatching = zone_container->m_Poly->GetHatchStyle();
g_Zone_Arc_Approximation = zone_container->m_ArcToSegmentsCount;
g_ThermalReliefGapValue = zone_container->m_ThermalReliefGapValue;
g_ThermalReliefCopperBridgeValue = zone_container->m_ThermalReliefCopperBridgeValue;
g_GridRoutingSize = zone_container->m_GridFillValue;
g_Zone_Pad_Options = zone_container->m_PadOption;
g_Zone_Default_Setting.ImportSetting( *zone_container );
// Use the general event handle to set others params (like toolbar) */
wxCommandEvent evt;
@ -101,12 +93,7 @@ void WinEDA_PcbFrame::Add_Zone_Cutout( wxDC* DC, ZONE_CONTAINER* zone_container
s_CurrentZone = zone_container;
/* set zones setup to the current zone */
g_Zone_Hatching = zone_container->m_Poly->GetHatchStyle();
g_Zone_Arc_Approximation = zone_container->m_ArcToSegmentsCount;
g_ThermalReliefGapValue = zone_container->m_ThermalReliefGapValue;
g_ThermalReliefCopperBridgeValue = zone_container->m_ThermalReliefCopperBridgeValue;
g_GridRoutingSize = zone_container->m_GridFillValue;
g_Zone_Pad_Options = zone_container->m_PadOption;
g_Zone_Default_Setting.ImportSetting( *zone_container );
// Use the general event handle to set others params (like toolbar) */
wxCommandEvent evt;
@ -243,7 +230,7 @@ void WinEDA_PcbFrame::Start_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_con
Hight_Light( DC ); // Remove old hightlight selection
}
g_HightLigth_NetCode = g_NetcodeSelection = zone_container->GetNet();
g_HightLigth_NetCode = g_Zone_Default_Setting.m_NetcodeSelection = zone_container->GetNet();
if( DC )
Hight_Light( DC );
}
@ -296,7 +283,7 @@ void WinEDA_PcbFrame::Start_Move_Zone_Outlines( wxDC* DC, ZONE_CONTAINER* zone_c
Hight_Light( DC ); // Remove old hightlight selection
}
g_HightLigth_NetCode = g_NetcodeSelection = zone_container->GetNet();
g_HightLigth_NetCode = g_Zone_Default_Setting.m_NetcodeSelection = zone_container->GetNet();
Hight_Light( DC );
}
@ -542,21 +529,24 @@ int WinEDA_PcbFrame::Begin_Zone( wxDC* DC )
{ // Put a zone on a copper layer
if ( g_HightLigth_NetCode )
{
g_NetcodeSelection = g_HightLigth_NetCode;
zone->SetNet( g_NetcodeSelection );
EQUIPOT* net = m_Pcb->FindNet( g_NetcodeSelection );
if( net )
zone->m_Netname = net->m_Netname;
g_Zone_Default_Setting.m_NetcodeSelection = g_HightLigth_NetCode;
zone->SetNet( g_Zone_Default_Setting.m_NetcodeSelection );
zone->SetNetNameFromNetCode( );
}
dialog_copper_zone* frame = new dialog_copper_zone( this, zone );
m_Parent->m_EDA_Config->Read( ZONE_THERMAL_RELIEF_GAP_STRING_KEY,
&g_Zone_Default_Setting.m_ThermalReliefGapValue );
m_Parent->m_EDA_Config->Read( ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY,
&g_Zone_Default_Setting.m_ThermalReliefCopperBridgeValue );
dialog_copper_zone* frame = new dialog_copper_zone( this, &g_Zone_Default_Setting );
diag = frame->ShowModal();
frame->Destroy();
}
else // Put a zone on a non copper layer (technical layer)
{
diag = InstallDialogNonCopperZonesEditor( this, zone );
g_NetcodeSelection = 0; // No net for non copper zones
g_Zone_Default_Setting.m_NetcodeSelection = 0; // No net for non copper zones
}
DrawPanel->MouseToCursorSchema();
DrawPanel->m_IgnoreMouseEvents = FALSE;
@ -564,26 +554,27 @@ int WinEDA_PcbFrame::Begin_Zone( wxDC* DC )
if( diag == ZONE_ABORT )
return 0;
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = g_CurrentZone_Layer; // Set by the dialog frame
// Switch active layer to the selectec zonz layer
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = g_Zone_Default_Setting.m_CurrentZone_Layer;
}
else // Start a new contour: init zone params (net and layer) from an existing zone (add cutout or similar zone)
{
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = g_CurrentZone_Layer =
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = g_Zone_Default_Setting.m_CurrentZone_Layer =
s_CurrentZone->GetLayer();
g_Zone_Hatching = s_CurrentZone->m_Poly->GetHatchStyle();
g_Zone_Default_Setting.ImportSetting( * s_CurrentZone);
}
/* Show the Net for zones on copper layers */
if( g_CurrentZone_Layer < FIRST_NO_COPPER_LAYER )
if( g_Zone_Default_Setting.m_CurrentZone_Layer < FIRST_NO_COPPER_LAYER )
{
if( s_CurrentZone )
g_NetcodeSelection = s_CurrentZone->GetNet();
g_Zone_Default_Setting.m_NetcodeSelection = s_CurrentZone->GetNet();
if( g_HightLigt_Status )
{
Hight_Light( DC ); // Remove old hightlight selection
}
g_HightLigth_NetCode = g_NetcodeSelection;
g_HightLigth_NetCode = g_Zone_Default_Setting.m_NetcodeSelection;
Hight_Light( DC );
}
if( !s_AddCutoutToCurrentZone )
@ -594,17 +585,11 @@ int WinEDA_PcbFrame::Begin_Zone( wxDC* DC )
if( zone->GetNumCorners() == 0 )
{
zone->m_Flags = IS_NEW;
zone->SetLayer( g_CurrentZone_Layer );
zone->SetNet( g_NetcodeSelection );
zone->m_TimeStamp = GetTimeStamp();
zone->m_PadOption = g_Zone_Pad_Options;
zone->m_ZoneClearance = g_DesignSettings.m_ZoneClearence;
zone->m_ThermalReliefGapValue = g_ThermalReliefGapValue;
zone->m_ThermalReliefCopperBridgeValue = g_ThermalReliefCopperBridgeValue;
zone->m_GridFillValue = g_GridRoutingSize;
zone->m_Poly->Start( g_CurrentZone_Layer,
g_Zone_Default_Setting.ExportSetting( *zone );
zone->m_Poly->Start( g_Zone_Default_Setting.m_CurrentZone_Layer,
GetScreen()->m_Curseur.x, GetScreen()->m_Curseur.y,
g_Zone_Hatching );
zone->GetHatchStyle() );
zone->AppendCorner( GetScreen()->m_Curseur );
if( Drc_On && (m_drc->Drc( zone, 0 ) == BAD_DRC) && zone->IsOnCopperLayer() )
{
@ -792,7 +777,8 @@ void WinEDA_PcbFrame::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container
DrawPanel->m_IgnoreMouseEvents = TRUE;
if( zone_container->GetLayer() < FIRST_NO_COPPER_LAYER )
{ // edit a zone on a copper layer
dialog_copper_zone* frame = new dialog_copper_zone( this, zone_container );
g_Zone_Default_Setting.ImportSetting(*zone_container);
dialog_copper_zone* frame = new dialog_copper_zone( this, &g_Zone_Default_Setting );
diag = frame->ShowModal();
frame->Destroy();
}
@ -812,19 +798,10 @@ void WinEDA_PcbFrame::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container
edge_zone->Draw( DrawPanel, DC, GR_XOR );
}
zone_container->SetLayer( g_CurrentZone_Layer );
zone_container->SetNet( g_NetcodeSelection );
EQUIPOT* net = m_Pcb->FindNet( g_NetcodeSelection );
if( net )
g_Zone_Default_Setting.ExportSetting( *zone_container);
EQUIPOT* net = m_Pcb->FindNet( g_Zone_Default_Setting.m_NetcodeSelection );
if( net ) // net === NULL should not occur
zone_container->m_Netname = net->m_Netname;
zone_container->m_Poly->SetHatch( g_Zone_Hatching );
zone_container->m_PadOption = g_Zone_Pad_Options;
zone_container->m_ZoneClearance = g_DesignSettings.m_ZoneClearence;
zone_container->m_GridFillValue = g_GridRoutingSize;
zone_container->m_ArcToSegmentsCount = g_Zone_Arc_Approximation;
zone_container->m_DrawOptions = g_FilledAreasShowMode;
zone_container->m_ThermalReliefGapValue = g_ThermalReliefGapValue;
zone_container->m_ThermalReliefCopperBridgeValue = g_ThermalReliefCopperBridgeValue;
// Combine zones if possible :
@ -897,13 +874,13 @@ int WinEDA_PcbFrame::Fill_Zone( wxDC* DC, ZONE_CONTAINER* zone_container, bool v
}
/* Show the Net */
g_NetcodeSelection = zone_container->GetNet();
if( g_HightLigt_Status && (g_HightLigth_NetCode != g_NetcodeSelection) && DC )
g_Zone_Default_Setting.m_NetcodeSelection = zone_container->GetNet();
if( g_HightLigt_Status && (g_HightLigth_NetCode != g_Zone_Default_Setting.m_NetcodeSelection) && DC )
{
Hight_Light( DC ); // Remove old hightlight selection
}
g_HightLigth_NetCode = g_NetcodeSelection;
g_HightLigth_NetCode = g_Zone_Default_Setting.m_NetcodeSelection;
if( DC )
Hight_Light( DC );
@ -988,7 +965,7 @@ int WinEDA_PcbFrame::Fill_All_Zones( wxDC* DC, bool verbose )
/**
* Function SetAreasNetCodesFromNetNames
* Set the .m_NetCode member of all copper areas, according to the area Net Name
* The SetNetCodesFromNetNames is an equivalent to net name, for fas comparisons.
* The SetNetCodesFromNetNames is an equivalent to net name, for fast comparisons.
* However the Netcode is an arbitrary equivalence, it must be set after each netlist read
* or net change
* Must be called after pad netcodes are calculated

View File

@ -74,7 +74,7 @@ void DialogNonCopperZonesEditor::InitDialog( wxInitDialogEvent& event )
if( g_Zone_45_Only )
m_OrientEdgesOpt->SetSelection( 1 );
switch( g_Zone_Hatching )
switch( g_Zone_Default_Setting.m_Zone_HatchingStyle )
{
case CPolyLine::NO_HATCH:
m_OutlineAppearanceCtrl->SetSelection( 0 );
@ -122,22 +122,22 @@ void DialogNonCopperZonesEditor::OnOkClick( wxCommandEvent& event )
switch( m_OutlineAppearanceCtrl->GetSelection() )
{
case 0:
g_Zone_Hatching = CPolyLine::NO_HATCH;
g_Zone_Default_Setting.m_Zone_HatchingStyle = CPolyLine::NO_HATCH;
break;
case 1:
g_Zone_Hatching = CPolyLine::DIAGONAL_EDGE;
g_Zone_Default_Setting.m_Zone_HatchingStyle = CPolyLine::DIAGONAL_EDGE;
break;
case 2:
g_Zone_Hatching = CPolyLine::DIAGONAL_FULL;
g_Zone_Default_Setting.m_Zone_HatchingStyle = CPolyLine::DIAGONAL_FULL;
break;
}
if( m_Parent->m_Parent->m_EDA_Config )
{
m_Parent->m_Parent->m_EDA_Config->Write( ZONE_NET_OUTLINES_HATCH_OPTION_KEY,
(long) g_Zone_Hatching );
(long) g_Zone_Default_Setting.m_Zone_HatchingStyle );
}
if( m_OrientEdgesOpt->GetSelection() == 0 )
@ -152,7 +152,7 @@ void DialogNonCopperZonesEditor::OnOkClick( wxCommandEvent& event )
DisplayError( this, _( "Error : you must choose a layer" ) );
return;
}
g_CurrentZone_Layer = ii + FIRST_NO_COPPER_LAYER;
g_Zone_Default_Setting.m_CurrentZone_Layer = ii + FIRST_NO_COPPER_LAYER;
EndModal( ZONE_OK );
}
@ -209,11 +209,11 @@ int ZONE_CONTAINER::BuildFilledPolysListData( BOARD * aPcb )
}
m_Poly->FreeKboolEngine();
/* For copper layers, we now must add holes in the Polygon list.
holes are pads and tracks with their clearance area
*/
if ( IsOnCopperLayer() )
AddClearanceAreasPolygonsToPolysList( aPcb );

View File

@ -1059,6 +1059,7 @@ bool DRC::doEdgeZoneDrc( ZONE_CONTAINER* aArea, int aCornerIndex )
for( int ia2 = 0; ia2 < m_pcb->GetAreaCount(); ia2++ )
{
ZONE_CONTAINER* Area_To_Test = m_pcb->GetArea( ia2 );
int zone_clearance = max(Area_To_Test->m_ZoneClearance, aArea->m_ZoneClearance);
// test for same layer
if( Area_To_Test->GetLayer() != aArea->GetLayer() )
@ -1111,9 +1112,9 @@ bool DRC::doEdgeZoneDrc( ZONE_CONTAINER* aArea, int aCornerIndex )
0,
ax1, ay1, ax2, ay2, astyle,
0,
g_DesignSettings.m_ZoneClearence,
zone_clearance,
&x, &y );
if( d < g_DesignSettings.m_ZoneClearence )
if( d < zone_clearance )
{
// COPPERAREA_COPPERAREA error : edge intersect or too close
m_currentMarker = fillMarker( aArea, wxPoint( x, y ),