Commit 9eba4f95 authored by charras's avatar charras

Solved a bug when creating a new zone outline that could crash pcbnew

parent 544ca4c9
......@@ -5,6 +5,14 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
email address.
2008-oct-11 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+pcbnew:
Solved a bug when creating a new zone outline that could crash pcbnew
More about copper zones filled without grid (by polygons)
Currently for tests only (work in progress).
now working: Thermal reliefs parameters can be set.
2008-oct-11 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+pcbnew:
......
No preview for this file type
This diff is collapsed.
......@@ -31,6 +31,8 @@ ZONE_CONTAINER::ZONE_CONTAINER( BOARD* parent ) :
m_Poly = new CPolyLine(); // Outlines
m_ArcToSegmentsCount = 16; // Use 16 segment to convert a circle to a polygon
m_DrawOptions = 0;
m_ThermalReliefGapValue = 200; // tickness of the gap in thermal reliefs
m_ThermalReliefCopperBridgeValue = 200; // tickness of the copper bridge in thermal reliefs
}
......@@ -138,8 +140,8 @@ bool ZONE_CONTAINER::Save( FILE* aFile ) const
if( ret < 2 )
return false;
ret = fprintf( aFile, "ZOptions %d %d %c\n", m_GridFillValue, m_ArcToSegmentsCount,
m_DrawOptions ? 'S' : 'F' );
ret = fprintf( aFile, "ZOptions %d %d %c %d %d\n", m_GridFillValue, m_ArcToSegmentsCount,
m_DrawOptions ? 'S' : 'F' , m_ThermalReliefGapValue, m_ThermalReliefCopperBridgeValue);
if( ret < 3 )
return false;
......@@ -274,20 +276,20 @@ int ZONE_CONTAINER::ReadDescr( FILE* aFile, int* aLineNum )
{
int gridsize = 50;
int arcsegmentcount = 16;
int drawopt = 'F';
char drawopt = 'F';
text = Line + 8;
ret = sscanf( text, "%d %d %c", &gridsize, &arcsegmentcount, &drawopt );
ret = sscanf( text, "%d %d %c %d %d", &gridsize, &arcsegmentcount, &drawopt,
&m_ThermalReliefGapValue, &m_ThermalReliefCopperBridgeValue );
if( ret < 1 ) // Must find 1 or more args.
return false;
else
m_GridFillValue = gridsize;
if ( arcsegmentcount >= 32 )
if( arcsegmentcount >= 32 )
m_ArcToSegmentsCount = 32;
if ( drawopt == 'S' ) // Sketch mode for filled areas in this zone selected
if( drawopt == 'S' ) // Sketch mode for filled areas in this zone selected
m_DrawOptions = 1;
}
if( strnicmp( Line, "ZClearance", 10 ) == 0 ) // Clearence and pad options info found
{
......@@ -351,7 +353,7 @@ int ZONE_CONTAINER::ReadDescr( FILE* aFile, int* aLineNum )
}
/* Set hatch here, when outlines corners are read */
m_Poly->SetHatch(outline_hatch);
m_Poly->SetHatch( outline_hatch );
return error ? 0 : 1;
}
......@@ -571,7 +573,7 @@ void ZONE_CONTAINER::DrawWhileCreateOutline( WinEDA_DrawPanel* panel, wxDC* DC,
if( DC == NULL )
return;
int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
int color = g_DesignSettings.m_LayerColor[m_Layer] & MASKCOLOR;
int color = g_DesignSettings.m_LayerColor[m_Layer & 31] & MASKCOLOR;
if( DisplayOpt.ContrastModeDisplay )
{
......@@ -585,27 +587,30 @@ void ZONE_CONTAINER::DrawWhileCreateOutline( WinEDA_DrawPanel* panel, wxDC* DC,
// draw the lines
wxPoint start_contour_pos = GetCornerPosition( 0 );
for( int ic = 0; ic < GetNumCorners(); ic++ )
int icmax = GetNumCorners() - 1;
for( int ic = 0; ic <= icmax; ic++ )
{
int xi = GetCornerPosition( ic ).x;
int yi = GetCornerPosition( ic ).y;
int xf, yf;
if( m_Poly->corner[ic].end_contour == FALSE && ic < GetNumCorners() - 1 )
if( m_Poly->corner[ic].end_contour == FALSE && ic < icmax )
{
is_close_segment = false;
xf = GetCornerPosition( ic + 1 ).x;
yf = GetCornerPosition( ic + 1 ).y;
if( (m_Poly->corner[ic + 1].end_contour) || (ic == GetNumCorners() - 2) )
if( (m_Poly->corner[ic + 1].end_contour) || (ic == icmax - 1) )
current_gr_mode = GR_XOR;
else
current_gr_mode = draw_mode;
}
else
else // Draw the line from last corner to the first corner of the current coutour
{
is_close_segment = true;
current_gr_mode = GR_XOR;
xf = start_contour_pos.x;
yf = start_contour_pos.y;
// Prepare the next contour for drawing, if exists
if ( ic < icmax )
start_contour_pos = GetCornerPosition( ic + 1 );
}
GRSetDrawMode( DC, current_gr_mode );
......
......@@ -34,6 +34,8 @@ public:
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_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
std::vector <CPolyPt> m_FilledPolysList; /* set of filled polygons used to draw a zone as a filled area.
* from outlines (m_Poly) but unlike m_Poly these filled polygons have no hole (they are all in one piece)
......
......@@ -53,7 +53,7 @@ dialog_copper_zone::dialog_copper_zone( WinEDA_PcbFrame* parent, ZONE_CONTAINER
/*****************************************************************/
void dialog_copper_zone::OnInitDialog( wxInitDialogEvent& event )
/*****************************************************************/
// Initialise dialog options
// Initialise all dialog options and values in wxTextCtrl
{
BOARD* board = m_Parent->m_Pcb;
......@@ -109,13 +109,13 @@ void dialog_copper_zone::OnInitDialog( wxInitDialogEvent& event )
switch( m_Zone_Container->m_PadOption )
{
case ZONE_CONTAINER::PAD_NOT_IN_ZONE: // Pads are not covered
m_FillOpt->SetSelection( 2 );
m_PadInZoneOpt->SetSelection( 2 );
break;
case ZONE_CONTAINER::THERMAL_PAD: // Use thermal relief for pads
m_FillOpt->SetSelection( 1 );
m_PadInZoneOpt->SetSelection( 1 );
break;
case ZONE_CONTAINER::PAD_IN_ZONE: // pads are covered by copper
m_FillOpt->SetSelection( 0 );
m_PadInZoneOpt->SetSelection( 0 );
break;
}
g_Zone_Hatching = m_Zone_Container->m_Poly->GetHatchStyle();
......@@ -133,19 +133,45 @@ void dialog_copper_zone::OnInitDialog( wxInitDialogEvent& event )
switch( g_Zone_Pad_Options )
{
case ZONE_CONTAINER::PAD_NOT_IN_ZONE: // Pads are not covered
m_FillOpt->SetSelection( 2 );
m_PadInZoneOpt->SetSelection( 2 );
break;
case ZONE_CONTAINER::THERMAL_PAD: // Use thermal relief for pads
m_FillOpt->SetSelection( 1 );
m_PadInZoneOpt->SetSelection( 1 );
break;
case ZONE_CONTAINER::PAD_IN_ZONE: // pads are covered by copper
m_FillOpt->SetSelection( 0 );
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 );
}
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 );
switch( g_Zone_Hatching )
{
case CPolyLine::NO_HATCH:
......@@ -245,6 +271,7 @@ void dialog_copper_zone::OnInitDialog( wxInitDialogEvent& event )
{
GetSizer()->SetSizeHints(this);
}
Center();
}
......@@ -265,7 +292,7 @@ bool dialog_copper_zone::AcceptOptions(bool aPromptForErrors, bool aUseExportabl
* @param aUseExportableSetupOnly = true to use exportable parametres only (used to export this setup to other zones)
*/
{
switch( m_FillOpt->GetSelection() )
switch( m_PadInZoneOpt->GetSelection() )
{
case 2:
g_Zone_Pad_Options = ZONE_CONTAINER::PAD_NOT_IN_ZONE; // Pads are not covered
......@@ -338,6 +365,12 @@ bool dialog_copper_zone::AcceptOptions(bool aPromptForErrors, bool aUseExportabl
g_FilledAreasShowMode = m_ShowFilledAreasInSketchOpt->IsChecked() ? 1 : 0;
g_ThermalReliefGapValue = ReturnValueFromTextCtrl( *m_AntipadSizeValue, PCB_INTERNAL_UNIT );
g_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 );
// If we use only exportable to others zones parameters, exit here:
if ( aUseExportableSetupOnly )
return true;
......@@ -467,7 +500,28 @@ void dialog_copper_zone::ExportSetupToOtherCopperZones( wxCommandEvent& event )
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();;
}
}
/******************************************************************/
void dialog_copper_zone::OnPadsInZoneClick( wxCommandEvent& event )
/******************************************************************/
{
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;
}
}
......@@ -24,6 +24,7 @@ public:
void OnRemoveFillZoneButtonClick( wxCommandEvent& event );
void OnNetSortingOptionSelected( wxCommandEvent& event );
void ExportSetupToOtherCopperZones( wxCommandEvent& event );
void OnPadsInZoneClick( wxCommandEvent& event );
};
#endif // #ifndef DIALOG_COPPER_ZONES
......@@ -11,6 +11,7 @@
BEGIN_EVENT_TABLE( dialog_copper_zone_frame, wxDialog )
EVT_INIT_DIALOG( dialog_copper_zone_frame::_wxFB_OnInitDialog )
EVT_RADIOBOX( wxID_PADS_IN_ZONE_OPTIONS, dialog_copper_zone_frame::_wxFB_OnPadsInZoneClick )
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 )
......@@ -37,30 +38,40 @@ dialog_copper_zone_frame::dialog_copper_zone_frame( wxWindow* parent, wxWindowID
wxStaticBoxSizer* m_FillOptionsBox;
m_FillOptionsBox = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Zone Fill Options:") ), wxVERTICAL );
wxString m_GridCtrlChoices[] = { _("0.00000"), _("0.00000"), _("0.00000"), _("0.00000"), _("No Grid (For tests only!)") };
wxString m_GridCtrlChoices[] = { _("0.00000"), _("0.00000"), _("0.00000"), _("0.00000"), _("No grid (For tests only!)") };
int m_GridCtrlNChoices = sizeof( m_GridCtrlChoices ) / sizeof( wxString );
m_GridCtrl = new wxRadioBox( this, ID_RADIOBOX_GRID_SELECTION, _("Grid Size for Filling:"), wxDefaultPosition, wxDefaultSize, m_GridCtrlNChoices, m_GridCtrlChoices, 1, wxRA_SPECIFY_COLS );
m_GridCtrl->SetSelection( 0 );
m_GridCtrl->SetSelection( 4 );
m_FillOptionsBox->Add( m_GridCtrl, 0, wxALL|wxEXPAND, 5 );
m_ClearanceValueTitle = new wxStaticText( this, wxID_ANY, _("Zone clearance value (mm):"), wxDefaultPosition, wxDefaultSize, 0 );
m_ClearanceValueTitle->Wrap( -1 );
m_FillOptionsBox->Add( m_ClearanceValueTitle, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
wxString m_PadInZoneOptChoices[] = { _("Include pads"), _("Thermal relief"), _("Exclude pads") };
int m_PadInZoneOptNChoices = sizeof( m_PadInZoneOptChoices ) / sizeof( wxString );
m_PadInZoneOpt = new wxRadioBox( this, wxID_PADS_IN_ZONE_OPTIONS, _("Pad in Zone:"), wxDefaultPosition, wxDefaultSize, m_PadInZoneOptNChoices, m_PadInZoneOptChoices, 1, wxRA_SPECIFY_COLS );
m_PadInZoneOpt->SetSelection( 1 );
m_FillOptionsBox->Add( m_PadInZoneOpt, 0, wxALL|wxEXPAND, 5 );
m_ZoneClearanceCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_FillOptionsBox->Add( m_ZoneClearanceCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxStaticBoxSizer* m_ThermalShapesParamsSizer;
m_ThermalShapesParamsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Thermal Reliefs Parameters") ), wxVERTICAL );
wxString m_FillOptChoices[] = { _("Include Pads"), _("Thermal Relief"), _("Exclude Pads") };
int m_FillOptNChoices = sizeof( m_FillOptChoices ) / sizeof( wxString );
m_FillOpt = new wxRadioBox( this, wxID_ANY, _("Pad in Zone:"), wxDefaultPosition, wxDefaultSize, m_FillOptNChoices, m_FillOptChoices, 1, wxRA_SPECIFY_COLS );
m_FillOpt->SetSelection( 2 );
m_FillOptionsBox->Add( m_FillOpt, 0, wxALL|wxEXPAND, 5 );
m_AntipadSizeText = new wxStaticText( this, wxID_ANY, _("Antipad Size"), wxDefaultPosition, wxDefaultSize, 0 );
m_AntipadSizeText->Wrap( -1 );
m_ThermalShapesParamsSizer->Add( m_AntipadSizeText, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_ShowFilledAreasInSketchOpt = new wxCheckBox( this, wxID_ANY, _("Show filled areas in sketch mode"), wxDefaultPosition, wxDefaultSize, 0 );
m_AntipadSizeValue = new wxTextCtrl( this, wxID_ANTIPAD_SIZE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_AntipadSizeValue->SetToolTip( _("Define the gap around the pad") );
m_ShowFilledAreasInSketchOpt->SetToolTip( _("If enabled, filled areas in is this zone will be displayed as non filled polygons.\nIf disabled, filled areas in is this zone will be displayed as \"solid\" areas (normal mode).") );
m_ThermalShapesParamsSizer->Add( m_AntipadSizeValue, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_CopperBridgeWidthText = new wxStaticText( this, wxID_ANY, _("Copper Width"), wxDefaultPosition, wxDefaultSize, 0 );
m_CopperBridgeWidthText->Wrap( -1 );
m_ThermalShapesParamsSizer->Add( m_CopperBridgeWidthText, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_FillOptionsBox->Add( m_ShowFilledAreasInSketchOpt, 0, wxALL, 5 );
m_CopperWidthValue = new wxTextCtrl( this, wxID_COPPER_BRIDGE_VALUE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_CopperWidthValue->SetToolTip( _("Define the tickness of copper in therma reliefs") );
m_ThermalShapesParamsSizer->Add( m_CopperWidthValue, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_FillOptionsBox->Add( m_ThermalShapesParamsSizer, 0, wxEXPAND, 5 );
m_LeftBoxSizer->Add( m_FillOptionsBox, 1, wxEXPAND, 5 );
......@@ -84,13 +95,10 @@ dialog_copper_zone_frame::dialog_copper_zone_frame( wxWindow* parent, wxWindowID
m_OrientEdgesOpt->SetSelection( 0 );
m_OutilinesBoxOpt->Add( m_OrientEdgesOpt, 0, wxALL|wxEXPAND, 5 );
m_OutilinesBoxOpt->Add( 5, 5, 0, 0, 5 );
wxString m_OutlineAppearanceCtrlChoices[] = { _("Line"), _("Hatched Outline"), _("Full Hatched") };
wxString m_OutlineAppearanceCtrlChoices[] = { _("Line"), _("Hatched outline"), _("Full hatched") };
int m_OutlineAppearanceCtrlNChoices = sizeof( m_OutlineAppearanceCtrlChoices ) / sizeof( wxString );
m_OutlineAppearanceCtrl = new wxRadioBox( this, ID_RADIOBOX_OUTLINES_OPTION, _("Outlines Appearance"), wxDefaultPosition, wxDefaultSize, m_OutlineAppearanceCtrlNChoices, m_OutlineAppearanceCtrlChoices, 1, wxRA_SPECIFY_COLS );
m_OutlineAppearanceCtrl->SetSelection( 0 );
m_OutlineAppearanceCtrl->SetSelection( 1 );
m_OutlineAppearanceCtrl->SetToolTip( _("Choose how a zone outline is displayed\n- Single line\n- Short hatching\n- Full zone area hatched") );
m_OutilinesBoxOpt->Add( m_OutlineAppearanceCtrl, 0, wxALL|wxEXPAND, 5 );
......@@ -103,12 +111,30 @@ dialog_copper_zone_frame::dialog_copper_zone_frame( wxWindow* parent, wxWindowID
m_OutilinesBoxOpt->Add( m_ArcApproximationOpt, 0, wxALL|wxEXPAND, 5 );
wxStaticBoxSizer* m_OthersOptionsSizer;
m_OthersOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Others Options:") ), wxVERTICAL );
m_ShowFilledAreasInSketchOpt = new wxCheckBox( this, wxID_ANY, _("Show filled areas in sketch mode"), wxDefaultPosition, wxDefaultSize, 0 );
m_ShowFilledAreasInSketchOpt->SetToolTip( _("If enabled, filled areas in is this zone will be displayed as non filled polygons.\nIf disabled, filled areas in is this zone will be displayed as \"solid\" areas (normal mode).") );
m_OthersOptionsSizer->Add( m_ShowFilledAreasInSketchOpt, 0, wxALL, 5 );
m_ClearanceValueTitle = new wxStaticText( this, wxID_ANY, _("Zone clearance value (mm):"), wxDefaultPosition, wxDefaultSize, 0 );
m_ClearanceValueTitle->Wrap( -1 );
m_OthersOptionsSizer->Add( m_ClearanceValueTitle, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_ZoneClearanceCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_OthersOptionsSizer->Add( m_ZoneClearanceCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_OutilinesBoxOpt->Add( m_OthersOptionsSizer, 1, wxEXPAND, 5 );
m_MiddleBoxSizer->Add( m_OutilinesBoxOpt, 1, wxEXPAND, 5 );
m_ExportSetupBuuton = new wxButton( this, wxID_BUTTON_EXPORT, _("Export to others zones"), wxDefaultPosition, wxDefaultSize, 0 );
m_ExportSetupBuuton->SetToolTip( _("Export this zone setup to all others copper zones") );
m_ExportSetupButton = new wxButton( this, wxID_BUTTON_EXPORT, _("Export to others zones"), wxDefaultPosition, wxDefaultSize, 0 );
m_ExportSetupButton->SetToolTip( _("Export this zone setup to all others copper zones") );
m_MiddleBoxSizer->Add( m_ExportSetupBuuton, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
m_MiddleBoxSizer->Add( m_ExportSetupButton, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
m_MiddleBox->Add( m_MiddleBoxSizer, 0, 0, 5 );
......@@ -129,7 +155,7 @@ 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, _("UnFill Zone"), wxDefaultPosition, wxDefaultSize, 0 );
m_UnFillZoneButton = new wxButton( this, wxID_BUTTON_UNFILL, _("Remove Filling"), wxDefaultPosition, wxDefaultSize, 0 );
m_RightBoxSizer->Add( m_UnFillZoneButton, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
......
This diff is collapsed.
......@@ -18,9 +18,9 @@
#include <wx/settings.h>
#include <wx/stattext.h>
#include <wx/textctrl.h>
#include <wx/checkbox.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/checkbox.h>
#include <wx/button.h>
#include <wx/listbox.h>
#include <wx/dialog.h>
......@@ -37,6 +37,7 @@ class dialog_copper_zone_frame : public wxDialog
// Private event handlers
void _wxFB_OnInitDialog( wxInitDialogEvent& event ){ OnInitDialog( event ); }
void _wxFB_OnPadsInZoneClick( wxCommandEvent& event ){ OnPadsInZoneClick( event ); }
void _wxFB_ExportSetupToOtherCopperZones( wxCommandEvent& event ){ ExportSetupToOtherCopperZones( event ); }
void _wxFB_OnButtonOkClick( wxCommandEvent& event ){ OnButtonOkClick( event ); }
void _wxFB_OnButtonCancelClick( wxCommandEvent& event ){ OnButtonCancelClick( event ); }
......@@ -48,6 +49,9 @@ class dialog_copper_zone_frame : public wxDialog
enum
{
ID_RADIOBOX_GRID_SELECTION = 1000,
wxID_PADS_IN_ZONE_OPTIONS,
wxID_ANTIPAD_SIZE,
wxID_COPPER_BRIDGE_VALUE,
ID_RADIOBOX_OUTLINES_OPTION,
wxID_ARC_APPROX,
wxID_BUTTON_EXPORT,
......@@ -59,16 +63,19 @@ class dialog_copper_zone_frame : public wxDialog
};
wxRadioBox* m_GridCtrl;
wxStaticText* m_ClearanceValueTitle;
wxTextCtrl* m_ZoneClearanceCtrl;
wxRadioBox* m_FillOpt;
wxCheckBox* m_ShowFilledAreasInSketchOpt;
wxRadioBox* m_PadInZoneOpt;
wxStaticText* m_AntipadSizeText;
wxTextCtrl* m_AntipadSizeValue;
wxStaticText* m_CopperBridgeWidthText;
wxTextCtrl* m_CopperWidthValue;
wxRadioBox* m_OrientEdgesOpt;
wxRadioBox* m_OutlineAppearanceCtrl;
wxRadioBox* m_ArcApproximationOpt;
wxButton* m_ExportSetupBuuton;
wxCheckBox* m_ShowFilledAreasInSketchOpt;
wxStaticText* m_ClearanceValueTitle;
wxTextCtrl* m_ZoneClearanceCtrl;
wxButton* m_ExportSetupButton;
wxButton* m_OkButton;
wxButton* m_ButtonCancel;
......@@ -84,6 +91,7 @@ class dialog_copper_zone_frame : public wxDialog
// Virtual event handlers, overide them in your derived class
virtual void OnInitDialog( wxInitDialogEvent& event ){ event.Skip(); }
virtual void OnPadsInZoneClick( wxCommandEvent& event ){ event.Skip(); }
virtual void ExportSetupToOtherCopperZones( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonOkClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonCancelClick( wxCommandEvent& event ){ event.Skip(); }
......@@ -92,7 +100,7 @@ class dialog_copper_zone_frame : public wxDialog
public:
dialog_copper_zone_frame( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Fill Zones Options"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 452,493 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
dialog_copper_zone_frame( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Fill Zones Options"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 545,493 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~dialog_copper_zone_frame();
};
......
......@@ -15,6 +15,8 @@
#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 {
ZONE_ABORT,
......@@ -37,6 +39,16 @@ eda_global int g_Zone_Hatching; // Option to show the zone a
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
......
......@@ -64,6 +64,8 @@ void WinEDA_PcbFrame::Add_Similar_Zone( wxDC* DC, ZONE_CONTAINER* zone_container
* @param zone_container = parent zone outline
*/
{
if ( zone_container == NULL )
return;
s_AddCutoutToCurrentZone = false;
s_CurrentZone = zone_container;
wxCommandEvent evt;
......@@ -83,6 +85,8 @@ void WinEDA_PcbFrame::Add_Zone_Cutout( wxDC* DC, ZONE_CONTAINER* zone_container
* @param zone_container = parent zone outline
*/
{
if ( zone_container == NULL )
return;
s_AddCutoutToCurrentZone = true;
s_CurrentZone = zone_container;
wxCommandEvent evt;
......@@ -479,39 +483,40 @@ int WinEDA_PcbFrame::Begin_Zone( wxDC* DC )
* Function Begin_Zone
* either initializes the first segment of a new zone, or adds an
* intermediate segment.
* A new zone can be:
* created from scratch: the user will be prompted to define parameters (layer, clearence ...)
* created from a similar zone (s_CurrentZone is used): parameters are copied from s_CurrentZone
* created as a cutout (an hole) inside s_CurrentZone
*/
{
// verify if s_CurrentZone exists:
// verify if s_CurrentZone exists (could be deleted since last selection) :
int ii;
for( ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{
if( s_CurrentZone == m_Pcb->GetArea( ii ) )
break;
}
if( ii == m_Pcb->GetAreaCount() ) // Not found: could be deleted since last selection
if( ii >= m_Pcb->GetAreaCount() ) // Not found: could be deleted since last selection
{
s_AddCutoutToCurrentZone = false;
s_CurrentZone = NULL;
}
ZONE_CONTAINER* zone;
// If no zone contour in progress, a new zone is beeing created:
if( m_Pcb->m_CurrentZoneContour == NULL )
m_Pcb->m_CurrentZoneContour = new ZONE_CONTAINER( m_Pcb );
zone = m_Pcb->m_CurrentZoneContour;
if( zone->GetNumCorners() == 0 ) /* Start a new contour: init zone params (net and layer) */
ZONE_CONTAINER* zone = m_Pcb->m_CurrentZoneContour;
if( zone->GetNumCorners() == 0 ) /* Start a new contour: init zone params (net, layer ...) */
{
if( s_CurrentZone == NULL ) // A new outline is created
if( s_CurrentZone == NULL ) // A new outline is created, from scratch
{
int diag;
// Init zone params to reasonnable values
zone->SetLayer( ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer );
// Prompt user fro exact parameters:
// Prompt user for parameters:
DrawPanel->m_IgnoreMouseEvents = TRUE;
if( zone->IsOnCopperLayer() )
{ // Put a zone on a copper layer
......@@ -541,7 +546,7 @@ int WinEDA_PcbFrame::Begin_Zone( wxDC* DC )
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = g_CurrentZone_Layer; // Set by the dialog frame
}
else /* Start a new contour: init zone params (net and layer) from an existing zone */
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 =
s_CurrentZone->GetLayer();
......@@ -551,18 +556,18 @@ int WinEDA_PcbFrame::Begin_Zone( wxDC* DC )
/* Show the Net for zones on copper layers */
if( g_CurrentZone_Layer < FIRST_NO_COPPER_LAYER )
{
if( g_HightLigt_Status && (g_HightLigth_NetCode != g_NetcodeSelection) )
if( s_CurrentZone )
g_NetcodeSelection = s_CurrentZone->GetNet();
if( g_HightLigt_Status )
{
Hight_Light( DC ); // Remove old hightlight selection
}
if( s_CurrentZone )
g_NetcodeSelection = s_CurrentZone->GetNet();
g_HightLigth_NetCode = g_NetcodeSelection;
Hight_Light( DC );
}
if( !s_AddCutoutToCurrentZone )
s_CurrentZone = NULL; // the zone is used only once
s_CurrentZone = NULL; // the zone is used only once ("add similar zone" command)
}
// if first segment
......@@ -574,6 +579,8 @@ int WinEDA_PcbFrame::Begin_Zone( wxDC* DC )
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,
GetScreen()->m_Curseur.x, GetScreen()->m_Curseur.y,
......@@ -729,6 +736,8 @@ static void Show_New_Edge_While_Move_Mouse( WinEDA_DrawPanel* panel, wxDC* DC, b
return;
int icorner = zone->GetNumCorners() - 1;
if ( icorner < 1 )
return; // We must have 2 (or more) corners
if( erase ) /* Undraw edge in old position*/
{
......@@ -760,7 +769,6 @@ void WinEDA_PcbFrame::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container
*/
{
int diag;
DrawPanel->m_IgnoreMouseEvents = TRUE;
if( zone_container->GetLayer() < FIRST_NO_COPPER_LAYER )
{ // edit a zone on a copper layer
......@@ -795,6 +803,8 @@ void WinEDA_PcbFrame::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container
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 :
......
......@@ -113,7 +113,8 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
break;
case THERMAL_PAD:
AddThermalReliefPadPolygon( booleng, *pad, 100, 100 );
AddThermalReliefPadPolygon( booleng, *pad,
m_ThermalReliefGapValue, m_ThermalReliefCopperBridgeValue );
break;
case PAD_IN_ZONE:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment