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-2015 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 <ratsnest_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 && ( aZone->GetLayer() == zoneSettings.m_CurrentZone_Layer ) )
131  {
132  DisplayError( this,
133  _( "The duplicated zone cannot be on the same layer as the original zone." ) );
134  success = false;
135  }
136 
137  if( success )
138  {
139  zoneSettings.ExportSetting( *newZone );
140  newZone->Hatch();
141 
142  s_AuxiliaryList.ClearListAndDeleteItems();
143  s_PickedList.ClearListAndDeleteItems();
144  SaveCopyOfZones( s_PickedList, GetBoard(), newZone->GetNetCode(), newZone->GetLayer() );
145  GetBoard()->Add( newZone );
146 
147  ITEM_PICKER picker( newZone, UR_NEW );
148  s_PickedList.PushItem( picker );
149 
150  GetScreen()->SetCurItem( NULL ); // This outline may be deleted when merging outlines
151 
152  // Combine zones if possible
153  GetBoard()->OnAreaPolygonModified( &s_AuxiliaryList, newZone );
154 
155  // Redraw zones
156  GetBoard()->RedrawAreasOutlines( m_canvas, aDC, GR_OR, newZone->GetLayer() );
157  GetBoard()->RedrawFilledAreas( m_canvas, aDC, GR_OR, newZone->GetLayer() );
158 
159  if( GetBoard()->GetAreaIndex( newZone ) >= 0
160  && GetBoard()->Test_Drc_Areas_Outlines_To_Areas_Outlines( newZone, true ) )
161  {
162  DisplayInfoMessage( this, _( "Warning: The new zone fails DRC" ) );
163  }
164 
165  UpdateCopyOfZonesList( s_PickedList, s_AuxiliaryList, GetBoard() );
166  SaveCopyInUndoList( s_PickedList, UR_UNSPECIFIED );
167  s_PickedList.ClearItemsList();
168 
169  OnModify();
170  }
171  else
172  delete newZone;
173 }
174 
175 
177 {
179 
180  if( !zone )
181  return 0;
182 
183  if( !zone->GetNumCorners() )
184  return 0;
185 
186  zone->DrawWhileCreateOutline( m_canvas, DC, GR_XOR );
187 
188  if( zone->GetNumCorners() > 2 )
189  {
190  zone->Outline()->RemoveVertex( zone->GetNumCorners() - 1 );
191 
192  if( m_canvas->IsMouseCaptured() )
193  m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
194  }
195  else
196  {
197  m_canvas->SetMouseCapture( NULL, NULL );
198  SetCurItem( NULL );
199  zone->RemoveAllContours();
200  zone->ClearFlags();
201  }
202 
203  return zone->GetNumCorners();
204 }
205 
206 
211 static void Abort_Zone_Create_Outline( EDA_DRAW_PANEL* Panel, wxDC* DC )
212 {
213  PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Panel->GetParent();
214  ZONE_CONTAINER* zone = pcbframe->GetBoard()->m_CurrentZoneContour;
215 
216  if( zone )
217  {
218  zone->DrawWhileCreateOutline( Panel, DC, GR_XOR );
219  zone->RemoveAllContours();
220  if( zone->IsNew() )
221  {
222  delete zone;
223  pcbframe->GetBoard()->m_CurrentZoneContour = NULL;
224  }
225  else
226  zone->ClearFlags();
227  }
228 
229  pcbframe->SetCurItem( NULL );
230  s_AddCutoutToCurrentZone = false;
231  s_CurrentZone = NULL;
232  Panel->SetMouseCapture( NULL, NULL );
233 }
234 
235 
237  int corner_id, bool IsNewCorner )
238 {
239  if( aZone->IsOnCopperLayer() ) // Show the Net
240  {
241  if( GetBoard()->IsHighLightNetON() && DC )
242  {
243  HighLight( DC ); // Remove old highlight selection
244  }
245 
246  ZONE_SETTINGS zoneInfo = GetZoneSettings();
247  zoneInfo.m_NetcodeSelection = aZone->GetNetCode();
248  SetZoneSettings( zoneInfo );
249 
250  GetBoard()->SetHighLightNet( aZone->GetNetCode() );
251 
252  if( DC )
253  HighLight( DC );
254  }
255 
256 
257  // Prepare copy of old zones, for undo/redo.
258  // if the corner is new, remove it from list, save and insert it in list
259  VECTOR2I corner = aZone->Outline()->Vertex( corner_id );
260 
261  if ( IsNewCorner )
262  aZone->Outline()->RemoveVertex( corner_id );
263 
264  s_AuxiliaryList.ClearListAndDeleteItems();
265  s_PickedList.ClearListAndDeleteItems();
266 
267  SaveCopyOfZones( s_PickedList, GetBoard(), aZone->GetNetCode(), aZone->GetLayer() );
268 
269  if ( IsNewCorner )
270  aZone->Outline()->InsertVertex(corner_id-1, corner );
271 
272  aZone->SetFlags( IN_EDIT );
275  s_CornerInitialPosition = static_cast<wxPoint>( aZone->GetCornerPosition( corner_id ) );
276  s_CornerIsNew = IsNewCorner;
277  s_AddCutoutToCurrentZone = false;
278  s_CurrentZone = NULL;
279 }
280 
281 
283  ZONE_CONTAINER* aZone,
284  int corner_id )
285 {
286  aZone->SetFlags( IS_DRAGGED );
287  aZone->SetSelectedCorner( corner_id );
290  s_CursorLastPosition = s_CornerInitialPosition = GetCrossHairPosition();
291  s_AddCutoutToCurrentZone = false;
292  s_CurrentZone = NULL;
293 
294  s_PickedList.ClearListAndDeleteItems();
295  s_AuxiliaryList.ClearListAndDeleteItems();
296  SaveCopyOfZones( s_PickedList, GetBoard(), aZone->GetNetCode(), aZone->GetLayer() );
297 }
298 
299 
301 {
302  // Show the Net
303  if( aZone->IsOnCopperLayer() ) // Show the Net
304  {
305  if( GetBoard()->IsHighLightNetON() )
306  {
307  HighLight( DC ); // Remove old highlight selection
308  }
309 
310  ZONE_SETTINGS zoneInfo = GetZoneSettings();
311  zoneInfo.m_NetcodeSelection = aZone->GetNetCode();
312  SetZoneSettings( zoneInfo );
313 
314  GetBoard()->SetHighLightNet( aZone->GetNetCode() );
315  HighLight( DC );
316  }
317 
318  s_PickedList.ClearListAndDeleteItems();
319  s_AuxiliaryList.ClearListAndDeleteItems();
320  SaveCopyOfZones( s_PickedList, GetBoard(), aZone->GetNetCode(), aZone->GetLayer() );
321 
322  aZone->SetFlags( IS_MOVED );
325  s_CursorLastPosition = s_CornerInitialPosition = GetCrossHairPosition();
326  s_CornerIsNew = false;
327  s_AddCutoutToCurrentZone = false;
328  s_CurrentZone = NULL;
329 }
330 
331 
333 {
334  aZone->ClearFlags();
335  m_canvas->SetMouseCapture( NULL, NULL );
336 
337  if( DC )
338  aZone->Draw( m_canvas, DC, GR_OR );
339 
340  OnModify();
341  s_AddCutoutToCurrentZone = false;
342  s_CurrentZone = NULL;
343 
344  SetCurItem( NULL ); // This outline can be deleted when merging outlines
345 
346  // Combine zones if possible
347  GetBoard()->OnAreaPolygonModified( &s_AuxiliaryList, aZone );
348  m_canvas->Refresh();
349 
350  int ii = GetBoard()->GetAreaIndex( aZone ); // test if aZone exists
351 
352  if( ii < 0 )
353  aZone = NULL; // was removed by combining zones
354 
355  UpdateCopyOfZonesList( s_PickedList, s_AuxiliaryList, GetBoard() );
356  SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED);
357  s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
358 
359  int error_count = GetBoard()->Test_Drc_Areas_Outlines_To_Areas_Outlines( aZone, true );
360 
361  if( error_count )
362  {
363  DisplayError( this, _( "Area: DRC outline error" ) );
364  }
365 }
366 
367 
369 {
370  OnModify();
371 
372  if( aZone->Outline()->TotalVertices() <= 3 )
373  {
375 
376  if( DC )
377  { // Remove the full zone because this is no more an area
378  aZone->UnFill();
379  aZone->DrawFilledArea( m_canvas, DC, GR_XOR );
380  }
381 
382  GetBoard()->Delete( aZone );
383  return;
384  }
385 
386  LAYER_ID layer = aZone->GetLayer();
387 
388  if( DC )
389  {
390  GetBoard()->RedrawAreasOutlines( m_canvas, DC, GR_XOR, layer );
391  GetBoard()->RedrawFilledAreas( m_canvas, DC, GR_XOR, layer );
392  }
393 
394  s_AuxiliaryList.ClearListAndDeleteItems();
395  s_PickedList. ClearListAndDeleteItems();
396  SaveCopyOfZones( s_PickedList, GetBoard(), aZone->GetNetCode(), aZone->GetLayer() );
397  aZone->Outline()->RemoveVertex( aZone->GetSelectedCorner() );
398 
399  // modify zones outlines according to the new aZone shape
400  GetBoard()->OnAreaPolygonModified( &s_AuxiliaryList, aZone );
401 
402  if( DC )
403  {
404  GetBoard()->RedrawAreasOutlines( m_canvas, DC, GR_OR, layer );
405  GetBoard()->RedrawFilledAreas( m_canvas, DC, GR_OR, layer );
406  }
407 
408  UpdateCopyOfZonesList( s_PickedList, s_AuxiliaryList, GetBoard() );
409  SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED);
410  s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
411 
412  int ii = GetBoard()->GetAreaIndex( aZone ); // test if aZone exists
413 
414  if( ii < 0 )
415  aZone = NULL; // aZone does not exist anymore, after combining zones
416 
417  int error_count = GetBoard()->Test_Drc_Areas_Outlines_To_Areas_Outlines( aZone, true );
418 
419  if( error_count )
420  {
421  DisplayError( this, _( "Area: DRC outline error" ) );
422  }
423 }
424 
425 
431 {
432  PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Panel->GetParent();
433  ZONE_CONTAINER* zone = (ZONE_CONTAINER*) pcbframe->GetCurItem();
434 
435  if( zone->IsMoving() )
436  {
437  wxPoint offset;
438  offset = s_CornerInitialPosition - s_CursorLastPosition;
439  zone->Move( offset );
440  }
441  else if( zone->IsDragging() )
442  {
443  wxPoint offset = s_CornerInitialPosition - s_CursorLastPosition;
444  int selection = zone->GetSelectedCorner();
445  zone->MoveEdge( offset, selection );
446  }
447  else
448  {
449  if( s_CornerIsNew )
450  {
451  zone->Outline()->RemoveVertex( zone->GetSelectedCorner() );
452  }
453  else
454  {
456  zone->Outline()->Vertex( zone->GetSelectedCorner() ) = pos;
457  }
458  }
459 
460  Panel->SetMouseCapture( NULL, NULL );
461  s_AuxiliaryList.ClearListAndDeleteItems();
462  s_PickedList. ClearListAndDeleteItems();
463  Panel->Refresh();
464 
465  pcbframe->SetCurItem( NULL );
466  zone->ClearFlags();
467  s_AddCutoutToCurrentZone = false;
468  s_CurrentZone = NULL;
469 }
470 
471 
474  const wxPoint& aPosition, bool aErase )
475 {
476  PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) aPanel->GetParent();
477  ZONE_CONTAINER* zone = (ZONE_CONTAINER*) pcbframe->GetCurItem();
478 
479  if( aErase ) // Undraw edge in old position
480  {
481  zone->Draw( aPanel, aDC, GR_XOR );
482  }
483 
484  wxPoint pos = pcbframe->GetCrossHairPosition();
485 
486  if( zone->IsMoving() )
487  {
488  wxPoint offset;
489  offset = pos - s_CursorLastPosition;
490  zone->Move( offset );
491  s_CursorLastPosition = pos;
492  }
493  else if( zone->IsDragging() )
494  {
495  wxPoint offset = pos - s_CursorLastPosition;
496  int selection = zone->GetSelectedCorner();
497  zone->MoveEdge( offset, selection );
498  s_CursorLastPosition = pos;
499  }
500  else
501  {
502  zone->Outline()->Vertex( zone->GetSelectedCorner() ) = pos;
503  }
504 
505  zone->Draw( aPanel, aDC, GR_XOR );
506 }
507 
508 
509 
511 {
512  ZONE_SETTINGS zoneInfo = GetZoneSettings();
513 
514  // verify if s_CurrentZone exists (could be deleted since last selection) :
515  int ii;
516  for( ii = 0; ii < GetBoard()->GetAreaCount(); ii++ )
517  {
518  if( s_CurrentZone == GetBoard()->GetArea( ii ) )
519  break;
520  }
521 
522  if( ii >= GetBoard()->GetAreaCount() ) // Not found: could be deleted since last selection
523  {
524  s_AddCutoutToCurrentZone = false;
525  s_CurrentZone = NULL;
526  }
527 
529 
530  // Verify if a new zone is allowed on this layer:
531  if( zone == NULL )
532  {
534  {
535  DisplayError( this,
536  _( "Error: a keepout area is allowed only on copper layers" ) );
537  return 0;
538  }
539  }
540 
541  // If no zone contour in progress, a new zone is being created,
542  if( zone == NULL )
543  {
545  zone->SetFlags( IS_NEW );
546  zone->SetTimeStamp( GetNewTimeStamp() );
547  }
548 
549  if( zone->GetNumCorners() == 0 ) // Start a new contour: init zone params (net, layer ...)
550  {
551  if( !s_CurrentZone ) // A new outline is created, from scratch
552  {
553  ZONE_EDIT_T edited;
554 
555  // Init zone params to reasonable values
556  zone->SetLayer( GetActiveLayer() );
557 
558  // Prompt user for parameters:
560 
561  if( zone->IsOnCopperLayer() )
562  {
563  // Put a zone on a copper layer
564  if( GetBoard()->GetHighLightNetCode() > 0 )
565  {
567  zone->SetNetCode( zoneInfo.m_NetcodeSelection );
568  }
569 
570  double tmp = ZONE_THERMAL_RELIEF_GAP_MIL;
571 
572  wxConfigBase* cfg = Kiface().KifaceSettings();
573  cfg->Read( ZONE_THERMAL_RELIEF_GAP_STRING_KEY, &tmp );
574  zoneInfo.m_ThermalReliefGap = KiROUND( tmp * IU_PER_MILS);
575 
578  zoneInfo.m_ThermalReliefCopperBridge = KiROUND( tmp * IU_PER_MILS );
579 
580  tmp = ZONE_CLEARANCE_MIL;
581  cfg->Read( ZONE_CLEARANCE_WIDTH_STRING_KEY, &tmp );
582  zoneInfo.m_ZoneClearance = KiROUND( tmp * IU_PER_MILS );
583 
584  tmp = ZONE_THICKNESS_MIL;
585  cfg->Read( ZONE_MIN_THICKNESS_WIDTH_STRING_KEY, &tmp );
586  zoneInfo.m_ZoneMinThickness = KiROUND( tmp * IU_PER_MILS );
587 
588  zoneInfo.m_CurrentZone_Layer = zone->GetLayer();
589 
591  {
592  zoneInfo.SetIsKeepout( true );
593  // Netcode, netname and some other settings are irrelevant,
594  // so ensure they are cleared
597  zoneInfo.SetCornerRadius( 0 );
598 
599  edited = InvokeKeepoutAreaEditor( this, &zoneInfo );
600  }
601  else
602  {
603  zoneInfo.SetIsKeepout( false );
604  edited = InvokeCopperZonesEditor( this, &zoneInfo );
605  }
606  }
607  else // Put a zone on a non copper layer (technical layer)
608  {
609  zoneInfo.SetIsKeepout( false );
610  zoneInfo.m_NetcodeSelection = 0; // No net for non copper zones
611  edited = InvokeNonCopperZonesEditor( this, zone, &zoneInfo );
612  }
613 
615  m_canvas->SetIgnoreMouseEvents( false );
616 
617  if( edited == ZONE_ABORT )
618  {
619  GetBoard()->m_CurrentZoneContour = NULL;
620  delete zone;
621  return 0;
622  }
623 
624  // Switch active layer to the selected zone layer
626  SetZoneSettings( zoneInfo );
627  }
628  else
629  {
630  // Start a new contour: init zone params (net and layer) from an existing
631  // zone (add cutout or similar zone)
632 
633  zoneInfo.m_CurrentZone_Layer = s_CurrentZone->GetLayer();
634  SetActiveLayer( s_CurrentZone->GetLayer() );
635 
636  zoneInfo << *s_CurrentZone;
637 
638  SetZoneSettings( zoneInfo );
639  }
640 
641  // Show the Net for zones on copper layers
642  if( IsCopperLayer( zoneInfo.m_CurrentZone_Layer ) &&
643  !zoneInfo.GetIsKeepout() )
644  {
645  if( s_CurrentZone )
646  {
647  zoneInfo.m_NetcodeSelection = s_CurrentZone->GetNetCode();
648  GetBoard()->SetZoneSettings( zoneInfo );
649  }
650 
651  if( GetBoard()->IsHighLightNetON() )
652  {
653  HighLight( DC ); // Remove old highlight selection
654  }
655 
657  HighLight( DC );
658  }
659 
661  s_CurrentZone = NULL; // the zone is used only once ("add similar zone" command)
662  }
663 
664  // if first segment
665  if( zone->GetNumCorners() == 0 )
666  {
667  zoneInfo.ExportSetting( *zone );
668 
669  zone->SetLayer( zoneInfo.m_CurrentZone_Layer );
670 
671  // A duplicated corner is needed; null segments are removed when the zone is finished.
673  zone->AppendCorner( GetCrossHairPosition(), true );
674 
675  if( g_Drc_On && (m_drc->Drc( zone, 0 ) == BAD_DRC) && zone->IsOnCopperLayer() )
676  {
677  zone->ClearFlags();
678  zone->RemoveAllContours();
679 
680  // use the form of SetCurItem() which does not write to the msg panel,
681  // SCREEN::SetCurItem(), so the DRC error remains on screen.
682  // PCB_EDIT_FRAME::SetCurItem() calls DisplayInfo().
683  GetScreen()->SetCurItem( NULL );
684  DisplayError( this,
685  _( "DRC error: this start point is inside or too close an other area" ) );
686  return 0;
687  }
688 
689  SetCurItem( zone );
691  }
692  else // edge in progress:
693  {
694  ii = zone->GetNumCorners() - 1;
695 
696  // edge in progress : the current corner coordinate was set
697  // by Show_New_Edge_While_Move_Mouse
698  if( zone->GetCornerPosition( ii - 1 ) != zone->GetCornerPosition( ii ) )
699  {
700  if( !g_Drc_On || !zone->IsOnCopperLayer() || ( m_drc->Drc( zone, ii - 1 ) == OK_DRC ) )
701  {
702  // Ok, we can add a new corner
703  if( m_canvas->IsMouseCaptured() )
704  m_canvas->CallMouseCapture( DC, wxPoint(0,0), false );
705 
706  // It is necessary to allow duplication of the points, as we have to handle the
707  // continuous drawing while creating the zone at the same time as we build it. Null
708  // segments are removed when the zone is finished, in End_Zone.
709  zone->AppendCorner( GetCrossHairPosition(), true );
710 
711  SetCurItem( zone ); // calls DisplayInfo().
712 
713  if( m_canvas->IsMouseCaptured() )
714  m_canvas->CallMouseCapture( DC, wxPoint(0,0), false );
715  }
716  }
717  }
718 
719  return zone->GetNumCorners();
720 }
721 
722 
723 bool PCB_EDIT_FRAME::End_Zone( wxDC* DC )
724 {
726 
727  if( !zone )
728  return true;
729 
730  // Validate the current outline:
731  if( zone->GetNumCorners() <= 2 ) // An outline must have 3 corners or more
732  {
734  return true;
735  }
736 
737  // Remove the last corner if is is at the same location as the prevoius corner
738  zone->Outline()->RemoveNullSegments();
739 
740  // Validate the current edge:
741  int icorner = zone->GetNumCorners() - 1;
742  if( zone->IsOnCopperLayer() )
743  {
744  if( g_Drc_On && m_drc->Drc( zone, icorner - 1 ) == BAD_DRC ) // we can't validate last edge
745  return false;
746 
747  if( g_Drc_On && m_drc->Drc( zone, icorner ) == BAD_DRC ) // we can't validate the closing edge
748  {
749  DisplayError( this,
750  _( "DRC error: closing this area creates a DRC error with an other area" ) );
752  return false;
753  }
754  }
755 
756  zone->ClearFlags();
757 
758  zone->DrawWhileCreateOutline( m_canvas, DC, GR_XOR );
759 
760  m_canvas->SetMouseCapture( NULL, NULL );
761 
762  // Undraw old drawings, because they can have important changes
763  LAYER_ID layer = zone->GetLayer();
764  GetBoard()->RedrawAreasOutlines( m_canvas, DC, GR_XOR, layer );
765  GetBoard()->RedrawFilledAreas( m_canvas, DC, GR_XOR, layer );
766 
767  // Save initial zones configuration, for undo/redo, before adding new zone
768  s_AuxiliaryList.ClearListAndDeleteItems();
769  s_PickedList.ClearListAndDeleteItems();
770  SaveCopyOfZones(s_PickedList, GetBoard(), zone->GetNetCode(), zone->GetLayer() );
771 
772  // Put new zone in list
773  if( !s_CurrentZone )
774  {
775  GetBoard()->Add( zone );
776 
777  // Add this zone in picked list, as new item
778  ITEM_PICKER picker( zone, UR_NEW );
779  s_PickedList.PushItem( picker );
780  }
781  else // Append this outline as a cutout to an existing zone
782  {
783  s_CurrentZone->Outline()->AddHole( zone->Outline()->Outline( 0 ) );
784 
785  zone->RemoveAllContours(); // All corners are copied in s_CurrentZone. Free corner list.
786  zone = s_CurrentZone;
787  }
788 
789  s_AddCutoutToCurrentZone = false;
790  s_CurrentZone = NULL;
791  GetBoard()->m_CurrentZoneContour = NULL;
792 
793  GetScreen()->SetCurItem( NULL ); // This outline can be deleted when merging outlines
794 
795  // Combine zones if possible :
796  GetBoard()->OnAreaPolygonModified( &s_AuxiliaryList, zone );
797 
798  // Redraw the real edge zone :
799  GetBoard()->RedrawAreasOutlines( m_canvas, DC, GR_OR, layer );
800  GetBoard()->RedrawFilledAreas( m_canvas, DC, GR_OR, layer );
801 
802  int ii = GetBoard()->GetAreaIndex( zone ); // test if zone exists
803 
804  if( ii < 0 )
805  zone = NULL; // was removed by combining zones
806 
807  int error_count = GetBoard()->Test_Drc_Areas_Outlines_To_Areas_Outlines( zone, true );
808 
809  if( error_count )
810  {
811  DisplayError( this, _( "Area: DRC outline error" ) );
812  }
813 
814  UpdateCopyOfZonesList( s_PickedList, s_AuxiliaryList, GetBoard() );
815  SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED);
816  s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
817 
818  OnModify();
819  return true;
820 }
821 
822 
823 /* Redraws the zone outlines when moving mouse
824  */
825 static void Show_New_Edge_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
826  const wxPoint& aPosition, bool aErase )
827 {
828  PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) aPanel->GetParent();
829  wxPoint c_pos = pcbframe->GetCrossHairPosition();
830  ZONE_CONTAINER* zone = pcbframe->GetBoard()->m_CurrentZoneContour;
831 
832  if( !zone )
833  return;
834 
835  int icorner = zone->GetNumCorners() - 1;
836 
837  if( icorner < 1 )
838  return; // We must have 2 (or more) corners
839 
840  if( aErase ) // Undraw edge in old position
841  {
842  zone->DrawWhileCreateOutline( aPanel, aDC );
843  }
844 
845  // Redraw the current edge in its new position
846  if( pcbframe->GetZoneSettings().m_Zone_45_Only )
847  {
848  // calculate the new position as allowed
849  wxPoint StartPoint = static_cast<wxPoint>( zone->GetCornerPosition( icorner - 1 ) );
850  CalculateSegmentEndPoint( c_pos, StartPoint.x, StartPoint.y, &c_pos.x, &c_pos.y );
851  }
852 
853  zone->SetCornerPosition( icorner, c_pos );
854 
855  zone->DrawWhileCreateOutline( aPanel, aDC );
856 }
857 
859 {
860  ZONE_EDIT_T edited;
861  ZONE_SETTINGS zoneInfo = GetZoneSettings();
862 
863  BOARD_COMMIT commit( this );
865 
866  // Save initial zones configuration, for undo/redo, before adding new zone
867  // note the net name and the layer can be changed, so we must save all zones
868  s_AuxiliaryList.ClearListAndDeleteItems();
869  s_PickedList.ClearListAndDeleteItems();
870  SaveCopyOfZones( s_PickedList, GetBoard(), -1, UNDEFINED_LAYER );
871 
872  if( aZone->GetIsKeepout() )
873  {
874  // edit a keepout area on a copper layer
875  zoneInfo << *aZone;
876  edited = InvokeKeepoutAreaEditor( this, &zoneInfo );
877  }
878  else if( IsCopperLayer( aZone->GetLayer() ) )
879  {
880  // edit a zone on a copper layer
881 
882  zoneInfo << *aZone;
883 
884  edited = InvokeCopperZonesEditor( this, &zoneInfo );
885  }
886  else
887  {
888  edited = InvokeNonCopperZonesEditor( this, aZone, &zoneInfo );
889  }
890 
892  m_canvas->SetIgnoreMouseEvents( false );
893 
894  if( edited == ZONE_ABORT )
895  {
896  s_AuxiliaryList.ClearListAndDeleteItems();
897  s_PickedList.ClearListAndDeleteItems();
898  return;
899  }
900 
901  SetZoneSettings( zoneInfo );
902 
903  if( edited == ZONE_EXPORT_VALUES )
904  {
905  UpdateCopyOfZonesList( s_PickedList, s_AuxiliaryList, GetBoard() );
906  commit.Stage( s_PickedList );
907  commit.Push( _( "Modify zone properties" ) );
908  s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
909  return;
910  }
911 
912  // Undraw old zone outlines
913  for( int ii = 0; ii < GetBoard()->GetAreaCount(); ii++ )
914  {
915  ZONE_CONTAINER* edge_zone = GetBoard()->GetArea( ii );
916  edge_zone->Draw( m_canvas, DC, GR_XOR );
917 
918  if( IsGalCanvasActive() )
919  {
920  GetGalCanvas()->GetView()->Update( edge_zone );
921  }
922  }
923 
924  zoneInfo.ExportSetting( *aZone );
925 
926  NETINFO_ITEM* net = GetBoard()->FindNet( zoneInfo.m_NetcodeSelection );
927 
928  if( net ) // net == NULL should not occur
929  aZone->SetNetCode( net->GetNet() );
930 
931  // Combine zones if possible
932  GetBoard()->OnAreaPolygonModified( &s_AuxiliaryList, aZone );
933 
934  // Redraw the real new zone outlines
936 
937  UpdateCopyOfZonesList( s_PickedList, s_AuxiliaryList, GetBoard() );
938 
939  // refill zones with the new properties applied
940  for( unsigned i = 0; i < s_PickedList.GetCount(); ++i )
941  {
942  auto zone = dyn_cast<ZONE_CONTAINER*>( s_PickedList.GetPickedItem( i ) );
943 
944  if( zone == nullptr )
945  {
946  wxASSERT_MSG( false, "Expected a zone after zone properties edit" );
947  continue;
948  }
949 
950  if( zone->IsFilled() )
951  {
952  Fill_Zone( zone );
953  GetBoard()->GetRatsnest()->Recalculate( zone->GetNetCode() );
954  }
955  }
956 
957  commit.Stage( s_PickedList );
958  commit.Push( _( "Modify zone properties" ) );
959 
960  s_PickedList.ClearItemsList(); // s_ItemsListPicker is no longer owner of picked items
961 }
962 
963 
965 {
966  // Get contour in which the selected corner is
968 
969  // If the selected corner does not exist, abort
970  if( !aZone->Outline()->GetRelativeIndices( aZone->GetSelectedCorner(), &indices ) )
971  throw( std::out_of_range( "Zone selected corner does not exist" ) );
972 
973  EDA_RECT dirty = aZone->GetBoundingBox();
974 
975  // For compatibility with old boards: remove old SEGZONE fill segments
976  Delete_OldZone_Fill( NULL, aZone->GetTimeStamp() );
977 
978  // Remove current filling:
979  aZone->UnFill();
980 
981  if( indices.m_contour == 0 ) // This is the main outline: remove all
982  {
983  SaveCopyInUndoList( aZone, UR_DELETED );
984  GetBoard()->Remove( aZone );
985  }
986 
987  else
988  {
989  SaveCopyInUndoList( aZone, UR_CHANGED );
990  aZone->Outline()->RemoveContour( indices.m_contour, indices.m_polygon );
991  }
992 
993  m_canvas->RefreshDrawingRect( dirty );
994 
995  OnModify();
996 }
void MoveEdge(const wxPoint &offset, int aEdge)
Function MoveEdge Move the outline Edge.
Definition: class_zone.cpp:730
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:179
virtual void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
Definition: pcbframe.cpp:1004
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:555
bool g_Drc_On
Definition: pcbnew.cpp:70
#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:44
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:376
bool IsMoving() const
Definition: base_struct.h:218
#define IN_EDIT
Item currently edited.
Definition: base_struct.h:111
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,.
void RedrawFilledAreas(EDA_DRAW_PANEL *aPanel, wxDC *aDC, GR_DRAWMODE aDrawMode, LAYER_ID aLayer)
Function RedrawFilledAreas Redraw all filled areas on layer aLayer ( redraw all if aLayer < 0 ) ...
int GetNumCorners(void) const
Access to m_Poly parameters.
Definition: class_zone.h:466
virtual LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
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:107
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Definition: draw_panel.cpp:326
static bool s_CornerIsNew
virtual void SetActiveLayer(LAYER_ID aLayer) override
Function SetActiveLayer will change the currently active layer to aLayer and also update the PCB_LAYE...
Definition: pcbframe.cpp:893
This file is part of the common library.
bool IsNew() const
Definition: base_struct.h:216
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:349
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:240
ZONE_EDIT_T
Exit codes for zone editing dialogs.
Definition: zones.h:47
Class that computes missing connections on a PCB.
const ZONE_SETTINGS & GetZoneSettings() const
virtual void SetLayer(LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
static bool s_AddCutoutToCurrentZone
ZONE_CONTAINER * m_CurrentZoneContour
zone contour currently in progress
Definition: class_board.h:254
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:247
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:306
void OnSelectTool(wxCommandEvent &aEvent)
Definition: edit.cpp:1422
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:348
LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
const VECTOR2I & GetCornerPosition(int aCornerIndex) const
Definition: class_zone.h:506
Casted dyn_cast(From aObject)
Function dyn_cast()
Definition: typeinfo.h:73
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:203
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:644
#define IS_NEW
New item, just created.
Definition: base_struct.h:113
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:115
int m_NetcodeSelection
Net code selection for the current zone.
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:253
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
void AppendCorner(wxPoint position, bool aAllowDuplication=false)
Function AppendCorner.
Definition: class_zone.h:546
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
>
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
bool UnFill()
Function UnFill Removes the zone filling.
Definition: class_zone.cpp:154
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:101
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:795
void RedrawAreasOutlines(EDA_DRAW_PANEL *aPanel, wxDC *aDC, GR_DRAWMODE aDrawMode, LAYER_ID aLayer)
Function RedrawAreasOutlines Redraw all areas outlines on layer aLayer ( redraw all if aLayer < 0 ) ...
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:1051
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:175
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:172
int RemoveNullSegments()
Function RemoveNullSegments looks for null segments; ie, segments whose ends are exactly the same and...
int Delete_LastCreatedCorner(wxDC *DC)
Function Delete_LastCreatedCorner Used only while creating a new zone outline Remove and delete the c...
void Update(VIEW_ITEM *aItem)
Function Update() For dynamic VIEWs, informs the associated VIEW that the graphical representation of...
Definition: view.cpp:1378
#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:221
RN_DATA * GetRatsnest() const
Function GetRatsnest() returns list of missing connections between components/tracks.
Definition: class_board.h:287
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:204
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.
void CalculateSegmentEndPoint(const wxPoint &aPosition, int ox, int oy, int *fx, int *fy)
Determine coordinate for a segment direction of 0, 90, or 45 degrees depending on it's position from ...
Definition: editrack.cpp:839
Class ZONE_SETTINGS handles zones parameters.
void Recalculate(int aNet=-1)
Function Recalculate() Recomputes ratsnest for selected net number or all nets that need updating...
void Move(const wxPoint &offset) override
Function Move Move the outlines.
Definition: class_zone.cpp:713
Definition: gr_basic.h:42
int GetNetCode() const
Function GetNetCode.
void SetHighLightNet(int aNetCode)
Function SetHighLightNet.
Definition: class_board.h:361
#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:92
void DisplayInfoMessage(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayInfoMessage displays an informational message box with aMessage.
Definition: confirm.cpp:89
Class NETINFO_ITEM handles the data for a net.
bool IsOnCopperLayer() const
Function IsOnCopperLayer.
Definition: class_zone.h:179
#define ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY
Definition: zones.h:33
void SetCornerPosition(int aCornerIndex, wxPoint new_pos)
Definition: class_zone.h:517
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:1022
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
Function GetPickedItem.
void duplicateZone(wxDC *aDC, ZONE_CONTAINER *aZone)
Function duplicateZone duplicates the given zone.
LAYER_ID
Enum LAYER_ID is the set of PCB layers.
static PICKED_ITEMS_LIST s_PickedList
int GetToolId() const
Definition: draw_frame.h:406
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.
LAYER_ID m_CurrentZone_Layer
Layer used to create the current zone.
void Hatch()
Function Hatch computes the hatch lines depending on the hatch parameters and stores it in the zone's...
Definition: class_zone.cpp:911
#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:254
int GetSelectedCorner() const
Definition: class_zone.h:212
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 IsHighLightNetON() const
Function IsHighLightNetON.
Definition: class_board.h:370
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:803
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:153
ZONE_EDIT_T InvokeKeepoutAreaEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings)
Function InvokeKeepoutAreaEditor invokes up a modal dialog window for copper zone editing...
#define ZONE_THERMAL_RELIEF_GAP_MIL
Definition: zones.h:38
int GetHighLightNetCode() const
Function GetHighLightNetCode.
Definition: class_board.h:355
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()
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:69
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:1036
void Remove(BOARD_ITEM *aBoardItem) override
>
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:501
bool IsDragging() const
Definition: base_struct.h:219
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:112