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 (std::vector< D_PAD * > &aList)
 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 152 of file dragsegm.cpp.

References fillList(), m_Module, m_Pad, MODULE::Pads(), and sortPadsByXthenYCoord().

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

153 {
154  m_Pad = NULL;
155  m_Module = aModule;
156 
157  std::vector<D_PAD*> padList;
158 
159  for( auto pad : aModule->Pads() )
160  padList.push_back( pad );
161 
162  sort( padList.begin(), padList.end(), sortPadsByXthenYCoord );
163 
164  fillList( padList );
165 }
MODULE * m_Module
Definition: drag.h:116
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...
DLIST_ITERATOR_WRAPPER< D_PAD > Pads()
Definition: class_module.h:160
D_PAD * m_Pad
Definition: drag.h:117
void fillList(std::vector< D_PAD * > &aList)
Fills m_DragList with of track segments connected to pads in aConnections For each selected track seg...
Definition: dragsegm.cpp:187
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 168 of file dragsegm.cpp.

References fillList(), m_Module, and m_Pad.

169 {
170  m_Pad = aPad;
171  m_Module = NULL;
172 
173  // Build connections info
174  std::vector<D_PAD*> padList;
175  padList.push_back( aPad );
176 
177  fillList( padList );
178 }
MODULE * m_Module
Definition: drag.h:116
D_PAD * m_Pad
Definition: drag.h:117
void fillList(std::vector< D_PAD * > &aList)
Fills m_DragList with of track segments connected to pads in aConnections For each selected track seg...
Definition: dragsegm.cpp:187
void DRAG_LIST::ClearList ( )

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

Definition at line 265 of file dragsegm.cpp.

References m_DragList, m_Module, and m_Pad.

266 {
267  for( unsigned ii = 0; ii < m_DragList.size(); ii++ )
268  m_DragList[ii].m_Track->ClearFlags();
269 
270  m_DragList.clear();
271 
272  m_Module = NULL;
273  m_Pad = NULL;
274 }
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 ( std::vector< D_PAD * > &  aList)
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 187 of file dragsegm.cpp.

References BUSY, END_ON_PAD, g_DragSegmentList, BOARD::GetConnectivity(), m_Brd, m_DragList, sort_tracklist(), and START_ON_PAD.

Referenced by BuildDragListe().

188 {
189  // clear flags and variables of selected tracks
190  for( auto pad : aList )
191  {
192  auto connectedTracks = m_Brd->GetConnectivity()->GetConnectedTracks( pad );
193 
194  // store track connected to the pad
195  for( auto track : connectedTracks )
196  {
197  track->start = NULL;
198  track->end = NULL;
199  track->SetState( START_ON_PAD|END_ON_PAD|BUSY, false );
200  }
201  }
202 
203  // store tracks connected to pads
204  for( auto pad : aList )
205  {
206  auto connectedTracks = m_Brd->GetConnectivity()->GetConnectedTracks( pad );
207 
208  // store track connected to the pad
209  for( auto track : connectedTracks )
210  {
211  if( pad->HitTest( track->GetStart() ) )
212  {
213  track->start = pad;
214  track->SetState( START_ON_PAD, true );
215  }
216 
217  if( pad->HitTest( track->GetEnd() ) )
218  {
219  track->end = pad;
220  track->SetState( END_ON_PAD, true );
221  }
222 
223  DRAG_SEGM_PICKER wrapper( track );
224  m_DragList.push_back( wrapper );
225  }
226  }
227 
228  // remove duplicate in m_DragList:
229  // a track can be stored more than once if connected to 2 overlapping pads, or
230  // each track end connected to 2 moving pads
231  // to avoid artifact in draw function, items should be not duplicated
232  // However, there is not a lot of items to be removed, so there ir no optimization.
233 
234  // sort the drag list by track pointers
235  sort( m_DragList.begin(), m_DragList.end(), sort_tracklist );
236 
237  // Explore the list, merge duplicates
238  for( int ii = 0; ii < (int)m_DragList.size()-1; ii++ )
239  {
240  int jj = ii+1;
241 
242  if( m_DragList[ii].m_Track != m_DragList[jj].m_Track )
243  continue;
244 
245  // duplicate found: merge info and remove duplicate
246  if( m_DragList[ii].m_Pad_Start == NULL )
247  m_DragList[ii].m_Pad_Start = m_DragList[jj].m_Pad_Start;
248 
249  if( m_DragList[ii].m_Pad_End == NULL )
250  m_DragList[ii].m_Pad_End = m_DragList[jj].m_Pad_End;
251 
252  m_DragList.erase( m_DragList.begin() + jj );
253  ii--;
254  }
255 
256  // Initialize pad offsets and other params
257  for( unsigned ii = 0; ii < m_DragList.size(); ii++ )
258  m_DragList[ii].SetAuxParameters();
259 
260  // Copy the list in global list
262 }
#define END_ON_PAD
BOARD * m_Brd
Definition: drag.h:115
#define BUSY
Pcbnew: flag indicating that the structure has.
Definition: base_struct.h:148
#define START_ON_PAD
std::vector< DRAG_SEGM_PICKER > m_DragList
Definition: drag.h:119
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:182
std::vector< DRAG_SEGM_PICKER > g_DragSegmentList
Definition: dragsegm.cpp:47
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:290

Member Data Documentation

BOARD* DRAG_LIST::m_Brd

Definition at line 115 of file drag.h.

Referenced by 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: