From 22de1c8813ea98353ce9342cfe1db24aa739059b Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 12 May 2023 10:06:20 +0200 Subject: [PATCH] Teardrop dialog: refinements. Show a PROGRESS_REPORTER when refilling zones. --- pcbnew/teardrop/dialog_teardrop.cpp | 6 +- pcbnew/teardrop/dialog_teardrop_base.cpp | 6 +- pcbnew/teardrop/dialog_teardrop_base.fbp | 77 +++++++++++++++++++++++- pcbnew/teardrop/dialog_teardrop_base.h | 2 +- pcbnew/teardrop/teardrop.cpp | 64 +++++++++++--------- pcbnew/teardrop/teardrop.h | 11 +++- 6 files changed, 130 insertions(+), 36 deletions(-) diff --git a/pcbnew/teardrop/dialog_teardrop.cpp b/pcbnew/teardrop/dialog_teardrop.cpp index b76381f824..63a51fa55d 100644 --- a/pcbnew/teardrop/dialog_teardrop.cpp +++ b/pcbnew/teardrop/dialog_teardrop.cpp @@ -31,6 +31,7 @@ #include "teardrop.h" #include "dialog_teardrop_base.h" #include +#include // Curved shapes options. The actual value is the ORed of options @@ -220,10 +221,13 @@ void PCB_EDIT_FRAME::OnRunTeardropTool( wxCommandEvent& event ) wxBusyCursor dummy; + std::unique_ptr reporter; + reporter = std::make_unique( this, _( "Filling Zones" ), 4 ); + BOARD_COMMIT committer( this ); dlg.TransferToParamList(); - TEARDROP_MANAGER trdm( GetBoard(), this ); + TEARDROP_MANAGER trdm( GetBoard(), this, reporter.get() ); int added_count = trdm.SetTeardrops( &committer, dlg.CanUseTwoTracks(), !dlg.GenerateRawTeardrops() ); diff --git a/pcbnew/teardrop/dialog_teardrop_base.cpp b/pcbnew/teardrop/dialog_teardrop_base.cpp index 56763741d9..fbfa274a7f 100644 --- a/pcbnew/teardrop/dialog_teardrop_base.cpp +++ b/pcbnew/teardrop/dialog_teardrop_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) +// C++ code generated with wxFormBuilder (version 3.10.1-282-g1fa54006) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -370,7 +370,7 @@ TEARDROP_DIALOG_BASE::TEARDROP_DIALOG_BASE( wxWindow* parent, wxWindowID id, con sbSizerScope->Add( m_cbTrack2Track, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - bSizerShape->Add( sbSizerScope, 1, wxEXPAND|wxTOP, 5 ); + bSizerShape->Add( sbSizerScope, 0, wxEXPAND|wxTOP, 5 ); wxStaticBoxSizer* sbSizerOptions; sbSizerOptions = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Options") ), wxVERTICAL ); @@ -412,7 +412,7 @@ TEARDROP_DIALOG_BASE::TEARDROP_DIALOG_BASE( wxWindow* parent, wxWindowID id, con m_rawTeardropsHint = new wxStaticText( sbSizerOptions->GetStaticBox(), wxID_ANY, _("(Shapes will be adjusted for clearances on next zone fill.)"), wxDefaultPosition, wxDefaultSize, 0 ); m_rawTeardropsHint->Wrap( -1 ); - m_rawTeardropsHint->SetFont( wxFont( 11, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) ); + m_rawTeardropsHint->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) ); sbSizerOptions->Add( m_rawTeardropsHint, 0, wxLEFT, 27 ); diff --git a/pcbnew/teardrop/dialog_teardrop_base.fbp b/pcbnew/teardrop/dialog_teardrop_base.fbp index 26067ae198..ea2f359458 100644 --- a/pcbnew/teardrop/dialog_teardrop_base.fbp +++ b/pcbnew/teardrop/dialog_teardrop_base.fbp @@ -36,6 +36,7 @@ wxBOTH 1 + 0 1 impl_virtual @@ -129,6 +130,7 @@ Dock 0 Left + 0 1 1 @@ -191,6 +193,7 @@ Dock 0 Left + 0 1 1 @@ -264,6 +267,7 @@ Dock 0 Left + 0 1 1 @@ -326,6 +330,7 @@ Dock 0 Left + 0 1 1 @@ -389,6 +394,7 @@ Dock 0 Left + 0 1 1 @@ -450,6 +456,7 @@ Dock 0 Left + 0 1 1 @@ -512,6 +519,7 @@ Dock 0 Left + 0 1 1 @@ -575,6 +583,7 @@ Dock 0 Left + 0 1 1 @@ -636,6 +645,7 @@ Dock 0 Left + 0 1 1 @@ -697,6 +707,7 @@ Dock 0 Left + 0 1 1 @@ -761,6 +772,7 @@ Dock 0 Left + 0 1 1 @@ -822,6 +834,7 @@ Dock 0 Left + 0 1 1 @@ -883,6 +896,7 @@ Dock 0 Left + 0 1 1 @@ -947,6 +961,7 @@ Dock 0 Left + 0 1 1 @@ -1038,6 +1053,7 @@ Dock 0 Left + 0 1 1 @@ -1100,6 +1116,7 @@ Dock 0 Left + 0 1 1 @@ -1163,6 +1180,7 @@ Dock 0 Left + 0 1 1 @@ -1227,6 +1245,7 @@ Dock 0 Left + 0 1 1 @@ -1292,6 +1311,7 @@ Dock 0 Left + 0 1 1 @@ -1350,6 +1370,7 @@ Dock 0 Left + 0 1 1 @@ -1408,6 +1429,7 @@ Dock 0 Left + 0 1 1 @@ -1466,6 +1488,7 @@ Dock 0 Left + 0 1 1 @@ -1524,6 +1547,7 @@ Dock 0 Left + 0 1 1 @@ -1586,6 +1610,7 @@ Dock 0 Left + 0 1 1 @@ -1659,6 +1684,7 @@ Dock 0 Left + 0 1 1 @@ -1721,6 +1747,7 @@ Dock 0 Left + 0 1 1 @@ -1784,6 +1811,7 @@ Dock 0 Left + 0 1 1 @@ -1845,6 +1873,7 @@ Dock 0 Left + 0 1 1 @@ -1907,6 +1936,7 @@ Dock 0 Left + 0 1 1 @@ -1970,6 +2000,7 @@ Dock 0 Left + 0 1 1 @@ -2031,6 +2062,7 @@ Dock 0 Left + 0 1 1 @@ -2092,6 +2124,7 @@ Dock 0 Left + 0 1 1 @@ -2156,6 +2189,7 @@ Dock 0 Left + 0 1 1 @@ -2217,6 +2251,7 @@ Dock 0 Left + 0 1 1 @@ -2278,6 +2313,7 @@ Dock 0 Left + 0 1 1 @@ -2342,6 +2378,7 @@ Dock 0 Left + 0 1 1 @@ -2433,6 +2470,7 @@ Dock 0 Left + 0 1 1 @@ -2495,6 +2533,7 @@ Dock 0 Left + 0 1 1 @@ -2558,6 +2597,7 @@ Dock 0 Left + 0 1 1 @@ -2622,6 +2662,7 @@ Dock 0 Left + 0 1 1 @@ -2687,6 +2728,7 @@ Dock 0 Left + 0 1 1 @@ -2745,6 +2787,7 @@ Dock 0 Left + 0 1 1 @@ -2803,6 +2846,7 @@ Dock 0 Left + 0 1 1 @@ -2861,6 +2905,7 @@ Dock 0 Left + 0 1 1 @@ -2919,6 +2964,7 @@ Dock 0 Left + 0 1 1 @@ -2981,6 +3027,7 @@ Dock 0 Left + 0 1 1 @@ -3054,6 +3101,7 @@ Dock 0 Left + 0 1 1 @@ -3116,6 +3164,7 @@ Dock 0 Left + 0 1 1 @@ -3179,6 +3228,7 @@ Dock 0 Left + 0 1 1 @@ -3240,6 +3290,7 @@ Dock 0 Left + 0 1 1 @@ -3302,6 +3353,7 @@ Dock 0 Left + 0 1 1 @@ -3365,6 +3417,7 @@ Dock 0 Left + 0 1 1 @@ -3426,6 +3479,7 @@ Dock 0 Left + 0 1 1 @@ -3487,6 +3541,7 @@ Dock 0 Left + 0 1 1 @@ -3551,6 +3606,7 @@ Dock 0 Left + 0 1 1 @@ -3612,6 +3668,7 @@ Dock 0 Left + 0 1 1 @@ -3673,6 +3730,7 @@ Dock 0 Left + 0 1 1 @@ -3737,6 +3795,7 @@ Dock 0 Left + 0 1 1 @@ -3828,6 +3887,7 @@ Dock 0 Left + 0 1 1 @@ -3890,6 +3950,7 @@ Dock 0 Left + 0 1 1 @@ -3953,6 +4014,7 @@ Dock 0 Left + 0 1 1 @@ -4017,6 +4079,7 @@ Dock 0 Left + 0 1 1 @@ -4075,7 +4138,7 @@ 5 wxEXPAND|wxTOP - 1 + 0 wxID_ANY Scope @@ -4110,6 +4173,7 @@ Dock 0 Left + 0 1 1 @@ -4174,6 +4238,7 @@ Dock 0 Left + 0 1 1 @@ -4238,6 +4303,7 @@ Dock 0 Left + 0 1 1 @@ -4302,6 +4368,7 @@ Dock 0 Left + 0 1 1 @@ -4380,6 +4447,7 @@ Dock 0 Left + 0 1 1 @@ -4444,6 +4512,7 @@ Dock 0 Left + 0 1 1 @@ -4526,6 +4595,7 @@ Dock 0 Left + 0 1 1 @@ -4587,6 +4657,7 @@ Dock 0 Left + 0 1 1 @@ -4652,6 +4723,7 @@ Dock 0 Left + 0 1 1 @@ -4725,10 +4797,11 @@ Dock 0 Left + 0 1 1 - ,90,400,11,70,0 + ,90,400,-1,70,0 0 0 wxID_ANY diff --git a/pcbnew/teardrop/dialog_teardrop_base.h b/pcbnew/teardrop/dialog_teardrop_base.h index e83e4f97c4..b3df2d8f0c 100644 --- a/pcbnew/teardrop/dialog_teardrop_base.h +++ b/pcbnew/teardrop/dialog_teardrop_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) +// C++ code generated with wxFormBuilder (version 3.10.1-282-g1fa54006) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! diff --git a/pcbnew/teardrop/teardrop.cpp b/pcbnew/teardrop/teardrop.cpp index 129eb0b598..13d653f611 100644 --- a/pcbnew/teardrop/teardrop.cpp +++ b/pcbnew/teardrop/teardrop.cpp @@ -37,18 +37,22 @@ #include #include +#include + #include // The first priority level of a teardrop area (arbitrary value) #define MAGIC_TEARDROP_ZONE_ID 30000 -TEARDROP_MANAGER::TEARDROP_MANAGER( BOARD* aBoard, PCB_EDIT_FRAME* aFrame ) +TEARDROP_MANAGER::TEARDROP_MANAGER( BOARD* aBoard, PCB_EDIT_FRAME* aFrame, PROGRESS_REPORTER* aReporter ) { + m_frame = aFrame; + m_reporter = aReporter; m_board = aBoard; m_prmsList = m_board->GetDesignSettings().GetTeadropParamsList(); m_tolerance = 0; - m_toolManager = aFrame->GetToolManager(); + m_toolManager = m_frame->GetToolManager(); } @@ -204,42 +208,46 @@ int TEARDROP_MANAGER::SetTeardrops( BOARD_COMMIT* aCommitter, bool aFollowTracks if( count || removed_cnt || track2trackCount ) { - if( aCommitter ) - aCommitter->Push( _( "Add teardrops" ) ); - // Note: // Refill zones can be made only with clean data, especially connectivity data, // therefore only after changes are pushed to avoid crashes in some cases + // + // Fill raw teardrop shapes, even if aFillAfter is true: it ensure teardrops + // will be filled even when undoing refilling zones. + // This is a rough calculation, just to show a filled + // shape on screen without the (potentially large) performance hit of a zone refill + int epsilon = pcbIUScale.mmToIU( 0.001 ); + int allowed_error = pcbIUScale.mmToIU( 0.005 ); + + for( ZONE* zone: m_createdTdList ) + { + int half_min_width = zone->GetMinThickness() / 2; + int numSegs = GetArcToSegmentCount( half_min_width, allowed_error, FULL_CIRCLE ); + SHAPE_POLY_SET filledPolys = *zone->Outline(); + + filledPolys.Deflate( half_min_width - epsilon, numSegs ); + + // Re-inflate after pruning of areas that don't meet minimum-width criteria + if( half_min_width - epsilon > epsilon ) + filledPolys.Inflate( half_min_width - epsilon, numSegs ); + + zone->SetFilledPolysList( zone->GetFirstLayer(), filledPolys ); + } + + if( aCommitter ) + aCommitter->Push( _( "Add teardrops" ) ); if( aFillAfter ) { ZONE_FILLER filler( m_board, aCommitter ); + + if( m_reporter ) + filler.SetProgressReporter( m_reporter ); + filler.Fill( m_board->Zones() ); if( aCommitter ) - aCommitter->Push( _( "Refill zones" ) ); - } - else - { - // Fill raw teardrop shapes. This is a rough calculation, just to show a filled - // shape on screen without the (potentially large) performance hit of a zone refill - int epsilon = pcbIUScale.mmToIU( 0.001 ); - int allowed_error = pcbIUScale.mmToIU( 0.005 ); - - for( ZONE* zone: m_createdTdList ) - { - int half_min_width = zone->GetMinThickness() / 2; - int numSegs = GetArcToSegmentCount( half_min_width, allowed_error, FULL_CIRCLE ); - SHAPE_POLY_SET filledPolys = *zone->Outline(); - - filledPolys.Deflate( half_min_width - epsilon, numSegs ); - - // Re-inflate after pruning of areas that don't meet minimum-width criteria - if( half_min_width - epsilon > epsilon ) - filledPolys.Inflate( half_min_width - epsilon, numSegs ); - - zone->SetFilledPolysList( zone->GetFirstLayer(), filledPolys ); - } + aCommitter->Push( _( "Add teardrops and refill zones" ) ); } } diff --git a/pcbnew/teardrop/teardrop.h b/pcbnew/teardrop/teardrop.h index e36828615a..b16d977b02 100644 --- a/pcbnew/teardrop/teardrop.h +++ b/pcbnew/teardrop/teardrop.h @@ -37,6 +37,7 @@ #define MAGIC_TEARDROP_TRACK_NAME "$teardrop_track$" class TRACK_BUFFER; +class PROGRESS_REPORTER; /** * Stores info of a pad, via or track end to build a teardrop @@ -87,7 +88,13 @@ public: TD_TYPE_TRACKEND // specify a teardrop on a rond end of a wide track }; - TEARDROP_MANAGER( BOARD* aBoard, PCB_EDIT_FRAME* aFrame ); + /** + * TEARDROP_MANAGER Ctor + * @param aBoard is the board to manage + * @param aFrame is the board editor frame + * @param aReporter optional: used to show a progrss bar when refilling zones + */ + TEARDROP_MANAGER( BOARD* aBoard, PCB_EDIT_FRAME* aFrame, PROGRESS_REPORTER* aReporter = nullptr ); /** * Set teardrops on a teardrop free board @@ -249,6 +256,8 @@ private: TOOL_MANAGER* m_toolManager; TEARDROP_PARAMETERS_LIST* m_prmsList; // the teardrop parameters list, from the board design settings std::vector m_createdTdList; // list of new created teardrops + PCB_EDIT_FRAME* m_frame; + PROGRESS_REPORTER* m_reporter; // A reporter to show a progress bar if refilling zones };