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 <connectivity_data.h>
50 #include <board_commit.h>
51 
53 #include <zone_filler.h>
54 
55 
66 {
67  bool modify = false;
68  timestamp_t TimeStamp;
69 
70  if( aZone == NULL )
71  TimeStamp = aTimestamp;
72  else
73  TimeStamp = aZone->GetTimeStamp(); // Save reference time stamp (aZone will be deleted)
74 
75  SEGZONE* next;
76 
77  for( SEGZONE* zone = GetBoard()->m_Zone; zone != NULL; zone = next )
78  {
79  next = zone->Next();
80 
81  if( zone->GetTimeStamp() == TimeStamp )
82  {
83  modify = true;
84  // remove item from linked list and free memory
85  zone->DeleteStructure();
86  }
87  }
88 
89  if( modify )
90  {
91  OnModify();
92  m_canvas->Refresh();
93  }
94 }
95 
96 
97 int PCB_EDIT_FRAME::Fill_All_Zones( wxWindow* aActiveWindow )
98 {
99  auto toolMgr = GetToolManager();
100  wxCHECK( toolMgr, 1 );
101  toolMgr->RunAction( PCB_ACTIONS::zoneFillAll, true );
102  return 0;
103 }
104 
105 
106 void PCB_EDIT_FRAME::Check_All_Zones( wxWindow* aActiveWindow )
107 {
108  std::vector<ZONE_CONTAINER*> toFill;
109 
110  for( auto zone : GetBoard()->Zones() )
111  toFill.push_back(zone);
112 
113  BOARD_COMMIT commit( this );
114 
115  std::unique_ptr<WX_PROGRESS_REPORTER> progressReporter(
116  new WX_PROGRESS_REPORTER( aActiveWindow, _( "Checking Zones" ), 3 ) );
117 
118  ZONE_FILLER filler( GetBoard(), &commit );
119  filler.SetProgressReporter( progressReporter.get() );
120  filler.Fill( toFill, true );
121 }
CITER next(CITER it)
Definition: ptree.cpp:130
long timestamp_t
timestamp_t is our type to represent unique IDs for all kinds of elements; historically simply the ti...
Definition: base_struct.h:155
virtual void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:338
static TOOL_ACTION zoneFillAll
Definition: pcb_actions.h:295
void Fill(std::vector< ZONE_CONTAINER * > aZones, bool aCheck=false)
Definition: zone_filler.cpp:84
Class BOARD to handle a board.
Class that computes missing connections on a PCB.
void Check_All_Zones(wxWindow *aActiveWindow)
Function Check_All_Zones Checks for out-of-date fills and fills them if requested by the user...
void DeleteStructure()
Function DeleteStructure deletes this object after UnLink()ing it from its owner if it has one...
BOARD * GetBoard() const
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.
SEGZONE * Next() const
Definition: class_track.h:361
void SetProgressReporter(WX_PROGRESS_REPORTER *aReporter)
Definition: zone_filler.cpp:79
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:98
TOOL_MANAGER * GetToolManager() const
Function GetToolManager returns the tool manager instance, if any.
Definition: draw_frame.h:902
see class PGM_BASE
int Fill_All_Zones(wxWindow *aActiveWindow)
Function Fill_All_Zones Fill all zones on the board The old fillings are removed. ...
void Delete_OldZone_Fill(SEGZONE *aZone, timestamp_t aTimestamp=0)
Function Delete_OldZone_Fill (obsolete) Used for compatibility with old boards Remove the zone fillin...
timestamp_t GetTimeStamp() const
Definition: base_struct.h:215