21#include <api/schematic/schematic_types.pb.h>
22#include <google/protobuf/any.pb.h>
69 group.mutable_id()->set_value(
m_Uuid.AsStdString() );
71 group.set_locked(
IsLocked() ? kiapi::common::types::LockedState::LS_LOCKED
72 : kiapi::common::types::LockedState::LS_UNLOCKED );
74 for(
EDA_ITEM* member : sortedItems )
75 group.add_items()->set_value( member->m_Uuid.AsStdString() );
78 aContainer.PackFrom(
group );
96 if( !aContainer.UnpackTo( &
group ) )
101 SetLocked(
group.locked() == kiapi::common::types::LockedState::LS_LOCKED );
112 for(
const kiapi::common::types::KIID& memberId :
group.items() )
114 KIID id( memberId.value() );
117 if( !item && aCommit )
130 std::unordered_set<SCH_ITEM*> items;
134 if( item->IsSCH_ITEM() )
135 items.insert(
static_cast<SCH_ITEM*
>( item ) );
165 if(
group == aScope )
168 while(
group &&
group->AsEdaItem()->GetParentGroup() &&
group->AsEdaItem()->GetParentGroup() != aScope )
270 image->RunOnChildren(
309 bbox.
Merge( item->GetBoundingBox() );
319 const std::vector<KICAD_T>& aScanTypes )
321 for(
KICAD_T scanType : aScanTypes )
323 if( scanType ==
Type() )
360 member->SetFlags( flags );
376 member->SetFlags( flags );
392 member->SetFlags( flags );
408 member->SetFlags( flags );
414 int aUnit,
int aBodyStyle,
const VECTOR2I& aOffset,
bool aDimmed )
422 return wxString::Format(
_(
"Unnamed Group, %zu members" ),
m_items.size() );
424 return wxString::Format(
_(
"Group '%s', %zu members" ),
m_name,
m_items.size() );
436 aList.emplace_back(
_(
"Group" ),
m_name.empty() ?
_(
"<unnamed>" ) :
m_name );
437 aList.emplace_back(
_(
"Members" ), wxString::Format( wxT(
"%zu" ),
m_items.size() ) );
453 aFunction(
static_cast<SCH_ITEM*
>( item ) );
459 catch( std::bad_function_call& )
461 wxFAIL_MSG( wxT(
"Error calling function in SCH_GROUP::RunOnChildren" ) );
473 return *
this == other;
487 for(
auto it1 = itemSet.begin(), it2 = otherItemSet.begin(); it1 != itemSet.end(); ++it1, ++it2 )
491 if( ( *it1 )->m_Uuid != ( *it2 )->m_Uuid )
509 double similarity = 0.0;
513 double maxSimilarity = 0.0;
519 maxSimilarity = std::max( maxSimilarity, itemSimilarity );
521 if( maxSimilarity == 1.0 )
525 similarity += maxSimilarity;
528 return similarity /
m_items.size();
546 const wxString groupTab =
_HKI(
"Group Properties" );
constexpr EDA_IU_SCALE schIUScale
BITMAPS
A list of all bitmap identifiers.
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
constexpr Vec Centre() const
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Represent a set of changes (additions, deletions or modifications) of a data model (e....
virtual EDA_ITEM * ResolveItem(KIID &aID)=0
Search for an item in this commit that matches the provided KIID.
The base class for create windows for drawing purpose.
A set of EDA_ITEMs (i.e., without duplicates).
std::unordered_set< EDA_ITEM * > m_items
LIB_ID m_designBlockLibId
void AddItem(EDA_ITEM *aItem)
Add item to group.
virtual EDA_ITEM * AsEdaItem()=0
std::unordered_set< EDA_ITEM * > m_deserializedItems
void SetName(const wxString &aName)
virtual EDA_GROUP * GetParentGroup() const
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.
virtual void SetParentGroup(EDA_GROUP *aGroup)
EDA_ITEM * GetParent() const
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
static constexpr double LOD_HIDE
Return this constant from ViewGetLOD() to hide the item unconditionally.
static constexpr double LOD_SHOW
Return this constant from ViewGetLOD() to show the item unconditionally.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Base plotter engine class.
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()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
Holds all the data relating to one schematic.
Commit for the schematic and symbol editors.
A set of SCH_ITEMs (i.e., without duplicates).
SCH_GROUP * DeepDuplicate(bool addToParentGroup, SCH_COMMIT *aCommit=nullptr) const
Duplicate this and all descendants.
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
bool DeserializeGroup(const google::protobuf::Any &aContainer, COMMIT *aCommit) override
Deserializes the given protobuf message into this group.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
static bool WithinScope(SCH_ITEM *aItem, SCH_GROUP *aScope, bool isSymbolEditor)
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
bool operator==(const SCH_GROUP &aOther) 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 Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
SCH_GROUP * DeepClone() const
Clone this and all descendants.
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
INSPECT_RESULT Visit(INSPECTOR aInspector, void *aTestData, const std::vector< KICAD_T > &aScanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode) override
void SetPosition(const VECTOR2I &aNewpos) override
std::unordered_set< SCH_ITEM * > GetSchItems() const
static EDA_GROUP * TopLevelGroup(SCH_ITEM *aItem, EDA_GROUP *aScope, bool isSymbolEditor)
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
VECTOR2I GetPosition() const override
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Base class for any item which can be embedded within the SCHEMATIC container class,...
SCH_ITEM * Duplicate(bool addToParentGroup, SCH_COMMIT *aCommit=nullptr, bool aDoClone=false) const
Routine to create a new copy of given item.
void SetLocked(bool aLocked) override
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
bool IsLocked() const override
void SetLayer(SCH_LAYER_ID aLayer)
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
A base class for LIB_SYMBOL and SCH_SYMBOL.
This file is part of the common library.
std::set< EDA_ITEM *, CompareByUuid > EDA_ITEM_SET
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
#define IGNORE_PARENT_GROUP
#define ENDPOINT
ends. (Used to support dragging.)
std::uint32_t EDA_ITEM_FLAGS
#define STARTPOINT
When a line is selected, these flags indicate which.
Message panel definition file.
KICOMMON_API void PackCustomProperties(google::protobuf::RepeatedPtrField< types::CustomProperty > *aOutput, const EDA_ITEM &aItem)
KICOMMON_API void UnpackCustomProperties(const google::protobuf::RepeatedPtrField< types::CustomProperty > &aInput, EDA_ITEM &aItem)
#define TYPE_HASH(x)
Macro to generate unique identifier for a type.
#define REGISTER_TYPE(x)
Helper macro to map type hashes to names.
static struct SCH_GROUP_DESC _SCH_GROUP_DESC
EDA_GROUP * getNestedGroup(SCH_ITEM *aItem, EDA_GROUP *aScope, bool isSymbolEditor)
Returns the top level group inside the aScope group, or nullptr.
EDA_GROUP * getClosestGroup(SCH_ITEM *aItem, bool isSymbolEditor)
Class to handle a set of SCH_ITEMs.
wxString UnescapeString(const wxString &aSource)
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
VECTOR2< int32_t > VECTOR2I