2012-09-11 07:33:17 +00:00
|
|
|
/**
|
|
|
|
* @file dragsegm.cpp
|
|
|
|
* @brief Classes to find track segments connected to a pad or a module
|
|
|
|
* for drag commands
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004-2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <common.h>
|
2012-09-11 07:33:17 +00:00
|
|
|
#include <trigo.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <wxBasePcbFrame.h>
|
2013-05-02 18:06:58 +00:00
|
|
|
#include <macros.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <drag.h>
|
|
|
|
#include <pcbnew.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_module.h>
|
|
|
|
#include <class_board.h>
|
2012-09-11 07:33:17 +00:00
|
|
|
#include <connect.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
/* a list of DRAG_SEGM_PICKER items used to move or drag tracks */
|
|
|
|
std::vector<DRAG_SEGM_PICKER> g_DragSegmentList;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2010-08-31 15:54:05 +00:00
|
|
|
/* helper class to handle a list of track segments to drag or move
|
|
|
|
*/
|
2012-09-11 07:33:17 +00:00
|
|
|
DRAG_SEGM_PICKER::DRAG_SEGM_PICKER( TRACK* aTrack )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-09-11 07:33:17 +00:00
|
|
|
m_Track = aTrack;
|
2013-01-13 00:04:00 +00:00
|
|
|
m_startInitialValue = m_Track->GetStart();
|
|
|
|
m_endInitialValue = m_Track->GetEnd();
|
2012-09-11 07:33:17 +00:00
|
|
|
m_Pad_Start = m_Track->GetState( START_ON_PAD ) ? (D_PAD*)m_Track->start : NULL;
|
|
|
|
m_Pad_End = m_Track->GetState( END_ON_PAD ) ? (D_PAD*)m_Track->end : NULL;
|
2015-01-19 08:23:10 +00:00
|
|
|
m_TempFlags = 0;
|
2012-09-11 07:33:17 +00:00
|
|
|
m_RotationOffset = 0.0;
|
|
|
|
m_Flipped = false;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
void DRAG_SEGM_PICKER::SetAuxParameters()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2013-03-07 17:12:59 +00:00
|
|
|
MODULE* module = NULL;
|
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
if( m_Pad_Start )
|
|
|
|
{
|
|
|
|
module = (MODULE *) m_Pad_Start->GetParent();
|
|
|
|
m_PadStartOffset = m_Track->GetStart() - m_Pad_Start->GetPosition();
|
|
|
|
}
|
2007-11-02 18:21:43 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
if( m_Pad_End )
|
2007-11-02 18:21:43 +00:00
|
|
|
{
|
2012-09-11 07:33:17 +00:00
|
|
|
if( module == NULL )
|
|
|
|
module = (MODULE *) m_Pad_End->GetParent();
|
2013-03-07 17:12:59 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
m_PadEndOffset = m_Track->GetEnd() - m_Pad_End->GetPosition();
|
|
|
|
}
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
if( module )
|
|
|
|
{
|
|
|
|
m_Flipped = module->IsFlipped();
|
|
|
|
m_RotationOffset = module->GetOrientation();
|
|
|
|
}
|
|
|
|
}
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2013-03-07 17:12:59 +00:00
|
|
|
|
|
|
|
void DRAG_SEGM_PICKER::SetTrackEndsCoordinates( wxPoint aOffset )
|
2012-09-11 07:33:17 +00:00
|
|
|
{
|
|
|
|
// the track start position is the pad position + m_PadStartOffset
|
|
|
|
// however m_PadStartOffset is known for the initial rotation/flip
|
|
|
|
// this is also true for track end position and m_PadEndOffset
|
|
|
|
// Therefore, because rotation/flipping is allowed during a drag
|
|
|
|
// and move module, we should recalculate the pad offset,
|
|
|
|
// depending on the current orientation/flip state of the module
|
|
|
|
// relative to its initial orientation.
|
|
|
|
// (although most of time, offset is 0,0)
|
|
|
|
|
|
|
|
double curr_rot_offset = m_RotationOffset;
|
2013-03-07 17:12:59 +00:00
|
|
|
MODULE* module = NULL;
|
2012-09-11 07:33:17 +00:00
|
|
|
bool flip = false;
|
|
|
|
|
|
|
|
if( m_Pad_Start )
|
|
|
|
module = (MODULE *) m_Pad_Start->GetParent();
|
|
|
|
|
|
|
|
if( module == NULL && m_Pad_End )
|
|
|
|
module = (MODULE *) m_Pad_End->GetParent();
|
|
|
|
|
|
|
|
if( module )
|
|
|
|
{
|
|
|
|
flip = m_Flipped != module->IsFlipped();
|
|
|
|
curr_rot_offset = module->GetOrientation() - m_RotationOffset;
|
2013-03-07 17:12:59 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
if( flip ) // when flipping, module orientation is negated
|
|
|
|
curr_rot_offset = - module->GetOrientation() - m_RotationOffset;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
if( m_Pad_Start )
|
|
|
|
{
|
|
|
|
wxPoint padoffset = m_PadStartOffset;
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
if( curr_rot_offset != 0.0 )
|
|
|
|
RotatePoint(&padoffset, curr_rot_offset);
|
2007-11-02 18:21:43 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
if( flip )
|
2015-06-26 13:41:56 +00:00
|
|
|
padoffset.y = -padoffset.y;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-01-13 00:04:00 +00:00
|
|
|
m_Track->SetStart( m_Pad_Start->GetPosition() - aOffset + padoffset );
|
2012-09-11 07:33:17 +00:00
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
if( m_Pad_End )
|
|
|
|
{
|
|
|
|
wxPoint padoffset = m_PadEndOffset;
|
|
|
|
|
|
|
|
if( curr_rot_offset != 0.0 )
|
2013-03-07 17:12:59 +00:00
|
|
|
RotatePoint( &padoffset, curr_rot_offset );
|
2012-09-11 07:33:17 +00:00
|
|
|
|
|
|
|
if( flip )
|
2015-06-26 13:41:56 +00:00
|
|
|
padoffset.y = -padoffset.y;
|
2012-09-11 07:33:17 +00:00
|
|
|
|
2013-01-13 00:04:00 +00:00
|
|
|
m_Track->SetEnd( m_Pad_End->GetPosition() - aOffset + padoffset );
|
2007-11-02 18:21:43 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
// A sort function needed to build ordered pads lists
|
|
|
|
extern bool sortPadsByXthenYCoord( D_PAD* const & ref, D_PAD* const & comp );
|
|
|
|
|
2013-03-07 17:12:59 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
void DRAG_LIST::BuildDragListe( MODULE* aModule )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-09-11 07:33:17 +00:00
|
|
|
m_Pad = NULL;
|
|
|
|
m_Module = aModule;
|
|
|
|
|
|
|
|
// Build connections info
|
|
|
|
CONNECTIONS connections( m_Brd );
|
|
|
|
std::vector<D_PAD*>&padList = connections.GetPadsList();
|
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
for( D_PAD* pad = aModule->Pads(); pad; pad = pad->Next() )
|
2012-09-11 07:33:17 +00:00
|
|
|
padList.push_back( pad );
|
2007-11-02 18:21:43 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
sort( padList.begin(), padList.end(), sortPadsByXthenYCoord );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
fillList( connections );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2013-03-07 17:12:59 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
void DRAG_LIST::BuildDragListe( D_PAD* aPad )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-09-11 07:33:17 +00:00
|
|
|
m_Pad = aPad;
|
|
|
|
m_Module = NULL;
|
2007-11-02 18:21:43 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
// Build connections info
|
|
|
|
CONNECTIONS connections( m_Brd );
|
|
|
|
std::vector<D_PAD*>&padList = connections.GetPadsList();
|
|
|
|
padList.push_back( aPad );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
fillList( connections );
|
|
|
|
}
|
2012-02-19 04:02:19 +00:00
|
|
|
|
2013-03-07 17:12:59 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
// A helper function to sort track list per tracks
|
|
|
|
bool sort_tracklist( const DRAG_SEGM_PICKER& ref, const DRAG_SEGM_PICKER& tst )
|
|
|
|
{
|
|
|
|
return ref.m_Track < tst.m_Track;
|
|
|
|
}
|
2013-03-07 17:12:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
void DRAG_LIST::fillList( CONNECTIONS& aConnections )
|
2012-09-11 07:33:17 +00:00
|
|
|
{
|
|
|
|
aConnections.BuildTracksCandidatesList( m_Brd->m_Track, NULL);
|
2007-11-02 18:21:43 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
// Build connections info tracks to pads
|
|
|
|
// Rebuild pads to track info only)
|
|
|
|
aConnections.SearchTracksConnectedToPads( false, true );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
std::vector<D_PAD*>padList = aConnections.GetPadsList();
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
// clear flags and variables of selected tracks
|
|
|
|
for( unsigned ii = 0; ii < padList.size(); ii++ )
|
|
|
|
{
|
|
|
|
D_PAD * pad = padList[ii];
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
// store track connected to the pad
|
|
|
|
for( unsigned jj = 0; jj < pad->m_TracksConnected.size(); jj++ )
|
2007-11-02 18:21:43 +00:00
|
|
|
{
|
2012-09-11 07:33:17 +00:00
|
|
|
TRACK * track = pad->m_TracksConnected[jj];
|
|
|
|
track->start = NULL;
|
|
|
|
track->end = NULL;
|
2013-03-28 06:40:19 +00:00
|
|
|
track->SetState( START_ON_PAD|END_ON_PAD|BUSY, false );
|
2007-11-02 18:21:43 +00:00
|
|
|
}
|
2012-09-11 07:33:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// store tracks connected to pads
|
|
|
|
for( unsigned ii = 0; ii < padList.size(); ii++ )
|
|
|
|
{
|
|
|
|
D_PAD * pad = padList[ii];
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
// store track connected to the pad
|
|
|
|
for( unsigned jj = 0; jj < pad->m_TracksConnected.size(); jj++ )
|
2007-11-02 18:21:43 +00:00
|
|
|
{
|
2012-09-11 07:33:17 +00:00
|
|
|
TRACK * track = pad->m_TracksConnected[jj];
|
|
|
|
|
|
|
|
if( pad->HitTest( track->GetStart() ) )
|
|
|
|
{
|
|
|
|
track->start = pad;
|
2013-05-25 09:01:44 +00:00
|
|
|
track->SetState( START_ON_PAD, true );
|
2012-09-11 07:33:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( pad->HitTest( track->GetEnd() ) )
|
|
|
|
{
|
|
|
|
track->end = pad;
|
2013-05-25 09:01:44 +00:00
|
|
|
track->SetState( END_ON_PAD, true );
|
2012-09-11 07:33:17 +00:00
|
|
|
}
|
2013-03-07 17:12:59 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
DRAG_SEGM_PICKER wrapper( track );
|
|
|
|
m_DragList.push_back( wrapper );
|
2007-11-02 18:21:43 +00:00
|
|
|
}
|
|
|
|
}
|
2012-09-11 07:33:17 +00:00
|
|
|
|
|
|
|
// remove duplicate in m_DragList:
|
|
|
|
// a track can be stored more than once if connected to 2 overlapping pads, or
|
|
|
|
// each track end connected to 2 moving pads
|
|
|
|
// to avoid artifact in draw function, items should be not duplicated
|
|
|
|
// However, there is not a lot of items to be removed, so there ir no optimization.
|
|
|
|
|
|
|
|
// sort the drag list by track pointers
|
|
|
|
sort( m_DragList.begin(), m_DragList.end(), sort_tracklist );
|
|
|
|
|
|
|
|
// Explore the list, merge duplicates
|
|
|
|
for( int ii = 0; ii < (int)m_DragList.size()-1; ii++ )
|
|
|
|
{
|
|
|
|
int jj = ii+1;
|
2013-03-07 17:12:59 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
if( m_DragList[ii].m_Track != m_DragList[jj].m_Track )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// duplicate found: merge info and remove duplicate
|
|
|
|
if( m_DragList[ii].m_Pad_Start == NULL )
|
|
|
|
m_DragList[ii].m_Pad_Start = m_DragList[jj].m_Pad_Start;
|
2013-03-07 17:12:59 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
if( m_DragList[ii].m_Pad_End == NULL )
|
|
|
|
m_DragList[ii].m_Pad_End = m_DragList[jj].m_Pad_End;
|
|
|
|
|
2013-03-07 17:12:59 +00:00
|
|
|
m_DragList.erase( m_DragList.begin() + jj );
|
2012-09-11 07:33:17 +00:00
|
|
|
ii--;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize pad offsets and other params
|
|
|
|
for( unsigned ii = 0; ii < m_DragList.size(); ii++ )
|
|
|
|
m_DragList[ii].SetAuxParameters();
|
|
|
|
|
|
|
|
// Copy the list in global list
|
|
|
|
g_DragSegmentList = m_DragList;
|
|
|
|
}
|
|
|
|
|
2013-03-07 17:12:59 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
void DRAG_LIST::ClearList()
|
|
|
|
{
|
|
|
|
for( unsigned ii = 0; ii < m_DragList.size(); ii++ )
|
|
|
|
m_DragList[ii].m_Track->ClearFlags();
|
|
|
|
|
|
|
|
m_DragList.clear();
|
|
|
|
|
|
|
|
m_Module = NULL;
|
|
|
|
m_Pad = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Redraw the list of segments stored in g_DragSegmentList, while moving a footprint
|
|
|
|
void DrawSegmentWhileMovingFootprint( EDA_DRAW_PANEL* panel, wxDC* DC )
|
|
|
|
{
|
|
|
|
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
|
|
|
|
{
|
|
|
|
TRACK* track = g_DragSegmentList[ii].m_Track;
|
|
|
|
|
|
|
|
#ifndef USE_WX_OVERLAY
|
|
|
|
track->Draw( panel, DC, GR_XOR ); // erase from screen at old position
|
|
|
|
#endif
|
|
|
|
g_DragSegmentList[ii].SetTrackEndsCoordinates( g_Offset_Module );
|
|
|
|
track->Draw( panel, DC, GR_XOR );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EraseDragList()
|
|
|
|
{
|
|
|
|
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
|
|
|
|
g_DragSegmentList[ii].m_Track->ClearFlags();
|
|
|
|
|
|
|
|
g_DragSegmentList.clear();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-11-02 18:21:43 +00:00
|
|
|
|
2013-03-07 17:12:59 +00:00
|
|
|
void AddSegmentToDragList( int flag, TRACK* aTrack )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-09-11 07:33:17 +00:00
|
|
|
DRAG_SEGM_PICKER wrapper( aTrack );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2013-03-07 17:12:59 +00:00
|
|
|
if( flag & STARTPOINT )
|
2015-01-20 07:01:32 +00:00
|
|
|
{
|
|
|
|
wrapper.m_TempFlags |= STARTPOINT;
|
2012-09-11 07:33:17 +00:00
|
|
|
aTrack->SetFlags( STARTPOINT );
|
2015-01-20 07:01:32 +00:00
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2013-03-07 17:12:59 +00:00
|
|
|
if( flag & ENDPOINT )
|
2015-01-20 07:01:32 +00:00
|
|
|
{
|
|
|
|
wrapper.m_TempFlags |= ENDPOINT;
|
2012-09-11 07:33:17 +00:00
|
|
|
aTrack->SetFlags( ENDPOINT );
|
2015-01-20 07:01:32 +00:00
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2010-08-31 15:54:05 +00:00
|
|
|
g_DragSegmentList.push_back( wrapper );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-11-02 18:21:43 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
void Collect_TrackSegmentsToDrag( BOARD* aPcb, const wxPoint& aRefPos, LSET aLayerMask,
|
2013-01-08 17:58:06 +00:00
|
|
|
int aNetCode, int aMaxDist )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2013-01-08 17:58:06 +00:00
|
|
|
TRACK* track = aPcb->m_Track->GetStartNetCode( aNetCode );
|
2010-08-31 15:54:05 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
for( ; track; track = track->Next() )
|
2007-11-02 18:21:43 +00:00
|
|
|
{
|
2014-02-25 10:40:34 +00:00
|
|
|
if( track->GetNetCode() != aNetCode ) // not the same netcode: all candidates tested
|
2010-08-31 15:54:05 +00:00
|
|
|
break;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2014-06-25 17:01:50 +00:00
|
|
|
if( !( aLayerMask & track->GetLayerSet() ).any() )
|
2010-08-31 15:54:05 +00:00
|
|
|
continue; // Cannot be connected, not on the same layer
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
if( track->IsDragging() )
|
2010-08-31 15:54:05 +00:00
|
|
|
continue; // already put in list
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2013-03-28 19:12:46 +00:00
|
|
|
STATUS_FLAGS flag = 0;
|
2013-01-08 17:58:06 +00:00
|
|
|
int maxdist = std::max( aMaxDist, track->GetWidth() / 2 );
|
2010-11-12 16:36:43 +00:00
|
|
|
|
2013-01-08 17:58:06 +00:00
|
|
|
if( (track->GetFlags() & STARTPOINT) == 0 )
|
|
|
|
{
|
2013-01-13 00:04:00 +00:00
|
|
|
wxPoint delta = track->GetStart() - aRefPos;
|
2013-03-07 17:12:59 +00:00
|
|
|
|
2013-01-08 17:58:06 +00:00
|
|
|
if( std::abs( delta.x ) <= maxdist && std::abs( delta.y ) <= maxdist )
|
|
|
|
{
|
2013-05-01 17:32:36 +00:00
|
|
|
int dist = KiROUND( EuclideanNorm( delta ) );
|
2013-03-07 17:12:59 +00:00
|
|
|
|
2013-01-08 17:58:06 +00:00
|
|
|
if( dist <= maxdist )
|
|
|
|
{
|
|
|
|
flag |= STARTPOINT;
|
2013-03-07 17:12:59 +00:00
|
|
|
|
2013-01-08 17:58:06 +00:00
|
|
|
if( track->Type() == PCB_VIA_T )
|
|
|
|
flag |= ENDPOINT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( (track->GetFlags() & ENDPOINT) == 0 )
|
|
|
|
{
|
2013-01-13 00:04:00 +00:00
|
|
|
wxPoint delta = track->GetEnd() - aRefPos;
|
2013-03-07 17:12:59 +00:00
|
|
|
|
2013-01-08 17:58:06 +00:00
|
|
|
if( std::abs( delta.x ) <= maxdist && std::abs( delta.y ) <= maxdist )
|
|
|
|
{
|
2013-05-01 17:32:36 +00:00
|
|
|
int dist = KiROUND( EuclideanNorm( delta ) );
|
2013-03-07 17:12:59 +00:00
|
|
|
|
2013-01-08 17:58:06 +00:00
|
|
|
if( dist <= maxdist )
|
|
|
|
flag |= ENDPOINT;
|
|
|
|
}
|
|
|
|
}
|
2010-08-31 15:54:05 +00:00
|
|
|
|
|
|
|
// Note: vias will be flagged with both STARTPOINT and ENDPOINT
|
|
|
|
// and must not be entered twice.
|
|
|
|
if( flag )
|
2007-11-02 18:21:43 +00:00
|
|
|
{
|
2012-09-11 07:33:17 +00:00
|
|
|
AddSegmentToDragList( flag, track );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-08-31 15:54:05 +00:00
|
|
|
// If a connected via is found at location aRefPos,
|
|
|
|
// collect also tracks connected by this via.
|
2011-10-01 19:24:27 +00:00
|
|
|
if( track->Type() == PCB_VIA_T )
|
2014-06-24 16:17:18 +00:00
|
|
|
Collect_TrackSegmentsToDrag( aPcb, aRefPos, track->GetLayerSet(),
|
2013-01-08 17:58:06 +00:00
|
|
|
aNetCode, track->GetWidth() / 2 );
|
2007-11-02 18:21:43 +00:00
|
|
|
}
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2013-03-07 17:12:59 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
void UndrawAndMarkSegmentsToDrag( EDA_DRAW_PANEL* aCanvas, wxDC* aDC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-08-31 15:54:05 +00:00
|
|
|
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
|
2012-09-11 07:33:17 +00:00
|
|
|
{
|
|
|
|
TRACK* track = g_DragSegmentList[ii].m_Track;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
track->Draw( aCanvas, aDC, GR_XOR );
|
2013-03-28 06:40:19 +00:00
|
|
|
track->SetState( IN_EDIT, false );
|
2013-07-05 17:48:01 +00:00
|
|
|
track->SetFlags( IS_DRAGGED );
|
2012-09-11 07:33:17 +00:00
|
|
|
|
2015-01-19 08:23:10 +00:00
|
|
|
if( g_DragSegmentList[ii].m_TempFlags & STARTPOINT )
|
2012-09-11 07:33:17 +00:00
|
|
|
track->SetFlags( STARTPOINT );
|
|
|
|
|
2015-01-19 08:23:10 +00:00
|
|
|
if( g_DragSegmentList[ii].m_TempFlags & ENDPOINT )
|
2012-09-11 07:33:17 +00:00
|
|
|
track->SetFlags( ENDPOINT );
|
|
|
|
|
|
|
|
track->Draw( aCanvas, aDC, GR_XOR );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|