KiCad PCB EDA Suite
block_module_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-2012 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 <wxPcbStruct.h>
41 #include <module_editor_frame.h>
42 #include <pcbplot.h>
43 #include <trigo.h>
44 
45 #include <pcbnew.h>
46 
47 #include <class_board.h>
48 #include <class_track.h>
49 #include <class_drawsegment.h>
50 #include <class_pcb_text.h>
51 #include <class_mire.h>
52 #include <class_module.h>
53 #include <class_dimension.h>
54 #include <class_edge_mod.h>
55 
57 
58 
59 #define BLOCK_COLOR BROWN
60 
61 // Functions defined here, but used also in other files
62 // These 3 functions are used in modedit to rotate, mirror or move the
63 // whole footprint so they are called with force_all = true
64 void MirrorMarkedItems( MODULE* module, wxPoint offset, bool force_all = false );
65 void RotateMarkedItems( MODULE* module, wxPoint offset, bool force_all = false );
66 void MoveMarkedItemsExactly( MODULE* module, const wxPoint& centre,
67  const wxPoint& translation, double rotation,
68  bool force_all = false );
69 
70 // Local functions:
71 static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
72  bool aErase );
73 static int MarkItemsInBloc( MODULE* module, EDA_RECT& Rect );
74 
75 static void ClearMarkItems( MODULE* module );
76 static void CopyMarkedItems( MODULE* module, wxPoint offset, bool aIncrement );
77 static void MoveMarkedItems( MODULE* module, wxPoint offset );
78 static void DeleteMarkedItems( MODULE* module );
79 
80 
82 {
83  int cmd;
84 
85  switch( key )
86  {
87  default:
88  cmd = key & 0xFF;
89  break;
90 
91  case EDA_KEY_C( 0xffffffff ): // -1
92  // Historically, -1 has been used as a key, which can cause bit flag
93  // clashes with unaware code. On debug builds, catch any old code that
94  // might still be doing this. TODO: remove if sure all this old code is gone.
95  wxFAIL_MSG( "negative EDA_KEY value should be converted to GR_KEY_INVALID" );
96  // fall through on release builds
97 
98  case GR_KEY_INVALID:
100  break;
101 
102  case 0:
103  cmd = BLOCK_MOVE;
104  break;
105 
106  case GR_KB_ALT:
107  cmd = BLOCK_MIRROR_Y;
108  break;
109 
110  case GR_KB_SHIFTCTRL:
111  cmd = BLOCK_DELETE;
112  break;
113 
114  case GR_KB_SHIFT:
115  cmd = BLOCK_COPY;
116  break;
117 
118  case GR_KB_CTRL:
119  cmd = BLOCK_ROTATE;
120  break;
121 
122  case MOUSE_MIDDLE:
123  cmd = BLOCK_ZOOM;
124  break;
125  }
126 
127  return cmd;
128 }
129 
130 
132 {
133  int itemsCount = 0;
134  bool nextcmd = false;
135  MODULE* currentModule = GetBoard()->m_Modules;
136 
137  if( GetScreen()->m_BlockLocate.GetCount() )
138  {
139  // Set the SELECTED flag of all preselected items, and clear preselect list
140  ClearMarkItems( currentModule );
142 
143  for( unsigned ii = 0, e = list->GetCount(); ii < e; ++ii )
144  {
145  BOARD_ITEM* item = (BOARD_ITEM*) list->GetPickedItem( ii );
146  item->SetFlags( SELECTED );
147  ++itemsCount;
148  }
149 
151  }
152 
153  switch( GetScreen()->m_BlockLocate.GetCommand() )
154  {
155  case BLOCK_IDLE:
156  DisplayError( this, wxT( "Error in HandleBlockPLace" ) );
157  break;
158 
159  case BLOCK_DRAG: // Drag
160  case BLOCK_DRAG_ITEM: // Drag a given item (not used here)
161  case BLOCK_MOVE: // Move
162  case BLOCK_COPY: // Copy
163  case BLOCK_COPY_AND_INCREMENT: // Specific to duplicate with increment command
164 
165  // Find selected items if we didn't already set them manually
166  if( itemsCount == 0 )
167  itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
168 
169  if( itemsCount )
170  {
171  nextcmd = true;
172 
173  if( m_canvas->IsMouseCaptured() )
174  {
175  m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
177  m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
178  }
179 
181  m_canvas->Refresh( true );
182  }
183 
184  break;
185 
186  case BLOCK_MOVE_EXACT:
187  itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
188 
189  if( itemsCount )
190  {
191  wxPoint translation;
192  double rotation = 0;
193 
194  DIALOG_MOVE_EXACT dialog( this, translation, rotation );
195  int ret = dialog.ShowModal();
196 
197  if( ret == wxID_OK )
198  {
199  SaveCopyInUndoList( currentModule, UR_CHANGED );
200  const wxPoint blockCentre = GetScreen()->m_BlockLocate.Centre();
201  MoveMarkedItemsExactly( currentModule, blockCentre, translation, rotation );
202  }
203  }
204  break;
205 
206  case BLOCK_PRESELECT_MOVE: // Move with preselection list
207  nextcmd = true;
210  break;
211 
212  case BLOCK_DELETE: // Delete
213  itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
214 
215  if( itemsCount )
216  SaveCopyInUndoList( currentModule, UR_CHANGED );
217 
218  DeleteMarkedItems( currentModule );
219  break;
220 
221  case BLOCK_SAVE: // Save
222  case BLOCK_PASTE:
223  break;
224 
225  case BLOCK_ROTATE:
226  itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
227 
228  if( itemsCount )
229  SaveCopyInUndoList( currentModule, UR_CHANGED );
230 
231  RotateMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
232  break;
233 
234  case BLOCK_MIRROR_X:
235  case BLOCK_MIRROR_Y:
236  case BLOCK_FLIP: // mirror
237  itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
238 
239  if( itemsCount )
240  SaveCopyInUndoList( currentModule, UR_CHANGED );
241 
242  MirrorMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
243  break;
244 
245  case BLOCK_ZOOM: // Window Zoom
246  Window_Zoom( GetScreen()->m_BlockLocate );
247  break;
248 
249  case BLOCK_ABORT:
250  break;
251 
253  break;
254  }
255 
256  if( !nextcmd )
257  {
258  if( GetScreen()->m_BlockLocate.GetCommand() != BLOCK_SELECT_ITEMS_ONLY )
259  {
260  ClearMarkItems( currentModule );
261  }
262 
264  SetCurItem( NULL );
266  false );
267  m_canvas->Refresh( true );
268  }
269 
270  return nextcmd;
271 }
272 
273 
275 {
276  MODULE* currentModule = GetBoard()->m_Modules;
277 
278  if( !m_canvas->IsMouseCaptured() )
279  {
280  DisplayError( this, wxT( "HandleBlockPLace : m_mouseCaptureCallback = NULL" ) );
281  }
282 
284 
285  const BLOCK_COMMAND_T command = GetScreen()->m_BlockLocate.GetCommand();
286 
287  switch( command )
288  {
289  case BLOCK_IDLE:
290  break;
291 
292  case BLOCK_DRAG: // Drag
293  case BLOCK_MOVE: // Move
294  case BLOCK_PRESELECT_MOVE: // Move with preselection list
296  SaveCopyInUndoList( currentModule, UR_CHANGED );
297  MoveMarkedItems( currentModule, GetScreen()->m_BlockLocate.GetMoveVector() );
298  m_canvas->Refresh( true );
299  break;
300 
301  case BLOCK_COPY: // Copy
302  case BLOCK_COPY_AND_INCREMENT: // Copy and increment pad names
304  SaveCopyInUndoList( currentModule, UR_CHANGED );
305  CopyMarkedItems( currentModule, GetScreen()->m_BlockLocate.GetMoveVector(),
306  command == BLOCK_COPY_AND_INCREMENT );
307  break;
308 
309  case BLOCK_PASTE: // Paste
311  break;
312 
313  case BLOCK_MIRROR_X:
314  case BLOCK_MIRROR_Y:
315  case BLOCK_FLIP: // Mirror by popup menu, from block move
316  SaveCopyInUndoList( currentModule, UR_CHANGED );
317  MirrorMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
318  break;
319 
320  case BLOCK_ROTATE:
321  SaveCopyInUndoList( currentModule, UR_CHANGED );
322  RotateMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
323  break;
324 
325  case BLOCK_ZOOM: // Handled by HandleBlockEnd
326  case BLOCK_DELETE:
327  case BLOCK_SAVE:
328  case BLOCK_ABORT:
329  default:
330  break;
331  }
332 
333  OnModify();
334 
337  SetCurItem( NULL );
338  m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString, false );
339  m_canvas->Refresh( true );
340 }
341 
342 
343 /* Traces the outline of the search block structures
344  * The entire block follows the cursor
345  */
346 static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
347  bool aErase )
348 {
349  BASE_SCREEN* screen = aPanel->GetScreen();
350  FOOTPRINT_EDIT_FRAME* moduleEditFrame = static_cast<FOOTPRINT_EDIT_FRAME*>( aPanel->GetParent() );
351 
352  wxASSERT( moduleEditFrame );
353  MODULE* currentModule = moduleEditFrame->GetBoard()->m_Modules;
354 
355  BLOCK_SELECTOR* block = &screen->m_BlockLocate;
356  GRSetDrawMode( aDC, g_XorMode );
357 
358  if( aErase )
359  {
360  block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
361 
362  if( currentModule )
363  {
364  wxPoint move_offset = -block->GetMoveVector();
365  BOARD_ITEM* item = currentModule->GraphicalItems();
366 
367  for( ; item != NULL; item = item->Next() )
368  {
369  if( !item->IsSelected() )
370  continue;
371 
372  switch( item->Type() )
373  {
374  case PCB_MODULE_TEXT_T:
375  case PCB_MODULE_EDGE_T:
376  item->Draw( aPanel, aDC, g_XorMode, move_offset );
377  break;
378 
379  default:
380  break;
381  }
382  }
383 
384  D_PAD* pad = currentModule->Pads();
385 
386  for( ; pad != NULL; pad = pad->Next() )
387  {
388  if( !pad->IsSelected() )
389  continue;
390 
391  pad->Draw( aPanel, aDC, g_XorMode, move_offset );
392  }
393  }
394  }
395 
396  // Repaint new view.
397  block->SetMoveVector( moduleEditFrame->GetCrossHairPosition() - block->GetLastCursorPosition() );
398 
399  block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
400 
401  if( currentModule )
402  {
403  BOARD_ITEM* item = currentModule->GraphicalItems();
404  wxPoint move_offset = - block->GetMoveVector();
405 
406  for( ; item != NULL; item = item->Next() )
407  {
408  if( !item->IsSelected() )
409  continue;
410 
411  switch( item->Type() )
412  {
413  case PCB_MODULE_TEXT_T:
414  case PCB_MODULE_EDGE_T:
415  item->Draw( aPanel, aDC, g_XorMode, move_offset );
416  break;
417 
418  default:
419  break;
420  }
421  }
422 
423  D_PAD* pad = currentModule->Pads();
424 
425  for( ; pad != NULL; pad = pad->Next() )
426  {
427  if( !pad->IsSelected() )
428  continue;
429 
430  pad->Draw( aPanel, aDC, g_XorMode, move_offset );
431  }
432  }
433 }
434 
435 
436 /* Copy marked items, at new position = old position + offset
437  */
438 void CopyMarkedItems( MODULE* module, wxPoint offset, bool aIncrement )
439 {
440  if( module == NULL )
441  return;
442 
443  // Reference and value cannot be copied, they are unique.
444  // Ensure they are not selected
445  module->Reference().ClearFlags();
446  module->Value().ClearFlags();
447 
448  for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
449  {
450  if( !pad->IsSelected() )
451  continue;
452 
453  pad->ClearFlags( SELECTED );
454  D_PAD* NewPad = new D_PAD( *pad );
455  NewPad->SetParent( module );
456  NewPad->SetFlags( SELECTED );
457  module->Pads().PushFront( NewPad );
458 
459  if( aIncrement )
460  NewPad->IncrementPadName( true, true );
461  }
462 
463  BOARD_ITEM* newItem;
464 
465  for( BOARD_ITEM* item = module->GraphicalItems(); item; item = item->Next() )
466  {
467  if( !item->IsSelected() )
468  continue;
469 
470  item->ClearFlags( SELECTED );
471 
472  newItem = (BOARD_ITEM*)item->Clone();
473  newItem->SetParent( module );
474  newItem->SetFlags( SELECTED );
475  module->GraphicalItems().PushFront( newItem );
476  }
477 
478  MoveMarkedItems( module, offset );
479 }
480 
481 
482 /* Move marked items, at new position = old position + offset
483  */
484 void MoveMarkedItems( MODULE* module, wxPoint offset )
485 {
486  EDA_ITEM* item;
487 
488  if( module == NULL )
489  return;
490 
491  if( module->Reference().IsSelected() )
492  module->Reference().Move( offset );
493 
494  if( module->Value().IsSelected() )
495  module->Value().Move( offset );
496 
497  D_PAD* pad = module->Pads();
498 
499  for( ; pad != NULL; pad = pad->Next() )
500  {
501  if( !pad->IsSelected() )
502  continue;
503 
504  pad->SetPosition( pad->GetPosition() + offset );
505  pad->SetPos0( pad->GetPos0() + offset );
506  }
507 
508  item = module->GraphicalItems();
509 
510  for( ; item != NULL; item = item->Next() )
511  {
512  if( !item->IsSelected() )
513  continue;
514 
515  switch( item->Type() )
516  {
517  case PCB_MODULE_TEXT_T:
518  static_cast<TEXTE_MODULE*>( item )->Move( offset );
519  break;
520 
521  case PCB_MODULE_EDGE_T:
522  {
523  EDGE_MODULE* em = (EDGE_MODULE*) item;
524  em->SetStart( em->GetStart() + offset );
525  em->SetEnd( em->GetEnd() + offset );
526  em->SetStart0( em->GetStart0() + offset );
527  em->SetEnd0( em->GetEnd0() + offset );
528  }
529  break;
530 
531  default:
532  ;
533  }
534  }
535 
536  ClearMarkItems( module );
537 }
538 
539 
540 /* Delete marked items
541  */
542 void DeleteMarkedItems( MODULE* module )
543 {
544  if( module == NULL )
545  return;
546 
547  D_PAD* next_pad;
548  BOARD* board = module->GetBoard();
549 
550  for( D_PAD* pad = module->Pads(); pad; pad = next_pad )
551  {
552  next_pad = pad->Next();
553 
554  if( !pad->IsSelected() )
555  continue;
556 
557  if( board )
558  board->PadDelete( pad );
559  else
560  pad->DeleteStructure();
561  }
562 
563  BOARD_ITEM* next_item;
564 
565  for( BOARD_ITEM* item = module->GraphicalItems(); item; item = next_item )
566  {
567  next_item = item->Next();
568 
569  if( !item->IsSelected() )
570  continue;
571 
572  item->DeleteStructure();
573  }
574 
575  // Ref and value can be flagged, but cannot be deleted
576  ClearMarkItems( module );
577 }
578 
579 
584 void MirrorMarkedItems( MODULE* module, wxPoint offset, bool force_all )
585 {
586 #define SETMIRROR( z ) (z) -= offset.x; (z) = -(z); (z) += offset.x;
587  wxPoint tmp;
588  wxSize tmpz;
589 
590  if( module == NULL )
591  return;
592 
593  if( module->Reference().IsSelected() || force_all )
594  module->Reference().Mirror( offset, false );
595 
596  if( module->Value().IsSelected() || force_all )
597  module->Value().Mirror( offset, false );
598 
599  for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
600  {
601  // Skip pads not selected, i.e. not inside the block to mirror:
602  if( !pad->IsSelected() && !force_all )
603  continue;
604 
605  tmp = pad->GetPosition();
606  SETMIRROR( tmp.x );
607  pad->SetPosition( tmp );
608 
609  pad->SetX0( pad->GetPosition().x );
610 
611  tmp = pad->GetOffset();
612  tmp.x = -tmp.x;
613  pad->SetOffset( tmp );
614 
615  tmpz = pad->GetDelta();
616  tmpz.x = -tmpz.x;
617  pad->SetDelta( tmpz );
618 
619  pad->SetOrientation( - pad->GetOrientation() );
620  }
621 
622  for( EDA_ITEM* item = module->GraphicalItems(); item; item = item->Next() )
623  {
624  // Skip items not selected, i.e. not inside the block to mirror:
625  if( !item->IsSelected() && !force_all )
626  continue;
627 
628  switch( item->Type() )
629  {
630  case PCB_MODULE_EDGE_T:
631  ((EDGE_MODULE*) item)->Mirror( offset, false );
632  break;
633 
634  case PCB_MODULE_TEXT_T:
635  static_cast<TEXTE_MODULE*>( item )->Mirror( offset, false );
636  break;
637 
638  default:
639  break;
640  }
641  }
642 
643  ClearMarkItems( module );
644 }
645 
646 
651 void RotateMarkedItems( MODULE* module, wxPoint offset, bool force_all )
652 {
653 #define ROTATE( z ) RotatePoint( (&z), offset, 900 )
654 
655  if( module == NULL )
656  return;
657 
658  if( module->Reference().IsSelected() || force_all )
659  module->Reference().Rotate( offset, 900 );
660 
661  if( module->Value().IsSelected() || force_all )
662  module->Value().Rotate( offset, 900 );
663 
664  for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
665  {
666  if( !pad->IsSelected() && !force_all )
667  continue;
668 
669  wxPoint pos = pad->GetPos0();
670  ROTATE( pos );
671  pad->SetPos0( pos );
672  pad->SetOrientation( pad->GetOrientation() + 900 );
673 
674  pad->SetDrawCoord();
675  }
676 
677  for( EDA_ITEM* item = module->GraphicalItems(); item; item = item->Next() )
678  {
679  if( !item->IsSelected() && !force_all )
680  continue;
681 
682  switch( item->Type() )
683  {
684  case PCB_MODULE_EDGE_T:
685  ((EDGE_MODULE*) item)->Rotate( offset, 900 );
686  break;
687 
688  case PCB_MODULE_TEXT_T:
689  static_cast<TEXTE_MODULE*>( item )->Rotate( offset, 900 );
690  break;
691 
692  default:
693  break;
694  }
695  }
696 
697  ClearMarkItems( module );
698 }
699 
700 
701 void ClearMarkItems( MODULE* module )
702 {
703  if( module == NULL )
704  return;
705 
706  module->Reference().ClearFlags();
707  module->Value().ClearFlags();
708 
709  EDA_ITEM* item = module->GraphicalItems();
710 
711  for( ; item != NULL; item = item->Next() )
712  {
713  item->ClearFlags();
714  }
715 
716  item = module->Pads();
717 
718  for( ; item != NULL; item = item->Next() )
719  {
720  item->ClearFlags();
721  }
722 }
723 
724 
725 void MoveMarkedItemsExactly( MODULE* module, const wxPoint& centre,
726  const wxPoint& translation,
727  double rotation, bool force_all )
728 {
729  if( module == NULL )
730  return;
731 
732  if( module->Reference().IsSelected() || force_all )
733  {
734  module->Reference().Rotate( centre, rotation );
735  module->Reference().Move( translation );
736  }
737 
738  if( module->Value().IsSelected() || force_all )
739  {
740  module->Value().Rotate( centre, rotation );
741  module->Value().Move( translation );
742  }
743 
744  D_PAD* pad = module->Pads();
745 
746  for( ; pad != NULL; pad = pad->Next() )
747  {
748  if( !pad->IsSelected() && !force_all )
749  continue;
750 
751  // rotate about centre point,
752  wxPoint newPos = pad->GetPosition();
753  RotatePoint( &newPos, centre, rotation );
754 
755  // shift and update
756  newPos += translation;
757  pad->SetPosition( newPos );
758  pad->SetPos0( newPos );
759 
760  // finally apply rotation to the pad itself
761  pad->Rotate( newPos, rotation );
762  }
763 
764  EDA_ITEM* item = module->GraphicalItems();
765 
766  for( ; item != NULL; item = item->Next() )
767  {
768  if( !item->IsSelected() && !force_all )
769  continue;
770 
771  switch( item->Type() )
772  {
773  case PCB_MODULE_TEXT_T:
774  {
775  TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
776 
777  text->Rotate( centre, rotation );
778  text->Move( translation );
779  break;
780  }
781  case PCB_MODULE_EDGE_T:
782  {
783  EDGE_MODULE* em = static_cast<EDGE_MODULE*>( item );
784  em->Rotate( centre, rotation );
785  em->Move( translation );
786  break;
787  }
788  default:
789  ;
790  }
791  }
792 
793  ClearMarkItems( module );
794 }
795 
796 
797 /* Mark items inside rect.
798  * Items are inside rect when an end point is inside rect
799  */
800 int MarkItemsInBloc( MODULE* module, EDA_RECT& Rect )
801 {
802  EDA_ITEM* item;
803  int ItemsCount = 0;
804  wxPoint pos;
805  D_PAD* pad;
806 
807  if( module == NULL )
808  return 0;
809 
810  ClearMarkItems( module ); // Just in case ...
811 
812  pos = module->Reference().GetTextPos();
813 
814  if( Rect.Contains( pos ) )
815  {
816  module->Reference().SetFlags( SELECTED );
817  ItemsCount++;
818  }
819 
820  pos = module->Value().GetTextPos();
821 
822  if( Rect.Contains( pos ) )
823  {
824  module->Value().SetFlags( SELECTED );
825  ItemsCount++;
826  }
827 
828  pad = module->Pads();
829 
830  for( ; pad != NULL; pad = pad->Next() )
831  {
832  pad->ClearFlags( SELECTED );
833  pos = pad->GetPosition();
834 
835  if( Rect.Contains( pos ) )
836  {
837  pad->SetFlags( SELECTED );
838  ItemsCount++;
839  }
840  }
841 
842  item = module->GraphicalItems();
843 
844  for( ; item != NULL; item = item->Next() )
845  {
846  item->ClearFlags( SELECTED );
847 
848  switch( item->Type() )
849  {
850  case PCB_MODULE_EDGE_T:
851  if( ((EDGE_MODULE*)item )->HitTest( Rect ) )
852  {
853  item->SetFlags( SELECTED );
854  ItemsCount++;
855  }
856 
857  break;
858 
859  case PCB_MODULE_TEXT_T:
860  pos = static_cast<TEXTE_MODULE*>( item )->GetTextPos();
861 
862  if( Rect.Contains( pos ) )
863  {
864  item->SetFlags( SELECTED );
865  ItemsCount++;
866  }
867 
868  break;
869 
870  default:
871  break;
872  }
873  }
874 
875  return ItemsCount;
876 }
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:51
bool IncrementPadName(bool aSkipUnconnectable, bool aFillSequenceGaps)
Function IncrementPadName.
Definition: class_pad.cpp:424
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
void SetEnd0(const wxPoint &aPoint)
Definition of class FOOTPRINT_EDIT_FRAME.
TEXTE_MODULE & Reference()
Definition: class_module.h:455
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
PCB_TARGET class definition.
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...
TEXTE_PCB class definition.
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:290
const wxPoint & GetTextPos() const
Definition: eda_text.h:224
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:836
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Definition: draw_panel.cpp:326
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)
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 return the current cursor shape, depending on the current selected tool...
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:221
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:169
const wxPoint & GetPos0() const
Definition: class_pad.h:176
void ClearBlockCommand()
EDA_ITEM * Next() const
Definition: base_struct.h:206
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
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.
static int MarkItemsInBloc(MODULE *module, EDA_RECT &Rect)
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:106
#define GR_KB_ALT
Definition: common.h:65
DLIST< BOARD_ITEM > & GraphicalItems()
Definition: class_module.h:136
#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:120
static void MoveMarkedItems(MODULE *module, wxPoint offset)
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
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 ...
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:253
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:213
#define GR_KB_SHIFT
Definition: common.h:66
bool IsMouseCaptured() const
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:454
void SetPos0(const wxPoint &aPos)
Definition: class_pad.h:175
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
const wxPoint & GetPosition() const override
Definition: class_pad.h:170
static void DeleteMarkedItems(MODULE *module)
void CallMouseCapture(wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function CallMouseCapture calls the mouse capture callback.
D_PAD * Next() const
Definition: class_pad.h:106
void MoveMarkedItemsExactly(MODULE *module, const wxPoint &centre, const wxPoint &translation, double rotation, bool force_all=false)
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:175
wxPoint Centre() const
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:172
#define GR_KB_SHIFTCTRL
Definition: common.h:67
void SetMouseCaptureCallback(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback)
static void CopyMarkedItems(MODULE *module, wxPoint offset, bool aIncrement)
#define SETMIRROR(z)
Definition: solve.cpp:178
void SetStart(const wxPoint &aStart)
unsigned GetCount() const
Function GetCount.
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:105
wxPoint GetLastCursorPosition() const
static void ClearMarkItems(MODULE *module)
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:92
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:166
DLIST< MODULE > m_Modules
Definition: class_board.h:243
int GetToolId() const
Definition: draw_frame.h:406
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.
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:188
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.
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:254
void Window_Zoom(EDA_RECT &Rect)
Compute the zoom factor and the new draw offset to draw the selected area (Rect) in full window scree...
Definition: zoom.cpp:103
BLOCK_COMMAND_T GetCommand() const
DLIST< D_PAD > & Pads()
Definition: class_module.h:133
Module description (excepted pads)
#define EDA_KEY_C
Definition: common.h:60
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 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...
static void DrawMovingBlockOutlines(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
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
#define ROTATE(z)