KiCad PCB EDA Suite
DRAG_SEGM_PICKER Class Reference

Helper classes to handle a list of track segments to drag and has info to undo/abort the move command. More...

#include <drag.h>

Public Member Functions

 DRAG_SEGM_PICKER (TRACK *aTrack)
 
 ~DRAG_SEGM_PICKER ()
 
void SetAuxParameters ()
 Set auxiliary parameters relative to calculations needed to find track ends positions while dragging pads and when modules are rotated, flipped. More...
 
void SetTrackEndsCoordinates (wxPoint aOffset)
 Calculate track ends position while dragging pads and when modules are rotated, flipped. More...
 
void RestoreInitialValues ()
 

Public Attributes

TRACKm_Track
 
D_PADm_Pad_Start
 
D_PADm_Pad_End
 
int m_TempFlags
 

Private Attributes

double m_RotationOffset
 
bool m_Flipped
 
wxPoint m_PadStartOffset
 
wxPoint m_PadEndOffset
 
wxPoint m_startInitialValue
 
wxPoint m_endInitialValue
 

Detailed Description

Helper classes to handle a list of track segments to drag and has info to undo/abort the move command.

a DRAG_SEGM_PICKER manage one track segment or a via

Definition at line 58 of file drag.h.

Constructor & Destructor Documentation

DRAG_SEGM_PICKER::DRAG_SEGM_PICKER ( TRACK aTrack)

Definition at line 52 of file dragsegm.cpp.

References TRACK::end, END_ON_PAD, TRACK::GetEnd(), TRACK::GetStart(), EDA_ITEM::GetState(), m_endInitialValue, m_Flipped, m_Pad_End, m_Pad_Start, m_RotationOffset, m_startInitialValue, m_TempFlags, m_Track, TRACK::start, and START_ON_PAD.

53 {
54  m_Track = aTrack;
59  m_TempFlags = 0;
60  m_RotationOffset = 0.0;
61  m_Flipped = false;
62 }
int m_TempFlags
Definition: drag.h:68
#define END_ON_PAD
wxPoint m_startInitialValue
Definition: drag.h:81
bool m_Flipped
Definition: drag.h:74
int GetState(int type) const
Definition: base_struct.h:237
#define START_ON_PAD
const wxPoint & GetEnd() const
Definition: class_track.h:117
wxPoint m_endInitialValue
Definition: drag.h:82
D_PAD * m_Pad_Start
Definition: drag.h:62
const wxPoint & GetStart() const
Definition: class_track.h:120
D_PAD * m_Pad_End
Definition: drag.h:65
double m_RotationOffset
Definition: drag.h:71
TRACK * m_Track
Definition: drag.h:61
BOARD_CONNECTED_ITEM * end
Definition: class_track.h:89
BOARD_CONNECTED_ITEM * start
Definition: class_track.h:88
DRAG_SEGM_PICKER::~DRAG_SEGM_PICKER ( )
inline

Definition at line 88 of file drag.h.

88 {};

Member Function Documentation

void DRAG_SEGM_PICKER::RestoreInitialValues ( )
inline

Definition at line 104 of file drag.h.

References TRACK::SetEnd(), and TRACK::SetStart().

105  {
108  }
void SetEnd(const wxPoint &aEnd)
Definition: class_track.h:116
wxPoint m_startInitialValue
Definition: drag.h:81
wxPoint m_endInitialValue
Definition: drag.h:82
TRACK * m_Track
Definition: drag.h:61
void SetStart(const wxPoint &aStart)
Definition: class_track.h:119
void DRAG_SEGM_PICKER::SetAuxParameters ( )

Set auxiliary parameters relative to calculations needed to find track ends positions while dragging pads and when modules are rotated, flipped.

Definition at line 65 of file dragsegm.cpp.

References TRACK::GetEnd(), MODULE::GetOrientation(), D_PAD::GetParent(), D_PAD::GetPosition(), TRACK::GetStart(), MODULE::IsFlipped(), m_Flipped, m_Pad_End, m_Pad_Start, m_PadEndOffset, m_PadStartOffset, m_RotationOffset, and m_Track.

66 {
67  MODULE* module = NULL;
68 
69  if( m_Pad_Start )
70  {
71  module = m_Pad_Start->GetParent();
73  }
74 
75  if( m_Pad_End )
76  {
77  if( module == NULL )
78  module = m_Pad_End->GetParent();
79 
81  }
82 
83  if( module )
84  {
85  m_Flipped = module->IsFlipped();
86  m_RotationOffset = module->GetOrientation();
87  }
88 }
wxPoint m_PadEndOffset
Definition: drag.h:79
MODULE * GetParent() const
Definition: class_pad.h:108
bool m_Flipped
Definition: drag.h:74
wxPoint m_PadStartOffset
Definition: drag.h:77
const wxPoint & GetEnd() const
Definition: class_track.h:117
double GetOrientation() const
Definition: class_module.h:147
D_PAD * m_Pad_Start
Definition: drag.h:62
const wxPoint & GetStart() const
Definition: class_track.h:120
const wxPoint & GetPosition() const override
Definition: class_pad.h:170
bool IsFlipped() const
function IsFlipped
Definition: class_module.h:214
D_PAD * m_Pad_End
Definition: drag.h:65
double m_RotationOffset
Definition: drag.h:71
TRACK * m_Track
Definition: drag.h:61
void DRAG_SEGM_PICKER::SetTrackEndsCoordinates ( wxPoint  aOffset)

Calculate track ends position while dragging pads and when modules are rotated, flipped.

Parameters
aOffset= offset of module or pad position (when moving)

Definition at line 91 of file dragsegm.cpp.

References MODULE::GetOrientation(), D_PAD::GetParent(), D_PAD::GetPosition(), MODULE::IsFlipped(), m_Flipped, m_Pad_End, m_Pad_Start, m_PadEndOffset, m_PadStartOffset, m_RotationOffset, m_Track, RotatePoint(), TRACK::SetEnd(), TRACK::SetStart(), and wxPoint::y.

92 {
93  // the track start position is the pad position + m_PadStartOffset
94  // however m_PadStartOffset is known for the initial rotation/flip
95  // this is also true for track end position and m_PadEndOffset
96  // Therefore, because rotation/flipping is allowed during a drag
97  // and move module, we should recalculate the pad offset,
98  // depending on the current orientation/flip state of the module
99  // relative to its initial orientation.
100  // (although most of time, offset is 0,0)
101 
102  double curr_rot_offset = m_RotationOffset;
103  MODULE* module = NULL;
104  bool flip = false;
105 
106  if( m_Pad_Start )
107  module = m_Pad_Start->GetParent();
108 
109  if( module == NULL && m_Pad_End )
110  module = m_Pad_End->GetParent();
111 
112  if( module )
113  {
114  flip = m_Flipped != module->IsFlipped();
115  curr_rot_offset = module->GetOrientation() - m_RotationOffset;
116 
117  if( flip ) // when flipping, module orientation is negated
118  curr_rot_offset = - module->GetOrientation() - m_RotationOffset;
119  }
120 
121  if( m_Pad_Start )
122  {
123  wxPoint padoffset = m_PadStartOffset;
124 
125  if( curr_rot_offset != 0.0 )
126  RotatePoint(&padoffset, curr_rot_offset);
127 
128  if( flip )
129  padoffset.y = -padoffset.y;
130 
131  m_Track->SetStart( m_Pad_Start->GetPosition() - aOffset + padoffset );
132  }
133 
134  if( m_Pad_End )
135  {
136  wxPoint padoffset = m_PadEndOffset;
137 
138  if( curr_rot_offset != 0.0 )
139  RotatePoint( &padoffset, curr_rot_offset );
140 
141  if( flip )
142  padoffset.y = -padoffset.y;
143 
144  m_Track->SetEnd( m_Pad_End->GetPosition() - aOffset + padoffset );
145  }
146 }
wxPoint m_PadEndOffset
Definition: drag.h:79
void SetEnd(const wxPoint &aEnd)
Definition: class_track.h:116
MODULE * GetParent() const
Definition: class_pad.h:108
bool m_Flipped
Definition: drag.h:74
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
wxPoint m_PadStartOffset
Definition: drag.h:77
double GetOrientation() const
Definition: class_module.h:147
D_PAD * m_Pad_Start
Definition: drag.h:62
const wxPoint & GetPosition() const override
Definition: class_pad.h:170
bool IsFlipped() const
function IsFlipped
Definition: class_module.h:214
D_PAD * m_Pad_End
Definition: drag.h:65
double m_RotationOffset
Definition: drag.h:71
TRACK * m_Track
Definition: drag.h:61
void SetStart(const wxPoint &aStart)
Definition: class_track.h:119

Member Data Documentation

wxPoint DRAG_SEGM_PICKER::m_endInitialValue
private

Definition at line 82 of file drag.h.

Referenced by DRAG_SEGM_PICKER().

bool DRAG_SEGM_PICKER::m_Flipped
private

Definition at line 74 of file drag.h.

Referenced by DRAG_SEGM_PICKER(), SetAuxParameters(), and SetTrackEndsCoordinates().

D_PAD* DRAG_SEGM_PICKER::m_Pad_End

Definition at line 65 of file drag.h.

Referenced by DRAG_SEGM_PICKER(), SetAuxParameters(), and SetTrackEndsCoordinates().

D_PAD* DRAG_SEGM_PICKER::m_Pad_Start

Definition at line 62 of file drag.h.

Referenced by DRAG_SEGM_PICKER(), SetAuxParameters(), and SetTrackEndsCoordinates().

wxPoint DRAG_SEGM_PICKER::m_PadEndOffset
private

Definition at line 79 of file drag.h.

Referenced by SetAuxParameters(), and SetTrackEndsCoordinates().

wxPoint DRAG_SEGM_PICKER::m_PadStartOffset
private

Definition at line 77 of file drag.h.

Referenced by SetAuxParameters(), and SetTrackEndsCoordinates().

double DRAG_SEGM_PICKER::m_RotationOffset
private

Definition at line 71 of file drag.h.

Referenced by DRAG_SEGM_PICKER(), SetAuxParameters(), and SetTrackEndsCoordinates().

wxPoint DRAG_SEGM_PICKER::m_startInitialValue
private

Definition at line 81 of file drag.h.

Referenced by DRAG_SEGM_PICKER().

int DRAG_SEGM_PICKER::m_TempFlags

Definition at line 68 of file drag.h.

Referenced by AddSegmentToDragList(), and DRAG_SEGM_PICKER().

TRACK* DRAG_SEGM_PICKER::m_Track

Definition at line 61 of file drag.h.

Referenced by DRAG_SEGM_PICKER(), SetAuxParameters(), SetTrackEndsCoordinates(), and sort_tracklist().


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