Cleanup and a big hack to prevent keyboard focus loss.
Fixes: lp:1810993 * https://bugs.launchpad.net/kicad/+bug/1810993
This commit is contained in:
parent
e32306c232
commit
183687c69e
|
@ -291,7 +291,6 @@ set( PCBNEW_CLASS_SRCS
|
||||||
undo_redo.cpp
|
undo_redo.cpp
|
||||||
zone_filler.cpp
|
zone_filler.cpp
|
||||||
zones_by_polygon.cpp
|
zones_by_polygon.cpp
|
||||||
zones_by_polygon_fill_functions.cpp
|
|
||||||
zones_functions_for_undo_redo.cpp
|
zones_functions_for_undo_redo.cpp
|
||||||
zones_test_and_combine_areas.cpp
|
zones_test_and_combine_areas.cpp
|
||||||
|
|
||||||
|
|
|
@ -30,13 +30,15 @@
|
||||||
#include <gerber_jobfile_writer.h>
|
#include <gerber_jobfile_writer.h>
|
||||||
#include <reporter.h>
|
#include <reporter.h>
|
||||||
#include <wildcards_and_files_ext.h>
|
#include <wildcards_and_files_ext.h>
|
||||||
#include <tool/tool_manager.h>
|
#include <layers_id_colors_and_visibility.h>
|
||||||
#include <bitmaps.h>
|
#include <bitmaps.h>
|
||||||
#include <class_board.h>
|
#include <class_board.h>
|
||||||
#include <dialog_plot.h>
|
#include <dialog_plot.h>
|
||||||
#include <dialog_gendrill.h>
|
#include <dialog_gendrill.h>
|
||||||
#include <wx_html_report_panel.h>
|
#include <wx_html_report_panel.h>
|
||||||
|
#include <tool/tool_manager.h>
|
||||||
#include <tools/drc.h>
|
#include <tools/drc.h>
|
||||||
|
#include <tools/zone_filler_tool.h>
|
||||||
|
|
||||||
|
|
||||||
DIALOG_PLOT::DIALOG_PLOT( PCB_EDIT_FRAME* aParent ) :
|
DIALOG_PLOT::DIALOG_PLOT( PCB_EDIT_FRAME* aParent ) :
|
||||||
|
@ -221,7 +223,6 @@ void DIALOG_PLOT::OnRightClick( wxMouseEvent& event )
|
||||||
|
|
||||||
|
|
||||||
// Select or deselect groups of layers in the layers list:
|
// Select or deselect groups of layers in the layers list:
|
||||||
#include <layers_id_colors_and_visibility.h>
|
|
||||||
void DIALOG_PLOT::OnPopUpLayers( wxCommandEvent& event )
|
void DIALOG_PLOT::OnPopUpLayers( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
// Build a list of layers for usual fabrication:
|
// Build a list of layers for usual fabrication:
|
||||||
|
@ -740,7 +741,7 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_zoneFillCheck->GetValue() )
|
if( m_zoneFillCheck->GetValue() )
|
||||||
m_parent->Check_All_Zones( this );
|
m_parent->GetToolManager()->GetTool<ZONE_FILLER_TOOL>()->CheckAllZones( this );
|
||||||
|
|
||||||
m_plotOpts.SetAutoScale( false );
|
m_plotOpts.SetAutoScale( false );
|
||||||
m_plotOpts.SetScale( 1 );
|
m_plotOpts.SetScale( 1 );
|
||||||
|
|
|
@ -863,20 +863,6 @@ public:
|
||||||
bool aUseNetclassValue );
|
bool aUseNetclassValue );
|
||||||
|
|
||||||
|
|
||||||
// zone handling
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function Fill_All_Zones
|
|
||||||
*/
|
|
||||||
void Fill_All_Zones();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function Check_All_Zones
|
|
||||||
* Checks for out-of-date fills and fills them if requested by the user.
|
|
||||||
* @param aActiveWindow
|
|
||||||
*/
|
|
||||||
void Check_All_Zones( wxWindow* aActiveWindow );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Edit_Zone_Params
|
* Function Edit_Zone_Params
|
||||||
* Edit params (layer, clearance, ...) for a zone outline
|
* Edit params (layer, clearance, ...) for a zone outline
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
#include <geometry/shape_arc.h>
|
#include <geometry/shape_arc.h>
|
||||||
|
|
||||||
#include <drc/courtyard_overlap.h>
|
#include <drc/courtyard_overlap.h>
|
||||||
|
#include "zone_filler_tool.h"
|
||||||
|
|
||||||
DRC::DRC() :
|
DRC::DRC() :
|
||||||
PCB_TOOL_BASE( "pcbnew.DRCTool" )
|
PCB_TOOL_BASE( "pcbnew.DRCTool" )
|
||||||
|
@ -393,14 +393,14 @@ void DRC::RunTests( wxTextCtrl* aMessages )
|
||||||
if( aMessages )
|
if( aMessages )
|
||||||
aMessages->AppendText( _( "Refilling all zones...\n" ) );
|
aMessages->AppendText( _( "Refilling all zones...\n" ) );
|
||||||
|
|
||||||
m_pcbEditorFrame->Fill_All_Zones();
|
m_toolMgr->GetTool<ZONE_FILLER_TOOL>()->FillAllZones( caller );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( aMessages )
|
if( aMessages )
|
||||||
aMessages->AppendText( _( "Checking zone fills...\n" ) );
|
aMessages->AppendText( _( "Checking zone fills...\n" ) );
|
||||||
|
|
||||||
m_pcbEditorFrame->Check_All_Zones( caller );
|
m_toolMgr->GetTool<ZONE_FILLER_TOOL>()->CheckAllZones( caller );
|
||||||
}
|
}
|
||||||
|
|
||||||
// test track and via clearances to other tracks, pads, and vias
|
// test track and via clearances to other tracks, pads, and vias
|
||||||
|
|
|
@ -24,13 +24,9 @@
|
||||||
*/
|
*/
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <mutex>
|
|
||||||
|
|
||||||
#include <class_zone.h>
|
#include <class_zone.h>
|
||||||
#include <class_module.h>
|
|
||||||
#include <connectivity/connectivity_data.h>
|
#include <connectivity/connectivity_data.h>
|
||||||
#include <board_commit.h>
|
#include <board_commit.h>
|
||||||
|
|
||||||
#include <widgets/progress_reporter.h>
|
#include <widgets/progress_reporter.h>
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
#include <bitmaps.h>
|
#include <bitmaps.h>
|
||||||
|
@ -55,7 +51,60 @@ void ZONE_FILLER_TOOL::Reset( RESET_REASON aReason )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Zone actions
|
|
||||||
|
void ZONE_FILLER_TOOL::CheckAllZones( wxWindow* aCaller )
|
||||||
|
{
|
||||||
|
if( !getEditFrame<PCB_EDIT_FRAME>()->m_ZoneFillsDirty )
|
||||||
|
return;
|
||||||
|
|
||||||
|
std::vector<ZONE_CONTAINER*> toFill;
|
||||||
|
|
||||||
|
for( auto zone : board()->Zones() )
|
||||||
|
toFill.push_back(zone);
|
||||||
|
|
||||||
|
BOARD_COMMIT commit( this );
|
||||||
|
|
||||||
|
ZONE_FILLER filler( frame()->GetBoard(), &commit );
|
||||||
|
filler.SetProgressReporter( std::make_unique<WX_PROGRESS_REPORTER>( aCaller,
|
||||||
|
_( "Checking Zones" ),
|
||||||
|
4 ) );
|
||||||
|
|
||||||
|
if( filler.Fill( toFill, true ) )
|
||||||
|
{
|
||||||
|
getEditFrame<PCB_EDIT_FRAME>()->m_ZoneFillsDirty = false;
|
||||||
|
canvas()->Refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ZONE_FILLER_TOOL::FillAllZones( wxWindow* aCaller )
|
||||||
|
{
|
||||||
|
std::vector<ZONE_CONTAINER*> toFill;
|
||||||
|
|
||||||
|
BOARD_COMMIT commit( this );
|
||||||
|
|
||||||
|
for( auto zone : board()->Zones() )
|
||||||
|
toFill.push_back(zone);
|
||||||
|
|
||||||
|
ZONE_FILLER filler( board(), &commit );
|
||||||
|
filler.SetProgressReporter( std::make_unique<WX_PROGRESS_REPORTER>( aCaller,
|
||||||
|
_( "Fill All Zones" ),
|
||||||
|
4 ) );
|
||||||
|
|
||||||
|
if( filler.Fill( toFill ) )
|
||||||
|
getEditFrame<PCB_EDIT_FRAME>()->m_ZoneFillsDirty = false;
|
||||||
|
|
||||||
|
canvas()->Refresh();
|
||||||
|
|
||||||
|
// wxWidgets has keyboard focus issues after the progress reporter. Re-setting the focus
|
||||||
|
// does not fix them; moving the mouse does. Here we warp the mouse to its existing location
|
||||||
|
// (which will bring it back inside the window if it was outside). While sometimes mildly
|
||||||
|
// annoying, it does fix the more-often annoying loss of keybard focus.
|
||||||
|
VECTOR2D cursor = getViewControls()->GetRawCursorPosition( false );
|
||||||
|
getViewControls()->SetCursorPosition( cursor, true, true );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int ZONE_FILLER_TOOL::ZoneFill( const TOOL_EVENT& aEvent )
|
int ZONE_FILLER_TOOL::ZoneFill( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
std::vector<ZONE_CONTAINER*> toFill;
|
std::vector<ZONE_CONTAINER*> toFill;
|
||||||
|
@ -77,36 +126,19 @@ int ZONE_FILLER_TOOL::ZoneFill( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
ZONE_FILLER filler( board(), &commit );
|
ZONE_FILLER filler( board(), &commit );
|
||||||
filler.SetProgressReporter(
|
filler.SetProgressReporter( std::make_unique<WX_PROGRESS_REPORTER>( frame(),
|
||||||
std::make_unique<WX_PROGRESS_REPORTER>( frame(), _( "Fill Zone" ), 4 ) );
|
_( "Fill Zone" ),
|
||||||
|
4 ) );
|
||||||
filler.Fill( toFill );
|
filler.Fill( toFill );
|
||||||
|
|
||||||
canvas()->Refresh();
|
canvas()->Refresh();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ZONE_FILLER_TOOL::ZoneFillAll( const TOOL_EVENT& aEvent )
|
int ZONE_FILLER_TOOL::ZoneFillAll( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
std::vector<ZONE_CONTAINER*> toFill;
|
FillAllZones( frame() );
|
||||||
|
|
||||||
BOARD_COMMIT commit( this );
|
|
||||||
|
|
||||||
for( auto zone : board()->Zones() )
|
|
||||||
{
|
|
||||||
toFill.push_back(zone);
|
|
||||||
}
|
|
||||||
|
|
||||||
ZONE_FILLER filler( board(), &commit );
|
|
||||||
filler.SetProgressReporter(
|
|
||||||
std::make_unique<WX_PROGRESS_REPORTER>( frame(), _( "Fill All Zones" ), 4 ) );
|
|
||||||
|
|
||||||
if( filler.Fill( toFill ) )
|
|
||||||
getEditFrame<PCB_EDIT_FRAME>()->m_ZoneFillsDirty = false;
|
|
||||||
|
|
||||||
canvas()->Refresh();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,9 @@ public:
|
||||||
/// @copydoc TOOL_INTERACTIVE::Reset()
|
/// @copydoc TOOL_INTERACTIVE::Reset()
|
||||||
void Reset( RESET_REASON aReason ) override;
|
void Reset( RESET_REASON aReason ) override;
|
||||||
|
|
||||||
// Zone actions
|
void CheckAllZones( wxWindow* aCaller );
|
||||||
|
void FillAllZones( wxWindow* aCaller );
|
||||||
|
|
||||||
int ZoneFill( const TOOL_EVENT& aEvent );
|
int ZoneFill( const TOOL_EVENT& aEvent );
|
||||||
int ZoneFillAll( const TOOL_EVENT& aEvent );
|
int ZoneFillAll( const TOOL_EVENT& aEvent );
|
||||||
int ZoneUnfill( const TOOL_EVENT& aEvent );
|
int ZoneUnfill( const TOOL_EVENT& aEvent );
|
||||||
|
|
|
@ -1,78 +0,0 @@
|
||||||
/*
|
|
||||||
* @file zones_by_polygon_fill_functions.cpp
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2009 Jean-Pierre Charras jp.charras at wanadoo.fr
|
|
||||||
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
|
|
||||||
*
|
|
||||||
* 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 <wx/progdlg.h>
|
|
||||||
#include <fctsys.h>
|
|
||||||
#include <pgm_base.h>
|
|
||||||
#include <class_draw_panel_gal.h>
|
|
||||||
#include <ratsnest_data.h>
|
|
||||||
#include <pcb_edit_frame.h>
|
|
||||||
#include <macros.h>
|
|
||||||
#include <tool/tool_manager.h>
|
|
||||||
#include <tools/pcb_actions.h>
|
|
||||||
#include <class_board.h>
|
|
||||||
#include <class_track.h>
|
|
||||||
#include <class_zone.h>
|
|
||||||
#include <pcbnew.h>
|
|
||||||
#include <zones.h>
|
|
||||||
#include <board_commit.h>
|
|
||||||
#include <widgets/progress_reporter.h>
|
|
||||||
#include <zone_filler.h>
|
|
||||||
|
|
||||||
|
|
||||||
void PCB_EDIT_FRAME::Fill_All_Zones()
|
|
||||||
{
|
|
||||||
auto toolMgr = GetToolManager();
|
|
||||||
toolMgr->RunAction( PCB_ACTIONS::zoneFillAll, true );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PCB_EDIT_FRAME::Check_All_Zones( wxWindow* aActiveWindow )
|
|
||||||
{
|
|
||||||
if( !m_ZoneFillsDirty )
|
|
||||||
return;
|
|
||||||
|
|
||||||
std::vector<ZONE_CONTAINER*> toFill;
|
|
||||||
|
|
||||||
for( auto zone : GetBoard()->Zones() )
|
|
||||||
toFill.push_back(zone);
|
|
||||||
|
|
||||||
BOARD_COMMIT commit( this );
|
|
||||||
|
|
||||||
std::unique_ptr<WX_PROGRESS_REPORTER> progressReporter(
|
|
||||||
new WX_PROGRESS_REPORTER( aActiveWindow, _( "Checking Zones" ), 4 ) );
|
|
||||||
|
|
||||||
ZONE_FILLER filler( GetBoard(), &commit );
|
|
||||||
filler.SetProgressReporter( progressReporter.get() );
|
|
||||||
|
|
||||||
if( filler.Fill( toFill, true ) )
|
|
||||||
{
|
|
||||||
m_ZoneFillsDirty = false;
|
|
||||||
GetCanvas()->ForceRefresh();
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue