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:
160  break;
161 
163  if( m_canvas->IsMouseCaptured() )
164  {
166  }
167 
168  // Should not be executed, just in case
169  if( GetScreen()->m_BlockLocate.GetCommand() != BLOCK_IDLE )
170  {
174  }
175 
176  if( GetToolId() == ID_NO_TOOL_SELECTED )
178  else
179  SetCursor( (wxStockCursor) m_canvas->GetDefaultCursor() );
180 
181  break;
182 
183  default: // Finish (abort) the command
184  if( m_canvas->IsMouseCaptured() )
186 
187  if( GetToolId() != id )
188  {
189  if( m_lastDrawToolId != GetToolId() )
191 
193  }
194  break;
195  }
196 
197  switch( id ) // Execute command
198  {
199  case 0:
200  break;
201 
203  {
205 
206  if( !editor )
207  {
209  editor->Zoom_Automatique( false );
210  }
211  else
212  {
213  // Needed on Windows, other platforms do not use it,
214  // but it creates no issue
215  if( editor->IsIconized() )
216  editor->Iconize( false );
217 
218  editor->Raise();
219 
220  // Raising the window does not set the focus on Linux. This should work on
221  // any platform.
222  if( wxWindow::FindFocus() != editor )
223  editor->SetFocus();
224  }
225 
226  editor->PushPreferences( m_canvas );
227  }
228  break;
229 
231  {
233 
234  if( !viewer )
235  {
237  viewer->Zoom_Automatique( false );
238  }
239  else
240  {
241  // Needed on Windows, other platforms do not use it,
242  // but it creates no issue
243  if( viewer->IsIconized() )
244  viewer->Iconize( false );
245 
246  viewer->Raise();
247 
248  // Raising the window does not set the focus on Linux. This should work on
249  // any platform.
250  if( wxWindow::FindFocus() != viewer )
251  viewer->SetFocus();
252  }
253 
254  viewer->PushPreferences( m_canvas );
255  }
256  break;
257 
259  InstallPcbGlobalDeleteFrame( wxDefaultPosition );
260  break;
261 
264  m_canvas->SetAutoPanRequest( false );
265  HandleBlockPlace( &dc );
266  break;
267 
271  m_canvas->SetAutoPanRequest( false );
272  HandleBlockPlace( &dc );
273  break;
274 
275  case ID_POPUP_ZOOM_BLOCK:
278  HandleBlockEnd( &dc );
279  break;
280 
284  HandleBlockEnd( &dc );
285  break;
286 
290  HandleBlockEnd( &dc );
291  break;
292 
293  case ID_POPUP_FLIP_BLOCK:
296  HandleBlockEnd( &dc );
297  break;
298 
299  case ID_DRC_CONTROL:
300  // Shows the DRC dialog in non modal mode, to allows board edition
301  // with the DRC dialog opened and showing errors.
302  m_drc->ShowDRCDialog();
303  break;
304 
305  case ID_GET_NETLIST:
306  InstallNetlistFrame( &dc );
307  break;
308 
309  case ID_FIND_ITEMS:
311  break;
312 
315  break;
316 
318  break;
319 
322 
323  // EndSegment(&dc);
324  break;
325 
327  if( GetCurItem() == NULL )
328  break;
329  Edit_Track_Width( &dc, (TRACK*) GetCurItem() );
331  OnModify();
332  break;
333 
335  if( GetCurItem() == NULL )
336  break;
339  OnModify();
340  break;
341 
343  {
344  DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS dlg( this, GetBoard()->GetHighLightNetCode() );
345  dlg.ShowModal();
346  }
347  break;
348 
350  if( GetCurItem() == NULL )
351  break;
352  {
353  int type = GetCurItem()->Type();
354 
355  if( type == PCB_TRACE_T || type == PCB_VIA_T )
356  {
358  DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS dlg( this, item->GetNetCode() );
359  dlg.ShowModal();
360  }
361 
362  }
364  break;
365 
368  OnHotkeyBeginRoute( &dc );
369  break;
370 
373  End_Route( (TRACK*) GetCurItem(), &dc );
374  break;
375 
378 
379  if( GetCurItem()->IsDragging() )
380  {
382  }
383 
384  break;
385 
387  /* change the position of initial segment when creating new tracks
388  * switch from _/ to -\ .
389  * If a track is in progress, it will be redrawn
390  */
391  if( m_canvas->IsMouseCaptured() )
392  m_canvas->CallMouseCapture( &dc, wxDefaultPosition, false );
393 
395 
396  if( m_canvas->IsMouseCaptured() )
397  m_canvas->CallMouseCapture( &dc, wxDefaultPosition, false );
398 
399  break;
400 
402  if( !IsMicroViaAcceptable() )
403  break;
404  // fall through
410 
411  if( GetCurItem()->IsDragging() )
412  {
414  }
415  else
416  {
418  VIATYPE_T v_type = settings.m_CurrentViaType;
419  switch( id )
420  {
424  break;
425 
427  settings.m_CurrentViaType = VIA_MICROVIA;
428  break;
429 
430  default:
431  settings.m_CurrentViaType = VIA_THROUGH;
432  break;
433  }
434 
435  // place via and switch layer.
438  {
440 
441  wxPoint dlgPosition;
442 
443  wxGetMousePosition( &dlgPosition.x, &dlgPosition.y );
444 
445  PCB_LAYER_ID layer = SelectLayer( GetActiveLayer(), LSET::AllNonCuMask(), dlgPosition );
446 
447  m_canvas->SetIgnoreMouseEvents( false );
449 
450  if( GetActiveLayer() != layer )
451  {
453  GetScreen()->m_Route_Layer_BOTTOM = layer;
454  Other_Layer_Route( (TRACK*) GetCurItem(), &dc );
455  }
456  }
457 
458  else
459  Other_Layer_Route( (TRACK*) GetCurItem(), &dc );
460 
461  settings.m_CurrentViaType = v_type;
462 
463  if( displ_opts->m_ContrastModeDisplay )
464  m_canvas->Refresh();
465  }
466  break;
467 
469  if( GetCurItem() == NULL )
470  break;
471 
473  SetCurItem( Delete_Segment( &dc, (TRACK*) GetCurItem() ) );
474  OnModify();
475  break;
476 
478  if( GetCurItem() == NULL )
479  break;
481  Delete_Track( &dc, (TRACK*) GetCurItem() );
482  SetCurItem( NULL );
483  OnModify();
484  break;
485 
488  Delete_net( &dc, (TRACK*) GetCurItem() );
489  SetCurItem( NULL );
490  OnModify();
491  break;
492 
494  Attribut_Segment( (TRACK*) GetCurItem(), &dc, true );
495  break;
496 
498  Attribut_Segment( (TRACK*) GetCurItem(), &dc, false );
499  break;
500 
502  Attribut_Track( (TRACK*) GetCurItem(), &dc, true );
503  break;
504 
506  Attribut_Track( (TRACK*) GetCurItem(), &dc, false );
507  break;
508 
510  Attribut_net( &dc, ( (TRACK*) GetCurItem() )->GetNetCode(), true );
511  break;
512 
514  Attribut_net( &dc, ( (TRACK*) GetCurItem() )->GetNetCode(), false );
515  break;
516 
518  break;
519 
522 
523  if( GetCurItem() == NULL )
524  break;
525 
526  {
527  SEGZONE* zsegm = (SEGZONE*) GetCurItem();
528  int netcode = zsegm->GetNetCode();
529  Delete_OldZone_Fill( zsegm );
530  SetCurItem( NULL );
531  TestNetConnection( NULL, netcode );
532  OnModify();
533  SetMsgPanel( GetBoard() );
534  }
535  break;
536 
539  SetCurItem( NULL ); // Outlines can have changed
540  break;
541 
543  {
545  duplicateZone( &dc, zone );
546  }
547  break;
548 
551  m_canvas->SetAutoPanRequest( true );
553  break;
554 
557  m_canvas->SetAutoPanRequest( true );
559  break;
560 
562  // Force the main contour selection, to remove the entire zone:
563  ((ZONE_CONTAINER*) GetCurItem())->SetSelectedCorner( 0 );
564  // Fall through
567  {
568  int netcode = ( (ZONE_CONTAINER*) GetCurItem() )->GetNetCode();
570  SetCurItem( NULL );
571  TestNetConnection( NULL, netcode );
572  SetMsgPanel( GetBoard() );
573  }
574  break;
575 
578  SetCurItem( NULL );
579  break;
580 
582  {
584  ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
585  m_canvas->SetAutoPanRequest( true );
586  Start_Move_Zone_Corner( &dc, zone_cont, zone_cont->GetSelectedCorner(), false );
587  }
588  break;
589 
591  {
593  ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
594  m_canvas->SetAutoPanRequest( true );
595  Start_Move_Zone_Drag_Outline_Edge( &dc, zone_cont, zone_cont->GetSelectedCorner() );
596  }
597  break;
598 
600  {
602  ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
603  m_canvas->SetAutoPanRequest( true );
604  Start_Move_Zone_Outlines( &dc, zone_cont );
605  }
606  break;
607 
609  {
611  ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
613 
614  /* add corner between zone_cont->m_CornerSelection
615  * and zone_cont->m_CornerSelection+1
616  * and start move the new corner
617  */
618  zone_cont->Draw( m_canvas, &dc, GR_XOR );
619  zone_cont->Outline()->InsertVertex( zone_cont->GetSelectedCorner(), pos );
620  zone_cont->SetSelectedCorner( zone_cont->GetSelectedCorner() + 1 );
621  zone_cont->Draw( m_canvas, &dc, GR_XOR );
622  m_canvas->SetAutoPanRequest( true );
623  Start_Move_Zone_Corner( &dc, zone_cont, zone_cont->GetSelectedCorner(), true );
624  }
625  break;
626 
630  {
632  ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
633  End_Move_Zone_Corner_Or_Outlines( &dc, zone_cont );
634  m_canvas->SetAutoPanRequest( false );
635  }
636  break;
637 
640  Fill_All_Zones( this );
641  m_canvas->Refresh();
642  SetMsgPanel( GetBoard() );
643  break;
644 
646  if( ( GetCurItem() )->Type() == PCB_ZONE_AREA_T )
647  {
648  ZONE_CONTAINER* zone_container = (ZONE_CONTAINER*) GetCurItem();
649  zone_container->UnFill();
650  GetBoard()->GetConnectivity()->Update( zone_container );
651  OnModify();
652  SetMsgPanel( GetBoard() );
653  m_canvas->Refresh();
654  }
655 
656  Compile_Ratsnest( &dc, false );
657  SetCurItem( NULL );
658  break;
659 
660  case ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_ALL_ZONES: // Remove all zones :
661  GetBoard()->m_Zone.DeleteAll(); // remove zone segments used to fill zones.
662 
663  for( int ii = 0; ii < GetBoard()->GetAreaCount(); ii++ )
664  {
665  // Remove filled areas in zone
666  ZONE_CONTAINER* zone_container = GetBoard()->GetArea( ii );
667  zone_container->UnFill();
668  GetBoard()->GetConnectivity()->Update( zone_container );
669  }
670 
671  Compile_Ratsnest( &dc, false );
672  SetCurItem( NULL ); // CurItem might be deleted by this command, clear the pointer
673  OnModify();
674  SetMsgPanel( GetBoard() );
675  m_canvas->Refresh();
676  break;
677 
679  {
681  ZONE_FILLER filler( GetBoard() );
682  filler.Fill( { (ZONE_CONTAINER*) GetCurItem() } );
683  SetMsgPanel( GetBoard() );
684  m_canvas->Refresh();
685  break;
686  }
687 
690  m_canvas->SetAutoPanRequest( true );
691  break;
692 
695  if( GetCurItem() == NULL )
696  break;
697 
698  // If the current Item is a pad, text module ...: Get its parent
699  if( GetCurItem()->Type() != PCB_MODULE_T )
700  SetCurItem( GetCurItem()->GetParent() );
701 
702  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
703  break;
704 
705  module = (MODULE*) GetCurItem();
706 
707  if( module->IsLocked() )
708  {
709  wxString msg;
710  msg.Printf( _( "Footprint %s found, but it is locked" ),
711  module->GetReference().GetData() );
712  DisplayInfoMessage( this, msg );
713  break;
714  }
715 
716  SendMessageToEESCHEMA( module );
717  SetCrossHairPosition( module->GetPosition() );
720  break;
721 
722  case ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST: // get module by name and move it
724  module = (MODULE*) GetCurItem();
725 
726  if( module == NULL )
727  break;
728 
729  if( module->IsLocked() )
730  {
731  wxString msg = wxString::Format(
732  _( "Footprint %s found, but it is locked" ),
733  module->GetReference().GetData() );
734  DisplayInfoMessage( this, msg );
735  break;
736  }
737 
738  SendMessageToEESCHEMA( module );
740  StartMoveModule( module, &dc, false );
741  break;
742 
745 
746  // If the current Item is a pad, text module ...: Get its parent
747  if( GetCurItem()->Type() != PCB_MODULE_T )
748  SetCurItem( GetCurItem()->GetParent() );
749 
750  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
751  break;
752 
753  module = (MODULE*) GetCurItem();
754 
755  if( module->IsLocked() )
756  {
757  wxString msg;
758  msg.Printf( _( "Footprint %s found, but it is locked" ),
759  module->GetReference().GetData() );
760  DisplayInfoMessage( this, msg );
761  break;
762  }
763 
764  if( Delete_Module( (MODULE*) GetCurItem(), &dc ) )
765  {
766  SetCurItem( NULL );
767  }
768 
769  break;
770 
773 
774  // If the current Item is a pad, text module ...: Get its parent
775  if( GetCurItem()->Type() != PCB_MODULE_T )
776  SetCurItem( GetCurItem()->GetParent() );
777 
778  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
779  break;
780 
781  module = (MODULE*) GetCurItem();
782 
783  if( module->IsLocked() )
784  {
785  wxString msg;
786  msg.Printf( _( "Footprint %s found, but it is locked" ),
787  module->GetReference().GetData() );
788  DisplayInfoMessage( this, msg );
789  break;
790  }
791 
792  // This is a simple rotation, no other editing in progress
793  if( !GetCurItem()->IsMoving() )
794  SaveCopyInUndoList( GetCurItem(), UR_CHANGED, ((MODULE*)GetCurItem())->GetPosition() );
795 
796  Rotate_Module( &dc, (MODULE*) GetCurItem(), m_rotationAngle, true );
797  break;
798 
801 
802  // If the current Item is a pad, text module ...: Get its parent
803  if( GetCurItem()->Type() != PCB_MODULE_T )
804  SetCurItem( GetCurItem()->GetParent() );
805 
806  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
807  break;
808 
809  module = (MODULE*) GetCurItem();
810 
811  if( module->IsLocked() )
812  {
813  wxString msg;
814  msg.Printf( _( "Footprint %s found, but it is locked" ),
815  module->GetReference().GetData() );
816  DisplayInfoMessage( this, msg );
817  break;
818  }
819 
820  // This is a simple rotation, no other editing in progress
821  if( !GetCurItem()->IsMoving() )
822  SaveCopyInUndoList( GetCurItem(), UR_CHANGED, ((MODULE*)GetCurItem())->GetPosition() );
823 
824  Rotate_Module( &dc, (MODULE*) GetCurItem(), -m_rotationAngle, true );
825  break;
826 
829 
830  // If the current Item is a pad, text module ...: Get its parent
831  if( GetCurItem()->Type() != PCB_MODULE_T )
832  SetCurItem( GetCurItem()->GetParent() );
833 
834  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
835  break;
836 
837  module = (MODULE*) GetCurItem();
838 
839  if( module->IsLocked() )
840  {
841  wxString msg;
842  msg.Printf( _( "Footprint %s found, but it is locked" ),
843  module->GetReference().GetData() );
844  DisplayInfoMessage( this, msg );
845  break;
846  }
847 
848  // This is a simple flip, no other editing in progress
849  if( !GetCurItem()->IsMoving() )
850  SaveCopyInUndoList( GetCurItem(), UR_FLIPPED, ((MODULE*)GetCurItem())->GetPosition() );
851 
852  Change_Side_Module( (MODULE*) GetCurItem(), &dc );
853  break;
854 
856  if( GetCurItem() && GetCurItem()->Type() != PCB_MODULE_T )
857  break;
858 
861  break;
862 
864  if( GetCurItem() && GetCurItem()->Type() != PCB_MODULE_T )
865  break;
866 
869  break;
870 
872  // If the current Item is a pad, text module ...: Get its parent
873  if( GetCurItem()->Type() != PCB_MODULE_T )
874  SetCurItem( GetCurItem()->GetParent() );
875 
876  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
877  break;
878 
881  break;
882 
884 
885  // If we don't have a current item, there's nothing we can do here
886  if( !GetCurItem() )
887  break;
888 
889  // If the current Item is a pad, text module ...: Get its parent
890  if( GetCurItem()->Type() != PCB_MODULE_T )
891  SetCurItem( GetCurItem()->GetParent() );
892 
893  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
894  break;
895 
896  if( GetCurItem()->GetTimeStamp() == 0 ) // Module Editor needs a non null timestamp
897  {
899  OnModify();
900  }
901 
902  {
904 
906  SetCurItem( NULL ); // the current module could be deleted by
907  }
909  break;
910 
912  module = (MODULE*) GetCurItem()->GetParent();
913 
914  if( !module || module->Type() != PCB_MODULE_T )
915  break;
916 
917  if( module->IsLocked() )
918  {
919  wxString msg;
920  msg.Printf( _( "The parent (%s) of the pad is locked" ),
921  module->GetReference().GetData() );
922  DisplayInfoMessage( this, msg );
923  break;
924  }
925 
927  StartMovePad( (D_PAD*) GetCurItem(), &dc, true );
928  break;
929 
931  module = (MODULE*) GetCurItem()->GetParent();
932 
933  if( !module || module->Type() != PCB_MODULE_T )
934  break;
935 
936  if( module->IsLocked() )
937  {
938  wxString msg;
939  msg.Printf( _( "The parent (%s) of the pad is locked" ),
940  module->GetReference().GetData() );
941  DisplayInfoMessage( this, msg );
942  break;
943  }
944 
946  StartMovePad( (D_PAD*) GetCurItem(), &dc, false );
947  break;
948 
952  break;
953 
956  SaveCopyInUndoList( GetCurItem()->GetParent(), UR_CHANGED );
957  Import_Pad_Settings( (D_PAD*) GetCurItem(), true );
958  break;
959 
963  break;
964 
968  break;
969 
971  SaveCopyInUndoList( GetCurItem()->GetParent(), UR_CHANGED );
972  DeletePad( (D_PAD*) GetCurItem() );
973  SetCurItem( NULL );
975  break;
976 
978  InstallTextModOptionsFrame( static_cast<TEXTE_MODULE*>( GetCurItem() ), &dc );
980  break;
981 
983  ResetTextSize( GetCurItem(), &dc );
984  break;
985 
988  StartMoveTexteModule( static_cast<TEXTE_MODULE*>( GetCurItem() ), &dc );
989  break;
990 
992  RotateTextModule( static_cast<TEXTE_MODULE*>( GetCurItem() ), &dc );
994  break;
995 
997  DeleteTextModule( static_cast<TEXTE_MODULE*>( GetCurItem() ) );
998  SetCurItem( NULL );
1000  break;
1001 
1003  {
1005 
1006  if( itmp >= 0 )
1007  {
1008  // if user changed colors and we are in high contrast mode, then redraw
1009  // because the PAD_ATTRIB_SMD pads may change color.
1010  if( displ_opts->m_ContrastModeDisplay && GetActiveLayer() != itmp )
1011  {
1012  m_canvas->Refresh();
1013  }
1014  SetActiveLayer( itmp );
1015  }
1016 
1018  }
1019  break;
1020 
1023  break;
1024 
1026  {
1028 
1029  if( itmp >= 0 )
1030  SetActiveLayer( itmp );
1031 
1033  }
1034  break;
1035 
1037  {
1039 
1040  if( itmp >= 0 )
1041  SetActiveLayer( itmp );
1042  }
1043  break;
1044 
1048  break;
1049 
1052 
1053  if( displ_opts->m_ContrastModeDisplay )
1054  m_canvas->Refresh( true );
1055  break;
1056 
1060  break;
1061 
1063  Rotate_Texte_Pcb( (TEXTE_PCB*) GetCurItem(), &dc );
1065  break;
1066 
1068  CreateTextePcb( &dc, (TEXTE_PCB*) GetCurItem() );
1070  m_canvas->SetAutoPanRequest( true );
1071  break;
1072 
1074  FlipTextePcb( (TEXTE_PCB*) GetCurItem(), &dc );
1076  break;
1077 
1079  Delete_Texte_Pcb( (TEXTE_PCB*) GetCurItem(), &dc );
1081  break;
1082 
1084  BeginMoveTarget( (PCB_TARGET*) GetCurItem(), &dc );
1086  break;
1087 
1091  break;
1092 
1095  DeleteTarget( (PCB_TARGET*) GetCurItem(), &dc );
1096  SetCurItem( NULL );
1097  break;
1098 
1101  DeleteDimension( (DIMENSION*) GetCurItem(), &dc );
1102  SetCurItem( NULL );
1103  break;
1104 
1108  break;
1109 
1112  break;
1113 
1117  break;
1118 
1120  RemoveStruct( GetCurItem(), &dc );
1122  break;
1123 
1125  if( GetCurItem() && GetCurItem()->Type() == PCB_MARKER_T )
1126  ( (MARKER_PCB*) GetCurItem() )->DisplayMarkerInfo( this );
1127 
1129  break;
1130 
1132  if( GetCurItem()->GetFlags() != 0 )
1133  break;
1134 
1136  SetCurItem( NULL );
1138  m_canvas->Refresh();
1139  break;
1140 
1142 #ifndef USE_WX_OVERLAY
1144 #else
1145  // #1277772 - Draw into dialog converted in refresh request
1147  m_canvas->Refresh();
1148 #endif
1150  break;
1151 
1155  break;
1156 
1159 
1160  if( GetCurItem() && (GetCurItem()->IsNew()) )
1161  {
1162  End_Edge( (DRAWSEGMENT*) GetCurItem(), &dc );
1163  SetCurItem( NULL );
1164  }
1165 
1166  break;
1167 
1170 
1171  if( GetCurItem() && (GetCurItem()->IsNew()) )
1172  {
1173  if( End_Zone( &dc ) )
1174  SetCurItem( NULL );
1175  }
1176 
1177  m_canvas->SetAutoPanRequest( false );
1178  break;
1179 
1182 
1183  if( GetCurItem() && (GetCurItem()->IsNew()) )
1184  {
1185  if( Delete_LastCreatedCorner( &dc ) == 0 ) // No more segment in outline,
1186  SetCurItem( NULL );
1187  }
1188 
1189  break;
1190 
1191 
1195  break;
1196 
1201  break;
1202 
1206  break;
1207 
1210  {
1211  TRACK* track = (TRACK*) GetScreen()->GetCurItem();
1212  wxPoint pos = GetCrossHairPosition();
1213 
1214  track->Draw( m_canvas, &dc, GR_XOR );
1215  PICKED_ITEMS_LIST itemsListPicker;
1216 
1217  TRACK* newtrack = GetBoard()->CreateLockPoint( pos, track, &itemsListPicker );
1218 
1219  SaveCopyInUndoList( itemsListPicker, UR_UNSPECIFIED );
1220  track->Draw( m_canvas, &dc, GR_XOR );
1221  newtrack->Draw( m_canvas, &dc, GR_XOR );
1222 
1223  // compute the new ratsnest, because connectivity could change
1224  TestNetConnection( &dc, track->GetNetCode() );
1225  }
1226  break;
1227 
1229  moveExact();
1230  break;
1231 
1235  break;
1236 
1238  createArray();
1239  break;
1240 
1241  case ID_MENU_PCB_CLEAN:
1242  Clean_Pcb();
1243  break;
1244 
1246  InstallExchangeModuleFrame( (MODULE*) nullptr, true );
1247  break;
1248 
1250  InstallExchangeModuleFrame( (MODULE*) nullptr, false );
1251  break;
1252 
1254  Swap_Layers( event );
1255  break;
1256 
1258  InvokeDialogGrid();
1259  break;
1260 
1262  {
1263  wxConfigBase* cfg = Pgm().CommonSettings();
1264  cfg->Read( wxT( "module_doc_file" ), g_DocModulesFileName );
1265  GetAssociatedDocument( this, g_DocModulesFileName, &Kiface().KifaceSearch() );
1266  }
1267  break;
1268 
1270  ArchiveModulesOnBoard( false );
1271  break;
1272 
1274  ArchiveModulesOnBoard( true );
1275  break;
1276 
1279  m_canvas->Refresh();
1280  break;
1281 
1282  default:
1283  wxString msg;
1284  msg.Printf( wxT( "PCB_EDIT_FRAME::Process_Special_Functions() unknown event id %d" ), id );
1285  DisplayError( this, msg );
1286  break;
1287  }
1288 
1289  m_canvas->CrossHairOn( &dc );
1290  m_canvas->SetIgnoreMouseEvents( false );
1291 }
1292 
1293 
1295 {
1296  if( Item == NULL )
1297  return;
1298 
1299  switch( Item->Type() )
1300  {
1301  case PCB_MODULE_T:
1302  Delete_Module( (MODULE*) Item, DC );
1303  break;
1304 
1305  case PCB_DIMENSION_T:
1306  DeleteDimension( (DIMENSION*) Item, DC );
1307  break;
1308 
1309  case PCB_TARGET_T:
1310  DeleteTarget( (PCB_TARGET*) Item, DC );
1311  break;
1312 
1313  case PCB_LINE_T:
1314  Delete_Segment_Edge( (DRAWSEGMENT*) Item, DC );
1315  break;
1316 
1317  case PCB_TEXT_T:
1318  Delete_Texte_Pcb( (TEXTE_PCB*) Item, DC );
1319  break;
1320 
1321  case PCB_TRACE_T:
1322  Delete_Track( DC, (TRACK*) Item );
1323  break;
1324 
1325  case PCB_VIA_T:
1326  Delete_Segment( DC, (TRACK*) Item );
1327  break;
1328 
1329  case PCB_ZONE_T:
1330  Delete_OldZone_Fill( (SEGZONE*) Item );
1331  break;
1332 
1333  case PCB_ZONE_AREA_T:
1334  {
1335  SetCurItem( NULL );
1336  int netcode = ( (ZONE_CONTAINER*) Item )->GetNetCode();
1337  Delete_Zone_Contour( DC, (ZONE_CONTAINER*) Item );
1338  TestNetConnection( NULL, netcode );
1339  SetMsgPanel( GetBoard() );
1340  }
1341  break;
1342 
1343  case PCB_MARKER_T:
1344  if( Item == GetCurItem() )
1345  SetCurItem( NULL );
1346 
1347  ( (MARKER_PCB*) Item )->Draw( m_canvas, DC, GR_XOR );
1348 
1349  // delete the marker, and free memory. Don't use undo stack.
1350  GetBoard()->Delete( Item );
1351  break;
1352 
1353  case PCB_PAD_T:
1354  case PCB_MODULE_TEXT_T:
1355  case PCB_MODULE_EDGE_T:
1356  break;
1357 
1358  case TYPE_NOT_INIT:
1359  case PCB_T:
1360  default:
1361  {
1362  wxString msg = wxString::Format(
1363  wxT( "Remove: item type %d unknown." ), Item->Type() );
1364  DisplayError( this, msg );
1365  }
1366  break;
1367  }
1368 }
1369 
1370 
1372 {
1373  PCB_LAYER_ID curLayer = GetActiveLayer();
1374  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
1375 
1376  // Check if the specified layer matches the present layer
1377  if( layer == curLayer )
1378  return;
1379 
1380  // Copper layers cannot be selected unconditionally; how many
1381  // of those layers are currently enabled needs to be checked.
1382  if( IsCopperLayer( layer ) )
1383  {
1384  // If only one copper layer is enabled, the only such layer
1385  // that can be selected to is the "Back" layer (so the
1386  // selection of any other copper layer is disregarded).
1387  if( GetBoard()->GetCopperLayerCount() < 2 )
1388  {
1389  if( layer != B_Cu )
1390  return;
1391  }
1392  // If more than one copper layer is enabled, the "Copper"
1393  // and "Component" layers can be selected, but the total
1394  // number of copper layers determines which internal
1395  // layers are also capable of being selected.
1396  else
1397  {
1398  if( layer != B_Cu && layer != F_Cu && layer >= GetBoard()->GetCopperLayerCount() - 1 )
1399  return;
1400  }
1401 
1402  EDA_ITEM* current = GetScreen()->GetCurItem();
1403 
1404  // See if we are drawing a segment; if so, add a via?
1405  if( GetToolId() == ID_TRACK_BUTT && current )
1406  {
1407  if( current->Type() == PCB_TRACE_T && current->IsNew() )
1408  {
1409  // Want to set the routing layers so that it switches properly -
1410  // see the implementation of Other_Layer_Route - the working
1411  // layer is used to 'start' the via and set the layer masks appropriately.
1412  GetScreen()->m_Route_Layer_TOP = curLayer;
1413  GetScreen()->m_Route_Layer_BOTTOM = layer;
1414 
1415  SetActiveLayer( curLayer );
1416 
1417  if( Other_Layer_Route( (TRACK*) GetScreen()->GetCurItem(), DC ) )
1418  {
1419  if( displ_opts->m_ContrastModeDisplay )
1420  m_canvas->Refresh();
1421  }
1422 
1423  // if the via was allowed by DRC, then the layer swap has already
1424  // been done by Other_Layer_Route(). if via not allowed, then
1425  // return now so assignment to setActiveLayer() below doesn't happen.
1426  return;
1427  }
1428  }
1429  }
1430 
1431  // Is yet more checking required? E.g. when the layer to be selected
1432  // is a non-copper layer, or when switching between a copper layer
1433  // and a non-copper layer, or vice-versa?
1434  // ...
1435 
1436  SetActiveLayer( layer );
1437 
1438  if( displ_opts->m_ContrastModeDisplay )
1439  m_canvas->Refresh();
1440 }
1441 
1442 
1443 void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
1444 {
1445  int id = aEvent.GetId();
1446  int lastToolID = GetToolId();
1447 
1449  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
1450 
1451  // Stop the current command and deselect the current tool.
1453 
1454  switch( id )
1455  {
1456  case ID_NO_TOOL_SELECTED:
1458  break;
1459 
1460  case ID_ZOOM_SELECTION:
1461  // This tool is located on the main toolbar: switch it on or off on click on it
1462  if( lastToolID != ID_ZOOM_SELECTION )
1463  SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) );
1464  else
1466  break;
1467 
1468  case ID_TRACK_BUTT:
1469  if( Settings().m_legacyDrcOn )
1470  SetToolID( id, wxCURSOR_PENCIL, _( "Add tracks" ) );
1471  else
1472  SetToolID( id, wxCURSOR_QUESTION_ARROW, _( "Add tracks" ) );
1473 
1474  Compile_Ratsnest( &dc, true );
1475  break;
1476 
1477  case ID_PCB_MODULE_BUTT:
1478  SetToolID( id, wxCURSOR_PENCIL, _( "Add footprint" ) );
1479  break;
1480 
1481  case ID_PCB_ZONES_BUTT:
1482  SetToolID( id, wxCURSOR_PENCIL, _( "Add zones" ) );
1483 
1484  if( displ_opts->m_DisplayZonesMode != 0 )
1485  DisplayInfoMessage( this, _( "Warning: zone display is OFF!!!" ) );
1486 
1487  if( !GetBoard()->IsHighLightNetON() && (GetBoard()->GetHighLightNetCode() > 0 ) )
1488  HighLight( &dc );
1489 
1490  break;
1491 
1493  SetToolID( id, wxCURSOR_PENCIL, _( "Add keepout" ) );
1494  break;
1495 
1496  case ID_PCB_TARGET_BUTT:
1497  SetToolID( id, wxCURSOR_PENCIL, _( "Add layer alignment target" ) );
1498  break;
1499 
1501  SetToolID( id, wxCURSOR_PENCIL, _( "Adjust zero" ) );
1502  break;
1503 
1505  SetToolID( id, wxCURSOR_PENCIL, _( "Adjust grid origin" ) );
1506  break;
1507 
1508  case ID_PCB_ADD_LINE_BUTT:
1509  SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic line" ) );
1510  break;
1511 
1512  case ID_PCB_ARC_BUTT:
1513  SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic arc" ) );
1514  break;
1515 
1516  case ID_PCB_CIRCLE_BUTT:
1517  SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic circle" ) );
1518  break;
1519 
1520  case ID_PCB_ADD_TEXT_BUTT:
1521  SetToolID( id, wxCURSOR_PENCIL, _( "Add text" ) );
1522  break;
1523 
1524  case ID_COMPONENT_BUTT:
1525  SetToolID( id, wxCURSOR_HAND, _( "Add footprint" ) );
1526  break;
1527 
1528  case ID_PCB_DIMENSION_BUTT:
1529  SetToolID( id, wxCURSOR_PENCIL, _( "Add dimension" ) );
1530  break;
1531 
1533  SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) );
1534  break;
1535 
1536  case ID_PCB_HIGHLIGHT_BUTT:
1537  SetToolID( id, wxCURSOR_HAND, _( "Highlight net" ) );
1538  break;
1539 
1541  SetToolID( id, wxCURSOR_HAND, _( "Select rats nest" ) );
1542 
1543  Compile_Ratsnest( &dc, true );
1544 
1545  break;
1546 
1547  // collect GAL-only tools here
1548  case ID_PCB_DRAW_VIA_BUTT:
1550  SetToolID( id, wxCURSOR_DEFAULT, _( "Unsupported tool in this canvas" ) );
1551  break;
1552  }
1553 }
1554 
1555 
1557 {
1558  MOVE_PARAMETERS params;
1559 
1560  DIALOG_MOVE_EXACT dialog( this, params );
1561  int ret = dialog.ShowModal();
1562 
1563  if( ret == wxID_OK )
1564  {
1565  if( BOARD_ITEM* item = GetScreen()->GetCurItem() )
1566  {
1567  // When a pad is modified, the full footprint is saved
1568  BOARD_ITEM* itemToSave = item;
1569 
1570  if( item->Type() == PCB_PAD_T )
1571  itemToSave = item->GetParent();
1572 
1573  // Could be moved or rotated
1574  SaveCopyInUndoList( itemToSave, UR_CHANGED );
1575 
1576  // begin with the default anchor
1577  wxPoint anchorPoint = item->GetPosition();
1578 
1579  if( item->Type() == PCB_MODULE_T )
1580  {
1581  // cast to module to allow access to the pads
1582  MODULE* mod = static_cast<MODULE*>( item );
1583 
1584  switch( params.anchor )
1585  {
1586  case ANCHOR_TOP_LEFT_PAD:
1587  if( mod->GetTopLeftPad()->GetAttribute() == PAD_ATTRIB_SMD )
1588  {
1589  anchorPoint = mod->GetTopLeftPad()->GetBoundingBox().GetPosition();
1590  }
1591  else
1592  {
1593  anchorPoint = mod->GetTopLeftPad()->GetPosition();
1594  }
1595  break;
1597  anchorPoint = mod->GetFootprintRect().GetCenter();
1598  break;
1599  case ANCHOR_FROM_LIBRARY:
1600  ; // nothing to do
1601  }
1602  }
1603 
1604  if( params.origin == RELATIVE_TO_CURRENT_POSITION )
1605  {
1606  anchorPoint = wxPoint( 0, 0 );
1607  }
1608 
1609  wxPoint finalMoveVector = params.translation - anchorPoint;
1610 
1611  item->Move( finalMoveVector );
1612  item->Rotate( item->GetPosition(), params.rotation );
1613  m_canvas->Refresh();
1614  }
1615  }
1616 
1618 }
1619 
1620 
1621 void PCB_EDIT_FRAME::duplicateItems( bool aIncrement )
1622 {
1623  BOARD_ITEM* item = GetScreen()->GetCurItem();
1624 
1625  if( !item )
1626  return;
1627 
1628  // In the board editor, the pads or fp texts can be edited
1629  // but cannot be duplicated (only the fp editor can do that).
1630  // only the footprint can be duplicated
1631  if( item->Type() == PCB_PAD_T || item->Type() == PCB_MODULE_TEXT_T )
1632  item = static_cast<MODULE*>( item )->GetParent();
1633 
1634  PCB_BASE_EDIT_FRAME::duplicateItem( item, aIncrement );
1635 }
1636 
1637 
1638 void PCB_BASE_EDIT_FRAME::duplicateItem( BOARD_ITEM* aItem, bool aIncrement )
1639 {
1640  if( !aItem )
1641  return;
1642 
1643  // The easiest way to handle a duplicate item command
1644  // is to simulate a block copy command, which gives us the undo management
1645  // for free
1646  if( GetScreen()->m_BlockLocate.GetState() == STATE_NO_BLOCK )
1647  {
1649 
1651 
1652  wxPoint crossHairPos = GetCrossHairPosition();
1653 
1654  const BLOCK_COMMAND_T blockType = aIncrement ? BLOCK_DUPLICATE_AND_INCREMENT : BLOCK_DUPLICATE;
1655 
1656  if( !HandleBlockBegin( &dc, blockType, crossHairPos ) )
1657  return;
1658 
1659  // Add the item to the block copy pick list:
1661  ITEM_PICKER picker( NULL, UR_UNSPECIFIED );
1662 
1663  picker.SetItem ( aItem );
1664  itemsList.PushItem( picker );
1665 
1666  // Set 2 coordinates updated by the mouse, because our simulation
1667  // does not use the mouse to call HandleBlockEnd()
1668  GetScreen()->m_BlockLocate.SetLastCursorPosition( crossHairPos );
1669  GetScreen()->m_BlockLocate.SetEnd( crossHairPos );
1670  HandleBlockEnd( &dc );
1671  }
1672 }
1673 
1674 
1676 {
1677 public:
1678 
1680  ARRAY_CREATOR( editFrame ),
1681  m_item( m_parent.GetScreen()->GetCurItem() )
1682  {}
1683 
1684 private:
1685 
1686  int getNumberOfItemsToArray() const override
1687  {
1688  // only handle single items
1689  return (m_item != NULL) ? 1 : 0;
1690  }
1691 
1692  BOARD_ITEM* getNthItemToArray( int n ) const override
1693  {
1694  wxASSERT_MSG( n == 0, "Legacy array tool can only handle a single item" );
1695  return m_item;
1696  }
1697 
1698  BOARD* getBoard() const override
1699  {
1700  return m_parent.GetBoard();
1701  }
1702 
1703  MODULE* getModule() const override
1704  {
1705  return dynamic_cast<MODULE*>( m_item->GetParent() );
1706  }
1707 
1708  wxPoint getRotationCentre() const override
1709  {
1710  return m_item->GetCenter();
1711  }
1712 
1713  void finalise() override
1714  {
1715  m_parent.GetCanvas()->Refresh();
1716  }
1717 
1718  BOARD_ITEM* m_item; // only have the one
1719 };
1720 
1721 
1723 {
1724  LEGACY_ARRAY_CREATOR array_creator( *this );
1725 
1726  array_creator.Invoke();
1727 }
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.
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:1686
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.
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp: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:1708
This file is part of the common library.
void FlipTextePcb(TEXTE_PCB *aTextePcb, wxDC *aDC)
void Fill(std::vector< ZONE_CONTAINER * > aZones, bool aCheck=false)
Definition: zone_filler.cpp:84
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
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)
DLIST< SEGZONE > m_Zone
Definition: class_board.h:247
void Delete_Texte_Pcb(TEXTE_PCB *TextePcb, wxDC *DC)
void OnSelectTool(wxCommandEvent &aEvent)
Definition: edit.cpp:1443
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
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:1638
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:41
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:865
void finalise() override
Definition: edit.cpp:1713
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:1294
bool End_Route(TRACK *aTrack, wxDC *aDC)
Function End_Route Terminates a track currently being created.
Definition: editrack.cpp:410
BOARD_ITEM * getNthItemToArray(int n) const override
Definition: edit.cpp:1692
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:1556
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:882
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:102
class MODULE, a footprint
Definition: typeinfo.h:89
timestamp_t GetNewTimeStamp()
Definition: common.cpp:167
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:832
bool IsMouseCaptured() const
BOARD_ITEM * m_item
Definition: edit.cpp:1718
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
void DlgGlobalChange_PadSettings(D_PAD *aPad, bool aRedraw)
Function DlgGlobalChange_PadSettings Function to change pad caracteristics for the given footprint or...
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:1722
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:1011
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:616
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:98
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:1698
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:982
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.
#define INSTALL_UNBUFFERED_DC(name, parent)
int GetToolId() const
Definition: draw_frame.h:488
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:1371
void duplicateItems(bool aIncrement) override
Function duplicateItems Duplicate selected item if possible and start a move.
Definition: edit.cpp:1621
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...
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:105
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:290
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:1679
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:1703
const wxPoint GetCenter() const
Definition: eda_rect.h:115