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>
|
2011-10-17 20:01:27 +00:00
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file attribut.cpp
|
|
|
|
* @brief Track attribute flags editing.
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <wxPcbStruct.h>
|
2013-01-12 17:32:24 +00:00
|
|
|
#include <msgpanel.h>
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <protos.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_track.h>
|
|
|
|
#include <class_board.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
/* Attribute change for 1 track segment.
|
2007-08-20 01:20:48 +00:00
|
|
|
* Attributes are
|
2011-02-13 17:53:48 +00:00
|
|
|
* TRACK_LOCKED protection against global delete
|
|
|
|
* TRACK_AR AutoRouted segment
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::Attribut_Segment( TRACK* track, wxDC* DC, bool Flag_On )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( track == NULL )
|
|
|
|
return;
|
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOff( DC ); // Erase cursor shape
|
2011-02-13 17:53:48 +00:00
|
|
|
track->SetState( TRACK_LOCKED, Flag_On );
|
2011-12-22 13:28:11 +00:00
|
|
|
track->Draw( m_canvas, DC, GR_OR | GR_HIGHLIGHT );
|
|
|
|
m_canvas->CrossHairOn( DC ); // Display cursor shape
|
2013-01-12 17:32:24 +00:00
|
|
|
|
|
|
|
MSG_PANEL_ITEMS items;
|
|
|
|
track->GetMsgPanelInfo( items );
|
|
|
|
SetMsgPanel( items );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Attribute change for an entire track */
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
TRACK* Track;
|
|
|
|
int nb_segm;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
if( (track == NULL ) || (track->Type() == PCB_ZONE_T) )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOff( DC ); // Erase cursor shape
|
2011-09-16 15:54:50 +00:00
|
|
|
Track = GetBoard()->MarkTrace( track, &nb_segm, NULL, NULL, true );
|
2011-12-22 13:28:11 +00:00
|
|
|
DrawTraces( m_canvas, DC, Track, nb_segm, GR_OR | GR_HIGHLIGHT );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
for( ; (Track != NULL) && (nb_segm > 0); nb_segm-- )
|
|
|
|
{
|
2011-02-13 17:53:48 +00:00
|
|
|
Track->SetState( TRACK_LOCKED, Flag_On );
|
2013-03-28 06:40:19 +00:00
|
|
|
Track->SetState( BUSY, false );
|
2008-11-24 06:53:43 +00:00
|
|
|
Track = Track->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOn( DC ); // Display cursor shape
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-02-13 17:53:48 +00:00
|
|
|
/* Modify the flag TRACK_LOCKED according to Flag_On value,
|
2007-08-20 01:20:48 +00:00
|
|
|
* for all the segments related to net_code.
|
|
|
|
* if net_code < 0 all the segments are modified.
|
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::Attribut_net( wxDC* DC, int net_code, bool Flag_On )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
TRACK* Track = GetBoard()->m_Track;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
/* search the first segment for the selected net_code */
|
|
|
|
if( net_code >= 0 )
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
for( ; Track != NULL; Track = Track->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2014-02-25 10:47:27 +00:00
|
|
|
if( net_code == Track->GetNetCode() )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOff( DC ); // Erase cursor shape
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
while( Track ) /* Flag change */
|
|
|
|
{
|
2014-02-25 10:47:27 +00:00
|
|
|
if( ( net_code >= 0 ) && ( net_code != Track->GetNetCode() ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2009-01-05 05:21:35 +00:00
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2011-02-13 17:53:48 +00:00
|
|
|
Track->SetState( TRACK_LOCKED, Flag_On );
|
2011-12-22 13:28:11 +00:00
|
|
|
Track->Draw( m_canvas, DC, GR_OR | GR_HIGHLIGHT );
|
2007-08-20 01:20:48 +00:00
|
|
|
Track = Track->Next();
|
|
|
|
}
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->CrossHairOn( DC ); // Display cursor shape
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|