KiCad PCB EDA Suite
DRAG_LIST Class Reference

#include <drag.h>

Public Member Functions

 DRAG_LIST (BOARD *aPcb)
 
void ClearList ()
 Function ClearList clear the .m_Flags of all track segments in m_DragList and clear the list. More...
 
void BuildDragListe (MODULE *aModule)
 Build the list of track segments connected to pads of aModule in m_DragList For each selected track segment the EDIT flag is set. More...
 
void BuildDragListe (D_PAD *aPad)
 Build the list of track segments connected to aPad in m_DragList For each selected track segment the EDIT flag is set. More...
 

Public Attributes

BOARDm_Brd
 
MODULEm_Module
 
D_PADm_Pad
 
std::vector< DRAG_SEGM_PICKERm_DragList
 

Private Member Functions

void fillList (CONNECTIONS &aConnections)
 Fills m_DragList with of track segments connected to pads in aConnections For each selected track segment the EDIT flag is set. More...
 

Detailed Description

Definition at line 112 of file drag.h.

Constructor & Destructor Documentation

DRAG_LIST::DRAG_LIST ( BOARD aPcb)
inline

Definition at line 122 of file drag.h.

123  {
124  m_Brd = aPcb;
125  m_Module = NULL;
126  m_Pad = NULL;
127  }
MODULE * m_Module
Definition: drag.h:116
BOARD * m_Brd
Definition: drag.h:115
D_PAD * m_Pad
Definition: drag.h:117

Member Function Documentation

void DRAG_LIST::BuildDragListe ( MODULE aModule)

Build the list of track segments connected to pads of aModule in m_DragList For each selected track segment the EDIT flag is set.

Definition at line 153 of file dragsegm.cpp.

References fillList(), CONNECTIONS::GetPadsList(), m_Brd, m_Module, m_Pad, D_PAD::Next(), MODULE::Pads(), and sortPadsByXthenYCoord().

Referenced by PCB_EDIT_FRAME::StartMoveModule(), and PCB_BASE_FRAME::StartMovePad().

154 {
155  m_Pad = NULL;
156  m_Module = aModule;
157 
158  // Build connections info
159  CONNECTIONS connections( m_Brd );
160  std::vector<D_PAD*>&padList = connections.GetPadsList();
161 
162  for( D_PAD* pad = aModule->Pads(); pad; pad = pad->Next() )
163  padList.push_back( pad );
164 
165  sort( padList.begin(), padList.end(), sortPadsByXthenYCoord );
166 
167  fillList( connections );
168 }
MODULE * m_Module
Definition: drag.h:116
void fillList(CONNECTIONS &aConnections)
Fills m_DragList with of track segments connected to pads in aConnections For each selected track seg...
Definition: dragsegm.cpp:192
bool sortPadsByXthenYCoord(D_PAD *const &ref, D_PAD *const &comp)
Function SortPadsByXCoord is used by GetSortedPadListByXCoord to Sort a pad list by x coordinate valu...
BOARD * m_Brd
Definition: drag.h:115
D_PAD * Next() const
Definition: class_pad.h:106
D_PAD * m_Pad
Definition: drag.h:117
DLIST< D_PAD > & Pads()
Definition: class_module.h:134
void DRAG_LIST::BuildDragListe ( D_PAD aPad)

Build the list of track segments connected to aPad in m_DragList For each selected track segment the EDIT flag is set.

Definition at line 171 of file dragsegm.cpp.

References fillList(), CONNECTIONS::GetPadsList(), m_Brd, m_Module, and m_Pad.

172 {
173  m_Pad = aPad;
174  m_Module = NULL;
175 
176  // Build connections info
177  CONNECTIONS connections( m_Brd );
178  std::vector<D_PAD*>&padList = connections.GetPadsList();
179  padList.push_back( aPad );
180 
181  fillList( connections );
182 }
MODULE * m_Module
Definition: drag.h:116
void fillList(CONNECTIONS &aConnections)
Fills m_DragList with of track segments connected to pads in aConnections For each selected track seg...
Definition: dragsegm.cpp:192
BOARD * m_Brd
Definition: drag.h:115
D_PAD * m_Pad
Definition: drag.h:117
void DRAG_LIST::ClearList ( )

Function ClearList clear the .m_Flags of all track segments in m_DragList and clear the list.

Definition at line 281 of file dragsegm.cpp.

References m_DragList, m_Module, and m_Pad.

282 {
283  for( unsigned ii = 0; ii < m_DragList.size(); ii++ )
284  m_DragList[ii].m_Track->ClearFlags();
285 
286  m_DragList.clear();
287 
288  m_Module = NULL;
289  m_Pad = NULL;
290 }
MODULE * m_Module
Definition: drag.h:116
std::vector< DRAG_SEGM_PICKER > m_DragList
Definition: drag.h:119
D_PAD * m_Pad
Definition: drag.h:117
void DRAG_LIST::fillList ( CONNECTIONS aConnections)
private

Fills m_DragList with of track segments connected to pads in aConnections For each selected track segment the EDIT flag is set.

Definition at line 192 of file dragsegm.cpp.

References CONNECTIONS::BuildTracksCandidatesList(), BUSY, TRACK::end, END_ON_PAD, g_DragSegmentList, TRACK::GetEnd(), CONNECTIONS::GetPadsList(), TRACK::GetStart(), D_PAD::HitTest(), m_Brd, m_DragList, BOARD::m_Track, BOARD_CONNECTED_ITEM::m_TracksConnected, CONNECTIONS::SearchTracksConnectedToPads(), EDA_ITEM::SetState(), sort_tracklist(), TRACK::start, and START_ON_PAD.

Referenced by BuildDragListe().

193 {
194  aConnections.BuildTracksCandidatesList( m_Brd->m_Track, NULL);
195 
196  // Build connections info tracks to pads
197  // Rebuild pads to track info only)
198  aConnections.SearchTracksConnectedToPads( false, true );
199 
200  std::vector<D_PAD*>padList = aConnections.GetPadsList();
201 
202  // clear flags and variables of selected tracks
203  for( unsigned ii = 0; ii < padList.size(); ii++ )
204  {
205  D_PAD * pad = padList[ii];
206 
207  // store track connected to the pad
208  for( unsigned jj = 0; jj < pad->m_TracksConnected.size(); jj++ )
209  {
210  TRACK * track = pad->m_TracksConnected[jj];
211  track->start = NULL;
212  track->end = NULL;
213  track->SetState( START_ON_PAD|END_ON_PAD|BUSY, false );
214  }
215  }
216 
217  // store tracks connected to pads
218  for( unsigned ii = 0; ii < padList.size(); ii++ )
219  {
220  D_PAD * pad = padList[ii];
221 
222  // store track connected to the pad
223  for( unsigned jj = 0; jj < pad->m_TracksConnected.size(); jj++ )
224  {
225  TRACK * track = pad->m_TracksConnected[jj];
226 
227  if( pad->HitTest( track->GetStart() ) )
228  {
229  track->start = pad;
230  track->SetState( START_ON_PAD, true );
231  }
232 
233  if( pad->HitTest( track->GetEnd() ) )
234  {
235  track->end = pad;
236  track->SetState( END_ON_PAD, true );
237  }
238 
239  DRAG_SEGM_PICKER wrapper( track );
240  m_DragList.push_back( wrapper );
241  }
242  }
243 
244  // remove duplicate in m_DragList:
245  // a track can be stored more than once if connected to 2 overlapping pads, or
246  // each track end connected to 2 moving pads
247  // to avoid artifact in draw function, items should be not duplicated
248  // However, there is not a lot of items to be removed, so there ir no optimization.
249 
250  // sort the drag list by track pointers
251  sort( m_DragList.begin(), m_DragList.end(), sort_tracklist );
252 
253  // Explore the list, merge duplicates
254  for( int ii = 0; ii < (int)m_DragList.size()-1; ii++ )
255  {
256  int jj = ii+1;
257 
258  if( m_DragList[ii].m_Track != m_DragList[jj].m_Track )
259  continue;
260 
261  // duplicate found: merge info and remove duplicate
262  if( m_DragList[ii].m_Pad_Start == NULL )
263  m_DragList[ii].m_Pad_Start = m_DragList[jj].m_Pad_Start;
264 
265  if( m_DragList[ii].m_Pad_End == NULL )
266  m_DragList[ii].m_Pad_End = m_DragList[jj].m_Pad_End;
267 
268  m_DragList.erase( m_DragList.begin() + jj );
269  ii--;
270  }
271 
272  // Initialize pad offsets and other params
273  for( unsigned ii = 0; ii < m_DragList.size(); ii++ )
274  m_DragList[ii].SetAuxParameters();
275 
276  // Copy the list in global list
278 }
bool HitTest(const wxPoint &aPosition) const override
Function HitTest tests if aPosition is contained within or on the bounding area of an item...
Definition: class_pad.cpp:752
#define END_ON_PAD
BOARD * m_Brd
Definition: drag.h:115
#define BUSY
Pcbnew: flag indicating that the structure has.
Definition: base_struct.h:134
#define START_ON_PAD
const wxPoint & GetEnd() const
Definition: class_track.h:118
std::vector< DRAG_SEGM_PICKER > m_DragList
Definition: drag.h:119
void BuildTracksCandidatesList(TRACK *aBegin, TRACK *aEnd=NULL)
Function BuildTracksCandidatesList Fills m_Candidates with all connecting points (track ends or via l...
Definition: connect.cpp:252
std::vector< D_PAD * > & GetPadsList()
Function GetPadsList.
Definition: connect.h:120
const wxPoint & GetStart() const
Definition: class_track.h:121
void SearchTracksConnectedToPads(bool add_to_padlist=true, bool add_to_tracklist=true)
function SearchTracksConnectedToPads Explores the list of pads.
Definition: connect.cpp:114
void SetState(int type, int state)
Definition: base_struct.h:242
std::vector< TRACK * > m_TracksConnected
DLIST< TRACK > m_Track
Definition: class_board.h:244
Helper classes to handle a list of track segments to drag and has info to undo/abort the move command...
Definition: drag.h:58
bool sort_tracklist(const DRAG_SEGM_PICKER &ref, const DRAG_SEGM_PICKER &tst)
Definition: dragsegm.cpp:186
BOARD_CONNECTED_ITEM * end
Definition: class_track.h:90
BOARD_CONNECTED_ITEM * start
Definition: class_track.h:89
std::vector< DRAG_SEGM_PICKER > g_DragSegmentList
Definition: dragsegm.cpp:48

Member Data Documentation

BOARD* DRAG_LIST::m_Brd

Definition at line 115 of file drag.h.

Referenced by BuildDragListe(), and fillList().

std::vector<DRAG_SEGM_PICKER> DRAG_LIST::m_DragList

Definition at line 119 of file drag.h.

Referenced by ClearList(), and fillList().

MODULE* DRAG_LIST::m_Module

Definition at line 116 of file drag.h.

Referenced by BuildDragListe(), and ClearList().

D_PAD* DRAG_LIST::m_Pad

Definition at line 117 of file drag.h.

Referenced by BuildDragListe(), and ClearList().


The documentation for this class was generated from the following files: