diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index 88ebce0443..8fd77f6cd9 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -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 { diff --git a/pcbnew/class_zone.h b/pcbnew/class_zone.h index 21960d3444..f8e45a5910 100644 --- a/pcbnew/class_zone.h +++ b/pcbnew/class_zone.h @@ -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 m_FilledPolysList; /* set of filled polygons used to draw a zone as a filled area. diff --git a/pcbnew/dialog_copper_zones.cpp b/pcbnew/dialog_copper_zones.cpp index 53d084b84d..6a4cd69960 100644 --- a/pcbnew/dialog_copper_zones.cpp +++ b/pcbnew/dialog_copper_zones.cpp @@ -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(); +} diff --git a/pcbnew/dialog_copper_zones.h b/pcbnew/dialog_copper_zones.h index 6bd34c9ce6..d86bd2b669 100644 --- a/pcbnew/dialog_copper_zones.h +++ b/pcbnew/dialog_copper_zones.h @@ -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 ); }; diff --git a/pcbnew/dialog_copper_zones_frame.cpp b/pcbnew/dialog_copper_zones_frame.cpp index a5afbd6f86..ed6fc1fa42 100644 --- a/pcbnew/dialog_copper_zones_frame.cpp +++ b/pcbnew/dialog_copper_zones_frame.cpp @@ -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_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_OutilinesBoxOpt->Add( 5, 5, 0, 0, 5 ); - 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_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( 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 ); + + 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") ); + + 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 ); diff --git a/pcbnew/dialog_copper_zones_frame.fbp b/pcbnew/dialog_copper_zones_frame.fbp index 9e4bf92b65..8b98f2b046 100644 --- a/pcbnew/dialog_copper_zones_frame.fbp +++ b/pcbnew/dialog_copper_zones_frame.fbp @@ -39,7 +39,7 @@ - wxSUNKEN_BORDER + @@ -125,7 +125,7 @@ m_GridCtrl protected - 4 + 1 wxRA_SPECIFY_COLS @@ -360,18 +360,18 @@ 0 - "Line" "Hatched Outline" "Full Hatched" + "Any" "H , V and 45 deg" 1 0 - ID_RADIOBOX_OUTLINES_OPTION - Outlines Appearance + wxID_ANY + Zone edges orient: 1 - m_OutlineAppearanceCtrl + m_OrientEdgesOpt protected 0 @@ -420,29 +420,83 @@ 5 - wxALL + wxALL|wxEXPAND 0 - "Any" "H , V and 45 deg" + "Line" "Hatched Outline" "Full Hatched" 1 0 - wxID_ANY - Zone edges orient: + ID_RADIOBOX_OUTLINES_OPTION + Outlines Appearance 1 - m_OrientEdgesOpt + m_OutlineAppearanceCtrl protected - 0 + 1 wxRA_SPECIFY_COLS - + How a zone outline is shoved: Single line Short hatching Full area hatched + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + "16 segments / 360 deg" "32 segments / 360 deg" + + 1 + + + 0 + wxID_ARC_APPROX + Arcs Approximation: + 1 + + + m_ArcApproximationOpt + protected + + 1 + + wxRA_SPECIFY_COLS + + Number of segments to approximate a circle in filling calculations. 16 segment is faster to calculate and when redraw screen. 32 segment give a better quality @@ -502,7 +556,7 @@ - 0 + 1 1 @@ -599,6 +653,58 @@ + + 5 + wxALL|wxALIGN_CENTER_HORIZONTAL + 0 + + + + 0 + 1 + + + 0 + wxID_ANY + UnFill Zone + + + m_UnFillZoneButton + protected + + + + + + + + + OnRemoveFillZoneButtonClick + + + + + + + + + + + + + + + + + + + + + + + + + 5 wxEXPAND @@ -641,11 +747,11 @@ m_NetSortingOption protected - 0 + 1 wxRA_SPECIFY_COLS - + Nets can be sorted: By alphabetic order By number of pads in the net (advanced) diff --git a/pcbnew/dialog_copper_zones_frame.h b/pcbnew/dialog_copper_zones_frame.h index d8c7355d4f..7bcf737732 100644 --- a/pcbnew/dialog_copper_zones_frame.h +++ b/pcbnew/dialog_copper_zones_frame.h @@ -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(); }; diff --git a/pcbnew/zones.h b/pcbnew/zones.h index ea30ebd8e3..ff538a3172 100644 --- a/pcbnew/zones.h +++ b/pcbnew/zones.h @@ -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 diff --git a/pcbnew/zones_by_polygon.cpp b/pcbnew/zones_by_polygon.cpp index 1251ecab2c..bcf28e8f02 100644 --- a/pcbnew/zones_by_polygon.cpp +++ b/pcbnew/zones_by_polygon.cpp @@ -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 ); diff --git a/pcbnew/zones_convert_brd_items_to_polygons.cpp b/pcbnew/zones_convert_brd_items_to_polygons.cpp index 35e6605067..e3c42ed93a 100644 --- a/pcbnew/zones_convert_brd_items_to_polygons.cpp +++ b/pcbnew/zones_convert_brd_items_to_polygons.cpp @@ -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 );