KiCad PCB EDA Suite
edit_tool.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) 2013-2015 CERN
5  * @author Maciej Suminski <maciej.suminski@cern.ch>
6  * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #include <limits>
27 
28 #include <class_board.h>
29 #include <class_module.h>
30 #include <class_edge_mod.h>
31 #include <class_zone.h>
32 #include <collectors.h>
33 #include <wxPcbStruct.h>
34 #include <kiway.h>
35 #include <class_draw_panel_gal.h>
36 #include <module_editor_frame.h>
37 #include <array_creator.h>
38 #include <pcbnew_id.h>
39 
40 #include <tool/tool_manager.h>
41 #include <view/view_controls.h>
42 #include <view/view.h>
44 #include <ratsnest_data.h>
45 #include <confirm.h>
46 #include <bitmaps.h>
47 #include <hotkeys.h>
48 
49 #include <cassert>
50 #include <functional>
51 using namespace std::placeholders;
52 
53 #include "pcb_actions.h"
54 #include "selection_tool.h"
55 #include "edit_tool.h"
56 #include "grid_helper.h"
57 
58 #include <router/router_tool.h>
59 
63 
64 #include <tools/tool_event_utils.h>
65 
67 
68 #include <board_commit.h>
69 
70 // Edit tool actions
71 TOOL_ACTION PCB_ACTIONS::editFootprintInFpEditor( "pcbnew.InteractiveEdit.editFootprintInFpEditor",
73  _( "Open in Footprint Editor" ),
74  _( "Opens the selected footprint in the Footprint Editor" ),
75  module_editor_xpm );
76 
77 TOOL_ACTION PCB_ACTIONS::copyPadToSettings( "pcbnew.InteractiveEdit.copyPadToSettings",
78  AS_GLOBAL, 0,
79  _( "Copy Pad Settings to Current Settings" ),
80  _( "Copies the properties of selected pad to the current template pad settings." ) );
81 
82 TOOL_ACTION PCB_ACTIONS::copySettingsToPads( "pcbnew.InteractiveEdit.copySettingsToPads",
83  AS_GLOBAL, 0,
84  _( "Copy Current Settings to Pads" ),
85  _( "Copies the current template pad settings to the selected pad(s)." ) );
86 
87 TOOL_ACTION PCB_ACTIONS::globalEditPads( "pcbnew.InteractiveEdit.globalPadEdit",
88  AS_GLOBAL, 0,
89  _( "Global Pad Edition" ),
90  _( "Changes pad properties globally." ), push_pad_settings_xpm );
91 
92 TOOL_ACTION PCB_ACTIONS::editActivate( "pcbnew.InteractiveEdit",
94  _( "Move" ), _( "Moves the selected item(s)" ), move_xpm, AF_ACTIVATE );
95 
96 TOOL_ACTION PCB_ACTIONS::duplicate( "pcbnew.InteractiveEdit.duplicate",
98  _( "Duplicate" ), _( "Duplicates the selected item(s)" ), duplicate_module_xpm );
99 
100 TOOL_ACTION PCB_ACTIONS::duplicateIncrement( "pcbnew.InteractiveEdit.duplicateIncrementPads",
102  _( "Duplicate" ), _( "Duplicates the selected item(s), incrementing pad numbers" ) );
103 
104 TOOL_ACTION PCB_ACTIONS::moveExact( "pcbnew.InteractiveEdit.moveExact",
106  _( "Move Exactly..." ), _( "Moves the selected item(s) by an exact amount" ),
107  move_module_xpm );
108 
109 TOOL_ACTION PCB_ACTIONS::createArray( "pcbnew.InteractiveEdit.createArray",
111  _( "Create Array" ), _( "Create array" ), array_module_xpm, AF_ACTIVATE );
112 
113 TOOL_ACTION PCB_ACTIONS::rotateCw( "pcbnew.InteractiveEdit.rotateCw",
115  _( "Rotate Clockwise" ), _( "Rotates selected item(s) clockwise" ),
116  rotate_cw_xpm, AF_NONE, (void*) 1 );
117 
118 TOOL_ACTION PCB_ACTIONS::rotateCcw( "pcbnew.InteractiveEdit.rotateCcw",
119  AS_GLOBAL, MD_SHIFT + 'R',
120  _( "Rotate Counter-clockwise" ), _( "Rotates selected item(s) counter-clockwise" ),
121  rotate_ccw_xpm, AF_NONE, (void*) -1 );
122 
123 TOOL_ACTION PCB_ACTIONS::flip( "pcbnew.InteractiveEdit.flip",
125  _( "Flip" ), _( "Flips selected item(s)" ), swap_layer_xpm );
126 
127 TOOL_ACTION PCB_ACTIONS::mirror( "pcbnew.InteractiveEdit.mirror",
128  AS_GLOBAL, 0,
129  _( "Mirror" ), _( "Mirrors selected item" ), mirror_h_xpm );
130 
131 TOOL_ACTION PCB_ACTIONS::remove( "pcbnew.InteractiveEdit.remove",
133  _( "Remove" ), _( "Deletes selected item(s)" ), delete_xpm,
134  AF_NONE, (void*) REMOVE_FLAGS::NORMAL );
135 
136 TOOL_ACTION PCB_ACTIONS::removeAlt( "pcbnew.InteractiveEdit.removeAlt",
138  _( "Remove (Alternative)" ), _( "Deletes selected item(s)" ), delete_xpm,
139  AF_NONE, (void*) REMOVE_FLAGS::ALT );
140 
141 TOOL_ACTION PCB_ACTIONS::exchangeFootprints( "pcbnew.InteractiveEdit.ExchangeFootprints",
142  AS_GLOBAL, 0,
143  _( "Exchange Footprint(s)" ), _( "Change the footprint used for modules" ),
144  import_module_xpm );
145 
146 
147 TOOL_ACTION PCB_ACTIONS::properties( "pcbnew.InteractiveEdit.properties",
149  _( "Properties..." ), _( "Displays item properties dialog" ), editor_xpm );
150 
151 TOOL_ACTION PCB_ACTIONS::editModifiedSelection( "pcbnew.InteractiveEdit.ModifiedSelection",
152  AS_GLOBAL, 0,
153  "", "" );
154 
155 TOOL_ACTION PCB_ACTIONS::measureTool( "pcbnew.InteractiveEdit.measureTool",
156  AS_GLOBAL, MD_CTRL + MD_SHIFT + 'M',
157  _( "Measure tool" ), _( "Interactively measure distance between points" ),
158  nullptr, AF_ACTIVATE );
159 
160 
162  PCB_TOOL( "pcbnew.InteractiveEdit" ), m_selectionTool( NULL ),
163  m_dragging( false )
164 {
165 }
166 
167 
169 {
170  m_dragging = false;
171 
172  if( aReason != RUN )
173  m_commit.reset( new BOARD_COMMIT( this ) );
174 }
175 
176 
178 {
179  // Find the selection tool, so they can cooperate
180  m_selectionTool = static_cast<SELECTION_TOOL*>( m_toolMgr->FindTool( "pcbnew.InteractiveSelection" ) );
181 
182  if( !m_selectionTool )
183  {
184  DisplayError( NULL, wxT( "pcbnew.InteractiveSelection tool is not available" ) );
185  return false;
186  }
187 
188  auto editingModuleCondition = [ this ] ( const SELECTION& aSelection ) {
189  return m_editModules;
190  };
191 
192  auto singleModuleCondition = SELECTION_CONDITIONS::OnlyType( PCB_MODULE_T )
194 
195  // Add context menu entries that are displayed when selection tool is active
207 
208  // Mirror only available in modedit
209  menu.AddItem( PCB_ACTIONS::mirror, editingModuleCondition && SELECTION_CONDITIONS::NotEmpty );
210 
211  // Footprint actions
213  singleModuleCondition );
215  singleModuleCondition );
216 
217  m_offset.x = 0;
218  m_offset.y = 0;
219 
220  return true;
221 }
222 
223 
225 {
226  TRACK* track = uniqueSelected<TRACK>();
227  VIA* via = uniqueSelected<VIA>();
228 
229  if( track || via )
230  {
231  ROUTER_TOOL* theRouter = static_cast<ROUTER_TOOL*>( m_toolMgr->FindTool( "pcbnew.InteractiveRouter" ) );
232  assert( theRouter );
233 
234  if( !theRouter->PNSSettings().InlineDragEnabled() )
235  return false;
236 
238  return true;
239  }
240 
241  return false;
242 }
243 
244 
245 int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
246 {
248  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
249 
250  VECTOR2I originalCursorPos = controls->GetCursorPosition();
251 
252  // Be sure that there is at least one item that we can modify. If nothing was selected before,
253  // try looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection)
255 
256  if( selection.Empty() )
257  return 0;
258 
259  bool unselect = selection.IsHover();
260 
261  Activate();
262 
263  m_dragging = false; // Are selected items being dragged?
264  bool restore = false; // Should items' state be restored when finishing the tool?
265  bool lockOverride = false;
266 
267  controls->ShowCursor( true );
268  controls->SetSnapping( true );
269  controls->SetAutoPan( true );
270 
271  // cumulative translation
272  wxPoint totalMovement( 0, 0 );
273 
274  GRID_HELPER grid( editFrame );
275  OPT_TOOL_EVENT evt = aEvent;
276 
277  // Main loop: keep receiving events
278  do
279  {
280  if( evt->IsAction( &PCB_ACTIONS::editActivate )
281  || evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
282  {
283  if( selection.Empty() )
284  break;
285 
286  BOARD_ITEM* curr_item = static_cast<BOARD_ITEM*>( selection.Front() );
287 
288  if( m_dragging && evt->Category() == TC_MOUSE )
289  {
290  m_cursor = grid.BestSnapAnchor( evt->Position(), curr_item );
291  controls->ForceCursorPosition( true, m_cursor );
292 
293  wxPoint movement = wxPoint( m_cursor.x, m_cursor.y ) - curr_item->GetPosition();
294  totalMovement += movement;
295 
296  // Drag items to the current cursor position
297  for( auto item : selection )
298  static_cast<BOARD_ITEM*>( item )->Move( movement + m_offset );
299 
300  updateRatsnest( true );
301  }
302  else if( !m_dragging ) // Prepare to start dragging
303  {
304  if( !invokeInlineRouter() )
305  {
307 
308  if( selection.Empty() )
309  break;
310 
311  // deal with locked items (override lock or abort the operation)
313 
314  if( lockFlags == SELECTION_LOCKED )
315  break;
316  else if( lockFlags == SELECTION_LOCK_OVERRIDE )
317  lockOverride = true;
318 
319  // Save items, so changes can be undone
320  for( auto item : selection )
321  m_commit->Modify( item );
322 
323  m_cursor = controls->GetCursorPosition();
324 
325  if( selection.Size() == 1 )
326  {
327  // Set the current cursor position to the first dragged item origin, so the
328  // movement vector could be computed later
329  m_cursor = grid.BestDragOrigin( originalCursorPos, curr_item );
330  grid.SetAuxAxes( true, m_cursor );
331  }
332  else
333  {
334  m_cursor = grid.Align( m_cursor );
335  }
336 
337  controls->ForceCursorPosition( true, m_cursor );
338  controls->WarpCursor( m_cursor, true );
339 
340  VECTOR2I o = VECTOR2I( curr_item->GetPosition() );
341  m_offset.x = o.x - m_cursor.x;
342  m_offset.y = o.y - m_cursor.y;
343 
344  controls->SetAutoPan( true );
345  m_dragging = true;
346  }
347  }
348 
349  getView()->Update( &selection );
351  }
352 
353  else if( evt->IsCancel() || evt->IsActivate() )
354  {
355  restore = true; // Cancelling the tool means that items have to be restored
356  break; // Finish
357  }
358 
359  else if( evt->Action() == TA_UNDO_REDO_PRE )
360  {
361  unselect = true;
362  break;
363  }
364 
365  // Dispatch TOOL_ACTIONs
366  else if( evt->Category() == TC_COMMAND )
367  {
368  wxPoint modPoint = getModificationPoint( selection );
369 
370  if( evt->IsAction( &PCB_ACTIONS::remove ) )
371  {
372  // exit the loop, as there is no further processing for removed items
373  break;
374  }
375  else if( evt->IsAction( &PCB_ACTIONS::duplicate ) )
376  {
377  // On duplicate, stop moving this item
378  // The duplicate tool should then select the new item and start
379  // a new move procedure
380  break;
381  }
382  else if( evt->IsAction( &PCB_ACTIONS::moveExact ) )
383  {
384  // Can't do this, because the selection will then contain
385  // stale pointers and it will all go horribly wrong...
386  //editFrame->RestoreCopyFromUndoList( dummy );
387  //
388  // So, instead, reset the position manually
389  for( auto item : selection )
390  {
391  BOARD_ITEM* i = static_cast<BOARD_ITEM*>( item );
392  i->SetPosition( i->GetPosition() - totalMovement );
393 
394  // And what about flipping and rotation?
395  // for now, they won't be undone, but maybe that is how
396  // it should be, so you can flip and move exact in the
397  // same action?
398  }
399 
400  // This causes a double event, so we will get the dialogue
401  // correctly, somehow - why does Rotate not?
402  //MoveExact( aEvent );
403  break; // exit the loop - we move exactly, so we have finished moving
404  }
405 
406  if( m_dragging )
407  {
408  // Update dragging offset (distance between cursor and the first dragged item)
409  m_offset = static_cast<BOARD_ITEM*>( selection.Front() )->GetPosition() - modPoint;
410  getView()->Update( &selection );
411  updateRatsnest( true );
412  }
413  }
414 
415  else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
416  {
417  if( !lockOverride )
418  break; // Finish
419 
420  lockOverride = false;
421  }
422  } while( ( evt = Wait() ) ); //Should be assignment not equality test
423 
424  controls->ForceCursorPosition( false );
425  controls->ShowCursor( false );
426  controls->SetSnapping( false );
427  controls->SetAutoPan( false );
428 
429  m_dragging = false;
430  m_offset.x = 0;
431  m_offset.y = 0;
432 
433  if( unselect || restore )
435 
436  if( restore )
437  m_commit->Revert();
438  else
439  m_commit->Push( _( "Drag" ) );
440 
441  return 0;
442 }
443 
444 
445 int EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
446 {
447  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
448 
450 
451  if( selection.Empty() )
452  return 0;
453 
454  // Tracks & vias are treated in a special way:
456  {
457  DIALOG_TRACK_VIA_PROPERTIES dlg( editFrame, selection );
458 
459  if( dlg.ShowModal() )
460  {
461  dlg.Apply( *m_commit );
462  m_commit->Push( _( "Edit track/via properties" ) );
463  }
464  }
465  else if( selection.Size() == 1 ) // Properties are displayed when there is only one item selected
466  {
467  // Display properties dialog
468  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.Front() );
469 
470  // Some of properties dialogs alter pointers, so we should deselect them
472 
473  // Store flags, so they can be restored later
474  STATUS_FLAGS flags = item->GetFlags();
475  item->ClearFlags();
476 
477  // Do not handle undo buffer, it is done by the properties dialogs @todo LEGACY
478  // Display properties dialog provided by the legacy canvas frame
479  editFrame->OnEditItemRequest( NULL, item );
480 
482  item->SetFlags( flags );
483  }
484 
485  if( selection.IsHover() )
487 
488  return 0;
489 }
490 
491 
492 int EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
493 {
494  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
495 
496  const auto& selection = m_selectionTool->RequestSelection();
497 
498  if( selection.Empty() )
499  return 0;
500 
502  return 0;
503 
504  // Shall the selection be cleared at the end?
505  wxPoint rotatePoint = getModificationPoint( selection );
506  const int rotateAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *editFrame, aEvent );
507 
508  for( auto item : selection )
509  {
510  m_commit->Modify( item );
511  static_cast<BOARD_ITEM*>( item )->Rotate( rotatePoint, rotateAngle );
512  }
513 
514  if( !m_dragging )
515  m_commit->Push( _( "Rotate" ) );
516  else
517  updateRatsnest( true );
518 
519  if( selection.IsHover() )
521 
522  // TODO selectionModified
524  editFrame->Refresh();
525 
526  return 0;
527 }
528 
532 static wxPoint mirrorPointX( const wxPoint& aPoint, const wxPoint& aMirrorPoint )
533 {
534  wxPoint mirrored = aPoint;
535 
536  mirrored.x -= aMirrorPoint.x;
537  mirrored.x = -mirrored.x;
538  mirrored.x += aMirrorPoint.x;
539 
540  return mirrored;
541 }
542 
543 
547 static void mirrorPadX( D_PAD& aPad, const wxPoint& aMirrorPoint )
548 {
549  wxPoint tmpPt = mirrorPointX( aPad.GetPosition(), aMirrorPoint );
550 
551  aPad.SetPosition( tmpPt );
552 
553  aPad.SetX0( aPad.GetPosition().x );
554 
555  tmpPt = aPad.GetOffset();
556  tmpPt.x = -tmpPt.x;
557  aPad.SetOffset( tmpPt );
558 
559  auto tmpz = aPad.GetDelta();
560  tmpz.x = -tmpz.x;
561  aPad.SetDelta( tmpz );
562 
563  aPad.SetOrientation( -aPad.GetOrientation() );
564 }
565 
566 
567 int EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
568 {
569  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
570 
571  const auto& selection = m_selectionTool->RequestSelection();
572 
574  return 0;
575 
576  if( selection.Empty() )
577  return 0;
578 
579  wxPoint mirrorPoint = getModificationPoint( selection );
580 
581  for( auto item : selection )
582  {
583  // only modify items we can mirror
584  switch( item->Type() )
585  {
586  case PCB_MODULE_EDGE_T:
587  case PCB_MODULE_TEXT_T:
588  case PCB_PAD_T:
589  m_commit->Modify( item );
590  break;
591  default:
592  continue;
593  }
594 
595  // modify each object as necessary
596  switch( item->Type() )
597  {
598  case PCB_MODULE_EDGE_T:
599  {
600  auto& edge = static_cast<EDGE_MODULE&>( *item );
601  edge.Mirror( mirrorPoint, false );
602  break;
603  }
604 
605  case PCB_MODULE_TEXT_T:
606  {
607  auto& modText = static_cast<TEXTE_MODULE&>( *item );
608  modText.Mirror( mirrorPoint, false );
609  break;
610  }
611 
612  case PCB_PAD_T:
613  {
614  auto& pad = static_cast<D_PAD&>( *item );
615  mirrorPadX( pad, mirrorPoint );
616  break;
617  }
618 
619  default:
620  // it's likely the commit object is wrong if you get here
621  assert( false );
622  break;
623  }
624  }
625 
626  if( !m_dragging )
627  m_commit->Push( _( "Mirror" ) );
628  else
629  updateRatsnest( true );
630 
631  if( selection.IsHover() )
633 
634  // TODO selectionModified
636  editFrame->Refresh();
637 
638  return 0;
639 }
640 
641 
642 int EDIT_TOOL::Flip( const TOOL_EVENT& aEvent )
643 {
644  const auto& selection = m_selectionTool->RequestSelection();
645 
647  return 0;
648 
649  if( selection.Empty() )
650  return 0;
651 
652  wxPoint flipPoint = getModificationPoint( selection );
653 
654  for( auto item : selection )
655  {
656  m_commit->Modify( item );
657  static_cast<BOARD_ITEM*>( item )->Flip( flipPoint );
658  }
659 
660  if( !m_dragging )
661  m_commit->Push( _( "Flip" ) );
662  else
663  updateRatsnest( true );
664 
665  if( selection.IsHover() )
667 
669  getEditFrame<PCB_BASE_EDIT_FRAME>()->Refresh();
670 
671  return 0;
672 }
673 
674 
675 int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
676 {
677  // get a copy instead of reference (as we're going to clear the selectio before removing items)
679 
681  return 0;
682 
683  if( selection.Empty() )
684  return 0;
685 
686  // is this "alternative" remove?
687  const bool isAlt = aEvent.Parameter<intptr_t>() ==
689 
690  // in "alternative" mode, deletion is not just a simple list
691  // of selected items, it is:
692  // - whole tracks, not just segments
693  if( isAlt && selection.IsHover() )
694  {
697  }
698 
699  // As we are about to remove items, they have to be removed from the selection first
701 
702  for( auto item : selection )
703  {
704  m_commit->Remove( item );
705  }
706 
707  m_commit->Push( _( "Delete" ) );
708 
709  return 0;
710 }
711 
712 
713 int EDIT_TOOL::MoveExact( const TOOL_EVENT& aEvent )
714 {
715  const auto& selection = m_selectionTool->RequestSelection();
716 
718  return 0;
719 
720  if( selection.Empty() )
721  return 0;
722 
723 
724  wxPoint translation;
725  double rotation = 0;
726 
727  PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>();
728 
729  DIALOG_MOVE_EXACT dialog( editFrame, translation, rotation );
730  int ret = dialog.ShowModal();
731 
732  if( ret == wxID_OK )
733  {
734  VECTOR2I rp = selection.GetCenter();
735  wxPoint rotPoint( rp.x, rp.y );
736 
737  for( auto item : selection )
738  {
739 
740  m_commit->Modify( item );
741  static_cast<BOARD_ITEM*>( item )->Move( translation );
742  static_cast<BOARD_ITEM*>( item )->Rotate( rotPoint, rotation );
743 
744  if( !m_dragging )
745  getView()->Update( item );
746  }
747 
748  m_commit->Push( _( "Move exact" ) );
749 
750  if( selection.IsHover() )
752 
754  }
755 
756  return 0;
757 }
758 
759 
760 int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
761 {
762  // Note: original items are no more modified.
763 
764  bool increment = aEvent.IsAction( &PCB_ACTIONS::duplicateIncrement );
765 
766  // Be sure that there is at least one item that we can modify
768 
769  if( selection.Empty() )
770  return 0;
771 
772  // we have a selection to work on now, so start the tool process
773  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
774 
775  std::vector<BOARD_ITEM*> old_items;
776 
777  for( auto item : selection )
778  {
779  if( item )
780  old_items.push_back( static_cast<BOARD_ITEM*>( item ) );
781  }
782 
783  for( unsigned i = 0; i < old_items.size(); ++i )
784  {
785  BOARD_ITEM* item = old_items[i];
786 
787  // Unselect the item, so we won't pick it up again
788  // Do this first, so a single-item duplicate will correctly call
789  // SetCurItem and show the item properties
791 
792  BOARD_ITEM* new_item = NULL;
793 
794  if( m_editModules )
795  {
796  new_item = editFrame->GetBoard()->m_Modules->Duplicate( item, increment );
797  }
798  else
799  {
800 #if 0
801  // @TODO: see if we allow zone duplication here
802  // Duplicate zones is especially tricky (overlaping zones must be merged)
803  // so zones are not duplicated
804  if( item->Type() != PCB_ZONE_AREA_T )
805 #endif
806  new_item = editFrame->GetBoard()->Duplicate( item );
807  }
808 
809  if( new_item )
810  {
811  m_commit->Add( new_item );
812 
813  // Select the new item, so we can pick it up
814  m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, new_item );
815  }
816  }
817 
818  // record the new items as added
819  if( !selection.Empty() )
820  {
821  editFrame->DisplayToolMsg( wxString::Format( _( "Duplicated %d item(s)" ),
822  (int) old_items.size() ) );
823 
824  // If items were duplicated, pick them up
825  // this works well for "dropping" copies around and pushes the commit
827  Main( evt );
828  }
829 
830  return 0;
831 };
832 
833 
835 {
836 public:
837 
838  GAL_ARRAY_CREATOR( PCB_BASE_FRAME& editFrame, bool editModules,
839  const SELECTION& selection ):
840  ARRAY_CREATOR( editFrame ),
841  m_editModules( editModules ),
842  m_selection( selection )
843  {}
844 
845 private:
846 
847  int getNumberOfItemsToArray() const override
848  {
849  // only handle single items
850  return m_selection.Size();
851  }
852 
853  BOARD_ITEM* getNthItemToArray( int n ) const override
854  {
855  return static_cast<BOARD_ITEM*>( m_selection[n] );
856  }
857 
858  BOARD* getBoard() const override
859  {
860  return m_parent.GetBoard();
861  }
862 
863  MODULE* getModule() const override
864  {
865  // Remember this is valid and used only in the module editor.
866  // in board editor, the parent of items is usually the board.
867  return m_editModules ? m_parent.GetBoard()->m_Modules.GetFirst() : NULL;
868  }
869 
870  wxPoint getRotationCentre() const override
871  {
872  const VECTOR2I rp = m_selection.GetCenter();
873  return wxPoint( rp.x, rp.y );
874  }
875 
876  void prePushAction( BOARD_ITEM* new_item ) override
877  {
879  true, new_item );
880  }
881 
882  void postPushAction( BOARD_ITEM* new_item ) override
883  {
884  }
885 
886  void finalise() override
887  {
888  }
889 
892 };
893 
894 
895 int EDIT_TOOL::CreateArray( const TOOL_EVENT& aEvent )
896 {
897  const auto& selection = m_selectionTool->RequestSelection();
898 
899  if( selection.Empty() )
900  return 0;
901 
902  // we have a selection to work on now, so start the tool process
903  PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>();
904  GAL_ARRAY_CREATOR array_creator( *editFrame, m_editModules, selection );
905  array_creator.Invoke();
906 
907  return 0;
908 }
909 
910 
912 {
913  const auto& selection = m_selectionTool->RequestSelection();
914 
915  if( selection.Empty() )
916  return 0;
917 
918  MODULE* mod = selection.FirstOfKind<MODULE> ();
919 
920  if( !mod )
921  return 0;
922 
923  frame()->SetCurItem( mod );
924 
925  // Footprint exchange could remove modules, so they have to be
926  // removed from the selection first
928 
929  // invoke the exchange dialog process
930  {
931  DIALOG_EXCHANGE_MODULE dialog( frame(), mod );
932  dialog.ShowQuasiModal();
933  }
934 
935  // The current item can be deleted by exchange module, and the
936  // selection is emptied, so remove current item from frame info area
937  frame()->SetCurItem( nullptr );
938 
939  return 0;
940 }
941 
942 
943 int EDIT_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
944 {
945  auto& view = *getView();
946  auto& controls = *getViewControls();
947 
948  Activate();
951  wxCURSOR_PENCIL, _( "Measure distance between two points" ) );
952 
954 
955  KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr );
956 
957  view.Add( &ruler );
958  view.SetVisible( &ruler, false );
959 
960  bool originSet = false;
961 
962  controls.ShowCursor( true );
963  controls.SetSnapping( true );
964 
965  while( auto evt = Wait() )
966  {
967  const VECTOR2I cursorPos = controls.GetCursorPosition();
968 
969  if( evt->IsCancel() || evt->IsActivate() )
970  {
971  break;
972  }
973 
974  // click or drag starts
975  else if( !originSet &&
976  ( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) ) )
977  {
978  if( !evt->IsDrag( BUT_LEFT ) )
979  {
980  twoPtMgr.SetOrigin( cursorPos );
981  twoPtMgr.SetEnd( cursorPos );
982  }
983 
984  controls.CaptureCursor( true );
985  controls.SetAutoPan( true );
986 
987  originSet = true;
988  }
989 
990  else if( !originSet && evt->IsMotion() )
991  {
992  // make sure the origin is set before a drag starts
993  // otherwise you can miss a step
994  twoPtMgr.SetOrigin( cursorPos );
995  twoPtMgr.SetEnd( cursorPos );
996  }
997 
998  // second click or mouse up after drag ends
999  else if( originSet &&
1000  ( evt->IsClick( BUT_LEFT ) || evt->IsMouseUp( BUT_LEFT ) ) )
1001  {
1002  originSet = false;
1003 
1004  controls.SetAutoPan( false );
1005  controls.CaptureCursor( false );
1006 
1007  view.SetVisible( &ruler, false );
1008  }
1009 
1010  // move or drag when origin set updates rules
1011  else if( originSet &&
1012  ( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) )
1013  {
1014  twoPtMgr.SetAngleSnap( evt->Modifier( MD_CTRL ) );
1015  twoPtMgr.SetEnd( cursorPos );
1016 
1017  view.SetVisible( &ruler, true );
1018  view.Update( &ruler, KIGFX::GEOMETRY );
1019  }
1020 
1021  else if( evt->IsClick( BUT_RIGHT ) )
1022  {
1023  GetManager()->PassEvent();
1024  }
1025  }
1026 
1027  view.SetVisible( &ruler, false );
1028  view.Remove( &ruler );
1029 
1030  frame()->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
1031 
1032  return 0;
1033 }
1034 
1035 
1037 {
1038  Go( &EDIT_TOOL::Main, PCB_ACTIONS::editActivate.MakeEvent() );
1039  Go( &EDIT_TOOL::Rotate, PCB_ACTIONS::rotateCw.MakeEvent() );
1040  Go( &EDIT_TOOL::Rotate, PCB_ACTIONS::rotateCcw.MakeEvent() );
1041  Go( &EDIT_TOOL::Flip, PCB_ACTIONS::flip.MakeEvent() );
1042  Go( &EDIT_TOOL::Remove, PCB_ACTIONS::remove.MakeEvent() );
1043  Go( &EDIT_TOOL::Remove, PCB_ACTIONS::removeAlt.MakeEvent() );
1049  Go( &EDIT_TOOL::Mirror, PCB_ACTIONS::mirror.MakeEvent() );
1053 }
1054 
1055 
1056 void EDIT_TOOL::updateRatsnest( bool aRedraw )
1057 {
1058  const SELECTION& selection = m_selectionTool->GetSelection();
1059  RN_DATA* ratsnest = getModel<BOARD>()->GetRatsnest();
1060 
1061  ratsnest->ClearSimple();
1062 
1063  for( auto item : selection )
1064  {
1065  ratsnest->Update( static_cast<BOARD_ITEM*>( item ) );
1066 
1067  if( aRedraw )
1068  ratsnest->AddSimple( static_cast<BOARD_ITEM*>( item ) );
1069  }
1070 }
1071 
1072 
1074 {
1075  if( aSelection.Size() == 1 )
1076  {
1077  return static_cast<BOARD_ITEM*>( aSelection.Front() )->GetPosition() - m_offset;
1078  }
1079  else
1080  {
1081  // If EDIT_TOOL is not currently active then it means that the cursor position is not
1082  // updated, so we have to fetch the latest value
1083  if( m_toolMgr->GetCurrentToolId() != m_toolId )
1085 
1086  return wxPoint( m_cursor.x, m_cursor.y );
1087  }
1088 }
1089 
1091 {
1092  const auto& selection = m_selectionTool->RequestSelection();
1093 
1094  if( selection.Empty() )
1095  return 0;
1096 
1097  MODULE* mod = selection.FirstOfKind<MODULE>();
1098 
1099  if( !mod )
1100  return 0;
1101 
1102  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
1103 
1104  editFrame->SetCurItem( mod );
1105 
1106  if( editFrame->GetCurItem()->GetTimeStamp() == 0 ) // Module Editor needs a non null timestamp
1107  {
1108  editFrame->GetCurItem()->SetTimeStamp( GetNewTimeStamp() );
1109  editFrame->OnModify();
1110  }
1111 
1113 
1114  editor->Load_Module_From_BOARD( (MODULE*) editFrame->GetCurItem() );
1115  editFrame->SetCurItem( NULL ); // the current module could be deleted by
1116 
1117  editor->Show( true );
1118  editor->Raise(); // Iconize( false );
1119 
1120  if( selection.IsHover() )
1122 
1123  return 0;
1124 }
1125 
1126 template<class T>
1128 {
1129  const auto selection = m_selectionTool->GetSelection();
1130 
1131  if( selection.Size() != 1 )
1132  return nullptr;
1133 
1134  auto item = selection[0];
1135  return dyn_cast<T*>( item );
1136 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
VECTOR2I BestDragOrigin(const VECTOR2I &aMousePos, BOARD_ITEM *aItem)
wxPoint getModificationPoint(const SELECTION &aSelection)
Returns the right modification point (e.g.
Definition: edit_tool.cpp:1073
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
VECTOR2I m_cursor
Last cursor position (needed for getModificationPoint() to avoid changes of edit reference point)...
Definition: edit_tool.h:145
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
int Main(const TOOL_EVENT &aEvent)
Function Main()
Definition: edit_tool.cpp:245
KIGFX::VIEW * view() const
Definition: pcb_tool.h:108
Definition of class FOOTPRINT_EDIT_FRAME.
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:255
int Properties(const TOOL_EVENT &aEvent)
Function Edit()
Definition: edit_tool.cpp:445
int Rotate(const TOOL_EVENT &aEvent)
Function Rotate()
Definition: edit_tool.cpp:492
TOOL_BASE * FindTool(int aId) const
Function FindTool() Searches for a tool with given ID.
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.
int ExchangeFootprints(const TOOL_EVENT &aEvent)
Function ExchangeFootprints()
Definition: edit_tool.cpp:911
static TOOL_ACTION editActivate
Activation of the edit tool.
Definition: pcb_actions.h:81
static const KICAD_T Tracks[]
A scan list for only TRACKS.
Definition: collectors.h:294
int GetCurrentToolId() const
Returns id of the tool that is on the top of the active tools stack (was invoked the most recently)...
Definition: tool_manager.h:268
SELECTION & RequestSelection(int aFlags=SELECTION_DEFAULT)
Function RequestSelection()
static TOOL_ACTION globalEditPads
Definition: pcb_actions.h:359
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 SetPosition(const wxPoint &aPos)=0
Class RN_DATA.
This file is part of the common library.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:206
T
enum T contains all this lexer's tokens.
VECTOR2I Align(const VECTOR2I &aPoint) const
Definition: grid_helper.cpp:95
VIEW_CONTROLS class definition.
Class SELECTION_TOOL.
Class TWO_POINT_GEOMETRY_MANAGER.
virtual void OnEditItemRequest(wxDC *aDC, BOARD_ITEM *aItem)=0
Function OnEditItemRequest Install the corresponding dialog editor for the given item.
Class BOARD to handle a board.
SELECTION_LOCK_FLAGS CheckLock()
Checks if the user has agreed to modify locked items for the given selection.
static TOOL_ACTION unselectItem
Unselects an item (specified as the event parameter).
Definition: pcb_actions.h:59
Class that computes missing connections on a PCB.
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:49
Tool is invoked after being inactive.
Definition: tool_base.h:82
TOOL_MENU & GetToolMenu()
EDA_ITEM * Front() const
Definition: selection.h:137
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
BOARD_ITEM * Duplicate(const BOARD_ITEM *aItem, bool aIncrementPadNumbers, bool aAddToModule=false)
Function Duplicate Duplicate a given item within the module, without adding to the board...
PCB_BASE_FRAME & m_parent
Definition: array_creator.h:61
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:114
void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:340
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:96
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
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:215
virtual const wxPoint & GetPosition() const =0
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
static TOOL_ACTION selectConnection
Selects a connection between junctions.
Definition: pcb_actions.h:62
static int LegacyHotKey(int aHotKey)
Creates a hot key code that refers to a legacy hot key setting, instead of a particular key...
Definition: tool_action.h:174
BOARD * GetBoard() const
void SetPosition(const wxPoint &aPos) override
Definition: class_pad.h:169
static TOOL_ACTION removeAlt
Definition: pcb_actions.h:115
Classes to handle copper zones.
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:54
static TOOL_ACTION mirror
Mirroring of selected items.
Definition: pcb_actions.h:93
class D_PAD, a pad in a footprint
Definition: typeinfo.h:102
VECTOR2I BestSnapAnchor(const VECTOR2I &aOrigin, BOARD_ITEM *aDraggedItem)
bool Update(const BOARD_ITEM *aItem)
Function Update() Updates the ratsnest data for an item.
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:135
wxPoint m_offset
Offset from the dragged item's center (anchor)
Definition: edit_tool.h:141
static SELECTION_CONDITION Count(int aNumber)
Function Count Creates a functor that tests if the number of selected items is equal to the value giv...
void prePushAction(BOARD_ITEM *new_item) override
Definition: edit_tool.cpp:876
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590
static bool NotEmpty(const SELECTION &aSelection)
Function NotEmpty Tests if there are any items selected.
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:106
Casted dyn_cast(From aObject)
Function dyn_cast()
Definition: typeinfo.h:73
static TOOL_ACTION copyPadToSettings
Definition: pcb_actions.h:357
MODULE * getModule() const override
Definition: edit_tool.cpp:863
void SetTimeStamp(time_t aNewTimeStamp)
Definition: base_struct.h:203
int Mirror(const TOOL_EVENT &aEvent)
Function Mirror.
Definition: edit_tool.cpp:567
Pcbnew hotkeys.
BOARD_ITEM * getNthItemToArray(int n) const override
Definition: edit_tool.cpp:853
static TOOL_ACTION moveExact
Activation of the exact move tool.
Definition: pcb_actions.h:102
const ROUTING_SETTINGS & PNSSettings() const
Definition: pns_tool_base.h:54
void finalise() override
Definition: edit_tool.cpp:886
static TOOL_ACTION copySettingsToPads
Definition: pcb_actions.h:358
void PassEvent()
Allows a tool to pass the already handled event to the next tool on the stack.
Definition: tool_manager.h:336
static TOOL_ACTION duplicate
Activation of the duplication tool.
Definition: pcb_actions.h:105
void Mirror(const wxPoint aCentre, bool aMirrorAroundXAxis)
Mirror an edge of the footprint.
class MODULE, a footprint
Definition: typeinfo.h:101
int Flip(const TOOL_EVENT &aEvent)
Function Flip()
Definition: edit_tool.cpp:642
static TOOL_ACTION duplicateIncrement
Activation of the duplication tool with incrementing (e.g. pad number)
Definition: pcb_actions.h:108
virtual void WarpCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false) const =0
Function WarpCursor() If enabled (.
static TOOL_ACTION rotateCw
Rotation of selected objects clockwise.
Definition: pcb_actions.h:84
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
int getNumberOfItemsToArray() const override
Definition: edit_tool.cpp:847
wxPoint getRotationCentre() const override
Definition: edit_tool.cpp:870
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:253
void Refresh()
virtual VECTOR2D GetCursorPosition() const =0
Function GetCursorPosition() Returns the current cursor position in world coordinates.
bool m_dragging
Flag determining if anything is being dragged right now
Definition: edit_tool.h:138
int ShowQuasiModal()
static SELECTION_CONDITION OnlyTypes(const std::vector< KICAD_T > &aTypes)
Function OnlyTypes Creates a functor that tests if the selected items are only of given types...
const wxPoint & GetPosition() const override
Definition: class_pad.h:170
SELECTION_LOCK_FLAGS
Definition: selection.h:177
T * uniqueSelected()
Function uniqueSelected()
Definition: edit_tool.cpp:1127
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:109
Class TOOL_EVENT.
Definition: tool_event.h:162
static TOOL_ACTION createArray
Tool for creating an array of objects.
Definition: pcb_actions.h:273
void SetOrigin(const VECTOR2I &aOrigin)
Set the origin of the ruler (the fixed end)
GAL_ARRAY_CREATOR(PCB_BASE_FRAME &editFrame, bool editModules, const SELECTION &selection)
Definition: edit_tool.cpp:838
T * GetFirst() const
Function GetFirst returns the first T* in the list without removing it, or NULL if the list is empty...
Definition: dlist.h:163
SELECTION & GetSelection()
Function GetSelection()
unsigned STATUS_FLAGS
Definition: base_struct.h:144
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
Definition: edit_tool.cpp:177
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
Definition: view_controls.h:94
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
Class RULER_ITEM.
Definition: ruler_item.h:43
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
static TOOL_ACTION exchangeFootprints
Exchange footprints of modules.
Definition: pcb_actions.h:111
All active tools
Definition: tool_event.h:138
Class PCB_TOOL.
Definition: pcb_tool.h:45
BOARD * getBoard() const override
Definition: edit_tool.cpp:858
const SELECTION & m_selection
Definition: edit_tool.cpp:891
void Update(VIEW_ITEM *aItem)
Function Update() For dynamic VIEWs, informs the associated VIEW that the graphical representation of...
Definition: view.cpp:1378
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
Definition: pcb_actions.h:189
bool invokeInlineRouter()
Definition: edit_tool.cpp:224
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg...
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:36
void updateRatsnest(bool aRedraw)
Updates ratsnest for selected items.
Definition: edit_tool.cpp:1056
time_t GetTimeStamp() const
Definition: base_struct.h:204
bool m_editModules
Definition: pcb_tool.h:112
void Reset(RESET_REASON aReason) override
Function Reset() Brings the tool to a known, initial state.
Definition: edit_tool.cpp:168
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
static TOOL_ACTION rotateCcw
Rotation of selected objects counter-clockwise.
Definition: pcb_actions.h:87
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:105
int MoveExact(const TOOL_EVENT &aEvent)
Function MoveExact()
Definition: edit_tool.cpp:713
int Remove(const TOOL_EVENT &aEvent)
Function Remove()
Definition: edit_tool.cpp:675
static ROUTER * theRouter
Definition: pns_router.cpp:66
bool EditingModules() const
Definition: pcb_tool.h:78
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:90
virtual void OnModify()
Function OnModify Virtual Must be called after a change in order to set the "modify" flag of the curr...
TOOL_MANAGER * GetToolManager() const
Function GetToolManager returns the tool manager instance, if any.
Definition: draw_frame.h:810
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:373
TOOL_EVENT MakeEvent() const
Function HasHotKey() Checks if the action has a hot key assigned.
Definition: tool_action.h:104
void DisplayToolMsg(const wxString &msg)
Definition: draw_frame.cpp:497
int CreateArray(const TOOL_EVENT &aEvent)
Function CreateArray()
Definition: edit_tool.cpp:895
Common, abstract interface for edit frames.
int MeasureTool(const TOOL_EVENT &aEvent)
Launches a tool to measure between points
Definition: edit_tool.cpp:943
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
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:166
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Function AddItem()
static TOOL_ACTION editFootprintInFpEditor
Definition: pcb_actions.h:356
DLIST< MODULE > m_Modules
Definition: class_board.h:243
Class TOOL_ACTION.
Definition: tool_action.h:46
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:56
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees, but soon degrees.
Definition: class_pad.h:214
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Function OnlyType Creates a functor that tests if the selected items are only of given type...
const wxSize & GetDelta() const
Definition: class_pad.h:185
void SetAuxAxes(bool aEnable, const VECTOR2I &aOrigin=VECTOR2I(0, 0), bool aEnableDiagonal=false)
Definition: grid_helper.cpp:84
static wxPoint mirrorPointX(const wxPoint &aPoint, const wxPoint &aMirrorPoint)
Definition: edit_tool.cpp:532
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:80
void Mirror(const wxPoint &aCentre, bool aMirrorAroundXAxis)
Mirror text position in footprint edition the text itself is not mirrored, and the layer not modified...
int editFootprintInFpEditor(const TOOL_EVENT &aEvent)
Definition: edit_tool.cpp:1090
bool IsHover() const
Definition: selection.h:66
void SetOrientation(double aAngle)
Function SetOrientation sets the rotation angle of the pad.
Definition: class_pad.cpp:306
TOOL_MANAGER * GetManager() const
Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool...
Definition: tool_base.h:144
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:254
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Function SetVisible() Sets the item visibility.
Definition: view.cpp:1330
void Activate()
Function Activate() Runs the tool.
void SetTransitions() override
Sets up handlers for various events.
Definition: edit_tool.cpp:1036
int Size() const
Returns the number of selected parts.
Definition: selection.h:112
void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:310
void SetX0(int x)
Definition: class_pad.h:179
Module description (excepted pads)
static TOOL_ACTION editModifiedSelection
Modified selection notification.
Definition: pcb_actions.h:99
static TOOL_ACTION remove
Deleting a BOARD_ITEM.
Definition: pcb_actions.h:114
EDGE_MODULE class definition.
void AddSimple(const BOARD_ITEM *aItem)
Function AddSimple() Sets an item to be drawn in simple mode (i.e.
void postPushAction(BOARD_ITEM *new_item) override
Definition: edit_tool.cpp:882
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
BOARD_ITEM * GetCurItem()
void SetOffset(const wxPoint &aOffset)
Definition: class_pad.h:190
VECTOR2I GetCenter() const
Returns the center point of the selection area bounding box.
int Duplicate(const TOOL_EVENT &aEvent)
Function Duplicate()
Definition: edit_tool.cpp:760
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:69
static void mirrorPadX(D_PAD &aPad, const wxPoint &aMirrorPoint)
Mirror a pad in the vertical axis passing through a point.
Definition: edit_tool.cpp:547
#define mod(a, n)
Definition: greymap.cpp:24
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer...
static TOOL_ACTION measureTool
Definition: pcb_actions.h:338
const wxPoint & GetOffset() const
Definition: class_pad.h:191
void ClearSimple()
Function ClearSimple() Clears the list of nodes for which ratsnest is drawn in simple mode (one line ...
void SetDelta(const wxSize &aSize)
Definition: class_pad.h:184
bool Apply(COMMIT &aCommit)
Applies values from the dialog to the selected items.
void SetEnd(const VECTOR2I &aEnd)
Set the current end of the rectangle (the end that moves with the cursor.
Color has changed.
Definition: view_item.h:57
BOARD_ITEM * Duplicate(const BOARD_ITEM *aItem, bool aAddToBoard=false)