KiCad PCB EDA Suite
drag.h
Go to the documentation of this file.
1 
6 /*
7  * This program source code file is part of KiCad, a free EDA CAD application.
8  *
9  * Copyright (C) 2004-2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
10  * Copyright (C) 1992-2015 KiCad Developers, see change_log.txt for contributors.
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, you may find one here:
24  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
25  * or you may search the http://www.gnu.org website for the version 2 license,
26  * or you may write to the Free Software Foundation, Inc.,
27  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
28  */
29 
30 #ifndef _DRAG_H_
31 #define _DRAG_H_
32 
33 
34 #include <class_track.h>
35 #include <vector>
36 
37 
38 class wxDC;
39 class wxPoint;
40 class EDA_DRAW_PANEL;
41 class MODULE;
42 class D_PAD;
43 class CONNECTIONS;
44 
45 
50  /*
51  * a DRAG_LIST manages the list of track segments to modify
52  * when the pad or the module is moving in drag mode
53  */
54 
59 {
60 public:
61  TRACK* m_Track; // pointer to the parent track segment
62  D_PAD* m_Pad_Start; // pointer to the moving pad
63  // if the start point should follow this pad
64  // or NULL
65  D_PAD* m_Pad_End; // pointer to the moving pad
66  // if the end point should follow this pad
67  // or NULL
68  int m_TempFlags; // flag used in drag vias and drag track segment functions
69 
70 private:
71  double m_RotationOffset; // initial orientation of the parent module
72  // Used to recalculate m_PadStartOffset and m_PadEndOffset
73  // after a module rotation when dragging
74  bool m_Flipped; // initial side of the parent module
75  // Used to recalculate m_PadStartOffset and m_PadEndOffset
76  // if the module is flipped when dragging
77  wxPoint m_PadStartOffset; // offset between the pad and the starting point of the track
78  // usually 0,0, but not always
79  wxPoint m_PadEndOffset; // offset between the pad and the ending point of the track
80  // usually 0,0, but not always
82  wxPoint m_endInitialValue; // For abort command:
83  // initial m_Start and m_End values for m_Track
84 
85 public:
86 
87  DRAG_SEGM_PICKER( TRACK* aTrack );
89 
95  void SetAuxParameters();
96 
102  void SetTrackEndsCoordinates( wxPoint aOffset );
103 
105  {
106  m_Track->SetStart( m_startInitialValue );
107  m_Track->SetEnd( m_endInitialValue );
108  }
109 };
110 
111 
113 {
114 public:
115  BOARD* m_Brd; // the main board
116  MODULE* m_Module; // The link to the module to move, or NULL
117  D_PAD* m_Pad; // The link to the pad to move, or NULL
118 
119  std::vector<DRAG_SEGM_PICKER> m_DragList; // The list of DRAG_SEGM_PICKER items
120 
121 public:
122  DRAG_LIST( BOARD* aPcb )
123  {
124  m_Brd = aPcb;
125  m_Module = NULL;
126  m_Pad = NULL;
127  }
128 
134  void ClearList();
135 
140  void BuildDragListe( MODULE* aModule );
141 
146  void BuildDragListe( D_PAD* aPad );
147 
148 private:
149 
153  void fillList( CONNECTIONS& aConnections );
154 };
155 
156 
157 // Global variables:
158 
159 // a list of DRAG_SEGM_PICKER items used to move or drag tracks.
160 // Each DRAG_SEGM_PICKER item points a segment to move.
161 extern std::vector<DRAG_SEGM_PICKER> g_DragSegmentList;
162 
163 // Functions:
164 void DrawSegmentWhileMovingFootprint( EDA_DRAW_PANEL* panel, wxDC* DC );
165 
173 void EraseDragList();
174 
188 void Collect_TrackSegmentsToDrag( BOARD* aPcb, const wxPoint& aRefPos, LSET aLayerMask,
189  int aNetCode, int aMaxDist );
190 
191 /* Add aTrack to the drag list
192  * flag = STARTPOINT (if the point to drag is the start point of Track)
193  * or ENDPOINT (if the point to drag is the end point of Track)
194  */
195 void AddSegmentToDragList( int flag, TRACK* aTrack );
196 
197 /*
198  * Undraw the track segments in list, and set the EDIT flag
199  * Usually called after the track list is built, to prepare
200  * the redraw of the list when the mouse is moved
201  */
202 void UndrawAndMarkSegmentsToDrag( EDA_DRAW_PANEL* aCanvas, wxDC* aDC );
203 
204 
205 #endif // _DRAG_H_
MODULE * m_Module
Definition: drag.h:116
wxPoint m_PadEndOffset
Definition: drag.h:79
int m_TempFlags
Definition: drag.h:68
void AddSegmentToDragList(int flag, TRACK *aTrack)
Definition: dragsegm.cpp:318
void DrawSegmentWhileMovingFootprint(EDA_DRAW_PANEL *panel, wxDC *DC)
Definition: dragsegm.cpp:294
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
void SetEnd(const wxPoint &aEnd)
Definition: class_track.h:117
wxPoint m_startInitialValue
Definition: drag.h:81
bool m_Flipped
Definition: drag.h:74
BOARD * m_Brd
Definition: drag.h:115
void EraseDragList()
Function EraseDragList clear the .m_Flags of all track segments stored in g_DragSegmentList and clear...
Definition: dragsegm.cpp:309
wxPoint m_PadStartOffset
Definition: drag.h:77
void SetTrackEndsCoordinates(wxPoint aOffset)
Calculate track ends position while dragging pads and when modules are rotated, flipped.
Definition: dragsegm.cpp:91
void SetAuxParameters()
Set auxiliary parameters relative to calculations needed to find track ends positions while dragging ...
Definition: dragsegm.cpp:65
Functions relatives to tracks, vias and segments used to fill zones.
std::vector< DRAG_SEGM_PICKER > m_DragList
Definition: drag.h:119
wxPoint m_endInitialValue
Definition: drag.h:82
void ClearList()
Function ClearList clear the .m_Flags of all track segments in m_DragList and clear the list...
Definition: dragsegm.cpp:281
DRAG_SEGM_PICKER(TRACK *aTrack)
Definition: dragsegm.cpp:52
std::vector< DRAG_SEGM_PICKER > g_DragSegmentList
Definition: dragsegm.cpp:48
Class LSET is a set of PCB_LAYER_IDs.
~DRAG_SEGM_PICKER()
Definition: drag.h:88
D_PAD * m_Pad_Start
Definition: drag.h:62
void UndrawAndMarkSegmentsToDrag(EDA_DRAW_PANEL *aCanvas, wxDC *aDC)
Definition: dragsegm.cpp:404
D_PAD * m_Pad
Definition: drag.h:117
void Collect_TrackSegmentsToDrag(BOARD *aPcb, const wxPoint &aRefPos, LSET aLayerMask, int aNetCode, int aMaxDist)
Function Collect_TrackSegmentsToDrag.
Definition: dragsegm.cpp:338
DRAG_LIST(BOARD *aPcb)
Definition: drag.h:122
D_PAD * m_Pad_End
Definition: drag.h:65
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:166
double m_RotationOffset
Definition: drag.h:71
void BuildDragListe(MODULE *aModule)
Build the list of track segments connected to pads of aModule in m_DragList For each selected track s...
Definition: dragsegm.cpp:153
TRACK * m_Track
Definition: drag.h:61
void SetStart(const wxPoint &aStart)
Definition: class_track.h:120
Helper classes to handle a list of track segments to drag and has info to undo/abort the move command...
Definition: drag.h:58
void RestoreInitialValues()
Definition: drag.h:104