KiCad PCB EDA Suite
edit.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) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net>
7  * Copyright (C) 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 
32 #include <fctsys.h>
33 #include <pgm_base.h>
34 #include <kiface_i.h>
35 #include <class_drawpanel.h>
36 #include <confirm.h>
37 #include <eda_doc.h>
38 #include <gestfich.h>
39 #include <kicad_device_context.h>
40 #include <pcb_edit_frame.h>
41 
42 #include <pcbnew_id.h>
43 #include <pcbnew.h>
44 #include <footprint_edit_frame.h>
45 
46 #include <class_board.h>
47 #include <class_module.h>
48 #include <class_track.h>
49 #include <class_zone.h>
50 #include <class_pcb_text.h>
51 #include <footprint_viewer_frame.h>
52 #include <pcb_layer_box_selector.h>
53 #include <dialog_drc.h>
55 #include <invoke_pcb_dialog.h>
56 #include <array_creator.h>
57 #include <connectivity_data.h>
58 
59 #include <zone_filler.h>
60 
61 #include <dialog_move_exact.h>
62 
63 #include <tool/tool_manager.h>
64 #include <tools/pcb_actions.h>
65 
66 // Handles the selection of command events.
67 void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
68 {
69  int id = event.GetId();
70 
72  MODULE* module;
73  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
74 
75  m_canvas->CrossHairOff( &dc );
76 
77  switch( id ) // Some (not all ) edit commands must be finished or aborted
78  {
79  case wxID_CUT:
80  case wxID_COPY:
149  case ID_POPUP_ZOOM_BLOCK:
150  case ID_POPUP_FLIP_BLOCK:
164  break;
165 
167  if( m_canvas->IsMouseCaptured() )
168  {
170  }
171 
172  // Should not be executed, just in case
173  if( GetScreen()->m_BlockLocate.GetCommand() != BLOCK_IDLE )
174  {
178  }
179 
180  if( GetToolId() == ID_NO_TOOL_SELECTED )
182  else
183  SetCursor( (wxStockCursor) m_canvas->GetDefaultCursor() );
184 
185  break;
186 
187  default: // Finish (abort) the command
188  if( m_canvas->IsMouseCaptured() )
190 
191  if( GetToolId() != id )
192  {
193  if( m_lastDrawToolId != GetToolId() )
195 
197  }
198  break;
199  }
200 
201  switch( id ) // Execute command
202  {
203  case 0:
204  break;
205 
207  {
209 
210  if( !editor )
211  {
213  editor->Zoom_Automatique( false );
214  }
215  else
216  {
217  // Needed on Windows, other platforms do not use it,
218  // but it creates no issue
219  if( editor->IsIconized() )
220  editor->Iconize( false );
221 
222  editor->Raise();
223 
224  // Raising the window does not set the focus on Linux. This should work on
225  // any platform.
226  if( wxWindow::FindFocus() != editor )
227  editor->SetFocus();
228  }
229 
230  editor->PushPreferences( m_canvas );
231  }
232  break;
233 
235  {
237 
238  if( !viewer )
239  {
241  viewer->Zoom_Automatique( false );
242  }
243  else
244  {
245  // Needed on Windows, other platforms do not use it,
246  // but it creates no issue
247  if( viewer->IsIconized() )
248  viewer->Iconize( false );
249 
250  viewer->Raise();
251 
252  // Raising the window does not set the focus on Linux. This should work on
253  // any platform.
254  if( wxWindow::FindFocus() != viewer )
255  viewer->SetFocus();
256  }
257 
258  viewer->PushPreferences( m_canvas );
259  }
260  break;
261 
263  InstallPcbGlobalDeleteFrame( wxDefaultPosition );
264  break;
265 
268  m_canvas->SetAutoPanRequest( false );
269  HandleBlockPlace( &dc );
270  break;
271 
275  m_canvas->SetAutoPanRequest( false );
276  HandleBlockPlace( &dc );
277  break;
278 
279  case ID_POPUP_ZOOM_BLOCK:
282  HandleBlockEnd( &dc );
283  break;
284 
288  HandleBlockEnd( &dc );
289  break;
290 
294  HandleBlockEnd( &dc );
295  break;
296 
297  case ID_POPUP_FLIP_BLOCK:
300  HandleBlockEnd( &dc );
301  break;
302 
303  case ID_DRC_CONTROL:
304  // Shows the DRC dialog in non modal mode, to allows board edition
305  // with the DRC dialog opened and showing errors.
306  m_drc->ShowDRCDialog();
307  break;
308 
309  case ID_GET_NETLIST:
310  InstallNetlistFrame( &dc );
311  break;
312 
313  case ID_FIND_ITEMS:
315  break;
316 
319  break;
320 
322  break;
323 
326 
327  // EndSegment(&dc);
328  break;
329 
331  if( GetCurItem() == NULL )
332  break;
333  Edit_Track_Width( &dc, (TRACK*) GetCurItem() );
335  OnModify();
336  break;
337 
339  if( GetCurItem() == NULL )
340  break;
343  OnModify();
344  break;
345 
347  {
348  DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS dlg( this, GetBoard()->GetHighLightNetCode() );
349  dlg.ShowModal();
350  }
351  break;
352 
354  if( GetCurItem() == NULL )
355  break;
356  {
357  int type = GetCurItem()->Type();
358 
359  if( type == PCB_TRACE_T || type == PCB_VIA_T )
360  {
362  DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS dlg( this, item->GetNetCode() );
363  dlg.ShowModal();
364  }
365 
366  }
368  break;
369 
372  OnHotkeyBeginRoute( &dc );
373  break;
374 
377  End_Route( (TRACK*) GetCurItem(), &dc );
378  break;
379 
382 
383  if( GetCurItem()->IsDragging() )
384  {
386  }
387 
388  break;
389 
391  /* change the position of initial segment when creating new tracks
392  * switch from _/ to -\ .
393  * If a track is in progress, it will be redrawn
394  */
395  if( m_canvas->IsMouseCaptured() )
396  m_canvas->CallMouseCapture( &dc, wxDefaultPosition, false );
397 
399 
400  if( m_canvas->IsMouseCaptured() )
401  m_canvas->CallMouseCapture( &dc, wxDefaultPosition, false );
402 
403  break;
404 
406  if( !IsMicroViaAcceptable() )
407  break;
408  // fall through
414 
415  if( GetCurItem()->IsDragging() )
416  {
418  }
419  else
420  {
422  VIATYPE_T v_type = settings.m_CurrentViaType;
423  switch( id )
424  {
428  break;
429 
431  settings.m_CurrentViaType = VIA_MICROVIA;
432  break;
433 
434  default:
435  settings.m_CurrentViaType = VIA_THROUGH;
436  break;
437  }
438 
439  // place via and switch layer.
442  {
444 
445  wxPoint dlgPosition;
446 
447  wxGetMousePosition( &dlgPosition.x, &dlgPosition.y );
448 
449  PCB_LAYER_ID layer = SelectLayer( GetActiveLayer(), LSET::AllNonCuMask(), dlgPosition );
450 
451  m_canvas->SetIgnoreMouseEvents( false );
453 
454  if( GetActiveLayer() != layer )
455  {
457  GetScreen()->m_Route_Layer_BOTTOM = layer;
458  Other_Layer_Route( (TRACK*) GetCurItem(), &dc );
459  }
460  }
461 
462  else
463  Other_Layer_Route( (TRACK*) GetCurItem(), &dc );
464 
465  settings.m_CurrentViaType = v_type;
466 
467  if( displ_opts->m_ContrastModeDisplay )
468  m_canvas->Refresh();
469  }
470  break;
471 
473  if( GetCurItem() == NULL )
474  break;
475 
477  SetCurItem( Delete_Segment( &dc, (TRACK*) GetCurItem() ) );
478  OnModify();
479  break;
480 
482  if( GetCurItem() == NULL )
483  break;
485  Delete_Track( &dc, (TRACK*) GetCurItem() );
486  SetCurItem( NULL );
487  OnModify();
488  break;
489 
492  Delete_net( &dc, (TRACK*) GetCurItem() );
493  SetCurItem( NULL );
494  OnModify();
495  break;
496 
498  Attribut_Segment( (TRACK*) GetCurItem(), &dc, true );
499  break;
500 
502  Attribut_Segment( (TRACK*) GetCurItem(), &dc, false );
503  break;
504 
506  Attribut_Track( (TRACK*) GetCurItem(), &dc, true );
507  break;
508 
510  Attribut_Track( (TRACK*) GetCurItem(), &dc, false );
511  break;
512 
514  Attribut_net( &dc, ( (TRACK*) GetCurItem() )->GetNetCode(), true );
515  break;
516 
518  Attribut_net( &dc, ( (TRACK*) GetCurItem() )->GetNetCode(), false );
519  break;
520 
522  break;
523 
526 
527  if( GetCurItem() == NULL )
528  break;
529 
530  {
531  SEGZONE* zsegm = (SEGZONE*) GetCurItem();
532  int netcode = zsegm->GetNetCode();
533  Delete_OldZone_Fill( zsegm );
534  SetCurItem( NULL );
535  TestNetConnection( NULL, netcode );
536  OnModify();
537  SetMsgPanel( GetBoard() );
538  }
539  break;
540 
543  SetCurItem( NULL ); // Outlines can have changed
544  break;
545 
547  {
549  duplicateZone( &dc, zone );
550  }
551  break;
552 
555  m_canvas->SetAutoPanRequest( true );
557  break;
558 
561  m_canvas->SetAutoPanRequest( true );
563  break;
564 
566  // Force the main contour selection, to remove the entire zone:
567  ((ZONE_CONTAINER*) GetCurItem())->SetSelectedCorner( 0 );
568  // Fall through
571  {
572  int netcode = ( (ZONE_CONTAINER*) GetCurItem() )->GetNetCode();
574  SetCurItem( NULL );
575  TestNetConnection( NULL, netcode );
576  SetMsgPanel( GetBoard() );
577  }
578  break;
579 
582  SetCurItem( NULL );
583  break;
584 
586  {
588  ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
589  m_canvas->SetAutoPanRequest( true );
590  Start_Move_Zone_Corner( &dc, zone_cont, zone_cont->GetSelectedCorner(), false );
591  }
592  break;
593 
595  {
597  ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
598  m_canvas->SetAutoPanRequest( true );
599  Start_Move_Zone_Drag_Outline_Edge( &dc, zone_cont, zone_cont->GetSelectedCorner() );
600  }
601  break;
602 
604  {
606  ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
607  m_canvas->SetAutoPanRequest( true );
608  Start_Move_Zone_Outlines( &dc, zone_cont );
609  }
610  break;
611 
613  {
615  ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
617 
618  /* add corner between zone_cont->m_CornerSelection
619  * and zone_cont->m_CornerSelection+1
620  * and start move the new corner
621  */
622  zone_cont->Draw( m_canvas, &dc, GR_XOR );
623  zone_cont->Outline()->InsertVertex( zone_cont->GetSelectedCorner(), pos );
624  zone_cont->SetSelectedCorner( zone_cont->GetSelectedCorner() + 1 );
625  zone_cont->Draw( m_canvas, &dc, GR_XOR );
626  m_canvas->SetAutoPanRequest( true );
627  Start_Move_Zone_Corner( &dc, zone_cont, zone_cont->GetSelectedCorner(), true );
628  }
629  break;
630 
634  {
636  ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
637  End_Move_Zone_Corner_Or_Outlines( &dc, zone_cont );
638  m_canvas->SetAutoPanRequest( false );
639  }
640  break;
641 
644  Fill_All_Zones( this );
645  m_canvas->Refresh();
646  SetMsgPanel( GetBoard() );
647  break;
648 
650  if( ( GetCurItem() )->Type() == PCB_ZONE_AREA_T )
651  {
652  ZONE_CONTAINER* zone_container = (ZONE_CONTAINER*) GetCurItem();
653  zone_container->UnFill();
654  GetBoard()->GetConnectivity()->Update( zone_container );
655  OnModify();
656  SetMsgPanel( GetBoard() );
657  m_canvas->Refresh();
658  }
659 
660  Compile_Ratsnest( &dc, false );
661  SetCurItem( NULL );
662  break;
663 
664  case ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_ALL_ZONES: // Remove all zones :
665  GetBoard()->m_SegZoneDeprecated.DeleteAll(); // remove deprecated zone segments used
666  // to fill zones in very old boards.
667 
668  for( int ii = 0; ii < GetBoard()->GetAreaCount(); ii++ )
669  {
670  // Remove filled areas in zone
671  ZONE_CONTAINER* zone_container = GetBoard()->GetArea( ii );
672  zone_container->UnFill();
673  GetBoard()->GetConnectivity()->Update( zone_container );
674  }
675 
676  Compile_Ratsnest( &dc, false );
677  SetCurItem( NULL ); // CurItem might be deleted by this command, clear the pointer
678  OnModify();
679  SetMsgPanel( GetBoard() );
680  m_canvas->Refresh();
681  break;
682 
684  {
686  ZONE_FILLER filler( GetBoard() );
687  filler.Fill( { (ZONE_CONTAINER*) GetCurItem() } );
688  SetMsgPanel( GetBoard() );
689  m_canvas->Refresh();
690  break;
691  }
692 
695  m_canvas->SetAutoPanRequest( true );
696  break;
697 
700  if( GetCurItem() == NULL )
701  break;
702 
703  // If the current Item is a pad, text module ...: Get its parent
704  if( GetCurItem()->Type() != PCB_MODULE_T )
705  SetCurItem( GetCurItem()->GetParent() );
706 
707  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
708  break;
709 
710  module = (MODULE*) GetCurItem();
711 
712  if( module->IsLocked() )
713  {
714  wxString msg;
715  msg.Printf( _( "Footprint %s found, but it is locked" ),
716  module->GetReference().GetData() );
717  DisplayInfoMessage( this, msg );
718  break;
719  }
720 
721  SendMessageToEESCHEMA( module );
722  SetCrossHairPosition( module->GetPosition() );
725  break;
726 
727  case ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST: // get module by name and move it
729  module = (MODULE*) GetCurItem();
730 
731  if( module == NULL )
732  break;
733 
734  if( module->IsLocked() )
735  {
736  wxString msg = wxString::Format(
737  _( "Footprint %s found, but it is locked" ),
738  module->GetReference().GetData() );
739  DisplayInfoMessage( this, msg );
740  break;
741  }
742 
743  SendMessageToEESCHEMA( module );
745  StartMoveModule( module, &dc, false );
746  break;
747 
750 
751  // If the current Item is a pad, text module ...: Get its parent
752  if( GetCurItem()->Type() != PCB_MODULE_T )
753  SetCurItem( GetCurItem()->GetParent() );
754 
755  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
756  break;
757 
758  module = (MODULE*) GetCurItem();
759 
760  if( module->IsLocked() )
761  {
762  wxString msg;
763  msg.Printf( _( "Footprint %s found, but it is locked" ),
764  module->GetReference().GetData() );
765  DisplayInfoMessage( this, msg );
766  break;
767  }
768 
769  if( Delete_Module( (MODULE*) GetCurItem(), &dc ) )
770  {
771  SetCurItem( NULL );
772  }
773 
774  break;
775 
778 
779  // If the current Item is a pad, text module ...: Get its parent
780  if( GetCurItem()->Type() != PCB_MODULE_T )
781  SetCurItem( GetCurItem()->GetParent() );
782 
783  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
784  break;
785 
786  module = (MODULE*) GetCurItem();
787 
788  if( module->IsLocked() )
789  {
790  wxString msg;
791  msg.Printf( _( "Footprint %s found, but it is locked" ),
792  module->GetReference().GetData() );
793  DisplayInfoMessage( this, msg );
794  break;
795  }
796 
797  // This is a simple rotation, no other editing in progress
798  if( !GetCurItem()->IsMoving() )
799  SaveCopyInUndoList( GetCurItem(), UR_CHANGED, ((MODULE*)GetCurItem())->GetPosition() );
800 
801  Rotate_Module( &dc, (MODULE*) GetCurItem(), m_rotationAngle, true );
802  break;
803 
806 
807  // If the current Item is a pad, text module ...: Get its parent
808  if( GetCurItem()->Type() != PCB_MODULE_T )
809  SetCurItem( GetCurItem()->GetParent() );
810 
811  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
812  break;
813 
814  module = (MODULE*) GetCurItem();
815 
816  if( module->IsLocked() )
817  {
818  wxString msg;
819  msg.Printf( _( "Footprint %s found, but it is locked" ),
820  module->GetReference().GetData() );
821  DisplayInfoMessage( this, msg );
822  break;
823  }
824 
825  // This is a simple rotation, no other editing in progress
826  if( !GetCurItem()->IsMoving() )
827  SaveCopyInUndoList( GetCurItem(), UR_CHANGED, ((MODULE*)GetCurItem())->GetPosition() );
828 
829  Rotate_Module( &dc, (MODULE*) GetCurItem(), -m_rotationAngle, true );
830  break;
831 
834 
835  // If the current Item is a pad, text module ...: Get its parent
836  if( GetCurItem()->Type() != PCB_MODULE_T )
837  SetCurItem( GetCurItem()->GetParent() );
838 
839  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
840  break;
841 
842  module = (MODULE*) GetCurItem();
843 
844  if( module->IsLocked() )
845  {
846  wxString msg;
847  msg.Printf( _( "Footprint %s found, but it is locked" ),
848  module->GetReference().GetData() );
849  DisplayInfoMessage( this, msg );
850  break;
851  }
852 
853  // This is a simple flip, no other editing in progress
854  if( !GetCurItem()->IsMoving() )
855  SaveCopyInUndoList( GetCurItem(), UR_FLIPPED, ((MODULE*)GetCurItem())->GetPosition() );
856 
857  Change_Side_Module( (MODULE*) GetCurItem(), &dc );
858  break;
859 
861  if( GetCurItem() && GetCurItem()->Type() != PCB_MODULE_T )
862  break;
863 
866  break;
867 
869  if( GetCurItem() && GetCurItem()->Type() != PCB_MODULE_T )
870  break;
871 
874  break;
875 
877  // If the current Item is a pad, text module ...: Get its parent
878  if( GetCurItem()->Type() != PCB_MODULE_T )
879  SetCurItem( GetCurItem()->GetParent() );
880 
881  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
882  break;
883 
886  break;
887 
889 
890  // If we don't have a current item, there's nothing we can do here
891  if( !GetCurItem() )
892  break;
893 
894  // If the current Item is a pad, text module ...: Get its parent
895  if( GetCurItem()->Type() != PCB_MODULE_T )
896  SetCurItem( GetCurItem()->GetParent() );
897 
898  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
899  break;
900 
901  if( GetCurItem()->GetTimeStamp() == 0 ) // Module Editor needs a non null timestamp
902  {
904  OnModify();
905  }
906 
907  {
909 
911  SetCurItem( NULL ); // the current module could be deleted by
912  }
914  break;
915 
917  module = (MODULE*) GetCurItem()->GetParent();
918 
919  if( !module || module->Type() != PCB_MODULE_T )
920  break;
921 
922  if( module->IsLocked() )
923  {
924  wxString msg;
925  msg.Printf( _( "The parent (%s) of the pad is locked" ),
926  module->GetReference().GetData() );
927  DisplayInfoMessage( this, msg );
928  break;
929  }
930 
932  StartMovePad( (D_PAD*) GetCurItem(), &dc, true );
933  break;
934 
936  module = (MODULE*) GetCurItem()->GetParent();
937 
938  if( !module || module->Type() != PCB_MODULE_T )
939  break;
940 
941  if( module->IsLocked() )
942  {
943  wxString msg;
944  msg.Printf( _( "The parent (%s) of the pad is locked" ),
945  module->GetReference().GetData() );
946  DisplayInfoMessage( this, msg );
947  break;
948  }
949 
951  StartMovePad( (D_PAD*) GetCurItem(), &dc, false );
952  break;
953 
957  break;
958 
961  SaveCopyInUndoList( GetCurItem()->GetParent(), UR_CHANGED );
962  Import_Pad_Settings( (D_PAD*) GetCurItem(), true );
963  break;
964 
968  break;
969 
973  break;
974 
976  SaveCopyInUndoList( GetCurItem()->GetParent(), UR_CHANGED );
977  DeletePad( (D_PAD*) GetCurItem() );
978  SetCurItem( NULL );
980  break;
981 
983  InstallTextModOptionsFrame( static_cast<TEXTE_MODULE*>( GetCurItem() ), &dc );
985  break;
986 
988  ResetTextSize( GetCurItem(), &dc );
989  break;
990 
993  StartMoveTexteModule( static_cast<TEXTE_MODULE*>( GetCurItem() ), &dc );
994  break;
995 
997  RotateTextModule( static_cast<TEXTE_MODULE*>( GetCurItem() ), &dc );
999  break;
1000 
1002  DeleteTextModule( static_cast<TEXTE_MODULE*>( GetCurItem() ) );
1003  SetCurItem( NULL );
1005  break;
1006 
1008  {
1010 
1011  if( itmp >= 0 )
1012  {
1013  // if user changed colors and we are in high contrast mode, then redraw
1014  // because the PAD_ATTRIB_SMD pads may change color.
1015  if( displ_opts->m_ContrastModeDisplay && GetActiveLayer() != itmp )
1016  {
1017  m_canvas->Refresh();
1018  }
1019  SetActiveLayer( itmp );
1020  }
1021 
1023  }
1024  break;
1025 
1028  break;
1029 
1031  {
1033 
1034  if( itmp >= 0 )
1035  SetActiveLayer( itmp );
1036 
1038  }
1039  break;
1040 
1042  {
1044 
1045  if( itmp >= 0 )
1046  SetActiveLayer( itmp );
1047  }
1048  break;
1049 
1053  break;
1054 
1057 
1058  if( displ_opts->m_ContrastModeDisplay )
1059  m_canvas->Refresh( true );
1060  break;
1061 
1065  break;
1066 
1068  Rotate_Texte_Pcb( (TEXTE_PCB*) GetCurItem(), &dc );
1070  break;
1071 
1073  CreateTextePcb( &dc, (TEXTE_PCB*) GetCurItem() );
1075  m_canvas->SetAutoPanRequest( true );
1076  break;
1077 
1079  FlipTextePcb( (TEXTE_PCB*) GetCurItem(), &dc );
1081  break;
1082 
1084  Delete_Texte_Pcb( (TEXTE_PCB*) GetCurItem(), &dc );
1086  break;
1087 
1089  BeginMoveTarget( (PCB_TARGET*) GetCurItem(), &dc );
1091  break;
1092 
1096  break;
1097 
1100  DeleteTarget( (PCB_TARGET*) GetCurItem(), &dc );
1101  SetCurItem( NULL );
1102  break;
1103 
1106  DeleteDimension( (DIMENSION*) GetCurItem(), &dc );
1107  SetCurItem( NULL );
1108  break;
1109 
1113  break;
1114 
1117  break;
1118 
1122  break;
1123 
1125  RemoveStruct( GetCurItem(), &dc );
1127  break;
1128 
1130  if( GetCurItem() && GetCurItem()->Type() == PCB_MARKER_T )
1131  ( (MARKER_PCB*) GetCurItem() )->DisplayMarkerInfo( this );
1132 
1134  break;
1135 
1137  if( GetCurItem()->GetFlags() != 0 )
1138  break;
1139 
1141  SetCurItem( NULL );
1143  m_canvas->Refresh();
1144  break;
1145 
1147 #ifndef USE_WX_OVERLAY
1149 #else
1150  // #1277772 - Draw into dialog converted in refresh request
1152  m_canvas->Refresh();
1153 #endif
1155  break;
1156 
1160  break;
1161 
1164 
1165  if( GetCurItem() && (GetCurItem()->IsNew()) )
1166  {
1167  End_Edge( (DRAWSEGMENT*) GetCurItem(), &dc );
1168  SetCurItem( NULL );
1169  }
1170 
1171  break;
1172 
1175 
1176  if( GetCurItem() && (GetCurItem()->IsNew()) )
1177  {
1178  if( End_Zone( &dc ) )
1179  SetCurItem( NULL );
1180  }
1181 
1182  m_canvas->SetAutoPanRequest( false );
1183  break;
1184 
1187 
1188  if( GetCurItem() && (GetCurItem()->IsNew()) )
1189  {
1190  if( Delete_LastCreatedCorner( &dc ) == 0 ) // No more segment in outline,
1191  SetCurItem( NULL );
1192  }
1193 
1194  break;
1195 
1196 
1200  break;
1201 
1206  break;
1207 
1211  break;
1212 
1215  {
1216  TRACK* track = (TRACK*) GetScreen()->GetCurItem();
1217  wxPoint pos = GetCrossHairPosition();
1218 
1219  track->Draw( m_canvas, &dc, GR_XOR );
1220  PICKED_ITEMS_LIST itemsListPicker;
1221 
1222  TRACK* newtrack = GetBoard()->CreateLockPoint( pos, track, &itemsListPicker );
1223 
1224  SaveCopyInUndoList( itemsListPicker, UR_UNSPECIFIED );
1225  track->Draw( m_canvas, &dc, GR_XOR );
1226  newtrack->Draw( m_canvas, &dc, GR_XOR );
1227 
1228  // compute the new ratsnest, because connectivity could change
1229  TestNetConnection( &dc, track->GetNetCode() );
1230  }
1231  break;
1232 
1234  moveExact();
1235  break;
1236 
1240  break;
1241 
1243  createArray();
1244  break;
1245 
1246  case ID_MENU_PCB_CLEAN:
1247  Clean_Pcb();
1248  break;
1249 
1251  InstallExchangeModuleFrame( (MODULE*) nullptr, true );
1252  break;
1253 
1255  InstallExchangeModuleFrame( (MODULE*) nullptr, false );
1256  break;
1257 
1259  Swap_Layers( event );
1260  break;
1261 
1263  InvokeDialogGrid();
1264  break;
1265 
1267  {
1268  wxConfigBase* cfg = Pgm().CommonSettings();
1269  cfg->Read( wxT( "module_doc_file" ), g_DocModulesFileName );
1270  GetAssociatedDocument( this, g_DocModulesFileName, &Kiface().KifaceSearch() );
1271  }
1272  break;
1273 
1275  ArchiveModulesOnBoard( false );
1276  break;
1277 
1279  ArchiveModulesOnBoard( true );
1280  break;
1281 
1284  m_canvas->Refresh();
1285  break;
1286 
1288  if( !IsOK( this,
1289  _("Not locked footprints inside the board will be moved. OK?") ) )
1290  break;
1291  // Fall through
1293  if( GetBoard()->m_Modules == NULL )
1294  {
1295  DisplayError( this, _( "No footprint found!" ) );
1296  return;
1297  }
1298  else
1299  {
1300  MODULE* footprint = GetBoard()->m_Modules;
1301  std::vector<MODULE*> footprintList;
1302  for( ; footprint != NULL; footprint = footprint->Next() )
1303  footprintList.push_back( footprint );
1304 
1305  SpreadFootprints( &footprintList, id == ID_POPUP_PCB_SPREAD_NEW_MODULES,
1306  true, GetCrossHairPosition() );
1307  }
1308  break;
1310  LockModule( (MODULE*) GetScreen()->GetCurItem(), true );
1311  break;
1312 
1314  LockModule( (MODULE*) GetScreen()->GetCurItem(), false );
1315  break;
1316 
1318  LockModule( NULL, false );
1319  break;
1320 
1322  LockModule( NULL, true );
1323  break;
1324 
1325  default:
1326  wxString msg;
1327  msg.Printf( wxT( "PCB_EDIT_FRAME::Process_Special_Functions() unknown event id %d" ), id );
1328  DisplayError( this, msg );
1329  break;
1330  }
1331 
1332  m_canvas->CrossHairOn( &dc );
1333  m_canvas->SetIgnoreMouseEvents( false );
1334 }
1335 
1336 
1338 {
1339  if( Item == NULL )
1340  return;
1341 
1342  switch( Item->Type() )
1343  {
1344  case PCB_MODULE_T:
1345  Delete_Module( (MODULE*) Item, DC );
1346  break;
1347 
1348  case PCB_DIMENSION_T:
1349  DeleteDimension( (DIMENSION*) Item, DC );
1350  break;
1351 
1352  case PCB_TARGET_T:
1353  DeleteTarget( (PCB_TARGET*) Item, DC );
1354  break;
1355 
1356  case PCB_LINE_T:
1357  Delete_Segment_Edge( (DRAWSEGMENT*) Item, DC );
1358  break;
1359 
1360  case PCB_TEXT_T:
1361  Delete_Texte_Pcb( (TEXTE_PCB*) Item, DC );
1362  break;
1363 
1364  case PCB_TRACE_T:
1365  Delete_Track( DC, (TRACK*) Item );
1366  break;
1367 
1368  case PCB_VIA_T:
1369  Delete_Segment( DC, (TRACK*) Item );
1370  break;
1371 
1372  case PCB_ZONE_T:
1373  Delete_OldZone_Fill( (SEGZONE*) Item );
1374  break;
1375 
1376  case PCB_ZONE_AREA_T:
1377  {
1378  SetCurItem( NULL );
1379  int netcode = ( (ZONE_CONTAINER*) Item )->GetNetCode();
1380  Delete_Zone_Contour( DC, (ZONE_CONTAINER*) Item );
1381  TestNetConnection( NULL, netcode );
1382  SetMsgPanel( GetBoard() );
1383  }
1384  break;
1385 
1386  case PCB_MARKER_T:
1387  if( Item == GetCurItem() )
1388  SetCurItem( NULL );
1389 
1390  ( (MARKER_PCB*) Item )->Draw( m_canvas, DC, GR_XOR );
1391 
1392  // delete the marker, and free memory. Don't use undo stack.
1393  GetBoard()->Delete( Item );
1394  break;
1395 
1396  case PCB_PAD_T:
1397  case PCB_MODULE_TEXT_T:
1398  case PCB_MODULE_EDGE_T:
1399  break;
1400 
1401  case TYPE_NOT_INIT:
1402  case PCB_T:
1403  default:
1404  {
1405  wxString msg = wxString::Format(
1406  wxT( "Remove: item type %d unknown." ), Item->Type() );
1407  DisplayError( this, msg );
1408  }
1409  break;
1410  }
1411 }
1412 
1413 
1415 {
1416  PCB_LAYER_ID curLayer = GetActiveLayer();
1417  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
1418 
1419  // Check if the specified layer matches the present layer
1420  if( layer == curLayer )
1421  return;
1422 
1423  // Copper layers cannot be selected unconditionally; how many
1424  // of those layers are currently enabled needs to be checked.
1425  if( IsCopperLayer( layer ) )
1426  {
1427  // If only one copper layer is enabled, the only such layer
1428  // that can be selected to is the "Back" layer (so the
1429  // selection of any other copper layer is disregarded).
1430  if( GetBoard()->GetCopperLayerCount() < 2 )
1431  {
1432  if( layer != B_Cu )
1433  return;
1434  }
1435  // If more than one copper layer is enabled, the "Copper"
1436  // and "Component" layers can be selected, but the total
1437  // number of copper layers determines which internal
1438  // layers are also capable of being selected.
1439  else
1440  {
1441  if( layer != B_Cu && layer != F_Cu && layer >= GetBoard()->GetCopperLayerCount() - 1 )
1442  return;
1443  }
1444 
1445  EDA_ITEM* current = GetScreen()->GetCurItem();
1446 
1447  // See if we are drawing a segment; if so, add a via?
1448  if( GetToolId() == ID_TRACK_BUTT && current )
1449  {
1450  if( current->Type() == PCB_TRACE_T && current->IsNew() )
1451  {
1452  // Want to set the routing layers so that it switches properly -
1453  // see the implementation of Other_Layer_Route - the working
1454  // layer is used to 'start' the via and set the layer masks appropriately.
1455  GetScreen()->m_Route_Layer_TOP = curLayer;
1456  GetScreen()->m_Route_Layer_BOTTOM = layer;
1457 
1458  SetActiveLayer( curLayer );
1459 
1460  if( Other_Layer_Route( (TRACK*) GetScreen()->GetCurItem(), DC ) )
1461  {
1462  if( displ_opts->m_ContrastModeDisplay )
1463  m_canvas->Refresh();
1464  }
1465 
1466  // if the via was allowed by DRC, then the layer swap has already
1467  // been done by Other_Layer_Route(). if via not allowed, then
1468  // return now so assignment to setActiveLayer() below doesn't happen.
1469  return;
1470  }
1471  }
1472  }
1473 
1474  // Is yet more checking required? E.g. when the layer to be selected
1475  // is a non-copper layer, or when switching between a copper layer
1476  // and a non-copper layer, or vice-versa?
1477  // ...
1478 
1479  SetActiveLayer( layer );
1480 
1481  if( displ_opts->m_ContrastModeDisplay )
1482  m_canvas->Refresh();
1483 }
1484 
1485 
1486 void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
1487 {
1488  int id = aEvent.GetId();
1489  int lastToolID = GetToolId();
1490 
1492  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
1493 
1494  // Stop the current command and deselect the current tool.
1496 
1497  switch( id )
1498  {
1499  case ID_NO_TOOL_SELECTED:
1501  break;
1502 
1503  case ID_ZOOM_SELECTION:
1504  // This tool is located on the main toolbar: switch it on or off on click on it
1505  if( lastToolID != ID_ZOOM_SELECTION )
1506  SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) );
1507  else
1509  break;
1510 
1511  case ID_TRACK_BUTT:
1512  if( Settings().m_legacyDrcOn )
1513  SetToolID( id, wxCURSOR_PENCIL, _( "Add tracks" ) );
1514  else
1515  SetToolID( id, wxCURSOR_QUESTION_ARROW, _( "Add tracks" ) );
1516 
1517  Compile_Ratsnest( &dc, true );
1518  break;
1519 
1520  case ID_PCB_MODULE_BUTT:
1521  SetToolID( id, wxCURSOR_PENCIL, _( "Add footprint" ) );
1522  break;
1523 
1524  case ID_PCB_ZONES_BUTT:
1525  SetToolID( id, wxCURSOR_PENCIL, _( "Add zones" ) );
1526 
1527  if( displ_opts->m_DisplayZonesMode != 0 )
1528  DisplayInfoMessage( this, _( "Warning: zone display is OFF!!!" ) );
1529 
1530  if( !GetBoard()->IsHighLightNetON() && (GetBoard()->GetHighLightNetCode() > 0 ) )
1531  HighLight( &dc );
1532 
1533  break;
1534 
1536  SetToolID( id, wxCURSOR_PENCIL, _( "Add keepout" ) );
1537  break;
1538 
1539  case ID_PCB_TARGET_BUTT:
1540  SetToolID( id, wxCURSOR_PENCIL, _( "Add layer alignment target" ) );
1541  break;
1542 
1544  SetToolID( id, wxCURSOR_PENCIL, _( "Adjust zero" ) );
1545  break;
1546 
1548  SetToolID( id, wxCURSOR_PENCIL, _( "Adjust grid origin" ) );
1549  break;
1550 
1551  case ID_PCB_ADD_LINE_BUTT:
1552  SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic line" ) );
1553  break;
1554 
1555  case ID_PCB_ARC_BUTT:
1556  SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic arc" ) );
1557  break;
1558 
1559  case ID_PCB_CIRCLE_BUTT:
1560  SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic circle" ) );
1561  break;
1562 
1563  case ID_PCB_ADD_TEXT_BUTT:
1564  SetToolID( id, wxCURSOR_PENCIL, _( "Add text" ) );
1565  break;
1566 
1567  case ID_COMPONENT_BUTT:
1568  SetToolID( id, wxCURSOR_HAND, _( "Add footprint" ) );
1569  break;
1570 
1571  case ID_PCB_DIMENSION_BUTT:
1572  SetToolID( id, wxCURSOR_PENCIL, _( "Add dimension" ) );
1573  break;
1574 
1576  SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) );
1577  break;
1578 
1579  case ID_PCB_HIGHLIGHT_BUTT:
1580  SetToolID( id, wxCURSOR_HAND, _( "Highlight net" ) );
1581  break;
1582 
1584  SetToolID( id, wxCURSOR_HAND, _( "Select rats nest" ) );
1585 
1586  Compile_Ratsnest( &dc, true );
1587 
1588  break;
1589 
1590  // collect GAL-only tools here
1591  case ID_PCB_DRAW_VIA_BUTT:
1593  SetToolID( id, wxCURSOR_DEFAULT, _( "Unsupported tool in this canvas" ) );
1594  break;
1595  }
1596 }
1597 
1598 
1600 {
1601  MOVE_PARAMETERS params;
1602 
1603  DIALOG_MOVE_EXACT dialog( this, params );
1604  int ret = dialog.ShowModal();
1605 
1606  if( ret == wxID_OK )
1607  {
1608  if( BOARD_ITEM* item = GetScreen()->GetCurItem() )
1609  {
1610  // When a pad is modified, the full footprint is saved
1611  BOARD_ITEM* itemToSave = item;
1612 
1613  if( item->Type() == PCB_PAD_T )
1614  itemToSave = item->GetParent();
1615 
1616  // Could be moved or rotated
1617  SaveCopyInUndoList( itemToSave, UR_CHANGED );
1618 
1619  // begin with the default anchor
1620  wxPoint anchorPoint = item->GetPosition();
1621 
1622  if( item->Type() == PCB_MODULE_T )
1623  {
1624  // cast to module to allow access to the pads
1625  MODULE* mod = static_cast<MODULE*>( item );
1626 
1627  switch( params.anchor )
1628  {
1629  case ANCHOR_TOP_LEFT_PAD:
1630  if( mod->GetTopLeftPad()->GetAttribute() == PAD_ATTRIB_SMD )
1631  {
1632  anchorPoint = mod->GetTopLeftPad()->GetBoundingBox().GetPosition();
1633  }
1634  else
1635  {
1636  anchorPoint = mod->GetTopLeftPad()->GetPosition();
1637  }
1638  break;
1640  anchorPoint = mod->GetFootprintRect().GetCenter();
1641  break;
1642  case ANCHOR_FROM_LIBRARY:
1643  ; // nothing to do
1644  }
1645  }
1646 
1647  if( params.origin == RELATIVE_TO_CURRENT_POSITION )
1648  {
1649  anchorPoint = wxPoint( 0, 0 );
1650  }
1651 
1652  wxPoint finalMoveVector = params.translation - anchorPoint;
1653 
1654  item->Move( finalMoveVector );
1655  item->Rotate( item->GetPosition(), params.rotation );
1656  m_canvas->Refresh();
1657  }
1658  }
1659 
1661 }
1662 
1663 
1664 void PCB_EDIT_FRAME::duplicateItems( bool aIncrement )
1665 {
1666  BOARD_ITEM* item = GetScreen()->GetCurItem();
1667 
1668  if( !item )
1669  return;
1670 
1671  // In the board editor, the pads or fp texts can be edited
1672  // but cannot be duplicated (only the fp editor can do that).
1673  // only the footprint can be duplicated
1674  if( item->Type() == PCB_PAD_T || item->Type() == PCB_MODULE_TEXT_T )
1675  item = static_cast<MODULE*>( item )->GetParent();
1676 
1677  PCB_BASE_EDIT_FRAME::duplicateItem( item, aIncrement );
1678 }
1679 
1680 
1681 void PCB_BASE_EDIT_FRAME::duplicateItem( BOARD_ITEM* aItem, bool aIncrement )
1682 {
1683  if( !aItem )
1684  return;
1685 
1686  // The easiest way to handle a duplicate item command
1687  // is to simulate a block copy command, which gives us the undo management
1688  // for free
1689  if( GetScreen()->m_BlockLocate.GetState() == STATE_NO_BLOCK )
1690  {
1692 
1694 
1695  wxPoint crossHairPos = GetCrossHairPosition();
1696 
1697  const BLOCK_COMMAND_T blockType = aIncrement ? BLOCK_DUPLICATE_AND_INCREMENT : BLOCK_DUPLICATE;
1698 
1699  if( !HandleBlockBegin( &dc, blockType, crossHairPos ) )
1700  return;
1701 
1702  // Add the item to the block copy pick list:
1704  ITEM_PICKER picker( NULL, UR_UNSPECIFIED );
1705 
1706  picker.SetItem ( aItem );
1707  itemsList.PushItem( picker );
1708 
1709  // Set 2 coordinates updated by the mouse, because our simulation
1710  // does not use the mouse to call HandleBlockEnd()
1711  GetScreen()->m_BlockLocate.SetLastCursorPosition( crossHairPos );
1712  GetScreen()->m_BlockLocate.SetEnd( crossHairPos );
1713  HandleBlockEnd( &dc );
1714  }
1715 }
1716 
1717 
1719 {
1720 public:
1721 
1723  ARRAY_CREATOR( editFrame ),
1724  m_item( m_parent.GetScreen()->GetCurItem() )
1725  {}
1726 
1727 private:
1728 
1729  int getNumberOfItemsToArray() const override
1730  {
1731  // only handle single items
1732  return (m_item != NULL) ? 1 : 0;
1733  }
1734 
1735  BOARD_ITEM* getNthItemToArray( int n ) const override
1736  {
1737  wxASSERT_MSG( n == 0, "Legacy array tool can only handle a single item" );
1738  return m_item;
1739  }
1740 
1741  BOARD* getBoard() const override
1742  {
1743  return m_parent.GetBoard();
1744  }
1745 
1746  MODULE* getModule() const override
1747  {
1748  return dynamic_cast<MODULE*>( m_item->GetParent() );
1749  }
1750 
1751  wxPoint getRotationCentre() const override
1752  {
1753  return m_item->GetCenter();
1754  }
1755 
1756  void finalise() override
1757  {
1758  m_parent.GetCanvas()->Refresh();
1759  }
1760 
1761  BOARD_ITEM* m_item; // only have the one
1762 };
1763 
1764 
1766 {
1767  LEGACY_ARRAY_CREATOR array_creator( *this );
1768 
1769  array_creator.Invoke();
1770 }
void BeginMoveTarget(PCB_TARGET *aTarget, wxDC *DC)
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:673
int InstallExchangeModuleFrame(MODULE *ExchangeModuleModule, bool updateMode)
void Edit_Track_Width(wxDC *aDC, TRACK *aTrackSegment)
Function Edit_Track_Width Modify a full track width (using DRC control).
KICAD_T Type() const
Function Type()
Definition: base_struct.h:209
BOARD_ITEM_CONTAINER * GetParent() const
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:276
virtual void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
bool Other_Layer_Route(TRACK *track, wxDC *DC)
Function Other_Layer_Route operates in one of two ways.
TRACK * CreateLockPoint(wxPoint &aPosition, TRACK *aSegment, PICKED_ITEMS_LIST *aList)
Function CreateLockPoint creates an intermediate point on aSegment and break it into two segments at ...
void DeleteTarget(PCB_TARGET *aTarget, wxDC *DC)
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...
VIATYPE_T m_CurrentViaType
via type (VIA_BLIND_BURIED, VIA_THROUGH VIA_MICROVIA)
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
Definition: base_screen.h:214
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,.
Definition: typeinfo.h:85
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
void SpreadFootprints(std::vector< MODULE * > *aFootprints, bool aMoveFootprintsOutsideBoardOnly, bool aCheckForBoardEdges, wxPoint aSpreadAreaPosition, bool aPrepareUndoCommand=true)
Function SpreadFootprints Footprints (after loaded by reading a netlist for instance) are moved to be...
TRACK * Delete_Segment(wxDC *DC, TRACK *Track)
Function Delete_Segment removes a track segment.
Definition: deltrack.cpp:45
void DeleteDimension(DIMENSION *aDimension, wxDC *aDC)
Definition: dimension.cpp:364
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:405
TEXTE_PCB class definition.
int getNumberOfItemsToArray() const override
Definition: edit.cpp:1729
bool g_Alternate_Track_Posture
Definition: pcbnew.cpp:71
bool End_Zone(wxDC *DC)
Function End_Zone terminates (if no DRC error ) the zone edge creation process.
void InstallTextPCBOptionsFrame(TEXTE_PCB *TextPCB, wxDC *DC)
Routine for main window class to launch text properties dialog.
void InstallPcbGlobalDeleteFrame(const wxPoint &pos)
This file is part of the common library TODO brief description.
void LockModule(MODULE *aModule, bool aLocked)
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:338
bool Delete_Module(MODULE *aModule, wxDC *aDC)
Function Delete Module Remove a footprint from m_Modules linked list and put it in undelete buffer Th...
This file is part of the common library.
bool IsNew() const
Definition: base_struct.h:227
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
void TestNetConnection(wxDC *aDC, int aNetCode)
Function TestNetConnection tests the connections relative to aNetCode.
Definition: connect.cpp:40
wxPoint getRotationCentre() const override
Definition: edit.cpp:1751
This file is part of the common library.
void FlipTextePcb(TEXTE_PCB *aTextePcb, wxDC *aDC)
Class BOARD to handle a board.
bool InvokeDXFDialogBoardImport(PCB_BASE_FRAME *aCaller)
Function InvokeDXFDialogBoardImport shows the modal DIALOG_DXF_IMPORT for importing a DXF file to a b...
void InstallFindFrame()
void InstallGraphicItemPropertiesDialog(DRAWSEGMENT *aItem, wxDC *aDC)
void SetMessageBlock(EDA_DRAW_FRAME *frame)
Function SetMessageBlock Displays the type of block command in the status bar of the window...
Component library viewer main window.
static LSET AllNonCuMask()
Function AllNonCuMask returns a mask holding all layer minus CU layers.
Definition: lset.cpp:696
MODULE * Next() const
Definition: class_module.h:121
void BeginMoveDimensionText(DIMENSION *aItem, wxDC *DC)
Definition: dimension.cpp:382
void ShowDimensionPropertyDialog(DIMENSION *aDimension, wxDC *aDC)
Definition: dimension.cpp:354
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:61
int GetCopperLayerCount() const
Function GetCopperLayerCount.
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
void SetCurItem(BOARD_ITEM *aItem, bool aDisplayInfo=true)
Function SetCurItem sets the currently selected item and displays it in the MsgPanel.
void Start_Move_Zone_Outlines(wxDC *DC, ZONE_CONTAINER *zone_container)
Function Start_Move_Zone_Outlines Initialize parameters to move an existing zone outlines.
SHAPE_POLY_SET * Outline()
Definition: class_zone.h:236
MOVE_EXACT_ORIGIN origin
void EndMouseCapture(int aId=-1, int aCursorId=-1, const wxString &aTitle=wxEmptyString, bool aCallEndFunc=true)
Function EndMouseCapture ends mouse a capture.
BLOCK_COMMAND_T
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
BOARD * GetBoard() const
bool GetAssociatedDocument(wxWindow *aParent, const wxString &aDocName, const wxPathList *aPaths)
Function GetAssociatedDocument open a document (file) with the suitable browser.
Definition: eda_doc.cpp:87
Classes to handle copper zones.
void Rotate_Module(wxDC *DC, MODULE *module, double angle, bool incremental)
void Delete_Texte_Pcb(TEXTE_PCB *TextePcb, wxDC *DC)
void OnSelectTool(wxCommandEvent &aEvent)
Definition: edit.cpp:1486
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
void PushItem(const ITEM_PICKER &aItem)
Function PushItem pushes aItem to the top of the list.
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
void duplicateItem(BOARD_ITEM *aItem, bool aIncrement)
Function duplicateItem Duplicate the specified item This function is shared between pcbnew and modedi...
Definition: edit.cpp:1681
void RotateTextModule(TEXTE_MODULE *Text, wxDC *DC)
Definition: edtxtmod.cpp:108
DRC * m_drc
the DRC controller, see drc.cpp
void DeleteAll()
Function DeleteAll deletes all items on the list and leaves the list empty.
Definition: dlist.cpp:44
void Swap_Layers(wxCommandEvent &event)
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 ...
VIATYPE_T
Definition: class_track.h:50
void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
Definition: draw_panel.cpp:360
int GetState(int type) const
Definition: base_struct.h:248
void PushPreferences(const EDA_DRAW_PANEL *aParentCanvas)
Function PushPreferences Pushes a few preferences from a parent window to a child window...
Definition: draw_frame.cpp:864
void finalise() override
Definition: edit.cpp:1756
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
Definition of class FOOTPRINT_EDIT_FRAME.
void RemoveStruct(BOARD_ITEM *Item, wxDC *DC)
Definition: edit.cpp:1337
bool End_Route(TRACK *aTrack, wxDC *aDC)
Function End_Route Terminates a track currently being created.
Definition: editrack.cpp:413
BOARD_ITEM * getNthItemToArray(int n) const override
Definition: edit.cpp:1735
void Start_Move_DrawItem(DRAWSEGMENT *drawitem, wxDC *DC)
Definition: editedge.cpp:56
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
void CallEndMouseCapture(wxDC *aDC)
Function CallEndMouseCapture calls the end mouse capture callback.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
Class DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS.
Functions relatives to tracks, vias and segments used to fill zones.
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
void StartMovePad(D_PAD *aPad, wxDC *aDC, bool aDragConnectedTracks)
Function StartMovePad Initialize a drag or move pad command.
void ClearItemsList()
Function ClearItemsList clear only the list of EDA_ITEM pointers, it does NOT delete the EDA_ITEM obj...
void DeletePad(D_PAD *aPad, bool aQuery=true)
Function DeletePad Delete the pad aPad.
void InstallFootprintPropertiesDialog(MODULE *Module, wxDC *DC)
void moveExact()
Function moveExact Move the selected item exactly.
Definition: edit.cpp:1599
void Export_Pad_Settings(D_PAD *aPad)
void SetState(BLOCK_STATE_T aState)
virtual bool HandleBlockBegin(wxDC *aDC, EDA_KEY aKey, const wxPoint &aPosition, int aExplicitCommand=0)
Initialize a block command.
Definition: draw_frame.cpp:881
void Zoom_Automatique(bool aWarpPointer)
Function Zoom_Automatique redraws the screen with best zoom level and the best centering that shows a...
Definition: zoom.cpp:106
class MODULE, a footprint
Definition: typeinfo.h:89
timestamp_t GetNewTimeStamp()
Definition: common.cpp:160
void ResetTextSize(BOARD_ITEM *aItem, wxDC *aDC)
Function ResetTextSize resets given field text size and width to current settings in Preferences->Dim...
Definition: edtxtmod.cpp:302
void Attribut_Track(TRACK *track, wxDC *DC, bool Flag_On)
Definition: attribut.cpp:68
Class PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings...
PCB_LAYER_ID
A quick note on layer IDs:
void StartMoveTextePcb(TEXTE_PCB *aTextePcb, wxDC *aDC, bool aErase=true)
a helper to handle the real device context used in KiCad
BOARD_ITEM * GetCurItem() const
Function GetCurItem returns the currently selected BOARD_ITEM, overriding BASE_SCREEN::GetCurItem().
Definition: pcb_screen.h:72
TEXTE_PCB * CreateTextePcb(wxDC *aDC, TEXTE_PCB *aText=NULL)
void InstallTextModOptionsFrame(TEXTE_MODULE *TextMod, wxDC *DC)
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:300
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Function SetMsgPanel clears the message panel and populates it with the contents of aList...
Definition: draw_frame.cpp:831
bool IsMouseCaptured() const
BOARD_ITEM * m_item
Definition: edit.cpp:1761
EDA_RECT GetFootprintRect() const
Function GetFootprintRect() Returns the area of the module footprint excluding any text...
void Rotate_Texte_Pcb(TEXTE_PCB *TextePcb, wxDC *DC)
PCB_GENERAL_SETTINGS & Settings()
void SetEnd(int x, int y)
Definition: eda_rect.h:134
DLIST< SEGZONE > m_SegZoneDeprecated
Definition: class_board.h:249
void DlgGlobalChange_PadSettings(D_PAD *aPad, bool aRedraw)
Function DlgGlobalChange_PadSettings Function to change pad caracteristics for the given footprint or...
bool Fill(std::vector< ZONE_CONTAINER * > aZones, bool aCheck=false)
Definition: zone_filler.cpp:85
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.
TRACK * OnHotkeyBeginRoute(wxDC *aDC)
Function OnHotkeyBeginRoute If the current active layer is a copper layer, and if no item currently e...
virtual bool HandleBlockEnd(wxDC *DC) override
Function HandleBlockEnd() Handle the "end" of a block command, i.e.
bool UnFill()
Function UnFill Removes the zone filling.
Definition: class_zone.cpp:156
void Delete_Segment_Edge(DRAWSEGMENT *Segment, wxDC *DC)
Definition: editedge.cpp:113
void HighLight(wxDC *DC)
Function HighLight.
Definition: highlight.cpp:101
PCB_LAYER_ID m_Route_Layer_BOTTOM
Definition: pcb_screen.h:46
bool Load_Module_From_BOARD(MODULE *Module)
Function Load_Module_From_BOARD load in Modedit a footprint from the main board.
void StartMoveOneNodeOrSegment(TRACK *aTrack, wxDC *aDC, int aCommand)
Function StartMoveOneNodeOrSegment initializes the parameters to move one via or/and a terminal point...
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame...
void createArray()
Function createArray Create an array of the selected item (invokes the dialogue) This function is sha...
Definition: edit.cpp:1765
void Start_DragTrackSegmentAndKeepSlope(TRACK *track, wxDC *DC)
wxString g_DocModulesFileName
Definition: pcbnew.cpp:81
class SEGZONE, a segment used to fill a zone area (segment on a copper layer)
Definition: typeinfo.h:97
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:1015
void SetAutoPanRequest(bool aEnable)
Class PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
void SaveCopyInUndoList(BOARD_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, const wxPoint &aTransformPoint=wxPoint(0, 0)) override
Function SaveCopyInUndoList Creates a new entry in undo list of commands.
Definition: undo_redo.cpp:202
bool PlaceDraggedOrMovedTrackSegment(TRACK *Track, wxDC *DC)
void SetItem(EDA_ITEM *aItem)
int Delete_LastCreatedCorner(wxDC *DC)
Function Delete_LastCreatedCorner Used only while creating a new zone outline Remove and delete the c...
void CrossHairOff(wxDC *DC)
Definition: draw_panel.cpp:265
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:100
bool IsLocked() const override
Function IsLocked.
Definition: class_module.h:263
void Add_Similar_Zone(wxDC *DC, ZONE_CONTAINER *zone_container)
Function Add_Similar_Zone Add a zone to a given zone outline.
const wxPoint GetPosition() const
Definition: eda_rect.h:113
void SetSelectedCorner(int aCorner)
Definition: class_zone.h:210
D_PAD * GetTopLeftPad()
void Add_Zone_Cutout(wxDC *DC, ZONE_CONTAINER *zone_container)
Function Add_Zone_Cutout Add a cutout zone to a given zone outline.
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:101
void Edit_Zone_Params(wxDC *DC, ZONE_CONTAINER *zone_container)
Function Edit_Zone_Params Edit params (layer, clearance, ...) for a zone outline. ...
void Compile_Ratsnest(wxDC *aDC, bool aDisplayStatus)
Function Compile_Ratsnest Create the entire board ratsnest.
Definition: ratsnest.cpp:54
void Attribut_net(wxDC *DC, int net_code, bool Flag_On)
Definition: attribut.cpp:97
int m_rotationAngle
User defined rotation angle (in tenths of a degree).
int GetNetCode() const
Function GetNetCode.
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
void DeleteTextModule(TEXTE_MODULE *Text)
Definition: edtxtmod.cpp:139
void Attribut_Segment(TRACK *track, wxDC *DC, bool Flag_On)
Definition: attribut.cpp:50
void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, GR_DRAWMODE aDrawMode, const wxPoint &aOffset=ZeroOffset) override
Function Draw BOARD_ITEMs have their own color information.
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
Definition: draw_frame.cpp:615
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:106
void Delete_Track(wxDC *DC, TRACK *Track)
Definition: deltrack.cpp:146
void SendMessageToEESCHEMA(BOARD_ITEM *objectToSync)
Function SendMessageToEESCHEMA sends a message to the schematic editor so that it may move its cursor...
BOARD * getBoard() const override
Definition: edit.cpp:1741
void ShowTargetOptionsDialog(PCB_TARGET *aTarget, wxDC *DC)
Definition: target_edit.cpp:83
virtual void HandleBlockPlace(wxDC *DC) override
Function HandleBlockPlace() Called after HandleBlockEnd, when a block command needs to be executed af...
void CrossHairOn(wxDC *DC)
Definition: draw_panel.cpp:272
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:99
void ShowDRCDialog(wxWindow *aParent=NULL)
Open a dialog and prompts the user, then if a test run button is clicked, runs the test(s) and create...
Definition: drc.cpp:59
see class PGM_BASE
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:986
Common, abstract interface for edit frames.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void Process_Special_Functions(wxCommandEvent &event)
Definition: edit.cpp:67
void ArchiveModulesOnBoard(bool aStoreInNewLib, const wxString &aLibName=wxEmptyString, wxString *aLibPath=NULL)
Function ArchiveModulesOnBoard Save modules in a library:
void duplicateZone(wxDC *aDC, ZONE_CONTAINER *aZone)
Function duplicateZone duplicates the given zone.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
const wxString & GetReference() const
Function GetReference.
Definition: class_module.h:458
void StartMoveModule(MODULE *aModule, wxDC *aDC, bool aDragConnectedTracks)
Function StartMoveModule Initialize a drag or move pad command.
DLIST< MODULE > m_Modules
Definition: class_board.h:247
#define INSTALL_UNBUFFERED_DC(name, parent)
int GetToolId() const
Definition: draw_frame.h:496
VTBL_ENTRY wxConfigBase * CommonSettings() const
Definition: pgm_base.h:145
void SetIgnoreMouseEvents(bool aIgnore)
LAYER_NUM GetLayerSelection() const
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:162
PCB_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
PICKED_ITEMS_LIST & GetItems()
static bool GetLayer(MODEL_VRML &aModel, LAYER_NUM layer, VRML_LAYER **vlayer)
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
int GetSelectedCorner() const
Definition: class_zone.h:201
virtual void Delete(BOARD_ITEM *aItem)
Removes an item from the containter and deletes it.
void InsertVertex(int aGlobalIndex, VECTOR2I aNewVertex)
Function InsertVertex Adds a vertex in the globally indexed position aGlobalIndex.
void Delete_Zone_Contour(wxDC *DC, ZONE_CONTAINER *zone_container)
Function Delete_Zone Remove the zone which include the segment aZone, or the zone which have the give...
void Delete_net(wxDC *DC, TRACK *Track)
Definition: deltrack.cpp:156
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
bool IsMicroViaAcceptable(void)
Function IsMicroViaAcceptable return true if a microvia can be placed on the board.
void InstallPadOptionsFrame(D_PAD *pad)
int Fill_All_Zones(wxWindow *aActiveWindow)
Function Fill_All_Zones Fill all zones on the board The old fillings are removed. ...
MODULE * GetFootprintFromBoardByReference()
Function GetFootprintFromBoardByReference.
void StartMoveTexteModule(TEXTE_MODULE *Text, wxDC *DC)
Definition: edtxtmod.cpp:199
Module description (excepted pads)
PCB_LAYER_BOX_SELECTOR * m_SelLayerBox
void SelectCopperLayerPair()
Definition: sel_layer.cpp:287
void Change_Side_Module(MODULE *Module, wxDC *DC)
Function Change_Side_Module Flip a footprint (switch layer from component or component to copper) The...
void SetCrossHairPosition(const wxPoint &aPosition, bool aSnapToGrid=true)
Function SetCrossHairPosition sets the screen cross hair position to aPosition in logical (drawing) u...
const wxPoint GetPosition() const override
Definition: class_pad.h:220
void Delete_OldZone_Fill(SEGZONE *aZone, timestamp_t aTimestamp=0)
Function Delete_OldZone_Fill (obsolete) Used for compatibility with old boards Remove the zone fillin...
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
void SetLastCursorPosition(const wxPoint &aPosition)
Function SetLastCursorPosition sets the last cursor position to aPosition.
int GetDefaultCursor() const
Function GetDefaultCursor.
BOARD_ITEM * GetCurItem()
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Function DisplayInfoMessage displays an informational message box with aMessage.
Definition: confirm.cpp:216
void SwitchLayer(wxDC *DC, PCB_LAYER_ID layer) override
Definition: edit.cpp:1414
void duplicateItems(bool aIncrement) override
Function duplicateItems Duplicate selected item if possible and start a move.
Definition: edit.cpp:1664
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:185
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:233
PCB_LAYER_ID SelectLayer(PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask=LSET(), wxPoint aDlgPosition=wxDefaultPosition)
Install the dialog box for layer selection.
Definition: sel_layer.cpp:221
const wxPoint GetPosition() const override
Definition: class_module.h:182
virtual void SetActiveLayer(PCB_LAYER_ID aLayer) override
Function SetActiveLayer will change the currently active layer to aLayer and also update the PCB_LAYE...
void Import_Pad_Settings(D_PAD *aPad, bool aDraw)
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:796
int m_lastDrawToolId
Tool ID of previously active draw tool bar button.
Definition: draw_frame.h:113
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:293
MOVE_EXACT_ANCHOR anchor
#define mod(a, n)
Definition: greymap.cpp:24
void Clean_Pcb()
Function Clean_Pcb Clean up the board (remove redundant vias, not connected tracks and merges colline...
void Delete_Drawings_All_Layer(PCB_LAYER_ID aLayer)
Definition: editedge.cpp:148
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Definition: class_pad.cpp:199
Class DIMENSION.
PCB_LAYER_ID m_Route_Layer_TOP
Definition: pcb_screen.h:45
void Edit_TrackSegm_Width(wxDC *aDC, TRACK *aTrackItem)
Function Edit_TrackSegm_Width Modify one track segment width or one via diameter (using DRC control)...
LEGACY_ARRAY_CREATOR(PCB_BASE_EDIT_FRAME &editFrame)
Definition: edit.cpp:1722
void SetCommand(BLOCK_COMMAND_T aCommand)
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:214
void End_Edge(DRAWSEGMENT *Segment, wxDC *DC)
Definition: editedge.cpp:316
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
MODULE * getModule() const override
Definition: edit.cpp:1746
const wxPoint GetCenter() const
Definition: eda_rect.h:115