Commit 2ffa0897 authored by charras's avatar charras

Some enhancements about zones

parent 0872c8a1
......@@ -29,6 +29,7 @@ ZONE_CONTAINER::ZONE_CONTAINER( BOARD* parent ) :
utility = 0; // flags used in polygon calculations
utility2 = 0; // flags used in polygon calculations
m_Poly = new CPolyLine(); // Outlines
m_ArcToSegmentsCount = 16; // Use 16 segment to convert a circle to a polygon
}
......@@ -136,8 +137,8 @@ bool ZONE_CONTAINER::Save( FILE* aFile ) const
if( ret < 2 )
return false;
ret = fprintf( aFile, "ZOptions %d\n", m_GridFillValue );
if( ret < 1 )
ret = fprintf( aFile, "ZOptions %d %d\n", m_GridFillValue, m_ArcToSegmentsCount );
if( ret < 2 )
return false;
......@@ -269,12 +270,15 @@ int ZONE_CONTAINER::ReadDescr( FILE* aFile, int* aLineNum )
if( strnicmp( Line, "ZOptions", 8 ) == 0 ) // Options info found
{
int gridsize = 50;
int arcsegmentcount = 16;
text = Line + 8;
ret = sscanf( text, "%d", &gridsize );
if( ret < 1 )
ret = sscanf( text, "%d %d", &gridsize, &arcsegmentcount );
if( ret < 1 ) // Must find 1 or 2 args.
return false;
else
m_GridFillValue = gridsize;
if ( arcsegmentcount >= 32 )
m_ArcToSegmentsCount = 32;
}
if( strnicmp( Line, "ZClearance", 10 ) == 0 ) // Clearence and pad options info found
{
......
......@@ -31,7 +31,8 @@ public:
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
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 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.
......
......@@ -64,7 +64,7 @@ void dialog_copper_zone::OnInitDialog( wxInitDialogEvent& event )
wxString title = _( "Zone clearance value:" ) + ReturnUnitSymbol( g_UnitMetric );
m_ClearanceValueTitle->SetLabel( title );
title = _( "Grid :" ) + ReturnUnitSymbol( g_UnitMetric );;
title = _( "Grid :" ) + ReturnUnitSymbol( g_UnitMetric );
m_GridCtrl->SetLabel( title );
if( g_DesignSettings.m_ZoneClearence == 0 )
......@@ -119,6 +119,7 @@ void dialog_copper_zone::OnInitDialog( wxInitDialogEvent& event )
break;
}
g_Zone_Hatching = m_Zone_Container->m_Poly->GetHatchStyle();
g_Zone_Arc_Approximation = m_Zone_Container->m_ArcToSegmentsCount;
}
else
......@@ -153,6 +154,8 @@ void dialog_copper_zone::OnInitDialog( wxInitDialogEvent& event )
m_OutlineAppearanceCtrl->SetSelection(2);
break;
}
m_ArcApproximationOpt->SetSelection( g_Zone_Arc_Approximation == 32 ? 1 : 0 );
/* build copper layers list */
int layer_cnt = board->GetCopperLayerCount();
......@@ -282,6 +285,8 @@ bool dialog_copper_zone::AcceptOptions(bool aPromptForErrors)
g_Zone_Hatching = CPolyLine::DIAGONAL_FULL;
break;
}
g_Zone_Arc_Approximation = m_ArcApproximationOpt->GetSelection() == 1 ? 32 : 16;
if( m_Parent->m_Parent->m_EDA_Config )
{
......@@ -394,5 +399,13 @@ void dialog_copper_zone::OnButtonOkClick( wxCommandEvent& event )
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();
}
......@@ -21,6 +21,7 @@ public:
void OnButtonOkClick( wxCommandEvent& event );
void OnButtonCancelClick( wxCommandEvent& event );
bool AcceptOptions(bool aPromptForErrors);
void OnRemoveFillZoneButtonClick( wxCommandEvent& event );
void OnNetSortingOptionSelected( wxCommandEvent& event );
};
......
......@@ -13,6 +13,7 @@ BEGIN_EVENT_TABLE( dialog_copper_zone_frame, wxDialog )
EVT_INIT_DIALOG( dialog_copper_zone_frame::_wxFB_OnInitDialog )
EVT_BUTTON( wxID_OK, dialog_copper_zone_frame::_wxFB_OnButtonOkClick )
EVT_BUTTON( wxID_CANCEL, dialog_copper_zone_frame::_wxFB_OnButtonCancelClick )
EVT_BUTTON( wxID_ANY, dialog_copper_zone_frame::_wxFB_OnRemoveFillZoneButtonClick )
EVT_RADIOBOX( ID_NET_SORTING_OPTION, dialog_copper_zone_frame::_wxFB_OnNetSortingOptionSelected )
END_EVENT_TABLE()
......@@ -35,7 +36,7 @@ dialog_copper_zone_frame::dialog_copper_zone_frame( wxWindow* parent, wxWindowID
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( 4 );
m_GridCtrl->SetSelection( 1 );
m_FillOptionsBox->Add( m_GridCtrl, 0, wxALL, 5 );
m_ClearanceValueTitle = new wxStaticText( this, wxID_ANY, _("Zone clearance value (mm):"), wxDefaultPosition, wxDefaultSize, 0 );
......@@ -64,20 +65,30 @@ dialog_copper_zone_frame::dialog_copper_zone_frame( wxWindow* parent, wxWindowID
wxStaticBoxSizer* m_OutilinesBoxOpt;
m_OutilinesBoxOpt = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Outlines Options:") ), wxVERTICAL );
wxString m_OrientEdgesOptChoices[] = { _("Any"), _("H , V and 45 deg") };
int m_OrientEdgesOptNChoices = sizeof( m_OrientEdgesOptChoices ) / sizeof( wxString );
m_OrientEdgesOpt = new wxRadioBox( this, wxID_ANY, _("Zone edges orient:"), wxDefaultPosition, wxDefaultSize, m_OrientEdgesOptNChoices, m_OrientEdgesOptChoices, 1, wxRA_SPECIFY_COLS );
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") };
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_OutilinesBoxOpt->Add( m_OutlineAppearanceCtrl, 0, wxALL|wxEXPAND, 5 );
m_OutlineAppearanceCtrl->SetSelection( 1 );
m_OutlineAppearanceCtrl->SetToolTip( _("How a zone outline is shoved:\nSingle line\nShort hatching\nFull area hatched") );
m_OutilinesBoxOpt->Add( m_OutlineAppearanceCtrl, 0, wxALL|wxEXPAND, 5 );
m_OutilinesBoxOpt->Add( 5, 5, 0, 0, 5 );
wxString m_ArcApproximationOptChoices[] = { _("16 segments / 360 deg"), _("32 segments / 360 deg") };
int m_ArcApproximationOptNChoices = sizeof( m_ArcApproximationOptChoices ) / sizeof( wxString );
m_ArcApproximationOpt = new wxRadioBox( this, wxID_ARC_APPROX, _("Arcs Approximation:"), wxDefaultPosition, wxDefaultSize, m_ArcApproximationOptNChoices, m_ArcApproximationOptChoices, 1, wxRA_SPECIFY_COLS );
m_ArcApproximationOpt->SetSelection( 1 );
m_ArcApproximationOpt->SetToolTip( _("Number of segments to approximate a circle in filling calculations.\n16 segment is faster to calculate and when redraw screen.\n32 segment give a better quality") );
wxString m_OrientEdgesOptChoices[] = { _("Any"), _("H , V and 45 deg") };
int m_OrientEdgesOptNChoices = sizeof( m_OrientEdgesOptChoices ) / sizeof( wxString );
m_OrientEdgesOpt = new wxRadioBox( this, wxID_ANY, _("Zone edges orient:"), wxDefaultPosition, wxDefaultSize, m_OrientEdgesOptNChoices, m_OrientEdgesOptChoices, 1, wxRA_SPECIFY_COLS );
m_OrientEdgesOpt->SetSelection( 0 );
m_OutilinesBoxOpt->Add( m_OrientEdgesOpt, 0, wxALL, 5 );
m_OutilinesBoxOpt->Add( m_ArcApproximationOpt, 0, wxALL|wxEXPAND, 5 );
m_MiddleBoxSizer->Add( m_OutilinesBoxOpt, 1, wxEXPAND, 5 );
......@@ -90,11 +101,15 @@ dialog_copper_zone_frame::dialog_copper_zone_frame( wxWindow* parent, wxWindowID
m_RightBoxSizer = new wxBoxSizer( wxVERTICAL );
m_OkButton = new wxButton( this, wxID_OK, _("Ok"), wxDefaultPosition, wxDefaultSize, 0 );
m_OkButton->SetDefault();
m_RightBoxSizer->Add( m_OkButton, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
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_ANY, _("UnFill Zone"), wxDefaultPosition, wxDefaultSize, 0 );
m_RightBoxSizer->Add( m_UnFillZoneButton, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
m_RightBoxSizer->Add( 5, 20, 0, wxEXPAND, 5 );
......@@ -104,7 +119,9 @@ dialog_copper_zone_frame::dialog_copper_zone_frame( wxWindow* parent, wxWindowID
wxString m_NetSortingOptionChoices[] = { _("Alphabetic"), _("Advanced") };
int m_NetSortingOptionNChoices = sizeof( m_NetSortingOptionChoices ) / sizeof( wxString );
m_NetSortingOption = new wxRadioBox( this, ID_NET_SORTING_OPTION, _("Net sorting:"), wxDefaultPosition, wxDefaultSize, m_NetSortingOptionNChoices, m_NetSortingOptionChoices, 1, wxRA_SPECIFY_COLS );
m_NetSortingOption->SetSelection( 0 );
m_NetSortingOption->SetSelection( 1 );
m_NetSortingOption->SetToolTip( _("Nets can be sorted:\nBy alphabetic order\nBy number of pads in the net (advanced)") );
m_NetSortOptSizer->Add( m_NetSortingOption, 0, wxALL|wxEXPAND, 5 );
m_staticText5 = new wxStaticText( this, wxID_ANY, _("Filter"), wxDefaultPosition, wxDefaultSize, 0 );
......
This diff is collapsed.
......@@ -38,6 +38,7 @@ class dialog_copper_zone_frame : public wxDialog
void _wxFB_OnInitDialog( wxInitDialogEvent& event ){ OnInitDialog( 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 ); }
......@@ -46,6 +47,7 @@ class dialog_copper_zone_frame : public wxDialog
{
ID_RADIOBOX_GRID_SELECTION = 1000,
ID_RADIOBOX_OUTLINES_OPTION,
wxID_ARC_APPROX,
ID_NET_SORTING_OPTION,
ID_TEXTCTRL_NETNAMES_FILTER,
ID_NETNAME_SELECTION,
......@@ -57,12 +59,14 @@ class dialog_copper_zone_frame : public wxDialog
wxTextCtrl* m_ZoneClearanceCtrl;
wxRadioBox* m_FillOpt;
wxRadioBox* m_OutlineAppearanceCtrl;
wxRadioBox* m_OrientEdgesOpt;
wxRadioBox* m_OutlineAppearanceCtrl;
wxRadioBox* m_ArcApproximationOpt;
wxButton* m_OkButton;
wxButton* m_ButtonCancel;
wxButton* m_UnFillZoneButton;
wxRadioBox* m_NetSortingOption;
wxStaticText* m_staticText5;
......@@ -76,11 +80,12 @@ class dialog_copper_zone_frame : public wxDialog
virtual void OnInitDialog( wxInitDialogEvent& 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(); }
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|wxSUNKEN_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( 452,493 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~dialog_copper_zone_frame();
};
......
......@@ -31,9 +31,11 @@ eda_global bool g_Zone_45_Only
= FALSE
#endif
;
eda_global int g_NetcodeSelection; // Net code selection for the current zone
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 ZONE_CONTAINER::m_PadInZone g_Zone_Pad_Options
#ifdef MAIN
......
......@@ -785,6 +785,8 @@ void WinEDA_PcbFrame::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container
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;
// Combine zones if possible :
m_Pcb->AreaPolygonModified( zone_container, true, verbose );
......
......@@ -30,7 +30,9 @@ void AddTextBoxWithClearancePolygon( Bool_Engine* aBooleng,
// Local Variables:
/* how many segments are used to create a polygon from a circle: */
static int s_CircleToSegmentsCount = 16;
static int s_CircleToSegmentsCount = 16; /* default value. the real value will be changed to 32
if g_Zone_Arc_Approximation == 1
*/
/** function AddClearanceAreasPolygonsToPolysList
* Add non copper areas polygons (pads and tracks with clearence)
......@@ -49,6 +51,12 @@ static int s_CircleToSegmentsCount = 16;
*/
void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
{
// Set the number of segments in arc approximations
if ( m_ArcToSegmentsCount == 32 )
s_CircleToSegmentsCount = 32;
else
s_CircleToSegmentsCount = 16;
/* Uses a kbool engine to add holes in the m_FilledPolysList polygon.
* Because this function is called just after creating the m_FilledPolysList,
* only one polygon is in list.
......@@ -56,8 +64,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
* after adding holes, many polygons could be exist in this list.
*/
Bool_Engine* booleng = new Bool_Engine();
Bool_Engine * booleng = new Bool_Engine();
ArmBoolEng( booleng, true );
......
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