22#include <google/protobuf/any.pb.h>
26#include <api/schematic/schematic_rules.pb.h>
44#define SCALING_FACTOR schIUScale.mmToIU( 0.15 )
73 res->m_rcItem = std::make_shared<ERC_ITEM>(
74 *std::static_pointer_cast<ERC_ITEM>(
m_rcItem ) );
75 res->m_rcItem->SetParent(
res );
108 std::shared_ptr<ERC_ITEM>
erc = std::static_pointer_cast<ERC_ITEM>( aMarker.
GetRCItem() );
115 if(
erc->IsSheetSpecific() )
116 PackSheetPath( *aMsg.mutable_sheet_specific_path(),
erc->GetSpecificSheetPath() );
118 if(
erc->MainItemHasSheetPath() )
119 PackSheetPath( *aMsg.mutable_main_item_sheet_path(),
erc->GetMainItemSheetPath() );
121 if(
erc->AuxItemHasSheetPath() )
122 PackSheetPath( *aMsg.mutable_aux_item_sheet_path(),
erc->GetAuxItemSheetPath() );
135 if( parent && parent->
IsType( { SCH_SYMBOL_T, SCH_LABEL_T, SCH_SHEET_T } ) && text_item )
138 aMsg.mutable_child()->set_text_value( text_item->
GetText().ToUTF8() );
142 for(
const KIID&
id :
erc->GetIDs() )
145 aMsg.add_items()->set_value(
id.AsStdString() );
161 if( aMsg.has_aux_item_sheet_path() && !aMsg.has_main_item_sheet_path() )
164 if( aMsg.has_sheet_specific_path() )
169 if( sheetPath.has_value() )
170 ercItem->SetSheetSpecificPath( sheetPath.value() );
175 if( aMsg.has_main_item_sheet_path() )
180 if( mainPath.has_value() )
182 if( aMsg.has_aux_item_sheet_path() )
186 std::optional<SCH_SHEET_PATH> auxPathResolved =
189 if( auxPathResolved.has_value() )
190 ercItem->SetItemsSheetPaths( mainPath.value(), auxPathResolved.value() );
196 ercItem->SetItemsSheetPaths( mainPath.value() );
205 if( aMsg.has_child() && aMsg.items_size() > 0 )
212 wxString
text = wxString::FromUTF8( aMsg.child().text_value() );
220 if( text_item->GetText() ==
text )
237 if( text_item->GetText() ==
text )
245 ercItem->SetItems( uuid );
251 std::vector<KIID> ids;
252 ids.reserve( aMsg.items_size() );
254 for(
const auto& item : aMsg.items() )
255 ids.emplace_back( item.value() );
257 ercItem->SetItems( ids );
268 kiapi::schematic::ErcMarker msg;
270 aContainer.PackFrom( msg );
276 kiapi::schematic::ErcMarker msg;
278 if( !aContainer.UnpackTo( &msg ) )
296void SCH_MARKER::Show(
int nestLevel, std::ostream& os )
const
299 NestedSpace( nestLevel, os ) <<
'<' <<
GetClass().Lower().mb_str() <<
GetPos() <<
"/>\n";
307 wxCHECK2_MSG(
Schematic(),
return {},
"No SCHEMATIC set for SCH_MARKER!" );
310 std::shared_ptr<ERC_ITEM> ercItem = std::static_pointer_cast<ERC_ITEM>(
GetRCItem() );
312 if( ercItem->IsSheetSpecific()
313 && ( ercItem->GetSpecificSheetPath() !=
Schematic()->CurrentSheet() ) )
318 std::vector<int> layers( 2 );
387 aList.emplace_back(
_(
"Type" ),
_(
"Marker" ) );
393 aList.emplace_back(
_(
"Severity" ),
_(
"Ignore" ) );
396 aList.emplace_back(
_(
"Severity" ),
_(
"Warning" ) );
399 aList.emplace_back(
_(
"Severity" ),
_(
"Error" ) );
407 aList.emplace_back(
_(
"Drawing Sheet" ), wxEmptyString );
428 aList.emplace_back( mainText, auxText );
432 aList.emplace_back(
_(
"Excluded" ),
m_comment );
KICOMMON_API types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
KICOMMON_API KICAD_T FromProtoEnum(types::KiCadObjectType aValue)
void PackSheetPath(types::SheetPath &aOutput, const SCH_SHEET_PATH &aInput)
constexpr EDA_IU_SCALE schIUScale
BITMAPS
A list of all bitmap identifiers.
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.
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
EDA_ITEM * GetParent() const
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
virtual const wxString & GetText() const
Return the string associated with the text object.
static std::shared_ptr< ERC_ITEM > Create(int aErrorCode)
Constructs an ERC_ITEM for the given error code.
SEVERITY GetSeverity(int aErrorCode) const
static wxString StripMarkup(const wxString &aValue)
Flatten [label](url) markup, keeping just the label.
A color representation with 4 components: red, green, blue, alpha.
std::string AsStdString() const
bool HitTestMarker(const VECTOR2I &aHitPosition, int aAccuracy) const
Test if the given VECTOR2I is within the bounds of this object.
std::shared_ptr< RC_ITEM > GetRCItem() const
int m_scalingFactor
Scaling factor to convert corners coordinates to internal units.
wxString m_comment
User supplied comment.
const VECTOR2I & GetPos() const
VECTOR2I m_Pos
Position of the marker.
MARKER_T m_markerType
The type of marker.
bool m_excluded
User has excluded this specific error.
std::shared_ptr< RC_ITEM > m_rcItem
enum MARKER_T GetMarkerType() const
BOX2I m_shapeBoundingBox
Bounding box of the graphic symbol relative to the position of the shape in marker shape units.
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 SetParent(MARKER_BASE *aMarker)
SCH_ITEM * ResolveItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr, bool aAllowNullptrReturn=false) const
ERC_SETTINGS & ErcSettings() const
Base class for any item which can be embedded within the SCHEMATIC container class,...
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode)
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
SEVERITY GetSeverity() const override
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxDat) const override
Compare DRC marker main and auxiliary text against search string.
wxString GetClass() const override
Return the class name.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
SCH_LAYER_ID GetColorLayer() const
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
std::vector< int > ViewGetLayers() const override
Return the layers the item is drawn on (which may be more than its "home" layer)
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
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.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
static SCH_MARKER * FromProto(const kiapi::schematic::ErcMarker &aMsg, const SCH_SHEET_LIST &aSheetList)
KIGFX::COLOR4D getColor() const override
BOX2I const GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
SCH_MARKER(std::shared_ptr< ERC_ITEM > aItem, const VECTOR2I &aPos)
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
std::optional< SCH_SHEET_PATH > GetSheetPathByKIIDPath(const KIID_PATH &aPath, bool aIncludeLastSheet=true) const
Finds a SCH_SHEET_PATH that matches the provided KIID_PATH.
SCH_ITEM * ResolveItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr, bool aAllowNullptrReturn=false) const
Fetch a SCH_ITEM by ID.
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode) override
@ ERCE_UNRESOLVED_VARIABLE
A text variable could not be resolved.
SCH_LAYER_ID
Eeschema drawing layers.
@ LAYER_SELECTION_SHADOWS
Message panel definition file.
KICOMMON_API KIID_PATH UnpackSheetPath(const types::SheetPath &aInput)
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)
#define SCALING_FACTOR
Factor to convert the maker unit shape to internal units:
static void ToProto(kiapi::schematic::ErcMarker &aMsg, const SCH_MARKER &aMarker)
Functions to provide common constants and other functions to assist in making a consistent UI.
VECTOR2< int32_t > VECTOR2I