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>( *std::static_pointer_cast<ERC_ITEM>(
m_rcItem ) );
74 res->m_rcItem->SetParent(
res );
107 std::shared_ptr<ERC_ITEM>
erc = std::static_pointer_cast<ERC_ITEM>( aMarker.
GetRCItem() );
114 if(
erc->IsSheetSpecific() )
115 PackSheetPath( *aMsg.mutable_sheet_specific_path(),
erc->GetSpecificSheetPath() );
117 if(
erc->MainItemHasSheetPath() )
118 PackSheetPath( *aMsg.mutable_main_item_sheet_path(),
erc->GetMainItemSheetPath() );
120 if(
erc->AuxItemHasSheetPath() )
121 PackSheetPath( *aMsg.mutable_aux_item_sheet_path(),
erc->GetAuxItemSheetPath() );
134 if( parent && parent->
IsType( { SCH_SYMBOL_T, SCH_LABEL_T, SCH_SHEET_T } ) && text_item )
137 aMsg.mutable_child()->set_text_value( text_item->
GetText().ToUTF8() );
141 for(
const KIID&
id :
erc->GetIDs() )
144 aMsg.add_items()->set_value(
id.AsStdString() );
160 if( aMsg.has_aux_item_sheet_path() && !aMsg.has_main_item_sheet_path() )
163 if( aMsg.has_sheet_specific_path() )
168 if( sheetPath.has_value() )
169 ercItem->SetSheetSpecificPath( sheetPath.value() );
174 if( aMsg.has_main_item_sheet_path() )
179 if( mainPath.has_value() )
181 if( aMsg.has_aux_item_sheet_path() )
186 if( auxPathResolved.has_value() )
187 ercItem->SetItemsSheetPaths( mainPath.value(), auxPathResolved.value() );
193 ercItem->SetItemsSheetPaths( mainPath.value() );
202 if( aMsg.has_child() && aMsg.items_size() > 0 )
209 wxString
text = wxString::FromUTF8( aMsg.child().text_value() );
217 if( text_item->GetText() ==
text )
234 if( text_item->GetText() ==
text )
242 ercItem->SetItems( uuid );
248 std::vector<KIID> ids;
249 ids.reserve( aMsg.items_size() );
251 for(
const auto& item : aMsg.items() )
252 ids.emplace_back( item.value() );
254 ercItem->SetItems( ids );
265 kiapi::schematic::ErcMarker msg;
267 aContainer.PackFrom( msg );
273 kiapi::schematic::ErcMarker msg;
275 if( !aContainer.UnpackTo( &msg ) )
293void SCH_MARKER::Show(
int nestLevel, std::ostream& os )
const
296 NestedSpace( nestLevel, os ) <<
'<' <<
GetClass().Lower().mb_str() <<
GetPos() <<
"/>\n";
304 wxCHECK2_MSG(
Schematic(),
return {},
"No SCHEMATIC set for SCH_MARKER!" );
307 std::shared_ptr<ERC_ITEM> ercItem = std::static_pointer_cast<ERC_ITEM>(
GetRCItem() );
309 if( ercItem->IsSheetSpecific()
310 && ( ercItem->GetSpecificSheetPath() !=
Schematic()->CurrentSheet() ) )
315 std::vector<int> layers( 2 );
384 aList.emplace_back(
_(
"Type" ),
_(
"Marker" ) );
397 aList.emplace_back(
_(
"Drawing Sheet" ), wxEmptyString );
418 aList.emplace_back( mainText, auxText );
422 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
wxString GetClass() const override
Return the class name.
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare DRC marker main and auxiliary text against search string.
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