2009-07-06 18:02:26 +00:00
|
|
|
/*
|
2011-09-30 18:15:37 +00:00
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
2009-07-06 18:02:26 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Dick Hollenbeck, dick@softplc.com
|
2018-01-28 21:02:31 +00:00
|
|
|
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
|
2009-07-06 18:02:26 +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
|
|
|
|
*/
|
|
|
|
|
2018-01-28 21:02:31 +00:00
|
|
|
#ifndef DRC_ITEM_H
|
|
|
|
#define DRC_ITEM_H
|
2009-07-06 18:02:26 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <macros.h>
|
2018-04-10 10:52:12 +00:00
|
|
|
#include <base_struct.h>
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2018-03-20 02:25:55 +00:00
|
|
|
class MARKER_BASE;
|
2018-01-28 09:35:33 +00:00
|
|
|
class BOARD;
|
|
|
|
class BOARD_ITEM;
|
2018-03-20 02:25:55 +00:00
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2009-07-06 18:02:26 +00:00
|
|
|
/**
|
|
|
|
* Class DRC_ITEM
|
|
|
|
* is a holder for a DRC (in Pcbnew) or ERC (in Eeschema) error item.
|
2012-03-15 14:31:16 +00:00
|
|
|
* It is generated when two objects are too close (DRC)
|
|
|
|
* or two connected objects (pins) have incompatible electrical types (ERC).
|
2009-07-06 18:02:26 +00:00
|
|
|
* There are holders for information on two items. The
|
|
|
|
* information held is the board coordinate and the MenuText for each item.
|
|
|
|
* Also held is the type of error by number and the location of the MARKER.
|
|
|
|
* A function is provided to translate that number into text.
|
|
|
|
* Some errors involve only one item (item with an incorrect param) so
|
|
|
|
* m_hasSecondItem is set to false in this case.
|
|
|
|
*/
|
|
|
|
class DRC_ITEM
|
|
|
|
{
|
|
|
|
protected:
|
2018-01-28 09:35:33 +00:00
|
|
|
int m_ErrorCode; // the error code's numeric value
|
|
|
|
wxString m_MainText; // text for the first BOARD_ITEM or SCH_ITEM
|
|
|
|
wxString m_AuxiliaryText; // text for the second BOARD_ITEM or SCH_ITEM
|
|
|
|
wxPoint m_MainPosition; // the location of the first (or main ) BOARD_ITEM or SCH_ITEM.
|
|
|
|
wxPoint m_AuxiliaryPosition; // the location of the second BOARD_ITEM or SCH_ITEM
|
|
|
|
bool m_hasSecondItem; // true when 2 items create a DRC/ERC error, false if only one item
|
|
|
|
bool m_noCoordinate;
|
|
|
|
|
|
|
|
MARKER_BASE* m_parent; // The marker this item belongs to, if any
|
|
|
|
void* m_mainItemWeakRef; // search the current BOARD_ITEMs or SCH_ITEMs for a match
|
|
|
|
void* m_auxItemWeakRef; // search the current BOARD_ITEMs or SCH_ITEMs for a match
|
2018-03-20 02:25:55 +00:00
|
|
|
|
2009-07-06 18:02:26 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
DRC_ITEM()
|
|
|
|
{
|
2018-01-28 09:35:33 +00:00
|
|
|
m_ErrorCode = 0;
|
|
|
|
m_hasSecondItem = false;
|
|
|
|
m_noCoordinate = false;
|
|
|
|
m_parent = nullptr;
|
|
|
|
m_mainItemWeakRef = nullptr;
|
|
|
|
m_auxItemWeakRef = nullptr;
|
2009-07-06 18:02:26 +00:00
|
|
|
}
|
|
|
|
|
2018-06-15 04:49:50 +00:00
|
|
|
DRC_ITEM( EDA_UNITS_T aUnits, int aErrorCode, EDA_ITEM* aMainItem, const wxPoint& aMainPos,
|
2018-01-28 09:35:33 +00:00
|
|
|
EDA_ITEM* bAuxiliaryItem, const wxPoint& bAuxiliaryPos )
|
2009-07-06 18:02:26 +00:00
|
|
|
{
|
2018-06-15 04:49:50 +00:00
|
|
|
SetData( aUnits, aErrorCode, aMainItem, aMainPos, bAuxiliaryItem, bAuxiliaryPos );
|
2009-07-06 18:02:26 +00:00
|
|
|
}
|
|
|
|
|
2019-06-01 16:49:33 +00:00
|
|
|
DRC_ITEM( EDA_UNITS_T aUnits, int aErrorCode, EDA_ITEM* aMainItem, const wxPoint& aMainPos )
|
|
|
|
{
|
|
|
|
SetData( aUnits, aErrorCode, aMainItem, aMainPos );
|
|
|
|
}
|
|
|
|
|
2009-07-06 18:02:26 +00:00
|
|
|
|
2019-03-28 19:30:51 +00:00
|
|
|
DRC_ITEM( int aErrorCode, const wxString& aMainText )
|
|
|
|
{
|
|
|
|
SetData( aErrorCode, aMainText, wxPoint() );
|
|
|
|
SetShowNoCoordinate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function SetData
|
2009-07-08 15:42:45 +00:00
|
|
|
* initialize all data in item
|
|
|
|
* @param aErrorCode = error code
|
2018-01-28 09:35:33 +00:00
|
|
|
* @param aMainItem = the first (main) schematic or board item
|
|
|
|
* @param bAuxiliaryItem = the second schematic or board item
|
|
|
|
* @param aMainPos = position the first item and therefore of this issue
|
|
|
|
* @param bAuxiliaryPos = position the second item
|
2009-07-08 15:42:45 +00:00
|
|
|
*/
|
2018-06-15 04:49:50 +00:00
|
|
|
void SetData( EDA_UNITS_T aUnits, int aErrorCode, EDA_ITEM* aMainItem, const wxPoint& aMainPos,
|
2018-01-28 09:35:33 +00:00
|
|
|
EDA_ITEM* bAuxiliaryItem = nullptr, const wxPoint& bAuxiliaryPos = wxPoint() )
|
2009-07-06 18:02:26 +00:00
|
|
|
{
|
2018-01-28 09:35:33 +00:00
|
|
|
m_ErrorCode = aErrorCode;
|
2018-06-15 04:49:50 +00:00
|
|
|
m_MainText = aMainItem->GetSelectMenuText( aUnits );
|
2018-04-10 10:52:12 +00:00
|
|
|
m_AuxiliaryText = wxEmptyString;
|
2018-01-28 09:35:33 +00:00
|
|
|
m_MainPosition = aMainPos;
|
|
|
|
m_AuxiliaryPosition = bAuxiliaryPos;
|
|
|
|
m_hasSecondItem = bAuxiliaryItem != nullptr;
|
|
|
|
m_noCoordinate = false;
|
|
|
|
m_parent = nullptr;
|
|
|
|
|
2018-04-10 10:52:12 +00:00
|
|
|
if( m_hasSecondItem )
|
2018-06-15 04:49:50 +00:00
|
|
|
m_AuxiliaryText = bAuxiliaryItem->GetSelectMenuText( aUnits );
|
2018-04-10 10:52:12 +00:00
|
|
|
|
2018-01-28 09:35:33 +00:00
|
|
|
// Weak references (void*). One must search the BOARD_ITEMS or SCH_ITEMS for a match.
|
|
|
|
m_mainItemWeakRef = aMainItem;
|
|
|
|
m_auxItemWeakRef = bAuxiliaryItem;
|
2009-07-06 18:02:26 +00:00
|
|
|
}
|
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function SetData
|
2009-07-08 15:42:45 +00:00
|
|
|
* initialize all data in item
|
|
|
|
* @param aErrorCode = error code
|
2018-01-28 09:35:33 +00:00
|
|
|
* @param aMainItem = the first (main) schematic or board item
|
|
|
|
* @param bAuxiliaryItem = the second schematic or board item
|
2009-07-08 15:42:45 +00:00
|
|
|
* @param aMainPos = position the first item and therefore of this issue
|
|
|
|
* @param bAuxiliaryPos = position the second item
|
|
|
|
*/
|
2018-01-28 09:35:33 +00:00
|
|
|
void SetData( int aErrorCode, const wxString& aMainText, const wxPoint& aMainPos,
|
|
|
|
const wxString& bAuxiliaryText = wxEmptyString, const wxPoint& bAuxiliaryPos = wxPoint() )
|
2009-07-06 18:02:26 +00:00
|
|
|
{
|
|
|
|
m_ErrorCode = aErrorCode;
|
|
|
|
m_MainText = aMainText;
|
|
|
|
m_AuxiliaryText = bAuxiliaryText;
|
|
|
|
m_MainPosition = aMainPos;
|
|
|
|
m_AuxiliaryPosition = bAuxiliaryPos;
|
2018-01-28 09:35:33 +00:00
|
|
|
m_hasSecondItem = bAuxiliaryText.Length();
|
2014-08-16 18:12:11 +00:00
|
|
|
m_noCoordinate = false;
|
2018-01-28 09:35:33 +00:00
|
|
|
m_parent = nullptr;
|
|
|
|
|
2018-04-10 10:52:12 +00:00
|
|
|
m_mainItemWeakRef = nullptr;
|
|
|
|
m_auxItemWeakRef = nullptr;
|
2009-07-06 18:02:26 +00:00
|
|
|
}
|
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function SetAuxiliaryData
|
2009-07-08 15:42:45 +00:00
|
|
|
* initialize data for the second (auxiliary) item
|
|
|
|
* @param aAuxiliaryText = the second text (main text) concerning the second schematic or board item
|
|
|
|
* @param aAuxiliaryPos = position the second item
|
|
|
|
*/
|
|
|
|
void SetAuxiliaryData( const wxString& aAuxiliaryText, const wxPoint& aAuxiliaryPos )
|
|
|
|
{
|
|
|
|
m_AuxiliaryText = aAuxiliaryText;
|
|
|
|
m_AuxiliaryPosition = aAuxiliaryPos;
|
|
|
|
m_hasSecondItem = true;
|
2018-01-28 09:35:33 +00:00
|
|
|
|
|
|
|
m_auxItemWeakRef = nullptr;
|
2009-07-08 15:42:45 +00:00
|
|
|
}
|
|
|
|
|
2018-03-20 02:25:55 +00:00
|
|
|
void SetParent( MARKER_BASE* aMarker ) { m_parent = aMarker; }
|
|
|
|
|
|
|
|
MARKER_BASE* GetParent() const { return m_parent; }
|
2009-07-06 18:02:26 +00:00
|
|
|
|
|
|
|
bool HasSecondItem() const { return m_hasSecondItem; }
|
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
void SetShowNoCoordinate() { m_noCoordinate = true; }
|
|
|
|
|
2018-01-28 09:35:33 +00:00
|
|
|
/**
|
|
|
|
* Access to A and B texts
|
2009-07-06 18:02:26 +00:00
|
|
|
*/
|
|
|
|
wxString GetMainText() const { return m_MainText; }
|
|
|
|
wxString GetAuxiliaryText() const { return m_AuxiliaryText; }
|
|
|
|
|
2018-01-28 09:35:33 +00:00
|
|
|
/**
|
|
|
|
* Access to A and B items for BOARDs
|
|
|
|
*/
|
|
|
|
BOARD_ITEM* GetMainItem( BOARD* aBoard ) const;
|
|
|
|
BOARD_ITEM* GetAuxiliaryItem( BOARD* aBoard ) const;
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2009-07-06 18:02:26 +00:00
|
|
|
/**
|
|
|
|
* Function ShowHtml
|
|
|
|
* translates this object into a fragment of HTML suitable for the
|
|
|
|
* wxWidget's wxHtmlListBox class.
|
|
|
|
* @return wxString - the html text.
|
|
|
|
*/
|
2018-06-15 04:49:50 +00:00
|
|
|
wxString ShowHtml( EDA_UNITS_T aUnits ) const;
|
2009-07-06 18:02:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function ShowReport
|
|
|
|
* translates this object into a text string suitable for saving
|
|
|
|
* to disk in a report.
|
|
|
|
* @return wxString - the simple multi-line report text.
|
|
|
|
*/
|
2018-06-15 04:49:50 +00:00
|
|
|
wxString ShowReport( EDA_UNITS_T aUnits ) const;
|
2009-07-06 18:02:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetErrorCode
|
|
|
|
* returns the error code.
|
|
|
|
*/
|
|
|
|
int GetErrorCode() const
|
|
|
|
{
|
|
|
|
return m_ErrorCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetErrorText
|
|
|
|
* returns the string form of a drc error code.
|
2012-03-15 14:31:16 +00:00
|
|
|
*/
|
|
|
|
wxString GetErrorText() const;
|
2009-07-06 18:02:26 +00:00
|
|
|
|
|
|
|
const wxString& GetTextA() const
|
|
|
|
{
|
|
|
|
return m_MainText;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const wxString& GetTextB() const
|
|
|
|
{
|
|
|
|
return m_AuxiliaryText;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const wxPoint& GetPointA() const
|
|
|
|
{
|
|
|
|
return m_MainPosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const wxPoint& GetPointB() const
|
|
|
|
{
|
|
|
|
return m_AuxiliaryPosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function ShowCoord
|
|
|
|
* formats a coordinate or position to text.
|
|
|
|
* @param aPos The position to format
|
|
|
|
* @return wxString - The formated string
|
|
|
|
*/
|
2018-04-10 10:52:12 +00:00
|
|
|
static wxString ShowCoord( EDA_UNITS_T aUnits, const wxPoint& aPos );
|
2009-07-06 18:02:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-01-28 21:02:31 +00:00
|
|
|
#endif // DRC_ITEM_H
|