KiCad PCB EDA Suite
block_footprint_editor.cpp File Reference
#include <fctsys.h>
#include <pgm_base.h>
#include <gr_basic.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <block_commande.h>
#include <macros.h>
#include <footprint_edit_frame.h>
#include <pcbplot.h>
#include <trigo.h>
#include <pcbnew.h>
#include <class_board.h>
#include <class_track.h>
#include <class_drawsegment.h>
#include <class_pcb_text.h>
#include <class_pcb_target.h>
#include <class_module.h>
#include <class_dimension.h>
#include <class_edge_mod.h>
#include <dialogs/dialog_move_exact.h>

Go to the source code of this file.

Macros

#define BLOCK_COLOR   BROWN
 
#define SETMIRROR(z)   (z) -= offset.x; (z) = -(z); (z) += offset.x;
 
#define ROTATE(z)   RotatePoint( (&z), offset, 900 )
 

Functions

void MirrorMarkedItems (MODULE *module, wxPoint offset, bool force_all)
 Mirror marked items, refer to a Vertical axis at position offset Note: because this function is used in global transform, if force_all is true, all items will be mirrored. More...
 
void RotateMarkedItems (MODULE *module, wxPoint offset, bool force_all)
 Rotate marked items, refer to a rotation point at position offset Note: because this function is used in global transform, if force_all is true, all items will be rotated. More...
 
void MoveMarkedItemsExactly (MODULE *module, const wxPoint &centre, const wxPoint &translation, double rotation, bool force_all=false)
 
static void DrawMovingBlockOutlines (EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
 
static int MarkItemsInBloc (MODULE *module, EDA_RECT &Rect)
 
static void ClearMarkItems (MODULE *module)
 
static void CopyMarkedItems (MODULE *module, wxPoint offset, bool aIncrement)
 
static void MoveMarkedItems (MODULE *module, wxPoint offset)
 
static void DeleteMarkedItems (MODULE *module)
 

Macro Definition Documentation

#define BLOCK_COLOR   BROWN

Definition at line 58 of file block_footprint_editor.cpp.

#define ROTATE (   z)    RotatePoint( (&z), offset, 900 )

Referenced by RotateMarkedItems().

#define SETMIRROR (   z)    (z) -= offset.x; (z) = -(z); (z) += offset.x;

Referenced by MirrorMarkedItems().

Function Documentation

void ClearMarkItems ( MODULE module)
static

Definition at line 714 of file block_footprint_editor.cpp.

References EDA_ITEM::ClearFlags(), MODULE::GraphicalItemsList(), EDA_ITEM::Next(), MODULE::PadsList(), MODULE::Reference(), and MODULE::Value().

Referenced by DeleteMarkedItems(), FOOTPRINT_EDIT_FRAME::HandleBlockEnd(), MarkItemsInBloc(), MirrorMarkedItems(), MoveMarkedItems(), MoveMarkedItemsExactly(), and RotateMarkedItems().

715 {
716  if( module == NULL )
717  return;
718 
719  module->Reference().ClearFlags();
720  module->Value().ClearFlags();
721 
722  EDA_ITEM* item = module->GraphicalItemsList();
723 
724  for( ; item != NULL; item = item->Next() )
725  {
726  item->ClearFlags();
727  }
728 
729  item = module->PadsList();
730 
731  for( ; item != NULL; item = item->Next() )
732  {
733  item->ClearFlags();
734  }
735 }
TEXTE_MODULE & Reference()
Definition: class_module.h:513
EDA_ITEM * Next() const
Definition: base_struct.h:209
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:512
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:166
DLIST< D_PAD > & PadsList()
Definition: class_module.h:163
void CopyMarkedItems ( MODULE module,
wxPoint  offset,
bool  aIncrement 
)
static

Definition at line 450 of file block_footprint_editor.cpp.

References EDA_ITEM::ClearFlags(), EDA_ITEM::Clone(), MODULE::GraphicalItemsList(), D_PAD::IncrementPadName(), MoveMarkedItems(), BOARD_ITEM::Next(), D_PAD::Next(), MODULE::PadsList(), DLIST< T >::PushFront(), MODULE::Reference(), SELECTED, EDA_ITEM::SetFlags(), EDA_ITEM::SetParent(), and MODULE::Value().

Referenced by FOOTPRINT_EDIT_FRAME::HandleBlockPlace().

451 {
452  if( module == NULL )
453  return;
454 
455  // Reference and value cannot be copied, they are unique.
456  // Ensure they are not selected
457  module->Reference().ClearFlags();
458  module->Value().ClearFlags();
459 
460  for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
461  {
462  if( !pad->IsSelected() )
463  continue;
464 
465  pad->ClearFlags( SELECTED );
466  D_PAD* NewPad = new D_PAD( *pad );
467  NewPad->SetParent( module );
468  NewPad->SetFlags( SELECTED );
469  module->PadsList().PushFront( NewPad );
470 
471  if( aIncrement )
472  NewPad->IncrementPadName( true, true );
473  }
474 
475  BOARD_ITEM* newItem;
476 
477  for( BOARD_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() )
478  {
479  if( !item->IsSelected() )
480  continue;
481 
482  item->ClearFlags( SELECTED );
483 
484  newItem = (BOARD_ITEM*)item->Clone();
485  newItem->SetParent( module );
486  newItem->SetFlags( SELECTED );
487  module->GraphicalItemsList().PushFront( newItem );
488  }
489 
490  MoveMarkedItems( module, offset );
491 }
bool IncrementPadName(bool aSkipUnconnectable, bool aFillSequenceGaps)
Function IncrementPadName.
Definition: class_pad.cpp:532
TEXTE_MODULE & Reference()
Definition: class_module.h:513
void PushFront(T *aNewElement)
Function PushFront puts aNewElement at front of list sequence.
Definition: dlist.h:240
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
virtual EDA_ITEM * Clone() const
Function Clone creates a duplicate of this item with linked list members set to NULL.
BOARD_ITEM * Next() const
#define SELECTED
Definition: base_struct.h:121
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:256
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:216
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:512
D_PAD * Next() const
Definition: class_pad.h:160
static void MoveMarkedItems(MODULE *module, wxPoint offset)
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:166
DLIST< D_PAD > & PadsList()
Definition: class_module.h:163
void DeleteMarkedItems ( MODULE module)
static

Definition at line 555 of file block_footprint_editor.cpp.

References ClearMarkItems(), BOARD_ITEM::DeleteStructure(), BOARD_ITEM::GetBoard(), MODULE::GraphicalItemsList(), BOARD_ITEM::Next(), D_PAD::Next(), BOARD::PadDelete(), and MODULE::PadsList().

Referenced by FOOTPRINT_EDIT_FRAME::HandleBlockEnd().

556 {
557  if( module == NULL )
558  return;
559 
560  D_PAD* next_pad;
561  BOARD* board = module->GetBoard();
562 
563  for( D_PAD* pad = module->PadsList(); pad; pad = next_pad )
564  {
565  next_pad = pad->Next();
566 
567  if( !pad->IsSelected() )
568  continue;
569 
570  if( board )
571  board->PadDelete( pad );
572  else
573  pad->DeleteStructure();
574  }
575 
576  BOARD_ITEM* next_item;
577 
578  for( BOARD_ITEM* item = module->GraphicalItemsList(); item; item = next_item )
579  {
580  next_item = item->Next();
581 
582  if( !item->IsSelected() )
583  continue;
584 
585  item->DeleteStructure();
586  }
587 
588  // Ref and value can be flagged, but cannot be deleted
589  ClearMarkItems( module );
590 }
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...
static void ClearMarkItems(MODULE *module)
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
void DeleteStructure()
Function DeleteStructure deletes this object after UnLink()ing it from its owner if it has one...
BOARD_ITEM * Next() const
D_PAD * Next() const
Definition: class_pad.h:160
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:170
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:166
DLIST< D_PAD > & PadsList()
Definition: class_module.h:163
static void DrawMovingBlockOutlines ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
const wxPoint aPosition,
bool  aErase 
)
static

Definition at line 358 of file block_footprint_editor.cpp.

References BLOCK_SELECTOR::Draw(), BOARD_ITEM::Draw(), D_PAD::Draw(), g_XorMode, PCB_BASE_FRAME::GetBoard(), BLOCK_SELECTOR::GetColor(), EDA_DRAW_FRAME::GetCrossHairPosition(), BLOCK_SELECTOR::GetLastCursorPosition(), BLOCK_SELECTOR::GetMoveVector(), EDA_DRAW_PANEL::GetParent(), EDA_DRAW_PANEL::GetScreen(), MODULE::GraphicalItemsList(), GRSetDrawMode(), EDA_ITEM::IsSelected(), BASE_SCREEN::m_BlockLocate, BOARD::m_Modules, BOARD_ITEM::Next(), D_PAD::Next(), MODULE::PadsList(), PCB_MODULE_EDGE_T, PCB_MODULE_TEXT_T, BLOCK_SELECTOR::SetMoveVector(), and EDA_ITEM::Type().

Referenced by FOOTPRINT_EDIT_FRAME::HandleBlockEnd().

360 {
361  BASE_SCREEN* screen = aPanel->GetScreen();
362  FOOTPRINT_EDIT_FRAME* moduleEditFrame = static_cast<FOOTPRINT_EDIT_FRAME*>( aPanel->GetParent() );
363 
364  wxASSERT( moduleEditFrame );
365  MODULE* currentModule = moduleEditFrame->GetBoard()->m_Modules;
366 
367  BLOCK_SELECTOR* block = &screen->m_BlockLocate;
368  GRSetDrawMode( aDC, g_XorMode );
369 
370  if( aErase )
371  {
372  block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
373 
374  if( currentModule )
375  {
376  wxPoint move_offset = -block->GetMoveVector();
377  BOARD_ITEM* item = currentModule->GraphicalItemsList();
378 
379  for( ; item != NULL; item = item->Next() )
380  {
381  if( !item->IsSelected() )
382  continue;
383 
384  switch( item->Type() )
385  {
386  case PCB_MODULE_TEXT_T:
387  case PCB_MODULE_EDGE_T:
388  item->Draw( aPanel, aDC, g_XorMode, move_offset );
389  break;
390 
391  default:
392  break;
393  }
394  }
395 
396  D_PAD* pad = currentModule->PadsList();
397 
398  for( ; pad != NULL; pad = pad->Next() )
399  {
400  if( !pad->IsSelected() )
401  continue;
402 
403  pad->Draw( aPanel, aDC, g_XorMode, move_offset );
404  }
405  }
406  }
407 
408  // Repaint new view.
409  block->SetMoveVector( moduleEditFrame->GetCrossHairPosition() - block->GetLastCursorPosition() );
410 
411  block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
412 
413  if( currentModule )
414  {
415  BOARD_ITEM* item = currentModule->GraphicalItemsList();
416  wxPoint move_offset = - block->GetMoveVector();
417 
418  for( ; item != NULL; item = item->Next() )
419  {
420  if( !item->IsSelected() )
421  continue;
422 
423  switch( item->Type() )
424  {
425  case PCB_MODULE_TEXT_T:
426  case PCB_MODULE_EDGE_T:
427  item->Draw( aPanel, aDC, g_XorMode, move_offset );
428  break;
429 
430  default:
431  break;
432  }
433  }
434 
435  D_PAD* pad = currentModule->PadsList();
436 
437  for( ; pad != NULL; pad = pad->Next() )
438  {
439  if( !pad->IsSelected() )
440  continue;
441 
442  pad->Draw( aPanel, aDC, g_XorMode, move_offset );
443  }
444  }
445 }
virtual BASE_SCREEN * GetScreen()=0
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:74
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
Definition: base_screen.h:214
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:223
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor)
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.
void SetMoveVector(const wxPoint &aMoveVector)
bool IsSelected() const
Definition: base_struct.h:224
BOARD * GetBoard() const
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.
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
BOARD_ITEM * Next() const
virtual EDA_DRAW_FRAME * GetParent() const =0
COLOR4D GetColor() const
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
D_PAD * Next() const
Definition: class_pad.h:160
Definition: solve.cpp:178
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
wxPoint GetLastCursorPosition() const
DLIST< MODULE > m_Modules
Definition: class_board.h:248
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:166
DLIST< D_PAD > & PadsList()
Definition: class_module.h:163
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
wxPoint GetMoveVector() const
int MarkItemsInBloc ( MODULE module,
EDA_RECT Rect 
)
static

Definition at line 813 of file block_footprint_editor.cpp.

References EDA_ITEM::ClearFlags(), ClearMarkItems(), EDA_RECT::Contains(), D_PAD::GetPosition(), EDA_TEXT::GetTextPos(), MODULE::GraphicalItemsList(), D_PAD::Next(), EDA_ITEM::Next(), MODULE::PadsList(), PCB_MODULE_EDGE_T, PCB_MODULE_TEXT_T, MODULE::Reference(), SELECTED, EDA_ITEM::SetFlags(), EDA_ITEM::Type(), and MODULE::Value().

Referenced by FOOTPRINT_EDIT_FRAME::HandleBlockEnd().

814 {
815  EDA_ITEM* item;
816  int ItemsCount = 0;
817  wxPoint pos;
818  D_PAD* pad;
819 
820  if( module == NULL )
821  return 0;
822 
823  ClearMarkItems( module ); // Just in case ...
824 
825  pos = module->Reference().GetTextPos();
826 
827  if( Rect.Contains( pos ) )
828  {
829  module->Reference().SetFlags( SELECTED );
830  ItemsCount++;
831  }
832 
833  pos = module->Value().GetTextPos();
834 
835  if( Rect.Contains( pos ) )
836  {
837  module->Value().SetFlags( SELECTED );
838  ItemsCount++;
839  }
840 
841  pad = module->PadsList();
842 
843  for( ; pad != NULL; pad = pad->Next() )
844  {
845  pad->ClearFlags( SELECTED );
846  pos = pad->GetPosition();
847 
848  if( Rect.Contains( pos ) )
849  {
850  pad->SetFlags( SELECTED );
851  ItemsCount++;
852  }
853  }
854 
855  item = module->GraphicalItemsList();
856 
857  for( ; item != NULL; item = item->Next() )
858  {
859  item->ClearFlags( SELECTED );
860 
861  switch( item->Type() )
862  {
863  case PCB_MODULE_EDGE_T:
864  if( ((EDGE_MODULE*)item )->HitTest( Rect ) )
865  {
866  item->SetFlags( SELECTED );
867  ItemsCount++;
868  }
869 
870  break;
871 
872  case PCB_MODULE_TEXT_T:
873  pos = static_cast<TEXTE_MODULE*>( item )->GetTextPos();
874 
875  if( Rect.Contains( pos ) )
876  {
877  item->SetFlags( SELECTED );
878  ItemsCount++;
879  }
880 
881  break;
882 
883  default:
884  break;
885  }
886  }
887 
888  return ItemsCount;
889 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
TEXTE_MODULE & Reference()
Definition: class_module.h:513
const wxPoint & GetTextPos() const
Definition: eda_text.h:237
static void ClearMarkItems(MODULE *module)
bool Contains(const wxPoint &aPoint) const
Function Contains.
EDA_ITEM * Next() const
Definition: base_struct.h:209
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
#define SELECTED
Definition: base_struct.h:121
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:256
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:512
D_PAD * Next() const
Definition: class_pad.h:160
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:166
DLIST< D_PAD > & PadsList()
Definition: class_module.h:163
const wxPoint GetPosition() const override
Definition: class_pad.h:220
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 in global transform, if force_all is true, all items will be mirrored.

Definition at line 597 of file block_footprint_editor.cpp.

References ClearMarkItems(), MODULE::GraphicalItemsList(), EDA_ITEM::IsSelected(), Mirror(), TEXTE_MODULE::Mirror(), BOARD_ITEM::Next(), D_PAD::Next(), MODULE::PadsList(), PCB_MODULE_EDGE_T, PCB_MODULE_TEXT_T, MODULE::Reference(), SETMIRROR, MODULE::Value(), and wxPoint::x.

Referenced by FOOTPRINT_EDIT_FRAME::HandleBlockEnd(), FOOTPRINT_EDIT_FRAME::HandleBlockPlace(), and FOOTPRINT_EDIT_FRAME::Transform().

598 {
599 #define SETMIRROR( z ) (z) -= offset.x; (z) = -(z); (z) += offset.x;
600  wxPoint tmp;
601  wxSize tmpz;
602 
603  if( module == NULL )
604  return;
605 
606  if( module->Reference().IsSelected() || force_all )
607  module->Reference().Mirror( offset, false );
608 
609  if( module->Value().IsSelected() || force_all )
610  module->Value().Mirror( offset, false );
611 
612  for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
613  {
614  // Skip pads not selected, i.e. not inside the block to mirror:
615  if( !pad->IsSelected() && !force_all )
616  continue;
617 
618  tmp = pad->GetPosition();
619  SETMIRROR( tmp.x );
620  pad->SetPosition( tmp );
621 
622  pad->SetX0( pad->GetPosition().x );
623 
624  tmp = pad->GetOffset();
625  tmp.x = -tmp.x;
626  pad->SetOffset( tmp );
627 
628  tmpz = pad->GetDelta();
629  tmpz.x = -tmpz.x;
630  pad->SetDelta( tmpz );
631 
632  pad->SetOrientation( - pad->GetOrientation() );
633  }
634 
635  for( EDA_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() )
636  {
637  // Skip items not selected, i.e. not inside the block to mirror:
638  if( !item->IsSelected() && !force_all )
639  continue;
640 
641  switch( item->Type() )
642  {
643  case PCB_MODULE_EDGE_T:
644  ((EDGE_MODULE*) item)->Mirror( offset, false );
645  break;
646 
647  case PCB_MODULE_TEXT_T:
648  static_cast<TEXTE_MODULE*>( item )->Mirror( offset, false );
649  break;
650 
651  default:
652  break;
653  }
654  }
655 
656  ClearMarkItems( module );
657 }
#define SETMIRROR(z)
TEXTE_MODULE & Reference()
Definition: class_module.h:513
static void ClearMarkItems(MODULE *module)
bool IsSelected() const
Definition: base_struct.h:224
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
BOARD_ITEM * Next() const
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:512
D_PAD * Next() const
Definition: class_pad.h:160
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
T Mirror(T aPoint, T aMirrorRef)
Function MIRROR Mirror aPoint in aMirrorRef.
Definition: macros.h:106
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
void Mirror(const wxPoint &aCentre, bool aMirrorAroundXAxis)
Mirror text position in footprint editing the text itself is not mirrored, and the layer not modified...
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:166
DLIST< D_PAD > & PadsList()
Definition: class_module.h:163
void MoveMarkedItems ( MODULE module,
wxPoint  offset 
)
static

Definition at line 496 of file block_footprint_editor.cpp.

References ClearMarkItems(), EDGE_MODULE::GetBezier0_C1(), EDGE_MODULE::GetBezier0_C2(), EDGE_MODULE::GetEnd0(), D_PAD::GetPos0(), D_PAD::GetPosition(), EDGE_MODULE::GetStart0(), MODULE::GraphicalItemsList(), EDA_ITEM::IsSelected(), EDGE_MODULE::Move(), TEXTE_MODULE::Move(), D_PAD::Next(), EDA_ITEM::Next(), MODULE::PadsList(), PCB_MODULE_EDGE_T, PCB_MODULE_TEXT_T, MODULE::Reference(), EDGE_MODULE::SetBezier0_C1(), EDGE_MODULE::SetBezier0_C2(), EDGE_MODULE::SetEnd0(), D_PAD::SetPos0(), D_PAD::SetPosition(), EDGE_MODULE::SetStart0(), EDA_ITEM::Type(), and MODULE::Value().

Referenced by CopyMarkedItems(), and FOOTPRINT_EDIT_FRAME::HandleBlockPlace().

497 {
498  EDA_ITEM* item;
499 
500  if( module == NULL )
501  return;
502 
503  if( module->Reference().IsSelected() )
504  module->Reference().Move( offset );
505 
506  if( module->Value().IsSelected() )
507  module->Value().Move( offset );
508 
509  D_PAD* pad = module->PadsList();
510 
511  for( ; pad != NULL; pad = pad->Next() )
512  {
513  if( !pad->IsSelected() )
514  continue;
515 
516  pad->SetPosition( pad->GetPosition() + offset );
517  pad->SetPos0( pad->GetPos0() + offset );
518  }
519 
520  item = module->GraphicalItemsList();
521 
522  for( ; item != NULL; item = item->Next() )
523  {
524  if( !item->IsSelected() )
525  continue;
526 
527  switch( item->Type() )
528  {
529  case PCB_MODULE_TEXT_T:
530  static_cast<TEXTE_MODULE*>( item )->Move( offset );
531  break;
532 
533  case PCB_MODULE_EDGE_T:
534  {
535  EDGE_MODULE* em = (EDGE_MODULE*) item;
536  em->Move( offset );
537  em->SetStart0( em->GetStart0() + offset );
538  em->SetEnd0( em->GetEnd0() + offset );
539  em->SetBezier0_C1( em->GetBezier0_C1() + offset );
540  em->SetBezier0_C2( em->GetBezier0_C2() + offset );
541  }
542  break;
543 
544  default:
545  ;
546  }
547  }
548 
549  ClearMarkItems( module );
550 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
void SetEnd0(const wxPoint &aPoint)
TEXTE_MODULE & Reference()
Definition: class_module.h:513
static void ClearMarkItems(MODULE *module)
const wxPoint & GetBezier0_C2() const
void SetBezier0_C1(const wxPoint &aPoint)
void SetBezier0_C2(const wxPoint &aPoint)
const wxPoint & GetEnd0() const
void Move(const wxPoint &aMoveVector) override
move text in move transform, in footprint editor
bool IsSelected() const
Definition: base_struct.h:224
void SetPosition(const wxPoint &aPos) override
Definition: class_pad.h:219
const wxPoint & GetPos0() const
Definition: class_pad.h:263
EDA_ITEM * Next() const
Definition: base_struct.h:209
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:512
void SetPos0(const wxPoint &aPos)
Definition: class_pad.h:262
D_PAD * Next() const
Definition: class_pad.h:160
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
const wxPoint & GetStart0() const
void Move(const wxPoint &aMoveVector) override
Move an edge of the footprint.
void SetStart0(const wxPoint &aPoint)
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:166
DLIST< D_PAD > & PadsList()
Definition: class_module.h:163
const wxPoint GetPosition() const override
Definition: class_pad.h:220
const wxPoint & GetBezier0_C1() const
void MoveMarkedItemsExactly ( MODULE module,
const wxPoint centre,
const wxPoint translation,
double  rotation,
bool  force_all = false 
)

Definition at line 738 of file block_footprint_editor.cpp.

References ClearMarkItems(), D_PAD::GetPosition(), MODULE::GraphicalItemsList(), EDA_ITEM::IsSelected(), EDGE_MODULE::Move(), TEXTE_MODULE::Move(), D_PAD::Next(), EDA_ITEM::Next(), MODULE::PadsList(), PCB_MODULE_EDGE_T, PCB_MODULE_TEXT_T, MODULE::Reference(), EDGE_MODULE::Rotate(), TEXTE_MODULE::Rotate(), D_PAD::Rotate(), RotatePoint(), D_PAD::SetPos0(), D_PAD::SetPosition(), EDA_ITEM::Type(), and MODULE::Value().

Referenced by FOOTPRINT_EDIT_FRAME::HandleBlockEnd(), and FOOTPRINT_EDIT_FRAME::Transform().

741 {
742  if( module == NULL )
743  return;
744 
745  if( module->Reference().IsSelected() || force_all )
746  {
747  module->Reference().Rotate( centre, rotation );
748  module->Reference().Move( translation );
749  }
750 
751  if( module->Value().IsSelected() || force_all )
752  {
753  module->Value().Rotate( centre, rotation );
754  module->Value().Move( translation );
755  }
756 
757  D_PAD* pad = module->PadsList();
758 
759  for( ; pad != NULL; pad = pad->Next() )
760  {
761  if( !pad->IsSelected() && !force_all )
762  continue;
763 
764  // rotate about centre point,
765  wxPoint newPos = pad->GetPosition();
766  RotatePoint( &newPos, centre, rotation );
767 
768  // shift and update
769  newPos += translation;
770  pad->SetPosition( newPos );
771  pad->SetPos0( newPos );
772 
773  // finally apply rotation to the pad itself
774  pad->Rotate( newPos, rotation );
775  }
776 
777  EDA_ITEM* item = module->GraphicalItemsList();
778 
779  for( ; item != NULL; item = item->Next() )
780  {
781  if( !item->IsSelected() && !force_all )
782  continue;
783 
784  switch( item->Type() )
785  {
786  case PCB_MODULE_TEXT_T:
787  {
788  TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
789 
790  text->Rotate( centre, rotation );
791  text->Move( translation );
792  break;
793  }
794  case PCB_MODULE_EDGE_T:
795  {
796  EDGE_MODULE* em = static_cast<EDGE_MODULE*>( item );
797  em->Rotate( centre, rotation );
798  em->Move( translation );
799  break;
800  }
801  default:
802  ;
803  }
804  }
805 
806  ClearMarkItems( module );
807 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
TEXTE_MODULE & Reference()
Definition: class_module.h:513
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Function Rotate Rotate this object.
Definition: class_pad.cpp:1160
static void ClearMarkItems(MODULE *module)
void Rotate(const wxPoint &aOffset, double aAngle) override
Rotate text, in footprint editor (for instance in footprint rotation transform)
void Move(const wxPoint &aMoveVector) override
move text in move transform, in footprint editor
bool IsSelected() const
Definition: base_struct.h:224
void SetPosition(const wxPoint &aPos) override
Definition: class_pad.h:219
EDA_ITEM * Next() const
Definition: base_struct.h:209
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate an edge of the footprint.
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:512
void SetPos0(const wxPoint &aPos)
Definition: class_pad.h:262
D_PAD * Next() const
Definition: class_pad.h:160
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
void Move(const wxPoint &aMoveVector) override
Move an edge of the footprint.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:166
DLIST< D_PAD > & PadsList()
Definition: class_module.h:163
const wxPoint GetPosition() const override
Definition: class_pad.h:220
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 in global transform, if force_all is true, all items will be rotated.

Definition at line 664 of file block_footprint_editor.cpp.

References ClearMarkItems(), MODULE::GraphicalItemsList(), EDA_ITEM::IsSelected(), BOARD_ITEM::Next(), D_PAD::Next(), MODULE::PadsList(), PCB_MODULE_EDGE_T, PCB_MODULE_TEXT_T, MODULE::Reference(), TEXTE_MODULE::Rotate(), ROTATE, and MODULE::Value().

Referenced by FOOTPRINT_EDIT_FRAME::HandleBlockEnd(), FOOTPRINT_EDIT_FRAME::HandleBlockPlace(), and FOOTPRINT_EDIT_FRAME::Transform().

665 {
666 #define ROTATE( z ) RotatePoint( (&z), offset, 900 )
667 
668  if( module == NULL )
669  return;
670 
671  if( module->Reference().IsSelected() || force_all )
672  module->Reference().Rotate( offset, 900 );
673 
674  if( module->Value().IsSelected() || force_all )
675  module->Value().Rotate( offset, 900 );
676 
677  for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
678  {
679  if( !pad->IsSelected() && !force_all )
680  continue;
681 
682  wxPoint pos = pad->GetPos0();
683  ROTATE( pos );
684  pad->SetPos0( pos );
685  pad->SetOrientation( pad->GetOrientation() + 900 );
686 
687  pad->SetDrawCoord();
688  }
689 
690  for( EDA_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() )
691  {
692  if( !item->IsSelected() && !force_all )
693  continue;
694 
695  switch( item->Type() )
696  {
697  case PCB_MODULE_EDGE_T:
698  ((EDGE_MODULE*) item)->Rotate( offset, 900 );
699  break;
700 
701  case PCB_MODULE_TEXT_T:
702  static_cast<TEXTE_MODULE*>( item )->Rotate( offset, 900 );
703  break;
704 
705  default:
706  break;
707  }
708  }
709 
710  ClearMarkItems( module );
711 }
TEXTE_MODULE & Reference()
Definition: class_module.h:513
static void ClearMarkItems(MODULE *module)
void Rotate(const wxPoint &aOffset, double aAngle) override
Rotate text, in footprint editor (for instance in footprint rotation transform)
bool IsSelected() const
Definition: base_struct.h:224
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
BOARD_ITEM * Next() const
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:512
D_PAD * Next() const
Definition: class_pad.h:160
#define ROTATE(z)
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:166
DLIST< D_PAD > & PadsList()
Definition: class_module.h:163