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 51 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.

52 {
53  m_Track = aTrack;
58  m_TempFlags = 0;
59  m_RotationOffset = 0.0;
60  m_Flipped = false;
61 }
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:264
#define START_ON_PAD
const wxPoint & GetEnd() const
Definition: class_track.h:120
wxPoint m_endInitialValue
Definition: drag.h:82
D_PAD * m_Pad_Start
Definition: drag.h:62
const wxPoint & GetStart() const
Definition: class_track.h:123
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:92
BOARD_CONNECTED_ITEM * start
Definition: class_track.h:91
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:119
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:122
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 64 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.

65 {
66  MODULE* module = NULL;
67 
68  if( m_Pad_Start )
69  {
70  module = m_Pad_Start->GetParent();
72  }
73 
74  if( m_Pad_End )
75  {
76  if( module == NULL )
77  module = m_Pad_End->GetParent();
78 
80  }
81 
82  if( module )
83  {
84  m_Flipped = module->IsFlipped();
85  m_RotationOffset = module->GetOrientation();
86  }
87 }
wxPoint m_PadEndOffset
Definition: drag.h:79
MODULE * GetParent() const
Definition: class_pad.h:162
bool m_Flipped
Definition: drag.h:74
wxPoint m_PadStartOffset
Definition: drag.h:77
const wxPoint & GetEnd() const
Definition: class_track.h:120
double GetOrientation() const
Definition: class_module.h:180
D_PAD * m_Pad_Start
Definition: drag.h:62
const wxPoint & GetStart() const
Definition: class_track.h:123
const wxPoint & GetPosition() const override
Definition: class_pad.h:220
bool IsFlipped() const
function IsFlipped
Definition: class_module.h:247
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 90 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.

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

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: