2011-10-13 19:56:32 +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>
|
2016-05-10 20:47:37 +00:00
|
|
|
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-13 19:56:32 +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 class_track.h
|
|
|
|
* @brief Functions relatives to tracks, vias and segments used to fill zones.
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2017-10-30 17:21:07 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <common.h>
|
|
|
|
#include <trigo.h>
|
2013-05-01 17:32:36 +00:00
|
|
|
#include <macros.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_drawpanel.h>
|
2018-01-29 10:37:29 +00:00
|
|
|
#include <pcb_screen.h>
|
2018-01-28 21:02:31 +00:00
|
|
|
#include <draw_graphic_text.h>
|
2018-01-29 15:39:40 +00:00
|
|
|
#include <pcb_base_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_track.h>
|
|
|
|
#include <pcbnew.h>
|
2012-04-27 14:15:11 +00:00
|
|
|
#include <base_units.h>
|
2013-01-12 17:32:24 +00:00
|
|
|
#include <msgpanel.h>
|
2017-02-20 12:20:39 +00:00
|
|
|
#include <bitmaps.h>
|
2018-02-19 14:48:22 +00:00
|
|
|
#include <view/view.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.
|
|
|
|
*/
|
2017-10-30 17:21:07 +00:00
|
|
|
static bool ShowClearance( PCB_DISPLAY_OPTIONS* aDisplOpts, const TRACK* aTrack )
|
2008-03-11 01:19:08 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
// maybe return true for tracks and vias, not for zone segments
|
2013-04-09 16:00:46 +00:00
|
|
|
return IsCopperLayer( aTrack->GetLayer() )
|
2011-10-01 19:24:27 +00:00
|
|
|
&& ( aTrack->Type() == PCB_TRACE_T || aTrack->Type() == PCB_VIA_T )
|
2017-10-30 17:21:07 +00:00
|
|
|
&& ( ( aDisplOpts->m_ShowTrackClearanceMode == PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_NEW_AND_EDITED_TRACKS_AND_VIA_AREAS
|
2011-12-21 13:42:02 +00:00
|
|
|
&& ( aTrack->IsDragging() || aTrack->IsMoving() || aTrack->IsNew() ) )
|
2017-10-30 17:21:07 +00:00
|
|
|
|| ( aDisplOpts->m_ShowTrackClearanceMode == PCB_DISPLAY_OPTIONS::SHOW_CLEARANCE_ALWAYS )
|
2011-09-30 08:24:10 +00:00
|
|
|
);
|
|
|
|
|
2008-03-11 01:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-30 19:16:22 +00:00
|
|
|
TRACK* GetTrack( TRACK* aStartTrace, const TRACK* aEndTrace,
|
2014-06-24 16:17:18 +00:00
|
|
|
const wxPoint& aPosition, LSET aLayerMask )
|
2011-09-16 14:13:02 +00:00
|
|
|
{
|
2016-07-12 19:05:54 +00:00
|
|
|
for( TRACK* seg = aStartTrace; seg; seg = seg->Next() )
|
2011-09-16 14:13:02 +00:00
|
|
|
{
|
2016-07-12 19:05:54 +00:00
|
|
|
if( seg->GetState( IS_DELETED | BUSY ) == 0 )
|
2011-09-16 14:13:02 +00:00
|
|
|
{
|
2016-07-12 19:05:54 +00:00
|
|
|
if( aPosition == seg->GetStart() )
|
2011-09-16 14:13:02 +00:00
|
|
|
{
|
2016-07-12 19:05:54 +00:00
|
|
|
if( ( aLayerMask & seg->GetLayerSet() ).any() )
|
|
|
|
return seg;
|
2011-09-16 14:13:02 +00:00
|
|
|
}
|
|
|
|
|
2016-07-12 19:05:54 +00:00
|
|
|
if( aPosition == seg->GetEnd() )
|
2011-09-16 14:13:02 +00:00
|
|
|
{
|
2016-07-12 19:05:54 +00:00
|
|
|
if( ( aLayerMask & seg->GetLayerSet() ).any() )
|
|
|
|
return seg;
|
2011-09-16 14:13:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-12 19:05:54 +00:00
|
|
|
if( seg == aEndTrace )
|
2011-09-16 14:13:02 +00:00
|
|
|
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
|
|
|
{
|
2013-07-29 07:33:56 +00:00
|
|
|
m_Width = Millimeter2iu( 0.2 );
|
2007-10-19 06:31:17 +00:00
|
|
|
start = end = NULL;
|
|
|
|
m_Param = 0;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2012-03-17 14:39:27 +00:00
|
|
|
EDA_ITEM* TRACK::Clone() const
|
2012-01-14 19:50:32 +00:00
|
|
|
{
|
|
|
|
return new TRACK( *this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-14 15:42:44 +00:00
|
|
|
wxString TRACK::ShowWidth() const
|
2007-10-11 00:11:59 +00:00
|
|
|
{
|
2012-04-27 14:15:11 +00:00
|
|
|
wxString msg = ::CoordinateToString( m_Width );
|
2007-10-11 00:11:59 +00:00
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2007-08-09 01:41:30 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
SEGZONE::SEGZONE( BOARD_ITEM* aParent ) :
|
2018-09-29 17:58:31 +00:00
|
|
|
TRACK( aParent, PCB_SEGZONE_T )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2012-03-17 14:39:27 +00:00
|
|
|
EDA_ITEM* SEGZONE::Clone() const
|
2012-01-14 19:50:32 +00:00
|
|
|
{
|
|
|
|
return new SEGZONE( *this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-14 15:42:44 +00:00
|
|
|
wxString SEGZONE::GetSelectMenuText() const
|
|
|
|
{
|
2013-04-09 17:49:01 +00:00
|
|
|
wxString text, nettxt;
|
2011-07-14 15:42:44 +00:00
|
|
|
BOARD* board = GetBoard();
|
|
|
|
|
|
|
|
if( board )
|
|
|
|
{
|
2014-02-25 10:40:34 +00:00
|
|
|
nettxt = GetNetname();
|
2011-07-14 15:42:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-04-07 11:55:18 +00:00
|
|
|
wxFAIL_MSG( wxT( "SEGZONE::GetSelectMenuText: BOARD is NULL" ) );
|
2013-04-09 17:49:01 +00:00
|
|
|
nettxt = wxT( "???" );
|
2011-07-14 15:42:44 +00:00
|
|
|
}
|
|
|
|
|
2013-06-29 09:52:22 +00:00
|
|
|
text.Printf( _( "Zone (%08lX) [%s] on %s" ),
|
2013-04-09 17:49:01 +00:00
|
|
|
m_TimeStamp, GetChars( nettxt ), GetChars( GetLayerName() ) );
|
2011-07-14 15:42:44 +00:00
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-20 12:20:39 +00:00
|
|
|
BITMAP_DEF SEGZONE::GetMenuImage() const
|
|
|
|
{
|
|
|
|
return add_zone_xpm;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
VIA::VIA( BOARD_ITEM* aParent ) :
|
2011-10-01 19:24:27 +00:00
|
|
|
TRACK( aParent, PCB_VIA_T )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2014-04-25 06:00:04 +00:00
|
|
|
SetViaType( VIA_THROUGH );
|
2014-06-24 16:17:18 +00:00
|
|
|
m_BottomLayer = B_Cu;
|
2014-04-25 06:00:04 +00:00
|
|
|
SetDrillDefault();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
EDA_ITEM* VIA::Clone() const
|
2012-01-14 19:50:32 +00:00
|
|
|
{
|
2014-04-25 06:00:04 +00:00
|
|
|
return new VIA( *this );
|
2012-01-14 19:50:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
wxString VIA::GetSelectMenuText() const
|
2011-07-14 15:42:44 +00:00
|
|
|
{
|
|
|
|
wxString text;
|
2013-04-08 07:13:26 +00:00
|
|
|
wxString format;
|
2011-07-14 15:42:44 +00:00
|
|
|
BOARD* board = GetBoard();
|
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
switch( GetViaType() )
|
|
|
|
{
|
|
|
|
case VIA_BLIND_BURIED:
|
2013-04-08 07:13:26 +00:00
|
|
|
format = _( "Blind/Buried Via %s, net[%s] (%d) on layers %s/%s" );
|
2014-04-25 06:00:04 +00:00
|
|
|
break;
|
|
|
|
case VIA_MICROVIA:
|
2013-04-08 07:13:26 +00:00
|
|
|
format = _( "Micro Via %s, Net [%s] (%d) on layers %s/%s" );
|
2014-04-25 06:00:04 +00:00
|
|
|
break;
|
2011-07-14 15:42:44 +00:00
|
|
|
// else say nothing about normal (through) vias
|
2014-04-25 06:00:04 +00:00
|
|
|
default:
|
|
|
|
format = _( "Via %s net [%s] (%d) on layers %s/%s" );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-07-14 15:42:44 +00:00
|
|
|
|
|
|
|
if( board )
|
|
|
|
{
|
2014-02-25 10:40:34 +00:00
|
|
|
wxString netname = GetNetname();
|
2011-07-14 15:42:44 +00:00
|
|
|
|
2013-04-07 11:55:18 +00:00
|
|
|
// say which layers, only two for now
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID topLayer;
|
|
|
|
PCB_LAYER_ID botLayer;
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
LayerPair( &topLayer, &botLayer );
|
2013-04-08 07:13:26 +00:00
|
|
|
text.Printf( format.GetData(), GetChars( ShowWidth() ),
|
2014-02-25 10:40:34 +00:00
|
|
|
GetChars( netname ), GetNetCode(),
|
2013-04-08 07:13:26 +00:00
|
|
|
GetChars( board->GetLayerName( topLayer ) ),
|
|
|
|
GetChars( board->GetLayerName( botLayer ) ) );
|
2011-07-14 15:42:44 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-04-25 06:00:04 +00:00
|
|
|
wxFAIL_MSG( wxT( "VIA::GetSelectMenuText: BOARD is NULL" ) );
|
2013-04-08 07:13:26 +00:00
|
|
|
text.Printf( format.GetData(), GetChars( ShowWidth() ),
|
|
|
|
wxT( "???" ), 0,
|
|
|
|
wxT( "??" ), wxT( "??" ) );
|
2011-07-14 15:42:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-20 12:20:39 +00:00
|
|
|
BITMAP_DEF VIA::GetMenuImage() const
|
|
|
|
{
|
2017-12-13 18:42:33 +00:00
|
|
|
return via_xpm;
|
2017-02-20 12:20:39 +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
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
int VIA::GetDrillValue() const
|
2008-01-12 20:31:56 +00:00
|
|
|
{
|
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
|
2014-05-20 09:29:37 +00:00
|
|
|
NETCLASSPTR netclass = GetNetClass();
|
2009-10-21 19:16:25 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
if( GetViaType() == 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
|
|
|
|
2013-03-28 19:12:46 +00:00
|
|
|
STATUS_FLAGS TRACK::IsPointOnEnds( const wxPoint& point, int min_dist )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2013-03-28 19:12:46 +00:00
|
|
|
STATUS_FLAGS result = 0;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
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
|
|
|
if( min_dist == 0 )
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
2013-05-04 11:57:09 +00:00
|
|
|
if( m_Start == point )
|
2007-08-08 20:51:08 +00:00
|
|
|
result |= STARTPOINT;
|
2013-05-04 11:57:09 +00:00
|
|
|
|
|
|
|
if( m_End == point )
|
|
|
|
result |= ENDPOINT;
|
2007-08-08 20:51:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-04 11:57:09 +00:00
|
|
|
double dist = GetLineLength( m_Start, point );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-05-01 17:32:36 +00:00
|
|
|
if( min_dist >= KiROUND( dist ) )
|
2007-08-08 20:51:08 +00:00
|
|
|
result |= STARTPOINT;
|
|
|
|
|
2013-05-04 11:57:09 +00:00
|
|
|
dist = GetLineLength( m_End, point );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-05-01 17:32:36 +00:00
|
|
|
if( min_dist >= KiROUND( 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
|
|
|
|
2013-11-24 17:48:14 +00:00
|
|
|
const 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
|
2018-06-12 08:36:41 +00:00
|
|
|
int radius = ( m_Width + 1 ) / 2;
|
|
|
|
int ymax, xmax, ymin, xmin;
|
2008-03-10 15:00:22 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
if( Type() == PCB_VIA_T )
|
2008-03-10 15:00:22 +00:00
|
|
|
{
|
|
|
|
ymax = m_Start.y;
|
|
|
|
xmax = m_Start.x;
|
|
|
|
|
|
|
|
ymin = m_Start.y;
|
|
|
|
xmin = m_Start.x;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-09-22 11:19:37 +00:00
|
|
|
ymax = std::max( m_Start.y, m_End.y );
|
|
|
|
xmax = std::max( m_Start.x, m_End.x );
|
2008-03-10 15:00:22 +00:00
|
|
|
|
2012-09-22 11:19:37 +00:00
|
|
|
ymin = std::min( m_Start.y, m_End.y );
|
|
|
|
xmin = std::min( m_Start.x, m_End.x );
|
2008-03-10 15:00:22 +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
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
void TRACK::Rotate( const wxPoint& aRotCentre, double 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);
|
2015-12-27 15:51:13 +00:00
|
|
|
int copperLayerCount = GetBoard()->GetCopperLayerCount();
|
|
|
|
SetLayer( FlipLayer( GetLayer(), copperLayerCount ) );
|
2014-04-30 19:16:22 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
|
|
|
|
2014-04-30 19:16:22 +00:00
|
|
|
void VIA::Flip( const wxPoint& aCentre )
|
|
|
|
{
|
|
|
|
m_Start.y = aCentre.y - (m_Start.y - aCentre.y);
|
|
|
|
m_End.y = aCentre.y - (m_End.y - aCentre.y);
|
2015-12-27 15:51:13 +00:00
|
|
|
|
|
|
|
if( GetViaType() != VIA_THROUGH )
|
|
|
|
{
|
|
|
|
int copperLayerCount = GetBoard()->GetCopperLayerCount();
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID top_layer;
|
|
|
|
PCB_LAYER_ID bottom_layer;
|
2015-12-27 15:51:13 +00:00
|
|
|
LayerPair( &top_layer, &bottom_layer );
|
|
|
|
top_layer = FlipLayer( top_layer, copperLayerCount );
|
|
|
|
bottom_layer = FlipLayer( bottom_layer, copperLayerCount );
|
|
|
|
SetLayerPair( top_layer, bottom_layer );
|
|
|
|
}
|
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
|
2016-07-12 19:05:54 +00:00
|
|
|
SEARCH_RESULT TRACK::Visit( INSPECTOR inspector, 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
|
|
|
|
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
|
|
|
{
|
2016-07-12 19:05:54 +00:00
|
|
|
if( SEARCH_QUIT == inspector( this, testData ) )
|
2007-08-30 22:20:52 +00:00
|
|
|
return SEARCH_QUIT;
|
|
|
|
}
|
|
|
|
|
2007-10-15 07:50:59 +00:00
|
|
|
return SEARCH_CONTINUE;
|
2007-08-30 22:20:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
bool VIA::IsOnLayer( PCB_LAYER_ID layer_number ) const
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID bottom_layer, top_layer;
|
2007-10-15 07:50:59 +00:00
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
LayerPair( &top_layer, &bottom_layer );
|
2007-10-15 07:50:59 +00:00
|
|
|
|
2014-06-30 04:40:16 +00:00
|
|
|
wxASSERT( top_layer <= bottom_layer );
|
|
|
|
|
|
|
|
if( top_layer <= layer_number && layer_number <= bottom_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
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
LSET VIA::GetLayerSet() const
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2014-04-25 06:00:04 +00:00
|
|
|
if( GetViaType() == VIA_THROUGH )
|
2014-06-24 16:17:18 +00:00
|
|
|
return LSET::AllCuMask();
|
2007-10-15 07:50:59 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
// VIA_BLIND_BURIED or VIA_MICRVIA:
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET layermask;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2014-07-23 16:27:52 +00:00
|
|
|
wxASSERT( m_Layer <= m_BottomLayer );
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
// PCB_LAYER_IDs are numbered from front to back, this is top to bottom.
|
2014-07-23 16:27:52 +00:00
|
|
|
for( LAYER_NUM id = m_Layer; id <= m_BottomLayer; ++id )
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
layermask.set( id );
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
2014-04-25 06:00:04 +00:00
|
|
|
|
|
|
|
return layermask;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
void VIA::SetLayerPair( PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-10-16 20:52:49 +00:00
|
|
|
|
2014-04-25 08:03:50 +00:00
|
|
|
m_Layer = aTopLayer;
|
|
|
|
m_BottomLayer = aBottomLayer;
|
2018-01-06 22:32:22 +00:00
|
|
|
SanitizeLayers();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VIA::SetTopLayer( PCB_LAYER_ID aLayer )
|
|
|
|
{
|
|
|
|
m_Layer = aLayer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VIA::SetBottomLayer( PCB_LAYER_ID aLayer )
|
|
|
|
{
|
|
|
|
m_BottomLayer = aLayer;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
void VIA::LayerPair( PCB_LAYER_ID* top_layer, PCB_LAYER_ID* bottom_layer ) const
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID t_layer = F_Cu;
|
|
|
|
PCB_LAYER_ID b_layer = B_Cu;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
if( GetViaType() != VIA_THROUGH )
|
2009-05-21 12:45:21 +00:00
|
|
|
{
|
2014-04-25 08:03:50 +00:00
|
|
|
b_layer = m_BottomLayer;
|
|
|
|
t_layer = m_Layer;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-06-25 17:01:50 +00:00
|
|
|
if( b_layer < t_layer )
|
2015-06-26 13:41:56 +00:00
|
|
|
std::swap( b_layer, t_layer );
|
2009-05-21 12:45:21 +00:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-06 22:32:22 +00:00
|
|
|
PCB_LAYER_ID VIA::TopLayer() const
|
|
|
|
{
|
|
|
|
return m_Layer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PCB_LAYER_ID VIA::BottomLayer() const
|
|
|
|
{
|
|
|
|
return m_BottomLayer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VIA::SanitizeLayers()
|
|
|
|
{
|
|
|
|
if( GetViaType() == VIA_THROUGH )
|
|
|
|
{
|
|
|
|
m_Layer = F_Cu;
|
|
|
|
m_BottomLayer = B_Cu;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_BottomLayer < m_Layer )
|
|
|
|
std::swap( m_BottomLayer, m_Layer );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2018-04-03 20:57:31 +00:00
|
|
|
// When reading from a file most of the items will already be in the correct order.
|
|
|
|
// Searching from the back therefore takes us from n^2 to essentially 0.
|
|
|
|
|
2018-09-29 17:58:31 +00:00
|
|
|
if( Type() == PCB_SEGZONE_T ) // Deprecated items, only found in very old boards
|
2018-05-12 19:37:43 +00:00
|
|
|
track = aPcb->m_SegZoneDeprecated.GetLast();
|
2007-08-08 20:51:08 +00:00
|
|
|
else
|
2018-04-03 20:57:31 +00:00
|
|
|
track = aPcb->m_Track.GetLast();
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2018-04-03 20:57:31 +00:00
|
|
|
for( ; track; track = track->Back() )
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
2018-04-03 20:57:31 +00:00
|
|
|
if( GetNetCode() >= track->GetNetCode() )
|
|
|
|
return track->Next();
|
2007-08-08 20:51:08 +00:00
|
|
|
}
|
|
|
|
|
2018-09-29 17:58:31 +00:00
|
|
|
if( Type() == PCB_SEGZONE_T ) // Deprecated
|
2018-05-12 19:37:43 +00:00
|
|
|
return aPcb->m_SegZoneDeprecated.GetFirst();
|
2018-04-26 17:42:39 +00:00
|
|
|
else
|
|
|
|
return aPcb->m_Track.GetFirst();
|
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 )
|
2014-02-25 10:40:34 +00:00
|
|
|
NetCode = GetNetCode();
|
2007-08-08 20:51:08 +00:00
|
|
|
|
|
|
|
while( Track != NULL )
|
|
|
|
{
|
2014-02-25 10:40:34 +00:00
|
|
|
if( Track->GetNetCode() > NetCode )
|
2007-08-08 20:51:08 +00:00
|
|
|
break;
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2014-02-25 10:40:34 +00:00
|
|
|
if( Track->GetNetCode() == 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 )
|
2014-02-25 10:40:34 +00:00
|
|
|
NetCode = GetNetCode();
|
2007-08-08 20:51:08 +00:00
|
|
|
|
|
|
|
while( Track != NULL )
|
|
|
|
{
|
|
|
|
NextS = (TRACK*) Track->Pnext;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-02-25 10:40:34 +00:00
|
|
|
if( Track->GetNetCode() == 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
|
|
|
|
2014-02-25 10:40:34 +00:00
|
|
|
if( NextS->GetNetCode() > 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
|
|
|
}
|
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
void TRACK::DrawShortNetname( EDA_DRAW_PANEL* panel,
|
2017-02-20 16:57:41 +00:00
|
|
|
wxDC* aDC, GR_DRAWMODE aDrawMode, COLOR4D aBgColor )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2015-04-03 09:13:06 +00:00
|
|
|
if( ! panel )
|
|
|
|
return;
|
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
/* we must filter tracks, to avoid a lot of texts.
|
|
|
|
* - only tracks with a length > 10 * thickness are eligible
|
|
|
|
* and, of course, if we are not printing the board
|
|
|
|
*/
|
2017-10-30 17:21:07 +00:00
|
|
|
auto displ_opts = (PCB_DISPLAY_OPTIONS*)( panel->GetDisplayOptions() );
|
2015-01-10 10:27:49 +00:00
|
|
|
|
|
|
|
if( displ_opts->m_DisplayNetNamesMode == 0 || displ_opts->m_DisplayNetNamesMode == 1 )
|
2014-04-25 06:00:04 +00:00
|
|
|
return;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
#define THRESHOLD 10
|
|
|
|
|
|
|
|
int len = KiROUND( GetLineLength( m_Start, m_End ) );
|
|
|
|
|
|
|
|
if( len < THRESHOLD * m_Width )
|
2007-08-08 20:51:08 +00:00
|
|
|
return;
|
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
// no room to display a text inside track
|
|
|
|
if( aDC->LogicalToDeviceXRel( m_Width ) < MIN_TEXT_SIZE )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( GetNetCode() == NETINFO_LIST::UNCONNECTED )
|
|
|
|
return;
|
|
|
|
|
|
|
|
NETINFO_ITEM* net = GetNet();
|
|
|
|
|
|
|
|
if( net == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
int textlen = net->GetShortNetname().Len();
|
|
|
|
|
|
|
|
if( textlen > 0 )
|
|
|
|
{
|
|
|
|
// calculate a good size for the text
|
|
|
|
int tsize = std::min( m_Width, len / textlen );
|
|
|
|
int dx = m_End.x - m_Start.x ;
|
|
|
|
int dy = m_End.y - m_Start.y ;
|
|
|
|
wxPoint tpos = m_Start + m_End;
|
|
|
|
tpos.x /= 2;
|
|
|
|
tpos.y /= 2;
|
|
|
|
|
|
|
|
// Calculate angle: if the track segment is vertical, angle = 90 degrees
|
|
|
|
// If horizontal 0 degrees, otherwise compute it
|
|
|
|
double angle; // angle is in 0.1 degree
|
|
|
|
|
|
|
|
if( dy == 0 ) // Horizontal segment
|
|
|
|
{
|
|
|
|
angle = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( dx == 0 ) // Vertical segment
|
|
|
|
{
|
|
|
|
angle = 900;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* atan2 is *not* the solution here, since it can give upside
|
|
|
|
down text. We want to work only in the first and fourth quadrant */
|
|
|
|
angle = RAD2DECIDEG( -atan( double( dy ) / double( dx ) ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
|
2015-04-03 09:13:06 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
if( ( aDC->LogicalToDeviceXRel( tsize ) >= MIN_TEXT_SIZE )
|
2015-01-10 10:27:49 +00:00
|
|
|
&& ( !(!IsOnLayer( curr_layer )&& displ_opts->m_ContrastModeDisplay) ) )
|
2014-04-25 06:00:04 +00:00
|
|
|
{
|
|
|
|
if( (aDrawMode & GR_XOR) == 0 )
|
|
|
|
GRSetDrawMode( aDC, GR_COPY );
|
|
|
|
|
|
|
|
tsize = (tsize * 7) / 10; // small reduction to give a better look
|
2015-04-03 09:13:06 +00:00
|
|
|
DrawGraphicHaloText( panel->GetClipBox(), aDC, tpos,
|
2014-04-25 06:00:04 +00:00
|
|
|
aBgColor, BLACK, WHITE, net->GetShortNetname(), angle,
|
|
|
|
wxSize( tsize, tsize ),
|
|
|
|
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
|
|
|
|
tsize / 7,
|
|
|
|
false, false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-25 17:01:50 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
|
|
|
|
const wxPoint& aOffset )
|
|
|
|
{
|
2017-02-20 16:57:41 +00:00
|
|
|
BOARD* brd = GetBoard();
|
2017-08-04 12:43:02 +00:00
|
|
|
|
|
|
|
auto frame = static_cast<PCB_BASE_FRAME*> ( panel->GetParent() );
|
|
|
|
auto color = frame->Settings().Colors().GetLayerColor( m_Layer );
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2018-02-19 14:48:22 +00:00
|
|
|
if( ( !brd->IsLayerVisible( m_Layer ) || !brd->IsElementVisible( LAYER_TRACKS ) )
|
|
|
|
&& !( aDrawMode & GR_HIGHLIGHT ) )
|
2010-10-16 14:51:22 +00:00
|
|
|
return;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2012-01-10 21:55:07 +00:00
|
|
|
#ifdef USE_WX_OVERLAY
|
|
|
|
// If dragged not draw in OnPaint otherwise remains impressed in wxOverlay
|
2014-06-02 16:16:06 +00:00
|
|
|
if( (m_Flags & IS_DRAGGED) && aDC->IsKindOf(wxCLASSINFO(wxPaintDC)))
|
2012-01-10 21:55:07 +00:00
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
|
2017-10-30 17:21:07 +00:00
|
|
|
auto displ_opts = (PCB_DISPLAY_OPTIONS*)( panel->GetDisplayOptions() );
|
2015-01-10 10:27:49 +00:00
|
|
|
|
|
|
|
if( ( aDrawMode & GR_ALLOW_HIGHCONTRAST ) && displ_opts->m_ContrastModeDisplay )
|
2010-10-16 14:51:22 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
|
2014-04-25 06:00:04 +00:00
|
|
|
|
2010-10-16 14:51:22 +00:00
|
|
|
if( !IsOnLayer( curr_layer ) )
|
2017-02-20 16:57:41 +00:00
|
|
|
color = COLOR4D( DARKDARKGRAY );
|
2010-10-16 14:51:22 +00:00
|
|
|
}
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
if( ( aDrawMode & GR_HIGHLIGHT ) && !( aDrawMode & GR_AND ) )
|
|
|
|
color.SetToLegacyHighlightColor();
|
2008-04-02 14:16:14 +00:00
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
color.a = 0.588;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2013-04-09 17:16:53 +00:00
|
|
|
GRSetDrawMode( aDC, aDrawMode );
|
2008-04-02 14:16:14 +00:00
|
|
|
|
2017-05-04 06:54:30 +00:00
|
|
|
// Draw track as line if width <= 1pixel:
|
|
|
|
if( aDC->LogicalToDeviceXRel( m_Width ) <= 1 )
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
2017-05-04 06:54:30 +00:00
|
|
|
GRLine( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, m_Width, color );
|
2007-08-08 20:51:08 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-10 10:27:49 +00:00
|
|
|
if( !displ_opts->m_DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
2013-04-09 17:16:53 +00:00
|
|
|
GRCSegm( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, m_Width, color );
|
2007-08-08 20:51:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-04-09 17:16:53 +00:00
|
|
|
GRFillCSegm( panel->GetClipBox(), aDC, m_Start.x + aOffset.x,
|
2010-11-11 21:46:55 +00:00
|
|
|
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
|
2015-01-10 10:27:49 +00:00
|
|
|
if( ShowClearance( displ_opts, this ) )
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
2013-04-09 17:16:53 +00:00
|
|
|
GRCSegm( panel->GetClipBox(), aDC, 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
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
DrawShortNetname( panel, aDC, aDrawMode, color );
|
|
|
|
}
|
2008-12-16 19:44:57 +00:00
|
|
|
|
2014-06-25 17:01:50 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
void SEGZONE::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
|
|
|
|
const wxPoint& aOffset )
|
|
|
|
{
|
2017-10-30 17:21:07 +00:00
|
|
|
auto displ_opts = (PCB_DISPLAY_OPTIONS*)( panel->GetDisplayOptions() );
|
2015-01-10 10:27:49 +00:00
|
|
|
|
|
|
|
if( displ_opts->m_DisplayZonesMode != 0 )
|
2009-03-26 19:27:50 +00:00
|
|
|
return;
|
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
BOARD* brd = GetBoard();
|
2017-08-04 12:43:02 +00:00
|
|
|
|
|
|
|
auto frame = static_cast<PCB_BASE_FRAME*> ( panel->GetParent() );
|
|
|
|
auto color = frame->Settings().Colors().GetLayerColor( m_Layer );
|
2008-12-16 19:44:57 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
if( brd->IsLayerVisible( m_Layer ) == false && !( aDrawMode & GR_HIGHLIGHT ) )
|
2008-12-16 19:44:57 +00:00
|
|
|
return;
|
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
#ifdef USE_WX_OVERLAY
|
|
|
|
// If dragged not draw in OnPaint otherwise remains impressed in wxOverlay
|
2014-06-02 16:16:06 +00:00
|
|
|
if( (m_Flags & IS_DRAGGED) && aDC->IsKindOf(wxCLASSINFO(wxPaintDC)))
|
2014-04-25 06:00:04 +00:00
|
|
|
return;
|
|
|
|
#endif
|
2008-12-19 20:40:08 +00:00
|
|
|
|
2015-01-10 10:27:49 +00:00
|
|
|
if( ( aDrawMode & GR_ALLOW_HIGHCONTRAST ) && displ_opts->m_ContrastModeDisplay )
|
2014-04-25 06:00:04 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
if( !IsOnLayer( curr_layer ) )
|
2017-02-20 16:57:41 +00:00
|
|
|
color = COLOR4D( DARKDARKGRAY );
|
2014-04-25 06:00:04 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
if( ( aDrawMode & GR_HIGHLIGHT ) && !( aDrawMode & GR_AND ) )
|
|
|
|
color.SetToLegacyHighlightColor();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
color.a = 0.588;
|
2008-12-16 19:44:57 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
GRSetDrawMode( aDC, aDrawMode );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2017-05-04 06:54:30 +00:00
|
|
|
// Draw track as line if width <= 1pixel:
|
|
|
|
if( aDC->LogicalToDeviceXRel( m_Width ) <= 1 )
|
2014-04-25 06:00:04 +00:00
|
|
|
{
|
2017-05-04 06:54:30 +00:00
|
|
|
GRLine( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, m_Width, color );
|
2014-04-25 06:00:04 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-04-09 17:16:53 +00:00
|
|
|
|
2015-01-10 10:27:49 +00:00
|
|
|
if( !displ_opts->m_DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
|
2014-04-25 06:00:04 +00:00
|
|
|
{
|
|
|
|
GRCSegm( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, m_Width, color );
|
2008-12-16 19:44:57 +00:00
|
|
|
}
|
2014-04-25 06:00:04 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
GRFillCSegm( panel->GetClipBox(), aDC, m_Start.x + aOffset.x,
|
|
|
|
m_Start.y + aOffset.y,
|
|
|
|
m_End.x + aOffset.x, m_End.y + aOffset.y, m_Width, color );
|
|
|
|
}
|
|
|
|
|
|
|
|
// No clearance or netnames for zones
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-08 07:57:23 +00:00
|
|
|
void TRACK::ViewGetLayers( int aLayers[], int& aCount ) const
|
|
|
|
{
|
|
|
|
// Show the track and its netname on different layers
|
|
|
|
aLayers[0] = GetLayer();
|
2013-07-08 14:46:04 +00:00
|
|
|
aLayers[1] = GetNetnameLayer( aLayers[0] );
|
2013-07-08 07:57:23 +00:00
|
|
|
aCount = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
unsigned int TRACK::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
|
2013-07-08 07:57:23 +00:00
|
|
|
{
|
2018-02-19 14:48:22 +00:00
|
|
|
const int HIDE = std::numeric_limits<unsigned int>::max();
|
|
|
|
|
|
|
|
if( !aView->IsLayerVisible( LAYER_TRACKS ) )
|
|
|
|
return HIDE;
|
|
|
|
|
2013-07-08 07:57:23 +00:00
|
|
|
// Netnames will be shown only if zoom is appropriate
|
2014-02-03 13:14:53 +00:00
|
|
|
if( IsNetnameLayer( aLayer ) )
|
2013-07-08 07:57:23 +00:00
|
|
|
{
|
2016-05-02 14:08:51 +00:00
|
|
|
return ( 40000000 / ( m_Width + 1 ) );
|
2013-07-08 07:57:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Other layers are shown without any conditions
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-06-12 08:36:41 +00:00
|
|
|
const BOX2I TRACK::ViewBBox() const
|
|
|
|
{
|
|
|
|
BOX2I bbox( GetBoundingBox() );
|
|
|
|
bbox.Inflate( 2 * GetClearance() );
|
|
|
|
return bbox;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-28 20:50:35 +00:00
|
|
|
void VIA::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoint& aOffset )
|
2008-11-24 06:53:43 +00:00
|
|
|
{
|
2015-02-28 20:50:35 +00:00
|
|
|
wxCHECK_RET( panel != NULL, wxT( "VIA::Draw panel cannot be NULL." ) );
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
int radius;
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID 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();
|
2017-10-30 17:21:07 +00:00
|
|
|
auto displ_opts = (PCB_DISPLAY_OPTIONS*)( frame->GetDisplayOptions() );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2015-01-10 10:27:49 +00:00
|
|
|
if( displ_opts->m_DisplayViaFill == FILLED )
|
2009-09-29 04:44:35 +00:00
|
|
|
fillvia = 1;
|
|
|
|
|
2013-04-09 17:16:53 +00:00
|
|
|
GRSetDrawMode( aDC, aDrawMode );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2014-07-23 16:27:52 +00:00
|
|
|
BOARD * brd = GetBoard();
|
2017-08-04 12:43:02 +00:00
|
|
|
COLOR4D color = frame->Settings().Colors().GetItemColor( LAYER_VIAS + GetViaType() );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
if( brd->IsElementVisible( LAYER_VIAS + GetViaType() ) == false
|
2017-02-20 16:57:41 +00:00
|
|
|
&& !( aDrawMode & GR_HIGHLIGHT ) )
|
|
|
|
return;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2014-07-23 16:27:52 +00:00
|
|
|
// Only draw the via if at least one of the layers it crosses is being displayed
|
|
|
|
if( !( brd->GetVisibleLayers() & GetLayerSet() ).any() )
|
|
|
|
return;
|
|
|
|
|
2015-01-10 10:27:49 +00:00
|
|
|
if( displ_opts->m_ContrastModeDisplay )
|
2008-11-24 06:53:43 +00:00
|
|
|
{
|
|
|
|
if( !IsOnLayer( curr_layer ) )
|
2017-02-20 16:57:41 +00:00
|
|
|
color = COLOR4D( DARKDARKGRAY );
|
2008-11-24 06:53:43 +00:00
|
|
|
}
|
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
if( ( aDrawMode & GR_HIGHLIGHT ) && !( aDrawMode & GR_AND ) )
|
|
|
|
color.SetToLegacyHighlightColor();
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
color.a = 0.588;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
|
|
|
|
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
|
|
|
|
2013-04-09 17:16:53 +00:00
|
|
|
int radius_in_pixels = aDC->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
|
|
|
|
2013-04-09 17:16:53 +00:00
|
|
|
int inner_radius = radius - aDC->DeviceToLogicalXRel( 2 );
|
2010-02-08 18:15:42 +00:00
|
|
|
|
2013-04-09 17:16:53 +00:00
|
|
|
if( radius_in_pixels < MIN_VIA_DRAW_SIZE )
|
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
|
|
|
{
|
2013-04-09 17:16:53 +00:00
|
|
|
GRFilledCircle( panel->GetClipBox(), aDC, m_Start + aOffset, radius, color );
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
2009-09-29 04:44:35 +00:00
|
|
|
else
|
2009-10-27 10:55:46 +00:00
|
|
|
{
|
2013-04-09 17:16:53 +00:00
|
|
|
GRCircle( panel->GetClipBox(), aDC, m_Start + aOffset, radius, 0, color );
|
2011-12-29 20:11:42 +00:00
|
|
|
|
2009-10-27 10:55:46 +00:00
|
|
|
if ( fast_draw )
|
|
|
|
return;
|
2011-12-29 20:11:42 +00:00
|
|
|
|
2013-04-09 17:16:53 +00:00
|
|
|
GRCircle( panel->GetClipBox(), aDC, m_Start + aOffset, inner_radius, 0, color );
|
2009-10-27 10:55:46 +00:00
|
|
|
}
|
2008-12-14 19:45:05 +00:00
|
|
|
|
2016-05-10 20:47:37 +00:00
|
|
|
if( fillvia )
|
2008-12-14 19:45:05 +00:00
|
|
|
{
|
2016-05-10 20:47:37 +00:00
|
|
|
bool blackpenstate = false;
|
2015-06-18 13:19:30 +00:00
|
|
|
|
2016-05-10 20:47:37 +00:00
|
|
|
if( screen->m_IsPrinting )
|
2015-06-18 13:19:30 +00:00
|
|
|
{
|
2016-05-10 20:47:37 +00:00
|
|
|
blackpenstate = GetGRForceBlackPenState();
|
|
|
|
GRForceBlackPen( false );
|
|
|
|
color = WHITE;
|
2015-06-18 13:19:30 +00:00
|
|
|
}
|
2016-05-10 20:47:37 +00:00
|
|
|
else
|
2011-09-14 15:08:44 +00:00
|
|
|
{
|
2016-05-10 20:47:37 +00:00
|
|
|
color = BLACK; // or DARKGRAY;
|
2008-11-24 06:53:43 +00:00
|
|
|
}
|
2016-05-10 20:47:37 +00:00
|
|
|
|
|
|
|
if( (aDrawMode & GR_XOR) == 0)
|
|
|
|
GRSetDrawMode( aDC, GR_COPY );
|
|
|
|
|
2017-05-04 06:54:30 +00:00
|
|
|
// Draw hole if the radius is > 1pixel.
|
|
|
|
if( aDC->LogicalToDeviceXRel( drill_radius ) > 1 )
|
2016-05-10 20:47:37 +00:00
|
|
|
GRFilledCircle( panel->GetClipBox(), aDC, m_Start.x + aOffset.x,
|
|
|
|
m_Start.y + aOffset.y, drill_radius, 0, color, color );
|
|
|
|
|
|
|
|
if( screen->m_IsPrinting )
|
|
|
|
GRForceBlackPen( blackpenstate );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( drill_radius < inner_radius ) // We can show the via hole
|
|
|
|
GRCircle( panel->GetClipBox(), aDC, m_Start + aOffset, drill_radius, 0, color );
|
2008-12-14 19:45:05 +00:00
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2015-01-10 10:27:49 +00:00
|
|
|
if( ShowClearance( displ_opts, this ) )
|
2012-06-13 13:32:43 +00:00
|
|
|
{
|
2013-04-09 17:16:53 +00:00
|
|
|
GRCircle( panel->GetClipBox(), aDC, m_Start + aOffset, radius + GetClearance(), 0, color );
|
2012-06-13 13:32:43 +00:00
|
|
|
}
|
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 ):
|
2014-04-25 06:00:04 +00:00
|
|
|
if( GetViaType() == VIA_MICROVIA )
|
2008-12-14 19:45:05 +00:00
|
|
|
{
|
|
|
|
int ax, ay, bx, by;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( IsOnLayer( B_Cu ) )
|
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
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
// lines '|' or '\'
|
2013-04-09 17:16:53 +00:00
|
|
|
GRLine( panel->GetClipBox(), aDC, m_Start.x + aOffset.x - ax,
|
2010-11-11 21:46:55 +00:00
|
|
|
m_Start.y + aOffset.y - ay,
|
|
|
|
m_Start.x + aOffset.x - bx,
|
|
|
|
m_Start.y + aOffset.y - by, 0, color );
|
2013-04-09 17:16:53 +00:00
|
|
|
GRLine( panel->GetClipBox(), aDC, m_Start.x + aOffset.x + bx,
|
2010-11-11 21:46:55 +00:00
|
|
|
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
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
// lines - or '/'
|
2013-04-09 17:16:53 +00:00
|
|
|
GRLine( panel->GetClipBox(), aDC, m_Start.x + aOffset.x + ay,
|
2010-11-11 21:46:55 +00:00
|
|
|
m_Start.y + aOffset.y - ax,
|
|
|
|
m_Start.x + aOffset.x + by,
|
|
|
|
m_Start.y + aOffset.y - bx, 0, color );
|
2013-04-09 17:16:53 +00:00
|
|
|
GRLine( panel->GetClipBox(), aDC, m_Start.x + aOffset.x - by,
|
2010-11-11 21:46:55 +00:00
|
|
|
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 ):
|
2014-04-25 06:00:04 +00:00
|
|
|
if( GetViaType() == VIA_BLIND_BURIED )
|
2008-12-14 19:45:05 +00:00
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
int ax = 0, ay = radius, bx = 0, by = drill_radius;
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID layer_top, layer_bottom;
|
2008-12-14 19:45:05 +00:00
|
|
|
|
2015-11-04 08:48:34 +00:00
|
|
|
LayerPair( &layer_top, &layer_bottom );
|
2008-12-14 19:45:05 +00:00
|
|
|
|
2013-04-09 17:16:53 +00:00
|
|
|
// lines for the top layer
|
2013-05-02 18:06:58 +00:00
|
|
|
RotatePoint( &ax, &ay, layer_top * 3600.0 / brd->GetCopperLayerCount( ) );
|
|
|
|
RotatePoint( &bx, &by, layer_top * 3600.0 / brd->GetCopperLayerCount( ) );
|
2013-04-09 17:16:53 +00:00
|
|
|
GRLine( panel->GetClipBox(), aDC, m_Start.x + aOffset.x - ax,
|
2010-11-11 21:46:55 +00:00
|
|
|
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
|
|
|
|
2013-06-29 09:52:22 +00:00
|
|
|
// lines for the bottom layer
|
2011-09-07 19:41:04 +00:00
|
|
|
ax = 0; ay = radius; bx = 0; by = drill_radius;
|
2013-05-02 18:06:58 +00:00
|
|
|
RotatePoint( &ax, &ay, layer_bottom * 3600.0 / brd->GetCopperLayerCount( ) );
|
|
|
|
RotatePoint( &bx, &by, layer_bottom * 3600.0 / brd->GetCopperLayerCount( ) );
|
2013-04-09 17:16:53 +00:00
|
|
|
GRLine( panel->GetClipBox(), aDC, m_Start.x + aOffset.x - ax,
|
2010-11-11 21:46:55 +00:00
|
|
|
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:
|
2014-02-25 10:40:34 +00:00
|
|
|
if( GetNetCode() == NETINFO_LIST::UNCONNECTED )
|
2008-12-14 19:45:05 +00:00
|
|
|
return;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2015-01-10 10:27:49 +00:00
|
|
|
if( displ_opts->m_DisplayNetNamesMode == 0 || displ_opts->m_DisplayNetNamesMode == 1 )
|
2009-03-26 19:27:50 +00:00
|
|
|
return;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-02-25 10:40:34 +00:00
|
|
|
NETINFO_ITEM* net = 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
|
|
|
|
2013-04-09 17:16:53 +00:00
|
|
|
if( aDC->LogicalToDeviceXRel( tsize ) >= MIN_TEXT_SIZE )
|
2008-12-15 10:24:19 +00:00
|
|
|
{
|
2013-04-10 19:09:59 +00:00
|
|
|
tsize = (tsize * 7) / 10; // small reduction to give a better look, inside via
|
2015-02-28 20:50:35 +00:00
|
|
|
|
2013-04-09 17:16:53 +00:00
|
|
|
if( (aDrawMode & GR_XOR) == 0 )
|
|
|
|
GRSetDrawMode( aDC, GR_COPY );
|
|
|
|
|
2015-02-28 20:50:35 +00:00
|
|
|
EDA_RECT* clipbox = panel->GetClipBox();
|
2013-06-29 09:52:22 +00:00
|
|
|
DrawGraphicHaloText( clipbox, aDC, m_Start,
|
|
|
|
color, WHITE, BLACK, net->GetShortNetname(), 0,
|
2013-04-09 17:16:53 +00:00
|
|
|
wxSize( tsize, tsize ),
|
2013-06-29 09:52:22 +00:00
|
|
|
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
|
2013-04-09 17:16:53 +00:00
|
|
|
tsize / 7, 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
|
|
|
|
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
void VIA::ViewGetLayers( int aLayers[], int& aCount ) const
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
aLayers[0] = LAYER_VIAS_HOLES;
|
2017-04-25 09:47:21 +00:00
|
|
|
aLayers[1] = LAYER_VIAS_NETNAMES;
|
2017-04-22 15:46:31 +00:00
|
|
|
aCount = 3;
|
2014-08-06 11:53:02 +00:00
|
|
|
|
|
|
|
// Just show it on common via & via holes layers
|
|
|
|
switch( GetViaType() )
|
|
|
|
{
|
|
|
|
case VIA_THROUGH:
|
2017-04-22 15:46:31 +00:00
|
|
|
aLayers[2] = LAYER_VIA_THROUGH;
|
2014-08-06 11:53:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VIA_BLIND_BURIED:
|
2017-04-22 15:46:31 +00:00
|
|
|
aLayers[2] = LAYER_VIA_BBLIND;
|
|
|
|
aLayers[3] = m_Layer;
|
|
|
|
aLayers[4] = m_BottomLayer;
|
2014-08-06 11:53:02 +00:00
|
|
|
aCount += 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIA_MICROVIA:
|
2017-04-22 15:46:31 +00:00
|
|
|
aLayers[2] = LAYER_VIA_MICROVIA;
|
2014-08-06 11:53:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2017-04-25 09:47:21 +00:00
|
|
|
aLayers[2] = LAYER_GP_OVERLAY;
|
|
|
|
wxASSERT( false );
|
2014-08-06 11:53:02 +00:00
|
|
|
break;
|
|
|
|
}
|
Introduction of Graphics Abstraction Layer based rendering for pcbnew.
New classes:
- VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.)
- VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes).
- EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL).
- GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries.
- WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc.
- PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods.
- STROKE_FONT - Implements stroke font drawing using GAL methods.
Most important changes to Kicad original code:
* EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects.
* EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime.
* There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew)
* Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom.
* Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime.
* Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods.
* Removed tools/class_painter.h, as now it is extended and included in source code.
Build changes:
* GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL.
* When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required.
* GAL-related code is compiled into a static library (common/libgal).
* Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad
Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS).
More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
2013-04-02 06:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-20 16:19:41 +00:00
|
|
|
unsigned int VIA::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
|
|
|
|
{
|
|
|
|
BOARD* board = GetBoard();
|
|
|
|
|
|
|
|
// Only draw the via if at least one of the layers it crosses is being displayed
|
|
|
|
if( board && ( board->GetVisibleLayers() & GetLayerSet() ).any() )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return std::numeric_limits<unsigned int>::max();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-14 15:08:44 +00:00
|
|
|
// see class_track.h
|
2013-01-12 17:32:24 +00:00
|
|
|
void TRACK::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
|
2009-10-14 18:14:58 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
2013-01-12 17:32:24 +00:00
|
|
|
BOARD* board = GetBoard();
|
2009-10-16 17:18:23 +00:00
|
|
|
|
2009-10-14 18:14:58 +00:00
|
|
|
// Display basic infos
|
2013-01-12 17:32:24 +00:00
|
|
|
GetMsgPanelInfoBase( aList );
|
2009-10-14 18:14:58 +00:00
|
|
|
|
2011-09-30 18:15:37 +00:00
|
|
|
// Display full track length (in Pcbnew)
|
2013-01-12 17:32:24 +00:00
|
|
|
if( board )
|
2009-10-14 18:14:58 +00:00
|
|
|
{
|
2012-12-12 11:57:17 +00:00
|
|
|
double trackLen = 0;
|
|
|
|
double lenPadToDie = 0;
|
2018-06-12 14:50:18 +00:00
|
|
|
|
|
|
|
// Find the beginning of the track buffer containing this, because it is not
|
|
|
|
// always the track list on board, but can be a "private" list
|
|
|
|
TRACK* track_buffer_start = this;
|
|
|
|
|
|
|
|
while( track_buffer_start->Back() )
|
|
|
|
track_buffer_start = track_buffer_start->Back();
|
|
|
|
|
|
|
|
board->MarkTrace( track_buffer_start, this, NULL, &trackLen, &lenPadToDie, false );
|
2014-07-24 06:43:23 +00:00
|
|
|
msg = ::LengthDoubleToString( trackLen );
|
2014-11-15 19:06:05 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Length" ), msg, DARKCYAN ) );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-12-12 11:57:17 +00:00
|
|
|
if( lenPadToDie != 0 )
|
2011-08-20 14:46:48 +00:00
|
|
|
{
|
2013-01-12 17:32:24 +00:00
|
|
|
msg = ::LengthDoubleToString( trackLen + lenPadToDie );
|
2014-11-15 19:06:05 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Full Length" ), msg, DARKCYAN ) );
|
2011-08-20 14:46:48 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
msg = ::LengthDoubleToString( lenPadToDie );
|
2014-11-15 19:06:05 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Pad To Die Length" ), msg, DARKCYAN ) );
|
2011-08-20 14:46:48 +00:00
|
|
|
}
|
2009-10-14 18:14:58 +00:00
|
|
|
}
|
2011-03-11 15:53:28 +00:00
|
|
|
|
2014-05-20 09:29:37 +00:00
|
|
|
NETCLASSPTR netclass = GetNetClass();
|
2011-03-11 15:53:28 +00:00
|
|
|
|
|
|
|
if( netclass )
|
|
|
|
{
|
2013-01-12 17:32:24 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "NC Name" ), netclass->GetName(), DARKMAGENTA ) );
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "NC Clearance" ),
|
|
|
|
::CoordinateToString( netclass->GetClearance(), true ),
|
|
|
|
DARKMAGENTA ) );
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "NC Width" ),
|
|
|
|
::CoordinateToString( netclass->GetTrackWidth(), true ),
|
|
|
|
DARKMAGENTA ) );
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "NC Via Size" ),
|
|
|
|
::CoordinateToString( netclass->GetViaDiameter(), true ),
|
|
|
|
DARKMAGENTA ) );
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "NC Via Drill"),
|
|
|
|
::CoordinateToString( netclass->GetViaDrill(), true ),
|
|
|
|
DARKMAGENTA ) );
|
2011-03-11 15:53:28 +00:00
|
|
|
}
|
2009-10-14 18:14:58 +00:00
|
|
|
}
|
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
void TRACK::GetMsgPanelInfoBase_Common( std::vector< MSG_PANEL_ITEM >& aList )
|
2007-08-20 19:33:15 +00:00
|
|
|
{
|
2008-12-14 19:45:05 +00:00
|
|
|
wxString msg;
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
// Display Net Name
|
|
|
|
if( GetBoard() )
|
2007-08-20 19:33:15 +00:00
|
|
|
{
|
2014-02-25 10:40:34 +00:00
|
|
|
NETINFO_ITEM* net = 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
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "NetName" ), msg, RED ) );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
// Display net code : (useful in test or debug)
|
2017-03-28 16:30:49 +00:00
|
|
|
msg.Printf( wxT( "%d" ), GetNetCode() );
|
2013-01-12 17:32:24 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "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 );
|
2013-01-12 17:32:24 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( wxT( "Flags" ), msg, BLUE ) );
|
2011-09-22 19:16:55 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
// Display start and end pointers:
|
|
|
|
msg.Printf( wxT( "%p" ), start );
|
2013-01-12 17:32:24 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( wxT( "start ptr" ), msg, BLUE ) );
|
2011-09-22 19:16:55 +00:00
|
|
|
msg.Printf( wxT( "%p" ), end );
|
2013-01-12 17:32:24 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( wxT( "end ptr" ), msg, BLUE ) );
|
2011-09-22 19:16:55 +00:00
|
|
|
// Display this ptr
|
|
|
|
msg.Printf( wxT( "%p" ), this );
|
2013-01-12 17:32:24 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( wxT( "this" ), msg, BLUE ) );
|
2011-09-22 19:16:55 +00:00
|
|
|
#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 );
|
2013-01-12 17:32:24 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( wxT( "Start pos" ), msg, BLUE ) );
|
2011-09-22 19:16:55 +00:00
|
|
|
msg.Printf( wxT( "%d %d" ), m_End.x, m_End.y );
|
2013-01-12 17:32:24 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( 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)
|
|
|
|
|
2014-04-25 06:00:04 +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 ) )
|
2016-05-04 14:35:12 +00:00
|
|
|
msg[0] = 'L';
|
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
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Status" ), msg, MAGENTA ) );
|
2014-04-25 06:00:04 +00:00
|
|
|
}
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
void TRACK::GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
BOARD* board = GetBoard();
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Type" ), _( "Track" ), DARKCYAN ) );
|
|
|
|
|
|
|
|
GetMsgPanelInfoBase_Common( aList );
|
|
|
|
|
|
|
|
// Display layer
|
|
|
|
if( board )
|
|
|
|
msg = board->GetLayerName( m_Layer );
|
2007-08-20 19:33:15 +00:00
|
|
|
else
|
2014-04-25 06:00:04 +00:00
|
|
|
msg.Printf(wxT("%d"), m_Layer );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), msg, BROWN ) );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2013-04-07 11:55:18 +00:00
|
|
|
// Display width
|
2013-01-12 17:32:24 +00:00
|
|
|
msg = ::CoordinateToString( (unsigned) m_Width );
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, DARKCYAN ) );
|
2007-08-20 19:33:15 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
// Display segment length
|
|
|
|
msg = ::LengthDoubleToString( GetLength() );
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Segment Length" ), msg, DARKCYAN ) );
|
|
|
|
}
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
void SEGZONE::GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
BOARD* board = GetBoard();
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Type" ), _( "Zone " ), DARKCYAN ) );
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
GetMsgPanelInfoBase_Common( aList );
|
2007-10-19 06:31:17 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
// Display layer
|
|
|
|
if( board )
|
|
|
|
msg = board->GetLayerName( m_Layer );
|
2007-08-20 19:33:15 +00:00
|
|
|
else
|
2014-11-15 19:06:05 +00:00
|
|
|
msg.Printf( wxT( "%d" ), m_Layer );
|
2014-04-25 06:00:04 +00:00
|
|
|
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), msg, BROWN ) );
|
|
|
|
|
|
|
|
// Display width
|
|
|
|
msg = ::CoordinateToString( (unsigned) m_Width );
|
|
|
|
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, DARKCYAN ) );
|
2009-10-10 17:27:53 +00:00
|
|
|
|
|
|
|
// Display segment length
|
2014-04-25 06:00:04 +00:00
|
|
|
msg = ::LengthDoubleToString( GetLength() );
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Segment Length" ), msg, DARKCYAN ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
void VIA::GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
BOARD* board = GetBoard();
|
|
|
|
|
|
|
|
switch( GetViaType() )
|
2009-10-10 17:27:53 +00:00
|
|
|
{
|
2014-04-25 06:00:04 +00:00
|
|
|
default:
|
|
|
|
case VIA_NOT_DEFINED:
|
|
|
|
msg = wxT( "???" ); // Not used yet, does not exist currently
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIA_MICROVIA:
|
|
|
|
msg = _( "Micro Via" ); // from external layer (TOP or BOTTOM) from
|
|
|
|
// the near neighbor inner layer only
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIA_BLIND_BURIED:
|
|
|
|
msg = _( "Blind/Buried Via" ); // from inner or external to inner
|
|
|
|
// or external layer (no restriction)
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIA_THROUGH:
|
|
|
|
msg = _( "Through Via" ); // Usual via (from TOP to BOTTOM layer only )
|
|
|
|
break;
|
2009-10-10 17:27:53 +00:00
|
|
|
}
|
2014-04-25 06:00:04 +00:00
|
|
|
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg, DARKCYAN ) );
|
|
|
|
|
|
|
|
GetMsgPanelInfoBase_Common( aList );
|
|
|
|
|
|
|
|
|
|
|
|
// Display layer pair
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID top_layer, bottom_layer;
|
2014-04-25 06:00:04 +00:00
|
|
|
|
|
|
|
LayerPair( &top_layer, &bottom_layer );
|
2015-06-18 13:19:30 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
if( board )
|
|
|
|
msg = board->GetLayerName( top_layer ) + wxT( "/" )
|
|
|
|
+ board->GetLayerName( bottom_layer );
|
|
|
|
else
|
2014-11-15 19:06:05 +00:00
|
|
|
msg.Printf( wxT( "%d/%d" ), top_layer, bottom_layer );
|
2014-04-25 06:00:04 +00:00
|
|
|
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Layers" ), msg, BROWN ) );
|
|
|
|
|
|
|
|
// Display width
|
|
|
|
msg = ::CoordinateToString( (unsigned) m_Width );
|
|
|
|
|
|
|
|
// Display diameter value:
|
2014-11-15 19:06:05 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Diameter" ), msg, DARKCYAN ) );
|
2014-04-25 06:00:04 +00:00
|
|
|
|
|
|
|
// Display drill value
|
|
|
|
int drill_value = GetDrillValue();
|
|
|
|
|
|
|
|
msg = ::CoordinateToString( drill_value );
|
|
|
|
|
|
|
|
wxString title = _( "Drill" );
|
|
|
|
title += wxT( " " );
|
|
|
|
|
2015-06-18 13:19:30 +00:00
|
|
|
bool drl_specific = true;
|
|
|
|
|
|
|
|
if( GetBoard() )
|
|
|
|
{
|
|
|
|
NETINFO_ITEM* net = GetNet();
|
|
|
|
int drill_class_value = 0;
|
|
|
|
|
|
|
|
if( net )
|
|
|
|
{
|
|
|
|
if( GetViaType() == VIA_MICROVIA )
|
|
|
|
drill_class_value = net->GetMicroViaDrillSize();
|
|
|
|
else
|
|
|
|
drill_class_value = net->GetViaDrillSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
drl_specific = drill_value != drill_class_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if( drl_specific )
|
2014-04-25 06:00:04 +00:00
|
|
|
title += _( "(Specific)" );
|
|
|
|
else
|
2015-06-18 13:19:30 +00:00
|
|
|
title += _( "(NetClass)" );
|
2014-04-25 06:00:04 +00:00
|
|
|
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( title, msg, RED ) );
|
2007-08-20 19:33:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-05-06 15:14:47 +00:00
|
|
|
bool TRACK::HitTest( const wxPoint& aPosition ) const
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
2014-05-01 06:50:11 +00:00
|
|
|
return TestSegmentHit( aPosition, m_Start, m_End, m_Width / 2 );
|
|
|
|
}
|
2008-03-05 22:39:33 +00:00
|
|
|
|
2014-05-04 17:08:36 +00:00
|
|
|
bool VIA::HitTest( const wxPoint& aPosition ) const
|
2014-05-01 06:50:11 +00:00
|
|
|
{
|
|
|
|
int max_dist = m_Width / 2;
|
2008-03-05 22:39:33 +00:00
|
|
|
|
2014-05-01 06:50:11 +00:00
|
|
|
// rel_pos is aPosition relative to m_Start (or the center of the via)
|
|
|
|
wxPoint rel_pos = aPosition - m_Start;
|
|
|
|
double dist = (double) rel_pos.x * rel_pos.x + (double) rel_pos.y * rel_pos.y;
|
|
|
|
return dist <= (double) max_dist * max_dist;
|
2007-10-19 06:31:17 +00:00
|
|
|
}
|
2007-08-09 01:41:30 +00:00
|
|
|
|
2008-12-14 19:45:05 +00:00
|
|
|
|
2013-09-21 18:09:41 +00:00
|
|
|
bool TRACK::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
|
2008-01-06 12:43:57 +00:00
|
|
|
{
|
2013-09-21 18:09:41 +00:00
|
|
|
EDA_RECT arect = aRect;
|
|
|
|
arect.Inflate( aAccuracy );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-05-01 06:50:11 +00:00
|
|
|
if( aContained )
|
|
|
|
/* Tracks are a special case:
|
|
|
|
* they are considered inside the rect if one end is inside the rect */
|
|
|
|
return arect.Contains( GetStart() ) || arect.Contains( GetEnd() );
|
2013-09-21 18:09:41 +00:00
|
|
|
else
|
2014-05-01 06:50:11 +00:00
|
|
|
return arect.Intersects( GetStart(), GetEnd() );
|
2008-01-06 12:43:57 +00:00
|
|
|
}
|
|
|
|
|
2014-05-01 06:50:11 +00:00
|
|
|
bool VIA::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
|
2011-09-14 20:04:58 +00:00
|
|
|
{
|
2013-09-21 18:09:41 +00:00
|
|
|
EDA_RECT box;
|
|
|
|
EDA_RECT arect = aRect;
|
|
|
|
arect.Inflate( aAccuracy );
|
2011-09-14 20:04:58 +00:00
|
|
|
|
2014-05-01 06:50:11 +00:00
|
|
|
box.SetOrigin( GetStart() );
|
|
|
|
box.Inflate( GetWidth() / 2 );
|
2011-09-14 20:04:58 +00:00
|
|
|
|
2014-05-01 06:50:11 +00:00
|
|
|
if( aContained )
|
2017-07-03 10:36:22 +00:00
|
|
|
{
|
2014-05-01 06:50:11 +00:00
|
|
|
return arect.Contains( box );
|
2017-07-03 10:36:22 +00:00
|
|
|
}
|
2013-09-21 18:09:41 +00:00
|
|
|
else
|
2017-07-03 10:36:22 +00:00
|
|
|
{
|
|
|
|
return arect.IntersectsCircle( GetStart(), GetWidth() / 2 );
|
|
|
|
}
|
2008-01-06 12:43:57 +00:00
|
|
|
}
|
2011-09-14 20:04:58 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
VIA* TRACK::GetVia( const wxPoint& aPosition, PCB_LAYER_ID aLayer)
|
2011-09-14 20:04:58 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
for( VIA* via = GetFirstVia( this ); via; via = GetFirstVia( via->Next() ) )
|
2011-09-14 20:04:58 +00:00
|
|
|
{
|
2014-05-01 06:50:11 +00:00
|
|
|
if( via->HitTest( aPosition ) &&
|
|
|
|
!via->GetState( BUSY | IS_DELETED ) &&
|
|
|
|
((aLayer == UNDEFINED_LAYER) || (via->IsOnLayer( aLayer ))) )
|
|
|
|
return via;
|
2011-09-14 20:04:58 +00:00
|
|
|
}
|
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
return NULL;
|
2011-09-14 20:04:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
VIA* TRACK::GetVia( TRACK* aEndTrace, const wxPoint& aPosition, LSET aLayerMask )
|
2011-09-14 20:04:58 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
for( VIA* via = GetFirstVia( this, aEndTrace ); via; via = GetFirstVia( via->Next() ) )
|
2011-09-14 20:04:58 +00:00
|
|
|
{
|
2014-05-01 06:50:11 +00:00
|
|
|
if( via->HitTest( aPosition ) &&
|
2014-06-24 16:17:18 +00:00
|
|
|
!via->GetState( BUSY | IS_DELETED ) &&
|
|
|
|
( aLayerMask & via->GetLayerSet() ).any()
|
|
|
|
)
|
|
|
|
{
|
2014-05-01 06:50:11 +00:00
|
|
|
return via;
|
2014-06-24 16:17:18 +00:00
|
|
|
}
|
2011-09-14 20:04:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-05-17 17:36:02 +00:00
|
|
|
TRACK* TRACK::GetTrack( TRACK* aStartTrace, TRACK* aEndTrace, ENDPOINT_T aEndPoint,
|
|
|
|
bool aSameNetOnly, bool aSequential )
|
2011-09-16 14:13:02 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
const wxPoint& position = GetEndPoint( aEndPoint );
|
|
|
|
LSET refLayers = GetLayerSet();
|
|
|
|
TRACK* previousSegment;
|
|
|
|
TRACK* nextSegment;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2014-05-17 17:36:02 +00:00
|
|
|
if( aSequential )
|
|
|
|
{
|
|
|
|
// Simple sequential search: from aStartTrace forward to aEndTrace
|
|
|
|
previousSegment = NULL;
|
|
|
|
nextSegment = aStartTrace;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Local bidirectional search: from this backward to aStartTrace
|
|
|
|
* AND forward to aEndTrace. The idea is that nearest segments
|
|
|
|
* are found (on average) faster in this way. In fact same-net
|
|
|
|
* segments are almost guaranteed to be found faster, in a global
|
|
|
|
* search, since they are grouped together in the track list */
|
|
|
|
previousSegment = this;
|
|
|
|
nextSegment = this;
|
|
|
|
}
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2014-05-17 17:36:02 +00:00
|
|
|
while( nextSegment || previousSegment )
|
2011-09-16 14:13:02 +00:00
|
|
|
{
|
2016-07-12 19:05:54 +00:00
|
|
|
// Terminate the search in the direction if the netcode mis-matches
|
2014-05-17 17:36:02 +00:00
|
|
|
if( aSameNetOnly )
|
|
|
|
{
|
|
|
|
if( nextSegment && (nextSegment->GetNetCode() != GetNetCode()) )
|
|
|
|
nextSegment = NULL;
|
|
|
|
if( previousSegment && (previousSegment->GetNetCode() != GetNetCode()) )
|
|
|
|
previousSegment = NULL;
|
|
|
|
}
|
2011-09-16 14:13:02 +00:00
|
|
|
|
|
|
|
if( nextSegment )
|
|
|
|
{
|
2014-06-02 16:16:06 +00:00
|
|
|
if ( (nextSegment != this) &&
|
2014-05-17 17:36:02 +00:00
|
|
|
!nextSegment->GetState( BUSY | IS_DELETED ) &&
|
2014-06-24 16:17:18 +00:00
|
|
|
( refLayers & nextSegment->GetLayerSet() ).any() )
|
2011-09-16 14:13:02 +00:00
|
|
|
{
|
2014-05-17 17:36:02 +00:00
|
|
|
if( (position == nextSegment->m_Start) ||
|
|
|
|
(position == nextSegment->m_End) )
|
2011-09-16 14:13:02 +00:00
|
|
|
return nextSegment;
|
|
|
|
}
|
|
|
|
|
2014-05-17 17:36:02 +00:00
|
|
|
// Keep looking forward
|
2011-09-16 14:13:02 +00:00
|
|
|
if( nextSegment == aEndTrace )
|
|
|
|
nextSegment = NULL;
|
|
|
|
else
|
2014-05-17 17:36:02 +00:00
|
|
|
nextSegment = nextSegment->Next();
|
2011-09-16 14:13:02 +00:00
|
|
|
}
|
|
|
|
|
2014-05-17 17:36:02 +00:00
|
|
|
// Same as above, looking back. During sequential search this branch is inactive
|
2011-09-16 14:13:02 +00:00
|
|
|
if( previousSegment )
|
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
if( (previousSegment != this) &&
|
|
|
|
!previousSegment->GetState( BUSY | IS_DELETED ) &&
|
|
|
|
( refLayers & previousSegment->GetLayerSet() ).any()
|
|
|
|
)
|
2011-09-16 14:13:02 +00:00
|
|
|
{
|
2014-05-17 17:36:02 +00:00
|
|
|
if( (position == previousSegment->m_Start) ||
|
|
|
|
(position == previousSegment->m_End) )
|
2011-09-16 14:13:02 +00:00
|
|
|
return previousSegment;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( previousSegment == aStartTrace )
|
|
|
|
previousSegment = NULL;
|
|
|
|
else
|
2014-05-17 17:36:02 +00:00
|
|
|
previousSegment = previousSegment->Back();
|
2011-09-16 14:13:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int TRACK::GetEndSegments( int aCount, TRACK** aStartTrace, TRACK** aEndTrace )
|
|
|
|
{
|
|
|
|
TRACK* Track, * via, * segm, * TrackListEnd;
|
2013-03-30 17:24:04 +00:00
|
|
|
int NbEnds, ii, ok = 0;
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET layerMask;
|
2011-09-16 14:13:02 +00:00
|
|
|
|
|
|
|
if( aCount <= 1 )
|
|
|
|
{
|
|
|
|
*aStartTrace = *aEndTrace = this;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
// Calculation of the limit analysis.
|
2011-09-16 14:13:02 +00:00
|
|
|
*aStartTrace = *aEndTrace = NULL;
|
|
|
|
TrackListEnd = Track = this;
|
|
|
|
ii = 0;
|
|
|
|
|
|
|
|
for( ; ( Track != NULL ) && ( ii < aCount ); ii++, Track = Track->Next() )
|
|
|
|
{
|
|
|
|
TrackListEnd = Track;
|
|
|
|
Track->m_Param = 0;
|
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
// Calculate the extremes.
|
2011-09-16 14:13:02 +00:00
|
|
|
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;
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
layerMask = Track->GetLayerSet();
|
2011-09-16 14:13:02 +00:00
|
|
|
via = GetVia( TrackListEnd, Track->m_Start, layerMask );
|
|
|
|
|
|
|
|
if( via )
|
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
layerMask |= via->GetLayerSet();
|
2013-03-28 19:12:46 +00:00
|
|
|
via->SetState( BUSY, true );
|
2011-09-16 14:13:02 +00:00
|
|
|
}
|
|
|
|
|
2013-03-28 19:12:46 +00:00
|
|
|
Track->SetState( BUSY, true );
|
2014-04-25 06:00:04 +00:00
|
|
|
segm = ::GetTrack( this, TrackListEnd, Track->m_Start, layerMask );
|
2013-03-28 19:12:46 +00:00
|
|
|
Track->SetState( BUSY, false );
|
2011-09-16 14:13:02 +00:00
|
|
|
|
|
|
|
if( via )
|
2013-03-28 19:12:46 +00:00
|
|
|
via->SetState( BUSY, false );
|
2011-09-16 14:13:02 +00:00
|
|
|
|
|
|
|
if( segm == NULL )
|
|
|
|
{
|
|
|
|
switch( NbEnds )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
*aStartTrace = Track; NbEnds++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
int BeginPad, EndPad;
|
|
|
|
*aEndTrace = Track;
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
// Swap ox, oy with fx, fy
|
2011-09-16 14:13:02 +00:00
|
|
|
BeginPad = Track->GetState( BEGIN_ONPAD );
|
|
|
|
EndPad = Track->GetState( END_ONPAD );
|
|
|
|
|
2013-03-28 19:12:46 +00:00
|
|
|
Track->SetState( BEGIN_ONPAD | END_ONPAD, false );
|
2011-09-16 14:13:02 +00:00
|
|
|
|
|
|
|
if( BeginPad )
|
2013-03-28 19:12:46 +00:00
|
|
|
Track->SetState( END_ONPAD, true );
|
2011-09-16 14:13:02 +00:00
|
|
|
|
|
|
|
if( EndPad )
|
2013-03-28 19:12:46 +00:00
|
|
|
Track->SetState( BEGIN_ONPAD, true );
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2015-06-26 13:41:56 +00:00
|
|
|
std::swap( Track->m_Start, Track->m_End );
|
|
|
|
std::swap( Track->start, Track->end );
|
2011-09-16 14:13:02 +00:00
|
|
|
ok = 1;
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
layerMask = Track->GetLayerSet();
|
2011-09-16 14:13:02 +00:00
|
|
|
via = GetVia( TrackListEnd, Track->m_End, layerMask );
|
|
|
|
|
|
|
|
if( via )
|
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
layerMask |= via->GetLayerSet();
|
2013-03-28 19:12:46 +00:00
|
|
|
via->SetState( BUSY, true );
|
2011-09-16 14:13:02 +00:00
|
|
|
}
|
|
|
|
|
2013-03-28 19:12:46 +00:00
|
|
|
Track->SetState( BUSY, true );
|
2014-04-25 06:00:04 +00:00
|
|
|
segm = ::GetTrack( this, TrackListEnd, Track->m_End, layerMask );
|
2013-03-28 19:12:46 +00:00
|
|
|
Track->SetState( BUSY, false );
|
2011-09-16 14:13:02 +00:00
|
|
|
|
|
|
|
if( via )
|
2013-03-28 19:12:46 +00:00
|
|
|
via->SetState( BUSY, false );
|
2011-09-16 14:13:02 +00:00
|
|
|
|
|
|
|
if( segm == NULL )
|
|
|
|
{
|
|
|
|
switch( NbEnds )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
int BeginPad, EndPad;
|
|
|
|
*aStartTrace = Track;
|
|
|
|
NbEnds++;
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
// Swap ox, oy with fx, fy
|
2011-09-16 14:13:02 +00:00
|
|
|
BeginPad = Track->GetState( BEGIN_ONPAD );
|
|
|
|
EndPad = Track->GetState( END_ONPAD );
|
|
|
|
|
2013-03-28 19:12:46 +00:00
|
|
|
Track->SetState( BEGIN_ONPAD | END_ONPAD, false );
|
2011-09-16 14:13:02 +00:00
|
|
|
|
|
|
|
if( BeginPad )
|
2013-03-28 19:12:46 +00:00
|
|
|
Track->SetState( END_ONPAD, true );
|
2011-09-16 14:13:02 +00:00
|
|
|
|
|
|
|
if( EndPad )
|
2013-03-28 19:12:46 +00:00
|
|
|
Track->SetState( BEGIN_ONPAD, true );
|
2011-09-16 14:13:02 +00:00
|
|
|
|
2015-06-26 13:41:56 +00:00
|
|
|
std::swap( Track->m_Start, Track->m_End );
|
|
|
|
std::swap( Track->start, Track->end );
|
2011-09-16 14:13:02 +00:00
|
|
|
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;
|
2013-04-08 07:13:26 +00:00
|
|
|
wxString netname;
|
2011-07-14 15:42:44 +00:00
|
|
|
NETINFO_ITEM* net;
|
|
|
|
BOARD* board = GetBoard();
|
|
|
|
|
|
|
|
// deleting tracks requires all the information we can get to
|
|
|
|
// disambiguate all the choices under the cursor!
|
|
|
|
if( board )
|
|
|
|
{
|
2014-02-25 10:40:34 +00:00
|
|
|
net = GetNet();
|
2011-07-14 15:42:44 +00:00
|
|
|
|
|
|
|
if( net )
|
2013-04-08 07:13:26 +00:00
|
|
|
netname = net->GetNetname();
|
|
|
|
else
|
|
|
|
netname = _("Not found");
|
2011-07-14 15:42:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-04-07 11:55:18 +00:00
|
|
|
wxFAIL_MSG( wxT( "TRACK::GetSelectMenuText: BOARD is NULL" ) );
|
2013-04-08 07:13:26 +00:00
|
|
|
netname = wxT( "???" );
|
2011-07-14 15:42:44 +00:00
|
|
|
}
|
|
|
|
|
2013-04-08 07:13:26 +00:00
|
|
|
text.Printf( _("Track %s, net [%s] (%d) on layer %s, length: %s" ),
|
|
|
|
GetChars( ShowWidth() ), GetChars( netname ),
|
2014-02-25 10:40:34 +00:00
|
|
|
GetNetCode(), GetChars( GetLayerName() ),
|
2013-04-08 07:13:26 +00:00
|
|
|
GetChars( ::LengthDoubleToString( GetLength() ) ) );
|
2011-07-14 15:42:44 +00:00
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-31 13:59:03 +00:00
|
|
|
BITMAP_DEF TRACK::GetMenuImage() const
|
2017-02-20 12:20:39 +00:00
|
|
|
{
|
2017-12-13 18:42:33 +00:00
|
|
|
return add_tracks_xpm;
|
2017-02-20 12:20:39 +00:00
|
|
|
}
|
|
|
|
|
2017-10-31 13:59:03 +00:00
|
|
|
void TRACK::SwapData( BOARD_ITEM* aImage )
|
|
|
|
{
|
|
|
|
assert( aImage->Type() == PCB_TRACE_T );
|
|
|
|
|
|
|
|
std::swap( *((TRACK*) this), *((TRACK*) aImage) );
|
|
|
|
}
|
|
|
|
|
|
|
|
void VIA::SwapData( BOARD_ITEM* aImage )
|
|
|
|
{
|
|
|
|
assert( aImage->Type() == PCB_VIA_T );
|
|
|
|
|
|
|
|
std::swap( *((VIA*) this), *((VIA*) aImage) );
|
|
|
|
}
|
2017-02-20 12:20:39 +00:00
|
|
|
|
2009-05-21 12:45:21 +00:00
|
|
|
#if defined(DEBUG)
|
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
|