KiCad PCB EDA Suite
modules.cpp File Reference
#include <fctsys.h>
#include <gr_basic.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <wxPcbStruct.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.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 modules.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:722
static PICKED_ITEMS_LIST s_PickedList
Definition: modules.cpp:56
wxPoint g_Offset_Module
Definition: pcbnew.cpp:73
bool IsElementVisible(GAL_LAYER_ID LAYER_aPCB) const
Function IsElementVisible tests whether a given element category is visible.
bool IsMoving() const
Definition: base_struct.h:232
#define IN_EDIT
Item currently edited.
Definition: base_struct.h:125
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:325
bool IsNew() const
Definition: base_struct.h:230
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, GR_DRAWMODE aDrawMode, const wxPoint &aOffset=ZeroOffset) override
Function Draw draws the footprint to the aDC.
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)
Definition: modules.cpp:433
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().
static MODULE * s_ModuleInitialCopy
Definition: modules.cpp:53
double GetOrientation() const
Definition: class_module.h:160
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:87
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
Definition: gr_basic.h:42
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.
PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
void SetState(int type, int state)
Definition: base_struct.h:256
PCB_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: base_struct.h:268
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:217
void Change_Side_Module(MODULE *Module, wxDC *DC)
Function Change_Side_Module Flip a footprint (switch layer from component or component to copper) The...
Definition: modules.cpp:287
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 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:237
#define IS_MOVED
Item being moved.
Definition: base_struct.h:126
void MoveFootprint ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
const wxPoint aPosition,
bool  aErase 

Definition at line 239 of file modules.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 }
wxPoint g_Offset_Module
Definition: pcbnew.cpp:73
void DrawSegmentWhileMovingFootprint(EDA_DRAW_PANEL *panel, wxDC *DC)
Definition: dragsegm.cpp:278
EDA_ITEM * GetCurItem() const
const wxPoint & GetPosition() const override
Definition: class_module.h:155
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:187
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:217
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...

Variable Documentation

MODULE* s_ModuleInitialCopy = NULL

Definition at line 56 of file modules.cpp.