2011-10-13 19:56:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
|
|
|
* Copyright (C) 2009 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
|
|
|
|
*/
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file class_track.h
|
|
|
|
* @brief Functions relatives to tracks, vias and segments used to fill zones.
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "trigo.h"
|
|
|
|
#include "class_drawpanel.h"
|
2011-09-23 13:57:12 +00:00
|
|
|
#include "class_pcb_screen.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "drawtxt.h"
|
2011-09-23 13:57:12 +00:00
|
|
|
#include "pcbcommon.h"
|
|
|
|
#include "colors_selection.h"
|
|
|
|
#include "wxstruct.h"
|
|
|
|
#include "macros.h"
|
|
|
|
#include "wxBasePcbFrame.h"
|
|
|
|
|
|
|
|
#include "class_board.h"
|
|
|
|
#include "class_track.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "pcbnew.h"
|
2007-08-20 19:33:15 +00:00
|
|
|
#include "protos.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-11 01:19:08 +00:00
|
|
|
/**
|
|
|
|
* Function ShowClearance
|
|
|
|
* tests to see if the clearance border is drawn on the given track.
|
|
|
|
* @return bool - true if should draw clearance, else false.
|
|
|
|
*/
|
|
|
|
static bool ShowClearance( const TRACK* aTrack )
|
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
// maybe return true for tracks and vias, not for zone segments
|
2011-09-30 08:24:10 +00:00
|
|
|
return aTrack->GetLayer() <= LAST_COPPER_LAYER
|
2011-10-01 19:24:27 +00:00
|
|
|
&& ( aTrack->Type() == PCB_TRACE_T || aTrack->Type() == PCB_VIA_T )
|
2011-09-30 08:24:10 +00:00
|
|
|
&& ( ( DisplayOpt.ShowTrackClearanceMode == SHOW_CLEARANCE_NEW_AND_EDITED_TRACKS_AND_VIA_AREAS
|
|
|
|
&& ( aTrack->m_Flags & IS_DRAGGED || aTrack->m_Flags & IS_MOVED || aTrack->m_Flags & IS_NEW ) )
|
|
|
|
|| ( DisplayOpt.ShowTrackClearanceMode == SHOW_CLEARANCE_ALWAYS )
|
|
|
|
);
|
|
|
|
|
2008-03-11 01:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-16 14:13:02 +00:00
|
|
|
/*
|
|
|
|
* return true if the dist between p1 and p2 < max_dist
|
|
|
|
* Currently in test (currently rasnest algos work only if p1 == p2)
|
|
|
|
*/
|
|
|
|
inline bool IsNear( wxPoint& p1, wxPoint& p2, int max_dist )
|
|
|
|
{
|
|
|
|
#if 0 // Do not change it: does not work
|
|
|
|
int dist;
|
|
|
|
dist = abs( p1.x - p2.x ) + abs( p1.y - p2.y );
|
|
|
|
dist *= 7;
|
|
|
|
dist /= 10;
|
|
|
|
|
|
|
|
if ( dist < max_dist )
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
if ( p1 == p2 )
|
|
|
|
return true;
|
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TRACK* GetTrace( TRACK* aStartTrace, TRACK* aEndTrace, const wxPoint& aPosition, int aLayerMask )
|
|
|
|
{
|
|
|
|
TRACK* PtSegm;
|
|
|
|
|
|
|
|
if( aStartTrace == NULL )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
for( PtSegm = aStartTrace; PtSegm != NULL; PtSegm = PtSegm->Next() )
|
|
|
|
{
|
|
|
|
if( PtSegm->GetState( IS_DELETED | BUSY ) == 0 )
|
|
|
|
{
|
|
|
|
if( aPosition == PtSegm->m_Start )
|
|
|
|
{
|
|
|
|
if( aLayerMask & PtSegm->ReturnMaskLayer() )
|
|
|
|
return PtSegm;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aPosition == PtSegm->m_End )
|
|
|
|
{
|
|
|
|
if( aLayerMask & PtSegm->ReturnMaskLayer() )
|
|
|
|
return PtSegm;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( PtSegm == aEndTrace )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
TRACK::TRACK( BOARD_ITEM* aParent, KICAD_T idtype ) :
|
|
|
|
BOARD_CONNECTED_ITEM( aParent, idtype )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-10-19 06:31:17 +00:00
|
|
|
m_Width = 0;
|
|
|
|
m_Shape = S_SEGMENT;
|
|
|
|
start = end = NULL;
|
2008-01-12 20:31:56 +00:00
|
|
|
SetDrillDefault();
|
2007-10-19 06:31:17 +00:00
|
|
|
m_Param = 0;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2011-07-14 15:42:44 +00:00
|
|
|
wxString TRACK::ShowWidth() const
|
2007-10-11 00:11:59 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2007-10-11 00:11:59 +00:00
|
|
|
valeur_param( m_Width, msg );
|
|
|
|
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2007-08-09 01:41:30 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
SEGZONE::SEGZONE( BOARD_ITEM* aParent ) :
|
2011-10-01 19:24:27 +00:00
|
|
|
TRACK( aParent, PCB_ZONE_T )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2011-07-14 15:42:44 +00:00
|
|
|
wxString SEGZONE::GetSelectMenuText() const
|
|
|
|
{
|
|
|
|
wxString text;
|
|
|
|
NETINFO_ITEM* net;
|
|
|
|
BOARD* board = GetBoard();
|
|
|
|
|
|
|
|
text << _( "Zone" ) << wxT( " " ) << wxString::Format( wxT( "(%8.8X)" ), m_TimeStamp );
|
|
|
|
|
|
|
|
if( board )
|
|
|
|
{
|
|
|
|
net = board->FindNet( GetNet() );
|
|
|
|
|
|
|
|
if( net )
|
|
|
|
text << wxT( " [" ) << net->GetNetname() << wxT( "]" );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
text << _( "** BOARD NOT DEFINED **" );
|
|
|
|
}
|
|
|
|
|
|
|
|
text << _( " on " ) << GetLayerName();
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
SEGVIA::SEGVIA( BOARD_ITEM* aParent ) :
|
2011-10-01 19:24:27 +00:00
|
|
|
TRACK( aParent, PCB_VIA_T )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2011-07-14 15:42:44 +00:00
|
|
|
wxString SEGVIA::GetSelectMenuText() const
|
|
|
|
{
|
|
|
|
wxString text;
|
|
|
|
NETINFO_ITEM* net;
|
|
|
|
BOARD* board = GetBoard();
|
|
|
|
|
|
|
|
text << _( "Via" ) << wxT( " " ) << ShowWidth();
|
|
|
|
|
|
|
|
int shape = Shape();
|
|
|
|
|
|
|
|
if( shape == VIA_BLIND_BURIED )
|
|
|
|
text << wxT( " " ) << _( "Blind/Buried" );
|
|
|
|
else if( shape == VIA_MICROVIA )
|
|
|
|
text << wxT( " " ) << _( "Micro Via" );
|
|
|
|
// else say nothing about normal (through) vias
|
|
|
|
|
|
|
|
if( board )
|
|
|
|
{
|
|
|
|
net = board->FindNet( GetNet() );
|
|
|
|
|
|
|
|
if( net )
|
|
|
|
text << wxT( " [" ) << net->GetNetname() << wxT( "]" );
|
|
|
|
|
|
|
|
text << wxChar( ' ' ) << _( "Net:" ) << GetNet();
|
|
|
|
|
|
|
|
if( shape != VIA_THROUGH )
|
|
|
|
{
|
|
|
|
// say which layers, only two for now
|
|
|
|
int topLayer;
|
|
|
|
int botLayer;
|
|
|
|
ReturnLayerPair( &topLayer, &botLayer );
|
|
|
|
text << _( " on " ) << board->GetLayerName( topLayer ).Trim() << wxT( " <-> " )
|
|
|
|
<< board->GetLayerName( botLayer ).Trim();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
text << _( "** BOARD NOT DEFINED **" );
|
|
|
|
}
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
// Copy constructor
|
2007-08-08 20:51:08 +00:00
|
|
|
TRACK::TRACK( const TRACK& Source ) :
|
2008-11-18 18:13:55 +00:00
|
|
|
BOARD_CONNECTED_ITEM( Source )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-10-19 06:31:17 +00:00
|
|
|
m_Shape = Source.m_Shape;
|
2007-10-13 06:18:44 +00:00
|
|
|
SetNet( Source.GetNet() );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
m_Flags = Source.m_Flags;
|
|
|
|
m_TimeStamp = Source.m_TimeStamp;
|
|
|
|
SetStatus( Source.ReturnStatus() );
|
|
|
|
m_Start = Source.m_Start;
|
|
|
|
m_End = Source.m_End;
|
|
|
|
m_Width = Source.m_Width;
|
|
|
|
m_Drill = Source.m_Drill;
|
2007-10-13 06:18:44 +00:00
|
|
|
SetSubNet( Source.GetSubNet() );
|
2007-08-08 20:51:08 +00:00
|
|
|
m_Param = Source.m_Param;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
TRACK* TRACK::Copy() const
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
if( Type() == PCB_TRACE_T )
|
2007-10-19 06:31:17 +00:00
|
|
|
return new TRACK( *this );
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
if( Type() == PCB_VIA_T )
|
2007-10-19 06:31:17 +00:00
|
|
|
return new SEGVIA( (const SEGVIA &) * this );
|
2007-09-11 04:14:15 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
if( Type() == PCB_ZONE_T )
|
2007-10-19 06:31:17 +00:00
|
|
|
return new SEGZONE( (const SEGZONE &) * this );
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
return NULL; // should never happen
|
|
|
|
}
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-04-08 11:33:43 +00:00
|
|
|
int TRACK::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
|
|
|
|
{
|
2011-09-14 20:04:58 +00:00
|
|
|
// Currently tracks have no specific clearance parameter on a per track or per
|
|
|
|
// segment basis. The NETCLASS clearance is used.
|
2010-04-08 11:33:43 +00:00
|
|
|
return BOARD_CONNECTED_ITEM::GetClearance( aItem );
|
|
|
|
}
|
2007-09-01 12:00:30 +00:00
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-02-09 08:34:45 +00:00
|
|
|
int TRACK::GetDrillValue() const
|
2008-01-12 20:31:56 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
if( Type() != PCB_VIA_T )
|
2008-02-09 08:34:45 +00:00
|
|
|
return 0;
|
|
|
|
|
2009-10-21 19:16:25 +00:00
|
|
|
if( m_Drill > 0 ) // Use the specific value.
|
2008-02-09 08:34:45 +00:00
|
|
|
return m_Drill;
|
2008-01-12 20:31:56 +00:00
|
|
|
|
2009-10-21 19:16:25 +00:00
|
|
|
// Use the default value from the Netclass
|
|
|
|
NETCLASS* netclass = GetNetClass();
|
|
|
|
|
2008-12-14 19:45:05 +00:00
|
|
|
if( m_Shape == VIA_MICROVIA )
|
2009-10-21 19:16:25 +00:00
|
|
|
return netclass->GetuViaDrill();
|
2008-01-12 20:31:56 +00:00
|
|
|
|
2009-10-21 19:16:25 +00:00
|
|
|
return netclass->GetViaDrill();
|
2008-01-12 20:31:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
bool TRACK::IsNull()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
if( ( Type() != PCB_VIA_T ) && ( m_Start == m_End ) )
|
2009-10-10 17:27:53 +00:00
|
|
|
return true;
|
2007-08-08 20:51:08 +00:00
|
|
|
else
|
2009-10-10 17:27:53 +00:00
|
|
|
return false;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2011-09-14 15:08:44 +00:00
|
|
|
int TRACK::IsPointOnEnds( const wxPoint& point, int min_dist )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-08 20:51:08 +00:00
|
|
|
int result = 0;
|
|
|
|
|
2011-09-14 15:08:44 +00:00
|
|
|
if( min_dist < 0 )
|
|
|
|
min_dist = m_Width / 2;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2011-09-14 15:08:44 +00:00
|
|
|
int dx = m_Start.x - point.x;
|
|
|
|
int dy = m_Start.y - point.y;
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2011-09-14 15:08:44 +00:00
|
|
|
if( min_dist == 0 )
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
|
|
|
if( (dx == 0) && (dy == 0 ) )
|
|
|
|
result |= STARTPOINT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-04-14 18:44:46 +00:00
|
|
|
double dist = hypot( (double)dx, (double) dy );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-09-14 15:08:44 +00:00
|
|
|
if( min_dist >= (int) dist )
|
2007-08-08 20:51:08 +00:00
|
|
|
result |= STARTPOINT;
|
|
|
|
}
|
|
|
|
|
2011-09-14 15:08:44 +00:00
|
|
|
dx = m_End.x - point.x;
|
|
|
|
dy = m_End.y - point.y;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-09-14 15:08:44 +00:00
|
|
|
if( min_dist == 0 )
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
|
|
|
if( (dx == 0) && (dy == 0 ) )
|
|
|
|
result |= ENDPOINT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-04-14 18:44:46 +00:00
|
|
|
double dist = hypot( (double) dx, (double) dy );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-09-14 15:08:44 +00:00
|
|
|
if( min_dist >= (int) dist )
|
2007-08-08 20:51:08 +00:00
|
|
|
result |= ENDPOINT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT TRACK::GetBoundingBox() const
|
2008-03-05 22:39:33 +00:00
|
|
|
{
|
2008-03-10 13:33:12 +00:00
|
|
|
// end of track is round, this is its radius, rounded up
|
2008-12-14 19:45:05 +00:00
|
|
|
int radius = ( m_Width + 1 ) / 2;
|
2008-03-05 22:39:33 +00:00
|
|
|
|
2008-03-10 15:00:22 +00:00
|
|
|
int ymax;
|
|
|
|
int xmax;
|
2008-03-05 22:39:33 +00:00
|
|
|
|
2008-03-10 15:00:22 +00:00
|
|
|
int ymin;
|
|
|
|
int xmin;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
if( Type() == PCB_VIA_T )
|
2008-03-10 15:00:22 +00:00
|
|
|
{
|
2008-03-10 15:02:27 +00:00
|
|
|
// Because vias are sometimes drawn larger than their m_Width would
|
|
|
|
// provide, erasing them using a dirty rect must also compensate for this
|
|
|
|
// possibility (that the via is larger on screen than its m_Width would provide).
|
|
|
|
// Because it is cheap to return a larger BoundingBox, do it so that
|
2008-03-10 15:00:22 +00:00
|
|
|
// the via gets erased properly. Do not divide width by 2 for this reason.
|
|
|
|
radius = m_Width;
|
|
|
|
|
|
|
|
ymax = m_Start.y;
|
|
|
|
xmax = m_Start.x;
|
|
|
|
|
|
|
|
ymin = m_Start.y;
|
|
|
|
xmin = m_Start.x;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-12-14 19:45:05 +00:00
|
|
|
radius = ( m_Width + 1 ) / 2;
|
2008-03-10 15:00:22 +00:00
|
|
|
|
|
|
|
ymax = MAX( m_Start.y, m_End.y );
|
|
|
|
xmax = MAX( m_Start.x, m_End.x );
|
|
|
|
|
|
|
|
ymin = MIN( m_Start.y, m_End.y );
|
|
|
|
xmin = MIN( m_Start.x, m_End.x );
|
|
|
|
}
|
2008-03-05 22:39:33 +00:00
|
|
|
|
2008-03-11 01:19:08 +00:00
|
|
|
if( ShowClearance( this ) )
|
|
|
|
{
|
|
|
|
// + 1 is for the clearance line itself.
|
2009-09-10 15:22:26 +00:00
|
|
|
radius += GetClearance() + 1;
|
2008-03-11 01:19:08 +00:00
|
|
|
}
|
|
|
|
|
2008-03-05 22:39:33 +00:00
|
|
|
ymax += radius;
|
|
|
|
xmax += radius;
|
|
|
|
|
|
|
|
ymin -= radius;
|
|
|
|
xmin -= radius;
|
|
|
|
|
2008-03-10 13:33:12 +00:00
|
|
|
// return a rectangle which is [pos,dim) in nature. therefore the +1
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT ret( wxPoint( xmin, ymin ), wxSize( xmax - xmin + 1, ymax - ymin + 1 ) );
|
2008-03-11 01:19:08 +00:00
|
|
|
|
|
|
|
return ret;
|
2008-03-05 22:39:33 +00:00
|
|
|
}
|
|
|
|
|
2009-10-10 17:27:53 +00:00
|
|
|
|
|
|
|
void TRACK::Rotate( const wxPoint& aRotCentre, int aAngle )
|
2009-08-01 19:26:05 +00:00
|
|
|
{
|
|
|
|
RotatePoint( &m_Start, aRotCentre, aAngle );
|
|
|
|
RotatePoint( &m_End, aRotCentre, aAngle );
|
|
|
|
}
|
|
|
|
|
2009-10-10 17:27:53 +00:00
|
|
|
|
|
|
|
void TRACK::Flip( const wxPoint& aCentre )
|
2009-08-01 19:26:05 +00:00
|
|
|
{
|
2009-10-10 17:27:53 +00:00
|
|
|
m_Start.y = aCentre.y - (m_Start.y - aCentre.y);
|
|
|
|
m_End.y = aCentre.y - (m_End.y - aCentre.y);
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
if( Type() == PCB_VIA_T )
|
2011-09-14 15:08:44 +00:00
|
|
|
{
|
|
|
|
// Huh? Wouldn't it be better to us Type() != VIA and get rid of these brackets?
|
|
|
|
}
|
|
|
|
else
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2009-08-01 19:26:05 +00:00
|
|
|
SetLayer( ChangeSideNumLayer( GetLayer() ) );
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
2009-08-01 19:26:05 +00:00
|
|
|
}
|
|
|
|
|
2008-03-05 22:39:33 +00:00
|
|
|
|
2011-09-14 15:08:44 +00:00
|
|
|
// see class_track.h
|
2007-10-19 06:31:17 +00:00
|
|
|
SEARCH_RESULT TRACK::Visit( INSPECTOR* inspector, const void* testData,
|
|
|
|
const KICAD_T scanTypes[] )
|
2007-08-30 22:20:52 +00:00
|
|
|
{
|
2007-10-19 06:31:17 +00:00
|
|
|
KICAD_T stype = *scanTypes;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2009-05-21 12:45:21 +00:00
|
|
|
#if 0 && defined(DEBUG)
|
2007-10-19 06:31:17 +00:00
|
|
|
std::cout << GetClass().mb_str() << ' ';
|
2007-08-30 22:20:52 +00:00
|
|
|
#endif
|
2007-10-16 20:52:49 +00:00
|
|
|
|
2007-08-30 22:20:52 +00:00
|
|
|
// If caller wants to inspect my type
|
2007-09-01 12:00:30 +00:00
|
|
|
if( stype == Type() )
|
2007-08-30 22:20:52 +00:00
|
|
|
{
|
|
|
|
if( SEARCH_QUIT == inspector->Inspect( this, testData ) )
|
|
|
|
return SEARCH_QUIT;
|
|
|
|
}
|
|
|
|
|
2007-10-15 07:50:59 +00:00
|
|
|
return SEARCH_CONTINUE;
|
2007-08-30 22:20:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SEGVIA::IsOnLayer( int layer_number ) const
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-08 20:51:08 +00:00
|
|
|
int bottom_layer, top_layer;
|
2007-10-15 07:50:59 +00:00
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
ReturnLayerPair( &top_layer, &bottom_layer );
|
2007-10-15 07:50:59 +00:00
|
|
|
|
|
|
|
if( bottom_layer <= layer_number && layer_number <= top_layer )
|
2007-08-30 22:20:52 +00:00
|
|
|
return true;
|
2007-08-08 20:51:08 +00:00
|
|
|
else
|
2007-08-30 22:20:52 +00:00
|
|
|
return false;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-31 13:44:13 +00:00
|
|
|
int TRACK::ReturnMaskLayer() const
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
if( Type() == PCB_VIA_T )
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
2007-10-01 13:51:07 +00:00
|
|
|
int via_type = Shape();
|
2007-10-15 07:50:59 +00:00
|
|
|
|
2007-10-19 16:24:44 +00:00
|
|
|
if( via_type == VIA_THROUGH )
|
2007-08-08 20:51:08 +00:00
|
|
|
return ALL_CU_LAYERS;
|
|
|
|
|
2008-01-12 20:31:56 +00:00
|
|
|
// VIA_BLIND_BURIED or VIA_MICRVIA:
|
2007-10-15 07:50:59 +00:00
|
|
|
|
|
|
|
int bottom_layer, top_layer;
|
2007-10-01 13:51:07 +00:00
|
|
|
|
|
|
|
// ReturnLayerPair() knows how layers are stored
|
2007-10-19 06:31:17 +00:00
|
|
|
( (SEGVIA*) this )->ReturnLayerPair( &top_layer, &bottom_layer );
|
2007-10-15 07:50:59 +00:00
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
int layermask = 0;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
while( bottom_layer <= top_layer )
|
|
|
|
{
|
2011-12-06 08:35:13 +00:00
|
|
|
layermask |= GetLayerMask( bottom_layer++ );
|
2007-08-08 20:51:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return layermask;
|
|
|
|
}
|
|
|
|
else
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2011-12-06 08:35:13 +00:00
|
|
|
return GetLayerMask( m_Layer );
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
void SEGVIA::SetLayerPair( int top_layer, int bottom_layer )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-05-21 12:45:21 +00:00
|
|
|
if( Shape() == VIA_THROUGH )
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
2009-12-07 03:46:13 +00:00
|
|
|
top_layer = LAYER_N_FRONT;
|
|
|
|
bottom_layer = LAYER_N_BACK;
|
2007-08-08 20:51:08 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
if( bottom_layer > top_layer )
|
|
|
|
EXCHG( bottom_layer, top_layer );
|
2007-10-16 20:52:49 +00:00
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
m_Layer = (top_layer & 15) + ( (bottom_layer & 15) << 4 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
void SEGVIA::ReturnLayerPair( int* top_layer, int* bottom_layer ) const
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-12-07 03:46:13 +00:00
|
|
|
int b_layer = LAYER_N_BACK;
|
|
|
|
int t_layer = LAYER_N_FRONT;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2009-05-21 12:45:21 +00:00
|
|
|
if( Shape() != VIA_THROUGH )
|
|
|
|
{
|
|
|
|
b_layer = (m_Layer >> 4) & 15;
|
|
|
|
t_layer = m_Layer & 15;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-05-21 12:45:21 +00:00
|
|
|
if( b_layer > t_layer )
|
|
|
|
EXCHG( b_layer, t_layer );
|
|
|
|
}
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
if( top_layer )
|
|
|
|
*top_layer = t_layer;
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
if( bottom_layer )
|
|
|
|
*bottom_layer = b_layer;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-29 17:47:32 +00:00
|
|
|
TRACK* TRACK::GetBestInsertPoint( BOARD* aPcb )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-12-14 19:45:05 +00:00
|
|
|
TRACK* track;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
if( Type() == PCB_ZONE_T )
|
2010-12-29 17:47:32 +00:00
|
|
|
track = aPcb->m_Zone;
|
2007-08-08 20:51:08 +00:00
|
|
|
else
|
2010-12-29 17:47:32 +00:00
|
|
|
track = aPcb->m_Track;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2008-12-14 19:45:05 +00:00
|
|
|
for( ; track; track = track->Next() )
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
if( GetNet() <= track->GetNet() )
|
|
|
|
return track;
|
2007-08-08 20:51:08 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
return NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
TRACK* TRACK::GetStartNetCode( int NetCode )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-08 20:51:08 +00:00
|
|
|
TRACK* Track = this;
|
|
|
|
int ii = 0;
|
|
|
|
|
|
|
|
if( NetCode == -1 )
|
2007-10-13 06:18:44 +00:00
|
|
|
NetCode = GetNet();
|
2007-08-08 20:51:08 +00:00
|
|
|
|
|
|
|
while( Track != NULL )
|
|
|
|
{
|
2007-10-13 06:18:44 +00:00
|
|
|
if( Track->GetNet() > NetCode )
|
2007-08-08 20:51:08 +00:00
|
|
|
break;
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2007-10-13 06:18:44 +00:00
|
|
|
if( Track->GetNet() == NetCode )
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
2007-10-19 06:31:17 +00:00
|
|
|
ii++;
|
2007-10-13 06:18:44 +00:00
|
|
|
break;
|
2007-08-08 20:51:08 +00:00
|
|
|
}
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
Track = (TRACK*) Track->Pnext;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ii )
|
|
|
|
return Track;
|
|
|
|
else
|
|
|
|
return NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
TRACK* TRACK::GetEndNetCode( int NetCode )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-08 20:51:08 +00:00
|
|
|
TRACK* NextS, * Track = this;
|
|
|
|
int ii = 0;
|
|
|
|
|
|
|
|
if( Track == NULL )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if( NetCode == -1 )
|
2007-10-13 06:18:44 +00:00
|
|
|
NetCode = GetNet();
|
2007-08-08 20:51:08 +00:00
|
|
|
|
|
|
|
while( Track != NULL )
|
|
|
|
{
|
|
|
|
NextS = (TRACK*) Track->Pnext;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-10-13 06:18:44 +00:00
|
|
|
if( Track->GetNet() == NetCode )
|
2007-08-08 20:51:08 +00:00
|
|
|
ii++;
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
if( NextS == NULL )
|
|
|
|
break;
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2007-10-13 06:18:44 +00:00
|
|
|
if( NextS->GetNet() > NetCode )
|
2007-08-08 20:51:08 +00:00
|
|
|
break;
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
Track = NextS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ii )
|
|
|
|
return Track;
|
|
|
|
else
|
|
|
|
return NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint& aOffset )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
int l_trace;
|
2007-08-08 20:51:08 +00:00
|
|
|
int color;
|
2011-09-07 19:41:04 +00:00
|
|
|
int radius;
|
2007-08-08 20:51:08 +00:00
|
|
|
int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
if( Type() == PCB_ZONE_T && DisplayOpt.DisplayZonesMode != 0 )
|
2007-08-08 20:51:08 +00:00
|
|
|
return;
|
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
BOARD * brd = GetBoard( );
|
2010-10-16 14:51:22 +00:00
|
|
|
color = brd->GetLayerColor(m_Layer);
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
if( brd->IsLayerVisible( m_Layer ) == false && ( color & HIGHLIGHT_FLAG ) != HIGHLIGHT_FLAG )
|
2010-10-16 14:51:22 +00:00
|
|
|
return;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2010-10-16 14:51:22 +00:00
|
|
|
if( DisplayOpt.ContrastModeDisplay )
|
|
|
|
{
|
|
|
|
if( !IsOnLayer( curr_layer ) )
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
2010-10-16 14:51:22 +00:00
|
|
|
color &= ~MASKCOLOR;
|
|
|
|
color |= DARKDARKGRAY;
|
2007-08-08 20:51:08 +00:00
|
|
|
}
|
2010-10-16 14:51:22 +00:00
|
|
|
}
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2011-10-17 20:01:27 +00:00
|
|
|
if( draw_mode & GR_HIGHLIGHT )
|
2010-10-16 14:51:22 +00:00
|
|
|
{
|
|
|
|
if( draw_mode & GR_AND )
|
2010-12-08 20:12:46 +00:00
|
|
|
color &= ~HIGHLIGHT_FLAG;
|
2010-10-16 14:51:22 +00:00
|
|
|
else
|
2010-12-08 20:12:46 +00:00
|
|
|
color |= HIGHLIGHT_FLAG;
|
2010-10-16 14:51:22 +00:00
|
|
|
}
|
2008-04-02 14:16:14 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
if( color & HIGHLIGHT_FLAG )
|
2010-10-16 14:51:22 +00:00
|
|
|
color = ColorRefs[color & MASKCOLOR].m_LightColor;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2010-10-16 14:51:22 +00:00
|
|
|
SetAlpha( &color, 150 );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
|
|
|
GRSetDrawMode( DC, draw_mode );
|
2008-04-02 14:16:14 +00:00
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
l_trace = m_Width >> 1;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
|
|
|
if( m_Shape == S_CIRCLE )
|
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
radius = (int) hypot( (double) ( m_End.x - m_Start.x ),
|
|
|
|
(double) ( m_End.y - m_Start.y ) );
|
2010-02-08 18:15:42 +00:00
|
|
|
|
2011-09-24 18:33:28 +00:00
|
|
|
if( DC->LogicalToDeviceXRel( l_trace ) < MIN_DRAW_WIDTH )
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
2010-11-11 21:46:55 +00:00
|
|
|
GRCircle( &panel->m_ClipBox, DC, m_Start.x + aOffset.x,
|
2011-09-07 19:41:04 +00:00
|
|
|
m_Start.y + aOffset.y, radius, color );
|
2007-08-08 20:51:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-02-08 18:15:42 +00:00
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
if( DC->LogicalToDeviceXRel( l_trace ) <= 1 ) /* Sketch mode if l_trace/zoom <= 1 */
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
2010-11-11 21:46:55 +00:00
|
|
|
GRCircle( &panel->m_ClipBox, DC, m_Start.x + aOffset.x,
|
2011-09-07 19:41:04 +00:00
|
|
|
m_Start.y + aOffset.y, radius, color );
|
2007-08-08 20:51:08 +00:00
|
|
|
}
|
|
|
|
else if( ( !DisplayOpt.DisplayPcbTrackFill) || GetState( FORCE_SKETCH ) )
|
|
|
|
{
|
2010-11-11 21:46:55 +00:00
|
|
|
GRCircle( &panel->m_ClipBox, DC, m_Start.x + aOffset.x,
|
2011-09-07 19:41:04 +00:00
|
|
|
m_Start.y + aOffset.y, radius - l_trace, color );
|
2010-11-11 21:46:55 +00:00
|
|
|
GRCircle( &panel->m_ClipBox, DC, m_Start.x + aOffset.x,
|
2011-09-07 19:41:04 +00:00
|
|
|
m_Start.y + aOffset.y, radius + l_trace, color );
|
2007-08-08 20:51:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-11-11 21:46:55 +00:00
|
|
|
GRCircle( &panel->m_ClipBox, DC, m_Start.x + aOffset.x,
|
2011-09-07 19:41:04 +00:00
|
|
|
m_Start.y + aOffset.y, radius, m_Width, color );
|
2007-08-08 20:51:08 +00:00
|
|
|
}
|
|
|
|
}
|
2011-09-14 20:04:58 +00:00
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-09-24 18:33:28 +00:00
|
|
|
if( DC->LogicalToDeviceXRel( l_trace ) < MIN_DRAW_WIDTH )
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
2011-04-14 18:44:46 +00:00
|
|
|
GRLine( &panel->m_ClipBox, DC, m_Start + aOffset, m_End + aOffset, 0, color );
|
2007-08-08 20:51:08 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
if( !DisplayOpt.DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
2011-04-14 18:44:46 +00:00
|
|
|
GRCSegm( &panel->m_ClipBox, DC, m_Start + aOffset, m_End + aOffset, m_Width, color );
|
2007-08-08 20:51:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-11-11 21:46:55 +00:00
|
|
|
GRFillCSegm( &panel->m_ClipBox, DC, m_Start.x + aOffset.x,
|
|
|
|
m_Start.y + aOffset.y,
|
|
|
|
m_End.x + aOffset.x, m_End.y + aOffset.y, m_Width, color );
|
2007-08-08 20:51:08 +00:00
|
|
|
}
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( panel->GetScreen()->m_IsPrinting )
|
2009-01-15 14:32:29 +00:00
|
|
|
return;
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
// Show clearance for tracks, not for zone segments
|
2008-03-11 01:19:08 +00:00
|
|
|
if( ShowClearance( this ) )
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
2011-04-14 18:44:46 +00:00
|
|
|
GRCSegm( &panel->m_ClipBox, DC, m_Start + aOffset, m_End + aOffset,
|
2009-09-10 15:22:26 +00:00
|
|
|
m_Width + (GetClearance() * 2), color );
|
2007-08-08 20:51:08 +00:00
|
|
|
}
|
2008-12-16 19:44:57 +00:00
|
|
|
|
2008-12-19 20:40:08 +00:00
|
|
|
/* Display the short netname for tracks, not for zone segments.
|
2008-12-16 19:44:57 +00:00
|
|
|
* we must filter tracks, to avoid a lot of texts.
|
|
|
|
* - only horizontal or vertical tracks are eligible
|
|
|
|
* - only tracks with a length > 10 * thickness are eligible
|
2009-01-14 08:27:16 +00:00
|
|
|
* and, of course, if we are not printing the board
|
2008-12-16 19:44:57 +00:00
|
|
|
*/
|
2011-10-01 19:24:27 +00:00
|
|
|
if( Type() == PCB_ZONE_T )
|
2008-12-19 20:40:08 +00:00
|
|
|
return;
|
2008-12-16 19:44:57 +00:00
|
|
|
|
2009-05-21 12:45:21 +00:00
|
|
|
if( DisplayOpt.DisplayNetNamesMode == 0 || DisplayOpt.DisplayNetNamesMode == 1 )
|
2009-03-26 19:27:50 +00:00
|
|
|
return;
|
|
|
|
|
2008-12-16 19:44:57 +00:00
|
|
|
#define THRESHOLD 10
|
2011-09-07 19:41:04 +00:00
|
|
|
if( (m_End.x - m_Start.x) != 0 && (m_End.y - m_Start.y) != 0 )
|
2008-12-16 19:44:57 +00:00
|
|
|
return;
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
int len = ABS( (m_End.x - m_Start.x) + (m_End.y - m_Start.y) );
|
2008-12-16 19:44:57 +00:00
|
|
|
|
|
|
|
if( len < THRESHOLD * m_Width )
|
|
|
|
return;
|
|
|
|
|
2010-02-08 18:15:42 +00:00
|
|
|
if( DC->LogicalToDeviceXRel( m_Width ) < 6 ) // no room to display a text inside track
|
2008-12-19 20:40:08 +00:00
|
|
|
return;
|
|
|
|
|
2008-12-16 19:44:57 +00:00
|
|
|
if( GetNet() == 0 )
|
|
|
|
return;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-05-24 18:28:36 +00:00
|
|
|
NETINFO_ITEM* net = ( (BOARD*) GetParent() )->FindNet( GetNet() );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-12-16 19:44:57 +00:00
|
|
|
if( net == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
int textlen = net->GetShortNetname().Len();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-12-16 19:44:57 +00:00
|
|
|
if( textlen > 0 )
|
|
|
|
{
|
|
|
|
// calculate a good size for the text
|
2009-05-21 12:45:21 +00:00
|
|
|
int tsize = MIN( m_Width, len / textlen );
|
|
|
|
wxPoint tpos = m_Start + m_End;
|
2008-12-16 19:44:57 +00:00
|
|
|
tpos.x /= 2;
|
|
|
|
tpos.y /= 2;
|
|
|
|
|
|
|
|
// Calculate angle: if the track segment is vertical, angle = 90 degrees
|
|
|
|
int angle = 0;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-05-21 12:45:21 +00:00
|
|
|
if( (m_End.x - m_Start.x) == 0 ) // Vertical segment
|
|
|
|
angle = 900; // angle is in 0.1 degree
|
2010-02-08 18:15:42 +00:00
|
|
|
|
|
|
|
if( DC->LogicalToDeviceXRel( tsize ) >= 6 )
|
2008-12-16 19:44:57 +00:00
|
|
|
{
|
2009-10-10 17:27:53 +00:00
|
|
|
if( !(!IsOnLayer( curr_layer )&& DisplayOpt.ContrastModeDisplay) )
|
|
|
|
{
|
|
|
|
tsize = (tsize * 8) / 10; // small reduction to give a better look
|
|
|
|
DrawGraphicText( panel, DC, tpos,
|
|
|
|
WHITE, net->GetShortNetname(), angle, wxSize( tsize, tsize ),
|
|
|
|
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, tsize / 7,
|
|
|
|
false, false );
|
2009-09-10 15:22:26 +00:00
|
|
|
}
|
2008-12-16 19:44:57 +00:00
|
|
|
}
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode, const wxPoint& aOffset )
|
2008-11-24 06:53:43 +00:00
|
|
|
{
|
2009-10-27 10:55:46 +00:00
|
|
|
int color;
|
2011-09-07 19:41:04 +00:00
|
|
|
int radius;
|
2009-10-27 10:55:46 +00:00
|
|
|
int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
|
2009-10-10 17:27:53 +00:00
|
|
|
|
2009-10-27 10:55:46 +00:00
|
|
|
int fillvia = 0;
|
2011-03-01 19:26:17 +00:00
|
|
|
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) panel->GetParent();
|
|
|
|
PCB_SCREEN* screen = frame->GetScreen();
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2009-09-29 04:44:35 +00:00
|
|
|
if( frame->m_DisplayViaFill == FILLED )
|
|
|
|
fillvia = 1;
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
GRSetDrawMode( DC, draw_mode );
|
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
BOARD * brd = GetBoard( );
|
|
|
|
color = brd->GetVisibleElementColor(VIAS_VISIBLE + m_Shape);
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
if( brd->IsElementVisible( PCB_VISIBLE(VIAS_VISIBLE + m_Shape) ) == false
|
2010-12-08 20:12:46 +00:00
|
|
|
&& ( color & HIGHLIGHT_FLAG ) != HIGHLIGHT_FLAG )
|
2008-11-24 06:53:43 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if( DisplayOpt.ContrastModeDisplay )
|
|
|
|
{
|
|
|
|
if( !IsOnLayer( curr_layer ) )
|
|
|
|
{
|
|
|
|
color &= ~MASKCOLOR;
|
|
|
|
color |= DARKDARKGRAY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-17 20:01:27 +00:00
|
|
|
if( draw_mode & GR_HIGHLIGHT )
|
2008-11-24 06:53:43 +00:00
|
|
|
{
|
|
|
|
if( draw_mode & GR_AND )
|
2010-12-08 20:12:46 +00:00
|
|
|
color &= ~HIGHLIGHT_FLAG;
|
2008-11-24 06:53:43 +00:00
|
|
|
else
|
2010-12-08 20:12:46 +00:00
|
|
|
color |= HIGHLIGHT_FLAG;
|
2008-11-24 06:53:43 +00:00
|
|
|
}
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
if( color & HIGHLIGHT_FLAG )
|
2008-11-24 06:53:43 +00:00
|
|
|
color = ColorRefs[color & MASKCOLOR].m_LightColor;
|
|
|
|
|
|
|
|
SetAlpha( &color, 150 );
|
|
|
|
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
radius = m_Width >> 1;
|
|
|
|
// for small via size on screen (radius < 4 pixels) draw a simplified shape
|
2010-02-08 18:15:42 +00:00
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
int radius_in_pixels = DC->LogicalToDeviceXRel( radius );
|
2010-02-08 18:15:42 +00:00
|
|
|
|
2009-10-27 10:55:46 +00:00
|
|
|
bool fast_draw = false;
|
|
|
|
|
|
|
|
// Vias are drawn as a filled circle or a double circle. The hole will be drawn later
|
2011-09-07 19:41:04 +00:00
|
|
|
int drill_radius = GetDrillValue() / 2;
|
2010-02-08 18:15:42 +00:00
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
int inner_radius = radius - DC->DeviceToLogicalXRel( 2 );
|
2010-02-08 18:15:42 +00:00
|
|
|
|
2009-10-27 10:55:46 +00:00
|
|
|
if( radius_in_pixels < 3 )
|
2009-01-29 14:26:20 +00:00
|
|
|
{
|
2009-10-27 10:55:46 +00:00
|
|
|
fast_draw = true;
|
|
|
|
fillvia = false;
|
2009-01-29 14:26:20 +00:00
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2009-09-29 04:44:35 +00:00
|
|
|
if( fillvia )
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
|
|
|
GRFilledCircle( &panel->m_ClipBox, DC, m_Start + aOffset, radius, color );
|
|
|
|
}
|
2009-09-29 04:44:35 +00:00
|
|
|
else
|
2009-10-27 10:55:46 +00:00
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
GRCircle( &panel->m_ClipBox, DC, m_Start + aOffset,radius, 0, color );
|
2009-10-27 10:55:46 +00:00
|
|
|
if ( fast_draw )
|
|
|
|
return;
|
2011-09-07 19:41:04 +00:00
|
|
|
GRCircle( &panel->m_ClipBox, DC, m_Start + aOffset, inner_radius, 0, color );
|
2009-10-27 10:55:46 +00:00
|
|
|
}
|
2008-12-14 19:45:05 +00:00
|
|
|
|
|
|
|
// Draw the via hole if the display option allows it
|
|
|
|
if( DisplayOpt.m_DisplayViaMode != VIA_HOLE_NOT_SHOW )
|
|
|
|
{
|
2011-09-14 20:04:58 +00:00
|
|
|
// Display all drill holes requested or Display non default holes requested
|
|
|
|
if( (DisplayOpt.m_DisplayViaMode == ALL_VIA_HOLE_SHOW)
|
|
|
|
|| ( (drill_radius > 0 ) && !IsDrillDefault() ) )
|
2011-09-14 15:08:44 +00:00
|
|
|
{
|
2009-10-27 10:55:46 +00:00
|
|
|
if( fillvia )
|
2008-11-24 06:53:43 +00:00
|
|
|
{
|
2009-10-27 10:55:46 +00:00
|
|
|
bool blackpenstate = false;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-10-27 10:55:46 +00:00
|
|
|
if( screen->m_IsPrinting )
|
2009-09-29 04:44:35 +00:00
|
|
|
{
|
2009-10-27 10:55:46 +00:00
|
|
|
blackpenstate = GetGRForceBlackPenState();
|
|
|
|
GRForceBlackPen( false );
|
|
|
|
color = g_DrawBgColor;
|
2009-09-29 04:44:35 +00:00
|
|
|
}
|
|
|
|
else
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2009-10-27 10:55:46 +00:00
|
|
|
color = BLACK; // or DARKGRAY;
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
2009-10-27 10:55:46 +00:00
|
|
|
|
|
|
|
if( draw_mode != GR_XOR )
|
|
|
|
GRSetDrawMode( DC, GR_COPY );
|
|
|
|
else
|
|
|
|
GRSetDrawMode( DC, GR_XOR );
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
if( DC->LogicalToDeviceXRel( drill_radius ) > 1 ) // Draw hole if large enough.
|
2010-11-11 21:46:55 +00:00
|
|
|
GRFilledCircle( &panel->m_ClipBox, DC, m_Start.x + aOffset.x,
|
2011-09-07 19:41:04 +00:00
|
|
|
m_Start.y + aOffset.y, drill_radius, 0, color, color );
|
2009-10-27 10:55:46 +00:00
|
|
|
|
|
|
|
if( screen->m_IsPrinting )
|
|
|
|
GRForceBlackPen( blackpenstate );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
if( drill_radius < inner_radius ) // We can show the via hole
|
|
|
|
GRCircle( &panel->m_ClipBox, DC, m_Start + aOffset, drill_radius, 0, color );
|
2008-11-24 06:53:43 +00:00
|
|
|
}
|
|
|
|
}
|
2008-12-14 19:45:05 +00:00
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2009-06-18 20:51:01 +00:00
|
|
|
if( DisplayOpt.ShowTrackClearanceMode == SHOW_CLEARANCE_ALWAYS )
|
2011-09-07 19:41:04 +00:00
|
|
|
GRCircle( &panel->m_ClipBox, DC, m_Start + aOffset, radius + GetClearance(), 0, color );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2011-09-14 20:04:58 +00:00
|
|
|
// for Micro Vias, draw a partial cross : X on component layer, or + on copper layer
|
2008-12-14 19:45:05 +00:00
|
|
|
// (so we can see 2 superimposed microvias ):
|
|
|
|
if( Shape() == VIA_MICROVIA )
|
|
|
|
{
|
|
|
|
int ax, ay, bx, by;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2009-12-07 03:46:13 +00:00
|
|
|
if( IsOnLayer( LAYER_N_BACK ) )
|
2008-12-14 19:45:05 +00:00
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
ax = radius; ay = 0;
|
|
|
|
bx = drill_radius; by = 0;
|
2008-11-24 06:53:43 +00:00
|
|
|
}
|
2008-12-14 19:45:05 +00:00
|
|
|
else
|
2008-11-24 06:53:43 +00:00
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
ax = ay = (radius * 707) / 1000;
|
|
|
|
bx = by = (drill_radius * 707) / 1000;
|
2008-11-24 06:53:43 +00:00
|
|
|
}
|
2008-12-14 19:45:05 +00:00
|
|
|
|
|
|
|
/* lines | or \ */
|
2010-11-11 21:46:55 +00:00
|
|
|
GRLine( &panel->m_ClipBox, DC, m_Start.x + aOffset.x - ax,
|
|
|
|
m_Start.y + aOffset.y - ay,
|
|
|
|
m_Start.x + aOffset.x - bx,
|
|
|
|
m_Start.y + aOffset.y - by, 0, color );
|
|
|
|
GRLine( &panel->m_ClipBox, DC, m_Start.x + aOffset.x + bx,
|
|
|
|
m_Start.y + aOffset.y + by,
|
|
|
|
m_Start.x + aOffset.x + ax,
|
|
|
|
m_Start.y + aOffset.y + ay, 0, color );
|
2008-12-14 19:45:05 +00:00
|
|
|
|
|
|
|
/* lines - or / */
|
2010-11-11 21:46:55 +00:00
|
|
|
GRLine( &panel->m_ClipBox, DC, m_Start.x + aOffset.x + ay,
|
|
|
|
m_Start.y + aOffset.y - ax,
|
|
|
|
m_Start.x + aOffset.x + by,
|
|
|
|
m_Start.y + aOffset.y - bx, 0, color );
|
|
|
|
GRLine( &panel->m_ClipBox, DC, m_Start.x + aOffset.x - by,
|
|
|
|
m_Start.y + aOffset.y + bx,
|
|
|
|
m_Start.x + aOffset.x - ay,
|
|
|
|
m_Start.y + aOffset.y + ax, 0, color );
|
2008-11-24 06:53:43 +00:00
|
|
|
}
|
|
|
|
|
2011-09-14 20:04:58 +00:00
|
|
|
// for Buried Vias, draw a partial line : orient depending on layer pair
|
2008-12-14 19:45:05 +00:00
|
|
|
// (so we can see superimposed buried vias ):
|
|
|
|
if( Shape() == VIA_BLIND_BURIED )
|
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
int ax = 0, ay = radius, bx = 0, by = drill_radius;
|
2008-12-14 19:45:05 +00:00
|
|
|
int layer_top, layer_bottom;
|
|
|
|
|
|
|
|
( (SEGVIA*) this )->ReturnLayerPair( &layer_top, &layer_bottom );
|
|
|
|
|
|
|
|
/* lines for the top layer */
|
2010-01-31 20:01:46 +00:00
|
|
|
RotatePoint( &ax, &ay, layer_top * 3600 / brd->GetCopperLayerCount( ) );
|
|
|
|
RotatePoint( &bx, &by, layer_top * 3600 / brd->GetCopperLayerCount( ) );
|
2010-11-11 21:46:55 +00:00
|
|
|
GRLine( &panel->m_ClipBox, DC, m_Start.x + aOffset.x - ax,
|
|
|
|
m_Start.y + aOffset.y - ay,
|
|
|
|
m_Start.x + aOffset.x - bx,
|
|
|
|
m_Start.y + aOffset.y - by, 0, color );
|
2008-12-14 19:45:05 +00:00
|
|
|
|
|
|
|
/* lines for the bottom layer */
|
2011-09-07 19:41:04 +00:00
|
|
|
ax = 0; ay = radius; bx = 0; by = drill_radius;
|
2010-01-31 20:01:46 +00:00
|
|
|
RotatePoint( &ax, &ay, layer_bottom * 3600 / brd->GetCopperLayerCount( ) );
|
|
|
|
RotatePoint( &bx, &by, layer_bottom * 3600 / brd->GetCopperLayerCount( ) );
|
2010-11-11 21:46:55 +00:00
|
|
|
GRLine( &panel->m_ClipBox, DC, m_Start.x + aOffset.x - ax,
|
|
|
|
m_Start.y + aOffset.y - ay,
|
|
|
|
m_Start.x + aOffset.x - bx,
|
|
|
|
m_Start.y + aOffset.y - by, 0, color );
|
2008-12-14 19:45:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Display the short netname:
|
|
|
|
if( GetNet() == 0 )
|
|
|
|
return;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-05-21 12:45:21 +00:00
|
|
|
if( DisplayOpt.DisplayNetNamesMode == 0 || DisplayOpt.DisplayNetNamesMode == 1 )
|
2009-03-26 19:27:50 +00:00
|
|
|
return;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-05-24 18:28:36 +00:00
|
|
|
NETINFO_ITEM* net = ( (BOARD*) GetParent() )->FindNet( GetNet() );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-12-14 19:45:05 +00:00
|
|
|
if( net == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
int len = net->GetShortNetname().Len();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-12-16 19:44:57 +00:00
|
|
|
if( len > 0 )
|
2008-12-14 19:45:05 +00:00
|
|
|
{
|
2008-12-15 10:24:19 +00:00
|
|
|
// calculate a good size for the text
|
|
|
|
int tsize = m_Width / len;
|
2010-02-08 18:15:42 +00:00
|
|
|
|
|
|
|
if( DC->LogicalToDeviceXRel( tsize ) >= 6 )
|
2008-12-15 10:24:19 +00:00
|
|
|
{
|
2011-09-14 20:04:58 +00:00
|
|
|
tsize = (tsize * 8) / 10; // small reduction to give a better look, inside via
|
2008-12-15 10:24:19 +00:00
|
|
|
DrawGraphicText( panel, DC, m_Start,
|
2009-05-21 12:45:21 +00:00
|
|
|
WHITE, net->GetShortNetname(), 0, wxSize( tsize, tsize ),
|
2009-05-28 17:39:40 +00:00
|
|
|
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, tsize / 7,
|
2009-10-10 17:27:53 +00:00
|
|
|
false, false );
|
2008-12-15 10:24:19 +00:00
|
|
|
}
|
2008-12-14 19:45:05 +00:00
|
|
|
}
|
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
|
|
|
2011-09-14 15:08:44 +00:00
|
|
|
// see class_track.h
|
2011-01-21 19:30:59 +00:00
|
|
|
void TRACK::DisplayInfo( EDA_DRAW_FRAME* frame )
|
2009-10-14 18:14:58 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
2011-03-01 19:26:17 +00:00
|
|
|
BOARD* board = ( (PCB_BASE_FRAME*) frame )->GetBoard();
|
2009-10-16 17:18:23 +00:00
|
|
|
|
2009-10-14 18:14:58 +00:00
|
|
|
// Display basic infos
|
2009-10-16 17:18:23 +00:00
|
|
|
DisplayInfoBase( frame );
|
2009-10-14 18:14:58 +00:00
|
|
|
|
2011-09-30 18:15:37 +00:00
|
|
|
// Display full track length (in Pcbnew)
|
2011-10-13 19:56:32 +00:00
|
|
|
if( frame->IsType( PCB_FRAME ) )
|
2009-10-14 18:14:58 +00:00
|
|
|
{
|
2009-10-27 10:55:46 +00:00
|
|
|
int trackLen = 0;
|
2011-08-20 14:46:48 +00:00
|
|
|
int lenDie = 0;
|
2011-09-16 15:54:50 +00:00
|
|
|
board->MarkTrace( this, NULL, &trackLen, &lenDie, false );
|
2011-03-11 15:53:28 +00:00
|
|
|
msg = frame->CoordinateToString( trackLen );
|
2011-08-20 14:46:48 +00:00
|
|
|
frame->AppendMsgPanel( _( "Track Len" ), msg, DARKCYAN );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-08-20 14:46:48 +00:00
|
|
|
if( lenDie != 0 )
|
|
|
|
{
|
|
|
|
msg = frame->CoordinateToString( trackLen + lenDie );
|
|
|
|
frame->AppendMsgPanel( _( "Full Len" ), msg, DARKCYAN );
|
|
|
|
|
|
|
|
msg = frame->CoordinateToString( lenDie );
|
|
|
|
frame->AppendMsgPanel( _( "On Die" ), msg, DARKCYAN );
|
|
|
|
}
|
2009-10-14 18:14:58 +00:00
|
|
|
}
|
2011-03-11 15:53:28 +00:00
|
|
|
|
|
|
|
NETCLASS* netclass = GetNetClass();
|
|
|
|
|
|
|
|
if( netclass )
|
|
|
|
{
|
|
|
|
frame->AppendMsgPanel( _( "NC Name" ), netclass->GetName(), DARKMAGENTA );
|
|
|
|
frame->AppendMsgPanel( _( "NC Clearance" ),
|
|
|
|
frame->CoordinateToString( netclass->GetClearance(), true ),
|
|
|
|
DARKMAGENTA );
|
|
|
|
frame->AppendMsgPanel( _( "NC Width" ),
|
|
|
|
frame->CoordinateToString( netclass->GetTrackWidth(), true ),
|
|
|
|
DARKMAGENTA );
|
|
|
|
frame->AppendMsgPanel( _( "NC Via Size"),
|
|
|
|
frame->CoordinateToString( netclass->GetViaDiameter(), true ),
|
|
|
|
DARKMAGENTA );
|
|
|
|
frame->AppendMsgPanel( _( "NC Via Drill"),
|
|
|
|
frame->CoordinateToString( netclass->GetViaDrill(), true ),
|
|
|
|
DARKMAGENTA );
|
|
|
|
}
|
2009-10-14 18:14:58 +00:00
|
|
|
}
|
|
|
|
|
2009-10-27 10:55:46 +00:00
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void TRACK::DisplayInfoBase( EDA_DRAW_FRAME* frame )
|
2007-08-20 19:33:15 +00:00
|
|
|
{
|
2008-12-14 19:45:05 +00:00
|
|
|
wxString msg;
|
2011-03-01 19:26:17 +00:00
|
|
|
BOARD* board = ( (PCB_BASE_FRAME*) frame )->GetBoard();
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2009-10-16 17:18:23 +00:00
|
|
|
frame->ClearMsgPanel();
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( Type() )
|
2007-08-20 19:33:15 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_VIA_T:
|
2011-12-06 08:35:13 +00:00
|
|
|
switch( Shape() )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case 0:
|
|
|
|
msg = _( "??? Via" ); // Not used yet, does not exist currently
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
msg = _( "Micro Via" ); // from external layer (TOP or BOTTOM) from
|
|
|
|
// the near neighbor inner layer only
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
msg = _( "Blind/Buried Via" ); // from inner or external to inner
|
|
|
|
// or external layer (no restriction)
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
msg = _( "Through Via" ); // Usual via (from TOP to BOTTOM layer only )
|
|
|
|
break;
|
|
|
|
}
|
2007-08-20 19:33:15 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TRACE_T:
|
2007-08-20 19:33:15 +00:00
|
|
|
msg = _( "Track" );
|
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_ZONE_T:
|
|
|
|
msg = _( "Zone" );
|
|
|
|
break;
|
2007-08-20 19:33:15 +00:00
|
|
|
|
|
|
|
default:
|
2011-10-01 19:24:27 +00:00
|
|
|
msg = wxT( "????" );
|
|
|
|
break;
|
2007-08-20 19:33:15 +00:00
|
|
|
}
|
|
|
|
|
2009-10-16 17:18:23 +00:00
|
|
|
frame->AppendMsgPanel( _( "Type" ), msg, DARKCYAN );
|
2008-02-19 00:30:10 +00:00
|
|
|
|
2011-09-30 18:15:37 +00:00
|
|
|
// Display Net Name (in Pcbnew)
|
2011-10-13 19:56:32 +00:00
|
|
|
if( frame->IsType( PCB_FRAME ) )
|
2007-08-20 19:33:15 +00:00
|
|
|
{
|
2009-05-28 08:42:24 +00:00
|
|
|
NETINFO_ITEM* net = board->FindNet( GetNet() );
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2009-05-28 08:42:24 +00:00
|
|
|
if( net )
|
|
|
|
msg = net->GetNetname();
|
2007-08-20 19:33:15 +00:00
|
|
|
else
|
|
|
|
msg = wxT( "<noname>" );
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2009-10-16 17:18:23 +00:00
|
|
|
frame->AppendMsgPanel( _( "NetName" ), msg, RED );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2011-09-14 20:04:58 +00:00
|
|
|
/* Display net code : (useful in test or debug) */
|
2007-10-13 06:18:44 +00:00
|
|
|
msg.Printf( wxT( "%d .%d" ), GetNet(), GetSubNet() );
|
2009-10-16 17:18:23 +00:00
|
|
|
frame->AppendMsgPanel( _( "NetCode" ), msg, RED );
|
2007-08-20 19:33:15 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
#if defined(DEBUG)
|
|
|
|
|
2011-09-22 19:16:55 +00:00
|
|
|
// Display the flags
|
2008-12-14 19:45:05 +00:00
|
|
|
msg.Printf( wxT( "0x%08X" ), m_Flags );
|
2011-09-22 19:16:55 +00:00
|
|
|
frame->AppendMsgPanel( wxT( "Flags" ), msg, BLUE );
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
// Display start and end pointers:
|
|
|
|
msg.Printf( wxT( "%p" ), start );
|
|
|
|
frame->AppendMsgPanel( wxT( "start ptr" ), msg, BLUE );
|
|
|
|
msg.Printf( wxT( "%p" ), end );
|
|
|
|
frame->AppendMsgPanel( wxT( "end ptr" ), msg, BLUE );
|
|
|
|
// Display this ptr
|
|
|
|
msg.Printf( wxT( "%p" ), this );
|
|
|
|
frame->AppendMsgPanel( wxT( "this" ), msg, BLUE );
|
|
|
|
#endif
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2011-09-22 19:16:55 +00:00
|
|
|
#if 0
|
|
|
|
// Display start and end positions:
|
|
|
|
msg.Printf( wxT( "%d %d" ), m_Start.x, m_Start.y );
|
|
|
|
frame->AppendMsgPanel( wxT( "Start pos" ), msg, BLUE );
|
|
|
|
msg.Printf( wxT( "%d %d" ), m_End.x, m_End.y );
|
|
|
|
frame->AppendMsgPanel( wxT( "End pos" ), msg, BLUE );
|
2008-12-04 04:28:11 +00:00
|
|
|
#endif
|
|
|
|
|
2011-09-22 19:16:55 +00:00
|
|
|
#endif // defined(DEBUG)
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
/* Display the State member */
|
2007-08-20 19:33:15 +00:00
|
|
|
msg = wxT( ". . " );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-02-13 17:53:48 +00:00
|
|
|
if( GetState( TRACK_LOCKED ) )
|
2007-08-20 19:33:15 +00:00
|
|
|
msg[0] = 'F';
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2011-02-13 17:53:48 +00:00
|
|
|
if( GetState( TRACK_AR ) )
|
2007-08-20 19:33:15 +00:00
|
|
|
msg[2] = 'A';
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2009-10-16 17:18:23 +00:00
|
|
|
frame->AppendMsgPanel( _( "Status" ), msg, MAGENTA );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2007-10-19 06:31:17 +00:00
|
|
|
/* Display layer or layer pair) */
|
2011-10-01 19:24:27 +00:00
|
|
|
if( Type() == PCB_VIA_T )
|
2007-08-20 19:33:15 +00:00
|
|
|
{
|
|
|
|
SEGVIA* Via = (SEGVIA*) this;
|
|
|
|
int top_layer, bottom_layer;
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2007-08-20 19:33:15 +00:00
|
|
|
Via->ReturnLayerPair( &top_layer, &bottom_layer );
|
2011-09-07 19:41:04 +00:00
|
|
|
msg = board->GetLayerName( top_layer ) + wxT( "/" ) + board->GetLayerName( bottom_layer );
|
2007-08-20 19:33:15 +00:00
|
|
|
}
|
|
|
|
else
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2008-02-19 00:30:10 +00:00
|
|
|
msg = board->GetLayerName( m_Layer );
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2009-10-16 17:18:23 +00:00
|
|
|
frame->AppendMsgPanel( _( "Layer" ), msg, BROWN );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2007-10-19 06:31:17 +00:00
|
|
|
/* Display width */
|
2011-03-11 15:53:28 +00:00
|
|
|
msg = frame->CoordinateToString( (unsigned) m_Width );
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
if( Type() == PCB_VIA_T ) // Display Diam and Drill values
|
2007-08-20 19:33:15 +00:00
|
|
|
{
|
2009-05-21 12:45:21 +00:00
|
|
|
// Display diameter value:
|
2009-10-16 17:18:23 +00:00
|
|
|
frame->AppendMsgPanel( _( "Diam" ), msg, DARKCYAN );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2009-05-21 12:45:21 +00:00
|
|
|
// Display drill value
|
2008-01-12 20:31:56 +00:00
|
|
|
int drill_value = GetDrillValue();
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2011-03-11 15:53:28 +00:00
|
|
|
msg = frame->CoordinateToString( (unsigned) drill_value );
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2007-08-20 19:33:15 +00:00
|
|
|
wxString title = _( "Drill" );
|
2009-10-10 17:27:53 +00:00
|
|
|
title += wxT( " " );
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2009-05-21 12:45:21 +00:00
|
|
|
if( m_Drill >= 0 )
|
|
|
|
title += _( "(Specific)" );
|
|
|
|
else
|
|
|
|
title += _( "(Default)" );
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2009-10-16 17:18:23 +00:00
|
|
|
frame->AppendMsgPanel( title, msg, RED );
|
2007-08-20 19:33:15 +00:00
|
|
|
}
|
|
|
|
else
|
2009-10-10 17:27:53 +00:00
|
|
|
{
|
2009-10-16 17:18:23 +00:00
|
|
|
frame->AppendMsgPanel( _( "Width" ), msg, DARKCYAN );
|
2009-10-10 17:27:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Display segment length
|
2011-10-01 19:24:27 +00:00
|
|
|
if( Type() != PCB_VIA_T ) // Display Diam and Drill values
|
2009-10-10 17:27:53 +00:00
|
|
|
{
|
2011-03-11 15:53:28 +00:00
|
|
|
msg = frame->CoordinateToString( wxRound( GetLength() ) );
|
2009-10-16 17:18:23 +00:00
|
|
|
frame->AppendMsgPanel( _( "Segment Length" ), msg, DARKCYAN );
|
2009-10-10 17:27:53 +00:00
|
|
|
}
|
2007-08-20 19:33:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-29 17:47:32 +00:00
|
|
|
bool TRACK::HitTest( const wxPoint& refPos )
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
2008-03-05 22:39:33 +00:00
|
|
|
int radius = m_Width >> 1;
|
|
|
|
|
|
|
|
// (dx, dy) is a vector from m_Start to m_End (an origin of m_Start)
|
|
|
|
int dx = m_End.x - m_Start.x;
|
|
|
|
int dy = m_End.y - m_Start.y;
|
|
|
|
|
|
|
|
// (spot_cX, spot_cY) is a vector from m_Start to ref_pos (an origin of m_Start)
|
2010-12-29 17:47:32 +00:00
|
|
|
int spot_cX = refPos.x - m_Start.x;
|
|
|
|
int spot_cY = refPos.y - m_Start.y;
|
2008-03-05 22:39:33 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
if( Type() == PCB_VIA_T )
|
2008-03-05 22:39:33 +00:00
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
return (double) spot_cX * spot_cX + (double) spot_cY * spot_cY <= (double) radius * radius;
|
2008-03-05 22:39:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( DistanceTest( radius, dx, dy, spot_cX, spot_cY ) )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-10-19 06:31:17 +00:00
|
|
|
return false;
|
|
|
|
}
|
2007-08-09 01:41:30 +00:00
|
|
|
|
2008-12-14 19:45:05 +00:00
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
bool TRACK::HitTest( EDA_RECT& refArea )
|
2008-01-06 12:43:57 +00:00
|
|
|
{
|
2010-12-20 17:44:25 +00:00
|
|
|
if( refArea.Contains( m_Start ) )
|
2008-02-09 08:34:45 +00:00
|
|
|
return true;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-12-20 17:44:25 +00:00
|
|
|
if( refArea.Contains( m_End ) )
|
2008-02-09 08:34:45 +00:00
|
|
|
return true;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-02-09 08:34:45 +00:00
|
|
|
return false;
|
2008-01-06 12:43:57 +00:00
|
|
|
}
|
|
|
|
|
2007-10-17 14:35:59 +00:00
|
|
|
|
2011-09-14 20:04:58 +00:00
|
|
|
TRACK* TRACK::GetVia( const wxPoint& aPosition, int aLayerMask )
|
|
|
|
{
|
|
|
|
TRACK* track;
|
|
|
|
|
|
|
|
for( track = this; track; track = track->Next() )
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
if( track->Type() != PCB_VIA_T )
|
2011-09-14 20:04:58 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if( !track->HitTest( aPosition ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( track->GetState( BUSY | IS_DELETED ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( aLayerMask < 0 )
|
|
|
|
break;
|
|
|
|
|
|
|
|
if( track->IsOnLayer( aLayerMask ) )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return track;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TRACK* TRACK::GetVia( TRACK* aEndTrace, const wxPoint& aPosition, int aLayerMask )
|
|
|
|
{
|
|
|
|
TRACK* trace;
|
|
|
|
|
|
|
|
for( trace = this; trace != NULL; trace = trace->Next() )
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
if( trace->Type() == PCB_VIA_T )
|
2011-09-14 20:04:58 +00:00
|
|
|
{
|
|
|
|
if( aPosition == trace->m_Start )
|
|
|
|
{
|
|
|
|
if( trace->GetState( BUSY | IS_DELETED ) == 0 )
|
|
|
|
{
|
|
|
|
if( aLayerMask & trace->ReturnMaskLayer() )
|
|
|
|
return trace;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( trace == aEndTrace )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-16 14:13:02 +00:00
|
|
|
TRACK* TRACK::GetTrace( TRACK* aStartTrace, TRACK* aEndTrace, int aEndPoint )
|
|
|
|
{
|
|
|
|
const int NEIGHTBOUR_COUNT_MAX = 50;
|
|
|
|
|
|
|
|
TRACK* previousSegment;
|
|
|
|
TRACK* nextSegment;
|
|
|
|
int Reflayer;
|
|
|
|
wxPoint position;
|
|
|
|
int ii;
|
|
|
|
int max_dist;
|
|
|
|
|
|
|
|
if( aEndPoint == START )
|
|
|
|
position = m_Start;
|
|
|
|
else
|
|
|
|
position = m_End;
|
|
|
|
|
|
|
|
Reflayer = ReturnMaskLayer();
|
|
|
|
|
|
|
|
previousSegment = nextSegment = this;
|
|
|
|
|
2011-09-22 19:16:55 +00:00
|
|
|
// Local search:
|
2011-09-16 14:13:02 +00:00
|
|
|
for( ii = 0; ii < NEIGHTBOUR_COUNT_MAX; ii++ )
|
|
|
|
{
|
|
|
|
if( (nextSegment == NULL) && (previousSegment == NULL) )
|
|
|
|
break;
|
|
|
|
|
|
|
|
if( nextSegment )
|
|
|
|
{
|
|
|
|
if( nextSegment->GetState( BUSY | IS_DELETED ) )
|
|
|
|
goto suite;
|
|
|
|
|
|
|
|
if( nextSegment == this )
|
|
|
|
goto suite;
|
|
|
|
|
|
|
|
/* max_dist is the max distance between 2 track ends which
|
|
|
|
* ensure a copper continuity */
|
|
|
|
max_dist = ( nextSegment->m_Width + this->m_Width ) / 2;
|
|
|
|
|
|
|
|
if( IsNear( position, nextSegment->m_Start, max_dist ) )
|
|
|
|
{
|
|
|
|
if( Reflayer & nextSegment->ReturnMaskLayer() )
|
|
|
|
return nextSegment;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( IsNear( position, nextSegment->m_End, max_dist ) )
|
|
|
|
{
|
|
|
|
if( Reflayer & nextSegment->ReturnMaskLayer() )
|
|
|
|
return nextSegment;
|
|
|
|
}
|
|
|
|
suite:
|
|
|
|
if( nextSegment == aEndTrace )
|
|
|
|
nextSegment = NULL;
|
|
|
|
else
|
|
|
|
nextSegment = nextSegment->Next();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( previousSegment )
|
|
|
|
{
|
|
|
|
if( previousSegment->GetState( BUSY | IS_DELETED ) )
|
|
|
|
goto suite1;
|
|
|
|
|
|
|
|
if( previousSegment == this )
|
|
|
|
goto suite1;
|
|
|
|
|
|
|
|
max_dist = ( previousSegment->m_Width + m_Width ) / 2;
|
|
|
|
|
|
|
|
if( IsNear( position, previousSegment->m_Start, max_dist ) )
|
|
|
|
{
|
|
|
|
if( Reflayer & previousSegment->ReturnMaskLayer() )
|
|
|
|
return previousSegment;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( IsNear( position, previousSegment->m_End, max_dist ) )
|
|
|
|
{
|
|
|
|
if( Reflayer & previousSegment->ReturnMaskLayer() )
|
|
|
|
return previousSegment;
|
|
|
|
}
|
|
|
|
suite1:
|
|
|
|
if( previousSegment == aStartTrace )
|
|
|
|
previousSegment = NULL;
|
2011-10-01 19:24:27 +00:00
|
|
|
else if( previousSegment->Type() != PCB_T )
|
2011-09-16 14:13:02 +00:00
|
|
|
previousSegment = previousSegment->Back();
|
|
|
|
else
|
|
|
|
previousSegment = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* General search. */
|
|
|
|
for( nextSegment = aStartTrace; nextSegment != NULL; nextSegment = nextSegment->Next() )
|
|
|
|
{
|
|
|
|
if( nextSegment->GetState( IS_DELETED | BUSY ) )
|
|
|
|
{
|
|
|
|
if( nextSegment == aEndTrace )
|
|
|
|
break;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( nextSegment == this )
|
|
|
|
{
|
|
|
|
if( nextSegment == aEndTrace )
|
|
|
|
break;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
max_dist = ( nextSegment->m_Width + m_Width ) / 2;
|
|
|
|
|
|
|
|
if( IsNear( position, nextSegment->m_Start, max_dist ) )
|
|
|
|
{
|
|
|
|
if( Reflayer & nextSegment->ReturnMaskLayer() )
|
|
|
|
return nextSegment;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( IsNear( position, nextSegment->m_End, max_dist ) )
|
|
|
|
{
|
|
|
|
if( Reflayer & nextSegment->ReturnMaskLayer() )
|
|
|
|
return nextSegment;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( nextSegment == aEndTrace )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int TRACK::GetEndSegments( int aCount, TRACK** aStartTrace, TRACK** aEndTrace )
|
|
|
|
{
|
|
|
|
TRACK* Track, * via, * segm, * TrackListEnd;
|
|
|
|
int NbEnds, layerMask, ii, ok = 0;
|
|
|
|
|
|
|
|
if( aCount <= 1 )
|
|
|
|
{
|
|
|
|
*aStartTrace = *aEndTrace = this;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Calculation of the limit analysis. */
|
|
|
|
*aStartTrace = *aEndTrace = NULL;
|
|
|
|
TrackListEnd = Track = this;
|
|
|
|
ii = 0;
|
|
|
|
|
|
|
|
for( ; ( Track != NULL ) && ( ii < aCount ); ii++, Track = Track->Next() )
|
|
|
|
{
|
|
|
|
TrackListEnd = Track;
|
|
|
|
Track->m_Param = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Calculate the extremes. */
|
|
|
|
NbEnds = 0;
|
|
|
|
Track = this;
|
|
|
|
ii = 0;
|
|
|
|
|
|
|
|
for( ; ( Track != NULL ) && ( ii < aCount ); ii++, Track = Track->Next() )
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
if( Track->Type() == PCB_VIA_T )
|
2011-09-16 14:13:02 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
layerMask = Track->ReturnMaskLayer();
|
|
|
|
via = GetVia( TrackListEnd, Track->m_Start, layerMask );
|
|
|
|
|
|
|
|
if( via )
|
|
|
|
{
|
|
|
|
layerMask |= via->ReturnMaskLayer();
|
|
|
|
via->SetState( BUSY, ON );
|
|
|
|
}
|
|
|
|
|
|
|
|
Track->SetState( BUSY, ON );
|
|
|
|
segm = ::GetTrace( this, TrackListEnd, Track->m_Start, layerMask );
|
|
|
|
Track->SetState( BUSY, OFF );
|
|
|
|
|
|
|
|
if( via )
|
|
|
|
via->SetState( BUSY, OFF );
|
|
|
|
|
|
|
|
if( segm == NULL )
|
|
|
|
{
|
|
|
|
switch( NbEnds )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
*aStartTrace = Track; NbEnds++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
int BeginPad, EndPad;
|
|
|
|
*aEndTrace = Track;
|
|
|
|
|
|
|
|
/* Swap ox, oy with fx, fy */
|
|
|
|
BeginPad = Track->GetState( BEGIN_ONPAD );
|
|
|
|
EndPad = Track->GetState( END_ONPAD );
|
|
|
|
|
|
|
|
Track->SetState( BEGIN_ONPAD | END_ONPAD, OFF );
|
|
|
|
|
|
|
|
if( BeginPad )
|
|
|
|
Track->SetState( END_ONPAD, ON );
|
|
|
|
|
|
|
|
if( EndPad )
|
|
|
|
Track->SetState( BEGIN_ONPAD, ON );
|
|
|
|
|
|
|
|
EXCHG( Track->m_Start, Track->m_End );
|
|
|
|
EXCHG( Track->start, Track->end );
|
|
|
|
ok = 1;
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
layerMask = Track->ReturnMaskLayer();
|
|
|
|
via = GetVia( TrackListEnd, Track->m_End, layerMask );
|
|
|
|
|
|
|
|
if( via )
|
|
|
|
{
|
|
|
|
layerMask |= via->ReturnMaskLayer();
|
|
|
|
via->SetState( BUSY, ON );
|
|
|
|
}
|
|
|
|
|
|
|
|
Track->SetState( BUSY, ON );
|
|
|
|
segm = ::GetTrace( this, TrackListEnd, Track->m_End, layerMask );
|
|
|
|
Track->SetState( BUSY, OFF );
|
|
|
|
|
|
|
|
if( via )
|
|
|
|
via->SetState( BUSY, OFF );
|
|
|
|
|
|
|
|
if( segm == NULL )
|
|
|
|
{
|
|
|
|
switch( NbEnds )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
int BeginPad, EndPad;
|
|
|
|
*aStartTrace = Track;
|
|
|
|
NbEnds++;
|
|
|
|
|
|
|
|
/* Swap ox, oy with fx, fy */
|
|
|
|
BeginPad = Track->GetState( BEGIN_ONPAD );
|
|
|
|
EndPad = Track->GetState( END_ONPAD );
|
|
|
|
|
|
|
|
Track->SetState( BEGIN_ONPAD | END_ONPAD, OFF );
|
|
|
|
|
|
|
|
if( BeginPad )
|
|
|
|
Track->SetState( END_ONPAD, ON );
|
|
|
|
|
|
|
|
if( EndPad )
|
|
|
|
Track->SetState( BEGIN_ONPAD, ON );
|
|
|
|
|
|
|
|
EXCHG( Track->m_Start, Track->m_End );
|
|
|
|
EXCHG( Track->start, Track->end );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
*aEndTrace = Track;
|
|
|
|
ok = 1;
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-14 15:42:44 +00:00
|
|
|
wxString TRACK::GetSelectMenuText() const
|
|
|
|
{
|
|
|
|
wxString text;
|
|
|
|
wxString temp;
|
|
|
|
NETINFO_ITEM* net;
|
|
|
|
BOARD* board = GetBoard();
|
|
|
|
|
|
|
|
// deleting tracks requires all the information we can get to
|
|
|
|
// disambiguate all the choices under the cursor!
|
|
|
|
text << _( "Track" ) << wxT( " " ) << ShowWidth();
|
|
|
|
|
|
|
|
if( board )
|
|
|
|
{
|
|
|
|
net = board->FindNet( GetNet() );
|
|
|
|
|
|
|
|
if( net )
|
|
|
|
text << wxT( " [" ) << net->GetNetname() << wxT( "]" );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-07-20 05:57:06 +00:00
|
|
|
text << _( "** BOARD NOT DEFINED **" );
|
2011-07-14 15:42:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
text << _( " on " ) << GetLayerName() << wxT(" ") << _("Net:") << GetNet()
|
|
|
|
<< wxT(" ") << _("Length:") << valeur_param( GetLength(), temp );
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-21 12:45:21 +00:00
|
|
|
#if defined(DEBUG)
|
2007-10-01 04:14:29 +00:00
|
|
|
|
2007-08-09 01:41:30 +00:00
|
|
|
void TRACK::Show( int nestLevel, std::ostream& os )
|
|
|
|
{
|
|
|
|
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() <<
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2007-10-01 04:14:29 +00:00
|
|
|
// " shape=\"" << m_Shape << '"' <<
|
2008-12-04 04:28:11 +00:00
|
|
|
" addr=\"" << std::hex << this << std::dec << '"' <<
|
2007-10-19 06:31:17 +00:00
|
|
|
" layer=\"" << m_Layer << '"' <<
|
|
|
|
" width=\"" << m_Width << '"' <<
|
2008-12-04 04:28:11 +00:00
|
|
|
" flags=\"" << m_Flags << '"' <<
|
2008-12-14 19:45:05 +00:00
|
|
|
" status=\"" << GetState( -1 ) << '"' <<
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2008-01-12 20:31:56 +00:00
|
|
|
// " drill=\"" << GetDrillValue() << '"' <<
|
2007-10-19 06:31:17 +00:00
|
|
|
" netcode=\"" << GetNet() << "\">" <<
|
|
|
|
"<start" << m_Start << "/>" <<
|
|
|
|
"<end" << m_End << "/>";
|
|
|
|
|
|
|
|
os << "</" << GetClass().Lower().mb_str() << ">\n";
|
2007-08-09 01:41:30 +00:00
|
|
|
}
|
|
|
|
|
2007-10-01 04:14:29 +00:00
|
|
|
|
|
|
|
void SEGVIA::Show( int nestLevel, std::ostream& os )
|
|
|
|
{
|
|
|
|
const char* cp;
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2007-10-01 04:14:29 +00:00
|
|
|
switch( Shape() )
|
|
|
|
{
|
2007-10-19 16:24:44 +00:00
|
|
|
case VIA_THROUGH:
|
2007-10-15 07:50:59 +00:00
|
|
|
cp = "through";
|
|
|
|
break;
|
|
|
|
|
2008-01-12 20:31:56 +00:00
|
|
|
case VIA_BLIND_BURIED:
|
|
|
|
cp = "blind/buried";
|
2007-10-15 07:50:59 +00:00
|
|
|
break;
|
|
|
|
|
2008-01-12 20:31:56 +00:00
|
|
|
case VIA_MICROVIA:
|
|
|
|
cp = "micro via";
|
2007-10-15 07:50:59 +00:00
|
|
|
break;
|
|
|
|
|
2007-10-01 04:14:29 +00:00
|
|
|
default:
|
2007-10-15 07:50:59 +00:00
|
|
|
case VIA_NOT_DEFINED:
|
|
|
|
cp = "undefined";
|
|
|
|
break;
|
2007-10-01 04:14:29 +00:00
|
|
|
}
|
|
|
|
|
2008-12-14 19:45:05 +00:00
|
|
|
int topLayer;
|
|
|
|
int botLayer;
|
|
|
|
BOARD* board = (BOARD*) m_Parent;
|
2008-02-19 00:30:10 +00:00
|
|
|
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2007-10-01 04:14:29 +00:00
|
|
|
ReturnLayerPair( &topLayer, &botLayer );
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2007-10-01 04:14:29 +00:00
|
|
|
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() <<
|
2008-02-19 00:30:10 +00:00
|
|
|
" type=\"" << cp << '"';
|
|
|
|
|
|
|
|
if( board )
|
|
|
|
os << " layers=\"" << board->GetLayerName( topLayer ).Trim().mb_str() << ","
|
2008-12-14 19:45:05 +00:00
|
|
|
<< board->GetLayerName( botLayer ).Trim().mb_str() << '"';
|
2011-09-07 19:41:04 +00:00
|
|
|
|
|
|
|
os << " width=\"" << m_Width << '"'
|
|
|
|
<< " drill=\"" << GetDrillValue() << '"'
|
|
|
|
<< " netcode=\"" << GetNet() << "\">"
|
|
|
|
<< "<pos" << m_Start << "/>";
|
2007-10-19 06:31:17 +00:00
|
|
|
|
|
|
|
os << "</" << GetClass().Lower().mb_str() << ">\n";
|
2007-10-01 04:14:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
wxString TRACK::ShowState( int stateBits )
|
|
|
|
{
|
|
|
|
wxString ret;
|
|
|
|
|
2011-02-13 17:53:48 +00:00
|
|
|
if( stateBits & IS_LINKED )
|
|
|
|
ret << wxT( " | IS_LINKED" );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-02-13 17:53:48 +00:00
|
|
|
if( stateBits & TRACK_AR )
|
|
|
|
ret << wxT( " | TRACK_AR" );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-02-13 17:53:48 +00:00
|
|
|
if( stateBits & TRACK_LOCKED )
|
|
|
|
ret << wxT( " | TRACK_LOCKED" );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-02-13 17:53:48 +00:00
|
|
|
if( stateBits & IN_EDIT )
|
|
|
|
ret << wxT( " | IN_EDIT" );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-02-13 17:53:48 +00:00
|
|
|
if( stateBits & IS_DRAGGED )
|
|
|
|
ret << wxT( " | IS_DRAGGED" );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-02-13 17:53:48 +00:00
|
|
|
if( stateBits & DO_NOT_DRAW )
|
|
|
|
ret << wxT( " | DO_NOT_DRAW" );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-02-13 17:53:48 +00:00
|
|
|
if( stateBits & IS_DELETED )
|
|
|
|
ret << wxT( " | IS_DELETED" );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
if( stateBits & BUSY )
|
2008-12-14 19:45:05 +00:00
|
|
|
ret << wxT( " | BUSY" );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-12-14 19:45:05 +00:00
|
|
|
if( stateBits & END_ONPAD )
|
|
|
|
ret << wxT( " | END_ONPAD" );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-12-14 19:45:05 +00:00
|
|
|
if( stateBits & BEGIN_ONPAD )
|
|
|
|
ret << wxT( " | BEGIN_ONPAD" );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-12-14 19:45:05 +00:00
|
|
|
if( stateBits & FLAG0 )
|
|
|
|
ret << wxT( " | FLAG0" );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
if( stateBits & FLAG1 )
|
2008-12-14 19:45:05 +00:00
|
|
|
ret << wxT( " | FLAG1" );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-08-09 01:41:30 +00:00
|
|
|
#endif
|