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
|
2021-10-06 02:46:53 +00:00
|
|
|
* Copyright (C) 2009-2020 KiCad Developers, see AUTHORS.TXT for contributors.
|
2014-10-22 15:51:34 +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
|
|
|
|
*/
|
|
|
|
|
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-08-11 13:33:16 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
#include <rc_item.h>
|
2012-09-01 13:38:27 +00:00
|
|
|
#include <gr_basic.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-04-14 12:25:00 +00:00
|
|
|
namespace KIGFX
|
|
|
|
{
|
|
|
|
class RENDER_SETTINGS;
|
|
|
|
}
|
|
|
|
|
|
|
|
using KIGFX::RENDER_SETTINGS;
|
|
|
|
|
|
|
|
|
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:
|
2024-01-29 11:51:06 +00:00
|
|
|
enum MARKER_T
|
|
|
|
{
|
2015-07-29 12:18:53 +00:00
|
|
|
MARKER_UNSPEC,
|
|
|
|
MARKER_ERC,
|
2021-12-01 14:42:44 +00:00
|
|
|
MARKER_DRC,
|
2022-08-15 16:59:34 +00:00
|
|
|
MARKER_DRAWING_SHEET,
|
2021-12-01 14:42:44 +00:00
|
|
|
MARKER_RATSNEST,
|
|
|
|
MARKER_PARITY,
|
2015-07-29 12:18:53 +00:00
|
|
|
MARKER_SIMUL
|
|
|
|
};
|
2020-02-28 00:05:40 +00:00
|
|
|
|
2020-12-19 23:29:10 +00:00
|
|
|
MARKER_BASE( int aScalingFactor, std::shared_ptr<RC_ITEM> aItem,
|
2024-01-29 11:51:06 +00:00
|
|
|
MARKER_T aType = MARKER_UNSPEC );
|
2020-02-28 00:05:40 +00:00
|
|
|
virtual ~MARKER_BASE();
|
2009-07-06 18:02:26 +00:00
|
|
|
|
2020-12-19 23:29:10 +00:00
|
|
|
/**
|
|
|
|
* The scaling factor to convert polygonal shape coordinates to internal units.
|
2018-12-19 14:07:07 +00:00
|
|
|
*/
|
2020-03-16 11:05:01 +00:00
|
|
|
int MarkerScale() const { return m_scalingFactor; }
|
2021-12-21 15:42:10 +00:00
|
|
|
void SetMarkerScale( int aScale ) { m_scalingFactor = aScale; }
|
2018-12-19 14:07:07 +00:00
|
|
|
|
2020-12-19 23:29:10 +00:00
|
|
|
/**
|
|
|
|
* Return 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.
|
2018-12-19 18:53:27 +00:00
|
|
|
*/
|
2020-10-12 22:24:35 +00:00
|
|
|
void ShapeToPolygon( SHAPE_LINE_CHAIN& aPolygon, int aScale = -1 ) const;
|
2018-12-19 18:53:27 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2022-01-01 18:08:03 +00:00
|
|
|
* Print the shape is the polygon defined in m_Corners (array of VECTOR2Is).
|
2009-07-06 18:02:26 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
void PrintMarker( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset );
|
2009-07-06 18:02:26 +00:00
|
|
|
|
|
|
|
/**
|
2020-12-19 23:29:10 +00:00
|
|
|
* @return the position of this marker in internal units.
|
2009-07-06 18:02:26 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
const VECTOR2I& 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-12-19 23:29:10 +00:00
|
|
|
* Accessors to set/get marker type (DRC, ERC, or other)
|
2009-07-06 18:02:26 +00:00
|
|
|
*/
|
2024-01-29 11:51:06 +00:00
|
|
|
void SetMarkerType( enum MARKER_T aMarkerType ) { m_markerType = aMarkerType; }
|
|
|
|
enum MARKER_T GetMarkerType() const { return m_markerType; }
|
2009-07-06 18:02:26 +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
|
|
|
|
2021-09-05 15:06:12 +00:00
|
|
|
virtual SEVERITY GetSeverity() const { return RPT_SEVERITY_UNDEFINED; }
|
|
|
|
|
2009-07-06 18:02:26 +00:00
|
|
|
/**
|
2020-12-19 23:29:10 +00:00
|
|
|
* @return the #RC_ITEM held within this marker so that its interface may be used.
|
2009-07-06 18:02:26 +00:00
|
|
|
*/
|
2020-08-11 13:33:16 +00:00
|
|
|
std::shared_ptr<RC_ITEM> GetRCItem() const { return m_rcItem; }
|
2009-07-13 15:25:41 +00:00
|
|
|
|
2009-07-06 18:02:26 +00:00
|
|
|
/**
|
2022-01-01 18:08:03 +00:00
|
|
|
* Test if the given VECTOR2I is within the bounds of this object.
|
2020-12-19 23:29:10 +00:00
|
|
|
*
|
2022-01-01 18:08:03 +00:00
|
|
|
* @param aHitPosition is the VECTOR2I to test (in internal units).
|
2020-12-19 23:29:10 +00:00
|
|
|
* @return true if a hit, else false.
|
2009-07-06 18:02:26 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
bool HitTestMarker( const VECTOR2I& aHitPosition, int aAccuracy ) const;
|
2009-07-09 17:02:15 +00:00
|
|
|
|
2009-07-08 15:42:45 +00:00
|
|
|
/**
|
2020-12-19 23:29:10 +00:00
|
|
|
* Return the orthogonal, bounding box of this object for display purposes.
|
|
|
|
*
|
2009-07-08 15:42:45 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
2022-08-30 23:28:18 +00:00
|
|
|
BOX2I GetBoundingBoxMarker() const;
|
2020-02-28 00:05:40 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual KIGFX::COLOR4D getColor() const = 0;
|
2020-12-19 23:29:10 +00:00
|
|
|
|
|
|
|
public:
|
2024-01-29 11:51:06 +00:00
|
|
|
VECTOR2I m_Pos; ///< position of the marker
|
2020-12-19 23:29:10 +00:00
|
|
|
|
|
|
|
protected:
|
2024-01-29 11:51:06 +00:00
|
|
|
MARKER_T m_markerType; // The type of marker (useful to filter markers)
|
|
|
|
bool m_excluded; // User has excluded this specific error
|
2020-12-19 23:29:10 +00:00
|
|
|
std::shared_ptr<RC_ITEM> m_rcItem;
|
|
|
|
|
2024-01-29 11:51:06 +00:00
|
|
|
int m_scalingFactor; // Scaling factor to convert corners coordinates
|
|
|
|
// to internal units coordinates
|
|
|
|
BOX2I m_shapeBoundingBox; // Bounding box of the graphic symbol, relative
|
|
|
|
// to the position of the shape, in marker shape
|
|
|
|
// units
|
2009-07-06 18:02:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-01-28 21:02:31 +00:00
|
|
|
#endif // MARKER_BASE_H
|