KiCad PCB EDA Suite
pcb_footprint_edit_utils.cpp File Reference
#include <fctsys.h>
#include <gr_basic.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <pcb_edit_frame.h>
#include <trigo.h>
#include <macros.h>
#include <class_board.h>
#include <class_module.h>
#include <pcbnew.h>
#include <drag.h>
#include <dialog_get_footprint_by_name.h>
#include <connectivity/connectivity_data.h>

Go to the source code of this file.


static void MoveFootprint (EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
static void Abort_MoveOrCopyModule (EDA_DRAW_PANEL *Panel, wxDC *DC)


static MODULEs_ModuleInitialCopy = NULL
static PICKED_ITEMS_LIST s_PickedList

Function Documentation

void Abort_MoveOrCopyModule ( EDA_DRAW_PANEL Panel,
wxDC *  DC 

Definition at line 163 of file pcb_footprint_edit_utils.cpp.

References BOARD::BuildListOfNets(), PCB_EDIT_FRAME::Change_Side_Module(), EDA_ITEM::ClearFlags(), PICKED_ITEMS_LIST::ClearListAndDeleteItems(), BOARD_ITEM::DeleteStructure(), DO_NOT_SHOW_GENERAL_RASTNEST, TRACK::Draw(), MODULE::Draw(), PCB_BASE_FRAME::DrawGeneralRatsnest(), MODULE::DrawOutlinesWhenMoving(), EraseDragList(), g_DragSegmentList, g_Offset_Module, PCB_BASE_FRAME::GetBoard(), PCB_SCREEN::GetCurItem(), BOARD_ITEM::GetLayer(), MODULE::GetOrientation(), EDA_DRAW_PANEL::GetParent(), PCB_BASE_FRAME::GetScreen(), GR_OR, GR_XOR, IN_EDIT, IS_MOVED, BOARD::IsElementVisible(), EDA_ITEM::IsMoving(), EDA_ITEM::IsNew(), LAYER_RATSNEST, BOARD::m_Status_Pcb, RATSNEST_ITEM_LOCAL_OK, EDA_DRAW_PANEL::Refresh(), PCB_BASE_FRAME::Rotate_Module(), s_ModuleInitialCopy, PCB_BASE_FRAME::SetCurItem(), EDA_DRAW_PANEL::SetMouseCapture(), and EDA_ITEM::SetState().

Referenced by PCB_EDIT_FRAME::StartMoveModule().

164 {
165  TRACK* pt_segm;
166  MODULE* module;
167  PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Panel->GetParent();
169  module = (MODULE*) pcbframe->GetScreen()->GetCurItem();
171  Panel->SetMouseCapture( NULL, NULL );
173  if( module )
174  {
175  // Erase the current footprint on screen
176  module->DrawOutlinesWhenMoving( Panel, DC, g_Offset_Module );
178  /* If a move command: return to old position
179  * If a copy command, delete the new footprint
180  */
181  if( module->IsMoving() )
182  {
183  /* Restore old position for dragged tracks */
184  for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
185  {
186  pt_segm = g_DragSegmentList[ii].m_Track;
187  pt_segm->Draw( Panel, DC, GR_XOR );
188  pt_segm->SetState( IN_EDIT, false );
189  pt_segm->ClearFlags();
190  g_DragSegmentList[ii].RestoreInitialValues();
191  pt_segm->Draw( Panel, DC, GR_OR );
192  }
194  EraseDragList();
195  module->ClearFlags( IS_MOVED );
196  }
198  if( module->IsNew() ) // Copy command: delete new footprint
199  {
200  module->DeleteStructure();
201  module = NULL;
202  pcbframe->GetBoard()->m_Status_Pcb = 0;
203  pcbframe->GetBoard()->BuildListOfNets();
204  }
205  }
207  /* Redraw the module. */
208  if( module && s_ModuleInitialCopy )
209  {
211  pcbframe->Rotate_Module( NULL, module, s_ModuleInitialCopy->GetOrientation(), false );
213  if( s_ModuleInitialCopy->GetLayer() != module->GetLayer() )
214  pcbframe->Change_Side_Module( module, NULL );
216  module->Draw( Panel, DC, GR_OR );
217  }
219  pcbframe->SetCurItem( NULL );
221  delete s_ModuleInitialCopy;
222  s_ModuleInitialCopy = NULL;
225  // Display ratsnest is allowed
228  if( pcbframe->GetBoard()->IsElementVisible( LAYER_RATSNEST ) )
229  pcbframe->DrawGeneralRatsnest( DC );
231 #ifdef __WXMAC__
232  Panel->Refresh();
233 #endif
234 }
void BuildListOfNets()
Definition: class_board.h:735
wxPoint g_Offset_Module
Definition: pcbnew.cpp:75
bool IsMoving() const
Definition: base_struct.h:221
#define IN_EDIT
Item currently edited.
Definition: base_struct.h:112
bool IsNew() const
Definition: base_struct.h:219
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, GR_DRAWMODE aDrawMode, const wxPoint &aOffset=ZeroOffset) override
Function Draw draws the footprint to the aDC.
static MODULE * s_ModuleInitialCopy
void SetCurItem(BOARD_ITEM *aItem, bool aDisplayInfo=true)
Function SetCurItem sets the currently selected item and displays it in the MsgPanel.
void EraseDragList()
Function EraseDragList clear the .m_Flags of all track segments stored in g_DragSegmentList and clear...
Definition: dragsegm.cpp:293
void DeleteStructure()
Function DeleteStructure deletes this object after UnLink()ing it from its owner if it has one...
BOARD * GetBoard() const
void Rotate_Module(wxDC *DC, MODULE *module, double angle, bool incremental)
virtual EDA_DRAW_FRAME * GetParent() const =0
std::vector< DRAG_SEGM_PICKER > g_DragSegmentList
Definition: dragsegm.cpp:47
BOARD_ITEM * GetCurItem() const
Function GetCurItem returns the currently selected BOARD_ITEM, overriding BASE_SCREEN::GetCurItem().
Definition: pcb_screen.h:72
double GetOrientation() const
Definition: class_module.h:188
virtual void SetMouseCapture(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback)
Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallb...
void DrawGeneralRatsnest(wxDC *aDC, int aNetcode=0)
function Displays the general ratsnest Only ratsnest with the status bit CH_VISIBLE is set are displa...
Definition: ratsnest.cpp:88
Definition: gr_basic.h:38
void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, GR_DRAWMODE aDrawMode, const wxPoint &aOffset=ZeroOffset) override
Function Draw BOARD_ITEMs have their own color information.
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Function IsElementVisible tests whether a given element category is visible.
void SetState(int type, int state)
Definition: base_struct.h:245
static PICKED_ITEMS_LIST s_PickedList
Class PCB_EDIT_FRAME is the main frame for Pcbnew.
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
Definition: base_struct.h:257
void DrawOutlinesWhenMoving(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aMoveVector)
Function DrawOutlinesWhenMoving draws in XOR mode the footprint when moving it to the aDC...
Definition: ratsnest.cpp:226
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL)
void Change_Side_Module(MODULE *Module, wxDC *DC)
Function Change_Side_Module Flip a footprint (switch layer from component or component to copper) The...
void ClearListAndDeleteItems()
Function ClearListAndDeleteItems deletes the list of pickers, AND the data pointed by m_PickedItem or...
int m_Status_Pcb
Flags used in ratsnest calculation and update.
Definition: class_board.h:241
#define IS_MOVED
Item being moved.
Definition: base_struct.h:113
void MoveFootprint ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
const wxPoint &  aPosition,
bool  aErase 

Definition at line 239 of file pcb_footprint_edit_utils.cpp.

References MODULE::DrawOutlinesWhenMoving(), DrawSegmentWhileMovingFootprint(), g_Offset_Module, EDA_DRAW_FRAME::GetCrossHairPosition(), BASE_SCREEN::GetCurItem(), EDA_DRAW_PANEL::GetParent(), MODULE::GetPosition(), and EDA_DRAW_PANEL::GetScreen().

Referenced by PCB_EDIT_FRAME::StartMoveModule().

240 {
241  MODULE* module = (MODULE*) aPanel->GetScreen()->GetCurItem();
243  if( module == NULL )
244  return;
246  /* Erase current footprint. */
247  if( aErase )
248  {
249  module->DrawOutlinesWhenMoving( aPanel, aDC, g_Offset_Module );
250  }
252  /* Redraw the module at the new position. */
253  g_Offset_Module = module->GetPosition() - aPanel->GetParent()->GetCrossHairPosition();
254  module->DrawOutlinesWhenMoving( aPanel, aDC, g_Offset_Module );
256  DrawSegmentWhileMovingFootprint( aPanel, aDC );
257 }
virtual BASE_SCREEN * GetScreen()=0
wxPoint g_Offset_Module
Definition: pcbnew.cpp:75
void DrawSegmentWhileMovingFootprint(EDA_DRAW_PANEL *panel, wxDC *DC)
Definition: dragsegm.cpp:278
EDA_ITEM * GetCurItem() const
Definition: base_screen.h:233
virtual EDA_DRAW_FRAME * GetParent() const =0
void DrawOutlinesWhenMoving(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aMoveVector)
Function DrawOutlinesWhenMoving draws in XOR mode the footprint when moving it to the aDC...
Definition: ratsnest.cpp:226
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
const wxPoint GetPosition() const override
Definition: class_module.h:183

Variable Documentation

MODULE* s_ModuleInitialCopy = NULL

Definition at line 56 of file pcb_footprint_edit_utils.cpp.