KiCad PCB EDA Suite
zones_by_polygon_fill_functions.cpp
Go to the documentation of this file.
1 /*
2  * @file zones_by_polygon_fill_functions.cpp
3  */
4 
5 /*
6  * This program source code file is part of KiCad, a free EDA CAD application.
7  *
8  * Copyright (C) 2009 Jean-Pierre Charras jp.charras at wanadoo.fr
9  * Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, you may find one here:
23  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
24  * or you may search the http://www.gnu.org website for the version 2 license,
25  * or you may write to the Free Software Foundation, Inc.,
26  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
27  */
28 
29 #include <wx/progdlg.h>
30 
31 #include <fctsys.h>
32 #include <pgm_base.h>
33 #include <class_drawpanel.h>
34 #include <class_draw_panel_gal.h>
35 #include <ratsnest_data.h>
36 #include <pcb_edit_frame.h>
37 #include <macros.h>
38 
39 #include <tool/tool_manager.h>
40 #include <tools/pcb_actions.h>
41 
42 #include <class_board.h>
43 #include <class_track.h>
44 #include <class_zone.h>
45 
46 #include <pcbnew.h>
47 #include <zones.h>
48 
49 #include <board_commit.h>
50 
52 #include <zone_filler.h>
53 
54 
56 {
57  auto toolMgr = GetToolManager();
58  toolMgr->RunAction( PCB_ACTIONS::zoneFillAll, true );
59 }
60 
61 
62 void PCB_EDIT_FRAME::Check_All_Zones( wxWindow* aActiveWindow )
63 {
64  if( !m_ZoneFillsDirty )
65  return;
66 
67  std::vector<ZONE_CONTAINER*> toFill;
68 
69  for( auto zone : GetBoard()->Zones() )
70  toFill.push_back(zone);
71 
72  BOARD_COMMIT commit( this );
73 
74  std::unique_ptr<WX_PROGRESS_REPORTER> progressReporter(
75  new WX_PROGRESS_REPORTER( aActiveWindow, _( "Checking Zones" ), 4 ) );
76 
77  ZONE_FILLER filler( GetBoard(), &commit );
78  filler.SetProgressReporter( progressReporter.get() );
79 
80  if( filler.Fill( toFill, true ) )
81  {
82  m_ZoneFillsDirty = false;
83 
84  if( IsGalCanvasActive() && GetGalCanvas() )
86 
87  GetCanvas()->Refresh();
88  }
89 }
void ForceRefresh()
Function ForceRefresh() Forces a redraw.
static TOOL_ACTION zoneFillAll
Definition: pcb_actions.h:251
Class BOARD to handle a board.
Class that computes missing connections on a PCB.
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:931
void Check_All_Zones(wxWindow *aActiveWindow)
Function Check_All_Zones Checks for out-of-date fills and fills them if requested by the user.
Classes to handle copper zones.
Functions relatives to tracks, vias and segments used to fill zones.
This file contains miscellaneous commonly used macros and functions.
bool IsGalCanvasActive() const
Function IsGalCanvasActive is used to check which canvas (GAL-based or standard) is currently in use.
Definition: draw_frame.h:924
void SetProgressReporter(WX_PROGRESS_REPORTER *aReporter)
Definition: zone_filler.cpp:97
TOOL_MANAGER * GetToolManager() const override
Return the tool manager instance, if any.
Definition: draw_frame.h:937
bool Fill(const std::vector< ZONE_CONTAINER * > &aZones, bool aCheck=false)
virtual EDA_DRAW_PANEL * GetCanvas() const
Definition: draw_frame.h:399
void Fill_All_Zones()
Function Fill_All_Zones.
see class PGM_BASE
BOARD * GetBoard() const
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL)