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_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)
 

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 711 of file block_module_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().

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

Definition at line 448 of file block_module_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().

449 {
450  if( module == NULL )
451  return;
452 
453  // Reference and value cannot be copied, they are unique.
454  // Ensure they are not selected
455  module->Reference().ClearFlags();
456  module->Value().ClearFlags();
457 
458  for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
459  {
460  if( !pad->IsSelected() )
461  continue;
462 
463  pad->ClearFlags( SELECTED );
464  D_PAD* NewPad = new D_PAD( *pad );
465  NewPad->SetParent( module );
466  NewPad->SetFlags( SELECTED );
467  module->PadsList().PushFront( NewPad );
468 
469  if( aIncrement )
470  NewPad->IncrementPadName( true, true );
471  }
472 
473  BOARD_ITEM* newItem;
474 
475  for( BOARD_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() )
476  {
477  if( !item->IsSelected() )
478  continue;
479 
480  item->ClearFlags( SELECTED );
481 
482  newItem = (BOARD_ITEM*)item->Clone();
483  newItem->SetParent( module );
484  newItem->SetFlags( SELECTED );
485  module->GraphicalItemsList().PushFront( newItem );
486  }
487 
488  MoveMarkedItems( module, offset );
489 }
bool IncrementPadName(bool aSkipUnconnectable, bool aFillSequenceGaps)
Function IncrementPadName.
Definition: class_pad.cpp:515
TEXTE_MODULE & Reference()
Definition: class_module.h:483
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:134
static void MoveMarkedItems(MODULE *module, wxPoint offset)
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:267
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:227
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:482
D_PAD * Next() const
Definition: class_pad.h:160
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:268
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:157
DLIST< D_PAD > & PadsList()
Definition: class_module.h:154
void DeleteMarkedItems ( MODULE module)
static

Definition at line 552 of file block_module_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().

553 {
554  if( module == NULL )
555  return;
556 
557  D_PAD* next_pad;
558  BOARD* board = module->GetBoard();
559 
560  for( D_PAD* pad = module->PadsList(); pad; pad = next_pad )
561  {
562  next_pad = pad->Next();
563 
564  if( !pad->IsSelected() )
565  continue;
566 
567  if( board )
568  board->PadDelete( pad );
569  else
570  pad->DeleteStructure();
571  }
572 
573  BOARD_ITEM* next_item;
574 
575  for( BOARD_ITEM* item = module->GraphicalItemsList(); item; item = next_item )
576  {
577  next_item = item->Next();
578 
579  if( !item->IsSelected() )
580  continue;
581 
582  item->DeleteStructure();
583  }
584 
585  // Ref and value can be flagged, but cannot be deleted
586  ClearMarkItems( module );
587 }
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...
BOARD_ITEM * Next() const
D_PAD * Next() const
Definition: class_pad.h:160
static void ClearMarkItems(MODULE *module)
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:157
DLIST< D_PAD > & PadsList()
Definition: class_module.h:154
static void DrawMovingBlockOutlines ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
const wxPoint aPosition,
bool  aErase 
)
static

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

358 {
359  BASE_SCREEN* screen = aPanel->GetScreen();
360  FOOTPRINT_EDIT_FRAME* moduleEditFrame = static_cast<FOOTPRINT_EDIT_FRAME*>( aPanel->GetParent() );
361 
362  wxASSERT( moduleEditFrame );
363  MODULE* currentModule = moduleEditFrame->GetBoard()->m_Modules;
364 
365  BLOCK_SELECTOR* block = &screen->m_BlockLocate;
366  GRSetDrawMode( aDC, g_XorMode );
367 
368  if( aErase )
369  {
370  block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
371 
372  if( currentModule )
373  {
374  wxPoint move_offset = -block->GetMoveVector();
375  BOARD_ITEM* item = currentModule->GraphicalItemsList();
376 
377  for( ; item != NULL; item = item->Next() )
378  {
379  if( !item->IsSelected() )
380  continue;
381 
382  switch( item->Type() )
383  {
384  case PCB_MODULE_TEXT_T:
385  case PCB_MODULE_EDGE_T:
386  item->Draw( aPanel, aDC, g_XorMode, move_offset );
387  break;
388 
389  default:
390  break;
391  }
392  }
393 
394  D_PAD* pad = currentModule->PadsList();
395 
396  for( ; pad != NULL; pad = pad->Next() )
397  {
398  if( !pad->IsSelected() )
399  continue;
400 
401  pad->Draw( aPanel, aDC, g_XorMode, move_offset );
402  }
403  }
404  }
405 
406  // Repaint new view.
407  block->SetMoveVector( moduleEditFrame->GetCrossHairPosition() - block->GetLastCursorPosition() );
408 
409  block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
410 
411  if( currentModule )
412  {
413  BOARD_ITEM* item = currentModule->GraphicalItemsList();
414  wxPoint move_offset = - block->GetMoveVector();
415 
416  for( ; item != NULL; item = item->Next() )
417  {
418  if( !item->IsSelected() )
419  continue;
420 
421  switch( item->Type() )
422  {
423  case PCB_MODULE_TEXT_T:
424  case PCB_MODULE_EDGE_T:
425  item->Draw( aPanel, aDC, g_XorMode, move_offset );
426  break;
427 
428  default:
429  break;
430  }
431  }
432 
433  D_PAD* pad = currentModule->PadsList();
434 
435  for( ; pad != NULL; pad = pad->Next() )
436  {
437  if( !pad->IsSelected() )
438  continue;
439 
440  pad->Draw( aPanel, aDC, g_XorMode, move_offset );
441  }
442  }
443 }
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:51
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:296
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:235
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 ...)
D_PAD * Next() const
Definition: class_pad.h:160
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
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:187
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:157
DLIST< D_PAD > & PadsList()
Definition: class_module.h:154
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 810 of file block_module_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().

811 {
812  EDA_ITEM* item;
813  int ItemsCount = 0;
814  wxPoint pos;
815  D_PAD* pad;
816 
817  if( module == NULL )
818  return 0;
819 
820  ClearMarkItems( module ); // Just in case ...
821 
822  pos = module->Reference().GetTextPos();
823 
824  if( Rect.Contains( pos ) )
825  {
826  module->Reference().SetFlags( SELECTED );
827  ItemsCount++;
828  }
829 
830  pos = module->Value().GetTextPos();
831 
832  if( Rect.Contains( pos ) )
833  {
834  module->Value().SetFlags( SELECTED );
835  ItemsCount++;
836  }
837 
838  pad = module->PadsList();
839 
840  for( ; pad != NULL; pad = pad->Next() )
841  {
842  pad->ClearFlags( SELECTED );
843  pos = pad->GetPosition();
844 
845  if( Rect.Contains( pos ) )
846  {
847  pad->SetFlags( SELECTED );
848  ItemsCount++;
849  }
850  }
851 
852  item = module->GraphicalItemsList();
853 
854  for( ; item != NULL; item = item->Next() )
855  {
856  item->ClearFlags( SELECTED );
857 
858  switch( item->Type() )
859  {
860  case PCB_MODULE_EDGE_T:
861  if( ((EDGE_MODULE*)item )->HitTest( Rect ) )
862  {
863  item->SetFlags( SELECTED );
864  ItemsCount++;
865  }
866 
867  break;
868 
869  case PCB_MODULE_TEXT_T:
870  pos = static_cast<TEXTE_MODULE*>( item )->GetTextPos();
871 
872  if( Rect.Contains( pos ) )
873  {
874  item->SetFlags( SELECTED );
875  ItemsCount++;
876  }
877 
878  break;
879 
880  default:
881  break;
882  }
883  }
884 
885  return ItemsCount;
886 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
TEXTE_MODULE & Reference()
Definition: class_module.h:483
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:220
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
#define SELECTED
Definition: base_struct.h:134
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:267
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:482
const wxPoint & GetPosition() const override
Definition: class_pad.h:220
D_PAD * Next() const
Definition: class_pad.h:160
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
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:165
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:268
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:157
DLIST< D_PAD > & PadsList()
Definition: class_module.h:154
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 594 of file block_module_editor.cpp.

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

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

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

495 {
496  EDA_ITEM* item;
497 
498  if( module == NULL )
499  return;
500 
501  if( module->Reference().IsSelected() )
502  module->Reference().Move( offset );
503 
504  if( module->Value().IsSelected() )
505  module->Value().Move( offset );
506 
507  D_PAD* pad = module->PadsList();
508 
509  for( ; pad != NULL; pad = pad->Next() )
510  {
511  if( !pad->IsSelected() )
512  continue;
513 
514  pad->SetPosition( pad->GetPosition() + offset );
515  pad->SetPos0( pad->GetPos0() + offset );
516  }
517 
518  item = module->GraphicalItemsList();
519 
520  for( ; item != NULL; item = item->Next() )
521  {
522  if( !item->IsSelected() )
523  continue;
524 
525  switch( item->Type() )
526  {
527  case PCB_MODULE_TEXT_T:
528  static_cast<TEXTE_MODULE*>( item )->Move( offset );
529  break;
530 
531  case PCB_MODULE_EDGE_T:
532  {
533  EDGE_MODULE* em = (EDGE_MODULE*) item;
534  em->SetStart( em->GetStart() + offset );
535  em->SetEnd( em->GetEnd() + offset );
536  em->SetStart0( em->GetStart0() + offset );
537  em->SetEnd0( em->GetEnd0() + offset );
538  }
539  break;
540 
541  default:
542  ;
543  }
544  }
545 
546  ClearMarkItems( module );
547 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
void SetEnd0(const wxPoint &aPoint)
TEXTE_MODULE & Reference()
Definition: class_module.h:483
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:235
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:220
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:482
void SetPos0(const wxPoint &aPos)
Definition: class_pad.h:262
const wxPoint & GetPosition() const override
Definition: class_pad.h:220
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
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:165
void SetEnd(const wxPoint &aEnd)
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:157
DLIST< D_PAD > & PadsList()
Definition: class_module.h:154
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 735 of file block_module_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().

738 {
739  if( module == NULL )
740  return;
741 
742  if( module->Reference().IsSelected() || force_all )
743  {
744  module->Reference().Rotate( centre, rotation );
745  module->Reference().Move( translation );
746  }
747 
748  if( module->Value().IsSelected() || force_all )
749  {
750  module->Value().Rotate( centre, rotation );
751  module->Value().Move( translation );
752  }
753 
754  D_PAD* pad = module->PadsList();
755 
756  for( ; pad != NULL; pad = pad->Next() )
757  {
758  if( !pad->IsSelected() && !force_all )
759  continue;
760 
761  // rotate about centre point,
762  wxPoint newPos = pad->GetPosition();
763  RotatePoint( &newPos, centre, rotation );
764 
765  // shift and update
766  newPos += translation;
767  pad->SetPosition( newPos );
768  pad->SetPos0( newPos );
769 
770  // finally apply rotation to the pad itself
771  pad->Rotate( newPos, rotation );
772  }
773 
774  EDA_ITEM* item = module->GraphicalItemsList();
775 
776  for( ; item != NULL; item = item->Next() )
777  {
778  if( !item->IsSelected() && !force_all )
779  continue;
780 
781  switch( item->Type() )
782  {
783  case PCB_MODULE_TEXT_T:
784  {
785  TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
786 
787  text->Rotate( centre, rotation );
788  text->Move( translation );
789  break;
790  }
791  case PCB_MODULE_EDGE_T:
792  {
793  EDGE_MODULE* em = static_cast<EDGE_MODULE*>( item );
794  em->Rotate( centre, rotation );
795  em->Move( translation );
796  break;
797  }
798  default:
799  ;
800  }
801  }
802 
803  ClearMarkItems( module );
804 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
TEXTE_MODULE & Reference()
Definition: class_module.h:483
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Function Rotate Rotate this object.
Definition: class_pad.cpp:1119
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:235
void SetPosition(const wxPoint &aPos) override
Definition: class_pad.h:219
EDA_ITEM * Next() const
Definition: base_struct.h:220
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
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:482
void SetPos0(const wxPoint &aPos)
Definition: class_pad.h:262
const wxPoint & GetPosition() const override
Definition: class_pad.h:220
D_PAD * Next() const
Definition: class_pad.h:160
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
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:165
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:157
DLIST< D_PAD > & PadsList()
Definition: class_module.h:154
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 661 of file block_module_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().

662 {
663 #define ROTATE( z ) RotatePoint( (&z), offset, 900 )
664 
665  if( module == NULL )
666  return;
667 
668  if( module->Reference().IsSelected() || force_all )
669  module->Reference().Rotate( offset, 900 );
670 
671  if( module->Value().IsSelected() || force_all )
672  module->Value().Rotate( offset, 900 );
673 
674  for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
675  {
676  if( !pad->IsSelected() && !force_all )
677  continue;
678 
679  wxPoint pos = pad->GetPos0();
680  ROTATE( pos );
681  pad->SetPos0( pos );
682  pad->SetOrientation( pad->GetOrientation() + 900 );
683 
684  pad->SetDrawCoord();
685  }
686 
687  for( EDA_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() )
688  {
689  if( !item->IsSelected() && !force_all )
690  continue;
691 
692  switch( item->Type() )
693  {
694  case PCB_MODULE_EDGE_T:
695  ((EDGE_MODULE*) item)->Rotate( offset, 900 );
696  break;
697 
698  case PCB_MODULE_TEXT_T:
699  static_cast<TEXTE_MODULE*>( item )->Rotate( offset, 900 );
700  break;
701 
702  default:
703  break;
704  }
705  }
706 
707  ClearMarkItems( module );
708 }
TEXTE_MODULE & Reference()
Definition: class_module.h:483
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:235
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
BOARD_ITEM * Next() const
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:482
D_PAD * Next() const
Definition: class_pad.h:160
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
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:165
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:157
DLIST< D_PAD > & PadsList()
Definition: class_module.h:154
#define ROTATE(z)