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 <wxPcbStruct.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_stuff.h>
48 #include <connectivity_data.h>
49 
50 // Outline creation:
51 static void Abort_Zone_Create_Outline( EDA_DRAW_PANEL* Panel, wxDC* DC );
52 static void Show_New_Edge_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
53  const wxPoint& aPosition, bool aErase );
54 
55 // Corner moving
56 static void Abort_Zone_Move_Corner_Or_Outlines( EDA_DRAW_PANEL* Panel, wxDC* DC );
58  wxDC* aDC,
59  const wxPoint& aPosition,
60  bool aErase );
61 
62 // Local variables
63 static wxPoint s_CornerInitialPosition; // Used to abort a move corner command
64 static bool s_CornerIsNew; // Used to abort a move corner command (if it is a new corner, it must be deleted)
65 static bool s_AddCutoutToCurrentZone; // if true, the next outline will be added to s_CurrentZone
66 static ZONE_CONTAINER* s_CurrentZone; // if != NULL, these ZONE_CONTAINER params will be used for the next zone
67 static wxPoint s_CursorLastPosition; // in move zone outline, last cursor position. Used to calculate the move vector
68 static PICKED_ITEMS_LIST s_PickedList; // a picked list to save zones for undo/redo command
69 static PICKED_ITEMS_LIST s_AuxiliaryList; // a picked list to store zones that are deleted or added when combined
70 
71 
73 {
74  if( !aZone )
75  return;
76 
78  s_CurrentZone = aZone;
79 
80  // set zone settings to the current zone
81  ZONE_SETTINGS zoneInfo = GetZoneSettings();
82  zoneInfo << *aZone;
83  SetZoneSettings( zoneInfo );
84 
85  // Use the general event handler to set others params (like toolbar)
86  wxCommandEvent evt;
87  evt.SetId( aZone->GetIsKeepout() ? ID_PCB_KEEPOUT_AREA_BUTT : ID_PCB_ZONES_BUTT );
88  OnSelectTool( evt );
89 }
90 
91 
93 {
94  if( !aZone )
95  return;
96 
98  s_CurrentZone = aZone;
99 
100  // set zones setup to the current zone
101  ZONE_SETTINGS zoneInfo = GetZoneSettings();
102  zoneInfo << *aZone;
103  SetZoneSettings( zoneInfo );
104 
105  // Use the general event handle to set others params (like toolbar)
106  wxCommandEvent evt;
107  evt.SetId( aZone->GetIsKeepout() ? ID_PCB_KEEPOUT_AREA_BUTT : ID_PCB_ZONES_BUTT );
108  OnSelectTool( evt );
109 }
110 
111 
113 {
114  ZONE_CONTAINER* newZone = new ZONE_CONTAINER( *aZone );
115  newZone->UnFill();
116  ZONE_SETTINGS zoneSettings;
117  zoneSettings << *aZone;
118 
119  bool success;
120 
121  if( aZone->GetIsKeepout() )
122  success = InvokeKeepoutAreaEditor( this, &zoneSettings );
123  else if( aZone->IsOnCopperLayer() )
124  success = InvokeCopperZonesEditor( this, &zoneSettings );
125  else
126  success = InvokeNonCopperZonesEditor( this, aZone, &zoneSettings );
127 
128  // If the new zone is on the same layer as the the initial zone,
129  // do nothing
130  if( success )
131  {
132  if( aZone->GetIsKeepout() && ( aZone->GetLayerSet() == zoneSettings.m_Layers ) )
133  {
135  this, _( "The duplicated zone cannot be on the same layers as the original zone." ) );
136  success = false;
137  }
138  else if( !aZone->GetIsKeepout() && ( aZone->GetLayer() == zoneSettings.m_CurrentZone_Layer ) )
139  {
141  this, _( "The duplicated zone cannot be on the same layer as the original zone." ) );
142  success = false;
143  }
144  }
145 
146  if( success )
147  {
148  zoneSettings.ExportSetting( *newZone );
149  newZone->Hatch();
150 
151  s_AuxiliaryList.ClearListAndDeleteItems();
152  s_PickedList.ClearListAndDeleteItems();
153  SaveCopyOfZones( s_PickedList, GetBoard(), newZone->GetNetCode(), newZone->GetLayer() );
154  GetBoard()->Add( newZone );
155 
156  ITEM_PICKER picker( newZone, UR_NEW );
157  s_PickedList.PushItem( picker );
158 
159  GetScreen()->SetCurItem( NULL ); // This outline may be deleted when merging outlines
160 
161  // Combine zones if possible
162  GetBoard()->OnAreaPolygonModified( &s_AuxiliaryList, newZone );
163 
164  // Redraw zones
165  GetBoard()->RedrawAreasOutlines( m_canvas, aDC, GR_OR, newZone->GetLayer() );
166  GetBoard()->RedrawFilledAreas( m_canvas, aDC, GR_OR, newZone->GetLayer() );
167 
168  if( GetBoard()->GetAreaIndex( newZone ) >= 0
169  && GetBoard()->Test_Drc_Areas_Outlines_To_Areas_Outlines( newZone, true ) )
170  {
171  DisplayInfoMessage( this, _( "Warning: The new zone fails DRC" ) );
172  }
173 
174  UpdateCopyOfZonesList( s_PickedList, s_AuxiliaryList, GetBoard() );
175  SaveCopyInUndoList( s_PickedList, UR_UNSPECIFIED );
176  s_PickedList.ClearItemsList();
177 
178  OnModify();
179  }
180  else
181  delete newZone;
182 }
183 
184 
186 {
188 
189  if( !zone )
190  return 0;
191 
192  if( !zone->GetNumCorners() )
193  return 0;
194 
195  zone->DrawWhileCreateOutline( m_canvas, DC, GR_XOR );
196 
197  if( zone->GetNumCorners() > 2 )
198  {
199  zone->Outline()->RemoveVertex( zone->GetNumCorners() - 1 );
200 
201  if( m_canvas->IsMouseCaptured() )
202  m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
203  }
204  else
205  {
206  m_canvas->SetMouseCapture( NULL, NULL );
207  SetCurItem( NULL );
208  zone->RemoveAllContours();
209  zone->ClearFlags();
210  }
211 
212  return zone->GetNumCorners();
213 }
214 
215 
220 static void Abort_Zone_Create_Outline( EDA_DRAW_PANEL* Panel, wxDC* DC )
221 {
222  PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Panel->GetParent();
223  ZONE_CONTAINER* zone = pcbframe->GetBoard()->m_CurrentZoneContour;
224 
225  if( zone )
226  {
227  zone->DrawWhileCreateOutline( Panel, DC, GR_XOR );
228  zone->RemoveAllContours();
229  if( zone->IsNew() )
230  {
231  delete zone;
232  pcbframe->GetBoard()->m_CurrentZoneContour = NULL;
233  }
234  else
235  zone->ClearFlags();
236  }
237 
238  pcbframe->SetCurItem( NULL );
239  s_AddCutoutToCurrentZone = false;
240  s_CurrentZone = NULL;
241  Panel->SetMouseCapture( NULL, NULL );
242 }
243 
244 
246  int corner_id, bool IsNewCorner )
247 {
248  if( aZone->IsOnCopperLayer() ) // Show the Net
249  {
250  if( GetBoard()->IsHighLightNetON() && DC )
251  {
252  HighLight( DC ); // Remove old highlight selection
253  }
254 
255  ZONE_SETTINGS zoneInfo = GetZoneSettings();
256  zoneInfo.m_NetcodeSelection = aZone->GetNetCode();
257  SetZoneSettings( zoneInfo );
258 
259  GetBoard()->SetHighLightNet( aZone->GetNetCode() );
260 
261  if( DC )
262  HighLight( DC );
263  }
264 
265 
266  // Prepare copy of old zones, for undo/redo.
267  // if the corner is new, remove it from list, save and insert it in list
268  VECTOR2I corner = aZone->Outline()->Vertex( corner_id );
269 
270  if ( IsNewCorner )
271  aZone->Outline()->RemoveVertex( corner_id );
272 
273  s_AuxiliaryList.ClearListAndDeleteItems();
274  s_PickedList.ClearListAndDeleteItems();
275 
276  SaveCopyOfZones( s_PickedList, GetBoard(), aZone->GetNetCode(), aZone->GetLayer() );
277 
278  if ( IsNewCorner )
279  aZone->Outline()->InsertVertex(corner_id-1, corner );
280 
281  aZone->SetFlags( IN_EDIT );
284  s_CornerInitialPosition = static_cast<wxPoint>( aZone->GetCornerPosition( corner_id ) );
285  s_CornerIsNew = IsNewCorner;
286  s_AddCutoutToCurrentZone = false;
287  s_CurrentZone = NULL;
288 }
289 
290 
292  ZONE_CONTAINER* aZone,
293  int corner_id )
294 {
295  aZone->SetFlags( IS_DRAGGED );
296  aZone->SetSelectedCorner( corner_id );
299  s_CursorLastPosition = s_CornerInitialPosition = GetCrossHairPosition();
300  s_AddCutoutToCurrentZone = false;
301  s_CurrentZone = NULL;
302 
303  s_PickedList.ClearListAndDeleteItems();
304  s_AuxiliaryList.ClearListAndDeleteItems();
305  SaveCopyOfZones( s_PickedList, GetBoard(), aZone->GetNetCode(), aZone->GetLayer() );
306 }
307 
308 
310 {
311  // Show the Net
312  if( aZone->IsOnCopperLayer() ) // Show the Net
313  {
314  if( GetBoard()->IsHighLightNetON() )
315  {
316  HighLight( DC ); // Remove old highlight selection
317  }
318 
319  ZONE_SETTINGS zoneInfo = GetZoneSettings();
320  zoneInfo.m_NetcodeSelection = aZone->GetNetCode();
321  SetZoneSettings( zoneInfo );
322 
323  GetBoard()->SetHighLightNet( aZone->GetNetCode() );
324  HighLight( DC );
325  }
326 
327  s_PickedList.ClearListAndDeleteItems();
328  s_AuxiliaryList.ClearListAndDeleteItems();
329  SaveCopyOfZones( s_PickedList, GetBoard(), aZone->GetNetCode(), aZone->GetLayer() );
330 
331  aZone->SetFlags( IS_MOVED );
334  s_CursorLastPosition = s_CornerInitialPosition = GetCrossHairPosition();
335  s_CornerIsNew = false;
336  s_AddCutoutToCurrentZone = false;
337  s_CurrentZone = NULL;
338 }
339 
340 
342 {
343  aZone->ClearFlags();
344  m_canvas->SetMouseCapture( NULL, NULL );
345 
346  if( DC )
347  aZone->Draw( m_canvas, DC, GR_OR );
348 
349  OnModify();
350  s_AddCutoutToCurrentZone = false;
351  s_CurrentZone = NULL;
352 
353  SetCurItem( NULL ); // This outline can be deleted when merging outlines
354 
355  // Combine zones if possible
356  GetBoard()->OnAreaPolygonModified( &s_AuxiliaryList, aZone );
357  m_canvas->Refresh();
358 
359  int ii = GetBoard()->GetAreaIndex( aZone ); // test if aZone exists
360 
361  if( ii < 0 )
362  aZone = NULL; // was removed by combining zones
363 
364  UpdateCopyOfZonesList( s_PickedList, s_AuxiliaryList, GetBoard() );
365  SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED);
366  s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
367 
368  int error_count = GetBoard()->Test_Drc_Areas_Outlines_To_Areas_Outlines( aZone, true );
369 
370  if( error_count )
371  {
372  DisplayErrorMessage( this, _( "Area: DRC outline error" ) );
373  }
374 }
375 
376 
378 {
379  OnModify();
380 
381  if( aZone->Outline()->TotalVertices() <= 3 )
382  {
384 
385  if( DC )
386  { // Remove the full zone because this is no more an area
387  aZone->UnFill();
388  aZone->DrawFilledArea( m_canvas, DC, GR_XOR );
389  }
390 
391  GetBoard()->Delete( aZone );
392  return;
393  }
394 
395  PCB_LAYER_ID layer = aZone->GetLayer();
396 
397  if( DC )
398  {
399  GetBoard()->RedrawAreasOutlines( m_canvas, DC, GR_XOR, layer );
400  GetBoard()->RedrawFilledAreas( m_canvas, DC, GR_XOR, layer );
401  }
402 
403  s_AuxiliaryList.ClearListAndDeleteItems();
404  s_PickedList. ClearListAndDeleteItems();
405  SaveCopyOfZones( s_PickedList, GetBoard(), aZone->GetNetCode(), aZone->GetLayer() );
406  aZone->Outline()->RemoveVertex( aZone->GetSelectedCorner() );
407 
408  // modify zones outlines according to the new aZone shape
409  GetBoard()->OnAreaPolygonModified( &s_AuxiliaryList, aZone );
410 
411  if( DC )
412  {
413  GetBoard()->RedrawAreasOutlines( m_canvas, DC, GR_OR, layer );
414  GetBoard()->RedrawFilledAreas( m_canvas, DC, GR_OR, layer );
415  }
416 
417  UpdateCopyOfZonesList( s_PickedList, s_AuxiliaryList, GetBoard() );
418  SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED);
419  s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
420 
421  int ii = GetBoard()->GetAreaIndex( aZone ); // test if aZone exists
422 
423  if( ii < 0 )
424  aZone = NULL; // aZone does not exist anymore, after combining zones
425 
426  int error_count = GetBoard()->Test_Drc_Areas_Outlines_To_Areas_Outlines( aZone, true );
427 
428  if( error_count )
429  {
430  DisplayErrorMessage( this, _( "Area: DRC outline error" ) );
431  }
432 }
433 
434 
440 {
441  PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Panel->GetParent();
442  ZONE_CONTAINER* zone = (ZONE_CONTAINER*) pcbframe->GetCurItem();
443 
444  if( zone->IsMoving() )
445  {
446  wxPoint offset;
447  offset = s_CornerInitialPosition - s_CursorLastPosition;
448  zone->Move( offset );
449  }
450  else if( zone->IsDragging() )
451  {
452  wxPoint offset = s_CornerInitialPosition - s_CursorLastPosition;
453  int selection = zone->GetSelectedCorner();
454  zone->MoveEdge( offset, selection );
455  }
456  else
457  {
458  if( s_CornerIsNew )
459  {
460  zone->Outline()->RemoveVertex( zone->GetSelectedCorner() );
461  }
462  else
463  {
465  zone->Outline()->Vertex( zone->GetSelectedCorner() ) = pos;
466  }
467  }
468 
469  Panel->SetMouseCapture( NULL, NULL );
470  s_AuxiliaryList.ClearListAndDeleteItems();
471  s_PickedList. ClearListAndDeleteItems();
472  Panel->Refresh();
473 
474  pcbframe->SetCurItem( NULL );
475  zone->ClearFlags();
476  s_AddCutoutToCurrentZone = false;
477  s_CurrentZone = NULL;
478 }
479 
480 
483  const wxPoint& aPosition, bool aErase )
484 {
485  PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) aPanel->GetParent();
486  ZONE_CONTAINER* zone = (ZONE_CONTAINER*) pcbframe->GetCurItem();
487 
488  if( aErase ) // Undraw edge in old position
489  {
490  zone->Draw( aPanel, aDC, GR_XOR );
491  }
492 
493  wxPoint pos = pcbframe->GetCrossHairPosition();
494 
495  if( zone->IsMoving() )
496  {
497  wxPoint offset;
498  offset = pos - s_CursorLastPosition;
499  zone->Move( offset );
500  s_CursorLastPosition = pos;
501  }
502  else if( zone->IsDragging() )
503  {
504  wxPoint offset = pos - s_CursorLastPosition;
505  int selection = zone->GetSelectedCorner();
506  zone->MoveEdge( offset, selection );
507  s_CursorLastPosition = pos;
508  }
509  else
510  {
511  zone->Outline()->Vertex( zone->GetSelectedCorner() ) = pos;
512  }
513 
514  zone->Draw( aPanel, aDC, GR_XOR );
515 }
516 
517 
518 
520 {
521  ZONE_SETTINGS zoneInfo = GetZoneSettings();
522 
523  // verify if s_CurrentZone exists (could be deleted since last selection) :
524  int ii;
525  for( ii = 0; ii < GetBoard()->GetAreaCount(); ii++ )
526  {
527  if( s_CurrentZone == GetBoard()->GetArea( ii ) )
528  break;
529  }
530 
531  if( ii >= GetBoard()->GetAreaCount() ) // Not found: could be deleted since last selection
532  {
533  s_AddCutoutToCurrentZone = false;
534  s_CurrentZone = NULL;
535  }
536 
538 
539  // Verify if a new zone is allowed on this layer:
540  if( zone == NULL )
541  {
543  {
544  DisplayErrorMessage( this,
545  _( "Error: a keepout area is allowed only on copper layers" ) );
546  return 0;
547  }
548  }
549 
550  // If no zone contour in progress, a new zone is being created,
551  if( zone == NULL )
552  {
554  zone->SetFlags( IS_NEW );
555  zone->SetTimeStamp( GetNewTimeStamp() );
556  }
557 
558  if( zone->GetNumCorners() == 0 ) // Start a new contour: init zone params (net, layer ...)
559  {
560  if( !s_CurrentZone ) // A new outline is created, from scratch
561  {
562  ZONE_EDIT_T edited;
563 
564  // Prompt user for parameters:
566 
567  if( IsCopperLayer( GetActiveLayer() ) )
568  {
569  // Put a zone on a copper layer
570  if( GetBoard()->GetHighLightNetCode() > 0 )
571  {
573  zone->SetNetCode( zoneInfo.m_NetcodeSelection );
574  }
575 
576  double tmp = ZONE_THERMAL_RELIEF_GAP_MIL;
577 
578  wxConfigBase* cfg = Kiface().KifaceSettings();
579  cfg->Read( ZONE_THERMAL_RELIEF_GAP_STRING_KEY, &tmp );
580  zoneInfo.m_ThermalReliefGap = KiROUND( tmp * IU_PER_MILS);
581 
584  zoneInfo.m_ThermalReliefCopperBridge = KiROUND( tmp * IU_PER_MILS );
585 
586  tmp = ZONE_CLEARANCE_MIL;
587  cfg->Read( ZONE_CLEARANCE_WIDTH_STRING_KEY, &tmp );
588  zoneInfo.m_ZoneClearance = KiROUND( tmp * IU_PER_MILS );
589 
590  tmp = ZONE_THICKNESS_MIL;
591  cfg->Read( ZONE_MIN_THICKNESS_WIDTH_STRING_KEY, &tmp );
592  zoneInfo.m_ZoneMinThickness = KiROUND( tmp * IU_PER_MILS );
593 
595  {
596  zoneInfo.SetIsKeepout( true );
597  // Netcode, netname and some other settings are irrelevant,
598  // so ensure they are cleared
601  zoneInfo.SetCornerRadius( 0 );
602 
603  edited = InvokeKeepoutAreaEditor( this, &zoneInfo );
604  }
605  else
606  {
607  zoneInfo.m_CurrentZone_Layer = GetActiveLayer(); // Preselect a layer
608  zoneInfo.SetIsKeepout( false );
609  edited = InvokeCopperZonesEditor( this, &zoneInfo );
610  }
611  }
612  else // Put a zone on a non copper layer (technical layer)
613  {
614  zone->SetLayer( GetActiveLayer() ); // Preselect a layer
615  zoneInfo.SetIsKeepout( false );
616  zoneInfo.m_NetcodeSelection = 0; // No net for non copper zones
617  edited = InvokeNonCopperZonesEditor( this, zone, &zoneInfo );
618  }
619 
621  m_canvas->SetIgnoreMouseEvents( false );
622 
623  if( edited == ZONE_ABORT )
624  {
625  GetBoard()->m_CurrentZoneContour = NULL;
626  delete zone;
627  return 0;
628  }
629 
630  // Switch active layer to the selected zone layer
632  SetZoneSettings( zoneInfo );
633  }
634  else
635  {
636  // Start a new contour: init zone params (net and layer) from an existing
637  // zone (add cutout or similar zone)
638 
639  zoneInfo.m_CurrentZone_Layer = s_CurrentZone->GetLayer();
640  SetActiveLayer( s_CurrentZone->GetLayer() );
641 
642  zoneInfo << *s_CurrentZone;
643 
644  SetZoneSettings( zoneInfo );
645  }
646 
647  // Show the Net for zones on copper layers
648  if( IsCopperLayer( zoneInfo.m_CurrentZone_Layer ) &&
649  !zoneInfo.GetIsKeepout() )
650  {
651  if( s_CurrentZone )
652  {
653  zoneInfo.m_NetcodeSelection = s_CurrentZone->GetNetCode();
654  GetBoard()->SetZoneSettings( zoneInfo );
655  }
656 
657  if( GetBoard()->IsHighLightNetON() )
658  {
659  HighLight( DC ); // Remove old highlight selection
660  }
661 
663  HighLight( DC );
664  }
665 
667  s_CurrentZone = NULL; // the zone is used only once ("add similar zone" command)
668  }
669 
670  // if first segment
671  if( zone->GetNumCorners() == 0 )
672  {
673  zoneInfo.ExportSetting( *zone );
674 
675  // A duplicated corner is needed; null segments are removed when the zone is finished.
676  zone->AppendCorner( GetCrossHairPosition(), -1 );
677  // Add the duplicate corner:
678  zone->AppendCorner( GetCrossHairPosition(), -1, true );
679 
680  if( Settings().m_legacyDrcOn && (m_drc->Drc( zone, 0 ) == BAD_DRC) && zone->IsOnCopperLayer() )
681  {
682  zone->ClearFlags();
683  zone->RemoveAllContours();
684 
685  // use the form of SetCurItem() which does not write to the msg panel,
686  // SCREEN::SetCurItem(), so the DRC error remains on screen.
687  // PCB_EDIT_FRAME::SetCurItem() calls DisplayInfo().
688  GetScreen()->SetCurItem( NULL );
689  DisplayErrorMessage( this,
690  _( "DRC error: this start point is inside or too close an other area" ) );
691  return 0;
692  }
693 
694  SetCurItem( zone );
696  }
697  else // edge in progress:
698  {
699  ii = zone->GetNumCorners() - 1;
700 
701  // edge in progress : the current corner coordinate was set
702  // by Show_New_Edge_While_Move_Mouse
703  if( zone->GetCornerPosition( ii - 1 ) != zone->GetCornerPosition( ii ) )
704  {
705  if( !Settings().m_legacyDrcOn || !zone->IsOnCopperLayer() || ( m_drc->Drc( zone, ii - 1 ) == OK_DRC ) )
706  {
707  // Ok, we can add a new corner
708  if( m_canvas->IsMouseCaptured() )
709  m_canvas->CallMouseCapture( DC, wxPoint(0,0), false );
710 
711  // It is necessary to allow duplication of the points, as we have to handle the
712  // continuous drawing while creating the zone at the same time as we build it. Null
713  // segments are removed when the zone is finished, in End_Zone.
714  zone->AppendCorner( GetCrossHairPosition(), -1, true );
715 
716  SetCurItem( zone ); // calls DisplayInfo().
717 
718  if( m_canvas->IsMouseCaptured() )
719  m_canvas->CallMouseCapture( DC, wxPoint(0,0), false );
720  }
721  }
722  }
723 
724  return zone->GetNumCorners();
725 }
726 
727 
728 bool PCB_EDIT_FRAME::End_Zone( wxDC* DC )
729 {
731 
732  if( !zone )
733  return true;
734 
735  // Validate the current outline:
736  if( zone->GetNumCorners() <= 2 ) // An outline must have 3 corners or more
737  {
739  return true;
740  }
741 
742  // Remove the last corner if is is at the same location as the prevoius corner
743  zone->Outline()->RemoveNullSegments();
744 
745  // Validate the current edge:
746  int icorner = zone->GetNumCorners() - 1;
747  if( zone->IsOnCopperLayer() )
748  {
749  if( Settings().m_legacyDrcOn && m_drc->Drc( zone, icorner - 1 ) == BAD_DRC ) // we can't validate last edge
750  return false;
751 
752  if( Settings().m_legacyDrcOn && m_drc->Drc( zone, icorner ) == BAD_DRC ) // we can't validate the closing edge
753  {
754  DisplayErrorMessage( this,
755  _( "DRC error: closing this area creates a DRC error with an other area" ) );
757  return false;
758  }
759  }
760 
761  zone->ClearFlags();
762 
763  zone->DrawWhileCreateOutline( m_canvas, DC, GR_XOR );
764 
765  m_canvas->SetMouseCapture( NULL, NULL );
766 
767  // Undraw old drawings, because they can have important changes
768  PCB_LAYER_ID layer = zone->GetLayer();
769  GetBoard()->RedrawAreasOutlines( m_canvas, DC, GR_XOR, layer );
770  GetBoard()->RedrawFilledAreas( m_canvas, DC, GR_XOR, layer );
771 
772  // Save initial zones configuration, for undo/redo, before adding new zone
773  s_AuxiliaryList.ClearListAndDeleteItems();
774  s_PickedList.ClearListAndDeleteItems();
775  SaveCopyOfZones(s_PickedList, GetBoard(), zone->GetNetCode(), zone->GetLayer() );
776 
777  // Put new zone in list
778  if( !s_CurrentZone )
779  {
780  GetBoard()->Add( zone );
781 
782  // Add this zone in picked list, as new item
783  ITEM_PICKER picker( zone, UR_NEW );
784  s_PickedList.PushItem( picker );
785  }
786  else // Append this outline as a cutout to an existing zone
787  {
788  s_CurrentZone->Outline()->AddHole( zone->Outline()->Outline( 0 ) );
789 
790  zone->RemoveAllContours(); // All corners are copied in s_CurrentZone. Free corner list.
791  zone = s_CurrentZone;
792  }
793 
794  s_AddCutoutToCurrentZone = false;
795  s_CurrentZone = NULL;
796  GetBoard()->m_CurrentZoneContour = NULL;
797 
798  GetScreen()->SetCurItem( NULL ); // This outline can be deleted when merging outlines
799 
800  // Combine zones if possible :
801  GetBoard()->OnAreaPolygonModified( &s_AuxiliaryList, zone );
802 
803  // Redraw the real edge zone :
804  GetBoard()->RedrawAreasOutlines( m_canvas, DC, GR_OR, layer );
805  GetBoard()->RedrawFilledAreas( m_canvas, DC, GR_OR, layer );
806 
807  int ii = GetBoard()->GetAreaIndex( zone ); // test if zone exists
808 
809  if( ii < 0 )
810  zone = NULL; // was removed by combining zones
811 
812  int error_count = GetBoard()->Test_Drc_Areas_Outlines_To_Areas_Outlines( zone, true );
813 
814  if( error_count )
815  {
816  DisplayErrorMessage( this, _( "Area: DRC outline error" ) );
817  }
818 
819  UpdateCopyOfZonesList( s_PickedList, s_AuxiliaryList, GetBoard() );
820  SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED);
821  s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
822 
823  OnModify();
824  return true;
825 }
826 
827 
828 /* Redraws the zone outlines when moving mouse
829  */
830 static void Show_New_Edge_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
831  const wxPoint& aPosition, bool aErase )
832 {
833  PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) aPanel->GetParent();
834  wxPoint c_pos = pcbframe->GetCrossHairPosition();
835  ZONE_CONTAINER* zone = pcbframe->GetBoard()->m_CurrentZoneContour;
836 
837  if( !zone )
838  return;
839 
840  int icorner = zone->GetNumCorners() - 1;
841 
842  if( icorner < 1 )
843  return; // We must have 2 (or more) corners
844 
845  if( aErase ) // Undraw edge in old position
846  {
847  zone->DrawWhileCreateOutline( aPanel, aDC );
848  }
849 
850  // Redraw the current edge in its new position
851  if( pcbframe->GetZoneSettings().m_Zone_45_Only )
852  {
853  // calculate the new position as allowed
854  wxPoint StartPoint = static_cast<wxPoint>( zone->GetCornerPosition( icorner - 1 ) );
855  c_pos = CalculateSegmentEndPoint( c_pos, StartPoint );
856  }
857 
858  zone->SetCornerPosition( icorner, c_pos );
859 
860  zone->DrawWhileCreateOutline( aPanel, aDC );
861 }
862 
864 {
865  ZONE_EDIT_T edited;
866  ZONE_SETTINGS zoneInfo = GetZoneSettings();
867 
868  BOARD_COMMIT commit( this );
870 
871  // Save initial zones configuration, for undo/redo, before adding new zone
872  // note the net name and the layer can be changed, so we must save all zones
873  s_AuxiliaryList.ClearListAndDeleteItems();
874  s_PickedList.ClearListAndDeleteItems();
875  SaveCopyOfZones( s_PickedList, GetBoard(), -1, UNDEFINED_LAYER );
876 
877  if( aZone->GetIsKeepout() )
878  {
879  // edit a keepout area on a copper layer
880  zoneInfo << *aZone;
881  edited = InvokeKeepoutAreaEditor( this, &zoneInfo );
882  }
883  else if( IsCopperLayer( aZone->GetLayer() ) )
884  {
885  // edit a zone on a copper layer
886 
887  zoneInfo << *aZone;
888 
889  edited = InvokeCopperZonesEditor( this, &zoneInfo );
890  }
891  else
892  {
893  edited = InvokeNonCopperZonesEditor( this, aZone, &zoneInfo );
894  }
895 
897  m_canvas->SetIgnoreMouseEvents( false );
898 
899  if( edited == ZONE_ABORT )
900  {
901  s_AuxiliaryList.ClearListAndDeleteItems();
902  s_PickedList.ClearListAndDeleteItems();
903  return;
904  }
905 
906  SetZoneSettings( zoneInfo );
907 
908  if( edited == ZONE_EXPORT_VALUES )
909  {
910  UpdateCopyOfZonesList( s_PickedList, s_AuxiliaryList, GetBoard() );
911  commit.Stage( s_PickedList );
912  commit.Push( _( "Modify zone properties" ) );
913  s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
914  return;
915  }
916 
917  // Undraw old zone outlines
918  for( int ii = 0; ii < GetBoard()->GetAreaCount(); ii++ )
919  {
920  ZONE_CONTAINER* edge_zone = GetBoard()->GetArea( ii );
921  edge_zone->Draw( m_canvas, DC, GR_XOR );
922 
923  if( IsGalCanvasActive() )
924  {
925  GetGalCanvas()->GetView()->Update( edge_zone );
926  }
927  }
928 
929  zoneInfo.ExportSetting( *aZone );
930 
931  NETINFO_ITEM* net = GetBoard()->FindNet( zoneInfo.m_NetcodeSelection );
932 
933  if( net ) // net == NULL should not occur
934  aZone->SetNetCode( net->GetNet() );
935 
936  // Combine zones if possible
937  GetBoard()->OnAreaPolygonModified( &s_AuxiliaryList, aZone );
938 
939  // Redraw the real new zone outlines
941 
942  UpdateCopyOfZonesList( s_PickedList, s_AuxiliaryList, GetBoard() );
943 
944  // refill zones with the new properties applied
945  for( unsigned i = 0; i < s_PickedList.GetCount(); ++i )
946  {
947  auto zone = dyn_cast<ZONE_CONTAINER*>( s_PickedList.GetPickedItem( i ) );
948 
949  if( zone == nullptr )
950  {
951  wxASSERT_MSG( false, "Expected a zone after zone properties edit" );
952  continue;
953  }
954 
955  if( zone->IsFilled() )
956  {
957  Fill_Zone( zone );
958  }
959  }
960 
961  commit.Stage( s_PickedList );
962  commit.Push( _( "Modify zone properties" ) );
963  GetBoard()->GetConnectivity()->RecalculateRatsnest();
964 
965  s_PickedList.ClearItemsList(); // s_ItemsListPicker is no longer owner of picked items
966 }
967 
968 
970 {
971  // Get contour in which the selected corner is
973 
974  // If the selected corner does not exist, abort
975  if( !aZone->Outline()->GetRelativeIndices( aZone->GetSelectedCorner(), &indices ) )
976  throw( std::out_of_range( "Zone selected corner does not exist" ) );
977 
978  EDA_RECT dirty = aZone->GetBoundingBox();
979 
980  // For compatibility with old boards: remove old SEGZONE fill segments
981  Delete_OldZone_Fill( NULL, aZone->GetTimeStamp() );
982 
983  // Remove current filling:
984  aZone->UnFill();
985 
986  if( indices.m_contour == 0 ) // This is the main outline: remove all
987  {
988  SaveCopyInUndoList( aZone, UR_DELETED );
989  GetBoard()->Remove( aZone );
990  }
991 
992  else
993  {
994  SaveCopyInUndoList( aZone, UR_CHANGED );
995  aZone->Outline()->RemoveContour( indices.m_contour, indices.m_polygon );
996  }
997 
998  m_canvas->RefreshDrawingRect( dirty );
999 
1000  OnModify();
1001 }
void MoveEdge(const wxPoint &offset, int aEdge)
Function MoveEdge Move the outline Edge.
Definition: class_zone.cpp:921
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:283
virtual void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
Definition: pcbframe.cpp:1001
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
void SetZoneSettings(const ZONE_SETTINGS &aSettings)
Definition: class_board.h:557
#define OK_DRC
Definition: drc_stuff.h:35
void SetCurItem(BOARD_ITEM *aItem)
Function SetCurItem sets the currently selected object, m_CurrentItem.
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:552
bool IsMoving() const
Definition: base_struct.h:232
#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:480
bool End_Zone(wxDC *DC)
Function End_Zone terminates (if no DRC error ) the zone edge creation process.
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:106
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:325
static bool s_CornerIsNew
This file is part of the common library.
bool IsNew() const
Definition: base_struct.h:230
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:525
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
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:413
ZONE_EDIT_T
Exit codes for zone editing dialogs.
Definition: zones.h:47
const ZONE_SETTINGS & GetZoneSettings() const
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:182
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.
time_t GetNewTimeStamp()
Definition: common.cpp:166
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:262
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:305
void OnSelectTool(wxCommandEvent &aEvent)
Definition: edit.cpp:1424
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
Definition: wxPcbStruct.h:96
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:347
const VECTOR2I & GetCornerPosition(int aCornerIndex) const
Definition: class_zone.h:520
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
void SetTimeStamp(time_t aNewTimeStamp)
Definition: base_struct.h:217
wxPoint CalculateSegmentEndPoint(const wxPoint &aPosition, const wxPoint &aOrigin)
Determine end point for a segment direction 0, 90, or 45 degrees depending on it's position from the ...
Definition: editrack.cpp:831
static wxPoint s_CursorLastPosition
static PICKED_ITEMS_LIST s_AuxiliaryList
#define BAD_DRC
Definition: drc_stuff.h:36
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:672
#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.
PCB_LAYER_ID
A quick note on layer IDs:
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString aExtraInfo)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:87
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:267
if values were exported to others zones
Definition: zones.h:50
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 Delete_OldZone_Fill(SEGZONE *aZone, time_t aTimestamp=0)
Function Delete_OldZone_Fill (obsolete) Used for compatibility with old boards Remove the zone fillin...
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:209
bool UnFill()
Function UnFill Removes the zone filling.
Definition: class_zone.cpp:157
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.
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:862
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString aExtraInfo)
Function DisplayInfoMessage displays an informational message box with aMessage.
Definition: confirm.cpp:104
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:1011
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
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 Fill_Zone(ZONE_CONTAINER *aZone)
Function Fill_Zone Calculate the zone filling for the outline zone_container The zone outline is a fr...
int GetNet() const
Function GetNet.
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:199
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:1385
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:236
void Add_Zone_Cutout(wxDC *DC, ZONE_CONTAINER *zone_container)
Function Add_Zone_Cutout Add a cutout zone to a given zone outline.
time_t GetTimeStamp() const
Definition: base_struct.h:218
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.
void Move(const wxPoint &offset) override
Function Move Move the outlines.
Definition: class_zone.cpp:904
Definition: gr_basic.h:42
int GetNetCode() const
Function GetNetCode.
void SetHighLightNet(int aNetCode)
Function SetHighLightNet.
Definition: class_board.h:372
#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: class_netinfo.h:69
bool IsOnCopperLayer() const
Function IsOnCopperLayer.
Definition: class_zone.cpp:188
#define ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY
Definition: zones.h:33
void SetCornerPosition(int aCornerIndex, wxPoint new_pos)
Definition: class_zone.h:531
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.
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 ) ...
static PICKED_ITEMS_LIST s_PickedList
int GetToolId() const
Definition: draw_frame.h:471
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.
void Hatch()
Function Hatch computes the hatch lines depending on the hatch parameters and stores it in the zone'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:268
int GetSelectedCorner() const
Definition: class_zone.h:227
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:870
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:155
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
int Test_Drc_Areas_Outlines_To_Areas_Outlines(ZONE_CONTAINER *aArea_To_Examine, bool aCreate_Markers)
Function Test_Drc_Areas_Outlines_To_Areas_Outlines tests area outlines for DRC: Tests areas inside ot...
void SetMouseCapture(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback)
Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallb...
BOARD_ITEM * GetCurItem()
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 ...
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...
Definition: pcbframe.cpp:890
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.
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
int m_ZoneMinThickness
Min thickness value in filled areas.
void RemoveAllContours(void)
Definition: class_zone.h:515
bool IsDragging() const
Definition: base_struct.h:233
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