23#include <google/protobuf/any.pb.h>
26#include <api/board/board_rules.pb.h>
48#define SCALING_FACTOR pcbIUScale.mmToIU( 0.1625 )
105 std::shared_ptr<DRC_ITEM>
drc = std::static_pointer_cast<DRC_ITEM>( aMarker.
GetRCItem() );
112 for(
const KIID&
id :
drc->GetIDs() )
115 aMsg.add_items()->set_value(
id.AsStdString() );
119 bool storeLayer =
false;
121 switch(
drc->GetErrorCode() )
167 KIID mainId = aMsg.items_size() > 0 ?
KIID( aMsg.items( 0 ).value() ) :
niluuid;
168 KIID auxId = aMsg.items_size() > 1 ?
KIID( aMsg.items( 1 ).value() ) :
niluuid;
169 KIID aux2Id = aMsg.items_size() > 2 ?
KIID( aMsg.items( 2 ).value() ) :
niluuid;
170 KIID aux3Id = aMsg.items_size() > 3 ?
KIID( aMsg.items( 3 ).value() ) :
niluuid;
180 kiapi::board::DrcMarker msg;
182 aContainer.PackFrom( msg );
188 kiapi::board::DrcMarker msg;
190 if( !aContainer.UnpackTo( &msg ) )
205 auto getMarkerLayer =
206 [](
const wxString& layerName ) ->
int
217 wxArrayString props = wxSplit( aData,
'|' );
221 if( props.size() < 5 )
224 int markerLayer =
F_Cu;
225 VECTOR2I markerPos( (
int) strtol( props[1].c_str(),
nullptr, 10 ),
226 (
int) strtol( props[2].c_str(),
nullptr, 10 ) );
237 drcItem->SetItems(
KIID( props[3] ) );
238 markerLayer = getMarkerLayer( props[4] );
243 if( props.size() == 5 )
244 drcItem->SetItems(
KIID( props[3] ),
KIID( props[4] ) );
245 else if( props.size() >= 7 )
246 drcItem->SetItems(
KIID( props[5] ),
KIID( props[6] ) );
252 drcItem->SetItems(
KIID( props[3] ),
KIID( props[4] ) );
255 if( props.size() == 6 )
256 markerLayer = getMarkerLayer( props[5] );
259 && props[3].IsEmpty()
260 && props[4].IsEmpty() )
267 drcItem->SetItems(
KIID( props[3] ),
KIID( props[4] ) );
270 return new PCB_MARKER( drcItem, markerPos, markerLayer );
282 res->m_rcItem = std::make_shared<DRC_ITEM>( *std::static_pointer_cast<DRC_ITEM>(
m_rcItem ) );
283 res->m_rcItem->SetParent(
res );
295 std::swap( *
this, *
image );
300 if(
image->m_rcItem )
307 aList.emplace_back(
_(
"Type" ),
_(
"Marker" ) );
320 aList.emplace_back(
_(
"Drawing Sheet" ), wxEmptyString );
335 aList.emplace_back( mainText, auxText );
339 aList.emplace_back(
_(
"Excluded" ),
m_comment );
358 return std::make_shared<SHAPE_NULL>();
366 return markerShape.
Area();
371 int aError,
ERROR_LOC aErrorLoc,
bool ignoreLineWidth )
const
379 return wxString::Format(
_(
"Marker (%s)" ), aFull ?
m_rcItem->GetErrorMessage(
true )
457 std::vector<PCB_SHAPE> pathShapes;
469 pathShapes.push_back( s );
473 pathShapes.push_back( s );
480 shape.SetStroke( hairline );
481 pathShapes.push_back( std::move( shape ) );
485 if( pathShapes.size() > 0 )
487 VECTOR2I V1 = pathShapes[0].GetStart() - pathShapes[0].GetEnd();
488 VECTOR2I V2 = pathShapes.back().GetStart() - pathShapes.back().GetEnd();
497 pathShapes.push_back( s );
501 pathShapes.push_back( s );
509 pathShapes.push_back( std::move( shape ) );
521 box.
Merge( s.GetBoundingBox() );
KICOMMON_API types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
KICOMMON_API KICAD_T FromProtoEnum(types::KiCadObjectType aValue)
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
BITMAPS
A list of all bitmap identifiers.
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
SEVERITY GetSeverity(int aDRCErrorCode) const
Return the severity of a given DRC error code.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
BOARD_DESIGN_SETTINGS & GetDesignSettings()
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
DRC_RULE * GetViolatingRule() const
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
The base class for create windows for drawing purpose.
virtual EDA_ITEM * ResolveItem(const KIID &aId, bool aAllowNullptrReturn=false) const
Fetch an item by KIID.
virtual wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const
Return a user-visible description string of this item.
KICAD_T Type() const
Returns the type of object.
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
static wxString StripMarkup(const wxString &aValue)
Flatten [label](url) markup, keeping just the label.
A color representation with 4 components: red, green, blue, alpha.
Marker are mainly used to show a DRC or ERC error or warning.
void SetMarkerScale(int aScale) const
std::shared_ptr< RC_ITEM > GetRCItem() const
wxString m_comment
User supplied comment.
int MarkerScale() const
The scaling factor to convert polygonal shape coordinates to internal units.
const VECTOR2I & GetPos() const
VECTOR2I m_Pos
Position of the marker.
void SetMarkerType(enum MARKER_T aMarkerType)
Accessors to set/get marker type (DRC, ERC, or other)
std::shared_ptr< RC_ITEM > m_rcItem
enum MARKER_T GetMarkerType() const
void ShapeToPolygon(SHAPE_LINE_CHAIN &aPolygon, int aScale=-1) const
Return the shape polygon in internal units in a SHAPE_LINE_CHAIN the coordinates are relatives to the...
MARKER_BASE(int aScalingFactor, std::shared_ptr< RC_ITEM > aItem, MARKER_T aType=MARKER_UNSPEC)
BOX2I GetBoundingBoxMarker() const
Return the orthogonal, bounding box of this object for display purposes.
void SetZoom(double aZoomFactor) const
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth) const override
Convert the item shape to a closed polygon.
PCB_MARKER(std::shared_ptr< DRC_ITEM > aItem, const VECTOR2I &aPos, int aLayer=F_Cu)
std::vector< PCB_SHAPE > m_pathShapes
std::vector< PCB_SHAPE > GetErrorLegendShapes() const
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
SEVERITY GetSeverity() const override
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
static PCB_MARKER * FromLegacyString(const wxString &aData)
GAL_LAYER_ID GetColorLayer() const
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
KIGFX::COLOR4D getColor() const override
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
double GetCoverageArea(int aTextMargin) const override
Return the board area this item covers, used to rank candidates under the cursor so a click on a smal...
static PCB_MARKER * FromProto(const kiapi::board::DrcMarker &aMsg)
void swapData(BOARD_ITEM *aImage) override
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
void SetEnd(const VECTOR2I &aEnd) override
void SetStart(const VECTOR2I &aStart) override
void SetStroke(const STROKE_PARAMS &aStroke) override
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
void Mask(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName)
Sets a base class property as masked in a derived class.
static PROPERTY_MANAGER & Instance()
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
void SetItems(const std::vector< KIID > &aIds)
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
double Area(bool aAbsolute=true) const
Return the area of this chain.
Represent a set of closed polygons.
Simple container to manage line stroke parameters.
constexpr VECTOR2< T > Perpendicular() const
Compute the perpendicular vector.
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
@ DRCE_SCHEMATIC_FIELDS_PARITY
@ DRCE_UNRESOLVED_VARIABLE
@ DRCE_DUPLICATE_FOOTPRINT
wxString LayerName(int aLayer)
Returns the default display name for a given layer.
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
@ LAYER_DRAWINGSHEET
Sheet frame and title block.
@ LAYER_DRC_EXCLUSION
Layer for DRC markers which have been individually excluded.
@ LAYER_DRC_HIGHLIGHTED
Color for highlighted DRC markers.
@ LAYER_DRC_WARNING
Layer for DRC markers with RPT_SEVERITY_WARNING.
@ LAYER_MARKER_SHADOWS
Shadows for DRC markers.
@ LAYER_DRC_ERROR
Layer for DRC markers with RPT_SEVERITY_ERROR.
PCB_LAYER_ID
A quick note on layer IDs:
PCB_LAYER_ID ToLAYER_ID(int aLayer)
KICOMMON_API VECTOR2I UnpackVector2(const types::Vector2 &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackVector2(types::Vector2 &aOutput, const VECTOR2I &aInput, const EDA_IU_SCALE &aScale)
static void ToProto(kiapi::board::DrcMarker &aMsg, const PCB_MARKER &aMarker)
static struct PCB_MARKER_DESC _PCB_MARKER_DESC
#define TYPE_HASH(x)
Macro to generate unique identifier for a type.
#define REGISTER_TYPE(x)
Helper macro to map type hashes to names.
#define SCALING_FACTOR
Factor to convert the maker unit shape to internal units:
static void ToProto(kiapi::schematic::ErcMarker &aMsg, const SCH_MARKER &aMarker)
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
Functions to provide common constants and other functions to assist in making a consistent UI.
VECTOR2< int32_t > VECTOR2I