2011-09-30 18:15:37 +00:00
|
|
|
/**
|
|
|
|
* @file drc_marker_functions.cpp
|
2011-09-23 20:00:30 +00:00
|
|
|
*/
|
2011-09-30 18:15:37 +00:00
|
|
|
|
2011-09-23 20:00:30 +00:00
|
|
|
/*
|
2011-09-30 18:15:37 +00:00
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
2011-09-23 20:00:30 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Dick Hollenbeck, dick@softplc.com
|
2017-03-16 17:09:33 +00:00
|
|
|
* Copyright (C) 2004-2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2018-01-28 21:02:31 +00:00
|
|
|
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-09-23 20:00:30 +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
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/* Methods of class DRC to initialize drc markers with messages
|
2015-06-18 13:19:30 +00:00
|
|
|
* according to items and error code
|
2011-09-23 20:00:30 +00:00
|
|
|
*/
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <common.h>
|
|
|
|
#include <pcbnew.h>
|
2018-02-02 20:57:12 +00:00
|
|
|
#include <board_design_settings.h>
|
2011-09-23 20:00:30 +00:00
|
|
|
|
2018-01-28 21:02:31 +00:00
|
|
|
#include <drc.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_pad.h>
|
|
|
|
#include <class_track.h>
|
|
|
|
#include <class_zone.h>
|
|
|
|
#include <class_marker_pcb.h>
|
2014-08-13 15:47:02 +00:00
|
|
|
#include <class_pcb_text.h>
|
2018-01-28 09:35:33 +00:00
|
|
|
#include <class_board_item.h>
|
2011-09-23 20:00:30 +00:00
|
|
|
|
|
|
|
|
2018-01-28 09:35:33 +00:00
|
|
|
MARKER_PCB* DRC::fillMarker( TRACK* aTrack, BOARD_ITEM* bItem, int aErrorCode, MARKER_PCB* fillMe )
|
2011-09-23 20:00:30 +00:00
|
|
|
{
|
2018-01-28 09:35:33 +00:00
|
|
|
wxPoint posA;
|
|
|
|
wxPoint posB = wxPoint();
|
2011-09-23 20:00:30 +00:00
|
|
|
|
2018-01-28 09:35:33 +00:00
|
|
|
if( bItem ) // aItem might be NULL
|
2011-09-23 20:00:30 +00:00
|
|
|
{
|
2018-01-28 09:35:33 +00:00
|
|
|
if( bItem->Type() == PCB_PAD_T )
|
2011-10-01 19:24:27 +00:00
|
|
|
{
|
2018-01-28 09:35:33 +00:00
|
|
|
posB = posA = ((D_PAD*)bItem)->GetPosition();
|
2011-10-01 19:24:27 +00:00
|
|
|
}
|
2018-01-28 09:35:33 +00:00
|
|
|
else if( bItem->Type() == PCB_VIA_T )
|
2011-10-01 19:24:27 +00:00
|
|
|
{
|
2018-01-28 09:35:33 +00:00
|
|
|
posB = posA = ((VIA*)bItem)->GetPosition();
|
2011-10-01 19:24:27 +00:00
|
|
|
}
|
2018-01-28 09:35:33 +00:00
|
|
|
else if( bItem->Type() == PCB_TRACE_T )
|
2011-09-23 20:00:30 +00:00
|
|
|
{
|
2018-01-28 09:35:33 +00:00
|
|
|
TRACK* track = (TRACK*) bItem;
|
2012-02-20 04:33:54 +00:00
|
|
|
|
|
|
|
posB = track->GetPosition();
|
|
|
|
|
2013-01-13 00:04:00 +00:00
|
|
|
wxPoint endPos = track->GetEnd();
|
2011-09-23 20:00:30 +00:00
|
|
|
|
|
|
|
// either of aItem's start or end will be used for the marker position
|
|
|
|
// first assume start, then switch at end if needed. decision made on
|
|
|
|
// distance from end of aTrack.
|
2018-01-28 09:35:33 +00:00
|
|
|
posA = track->GetStart();
|
2011-09-23 20:00:30 +00:00
|
|
|
|
2013-05-01 17:32:36 +00:00
|
|
|
double dToEnd = GetLineLength( endPos, aTrack->GetEnd() );
|
2018-01-28 09:35:33 +00:00
|
|
|
double dToStart = GetLineLength( posA, aTrack->GetEnd() );
|
2011-09-23 20:00:30 +00:00
|
|
|
|
|
|
|
if( dToEnd < dToStart )
|
2018-01-28 09:35:33 +00:00
|
|
|
posA = endPos;
|
2011-09-23 20:00:30 +00:00
|
|
|
}
|
2018-01-28 09:35:33 +00:00
|
|
|
else if( bItem->Type() == PCB_TEXT_T )
|
2014-08-13 15:47:02 +00:00
|
|
|
{
|
2018-01-28 09:35:33 +00:00
|
|
|
posA = aTrack->GetPosition();
|
|
|
|
posB = ((TEXTE_PCB*) bItem)->GetPosition();
|
2014-08-13 15:47:02 +00:00
|
|
|
}
|
2011-09-23 20:00:30 +00:00
|
|
|
}
|
|
|
|
else
|
2018-01-28 09:35:33 +00:00
|
|
|
posA = aTrack->GetPosition();
|
2011-09-23 20:00:30 +00:00
|
|
|
|
|
|
|
if( fillMe )
|
2018-06-15 04:49:50 +00:00
|
|
|
fillMe->SetData( m_units, aErrorCode, posA, aTrack, aTrack->GetPosition(), bItem, posB );
|
2011-09-23 20:00:30 +00:00
|
|
|
else
|
2018-06-15 04:49:50 +00:00
|
|
|
fillMe = new MARKER_PCB( m_units, aErrorCode, posA, aTrack, aTrack->GetPosition(), bItem, posB );
|
2011-09-23 20:00:30 +00:00
|
|
|
|
|
|
|
return fillMe;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-13 15:47:02 +00:00
|
|
|
MARKER_PCB* DRC::fillMarker( D_PAD* aPad, BOARD_ITEM* aItem, int aErrorCode, MARKER_PCB* fillMe )
|
2011-09-23 20:00:30 +00:00
|
|
|
{
|
|
|
|
wxPoint posA = aPad->GetPosition();
|
2014-08-13 15:47:02 +00:00
|
|
|
wxPoint posB;
|
|
|
|
|
|
|
|
if( aItem )
|
|
|
|
{
|
|
|
|
switch( aItem->Type() )
|
|
|
|
{
|
|
|
|
case PCB_PAD_T:
|
|
|
|
posB = ((D_PAD*)aItem)->GetPosition();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PCB_TEXT_T:
|
|
|
|
posB = ((TEXTE_PCB*)aItem)->GetPosition();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
wxLogDebug( wxT("fillMarker: unsupported item") );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-09-23 20:00:30 +00:00
|
|
|
|
|
|
|
if( fillMe )
|
2018-06-15 04:49:50 +00:00
|
|
|
fillMe->SetData( m_units, aErrorCode, posA, aPad, posA, aItem, posB );
|
2011-09-23 20:00:30 +00:00
|
|
|
else
|
2018-06-15 04:49:50 +00:00
|
|
|
fillMe = new MARKER_PCB( m_units, aErrorCode, posA, aPad, posA, aItem, posB );
|
2011-09-23 20:00:30 +00:00
|
|
|
|
|
|
|
return fillMe;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-28 09:35:33 +00:00
|
|
|
MARKER_PCB* DRC::fillMarker(BOARD_ITEM *aItem, const wxPoint &aPos, int aErrorCode,
|
|
|
|
MARKER_PCB *fillMe)
|
2011-09-23 20:00:30 +00:00
|
|
|
{
|
2018-01-28 09:35:33 +00:00
|
|
|
return fillMarker(aPos, aItem, nullptr, aErrorCode, fillMe );
|
2011-09-23 20:00:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-28 09:35:33 +00:00
|
|
|
MARKER_PCB* DRC::fillMarker( const wxPoint& aPos, BOARD_ITEM* aItem, BOARD_ITEM* bItem,
|
|
|
|
int aErrorCode, MARKER_PCB* fillMe )
|
2011-09-23 20:00:30 +00:00
|
|
|
{
|
|
|
|
if( fillMe )
|
2018-06-15 04:49:50 +00:00
|
|
|
fillMe->SetData( m_units, aErrorCode, aPos, aItem, aPos, bItem, aPos );
|
2011-09-23 20:00:30 +00:00
|
|
|
else
|
2018-06-15 04:49:50 +00:00
|
|
|
fillMe = new MARKER_PCB( m_units, aErrorCode, aPos, aItem, aPos, bItem, aPos );
|
2011-09-23 20:00:30 +00:00
|
|
|
|
|
|
|
return fillMe;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MARKER_PCB* DRC::fillMarker( int aErrorCode, const wxString& aMessage, MARKER_PCB* fillMe )
|
|
|
|
{
|
|
|
|
wxPoint posA; // not displayed
|
|
|
|
|
|
|
|
if( fillMe )
|
|
|
|
fillMe->SetData( aErrorCode, posA, aMessage, posA );
|
|
|
|
else
|
|
|
|
fillMe = new MARKER_PCB( aErrorCode, posA, aMessage, posA );
|
|
|
|
|
|
|
|
fillMe->SetShowNoCoordinate();
|
|
|
|
|
|
|
|
return fillMe;
|
|
|
|
}
|
|
|
|
|
2017-03-16 17:09:33 +00:00
|
|
|
|