24#include <api/schematic/schematic_types.pb.h>
25#include <google/protobuf/any.pb.h>
61 using namespace kiapi::schematic::types;
66 group.mutable_id()->set_value(
m_Uuid.AsStdString() );
68 group.set_locked(
IsLocked() ? kiapi::common::types::LockedState::LS_LOCKED
69 : kiapi::common::types::LockedState::LS_UNLOCKED );
71 for(
EDA_ITEM* member : sortedItems )
72 group.add_items()->set_value( member->m_Uuid.AsStdString() );
74 aContainer.PackFrom(
group );
80 using namespace kiapi::schematic::types;
84 if( !aContainer.UnpackTo( &
group ) )
89 SetLocked(
group.locked() == kiapi::common::types::LockedState::LS_LOCKED );
98 for(
const kiapi::common::types::KIID& memberId :
group.items() )
100 KIID id( memberId.value() );
102 if(
SCH_ITEM* item = schematic->ResolveItem(
id,
nullptr,
true ) )
111 std::unordered_set<SCH_ITEM*> items;
115 if( item->IsSCH_ITEM() )
116 items.insert(
static_cast<SCH_ITEM*
>( item ) );
146 if(
group == aScope )
149 while(
group &&
group->AsEdaItem()->GetParentGroup() &&
group->AsEdaItem()->GetParentGroup() != aScope )
251 image->RunOnChildren(
290 bbox.
Merge( item->GetBoundingBox() );
300 const std::vector<KICAD_T>& aScanTypes )
302 for(
KICAD_T scanType : aScanTypes )
304 if( scanType ==
Type() )
341 member->SetFlags( flags );
357 member->SetFlags( flags );
373 member->SetFlags( flags );
389 member->SetFlags( flags );
395 int aUnit,
int aBodyStyle,
const VECTOR2I& aOffset,
bool aDimmed )
403 return wxString::Format(
_(
"Unnamed Group, %zu members" ),
m_items.size() );
405 return wxString::Format(
_(
"Group '%s', %zu members" ),
m_name,
m_items.size() );
417 aList.emplace_back(
_(
"Group" ),
m_name.empty() ?
_(
"<unnamed>" ) :
m_name );
418 aList.emplace_back(
_(
"Members" ), wxString::Format( wxT(
"%zu" ),
m_items.size() ) );
434 aFunction(
static_cast<SCH_ITEM*
>( item ) );
440 catch( std::bad_function_call& )
442 wxFAIL_MSG( wxT(
"Error calling function in SCH_GROUP::RunOnChildren" ) );
454 return *
this == other;
468 for(
auto it1 = itemSet.begin(), it2 = otherItemSet.begin(); it1 != itemSet.end(); ++it1, ++it2 )
472 if( ( *it1 )->m_Uuid != ( *it2 )->m_Uuid )
487 double similarity = 0.0;
497 return similarity /
m_items.size();
515 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.
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
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.
Provide class metadata.Helper macro to map type hashes to names.
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.
A set of SCH_ITEMs (i.e., without duplicates).
SCH_GROUP * DeepDuplicate(bool addToParentGroup, SCH_COMMIT *aCommit=nullptr) const
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
std::vector< int > ViewGetLayers() const override
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.
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
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
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 swapData(SCH_ITEM *aImage) override
Swap the internal data structures aItem with the schematic item.
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
Base class for any item which can be embedded within the SCHEMATIC container class,...
SCH_ITEM * Duplicate(bool addToParentGroup, SCH_COMMIT *aCommit=nullptr, bool doClone=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.
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