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

◆ BLOCK_COLOR

#define BLOCK_COLOR   BROWN

Definition at line 58 of file block_footprint_editor.cpp.

◆ ROTATE

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

◆ SETMIRROR

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

Function Documentation

◆ ClearMarkItems()

void ClearMarkItems ( MODULE module)
static

Definition at line 719 of file block_footprint_editor.cpp.

720 {
721  if( module == NULL )
722  return;
723 
724  module->Reference().ClearFlags();
725  module->Value().ClearFlags();
726 
727  EDA_ITEM* item = module->GraphicalItemsList();
728 
729  for( ; item != NULL; item = item->Next() )
730  {
731  item->ClearFlags();
732  }
733 
734  item = module->PadsList();
735 
736  for( ; item != NULL; item = item->Next() )
737  {
738  item->ClearFlags();
739  }
740 }
TEXTE_MODULE & Reference()
Definition: class_module.h:503
EDA_ITEM * Next() const
Definition: base_struct.h:212
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:502
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:260
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:165
DLIST< D_PAD > & PadsList()
Definition: class_module.h:162

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

◆ CopyMarkedItems()

void CopyMarkedItems ( MODULE module,
wxPoint  offset,
bool  aIncrement 
)
static

Definition at line 455 of file block_footprint_editor.cpp.

456 {
457  if( module == NULL )
458  return;
459 
460  // Reference and value cannot be copied, they are unique.
461  // Ensure they are not selected
462  module->Reference().ClearFlags();
463  module->Value().ClearFlags();
464 
465  for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
466  {
467  if( !pad->IsSelected() )
468  continue;
469 
470  pad->ClearFlags( SELECTED );
471  D_PAD* NewPad = new D_PAD( *pad );
472  NewPad->SetParent( module );
473  NewPad->SetFlags( SELECTED );
474  module->PadsList().PushFront( NewPad );
475 
476  if( aIncrement )
477  NewPad->IncrementPadName( true, true );
478  }
479 
480  BOARD_ITEM* newItem;
481 
482  for( BOARD_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() )
483  {
484  if( !item->IsSelected() )
485  continue;
486 
487  item->ClearFlags( SELECTED );
488 
489  newItem = (BOARD_ITEM*)item->Clone();
490  newItem->SetParent( module );
491  newItem->SetFlags( SELECTED );
492  module->GraphicalItemsList().PushFront( newItem );
493  }
494 
495  MoveMarkedItems( module, offset );
496 }
bool IncrementPadName(bool aSkipUnconnectable, bool aFillSequenceGaps)
Function IncrementPadName.
Definition: class_pad.cpp:577
TEXTE_MODULE & Reference()
Definition: class_module.h:503
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.
#define SELECTED
Definition: base_struct.h:121
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:259
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:219
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:502
static void MoveMarkedItems(MODULE *module, wxPoint offset)
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:260
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:165
DLIST< D_PAD > & PadsList()
Definition: class_module.h:162

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

Referenced by FOOTPRINT_EDIT_FRAME::HandleBlockPlace().

◆ DeleteMarkedItems()

void DeleteMarkedItems ( MODULE module)
static

Definition at line 560 of file block_footprint_editor.cpp.

561 {
562  if( module == NULL )
563  return;
564 
565  D_PAD* next_pad;
566  BOARD* board = module->GetBoard();
567 
568  for( D_PAD* pad = module->PadsList(); pad; pad = next_pad )
569  {
570  next_pad = pad->Next();
571 
572  if( !pad->IsSelected() )
573  continue;
574 
575  if( board )
576  board->PadDelete( pad );
577  else
578  pad->DeleteStructure();
579  }
580 
581  BOARD_ITEM* next_item;
582 
583  for( BOARD_ITEM* item = module->GraphicalItemsList(); item; item = next_item )
584  {
585  next_item = item->Next();
586 
587  if( !item->IsSelected() )
588  continue;
589 
590  item->DeleteStructure();
591  }
592 
593  // Ref and value can be flagged, but cannot be deleted
594  ClearMarkItems( module );
595 }
D_PAD * Next() const
Definition: class_pad.h:162
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.
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
BOARD_ITEM * Next() const
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:170
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:165
DLIST< D_PAD > & PadsList()
Definition: class_module.h:162

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

◆ DrawMovingBlockOutlines()

static void DrawMovingBlockOutlines ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
const wxPoint &  aPosition,
bool  aErase 
)
static

Definition at line 363 of file block_footprint_editor.cpp.

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

References BOARD_ITEM::Draw(), D_PAD::Draw(), g_XorMode, PCB_BASE_FRAME::GetBoard(), EDA_DRAW_FRAME::GetCrossHairPosition(), 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, and EDA_ITEM::Type().

Referenced by FOOTPRINT_EDIT_FRAME::HandleBlockEnd().

◆ MarkItemsInBloc()

int MarkItemsInBloc ( MODULE module,
EDA_RECT Rect 
)
static

Definition at line 818 of file block_footprint_editor.cpp.

819 {
820  EDA_ITEM* item;
821  int ItemsCount = 0;
822  wxPoint pos;
823  D_PAD* pad;
824 
825  if( module == NULL )
826  return 0;
827 
828  ClearMarkItems( module ); // Just in case ...
829 
830  pos = module->Reference().GetTextPos();
831 
832  if( Rect.Contains( pos ) )
833  {
834  module->Reference().SetFlags( SELECTED );
835  ItemsCount++;
836  }
837 
838  pos = module->Value().GetTextPos();
839 
840  if( Rect.Contains( pos ) )
841  {
842  module->Value().SetFlags( SELECTED );
843  ItemsCount++;
844  }
845 
846  pad = module->PadsList();
847 
848  for( ; pad != NULL; pad = pad->Next() )
849  {
850  pad->ClearFlags( SELECTED );
851  pos = pad->GetPosition();
852 
853  if( Rect.Contains( pos ) )
854  {
855  pad->SetFlags( SELECTED );
856  ItemsCount++;
857  }
858  }
859 
860  item = module->GraphicalItemsList();
861 
862  for( ; item != NULL; item = item->Next() )
863  {
864  item->ClearFlags( SELECTED );
865 
866  switch( item->Type() )
867  {
868  case PCB_MODULE_EDGE_T:
869  if( ((EDGE_MODULE*)item )->HitTest( Rect, false ) )
870  {
871  item->SetFlags( SELECTED );
872  ItemsCount++;
873  }
874 
875  break;
876 
877  case PCB_MODULE_TEXT_T:
878  pos = static_cast<TEXTE_MODULE*>( item )->GetTextPos();
879 
880  if( Rect.Contains( pos ) )
881  {
882  item->SetFlags( SELECTED );
883  ItemsCount++;
884  }
885 
886  break;
887 
888  default:
889  break;
890  }
891  }
892 
893  return ItemsCount;
894 }
D_PAD * Next() const
Definition: class_pad.h:162
TEXTE_MODULE & Reference()
Definition: class_module.h:503
static void ClearMarkItems(MODULE *module)
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
bool Contains(const wxPoint &aPoint) const
Function Contains.
EDA_ITEM * Next() const
Definition: base_struct.h:212
#define SELECTED
Definition: base_struct.h:121
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:259
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:502
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:157
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:260
const wxPoint & GetTextPos() const
Definition: eda_text.h:241
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:165
DLIST< D_PAD > & PadsList()
Definition: class_module.h:162
const wxPoint GetPosition() const override
Definition: class_pad.h:222
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204

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

◆ MirrorMarkedItems()

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 602 of file block_footprint_editor.cpp.

603 {
604 #define SETMIRROR( z ) (z) -= offset.x; (z) = -(z); (z) += offset.x;
605  wxPoint tmp;
606  wxSize tmpz;
607 
608  if( module == NULL )
609  return;
610 
611  if( module->Reference().IsSelected() || force_all )
612  module->Reference().Mirror( offset, false );
613 
614  if( module->Value().IsSelected() || force_all )
615  module->Value().Mirror( offset, false );
616 
617  for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
618  {
619  // Skip pads not selected, i.e. not inside the block to mirror:
620  if( !pad->IsSelected() && !force_all )
621  continue;
622 
623  tmp = pad->GetPosition();
624  SETMIRROR( tmp.x );
625  pad->SetPosition( tmp );
626 
627  pad->SetX0( pad->GetPosition().x );
628 
629  tmp = pad->GetOffset();
630  tmp.x = -tmp.x;
631  pad->SetOffset( tmp );
632 
633  tmpz = pad->GetDelta();
634  tmpz.x = -tmpz.x;
635  pad->SetDelta( tmpz );
636 
637  pad->SetOrientation( - pad->GetOrientation() );
638  }
639 
640  for( EDA_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() )
641  {
642  // Skip items not selected, i.e. not inside the block to mirror:
643  if( !item->IsSelected() && !force_all )
644  continue;
645 
646  switch( item->Type() )
647  {
648  case PCB_MODULE_EDGE_T:
649  ((EDGE_MODULE*) item)->Mirror( offset, false );
650  break;
651 
652  case PCB_MODULE_TEXT_T:
653  static_cast<TEXTE_MODULE*>( item )->Mirror( offset, false );
654  break;
655 
656  default:
657  break;
658  }
659  }
660 
661  ClearMarkItems( module );
662 }
#define SETMIRROR(z)
TEXTE_MODULE & Reference()
Definition: class_module.h:503
bool IsSelected() const
Definition: base_struct.h:227
static void ClearMarkItems(MODULE *module)
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:502
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:157
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:165
DLIST< D_PAD > & PadsList()
Definition: class_module.h:162

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

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

◆ MoveMarkedItems()

void MoveMarkedItems ( MODULE module,
wxPoint  offset 
)
static

Definition at line 501 of file block_footprint_editor.cpp.

502 {
503  EDA_ITEM* item;
504 
505  if( module == NULL )
506  return;
507 
508  if( module->Reference().IsSelected() )
509  module->Reference().Move( offset );
510 
511  if( module->Value().IsSelected() )
512  module->Value().Move( offset );
513 
514  D_PAD* pad = module->PadsList();
515 
516  for( ; pad != NULL; pad = pad->Next() )
517  {
518  if( !pad->IsSelected() )
519  continue;
520 
521  pad->SetPosition( pad->GetPosition() + offset );
522  pad->SetPos0( pad->GetPos0() + offset );
523  }
524 
525  item = module->GraphicalItemsList();
526 
527  for( ; item != NULL; item = item->Next() )
528  {
529  if( !item->IsSelected() )
530  continue;
531 
532  switch( item->Type() )
533  {
534  case PCB_MODULE_TEXT_T:
535  static_cast<TEXTE_MODULE*>( item )->Move( offset );
536  break;
537 
538  case PCB_MODULE_EDGE_T:
539  {
540  EDGE_MODULE* em = (EDGE_MODULE*) item;
541  em->Move( offset );
542  em->SetStart0( em->GetStart0() + offset );
543  em->SetEnd0( em->GetEnd0() + offset );
544  em->SetBezier0_C1( em->GetBezier0_C1() + offset );
545  em->SetBezier0_C2( em->GetBezier0_C2() + offset );
546  }
547  break;
548 
549  default:
550  ;
551  }
552  }
553 
554  ClearMarkItems( module );
555 }
D_PAD * Next() const
Definition: class_pad.h:162
void SetEnd0(const wxPoint &aPoint)
TEXTE_MODULE & Reference()
Definition: class_module.h:503
const wxPoint & GetPos0() const
Definition: class_pad.h:265
bool IsSelected() const
Definition: base_struct.h:227
static void ClearMarkItems(MODULE *module)
void SetBezier0_C1(const wxPoint &aPoint)
void SetBezier0_C2(const wxPoint &aPoint)
void Move(const wxPoint &aMoveVector) override
move text in move transform, in footprint editor
void SetPosition(const wxPoint &aPos) override
Definition: class_pad.h:221
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
EDA_ITEM * Next() const
Definition: base_struct.h:212
const wxPoint & GetStart0() const
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:502
void SetPos0(const wxPoint &aPos)
Definition: class_pad.h:264
const wxPoint & GetBezier0_C2() const
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
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:157
const wxPoint & GetBezier0_C1() const
const wxPoint & GetEnd0() const
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:165
DLIST< D_PAD > & PadsList()
Definition: class_module.h:162
const wxPoint GetPosition() const override
Definition: class_pad.h:222
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204

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

◆ MoveMarkedItemsExactly()

void MoveMarkedItemsExactly ( MODULE module,
const wxPoint &  centre,
const wxPoint &  translation,
double  rotation,
bool  force_all = false 
)

Definition at line 743 of file block_footprint_editor.cpp.

746 {
747  if( module == NULL )
748  return;
749 
750  if( module->Reference().IsSelected() || force_all )
751  {
752  module->Reference().Rotate( centre, rotation );
753  module->Reference().Move( translation );
754  }
755 
756  if( module->Value().IsSelected() || force_all )
757  {
758  module->Value().Rotate( centre, rotation );
759  module->Value().Move( translation );
760  }
761 
762  D_PAD* pad = module->PadsList();
763 
764  for( ; pad != NULL; pad = pad->Next() )
765  {
766  if( !pad->IsSelected() && !force_all )
767  continue;
768 
769  // rotate about centre point,
770  wxPoint newPos = pad->GetPosition();
771  RotatePoint( &newPos, centre, rotation );
772 
773  // shift and update
774  newPos += translation;
775  pad->SetPosition( newPos );
776  pad->SetPos0( newPos );
777 
778  // finally apply rotation to the pad itself
779  pad->Rotate( newPos, rotation );
780  }
781 
782  EDA_ITEM* item = module->GraphicalItemsList();
783 
784  for( ; item != NULL; item = item->Next() )
785  {
786  if( !item->IsSelected() && !force_all )
787  continue;
788 
789  switch( item->Type() )
790  {
791  case PCB_MODULE_TEXT_T:
792  {
793  TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
794 
795  text->Rotate( centre, rotation );
796  text->Move( translation );
797  break;
798  }
799  case PCB_MODULE_EDGE_T:
800  {
801  EDGE_MODULE* em = static_cast<EDGE_MODULE*>( item );
802  em->Rotate( centre, rotation );
803  em->Move( translation );
804  break;
805  }
806  default:
807  ;
808  }
809  }
810 
811  ClearMarkItems( module );
812 }
D_PAD * Next() const
Definition: class_pad.h:162
TEXTE_MODULE & Reference()
Definition: class_module.h:503
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Function Rotate Rotate this object.
Definition: class_pad.cpp:1215
bool IsSelected() const
Definition: base_struct.h:227
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
void SetPosition(const wxPoint &aPos) override
Definition: class_pad.h:221
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
EDA_ITEM * Next() const
Definition: base_struct.h:212
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate an edge of the footprint.
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:502
void SetPos0(const wxPoint &aPos)
Definition: class_pad.h:264
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:157
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:165
DLIST< D_PAD > & PadsList()
Definition: class_module.h:162
const wxPoint GetPosition() const override
Definition: class_pad.h:222
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204

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

◆ RotateMarkedItems()

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 669 of file block_footprint_editor.cpp.

670 {
671 #define ROTATE( z ) RotatePoint( (&z), offset, 900 )
672 
673  if( module == NULL )
674  return;
675 
676  if( module->Reference().IsSelected() || force_all )
677  module->Reference().Rotate( offset, 900 );
678 
679  if( module->Value().IsSelected() || force_all )
680  module->Value().Rotate( offset, 900 );
681 
682  for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
683  {
684  if( !pad->IsSelected() && !force_all )
685  continue;
686 
687  wxPoint pos = pad->GetPos0();
688  ROTATE( pos );
689  pad->SetPos0( pos );
690  pad->SetOrientation( pad->GetOrientation() + 900 );
691 
692  pad->SetDrawCoord();
693  }
694 
695  for( EDA_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() )
696  {
697  if( !item->IsSelected() && !force_all )
698  continue;
699 
700  switch( item->Type() )
701  {
702  case PCB_MODULE_EDGE_T:
703  ((EDGE_MODULE*) item)->Rotate( offset, 900 );
704  break;
705 
706  case PCB_MODULE_TEXT_T:
707  static_cast<TEXTE_MODULE*>( item )->Rotate( offset, 900 );
708  break;
709 
710  default:
711  break;
712  }
713  }
714 
715  ClearMarkItems( module );
716 }
TEXTE_MODULE & Reference()
Definition: class_module.h:503
bool IsSelected() const
Definition: base_struct.h:227
static void ClearMarkItems(MODULE *module)
void Rotate(const wxPoint &aOffset, double aAngle) override
Rotate text, in footprint editor (for instance in footprint rotation transform)
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:502
#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:157
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:165
DLIST< D_PAD > & PadsList()
Definition: class_module.h:162

References ClearMarkItems(), MODULE::GraphicalItemsList(), EDA_ITEM::IsSelected(), 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().