2017-11-23 16:20:27 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014-2017 CERN
|
2023-01-16 15:07:24 +00:00
|
|
|
* Copyright (C) 2014-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2017-11-23 16:20:27 +00:00
|
|
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
#include <cstdint>
|
|
|
|
#include <thread>
|
2020-11-11 23:05:59 +00:00
|
|
|
#include <zone.h>
|
2018-10-12 06:17:15 +00:00
|
|
|
#include <connectivity/connectivity_data.h>
|
2017-11-23 16:20:27 +00:00
|
|
|
#include <board_commit.h>
|
2022-02-24 09:59:54 +00:00
|
|
|
#include <footprint.h>
|
2022-10-15 10:17:48 +00:00
|
|
|
#include <pcb_track.h>
|
|
|
|
#include <pad.h>
|
2022-02-24 09:59:54 +00:00
|
|
|
#include <pcb_group.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <board_design_settings.h>
|
2021-08-14 20:05:21 +00:00
|
|
|
#include <progress_reporter.h>
|
2022-12-28 22:03:03 +00:00
|
|
|
#include <widgets/wx_infobar.h>
|
2021-08-14 20:05:21 +00:00
|
|
|
#include <widgets/wx_progress_reporters.h>
|
2019-07-14 11:06:30 +00:00
|
|
|
#include <wx/event.h>
|
2020-10-16 11:20:37 +00:00
|
|
|
#include <wx/hyperlink.h>
|
2017-11-23 16:20:27 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2022-11-18 00:45:14 +00:00
|
|
|
#include <tool/actions.h>
|
2023-07-12 21:25:15 +00:00
|
|
|
#include <tools/pcb_selection_tool.h>
|
2017-11-23 16:20:27 +00:00
|
|
|
#include "pcb_actions.h"
|
|
|
|
#include "zone_filler_tool.h"
|
2017-11-30 16:22:45 +00:00
|
|
|
#include "zone_filler.h"
|
2023-05-12 21:03:54 +00:00
|
|
|
#include "teardrop/teardrop.h"
|
2023-09-07 11:22:10 +00:00
|
|
|
#include <core/profile.h>
|
2019-06-09 21:57:23 +00:00
|
|
|
|
2017-11-23 16:20:27 +00:00
|
|
|
ZONE_FILLER_TOOL::ZONE_FILLER_TOOL() :
|
2021-06-16 15:11:17 +00:00
|
|
|
PCB_TOOL_BASE( "pcbnew.ZoneFiller" ),
|
|
|
|
m_fillInProgress( false )
|
2017-11-23 16:20:27 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ZONE_FILLER_TOOL::~ZONE_FILLER_TOOL()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ZONE_FILLER_TOOL::Reset( RESET_REASON aReason )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-07-08 19:44:40 +00:00
|
|
|
|
2020-09-16 15:03:55 +00:00
|
|
|
void ZONE_FILLER_TOOL::CheckAllZones( wxWindow* aCaller, PROGRESS_REPORTER* aReporter )
|
2019-07-08 19:44:40 +00:00
|
|
|
{
|
2021-06-16 15:11:17 +00:00
|
|
|
if( !getEditFrame<PCB_EDIT_FRAME>()->m_ZoneFillsDirty || m_fillInProgress )
|
2019-07-08 19:44:40 +00:00
|
|
|
return;
|
|
|
|
|
2021-06-16 15:11:17 +00:00
|
|
|
m_fillInProgress = true;
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
std::vector<ZONE*> toFill;
|
2019-07-08 19:44:40 +00:00
|
|
|
|
2021-01-08 21:20:29 +00:00
|
|
|
for( ZONE* zone : board()->Zones() )
|
2022-02-24 09:59:54 +00:00
|
|
|
toFill.push_back( zone );
|
2019-07-08 19:44:40 +00:00
|
|
|
|
2021-08-14 20:05:21 +00:00
|
|
|
BOARD_COMMIT commit( this );
|
|
|
|
std::unique_ptr<WX_PROGRESS_REPORTER> reporter;
|
2023-01-16 15:07:24 +00:00
|
|
|
|
|
|
|
m_filler = std::make_unique<ZONE_FILLER>( frame()->GetBoard(), &commit );
|
2020-09-14 17:54:14 +00:00
|
|
|
|
|
|
|
if( aReporter )
|
2021-08-14 20:05:21 +00:00
|
|
|
{
|
2023-01-16 15:07:24 +00:00
|
|
|
m_filler->SetProgressReporter( aReporter );
|
2021-08-14 20:05:21 +00:00
|
|
|
}
|
2020-09-14 17:54:14 +00:00
|
|
|
else
|
2021-08-14 20:05:21 +00:00
|
|
|
{
|
|
|
|
reporter = std::make_unique<WX_PROGRESS_REPORTER>( aCaller, _( "Checking Zones" ), 4 );
|
2023-01-16 15:07:24 +00:00
|
|
|
m_filler->SetProgressReporter( reporter.get() );
|
2021-08-14 20:05:21 +00:00
|
|
|
}
|
2019-07-08 19:44:40 +00:00
|
|
|
|
2023-01-16 15:07:24 +00:00
|
|
|
if( m_filler->Fill( toFill, true, aCaller ) )
|
2019-07-08 19:44:40 +00:00
|
|
|
{
|
2022-02-25 13:05:25 +00:00
|
|
|
commit.Push( _( "Fill Zone(s)" ), SKIP_CONNECTIVITY | ZONE_FILL_OP );
|
2019-07-08 19:44:40 +00:00
|
|
|
getEditFrame<PCB_EDIT_FRAME>()->m_ZoneFillsDirty = false;
|
|
|
|
}
|
2020-08-12 16:39:57 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
commit.Revert();
|
|
|
|
}
|
|
|
|
|
2022-11-30 12:18:58 +00:00
|
|
|
rebuildConnectivity();
|
2022-10-15 10:17:48 +00:00
|
|
|
refresh();
|
|
|
|
|
2021-06-16 15:11:17 +00:00
|
|
|
m_fillInProgress = false;
|
2023-01-16 15:07:24 +00:00
|
|
|
m_filler.reset( nullptr );
|
2019-07-08 19:44:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-14 11:06:30 +00:00
|
|
|
void ZONE_FILLER_TOOL::singleShotRefocus( wxIdleEvent& )
|
|
|
|
{
|
|
|
|
canvas()->SetFocus();
|
|
|
|
canvas()->Unbind( wxEVT_IDLE, &ZONE_FILLER_TOOL::singleShotRefocus, this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-16 15:03:55 +00:00
|
|
|
void ZONE_FILLER_TOOL::FillAllZones( wxWindow* aCaller, PROGRESS_REPORTER* aReporter )
|
2019-07-08 19:44:40 +00:00
|
|
|
{
|
2021-06-16 15:11:17 +00:00
|
|
|
if( m_fillInProgress )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_fillInProgress = true;
|
|
|
|
|
2023-05-12 21:03:54 +00:00
|
|
|
PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
|
|
|
|
BOARD_COMMIT commit( this );
|
|
|
|
std::unique_ptr<WX_PROGRESS_REPORTER> reporter;
|
|
|
|
TEARDROP_MANAGER teardropMgr( board(), m_toolMgr );
|
|
|
|
std::vector<ZONE*> toFill;
|
|
|
|
|
|
|
|
teardropMgr.UpdateTeardrops( commit, nullptr, nullptr, true /* forceFullUpdate */ );
|
2019-07-08 19:44:40 +00:00
|
|
|
|
2021-03-25 17:19:29 +00:00
|
|
|
board()->IncrementTimeStamp(); // Clear caches
|
|
|
|
|
2023-05-12 21:03:54 +00:00
|
|
|
for( ZONE* zone : board()->Zones() )
|
|
|
|
toFill.push_back( zone );
|
2023-01-16 15:07:24 +00:00
|
|
|
|
|
|
|
m_filler = std::make_unique<ZONE_FILLER>( board(), &commit );
|
2020-09-14 17:54:14 +00:00
|
|
|
|
2020-10-16 11:20:37 +00:00
|
|
|
if( !board()->GetDesignSettings().m_DRCEngine->RulesValid() )
|
|
|
|
{
|
2021-03-25 17:19:29 +00:00
|
|
|
WX_INFOBAR* infobar = frame->GetInfoBar();
|
2022-02-14 17:19:28 +00:00
|
|
|
wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, _( "Show DRC rules" ),
|
2020-10-16 11:20:37 +00:00
|
|
|
wxEmptyString );
|
|
|
|
|
2021-03-25 17:19:29 +00:00
|
|
|
button->Bind( wxEVT_COMMAND_HYPERLINK,
|
|
|
|
std::function<void( wxHyperlinkEvent& aEvent )>(
|
2022-02-17 12:48:29 +00:00
|
|
|
[frame]( wxHyperlinkEvent& aEvent )
|
|
|
|
{
|
|
|
|
frame->ShowBoardSetupDialog( _( "Rules" ) );
|
|
|
|
} ) );
|
2020-10-16 11:20:37 +00:00
|
|
|
|
2020-10-16 16:07:59 +00:00
|
|
|
infobar->RemoveAllButtons();
|
|
|
|
infobar->AddButton( button );
|
|
|
|
|
2020-10-16 11:20:37 +00:00
|
|
|
infobar->ShowMessageFor( _( "Zone fills may be inaccurate. DRC rules contain errors." ),
|
|
|
|
10000, wxICON_WARNING );
|
|
|
|
}
|
|
|
|
|
2020-09-14 17:54:14 +00:00
|
|
|
if( aReporter )
|
2021-08-14 20:05:21 +00:00
|
|
|
{
|
2023-01-16 15:07:24 +00:00
|
|
|
m_filler->SetProgressReporter( aReporter );
|
2021-08-14 20:05:21 +00:00
|
|
|
}
|
2020-09-14 17:54:14 +00:00
|
|
|
else
|
2021-08-14 20:05:21 +00:00
|
|
|
{
|
2022-02-14 17:19:28 +00:00
|
|
|
reporter = std::make_unique<WX_PROGRESS_REPORTER>( aCaller, _( "Fill All Zones" ), 5 );
|
2023-01-16 15:07:24 +00:00
|
|
|
m_filler->SetProgressReporter( reporter.get() );
|
2021-08-14 20:05:21 +00:00
|
|
|
}
|
2019-07-08 19:44:40 +00:00
|
|
|
|
2023-01-16 15:07:24 +00:00
|
|
|
if( m_filler->Fill( toFill ) )
|
2020-08-12 16:39:57 +00:00
|
|
|
{
|
2023-01-16 15:07:24 +00:00
|
|
|
m_filler->GetProgressReporter()->AdvancePhase();
|
2022-02-17 08:21:14 +00:00
|
|
|
|
2022-02-25 13:05:25 +00:00
|
|
|
commit.Push( _( "Fill Zone(s)" ), SKIP_CONNECTIVITY | ZONE_FILL_OP );
|
2022-02-14 17:19:28 +00:00
|
|
|
frame->m_ZoneFillsDirty = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
commit.Revert();
|
2021-12-14 21:35:46 +00:00
|
|
|
}
|
2020-10-29 21:17:57 +00:00
|
|
|
|
2022-11-30 12:18:58 +00:00
|
|
|
rebuildConnectivity();
|
|
|
|
refresh();
|
2022-02-16 17:00:54 +00:00
|
|
|
|
2023-01-16 15:07:24 +00:00
|
|
|
if( m_filler->IsDebug() )
|
2022-02-14 17:19:28 +00:00
|
|
|
frame->UpdateUserInterface();
|
|
|
|
|
2021-06-16 15:11:17 +00:00
|
|
|
m_fillInProgress = false;
|
2023-01-16 15:07:24 +00:00
|
|
|
m_filler.reset( nullptr );
|
2019-07-08 19:44:40 +00:00
|
|
|
|
|
|
|
// wxWidgets has keyboard focus issues after the progress reporter. Re-setting the focus
|
2019-07-14 11:06:30 +00:00
|
|
|
// here doesn't work, so we delay it to an idle event.
|
|
|
|
canvas()->Bind( wxEVT_IDLE, &ZONE_FILLER_TOOL::singleShotRefocus, this );
|
2019-07-08 19:44:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-02-24 09:59:54 +00:00
|
|
|
int ZONE_FILLER_TOOL::ZoneFillDirty( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
|
|
|
|
std::vector<ZONE*> toFill;
|
|
|
|
|
|
|
|
for( ZONE* zone : board()->Zones() )
|
|
|
|
{
|
2023-12-02 20:15:43 +00:00
|
|
|
if( !zone->IsFilled() || m_dirtyZoneIDs.count( zone->m_Uuid ) )
|
2022-02-24 09:59:54 +00:00
|
|
|
toFill.push_back( zone );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( toFill.empty() )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if( m_fillInProgress )
|
|
|
|
return 0;
|
|
|
|
|
2022-11-29 21:08:53 +00:00
|
|
|
unsigned startTime = GetRunningMicroSecs();
|
2022-02-24 09:59:54 +00:00
|
|
|
m_fillInProgress = true;
|
|
|
|
|
|
|
|
m_dirtyZoneIDs.clear();
|
|
|
|
|
|
|
|
board()->IncrementTimeStamp(); // Clear caches
|
|
|
|
|
|
|
|
BOARD_COMMIT commit( this );
|
|
|
|
std::unique_ptr<WX_PROGRESS_REPORTER> reporter;
|
|
|
|
int pts = 0;
|
|
|
|
|
2023-01-16 15:07:24 +00:00
|
|
|
m_filler = std::make_unique<ZONE_FILLER>( board(), &commit );
|
|
|
|
|
2022-02-24 09:59:54 +00:00
|
|
|
if( !board()->GetDesignSettings().m_DRCEngine->RulesValid() )
|
|
|
|
{
|
|
|
|
WX_INFOBAR* infobar = frame->GetInfoBar();
|
|
|
|
wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, _( "Show DRC rules" ),
|
|
|
|
wxEmptyString );
|
|
|
|
|
|
|
|
button->Bind( wxEVT_COMMAND_HYPERLINK,
|
2022-02-25 13:26:37 +00:00
|
|
|
std::function<void( wxHyperlinkEvent& aLocEvent )>(
|
|
|
|
[frame]( wxHyperlinkEvent& aLocEvent )
|
2022-02-24 09:59:54 +00:00
|
|
|
{
|
|
|
|
frame->ShowBoardSetupDialog( _( "Rules" ) );
|
|
|
|
} ) );
|
|
|
|
|
|
|
|
infobar->RemoveAllButtons();
|
|
|
|
infobar->AddButton( button );
|
|
|
|
|
|
|
|
infobar->ShowMessageFor( _( "Zone fills may be inaccurate. DRC rules contain errors." ),
|
|
|
|
10000, wxICON_WARNING );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( ZONE* zone : toFill )
|
|
|
|
{
|
|
|
|
for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
|
|
|
|
pts += zone->GetFilledPolysList( layer )->FullPointCount();
|
|
|
|
|
|
|
|
if( pts > 1000 )
|
|
|
|
{
|
|
|
|
wxString title = wxString::Format( _( "Refill %d Zones" ), (int) toFill.size() );
|
|
|
|
|
|
|
|
reporter = std::make_unique<WX_PROGRESS_REPORTER>( frame, title, 5 );
|
2023-01-16 15:07:24 +00:00
|
|
|
m_filler->SetProgressReporter( reporter.get() );
|
2022-02-24 09:59:54 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-16 15:07:24 +00:00
|
|
|
if( m_filler->Fill( toFill ) )
|
2022-02-25 13:05:25 +00:00
|
|
|
commit.Push( _( "Auto-fill Zone(s)" ), APPEND_UNDO | SKIP_CONNECTIVITY | ZONE_FILL_OP );
|
2022-02-24 09:59:54 +00:00
|
|
|
else
|
|
|
|
commit.Revert();
|
|
|
|
|
2022-11-30 12:18:58 +00:00
|
|
|
rebuildConnectivity();
|
|
|
|
refresh();
|
2022-02-24 09:59:54 +00:00
|
|
|
|
2022-11-30 17:36:05 +00:00
|
|
|
if( GetRunningMicroSecs() - startTime > 3000000 ) // 3 seconds
|
2022-11-29 21:08:53 +00:00
|
|
|
{
|
|
|
|
WX_INFOBAR* infobar = frame->GetInfoBar();
|
|
|
|
|
|
|
|
wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, _( "Open Preferences" ),
|
|
|
|
wxEmptyString );
|
|
|
|
|
2022-11-29 23:12:39 +00:00
|
|
|
button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& )>(
|
|
|
|
[this]( wxHyperlinkEvent& )
|
2022-11-29 21:08:53 +00:00
|
|
|
{
|
|
|
|
getEditFrame<PCB_EDIT_FRAME>()->ShowPreferences( _( "Editing Options" ),
|
|
|
|
_( "PCB Editor" ) );
|
|
|
|
} ) );
|
|
|
|
|
|
|
|
infobar->RemoveAllButtons();
|
|
|
|
infobar->AddButton( button );
|
2022-11-30 17:36:05 +00:00
|
|
|
infobar->ShowMessageFor( _( "Automatic refill of zones can be turned off in Preferences "
|
|
|
|
"if it becomes too slow." ),
|
|
|
|
10000, wxICON_INFORMATION, WX_INFOBAR::MESSAGE_TYPE::GENERIC );
|
2022-11-29 21:08:53 +00:00
|
|
|
}
|
|
|
|
|
2023-01-16 15:07:24 +00:00
|
|
|
if( m_filler->IsDebug() )
|
2022-02-24 09:59:54 +00:00
|
|
|
frame->UpdateUserInterface();
|
|
|
|
|
|
|
|
m_fillInProgress = false;
|
2023-01-16 15:07:24 +00:00
|
|
|
m_filler.reset( nullptr );
|
2022-02-24 09:59:54 +00:00
|
|
|
|
|
|
|
// wxWidgets has keyboard focus issues after the progress reporter. Re-setting the focus
|
|
|
|
// here doesn't work, so we delay it to an idle event.
|
|
|
|
canvas()->Bind( wxEVT_IDLE, &ZONE_FILLER_TOOL::singleShotRefocus, this );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-29 17:22:25 +00:00
|
|
|
int ZONE_FILLER_TOOL::ZoneFill( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
if( m_fillInProgress )
|
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<ZONE*> toFill;
|
|
|
|
|
|
|
|
if( ZONE* passedZone = aEvent.Parameter<ZONE*>() )
|
|
|
|
{
|
|
|
|
toFill.push_back( passedZone );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-07-12 21:25:15 +00:00
|
|
|
const PCB_SELECTION& sel = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->RequestSelection(
|
|
|
|
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
|
|
|
|
{
|
|
|
|
} );
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : sel )
|
2022-11-29 17:22:25 +00:00
|
|
|
{
|
|
|
|
if( ZONE* zone = dynamic_cast<ZONE*>( item ) )
|
|
|
|
toFill.push_back( zone );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-12 21:25:15 +00:00
|
|
|
// Bail out of the filler if there is nothing to fill
|
|
|
|
if( toFill.empty() )
|
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_fillInProgress = true;
|
|
|
|
|
2022-11-29 17:22:25 +00:00
|
|
|
BOARD_COMMIT commit( this );
|
|
|
|
std::unique_ptr<WX_PROGRESS_REPORTER> reporter;
|
2023-01-16 15:07:24 +00:00
|
|
|
|
|
|
|
m_filler = std::make_unique<ZONE_FILLER>( board(), &commit );
|
2022-11-29 17:22:25 +00:00
|
|
|
|
|
|
|
reporter = std::make_unique<WX_PROGRESS_REPORTER>( frame(), _( "Fill Zone" ), 5 );
|
2023-01-16 15:07:24 +00:00
|
|
|
m_filler->SetProgressReporter( reporter.get() );
|
2022-11-29 17:22:25 +00:00
|
|
|
|
2023-01-16 15:07:24 +00:00
|
|
|
if( m_filler->Fill( toFill ) )
|
2022-11-29 17:22:25 +00:00
|
|
|
{
|
|
|
|
reporter->AdvancePhase();
|
|
|
|
commit.Push( _( "Fill Zone(s)" ), SKIP_CONNECTIVITY | ZONE_FILL_OP );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
commit.Revert();
|
|
|
|
}
|
|
|
|
|
2022-11-30 12:18:58 +00:00
|
|
|
rebuildConnectivity();
|
2022-11-29 17:22:25 +00:00
|
|
|
refresh();
|
|
|
|
|
|
|
|
m_fillInProgress = false;
|
2023-01-16 15:07:24 +00:00
|
|
|
m_filler.reset( nullptr );
|
2022-11-29 17:22:25 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-23 16:20:27 +00:00
|
|
|
int ZONE_FILLER_TOOL::ZoneFillAll( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2019-07-08 19:44:40 +00:00
|
|
|
FillAllZones( frame() );
|
2017-11-23 16:20:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-29 17:22:25 +00:00
|
|
|
int ZONE_FILLER_TOOL::ZoneUnfill( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
2023-07-12 21:25:15 +00:00
|
|
|
const PCB_SELECTION& sel = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->RequestSelection(
|
|
|
|
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
|
|
|
|
{
|
|
|
|
} );
|
|
|
|
|
|
|
|
std::vector<ZONE*> toUnfill;
|
2022-11-29 17:22:25 +00:00
|
|
|
|
2023-07-12 21:25:15 +00:00
|
|
|
for( EDA_ITEM* item : sel )
|
2022-11-29 17:22:25 +00:00
|
|
|
{
|
2023-07-12 21:25:15 +00:00
|
|
|
if( ZONE* zone = dynamic_cast<ZONE*>( item ) )
|
|
|
|
toUnfill.push_back( zone );
|
|
|
|
}
|
2022-11-29 17:22:25 +00:00
|
|
|
|
2023-07-12 21:25:15 +00:00
|
|
|
// Bail out if there are no zones
|
|
|
|
if( toUnfill.empty() )
|
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
return -1;
|
|
|
|
}
|
2022-11-29 17:22:25 +00:00
|
|
|
|
2023-07-12 21:25:15 +00:00
|
|
|
BOARD_COMMIT commit( this );
|
|
|
|
|
|
|
|
for( ZONE* zone : toUnfill )
|
|
|
|
{
|
2022-11-29 17:22:25 +00:00
|
|
|
commit.Modify( zone );
|
|
|
|
|
|
|
|
zone->UnFill();
|
|
|
|
}
|
|
|
|
|
|
|
|
commit.Push( _( "Unfill Zone" ), ZONE_FILL_OP );
|
|
|
|
|
|
|
|
refresh();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-23 16:20:27 +00:00
|
|
|
int ZONE_FILLER_TOOL::ZoneUnfillAll( const TOOL_EVENT& aEvent )
|
|
|
|
{
|
|
|
|
BOARD_COMMIT commit( this );
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
for( ZONE* zone : board()->Zones() )
|
2017-11-23 16:20:27 +00:00
|
|
|
{
|
|
|
|
commit.Modify( zone );
|
|
|
|
|
2021-03-19 19:32:44 +00:00
|
|
|
zone->UnFill();
|
2017-11-23 16:20:27 +00:00
|
|
|
}
|
|
|
|
|
2022-02-25 13:05:25 +00:00
|
|
|
commit.Push( _( "Unfill All Zones" ), ZONE_FILL_OP );
|
2022-10-15 10:17:48 +00:00
|
|
|
|
|
|
|
refresh();
|
2017-11-23 16:20:27 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-01-16 15:07:24 +00:00
|
|
|
PROGRESS_REPORTER* ZONE_FILLER_TOOL::GetProgressReporter()
|
|
|
|
{
|
|
|
|
if( m_fillInProgress && m_filler )
|
|
|
|
return m_filler->GetProgressReporter();
|
|
|
|
else
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-30 12:18:58 +00:00
|
|
|
void ZONE_FILLER_TOOL::rebuildConnectivity()
|
|
|
|
{
|
|
|
|
board()->BuildConnectivity();
|
|
|
|
m_toolMgr->PostEvent( EVENTS::ConnectivityChangedEvent );
|
|
|
|
canvas()->RedrawRatsnest();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-15 10:17:48 +00:00
|
|
|
void ZONE_FILLER_TOOL::refresh()
|
|
|
|
{
|
2022-12-24 17:04:34 +00:00
|
|
|
// Note: KIGFX::REPAINT isn't enough for things that go from invisible to visible as
|
|
|
|
// they won't be found in the view layer's itemset for re-painting.
|
|
|
|
canvas()->GetView()->UpdateAllItemsConditionally( KIGFX::ALL,
|
2022-10-15 10:17:48 +00:00
|
|
|
[&]( KIGFX::VIEW_ITEM* aItem ) -> bool
|
|
|
|
{
|
|
|
|
if( PCB_VIA* via = dynamic_cast<PCB_VIA*>( aItem ) )
|
|
|
|
{
|
|
|
|
return via->GetRemoveUnconnected();
|
|
|
|
}
|
|
|
|
else if( PAD* pad = dynamic_cast<PAD*>( aItem ) )
|
|
|
|
{
|
|
|
|
return pad->GetRemoveUnconnected();
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
} );
|
|
|
|
|
|
|
|
canvas()->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-14 23:39:08 +00:00
|
|
|
bool ZONE_FILLER_TOOL::IsZoneFillAction( const TOOL_EVENT* aEvent )
|
|
|
|
{
|
2023-01-15 18:09:20 +00:00
|
|
|
return aEvent->IsAction( &PCB_ACTIONS::zoneFill )
|
|
|
|
|| aEvent->IsAction( &PCB_ACTIONS::zoneFillAll )
|
|
|
|
|| aEvent->IsAction( &PCB_ACTIONS::zoneUnfill )
|
2022-11-14 23:39:08 +00:00
|
|
|
|| aEvent->IsAction( &PCB_ACTIONS::zoneUnfillAll );
|
2023-01-15 18:09:20 +00:00
|
|
|
|
|
|
|
// Don't include zoneFillDirty; that's a system action not a user action
|
2022-11-14 23:39:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-23 16:20:27 +00:00
|
|
|
void ZONE_FILLER_TOOL::setTransitions()
|
|
|
|
{
|
|
|
|
// Zone actions
|
2022-11-29 17:22:25 +00:00
|
|
|
Go( &ZONE_FILLER_TOOL::ZoneFill, PCB_ACTIONS::zoneFill.MakeEvent() );
|
|
|
|
Go( &ZONE_FILLER_TOOL::ZoneFillAll, PCB_ACTIONS::zoneFillAll.MakeEvent() );
|
|
|
|
Go( &ZONE_FILLER_TOOL::ZoneFillDirty, PCB_ACTIONS::zoneFillDirty.MakeEvent() );
|
|
|
|
Go( &ZONE_FILLER_TOOL::ZoneUnfill, PCB_ACTIONS::zoneUnfill.MakeEvent() );
|
|
|
|
Go( &ZONE_FILLER_TOOL::ZoneUnfillAll, PCB_ACTIONS::zoneUnfillAll.MakeEvent() );
|
2017-11-23 16:20:27 +00:00
|
|
|
}
|