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>
54 #include <invoke_pcb_dialog.h>
55 #include <array_creator.h>
57 
58 #include <zone_filler.h>
59 
60 #include <dialog_move_exact.h>
61 
62 #include <tool/tool_manager.h>
63 #include <tools/pcb_actions.h>
64 
65 // Handles the selection of command events.
66 void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
67 {
68  int id = event.GetId();
69 
71  MODULE* module;
72  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
73 
74  m_canvas->CrossHairOff( &dc );
75 
76  switch( id ) // Some (not all ) edit commands must be finished or aborted
77  {
78  case wxID_CUT:
79  case wxID_COPY:
146  case ID_POPUP_ZOOM_BLOCK:
147  case ID_POPUP_FLIP_BLOCK:
157  break;
158 
160  if( m_canvas->IsMouseCaptured() )
161  {
163  }
164 
165  // Should not be executed, just in case
166  if( GetScreen()->m_BlockLocate.GetCommand() != BLOCK_IDLE )
167  {
171  }
172 
173  if( GetToolId() == ID_NO_TOOL_SELECTED )
175  else
176  SetCursor( (wxStockCursor) m_canvas->GetDefaultCursor() );
177 
178  break;
179 
180  default: // Finish (abort) the command
181  if( m_canvas->IsMouseCaptured() )
183 
184  if( GetToolId() != id )
185  {
186  if( m_lastDrawToolId != GetToolId() )
188 
190  }
191  break;
192  }
193 
194  switch( id ) // Execute command
195  {
196  case 0:
197  break;
198 
200  {
202 
203  if( !editor )
204  {
206  editor->Zoom_Automatique( false );
207  }
208  else
209  {
210  // Needed on Windows, other platforms do not use it,
211  // but it creates no issue
212  if( editor->IsIconized() )
213  editor->Iconize( false );
214 
215  editor->Raise();
216 
217  // Raising the window does not set the focus on Linux. This should work on
218  // any platform.
219  if( wxWindow::FindFocus() != editor )
220  editor->SetFocus();
221  }
222 
223  editor->PushPreferences( m_canvas );
224  }
225  break;
226 
228  {
230 
231  if( !viewer )
232  {
234  }
235  else
236  {
237  // Needed on Windows, other platforms do not use it,
238  // but it creates no issue
239  if( viewer->IsIconized() )
240  viewer->Iconize( false );
241 
242  viewer->Raise();
243 
244  // Raising the window does not set the focus on Linux. This should work on
245  // any platform.
246  if( wxWindow::FindFocus() != viewer )
247  viewer->SetFocus();
248  }
249 
250  viewer->PushPreferences( m_canvas );
251  }
252  break;
253 
255  InstallPcbGlobalDeleteFrame( wxDefaultPosition );
256  break;
257 
260  m_canvas->SetAutoPanRequest( false );
261  HandleBlockPlace( &dc );
262  break;
263 
267  m_canvas->SetAutoPanRequest( false );
268  HandleBlockPlace( &dc );
269  break;
270 
271  case ID_POPUP_ZOOM_BLOCK:
274  HandleBlockEnd( &dc );
275  break;
276 
280  HandleBlockEnd( &dc );
281  break;
282 
286  HandleBlockEnd( &dc );
287  break;
288 
289  case ID_POPUP_FLIP_BLOCK:
292  HandleBlockEnd( &dc );
293  break;
294 
295  case ID_DRC_CONTROL:
296  // Shows the DRC dialog in non modal mode, to allows board editing
297  // with the DRC dialog opened and showing errors.
298  m_drc->ShowDRCDialog();
299  break;
300 
301  case ID_GET_NETLIST:
302  InstallNetlistFrame( &dc );
303  break;
304 
305  case ID_FIND_ITEMS:
307  break;
308 
311  break;
312 
314  break;
315 
318 
319  // EndSegment(&dc);
320  break;
321 
323  if( GetCurItem() == NULL )
324  break;
325  Edit_Track_Width( &dc, (TRACK*) GetCurItem() );
327  OnModify();
328  break;
329 
331  if( GetCurItem() == NULL )
332  break;
335  OnModify();
336  break;
337 
339  {
340  wxCommandEvent dummy;
342  }
344  break;
345 
348  OnHotkeyBeginRoute( &dc );
349  break;
350 
353  End_Route( (TRACK*) GetCurItem(), &dc );
354  break;
355 
358 
359  if( GetCurItem()->IsDragging() )
360  {
362  }
363 
364  break;
365 
367  /* change the position of initial segment when creating new tracks
368  * switch from _/ to -\ .
369  * If a track is in progress, it will be redrawn
370  */
371  if( m_canvas->IsMouseCaptured() )
372  m_canvas->CallMouseCapture( &dc, wxDefaultPosition, false );
373 
375 
376  if( m_canvas->IsMouseCaptured() )
377  m_canvas->CallMouseCapture( &dc, wxDefaultPosition, false );
378 
379  break;
380 
382  if( !IsMicroViaAcceptable() )
383  break;
384  // fall through
390 
391  if( GetCurItem()->IsDragging() )
392  {
394  }
395  else
396  {
398  VIATYPE_T v_type = settings.m_CurrentViaType;
399  switch( id )
400  {
404  break;
405 
407  settings.m_CurrentViaType = VIA_MICROVIA;
408  break;
409 
410  default:
411  settings.m_CurrentViaType = VIA_THROUGH;
412  break;
413  }
414 
415  // place via and switch layer.
418  {
420 
421  wxPoint dlgPosition;
422 
423  wxGetMousePosition( &dlgPosition.x, &dlgPosition.y );
424 
425  PCB_LAYER_ID layer = SelectLayer( GetActiveLayer(), LSET::AllNonCuMask(), dlgPosition );
426 
427  m_canvas->SetIgnoreMouseEvents( false );
429 
430  if( GetActiveLayer() != layer )
431  {
433  GetScreen()->m_Route_Layer_BOTTOM = layer;
434  Other_Layer_Route( (TRACK*) GetCurItem(), &dc );
435  }
436  }
437 
438  else
439  Other_Layer_Route( (TRACK*) GetCurItem(), &dc );
440 
441  settings.m_CurrentViaType = v_type;
442 
443  if( displ_opts->m_ContrastModeDisplay )
444  m_canvas->Refresh();
445  }
446  break;
447 
449  if( GetCurItem() )
450  {
452  SetCurItem( Delete_Segment( &dc, (TRACK*) GetCurItem() ) );
453  OnModify();
454  }
455  break;
456 
458  if( GetCurItem() )
459  {
461  Delete_Track( &dc, (TRACK*) GetCurItem() );
462  SetCurItem( NULL );
463  OnModify();
464  }
465  break;
466 
469  Delete_net( &dc, (TRACK*) GetCurItem() );
470  SetCurItem( NULL );
471  OnModify();
472  break;
473 
475  Attribut_Segment( (TRACK*) GetCurItem(), &dc, true );
476  break;
477 
479  Attribut_Segment( (TRACK*) GetCurItem(), &dc, false );
480  break;
481 
483  Attribut_Track( (TRACK*) GetCurItem(), &dc, true );
484  break;
485 
487  Attribut_Track( (TRACK*) GetCurItem(), &dc, false );
488  break;
489 
491  Attribut_net( &dc, ( (TRACK*) GetCurItem() )->GetNetCode(), true );
492  break;
493 
495  Attribut_net( &dc, ( (TRACK*) GetCurItem() )->GetNetCode(), false );
496  break;
497 
499  break;
500 
503  SetCurItem( NULL ); // Outlines can have changed
504  break;
505 
507  {
509  duplicateZone( &dc, zone );
510  }
511  break;
512 
515  m_canvas->SetAutoPanRequest( true );
517  break;
518 
521  m_canvas->SetAutoPanRequest( true );
523  break;
524 
526  // Force the main contour selection, to remove the entire zone:
527  ((ZONE_CONTAINER*) GetCurItem())->SetSelectedCorner( 0 );
528  // Fall through
531  {
532  int netcode = ( (ZONE_CONTAINER*) GetCurItem() )->GetNetCode();
534  SetCurItem( NULL );
535  TestNetConnection( NULL, netcode );
536  SetMsgPanel( GetBoard() );
537  }
538  break;
539 
542  SetCurItem( NULL );
543  break;
544 
546  {
548  ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
549  m_canvas->SetAutoPanRequest( true );
550  Start_Move_Zone_Corner( &dc, zone_cont, zone_cont->GetSelectedCorner(), false );
551  }
552  break;
553 
555  {
557  ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
558  m_canvas->SetAutoPanRequest( true );
559  Start_Move_Zone_Drag_Outline_Edge( &dc, zone_cont, zone_cont->GetSelectedCorner() );
560  }
561  break;
562 
564  {
566  ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
567  m_canvas->SetAutoPanRequest( true );
568  Start_Move_Zone_Outlines( &dc, zone_cont );
569  }
570  break;
571 
573  {
575  ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
576  wxPoint pos = GetCrossHairPosition();
577 
578  /* add corner between zone_cont->m_CornerSelection
579  * and zone_cont->m_CornerSelection+1
580  * and start move the new corner
581  */
582  zone_cont->Draw( m_canvas, &dc, GR_XOR );
583  zone_cont->Outline()->InsertVertex( zone_cont->GetSelectedCorner(), pos );
584  zone_cont->SetSelectedCorner( zone_cont->GetSelectedCorner() + 1 );
585  zone_cont->Draw( m_canvas, &dc, GR_XOR );
586  m_canvas->SetAutoPanRequest( true );
587  Start_Move_Zone_Corner( &dc, zone_cont, zone_cont->GetSelectedCorner(), true );
588  }
589  break;
590 
594  {
596  ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
597  End_Move_Zone_Corner_Or_Outlines( &dc, zone_cont );
598  m_canvas->SetAutoPanRequest( false );
599  }
600  break;
601 
604  Fill_All_Zones();
605  m_canvas->Refresh();
606  SetMsgPanel( GetBoard() );
607  break;
608 
610  if( ( GetCurItem() )->Type() == PCB_ZONE_AREA_T )
611  {
612  ZONE_CONTAINER* zone_container = (ZONE_CONTAINER*) GetCurItem();
613  zone_container->UnFill();
614  GetBoard()->GetConnectivity()->Update( zone_container );
615  OnModify();
616  SetMsgPanel( GetBoard() );
617  m_canvas->Refresh();
618  }
619 
620  Compile_Ratsnest( &dc, false );
621  SetCurItem( NULL );
622  break;
623 
624  case ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_ALL_ZONES: // Remove all zones :
625  for( int ii = 0; ii < GetBoard()->GetAreaCount(); ii++ )
626  {
627  // Remove filled areas in zone
628  ZONE_CONTAINER* zone_container = GetBoard()->GetArea( ii );
629  zone_container->UnFill();
630  GetBoard()->GetConnectivity()->Update( zone_container );
631  }
632 
633  Compile_Ratsnest( &dc, false );
634  SetCurItem( NULL ); // CurItem might be deleted by this command, clear the pointer
635  OnModify();
636  SetMsgPanel( GetBoard() );
637  m_canvas->Refresh();
638  break;
639 
641  {
643  ZONE_FILLER filler( GetBoard() );
644  filler.Fill( { (ZONE_CONTAINER*) GetCurItem() } );
645  SetMsgPanel( GetBoard() );
646  m_canvas->Refresh();
647  break;
648  }
649 
652  m_canvas->SetAutoPanRequest( true );
653  break;
654 
657  if( GetCurItem() == NULL )
658  break;
659 
660  // If the current Item is a pad, text module ...: Get its parent
661  if( GetCurItem()->Type() != PCB_MODULE_T )
662  SetCurItem( GetCurItem()->GetParent() );
663 
664  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
665  break;
666 
667  module = (MODULE*) GetCurItem();
668 
669  if( module->IsLocked() )
670  {
671  wxString msg;
672  msg.Printf( _( "Footprint %s found, but it is locked" ),
673  module->GetReference().GetData() );
674  DisplayInfoMessage( this, msg );
675  break;
676  }
677 
678  SendMessageToEESCHEMA( module );
679  SetCrossHairPosition( module->GetPosition() );
682  break;
683 
684  case ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST: // get module by name and move it
686  module = (MODULE*) GetCurItem();
687 
688  if( module == NULL )
689  break;
690 
691  if( module->IsLocked() )
692  {
693  wxString msg = wxString::Format(
694  _( "Footprint %s found, but it is locked" ),
695  module->GetReference().GetData() );
696  DisplayInfoMessage( this, msg );
697  break;
698  }
699 
700  SendMessageToEESCHEMA( module );
702  StartMoveModule( module, &dc, false );
703  break;
704 
707 
708  // If the current Item is a pad, text module ...: Get its parent
709  if( GetCurItem()->Type() != PCB_MODULE_T )
710  SetCurItem( GetCurItem()->GetParent() );
711 
712  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
713  break;
714 
715  module = (MODULE*) GetCurItem();
716 
717  if( module->IsLocked() )
718  {
719  wxString msg;
720  msg.Printf( _( "Footprint %s found, but it is locked" ),
721  module->GetReference().GetData() );
722  DisplayInfoMessage( this, msg );
723  break;
724  }
725 
726  if( Delete_Module( (MODULE*) GetCurItem(), &dc ) )
727  {
728  SetCurItem( NULL );
729  }
730 
731  break;
732 
735 
736  // If the current Item is a pad, text module ...: Get its parent
737  if( GetCurItem()->Type() != PCB_MODULE_T )
738  SetCurItem( GetCurItem()->GetParent() );
739 
740  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
741  break;
742 
743  module = (MODULE*) GetCurItem();
744 
745  if( module->IsLocked() )
746  {
747  wxString msg;
748  msg.Printf( _( "Footprint %s found, but it is locked" ),
749  module->GetReference().GetData() );
750  DisplayInfoMessage( this, msg );
751  break;
752  }
753 
754  // This is a simple rotation, no other editing in progress
755  if( !GetCurItem()->IsMoving() )
756  SaveCopyInUndoList( GetCurItem(), UR_CHANGED, ((MODULE*)GetCurItem())->GetPosition() );
757 
758  Rotate_Module( &dc, (MODULE*) GetCurItem(), m_rotationAngle, true );
759  break;
760 
763 
764  // If the current Item is a pad, text module ...: Get its parent
765  if( GetCurItem()->Type() != PCB_MODULE_T )
766  SetCurItem( GetCurItem()->GetParent() );
767 
768  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
769  break;
770 
771  module = (MODULE*) GetCurItem();
772 
773  if( module->IsLocked() )
774  {
775  wxString msg;
776  msg.Printf( _( "Footprint %s found, but it is locked" ),
777  module->GetReference().GetData() );
778  DisplayInfoMessage( this, msg );
779  break;
780  }
781 
782  // This is a simple rotation, no other editing in progress
783  if( !GetCurItem()->IsMoving() )
784  SaveCopyInUndoList( GetCurItem(), UR_CHANGED, ((MODULE*)GetCurItem())->GetPosition() );
785 
786  Rotate_Module( &dc, (MODULE*) GetCurItem(), -m_rotationAngle, true );
787  break;
788 
791 
792  // If the current Item is a pad, text module ...: Get its parent
793  if( GetCurItem()->Type() != PCB_MODULE_T )
794  SetCurItem( GetCurItem()->GetParent() );
795 
796  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
797  break;
798 
799  module = (MODULE*) GetCurItem();
800 
801  if( module->IsLocked() )
802  {
803  wxString msg;
804  msg.Printf( _( "Footprint %s found, but it is locked" ),
805  module->GetReference().GetData() );
806  DisplayInfoMessage( this, msg );
807  break;
808  }
809 
810  // This is a simple flip, no other editing in progress
811  if( !GetCurItem()->IsMoving() )
812  SaveCopyInUndoList( GetCurItem(), UR_FLIPPED, ((MODULE*)GetCurItem())->GetPosition() );
813 
814  Change_Side_Module( (MODULE*) GetCurItem(), &dc );
815  break;
816 
818  if( GetCurItem() && GetCurItem()->Type() == PCB_MODULE_T )
819  {
820  InstallExchangeModuleFrame( dynamic_cast<MODULE*>( GetCurItem() ), true, true );
822  }
823  break;
824 
826  if( GetCurItem() && GetCurItem()->Type() == PCB_MODULE_T )
827  {
828  InstallExchangeModuleFrame( dynamic_cast<MODULE*>( GetCurItem() ), false, true );
830  }
831  break;
832 
834  // If the current Item is a pad, text module ...: Get its parent
835  if( GetCurItem()->Type() != PCB_MODULE_T )
836  SetCurItem( GetCurItem()->GetParent() );
837 
838  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
839  break;
840 
843  break;
844 
846 
847  // If we don't have a current item, there's nothing we can do here
848  if( !GetCurItem() )
849  break;
850 
851  // If the current Item is a pad, text module ...: Get its parent
852  if( GetCurItem()->Type() != PCB_MODULE_T )
853  SetCurItem( GetCurItem()->GetParent() );
854 
855  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
856  break;
857 
858  if( GetCurItem()->GetTimeStamp() == 0 ) // Module Editor needs a non null timestamp
859  {
861  OnModify();
862  }
863 
864  {
866 
868  SetCurItem( NULL ); // the current module could be deleted by
869  }
871  break;
872 
874  module = (MODULE*) GetCurItem()->GetParent();
875 
876  if( !module || module->Type() != PCB_MODULE_T )
877  break;
878 
879  if( module->IsLocked() )
880  {
881  wxString msg;
882  msg.Printf( _( "The parent (%s) of the pad is locked" ),
883  module->GetReference().GetData() );
884  DisplayInfoMessage( this, msg );
885  break;
886  }
887 
889  StartMovePad( (D_PAD*) GetCurItem(), &dc, true );
890  break;
891 
893  module = (MODULE*) GetCurItem()->GetParent();
894 
895  if( !module || module->Type() != PCB_MODULE_T )
896  break;
897 
898  if( module->IsLocked() )
899  {
900  wxString msg;
901  msg.Printf( _( "The parent (%s) of the pad is locked" ),
902  module->GetReference().GetData() );
903  DisplayInfoMessage( this, msg );
904  break;
905  }
906 
908  StartMovePad( (D_PAD*) GetCurItem(), &dc, false );
909  break;
910 
914  break;
915 
918  SaveCopyInUndoList( GetCurItem()->GetParent(), UR_CHANGED );
919  Import_Pad_Settings( (D_PAD*) GetCurItem(), true );
920  break;
921 
925  break;
926 
930  break;
931 
933  SaveCopyInUndoList( GetCurItem()->GetParent(), UR_CHANGED );
934  DeletePad( (D_PAD*) GetCurItem() );
935  SetCurItem( NULL );
937  break;
938 
941  break;
942 
944  ResetTextSize( GetCurItem(), &dc );
945  break;
946 
949  StartMoveTexteModule( static_cast<TEXTE_MODULE*>( GetCurItem() ), &dc );
950  break;
951 
953  RotateTextModule( static_cast<TEXTE_MODULE*>( GetCurItem() ), &dc );
955  break;
956 
958  DeleteTextModule( static_cast<TEXTE_MODULE*>( GetCurItem() ) );
959  SetCurItem( NULL );
961  break;
962 
964  {
966 
967  if( itmp >= 0 )
968  {
969  // if user changed colors and we are in high contrast mode, then redraw
970  // because the PAD_ATTRIB_SMD pads may change color.
971  if( displ_opts->m_ContrastModeDisplay && GetActiveLayer() != itmp )
972  {
973  m_canvas->Refresh();
974  }
975  SetActiveLayer( itmp );
976  }
977 
979  }
980  break;
981 
984  break;
985 
987  {
989 
990  if( itmp >= 0 )
991  SetActiveLayer( itmp );
992 
994  }
995  break;
996 
998  {
1000 
1001  if( itmp >= 0 )
1002  SetActiveLayer( itmp );
1003  }
1004  break;
1005 
1009  break;
1010 
1013 
1014  if( displ_opts->m_ContrastModeDisplay )
1015  m_canvas->Refresh( true );
1016  break;
1017 
1020  break;
1021 
1023  Rotate_Texte_Pcb( (TEXTE_PCB*) GetCurItem(), &dc );
1025  break;
1026 
1028  CreateTextePcb( &dc, (TEXTE_PCB*) GetCurItem() );
1030  m_canvas->SetAutoPanRequest( true );
1031  break;
1032 
1034  FlipTextePcb( (TEXTE_PCB*) GetCurItem(), &dc );
1036  break;
1037 
1039  Delete_Texte_Pcb( (TEXTE_PCB*) GetCurItem(), &dc );
1041  break;
1042 
1044  BeginMoveTarget( (PCB_TARGET*) GetCurItem(), &dc );
1046  break;
1047 
1051  break;
1052 
1055  DeleteTarget( (PCB_TARGET*) GetCurItem(), &dc );
1056  SetCurItem( NULL );
1057  break;
1058 
1061  DeleteDimension( (DIMENSION*) GetCurItem(), &dc );
1062  SetCurItem( NULL );
1063  break;
1064 
1068  break;
1069 
1072  break;
1073 
1077  break;
1078 
1080  RemoveStruct( GetCurItem(), &dc );
1082  break;
1083 
1085  if( GetCurItem() && GetCurItem()->Type() == PCB_MARKER_T )
1086  ( (MARKER_PCB*) GetCurItem() )->DisplayMarkerInfo( this );
1087 
1089  break;
1090 
1092  if( GetCurItem()->GetEditFlags() != 0 )
1093  break;
1094 
1096  SetCurItem( NULL );
1098  m_canvas->Refresh();
1099  break;
1100 
1103  break;
1104 
1108  break;
1109 
1112 
1113  if( GetCurItem() && (GetCurItem()->IsNew()) )
1114  {
1115  End_Edge( (DRAWSEGMENT*) GetCurItem(), &dc );
1116  SetCurItem( NULL );
1117  }
1118 
1119  break;
1120 
1123 
1124  if( GetCurItem() && (GetCurItem()->IsNew()) )
1125  {
1126  if( End_Zone( &dc ) )
1127  SetCurItem( NULL );
1128  }
1129 
1130  m_canvas->SetAutoPanRequest( false );
1131  break;
1132 
1135 
1136  if( GetCurItem() && (GetCurItem()->IsNew()) )
1137  {
1138  if( Delete_LastCreatedCorner( &dc ) == 0 ) // No more segment in outline,
1139  SetCurItem( NULL );
1140  }
1141 
1142  break;
1143 
1144 
1148  break;
1149 
1154  break;
1155 
1159  break;
1160 
1163  {
1164  TRACK* track = (TRACK*) GetScreen()->GetCurItem();
1165  wxPoint pos = GetCrossHairPosition();
1166 
1167  track->Draw( m_canvas, &dc, GR_XOR );
1168  PICKED_ITEMS_LIST itemsListPicker;
1169 
1170  TRACK* newtrack = GetBoard()->CreateLockPoint( pos, track, &itemsListPicker );
1171 
1172  SaveCopyInUndoList( itemsListPicker, UR_UNSPECIFIED );
1173  track->Draw( m_canvas, &dc, GR_XOR );
1174  newtrack->Draw( m_canvas, &dc, GR_XOR );
1175 
1176  // compute the new ratsnest, because connectivity could change
1177  TestNetConnection( &dc, track->GetNetCode() );
1178  }
1179  break;
1180 
1182  moveExact();
1183  break;
1184 
1188  break;
1189 
1191  createArray();
1192  break;
1193 
1194  case ID_MENU_PCB_CLEAN:
1195  Clean_Pcb();
1196  break;
1197 
1199  InstallExchangeModuleFrame( dynamic_cast<MODULE*>( GetCurItem() ), true, false );
1200  break;
1201 
1203  InstallExchangeModuleFrame( dynamic_cast<MODULE*>( GetCurItem() ), false, false );
1204  break;
1205 
1207  Swap_Layers( event );
1208  break;
1209 
1211  {
1212  wxConfigBase* cfg = Pgm().CommonSettings();
1213  cfg->Read( wxT( "module_doc_file" ), g_DocModulesFileName );
1214  GetAssociatedDocument( this, g_DocModulesFileName, &Kiface().KifaceSearch() );
1215  }
1216  break;
1217 
1219  ArchiveModulesOnBoard( false );
1220  break;
1221 
1223  ArchiveModulesOnBoard( true );
1224  break;
1225 
1228  m_canvas->Refresh();
1229  break;
1230 
1231 
1232  default:
1233  wxLogDebug( wxT( "PCB_EDIT_FRAME::Process_Special_Functions() unknown event id %d" ), id );
1234  break;
1235  }
1236 
1237  m_canvas->CrossHairOn( &dc );
1238  m_canvas->SetIgnoreMouseEvents( false );
1239 }
1240 
1241 
1243 {
1244  if( Item == NULL )
1245  return;
1246 
1247  switch( Item->Type() )
1248  {
1249  case PCB_MODULE_T:
1250  Delete_Module( (MODULE*) Item, DC );
1251  break;
1252 
1253  case PCB_DIMENSION_T:
1254  DeleteDimension( (DIMENSION*) Item, DC );
1255  break;
1256 
1257  case PCB_TARGET_T:
1258  DeleteTarget( (PCB_TARGET*) Item, DC );
1259  break;
1260 
1261  case PCB_LINE_T:
1262  Delete_Segment_Edge( (DRAWSEGMENT*) Item, DC );
1263  break;
1264 
1265  case PCB_TEXT_T:
1266  Delete_Texte_Pcb( (TEXTE_PCB*) Item, DC );
1267  break;
1268 
1269  case PCB_TRACE_T:
1270  Delete_Track( DC, (TRACK*) Item );
1271  break;
1272 
1273  case PCB_VIA_T:
1274  Delete_Segment( DC, (TRACK*) Item );
1275  break;
1276 
1277  case PCB_ZONE_AREA_T:
1278  {
1279  SetCurItem( NULL );
1280  int netcode = ( (ZONE_CONTAINER*) Item )->GetNetCode();
1281  Delete_Zone_Contour( DC, (ZONE_CONTAINER*) Item );
1282  TestNetConnection( NULL, netcode );
1283  SetMsgPanel( GetBoard() );
1284  }
1285  break;
1286 
1287  case PCB_MARKER_T:
1288  if( Item == GetCurItem() )
1289  SetCurItem( NULL );
1290 
1291  ( (MARKER_PCB*) Item )->Draw( m_canvas, DC, GR_XOR );
1292 
1293  // delete the marker, and free memory. Don't use undo stack.
1294  GetBoard()->Delete( Item );
1295  break;
1296 
1297  case PCB_PAD_T:
1298  case PCB_MODULE_TEXT_T:
1299  case PCB_MODULE_EDGE_T:
1300  break;
1301 
1302  case TYPE_NOT_INIT:
1303  case PCB_T:
1304  default:
1305  wxLogDebug( wxT( "Remove: item type %d unknown." ), Item->Type() );
1306  break;
1307  }
1308 }
1309 
1310 
1312 {
1313  PCB_LAYER_ID curLayer = GetActiveLayer();
1314  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
1315 
1316  // Check if the specified layer matches the present layer
1317  if( layer == curLayer )
1318  return;
1319 
1320  // Copper layers cannot be selected unconditionally; how many
1321  // of those layers are currently enabled needs to be checked.
1322  if( IsCopperLayer( layer ) )
1323  {
1324  // If only one copper layer is enabled, the only such layer
1325  // that can be selected to is the "Back" layer (so the
1326  // selection of any other copper layer is disregarded).
1327  if( GetBoard()->GetCopperLayerCount() < 2 )
1328  {
1329  if( layer != B_Cu )
1330  return;
1331  }
1332  // If more than one copper layer is enabled, the "Copper"
1333  // and "Component" layers can be selected, but the total
1334  // number of copper layers determines which internal
1335  // layers are also capable of being selected.
1336  else
1337  {
1338  if( layer != B_Cu && layer != F_Cu && layer >= GetBoard()->GetCopperLayerCount() - 1 )
1339  return;
1340  }
1341 
1342  EDA_ITEM* current = GetScreen()->GetCurItem();
1343 
1344  // See if we are drawing a segment; if so, add a via?
1345  if( GetToolId() == ID_TRACK_BUTT && current )
1346  {
1347  if( current->Type() == PCB_TRACE_T && current->IsNew() )
1348  {
1349  // Want to set the routing layers so that it switches properly -
1350  // see the implementation of Other_Layer_Route - the working
1351  // layer is used to 'start' the via and set the layer masks appropriately.
1352  GetScreen()->m_Route_Layer_TOP = curLayer;
1353  GetScreen()->m_Route_Layer_BOTTOM = layer;
1354 
1355  SetActiveLayer( curLayer );
1356 
1357  if( Other_Layer_Route( (TRACK*) GetScreen()->GetCurItem(), DC ) )
1358  {
1359  if( displ_opts->m_ContrastModeDisplay )
1360  m_canvas->Refresh();
1361  }
1362 
1363  // if the via was allowed by DRC, then the layer swap has already
1364  // been done by Other_Layer_Route(). if via not allowed, then
1365  // return now so assignment to setActiveLayer() below doesn't happen.
1366  return;
1367  }
1368  }
1369  }
1370 
1371  // Is yet more checking required? E.g. when the layer to be selected
1372  // is a non-copper layer, or when switching between a copper layer
1373  // and a non-copper layer, or vice-versa?
1374  // ...
1375 
1376  SetActiveLayer( layer );
1377 
1378  if( displ_opts->m_ContrastModeDisplay )
1379  m_canvas->Refresh();
1380 }
1381 
1382 
1383 void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
1384 {
1385  int id = aEvent.GetId();
1386  int lastToolID = GetToolId();
1387 
1389  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
1390 
1391  // Stop the current command and deselect the current tool.
1393 
1394  switch( id )
1395  {
1396  case ID_NO_TOOL_SELECTED:
1398  break;
1399 
1400  case ID_ZOOM_SELECTION:
1401  // This tool is located on the main toolbar: switch it on or off on click on it
1402  if( lastToolID != ID_ZOOM_SELECTION )
1403  SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) );
1404  else
1406  break;
1407 
1408  case ID_TRACK_BUTT:
1409  if( Settings().m_legacyDrcOn )
1410  SetToolID( id, wxCURSOR_PENCIL, _( "Add tracks" ) );
1411  else
1412  SetToolID( id, wxCURSOR_QUESTION_ARROW, _( "Add tracks" ) );
1413 
1414  Compile_Ratsnest( &dc, true );
1415  break;
1416 
1417  case ID_PCB_MODULE_BUTT:
1418  SetToolID( id, wxCURSOR_PENCIL, _( "Add footprint" ) );
1419  break;
1420 
1421  case ID_PCB_ZONES_BUTT:
1422  SetToolID( id, wxCURSOR_PENCIL, _( "Add zones" ) );
1423 
1424  if( displ_opts->m_DisplayZonesMode != 0 )
1425  DisplayInfoMessage( this, _( "Warning: zone display is OFF!!!" ) );
1426 
1427  if( !GetBoard()->IsHighLightNetON() && (GetBoard()->GetHighLightNetCode() > 0 ) )
1428  HighLight( &dc );
1429 
1430  break;
1431 
1433  SetToolID( id, wxCURSOR_PENCIL, _( "Add keepout" ) );
1434  break;
1435 
1436  case ID_PCB_TARGET_BUTT:
1437  SetToolID( id, wxCURSOR_PENCIL, _( "Add layer alignment target" ) );
1438  break;
1439 
1441  SetToolID( id, wxCURSOR_PENCIL, _( "Adjust zero" ) );
1442  break;
1443 
1445  SetToolID( id, wxCURSOR_PENCIL, _( "Adjust grid origin" ) );
1446  break;
1447 
1448  case ID_PCB_ADD_LINE_BUTT:
1449  SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic line" ) );
1450  break;
1451 
1452  case ID_PCB_ARC_BUTT:
1453  SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic arc" ) );
1454  break;
1455 
1456  case ID_PCB_CIRCLE_BUTT:
1457  SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic circle" ) );
1458  break;
1459 
1460  case ID_PCB_ADD_TEXT_BUTT:
1461  SetToolID( id, wxCURSOR_PENCIL, _( "Add text" ) );
1462  break;
1463 
1464  case ID_COMPONENT_BUTT:
1465  SetToolID( id, wxCURSOR_HAND, _( "Add footprint" ) );
1466  break;
1467 
1468  case ID_PCB_DIMENSION_BUTT:
1469  SetToolID( id, wxCURSOR_PENCIL, _( "Add dimension" ) );
1470  break;
1471 
1473  SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) );
1474  break;
1475 
1476  case ID_PCB_HIGHLIGHT_BUTT:
1477  SetToolID( id, wxCURSOR_HAND, _( "Highlight net" ) );
1478  break;
1479 
1481  SetToolID( id, wxCURSOR_HAND, _( "Select rats nest" ) );
1482 
1483  Compile_Ratsnest( &dc, true );
1484 
1485  break;
1486 
1487  // collect GAL-only tools here
1488  case ID_PCB_DRAW_VIA_BUTT:
1490  SetToolID( id, wxCURSOR_DEFAULT, _( "Unsupported tool in this canvas" ) );
1491  break;
1492  }
1493 }
1494 
1495 
1497 {
1498  wxPoint translation;
1499  double rotation;
1500  ROTATION_ANCHOR rotationAnchor = ROTATE_AROUND_ITEM_ANCHOR;
1501 
1502  DIALOG_MOVE_EXACT dialog( this, translation, rotation, rotationAnchor );
1503  int ret = dialog.ShowModal();
1504 
1505  if( ret == wxID_OK )
1506  {
1507  if( BOARD_ITEM* item = GetScreen()->GetCurItem() )
1508  {
1509  // When a pad is modified, the full footprint is saved
1510  BOARD_ITEM* itemToSave = item;
1511 
1512  if( item->Type() == PCB_PAD_T )
1513  itemToSave = item->GetParent();
1514 
1515  // Could be moved or rotated
1516  SaveCopyInUndoList( itemToSave, UR_CHANGED );
1517 
1518  item->Move( translation );
1519 
1520  switch( rotationAnchor )
1521  {
1523  item->Rotate( item->GetPosition(), rotation );
1524  break;
1526  item->Rotate( GetScreen()->m_O_Curseur, rotation );
1527  break;
1529  item->Rotate( GetAuxOrigin(), rotation );
1530  break;
1531  default:
1532  wxFAIL_MSG( "Rotation choice shouldn't have been available in this context." );
1533  }
1534 
1535  m_canvas->Refresh();
1536  }
1537  }
1538 
1540 }
1541 
1542 
1543 void PCB_EDIT_FRAME::duplicateItems( bool aIncrement )
1544 {
1545  BOARD_ITEM* item = GetScreen()->GetCurItem();
1546 
1547  if( !item )
1548  return;
1549 
1550  // In the board editor, the pads or fp texts can be edited
1551  // but cannot be duplicated (only the fp editor can do that).
1552  // only the footprint can be duplicated
1553  if( item->Type() == PCB_PAD_T || item->Type() == PCB_MODULE_TEXT_T )
1554  item = static_cast<MODULE*>( item )->GetParent();
1555 
1556  PCB_BASE_EDIT_FRAME::duplicateItem( item, aIncrement );
1557 }
1558 
1559 
1560 void PCB_BASE_EDIT_FRAME::duplicateItem( BOARD_ITEM* aItem, bool aIncrement )
1561 {
1562  if( !aItem )
1563  return;
1564 
1565  // The easiest way to handle a duplicate item command
1566  // is to simulate a block copy command, which gives us the undo management
1567  // for free
1568  if( GetScreen()->m_BlockLocate.GetState() == STATE_NO_BLOCK )
1569  {
1571 
1573 
1574  wxPoint crossHairPos = GetCrossHairPosition();
1575 
1576  const BLOCK_COMMAND_T blockType = aIncrement ? BLOCK_DUPLICATE_AND_INCREMENT : BLOCK_DUPLICATE;
1577 
1578  if( !HandleBlockBegin( &dc, blockType, crossHairPos ) )
1579  return;
1580 
1581  // Add the item to the block copy pick list:
1583  ITEM_PICKER picker( NULL, UR_UNSPECIFIED );
1584 
1585  picker.SetItem ( aItem );
1586  itemsList.PushItem( picker );
1587 
1588  // Set 2 coordinates updated by the mouse, because our simulation
1589  // does not use the mouse to call HandleBlockEnd()
1590  GetScreen()->m_BlockLocate.SetLastCursorPosition( crossHairPos );
1591  GetScreen()->m_BlockLocate.SetEnd( crossHairPos );
1592  HandleBlockEnd( &dc );
1593  }
1594 }
1595 
1596 
1598 {
1599 public:
1600 
1602  ARRAY_CREATOR( editFrame ),
1603  m_item( m_parent.GetScreen()->GetCurItem() )
1604  {}
1605 
1606 private:
1607 
1608  int getNumberOfItemsToArray() const override
1609  {
1610  // only handle single items
1611  return (m_item != NULL) ? 1 : 0;
1612  }
1613 
1614  BOARD_ITEM* getNthItemToArray( int n ) const override
1615  {
1616  wxASSERT_MSG( n == 0, "Legacy array tool can only handle a single item" );
1617  return m_item;
1618  }
1619 
1620  BOARD* getBoard() const override
1621  {
1622  return m_parent.GetBoard();
1623  }
1624 
1625  MODULE* getModule() const override
1626  {
1627  return dynamic_cast<MODULE*>( m_item->GetParent() );
1628  }
1629 
1630  wxPoint getRotationCentre() const override
1631  {
1632  return m_item->GetCenter();
1633  }
1634 
1635  void finalise() override
1636  {
1637  m_parent.GetCanvas()->Refresh();
1638  }
1639 
1640  BOARD_ITEM* m_item; // only have the one
1641 };
1642 
1643 
1645 {
1646  LEGACY_ARRAY_CREATOR array_creator( *this );
1647 
1648  array_creator.Invoke();
1649 }
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:676
void Edit_Track_Width(wxDC *aDC, TRACK *aTrackSegment)
Function Edit_Track_Width Modify a full track width (using DRC control).
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:289
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:59
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_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,.
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:61
int GetNetCode() const
Function GetNetCode.
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame.
Definition: typeinfo.h:85
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Set the tool command ID to aId and sets the cursor to aCursor.
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:196
TEXTE_PCB class definition.
int getNumberOfItemsToArray() const override
Definition: edit.cpp:1608
bool g_Alternate_Track_Posture
Definition: pcbnew.cpp:73
bool End_Zone(wxDC *DC)
Function End_Zone terminates (if no DRC error ) the zone edge creation process.
bool InvokeDialogImportGfxBoard(PCB_BASE_FRAME *aCaller)
Shows the modal DIALOG_IMPORT_GFX for importing a DXF file to a board.
void InstallPcbGlobalDeleteFrame(const wxPoint &pos)
This file is part of the common library TODO brief description.
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.
int GetDefaultCursor() const
Function GetDefaultCursor.
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:1630
BOARD_ITEM * GetCurItem() const
Function GetCurItem returns the currently selected BOARD_ITEM, overriding BASE_SCREEN::GetCurItem().
Definition: pcb_screen.h:72
This file is part of the common library.
void FlipTextePcb(TEXTE_PCB *aTextePcb, wxDC *aDC)
int GetSelectedCorner() const
Definition: class_zone.h:223
Class BOARD to handle a board.
void InstallFindFrame()
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:699
void BeginMoveDimensionText(DIMENSION *aItem, wxDC *DC)
Definition: dimension.cpp:214
void ShowDimensionPropertyDialog(DIMENSION *aDimension, wxDC *aDC)
Definition: dimension.cpp:186
PCB_BASE_FRAME & m_parent
Definition: array_creator.h:61
void InstallGraphicItemPropertiesDialog(BOARD_ITEM *aItem)
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:100
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:260
virtual 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
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:1383
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:1560
void RotateTextModule(TEXTE_MODULE *Text, wxDC *DC)
Definition: edtxtmod.cpp:98
virtual void SetAutoPanRequest(bool aEnable)=0
DRC * m_drc
the DRC controller, see drc.cpp
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:57
virtual void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
void PushPreferences(const EDA_DRAW_PANEL *aParentCanvas)
Push preferences from a parent window to a child window.
void finalise() override
Definition: edit.cpp:1635
void InstallTextOptionsFrame(BOARD_ITEM *aText, wxDC *aDC)
Routine for main window class to launch text properties dialog.
void RemoveStruct(BOARD_ITEM *Item, wxDC *DC)
Definition: edit.cpp:1242
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:1614
void Start_Move_DrawItem(DRAWSEGMENT *drawitem, wxDC *DC)
Definition: editedge.cpp:56
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
virtual void CallEndMouseCapture(wxDC *aDC)
Function CallEndMouseCapture calls the end mouse capture callback.
const wxPoint & GetAuxOrigin() const override
Return the origin of the axis used for plotting and various exports.
int InstallExchangeModuleFrame(MODULE *aModule, bool updateMode, bool selectedMode)
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
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...
bool IsNew() const
Definition: base_struct.h:222
const wxString GetReference() const
Function GetReference.
Definition: class_module.h:462
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:1496
void Export_Pad_Settings(D_PAD *aPad)
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
void SetState(BLOCK_STATE_T aState)
virtual bool HandleBlockBegin(wxDC *aDC, EDA_KEY aKey, const wxPoint &aPosition, int aExplicitCommand=0)
Initialize a block command.
LAYER_NUM GetLayerSelection() const
virtual void Zoom_Automatique(bool aWarpPointer)
Redraw the screen with best zoom level and the best centering that shows all the page or the board.
class MODULE, a footprint
Definition: typeinfo.h:89
timestamp_t GetNewTimeStamp()
Definition: common.cpp:217
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:294
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)
void OnEditTracksAndVias(wxCommandEvent &event)
Function OnEditTracksAndVias Dialog for editing the properties of tracks and vias,...
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:981
a helper to handle the real device context used in KiCad
TEXTE_PCB * CreateTextePcb(wxDC *aDC, TEXTE_PCB *aText=NULL)
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:321
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
BOARD_ITEM * m_item
Definition: edit.cpp:1640
virtual void CrossHairOn(wxDC *DC=nullptr)
void Rotate_Texte_Pcb(TEXTE_PCB *TextePcb, wxDC *DC)
PCB_GENERAL_SETTINGS & Settings()
void SetEnd(int x, int y)
Definition: eda_rect.h:134
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:292
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,...
virtual 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:166
void Delete_Segment_Edge(DRAWSEGMENT *Segment, wxDC *DC)
Definition: editedge.cpp:112
void HighLight(wxDC *DC)
Function HighLight.
Definition: highlight.cpp:104
PCB_LAYER_ID m_Route_Layer_BOTTOM
Definition: pcb_screen.h:46
bool Load_Module_From_BOARD(MODULE *Module)
Load in Modedit a footprint from the main board.
virtual void CrossHairOff(wxDC *DC=nullptr)
void StartMoveOneNodeOrSegment(TRACK *aTrack, wxDC *aDC, int aCommand)
Function StartMoveOneNodeOrSegment initializes the parameters to move one via or/and a terminal point...
void createArray()
Function createArray Create an array of the selected item (invokes the dialogue) This function is sha...
Definition: edit.cpp:1644
void Start_DragTrackSegmentAndKeepSlope(TRACK *track, wxDC *DC)
wxString g_DocModulesFileName
Definition: pcbnew.cpp:83
bool Fill(const std::vector< ZONE_CONTAINER * > &aZones, bool aCheck=false)
virtual EDA_DRAW_PANEL * GetCanvas() const
Definition: draw_frame.h:399
PCB_EDIT_FRAME::OnSelectOptionToolbar ID_PCB_MEASUREMENT_TOOL
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:198
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...
ROTATION_ANCHOR
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:98
VTBL_ENTRY wxConfigBase * CommonSettings() const
Definition: pgm_base.h:190
bool IsLocked() const override
Function IsLocked.
Definition: class_module.h:267
void Add_Similar_Zone(wxDC *DC, ZONE_CONTAINER *zone_container)
Function Add_Similar_Zone Add a zone to a given zone outline.
void SetSelectedCorner(int aCorner)
Definition: class_zone.h:234
void Fill_All_Zones()
Function Fill_All_Zones.
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:99
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:53
virtual bool HandleBlockEnd(wxDC *DC)
Handle the "end" of a block command, i.e.
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).
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
void DeleteTextModule(TEXTE_MODULE *Text)
Definition: edtxtmod.cpp:126
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)
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:128
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:1620
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...
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:97
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:65
see class PGM_BASE
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:66
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.
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:170
void StartMoveModule(MODULE *aModule, wxDC *aDC, bool aDragConnectedTracks)
Function StartMoveModule Initialize a drag or move pad command.
#define INSTALL_UNBUFFERED_DC(name, parent)
int GetCopperLayerCount() const
Function GetCopperLayerCount.
void SetIgnoreMouseEvents(bool aIgnore)
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
PCB_SCREEN * GetScreen() const override
Return 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)
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
bool IsMicroViaAcceptable()
Function IsMicroViaAcceptable return true if a microvia can be placed on the board.
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 PushPadProperties(D_PAD *aPad)
Function PushPadProperties Function to change pad caracteristics for the given footprint or all footp...
virtual const wxPoint GetCenter() const
Function GetCenter()
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
void InstallPadOptionsFrame(D_PAD *pad)
MODULE * GetFootprintFromBoardByReference()
Function GetFootprintFromBoardByReference.
void StartMoveTexteModule(TEXTE_MODULE *Text, wxDC *DC)
Definition: edtxtmod.cpp:192
Module description (excepted pads)
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:952
BOARD * GetBoard() const
PCB_LAYER_BOX_SELECTOR * m_SelLayerBox
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL)
void SelectCopperLayerPair()
Definition: sel_layer.cpp:260
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)
Set the screen cross hair position to aPosition in logical (drawing) units.
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.
BOARD_ITEM_CONTAINER * GetParent() const
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:276
void SwitchLayer(wxDC *DC, PCB_LAYER_ID layer) override
Definition: edit.cpp:1311
void duplicateItems(bool aIncrement) override
Function duplicateItems Duplicate selected item if possible and start a move.
Definition: edit.cpp:1543
int GetState(int type) const
Definition: base_struct.h:243
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:205
const wxPoint GetPosition() const override
Definition: class_module.h:183
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)
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:813
int m_lastDrawToolId
Tool ID of previously active draw tool bar button.
Definition: draw_frame.h:135
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:141
Class DIMENSION.
int GetToolId() const
Definition: draw_frame.h:524
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:1601
void SetCommand(BLOCK_COMMAND_T aCommand)
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:209
void End_Edge(DRAWSEGMENT *Segment, wxDC *DC)
Definition: editedge.cpp:299
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
MODULE * getModule() const override
Definition: edit.cpp:1625