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.h>
58 
59 #include <dialog_move_exact.h>
60 
61 #include <tool/tool_manager.h>
62 #include <tools/pcb_actions.h>
63 
64 // Handles the selection of command events.
65 void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
66 {
67  int id = event.GetId();
68 
70  MODULE* module;
72 
73  m_canvas->CrossHairOff( &dc );
74 
75  switch( id ) // Some (not all ) edit commands must be finished or aborted
76  {
77  case wxID_CUT:
78  case wxID_COPY:
147  case ID_POPUP_ZOOM_BLOCK:
148  case ID_POPUP_FLIP_BLOCK:
150  case ID_POPUP_COPY_BLOCK:
158  break;
159 
161  if( m_canvas->IsMouseCaptured() )
162  {
164  }
165 
166  // Should not be executed, just in case
167  if( GetScreen()->m_BlockLocate.GetCommand() != BLOCK_IDLE )
168  {
172  }
173 
174  if( GetToolId() == ID_NO_TOOL_SELECTED )
176  else
177  SetCursor( (wxStockCursor) m_canvas->GetDefaultCursor() );
178 
179  break;
180 
181  default: // Finish (abort) the command
182  if( m_canvas->IsMouseCaptured() )
184 
185  if( GetToolId() != id )
186  {
187  if( m_lastDrawToolId != GetToolId() )
189 
191  }
192  break;
193  }
194 
195  switch( id ) // Execute command
196  {
197  case 0:
198  break;
199 
201  {
203 
204  if( !editor )
205  {
207  editor->Zoom_Automatique( false );
208  }
209  else
210  {
211  // Needed on Windows, other platforms do not use it,
212  // but it creates no issue
213  if( editor->IsIconized() )
214  editor->Iconize( false );
215 
216  editor->Raise();
217 
218  // Raising the window does not set the focus on Linux. This should work on
219  // any platform.
220  if( wxWindow::FindFocus() != editor )
221  editor->SetFocus();
222  }
223 
224  editor->PushPreferences( m_canvas );
225  }
226  break;
227 
229  {
231 
232  if( !viewer )
233  {
235  viewer->Zoom_Automatique( false );
236  }
237  else
238  {
239  // Needed on Windows, other platforms do not use it,
240  // but it creates no issue
241  if( viewer->IsIconized() )
242  viewer->Iconize( false );
243 
244  viewer->Raise();
245 
246  // Raising the window does not set the focus on Linux. This should work on
247  // any platform.
248  if( wxWindow::FindFocus() != viewer )
249  viewer->SetFocus();
250  }
251 
252  viewer->PushPreferences( m_canvas );
253  }
254  break;
255 
257  InstallPcbGlobalDeleteFrame( wxDefaultPosition );
258  break;
259 
262  m_canvas->SetAutoPanRequest( false );
263  HandleBlockPlace( &dc );
264  break;
265 
266  case ID_POPUP_COPY_BLOCK:
269  m_canvas->SetAutoPanRequest( false );
270  HandleBlockPlace( &dc );
271  break;
272 
273  case ID_POPUP_ZOOM_BLOCK:
276  HandleBlockEnd( &dc );
277  break;
278 
282  HandleBlockEnd( &dc );
283  break;
284 
288  HandleBlockEnd( &dc );
289  break;
290 
291  case ID_POPUP_FLIP_BLOCK:
294  HandleBlockEnd( &dc );
295  break;
296 
297  case ID_DRC_CONTROL:
298  // Shows the DRC dialog in non modal mode, to allows board edition
299  // with the DRC dialog opened and showing errors.
300  m_drc->ShowDRCDialog();
301  break;
302 
303  case ID_GET_NETLIST:
304  InstallNetlistFrame( &dc );
305  break;
306 
307  case ID_FIND_ITEMS:
309  break;
310 
313  break;
314 
316  break;
317 
320 
321  // EndSegment(&dc);
322  break;
323 
325  if( GetCurItem() == NULL )
326  break;
327  Edit_Track_Width( &dc, (TRACK*) GetCurItem() );
329  OnModify();
330  break;
331 
333  if( GetCurItem() == NULL )
334  break;
337  OnModify();
338  break;
339 
341  {
342  DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS dlg( this, GetBoard()->GetHighLightNetCode() );
343  dlg.ShowModal();
344  }
345  break;
346 
348  if( GetCurItem() == NULL )
349  break;
350  {
351  int type = GetCurItem()->Type();
352 
353  if( type == PCB_TRACE_T || type == PCB_VIA_T )
354  {
356  DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS dlg( this, item->GetNetCode() );
357  dlg.ShowModal();
358  }
359 
360  }
362  break;
363 
366  OnHotkeyBeginRoute( &dc );
367  break;
368 
371  End_Route( (TRACK*) GetCurItem(), &dc );
372  break;
373 
376 
377  if( GetCurItem()->IsDragging() )
378  {
380  }
381 
382  break;
383 
385  /* change the position of initial segment when creating new tracks
386  * switch from _/ to -\ .
387  * If a track is in progress, it will be redrawn
388  */
389  if( m_canvas->IsMouseCaptured() )
390  m_canvas->CallMouseCapture( &dc, wxDefaultPosition, false );
391 
393 
394  if( m_canvas->IsMouseCaptured() )
395  m_canvas->CallMouseCapture( &dc, wxDefaultPosition, false );
396 
397  break;
398 
400  if( !IsMicroViaAcceptable() )
401  break;
402  // fall through
408 
409  if( GetCurItem()->IsDragging() )
410  {
412  }
413  else
414  {
416  VIATYPE_T v_type = settings.m_CurrentViaType;
417  switch( id )
418  {
422  break;
423 
425  settings.m_CurrentViaType = VIA_MICROVIA;
426  break;
427 
428  default:
429  settings.m_CurrentViaType = VIA_THROUGH;
430  break;
431  }
432 
433  // place via and switch layer.
436  {
438 
439  wxPoint dlgPosition;
440 
441  wxGetMousePosition( &dlgPosition.x, &dlgPosition.y );
442 
443  PCB_LAYER_ID layer = SelectLayer( GetActiveLayer(), LSET::AllNonCuMask(), dlgPosition );
444 
445  m_canvas->SetIgnoreMouseEvents( false );
447 
448  if( GetActiveLayer() != layer )
449  {
451  GetScreen()->m_Route_Layer_BOTTOM = layer;
452  Other_Layer_Route( (TRACK*) GetCurItem(), &dc );
453  }
454  }
455 
456  else
457  Other_Layer_Route( (TRACK*) GetCurItem(), &dc );
458 
459  settings.m_CurrentViaType = v_type;
460 
461  if( displ_opts->m_ContrastModeDisplay )
462  m_canvas->Refresh();
463  }
464  break;
465 
467  if( GetCurItem() == NULL )
468  break;
469 
471  SetCurItem( Delete_Segment( &dc, (TRACK*) GetCurItem() ) );
472  OnModify();
473  break;
474 
476  if( GetCurItem() == NULL )
477  break;
479  Delete_Track( &dc, (TRACK*) GetCurItem() );
480  SetCurItem( NULL );
481  OnModify();
482  break;
483 
486  Delete_net( &dc, (TRACK*) GetCurItem() );
487  SetCurItem( NULL );
488  OnModify();
489  break;
490 
492  Attribut_Segment( (TRACK*) GetCurItem(), &dc, true );
493  break;
494 
496  Attribut_Segment( (TRACK*) GetCurItem(), &dc, false );
497  break;
498 
500  Attribut_Track( (TRACK*) GetCurItem(), &dc, true );
501  break;
502 
504  Attribut_Track( (TRACK*) GetCurItem(), &dc, false );
505  break;
506 
508  Attribut_net( &dc, ( (TRACK*) GetCurItem() )->GetNetCode(), true );
509  break;
510 
512  Attribut_net( &dc, ( (TRACK*) GetCurItem() )->GetNetCode(), false );
513  break;
514 
516  break;
517 
520 
521  if( GetCurItem() == NULL )
522  break;
523 
524  {
525  SEGZONE* zsegm = (SEGZONE*) GetCurItem();
526  int netcode = zsegm->GetNetCode();
527  Delete_OldZone_Fill( zsegm );
528  SetCurItem( NULL );
529  TestNetConnection( NULL, netcode );
530  OnModify();
531  SetMsgPanel( GetBoard() );
532  }
533  break;
534 
537  SetCurItem( NULL ); // Outlines can have changed
538  break;
539 
541  {
543  duplicateZone( &dc, zone );
544  }
545  break;
546 
549  m_canvas->SetAutoPanRequest( true );
551  break;
552 
555  m_canvas->SetAutoPanRequest( true );
557  break;
558 
560  // Force the main contour selection, to remove the entire zone:
561  ((ZONE_CONTAINER*) GetCurItem())->SetSelectedCorner( 0 );
562  // Fall through
565  {
566  int netcode = ( (ZONE_CONTAINER*) GetCurItem() )->GetNetCode();
568  SetCurItem( NULL );
569  TestNetConnection( NULL, netcode );
570  SetMsgPanel( GetBoard() );
571  }
572  break;
573 
576  SetCurItem( NULL );
577  break;
578 
580  {
582  ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
583  m_canvas->SetAutoPanRequest( true );
584  Start_Move_Zone_Corner( &dc, zone_cont, zone_cont->GetSelectedCorner(), false );
585  }
586  break;
587 
589  {
591  ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
592  m_canvas->SetAutoPanRequest( true );
593  Start_Move_Zone_Drag_Outline_Edge( &dc, zone_cont, zone_cont->GetSelectedCorner() );
594  }
595  break;
596 
598  {
600  ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
601  m_canvas->SetAutoPanRequest( true );
602  Start_Move_Zone_Outlines( &dc, zone_cont );
603  }
604  break;
605 
607  {
609  ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
611 
612  /* add corner between zone_cont->m_CornerSelection
613  * and zone_cont->m_CornerSelection+1
614  * and start move the new corner
615  */
616  zone_cont->Draw( m_canvas, &dc, GR_XOR );
617  zone_cont->Outline()->InsertVertex( zone_cont->GetSelectedCorner(), pos );
618  zone_cont->SetSelectedCorner( zone_cont->GetSelectedCorner() + 1 );
619  zone_cont->Draw( m_canvas, &dc, GR_XOR );
620  m_canvas->SetAutoPanRequest( true );
621  Start_Move_Zone_Corner( &dc, zone_cont, zone_cont->GetSelectedCorner(), true );
622  }
623  break;
624 
628  {
630  ZONE_CONTAINER* zone_cont = (ZONE_CONTAINER*) GetCurItem();
631  End_Move_Zone_Corner_Or_Outlines( &dc, zone_cont );
632  m_canvas->SetAutoPanRequest( false );
633  }
634  break;
635 
638  Fill_All_Zones( this );
639  m_canvas->Refresh();
640  SetMsgPanel( GetBoard() );
641  break;
642 
644  if( ( GetCurItem() )->Type() == PCB_ZONE_AREA_T )
645  {
646  ZONE_CONTAINER* zone_container = (ZONE_CONTAINER*) GetCurItem();
647  zone_container->UnFill();
648  GetBoard()->GetConnectivity()->Update( zone_container );
649  OnModify();
650  SetMsgPanel( GetBoard() );
651  m_canvas->Refresh();
652  }
653 
654  Compile_Ratsnest( &dc, false );
655  SetCurItem( NULL );
656  break;
657 
658  case ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_ALL_ZONES: // Remove all zones :
659  GetBoard()->m_Zone.DeleteAll(); // remove zone segments used to fill zones.
660 
661  for( int ii = 0; ii < GetBoard()->GetAreaCount(); ii++ )
662  {
663  // Remove filled areas in zone
664  ZONE_CONTAINER* zone_container = GetBoard()->GetArea( ii );
665  zone_container->UnFill();
666  GetBoard()->GetConnectivity()->Update( zone_container );
667  }
668 
669  Compile_Ratsnest( &dc, false );
670  SetCurItem( NULL ); // CurItem might be deleted by this command, clear the pointer
671  OnModify();
672  SetMsgPanel( GetBoard() );
673  m_canvas->Refresh();
674  break;
675 
679  SetMsgPanel( GetBoard() );
680  m_canvas->Refresh();
681  break;
682 
685  m_canvas->SetAutoPanRequest( true );
686  break;
687 
690  if( GetCurItem() == NULL )
691  break;
692 
693  // If the current Item is a pad, text module ...: Get its parent
694  if( GetCurItem()->Type() != PCB_MODULE_T )
695  SetCurItem( GetCurItem()->GetParent() );
696 
697  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
698  break;
699 
700  module = (MODULE*) GetCurItem();
701 
702  if( module->IsLocked() )
703  {
704  wxString msg;
705  msg.Printf( _( "Footprint %s found, but it is locked" ),
706  module->GetReference().GetData() );
707  DisplayInfoMessage( this, msg );
708  break;
709  }
710 
711  SendMessageToEESCHEMA( module );
712  SetCrossHairPosition( module->GetPosition() );
715  break;
716 
717  case ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST: // get module by name and move it
719  module = (MODULE*) GetCurItem();
720 
721  if( module == NULL )
722  break;
723 
724  if( module->IsLocked() )
725  {
726  wxString msg = wxString::Format(
727  _( "Footprint %s found, but it is locked" ),
728  module->GetReference().GetData() );
729  DisplayInfoMessage( this, msg );
730  break;
731  }
732 
733  SendMessageToEESCHEMA( module );
735  StartMoveModule( module, &dc, false );
736  break;
737 
740 
741  // If the current Item is a pad, text module ...: Get its parent
742  if( GetCurItem()->Type() != PCB_MODULE_T )
743  SetCurItem( GetCurItem()->GetParent() );
744 
745  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
746  break;
747 
748  module = (MODULE*) GetCurItem();
749 
750  if( module->IsLocked() )
751  {
752  wxString msg;
753  msg.Printf( _( "Footprint %s found, but it is locked" ),
754  module->GetReference().GetData() );
755  DisplayInfoMessage( this, msg );
756  break;
757  }
758 
759  if( Delete_Module( (MODULE*) GetCurItem(), &dc ) )
760  {
761  SetCurItem( NULL );
762  }
763 
764  break;
765 
768 
769  // If the current Item is a pad, text module ...: Get its parent
770  if( GetCurItem()->Type() != PCB_MODULE_T )
771  SetCurItem( GetCurItem()->GetParent() );
772 
773  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
774  break;
775 
776  module = (MODULE*) GetCurItem();
777 
778  if( module->IsLocked() )
779  {
780  wxString msg;
781  msg.Printf( _( "Footprint %s found, but it is locked" ),
782  module->GetReference().GetData() );
783  DisplayInfoMessage( this, msg );
784  break;
785  }
786 
787  // This is a simple rotation, no other editing in progress
788  if( !GetCurItem()->IsMoving() )
789  SaveCopyInUndoList( GetCurItem(), UR_CHANGED, ((MODULE*)GetCurItem())->GetPosition() );
790 
791  Rotate_Module( &dc, (MODULE*) GetCurItem(), m_rotationAngle, true );
792  break;
793 
796 
797  // If the current Item is a pad, text module ...: Get its parent
798  if( GetCurItem()->Type() != PCB_MODULE_T )
799  SetCurItem( GetCurItem()->GetParent() );
800 
801  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
802  break;
803 
804  module = (MODULE*) GetCurItem();
805 
806  if( module->IsLocked() )
807  {
808  wxString msg;
809  msg.Printf( _( "Footprint %s found, but it is locked" ),
810  module->GetReference().GetData() );
811  DisplayInfoMessage( this, msg );
812  break;
813  }
814 
815  // This is a simple rotation, no other editing in progress
816  if( !GetCurItem()->IsMoving() )
817  SaveCopyInUndoList( GetCurItem(), UR_CHANGED, ((MODULE*)GetCurItem())->GetPosition() );
818 
819  Rotate_Module( &dc, (MODULE*) GetCurItem(), -m_rotationAngle, true );
820  break;
821 
824 
825  // If the current Item is a pad, text module ...: Get its parent
826  if( GetCurItem()->Type() != PCB_MODULE_T )
827  SetCurItem( GetCurItem()->GetParent() );
828 
829  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
830  break;
831 
832  module = (MODULE*) GetCurItem();
833 
834  if( module->IsLocked() )
835  {
836  wxString msg;
837  msg.Printf( _( "Footprint %s found, but it is locked" ),
838  module->GetReference().GetData() );
839  DisplayInfoMessage( this, msg );
840  break;
841  }
842 
843  // This is a simple flip, no other editing in progress
844  if( !GetCurItem()->IsMoving() )
845  SaveCopyInUndoList( GetCurItem(), UR_FLIPPED, ((MODULE*)GetCurItem())->GetPosition() );
846 
847  Change_Side_Module( (MODULE*) GetCurItem(), &dc );
848  break;
849 
851  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
852  break;
853 
855  // Warning: the current item can be deleted by exchange module
856  SetCurItem( NULL );
858  break;
859 
861  // If the current Item is a pad, text module ...: Get its parent
862  if( GetCurItem()->Type() != PCB_MODULE_T )
863  SetCurItem( GetCurItem()->GetParent() );
864 
865  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
866  break;
867 
870  break;
871 
873 
874  // If we don't have a current item, there's nothing we can do here
875  if( !GetCurItem() )
876  break;
877 
878  // If the current Item is a pad, text module ...: Get its parent
879  if( GetCurItem()->Type() != PCB_MODULE_T )
880  SetCurItem( GetCurItem()->GetParent() );
881 
882  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
883  break;
884 
885  if( GetCurItem()->GetTimeStamp() == 0 ) // Module Editor needs a non null timestamp
886  {
888  OnModify();
889  }
890 
891  {
893 
895  SetCurItem( NULL ); // the current module could be deleted by
896  }
898  break;
899 
901  module = (MODULE*) GetCurItem()->GetParent();
902 
903  if( !module || module->Type() != PCB_MODULE_T )
904  break;
905 
906  if( module->IsLocked() )
907  {
908  wxString msg;
909  msg.Printf( _( "The parent (%s) of the pad is locked" ),
910  module->GetReference().GetData() );
911  DisplayInfoMessage( this, msg );
912  break;
913  }
914 
916  StartMovePad( (D_PAD*) GetCurItem(), &dc, true );
917  break;
918 
920  module = (MODULE*) GetCurItem()->GetParent();
921 
922  if( !module || module->Type() != PCB_MODULE_T )
923  break;
924 
925  if( module->IsLocked() )
926  {
927  wxString msg;
928  msg.Printf( _( "The parent (%s) of the pad is locked" ),
929  module->GetReference().GetData() );
930  DisplayInfoMessage( this, msg );
931  break;
932  }
933 
935  StartMovePad( (D_PAD*) GetCurItem(), &dc, false );
936  break;
937 
941  break;
942 
945  SaveCopyInUndoList( GetCurItem()->GetParent(), UR_CHANGED );
946  Import_Pad_Settings( (D_PAD*) GetCurItem(), true );
947  break;
948 
952  break;
953 
957  break;
958 
960  SaveCopyInUndoList( GetCurItem()->GetParent(), UR_CHANGED );
961  DeletePad( (D_PAD*) GetCurItem() );
962  SetCurItem( NULL );
964  break;
965 
967  InstallTextModOptionsFrame( static_cast<TEXTE_MODULE*>( GetCurItem() ), &dc );
969  break;
970 
972  ResetTextSize( GetCurItem(), &dc );
973  break;
974 
977  StartMoveTexteModule( static_cast<TEXTE_MODULE*>( GetCurItem() ), &dc );
978  break;
979 
981  RotateTextModule( static_cast<TEXTE_MODULE*>( GetCurItem() ), &dc );
983  break;
984 
986  DeleteTextModule( static_cast<TEXTE_MODULE*>( GetCurItem() ) );
987  SetCurItem( NULL );
989  break;
990 
992  {
994 
995  if( itmp >= 0 )
996  {
997  // if user changed colors and we are in high contrast mode, then redraw
998  // because the PAD_ATTRIB_SMD pads may change color.
999  if( displ_opts->m_ContrastModeDisplay && GetActiveLayer() != itmp )
1000  {
1001  m_canvas->Refresh();
1002  }
1003  SetActiveLayer( itmp );
1004  }
1005 
1007  }
1008  break;
1009 
1012  break;
1013 
1015  {
1017 
1018  if( itmp >= 0 )
1019  SetActiveLayer( itmp );
1020 
1022  }
1023  break;
1024 
1026  {
1028 
1029  if( itmp >= 0 )
1030  SetActiveLayer( itmp );
1031  }
1032  break;
1033 
1037  break;
1038 
1041 
1042  if( displ_opts->m_ContrastModeDisplay )
1043  m_canvas->Refresh( true );
1044  break;
1045 
1049  break;
1050 
1052  Rotate_Texte_Pcb( (TEXTE_PCB*) GetCurItem(), &dc );
1054  break;
1055 
1057  CreateTextePcb( &dc, (TEXTE_PCB*) GetCurItem() );
1059  m_canvas->SetAutoPanRequest( true );
1060  break;
1061 
1063  FlipTextePcb( (TEXTE_PCB*) GetCurItem(), &dc );
1065  break;
1066 
1068  Delete_Texte_Pcb( (TEXTE_PCB*) GetCurItem(), &dc );
1070  break;
1071 
1073  BeginMoveTarget( (PCB_TARGET*) GetCurItem(), &dc );
1075  break;
1076 
1080  break;
1081 
1084  DeleteTarget( (PCB_TARGET*) GetCurItem(), &dc );
1085  SetCurItem( NULL );
1086  break;
1087 
1090  DeleteDimension( (DIMENSION*) GetCurItem(), &dc );
1091  SetCurItem( NULL );
1092  break;
1093 
1097  break;
1098 
1101  break;
1102 
1106  break;
1107 
1109  RemoveStruct( GetCurItem(), &dc );
1111  break;
1112 
1114  if( GetCurItem() && GetCurItem()->Type() == PCB_MARKER_T )
1115  ( (MARKER_PCB*) GetCurItem() )->DisplayMarkerInfo( this );
1116 
1118  break;
1119 
1121  if( GetCurItem()->GetFlags() != 0 )
1122  break;
1123 
1125  SetCurItem( NULL );
1127  m_canvas->Refresh();
1128  break;
1129 
1131 #ifndef USE_WX_OVERLAY
1133 #else
1134  // #1277772 - Draw into dialog converted in refresh request
1136  m_canvas->Refresh();
1137 #endif
1139  break;
1140 
1144  break;
1145 
1148 
1149  if( GetCurItem() && (GetCurItem()->IsNew()) )
1150  {
1151  End_Edge( (DRAWSEGMENT*) GetCurItem(), &dc );
1152  SetCurItem( NULL );
1153  }
1154 
1155  break;
1156 
1159 
1160  if( GetCurItem() && (GetCurItem()->IsNew()) )
1161  {
1162  if( End_Zone( &dc ) )
1163  SetCurItem( NULL );
1164  }
1165 
1166  m_canvas->SetAutoPanRequest( false );
1167  break;
1168 
1171 
1172  if( GetCurItem() && (GetCurItem()->IsNew()) )
1173  {
1174  if( Delete_LastCreatedCorner( &dc ) == 0 ) // No more segment in outline,
1175  SetCurItem( NULL );
1176  }
1177 
1178  break;
1179 
1180 
1184  break;
1185 
1190  break;
1191 
1195  break;
1196 
1199  {
1200  TRACK* track = (TRACK*) GetScreen()->GetCurItem();
1201  wxPoint pos = GetCrossHairPosition();
1202 
1203  track->Draw( m_canvas, &dc, GR_XOR );
1204  PICKED_ITEMS_LIST itemsListPicker;
1205 
1206  TRACK* newtrack = GetBoard()->CreateLockPoint( pos, track, &itemsListPicker );
1207 
1208  SaveCopyInUndoList( itemsListPicker, UR_UNSPECIFIED );
1209  track->Draw( m_canvas, &dc, GR_XOR );
1210  newtrack->Draw( m_canvas, &dc, GR_XOR );
1211 
1212  // compute the new ratsnest, because connectivity could change
1213  TestNetConnection( &dc, track->GetNetCode() );
1214  }
1215  break;
1216 
1218  moveExact();
1219  break;
1220 
1224  break;
1225 
1227  createArray();
1228  break;
1229 
1230  case ID_MENU_PCB_CLEAN:
1231  Clean_Pcb();
1232  break;
1233 
1235  Swap_Layers( event );
1236  break;
1237 
1239  InvokeDialogGrid();
1240  break;
1241 
1243  {
1244  wxConfigBase* cfg = Pgm().CommonSettings();
1245  cfg->Read( wxT( "module_doc_file" ), g_DocModulesFileName );
1246  GetAssociatedDocument( this, g_DocModulesFileName, &Kiface().KifaceSearch() );
1247  }
1248  break;
1249 
1251  ArchiveModulesOnBoard( false );
1252  break;
1253 
1255  ArchiveModulesOnBoard( true );
1256  break;
1257 
1260  m_canvas->Refresh();
1261  break;
1262 
1263  default:
1264  wxString msg;
1265  msg.Printf( wxT( "PCB_EDIT_FRAME::Process_Special_Functions() unknown event id %d" ), id );
1266  DisplayError( this, msg );
1267  break;
1268  }
1269 
1270  m_canvas->CrossHairOn( &dc );
1271  m_canvas->SetIgnoreMouseEvents( false );
1272 }
1273 
1274 
1276 {
1277  if( Item == NULL )
1278  return;
1279 
1280  switch( Item->Type() )
1281  {
1282  case PCB_MODULE_T:
1283  Delete_Module( (MODULE*) Item, DC );
1284  break;
1285 
1286  case PCB_DIMENSION_T:
1287  DeleteDimension( (DIMENSION*) Item, DC );
1288  break;
1289 
1290  case PCB_TARGET_T:
1291  DeleteTarget( (PCB_TARGET*) Item, DC );
1292  break;
1293 
1294  case PCB_LINE_T:
1295  Delete_Segment_Edge( (DRAWSEGMENT*) Item, DC );
1296  break;
1297 
1298  case PCB_TEXT_T:
1299  Delete_Texte_Pcb( (TEXTE_PCB*) Item, DC );
1300  break;
1301 
1302  case PCB_TRACE_T:
1303  Delete_Track( DC, (TRACK*) Item );
1304  break;
1305 
1306  case PCB_VIA_T:
1307  Delete_Segment( DC, (TRACK*) Item );
1308  break;
1309 
1310  case PCB_ZONE_T:
1311  Delete_OldZone_Fill( (SEGZONE*) Item );
1312  break;
1313 
1314  case PCB_ZONE_AREA_T:
1315  {
1316  SetCurItem( NULL );
1317  int netcode = ( (ZONE_CONTAINER*) Item )->GetNetCode();
1318  Delete_Zone_Contour( DC, (ZONE_CONTAINER*) Item );
1319  TestNetConnection( NULL, netcode );
1320  SetMsgPanel( GetBoard() );
1321  }
1322  break;
1323 
1324  case PCB_MARKER_T:
1325  if( Item == GetCurItem() )
1326  SetCurItem( NULL );
1327 
1328  ( (MARKER_PCB*) Item )->Draw( m_canvas, DC, GR_XOR );
1329 
1330  // delete the marker, and free memory. Don't use undo stack.
1331  GetBoard()->Delete( Item );
1332  break;
1333 
1334  case PCB_PAD_T:
1335  case PCB_MODULE_TEXT_T:
1336  case PCB_MODULE_EDGE_T:
1337  break;
1338 
1339  case TYPE_NOT_INIT:
1340  case PCB_T:
1341  default:
1342  {
1343  wxString msg = wxString::Format(
1344  wxT( "Remove: item type %d unknown." ), Item->Type() );
1345  DisplayError( this, msg );
1346  }
1347  break;
1348  }
1349 }
1350 
1351 
1353 {
1354  PCB_LAYER_ID curLayer = GetActiveLayer();
1356 
1357  // Check if the specified layer matches the present layer
1358  if( layer == curLayer )
1359  return;
1360 
1361  // Copper layers cannot be selected unconditionally; how many
1362  // of those layers are currently enabled needs to be checked.
1363  if( IsCopperLayer( layer ) )
1364  {
1365  // If only one copper layer is enabled, the only such layer
1366  // that can be selected to is the "Back" layer (so the
1367  // selection of any other copper layer is disregarded).
1368  if( GetBoard()->GetCopperLayerCount() < 2 )
1369  {
1370  if( layer != B_Cu )
1371  return;
1372  }
1373  // If more than one copper layer is enabled, the "Copper"
1374  // and "Component" layers can be selected, but the total
1375  // number of copper layers determines which internal
1376  // layers are also capable of being selected.
1377  else
1378  {
1379  if( layer != B_Cu && layer != F_Cu && layer >= GetBoard()->GetCopperLayerCount() - 1 )
1380  return;
1381  }
1382 
1383  EDA_ITEM* current = GetScreen()->GetCurItem();
1384 
1385  // See if we are drawing a segment; if so, add a via?
1386  if( GetToolId() == ID_TRACK_BUTT && current )
1387  {
1388  if( current->Type() == PCB_TRACE_T && current->IsNew() )
1389  {
1390  // Want to set the routing layers so that it switches properly -
1391  // see the implementation of Other_Layer_Route - the working
1392  // layer is used to 'start' the via and set the layer masks appropriately.
1393  GetScreen()->m_Route_Layer_TOP = curLayer;
1394  GetScreen()->m_Route_Layer_BOTTOM = layer;
1395 
1396  SetActiveLayer( curLayer );
1397 
1398  if( Other_Layer_Route( (TRACK*) GetScreen()->GetCurItem(), DC ) )
1399  {
1400  if( displ_opts->m_ContrastModeDisplay )
1401  m_canvas->Refresh();
1402  }
1403 
1404  // if the via was allowed by DRC, then the layer swap has already
1405  // been done by Other_Layer_Route(). if via not allowed, then
1406  // return now so assignment to setActiveLayer() below doesn't happen.
1407  return;
1408  }
1409  }
1410  }
1411 
1412  // Is yet more checking required? E.g. when the layer to be selected
1413  // is a non-copper layer, or when switching between a copper layer
1414  // and a non-copper layer, or vice-versa?
1415  // ...
1416 
1417  SetActiveLayer( layer );
1418 
1419  if( displ_opts->m_ContrastModeDisplay )
1420  m_canvas->Refresh();
1421 }
1422 
1423 
1424 void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
1425 {
1426  int id = aEvent.GetId();
1427  int lastToolID = GetToolId();
1428 
1431 
1432  // Stop the current command and deselect the current tool.
1434 
1435  switch( id )
1436  {
1437  case ID_NO_TOOL_SELECTED:
1439  break;
1440 
1441  case ID_ZOOM_SELECTION:
1442  // This tool is located on the main toolbar: switch it on or off on click on it
1443  if( lastToolID != ID_ZOOM_SELECTION )
1444  SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) );
1445  else
1447  break;
1448 
1449  case ID_TRACK_BUTT:
1450  if( g_Drc_On )
1451  SetToolID( id, wxCURSOR_PENCIL, _( "Add tracks" ) );
1452  else
1453  SetToolID( id, wxCURSOR_QUESTION_ARROW, _( "Add tracks" ) );
1454 
1455  Compile_Ratsnest( &dc, true );
1456  break;
1457 
1458  case ID_PCB_MODULE_BUTT:
1459  SetToolID( id, wxCURSOR_PENCIL, _( "Add footprint" ) );
1460  break;
1461 
1462  case ID_PCB_ZONES_BUTT:
1463  SetToolID( id, wxCURSOR_PENCIL, _( "Add zones" ) );
1464 
1465  if( displ_opts->m_DisplayZonesMode != 0 )
1466  DisplayInfoMessage( this, _( "Warning: zone display is OFF!!!" ) );
1467 
1468  if( !GetBoard()->IsHighLightNetON() && (GetBoard()->GetHighLightNetCode() > 0 ) )
1469  HighLight( &dc );
1470 
1471  break;
1472 
1474  SetToolID( id, wxCURSOR_PENCIL, _( "Add keepout" ) );
1475  break;
1476 
1477  case ID_PCB_MIRE_BUTT:
1478  SetToolID( id, wxCURSOR_PENCIL, _( "Add layer alignment target" ) );
1479  break;
1480 
1482  SetToolID( id, wxCURSOR_PENCIL, _( "Adjust zero" ) );
1483  break;
1484 
1486  SetToolID( id, wxCURSOR_PENCIL, _( "Adjust grid origin" ) );
1487  break;
1488 
1489  case ID_PCB_ADD_LINE_BUTT:
1490  SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic line" ) );
1491  break;
1492 
1493  case ID_PCB_ARC_BUTT:
1494  SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic arc" ) );
1495  break;
1496 
1497  case ID_PCB_CIRCLE_BUTT:
1498  SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic circle" ) );
1499  break;
1500 
1501  case ID_PCB_ADD_TEXT_BUTT:
1502  SetToolID( id, wxCURSOR_PENCIL, _( "Add text" ) );
1503  break;
1504 
1505  case ID_COMPONENT_BUTT:
1506  SetToolID( id, wxCURSOR_HAND, _( "Add footprint" ) );
1507  break;
1508 
1509  case ID_PCB_DIMENSION_BUTT:
1510  SetToolID( id, wxCURSOR_PENCIL, _( "Add dimension" ) );
1511  break;
1512 
1514  SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) );
1515  break;
1516 
1517  case ID_PCB_HIGHLIGHT_BUTT:
1518  SetToolID( id, wxCURSOR_HAND, _( "Highlight net" ) );
1519  break;
1520 
1522  SetToolID( id, wxCURSOR_HAND, _( "Select rats nest" ) );
1523 
1524  Compile_Ratsnest( &dc, true );
1525 
1526  break;
1527 
1528  // collect GAL-only tools here
1530  SetToolID( id, wxCURSOR_DEFAULT, _( "Unsupported tool in this canvas" ) );
1531  break;
1532  }
1533 }
1534 
1535 
1537 {
1538  MOVE_PARAMETERS params;
1539 
1540  DIALOG_MOVE_EXACT dialog( this, params );
1541  int ret = dialog.ShowModal();
1542 
1543  if( ret == wxID_OK )
1544  {
1545  if( BOARD_ITEM* item = GetScreen()->GetCurItem() )
1546  {
1547  // When a pad is modified, the full footprint is saved
1548  BOARD_ITEM* itemToSave = item;
1549 
1550  if( item->Type() == PCB_PAD_T )
1551  itemToSave = item->GetParent();
1552 
1553  // Could be moved or rotated
1554  SaveCopyInUndoList( itemToSave, UR_CHANGED );
1555 
1556  // begin with the default anchor
1557  wxPoint anchorPoint = item->GetPosition();
1558 
1559  if( item->Type() == PCB_MODULE_T )
1560  {
1561  // cast to module to allow access to the pads
1562  MODULE* mod = static_cast<MODULE*>( item );
1563 
1564  switch( params.anchor )
1565  {
1566  case ANCHOR_TOP_LEFT_PAD:
1567  if( mod->GetTopLeftPad()->GetAttribute() == PAD_ATTRIB_SMD )
1568  {
1569  anchorPoint = mod->GetTopLeftPad()->GetBoundingBox().GetPosition();
1570  }
1571  else
1572  {
1573  anchorPoint = mod->GetTopLeftPad()->GetPosition();
1574  }
1575  break;
1577  anchorPoint = mod->GetFootprintRect().GetCenter();
1578  break;
1579  case ANCHOR_FROM_LIBRARY:
1580  ; // nothing to do
1581  }
1582  }
1583 
1584  wxPoint origin;
1585 
1586  switch( params.origin )
1587  {
1589  origin = GetScreen()->m_O_Curseur;
1590  break;
1591 
1593  origin = GetGridOrigin();
1594  break;
1595 
1597  origin = GetAuxOrigin();
1598  break;
1599 
1601  origin = wxPoint( 0, 0 );
1602  break;
1603 
1605  // relative movement means that only the translation values should be used:
1606  // -> set origin and anchor to zero
1607  origin = wxPoint( 0, 0 );
1608  anchorPoint = wxPoint( 0, 0 );
1609  break;
1610  }
1611 
1612  wxPoint finalMoveVector = params.translation + origin - anchorPoint;
1613 
1614  item->Move( finalMoveVector );
1615  item->Rotate( item->GetPosition(), params.rotation );
1616  m_canvas->Refresh();
1617  }
1618  }
1619 
1621 }
1622 
1623 
1624 void PCB_EDIT_FRAME::duplicateItems( bool aIncrement )
1625 {
1626  BOARD_ITEM* item = GetScreen()->GetCurItem();
1627 
1628  if( !item )
1629  return;
1630 
1631  // In the board editor, the pads or fp texts can be edited
1632  // but cannot be duplicated (only the fp editor can do that).
1633  // only the footprint can be duplicated
1634  if( item->Type() == PCB_PAD_T || item->Type() == PCB_MODULE_TEXT_T )
1635  item = static_cast<MODULE*>( item )->GetParent();
1636 
1637  PCB_BASE_EDIT_FRAME::duplicateItem( item, aIncrement );
1638 }
1639 
1640 
1641 void PCB_BASE_EDIT_FRAME::duplicateItem( BOARD_ITEM* aItem, bool aIncrement )
1642 {
1643  if( !aItem )
1644  return;
1645 
1646  // The easiest way to handle a duplicate item command
1647  // is to simulate a block copy command, which gives us the undo management
1648  // for free
1649  if( GetScreen()->m_BlockLocate.GetState() == STATE_NO_BLOCK )
1650  {
1652 
1654 
1655  wxPoint crossHairPos = GetCrossHairPosition();
1656 
1657  const BLOCK_COMMAND_T blockType = aIncrement ? BLOCK_COPY_AND_INCREMENT : BLOCK_COPY;
1658 
1659  if( !HandleBlockBegin( &dc, blockType, crossHairPos ) )
1660  return;
1661 
1662  // Add the item to the block copy pick list:
1664  ITEM_PICKER picker( NULL, UR_UNSPECIFIED );
1665 
1666  picker.SetItem ( aItem );
1667  itemsList.PushItem( picker );
1668 
1669  // Set 2 coordinates updated by the mouse, because our simulation
1670  // does not use the mouse to call HandleBlockEnd()
1671  GetScreen()->m_BlockLocate.SetLastCursorPosition( crossHairPos );
1672  GetScreen()->m_BlockLocate.SetEnd( crossHairPos );
1673  HandleBlockEnd( &dc );
1674  }
1675 }
1676 
1677 
1679 {
1680 public:
1681 
1683  ARRAY_CREATOR( editFrame ),
1684  m_item( m_parent.GetScreen()->GetCurItem() )
1685  {}
1686 
1687 private:
1688 
1689  int getNumberOfItemsToArray() const override
1690  {
1691  // only handle single items
1692  return (m_item != NULL) ? 1 : 0;
1693  }
1694 
1695  BOARD_ITEM* getNthItemToArray( int n ) const override
1696  {
1697  wxASSERT_MSG( n == 0, "Legacy array tool can only handle a single item" );
1698  return m_item;
1699  }
1700 
1701  BOARD* getBoard() const override
1702  {
1703  return m_parent.GetBoard();
1704  }
1705 
1706  MODULE* getModule() const override
1707  {
1708  return dynamic_cast<MODULE*>( m_item->GetParent() );
1709  }
1710 
1711  wxPoint getRotationCentre() const override
1712  {
1713  return m_item->GetCenter();
1714  }
1715 
1716  void finalise() override
1717  {
1718  m_parent.GetCanvas()->Refresh();
1719  }
1720 
1721  BOARD_ITEM* m_item; // only have the one
1722 };
1723 
1724 
1726 {
1727  LEGACY_ARRAY_CREATOR array_creator( *this );
1728 
1729  array_creator.Invoke();
1730 }
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:639
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:198
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:179
virtual void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
Definition: pcbframe.cpp:993
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
bool Other_Layer_Route(TRACK *track, wxDC *DC)
Function Other_Layer_Route operates in one of two ways.
bool g_Drc_On
Definition: pcbnew.cpp:70
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:97
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:363
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:238
TEXTE_PCB class definition.
int getNumberOfItemsToArray() const override
Definition: edit.cpp:1689
bool g_Alternate_Track_Posture
Definition: pcbnew.cpp:73
bool End_Zone(wxDC *DC)
Function End_Zone terminates (if no DRC error ) the zone edge creation process.
void InstallTextPCBOptionsFrame(TEXTE_PCB *TextPCB, wxDC *DC)
Routine for main window class to launch text properties dialog.
int InstallExchangeModuleFrame(MODULE *ExchangeModuleModule)
Definition: pcbframe.cpp:1186
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
Definition: draw_panel.cpp:326
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:216
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
int Fill_All_Zones(wxWindow *aActiveWindow, bool aVerbose=true)
Function Fill_All_Zones Fill all zones on the board The old fillings are removed. ...
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:299
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:1711
This file is part of the common library.
void FlipTextePcb(TEXTE_PCB *aTextePcb, wxDC *aDC)
Class BOARD to handle a board.
const wxPoint & GetPosition() const override
Definition: class_module.h:155
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:662
void BeginMoveDimensionText(DIMENSION *aItem, wxDC *DC)
Definition: dimension.cpp:381
void ShowDimensionPropertyDialog(DIMENSION *aDimension, wxDC *aDC)
Definition: dimension.cpp:353
PCB_BASE_FRAME & m_parent
Definition: array_creator.h:61
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:59
int GetCopperLayerCount() const
Function GetCopperLayerCount.
const wxPoint & GetGridOrigin() const override
Function GetGridOrigin returns the absolute coordinates of the origin of the snap grid...
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:114
void SetCurItem(BOARD_ITEM *aItem, bool aDisplayInfo=true)
Function SetCurItem sets the currently selected item and displays it in the MsgPanel.
time_t GetNewTimeStamp()
Definition: common.cpp:166
void Start_Move_Zone_Outlines(wxDC *DC, ZONE_CONTAINER *zone_container)
Function Start_Move_Zone_Outlines Initialize parameters to move an existing zone outlines.
SHAPE_POLY_SET * Outline()
Definition: class_zone.h:247
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:104
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:1424
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:102
void duplicateItem(BOARD_ITEM *aItem, bool aIncrement)
Function duplicateItem Duplicate the specified item This function is shared between pcbnew and modedi...
Definition: edit.cpp:1641
void RotateTextModule(TEXTE_MODULE *Text, wxDC *DC)
Definition: edtxtmod.cpp:108
DRC * m_drc
the DRC controller, see drc.cpp
Definition: wxPcbStruct.h:96
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:49
void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
Definition: draw_panel.cpp:348
int GetState(int type) const
Definition: base_struct.h:237
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:806
void finalise() override
Definition: edit.cpp:1716
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:1275
bool End_Route(TRACK *aTrack, wxDC *aDC)
Function End_Route Terminates a track currently being created.
Definition: editrack.cpp:411
wxPoint m_O_Curseur
Relative Screen cursor coordinate (on grid) in user units.
BOARD_ITEM * getNthItemToArray(int n) const override
Definition: edit.cpp:1695
void Start_Move_DrawItem(DRAWSEGMENT *drawitem, wxDC *DC)
Definition: editedge.cpp:56
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:106
void CallEndMouseCapture(wxDC *aDC)
Function CallEndMouseCapture calls the end mouse capture callback.
const wxPoint & GetAuxOrigin() const override
Function GetAuxOrigin returns the origin of the axis used for plotting and various exports...
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
Class DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS.
void SetTimeStamp(time_t aNewTimeStamp)
Definition: base_struct.h:203
Functions relatives to tracks, vias and segments used to fill zones.
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:107
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:1536
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:823
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:101
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
PCB_LAYER_ID
A quick note on layer IDs:
void StartMoveTextePcb(TEXTE_PCB *aTextePcb, wxDC *aDC, bool aErase=true)
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, KIWAY_PLAYER *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:302
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().
TEXTE_PCB * CreateTextePcb(wxDC *aDC, TEXTE_PCB *aText=NULL)
void InstallTextModOptionsFrame(TEXTE_MODULE *TextMod, wxDC *DC)
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:773
bool IsMouseCaptured() const
BOARD_ITEM * m_item
Definition: edit.cpp:1721
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)
const wxPoint & GetPosition() const override
Definition: class_pad.h:170
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 Delete_OldZone_Fill(SEGZONE *aZone, time_t aTimestamp=0)
Function Delete_OldZone_Fill (obsolete) Used for compatibility with old boards Remove the zone fillin...
void 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.
bool m_ContrastModeDisplay
Definition: pcbstruct.h:85
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:154
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:1725
void Start_DragTrackSegmentAndKeepSlope(TRACK *track, wxDC *DC)
int m_DisplayZonesMode
Definition: pcbstruct.h:77
wxString g_DocModulesFileName
Definition: pcbnew.cpp:90
class SEGZONE, a segment used to fill a zone area (segment on a copper layer)
Definition: typeinfo.h:109
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:1025
void SetAutoPanRequest(bool aEnable)
Class PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
int Fill_Zone(ZONE_CONTAINER *aZone)
Function Fill_Zone Calculate the zone filling for the outline zone_container The zone outline is a fr...
void SaveCopyInUndoList(BOARD_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, const wxPoint &aTransformPoint=wxPoint(0, 0)) override
Function SaveCopyInUndoList Creates a new entry in undo list of commands.
Definition: undo_redo.cpp:172
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:253
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:112
bool IsLocked() const override
Function IsLocked.
Definition: class_module.h:236
void Add_Similar_Zone(wxDC *DC, ZONE_CONTAINER *zone_container)
Function Add_Similar_Zone Add a zone to a given zone outline.
void SetSelectedCorner(int aCorner)
Definition: class_zone.h:221
D_PAD * GetTopLeftPad()
const wxPoint & GetPosition() const
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:113
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:57
Class DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
Definition: pcbstruct.h:62
virtual bool HandleBlockEnd(wxDC *DC)
Function HandleBlockEnd( ) Handle the "end" of a block command, i.e.
Definition: draw_frame.cpp:663
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:105
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:560
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:92
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...
void DisplayInfoMessage(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayInfoMessage displays an informational message box with aMessage.
Definition: confirm.cpp:89
BOARD * getBoard() const override
Definition: edit.cpp:1701
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:260
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:111
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:58
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:996
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:65
void duplicateZone(wxDC *aDC, ZONE_CONTAINER *aZone)
Function duplicateZone duplicates the given zone.
void ArchiveModulesOnBoard(bool aStoreInNewLib)
Function ArchiveModulesOnBoard Save modules in a library:
Definition: librairi.cpp:568
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:419
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:419
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:151
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:212
virtual void Delete(BOARD_ITEM *aItem)
Removes an item from the containter and deletes it.
void InsertVertex(int aGlobalIndex, VECTOR2I aNewVertex)
Function InsertVertex Adds a vertex in the globally indexed position aGlobalIndex.
void Delete_Zone_Contour(wxDC *DC, ZONE_CONTAINER *zone_container)
Function Delete_Zone Remove the zone which include the segment aZone, or the zone which have the give...
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:108
bool IsMicroViaAcceptable(void)
Function IsMicroViaAcceptable return true if a microvia can be placed on the board.
Definition: pcbframe.cpp:861
void InstallPadOptionsFrame(D_PAD *pad)
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:238
void SelectCopperLayerPair()
Definition: sel_layer.cpp:285
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...
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:103
void SetLastCursorPosition(const wxPoint &aPosition)
Function SetLastCursorPosition sets the last cursor position to aPosition.
int GetDefaultCursor() const
Function GetDefaultCursor.
BOARD_ITEM * GetCurItem()
void SwitchLayer(wxDC *DC, PCB_LAYER_ID layer) override
Definition: edit.cpp:1352
void duplicateItems(bool aIncrement) override
Function duplicateItems Duplicate selected item if possible and start a move.
Definition: edit.cpp:1624
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:69
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
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:220
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:882
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:767
int m_lastDrawToolId
Tool ID of previously active draw tool bar button.
Definition: draw_frame.h:99
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:181
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:262
LEGACY_ARRAY_CREATOR(PCB_BASE_EDIT_FRAME &editFrame)
Definition: edit.cpp:1682
void SetCommand(BLOCK_COMMAND_T aCommand)
void End_Edge(DRAWSEGMENT *Segment, wxDC *DC)
Definition: editedge.cpp:308
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
MODULE * getModule() const override
Definition: edit.cpp:1706
const wxPoint GetCenter() const