60 const wxString& aName ) :
66 m_allowAutoPlace( true ),
67 m_renderCacheValid( false ),
93 for(
const std::unique_ptr<KIFONT::GLYPH>& glyph : aField.
m_renderCache )
96 m_renderCache.emplace_back( std::make_unique<KIFONT::OUTLINE_GLYPH>( *outline_glyph ) );
117 for(
const std::unique_ptr<KIFONT::GLYPH>& glyph : aField.
m_renderCache )
120 m_renderCache.emplace_back( std::make_unique<KIFONT::OUTLINE_GLYPH>( *outline_glyph ) );
177 std::function<bool( wxString* )> symbolResolver =
178 [&]( wxString* token ) ->
bool
183 std::function<bool( wxString* )> sheetResolver =
184 [&]( wxString* token ) ->
bool
189 std::function<bool( wxString* )> labelResolver =
190 [&]( wxString* token ) ->
bool
200 if(
text == wxS(
"~" ) )
275std::vector<std::unique_ptr<KIFONT::GLYPH>>*
334 if( !blackAndWhiteMode &&
GetTextColor() != COLOR4D::UNSPECIFIED )
352 if( parentSymbol && parentSymbol->
GetDNP() )
392 wxT(
"Cannot swap field data with invalid item." ) );
499 return render_center.
y > pos.
y;
501 return render_center.
x < pos.
x;
504 return render_center.
y < pos.
y;
506 return render_center.
x > pos.
x;
536 return render_center.
x < pos.
x;
538 return render_center.
y < pos.
y;
541 return render_center.
x > pos.
x;
543 return render_center.
y > pos.
y;
566 bool searchHiddenFields =
false;
567 bool searchAndReplace =
false;
568 bool replaceReferences =
false;
577 catch(
const std::bad_cast& )
583 if( !
IsVisible() && !searchHiddenFields )
588 if( searchAndReplace && !replaceReferences )
592 wxASSERT( aAuxData );
642 bool replaceReferences =
false;
649 catch(
const std::bad_cast& )
654 bool resolve =
false;
655 bool isReplaced =
false;
664 wxCHECK_MSG( aAuxData,
false, wxT(
"Need sheetpath to replace in refdes." ) );
666 if( !replaceReferences )
678 wxCHECK_MSG( aAuxData,
false, wxT(
"Need sheetpath to replace in value field." ) );
689 wxCHECK_MSG( aAuxData,
false, wxT(
"Need sheetpath to replace in footprint field." ) );
741 aList.emplace_back(
_(
"Symbol Field" ),
GetName() );
746 aList.emplace_back(
_(
"Visible" ),
IsVisible() ?
_(
"Yes" ) :
_(
"No" ) );
761 aList.emplace_back(
_(
"H Justification" ), msg );
770 aList.emplace_back(
_(
"V Justification" ), msg );
776 constexpr int START_ID = 1;
781 std::vector<std::pair<wxString, wxString>> pages;
787 for(
int i = 0; i < (int) pages.size(); ++i )
794 menu.AppendSeparator();
795 menu.Append( 999 + START_ID,
_(
"Back to Previous Selected Sheet" ) );
797 int sel = aFrame->GetPopupMenuSelectionFromUser( menu ) - START_ID;
799 if( sel >= 0 && sel < (
int) pages.size() )
800 href = wxT(
"#" ) + pages[ sel ].first;
801 else if( sel == 999 )
804 if( !href.IsEmpty() )
819 else if(
m_name.IsEmpty() && aUseDefaultName )
828 else if(
m_name.IsEmpty() && aUseDefaultName )
839 wxFAIL_MSG(
"Unhandled field owner type." );
862 case SHEETNAME:
return wxT(
"Sheetname" );
870 if(
m_name ==
_(
"Net Class" ) ||
m_name == wxT(
"Net Class" ) )
871 return wxT(
"Netclass" );
872 else if(
m_name ==
_(
"Sheet References" )
873 ||
m_name == wxT(
"Sheet References" )
874 ||
m_name == wxT(
"Intersheet References" ) )
875 return wxT(
"Intersheetrefs" );
883 wxFAIL_MSG(
wxString::Format(
"Unhandled field owner type (id %d, parent type %d).",
963 if( bg == COLOR4D::UNSPECIFIED || !aPlotter->
GetColorMode() )
984 if( parentSymbol->
GetDNP() )
1025 std::vector<std::pair<wxString, wxString>> pages;
1026 std::vector<wxString> pageHrefs;
1031 for(
const std::pair<wxString, wxString>& page : pages )
1032 pageHrefs.push_back( wxT(
"#" ) + page.first );
1088 auto field =
static_cast<const SCH_FIELD*
>( &aItem );
1090 if(
GetId() != field->GetId() )
1091 return GetId() < field->GetId();
1093 if(
GetText() != field->GetText() )
1094 return GetText() < field->GetText();
1102 return GetName() < field->GetName();
constexpr EDA_IU_SCALE schIUScale
BITMAPS
A list of all bitmap identifiers.
void SetOrigin(const Vec &pos)
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
const Vec & GetOrigin() const
void Offset(coord_type dx, coord_type dy)
bool Intersects(const BOX2< Vec > &aRect) const
void Move(const Vec &aMoveVector)
Move the rectangle by the aMoveVector.
bool Contains(const Vec &aPoint) const
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
void SetEnd(coord_type x, coord_type y)
bool IsHorizontal() const
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
virtual VECTOR2I GetPosition() 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 bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
EDA_ITEM * GetParent() const
EDA_ITEM * m_parent
Linked list: Link (parent struct)
bool IsForceVisible() const
static bool Replace(const EDA_SEARCH_DATA &aSearchData, wxString &aText)
Perform a text replace on aText using the find and replace criteria in aSearchData on items that supp...
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
BOX2I GetTextBox(int aLine=-1, bool aInvertY=false) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
const VECTOR2I & GetTextPos() const
COLOR4D GetTextColor() const
wxString GetTextStyleName() const
const EDA_ANGLE & GetTextAngle() const
virtual const wxString & GetText() const
Return the string associated with the text object.
void SetAttributes(const EDA_TEXT &aSrc)
Set the text attributes from another instance.
virtual bool IsVisible() const
void SetTextPos(const VECTOR2I &aPoint)
KIFONT::FONT * GetFont() const
EDA_TEXT & operator=(const EDA_TEXT &aItem)
GR_TEXT_H_ALIGN_T GetHorizJustify() const
bool Replace(const EDA_SEARCH_DATA &aSearchData)
Helper function used in search and replace dialog.
bool HasTextVars() const
Indicates the ShownText has text var references which need to be processed.
virtual void SetVisible(bool aVisible)
virtual void ClearBoundingBoxCache()
virtual void ClearRenderCache()
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
void SwapAttributes(EDA_TEXT &aTradingPartner)
Swap the text attributes of the two involved instances.
GR_TEXT_V_ALIGN_T GetVertJustify() const
virtual wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const
Return the string actually shown after processing of the base text.
void SwapText(EDA_TEXT &aTradingPartner)
VECTOR2I GetTextSize() const
FONT is an abstract base class for both outline and stroke fonts.
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false)
virtual bool IsOutline() const
Class OUTLINE_FONT implements outline font drawing.
void GetLinesAsGlyphs(std::vector< std::unique_ptr< GLYPH > > *aGlyphs, const wxString &aText, const VECTOR2I &aPosition, const TEXT_ATTRIBUTES &aAttrs) const
A color representation with 4 components: red, green, blue, alpha.
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
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
virtual const COLOR4D & GetBackgroundColor() const =0
Return current background color settings.
wxDC * GetPrintDC() const
Field object used in symbol libraries.
bool CanAutoplace() const
static wxString SubReference(int aUnit, bool aAddSeparator=true)
Base plotter engine class.
RENDER_SETTINGS * RenderSettings()
virtual void Text(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aPenWidth, bool aItalic, bool aBold, bool aMultilineAllowed, KIFONT::FONT *aFont, void *aData=nullptr)
Draw text with the plotter.
bool GetColorMode() const
virtual void HyperlinkMenu(const BOX2I &aBox, const std::vector< wxString > &aDestURLs)
Create a clickable hyperlink menu with a rectangular click area.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
void ClearRenderCache() override
COLOR4D m_lastResolvedColor
GR_TEXT_V_ALIGN_T GetEffectiveVertJustify() const
wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const override
Return the string actually shown after processing of the base text.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
std::vector< std::unique_ptr< KIFONT::GLYPH > > m_renderCache
void Plot(PLOTTER *aPlotter, bool aBackground) const override
Plot the schematic item to aPlotter.
VECTOR2I GetPosition() const override
bool Replace(const EDA_SEARCH_DATA &aSearchData, void *aAuxData=nullptr) override
Perform a text replace using the find and replace criteria in aSearchData on items that support text ...
bool m_showName
Render the field name in addition to its value.
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
Print a schematic item.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
bool IsHypertext() const override
Allow items to support hypertext actions when hovered/clicked.
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
bool IsHorizJustifyFlipped() const
Return whether the field will be rendered with the horizontal justification inverted due to rotation ...
bool IsVertJustifyFlipped() const
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
EDA_ANGLE GetDrawRotation() const override
Adjusters to allow EDA_TEXT to draw/print/etc.
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
void SetCanAutoplace(bool aCanPlace)
void DoHypertextAction(EDA_DRAW_FRAME *aFrame) const override
int GetPenWidth() const override
wxString GetCanonicalName() const
Get a non-language-specific name for a field which can be used for storage, variable look-up,...
COLOR4D GetFieldColor() const
SCH_FIELD & operator=(const SCH_FIELD &aField)
bool operator<(const SCH_ITEM &aItem) const override
VECTOR2I GetLibPosition() const
SCH_FIELD(const VECTOR2I &aPos, int aFieldId, SCH_ITEM *aParent, const wxString &aName=wxEmptyString)
bool IsReplaceable() const override
Override this method in any derived object that supports test find and replace.
GR_TEXT_H_ALIGN_T GetEffectiveHorizJustify() const
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
void SetPosition(const VECTOR2I &aPosition) override
void ImportValues(const LIB_FIELD &aSource)
Copy parameters from a LIB_FIELD source.
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
VECTOR2I m_renderCachePos
std::vector< std::unique_ptr< KIFONT::GLYPH > > * GetRenderCache(const wxString &forResolvedText, const VECTOR2I &forPosition, TEXT_ATTRIBUTES &aAttrs) 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 ClearCaches() override
VECTOR2I GetParentPosition() const
void SetNameShown(bool aShown=true)
KIFONT::FONT * getDrawFont() const override
bool m_allowAutoPlace
This field can be autoplaced.
VECTOR2I GetSchematicTextOffset(const RENDER_SETTINGS *aSettings) const override
This offset depends on the orientation, the type of text, and the area required to draw the associate...
Base class for any item which can be embedded within the SCHEMATIC container class,...
const wxString & GetDefaultFont() const
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
std::shared_ptr< NETCLASS > GetEffectiveNetClass(const SCH_SHEET_PATH *aSheet=nullptr) const
void SetLayer(SCH_LAYER_ID aLayer)
Set the layer this item is on.
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
bool IsConnectivityDirty() const
void GetIntersheetRefs(std::vector< std::pair< wxString, wxString > > *pages)
Builds an array of { pageNumber, pageName } pairs.
static const wxString GetDefaultFieldName(const wxString &aName, bool aUseDefaultName)
VECTOR2I GetSchematicTextOffset(const RENDER_SETTINGS *aSettings) const override
This offset depends on the orientation, the type of text, and the area required to draw the associate...
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.
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslated=true)
int GetUnitCount() const
Return the number of units per package of the symbol.
void SetValueFieldText(const wxString &aValue)
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
const wxString GetFootprintFieldText(bool aResolve) const
void SetFootprintFieldText(const wxString &aFootprint)
VECTOR2I GetPosition() const override
const wxString GetValueFieldText(bool aResolve) const
TRANSFORM & GetTransform()
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject)
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
static constexpr EDA_ANGLE & ANGLE_VERTICAL
static constexpr EDA_ANGLE & ANGLE_90
bool GetGRForceBlackPenState(void)
void GRPrintText(wxDC *aDC, const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aWidth, bool aItalic, bool aBold, KIFONT::FONT *aFont)
Print a graphic text through wxDC.
void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
wxString EllipsizeMenuText(const wxString &aString)
Ellipsize text (at the end) to be no more than 36 characters.
Plot settings, and plotting engines (PostScript, Gerber, HPGL and DXF)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
@ SHEET_MANDATORY_FIELDS
The first 2 are mandatory, and must be instantiated in SCH_SHEET.
wxString UnescapeString(const wxString &aSource)
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslateForHI=false)
Return a default symbol field name for field aFieldNdx for all components.
Definition for symbol library class.
@ DATASHEET_FIELD
name of datasheet
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ MANDATORY_FIELDS
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
wxLogTrace helper definitions.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)