2007-08-10 19:14:51 +00:00
|
|
|
/****************************************************/
|
2009-03-05 13:41:34 +00:00
|
|
|
/* Track editing */
|
2007-08-10 19:14:51 +00:00
|
|
|
/* routines to move and drag track segments or node */
|
|
|
|
/****************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "pcbnew.h"
|
2009-07-30 11:04:07 +00:00
|
|
|
#include "wxPcbStruct.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "trigo.h"
|
|
|
|
|
|
|
|
#include "drag.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "pcbnew_id.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
static void Show_MoveNode( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
|
2009-11-18 12:52:19 +00:00
|
|
|
static void Show_Drag_Track_Segment_With_Cte_Slope( WinEDA_DrawPanel* panel,
|
|
|
|
wxDC* DC,
|
|
|
|
bool erase );
|
2007-08-10 19:14:51 +00:00
|
|
|
static void Abort_MoveTrack( WinEDA_DrawPanel* Panel, wxDC* DC );
|
2007-09-01 12:00:30 +00:00
|
|
|
static bool InitialiseDragParameters();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
static wxPoint PosInit, s_LastPos;
|
2009-11-18 12:52:19 +00:00
|
|
|
static TRACK* NewTrack; /* New track or track being moved. */
|
2007-08-10 19:14:51 +00:00
|
|
|
static int NbPtNewTrack;
|
2010-01-24 13:46:01 +00:00
|
|
|
static int Old_HighLigth_NetCode;
|
|
|
|
static bool Old_HighLigt_Status;
|
2009-11-18 12:52:19 +00:00
|
|
|
static double s_StartSegmentSlope, s_EndSegmentSlope,
|
|
|
|
s_MovingSegmentSlope,
|
2007-08-10 19:14:51 +00:00
|
|
|
s_StartSegment_Yorg, s_EndSegment_Yorg,
|
|
|
|
s_MovingSegment_Yorg; //slope and intercept parameters of lines
|
2009-11-18 12:52:19 +00:00
|
|
|
bool s_StartPointVertical, s_EndPointVertical,
|
|
|
|
s_MovingSegmentVertical, s_MovingSegmentHorizontal,
|
|
|
|
s_StartPointHorizontal, s_EndPointHorizontal; // vertical or
|
|
|
|
// horizontal line
|
|
|
|
// indicators
|
|
|
|
bool s_StartSegmentPresent, s_EndSegmentPresent;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-08-08 06:07:08 +00:00
|
|
|
static PICKED_ITEMS_LIST s_ItemsListPicker;
|
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/** Abort function for commands drag, copy or move track
|
2007-08-10 19:14:51 +00:00
|
|
|
*/
|
2009-11-18 12:52:19 +00:00
|
|
|
static void Abort_MoveTrack( WinEDA_DrawPanel* Panel, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-10 19:14:51 +00:00
|
|
|
TRACK* NextS;
|
2009-11-18 12:52:19 +00:00
|
|
|
int ii;
|
2007-08-10 19:14:51 +00:00
|
|
|
|
|
|
|
/* Erase the current drawings */
|
|
|
|
wxPoint oldpos = Panel->GetScreen()->m_Curseur;
|
|
|
|
|
|
|
|
Panel->GetScreen()->m_Curseur = PosInit;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
if( Panel->ManageCurseur )
|
2009-08-08 06:07:08 +00:00
|
|
|
Panel->ManageCurseur( Panel, DC, true );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
Panel->GetScreen()->m_Curseur = oldpos;
|
2010-08-31 15:54:05 +00:00
|
|
|
g_HighLight_Status = false;
|
2009-12-21 12:05:36 +00:00
|
|
|
( (WinEDA_PcbFrame*) Panel->GetParent() )->GetBoard()->DrawHighLight(
|
2009-11-18 12:52:19 +00:00
|
|
|
Panel,
|
|
|
|
DC,
|
2010-01-24 13:46:01 +00:00
|
|
|
g_HighLight_NetCode );
|
2007-08-10 19:14:51 +00:00
|
|
|
|
|
|
|
if( NewTrack )
|
|
|
|
{
|
|
|
|
if( NewTrack->m_Flags & IS_NEW )
|
|
|
|
{
|
|
|
|
for( ii = 0; ii < NbPtNewTrack; ii++, NewTrack = NextS )
|
|
|
|
{
|
|
|
|
if( NewTrack == NULL )
|
|
|
|
break;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
|
|
|
NextS = NewTrack->Next();
|
2007-08-10 19:14:51 +00:00
|
|
|
delete NewTrack;
|
|
|
|
}
|
|
|
|
}
|
2009-11-18 12:52:19 +00:00
|
|
|
else /* Move existing trace. */
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
|
|
|
TRACK* Track = NewTrack;
|
|
|
|
int dx = s_LastPos.x - PosInit.x;
|
|
|
|
int dy = s_LastPos.y - PosInit.y;
|
2008-12-04 04:28:11 +00:00
|
|
|
for( ii = 0; ii < NbPtNewTrack; ii++, Track = Track->Next() )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
|
|
|
if( Track == NULL )
|
|
|
|
break;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
Track->m_Start.x -= dx;
|
|
|
|
Track->m_Start.y -= dy;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2009-03-05 13:41:34 +00:00
|
|
|
Track->m_End.x -= dx;
|
|
|
|
Track->m_End.y -= dy;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2009-03-05 13:41:34 +00:00
|
|
|
Track->m_Flags = 0;
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Trace_Une_Piste( Panel, DC, NewTrack, NbPtNewTrack, GR_OR );
|
|
|
|
}
|
|
|
|
|
|
|
|
NewTrack = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
Panel->ManageCurseur = NULL;
|
|
|
|
Panel->ForceCloseManageCurseur = NULL;
|
2009-12-21 12:05:36 +00:00
|
|
|
( (WinEDA_PcbFrame*) Panel->GetParent() )->SetCurItem( NULL );
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Undo move and redraw trace segments. */
|
2010-08-31 15:54:05 +00:00
|
|
|
for( unsigned jj=0 ; jj < g_DragSegmentList.size(); jj++ )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2010-08-31 15:54:05 +00:00
|
|
|
TRACK* Track = g_DragSegmentList[jj].m_Segm;
|
|
|
|
g_DragSegmentList[jj].SetInitialValues();
|
2007-08-10 19:14:51 +00:00
|
|
|
Track->SetState( EDIT, OFF );
|
|
|
|
Track->m_Flags = 0;
|
|
|
|
Track->Draw( Panel, DC, GR_OR );
|
|
|
|
}
|
|
|
|
|
2009-08-08 06:07:08 +00:00
|
|
|
// Clear the undo picker list:
|
|
|
|
s_ItemsListPicker.ClearListAndDeleteItems();
|
|
|
|
|
2010-01-24 13:46:01 +00:00
|
|
|
g_HighLight_NetCode = Old_HighLigth_NetCode;
|
|
|
|
g_HighLight_Status = Old_HighLigt_Status;
|
|
|
|
if( g_HighLight_Status )
|
2009-12-21 12:05:36 +00:00
|
|
|
( (WinEDA_PcbFrame*) Panel->GetParent() )->GetBoard()->DrawHighLight(
|
2010-08-31 15:54:05 +00:00
|
|
|
Panel, DC, g_HighLight_NetCode );
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2010-08-31 15:54:05 +00:00
|
|
|
EraseDragList();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Redraw the moved node according to the mouse cursor position */
|
2009-11-18 12:52:19 +00:00
|
|
|
static void Show_MoveNode( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-08-08 06:07:08 +00:00
|
|
|
int ii;
|
2009-11-18 12:52:19 +00:00
|
|
|
wxPoint moveVector;
|
2007-08-10 19:14:51 +00:00
|
|
|
TRACK* Track;
|
|
|
|
BASE_SCREEN* screen = panel->GetScreen();
|
|
|
|
int track_fill_copy = DisplayOpt.DisplayPcbTrackFill;
|
|
|
|
int draw_mode = GR_XOR | GR_SURBRILL;
|
|
|
|
|
2010-08-31 15:54:05 +00:00
|
|
|
DisplayOpt.DisplayPcbTrackFill = false;
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2009-08-08 06:07:08 +00:00
|
|
|
erase = true;
|
2007-08-10 19:14:51 +00:00
|
|
|
|
|
|
|
/* erase the current moved track segments from screen */
|
|
|
|
if( erase )
|
|
|
|
{
|
|
|
|
if( NewTrack )
|
|
|
|
Trace_Une_Piste( panel, DC, NewTrack, NbPtNewTrack, draw_mode );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set the new track coordinates */
|
|
|
|
wxPoint Pos = screen->m_Curseur;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2009-08-08 06:07:08 +00:00
|
|
|
moveVector = Pos - s_LastPos;
|
2009-11-18 12:52:19 +00:00
|
|
|
s_LastPos = Pos;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2009-03-05 13:41:34 +00:00
|
|
|
ii = NbPtNewTrack;
|
2008-12-04 04:28:11 +00:00
|
|
|
Track = NewTrack;
|
2007-08-10 19:14:51 +00:00
|
|
|
for( ; (ii > 0) && (Track != NULL); ii--, Track = Track->Next() )
|
|
|
|
{
|
|
|
|
if( Track->m_Flags & STARTPOINT )
|
2009-08-08 06:07:08 +00:00
|
|
|
Track->m_Start += moveVector;
|
2007-08-10 19:14:51 +00:00
|
|
|
if( Track->m_Flags & ENDPOINT )
|
2009-08-08 06:07:08 +00:00
|
|
|
Track->m_End += moveVector;
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Redraw the current moved track segments */
|
2009-12-27 14:01:21 +00:00
|
|
|
Trace_Une_Piste( panel, DC, NewTrack, NbPtNewTrack, draw_mode );
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2010-08-31 15:54:05 +00:00
|
|
|
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2010-08-31 15:54:05 +00:00
|
|
|
Track = g_DragSegmentList[ii].m_Segm;
|
2007-08-10 19:14:51 +00:00
|
|
|
if( erase )
|
|
|
|
Track->Draw( panel, DC, draw_mode );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
if( Track->m_Flags & STARTPOINT )
|
2009-08-08 06:07:08 +00:00
|
|
|
Track->m_Start += moveVector;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
if( Track->m_Flags & ENDPOINT )
|
2009-08-08 06:07:08 +00:00
|
|
|
Track->m_End += moveVector;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
Track->Draw( panel, DC, draw_mode );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
DisplayOpt.DisplayPcbTrackFill = track_fill_copy;
|
2009-11-18 12:52:19 +00:00
|
|
|
|
2009-10-14 18:14:58 +00:00
|
|
|
// Display track length
|
2009-12-21 12:05:36 +00:00
|
|
|
WinEDA_BasePcbFrame* frame = (WinEDA_BasePcbFrame*) panel->GetParent();
|
2009-10-14 18:14:58 +00:00
|
|
|
Track->DisplayInfo( frame );
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* drawing the track segment movement
|
2007-08-10 19:14:51 +00:00
|
|
|
* > s_MovingSegmentSlope slope = moving track segment slope
|
2009-11-18 12:52:19 +00:00
|
|
|
* > s_StartSegmentSlope slope = slope of the segment connected to the start
|
|
|
|
* point of the moving segment
|
|
|
|
* > s_EndSegmentSlope slope = slope of the segment connected to the end point
|
|
|
|
* of the moving segment
|
2007-08-20 01:20:48 +00:00
|
|
|
*
|
2007-08-10 19:14:51 +00:00
|
|
|
* moved segment function :
|
|
|
|
* yt=s_MovingSegmentSlope * x + s_MovingSegment_Yorg
|
2007-08-20 01:20:48 +00:00
|
|
|
*
|
2007-08-10 19:14:51 +00:00
|
|
|
* segment connected to moved segment's start:
|
|
|
|
* y1 = s_StartSegmentSlope * x + s_StartSegment_Yorg
|
2007-08-20 01:20:48 +00:00
|
|
|
*
|
2007-08-10 19:14:51 +00:00
|
|
|
* segment connected to moved segment's end:
|
|
|
|
* y2=s_EndSegmentSlope * x + s_EndSegment_Yorg
|
2007-08-20 01:20:48 +00:00
|
|
|
*
|
2007-08-10 19:14:51 +00:00
|
|
|
* first intersection point will be located at
|
|
|
|
* y1=yt ->
|
2009-11-18 12:52:19 +00:00
|
|
|
*
|
|
|
|
* xi1=(s_MovingSegment_Yorg-s_StartSegment_Yorg)/(s_StartSegmentSlope-s_MovingSegmentSlope)
|
2007-08-10 19:14:51 +00:00
|
|
|
* yi1=s_MovingSegmentSlope*xi1+s_MovingSegment_Yorg
|
|
|
|
* or yi1=s_StartSegmentSlope*xi1+s_MovingSegment_Yorg
|
2007-08-20 01:20:48 +00:00
|
|
|
*
|
2007-08-10 19:14:51 +00:00
|
|
|
* second intersection point
|
|
|
|
* y2=yt ->
|
2009-11-18 12:52:19 +00:00
|
|
|
*
|
|
|
|
* xi2=(s_MovingSegment_Yorg-s_StartSegment_Yorg)/(s_MovingSegmentSlope-s_MovingSegmentSlope)
|
2007-08-10 19:14:51 +00:00
|
|
|
* yi2=s_MovingSegmentSlope*xi2+s_MovingSegment_Yorg
|
|
|
|
* or yi1=s_EndSegmentSlope*xi2+s_MovingSegment_Yorg
|
|
|
|
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
* !!!!! special attention to vertical segments because
|
|
|
|
* !!!!! their slope=infinite
|
|
|
|
* !!!!! intersection point will be calculated using the
|
|
|
|
* !!!!! segment intersecting it
|
|
|
|
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
2007-08-20 01:20:48 +00:00
|
|
|
*
|
2009-11-18 12:52:19 +00:00
|
|
|
* Slope parameters are computed once, because they can become undetermined
|
|
|
|
* when moving segments
|
|
|
|
* (i.e. when a segment length is 0) and we want keep them constant
|
2007-08-10 19:14:51 +00:00
|
|
|
*/
|
2009-11-18 12:52:19 +00:00
|
|
|
static void Show_Drag_Track_Segment_With_Cte_Slope( WinEDA_DrawPanel* panel,
|
|
|
|
wxDC* DC, bool erase )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
double xi1 = 0, yi1 = 0, xi2 = 0, yi2 = 0; // calculated
|
|
|
|
// intersection points
|
|
|
|
double tx1, tx2, ty1, ty2; // temporary storage of
|
|
|
|
// points
|
2007-08-10 19:14:51 +00:00
|
|
|
int dx, dy;
|
|
|
|
BASE_SCREEN* screen = panel->GetScreen();
|
|
|
|
bool update = true;
|
|
|
|
TRACK* Track;
|
|
|
|
TRACK* tSegmentToStart = NULL, * tSegmentToEnd = NULL;
|
|
|
|
|
2010-08-31 15:54:05 +00:00
|
|
|
if( g_DragSegmentList.size() == 0 )
|
2007-08-10 19:14:51 +00:00
|
|
|
return;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2010-08-31 15:54:05 +00:00
|
|
|
/* get the segments :
|
|
|
|
* from last to first in list are:
|
|
|
|
* the segment to move
|
|
|
|
* the segment connected to its end point (if exists)
|
|
|
|
* the segment connected to its start point (if exists)
|
|
|
|
*/
|
|
|
|
int ii = g_DragSegmentList.size() - 1;
|
|
|
|
Track = g_DragSegmentList[ii].m_Segm;
|
2007-12-14 22:31:45 +00:00
|
|
|
if( Track == NULL )
|
2007-08-10 19:14:51 +00:00
|
|
|
return;
|
2010-08-31 15:54:05 +00:00
|
|
|
ii--;
|
|
|
|
if( ii >= 0)
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2010-08-31 15:54:05 +00:00
|
|
|
if( s_EndSegmentPresent )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2010-08-31 15:54:05 +00:00
|
|
|
// Get the segment connected to the end point
|
|
|
|
tSegmentToEnd = g_DragSegmentList[ii].m_Segm;
|
|
|
|
ii--;
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
if( s_StartSegmentPresent )
|
|
|
|
{
|
2010-08-31 15:54:05 +00:00
|
|
|
// Get the segment connected to the start point
|
|
|
|
if( ii >= 0 )
|
|
|
|
tSegmentToStart = g_DragSegmentList[ii].m_Segm;
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int draw_mode = GR_XOR | GR_SURBRILL;
|
|
|
|
/* Undraw the current moved track segments before modification*/
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// if( erase )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
|
|
|
Track->Draw( panel, DC, draw_mode );
|
|
|
|
if( tSegmentToStart )
|
|
|
|
tSegmentToStart->Draw( panel, DC, draw_mode );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
if( tSegmentToEnd )
|
|
|
|
tSegmentToEnd->Draw( panel, DC, draw_mode );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compute the new track segment position */
|
|
|
|
wxPoint Pos = screen->m_Curseur;
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
dx = Pos.x - s_LastPos.x;
|
|
|
|
dy = Pos.y - s_LastPos.y;
|
2007-08-10 19:14:51 +00:00
|
|
|
|
|
|
|
//move the line by dx and dy
|
2009-03-05 13:41:34 +00:00
|
|
|
tx1 = (double) ( Track->m_Start.x + dx );
|
|
|
|
ty1 = (double) ( Track->m_Start.y + dy );
|
|
|
|
tx2 = (double) ( Track->m_End.x + dx );
|
|
|
|
ty2 = (double) ( Track->m_End.y + dy );
|
2007-08-10 19:14:51 +00:00
|
|
|
|
|
|
|
// recalculate the segments new parameters and intersection points
|
|
|
|
// only the intercept will change, segment slopes does not change
|
|
|
|
// because we are moving parallel with is initial state
|
|
|
|
if( !s_MovingSegmentVertical )
|
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
s_MovingSegment_Yorg = ty1 - ( s_MovingSegmentSlope * tx1 );
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
if( ( !s_EndPointVertical ) && ( !s_MovingSegmentVertical ) )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
xi2 = ( s_MovingSegment_Yorg - s_EndSegment_Yorg )
|
|
|
|
/ ( s_EndSegmentSlope - s_MovingSegmentSlope );
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( !s_EndPointVertical )
|
|
|
|
{
|
|
|
|
xi2 = tx2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//P1=P2
|
|
|
|
if( !s_EndPointHorizontal )
|
|
|
|
{
|
|
|
|
xi2 = tx2 - dx;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
update = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !s_MovingSegmentVertical )
|
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
yi2 = s_MovingSegmentSlope * ( xi2 ) + s_MovingSegment_Yorg;
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( !s_EndPointVertical )
|
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
yi2 = s_EndSegmentSlope * ( xi2 ) + s_EndSegment_Yorg;
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( !s_EndPointHorizontal )
|
|
|
|
{
|
|
|
|
update = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
yi2 = s_MovingSegmentSlope * ( xi2 ) + s_MovingSegment_Yorg;
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
if( ( !s_StartPointVertical ) && ( !s_MovingSegmentVertical ) )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
xi1 = ( s_MovingSegment_Yorg - s_StartSegment_Yorg )
|
|
|
|
/ ( s_StartSegmentSlope - s_MovingSegmentSlope );
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( !s_StartPointVertical )
|
|
|
|
{
|
|
|
|
xi1 = tx1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//P1=P2
|
|
|
|
if( !s_StartPointHorizontal )
|
|
|
|
{
|
|
|
|
xi1 = tx1 - dx;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( !s_StartPointHorizontal )
|
|
|
|
{
|
|
|
|
update = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !s_MovingSegmentVertical )
|
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
yi1 = s_MovingSegmentSlope * ( xi1 ) + s_MovingSegment_Yorg;
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( !s_StartPointVertical )
|
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
yi1 = s_StartSegmentSlope * ( xi1 ) + s_StartSegment_Yorg;
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( !s_StartPointHorizontal )
|
|
|
|
{
|
|
|
|
update = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
yi2 = s_MovingSegmentSlope * ( xi1 ) + s_MovingSegment_Yorg;
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// update the segment coordinates (if possible)
|
|
|
|
if( tSegmentToStart == NULL )
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
xi1 = tx1;
|
2007-12-14 22:31:45 +00:00
|
|
|
yi1 = ty1;
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
if( tSegmentToEnd == NULL )
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
xi2 = tx2;
|
2007-12-14 22:31:45 +00:00
|
|
|
yi2 = ty2;
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if( update )
|
|
|
|
{
|
|
|
|
s_LastPos = Pos;
|
2009-04-05 20:49:15 +00:00
|
|
|
Track->m_Start.x = wxRound( xi1 );
|
|
|
|
Track->m_Start.y = wxRound( yi1 );
|
|
|
|
Track->m_End.x = wxRound( xi2 );
|
|
|
|
Track->m_End.y = wxRound( yi2 );
|
2007-08-10 19:14:51 +00:00
|
|
|
if( tSegmentToEnd )
|
|
|
|
{
|
|
|
|
if( tSegmentToEnd->m_Flags & STARTPOINT )
|
|
|
|
tSegmentToEnd->m_Start = Track->m_End;
|
|
|
|
else
|
|
|
|
tSegmentToEnd->m_End = Track->m_End;
|
|
|
|
}
|
|
|
|
if( tSegmentToStart )
|
|
|
|
{
|
|
|
|
if( tSegmentToStart->m_Flags & STARTPOINT )
|
|
|
|
tSegmentToStart->m_Start = Track->m_Start;
|
|
|
|
else
|
|
|
|
tSegmentToStart->m_End = Track->m_Start;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Track->Draw( panel, DC, draw_mode );
|
|
|
|
if( tSegmentToStart )
|
|
|
|
tSegmentToStart->Draw( panel, DC, draw_mode );
|
|
|
|
if( tSegmentToEnd )
|
|
|
|
tSegmentToEnd->Draw( panel, DC, draw_mode );
|
2009-11-18 12:52:19 +00:00
|
|
|
|
2009-10-14 18:14:58 +00:00
|
|
|
// Display track length
|
2009-12-21 12:05:36 +00:00
|
|
|
WinEDA_BasePcbFrame* frame = (WinEDA_BasePcbFrame*) panel->GetParent();
|
2009-10-14 18:14:58 +00:00
|
|
|
Track->DisplayInfo( frame );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Init variables (slope, Y intersect point, flags) for
|
|
|
|
* Show_Drag_Track_Segment_With_Cte_Slope()
|
2010-08-31 15:54:05 +00:00
|
|
|
* return true if Ok, false if dragging is not possible
|
2007-08-10 19:14:51 +00:00
|
|
|
* (2 colinear segments)
|
|
|
|
*/
|
2009-11-18 12:52:19 +00:00
|
|
|
bool InitialiseDragParameters()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-10 19:14:51 +00:00
|
|
|
double tx1, tx2, ty1, ty2; // temporary storage of points
|
|
|
|
TRACK* Track;
|
|
|
|
TRACK* tSegmentToStart = NULL, * tSegmentToEnd = NULL;
|
|
|
|
|
2010-08-31 15:54:05 +00:00
|
|
|
if( g_DragSegmentList.size() == 0 )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* get the segments :
|
|
|
|
* from last to first in list are:
|
|
|
|
* the segment to move
|
|
|
|
* the segment connected to its end point (if exists)
|
|
|
|
* the segment connected to its start point (if exists)
|
|
|
|
*/
|
|
|
|
int ii = g_DragSegmentList.size() - 1;
|
|
|
|
Track = g_DragSegmentList[ii].m_Segm;
|
2007-08-10 19:14:51 +00:00
|
|
|
if( Track == NULL )
|
2010-08-31 15:54:05 +00:00
|
|
|
return false;
|
|
|
|
ii--;
|
|
|
|
if( ii >= 0)
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
|
|
|
if( s_EndSegmentPresent )
|
|
|
|
{
|
2010-08-31 15:54:05 +00:00
|
|
|
tSegmentToEnd = g_DragSegmentList[ii].m_Segm; // Get the segment
|
2009-11-18 12:52:19 +00:00
|
|
|
// connected to the end
|
|
|
|
// point
|
2010-08-31 15:54:05 +00:00
|
|
|
ii--;
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
if( s_StartSegmentPresent )
|
|
|
|
{
|
2010-08-31 15:54:05 +00:00
|
|
|
if( ii >= 0 )
|
|
|
|
tSegmentToStart = g_DragSegmentList[ii].m_Segm; // Get the segment
|
2009-11-18 12:52:19 +00:00
|
|
|
// connected to the
|
|
|
|
// start point
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
}
|
2009-03-05 13:41:34 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
//would be nice to eliminate collinear segments here, so we don't
|
2009-11-18 12:52:19 +00:00
|
|
|
//have to deal with that annoying "Unable to drag this segment: two
|
|
|
|
// collinear segments"
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2009-03-05 13:41:34 +00:00
|
|
|
s_StartPointVertical = false;
|
2009-11-18 12:52:19 +00:00
|
|
|
s_EndPointVertical = false;
|
2007-08-10 19:14:51 +00:00
|
|
|
s_MovingSegmentVertical = false;
|
|
|
|
s_StartPointHorizontal = false;
|
|
|
|
s_EndPointHorizontal = false;
|
|
|
|
s_MovingSegmentHorizontal = false;
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// Init parameters for the starting point of the moved segment
|
2007-08-10 19:14:51 +00:00
|
|
|
if( tSegmentToStart )
|
|
|
|
{
|
|
|
|
if( tSegmentToStart->m_Flags & ENDPOINT )
|
|
|
|
{
|
|
|
|
tx1 = (double) tSegmentToStart->m_Start.x;
|
|
|
|
ty1 = (double) tSegmentToStart->m_Start.y;
|
|
|
|
tx2 = (double) tSegmentToStart->m_End.x;
|
|
|
|
ty2 = (double) tSegmentToStart->m_End.y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tx1 = (double) tSegmentToStart->m_End.x;
|
|
|
|
ty1 = (double) tSegmentToStart->m_End.y;
|
|
|
|
tx2 = (double) tSegmentToStart->m_Start.x;
|
|
|
|
ty2 = (double) tSegmentToStart->m_Start.y;
|
|
|
|
}
|
|
|
|
}
|
2009-11-18 12:52:19 +00:00
|
|
|
else // move the start point on a line starting at Track->m_Start, and
|
|
|
|
// perpendicular to Track
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
|
|
|
tx1 = (double) Track->m_Start.x;
|
|
|
|
ty1 = (double) Track->m_Start.y;
|
|
|
|
tx2 = (double) Track->m_End.x;
|
|
|
|
ty2 = (double) Track->m_End.y;
|
|
|
|
RotatePoint( &tx2, &ty2, tx1, ty1, 900 );
|
|
|
|
}
|
2009-11-18 12:52:19 +00:00
|
|
|
if( tx1 != tx2 )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
s_StartSegmentSlope = ( ty2 - ty1 ) / ( tx2 - tx1 );
|
|
|
|
s_StartSegment_Yorg = ty1 - ( ty2 - ty1 ) * tx1 / ( tx2 - tx1 );
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
s_StartPointVertical = true; //signal first segment vertical
|
|
|
|
}
|
2009-11-18 12:52:19 +00:00
|
|
|
if( ty1 == ty2 )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
|
|
|
s_StartPointHorizontal = true;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Init parameters for the ending point of the moved segment
|
2007-08-10 19:14:51 +00:00
|
|
|
if( tSegmentToEnd )
|
|
|
|
{
|
|
|
|
//check if second line is vertical
|
|
|
|
if( tSegmentToEnd->m_Flags & STARTPOINT )
|
|
|
|
{
|
|
|
|
tx1 = (double) tSegmentToEnd->m_Start.x;
|
|
|
|
ty1 = (double) tSegmentToEnd->m_Start.y;
|
|
|
|
tx2 = (double) tSegmentToEnd->m_End.x;
|
|
|
|
ty2 = (double) tSegmentToEnd->m_End.y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tx1 = (double) tSegmentToEnd->m_End.x;
|
|
|
|
ty1 = (double) tSegmentToEnd->m_End.y;
|
|
|
|
tx2 = (double) tSegmentToEnd->m_Start.x;
|
|
|
|
ty2 = (double) tSegmentToEnd->m_Start.y;
|
|
|
|
}
|
|
|
|
}
|
2009-11-18 12:52:19 +00:00
|
|
|
else // move the start point on a line starting at Track->m_End, and
|
|
|
|
// perpendicular to Track
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
|
|
|
tx1 = (double) Track->m_End.x;
|
|
|
|
ty1 = (double) Track->m_End.y;
|
|
|
|
tx2 = (double) Track->m_Start.x;
|
|
|
|
ty2 = (double) Track->m_Start.y;
|
|
|
|
RotatePoint( &tx2, &ty2, tx1, ty1, -900 );
|
|
|
|
}
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
if( tx2 != tx1 )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
s_EndSegmentSlope = ( ty2 - ty1 ) / ( tx2 - tx1 );
|
|
|
|
s_EndSegment_Yorg = ty1 - ( ty2 - ty1 ) * tx1 / ( tx2 - tx1 );
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
s_EndPointVertical = true; //signal second segment vertical
|
|
|
|
}
|
2009-11-18 12:52:19 +00:00
|
|
|
if( ty1 == ty2 )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
|
|
|
s_EndPointHorizontal = true;
|
|
|
|
}
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// Init parameters for the moved segment
|
2007-08-10 19:14:51 +00:00
|
|
|
tx1 = (double) Track->m_Start.x;
|
|
|
|
ty1 = (double) Track->m_Start.y;
|
|
|
|
tx2 = (double) Track->m_End.x;
|
|
|
|
ty2 = (double) Track->m_End.y;
|
2009-11-18 12:52:19 +00:00
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
if( tx2 != tx1 )
|
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
s_MovingSegmentSlope = ( ty2 - ty1 ) / ( tx2 - tx1 );
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
s_MovingSegmentVertical = true; //signal vertical line
|
|
|
|
}
|
2009-11-18 12:52:19 +00:00
|
|
|
if( ty1 == ty2 )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
|
|
|
s_MovingSegmentHorizontal = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test if drag is possible:
|
|
|
|
if( s_MovingSegmentVertical )
|
|
|
|
{
|
|
|
|
if( s_EndPointVertical || s_StartPointVertical )
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
if( !s_EndPointVertical
|
|
|
|
&& ( s_MovingSegmentSlope == s_EndSegmentSlope ) )
|
2007-08-10 19:14:51 +00:00
|
|
|
return false;
|
2009-11-18 12:52:19 +00:00
|
|
|
if( !s_StartPointVertical
|
|
|
|
&& ( s_MovingSegmentSlope == s_StartSegmentSlope ) )
|
2007-08-10 19:14:51 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-08-08 06:07:08 +00:00
|
|
|
return true;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Init parameters to move one node:
|
2007-08-10 19:14:51 +00:00
|
|
|
* a via or/and a terminal point of a track segment
|
|
|
|
* The terminal point of other connected segments (if any) are moved too.
|
|
|
|
*/
|
2009-11-18 12:52:19 +00:00
|
|
|
void WinEDA_PcbFrame::Start_MoveOneNodeOrSegment( TRACK* track,
|
|
|
|
wxDC* DC,
|
|
|
|
int command )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-10 19:14:51 +00:00
|
|
|
if( !track )
|
|
|
|
return;
|
|
|
|
|
|
|
|
NewTrack = NULL;
|
|
|
|
NbPtNewTrack = 0;
|
2010-08-31 15:54:05 +00:00
|
|
|
EraseDragList();
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Change highlighted net: the new one will be highlighted */
|
2010-01-24 13:46:01 +00:00
|
|
|
Old_HighLigt_Status = g_HighLight_Status;
|
|
|
|
Old_HighLigth_NetCode = g_HighLight_NetCode;
|
|
|
|
if( g_HighLight_Status )
|
|
|
|
High_Light( DC );
|
2007-08-10 19:14:51 +00:00
|
|
|
PosInit = GetScreen()->m_Curseur;
|
|
|
|
|
2010-08-31 15:54:05 +00:00
|
|
|
if( track->Type() == TYPE_VIA ) // For a via: always drag it
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
|
|
|
track->m_Flags = IS_DRAGGED | STARTPOINT | ENDPOINT;
|
|
|
|
if( command != ID_POPUP_PCB_MOVE_TRACK_SEGMENT )
|
|
|
|
{
|
|
|
|
Collect_TrackSegmentsToDrag( DrawPanel, DC, track->m_Start,
|
2009-11-18 12:52:19 +00:00
|
|
|
track->ReturnMaskLayer(),
|
|
|
|
track->GetNet() );
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
NewTrack = track;
|
|
|
|
NbPtNewTrack = 1;
|
|
|
|
PosInit = track->m_Start;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int diag = track->IsPointOnEnds( GetScreen()->m_Curseur, -1 );
|
|
|
|
wxPoint pos;
|
|
|
|
|
|
|
|
switch( command )
|
|
|
|
{
|
2010-08-31 15:54:05 +00:00
|
|
|
case ID_POPUP_PCB_MOVE_TRACK_SEGMENT: // Move segment
|
2007-08-10 19:14:51 +00:00
|
|
|
track->m_Flags |= IS_DRAGGED | ENDPOINT | STARTPOINT;
|
|
|
|
AddSegmentToDragList( DrawPanel, DC, track->m_Flags, track );
|
|
|
|
break;
|
|
|
|
|
2010-08-31 15:54:05 +00:00
|
|
|
case ID_POPUP_PCB_DRAG_TRACK_SEGMENT: // drag a segment
|
2007-08-10 19:14:51 +00:00
|
|
|
pos = track->m_Start;
|
|
|
|
Collect_TrackSegmentsToDrag( DrawPanel, DC, pos,
|
2009-11-18 12:52:19 +00:00
|
|
|
track->ReturnMaskLayer(),
|
|
|
|
track->GetNet() );
|
2007-08-10 19:14:51 +00:00
|
|
|
pos = track->m_End;
|
|
|
|
track->m_Flags |= IS_DRAGGED | ENDPOINT | STARTPOINT;
|
|
|
|
Collect_TrackSegmentsToDrag( DrawPanel, DC, pos,
|
2009-11-18 12:52:19 +00:00
|
|
|
track->ReturnMaskLayer(),
|
|
|
|
track->GetNet() );
|
2007-08-10 19:14:51 +00:00
|
|
|
break;
|
|
|
|
|
2010-08-31 15:54:05 +00:00
|
|
|
case ID_POPUP_PCB_MOVE_TRACK_NODE: // Drag via or move node
|
2007-08-10 19:14:51 +00:00
|
|
|
pos = (diag & STARTPOINT) ? track->m_Start : track->m_End;
|
|
|
|
Collect_TrackSegmentsToDrag( DrawPanel, DC, pos,
|
2009-11-18 12:52:19 +00:00
|
|
|
track->ReturnMaskLayer(),
|
|
|
|
track->GetNet() );
|
2007-08-10 19:14:51 +00:00
|
|
|
PosInit = pos;
|
|
|
|
break;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
track->m_Flags |= IS_DRAGGED;
|
|
|
|
}
|
2009-11-18 12:52:19 +00:00
|
|
|
|
2009-08-08 06:07:08 +00:00
|
|
|
// Prepare the Undo command
|
|
|
|
ITEM_PICKER picker( track, UR_CHANGED );
|
|
|
|
picker.m_Link = track->Copy();
|
|
|
|
s_ItemsListPicker.PushItem( picker );
|
2010-08-31 15:54:05 +00:00
|
|
|
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
|
2009-08-08 06:07:08 +00:00
|
|
|
{
|
2010-08-31 15:54:05 +00:00
|
|
|
TRACK* draggedtrack = g_DragSegmentList[ii].m_Segm;
|
2009-08-08 06:07:08 +00:00
|
|
|
picker.m_PickedItem = draggedtrack;
|
|
|
|
picker.m_Link = draggedtrack->Copy();
|
|
|
|
s_ItemsListPicker.PushItem( picker );
|
2009-11-18 12:52:19 +00:00
|
|
|
draggedtrack = (TRACK*) picker.m_Link;
|
2009-08-08 06:07:08 +00:00
|
|
|
draggedtrack->SetStatus( 0 );
|
|
|
|
draggedtrack->m_Flags = 0;
|
|
|
|
}
|
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
s_LastPos = PosInit;
|
|
|
|
DrawPanel->ManageCurseur = Show_MoveNode;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = Abort_MoveTrack;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-01-24 13:46:01 +00:00
|
|
|
g_HighLight_NetCode = track->GetNet();
|
|
|
|
g_HighLight_Status = true;
|
2009-02-25 16:35:47 +00:00
|
|
|
|
2010-01-24 13:46:01 +00:00
|
|
|
GetBoard()->DrawHighLight( DrawPanel, DC, g_HighLight_NetCode );
|
2009-08-08 06:07:08 +00:00
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, true );
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
2009-03-05 13:41:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
2009-11-18 12:52:19 +00:00
|
|
|
|
|
|
|
// @todo: This function is broken: does not handle pointers to pads for start
|
|
|
|
// and end and flags relative to these pointers
|
2009-03-05 13:41:34 +00:00
|
|
|
void SortTrackEndPoints( TRACK* track )
|
2008-03-04 05:40:15 +00:00
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
//sort the track endpoints -- should not matter in terms of drawing
|
|
|
|
//or producing the pcb -- but makes doing comparisons easier.
|
2009-11-18 12:52:19 +00:00
|
|
|
int dx = track->m_End.x - track->m_Start.x;
|
2009-03-05 13:41:34 +00:00
|
|
|
|
|
|
|
if( dx )
|
|
|
|
{
|
|
|
|
if( track->m_Start.x > track->m_End.x )
|
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
EXCHG( track->m_Start, track->m_End );
|
2008-11-24 06:53:43 +00:00
|
|
|
}
|
2009-03-05 13:41:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( track->m_Start.y > track->m_End.y )
|
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
EXCHG( track->m_Start, track->m_End );
|
2008-11-24 06:53:43 +00:00
|
|
|
}
|
|
|
|
}
|
2008-03-04 05:40:15 +00:00
|
|
|
}
|
2009-03-05 13:41:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2009-11-18 12:52:19 +00:00
|
|
|
* @todo: this function is broken, because it merge segments having different
|
|
|
|
* width or without any connectivity test.
|
|
|
|
* 2 collinear segments can be merged only in no other segment or via is
|
|
|
|
* connected to the common point
|
2009-03-05 13:41:34 +00:00
|
|
|
* and if they have the same width. See cleanup.cpp for merge functions,
|
|
|
|
* and consider Marque_Une_Piste() to locate segments that can be merged
|
|
|
|
*/
|
2009-11-18 12:52:19 +00:00
|
|
|
bool WinEDA_PcbFrame::MergeCollinearTracks( TRACK* track, wxDC* DC, int end )
|
|
|
|
{
|
|
|
|
testtrack = (TRACK*) Locate_Piste_Connectee( track,
|
|
|
|
GetBoard()->m_Track, NULL,
|
|
|
|
end );
|
2008-11-24 06:53:43 +00:00
|
|
|
if( testtrack )
|
|
|
|
{
|
2009-03-05 13:41:34 +00:00
|
|
|
SortTrackEndPoints( track );
|
|
|
|
SortTrackEndPoints( testtrack );
|
|
|
|
int dx = track->m_End.x - track->m_Start.x;
|
|
|
|
int dy = track->m_End.y - track->m_Start.y;
|
2008-11-24 06:53:43 +00:00
|
|
|
int tdx = testtrack->m_End.x - testtrack->m_Start.x;
|
|
|
|
int tdy = testtrack->m_End.y - testtrack->m_Start.y;
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
if( ( dy * tdx == dx * tdy && dy != 0 && dx != 0 && tdy != 0 && tdx !=
|
|
|
|
0 ) /* angle, same slope */
|
|
|
|
|| ( dy == 0 && tdy == 0 && dx * tdx ) /*horizontal */
|
|
|
|
|| ( dx == 0 && tdx == 0 && dy * tdy ) /*vertical */
|
|
|
|
)
|
2009-03-05 13:41:34 +00:00
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
if( track->m_Start == testtrack->m_Start || track->m_End ==
|
|
|
|
testtrack->m_Start )
|
2009-03-05 13:41:34 +00:00
|
|
|
{
|
|
|
|
if( ( dx * tdx && testtrack->m_End.x > track->m_End.x )
|
|
|
|
||( dy * tdy && testtrack->m_End.y > track->m_End.y ) )
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
track->m_End = testtrack->m_End;
|
|
|
|
|
|
|
|
Delete_Segment( DC, testtrack );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2009-11-18 12:52:19 +00:00
|
|
|
if( track->m_Start == testtrack->m_End || track->m_End ==
|
|
|
|
testtrack->m_End )
|
2009-03-05 13:41:34 +00:00
|
|
|
{
|
|
|
|
if( ( dx * tdx && testtrack->m_Start.x < track->m_Start.x )
|
|
|
|
||( dy * tdy && testtrack->m_Start.y < track->m_Start.y ) )
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
track->m_Start = testtrack->m_Start;
|
|
|
|
|
|
|
|
Delete_Segment( DC, testtrack );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-11-18 12:52:19 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
return false;
|
2008-03-04 05:40:15 +00:00
|
|
|
}
|
2009-11-18 12:52:19 +00:00
|
|
|
|
|
|
|
|
2009-03-05 13:41:34 +00:00
|
|
|
#endif
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
|
|
|
|
void WinEDA_PcbFrame::Start_DragTrackSegmentAndKeepSlope( TRACK* track,
|
|
|
|
wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-10 19:14:51 +00:00
|
|
|
TRACK* TrackToStartPoint = NULL;
|
|
|
|
TRACK* TrackToEndPoint = NULL;
|
2010-08-31 15:54:05 +00:00
|
|
|
bool error = false;
|
2007-08-10 19:14:51 +00:00
|
|
|
|
|
|
|
if( !track )
|
|
|
|
return;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2009-03-05 13:41:34 +00:00
|
|
|
|
|
|
|
#if 0
|
2009-11-18 12:52:19 +00:00
|
|
|
|
2009-03-05 13:41:34 +00:00
|
|
|
// Broken functions: see comments
|
|
|
|
while( MergeCollinearTracks( track, DC, START ) )
|
|
|
|
{
|
2010-08-31 15:54:05 +00:00
|
|
|
};
|
2009-03-05 13:41:34 +00:00
|
|
|
while( MergeCollinearTracks( track, DC, END ) )
|
|
|
|
{
|
2010-08-31 15:54:05 +00:00
|
|
|
};
|
2009-03-05 13:41:34 +00:00
|
|
|
#endif
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2009-08-08 06:07:08 +00:00
|
|
|
s_StartSegmentPresent = s_EndSegmentPresent = true;
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
if( ( track->start == NULL ) || ( track->start->Type() == TYPE_TRACK ) )
|
2009-08-08 06:07:08 +00:00
|
|
|
TrackToStartPoint = Locate_Piste_Connectee( track,
|
2009-11-18 12:52:19 +00:00
|
|
|
GetBoard()->m_Track, NULL,
|
|
|
|
START );
|
2007-08-10 19:14:51 +00:00
|
|
|
|
|
|
|
// Test if more than one segment is connected to this point
|
|
|
|
if( TrackToStartPoint )
|
|
|
|
{
|
|
|
|
TrackToStartPoint->SetState( BUSY, ON );
|
2009-11-18 12:52:19 +00:00
|
|
|
if( ( TrackToStartPoint->Type() == TYPE_VIA )
|
|
|
|
|| Locate_Piste_Connectee( track, GetBoard()->m_Track, NULL, START ) )
|
2009-08-08 06:07:08 +00:00
|
|
|
error = true;
|
2007-08-10 19:14:51 +00:00
|
|
|
TrackToStartPoint->SetState( BUSY, OFF );
|
|
|
|
}
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
if( ( track->end == NULL ) || ( track->end->Type() == TYPE_TRACK ) )
|
|
|
|
TrackToEndPoint = Locate_Piste_Connectee( track,
|
|
|
|
GetBoard()->m_Track, NULL,
|
|
|
|
END );
|
2007-08-10 19:14:51 +00:00
|
|
|
|
|
|
|
// Test if more than one segment is connected to this point
|
|
|
|
if( TrackToEndPoint )
|
|
|
|
{
|
|
|
|
TrackToEndPoint->SetState( BUSY, ON );
|
2009-11-18 12:52:19 +00:00
|
|
|
if( (TrackToEndPoint->Type() == TYPE_VIA)
|
|
|
|
|| Locate_Piste_Connectee( track, GetBoard()->m_Track, NULL, END ) )
|
2009-08-08 06:07:08 +00:00
|
|
|
error = true;
|
2007-08-10 19:14:51 +00:00
|
|
|
TrackToEndPoint->SetState( BUSY, OFF );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( error )
|
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
DisplayError( this,
|
|
|
|
_( "Unable to drag this segment: too many segments connected" ) );
|
2007-08-10 19:14:51 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
if( !TrackToStartPoint || ( TrackToStartPoint->Type() != TYPE_TRACK ) )
|
2010-08-31 15:54:05 +00:00
|
|
|
s_StartSegmentPresent = false;
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
if( !TrackToEndPoint || ( TrackToEndPoint->Type() != TYPE_TRACK ) )
|
2010-08-31 15:54:05 +00:00
|
|
|
s_EndSegmentPresent = false;
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Change high light net: the new one will be highlighted */
|
2010-01-24 13:46:01 +00:00
|
|
|
Old_HighLigt_Status = g_HighLight_Status;
|
|
|
|
Old_HighLigth_NetCode = g_HighLight_NetCode;
|
|
|
|
if( g_HighLight_Status )
|
|
|
|
High_Light( DC );
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2010-08-31 15:54:05 +00:00
|
|
|
EraseDragList();
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2009-03-05 13:41:34 +00:00
|
|
|
NewTrack = NULL;
|
2007-08-10 19:14:51 +00:00
|
|
|
NbPtNewTrack = 0;
|
|
|
|
track->m_Flags = IS_DRAGGED;
|
|
|
|
|
|
|
|
if( TrackToStartPoint )
|
|
|
|
{
|
|
|
|
int flag = STARTPOINT;
|
|
|
|
if( track->m_Start != TrackToStartPoint->m_Start )
|
|
|
|
flag = ENDPOINT;
|
|
|
|
AddSegmentToDragList( DrawPanel, DC, flag, TrackToStartPoint );
|
|
|
|
track->m_Flags |= STARTPOINT;
|
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
if( TrackToEndPoint )
|
|
|
|
{
|
|
|
|
int flag = STARTPOINT;
|
|
|
|
if( track->m_End != TrackToEndPoint->m_Start )
|
|
|
|
flag = ENDPOINT;
|
|
|
|
AddSegmentToDragList( DrawPanel, DC, flag, TrackToEndPoint );
|
|
|
|
track->m_Flags |= ENDPOINT;
|
|
|
|
}
|
|
|
|
|
|
|
|
AddSegmentToDragList( DrawPanel, DC, track->m_Flags, track );
|
|
|
|
|
|
|
|
|
|
|
|
PosInit = GetScreen()->m_Curseur;
|
|
|
|
s_LastPos = GetScreen()->m_Curseur;
|
|
|
|
DrawPanel->ManageCurseur = Show_Drag_Track_Segment_With_Cte_Slope;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = Abort_MoveTrack;
|
|
|
|
|
2010-01-24 13:46:01 +00:00
|
|
|
g_HighLight_NetCode = track->GetNet();
|
|
|
|
g_HighLight_Status = true;
|
|
|
|
GetBoard()->DrawHighLight( DrawPanel, DC, g_HighLight_NetCode );
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2009-08-08 06:07:08 +00:00
|
|
|
// Prepare the Undo command
|
|
|
|
ITEM_PICKER picker( NULL, UR_CHANGED );
|
2010-08-31 15:54:05 +00:00
|
|
|
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
|
2009-08-08 06:07:08 +00:00
|
|
|
{
|
2010-08-31 15:54:05 +00:00
|
|
|
TRACK* draggedtrack = g_DragSegmentList[ii].m_Segm;
|
2009-08-08 06:07:08 +00:00
|
|
|
picker.m_PickedItem = draggedtrack;
|
|
|
|
picker.m_Link = draggedtrack->Copy();
|
|
|
|
s_ItemsListPicker.PushItem( picker );
|
2009-11-18 12:52:19 +00:00
|
|
|
draggedtrack = (TRACK*) picker.m_Link;
|
2009-08-08 06:07:08 +00:00
|
|
|
draggedtrack->SetStatus( 0 );
|
|
|
|
draggedtrack->m_Flags = 0;
|
|
|
|
}
|
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
if( !InitialiseDragParameters() )
|
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
DisplayError( this,
|
|
|
|
_( "Unable to drag this segment: two collinear segments" ) );
|
2007-08-10 19:14:51 +00:00
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
Abort_MoveTrack( DrawPanel, DC );
|
|
|
|
return;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Place a dragged (or moved) track segment or via */
|
2009-11-18 12:52:19 +00:00
|
|
|
bool WinEDA_PcbFrame::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-10 19:14:51 +00:00
|
|
|
int errdrc;
|
|
|
|
|
|
|
|
if( Track == NULL )
|
2010-08-31 15:54:05 +00:00
|
|
|
return false;
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2007-10-13 06:18:44 +00:00
|
|
|
int current_net_code = Track->GetNet();
|
2007-08-10 19:14:51 +00:00
|
|
|
|
|
|
|
// DRC control:
|
|
|
|
if( Drc_On )
|
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
errdrc = m_drc->Drc( Track, GetBoard()->m_Track );
|
2007-08-10 19:14:51 +00:00
|
|
|
if( errdrc == BAD_DRC )
|
2010-08-31 15:54:05 +00:00
|
|
|
return false;
|
2007-08-10 19:14:51 +00:00
|
|
|
/* Redraw the dragged segments */
|
2010-08-31 15:54:05 +00:00
|
|
|
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2010-08-31 15:54:05 +00:00
|
|
|
errdrc = m_drc->Drc( g_DragSegmentList[ii].m_Segm, GetBoard()->m_Track );
|
2007-08-10 19:14:51 +00:00
|
|
|
if( errdrc == BAD_DRC )
|
2010-08-31 15:54:05 +00:00
|
|
|
return false;
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int draw_mode = GR_OR | GR_SURBRILL;
|
|
|
|
|
|
|
|
// DRC Ok: place track segments
|
|
|
|
Track->m_Flags = 0;
|
|
|
|
Track->SetState( EDIT, OFF );
|
|
|
|
Track->Draw( DrawPanel, DC, draw_mode );
|
|
|
|
|
2009-08-08 06:07:08 +00:00
|
|
|
/* Draw dragged tracks */
|
2010-08-31 15:54:05 +00:00
|
|
|
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2010-08-31 15:54:05 +00:00
|
|
|
Track = g_DragSegmentList[ii].m_Segm;
|
2007-08-10 19:14:51 +00:00
|
|
|
Track->SetState( EDIT, OFF );
|
|
|
|
Track->m_Flags = 0;
|
|
|
|
Track->Draw( DrawPanel, DC, draw_mode );
|
|
|
|
|
|
|
|
/* Test the connections modified by the move
|
2009-11-18 12:52:19 +00:00
|
|
|
* (only pad connection must be tested, track connection will be
|
|
|
|
* tested by test_1_net_connexion() ) */
|
2007-08-23 04:28:46 +00:00
|
|
|
int masque_layer = g_TabOneLayerMask[Track->GetLayer()];
|
2009-11-18 12:52:19 +00:00
|
|
|
Track->start = Fast_Locate_Pad_Connecte(
|
|
|
|
GetBoard(), Track->m_Start, masque_layer );
|
|
|
|
Track->end = Fast_Locate_Pad_Connecte(
|
|
|
|
GetBoard(), Track->m_End, masque_layer );
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
|
2010-08-31 15:54:05 +00:00
|
|
|
EraseDragList();
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
SaveCopyInUndoList( s_ItemsListPicker, UR_UNSPECIFIED );
|
|
|
|
s_ItemsListPicker.ClearItemsList(); // s_ItemsListPicker is no more owner
|
|
|
|
// of picked items
|
2009-08-08 06:07:08 +00:00
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2007-08-10 19:14:51 +00:00
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
|
|
|
|
|
|
|
if( current_net_code > 0 )
|
|
|
|
test_1_net_connexion( DC, current_net_code );
|
|
|
|
|
2009-08-08 06:07:08 +00:00
|
|
|
return true;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Find the point "attachment" of the end of a trace.
|
|
|
|
* This may be a TBP or another segment of the trace
|
|
|
|
* Returns:
|
|
|
|
* - Pointer to the PAD or:
|
|
|
|
* - Pointer to the segment or:
|
|
|
|
* - NULL
|
|
|
|
* Parameters:
|
|
|
|
* - position to test
|
|
|
|
* - mask layers to be tested
|
2007-08-10 19:14:51 +00:00
|
|
|
*/
|
2009-11-18 12:52:19 +00:00
|
|
|
BOARD_ITEM* LocateLockPoint( BOARD* Pcb, wxPoint pos, int LayerMask )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
for( MODULE* module = Pcb->m_Modules; module; module = module->Next() )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
D_PAD* pad = Locate_Pads( module, pos, LayerMask );
|
|
|
|
if( pad )
|
|
|
|
return pad;
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* No pad has been located so check for a segment of the trace. */
|
2009-03-05 13:41:34 +00:00
|
|
|
TRACK* ptsegm = Fast_Locate_Piste( Pcb->m_Track, NULL, pos, LayerMask );
|
2007-08-10 19:14:51 +00:00
|
|
|
if( ptsegm == NULL )
|
2010-01-31 20:01:46 +00:00
|
|
|
ptsegm = Locate_Pistes( Pcb, Pcb->m_Track, pos, LayerMask );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
return ptsegm;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Create an intermediate point on a segment
|
2010-05-27 10:23:29 +00:00
|
|
|
* aSegm segment is broken into 2 segments connecting point pX, pY
|
|
|
|
* After insertion:
|
|
|
|
* The new segment starts from to new point, and ends to initial aSegm ending point
|
|
|
|
* the old segment aSegm ends to new point
|
2009-11-18 12:52:19 +00:00
|
|
|
* Returns:
|
2010-05-27 10:23:29 +00:00
|
|
|
* NULL if no new point (ie if aRefPoint already corresponded at one end of aSegm
|
|
|
|
* or
|
|
|
|
* Pointer to the segment created
|
|
|
|
* Returns the exact value of aRefPoint
|
2009-11-18 12:52:19 +00:00
|
|
|
* If aSegm points to a via:
|
2010-05-27 10:23:29 +00:00
|
|
|
* Returns the exact value of aRefPoint and a pointer to the via,
|
|
|
|
* But does not create extra point
|
2007-08-10 19:14:51 +00:00
|
|
|
*/
|
2010-05-27 10:23:29 +00:00
|
|
|
TRACK* CreateLockPoint( BOARD* aPcb,
|
|
|
|
wxPoint& aRefPoint,
|
2009-11-18 12:52:19 +00:00
|
|
|
TRACK* aSegm,
|
|
|
|
PICKED_ITEMS_LIST* aItemsListPicker )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-08-08 06:07:08 +00:00
|
|
|
if( aSegm->m_Start == aRefPoint || aSegm->m_End == aRefPoint )
|
2007-08-10 19:14:51 +00:00
|
|
|
return NULL;
|
|
|
|
|
2009-08-08 06:07:08 +00:00
|
|
|
/* A via is a good lock point */
|
|
|
|
if( aSegm->Type() == TYPE_VIA )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2009-08-08 06:07:08 +00:00
|
|
|
aRefPoint = aSegm->m_Start;
|
|
|
|
return aSegm;
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
|
2010-05-27 10:23:29 +00:00
|
|
|
/* Calculation coordinate of intermediate point relative to
|
|
|
|
* the start point of aSegm
|
2008-12-04 04:28:11 +00:00
|
|
|
*/
|
2010-05-27 10:23:29 +00:00
|
|
|
wxPoint delta = aSegm->m_End - aSegm->m_Start;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-05-27 10:23:29 +00:00
|
|
|
// Not yet in use:
|
2009-08-08 06:07:08 +00:00
|
|
|
#if 0
|
2009-11-18 12:52:19 +00:00
|
|
|
int ox, oy, fx, fy;
|
|
|
|
|
2009-08-08 06:07:08 +00:00
|
|
|
if( aRefSegm )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2009-08-08 06:07:08 +00:00
|
|
|
ox = aRefSegm->m_Start.x - aSegm->m_Start.x;
|
|
|
|
oy = aRefSegm->m_Start.y - aSegm->m_Start.y;
|
|
|
|
fx = aRefSegm->m_End.x - aSegm->m_Start.x;
|
|
|
|
fy = aRefSegm->m_End.y - aSegm->m_Start.y;
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
2009-08-08 06:07:08 +00:00
|
|
|
#endif
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-05-27 10:23:29 +00:00
|
|
|
// calculate coordinates of aRefPoint relative to aSegm->m_Start
|
|
|
|
wxPoint newPoint = aRefPoint - aSegm->m_Start;
|
|
|
|
// newPoint must be on aSegm:
|
|
|
|
// Ensure newPoint.y/newPoint.y = delta.y/delta.x
|
|
|
|
if( delta.x == 0 )
|
|
|
|
newPoint.x = 0; /* horizontal segment*/
|
2007-08-10 19:14:51 +00:00
|
|
|
else
|
2010-05-27 10:23:29 +00:00
|
|
|
newPoint.y = wxRound(( (double)newPoint.x * delta.y ) / delta.x);
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Create the intermediate point (that is to say creation of a new
|
|
|
|
* segment, beginning at the intermediate point.
|
2008-12-04 04:28:11 +00:00
|
|
|
*/
|
2010-05-27 10:23:29 +00:00
|
|
|
newPoint.x += aSegm->m_Start.x;
|
|
|
|
newPoint.y += aSegm->m_Start.y;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
TRACK* newTrack = aSegm->Copy();
|
2009-08-08 06:07:08 +00:00
|
|
|
if( aItemsListPicker )
|
|
|
|
{
|
|
|
|
ITEM_PICKER picker( newTrack, UR_NEW );
|
2009-11-18 12:52:19 +00:00
|
|
|
aItemsListPicker->PushItem( picker );
|
2009-08-08 06:07:08 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-08-08 06:07:08 +00:00
|
|
|
|
|
|
|
DLIST<TRACK>* list = (DLIST<TRACK>*)aSegm->GetList();
|
2008-12-04 04:28:11 +00:00
|
|
|
wxASSERT( list );
|
2009-08-08 06:07:08 +00:00
|
|
|
list->Insert( newTrack, aSegm->Next() );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-08-08 06:07:08 +00:00
|
|
|
if( aItemsListPicker )
|
|
|
|
{
|
|
|
|
ITEM_PICKER picker( aSegm, UR_CHANGED );
|
|
|
|
picker.m_Link = aSegm->Copy();
|
2009-11-18 12:52:19 +00:00
|
|
|
aItemsListPicker->PushItem( picker );
|
2009-08-08 06:07:08 +00:00
|
|
|
}
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2010-05-27 10:23:29 +00:00
|
|
|
/* Correct pointer at the end of the new segment. */
|
|
|
|
newTrack->end = aSegm->end;
|
|
|
|
newTrack->SetState( END_ONPAD, aSegm->GetState( END_ONPAD ) );
|
|
|
|
|
|
|
|
/* Set connections info relative to the new point
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Old segment now ends at new point. */
|
|
|
|
aSegm->m_End = newPoint;
|
|
|
|
aSegm->end = newTrack;
|
2009-08-08 06:07:08 +00:00
|
|
|
aSegm->SetState( END_ONPAD, OFF );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-05-27 10:23:29 +00:00
|
|
|
/* The new segment begins at the new point. */
|
|
|
|
newTrack->m_Start = newPoint;
|
|
|
|
newTrack->start = aSegm;
|
|
|
|
newTrack->SetState( BEGIN_ONPAD, OFF );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2010-05-27 10:23:29 +00:00
|
|
|
D_PAD * pad = Locate_Pad_Connecte( aPcb, newTrack, START );
|
|
|
|
if ( pad )
|
|
|
|
{
|
|
|
|
newTrack->start = pad;
|
|
|
|
newTrack->SetState( BEGIN_ONPAD, ON );
|
|
|
|
aSegm->end = pad;
|
|
|
|
aSegm->SetState( END_ONPAD, ON );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-05-27 10:23:29 +00:00
|
|
|
aRefPoint = newPoint;
|
|
|
|
return newTrack;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|