KiCad PCB EDA Suite
block_footprint_editor.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) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
5  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
7  * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
32 #include <fctsys.h>
33 #include <pgm_base.h>
34 #include <gr_basic.h>
35 #include <class_drawpanel.h>
36 #include <confirm.h>
37 #include <block_commande.h>
38 #include <macros.h>
39 
40 #include <footprint_edit_frame.h>
41 #include <pcbplot.h>
42 #include <trigo.h>
43 
44 #include <pcbnew.h>
45 
46 #include <class_board.h>
47 #include <class_track.h>
48 #include <class_drawsegment.h>
49 #include <class_pcb_text.h>
50 #include <class_pcb_target.h>
51 #include <class_module.h>
52 #include <class_dimension.h>
53 #include <class_edge_mod.h>
54 
56 
57 
58 #define BLOCK_COLOR BROWN
59 
60 // Functions defined here, but used also in other files
61 // These 3 functions are used in modedit to rotate, mirror or move the
62 // whole footprint so they are called with force_all = true
63 void MirrorMarkedItems( MODULE* module, wxPoint offset, bool force_all = false );
64 void RotateMarkedItems( MODULE* module, wxPoint offset, bool force_all = false );
65 void MoveMarkedItemsExactly( MODULE* module, const wxPoint& centre,
66  const wxPoint& translation, double rotation,
67  bool force_all = false );
68 
69 // Local functions:
70 static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
71  bool aErase );
72 static int MarkItemsInBloc( MODULE* module, EDA_RECT& Rect );
73 
74 static void ClearMarkItems( MODULE* module );
75 static void CopyMarkedItems( MODULE* module, wxPoint offset, bool aIncrement );
76 static void MoveMarkedItems( MODULE* module, wxPoint offset );
77 static void DeleteMarkedItems( MODULE* module );
78 
79 
81 {
82  int cmd;
83 
84  switch( key )
85  {
86  default:
87  cmd = key & 0xFF;
88  break;
89 
90  case EDA_KEY_C( 0xffffffff ): // -1
91  // Historically, -1 has been used as a key, which can cause bit flag
92  // clashes with unaware code. On debug builds, catch any old code that
93  // might still be doing this. TODO: remove if sure all this old code is gone.
94  wxFAIL_MSG( "negative EDA_KEY value should be converted to GR_KEY_INVALID" );
95  // fall through on release builds
96 
97  case GR_KEY_INVALID:
99  break;
100 
101  case 0:
102  cmd = BLOCK_MOVE;
103  break;
104 
105  case GR_KB_ALT:
106  cmd = BLOCK_MIRROR_Y;
107  break;
108 
109  case GR_KB_SHIFTCTRL:
110  cmd = BLOCK_DELETE;
111  break;
112 
113  case GR_KB_SHIFT:
114  cmd = BLOCK_DUPLICATE;
115  break;
116 
117  case GR_KB_CTRL:
118  cmd = BLOCK_ROTATE;
119  break;
120 
121  case MOUSE_MIDDLE:
122  cmd = BLOCK_ZOOM;
123  break;
124  }
125 
126  return cmd;
127 }
128 
129 
131 {
132  int itemsCount = 0;
133  bool nextcmd = false;
134  MODULE* currentModule = GetBoard()->m_Modules;
135 
136  if( GetScreen()->m_BlockLocate.GetCount() )
137  {
138  // Set the SELECTED flag of all preselected items, and clear preselect list
139  ClearMarkItems( currentModule );
141 
142  for( unsigned ii = 0, e = list->GetCount(); ii < e; ++ii )
143  {
144  BOARD_ITEM* item = (BOARD_ITEM*) list->GetPickedItem( ii );
145  item->SetFlags( SELECTED );
146  ++itemsCount;
147  }
148 
150  }
151 
152  switch( GetScreen()->m_BlockLocate.GetCommand() )
153  {
154  case BLOCK_IDLE:
155  DisplayError( this, wxT( "Error in HandleBlockPLace" ) );
156  break;
157 
158  case BLOCK_DRAG: // Drag
159  case BLOCK_DRAG_ITEM: // Drag a given item (not used here)
160  case BLOCK_MOVE: // Move
161  case BLOCK_DUPLICATE: // Duplicate
162  case BLOCK_DUPLICATE_AND_INCREMENT: // Specific to duplicate with increment command
163 
164  // Find selected items if we didn't already set them manually
165  if( itemsCount == 0 )
166  itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
167 
168  if( itemsCount )
169  {
170  nextcmd = true;
171 
172  if( m_canvas->IsMouseCaptured() )
173  {
174  m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
176  m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
177  }
178 
180  m_canvas->Refresh( true );
181  }
182 
183  break;
184 
185  case BLOCK_MOVE_EXACT:
186  itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
187 
188  if( itemsCount )
189  {
190  MOVE_PARAMETERS params;
191  params.allowOverride = false;
192 
193  DIALOG_MOVE_EXACT dialog( this, params );
194 
195  int ret = dialog.ShowModal();
196 
197  if( ret == wxID_OK )
198  {
199  SaveCopyInUndoList( currentModule, UR_CHANGED );
200  wxPoint blockCentre = GetScreen()->m_BlockLocate.Centre();
201 
202  if( params.origin == RELATIVE_TO_CURRENT_POSITION )
203  {
204  blockCentre = wxPoint( 0, 0 );
205  }
206 
207  wxPoint finalMoveVector = params.translation - blockCentre;
208 
209  MoveMarkedItemsExactly( currentModule, blockCentre, finalMoveVector, params.rotation );
210  }
211  }
212  break;
213 
214  case BLOCK_PRESELECT_MOVE: // Move with preselection list
215  nextcmd = true;
218  break;
219 
220  case BLOCK_DELETE: // Delete
221  itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
222 
223  if( itemsCount )
224  SaveCopyInUndoList( currentModule, UR_CHANGED );
225 
226  DeleteMarkedItems( currentModule );
227  break;
228 
229  case BLOCK_COPY: // Copy
230  case BLOCK_PASTE:
231  case BLOCK_CUT:
232  break;
233 
234  case BLOCK_ROTATE:
235  itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
236 
237  if( itemsCount )
238  SaveCopyInUndoList( currentModule, UR_CHANGED );
239 
240  RotateMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
241  break;
242 
243  case BLOCK_MIRROR_X:
244  case BLOCK_MIRROR_Y:
245  case BLOCK_FLIP: // mirror
246  itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
247 
248  if( itemsCount )
249  SaveCopyInUndoList( currentModule, UR_CHANGED );
250 
251  MirrorMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
252  break;
253 
254  case BLOCK_ZOOM: // Window Zoom
255  Window_Zoom( GetScreen()->m_BlockLocate );
256  break;
257 
258  case BLOCK_ABORT:
259  break;
260 
262  break;
263  }
264 
265  if( !nextcmd )
266  {
267  if( GetScreen()->m_BlockLocate.GetCommand() != BLOCK_SELECT_ITEMS_ONLY )
268  {
269  ClearMarkItems( currentModule );
270  }
271 
273  SetCurItem( NULL );
275  false );
276  m_canvas->Refresh( true );
277  }
278 
279  return nextcmd;
280 }
281 
282 
284 {
285  MODULE* currentModule = GetBoard()->m_Modules;
286 
287  if( !m_canvas->IsMouseCaptured() )
288  {
289  DisplayError( this, wxT( "HandleBlockPLace : m_mouseCaptureCallback = NULL" ) );
290  }
291 
293 
294  const BLOCK_COMMAND_T command = GetScreen()->m_BlockLocate.GetCommand();
295 
296  switch( command )
297  {
298  case BLOCK_IDLE:
299  break;
300 
301  case BLOCK_DRAG: // Drag
302  case BLOCK_MOVE: // Move
303  case BLOCK_PRESELECT_MOVE: // Move with preselection list
305  SaveCopyInUndoList( currentModule, UR_CHANGED );
306  MoveMarkedItems( currentModule, GetScreen()->m_BlockLocate.GetMoveVector() );
307  m_canvas->Refresh( true );
308  break;
309 
310  case BLOCK_DUPLICATE: // Duplicate
311  case BLOCK_DUPLICATE_AND_INCREMENT: // Duplicate and increment pad names
313  SaveCopyInUndoList( currentModule, UR_CHANGED );
314  CopyMarkedItems( currentModule, GetScreen()->m_BlockLocate.GetMoveVector(),
315  command == BLOCK_DUPLICATE_AND_INCREMENT );
316  break;
317 
318  case BLOCK_PASTE: // Paste
320  break;
321 
322  case BLOCK_MIRROR_X:
323  case BLOCK_MIRROR_Y:
324  case BLOCK_FLIP: // Mirror by popup menu, from block move
325  SaveCopyInUndoList( currentModule, UR_CHANGED );
326  MirrorMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
327  break;
328 
329  case BLOCK_ROTATE:
330  SaveCopyInUndoList( currentModule, UR_CHANGED );
331  RotateMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
332  break;
333 
334  case BLOCK_ZOOM: // Handled by HandleBlockEnd
335  case BLOCK_DELETE:
336  case BLOCK_COPY:
337  case BLOCK_ABORT:
338  default:
339  break;
340  }
341 
342  OnModify();
343 
346  SetCurItem( NULL );
347  m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString, false );
348  m_canvas->Refresh( true );
349 }
350 
351 
352 /* Traces the outline of the search block structures
353  * The entire block follows the cursor
354  */
355 static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
356  bool aErase )
357 {
358  BASE_SCREEN* screen = aPanel->GetScreen();
359  FOOTPRINT_EDIT_FRAME* moduleEditFrame = static_cast<FOOTPRINT_EDIT_FRAME*>( aPanel->GetParent() );
360 
361  wxASSERT( moduleEditFrame );
362  MODULE* currentModule = moduleEditFrame->GetBoard()->m_Modules;
363 
364  BLOCK_SELECTOR* block = &screen->m_BlockLocate;
365  GRSetDrawMode( aDC, g_XorMode );
366 
367  if( aErase )
368  {
369  block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
370 
371  if( currentModule )
372  {
373  wxPoint move_offset = -block->GetMoveVector();
374  BOARD_ITEM* item = currentModule->GraphicalItemsList();
375 
376  for( ; item != NULL; item = item->Next() )
377  {
378  if( !item->IsSelected() )
379  continue;
380 
381  switch( item->Type() )
382  {
383  case PCB_MODULE_TEXT_T:
384  case PCB_MODULE_EDGE_T:
385  item->Draw( aPanel, aDC, g_XorMode, move_offset );
386  break;
387 
388  default:
389  break;
390  }
391  }
392 
393  D_PAD* pad = currentModule->PadsList();
394 
395  for( ; pad != NULL; pad = pad->Next() )
396  {
397  if( !pad->IsSelected() )
398  continue;
399 
400  pad->Draw( aPanel, aDC, g_XorMode, move_offset );
401  }
402  }
403  }
404 
405  // Repaint new view.
406  block->SetMoveVector( moduleEditFrame->GetCrossHairPosition() - block->GetLastCursorPosition() );
407 
408  block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
409 
410  if( currentModule )
411  {
412  BOARD_ITEM* item = currentModule->GraphicalItemsList();
413  wxPoint move_offset = - block->GetMoveVector();
414 
415  for( ; item != NULL; item = item->Next() )
416  {
417  if( !item->IsSelected() )
418  continue;
419 
420  switch( item->Type() )
421  {
422  case PCB_MODULE_TEXT_T:
423  case PCB_MODULE_EDGE_T:
424  item->Draw( aPanel, aDC, g_XorMode, move_offset );
425  break;
426 
427  default:
428  break;
429  }
430  }
431 
432  D_PAD* pad = currentModule->PadsList();
433 
434  for( ; pad != NULL; pad = pad->Next() )
435  {
436  if( !pad->IsSelected() )
437  continue;
438 
439  pad->Draw( aPanel, aDC, g_XorMode, move_offset );
440  }
441  }
442 }
443 
444 
445 /* Copy marked items, at new position = old position + offset
446  */
447 void CopyMarkedItems( MODULE* module, wxPoint offset, bool aIncrement )
448 {
449  if( module == NULL )
450  return;
451 
452  // Reference and value cannot be copied, they are unique.
453  // Ensure they are not selected
454  module->Reference().ClearFlags();
455  module->Value().ClearFlags();
456 
457  for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
458  {
459  if( !pad->IsSelected() )
460  continue;
461 
462  pad->ClearFlags( SELECTED );
463  D_PAD* NewPad = new D_PAD( *pad );
464  NewPad->SetParent( module );
465  NewPad->SetFlags( SELECTED );
466  module->PadsList().PushFront( NewPad );
467 
468  if( aIncrement )
469  NewPad->IncrementPadName( true, true );
470  }
471 
472  BOARD_ITEM* newItem;
473 
474  for( BOARD_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() )
475  {
476  if( !item->IsSelected() )
477  continue;
478 
479  item->ClearFlags( SELECTED );
480 
481  newItem = (BOARD_ITEM*)item->Clone();
482  newItem->SetParent( module );
483  newItem->SetFlags( SELECTED );
484  module->GraphicalItemsList().PushFront( newItem );
485  }
486 
487  MoveMarkedItems( module, offset );
488 }
489 
490 
491 /* Move marked items, at new position = old position + offset
492  */
493 void MoveMarkedItems( MODULE* module, wxPoint offset )
494 {
495  EDA_ITEM* item;
496 
497  if( module == NULL )
498  return;
499 
500  if( module->Reference().IsSelected() )
501  module->Reference().Move( offset );
502 
503  if( module->Value().IsSelected() )
504  module->Value().Move( offset );
505 
506  D_PAD* pad = module->PadsList();
507 
508  for( ; pad != NULL; pad = pad->Next() )
509  {
510  if( !pad->IsSelected() )
511  continue;
512 
513  pad->SetPosition( pad->GetPosition() + offset );
514  pad->SetPos0( pad->GetPos0() + offset );
515  }
516 
517  item = module->GraphicalItemsList();
518 
519  for( ; item != NULL; item = item->Next() )
520  {
521  if( !item->IsSelected() )
522  continue;
523 
524  switch( item->Type() )
525  {
526  case PCB_MODULE_TEXT_T:
527  static_cast<TEXTE_MODULE*>( item )->Move( offset );
528  break;
529 
530  case PCB_MODULE_EDGE_T:
531  {
532  EDGE_MODULE* em = (EDGE_MODULE*) item;
533  em->SetStart( em->GetStart() + offset );
534  em->SetEnd( em->GetEnd() + offset );
535  em->SetStart0( em->GetStart0() + offset );
536  em->SetEnd0( em->GetEnd0() + offset );
537  }
538  break;
539 
540  default:
541  ;
542  }
543  }
544 
545  ClearMarkItems( module );
546 }
547 
548 
549 /* Delete marked items
550  */
551 void DeleteMarkedItems( MODULE* module )
552 {
553  if( module == NULL )
554  return;
555 
556  D_PAD* next_pad;
557  BOARD* board = module->GetBoard();
558 
559  for( D_PAD* pad = module->PadsList(); pad; pad = next_pad )
560  {
561  next_pad = pad->Next();
562 
563  if( !pad->IsSelected() )
564  continue;
565 
566  if( board )
567  board->PadDelete( pad );
568  else
569  pad->DeleteStructure();
570  }
571 
572  BOARD_ITEM* next_item;
573 
574  for( BOARD_ITEM* item = module->GraphicalItemsList(); item; item = next_item )
575  {
576  next_item = item->Next();
577 
578  if( !item->IsSelected() )
579  continue;
580 
581  item->DeleteStructure();
582  }
583 
584  // Ref and value can be flagged, but cannot be deleted
585  ClearMarkItems( module );
586 }
587 
588 
593 void MirrorMarkedItems( MODULE* module, wxPoint offset, bool force_all )
594 {
595 #define SETMIRROR( z ) (z) -= offset.x; (z) = -(z); (z) += offset.x;
596  wxPoint tmp;
597  wxSize tmpz;
598 
599  if( module == NULL )
600  return;
601 
602  if( module->Reference().IsSelected() || force_all )
603  module->Reference().Mirror( offset, false );
604 
605  if( module->Value().IsSelected() || force_all )
606  module->Value().Mirror( offset, false );
607 
608  for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
609  {
610  // Skip pads not selected, i.e. not inside the block to mirror:
611  if( !pad->IsSelected() && !force_all )
612  continue;
613 
614  tmp = pad->GetPosition();
615  SETMIRROR( tmp.x );
616  pad->SetPosition( tmp );
617 
618  pad->SetX0( pad->GetPosition().x );
619 
620  tmp = pad->GetOffset();
621  tmp.x = -tmp.x;
622  pad->SetOffset( tmp );
623 
624  tmpz = pad->GetDelta();
625  tmpz.x = -tmpz.x;
626  pad->SetDelta( tmpz );
627 
628  pad->SetOrientation( - pad->GetOrientation() );
629  }
630 
631  for( EDA_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() )
632  {
633  // Skip items not selected, i.e. not inside the block to mirror:
634  if( !item->IsSelected() && !force_all )
635  continue;
636 
637  switch( item->Type() )
638  {
639  case PCB_MODULE_EDGE_T:
640  ((EDGE_MODULE*) item)->Mirror( offset, false );
641  break;
642 
643  case PCB_MODULE_TEXT_T:
644  static_cast<TEXTE_MODULE*>( item )->Mirror( offset, false );
645  break;
646 
647  default:
648  break;
649  }
650  }
651 
652  ClearMarkItems( module );
653 }
654 
655 
660 void RotateMarkedItems( MODULE* module, wxPoint offset, bool force_all )
661 {
662 #define ROTATE( z ) RotatePoint( (&z), offset, 900 )
663 
664  if( module == NULL )
665  return;
666 
667  if( module->Reference().IsSelected() || force_all )
668  module->Reference().Rotate( offset, 900 );
669 
670  if( module->Value().IsSelected() || force_all )
671  module->Value().Rotate( offset, 900 );
672 
673  for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
674  {
675  if( !pad->IsSelected() && !force_all )
676  continue;
677 
678  wxPoint pos = pad->GetPos0();
679  ROTATE( pos );
680  pad->SetPos0( pos );
681  pad->SetOrientation( pad->GetOrientation() + 900 );
682 
683  pad->SetDrawCoord();
684  }
685 
686  for( EDA_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() )
687  {
688  if( !item->IsSelected() && !force_all )
689  continue;
690 
691  switch( item->Type() )
692  {
693  case PCB_MODULE_EDGE_T:
694  ((EDGE_MODULE*) item)->Rotate( offset, 900 );
695  break;
696 
697  case PCB_MODULE_TEXT_T:
698  static_cast<TEXTE_MODULE*>( item )->Rotate( offset, 900 );
699  break;
700 
701  default:
702  break;
703  }
704  }
705 
706  ClearMarkItems( module );
707 }
708 
709 
710 void ClearMarkItems( MODULE* module )
711 {
712  if( module == NULL )
713  return;
714 
715  module->Reference().ClearFlags();
716  module->Value().ClearFlags();
717 
718  EDA_ITEM* item = module->GraphicalItemsList();
719 
720  for( ; item != NULL; item = item->Next() )
721  {
722  item->ClearFlags();
723  }
724 
725  item = module->PadsList();
726 
727  for( ; item != NULL; item = item->Next() )
728  {
729  item->ClearFlags();
730  }
731 }
732 
733 
734 void MoveMarkedItemsExactly( MODULE* module, const wxPoint& centre,
735  const wxPoint& translation,
736  double rotation, bool force_all )
737 {
738  if( module == NULL )
739  return;
740 
741  if( module->Reference().IsSelected() || force_all )
742  {
743  module->Reference().Rotate( centre, rotation );
744  module->Reference().Move( translation );
745  }
746 
747  if( module->Value().IsSelected() || force_all )
748  {
749  module->Value().Rotate( centre, rotation );
750  module->Value().Move( translation );
751  }
752 
753  D_PAD* pad = module->PadsList();
754 
755  for( ; pad != NULL; pad = pad->Next() )
756  {
757  if( !pad->IsSelected() && !force_all )
758  continue;
759 
760  // rotate about centre point,
761  wxPoint newPos = pad->GetPosition();
762  RotatePoint( &newPos, centre, rotation );
763 
764  // shift and update
765  newPos += translation;
766  pad->SetPosition( newPos );
767  pad->SetPos0( newPos );
768 
769  // finally apply rotation to the pad itself
770  pad->Rotate( newPos, rotation );
771  }
772 
773  EDA_ITEM* item = module->GraphicalItemsList();
774 
775  for( ; item != NULL; item = item->Next() )
776  {
777  if( !item->IsSelected() && !force_all )
778  continue;
779 
780  switch( item->Type() )
781  {
782  case PCB_MODULE_TEXT_T:
783  {
784  TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
785 
786  text->Rotate( centre, rotation );
787  text->Move( translation );
788  break;
789  }
790  case PCB_MODULE_EDGE_T:
791  {
792  EDGE_MODULE* em = static_cast<EDGE_MODULE*>( item );
793  em->Rotate( centre, rotation );
794  em->Move( translation );
795  break;
796  }
797  default:
798  ;
799  }
800  }
801 
802  ClearMarkItems( module );
803 }
804 
805 
806 /* Mark items inside rect.
807  * Items are inside rect when an end point is inside rect
808  */
809 int MarkItemsInBloc( MODULE* module, EDA_RECT& Rect )
810 {
811  EDA_ITEM* item;
812  int ItemsCount = 0;
813  wxPoint pos;
814  D_PAD* pad;
815 
816  if( module == NULL )
817  return 0;
818 
819  ClearMarkItems( module ); // Just in case ...
820 
821  pos = module->Reference().GetTextPos();
822 
823  if( Rect.Contains( pos ) )
824  {
825  module->Reference().SetFlags( SELECTED );
826  ItemsCount++;
827  }
828 
829  pos = module->Value().GetTextPos();
830 
831  if( Rect.Contains( pos ) )
832  {
833  module->Value().SetFlags( SELECTED );
834  ItemsCount++;
835  }
836 
837  pad = module->PadsList();
838 
839  for( ; pad != NULL; pad = pad->Next() )
840  {
841  pad->ClearFlags( SELECTED );
842  pos = pad->GetPosition();
843 
844  if( Rect.Contains( pos ) )
845  {
846  pad->SetFlags( SELECTED );
847  ItemsCount++;
848  }
849  }
850 
851  item = module->GraphicalItemsList();
852 
853  for( ; item != NULL; item = item->Next() )
854  {
855  item->ClearFlags( SELECTED );
856 
857  switch( item->Type() )
858  {
859  case PCB_MODULE_EDGE_T:
860  if( ((EDGE_MODULE*)item )->HitTest( Rect ) )
861  {
862  item->SetFlags( SELECTED );
863  ItemsCount++;
864  }
865 
866  break;
867 
868  case PCB_MODULE_TEXT_T:
869  pos = static_cast<TEXTE_MODULE*>( item )->GetTextPos();
870 
871  if( Rect.Contains( pos ) )
872  {
873  item->SetFlags( SELECTED );
874  ItemsCount++;
875  }
876 
877  break;
878 
879  default:
880  break;
881  }
882  }
883 
884  return ItemsCount;
885 }
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:73
#define SETMIRROR(z)
bool IncrementPadName(bool aSkipUnconnectable, bool aFillSequenceGaps)
Function IncrementPadName.
Definition: class_pad.cpp:515
KICAD_T Type() const
Function Type()
Definition: base_struct.h:209
void SetEnd0(const wxPoint &aPoint)
void MirrorMarkedItems(MODULE *module, wxPoint offset, bool force_all=false)
Mirror marked items, refer to a Vertical axis at position offset Note: because this function is used ...
TEXTE_MODULE & Reference()
Definition: class_module.h:502
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
Definition: base_screen.h:214
TEXTE_PCB class definition.
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:318
const wxPoint & GetTextPos() const
Definition: eda_text.h:222
void PadDelete(D_PAD *aPad)
Function PadDelete deletes a given bad from the BOARD by removing it from its module and from the m_N...
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Function Rotate Rotate this object.
Definition: class_pad.cpp:1142
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:338
void PushFront(T *aNewElement)
Function PushFront puts aNewElement at front of list sequence.
Definition: dlist.h:240
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor)
static void ClearMarkItems(MODULE *module)
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...
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, GR_DRAWMODE aDrawMode, const wxPoint &aOffset=ZeroOffset) override
Function Draw BOARD_ITEMs have their own color information.
virtual EDA_ITEM * Clone() const
Function Clone creates a duplicate of this item with linked list members set to NULL.
int GetCurrentCursor() const
Function GetCurrentCursor.
bool Contains(const wxPoint &aPoint) const
Function Contains.
void Rotate(const wxPoint &aOffset, double aAngle) override
Rotate text, in footprint editor (for instance in footprint rotation transform)
Class BOARD to handle a board.
void SetMoveVector(const wxPoint &aMoveVector)
const wxPoint & GetEnd0() const
void Move(const wxPoint &aMoveVector) override
move text in move transform, in footprint editor
void SetCurItem(BOARD_ITEM *aItem, bool aDisplayInfo=true)
Function SetCurItem sets the currently selected item and displays it in the MsgPanel.
bool IsSelected() const
Definition: base_struct.h:232
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.
void DeleteStructure()
Function DeleteStructure deletes this object after UnLink()ing it from its owner if it has one...
BLOCK_COMMAND_T
BOARD * GetBoard() const
void SetPosition(const wxPoint &aPos) override
Definition: class_pad.h:219
static void CopyMarkedItems(MODULE *module, wxPoint offset, bool aIncrement)
const wxPoint & GetPos0() const
Definition: class_pad.h:263
void ClearBlockCommand()
Definition: base_screen.h:501
EDA_ITEM * Next() const
Definition: base_struct.h:217
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
static int MarkItemsInBloc(MODULE *module, EDA_RECT &Rect)
virtual void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, GR_DRAWMODE aDrawMode, const wxPoint &offset=ZeroOffset)=0
Function Draw BOARD_ITEMs have their own color information.
Definition of class FOOTPRINT_EDIT_FRAME.
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
#define GR_KB_ALT
Definition: common.h:65
#define GR_KEY_INVALID
Definition: common.h:69
Functions relatives to tracks, vias and segments used to fill zones.
This file contains miscellaneous commonly used macros and functions.
void ClearItemsList()
Function ClearItemsList clear only the list of EDA_ITEM pointers, it does NOT delete the EDA_ITEM obj...
Board plot function definition file.
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate an edge of the footprint.
BOARD_ITEM * Next() const
void SetState(BLOCK_STATE_T aState)
DIMENSION class definition.
#define SELECTED
Definition: base_struct.h:116
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:264
COLOR4D GetColor() const
virtual void HandleBlockPlace(wxDC *DC) override
Function HandleBlockPlace handles the BLOCK PLACE command Last routine for block operation for: ...
virtual void OnModify() override
Virtual Function OnModify() Must be called after a footprint change in order to set the "modify" flag...
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:224
#define GR_KB_SHIFT
Definition: common.h:66
bool IsMouseCaptured() const
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:501
void SetPos0(const wxPoint &aPos)
Definition: class_pad.h:262
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
void CallMouseCapture(wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function CallMouseCapture calls the mouse capture callback.
D_PAD * Next() const
Definition: class_pad.h:160
uint32_t EDA_KEY
Definition: common.h:52
virtual int BlockCommand(EDA_KEY key) override
Function BlockCommand Returns the block command code (BLOCK_MOVE, BLOCK_COPY...) corresponding to the...
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
#define ROTATE(z)
wxPoint Centre() const
Definition: eda_rect.h:60
Class PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
void SaveCopyInUndoList(BOARD_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, const wxPoint &aTransformPoint=wxPoint(0, 0)) override
Function SaveCopyInUndoList Creates a new entry in undo list of commands.
Definition: undo_redo.cpp:202
#define GR_KB_SHIFTCTRL
Definition: common.h:67
void SetMouseCaptureCallback(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback)
Definition: solve.cpp:178
void SetStart(const wxPoint &aStart)
unsigned GetCount() const
Function GetCount.
void RotateMarkedItems(MODULE *module, wxPoint offset, bool force_all=false)
Rotate marked items, refer to a rotation point at position offset Note: because this function is used...
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
wxPoint GetLastCursorPosition() const
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:106
This file is part of the common library.
see class PGM_BASE
Class to handle a graphic segment.
const wxPoint & GetStart0() const
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
Function GetPickedItem.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
DLIST< MODULE > m_Modules
Definition: class_board.h:245
static void DrawMovingBlockOutlines(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
int GetToolId() const
Definition: draw_frame.h:496
void Move(const wxPoint &aMoveVector) override
Move an edge of the footprint.
#define MOUSE_MIDDLE
Definition: common.h:68
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
void SetStart0(const wxPoint &aPoint)
T Mirror(T aPoint, T aMirrorRef)
Function MIRROR Mirror aPoint in aMirrorRef.
Definition: macros.h:106
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:193
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:162
static void MoveMarkedItems(MODULE *module, wxPoint offset)
PCB_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
void Mirror(const wxPoint &aCentre, bool aMirrorAroundXAxis)
Mirror text position in footprint edition the text itself is not mirrored, and the layer not modified...
PICKED_ITEMS_LIST & GetItems()
void SetEnd(const wxPoint &aEnd)
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:265
void Window_Zoom(EDA_RECT &Rect)
Definition: zoom.cpp:124
BLOCK_COMMAND_T GetCommand() const
PCB_TARGET class definition.
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:164
DLIST< D_PAD > & PadsList()
Definition: class_module.h:161
static void DeleteMarkedItems(MODULE *module)
Module description (excepted pads)
#define EDA_KEY_C
Definition: common.h:60
const wxPoint GetPosition() const override
Definition: class_pad.h:220
EDGE_MODULE class definition.
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
#define GR_KB_CTRL
Definition: common.h:64
void MoveMarkedItemsExactly(MODULE *module, const wxPoint &centre, const wxPoint &translation, double rotation, bool force_all=false)
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:185
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
virtual bool HandleBlockEnd(wxDC *DC) override
Function HandleBlockEnd( ) Handle the "end" of a block command, i.e.
void SetCommand(BLOCK_COMMAND_T aCommand)
wxPoint GetMoveVector() const