KiCad PCB EDA Suite
zones_by_polygon.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
7  * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
31 #include <fctsys.h>
32 #include <kiface_i.h>
33 #include <class_drawpanel.h>
34 #include <confirm.h>
35 #include <pcb_edit_frame.h>
36 #include <board_commit.h>
37 #include <view/view.h>
38 
39 #include <class_board.h>
40 #include <class_zone.h>
41 
42 #include <pcbnew.h>
43 #include <zones.h>
44 #include <pcbnew_id.h>
45 #include <protos.h>
47 #include <drc.h>
48 #include <connectivity_data.h>
49 
51 
52 #include <zone_filler.h>
53 
54 // Outline creation:
55 static void Abort_Zone_Create_Outline( EDA_DRAW_PANEL* Panel, wxDC* DC );
56 static void Show_New_Edge_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
57  const wxPoint& aPosition, bool aErase );
58 
59 // Corner moving
60 static void Abort_Zone_Move_Corner_Or_Outlines( EDA_DRAW_PANEL* Panel, wxDC* DC );
62  wxDC* aDC,
63  const wxPoint& aPosition,
64  bool aErase );
65 
66 // Local variables
67 static wxPoint s_CornerInitialPosition; // Used to abort a move corner command
68 static bool s_CornerIsNew; // Used to abort a move corner command (if it is a new corner, it must be deleted)
69 static bool s_AddCutoutToCurrentZone; // if true, the next outline will be added to s_CurrentZone
70 static ZONE_CONTAINER* s_CurrentZone; // if != NULL, these ZONE_CONTAINER params will be used for the next zone
71 static wxPoint s_CursorLastPosition; // in move zone outline, last cursor position. Used to calculate the move vector
72 static PICKED_ITEMS_LIST s_PickedList; // a picked list to save zones for undo/redo command
73 static PICKED_ITEMS_LIST s_AuxiliaryList; // a picked list to store zones that are deleted or added when combined
74 
75 
77 {
78  if( !aZone )
79  return;
80 
82  s_CurrentZone = aZone;
83 
84  // set zone settings to the current zone
85  ZONE_SETTINGS zoneInfo = GetZoneSettings();
86  zoneInfo << *aZone;
87  SetZoneSettings( zoneInfo );
88 
89  // Use the general event handler to set others params (like toolbar)
90  wxCommandEvent evt;
91  evt.SetId( aZone->GetIsKeepout() ? ID_PCB_KEEPOUT_AREA_BUTT : ID_PCB_ZONES_BUTT );
92  OnSelectTool( evt );
93 }
94 
95 
97 {
98  if( !aZone )
99  return;
100 
102  s_CurrentZone = aZone;
103 
104  // set zones setup to the current zone
105  ZONE_SETTINGS zoneInfo = GetZoneSettings();
106  zoneInfo << *aZone;
107  SetZoneSettings( zoneInfo );
108 
109  // Use the general event handle to set others params (like toolbar)
110  wxCommandEvent evt;
111  evt.SetId( aZone->GetIsKeepout() ? ID_PCB_KEEPOUT_AREA_BUTT : ID_PCB_ZONES_BUTT );
112  OnSelectTool( evt );
113 }
114 
115 
117 {
118  ZONE_CONTAINER* newZone = new ZONE_CONTAINER( *aZone );
119  newZone->UnFill();
120  ZONE_SETTINGS zoneSettings;
121  zoneSettings << *aZone;
122 
123  bool success;
124 
125  if( aZone->GetIsKeepout() )
126  success = InvokeKeepoutAreaEditor( this, &zoneSettings );
127  else if( aZone->IsOnCopperLayer() )
128  success = InvokeCopperZonesEditor( this, &zoneSettings );
129  else
130  success = InvokeNonCopperZonesEditor( this, aZone, &zoneSettings );
131 
132  // If the new zone is on the same layer as the the initial zone,
133  // do nothing
134  if( success )
135  {
136  if( aZone->GetIsKeepout() && ( aZone->GetLayerSet() == zoneSettings.m_Layers ) )
137  {
139  this, _( "The duplicated zone cannot be on the same layers as the original zone." ) );
140  success = false;
141  }
142  else if( !aZone->GetIsKeepout() && ( aZone->GetLayer() == zoneSettings.m_CurrentZone_Layer ) )
143  {
145  this, _( "The duplicated zone cannot be on the same layer as the original zone." ) );
146  success = false;
147  }
148  }
149 
150  if( success )
151  {
152  zoneSettings.ExportSetting( *newZone );
153  newZone->Hatch();
154 
155  s_AuxiliaryList.ClearListAndDeleteItems();
156  s_PickedList.ClearListAndDeleteItems();
157  SaveCopyOfZones( s_PickedList, GetBoard(), newZone->GetNetCode(), newZone->GetLayer() );
158  GetBoard()->Add( newZone );
159 
160  ITEM_PICKER picker( newZone, UR_NEW );
161  s_PickedList.PushItem( picker );
162 
163  GetScreen()->SetCurItem( NULL ); // This outline may be deleted when merging outlines
164 
165  // Combine zones if possible
166  GetBoard()->OnAreaPolygonModified( &s_AuxiliaryList, newZone );
167 
168  // Redraw zones
169  GetBoard()->RedrawAreasOutlines( m_canvas, aDC, GR_OR, newZone->GetLayer() );
170  GetBoard()->RedrawFilledAreas( m_canvas, aDC, GR_OR, newZone->GetLayer() );
171 
172  DRC drc( this );
173 
174  if( GetBoard()->GetAreaIndex( newZone ) >= 0
175  && drc.TestZoneToZoneOutline( newZone, true ) )
176  {
177  DisplayInfoMessage( this, _( "Warning: The new zone fails DRC" ) );
178  }
179 
180  UpdateCopyOfZonesList( s_PickedList, s_AuxiliaryList, GetBoard() );
181  SaveCopyInUndoList( s_PickedList, UR_UNSPECIFIED );
182  s_PickedList.ClearItemsList();
183 
184  OnModify();
185  }
186  else
187  delete newZone;
188 }
189 
190 
192 {
194 
195  if( !zone )
196  return 0;
197 
198  if( !zone->GetNumCorners() )
199  return 0;
200 
201  zone->DrawWhileCreateOutline( m_canvas, DC, GR_XOR );
202 
203  if( zone->GetNumCorners() > 2 )
204  {
205  zone->Outline()->RemoveVertex( zone->GetNumCorners() - 1 );
206 
207  if( m_canvas->IsMouseCaptured() )
208  m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
209  }
210  else
211  {
212  m_canvas->SetMouseCapture( NULL, NULL );
213  SetCurItem( NULL );
214  zone->RemoveAllContours();
215  zone->ClearFlags();
216  }
217 
218  return zone->GetNumCorners();
219 }
220 
221 
226 static void Abort_Zone_Create_Outline( EDA_DRAW_PANEL* Panel, wxDC* DC )
227 {
228  PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Panel->GetParent();
229  ZONE_CONTAINER* zone = pcbframe->GetBoard()->m_CurrentZoneContour;
230 
231  if( zone )
232  {
233  zone->DrawWhileCreateOutline( Panel, DC, GR_XOR );
234  zone->RemoveAllContours();
235  if( zone->IsNew() )
236  {
237  delete zone;
238  pcbframe->GetBoard()->m_CurrentZoneContour = NULL;
239  }
240  else
241  zone->ClearFlags();
242  }
243 
244  pcbframe->SetCurItem( NULL );
245  s_AddCutoutToCurrentZone = false;
246  s_CurrentZone = NULL;
247  Panel->SetMouseCapture( NULL, NULL );
248 }
249 
250 
252  int corner_id, bool IsNewCorner )
253 {
254  if( aZone->IsOnCopperLayer() ) // Show the Net
255  {
256  if( GetBoard()->IsHighLightNetON() && DC )
257  {
258  HighLight( DC ); // Remove old highlight selection
259  }
260 
261  ZONE_SETTINGS zoneInfo = GetZoneSettings();
262  zoneInfo.m_NetcodeSelection = aZone->GetNetCode();
263  SetZoneSettings( zoneInfo );
264 
265  GetBoard()->SetHighLightNet( aZone->GetNetCode() );
266 
267  if( DC )
268  HighLight( DC );
269  }
270 
271 
272  // Prepare copy of old zones, for undo/redo.
273  // if the corner is new, remove it from list, save and insert it in list
274  VECTOR2I corner = aZone->Outline()->Vertex( corner_id );
275 
276  if ( IsNewCorner )
277  aZone->Outline()->RemoveVertex( corner_id );
278 
279  s_AuxiliaryList.ClearListAndDeleteItems();
280  s_PickedList.ClearListAndDeleteItems();
281 
282  SaveCopyOfZones( s_PickedList, GetBoard(), aZone->GetNetCode(), aZone->GetLayer() );
283 
284  if ( IsNewCorner )
285  aZone->Outline()->InsertVertex(corner_id-1, corner );
286 
287  aZone->SetFlags( IN_EDIT );
290  s_CornerInitialPosition = static_cast<wxPoint>( aZone->GetCornerPosition( corner_id ) );
291  s_CornerIsNew = IsNewCorner;
292  s_AddCutoutToCurrentZone = false;
293  s_CurrentZone = NULL;
294 }
295 
296 
298  ZONE_CONTAINER* aZone,
299  int corner_id )
300 {
301  aZone->SetFlags( IS_DRAGGED );
302  aZone->SetSelectedCorner( corner_id );
305  s_CursorLastPosition = s_CornerInitialPosition = GetCrossHairPosition();
306  s_AddCutoutToCurrentZone = false;
307  s_CurrentZone = NULL;
308 
309  s_PickedList.ClearListAndDeleteItems();
310  s_AuxiliaryList.ClearListAndDeleteItems();
311  SaveCopyOfZones( s_PickedList, GetBoard(), aZone->GetNetCode(), aZone->GetLayer() );
312 }
313 
314 
316 {
317  // Show the Net
318  if( aZone->IsOnCopperLayer() ) // Show the Net
319  {
320  if( GetBoard()->IsHighLightNetON() )
321  {
322  HighLight( DC ); // Remove old highlight selection
323  }
324 
325  ZONE_SETTINGS zoneInfo = GetZoneSettings();
326  zoneInfo.m_NetcodeSelection = aZone->GetNetCode();
327  SetZoneSettings( zoneInfo );
328 
329  GetBoard()->SetHighLightNet( aZone->GetNetCode() );
330  HighLight( DC );
331  }
332 
333  s_PickedList.ClearListAndDeleteItems();
334  s_AuxiliaryList.ClearListAndDeleteItems();
335  SaveCopyOfZones( s_PickedList, GetBoard(), aZone->GetNetCode(), aZone->GetLayer() );
336 
337  aZone->SetFlags( IS_MOVED );
340  s_CursorLastPosition = s_CornerInitialPosition = GetCrossHairPosition();
341  s_CornerIsNew = false;
342  s_AddCutoutToCurrentZone = false;
343  s_CurrentZone = NULL;
344 }
345 
346 
348 {
349  aZone->ClearFlags();
350  m_canvas->SetMouseCapture( NULL, NULL );
351 
352  if( DC )
353  aZone->Draw( m_canvas, DC, GR_OR );
354 
355  OnModify();
356  s_AddCutoutToCurrentZone = false;
357  s_CurrentZone = NULL;
358 
359  SetCurItem( NULL ); // This outline can be deleted when merging outlines
360 
361  // Combine zones if possible
362  GetBoard()->OnAreaPolygonModified( &s_AuxiliaryList, aZone );
363  m_canvas->Refresh();
364 
365  int ii = GetBoard()->GetAreaIndex( aZone ); // test if aZone exists
366 
367  if( ii < 0 )
368  aZone = NULL; // was removed by combining zones
369 
370  UpdateCopyOfZonesList( s_PickedList, s_AuxiliaryList, GetBoard() );
371  SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED);
372  s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
373 
374  DRC drc( this );
375  int error_count = drc.TestZoneToZoneOutline( aZone, true );
376 
377  if( error_count )
378  {
379  DisplayErrorMessage( this, _( "Area: DRC outline error" ) );
380  }
381 }
382 
383 
385 {
386  OnModify();
387 
388  if( aZone->Outline()->TotalVertices() <= 3 )
389  {
391 
392  if( DC )
393  { // Remove the full zone because this is no more an area
394  aZone->UnFill();
395  aZone->DrawFilledArea( m_canvas, DC, GR_XOR );
396  }
397 
398  GetBoard()->Delete( aZone );
399  return;
400  }
401 
402  PCB_LAYER_ID layer = aZone->GetLayer();
403 
404  if( DC )
405  {
406  GetBoard()->RedrawAreasOutlines( m_canvas, DC, GR_XOR, layer );
407  GetBoard()->RedrawFilledAreas( m_canvas, DC, GR_XOR, layer );
408  }
409 
410  s_AuxiliaryList.ClearListAndDeleteItems();
411  s_PickedList. ClearListAndDeleteItems();
412  SaveCopyOfZones( s_PickedList, GetBoard(), aZone->GetNetCode(), aZone->GetLayer() );
413  aZone->Outline()->RemoveVertex( aZone->GetSelectedCorner() );
414 
415  // modify zones outlines according to the new aZone shape
416  GetBoard()->OnAreaPolygonModified( &s_AuxiliaryList, aZone );
417 
418  if( DC )
419  {
420  GetBoard()->RedrawAreasOutlines( m_canvas, DC, GR_OR, layer );
421  GetBoard()->RedrawFilledAreas( m_canvas, DC, GR_OR, layer );
422  }
423 
424  UpdateCopyOfZonesList( s_PickedList, s_AuxiliaryList, GetBoard() );
425  SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED);
426  s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
427 
428  int ii = GetBoard()->GetAreaIndex( aZone ); // test if aZone exists
429 
430  if( ii < 0 )
431  aZone = NULL; // aZone does not exist anymore, after combining zones
432 
433  DRC drc( this );
434  int error_count = drc.TestZoneToZoneOutline( aZone, true );
435 
436  if( error_count )
437  {
438  DisplayErrorMessage( this, _( "Area: DRC outline error" ) );
439  }
440 }
441 
442 
448 {
449  PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Panel->GetParent();
450  ZONE_CONTAINER* zone = (ZONE_CONTAINER*) pcbframe->GetCurItem();
451 
452  if( zone->IsMoving() )
453  {
454  wxPoint offset;
455  offset = s_CornerInitialPosition - s_CursorLastPosition;
456  zone->Move( offset );
457  }
458  else if( zone->IsDragging() )
459  {
460  wxPoint offset = s_CornerInitialPosition - s_CursorLastPosition;
461  int selection = zone->GetSelectedCorner();
462  zone->MoveEdge( offset, selection );
463  }
464  else
465  {
466  if( s_CornerIsNew )
467  {
468  zone->Outline()->RemoveVertex( zone->GetSelectedCorner() );
469  }
470  else
471  {
473  zone->Outline()->Vertex( zone->GetSelectedCorner() ) = pos;
474  }
475  }
476 
477  Panel->SetMouseCapture( NULL, NULL );
478  s_AuxiliaryList.ClearListAndDeleteItems();
479  s_PickedList. ClearListAndDeleteItems();
480  Panel->Refresh();
481 
482  pcbframe->SetCurItem( NULL );
483  zone->ClearFlags();
484  s_AddCutoutToCurrentZone = false;
485  s_CurrentZone = NULL;
486 }
487 
488 
491  const wxPoint& aPosition, bool aErase )
492 {
493  PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) aPanel->GetParent();
494  ZONE_CONTAINER* zone = (ZONE_CONTAINER*) pcbframe->GetCurItem();
495 
496  if( aErase ) // Undraw edge in old position
497  {
498  zone->Draw( aPanel, aDC, GR_XOR );
499  }
500 
501  wxPoint pos = pcbframe->GetCrossHairPosition();
502 
503  if( zone->IsMoving() )
504  {
505  wxPoint offset;
506  offset = pos - s_CursorLastPosition;
507  zone->Move( offset );
508  s_CursorLastPosition = pos;
509  }
510  else if( zone->IsDragging() )
511  {
512  wxPoint offset = pos - s_CursorLastPosition;
513  int selection = zone->GetSelectedCorner();
514  zone->MoveEdge( offset, selection );
515  s_CursorLastPosition = pos;
516  }
517  else
518  {
519  zone->Outline()->Vertex( zone->GetSelectedCorner() ) = pos;
520  }
521 
522  zone->Draw( aPanel, aDC, GR_XOR );
523 }
524 
525 
526 
528 {
529  ZONE_SETTINGS zoneInfo = GetZoneSettings();
530 
531  // verify if s_CurrentZone exists (could be deleted since last selection) :
532  int ii;
533  for( ii = 0; ii < GetBoard()->GetAreaCount(); ii++ )
534  {
535  if( s_CurrentZone == GetBoard()->GetArea( ii ) )
536  break;
537  }
538 
539  if( ii >= GetBoard()->GetAreaCount() ) // Not found: could be deleted since last selection
540  {
541  s_AddCutoutToCurrentZone = false;
542  s_CurrentZone = NULL;
543  }
544 
546 
547  // Verify if a new zone is allowed on this layer:
548  if( zone == NULL )
549  {
551  {
552  DisplayErrorMessage( this,
553  _( "Error: a keepout area is allowed only on copper layers" ) );
554  return 0;
555  }
556  }
557 
558  // If no zone contour in progress, a new zone is being created,
559  if( zone == NULL )
560  {
562  zone->SetFlags( IS_NEW );
563  zone->SetTimeStamp( GetNewTimeStamp() );
564  }
565 
566  if( zone->GetNumCorners() == 0 ) // Start a new contour: init zone params (net, layer ...)
567  {
568  if( !s_CurrentZone ) // A new outline is created, from scratch
569  {
570  ZONE_EDIT_T edited;
571 
572  // Prompt user for parameters:
574 
575  if( IsCopperLayer( GetActiveLayer() ) )
576  {
577  // Put a zone on a copper layer
578  if( GetBoard()->GetHighLightNetCode() > 0 )
579  {
581  zone->SetNetCode( zoneInfo.m_NetcodeSelection );
582  }
583 
584  double tmp = ZONE_THERMAL_RELIEF_GAP_MIL;
585 
586  wxConfigBase* cfg = Kiface().KifaceSettings();
587  cfg->Read( ZONE_THERMAL_RELIEF_GAP_STRING_KEY, &tmp );
588  zoneInfo.m_ThermalReliefGap = KiROUND( tmp * IU_PER_MILS);
589 
592  zoneInfo.m_ThermalReliefCopperBridge = KiROUND( tmp * IU_PER_MILS );
593 
594  tmp = ZONE_CLEARANCE_MIL;
595  cfg->Read( ZONE_CLEARANCE_WIDTH_STRING_KEY, &tmp );
596  zoneInfo.m_ZoneClearance = KiROUND( tmp * IU_PER_MILS );
597 
598  tmp = ZONE_THICKNESS_MIL;
599  cfg->Read( ZONE_MIN_THICKNESS_WIDTH_STRING_KEY, &tmp );
600  zoneInfo.m_ZoneMinThickness = KiROUND( tmp * IU_PER_MILS );
601 
603  {
604  zoneInfo.SetIsKeepout( true );
605  // Netcode, netname and some other settings are irrelevant,
606  // so ensure they are cleared
609  zoneInfo.SetCornerRadius( 0 );
610 
611  edited = InvokeKeepoutAreaEditor( this, &zoneInfo );
612  }
613  else
614  {
615  zoneInfo.m_CurrentZone_Layer = GetActiveLayer(); // Preselect a layer
616  zoneInfo.SetIsKeepout( false );
617  edited = InvokeCopperZonesEditor( this, &zoneInfo );
618  }
619  }
620  else // Put a zone on a non copper layer (technical layer)
621  {
622  zone->SetLayer( GetActiveLayer() ); // Preselect a layer
623  zoneInfo.SetIsKeepout( false );
624  zoneInfo.m_NetcodeSelection = 0; // No net for non copper zones
625  edited = InvokeNonCopperZonesEditor( this, zone, &zoneInfo );
626  }
627 
629  m_canvas->SetIgnoreMouseEvents( false );
630 
631  if( edited == ZONE_ABORT )
632  {
633  GetBoard()->m_CurrentZoneContour = NULL;
634  delete zone;
635  return 0;
636  }
637 
638  // Switch active layer to the selected zone layer
640  SetZoneSettings( zoneInfo );
641  OnModify();
642  }
643  else
644  {
645  // Start a new contour: init zone params (net and layer) from an existing
646  // zone (add cutout or similar zone)
647 
648  zoneInfo.m_CurrentZone_Layer = s_CurrentZone->GetLayer();
649  SetActiveLayer( s_CurrentZone->GetLayer() );
650 
651  zoneInfo << *s_CurrentZone;
652 
653  SetZoneSettings( zoneInfo );
654  OnModify();
655  }
656 
657  // Show the Net for zones on copper layers
658  if( IsCopperLayer( zoneInfo.m_CurrentZone_Layer ) &&
659  !zoneInfo.GetIsKeepout() )
660  {
661  if( s_CurrentZone )
662  {
663  zoneInfo.m_NetcodeSelection = s_CurrentZone->GetNetCode();
664  GetBoard()->SetZoneSettings( zoneInfo );
665  }
666 
667  if( GetBoard()->IsHighLightNetON() )
668  {
669  HighLight( DC ); // Remove old highlight selection
670  }
671 
673  HighLight( DC );
674  }
675 
677  s_CurrentZone = NULL; // the zone is used only once ("add similar zone" command)
678  }
679 
680  // if first segment
681  if( zone->GetNumCorners() == 0 )
682  {
683  zoneInfo.ExportSetting( *zone );
684 
685  // A duplicated corner is needed; null segments are removed when the zone is finished.
686  zone->AppendCorner( GetCrossHairPosition(), -1 );
687  // Add the duplicate corner:
688  zone->AppendCorner( GetCrossHairPosition(), -1, true );
689 
690  if( Settings().m_legacyDrcOn && (m_drc->Drc( zone, 0 ) == BAD_DRC) && zone->IsOnCopperLayer() )
691  {
692  zone->ClearFlags();
693  zone->RemoveAllContours();
694 
695  // use the form of SetCurItem() which does not write to the msg panel,
696  // SCREEN::SetCurItem(), so the DRC error remains on screen.
697  // PCB_EDIT_FRAME::SetCurItem() calls DisplayInfo().
698  GetScreen()->SetCurItem( NULL );
699  DisplayErrorMessage( this,
700  _( "DRC error: this start point is inside or too close an other area" ) );
701  return 0;
702  }
703 
704  SetCurItem( zone );
706  }
707  else // edge in progress:
708  {
709  ii = zone->GetNumCorners() - 1;
710 
711  // edge in progress : the current corner coordinate was set
712  // by Show_New_Edge_While_Move_Mouse
713  if( zone->GetCornerPosition( ii - 1 ) != zone->GetCornerPosition( ii ) )
714  {
715  if( !Settings().m_legacyDrcOn || !zone->IsOnCopperLayer() || ( m_drc->Drc( zone, ii - 1 ) == OK_DRC ) )
716  {
717  // Ok, we can add a new corner
718  if( m_canvas->IsMouseCaptured() )
719  m_canvas->CallMouseCapture( DC, wxPoint(0,0), false );
720 
721  // It is necessary to allow duplication of the points, as we have to handle the
722  // continuous drawing while creating the zone at the same time as we build it. Null
723  // segments are removed when the zone is finished, in End_Zone.
724  zone->AppendCorner( GetCrossHairPosition(), -1, true );
725 
726  SetCurItem( zone ); // calls DisplayInfo().
727 
728  if( m_canvas->IsMouseCaptured() )
729  m_canvas->CallMouseCapture( DC, wxPoint(0,0), false );
730  }
731  }
732  }
733 
734  return zone->GetNumCorners();
735 }
736 
737 
738 bool PCB_EDIT_FRAME::End_Zone( wxDC* DC )
739 {
741 
742  if( !zone )
743  return true;
744 
745  // Validate the current outline:
746  if( zone->GetNumCorners() <= 2 ) // An outline must have 3 corners or more
747  {
749  return true;
750  }
751 
752  // Remove the last corner if is is at the same location as the prevoius corner
753  zone->Outline()->RemoveNullSegments();
754 
755  // Validate the current edge:
756  int icorner = zone->GetNumCorners() - 1;
757  if( zone->IsOnCopperLayer() )
758  {
759  if( Settings().m_legacyDrcOn && m_drc->Drc( zone, icorner - 1 ) == BAD_DRC ) // we can't validate last edge
760  return false;
761 
762  if( Settings().m_legacyDrcOn && m_drc->Drc( zone, icorner ) == BAD_DRC ) // we can't validate the closing edge
763  {
764  DisplayErrorMessage( this,
765  _( "DRC error: closing this area creates a DRC error with an other area" ) );
767  return false;
768  }
769  }
770 
771  zone->ClearFlags();
772 
773  zone->DrawWhileCreateOutline( m_canvas, DC, GR_XOR );
774 
775  m_canvas->SetMouseCapture( NULL, NULL );
776 
777  // Undraw old drawings, because they can have important changes
778  PCB_LAYER_ID layer = zone->GetLayer();
779  GetBoard()->RedrawAreasOutlines( m_canvas, DC, GR_XOR, layer );
780  GetBoard()->RedrawFilledAreas( m_canvas, DC, GR_XOR, layer );
781 
782  // Save initial zones configuration, for undo/redo, before adding new zone
783  s_AuxiliaryList.ClearListAndDeleteItems();
784  s_PickedList.ClearListAndDeleteItems();
785  SaveCopyOfZones(s_PickedList, GetBoard(), zone->GetNetCode(), zone->GetLayer() );
786 
787  // Put new zone in list
788  if( !s_CurrentZone )
789  {
790  GetBoard()->Add( zone );
791 
792  // Add this zone in picked list, as new item
793  ITEM_PICKER picker( zone, UR_NEW );
794  s_PickedList.PushItem( picker );
795  }
796  else // Append this outline as a cutout to an existing zone
797  {
798  s_CurrentZone->Outline()->AddHole( zone->Outline()->Outline( 0 ) );
799 
800  zone->RemoveAllContours(); // All corners are copied in s_CurrentZone. Free corner list.
801  zone = s_CurrentZone;
802  }
803 
804  s_AddCutoutToCurrentZone = false;
805  s_CurrentZone = NULL;
806  GetBoard()->m_CurrentZoneContour = NULL;
807 
808  GetScreen()->SetCurItem( NULL ); // This outline can be deleted when merging outlines
809 
810  // Combine zones if possible :
811  GetBoard()->OnAreaPolygonModified( &s_AuxiliaryList, zone );
812 
813  // Redraw the real edge zone :
814  GetBoard()->RedrawAreasOutlines( m_canvas, DC, GR_OR, layer );
815  GetBoard()->RedrawFilledAreas( m_canvas, DC, GR_OR, layer );
816 
817  int ii = GetBoard()->GetAreaIndex( zone ); // test if zone exists
818 
819  if( ii < 0 )
820  zone = NULL; // was removed by combining zones
821 
822  DRC drc( this );
823  int error_count = drc.TestZoneToZoneOutline( zone, true );
824 
825  if( error_count )
826  {
827  DisplayErrorMessage( this, _( "Area: DRC outline error" ) );
828  }
829 
830  UpdateCopyOfZonesList( s_PickedList, s_AuxiliaryList, GetBoard() );
831  SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED);
832  s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
833 
834  OnModify();
835  return true;
836 }
837 
838 
839 /* Redraws the zone outlines when moving mouse
840  */
841 static void Show_New_Edge_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
842  const wxPoint& aPosition, bool aErase )
843 {
844  PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) aPanel->GetParent();
845  wxPoint c_pos = pcbframe->GetCrossHairPosition();
846  ZONE_CONTAINER* zone = pcbframe->GetBoard()->m_CurrentZoneContour;
847 
848  if( !zone )
849  return;
850 
851  int icorner = zone->GetNumCorners() - 1;
852 
853  if( icorner < 1 )
854  return; // We must have 2 (or more) corners
855 
856  if( aErase ) // Undraw edge in old position
857  {
858  zone->DrawWhileCreateOutline( aPanel, aDC );
859  }
860 
861  // Redraw the current edge in its new position
862  if( pcbframe->GetZoneSettings().m_Zone_45_Only )
863  {
864  // calculate the new position as allowed
865  wxPoint StartPoint = static_cast<wxPoint>( zone->GetCornerPosition( icorner - 1 ) );
866  c_pos = CalculateSegmentEndPoint( c_pos, StartPoint );
867  }
868 
869  zone->SetCornerPosition( icorner, c_pos );
870 
871  zone->DrawWhileCreateOutline( aPanel, aDC );
872 }
873 
875 {
876  ZONE_EDIT_T edited;
877  ZONE_SETTINGS zoneInfo = GetZoneSettings();
878 
879  BOARD_COMMIT commit( this );
881 
882  // Save initial zones configuration, for undo/redo, before adding new zone
883  // note the net name and the layer can be changed, so we must save all zones
884  s_AuxiliaryList.ClearListAndDeleteItems();
885  s_PickedList.ClearListAndDeleteItems();
886  SaveCopyOfZones( s_PickedList, GetBoard(), -1, UNDEFINED_LAYER );
887 
888  if( aZone->GetIsKeepout() )
889  {
890  // edit a keepout area on a copper layer
891  zoneInfo << *aZone;
892  edited = InvokeKeepoutAreaEditor( this, &zoneInfo );
893  }
894  else if( IsCopperLayer( aZone->GetLayer() ) )
895  {
896  // edit a zone on a copper layer
897 
898  zoneInfo << *aZone;
899 
900  edited = InvokeCopperZonesEditor( this, &zoneInfo );
901  }
902  else
903  {
904  edited = InvokeNonCopperZonesEditor( this, aZone, &zoneInfo );
905  }
906 
908  m_canvas->SetIgnoreMouseEvents( false );
909 
910  if( edited == ZONE_ABORT )
911  {
912  s_AuxiliaryList.ClearListAndDeleteItems();
913  s_PickedList.ClearListAndDeleteItems();
914  return;
915  }
916 
917  SetZoneSettings( zoneInfo );
918  OnModify();
919 
920  if( edited == ZONE_EXPORT_VALUES )
921  {
922  UpdateCopyOfZonesList( s_PickedList, s_AuxiliaryList, GetBoard() );
923  commit.Stage( s_PickedList );
924  commit.Push( _( "Modify zone properties" ) );
925  s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
926  return;
927  }
928 
929  wxBusyCursor dummy;
930 
931  // Undraw old zone outlines
932  for( int ii = 0; ii < GetBoard()->GetAreaCount(); ii++ )
933  {
934  ZONE_CONTAINER* edge_zone = GetBoard()->GetArea( ii );
935  edge_zone->Draw( m_canvas, DC, GR_XOR );
936 
937  if( IsGalCanvasActive() )
938  {
939  GetGalCanvas()->GetView()->Update( edge_zone );
940  }
941  }
942 
943  zoneInfo.ExportSetting( *aZone );
944 
945  NETINFO_ITEM* net = GetBoard()->FindNet( zoneInfo.m_NetcodeSelection );
946 
947  if( net ) // net == NULL should not occur
948  aZone->SetNetCode( net->GetNet() );
949 
950  // Combine zones if possible
951  GetBoard()->OnAreaPolygonModified( &s_AuxiliaryList, aZone );
952 
953  // Redraw the real new zone outlines
955 
956  UpdateCopyOfZonesList( s_PickedList, s_AuxiliaryList, GetBoard() );
957 
958  // refill zones with the new properties applied
959  std::vector<ZONE_CONTAINER*> zones_to_refill;
960 
961  for( unsigned i = 0; i < s_PickedList.GetCount(); ++i )
962  {
963  ZONE_CONTAINER* zone = dyn_cast<ZONE_CONTAINER*>( s_PickedList.GetPickedItem( i ) );
964 
965  if( zone == nullptr )
966  {
967  wxASSERT_MSG( false, "Expected a zone after zone properties edit" );
968  continue;
969  }
970 
971  if( zone->IsFilled() )
972  zones_to_refill.push_back( zone );
973  }
974 
975  if( zones_to_refill.size() )
976  {
977  ZONE_FILLER filler ( GetBoard() );
978  wxString title;
979  title.Printf( _( "Refill %d Zones" ), (int)zones_to_refill.size() );
980  std::unique_ptr<WX_PROGRESS_REPORTER> progressReporter(
981  new WX_PROGRESS_REPORTER( this, title, 3 ) );
982 
983  filler.SetProgressReporter( progressReporter.get() );
984  filler.Fill( zones_to_refill );
985  }
986 
987  commit.Stage( s_PickedList );
988  commit.Push( _( "Modify zone properties" ) );
989  GetBoard()->GetConnectivity()->RecalculateRatsnest();
990 
991  s_PickedList.ClearItemsList(); // s_ItemsListPicker is no longer owner of picked items
992 }
993 
994 
996 {
997  // Get contour in which the selected corner is
999 
1000  // If the selected corner does not exist, abort
1001  if( !aZone->Outline()->GetRelativeIndices( aZone->GetSelectedCorner(), &indices ) )
1002  throw( std::out_of_range( "Zone selected corner does not exist" ) );
1003 
1004  EDA_RECT dirty = aZone->GetBoundingBox();
1005 
1006  // For compatibility with old boards: remove old SEGZONE fill segments
1007  Delete_OldZone_Fill( NULL, aZone->GetTimeStamp() );
1008 
1009  // Remove current filling:
1010  aZone->UnFill();
1011 
1012  if( indices.m_contour == 0 ) // This is the main outline: remove all
1013  {
1014  SaveCopyInUndoList( aZone, UR_DELETED );
1015  GetBoard()->Remove( aZone );
1016  }
1017 
1018  else
1019  {
1020  SaveCopyInUndoList( aZone, UR_CHANGED );
1021  aZone->Outline()->RemoveContour( indices.m_contour, indices.m_polygon );
1022  }
1023 
1024  m_canvas->RefreshDrawingRect( dirty );
1025 
1026  OnModify();
1027 }
void MoveEdge(const wxPoint &offset, int aEdge)
Function MoveEdge Move the outline Edge.
Definition: class_zone.cpp:910
void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, GR_DRAWMODE aDrawMode, const wxPoint &offset=ZeroOffset) override
Function Draw Draws the zone outline.
Definition: class_zone.cpp:272
virtual void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
void SetZoneSettings(const ZONE_SETTINGS &aSettings)
Definition: class_board.h:557
void SetCurItem(BOARD_ITEM *aItem)
Function SetCurItem sets the currently selected object, m_CurrentItem.
Definition: pcb_screen.h:82
COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType)
Adds a change of the item aItem of type aChangeType to the change list.
Definition: commit.cpp:46
void DrawWhileCreateOutline(EDA_DRAW_PANEL *panel, wxDC *DC, GR_DRAWMODE draw_mode=GR_OR)
Function DrawWhileCreateOutline Draws the zone outline when it is created.
Definition: class_zone.cpp:541
#define OK_DRC
Definition: drc.h:35
bool IsMoving() const
Definition: base_struct.h:247
#define IN_EDIT
Item currently edited.
Definition: base_struct.h:125
void Start_Move_Zone_Corner(wxDC *DC, ZONE_CONTAINER *zone_container, int corner_id, bool IsNewCorner)
Function Start_Move_Zone_Corner Prepares a move corner in a zone outline, called from a move corner c...
void Start_Move_Zone_Drag_Outline_Edge(wxDC *DC, ZONE_CONTAINER *zone_container, int corner_id)
Function Start_Move_Zone_Corner Prepares a drag edge in an existing zone outline,.
int GetNumCorners(void) const
Access to m_Poly parameters.
Definition: class_zone.h:414
bool End_Zone(wxDC *DC)
Function End_Zone terminates (if no DRC error ) the zone edge creation process.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:88
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
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
static bool s_CornerIsNew
int TestZoneToZoneOutline(ZONE_CONTAINER *aZone, bool aCreateMarkers)
Definition: drc.cpp:182
This file is part of the common library.
bool IsNew() const
Definition: base_struct.h:245
void UpdateCopyOfZonesList(PICKED_ITEMS_LIST &aPickList, PICKED_ITEMS_LIST &aAuxiliaryList, BOARD *aPcb)
Function UpdateCopyOfZonesList check a pick list to remove zones identical to their copies and set th...
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox (virtual)
Definition: class_zone.cpp:514
void SetCornerSmoothingType(int aType)
bool OnAreaPolygonModified(PICKED_ITEMS_LIST *aModifiedZonesList, ZONE_CONTAINER *modified_area)
Function OnAreaPolygonModified Process an area that has been modified, by normalizing its polygon and...
static void Abort_Zone_Move_Corner_Or_Outlines(EDA_DRAW_PANEL *Panel, wxDC *DC)
Function Abort_Zone_Move_Corner_Or_Outlines cancels the Begin_Zone state if at least one EDGE_ZONE ha...
long m_ThermalReliefCopperBridge
thickness of the copper bridge in thermal reliefs
Definition: zone_settings.h:78
Class BOARD to handle a board.
void DrawFilledArea(EDA_DRAW_PANEL *panel, wxDC *DC, GR_DRAWMODE aDrawMode, const wxPoint &offset=ZeroOffset)
Function DrawDrawFilledArea Draws the filled area for this zone (polygon list .m_FilledPolysList) ...
Definition: class_zone.cpp:402
ZONE_EDIT_T
Exit codes for zone editing dialogs.
Definition: zones.h:47
const ZONE_SETTINGS & GetZoneSettings() const
bool IsFilled() const
Definition: class_zone.h:189
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:171
static bool s_AddCutoutToCurrentZone
ZONE_CONTAINER * m_CurrentZoneContour
zone contour currently in progress
Definition: class_board.h:259
void SetCurItem(BOARD_ITEM *aItem, bool aDisplayInfo=true)
Function SetCurItem sets the currently selected item and displays it in the MsgPanel.
int TotalVertices() const
Returns total number of vertices stored in the set.
void Start_Move_Zone_Outlines(wxDC *DC, ZONE_CONTAINER *zone_container)
Function Start_Move_Zone_Outlines Initialize parameters to move an existing zone outlines.
SHAPE_POLY_SET * Outline()
Definition: class_zone.h:236
Struct VERTEX_INDEX.
BOARD * GetBoard() const
Classes to handle copper zones.
void RefreshDrawingRect(const EDA_RECT &aRect, bool aEraseBackground=true)
Function RefreshDrawingRect redraws the contents of aRect in drawing units.
Definition: draw_panel.cpp:319
void OnSelectTool(wxCommandEvent &aEvent)
Definition: edit.cpp:1443
void PushItem(const ITEM_PICKER &aItem)
Function PushItem pushes aItem to the top of the list.
#define ZONE_THERMAL_RELIEF_COPPER_WIDTH_MIL
Definition: zones.h:39
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
DRC * m_drc
the DRC controller, see drc.cpp
void Remove_Zone_Corner(wxDC *DC, ZONE_CONTAINER *zone_container)
Function End_Move_Zone_Corner_Or_Outlines Remove the currently selected corner in a zone outline the ...
void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
Definition: draw_panel.cpp:361
const VECTOR2I & GetCornerPosition(int aCornerIndex) const
Definition: class_zone.h:454
Casted dyn_cast(From aObject)
Function dyn_cast()
Definition: typeinfo.h:61
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true) override
Executes the changes.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
wxPoint CalculateSegmentEndPoint(const wxPoint &aPosition, const wxPoint &aOrigin)
Determine end point for a segment direction 0, 90, or 45 degrees depending on it&#39;s position from the ...
Definition: editrack.cpp:831
static wxPoint s_CursorLastPosition
static PICKED_ITEMS_LIST s_AuxiliaryList
VECTOR2I & Vertex(int aIndex, int aOutline, int aHole)
Returns the index-th vertex in a given hole outline within a given outline
void ExportSetting(ZONE_CONTAINER &aTarget, bool aFullExport=true) const
Function ExportSetting copy settings to a given zone.
bool GetIsKeepout() const
Accessors to parameters used in Keepout zones:
Definition: class_zone.h:602
#define IS_NEW
New item, just created.
Definition: base_struct.h:127
int SaveCopyOfZones(PICKED_ITEMS_LIST &aPickList, BOARD *aPcb, int aNetCode, LAYER_NUM aLayer)
Function SaveCopyOfZones creates a copy of zones having a given netcode on a given layer...
#define IS_DRAGGED
Item being dragged.
Definition: base_struct.h:129
int m_NetcodeSelection
Net code selection for the current zone.
Definition: zone_settings.h:65
timestamp_t GetNewTimeStamp()
Definition: common.cpp:166
PCB_LAYER_ID
A quick note on layer IDs:
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:282
if values were exported to others zones
Definition: zones.h:50
void SetProgressReporter(PROGRESS_REPORTER *aReporter)
Definition: zone_filler.cpp:77
int Begin_Zone(wxDC *DC)
Function Begin_Zone either initializes the first segment of a new zone, or adds an intermediate segme...
const bool GetIsKeepout() const
Accessors to parameters used in Keepout zones:
bool IsMouseCaptured() const
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
PCB_GENERAL_SETTINGS & Settings()
static ZONE_CONTAINER * s_CurrentZone
bool GetRelativeIndices(int aGlobalIdx, VERTEX_INDEX *aRelativeIndices) const
Function GetRelativeIndices.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_INSERT) override
Adds an item to the container.
void End_Move_Zone_Corner_Or_Outlines(wxDC *DC, ZONE_CONTAINER *zone_container)
Function End_Move_Zone_Corner_Or_Outlines Terminates a move corner in a zone outline, or a move zone outlines.
void CallMouseCapture(wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function CallMouseCapture calls the mouse capture callback.
if no change
Definition: zones.h:48
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Function SetLayer sets the layer this item is on.
Definition: class_zone.cpp:198
bool UnFill()
Function UnFill Removes the zone filling.
Definition: class_zone.cpp:152
static void Abort_Zone_Create_Outline(EDA_DRAW_PANEL *Panel, wxDC *DC)
Function Abort_Zone_Create_Outline cancels the Begin_Zone command if at least one EDGE_ZONE was creat...
#define ZONE_CLEARANCE_MIL
Definition: zones.h:42
int m_ZoneClearance
Clearance value.
Definition: zone_settings.h:63
void HighLight(wxDC *DC)
Function HighLight.
Definition: highlight.cpp:101
#define ZONE_THERMAL_RELIEF_GAP_STRING_KEY
Definition: zones.h:32
wxConfigBase * KifaceSettings() const
Definition: kiface_i.h:103
bool SetNetCode(int aNetCode, bool aNoAssert=false)
Function SetNetCode sets net using a net code.
void SetIsKeepout(bool aEnable)
bool IsGalCanvasActive() const
Function IsGalCanvasActive is used to check which canvas (GAL-based or standard) is currently in use...
Definition: draw_frame.h:874
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:1011
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:181
static wxPoint s_CornerInitialPosition
ZONE_EDIT_T InvokeNonCopperZonesEditor(PCB_BASE_FRAME *aParent, ZONE_CONTAINER *aZone, ZONE_SETTINGS *aSettings)
Function InvokeNonCopperZonesEditor invokes up a modal dialog window for non-copper zone editing...
static void Show_Zone_Corner_Or_Outline_While_Move_Mouse(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
Redraws the zone outline when moving a corner according to the cursor position.
Class PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
int GetNet() const
Function GetNet.
Definition: netinfo.h:227
void SaveCopyInUndoList(BOARD_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, const wxPoint &aTransformPoint=wxPoint(0, 0)) override
Function SaveCopyInUndoList Creates a new entry in undo list of commands.
Definition: undo_redo.cpp:202
int RemoveNullSegments()
Function RemoveNullSegments looks for null segments; ie, segments whose ends are exactly the same and...
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1382
int Delete_LastCreatedCorner(wxDC *DC)
Function Delete_LastCreatedCorner Used only while creating a new zone outline Remove and delete the c...
#define ZONE_THICKNESS_MIL
Definition: zones.h:40
void Add_Similar_Zone(wxDC *DC, ZONE_CONTAINER *zone_container)
Function Add_Similar_Zone Add a zone to a given zone outline.
int AddHole(const SHAPE_LINE_CHAIN &aHole, int aOutline=-1)
Adds a new hole to the given outline (default: last) and returns its index
void SetSelectedCorner(int aCorner)
Definition: class_zone.h:210
#define BAD_DRC
Definition: drc.h:36
void Add_Zone_Cutout(wxDC *DC, ZONE_CONTAINER *zone_container)
Function Add_Zone_Cutout Add a cutout zone to a given zone outline.
void Edit_Zone_Params(wxDC *DC, ZONE_CONTAINER *zone_container)
Function Edit_Zone_Params Edit params (layer, clearance, ...) for a zone outline. ...
unsigned GetCount() const
Function GetCount.
Class ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:49
void Move(const wxPoint &offset) override
Function Move Move the outlines.
Definition: class_zone.cpp:893
Definition: gr_basic.h:38
int GetNetCode() const
Function GetNetCode.
void SetHighLightNet(int aNetCode)
Function SetHighLightNet.
Definition: class_board.h:372
void Fill(std::vector< ZONE_CONTAINER * > aZones)
Definition: zone_filler.cpp:82
#define ZONE_MIN_THICKNESS_WIDTH_STRING_KEY
Definition: zones.h:35
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
Class NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:69
bool IsOnCopperLayer() const
Function IsOnCopperLayer.
Definition: class_zone.cpp:177
#define ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY
Definition: zones.h:33
void SetCornerPosition(int aCornerIndex, wxPoint new_pos)
Definition: class_zone.h:465
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:982
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
Function GetPickedItem.
void duplicateZone(wxDC *aDC, ZONE_CONTAINER *aZone)
Function duplicateZone duplicates the given zone.
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...
void RedrawFilledAreas(EDA_DRAW_PANEL *aPanel, wxDC *aDC, GR_DRAWMODE aDrawMode, PCB_LAYER_ID aLayer)
Function RedrawFilledAreas Redraw all filled areas on layer aLayer ( redraw all if aLayer < 0 ) ...
Design Rule Checker object that performs all the DRC tests.
Definition: drc.h:162
static PICKED_ITEMS_LIST s_PickedList
int GetToolId() const
Definition: draw_frame.h:476
void RemoveVertex(int aGlobalIndex)
Function RemoveVertex deletes the aGlobalIndex-th vertex.
void SetCornerRadius(int aRadius)
void SetIgnoreMouseEvents(bool aIgnore)
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
void Hatch()
Function Hatch computes the hatch lines depending on the hatch parameters and stores it in the zone&#39;s...
#define ZONE_CLEARANCE_WIDTH_STRING_KEY
Definition: zones.h:34
NETINFO_ITEM * FindNet(int aNetcode) const
Function FindNet searches for a net with the given netcode.
ZONE_EDIT_T InvokeCopperZonesEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings)
Function InvokeCopperZonesEditor invokes up a modal dialog window for copper zone editing...
void ClearItemsList()
Function ClearItemsList deletes only the list of pickers, NOT the picked data itself.
PCB_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:283
int GetSelectedCorner() const
Definition: class_zone.h:201
virtual void Delete(BOARD_ITEM *aItem)
Removes an item from the containter and deletes it.
void InsertVertex(int aGlobalIndex, VECTOR2I aNewVertex)
Function InsertVertex Adds a vertex in the globally indexed position aGlobalIndex.
void Delete_Zone_Contour(wxDC *DC, ZONE_CONTAINER *zone_container)
Function Delete_Zone Remove the zone which include the segment aZone, or the zone which have the give...
bool AppendCorner(wxPoint aPosition, int aHoleIdx, bool aAllowDuplication=false)
Add a new corner to the zone outline (to the main outline or a hole)
bool IsHighLightNetON() const
Function IsHighLightNetON.
Definition: class_board.h:381
void SetZoneSettings(const ZONE_SETTINGS &aSettings)
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:882
int Drc(TRACK *aRefSeg, TRACK *aList)
Function Drc tests the current segment and returns the result and displays the error in the status pa...
Definition: drc.cpp:158
ZONE_EDIT_T InvokeKeepoutAreaEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings)
Function InvokeKeepoutAreaEditor invokes up a modal dialog window for copper zone editing...
void RedrawAreasOutlines(EDA_DRAW_PANEL *aPanel, wxDC *aDC, GR_DRAWMODE aDrawMode, PCB_LAYER_ID aLayer)
Function RedrawAreasOutlines Redraw all areas outlines on layer aLayer ( redraw all if aLayer < 0 ) ...
#define ZONE_THERMAL_RELIEF_GAP_MIL
Definition: zones.h:38
int GetHighLightNetCode() const
Function GetHighLightNetCode.
Definition: class_board.h:366
void SetMouseCapture(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback)
Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallb...
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...
BOARD_ITEM * GetCurItem()
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Function DisplayInfoMessage displays an informational message box with aMessage.
Definition: confirm.cpp:105
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
Definition: netinfo.h:461
int GetAreaIndex(const ZONE_CONTAINER *aArea) const
Function GetAreaIndex returns the Area Index for the given Zone Container.
Definition: class_board.h:996
virtual void SetActiveLayer(PCB_LAYER_ID aLayer) override
Function SetActiveLayer will change the currently active layer to aLayer and also update the PCB_LAYE...
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:290
PCB_LAYER_ID m_CurrentZone_Layer
Layer used to create the current zone.
Definition: zone_settings.h:69
void Remove(BOARD_ITEM *aBoardItem) override
Removes an item from the container.
static void Show_New_Edge_While_Move_Mouse(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
void ClearListAndDeleteItems()
Function ClearListAndDeleteItems deletes the list of pickers, AND the data pointed by m_PickedItem or...
long m_ThermalReliefGap
thickness of the gap in thermal reliefs
Definition: zone_settings.h:77
int m_ZoneMinThickness
Min thickness value in filled areas.
Definition: zone_settings.h:64
timestamp_t GetTimeStamp() const
Definition: base_struct.h:233
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:232
void RemoveAllContours(void)
Definition: class_zone.h:449
bool IsDragging() const
Definition: base_struct.h:248
void RemoveContour(int aContourIdx, int aPolygonIdx=-1)
Function RemoveContour deletes the aContourIdx-th contour of the aPolygonIdx-th polygon in the set...
#define IS_MOVED
Item being moved.
Definition: base_struct.h:126