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) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
8  * Copyright (C) 2017 KiCad Developers, see CHANGELOG.TXT for contributors.
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, you may find one here:
22  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
23  * or you may search the http://www.gnu.org website for the version 2 license,
24  * or you may write to the Free Software Foundation, Inc.,
25  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26  */
27 
33 #include <fctsys.h>
34 #include <pgm_base.h>
35 #include <kiface_i.h>
36 #include <class_drawpanel.h>
37 #include <confirm.h>
38 #include <eda_doc.h>
39 #include <gestfich.h>
40 #include <kicad_device_context.h>
41 #include <wxPcbStruct.h>
42 
43 #include <pcbnew_id.h>
44 #include <pcbnew.h>
45 #include <module_editor_frame.h>
46 
47 #include <class_board.h>
48 #include <class_module.h>
49 #include <class_track.h>
50 #include <class_zone.h>
51 #include <class_pcb_text.h>
52 #include <modview_frame.h>
54 #include <dialog_drc.h>
56 #include <invoke_pcb_dialog.h>
57 #include <array_creator.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  TestNetConnection( NULL, zone_container->GetNetCode() );
649  OnModify();
650  SetMsgPanel( GetBoard() );
651  m_canvas->Refresh();
652  }
653  SetCurItem( NULL );
654  break;
655 
656  case ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_ALL_ZONES: // Remove all zones :
657  GetBoard()->m_Zone.DeleteAll(); // remove zone segments used to fill zones.
658 
659  for( int ii = 0; ii < GetBoard()->GetAreaCount(); ii++ )
660  {
661  // Remove filled areas in zone
662  ZONE_CONTAINER* zone_container = GetBoard()->GetArea( ii );
663  zone_container->UnFill();
664  }
665 
666  SetCurItem( NULL ); // CurItem might be deleted by this command, clear the pointer
667  TestConnections();
668  TestForActiveLinksInRatsnest( 0 ); // Recalculate the active ratsnest, i.e. the unconnected links
669  OnModify();
670  SetMsgPanel( GetBoard() );
671  m_canvas->Refresh();
672  break;
673 
677  TestNetConnection( NULL, ( (ZONE_CONTAINER*) GetCurItem() )->GetNetCode() );
678  SetMsgPanel( GetBoard() );
679  m_canvas->Refresh();
680  break;
681 
684  m_canvas->SetAutoPanRequest( true );
685  break;
686 
689  if( GetCurItem() == NULL )
690  break;
691 
692  // If the current Item is a pad, text module ...: Get its parent
693  if( GetCurItem()->Type() != PCB_MODULE_T )
694  SetCurItem( GetCurItem()->GetParent() );
695 
696  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
697  break;
698 
699  module = (MODULE*) GetCurItem();
700 
701  if( module->IsLocked() )
702  {
703  wxString msg;
704  msg.Printf( _( "Footprint %s found, but it is locked" ),
705  module->GetReference().GetData() );
706  DisplayInfoMessage( this, msg );
707  break;
708  }
709 
710  SendMessageToEESCHEMA( module );
711  SetCrossHairPosition( module->GetPosition() );
714  break;
715 
716  case ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST: // get module by name and move it
718  module = (MODULE*) GetCurItem();
719 
720  if( module == NULL )
721  break;
722 
723  if( module->IsLocked() )
724  {
725  wxString msg = wxString::Format(
726  _( "Footprint %s found, but it is locked" ),
727  module->GetReference().GetData() );
728  DisplayInfoMessage( this, msg );
729  break;
730  }
731 
732  SendMessageToEESCHEMA( module );
734  StartMoveModule( module, &dc, false );
735  break;
736 
739 
740  // If the current Item is a pad, text module ...: Get its parent
741  if( GetCurItem()->Type() != PCB_MODULE_T )
742  SetCurItem( GetCurItem()->GetParent() );
743 
744  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
745  break;
746 
747  module = (MODULE*) GetCurItem();
748 
749  if( module->IsLocked() )
750  {
751  wxString msg;
752  msg.Printf( _( "Footprint %s found, but it is locked" ),
753  module->GetReference().GetData() );
754  DisplayInfoMessage( this, msg );
755  break;
756  }
757 
758  if( Delete_Module( (MODULE*) GetCurItem(), &dc ) )
759  {
760  SetCurItem( NULL );
761  }
762 
763  break;
764 
767 
768  // If the current Item is a pad, text module ...: Get its parent
769  if( GetCurItem()->Type() != PCB_MODULE_T )
770  SetCurItem( GetCurItem()->GetParent() );
771 
772  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
773  break;
774 
775  module = (MODULE*) GetCurItem();
776 
777  if( module->IsLocked() )
778  {
779  wxString msg;
780  msg.Printf( _( "Footprint %s found, but it is locked" ),
781  module->GetReference().GetData() );
782  DisplayInfoMessage( this, msg );
783  break;
784  }
785 
786  // This is a simple rotation, no other editing in progress
787  if( !GetCurItem()->IsMoving() )
788  SaveCopyInUndoList( GetCurItem(), UR_CHANGED, ((MODULE*)GetCurItem())->GetPosition() );
789 
790  Rotate_Module( &dc, (MODULE*) GetCurItem(), m_rotationAngle, true );
791  break;
792 
795 
796  // If the current Item is a pad, text module ...: Get its parent
797  if( GetCurItem()->Type() != PCB_MODULE_T )
798  SetCurItem( GetCurItem()->GetParent() );
799 
800  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
801  break;
802 
803  module = (MODULE*) GetCurItem();
804 
805  if( module->IsLocked() )
806  {
807  wxString msg;
808  msg.Printf( _( "Footprint %s found, but it is locked" ),
809  module->GetReference().GetData() );
810  DisplayInfoMessage( this, msg );
811  break;
812  }
813 
814  // This is a simple rotation, no other editing in progress
815  if( !GetCurItem()->IsMoving() )
816  SaveCopyInUndoList( GetCurItem(), UR_CHANGED, ((MODULE*)GetCurItem())->GetPosition() );
817 
818  Rotate_Module( &dc, (MODULE*) GetCurItem(), -m_rotationAngle, true );
819  break;
820 
823 
824  // If the current Item is a pad, text module ...: Get its parent
825  if( GetCurItem()->Type() != PCB_MODULE_T )
826  SetCurItem( GetCurItem()->GetParent() );
827 
828  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
829  break;
830 
831  module = (MODULE*) GetCurItem();
832 
833  if( module->IsLocked() )
834  {
835  wxString msg;
836  msg.Printf( _( "Footprint %s found, but it is locked" ),
837  module->GetReference().GetData() );
838  DisplayInfoMessage( this, msg );
839  break;
840  }
841 
842  // This is a simple flip, no other editing in progress
843  if( !GetCurItem()->IsMoving() )
844  SaveCopyInUndoList( GetCurItem(), UR_FLIPPED, ((MODULE*)GetCurItem())->GetPosition() );
845 
846  Change_Side_Module( (MODULE*) GetCurItem(), &dc );
847  break;
848 
850  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
851  break;
852 
854  // Warning: the current item can be deleted by exchange module
855  SetCurItem( NULL );
857  break;
858 
860  // If the current Item is a pad, text module ...: Get its parent
861  if( GetCurItem()->Type() != PCB_MODULE_T )
862  SetCurItem( GetCurItem()->GetParent() );
863 
864  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
865  break;
866 
869  break;
870 
872 
873  // If we don't have a current item, there's nothing we can do here
874  if( !GetCurItem() )
875  break;
876 
877  // If the current Item is a pad, text module ...: Get its parent
878  if( GetCurItem()->Type() != PCB_MODULE_T )
879  SetCurItem( GetCurItem()->GetParent() );
880 
881  if( !GetCurItem() || GetCurItem()->Type() != PCB_MODULE_T )
882  break;
883 
884  if( GetCurItem()->GetTimeStamp() == 0 ) // Module Editor needs a non null timestamp
885  {
887  OnModify();
888  }
889 
890  {
892 
894  SetCurItem( NULL ); // the current module could be deleted by
895  }
897  break;
898 
900  module = (MODULE*) GetCurItem()->GetParent();
901 
902  if( !module || module->Type() != PCB_MODULE_T )
903  break;
904 
905  if( module->IsLocked() )
906  {
907  wxString msg;
908  msg.Printf( _( "The parent (%s) of the pad is locked" ),
909  module->GetReference().GetData() );
910  DisplayInfoMessage( this, msg );
911  break;
912  }
913 
915  StartMovePad( (D_PAD*) GetCurItem(), &dc, true );
916  break;
917 
919  module = (MODULE*) GetCurItem()->GetParent();
920 
921  if( !module || module->Type() != PCB_MODULE_T )
922  break;
923 
924  if( module->IsLocked() )
925  {
926  wxString msg;
927  msg.Printf( _( "The parent (%s) of the pad is locked" ),
928  module->GetReference().GetData() );
929  DisplayInfoMessage( this, msg );
930  break;
931  }
932 
934  StartMovePad( (D_PAD*) GetCurItem(), &dc, false );
935  break;
936 
940  break;
941 
944  SaveCopyInUndoList( GetCurItem()->GetParent(), UR_CHANGED );
945  Import_Pad_Settings( (D_PAD*) GetCurItem(), true );
946  break;
947 
951  break;
952 
956  break;
957 
959  SaveCopyInUndoList( GetCurItem()->GetParent(), UR_CHANGED );
960  DeletePad( (D_PAD*) GetCurItem() );
961  SetCurItem( NULL );
963  break;
964 
966  InstallTextModOptionsFrame( static_cast<TEXTE_MODULE*>( GetCurItem() ), &dc );
968  break;
969 
971  ResetTextSize( GetCurItem(), &dc );
972  break;
973 
976  StartMoveTexteModule( static_cast<TEXTE_MODULE*>( GetCurItem() ), &dc );
977  break;
978 
980  RotateTextModule( static_cast<TEXTE_MODULE*>( GetCurItem() ), &dc );
982  break;
983 
985  DeleteTextModule( static_cast<TEXTE_MODULE*>( GetCurItem() ) );
986  SetCurItem( NULL );
988  break;
989 
991  {
993 
994  if( itmp >= 0 )
995  {
996  // if user changed colors and we are in high contrast mode, then redraw
997  // because the PAD_ATTRIB_SMD pads may change color.
998  if( displ_opts->m_ContrastModeDisplay && GetActiveLayer() != itmp )
999  {
1000  m_canvas->Refresh();
1001  }
1002  SetActiveLayer( itmp );
1003  }
1004 
1006  }
1007  break;
1008 
1011  break;
1012 
1014  {
1016 
1017  if( itmp >= 0 )
1018  SetActiveLayer( itmp );
1019 
1021  }
1022  break;
1023 
1025  {
1027 
1028  if( itmp >= 0 )
1029  SetActiveLayer( itmp );
1030  }
1031  break;
1032 
1036  break;
1037 
1040 
1041  if( displ_opts->m_ContrastModeDisplay )
1042  m_canvas->Refresh( true );
1043  break;
1044 
1048  break;
1049 
1051  Rotate_Texte_Pcb( (TEXTE_PCB*) GetCurItem(), &dc );
1053  break;
1054 
1056  CreateTextePcb( &dc, (TEXTE_PCB*) GetCurItem() );
1058  m_canvas->SetAutoPanRequest( true );
1059  break;
1060 
1062  FlipTextePcb( (TEXTE_PCB*) GetCurItem(), &dc );
1064  break;
1065 
1067  Delete_Texte_Pcb( (TEXTE_PCB*) GetCurItem(), &dc );
1069  break;
1070 
1072  BeginMoveTarget( (PCB_TARGET*) GetCurItem(), &dc );
1074  break;
1075 
1079  break;
1080 
1083  DeleteTarget( (PCB_TARGET*) GetCurItem(), &dc );
1084  SetCurItem( NULL );
1085  break;
1086 
1089  DeleteDimension( (DIMENSION*) GetCurItem(), &dc );
1090  SetCurItem( NULL );
1091  break;
1092 
1096  break;
1097 
1100  break;
1101 
1105  break;
1106 
1108  RemoveStruct( GetCurItem(), &dc );
1110  break;
1111 
1113  if( GetCurItem() && GetCurItem()->Type() == PCB_MARKER_T )
1114  ( (MARKER_PCB*) GetCurItem() )->DisplayMarkerInfo( this );
1115 
1117  break;
1118 
1120  if( GetCurItem()->GetFlags() != 0 )
1121  break;
1122 
1124  SetCurItem( NULL );
1126  m_canvas->Refresh();
1127  break;
1128 
1130 #ifndef USE_WX_OVERLAY
1132 #else
1133  // #1277772 - Draw into dialog converted in refresh request
1135  m_canvas->Refresh();
1136 #endif
1138  break;
1139 
1143  break;
1144 
1147 
1148  if( GetCurItem() && (GetCurItem()->IsNew()) )
1149  {
1150  End_Edge( (DRAWSEGMENT*) GetCurItem(), &dc );
1151  SetCurItem( NULL );
1152  }
1153 
1154  break;
1155 
1158 
1159  if( GetCurItem() && (GetCurItem()->IsNew()) )
1160  {
1161  if( End_Zone( &dc ) )
1162  SetCurItem( NULL );
1163  }
1164 
1165  m_canvas->SetAutoPanRequest( false );
1166  break;
1167 
1170 
1171  if( GetCurItem() && (GetCurItem()->IsNew()) )
1172  {
1173  if( Delete_LastCreatedCorner( &dc ) == 0 ) // No more segment in outline,
1174  SetCurItem( NULL );
1175  }
1176 
1177  break;
1178 
1179 
1183  break;
1184 
1189  break;
1190 
1194  break;
1195 
1198  {
1199  TRACK* track = (TRACK*) GetScreen()->GetCurItem();
1200  wxPoint pos = GetCrossHairPosition();
1201 
1202  track->Draw( m_canvas, &dc, GR_XOR );
1203  PICKED_ITEMS_LIST itemsListPicker;
1204 
1205  TRACK* newtrack = GetBoard()->CreateLockPoint( pos, track, &itemsListPicker );
1206 
1207  SaveCopyInUndoList( itemsListPicker, UR_UNSPECIFIED );
1208  track->Draw( m_canvas, &dc, GR_XOR );
1209  newtrack->Draw( m_canvas, &dc, GR_XOR );
1210 
1211  // compute the new ratsnest, because connectivity could change
1212  TestNetConnection( &dc, track->GetNetCode() );
1213  }
1214  break;
1215 
1217  moveExact();
1218  break;
1219 
1223  break;
1224 
1226  createArray();
1227  break;
1228 
1229  case ID_MENU_PCB_CLEAN:
1230  Clean_Pcb();
1231  break;
1232 
1234  Swap_Layers( event );
1235  break;
1236 
1238  InvokeDialogGrid();
1239  break;
1240 
1242  {
1243  wxConfigBase* cfg = Pgm().CommonSettings();
1244  cfg->Read( wxT( "module_doc_file" ), g_DocModulesFileName );
1245  GetAssociatedDocument( this, g_DocModulesFileName, &Kiface().KifaceSearch() );
1246  }
1247  break;
1248 
1250  ArchiveModulesOnBoard( false );
1251  break;
1252 
1254  ArchiveModulesOnBoard( true );
1255  break;
1256 
1259  m_canvas->Refresh();
1260  break;
1261 
1262  default:
1263  wxString msg;
1264  msg.Printf( wxT( "PCB_EDIT_FRAME::Process_Special_Functions() unknown event id %d" ), id );
1265  DisplayError( this, msg );
1266  break;
1267  }
1268 
1269  m_canvas->CrossHairOn( &dc );
1270  m_canvas->SetIgnoreMouseEvents( false );
1271 }
1272 
1273 
1275 {
1276  if( Item == NULL )
1277  return;
1278 
1279  switch( Item->Type() )
1280  {
1281  case PCB_MODULE_T:
1282  Delete_Module( (MODULE*) Item, DC );
1283  break;
1284 
1285  case PCB_DIMENSION_T:
1286  DeleteDimension( (DIMENSION*) Item, DC );
1287  break;
1288 
1289  case PCB_TARGET_T:
1290  DeleteTarget( (PCB_TARGET*) Item, DC );
1291  break;
1292 
1293  case PCB_LINE_T:
1294  Delete_Segment_Edge( (DRAWSEGMENT*) Item, DC );
1295  break;
1296 
1297  case PCB_TEXT_T:
1298  Delete_Texte_Pcb( (TEXTE_PCB*) Item, DC );
1299  break;
1300 
1301  case PCB_TRACE_T:
1302  Delete_Track( DC, (TRACK*) Item );
1303  break;
1304 
1305  case PCB_VIA_T:
1306  Delete_Segment( DC, (TRACK*) Item );
1307  break;
1308 
1309  case PCB_ZONE_T:
1310  Delete_OldZone_Fill( (SEGZONE*) Item );
1311  break;
1312 
1313  case PCB_ZONE_AREA_T:
1314  {
1315  SetCurItem( NULL );
1316  int netcode = ( (ZONE_CONTAINER*) Item )->GetNetCode();
1317  Delete_Zone_Contour( DC, (ZONE_CONTAINER*) Item );
1318  TestNetConnection( NULL, netcode );
1319  SetMsgPanel( GetBoard() );
1320  }
1321  break;
1322 
1323  case PCB_MARKER_T:
1324  if( Item == GetCurItem() )
1325  SetCurItem( NULL );
1326 
1327  ( (MARKER_PCB*) Item )->Draw( m_canvas, DC, GR_XOR );
1328 
1329  // delete the marker, and free memory. Don't use undo stack.
1330  GetBoard()->Delete( Item );
1331  break;
1332 
1333  case PCB_PAD_T:
1334  case PCB_MODULE_TEXT_T:
1335  case PCB_MODULE_EDGE_T:
1336  break;
1337 
1338  case TYPE_NOT_INIT:
1339  case PCB_T:
1340  default:
1341  {
1342  wxString msg = wxString::Format(
1343  wxT( "Remove: item type %d unknown." ), Item->Type() );
1344  DisplayError( this, msg );
1345  }
1346  break;
1347  }
1348 }
1349 
1350 
1352 {
1353  PCB_LAYER_ID curLayer = GetActiveLayer();
1355 
1356  // Check if the specified layer matches the present layer
1357  if( layer == curLayer )
1358  return;
1359 
1360  // Copper layers cannot be selected unconditionally; how many
1361  // of those layers are currently enabled needs to be checked.
1362  if( IsCopperLayer( layer ) )
1363  {
1364  // If only one copper layer is enabled, the only such layer
1365  // that can be selected to is the "Back" layer (so the
1366  // selection of any other copper layer is disregarded).
1367  if( GetBoard()->GetCopperLayerCount() < 2 )
1368  {
1369  if( layer != B_Cu )
1370  return;
1371  }
1372  // If more than one copper layer is enabled, the "Copper"
1373  // and "Component" layers can be selected, but the total
1374  // number of copper layers determines which internal
1375  // layers are also capable of being selected.
1376  else
1377  {
1378  if( layer != B_Cu && layer != F_Cu && layer >= GetBoard()->GetCopperLayerCount() - 1 )
1379  return;
1380  }
1381 
1382  EDA_ITEM* current = GetScreen()->GetCurItem();
1383 
1384  // See if we are drawing a segment; if so, add a via?
1385  if( GetToolId() == ID_TRACK_BUTT && current )
1386  {
1387  if( current->Type() == PCB_TRACE_T && current->IsNew() )
1388  {
1389  // Want to set the routing layers so that it switches properly -
1390  // see the implementation of Other_Layer_Route - the working
1391  // layer is used to 'start' the via and set the layer masks appropriately.
1392  GetScreen()->m_Route_Layer_TOP = curLayer;
1393  GetScreen()->m_Route_Layer_BOTTOM = layer;
1394 
1395  SetActiveLayer( curLayer );
1396 
1397  if( Other_Layer_Route( (TRACK*) GetScreen()->GetCurItem(), DC ) )
1398  {
1399  if( displ_opts->m_ContrastModeDisplay )
1400  m_canvas->Refresh();
1401  }
1402 
1403  // if the via was allowed by DRC, then the layer swap has already
1404  // been done by Other_Layer_Route(). if via not allowed, then
1405  // return now so assignment to setActiveLayer() below doesn't happen.
1406  return;
1407  }
1408  }
1409  }
1410 
1411  // Is yet more checking required? E.g. when the layer to be selected
1412  // is a non-copper layer, or when switching between a copper layer
1413  // and a non-copper layer, or vice-versa?
1414  // ...
1415 
1416  SetActiveLayer( layer );
1417 
1418  if( displ_opts->m_ContrastModeDisplay )
1419  m_canvas->Refresh();
1420 }
1421 
1422 
1423 void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
1424 {
1425  int id = aEvent.GetId();
1426 
1427  if( GetToolId() == id )
1428  return;
1429 
1432 
1433  // Stop the current command and deselect the current tool.
1435 
1436  switch( id )
1437  {
1438  case ID_NO_TOOL_SELECTED:
1439  SetToolID( id, m_canvas->GetDefaultCursor(), wxEmptyString );
1440  break;
1441 
1442  case ID_ZOOM_SELECTION:
1443  SetToolID( id, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) );
1444  break;
1445 
1446  case ID_TRACK_BUTT:
1447  if( g_Drc_On )
1448  SetToolID( id, wxCURSOR_PENCIL, _( "Add tracks" ) );
1449  else
1450  SetToolID( id, wxCURSOR_QUESTION_ARROW, _( "Add tracks" ) );
1451 
1452  if( (GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 )
1453  {
1454  Compile_Ratsnest( &dc, true );
1455  }
1456 
1457  break;
1458 
1459  case ID_PCB_MODULE_BUTT:
1460  SetToolID( id, wxCURSOR_PENCIL, _( "Add footprint" ) );
1461  break;
1462 
1463  case ID_PCB_ZONES_BUTT:
1464  SetToolID( id, wxCURSOR_PENCIL, _( "Add zones" ) );
1465 
1466  if( displ_opts->m_DisplayZonesMode != 0 )
1467  DisplayInfoMessage( this, _( "Warning: zone display is OFF!!!" ) );
1468 
1469  if( !GetBoard()->IsHighLightNetON() && (GetBoard()->GetHighLightNetCode() > 0 ) )
1470  HighLight( &dc );
1471 
1472  break;
1473 
1475  SetToolID( id, wxCURSOR_PENCIL, _( "Add keepout" ) );
1476  break;
1477 
1478  case ID_PCB_MIRE_BUTT:
1479  SetToolID( id, wxCURSOR_PENCIL, _( "Add layer alignment target" ) );
1480  break;
1481 
1483  SetToolID( id, wxCURSOR_PENCIL, _( "Adjust zero" ) );
1484  break;
1485 
1487  SetToolID( id, wxCURSOR_PENCIL, _( "Adjust grid origin" ) );
1488  break;
1489 
1490  case ID_PCB_ADD_LINE_BUTT:
1491  SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic line" ) );
1492  break;
1493 
1494  case ID_PCB_ARC_BUTT:
1495  SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic arc" ) );
1496  break;
1497 
1498  case ID_PCB_CIRCLE_BUTT:
1499  SetToolID( id, wxCURSOR_PENCIL, _( "Add graphic circle" ) );
1500  break;
1501 
1502  case ID_PCB_ADD_TEXT_BUTT:
1503  SetToolID( id, wxCURSOR_PENCIL, _( "Add text" ) );
1504  break;
1505 
1506  case ID_COMPONENT_BUTT:
1507  SetToolID( id, wxCURSOR_HAND, _( "Add footprint" ) );
1508  break;
1509 
1510  case ID_PCB_DIMENSION_BUTT:
1511  SetToolID( id, wxCURSOR_PENCIL, _( "Add dimension" ) );
1512  break;
1513 
1515  SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) );
1516  break;
1517 
1518  case ID_PCB_HIGHLIGHT_BUTT:
1519  SetToolID( id, wxCURSOR_HAND, _( "Highlight net" ) );
1520  break;
1521 
1523  SetToolID( id, wxCURSOR_HAND, _( "Select rats nest" ) );
1524 
1525  if( ( GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK ) == 0 )
1526  Compile_Ratsnest( &dc, true );
1527 
1528  break;
1529 
1530  // collect GAL-only tools here
1532  SetToolID( id, wxCURSOR_DEFAULT, _( "Unsupported tool in this canvas" ) );
1533  break;
1534  }
1535 }
1536 
1537 
1539 {
1540  MOVE_PARAMETERS params;
1541 
1542  DIALOG_MOVE_EXACT dialog( this, params );
1543  int ret = dialog.ShowModal();
1544 
1545  if( ret == wxID_OK )
1546  {
1547  if( BOARD_ITEM* item = GetScreen()->GetCurItem() )
1548  {
1549  // When a pad is modified, the full footprint is saved
1550  BOARD_ITEM* itemToSave = item;
1551 
1552  if( item->Type() == PCB_PAD_T )
1553  itemToSave = item->GetParent();
1554 
1555  // Could be moved or rotated
1556  SaveCopyInUndoList( itemToSave, UR_CHANGED );
1557 
1558  // begin with the default anchor
1559  wxPoint anchorPoint = item->GetPosition();
1560 
1561  if( item->Type() == PCB_MODULE_T )
1562  {
1563  // cast to module to allow access to the pads
1564  MODULE* mod = static_cast<MODULE*>( item );
1565 
1566  switch( params.anchor )
1567  {
1568  case ANCHOR_TOP_LEFT_PAD:
1569  if( mod->GetTopLeftPad()->GetAttribute() == PAD_ATTRIB_SMD )
1570  {
1571  anchorPoint = mod->GetTopLeftPad()->GetBoundingBox().GetPosition();
1572  }
1573  else
1574  {
1575  anchorPoint = mod->GetTopLeftPad()->GetPosition();
1576  }
1577  break;
1579  anchorPoint = mod->GetFootprintRect().GetCenter();
1580  break;
1581  case ANCHOR_FROM_LIBRARY:
1582  ; // nothing to do
1583  }
1584  }
1585 
1586  wxPoint origin;
1587 
1588  switch( params.origin )
1589  {
1591  origin = GetScreen()->m_O_Curseur;
1592  break;
1593 
1595  origin = GetGridOrigin();
1596  break;
1597 
1599  origin = GetAuxOrigin();
1600  break;
1601 
1603  origin = wxPoint( 0, 0 );
1604  break;
1605 
1607  // relative movement means that only the translation values should be used:
1608  // -> set origin and anchor to zero
1609  origin = wxPoint( 0, 0 );
1610  anchorPoint = wxPoint( 0, 0 );
1611  break;
1612  }
1613 
1614  wxPoint finalMoveVector = params.translation + origin - anchorPoint;
1615 
1616  item->Move( finalMoveVector );
1617  item->Rotate( item->GetPosition(), params.rotation );
1618  m_canvas->Refresh();
1619  }
1620  }
1621 
1623 }
1624 
1625 
1626 void PCB_EDIT_FRAME::duplicateItems( bool aIncrement )
1627 {
1628  BOARD_ITEM* item = GetScreen()->GetCurItem();
1629 
1630  if( !item )
1631  return;
1632 
1633  // In the board editor, the pads or fp texts can be edited
1634  // but cannot be duplicated (only the fp editor can do that).
1635  // only the footprint can be duplicated
1636  if( item->Type() == PCB_PAD_T || item->Type() == PCB_MODULE_TEXT_T )
1637  item = static_cast<MODULE*>( item )->GetParent();
1638 
1639  PCB_BASE_EDIT_FRAME::duplicateItem( item, aIncrement );
1640 }
1641 
1642 
1643 void PCB_BASE_EDIT_FRAME::duplicateItem( BOARD_ITEM* aItem, bool aIncrement )
1644 {
1645  if( !aItem )
1646  return;
1647 
1648  // The easiest way to handle a duplicate item command
1649  // is to simulate a block copy command, which gives us the undo management
1650  // for free
1651  if( GetScreen()->m_BlockLocate.GetState() == STATE_NO_BLOCK )
1652  {
1654 
1656 
1657  wxPoint crossHairPos = GetCrossHairPosition();
1658 
1659  const BLOCK_COMMAND_T blockType = aIncrement ? BLOCK_COPY_AND_INCREMENT : BLOCK_COPY;
1660 
1661  if( !HandleBlockBegin( &dc, blockType, crossHairPos ) )
1662  return;
1663 
1664  // Add the item to the block copy pick list:
1666  ITEM_PICKER picker( NULL, UR_UNSPECIFIED );
1667 
1668  picker.SetItem ( aItem );
1669  itemsList.PushItem( picker );
1670 
1671  // Set 2 coordinates updated by the mouse, because our simulation
1672  // does not use the mouse to call HandleBlockEnd()
1673  GetScreen()->m_BlockLocate.SetLastCursorPosition( crossHairPos );
1674  GetScreen()->m_BlockLocate.SetEnd( crossHairPos );
1675  HandleBlockEnd( &dc );
1676  }
1677 }
1678 
1679 
1681 {
1682 public:
1683 
1685  ARRAY_CREATOR( editFrame ),
1686  m_item( m_parent.GetScreen()->GetCurItem() )
1687  {}
1688 
1689 private:
1690 
1691  int getNumberOfItemsToArray() const override
1692  {
1693  // only handle single items
1694  return (m_item != NULL) ? 1 : 0;
1695  }
1696 
1697  BOARD_ITEM* getNthItemToArray( int n ) const override
1698  {
1699  wxASSERT_MSG( n == 0, "Legacy array tool can only handle a single item" );
1700  return m_item;
1701  }
1702 
1703  BOARD* getBoard() const override
1704  {
1705  return m_parent.GetBoard();
1706  }
1707 
1708  MODULE* getModule() const override
1709  {
1710  return dynamic_cast<MODULE*>( m_item->GetParent() );
1711  }
1712 
1713  wxPoint getRotationCentre() const override
1714  {
1715  return m_item->GetCenter();
1716  }
1717 
1718  void finalise() override
1719  {
1720  m_parent.GetCanvas()->Refresh();
1721  }
1722 
1723  BOARD_ITEM* m_item; // only have the one
1724 };
1725 
1726 
1728 {
1729  LEGACY_ARRAY_CREATOR array_creator( *this );
1730 
1731  array_creator.Invoke();
1732 }
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:996
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 TestForActiveLinksInRatsnest(int aNetCode)
Function TestForActiveLinksInRatsnest Explores the full rats nest list (which must exist) to determin...
Definition: ratsnest.cpp:469
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:1691
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:1189
void InstallPcbGlobalDeleteFrame(const wxPoint &pos)
This file is part of the common library TODO brief description.
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
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:258
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:786
wxPoint getRotationCentre() const override
Definition: edit.cpp:1713
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:144
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:430
DLIST< SEGZONE > m_Zone
Definition: class_board.h:245
void Delete_Texte_Pcb(TEXTE_PCB *TextePcb, wxDC *DC)
void OnSelectTool(wxCommandEvent &aEvent)
Definition: edit.cpp:1423
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:1643
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:787
void finalise() override
Definition: edit.cpp:1718
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:1274
bool End_Route(TRACK *aTrack, wxDC *aDC)
Function End_Route Terminates a track currently being created.
Definition: editrack.cpp:415
wxPoint m_O_Curseur
Relative Screen cursor coordinate (on grid) in user units.
BOARD_ITEM * getNthItemToArray(int n) const override
Definition: edit.cpp:1697
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:1538
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)
Function HandleBlockBegin initializes the block command including the command type, initial position, and other variables.
Definition: draw_frame.cpp:804
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 TestConnections()
Function TestConnections tests the connections relative to all nets.
Definition: connect.cpp:733
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:754
bool IsMouseCaptured() const
BOARD_ITEM * m_item
Definition: edit.cpp:1723
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:1727
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:1051
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:224
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:165
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:644
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.
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:1703
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:56
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:1022
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:564
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:166
const wxString & GetReference() const
Function GetReference.
Definition: class_module.h:412
void StartMoveModule(MODULE *aModule, wxDC *aDC, bool aDragConnectedTracks)
Function StartMoveModule Initialize a drag or move pad command.
Definition: modules.cpp:98
#define INSTALL_UNBUFFERED_DC(name, parent)
int GetToolId() const
Definition: draw_frame.h:406
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:864
void InstallPadOptionsFrame(D_PAD *pad)
MODULE * GetFootprintFromBoardByReference()
Function GetFootprintFromBoardByReference.
Definition: modules.cpp:60
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:285
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 return the default cursor shape.
BOARD_ITEM * GetCurItem()
void SwitchLayer(wxDC *DC, PCB_LAYER_ID layer) override
Definition: edit.cpp:1351
void duplicateItems(bool aIncrement) override
Function duplicateItems Duplicate selected item if possible and start a move.
Definition: edit.cpp:1626
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:885
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
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:129
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)...
LEGACY_ARRAY_CREATOR(PCB_BASE_EDIT_FRAME &editFrame)
Definition: edit.cpp:1684
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:1708
const wxPoint GetCenter() const