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 710 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().

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 }
TEXTE_MODULE & Reference()
Definition: class_module.h:502
EDA_ITEM * Next() const
Definition: base_struct.h:217
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:501
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:162
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:265
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:164
DLIST< D_PAD > & PadsList()
Definition: class_module.h:161
void CopyMarkedItems ( MODULE module,
wxPoint  offset,
bool  aIncrement 
)
static

Definition at line 447 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().

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 }
bool IncrementPadName(bool aSkipUnconnectable, bool aFillSequenceGaps)
Function IncrementPadName.
Definition: class_pad.cpp:515
TEXTE_MODULE & Reference()
Definition: class_module.h:502
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:116
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:264
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:224
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:501
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:265
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:164
DLIST< D_PAD > & PadsList()
Definition: class_module.h:161
void DeleteMarkedItems ( MODULE module)
static

Definition at line 551 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().

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 }
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:169
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:164
DLIST< D_PAD > & PadsList()
Definition: class_module.h:161
static void DrawMovingBlockOutlines ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
const wxPoint aPosition,
bool  aErase 
)
static

Definition at line 355 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().

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 }
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:73
KICAD_T Type() const
Function Type()
Definition: base_struct.h:209
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:318
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:232
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
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
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
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:245
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:193
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:164
DLIST< D_PAD > & PadsList()
Definition: class_module.h:161
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
wxPoint GetMoveVector() const
int MarkItemsInBloc ( MODULE module,
EDA_RECT Rect 
)
static

Definition at line 809 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().

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 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:209
TEXTE_MODULE & Reference()
Definition: class_module.h:502
const wxPoint & GetTextPos() const
Definition: eda_text.h:222
static void ClearMarkItems(MODULE *module)
bool Contains(const wxPoint &aPoint) const
Function Contains.
EDA_ITEM * Next() const
Definition: base_struct.h:217
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
#define SELECTED
Definition: base_struct.h:116
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:264
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:501
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:162
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:265
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:164
DLIST< D_PAD > & PadsList()
Definition: class_module.h:161
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 593 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().

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 }
#define SETMIRROR(z)
TEXTE_MODULE & Reference()
Definition: class_module.h:502
static void ClearMarkItems(MODULE *module)
bool IsSelected() const
Definition: base_struct.h:232
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
BOARD_ITEM * Next() const
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:501
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:162
void Mirror(const wxPoint &aCentre, bool aMirrorAroundXAxis)
Mirror text position in footprint edition the text itself is not mirrored, and the layer not modified...
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:164
DLIST< D_PAD > & PadsList()
Definition: class_module.h:161
void MoveMarkedItems ( MODULE module,
wxPoint  offset 
)
static

Definition at line 493 of file block_footprint_editor.cpp.

References ClearMarkItems(), DRAWSEGMENT::GetEnd(), EDGE_MODULE::GetEnd0(), D_PAD::GetPos0(), D_PAD::GetPosition(), DRAWSEGMENT::GetStart(), EDGE_MODULE::GetStart0(), MODULE::GraphicalItemsList(), EDA_ITEM::IsSelected(), TEXTE_MODULE::Move(), D_PAD::Next(), EDA_ITEM::Next(), MODULE::PadsList(), PCB_MODULE_EDGE_T, PCB_MODULE_TEXT_T, MODULE::Reference(), DRAWSEGMENT::SetEnd(), EDGE_MODULE::SetEnd0(), D_PAD::SetPos0(), D_PAD::SetPosition(), DRAWSEGMENT::SetStart(), EDGE_MODULE::SetStart0(), EDA_ITEM::Type(), and MODULE::Value().

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

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 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:209
void SetEnd0(const wxPoint &aPoint)
TEXTE_MODULE & Reference()
Definition: class_module.h:502
static void ClearMarkItems(MODULE *module)
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:232
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:217
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:501
void SetPos0(const wxPoint &aPos)
Definition: class_pad.h:262
D_PAD * Next() const
Definition: class_pad.h:160
void SetStart(const wxPoint &aStart)
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
const wxPoint & GetStart0() const
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:162
void SetEnd(const wxPoint &aEnd)
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:164
DLIST< D_PAD > & PadsList()
Definition: class_module.h:161
const wxPoint GetPosition() const override
Definition: class_pad.h:220
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
void MoveMarkedItemsExactly ( MODULE module,
const wxPoint centre,
const wxPoint translation,
double  rotation,
bool  force_all = false 
)

Definition at line 734 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().

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 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:209
TEXTE_MODULE & Reference()
Definition: class_module.h:502
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Function Rotate Rotate this object.
Definition: class_pad.cpp:1142
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:232
void SetPosition(const wxPoint &aPos) override
Definition: class_pad.h:219
EDA_ITEM * Next() const
Definition: base_struct.h:217
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:501
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:162
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:164
DLIST< D_PAD > & PadsList()
Definition: class_module.h:161
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 660 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().

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 }
TEXTE_MODULE & Reference()
Definition: class_module.h:502
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:232
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
BOARD_ITEM * Next() const
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:501
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:162
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:164
DLIST< D_PAD > & PadsList()
Definition: class_module.h:161