2011-10-17 20:01:27 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2012-06-08 09:56:42 +00:00
|
|
|
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
|
|
|
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-17 20:01:27 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file move_or_drag_track.cpp
|
|
|
|
* @brief Track editing routines to move and drag track segments or node.
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <trigo.h>
|
|
|
|
#include <macros.h>
|
|
|
|
#include <gr_basic.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew.h>
|
2018-01-28 21:02:31 +00:00
|
|
|
#include <drc.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <drag.h>
|
|
|
|
#include <pcbnew_id.h>
|
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
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
// Place a dragged (or moved) track segment or via
|
2011-03-01 19:26:17 +00:00
|
|
|
bool PCB_EDIT_FRAME::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
|
|
|
|
2014-02-25 10:40:34 +00:00
|
|
|
int current_net_code = Track->GetNetCode();
|
2007-08-10 19:14:51 +00:00
|
|
|
|
|
|
|
// DRC control:
|
2017-08-04 12:43:02 +00:00
|
|
|
if( Settings().m_legacyDrcOn )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2018-06-04 08:44:25 +00:00
|
|
|
errdrc = m_drc->DrcOnCreatingTrack( Track, GetBoard()->m_Track );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
if( errdrc == BAD_DRC )
|
2010-08-31 15:54:05 +00:00
|
|
|
return false;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2018-06-04 08:44:25 +00:00
|
|
|
// Test 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
|
|
|
{
|
2018-06-04 08:44:25 +00:00
|
|
|
errdrc = m_drc->DrcOnCreatingTrack( g_DragSegmentList[ii].m_Track, GetBoard()->m_Track );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// DRC Ok: place track segments
|
2011-12-21 13:42:02 +00:00
|
|
|
Track->ClearFlags();
|
2013-03-27 18:32:12 +00:00
|
|
|
Track->SetState( IN_EDIT, false );
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2013-08-03 05:15:23 +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
|
|
|
{
|
2012-09-11 07:33:17 +00:00
|
|
|
Track = g_DragSegmentList[ii].m_Track;
|
2013-03-27 18:32:12 +00:00
|
|
|
Track->SetState( IN_EDIT, false );
|
2011-12-21 13:42:02 +00:00
|
|
|
Track->ClearFlags();
|
2007-08-10 19:14:51 +00:00
|
|
|
|
|
|
|
/* 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
|
2011-09-15 17:58:35 +00:00
|
|
|
* tested by TestNetConnection() ) */
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET layerMask( Track->GetLayer() );
|
|
|
|
|
2013-01-13 00:04:00 +00:00
|
|
|
Track->start = GetBoard()->GetPadFast( Track->GetStart(), layerMask );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-09-07 09:27:02 +00:00
|
|
|
if( Track->start )
|
2013-03-27 18:32:12 +00:00
|
|
|
Track->SetState( BEGIN_ONPAD, true );
|
2011-09-07 09:27:02 +00:00
|
|
|
else
|
2013-03-27 18:32:12 +00:00
|
|
|
Track->SetState( BEGIN_ONPAD, false );
|
2011-09-07 09:27:02 +00:00
|
|
|
|
2013-01-13 00:04:00 +00:00
|
|
|
Track->end = GetBoard()->GetPadFast( Track->GetEnd(), layerMask );
|
2011-09-15 17:58:35 +00:00
|
|
|
|
2011-09-07 09:27:02 +00:00
|
|
|
if( Track->end )
|
2013-03-27 18:32:12 +00:00
|
|
|
Track->SetState( END_ONPAD, true );
|
2011-09-07 09:27:02 +00:00
|
|
|
else
|
2013-03-27 18:32:12 +00:00
|
|
|
Track->SetState( END_ONPAD, false );
|
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 );
|
2011-09-07 19:41:04 +00:00
|
|
|
s_ItemsListPicker.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
|
2009-08-08 06:07:08 +00:00
|
|
|
|
2011-09-14 20:04:58 +00:00
|
|
|
GetBoard()->PopHighLight();
|
2011-04-15 14:10:20 +00:00
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->SetMouseCapture( NULL, NULL );
|
2007-08-10 19:14:51 +00:00
|
|
|
|
|
|
|
if( current_net_code > 0 )
|
2011-09-15 17:58:35 +00:00
|
|
|
TestNetConnection( DC, current_net_code );
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2012-09-11 07:33:17 +00:00
|
|
|
m_canvas->Refresh();
|
|
|
|
|
2009-08-08 06:07:08 +00:00
|
|
|
return true;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|