2014-10-22 15:51:34 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 1992-2014 KiCad Developers, see CHANGELOG.TXT for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2009-07-06 18:02:26 +00:00
|
|
|
|
2018-01-28 21:02:31 +00:00
|
|
|
#ifndef MARKER_BASE_H
|
|
|
|
#define MARKER_BASE_H
|
2009-07-06 18:02:26 +00:00
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
#include <rc_item.h>
|
2012-09-01 13:38:27 +00:00
|
|
|
#include <gr_basic.h>
|
2018-09-04 20:53:04 +00:00
|
|
|
#include <eda_rect.h>
|
2020-03-16 11:05:01 +00:00
|
|
|
|
|
|
|
|
2018-12-19 18:53:27 +00:00
|
|
|
class SHAPE_LINE_CHAIN;
|
2015-07-29 12:18:53 +00:00
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
/*
|
|
|
|
* Marker are mainly used to show a DRC or ERC error or warning
|
2015-07-29 12:18:53 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2009-07-06 18:02:26 +00:00
|
|
|
class MARKER_BASE
|
|
|
|
{
|
|
|
|
public:
|
2020-02-28 00:05:40 +00:00
|
|
|
enum TYPEMARKER {
|
2015-07-29 12:18:53 +00:00
|
|
|
MARKER_UNSPEC,
|
|
|
|
MARKER_ERC,
|
|
|
|
MARKER_PCB,
|
|
|
|
MARKER_SIMUL
|
|
|
|
};
|
2020-02-28 00:05:40 +00:00
|
|
|
|
2010-12-21 15:13:09 +00:00
|
|
|
wxPoint m_Pos; ///< position of the marker
|
2015-07-29 12:18:53 +00:00
|
|
|
|
2009-07-06 18:02:26 +00:00
|
|
|
protected:
|
2020-03-16 11:05:01 +00:00
|
|
|
TYPEMARKER m_markerType; // The type of marker (useful to filter markers)
|
|
|
|
bool m_excluded; // User has excluded this specific error
|
|
|
|
RC_ITEM* m_rcItem;
|
2020-02-28 00:05:40 +00:00
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
int m_scalingFactor; // Scaling factor to convert corners coordinates
|
|
|
|
// to internat units coordinates
|
|
|
|
EDA_RECT m_shapeBoundingBox; // Bounding box of the graphic symbol, relative
|
2020-02-28 00:05:40 +00:00
|
|
|
// to the position of the shape, in marker shape
|
|
|
|
// units
|
2009-07-06 18:02:26 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
MARKER_BASE( int aScalingFactor, RC_ITEM* aItem, TYPEMARKER aType = MARKER_UNSPEC );
|
2009-07-06 18:02:26 +00:00
|
|
|
|
2020-02-28 00:05:40 +00:00
|
|
|
virtual ~MARKER_BASE();
|
2009-07-06 18:02:26 +00:00
|
|
|
|
2018-12-19 14:07:07 +00:00
|
|
|
/** The scaling factor to convert polygonal shape coordinates to internal units
|
|
|
|
*/
|
2020-03-16 11:05:01 +00:00
|
|
|
int MarkerScale() const { return m_scalingFactor; }
|
2018-12-19 14:07:07 +00:00
|
|
|
|
2018-12-19 18:53:27 +00:00
|
|
|
/** Returns the shape polygon in internal units in a SHAPE_LINE_CHAIN
|
|
|
|
* the coordinates are relatives to the marker position (are not absolute)
|
|
|
|
* @param aPolygon is the SHAPE_LINE_CHAIN to fill with the shape
|
|
|
|
*/
|
|
|
|
void ShapeToPolygon( SHAPE_LINE_CHAIN& aPolygon) const;
|
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2019-05-31 12:15:25 +00:00
|
|
|
* Function PrintMarker
|
|
|
|
* Prints the shape is the polygon defined in m_Corners (array of wxPoints).
|
2009-07-06 18:02:26 +00:00
|
|
|
*/
|
2019-05-31 12:15:25 +00:00
|
|
|
void PrintMarker( wxDC* aDC, const wxPoint& aOffset );
|
2009-07-06 18:02:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetPos
|
2018-12-19 14:07:07 +00:00
|
|
|
* @return the position of this MARKER in internal units.
|
2009-07-06 18:02:26 +00:00
|
|
|
*/
|
2020-03-16 11:05:01 +00:00
|
|
|
const wxPoint& GetPos() const { return m_Pos; }
|
2009-07-06 18:02:26 +00:00
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
virtual const KIID GetUUID() const = 0;
|
2009-07-07 17:50:02 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2020-02-28 00:05:40 +00:00
|
|
|
* accessors to set/get marker type (DRC, ERC, or other)
|
2009-07-06 18:02:26 +00:00
|
|
|
*/
|
2020-03-16 11:05:01 +00:00
|
|
|
void SetMarkerType( enum TYPEMARKER aMarkerType ) { m_markerType = aMarkerType; }
|
|
|
|
enum TYPEMARKER GetMarkerType() const { return m_markerType; }
|
2009-07-06 18:02:26 +00:00
|
|
|
|
2020-02-28 00:05:40 +00:00
|
|
|
/**
|
|
|
|
* Function SetData
|
|
|
|
* fills in all the reportable data associated with a MARKER.
|
|
|
|
* @param aErrorCode The categorizing identifier for an error
|
|
|
|
* @param aMarkerPos The position of the MARKER on the BOARD
|
|
|
|
* @param aItem The first of two objects
|
|
|
|
* @param aPos The position of the first of two objects
|
|
|
|
* @param bItem The second of the two conflicting objects
|
|
|
|
* @param bPos The position of the second of two objects
|
2009-07-06 18:02:26 +00:00
|
|
|
*/
|
2020-02-28 00:05:40 +00:00
|
|
|
void SetData( EDA_UNITS aUnits, int aErrorCode, const wxPoint& aMarkerPos,
|
|
|
|
EDA_ITEM* aItem, const wxPoint& aPos,
|
|
|
|
EDA_ITEM* bItem = nullptr, const wxPoint& bPos = wxPoint() );
|
2009-07-06 18:02:26 +00:00
|
|
|
|
2020-02-28 00:05:40 +00:00
|
|
|
/**
|
|
|
|
* Function SetData
|
|
|
|
* fills in all the reportable data associated with a MARKER.
|
|
|
|
* @param aErrorCode The categorizing identifier for an error
|
|
|
|
* @param aMarkerPos The position of the MARKER on the BOARD
|
|
|
|
* @param aText Text describing the first of two objects
|
|
|
|
* @param aPos The position of the first of two objects
|
|
|
|
* @param bText Text describing the second of the two conflicting objects
|
|
|
|
* @param bPos The position of the second of two objects
|
|
|
|
*/
|
|
|
|
void SetData( int aErrorCode, const wxPoint& aMarkerPos,
|
|
|
|
const wxString& aText, const wxPoint& aPos,
|
|
|
|
const wxString& bText = wxEmptyString, const wxPoint& bPos = wxPoint() );
|
2009-07-06 18:02:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function SetData
|
|
|
|
* fills in all the reportable data associated with a MARKER.
|
|
|
|
* @param aErrorCode The categorizing identifier for an error
|
|
|
|
* @param aMarkerPos The position of the MARKER on the BOARD
|
2018-01-28 09:35:33 +00:00
|
|
|
* @param aItem The first of two objects
|
2009-07-06 18:02:26 +00:00
|
|
|
* @param aPos The position of the first of two objects
|
2018-01-28 09:35:33 +00:00
|
|
|
* @param bItem The second of the two conflicting objects
|
2009-07-06 18:02:26 +00:00
|
|
|
* @param bPos The position of the second of two objects
|
|
|
|
*/
|
2020-02-28 00:05:40 +00:00
|
|
|
void SetData( EDA_UNITS aUnits, int aErrorCode, const wxPoint& aMarkerPos,
|
|
|
|
EDA_ITEM* aItem,
|
|
|
|
EDA_ITEM* bItem = nullptr );
|
2009-07-06 18:02:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function SetData
|
|
|
|
* fills in all the reportable data associated with a MARKER.
|
|
|
|
* @param aErrorCode The categorizing identifier for an error
|
|
|
|
* @param aMarkerPos The position of the MARKER on the BOARD
|
2018-01-28 09:35:33 +00:00
|
|
|
* @param aText Text describing the first of two objects
|
|
|
|
* @param aPos The position of the first of two objects
|
|
|
|
* @param bText Text describing the second of the two conflicting objects
|
|
|
|
* @param bPos The position of the second of two objects
|
2009-07-06 18:02:26 +00:00
|
|
|
*/
|
|
|
|
void SetData( int aErrorCode, const wxPoint& aMarkerPos,
|
2020-02-28 00:05:40 +00:00
|
|
|
const wxString& aText,
|
|
|
|
const wxString& bText = wxEmptyString );
|
|
|
|
|
|
|
|
void SetData( int aErrorCode, const wxPoint& aMarkerPos,
|
|
|
|
const wxString& aText, const KIID& aID,
|
2020-03-16 11:05:01 +00:00
|
|
|
const wxString& bText = wxEmptyString, const KIID& bID = niluuid );
|
2009-07-06 18:02:26 +00:00
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
/**
|
|
|
|
* Function SetAuxiliaryData
|
2009-07-08 15:42:45 +00:00
|
|
|
* initialize data for the second (auxiliary) item
|
2010-12-21 15:13:09 +00:00
|
|
|
* @param aAuxiliaryText = the second text (main text) concerning the second schematic or
|
|
|
|
* board item
|
2009-07-08 15:42:45 +00:00
|
|
|
* @param aAuxiliaryPos = position the second item
|
|
|
|
*/
|
|
|
|
void SetAuxiliaryData( const wxString& aAuxiliaryText, const wxPoint& aAuxiliaryPos )
|
|
|
|
{
|
2020-03-16 11:05:01 +00:00
|
|
|
m_rcItem->SetAuxiliaryData( aAuxiliaryText, aAuxiliaryPos );
|
2009-07-08 15:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
bool IsExcluded() const { return m_excluded; }
|
|
|
|
void SetExcluded( bool aExcluded ) { m_excluded = aExcluded; }
|
2009-07-09 17:02:15 +00:00
|
|
|
|
2009-07-06 18:02:26 +00:00
|
|
|
/**
|
|
|
|
* Function GetReporter
|
|
|
|
* returns the DRC_ITEM held within this MARKER so that its
|
|
|
|
* interface may be used.
|
|
|
|
* @return const& DRC_ITEM
|
|
|
|
*/
|
2020-03-16 11:05:01 +00:00
|
|
|
RC_ITEM* GetRCItem() { return m_rcItem; }
|
|
|
|
const RC_ITEM* GetRCItem() const { return m_rcItem; }
|
2009-07-13 15:25:41 +00:00
|
|
|
|
2009-07-06 18:02:26 +00:00
|
|
|
/**
|
2018-12-19 14:07:07 +00:00
|
|
|
* Tests if the given wxPoint is within the bounds of this object.
|
|
|
|
* @param aHitPosition is the wxPoint to test (in internal units)
|
2009-07-06 18:02:26 +00:00
|
|
|
* @return bool - true if a hit, else false
|
|
|
|
*/
|
2019-05-05 10:33:34 +00:00
|
|
|
bool HitTestMarker( const wxPoint& aHitPosition, int aAccuracy ) const;
|
2009-07-09 17:02:15 +00:00
|
|
|
|
2009-07-08 15:42:45 +00:00
|
|
|
/**
|
|
|
|
* Function GetBoundingBoxMarker
|
|
|
|
* returns the orthogonal, bounding box of this object for display purposes.
|
|
|
|
* This box should be an enclosing perimeter for visible components of this
|
|
|
|
* object, and the units should be in the pcb or schematic coordinate system.
|
|
|
|
* It is OK to overestimate the size by a few counts.
|
|
|
|
*/
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT GetBoundingBoxMarker() const;
|
2020-02-28 00:05:40 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual KIGFX::COLOR4D getColor() const = 0;
|
2009-07-06 18:02:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-01-28 21:02:31 +00:00
|
|
|
#endif // MARKER_BASE_H
|