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 <class_board.h>
40 #include <class_track.h>
41 #include <class_zone.h>
42 
43 #include <pcbnew.h>
44 #include <zones.h>
45 
46 #include <connectivity_data.h>
47 #include <board_commit.h>
48 
50 #include <zone_filler.h>
51 
52 
63 {
64  bool modify = false;
65  timestamp_t TimeStamp;
66 
67  if( aZone == NULL )
68  TimeStamp = aTimestamp;
69  else
70  TimeStamp = aZone->GetTimeStamp(); // Save reference time stamp (aZone will be deleted)
71 
72  SEGZONE* next;
73 
74  for( SEGZONE* zone = GetBoard()->m_Zone; zone != NULL; zone = next )
75  {
76  next = zone->Next();
77 
78  if( zone->GetTimeStamp() == TimeStamp )
79  {
80  modify = true;
81  // remove item from linked list and free memory
82  zone->DeleteStructure();
83  }
84  }
85 
86  if( modify )
87  {
88  OnModify();
89  m_canvas->Refresh();
90  }
91 }
92 
93 int PCB_EDIT_FRAME::Fill_All_Zones( wxWindow * aActiveWindow )
94 {
95  wxBusyCursor dummy;
96 
97  std::vector<ZONE_CONTAINER*> toFill;
98 
99  for( auto zone : GetBoard()->Zones() )
100  {
101  toFill.push_back(zone);
102  }
103 
104  ZONE_FILLER filler( GetBoard() );
105 
106  std::unique_ptr<WX_PROGRESS_REPORTER> progressReporter(
107  new WX_PROGRESS_REPORTER( aActiveWindow, _( "Fill All Zones" ), 3 ) );
108 
109  filler.SetProgressReporter( progressReporter.get() );
110  filler.Fill( toFill );
111 
112  return 0;
113 }
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:173
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:339
Class BOARD to handle a board.
Class that computes missing connections on a PCB.
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(PROGRESS_REPORTER *aReporter)
Definition: zone_filler.cpp:77
void Fill(std::vector< ZONE_CONTAINER * > aZones)
Definition: zone_filler.cpp:82
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
see class PGM_BASE
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
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:233