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 <wxPcbStruct.h>
41 
42 #include <pcbnew_id.h>
43 #include <pcbnew.h>
44 #include <module_editor_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 <modview_frame.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 
860  // Warning: the current item can be deleted by exchange module
861  SetCurItem( NULL );
863  break;
864 
866  // If the current Item is a pad, text module ...: Get its parent
867  if( GetCurItem()->Type() != PCB_MODULE_T )
868  SetCurItem( GetCurItem()->GetParent() );
869 
870  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
871  break;
872 
875  break;
876 
878 
879  // If we don't have a current item, there's nothing we can do here
880  if( !GetCurItem() )
881  break;
882 
883  // If the current Item is a pad, text module ...: Get its parent
884  if( GetCurItem()->Type() != PCB_MODULE_T )
885  SetCurItem( GetCurItem()->GetParent() );
886 
887  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
888  break;
889 
890  if( GetCurItem()->GetTimeStamp() == 0 ) // Module Editor needs a non null timestamp
891  {
893  OnModify();
894  }
895 
896  {
898 
900  SetCurItem( NULL ); // the current module could be deleted by
901  }
903  break;
904 
906  module = (MODULE*) GetCurItem()->GetParent();
907 
908  if( !module || module->Type() != PCB_MODULE_T )
909  break;
910 
911  if( module->IsLocked() )
912  {
913  wxString msg;
914  msg.Printf( _( "The parent (%s) of the pad is locked" ),
915  module->GetReference().GetData() );
916  DisplayInfoMessage( this, msg );
917  break;
918  }
919 
921  StartMovePad( (D_PAD*) GetCurItem(), &dc, true );
922  break;
923 
925  module = (MODULE*) GetCurItem()->GetParent();
926 
927  if( !module || module->Type() != PCB_MODULE_T )
928  break;
929 
930  if( module->IsLocked() )
931  {
932  wxString msg;
933  msg.Printf( _( "The parent (%s) of the pad is locked" ),
934  module->GetReference().GetData() );
935  DisplayInfoMessage( this, msg );
936  break;
937  }
938 
940  StartMovePad( (D_PAD*) GetCurItem(), &dc, false );
941  break;
942 
946  break;
947 
950  SaveCopyInUndoList( GetCurItem()->GetParent(), UR_CHANGED );
951  Import_Pad_Settings( (D_PAD*) GetCurItem(), true );
952  break;
953 
957  break;
958 
962  break;
963 
965  SaveCopyInUndoList( GetCurItem()->GetParent(), UR_CHANGED );
966  DeletePad( (D_PAD*) GetCurItem() );
967  SetCurItem( NULL );
969  break;
970 
972  InstallTextModOptionsFrame( static_cast<TEXTE_MODULE*>( GetCurItem() ), &dc );
974  break;
975 
977  ResetTextSize( GetCurItem(), &dc );
978  break;
979 
982  StartMoveTexteModule( static_cast<TEXTE_MODULE*>( GetCurItem() ), &dc );
983  break;
984 
986  RotateTextModule( static_cast<TEXTE_MODULE*>( GetCurItem() ), &dc );
988  break;
989 
991  DeleteTextModule( static_cast<TEXTE_MODULE*>( GetCurItem() ) );
992  SetCurItem( NULL );
994  break;
995 
997  {
999 
1000  if( itmp >= 0 )
1001  {
1002  // if user changed colors and we are in high contrast mode, then redraw
1003  // because the PAD_ATTRIB_SMD pads may change color.
1004  if( displ_opts->m_ContrastModeDisplay && GetActiveLayer() != itmp )
1005  {
1006  m_canvas->Refresh();
1007  }
1008  SetActiveLayer( itmp );
1009  }
1010 
1012  }
1013  break;
1014 
1017  break;
1018 
1020  {
1022 
1023  if( itmp >= 0 )
1024  SetActiveLayer( itmp );
1025 
1027  }
1028  break;
1029 
1031  {
1033 
1034  if( itmp >= 0 )
1035  SetActiveLayer( itmp );
1036  }
1037  break;
1038 
1042  break;
1043 
1046 
1047  if( displ_opts->m_ContrastModeDisplay )
1048  m_canvas->Refresh( true );
1049  break;
1050 
1054  break;
1055 
1057  Rotate_Texte_Pcb( (TEXTE_PCB*) GetCurItem(), &dc );
1059  break;
1060 
1062  CreateTextePcb( &dc, (TEXTE_PCB*) GetCurItem() );
1064  m_canvas->SetAutoPanRequest( true );
1065  break;
1066 
1068  FlipTextePcb( (TEXTE_PCB*) GetCurItem(), &dc );
1070  break;
1071 
1073  Delete_Texte_Pcb( (TEXTE_PCB*) GetCurItem(), &dc );
1075  break;
1076 
1078  BeginMoveTarget( (PCB_TARGET*) GetCurItem(), &dc );
1080  break;
1081 
1085  break;
1086 
1089  DeleteTarget( (PCB_TARGET*) GetCurItem(), &dc );
1090  SetCurItem( NULL );
1091  break;
1092 
1095  DeleteDimension( (DIMENSION*) GetCurItem(), &dc );
1096  SetCurItem( NULL );
1097  break;
1098 
1102  break;
1103 
1106  break;
1107 
1111  break;
1112 
1114  RemoveStruct( GetCurItem(), &dc );
1116  break;
1117 
1119  if( GetCurItem() && GetCurItem()->Type() == PCB_MARKER_T )
1120  ( (MARKER_PCB*) GetCurItem() )->DisplayMarkerInfo( this );
1121 
1123  break;
1124 
1126  if( GetCurItem()->GetFlags() != 0 )
1127  break;
1128 
1130  SetCurItem( NULL );
1132  m_canvas->Refresh();
1133  break;
1134 
1136 #ifndef USE_WX_OVERLAY
1138 #else
1139  // #1277772 - Draw into dialog converted in refresh request
1141  m_canvas->Refresh();
1142 #endif
1144  break;
1145 
1149  break;
1150 
1153 
1154  if( GetCurItem() && (GetCurItem()->IsNew()) )
1155  {
1156  End_Edge( (DRAWSEGMENT*) GetCurItem(), &dc );
1157  SetCurItem( NULL );
1158  }
1159 
1160  break;
1161 
1164 
1165  if( GetCurItem() && (GetCurItem()->IsNew()) )
1166  {
1167  if( End_Zone( &dc ) )
1168  SetCurItem( NULL );
1169  }
1170 
1171  m_canvas->SetAutoPanRequest( false );
1172  break;
1173 
1176 
1177  if( GetCurItem() && (GetCurItem()->IsNew()) )
1178  {
1179  if( Delete_LastCreatedCorner( &dc ) == 0 ) // No more segment in outline,
1180  SetCurItem( NULL );
1181  }
1182 
1183  break;
1184 
1185 
1189  break;
1190 
1195  break;
1196 
1200  break;
1201 
1204  {
1205  TRACK* track = (TRACK*) GetScreen()->GetCurItem();
1206  wxPoint pos = GetCrossHairPosition();
1207 
1208  track->Draw( m_canvas, &dc, GR_XOR );
1209  PICKED_ITEMS_LIST itemsListPicker;
1210 
1211  TRACK* newtrack = GetBoard()->CreateLockPoint( pos, track, &itemsListPicker );
1212 
1213  SaveCopyInUndoList( itemsListPicker, UR_UNSPECIFIED );
1214  track->Draw( m_canvas, &dc, GR_XOR );
1215  newtrack->Draw( m_canvas, &dc, GR_XOR );
1216 
1217  // compute the new ratsnest, because connectivity could change
1218  TestNetConnection( &dc, track->GetNetCode() );
1219  }
1220  break;
1221 
1223  moveExact();
1224  break;
1225 
1229  break;
1230 
1232  createArray();
1233  break;
1234 
1235  case ID_MENU_PCB_CLEAN:
1236  Clean_Pcb();
1237  break;
1238 
1240  Swap_Layers( event );
1241  break;
1242 
1244  InvokeDialogGrid();
1245  break;
1246 
1248  {
1249  wxConfigBase* cfg = Pgm().CommonSettings();
1250  cfg->Read( wxT( "module_doc_file" ), g_DocModulesFileName );
1251  GetAssociatedDocument( this, g_DocModulesFileName, &Kiface().KifaceSearch() );
1252  }
1253  break;
1254 
1256  ArchiveModulesOnBoard( false );
1257  break;
1258 
1260  ArchiveModulesOnBoard( true );
1261  break;
1262 
1265  m_canvas->Refresh();
1266  break;
1267 
1268  default:
1269  wxString msg;
1270  msg.Printf( wxT( "PCB_EDIT_FRAME::Process_Special_Functions() unknown event id %d" ), id );
1271  DisplayError( this, msg );
1272  break;
1273  }
1274 
1275  m_canvas->CrossHairOn( &dc );
1276  m_canvas->SetIgnoreMouseEvents( false );
1277 }
1278 
1279 
1281 {
1282  if( Item == NULL )
1283  return;
1284 
1285  switch( Item->Type() )
1286  {
1287  case PCB_MODULE_T:
1288  Delete_Module( (MODULE*) Item, DC );
1289  break;
1290 
1291  case PCB_DIMENSION_T:
1292  DeleteDimension( (DIMENSION*) Item, DC );
1293  break;
1294 
1295  case PCB_TARGET_T:
1296  DeleteTarget( (PCB_TARGET*) Item, DC );
1297  break;
1298 
1299  case PCB_LINE_T:
1300  Delete_Segment_Edge( (DRAWSEGMENT*) Item, DC );
1301  break;
1302 
1303  case PCB_TEXT_T:
1304  Delete_Texte_Pcb( (TEXTE_PCB*) Item, DC );
1305  break;
1306 
1307  case PCB_TRACE_T:
1308  Delete_Track( DC, (TRACK*) Item );
1309  break;
1310 
1311  case PCB_VIA_T:
1312  Delete_Segment( DC, (TRACK*) Item );
1313  break;
1314 
1315  case PCB_ZONE_T:
1316  Delete_OldZone_Fill( (SEGZONE*) Item );
1317  break;
1318 
1319  case PCB_ZONE_AREA_T:
1320  {
1321  SetCurItem( NULL );
1322  int netcode = ( (ZONE_CONTAINER*) Item )->GetNetCode();
1323  Delete_Zone_Contour( DC, (ZONE_CONTAINER*) Item );
1324  TestNetConnection( NULL, netcode );
1325  SetMsgPanel( GetBoard() );
1326  }
1327  break;
1328 
1329  case PCB_MARKER_T:
1330  if( Item == GetCurItem() )
1331  SetCurItem( NULL );
1332 
1333  ( (MARKER_PCB*) Item )->Draw( m_canvas, DC, GR_XOR );
1334 
1335  // delete the marker, and free memory. Don't use undo stack.
1336  GetBoard()->Delete( Item );
1337  break;
1338 
1339  case PCB_PAD_T:
1340  case PCB_MODULE_TEXT_T:
1341  case PCB_MODULE_EDGE_T:
1342  break;
1343 
1344  case TYPE_NOT_INIT:
1345  case PCB_T:
1346  default:
1347  {
1348  wxString msg = wxString::Format(
1349  wxT( "Remove: item type %d unknown." ), Item->Type() );
1350  DisplayError( this, msg );
1351  }
1352  break;
1353  }
1354 }
1355 
1356 
1358 {
1359  PCB_LAYER_ID curLayer = GetActiveLayer();
1360  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
1361 
1362  // Check if the specified layer matches the present layer
1363  if( layer == curLayer )
1364  return;
1365 
1366  // Copper layers cannot be selected unconditionally; how many
1367  // of those layers are currently enabled needs to be checked.
1368  if( IsCopperLayer( layer ) )
1369  {
1370  // If only one copper layer is enabled, the only such layer
1371  // that can be selected to is the "Back" layer (so the
1372  // selection of any other copper layer is disregarded).
1373  if( GetBoard()->GetCopperLayerCount() < 2 )
1374  {
1375  if( layer != B_Cu )
1376  return;
1377  }
1378  // If more than one copper layer is enabled, the "Copper"
1379  // and "Component" layers can be selected, but the total
1380  // number of copper layers determines which internal
1381  // layers are also capable of being selected.
1382  else
1383  {
1384  if( layer != B_Cu && layer != F_Cu && layer >= GetBoard()->GetCopperLayerCount() - 1 )
1385  return;
1386  }
1387 
1388  EDA_ITEM* current = GetScreen()->GetCurItem();
1389 
1390  // See if we are drawing a segment; if so, add a via?
1391  if( GetToolId() == ID_TRACK_BUTT && current )
1392  {
1393  if( current->Type() == PCB_TRACE_T && current->IsNew() )
1394  {
1395  // Want to set the routing layers so that it switches properly -
1396  // see the implementation of Other_Layer_Route - the working
1397  // layer is used to 'start' the via and set the layer masks appropriately.
1398  GetScreen()->m_Route_Layer_TOP = curLayer;
1399  GetScreen()->m_Route_Layer_BOTTOM = layer;
1400 
1401  SetActiveLayer( curLayer );
1402 
1403  if( Other_Layer_Route( (TRACK*) GetScreen()->GetCurItem(), DC ) )
1404  {
1405  if( displ_opts->m_ContrastModeDisplay )
1406  m_canvas->Refresh();
1407  }
1408 
1409  // if the via was allowed by DRC, then the layer swap has already
1410  // been done by Other_Layer_Route(). if via not allowed, then
1411  // return now so assignment to setActiveLayer() below doesn't happen.
1412  return;
1413  }
1414  }
1415  }
1416 
1417  // Is yet more checking required? E.g. when the layer to be selected
1418  // is a non-copper layer, or when switching between a copper layer
1419  // and a non-copper layer, or vice-versa?
1420  // ...
1421 
1422  SetActiveLayer( layer );
1423 
1424  if( displ_opts->m_ContrastModeDisplay )
1425  m_canvas->Refresh();
1426 }
1427 
1428 
1429 void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
1430 {
1431  int id = aEvent.GetId();
1432  int lastToolID = GetToolId();
1433 
1435  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
1436 
1437  // Stop the current command and deselect the current tool.
1439 
1440  switch( id )
1441  {
1442  case ID_NO_TOOL_SELECTED:
1444  break;
1445 
1446  case ID_ZOOM_SELECTION:
1447  // This tool is located on the main toolbar: switch it on or off on click on it
1448  if( lastToolID != ID_ZOOM_SELECTION )
1449  SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) );
1450  else
1452  break;
1453 
1454  case ID_TRACK_BUTT:
1455  if( Settings().m_legacyDrcOn )
1456  SetToolID( id, wxCURSOR_PENCIL, _( "Add tracks" ) );
1457  else
1458  SetToolID( id, wxCURSOR_QUESTION_ARROW, _( "Add tracks" ) );
1459 
1460  Compile_Ratsnest( &dc, true );
1461  break;
1462 
1463  case ID_PCB_MODULE_BUTT:
1464  SetToolID( id, wxCURSOR_PENCIL, _( "Add footprint" ) );
1465  break;
1466 
1467  case ID_PCB_ZONES_BUTT:
1468  SetToolID( id, wxCURSOR_PENCIL, _( "Add zones" ) );
1469 
1470  if( displ_opts->m_DisplayZonesMode != 0 )
1471  DisplayInfoMessage( this, _( "Warning: zone display is OFF!!!" ) );
1472 
1473  if( !GetBoard()->IsHighLightNetON() && (GetBoard()->GetHighLightNetCode() > 0 ) )
1474  HighLight( &dc );
1475 
1476  break;
1477 
1479  SetToolID( id, wxCURSOR_PENCIL, _( "Add keepout" ) );
1480  break;
1481 
1482  case ID_PCB_TARGET_BUTT:
1483  SetToolID( id, wxCURSOR_PENCIL, _( "Add layer alignment target" ) );
1484  break;
1485 
1487  SetToolID( id, wxCURSOR_PENCIL, _( "Adjust zero" ) );
1488  break;
1489 
1491  SetToolID( id, wxCURSOR_PENCIL, _( "Adjust grid origin" ) );
1492  break;
1493 
1494  case ID_PCB_ADD_LINE_BUTT:
1495  SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic line" ) );
1496  break;
1497 
1498  case ID_PCB_ARC_BUTT:
1499  SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic arc" ) );
1500  break;
1501 
1502  case ID_PCB_CIRCLE_BUTT:
1503  SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic circle" ) );
1504  break;
1505 
1506  case ID_PCB_ADD_TEXT_BUTT:
1507  SetToolID( id, wxCURSOR_PENCIL, _( "Add text" ) );
1508  break;
1509 
1510  case ID_COMPONENT_BUTT:
1511  SetToolID( id, wxCURSOR_HAND, _( "Add footprint" ) );
1512  break;
1513 
1514  case ID_PCB_DIMENSION_BUTT:
1515  SetToolID( id, wxCURSOR_PENCIL, _( "Add dimension" ) );
1516  break;
1517 
1519  SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) );
1520  break;
1521 
1522  case ID_PCB_HIGHLIGHT_BUTT:
1523  SetToolID( id, wxCURSOR_HAND, _( "Highlight net" ) );
1524  break;
1525 
1527  SetToolID( id, wxCURSOR_HAND, _( "Select rats nest" ) );
1528 
1529  Compile_Ratsnest( &dc, true );
1530 
1531  break;
1532 
1533  // collect GAL-only tools here
1534  case ID_PCB_DRAW_VIA_BUTT:
1536  SetToolID( id, wxCURSOR_DEFAULT, _( "Unsupported tool in this canvas" ) );
1537  break;
1538  }
1539 }
1540 
1541 
1543 {
1544  MOVE_PARAMETERS params;
1545 
1546  DIALOG_MOVE_EXACT dialog( this, params );
1547  int ret = dialog.ShowModal();
1548 
1549  if( ret == wxID_OK )
1550  {
1551  if( BOARD_ITEM* item = GetScreen()->GetCurItem() )
1552  {
1553  // When a pad is modified, the full footprint is saved
1554  BOARD_ITEM* itemToSave = item;
1555 
1556  if( item->Type() == PCB_PAD_T )
1557  itemToSave = item->GetParent();
1558 
1559  // Could be moved or rotated
1560  SaveCopyInUndoList( itemToSave, UR_CHANGED );
1561 
1562  // begin with the default anchor
1563  wxPoint anchorPoint = item->GetPosition();
1564 
1565  if( item->Type() == PCB_MODULE_T )
1566  {
1567  // cast to module to allow access to the pads
1568  MODULE* mod = static_cast<MODULE*>( item );
1569 
1570  switch( params.anchor )
1571  {
1572  case ANCHOR_TOP_LEFT_PAD:
1573  if( mod->GetTopLeftPad()->GetAttribute() == PAD_ATTRIB_SMD )
1574  {
1575  anchorPoint = mod->GetTopLeftPad()->GetBoundingBox().GetPosition();
1576  }
1577  else
1578  {
1579  anchorPoint = mod->GetTopLeftPad()->GetPosition();
1580  }
1581  break;
1583  anchorPoint = mod->GetFootprintRect().GetCenter();
1584  break;
1585  case ANCHOR_FROM_LIBRARY:
1586  ; // nothing to do
1587  }
1588  }
1589 
1590  if( params.origin == RELATIVE_TO_CURRENT_POSITION )
1591  {
1592  anchorPoint = wxPoint( 0, 0 );
1593  }
1594 
1595  wxPoint finalMoveVector = params.translation - anchorPoint;
1596 
1597  item->Move( finalMoveVector );
1598  item->Rotate( item->GetPosition(), params.rotation );
1599  m_canvas->Refresh();
1600  }
1601  }
1602 
1604 }
1605 
1606 
1607 void PCB_EDIT_FRAME::duplicateItems( bool aIncrement )
1608 {
1609  BOARD_ITEM* item = GetScreen()->GetCurItem();
1610 
1611  if( !item )
1612  return;
1613 
1614  // In the board editor, the pads or fp texts can be edited
1615  // but cannot be duplicated (only the fp editor can do that).
1616  // only the footprint can be duplicated
1617  if( item->Type() == PCB_PAD_T || item->Type() == PCB_MODULE_TEXT_T )
1618  item = static_cast<MODULE*>( item )->GetParent();
1619 
1620  PCB_BASE_EDIT_FRAME::duplicateItem( item, aIncrement );
1621 }
1622 
1623 
1624 void PCB_BASE_EDIT_FRAME::duplicateItem( BOARD_ITEM* aItem, bool aIncrement )
1625 {
1626  if( !aItem )
1627  return;
1628 
1629  // The easiest way to handle a duplicate item command
1630  // is to simulate a block copy command, which gives us the undo management
1631  // for free
1632  if( GetScreen()->m_BlockLocate.GetState() == STATE_NO_BLOCK )
1633  {
1635 
1637 
1638  wxPoint crossHairPos = GetCrossHairPosition();
1639 
1640  const BLOCK_COMMAND_T blockType = aIncrement ? BLOCK_DUPLICATE_AND_INCREMENT : BLOCK_DUPLICATE;
1641 
1642  if( !HandleBlockBegin( &dc, blockType, crossHairPos ) )
1643  return;
1644 
1645  // Add the item to the block copy pick list:
1647  ITEM_PICKER picker( NULL, UR_UNSPECIFIED );
1648 
1649  picker.SetItem ( aItem );
1650  itemsList.PushItem( picker );
1651 
1652  // Set 2 coordinates updated by the mouse, because our simulation
1653  // does not use the mouse to call HandleBlockEnd()
1654  GetScreen()->m_BlockLocate.SetLastCursorPosition( crossHairPos );
1655  GetScreen()->m_BlockLocate.SetEnd( crossHairPos );
1656  HandleBlockEnd( &dc );
1657  }
1658 }
1659 
1660 
1662 {
1663 public:
1664 
1666  ARRAY_CREATOR( editFrame ),
1667  m_item( m_parent.GetScreen()->GetCurItem() )
1668  {}
1669 
1670 private:
1671 
1672  int getNumberOfItemsToArray() const override
1673  {
1674  // only handle single items
1675  return (m_item != NULL) ? 1 : 0;
1676  }
1677 
1678  BOARD_ITEM* getNthItemToArray( int n ) const override
1679  {
1680  wxASSERT_MSG( n == 0, "Legacy array tool can only handle a single item" );
1681  return m_item;
1682  }
1683 
1684  BOARD* getBoard() const override
1685  {
1686  return m_parent.GetBoard();
1687  }
1688 
1689  MODULE* getModule() const override
1690  {
1691  return dynamic_cast<MODULE*>( m_item->GetParent() );
1692  }
1693 
1694  wxPoint getRotationCentre() const override
1695  {
1696  return m_item->GetCenter();
1697  }
1698 
1699  void finalise() override
1700  {
1701  m_parent.GetCanvas()->Refresh();
1702  }
1703 
1704  BOARD_ITEM* m_item; // only have the one
1705 };
1706 
1707 
1709 {
1710  LEGACY_ARRAY_CREATOR array_creator( *this );
1711 
1712  array_creator.Invoke();
1713 }
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
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:225
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:273
virtual void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
Definition: pcbframe.cpp:1038
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.
Definition of class FOOTPRINT_EDIT_FRAME.
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.
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:398
TEXTE_PCB class definition.
int getNumberOfItemsToArray() const override
Definition: edit.cpp:1672
bool g_Alternate_Track_Posture
Definition: pcbnew.cpp:70
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.
int InstallExchangeModuleFrame(MODULE *ExchangeModuleModule)
Definition: pcbframe.cpp:1281
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:332
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...
Definition: modules.cpp:260
This file is part of the common library.
bool IsNew() const
Definition: base_struct.h:243
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:346
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:1694
This file is part of the common library.
void FlipTextePcb(TEXTE_PCB *aTextePcb, wxDC *aDC)
Class BOARD to handle a board.
bool InvokeDXFDialogBoardImport(PCB_BASE_FRAME *aCaller)
Function InvokeDXFDialogBoardImport shows the modal DIALOG_DXF_IMPORT for importing a DXF file to a b...
void InstallFindFrame()
void InstallGraphicItemPropertiesDialog(DRAWSEGMENT *aItem, wxDC *aDC)
void SetMessageBlock(EDA_DRAW_FRAME *frame)
Function SetMessageBlock Displays the type of block command in the status bar of the window...
Component library viewer main window.
Definition: modview_frame.h:44
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
PCB_BASE_FRAME & m_parent
Definition: array_creator.h:61
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:86
Classes to handle copper zones.
void Rotate_Module(wxDC *DC, MODULE *module, double angle, bool incremental)
Definition: modules.cpp:433
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:1429
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:1624
void RotateTextModule(TEXTE_MODULE *Text, wxDC *DC)
Definition: edtxtmod.cpp:108
DRC * m_drc
the DRC controller, see drc.cpp
Definition: wxPcbStruct.h:91
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:51
void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
Definition: draw_panel.cpp:354
int GetState(int type) const
Definition: base_struct.h:264
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:826
void finalise() override
Definition: edit.cpp:1699
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
void RemoveStruct(BOARD_ITEM *Item, wxDC *DC)
Definition: edit.cpp:1280
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:1678
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 moveExact()
Function moveExact Move the selected item exactly.
Definition: edit.cpp:1542
void Export_Pad_Settings(D_PAD *aPad)
virtual const wxPoint GetCenter() const
Function GetCenter()
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:843
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:77
class MODULE, a footprint
Definition: typeinfo.h:89
timestamp_t GetNewTimeStamp()
Definition: common.cpp:166
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().
void ArchiveModulesOnBoard(bool aStoreInNewLib, const wxString &aLibName=wxEmptyString)
Function ArchiveModulesOnBoard Save modules in a library:
Definition: librairi.cpp:591
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:793
bool IsMouseCaptured() const
BOARD_ITEM * m_item
Definition: edit.cpp:1704
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)
void InstallModuleOptionsFrame(MODULE *Module, wxDC *DC)
Definition: editmod.cpp:49
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:153
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
bool Load_Module_From_BOARD(MODULE *Module)
Function Load_Module_From_BOARD load in Modedit a footprint from the main board.
Definition: loadcmp.cpp:75
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:1708
void Start_DragTrackSegmentAndKeepSlope(TRACK *track, wxDC *DC)
wxString g_DocModulesFileName
Definition: pcbnew.cpp:80
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:199
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:259
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:100
bool IsLocked() const override
Function IsLocked.
Definition: class_module.h:256
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
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:56
virtual bool HandleBlockEnd(wxDC *DC)
Function HandleBlockEnd( ) Handle the "end" of a block command, i.e.
Definition: draw_frame.cpp:680
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 Fill(std::vector< ZONE_CONTAINER * > aZones)
Definition: zone_filler.cpp:82
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:577
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
void Delete_Track(wxDC *DC, TRACK *Track)
Definition: deltrack.cpp:140
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:1684
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:266
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:99
void ShowDRCDialog(wxWindow *aParent=NULL)
Function ShowDRCDialog opens a dialog and prompts the user, then if a test run button is clicked...
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 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:439
void StartMoveModule(MODULE *aModule, wxDC *aDC, bool aDragConnectedTracks)
Function StartMoveModule Initialize a drag or move pad command.
Definition: modules.cpp:100
#define INSTALL_UNBUFFERED_DC(name, parent)
int GetToolId() const
Definition: draw_frame.h:480
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:178
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)
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:152
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.
Definition: pcbframe.cpp:906
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.
Definition: modules.cpp:62
void StartMoveTexteModule(TEXTE_MODULE *Text, wxDC *DC)
Definition: edtxtmod.cpp:199
Module description (excepted pads)
PCB_LAYER_BOX_SELECTOR * m_SelLayerBox
Definition: wxPcbStruct.h:232
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...
Definition: modules.cpp:287
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:105
void SwitchLayer(wxDC *DC, PCB_LAYER_ID layer) override
Definition: edit.cpp:1357
void duplicateItems(bool aIncrement) override
Function duplicateItems Duplicate selected item if possible and start a move.
Definition: edit.cpp:1607
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:74
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:175
virtual void SetActiveLayer(PCB_LAYER_ID aLayer) override
Function SetActiveLayer will change the currently active layer to aLayer and also update the PCB_LAYE...
Definition: pcbframe.cpp:927
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:100
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...
Definition: clean.cpp:142
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
void Edit_TrackSegm_Width(wxDC *aDC, TRACK *aTrackItem)
Function Edit_TrackSegm_Width Modify one track segment width or one via diameter (using DRC control)...
PCB_EDIT_FRAME::OnResetModuleTextSizes PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar ID_PCB_MEASUREMENT_TOOL
Definition: pcbframe.cpp:259
LEGACY_ARRAY_CREATOR(PCB_BASE_EDIT_FRAME &editFrame)
Definition: edit.cpp:1665
void SetCommand(BLOCK_COMMAND_T aCommand)
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:230
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:1689
const wxPoint GetCenter() const