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
|
2022-02-17 08:21:14 +00:00
|
|
|
* Copyright (C) 2014-2022 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>
|
2020-10-16 11:20:37 +00:00
|
|
|
#include <widgets/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>
|
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"
|
2022-11-29 21:08:53 +00:00
|
|
|
#include <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;
|
|
|
|
ZONE_FILLER filler( frame()->GetBoard(), &commit );
|
2020-09-14 17:54:14 +00:00
|
|
|
|
|
|
|
if( aReporter )
|
2021-08-14 20:05:21 +00:00
|
|
|
{
|
2020-09-14 17:54:14 +00:00
|
|
|
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 );
|
|
|
|
filler.SetProgressReporter( reporter.get() );
|
|
|
|
}
|
2019-07-08 19:44:40 +00:00
|
|
|
|
2020-09-16 15:03:55 +00:00
|
|
|
if( 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;
|
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-03-25 17:19:29 +00:00
|
|
|
PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
|
2020-11-11 23:05:59 +00:00
|
|
|
std::vector<ZONE*> toFill;
|
2019-07-08 19:44:40 +00:00
|
|
|
|
2021-06-16 15:11:17 +00:00
|
|
|
if( m_fillInProgress )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_fillInProgress = true;
|
|
|
|
|
2020-11-11 23:05:59 +00:00
|
|
|
for( ZONE* zone : board()->Zones() )
|
2020-09-21 19:20:20 +00:00
|
|
|
toFill.push_back( zone );
|
2019-07-08 19:44:40 +00:00
|
|
|
|
2021-03-25 17:19:29 +00:00
|
|
|
board()->IncrementTimeStamp(); // Clear caches
|
|
|
|
|
2021-08-14 20:05:21 +00:00
|
|
|
BOARD_COMMIT commit( this );
|
|
|
|
std::unique_ptr<WX_PROGRESS_REPORTER> reporter;
|
|
|
|
ZONE_FILLER 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
|
|
|
{
|
2020-09-14 17:54:14 +00:00
|
|
|
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 );
|
2021-08-14 20:05:21 +00:00
|
|
|
filler.SetProgressReporter( reporter.get() );
|
|
|
|
}
|
2019-07-08 19:44:40 +00:00
|
|
|
|
2022-02-14 17:19:28 +00:00
|
|
|
if( filler.Fill( toFill ) )
|
2020-08-12 16:39:57 +00:00
|
|
|
{
|
2022-02-17 12:48:29 +00:00
|
|
|
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
|
|
|
|
2022-02-14 17:19:28 +00:00
|
|
|
if( filler.IsDebug() )
|
|
|
|
frame->UpdateUserInterface();
|
|
|
|
|
2021-06-16 15:11:17 +00:00
|
|
|
m_fillInProgress = false;
|
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() )
|
|
|
|
{
|
|
|
|
if( m_dirtyZoneIDs.count( zone->m_Uuid ) )
|
|
|
|
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;
|
|
|
|
ZONE_FILLER filler( board(), &commit );
|
|
|
|
int pts = 0;
|
|
|
|
|
|
|
|
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 );
|
|
|
|
filler.SetProgressReporter( reporter.get() );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( 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
|
|
|
}
|
|
|
|
|
2022-02-24 09:59:54 +00:00
|
|
|
if( filler.IsDebug() )
|
|
|
|
frame->UpdateUserInterface();
|
|
|
|
|
|
|
|
m_fillInProgress = false;
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_fillInProgress = true;
|
|
|
|
|
|
|
|
std::vector<ZONE*> toFill;
|
|
|
|
|
|
|
|
if( ZONE* passedZone = aEvent.Parameter<ZONE*>() )
|
|
|
|
{
|
|
|
|
toFill.push_back( passedZone );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for( EDA_ITEM* item : selection() )
|
|
|
|
{
|
|
|
|
if( ZONE* zone = dynamic_cast<ZONE*>( item ) )
|
|
|
|
toFill.push_back( zone );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BOARD_COMMIT commit( this );
|
|
|
|
std::unique_ptr<WX_PROGRESS_REPORTER> reporter;
|
|
|
|
ZONE_FILLER filler( board(), &commit );
|
|
|
|
|
|
|
|
reporter = std::make_unique<WX_PROGRESS_REPORTER>( frame(), _( "Fill Zone" ), 5 );
|
|
|
|
filler.SetProgressReporter( reporter.get() );
|
|
|
|
|
|
|
|
if( filler.Fill( toFill ) )
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
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 )
|
|
|
|
{
|
|
|
|
BOARD_COMMIT commit( this );
|
|
|
|
|
|
|
|
for( EDA_ITEM* item : selection() )
|
|
|
|
{
|
|
|
|
assert( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T );
|
|
|
|
|
|
|
|
ZONE* zone = static_cast<ZONE*>( item );
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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 )
|
|
|
|
{
|
|
|
|
return aEvent->IsAction( &PCB_ACTIONS::zoneFillAll )
|
|
|
|
|| aEvent->IsAction( &PCB_ACTIONS::zoneFillDirty )
|
|
|
|
|| aEvent->IsAction( &PCB_ACTIONS::zoneUnfillAll );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|