KiCad PCB EDA Suite
block_module_editor.cpp File Reference

Footprint editor block handling implementation. More...

#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 <wxPcbStruct.h>
#include <module_editor_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_mire.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)
 

Detailed Description

Footprint editor block handling implementation.

Definition in file block_module_editor.cpp.

Macro Definition Documentation

#define BLOCK_COLOR   BROWN

Definition at line 59 of file block_module_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 733 of file block_module_editor.cpp.

References EDA_ITEM::ClearFlags(), MODULE::GraphicalItems(), EDA_ITEM::Next(), MODULE::Pads(), MODULE::Reference(), and MODULE::Value().

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

734 {
735  if( module == NULL )
736  return;
737 
738  module->Reference().ClearFlags();
739  module->Value().ClearFlags();
740 
741  EDA_ITEM* item = module->GraphicalItems();
742 
743  for( ; item != NULL; item = item->Next() )
744  {
745  item->ClearFlags();
746  }
747 
748  item = module->Pads();
749 
750  for( ; item != NULL; item = item->Next() )
751  {
752  item->ClearFlags();
753  }
754 }
TEXTE_MODULE & Reference()
Definition: class_module.h:455
EDA_ITEM * Next() const
Definition: base_struct.h:206
DLIST< BOARD_ITEM > & GraphicalItems()
Definition: class_module.h:136
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:454
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:254
DLIST< D_PAD > & Pads()
Definition: class_module.h:133
void CopyMarkedItems ( MODULE module,
wxPoint  offset,
bool  aIncrement 
)
static

Definition at line 470 of file block_module_editor.cpp.

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

Referenced by FOOTPRINT_EDIT_FRAME::HandleBlockPlace().

471 {
472  if( module == NULL )
473  return;
474 
475  // Reference and value cannot be copied, they are unique.
476  // Ensure they are not selected
477  module->Reference().ClearFlags();
478  module->Value().ClearFlags();
479 
480  for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
481  {
482  if( !pad->IsSelected() )
483  continue;
484 
485  pad->ClearFlags( SELECTED );
486  D_PAD* NewPad = new D_PAD( *pad );
487  NewPad->SetParent( module );
488  NewPad->SetFlags( SELECTED );
489  module->Pads().PushFront( NewPad );
490 
491  if( aIncrement )
492  NewPad->IncrementPadName( true, true );
493  }
494 
495  BOARD_ITEM* newItem;
496 
497  for( BOARD_ITEM* item = module->GraphicalItems(); item; item = item->Next() )
498  {
499  if( !item->IsSelected() )
500  continue;
501 
502  item->ClearFlags( SELECTED );
503 
504  newItem = (BOARD_ITEM*)item->Clone();
505  newItem->SetParent( module );
506  newItem->SetFlags( SELECTED );
507  module->GraphicalItems().PushFront( newItem );
508  }
509 
510  MoveMarkedItems( module, offset );
511 }
bool IncrementPadName(bool aSkipUnconnectable, bool aFillSequenceGaps)
Function IncrementPadName.
Definition: class_pad.cpp:475
TEXTE_MODULE & Reference()
Definition: class_module.h:455
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.
DLIST< BOARD_ITEM > & GraphicalItems()
Definition: class_module.h:136
BOARD_ITEM * Next() const
#define SELECTED
Definition: base_struct.h:120
static void MoveMarkedItems(MODULE *module, wxPoint offset)
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:253
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:213
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:454
D_PAD * Next() const
Definition: class_pad.h:106
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:254
DLIST< D_PAD > & Pads()
Definition: class_module.h:133
void DeleteMarkedItems ( MODULE module)
static

Definition at line 574 of file block_module_editor.cpp.

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

Referenced by FOOTPRINT_EDIT_FRAME::HandleBlockEnd().

575 {
576  if( module == NULL )
577  return;
578 
579  D_PAD* next_pad;
580  BOARD* board = module->GetBoard();
581 
582  for( D_PAD* pad = module->Pads(); pad; pad = next_pad )
583  {
584  next_pad = pad->Next();
585 
586  if( !pad->IsSelected() )
587  continue;
588 
589  if( board )
590  board->PadDelete( pad );
591  else
592  pad->DeleteStructure();
593  }
594 
595  BOARD_ITEM* next_item;
596 
597  for( BOARD_ITEM* item = module->GraphicalItems(); item; item = next_item )
598  {
599  next_item = item->Next();
600 
601  if( !item->IsSelected() )
602  continue;
603 
604  item->DeleteStructure();
605  }
606 
607  // Ref and value can be flagged, but cannot be deleted
608  ClearMarkItems( module );
609 }
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...
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...
DLIST< BOARD_ITEM > & GraphicalItems()
Definition: class_module.h:136
BOARD_ITEM * Next() const
D_PAD * Next() const
Definition: class_pad.h:106
static void ClearMarkItems(MODULE *module)
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:166
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
DLIST< D_PAD > & Pads()
Definition: class_module.h:133
static void DrawMovingBlockOutlines ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
const wxPoint aPosition,
bool  aErase 
)
static

Definition at line 378 of file block_module_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::GraphicalItems(), GRSetDrawMode(), EDA_ITEM::IsSelected(), BASE_SCREEN::m_BlockLocate, BOARD::m_Modules, D_PAD::Next(), BOARD_ITEM::Next(), MODULE::Pads(), PCB_MODULE_EDGE_T, PCB_MODULE_TEXT_T, BLOCK_SELECTOR::SetMoveVector(), and EDA_ITEM::Type().

Referenced by FOOTPRINT_EDIT_FRAME::HandleBlockEnd().

380 {
381  BASE_SCREEN* screen = aPanel->GetScreen();
382  FOOTPRINT_EDIT_FRAME* moduleEditFrame = static_cast<FOOTPRINT_EDIT_FRAME*>( aPanel->GetParent() );
383 
384  wxASSERT( moduleEditFrame );
385  MODULE* currentModule = moduleEditFrame->GetBoard()->m_Modules;
386 
387  BLOCK_SELECTOR* block = &screen->m_BlockLocate;
388  GRSetDrawMode( aDC, g_XorMode );
389 
390  if( aErase )
391  {
392  block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
393 
394  if( currentModule )
395  {
396  wxPoint move_offset = -block->GetMoveVector();
397  BOARD_ITEM* item = currentModule->GraphicalItems();
398 
399  for( ; item != NULL; item = item->Next() )
400  {
401  if( !item->IsSelected() )
402  continue;
403 
404  switch( item->Type() )
405  {
406  case PCB_MODULE_TEXT_T:
407  case PCB_MODULE_EDGE_T:
408  item->Draw( aPanel, aDC, g_XorMode, move_offset );
409  break;
410 
411  default:
412  break;
413  }
414  }
415 
416  D_PAD* pad = currentModule->Pads();
417 
418  for( ; pad != NULL; pad = pad->Next() )
419  {
420  if( !pad->IsSelected() )
421  continue;
422 
423  pad->Draw( aPanel, aDC, g_XorMode, move_offset );
424  }
425  }
426  }
427 
428  // Repaint new view.
429  block->SetMoveVector( moduleEditFrame->GetCrossHairPosition() - block->GetLastCursorPosition() );
430 
431  block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
432 
433  if( currentModule )
434  {
435  BOARD_ITEM* item = currentModule->GraphicalItems();
436  wxPoint move_offset = - block->GetMoveVector();
437 
438  for( ; item != NULL; item = item->Next() )
439  {
440  if( !item->IsSelected() )
441  continue;
442 
443  switch( item->Type() )
444  {
445  case PCB_MODULE_TEXT_T:
446  case PCB_MODULE_EDGE_T:
447  item->Draw( aPanel, aDC, g_XorMode, move_offset );
448  break;
449 
450  default:
451  break;
452  }
453  }
454 
455  D_PAD* pad = currentModule->Pads();
456 
457  for( ; pad != NULL; pad = pad->Next() )
458  {
459  if( !pad->IsSelected() )
460  continue;
461 
462  pad->Draw( aPanel, aDC, g_XorMode, move_offset );
463  }
464  }
465 }
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:51
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:290
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:221
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:106
DLIST< BOARD_ITEM > & GraphicalItems()
Definition: class_module.h:136
BOARD_ITEM * Next() const
COLOR4D GetColor() const
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
D_PAD * Next() const
Definition: class_pad.h:106
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:175
Definition: solve.cpp:178
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:105
wxPoint GetLastCursorPosition() const
DLIST< MODULE > m_Modules
Definition: class_board.h:243
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:188
DLIST< D_PAD > & Pads()
Definition: class_module.h:133
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 832 of file block_module_editor.cpp.

References EDA_ITEM::ClearFlags(), ClearMarkItems(), EDA_RECT::Contains(), D_PAD::GetPosition(), EDA_TEXT::GetTextPos(), MODULE::GraphicalItems(), D_PAD::Next(), EDA_ITEM::Next(), MODULE::Pads(), 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().

833 {
834  EDA_ITEM* item;
835  int ItemsCount = 0;
836  wxPoint pos;
837  D_PAD* pad;
838 
839  if( module == NULL )
840  return 0;
841 
842  ClearMarkItems( module ); // Just in case ...
843 
844  pos = module->Reference().GetTextPos();
845 
846  if( Rect.Contains( pos ) )
847  {
848  module->Reference().SetFlags( SELECTED );
849  ItemsCount++;
850  }
851 
852  pos = module->Value().GetTextPos();
853 
854  if( Rect.Contains( pos ) )
855  {
856  module->Value().SetFlags( SELECTED );
857  ItemsCount++;
858  }
859 
860  pad = module->Pads();
861 
862  for( ; pad != NULL; pad = pad->Next() )
863  {
864  pad->ClearFlags( SELECTED );
865  pos = pad->GetPosition();
866 
867  if( Rect.Contains( pos ) )
868  {
869  pad->SetFlags( SELECTED );
870  ItemsCount++;
871  }
872  }
873 
874  item = module->GraphicalItems();
875 
876  for( ; item != NULL; item = item->Next() )
877  {
878  item->ClearFlags( SELECTED );
879 
880  switch( item->Type() )
881  {
882  case PCB_MODULE_EDGE_T:
883  if( ((EDGE_MODULE*)item )->HitTest( Rect ) )
884  {
885  item->SetFlags( SELECTED );
886  ItemsCount++;
887  }
888 
889  break;
890 
891  case PCB_MODULE_TEXT_T:
892  pos = static_cast<TEXTE_MODULE*>( item )->GetTextPos();
893 
894  if( Rect.Contains( pos ) )
895  {
896  item->SetFlags( SELECTED );
897  ItemsCount++;
898  }
899 
900  break;
901 
902  default:
903  break;
904  }
905  }
906 
907  return ItemsCount;
908 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
TEXTE_MODULE & Reference()
Definition: class_module.h:455
const wxPoint & GetTextPos() const
Definition: eda_text.h:224
bool Contains(const wxPoint &aPoint) const
Function Contains.
EDA_ITEM * Next() const
Definition: base_struct.h:206
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:106
DLIST< BOARD_ITEM > & GraphicalItems()
Definition: class_module.h:136
#define SELECTED
Definition: base_struct.h:120
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:253
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:454
const wxPoint & GetPosition() const override
Definition: class_pad.h:170
D_PAD * Next() const
Definition: class_pad.h:106
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:105
static void ClearMarkItems(MODULE *module)
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:254
DLIST< D_PAD > & Pads()
Definition: class_module.h:133
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 616 of file block_module_editor.cpp.

References ClearMarkItems(), MODULE::GraphicalItems(), EDA_ITEM::IsSelected(), TEXTE_MODULE::Mirror(), Mirror(), D_PAD::Next(), BOARD_ITEM::Next(), MODULE::Pads(), 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().

617 {
618 #define SETMIRROR( z ) (z) -= offset.x; (z) = -(z); (z) += offset.x;
619  wxPoint tmp;
620  wxSize tmpz;
621 
622  if( module == NULL )
623  return;
624 
625  if( module->Reference().IsSelected() || force_all )
626  module->Reference().Mirror( offset, false );
627 
628  if( module->Value().IsSelected() || force_all )
629  module->Value().Mirror( offset, false );
630 
631  for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
632  {
633  // Skip pads not selected, i.e. not inside the block to mirror:
634  if( !pad->IsSelected() && !force_all )
635  continue;
636 
637  tmp = pad->GetPosition();
638  SETMIRROR( tmp.x );
639  pad->SetPosition( tmp );
640 
641  pad->SetX0( pad->GetPosition().x );
642 
643  tmp = pad->GetOffset();
644  tmp.x = -tmp.x;
645  pad->SetOffset( tmp );
646 
647  tmpz = pad->GetDelta();
648  tmpz.x = -tmpz.x;
649  pad->SetDelta( tmpz );
650 
651  pad->SetOrientation( - pad->GetOrientation() );
652  }
653 
654  for( EDA_ITEM* item = module->GraphicalItems(); item; item = item->Next() )
655  {
656  // Skip items not selected, i.e. not inside the block to mirror:
657  if( !item->IsSelected() && !force_all )
658  continue;
659 
660  switch( item->Type() )
661  {
662  case PCB_MODULE_EDGE_T:
663  ((EDGE_MODULE*) item)->Mirror( offset, false );
664  break;
665 
666  case PCB_MODULE_TEXT_T:
667  static_cast<TEXTE_MODULE*>( item )->Mirror( offset, false );
668  break;
669 
670  default:
671  break;
672  }
673  }
674 
675  ClearMarkItems( module );
676 }
TEXTE_MODULE & Reference()
Definition: class_module.h:455
bool IsSelected() const
Definition: base_struct.h:221
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:106
DLIST< BOARD_ITEM > & GraphicalItems()
Definition: class_module.h:136
BOARD_ITEM * Next() const
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:454
D_PAD * Next() const
Definition: class_pad.h:106
#define SETMIRROR(z)
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:105
static void ClearMarkItems(MODULE *module)
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:151
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< D_PAD > & Pads()
Definition: class_module.h:133
void MoveMarkedItems ( MODULE module,
wxPoint  offset 
)
static

Definition at line 516 of file block_module_editor.cpp.

References ClearMarkItems(), DRAWSEGMENT::GetEnd(), EDGE_MODULE::GetEnd0(), D_PAD::GetPos0(), D_PAD::GetPosition(), DRAWSEGMENT::GetStart(), EDGE_MODULE::GetStart0(), MODULE::GraphicalItems(), EDA_ITEM::IsSelected(), TEXTE_MODULE::Move(), D_PAD::Next(), EDA_ITEM::Next(), MODULE::Pads(), 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().

517 {
518  EDA_ITEM* item;
519 
520  if( module == NULL )
521  return;
522 
523  if( module->Reference().IsSelected() )
524  module->Reference().Move( offset );
525 
526  if( module->Value().IsSelected() )
527  module->Value().Move( offset );
528 
529  D_PAD* pad = module->Pads();
530 
531  for( ; pad != NULL; pad = pad->Next() )
532  {
533  if( !pad->IsSelected() )
534  continue;
535 
536  pad->SetPosition( pad->GetPosition() + offset );
537  pad->SetPos0( pad->GetPos0() + offset );
538  }
539 
540  item = module->GraphicalItems();
541 
542  for( ; item != NULL; item = item->Next() )
543  {
544  if( !item->IsSelected() )
545  continue;
546 
547  switch( item->Type() )
548  {
549  case PCB_MODULE_TEXT_T:
550  static_cast<TEXTE_MODULE*>( item )->Move( offset );
551  break;
552 
553  case PCB_MODULE_EDGE_T:
554  {
555  EDGE_MODULE* em = (EDGE_MODULE*) item;
556  em->SetStart( em->GetStart() + offset );
557  em->SetEnd( em->GetEnd() + offset );
558  em->SetStart0( em->GetStart0() + offset );
559  em->SetEnd0( em->GetEnd0() + offset );
560  }
561  break;
562 
563  default:
564  ;
565  }
566  }
567 
568  ClearMarkItems( module );
569 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
void SetEnd0(const wxPoint &aPoint)
TEXTE_MODULE & Reference()
Definition: class_module.h:455
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:221
void SetPosition(const wxPoint &aPos) override
Definition: class_pad.h:169
const wxPoint & GetPos0() const
Definition: class_pad.h:176
EDA_ITEM * Next() const
Definition: base_struct.h:206
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:106
DLIST< BOARD_ITEM > & GraphicalItems()
Definition: class_module.h:136
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:454
void SetPos0(const wxPoint &aPos)
Definition: class_pad.h:175
const wxPoint & GetPosition() const override
Definition: class_pad.h:170
D_PAD * Next() const
Definition: class_pad.h:106
void SetStart(const wxPoint &aStart)
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:105
static void ClearMarkItems(MODULE *module)
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:151
void SetEnd(const wxPoint &aEnd)
DLIST< D_PAD > & Pads()
Definition: class_module.h:133
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 757 of file block_module_editor.cpp.

References ClearMarkItems(), D_PAD::GetPosition(), MODULE::GraphicalItems(), EDA_ITEM::IsSelected(), EDGE_MODULE::Move(), TEXTE_MODULE::Move(), D_PAD::Next(), EDA_ITEM::Next(), MODULE::Pads(), 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().

760 {
761  if( module == NULL )
762  return;
763 
764  if( module->Reference().IsSelected() || force_all )
765  {
766  module->Reference().Rotate( centre, rotation );
767  module->Reference().Move( translation );
768  }
769 
770  if( module->Value().IsSelected() || force_all )
771  {
772  module->Value().Rotate( centre, rotation );
773  module->Value().Move( translation );
774  }
775 
776  D_PAD* pad = module->Pads();
777 
778  for( ; pad != NULL; pad = pad->Next() )
779  {
780  if( !pad->IsSelected() && !force_all )
781  continue;
782 
783  // rotate about centre point,
784  wxPoint newPos = pad->GetPosition();
785  RotatePoint( &newPos, centre, rotation );
786 
787  // shift and update
788  newPos += translation;
789  pad->SetPosition( newPos );
790  pad->SetPos0( newPos );
791 
792  // finally apply rotation to the pad itself
793  pad->Rotate( newPos, rotation );
794  }
795 
796  EDA_ITEM* item = module->GraphicalItems();
797 
798  for( ; item != NULL; item = item->Next() )
799  {
800  if( !item->IsSelected() && !force_all )
801  continue;
802 
803  switch( item->Type() )
804  {
805  case PCB_MODULE_TEXT_T:
806  {
807  TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
808 
809  text->Rotate( centre, rotation );
810  text->Move( translation );
811  break;
812  }
813  case PCB_MODULE_EDGE_T:
814  {
815  EDGE_MODULE* em = static_cast<EDGE_MODULE*>( item );
816  em->Rotate( centre, rotation );
817  em->Move( translation );
818  break;
819  }
820  default:
821  ;
822  }
823  }
824 
825  ClearMarkItems( module );
826 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
TEXTE_MODULE & Reference()
Definition: class_module.h:455
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Function Rotate Rotate this object.
Definition: class_pad.cpp:1077
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:221
void SetPosition(const wxPoint &aPos) override
Definition: class_pad.h:169
EDA_ITEM * Next() const
Definition: base_struct.h:206
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:106
DLIST< BOARD_ITEM > & GraphicalItems()
Definition: class_module.h:136
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate an edge of the footprint.
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:454
void SetPos0(const wxPoint &aPos)
Definition: class_pad.h:175
const wxPoint & GetPosition() const override
Definition: class_pad.h:170
D_PAD * Next() const
Definition: class_pad.h:106
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:105
static void ClearMarkItems(MODULE *module)
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:151
DLIST< D_PAD > & Pads()
Definition: class_module.h:133
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 683 of file block_module_editor.cpp.

References ClearMarkItems(), MODULE::GraphicalItems(), EDA_ITEM::IsSelected(), D_PAD::Next(), BOARD_ITEM::Next(), MODULE::Pads(), 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().

684 {
685 #define ROTATE( z ) RotatePoint( (&z), offset, 900 )
686 
687  if( module == NULL )
688  return;
689 
690  if( module->Reference().IsSelected() || force_all )
691  module->Reference().Rotate( offset, 900 );
692 
693  if( module->Value().IsSelected() || force_all )
694  module->Value().Rotate( offset, 900 );
695 
696  for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
697  {
698  if( !pad->IsSelected() && !force_all )
699  continue;
700 
701  wxPoint pos = pad->GetPos0();
702  ROTATE( pos );
703  pad->SetPos0( pos );
704  pad->SetOrientation( pad->GetOrientation() + 900 );
705 
706  pad->SetDrawCoord();
707  }
708 
709  for( EDA_ITEM* item = module->GraphicalItems(); item; item = item->Next() )
710  {
711  if( !item->IsSelected() && !force_all )
712  continue;
713 
714  switch( item->Type() )
715  {
716  case PCB_MODULE_EDGE_T:
717  ((EDGE_MODULE*) item)->Rotate( offset, 900 );
718  break;
719 
720  case PCB_MODULE_TEXT_T:
721  static_cast<TEXTE_MODULE*>( item )->Rotate( offset, 900 );
722  break;
723 
724  default:
725  break;
726  }
727  }
728 
729  ClearMarkItems( module );
730 }
TEXTE_MODULE & Reference()
Definition: class_module.h:455
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:221
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:106
DLIST< BOARD_ITEM > & GraphicalItems()
Definition: class_module.h:136
BOARD_ITEM * Next() const
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:454
D_PAD * Next() const
Definition: class_pad.h:106
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:105
static void ClearMarkItems(MODULE *module)
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
DLIST< D_PAD > & Pads()
Definition: class_module.h:133
#define ROTATE(z)