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

702 {
703  if( module == NULL )
704  return;
705 
706  module->Reference().ClearFlags();
707  module->Value().ClearFlags();
708 
709  EDA_ITEM* item = module->GraphicalItems();
710 
711  for( ; item != NULL; item = item->Next() )
712  {
713  item->ClearFlags();
714  }
715 
716  item = module->Pads();
717 
718  for( ; item != NULL; item = item->Next() )
719  {
720  item->ClearFlags();
721  }
722 }
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 438 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().

439 {
440  if( module == NULL )
441  return;
442 
443  // Reference and value cannot be copied, they are unique.
444  // Ensure they are not selected
445  module->Reference().ClearFlags();
446  module->Value().ClearFlags();
447 
448  for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
449  {
450  if( !pad->IsSelected() )
451  continue;
452 
453  pad->ClearFlags( SELECTED );
454  D_PAD* NewPad = new D_PAD( *pad );
455  NewPad->SetParent( module );
456  NewPad->SetFlags( SELECTED );
457  module->Pads().PushFront( NewPad );
458 
459  if( aIncrement )
460  NewPad->IncrementPadName( true, true );
461  }
462 
463  BOARD_ITEM* newItem;
464 
465  for( BOARD_ITEM* item = module->GraphicalItems(); item; item = item->Next() )
466  {
467  if( !item->IsSelected() )
468  continue;
469 
470  item->ClearFlags( SELECTED );
471 
472  newItem = (BOARD_ITEM*)item->Clone();
473  newItem->SetParent( module );
474  newItem->SetFlags( SELECTED );
475  module->GraphicalItems().PushFront( newItem );
476  }
477 
478  MoveMarkedItems( module, offset );
479 }
bool IncrementPadName(bool aSkipUnconnectable, bool aFillSequenceGaps)
Function IncrementPadName.
Definition: class_pad.cpp:424
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 542 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().

543 {
544  if( module == NULL )
545  return;
546 
547  D_PAD* next_pad;
548  BOARD* board = module->GetBoard();
549 
550  for( D_PAD* pad = module->Pads(); pad; pad = next_pad )
551  {
552  next_pad = pad->Next();
553 
554  if( !pad->IsSelected() )
555  continue;
556 
557  if( board )
558  board->PadDelete( pad );
559  else
560  pad->DeleteStructure();
561  }
562 
563  BOARD_ITEM* next_item;
564 
565  for( BOARD_ITEM* item = module->GraphicalItems(); item; item = next_item )
566  {
567  next_item = item->Next();
568 
569  if( !item->IsSelected() )
570  continue;
571 
572  item->DeleteStructure();
573  }
574 
575  // Ref and value can be flagged, but cannot be deleted
576  ClearMarkItems( module );
577 }
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 346 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().

348 {
349  BASE_SCREEN* screen = aPanel->GetScreen();
350  FOOTPRINT_EDIT_FRAME* moduleEditFrame = static_cast<FOOTPRINT_EDIT_FRAME*>( aPanel->GetParent() );
351 
352  wxASSERT( moduleEditFrame );
353  MODULE* currentModule = moduleEditFrame->GetBoard()->m_Modules;
354 
355  BLOCK_SELECTOR* block = &screen->m_BlockLocate;
356  GRSetDrawMode( aDC, g_XorMode );
357 
358  if( aErase )
359  {
360  block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
361 
362  if( currentModule )
363  {
364  wxPoint move_offset = -block->GetMoveVector();
365  BOARD_ITEM* item = currentModule->GraphicalItems();
366 
367  for( ; item != NULL; item = item->Next() )
368  {
369  if( !item->IsSelected() )
370  continue;
371 
372  switch( item->Type() )
373  {
374  case PCB_MODULE_TEXT_T:
375  case PCB_MODULE_EDGE_T:
376  item->Draw( aPanel, aDC, g_XorMode, move_offset );
377  break;
378 
379  default:
380  break;
381  }
382  }
383 
384  D_PAD* pad = currentModule->Pads();
385 
386  for( ; pad != NULL; pad = pad->Next() )
387  {
388  if( !pad->IsSelected() )
389  continue;
390 
391  pad->Draw( aPanel, aDC, g_XorMode, move_offset );
392  }
393  }
394  }
395 
396  // Repaint new view.
397  block->SetMoveVector( moduleEditFrame->GetCrossHairPosition() - block->GetLastCursorPosition() );
398 
399  block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
400 
401  if( currentModule )
402  {
403  BOARD_ITEM* item = currentModule->GraphicalItems();
404  wxPoint move_offset = - block->GetMoveVector();
405 
406  for( ; item != NULL; item = item->Next() )
407  {
408  if( !item->IsSelected() )
409  continue;
410 
411  switch( item->Type() )
412  {
413  case PCB_MODULE_TEXT_T:
414  case PCB_MODULE_EDGE_T:
415  item->Draw( aPanel, aDC, g_XorMode, move_offset );
416  break;
417 
418  default:
419  break;
420  }
421  }
422 
423  D_PAD* pad = currentModule->Pads();
424 
425  for( ; pad != NULL; pad = pad->Next() )
426  {
427  if( !pad->IsSelected() )
428  continue;
429 
430  pad->Draw( aPanel, aDC, g_XorMode, move_offset );
431  }
432  }
433 }
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 800 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().

801 {
802  EDA_ITEM* item;
803  int ItemsCount = 0;
804  wxPoint pos;
805  D_PAD* pad;
806 
807  if( module == NULL )
808  return 0;
809 
810  ClearMarkItems( module ); // Just in case ...
811 
812  pos = module->Reference().GetTextPos();
813 
814  if( Rect.Contains( pos ) )
815  {
816  module->Reference().SetFlags( SELECTED );
817  ItemsCount++;
818  }
819 
820  pos = module->Value().GetTextPos();
821 
822  if( Rect.Contains( pos ) )
823  {
824  module->Value().SetFlags( SELECTED );
825  ItemsCount++;
826  }
827 
828  pad = module->Pads();
829 
830  for( ; pad != NULL; pad = pad->Next() )
831  {
832  pad->ClearFlags( SELECTED );
833  pos = pad->GetPosition();
834 
835  if( Rect.Contains( pos ) )
836  {
837  pad->SetFlags( SELECTED );
838  ItemsCount++;
839  }
840  }
841 
842  item = module->GraphicalItems();
843 
844  for( ; item != NULL; item = item->Next() )
845  {
846  item->ClearFlags( SELECTED );
847 
848  switch( item->Type() )
849  {
850  case PCB_MODULE_EDGE_T:
851  if( ((EDGE_MODULE*)item )->HitTest( Rect ) )
852  {
853  item->SetFlags( SELECTED );
854  ItemsCount++;
855  }
856 
857  break;
858 
859  case PCB_MODULE_TEXT_T:
860  pos = static_cast<TEXTE_MODULE*>( item )->GetTextPos();
861 
862  if( Rect.Contains( pos ) )
863  {
864  item->SetFlags( SELECTED );
865  ItemsCount++;
866  }
867 
868  break;
869 
870  default:
871  break;
872  }
873  }
874 
875  return ItemsCount;
876 }
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 584 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().

585 {
586 #define SETMIRROR( z ) (z) -= offset.x; (z) = -(z); (z) += offset.x;
587  wxPoint tmp;
588  wxSize tmpz;
589 
590  if( module == NULL )
591  return;
592 
593  if( module->Reference().IsSelected() || force_all )
594  module->Reference().Mirror( offset, false );
595 
596  if( module->Value().IsSelected() || force_all )
597  module->Value().Mirror( offset, false );
598 
599  for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
600  {
601  // Skip pads not selected, i.e. not inside the block to mirror:
602  if( !pad->IsSelected() && !force_all )
603  continue;
604 
605  tmp = pad->GetPosition();
606  SETMIRROR( tmp.x );
607  pad->SetPosition( tmp );
608 
609  pad->SetX0( pad->GetPosition().x );
610 
611  tmp = pad->GetOffset();
612  tmp.x = -tmp.x;
613  pad->SetOffset( tmp );
614 
615  tmpz = pad->GetDelta();
616  tmpz.x = -tmpz.x;
617  pad->SetDelta( tmpz );
618 
619  pad->SetOrientation( - pad->GetOrientation() );
620  }
621 
622  for( EDA_ITEM* item = module->GraphicalItems(); item; item = item->Next() )
623  {
624  // Skip items not selected, i.e. not inside the block to mirror:
625  if( !item->IsSelected() && !force_all )
626  continue;
627 
628  switch( item->Type() )
629  {
630  case PCB_MODULE_EDGE_T:
631  ((EDGE_MODULE*) item)->Mirror( offset, false );
632  break;
633 
634  case PCB_MODULE_TEXT_T:
635  static_cast<TEXTE_MODULE*>( item )->Mirror( offset, false );
636  break;
637 
638  default:
639  break;
640  }
641  }
642 
643  ClearMarkItems( module );
644 }
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 484 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().

485 {
486  EDA_ITEM* item;
487 
488  if( module == NULL )
489  return;
490 
491  if( module->Reference().IsSelected() )
492  module->Reference().Move( offset );
493 
494  if( module->Value().IsSelected() )
495  module->Value().Move( offset );
496 
497  D_PAD* pad = module->Pads();
498 
499  for( ; pad != NULL; pad = pad->Next() )
500  {
501  if( !pad->IsSelected() )
502  continue;
503 
504  pad->SetPosition( pad->GetPosition() + offset );
505  pad->SetPos0( pad->GetPos0() + offset );
506  }
507 
508  item = module->GraphicalItems();
509 
510  for( ; item != NULL; item = item->Next() )
511  {
512  if( !item->IsSelected() )
513  continue;
514 
515  switch( item->Type() )
516  {
517  case PCB_MODULE_TEXT_T:
518  static_cast<TEXTE_MODULE*>( item )->Move( offset );
519  break;
520 
521  case PCB_MODULE_EDGE_T:
522  {
523  EDGE_MODULE* em = (EDGE_MODULE*) item;
524  em->SetStart( em->GetStart() + offset );
525  em->SetEnd( em->GetEnd() + offset );
526  em->SetStart0( em->GetStart0() + offset );
527  em->SetEnd0( em->GetEnd0() + offset );
528  }
529  break;
530 
531  default:
532  ;
533  }
534  }
535 
536  ClearMarkItems( module );
537 }
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 725 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().

728 {
729  if( module == NULL )
730  return;
731 
732  if( module->Reference().IsSelected() || force_all )
733  {
734  module->Reference().Rotate( centre, rotation );
735  module->Reference().Move( translation );
736  }
737 
738  if( module->Value().IsSelected() || force_all )
739  {
740  module->Value().Rotate( centre, rotation );
741  module->Value().Move( translation );
742  }
743 
744  D_PAD* pad = module->Pads();
745 
746  for( ; pad != NULL; pad = pad->Next() )
747  {
748  if( !pad->IsSelected() && !force_all )
749  continue;
750 
751  // rotate about centre point,
752  wxPoint newPos = pad->GetPosition();
753  RotatePoint( &newPos, centre, rotation );
754 
755  // shift and update
756  newPos += translation;
757  pad->SetPosition( newPos );
758  pad->SetPos0( newPos );
759 
760  // finally apply rotation to the pad itself
761  pad->Rotate( newPos, rotation );
762  }
763 
764  EDA_ITEM* item = module->GraphicalItems();
765 
766  for( ; item != NULL; item = item->Next() )
767  {
768  if( !item->IsSelected() && !force_all )
769  continue;
770 
771  switch( item->Type() )
772  {
773  case PCB_MODULE_TEXT_T:
774  {
775  TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
776 
777  text->Rotate( centre, rotation );
778  text->Move( translation );
779  break;
780  }
781  case PCB_MODULE_EDGE_T:
782  {
783  EDGE_MODULE* em = static_cast<EDGE_MODULE*>( item );
784  em->Rotate( centre, rotation );
785  em->Move( translation );
786  break;
787  }
788  default:
789  ;
790  }
791  }
792 
793  ClearMarkItems( module );
794 }
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:836
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 651 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().

652 {
653 #define ROTATE( z ) RotatePoint( (&z), offset, 900 )
654 
655  if( module == NULL )
656  return;
657 
658  if( module->Reference().IsSelected() || force_all )
659  module->Reference().Rotate( offset, 900 );
660 
661  if( module->Value().IsSelected() || force_all )
662  module->Value().Rotate( offset, 900 );
663 
664  for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
665  {
666  if( !pad->IsSelected() && !force_all )
667  continue;
668 
669  wxPoint pos = pad->GetPos0();
670  ROTATE( pos );
671  pad->SetPos0( pos );
672  pad->SetOrientation( pad->GetOrientation() + 900 );
673 
674  pad->SetDrawCoord();
675  }
676 
677  for( EDA_ITEM* item = module->GraphicalItems(); item; item = item->Next() )
678  {
679  if( !item->IsSelected() && !force_all )
680  continue;
681 
682  switch( item->Type() )
683  {
684  case PCB_MODULE_EDGE_T:
685  ((EDGE_MODULE*) item)->Rotate( offset, 900 );
686  break;
687 
688  case PCB_MODULE_TEXT_T:
689  static_cast<TEXTE_MODULE*>( item )->Rotate( offset, 900 );
690  break;
691 
692  default:
693  break;
694  }
695  }
696 
697  ClearMarkItems( module );
698 }
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)