56#define BITMAP_FONT_SIZE_THRESHOLD 3
66 EDA_ITEM( aParent, aType, true, false ),
94 screen->BumpConnectivityRevision(
Type() );
113 if(
const std::shared_ptr<CONNECTION_GRAPH_LIFETIME>& owner = weakOwner.lock() )
114 owner->graph->RemoveItem(
this );
122 ruleArea->RemoveItem(
this );
129 [](
const auto& owner )
131 return owner.expired();
136 if( owner.lock() == aOwner )
183 if(
group->AsEdaItem()->IsLocked() )
210 if( addToParentGroup )
212 wxCHECK_MSG( aCommit, newItem,
"Must supply a commit to update parent group" );
217 group->AddItem( newItem );
228 return aLabel ?
_(
"All units" ) : wxString(
_HKI(
"All units" ) );
230 return symbol->GetUnitDisplayName( aUnit, aLabel );
232 return wxEmptyString;
238 if( aBodyStyle == 0 )
239 return aLabel ?
_(
"All body styles" ) : wxString(
_HKI(
"All body styles" ) );
241 return symbol->GetBodyStyleDescription( aBodyStyle, aLabel );
243 return wxEmptyString;
249 if( aUnit ==
_HKI(
"All units" ) )
257 for(
int ii = 1; ii <= symbol->GetUnitCount(); ii++ )
259 if( symbol->GetUnitDisplayName( ii,
false ) == aUnit )
276 if( aBodyStyle ==
_HKI(
"All body styles" ) )
286 if( symbol->GetBodyStyleDescription( bodyStyle,
false ) == aBodyStyle )
334 owner->RunOnChildren( [&](
SCH_ITEM* child )
336 owned |= child ==
this;
384 if( area->GetExcludedFromSim( aInstance, aVariantName ) )
402 if( area->GetExcludedFromBOM( aInstance, aVariantName ) )
420 if( area->GetExcludedFromBoard( aInstance, aVariantName ) )
438 if( area->GetExcludedFromPosFiles( aInstance, aVariantName ) )
448 if(
GetDNP( aInstance, aVariantName ) )
456 if( area->GetDNP( aInstance, aVariantName ) )
472 const wxString& aVariantName )
const
477 std::function<bool( wxString* )> libSymbolResolver =
478 [&]( wxString* token ) ->
bool
484 std::function<bool( wxString* )> symbolResolver =
485 [&]( wxString* token ) ->
bool
488 return symbol->
ResolveTextVar( aPath, token, aVariantName, depth + 1 );
491 std::function<bool( wxString* )> schematicResolver =
492 [&]( wxString* token ) ->
bool
498 return schematic->ResolveTextVar( aPath, token, depth + 1 );
503 std::function<bool( wxString* )> sheetResolver =
504 [&]( wxString* token ) ->
bool
512 if(
path.Last() != sheet )
513 path.push_back( sheet );
519 std::function<bool( wxString* )> labelResolver =
520 [&]( wxString* token ) ->
bool
530 std::function<bool( wxString* )> fieldResolver =
531 [&]( wxString* token ) ->
bool
533 bool resolved =
false;
536 resolved = libSymbolResolver( token );
538 resolved = symbolResolver( token );
540 resolved = sheetResolver( token );
542 resolved = labelResolver( token );
547 resolved |= schematicResolver( token );
608 conn->SetGraph( aGraph );
610 for(
auto& member : conn->AllMembers() )
611 member->SetGraph( aGraph );
621 if( !schematic || !schematic->
IsValid() )
630 bool aIgnoreSheet )
const
635 return aLocal ? connection->LocalName() : connection->Name( aIgnoreSheet );
641 return aLocal ? connection->LocalName() : connection->Name( aIgnoreSheet );
649 std::vector<wxString> names;
655 if( connection && connection->IsBus() )
657 for(
const auto& member : connection->Members().leaves )
658 names.push_back( member.Name() );
666 if( connection && connection->
IsBus() )
668 for(
const std::shared_ptr<SCH_CONNECTION>& member : connection->
Members() )
669 names.push_back( member->Name() );
680 const std::optional<SCH_CONNECTIVITY::ITEM_VIEW> connection =
publishedConnection( *
this, aSheet );
685 if( !connection->IsBus() )
702 if( !connection->
IsBus() )
705 std::set<wxString> netNames;
707 for(
const std::shared_ptr<SCH_CONNECTION>& member : connection->
AllMembers() )
708 netNames.insert( member->GetNetName() );
710 for(
const wxString& netName : netNames )
724 const auto connection = wxThread::IsMain() ?
publishedConnection( *
this, aSheet ) : std::nullopt;
725 return connection && connection->IsBus();
729 return connection && connection->
IsBus();
735 static std::shared_ptr<NETCLASS> nullNetclass = std::make_shared<NETCLASS>( wxEmptyString );
739 if( !schematic || !schematic->
IsValid() )
748 return netSettings->GetEffectiveNetClass( *
name );
750 if( std::shared_ptr<NETCLASS> defaultNetclass = netSettings->GetDefaultNetclass() )
751 return defaultNetclass;
768 static const std::vector<SCH_ITEM*>
empty;
779 if( vec.size() == vec.capacity() )
780 vec.reserve( vec.size() + 4096 );
783 auto it = std::lower_bound( vec.begin(), vec.end(), aItem );
785 if( it == vec.end() || *it != aItem )
786 vec.insert( it, aItem );
829 static wxString s_empty;
842 if( aImage ==
nullptr )
846 screen->BumpConnectivityRevision(
Type() );
849 screen->BumpConnectivityRevision( aImage->
Type() );
893 auto clearTextCaches =
900 text->ClearBoundingBoxCache();
901 text->ClearRenderCache();
905 clearTextCaches(
this );
925 return (
compare( aOther ) < 0 );
974 if( !value.IsEmpty() )
993 return schematic->Settings().m_MaxError;
1006 return cfg->m_Appearance.default_font;
1015 return schematic->Settings().m_FontMetrics;
1060 if( symbol->IsMultiUnit() )
1063 if( symbol->IsMultiBodyStyle() )
1067 aList.emplace_back(
_(
"Private" ), wxEmptyString );
1075 return schematic->GetEmbeddedFiles()->GetFontFiles();
1079 if(
EMBEDDED_FILES* symbolEmbeddedFiles = symbol->GetEmbeddedFiles() )
1080 return symbolEmbeddedFiles->UpdateFontFiles();
1105 return symbol->IsMultiUnit();
1111 auto multiBodyStyle =
1117 return symbol->IsMultiBodyStyle();
1129 wxPGChoices choices;
1130 choices.Add(
_HKI(
"All units" ), 0 );
1136 for(
int ii = 1; ii <= symbol->GetUnitCount(); ii++ )
1137 choices.Add( symbol->GetUnitDisplayName( ii,
false ), ii );
1151 wxPGChoices choices;
1152 choices.Add(
_HKI(
"All body styles" ) );
1159 choices.Add( symbol->GetBodyStyleDescription( ii,
false ) );
1177 const auto aPos = a.GetPosition();
1178 const auto bPos = b.GetPosition();
1179 return aPos.y < bPos.y ? true : ( aPos.y > bPos.y ? false : aPos.x < bPos.x );
1189std::vector<DANGLING_END_ITEM>::iterator
1194 auto start = aItemListByPos.begin();
1195 auto end = aItemListByPos.end();
1196 return std::lower_bound( start,
end, needle,
lessYX );
1200std::vector<DANGLING_END_ITEM>::iterator
1205 auto start = aItemListByType.begin();
1206 auto end = aItemListByType.end();
1207 return std::lower_bound( start,
end, needle,
lessType );
1212 std::vector<DANGLING_END_ITEM>& aItemListByType,
1213 std::vector<DANGLING_END_ITEM>& aItemListByPos )
1216 std::stable_sort( aItemListByType.begin(), aItemListByType.end(),
lessType );
1219 std::sort( aItemListByPos.begin(), aItemListByPos.end(),
lessYX );
constexpr EDA_IU_SCALE schIUScale
constexpr double ARC_LOW_DEF_MM
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
static std::vector< DANGLING_END_ITEM >::iterator get_lower_type(std::vector< DANGLING_END_ITEM > &aItemListByType, const DANGLING_END_T &aType)
static std::vector< DANGLING_END_ITEM >::iterator get_lower_pos(std::vector< DANGLING_END_ITEM > &aItemListByPos, const VECTOR2I &aPos)
static void sort_dangling_end_items(std::vector< DANGLING_END_ITEM > &aItemListByType, std::vector< DANGLING_END_ITEM > &aItemListByPos)
Helper class used to store the state of schematic items that can be connected to other schematic item...
DANGLING_END_T GetType() const
The base class for create windows for drawing purpose.
A set of EDA_ITEMs (i.e., without duplicates).
A base class for most all the KiCad significant classes used in schematics and boards.
virtual VECTOR2I GetPosition() const
virtual void ClearEditFlags()
EDA_ITEM_FLAGS GetEditFlags() const
void SetFlags(EDA_ITEM_FLAGS aMask)
virtual EDA_GROUP * GetParentGroup() const
KICAD_T Type() const
Returns the type of object.
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
EDA_ITEM_FLAGS GetTempFlags() const
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
std::map< wxString, wxString > m_customProperties
EDA_ITEM * GetParent() const
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
virtual void SetParent(EDA_ITEM *aParent)
EDA_ITEM * m_parent
Owner.
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
virtual void ClearTempFlags()
EDA_ITEM * findParent(KICAD_T aType) const
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Class that other classes need to inherit from, in order to be inspectable.
static const METRICS & Default()
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
int GetDefaultPenWidth() const
int GetMinPenWidth() const
const wxString & GetDefaultFont() const
bool ResolveTextVar(wxString *aToken, int aDepth=0) const
Resolve any references to system tokens supported by the symbol.
Base plotter engine class.
RENDER_SETTINGS * RenderSettings()
std::shared_ptr< NET_SETTINGS > m_NetSettings
Net settings for this project (owned here)
virtual bool TextVarResolver(wxString *aToken) const
virtual PROJECT_FILE & GetProjectFile() const
PROPERTY_BASE & SetChoicesFunc(std::function< wxPGChoices(INSPECTABLE *)> aFunc)
PROPERTY_BASE & SetAvailableFunc(std::function< bool(INSPECTABLE *)> aFunc)
Set a callback function to determine whether an object provides this property.
PROPERTY_BASE & SetIsHiddenFromDesignEditors(bool aIsHidden=true)
PROPERTY_BASE & SetIsHiddenFromLibraryEditors(bool aIsHidden=true)
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
Holds all the data relating to one schematic.
PROJECT & Project() const
Return a reference to the project this schematic is part of.
SCH_CONNECTIVITY::FACADE & Connectivity() const
wxString GetCurrentVariant() const
Return the current variant being edited.
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
SCH_SHEET_PATH & CurrentSheet() const
Commit for the schematic and symbol editors.
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
wxString GetNetName() const
const std::vector< std::shared_ptr< SCH_CONNECTION > > AllMembers() const
void Reset()
Clears connectivity information.
void SetGraph(CONNECTION_GRAPH *aGraph)
const std::vector< std::shared_ptr< SCH_CONNECTION > > & Members() const
void SetSheet(const SCH_SHEET_PATH &aSheet)
std::optional< ITEM_VIEW > Connection(const KIID &aItem, const KIID_PATH &aPath) const
BUS_MEMBERS Members() const
Marks the canvas reads of this thread, which are item drawing and view bounds.
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 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.
friend class CONNECTION_GRAPH
virtual bool IsConnectable() const
void SetLocked(bool aLocked) override
bool MatchesNetName(const EDA_SEARCH_DATA &aSearchData, const SCH_SHEET_PATH *aSheet) const
Match aSearchData against the connection of this item on aSheet.
bool ResolveExcludedFromPosFiles(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
virtual int GetPenWidth() const
SCH_ITEM & operator=(const SCH_ITEM &aPin)
std::map< SCH_SHEET_PATH, std::vector< SCH_ITEM * >, SHEET_PATH_CMP > m_connected_items
Store pointers to other items that are connected to this one, per sheet.
const wxString & GetDefaultFont(const KIGFX::RENDER_SETTINGS *aSettings) const
void ClearConnectedItems(const SCH_SHEET_PATH &aPath)
Clear all connections to this item.
virtual bool doIsConnected(const VECTOR2I &aPosition) const
Provide the object specific test to see if it is connected to aPosition.
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode)
SCH_SCREEN * GetParentScreen() const
std::vector< std::weak_ptr< CONNECTION_GRAPH_LIFETIME > > m_connectivityOwners
An item may be indexed by multiple graphs, each with an independent lifetime.
void invalidateConnectivity(KICAD_T aChangedType=TYPE_NOT_INIT)
Bump the parent screen's connectivity revision when this item, or the item owning it as a child,...
const std::vector< wxString > * GetEmbeddedFonts() override
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
const SYMBOL * GetParentSymbol() const
virtual wxString GetBodyStyleDescription(int aBodyStyle, bool aLabel) const
void SetPrivate(bool aPrivate)
virtual void swapData(SCH_ITEM *aItem)
Swap the internal data structures aItem with the schematic item.
virtual const wxString & GetCachedDriverName() const
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
std::vector< int > ViewGetLayers() const override
Return the layers the item is drawn on (which may be more than its "home" layer)
SCH_CONNECTION * InitializeConnection(const SCH_SHEET_PATH &aPath, CONNECTION_GRAPH *aGraph)
Create a new connection object associated with this object.
const std::vector< SCH_ITEM * > & ConnectedItems(const SCH_SHEET_PATH &aPath) const
Retrieve the set of items connected to this item on the given sheet.
virtual wxString GetUnitDisplayName(int aUnit, bool aLabel) const
bool IsLocked() const override
void AddConnectionTo(const SCH_SHEET_PATH &aPath, SCH_ITEM *aItem)
Add a connection link between this item and another.
virtual bool HasHypertext() const
Indicates that the item has at least one hypertext action.
virtual bool GetExcludedFromPosFiles(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
std::vector< wxString > GetBusMemberNames(const SCH_SHEET_PATH *aSheet=nullptr) const
Names of the bus members of this item's connection, empty when it does not have a bus.
std::shared_ptr< NETCLASS > GetEffectiveNetClass(const SCH_SHEET_PATH *aSheet=nullptr) const
virtual bool operator==(const SCH_ITEM &aOther) const
bool m_connectivity_dirty
virtual void ClearCaches()
virtual bool GetExcludedFromBoard(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
virtual void SetBodyStyleProp(const wxString &aBodyStyle)
void SetConnectivityDirty(bool aDirty=true)
Set the dirty flag.
virtual wxString GetBodyStyleProp() const
bool RenderAsBitmap(double aWorldScale) const override
std::optional< wxString > GetConnectionName(const SCH_SHEET_PATH *aSheet=nullptr, bool aLocal=false, bool aIgnoreSheet=false) const
Return the active connection name; absent for missing or stale published rows.
void SetConnectionGraph(CONNECTION_GRAPH *aGraph)
Update the connection graph for all connections in this item.
AUTOPLACE_ALGO m_fieldsAutoplaced
std::unordered_set< SCH_RULE_AREA * > m_rule_areas_cache
Store pointers to rule areas which this item is contained within.
void SwapFlags(SCH_ITEM *aItem)
Swap the non-temp and non-edit flags.
bool IsConnected(const VECTOR2I &aPoint) const
Test the item to see if it is connected to aPoint.
virtual void SetUnitString(const wxString &aUnit)
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
std::unordered_map< SCH_SHEET_PATH, SCH_CONNECTION * > m_connection_map
Store connectivity information, per sheet.
virtual bool operator<(const SCH_ITEM &aItem) const
bool ResolveExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
void registerConnectivityOwner(const std::shared_ptr< CONNECTION_GRAPH_LIFETIME > &aOwner)
Graph membership belongs to this item identity and must not propagate to clones.
SCH_CONNECTION * GetOrInitConnection(const SCH_SHEET_PATH &aPath, CONNECTION_GRAPH *aGraph)
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
wxString ResolveText(const wxString &aText, const SCH_SHEET_PATH *aPath, int aDepth=0) const
virtual int compare(const SCH_ITEM &aOther, int aCompareFlags=~COMPARE_FLAGS::UNIT) const
Provide the draw object specific comparison called by the == and < operators.
wxString GetClass() const override
Return the class name.
bool ResolveExcludedFromBoard(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
const KIFONT::METRICS & GetFontMetrics() const
bool ResolveDNP(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
virtual wxString GetUnitString() const
bool HasBusConnection(const SCH_SHEET_PATH *aSheet=nullptr) const
int GetEffectivePenWidth(const SCH_RENDER_SETTINGS *aSettings) const
bool IsGroupableType() const
void SwapItemData(SCH_ITEM *aImage)
Swap data between aItem and aImage.
bool ResolveExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
virtual bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
virtual bool GetDNP(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
const BOX2I ViewBBox() const override
The view bounds of text that shows a net name must match the drawing, so this reads connectivity insi...
virtual bool GetExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
virtual bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth) const
Resolve any references to system tokens supported by the label.
int m_SymbolLineWidth
Override line widths for symbol drawing objects set to default line width.
static bool IsConnectivitySource(const SCH_ITEM *aItem)
Markers, bitmaps, plain shapes, graphic lines and groups carry nothing captured by connectivity.
void BumpConnectivityRevision(KICAD_T aChangedType=TYPE_NOT_INIT)
Increment the connectivity revisions of this screen.
bool CheckIfOnDrawList(const SCH_ITEM *aItem) const
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the symbol.
A base class for LIB_SYMBOL and SCH_SYMBOL.
wxString ResolveTextVars(const wxString &aSource, const std::function< bool(wxString *)> *aResolver, int &aDepth)
Multi-pass text variable expansion and math expression evaluation.
static bool empty(const wxTextEntryBase *aCtrl)
#define BRIGHTENED
item is drawn with a bright contour
#define SELECTED
Item was manually selected by the user.
#define STRUCT_DELETED
flag indication structures to be erased
#define SKIP_STRUCT
flag indicating that the structure should be ignored
std::uint32_t EDA_ITEM_FLAGS
SCH_LAYER_ID
Eeschema drawing layers.
@ LAYER_DEVICE_BACKGROUND
@ LAYER_SELECTION_SHADOWS
#define UNIMPLEMENTED_FOR(type)
#define TYPE_HASH(x)
Macro to generate unique identifier for a type.
#define IMPLEMENT_ENUM_TO_WXANY(type)
#define REGISTER_TYPE(x)
Helper macro to map type hashes to names.
static const std::vector< KICAD_T > labelTypes
Class to handle a set of SCH_ITEMs.
static bool lessYX(const DANGLING_END_ITEM &a, const DANGLING_END_ITEM &b)
#define BITMAP_FONT_SIZE_THRESHOLD
static bool lessType(const DANGLING_END_ITEM &a, const DANGLING_END_ITEM &b)
static struct SCH_ITEM_DESC _SCH_ITEM_DESC
static std::optional< SCH_CONNECTIVITY::ITEM_VIEW > publishedConnection(const SCH_ITEM &aItem, const SCH_SHEET_PATH *aSheet)
T * GetAppSettings(const char *aFilename)
std::vector< NET_VIEW > leaves
bool operator()(const SCH_ITEM *aFirst, const SCH_ITEM *aSecond) const
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
VECTOR2< int32_t > VECTOR2I