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-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 <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_DUPLICATE;
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_DUPLICATE: // Duplicate
163  case BLOCK_DUPLICATE_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  MOVE_PARAMETERS params;
192  params.allowOverride = false;
193 
194  DIALOG_MOVE_EXACT dialog( this, params );
195 
196  int ret = dialog.ShowModal();
197 
198  if( ret == wxID_OK )
199  {
200  SaveCopyInUndoList( currentModule, UR_CHANGED );
201  wxPoint blockCentre = GetScreen()->m_BlockLocate.Centre();
202 
203  if( params.origin == RELATIVE_TO_CURRENT_POSITION )
204  {
205  blockCentre = wxPoint( 0, 0 );
206  }
207 
208  wxPoint finalMoveVector = params.translation - blockCentre;
209 
210  MoveMarkedItemsExactly( currentModule, blockCentre, finalMoveVector, params.rotation );
211  }
212  }
213  break;
214 
215  case BLOCK_PRESELECT_MOVE: // Move with preselection list
216  nextcmd = true;
219  break;
220 
221  case BLOCK_DELETE: // Delete
222  itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
223 
224  if( itemsCount )
225  SaveCopyInUndoList( currentModule, UR_CHANGED );
226 
227  DeleteMarkedItems( currentModule );
228  break;
229 
230  case BLOCK_COPY: // Copy
231  case BLOCK_PASTE:
232  case BLOCK_CUT:
233  break;
234 
235  case BLOCK_ROTATE:
236  itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
237 
238  if( itemsCount )
239  SaveCopyInUndoList( currentModule, UR_CHANGED );
240 
241  RotateMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
242  break;
243 
244  case BLOCK_MIRROR_X:
245  case BLOCK_MIRROR_Y:
246  case BLOCK_FLIP: // mirror
247  itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
248 
249  if( itemsCount )
250  SaveCopyInUndoList( currentModule, UR_CHANGED );
251 
252  MirrorMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
253  break;
254 
255  case BLOCK_ZOOM: // Window Zoom
256  Window_Zoom( GetScreen()->m_BlockLocate );
257  break;
258 
259  case BLOCK_ABORT:
260  break;
261 
263  break;
264  }
265 
266  if( !nextcmd )
267  {
268  if( GetScreen()->m_BlockLocate.GetCommand() != BLOCK_SELECT_ITEMS_ONLY )
269  {
270  ClearMarkItems( currentModule );
271  }
272 
274  SetCurItem( NULL );
276  false );
277  m_canvas->Refresh( true );
278  }
279 
280  return nextcmd;
281 }
282 
283 
285 {
286  MODULE* currentModule = GetBoard()->m_Modules;
287 
288  if( !m_canvas->IsMouseCaptured() )
289  {
290  DisplayError( this, wxT( "HandleBlockPLace : m_mouseCaptureCallback = NULL" ) );
291  }
292 
294 
295  const BLOCK_COMMAND_T command = GetScreen()->m_BlockLocate.GetCommand();
296 
297  switch( command )
298  {
299  case BLOCK_IDLE:
300  break;
301 
302  case BLOCK_DRAG: // Drag
303  case BLOCK_MOVE: // Move
304  case BLOCK_PRESELECT_MOVE: // Move with preselection list
306  SaveCopyInUndoList( currentModule, UR_CHANGED );
307  MoveMarkedItems( currentModule, GetScreen()->m_BlockLocate.GetMoveVector() );
308  m_canvas->Refresh( true );
309  break;
310 
311  case BLOCK_DUPLICATE: // Duplicate
312  case BLOCK_DUPLICATE_AND_INCREMENT: // Duplicate and increment pad names
314  SaveCopyInUndoList( currentModule, UR_CHANGED );
315  CopyMarkedItems( currentModule, GetScreen()->m_BlockLocate.GetMoveVector(),
316  command == BLOCK_DUPLICATE_AND_INCREMENT );
317  break;
318 
319  case BLOCK_PASTE: // Paste
321  break;
322 
323  case BLOCK_MIRROR_X:
324  case BLOCK_MIRROR_Y:
325  case BLOCK_FLIP: // Mirror by popup menu, from block move
326  SaveCopyInUndoList( currentModule, UR_CHANGED );
327  MirrorMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
328  break;
329 
330  case BLOCK_ROTATE:
331  SaveCopyInUndoList( currentModule, UR_CHANGED );
332  RotateMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
333  break;
334 
335  case BLOCK_ZOOM: // Handled by HandleBlockEnd
336  case BLOCK_DELETE:
337  case BLOCK_COPY:
338  case BLOCK_ABORT:
339  default:
340  break;
341  }
342 
343  OnModify();
344 
347  SetCurItem( NULL );
348  m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString, false );
349  m_canvas->Refresh( true );
350 }
351 
352 
353 /* Traces the outline of the search block structures
354  * The entire block follows the cursor
355  */
356 static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
357  bool aErase )
358 {
359  BASE_SCREEN* screen = aPanel->GetScreen();
360  FOOTPRINT_EDIT_FRAME* moduleEditFrame = static_cast<FOOTPRINT_EDIT_FRAME*>( aPanel->GetParent() );
361 
362  wxASSERT( moduleEditFrame );
363  MODULE* currentModule = moduleEditFrame->GetBoard()->m_Modules;
364 
365  BLOCK_SELECTOR* block = &screen->m_BlockLocate;
366  GRSetDrawMode( aDC, g_XorMode );
367 
368  if( aErase )
369  {
370  block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
371 
372  if( currentModule )
373  {
374  wxPoint move_offset = -block->GetMoveVector();
375  BOARD_ITEM* item = currentModule->GraphicalItemsList();
376 
377  for( ; item != NULL; item = item->Next() )
378  {
379  if( !item->IsSelected() )
380  continue;
381 
382  switch( item->Type() )
383  {
384  case PCB_MODULE_TEXT_T:
385  case PCB_MODULE_EDGE_T:
386  item->Draw( aPanel, aDC, g_XorMode, move_offset );
387  break;
388 
389  default:
390  break;
391  }
392  }
393 
394  D_PAD* pad = currentModule->PadsList();
395 
396  for( ; pad != NULL; pad = pad->Next() )
397  {
398  if( !pad->IsSelected() )
399  continue;
400 
401  pad->Draw( aPanel, aDC, g_XorMode, move_offset );
402  }
403  }
404  }
405 
406  // Repaint new view.
407  block->SetMoveVector( moduleEditFrame->GetCrossHairPosition() - block->GetLastCursorPosition() );
408 
409  block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
410 
411  if( currentModule )
412  {
413  BOARD_ITEM* item = currentModule->GraphicalItemsList();
414  wxPoint move_offset = - block->GetMoveVector();
415 
416  for( ; item != NULL; item = item->Next() )
417  {
418  if( !item->IsSelected() )
419  continue;
420 
421  switch( item->Type() )
422  {
423  case PCB_MODULE_TEXT_T:
424  case PCB_MODULE_EDGE_T:
425  item->Draw( aPanel, aDC, g_XorMode, move_offset );
426  break;
427 
428  default:
429  break;
430  }
431  }
432 
433  D_PAD* pad = currentModule->PadsList();
434 
435  for( ; pad != NULL; pad = pad->Next() )
436  {
437  if( !pad->IsSelected() )
438  continue;
439 
440  pad->Draw( aPanel, aDC, g_XorMode, move_offset );
441  }
442  }
443 }
444 
445 
446 /* Copy marked items, at new position = old position + offset
447  */
448 void CopyMarkedItems( MODULE* module, wxPoint offset, bool aIncrement )
449 {
450  if( module == NULL )
451  return;
452 
453  // Reference and value cannot be copied, they are unique.
454  // Ensure they are not selected
455  module->Reference().ClearFlags();
456  module->Value().ClearFlags();
457 
458  for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
459  {
460  if( !pad->IsSelected() )
461  continue;
462 
463  pad->ClearFlags( SELECTED );
464  D_PAD* NewPad = new D_PAD( *pad );
465  NewPad->SetParent( module );
466  NewPad->SetFlags( SELECTED );
467  module->PadsList().PushFront( NewPad );
468 
469  if( aIncrement )
470  NewPad->IncrementPadName( true, true );
471  }
472 
473  BOARD_ITEM* newItem;
474 
475  for( BOARD_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() )
476  {
477  if( !item->IsSelected() )
478  continue;
479 
480  item->ClearFlags( SELECTED );
481 
482  newItem = (BOARD_ITEM*)item->Clone();
483  newItem->SetParent( module );
484  newItem->SetFlags( SELECTED );
485  module->GraphicalItemsList().PushFront( newItem );
486  }
487 
488  MoveMarkedItems( module, offset );
489 }
490 
491 
492 /* Move marked items, at new position = old position + offset
493  */
494 void MoveMarkedItems( MODULE* module, wxPoint offset )
495 {
496  EDA_ITEM* item;
497 
498  if( module == NULL )
499  return;
500 
501  if( module->Reference().IsSelected() )
502  module->Reference().Move( offset );
503 
504  if( module->Value().IsSelected() )
505  module->Value().Move( offset );
506 
507  D_PAD* pad = module->PadsList();
508 
509  for( ; pad != NULL; pad = pad->Next() )
510  {
511  if( !pad->IsSelected() )
512  continue;
513 
514  pad->SetPosition( pad->GetPosition() + offset );
515  pad->SetPos0( pad->GetPos0() + offset );
516  }
517 
518  item = module->GraphicalItemsList();
519 
520  for( ; item != NULL; item = item->Next() )
521  {
522  if( !item->IsSelected() )
523  continue;
524 
525  switch( item->Type() )
526  {
527  case PCB_MODULE_TEXT_T:
528  static_cast<TEXTE_MODULE*>( item )->Move( offset );
529  break;
530 
531  case PCB_MODULE_EDGE_T:
532  {
533  EDGE_MODULE* em = (EDGE_MODULE*) item;
534  em->SetStart( em->GetStart() + offset );
535  em->SetEnd( em->GetEnd() + offset );
536  em->SetStart0( em->GetStart0() + offset );
537  em->SetEnd0( em->GetEnd0() + offset );
538  }
539  break;
540 
541  default:
542  ;
543  }
544  }
545 
546  ClearMarkItems( module );
547 }
548 
549 
550 /* Delete marked items
551  */
552 void DeleteMarkedItems( MODULE* module )
553 {
554  if( module == NULL )
555  return;
556 
557  D_PAD* next_pad;
558  BOARD* board = module->GetBoard();
559 
560  for( D_PAD* pad = module->PadsList(); pad; pad = next_pad )
561  {
562  next_pad = pad->Next();
563 
564  if( !pad->IsSelected() )
565  continue;
566 
567  if( board )
568  board->PadDelete( pad );
569  else
570  pad->DeleteStructure();
571  }
572 
573  BOARD_ITEM* next_item;
574 
575  for( BOARD_ITEM* item = module->GraphicalItemsList(); item; item = next_item )
576  {
577  next_item = item->Next();
578 
579  if( !item->IsSelected() )
580  continue;
581 
582  item->DeleteStructure();
583  }
584 
585  // Ref and value can be flagged, but cannot be deleted
586  ClearMarkItems( module );
587 }
588 
589 
594 void MirrorMarkedItems( MODULE* module, wxPoint offset, bool force_all )
595 {
596 #define SETMIRROR( z ) (z) -= offset.x; (z) = -(z); (z) += offset.x;
597  wxPoint tmp;
598  wxSize tmpz;
599 
600  if( module == NULL )
601  return;
602 
603  if( module->Reference().IsSelected() || force_all )
604  module->Reference().Mirror( offset, false );
605 
606  if( module->Value().IsSelected() || force_all )
607  module->Value().Mirror( offset, false );
608 
609  for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
610  {
611  // Skip pads not selected, i.e. not inside the block to mirror:
612  if( !pad->IsSelected() && !force_all )
613  continue;
614 
615  tmp = pad->GetPosition();
616  SETMIRROR( tmp.x );
617  pad->SetPosition( tmp );
618 
619  pad->SetX0( pad->GetPosition().x );
620 
621  tmp = pad->GetOffset();
622  tmp.x = -tmp.x;
623  pad->SetOffset( tmp );
624 
625  tmpz = pad->GetDelta();
626  tmpz.x = -tmpz.x;
627  pad->SetDelta( tmpz );
628 
629  pad->SetOrientation( - pad->GetOrientation() );
630  }
631 
632  for( EDA_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() )
633  {
634  // Skip items not selected, i.e. not inside the block to mirror:
635  if( !item->IsSelected() && !force_all )
636  continue;
637 
638  switch( item->Type() )
639  {
640  case PCB_MODULE_EDGE_T:
641  ((EDGE_MODULE*) item)->Mirror( offset, false );
642  break;
643 
644  case PCB_MODULE_TEXT_T:
645  static_cast<TEXTE_MODULE*>( item )->Mirror( offset, false );
646  break;
647 
648  default:
649  break;
650  }
651  }
652 
653  ClearMarkItems( module );
654 }
655 
656 
661 void RotateMarkedItems( MODULE* module, wxPoint offset, bool force_all )
662 {
663 #define ROTATE( z ) RotatePoint( (&z), offset, 900 )
664 
665  if( module == NULL )
666  return;
667 
668  if( module->Reference().IsSelected() || force_all )
669  module->Reference().Rotate( offset, 900 );
670 
671  if( module->Value().IsSelected() || force_all )
672  module->Value().Rotate( offset, 900 );
673 
674  for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
675  {
676  if( !pad->IsSelected() && !force_all )
677  continue;
678 
679  wxPoint pos = pad->GetPos0();
680  ROTATE( pos );
681  pad->SetPos0( pos );
682  pad->SetOrientation( pad->GetOrientation() + 900 );
683 
684  pad->SetDrawCoord();
685  }
686 
687  for( EDA_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() )
688  {
689  if( !item->IsSelected() && !force_all )
690  continue;
691 
692  switch( item->Type() )
693  {
694  case PCB_MODULE_EDGE_T:
695  ((EDGE_MODULE*) item)->Rotate( offset, 900 );
696  break;
697 
698  case PCB_MODULE_TEXT_T:
699  static_cast<TEXTE_MODULE*>( item )->Rotate( offset, 900 );
700  break;
701 
702  default:
703  break;
704  }
705  }
706 
707  ClearMarkItems( module );
708 }
709 
710 
711 void ClearMarkItems( MODULE* module )
712 {
713  if( module == NULL )
714  return;
715 
716  module->Reference().ClearFlags();
717  module->Value().ClearFlags();
718 
719  EDA_ITEM* item = module->GraphicalItemsList();
720 
721  for( ; item != NULL; item = item->Next() )
722  {
723  item->ClearFlags();
724  }
725 
726  item = module->PadsList();
727 
728  for( ; item != NULL; item = item->Next() )
729  {
730  item->ClearFlags();
731  }
732 }
733 
734 
735 void MoveMarkedItemsExactly( MODULE* module, const wxPoint& centre,
736  const wxPoint& translation,
737  double rotation, bool force_all )
738 {
739  if( module == NULL )
740  return;
741 
742  if( module->Reference().IsSelected() || force_all )
743  {
744  module->Reference().Rotate( centre, rotation );
745  module->Reference().Move( translation );
746  }
747 
748  if( module->Value().IsSelected() || force_all )
749  {
750  module->Value().Rotate( centre, rotation );
751  module->Value().Move( translation );
752  }
753 
754  D_PAD* pad = module->PadsList();
755 
756  for( ; pad != NULL; pad = pad->Next() )
757  {
758  if( !pad->IsSelected() && !force_all )
759  continue;
760 
761  // rotate about centre point,
762  wxPoint newPos = pad->GetPosition();
763  RotatePoint( &newPos, centre, rotation );
764 
765  // shift and update
766  newPos += translation;
767  pad->SetPosition( newPos );
768  pad->SetPos0( newPos );
769 
770  // finally apply rotation to the pad itself
771  pad->Rotate( newPos, rotation );
772  }
773 
774  EDA_ITEM* item = module->GraphicalItemsList();
775 
776  for( ; item != NULL; item = item->Next() )
777  {
778  if( !item->IsSelected() && !force_all )
779  continue;
780 
781  switch( item->Type() )
782  {
783  case PCB_MODULE_TEXT_T:
784  {
785  TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
786 
787  text->Rotate( centre, rotation );
788  text->Move( translation );
789  break;
790  }
791  case PCB_MODULE_EDGE_T:
792  {
793  EDGE_MODULE* em = static_cast<EDGE_MODULE*>( item );
794  em->Rotate( centre, rotation );
795  em->Move( translation );
796  break;
797  }
798  default:
799  ;
800  }
801  }
802 
803  ClearMarkItems( module );
804 }
805 
806 
807 /* Mark items inside rect.
808  * Items are inside rect when an end point is inside rect
809  */
810 int MarkItemsInBloc( MODULE* module, EDA_RECT& Rect )
811 {
812  EDA_ITEM* item;
813  int ItemsCount = 0;
814  wxPoint pos;
815  D_PAD* pad;
816 
817  if( module == NULL )
818  return 0;
819 
820  ClearMarkItems( module ); // Just in case ...
821 
822  pos = module->Reference().GetTextPos();
823 
824  if( Rect.Contains( pos ) )
825  {
826  module->Reference().SetFlags( SELECTED );
827  ItemsCount++;
828  }
829 
830  pos = module->Value().GetTextPos();
831 
832  if( Rect.Contains( pos ) )
833  {
834  module->Value().SetFlags( SELECTED );
835  ItemsCount++;
836  }
837 
838  pad = module->PadsList();
839 
840  for( ; pad != NULL; pad = pad->Next() )
841  {
842  pad->ClearFlags( SELECTED );
843  pos = pad->GetPosition();
844 
845  if( Rect.Contains( pos ) )
846  {
847  pad->SetFlags( SELECTED );
848  ItemsCount++;
849  }
850  }
851 
852  item = module->GraphicalItemsList();
853 
854  for( ; item != NULL; item = item->Next() )
855  {
856  item->ClearFlags( SELECTED );
857 
858  switch( item->Type() )
859  {
860  case PCB_MODULE_EDGE_T:
861  if( ((EDGE_MODULE*)item )->HitTest( Rect ) )
862  {
863  item->SetFlags( SELECTED );
864  ItemsCount++;
865  }
866 
867  break;
868 
869  case PCB_MODULE_TEXT_T:
870  pos = static_cast<TEXTE_MODULE*>( item )->GetTextPos();
871 
872  if( Rect.Contains( pos ) )
873  {
874  item->SetFlags( SELECTED );
875  ItemsCount++;
876  }
877 
878  break;
879 
880  default:
881  break;
882  }
883  }
884 
885  return ItemsCount;
886 }
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:51
bool IncrementPadName(bool aSkipUnconnectable, bool aFillSequenceGaps)
Function IncrementPadName.
Definition: class_pad.cpp:475
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:463
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:1070
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.
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
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: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
#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:462
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:169
DLIST< MODULE > m_Modules
Definition: class_board.h:245
int GetToolId() const
Definition: draw_frame.h:419
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< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:137
DLIST< D_PAD > & PadsList()
Definition: class_module.h:134
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)