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 ) );
178 std::function<bool( wxString* )> symbolResolver =
179 [&]( wxString* token ) ->
bool
181 return static_cast<SCH_SYMBOL*
>(
m_parent )->ResolveTextVar( aPath, token, aDepth + 1 );
184 std::function<bool( wxString* )> sheetResolver =
185 [&]( wxString* token ) ->
bool
190 std::function<bool( wxString* )> labelResolver =
191 [&]( wxString* token ) ->
bool
202 if(
text == wxS(
"~" ) )
249 return GetShownText( &schematic->CurrentSheet(), aAllowExtraText, aDepth );
287std::vector<std::unique_ptr<KIFONT::GLYPH>>*
346 if( !blackAndWhiteMode &&
GetTextColor() != COLOR4D::UNSPECIFIED )
364 if( parentSymbol && parentSymbol->
GetDNP() )
405 wxT(
"Cannot swap field data with invalid item." ) );
527 return render_center.
y > pos.
y;
529 return render_center.
x < pos.
x;
532 return render_center.
y < pos.
y;
534 return render_center.
x > pos.
x;
564 return render_center.
x < pos.
x;
566 return render_center.
y < pos.
y;
569 return render_center.
x > pos.
x;
571 return render_center.
y > pos.
y;
594 bool searchHiddenFields =
false;
595 bool searchAndReplace =
false;
596 bool replaceReferences =
false;
605 catch(
const std::bad_cast& )
611 if( !
IsVisible() && !searchHiddenFields )
616 if( searchAndReplace && !replaceReferences )
620 wxASSERT( aAuxData );
660 bool replaceReferences =
false;
667 catch(
const std::bad_cast& )
672 bool isReplaced =
false;
681 wxCHECK_MSG( aAuxData,
false, wxT(
"Need sheetpath to replace in refdes." ) );
683 if( !replaceReferences )
695 wxCHECK_MSG( aAuxData,
false, wxT(
"Need sheetpath to replace in value field." ) );
706 wxCHECK_MSG( aAuxData,
false, wxT(
"Need sheetpath to replace in footprint field." ) );
763 aList.emplace_back(
_(
"Visible" ),
IsVisible() ?
_(
"Yes" ) :
_(
"No" ) );
778 aList.emplace_back(
_(
"H Justification" ), msg );
787 aList.emplace_back(
_(
"V Justification" ), msg );
793 constexpr int START_ID = 1;
798 std::vector<std::pair<wxString, wxString>> pages;
804 for(
int i = 0; i < (int) pages.size(); ++i )
806 menu.Append( i + START_ID, wxString::Format(
_(
"Go to Page %s (%s)" ),
811 menu.AppendSeparator();
812 menu.Append( 999 + START_ID,
_(
"Back to Previous Selected Sheet" ) );
814 int sel = aFrame->GetPopupMenuSelectionFromUser( menu ) - START_ID;
816 if( sel >= 0 && sel < (
int) pages.size() )
817 href = wxT(
"#" ) + pages[ sel ].first;
818 else if( sel == 999 )
821 if( !href.IsEmpty() )
836 else if(
m_name.IsEmpty() && aUseDefaultName )
845 else if(
m_name.IsEmpty() && aUseDefaultName )
856 wxFAIL_MSG(
"Unhandled field owner type." );
879 case SHEETNAME:
return wxT(
"Sheetname" );
887 if(
m_name ==
_(
"Net Class" ) ||
m_name == wxT(
"Net Class" ) )
888 return wxT(
"Netclass" );
889 else if(
m_name ==
_(
"Sheet References" )
890 ||
m_name == wxT(
"Sheet References" )
891 ||
m_name == wxT(
"Intersheet References" ) )
892 return wxT(
"Intersheetrefs" );
900 wxFAIL_MSG( wxString::Format(
"Unhandled field owner type (id %d, parent type %d).",
918 default:
return BITMAPS::text;
922 return BITMAPS::text;
980 if( bg == COLOR4D::UNSPECIFIED || !aPlotter->
GetColorMode() )
1004 if( parentSymbol->
GetDNP() )
1056 std::vector<std::pair<wxString, wxString>> pages;
1057 std::vector<wxString> pageHrefs;
1064 for(
const std::pair<wxString, wxString>& page : pages )
1065 pageHrefs.push_back( wxT(
"#" ) + page.first );
1121 auto field =
static_cast<const SCH_FIELD*
>( &aItem );
1123 if(
GetId() != field->GetId() )
1124 return GetId() < field->GetId();
1126 if(
GetText() != field->GetText() )
1127 return GetText() < field->GetText();
1135 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()
const TEXT_ATTRIBUTES & GetAttributes() const
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(bool aAllowExtraText, int aDepth=0) 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 PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont, void *aData=nullptr)
bool GetColorMode() const
virtual void HyperlinkMenu(const BOX2I &aBox, const std::vector< wxString > &aDestURLs)
Create a clickable hyperlink menu with a rectangular click area.
Holds all the data relating to one schematic.
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
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.
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
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.
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
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.
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
void SetFootprintFieldText(const wxString &aFootprint)
VECTOR2I GetPosition() const override
TRANSFORM & GetTransform()
GR_TEXT_H_ALIGN_T m_Halign
GR_TEXT_V_ALIGN_T m_Valign
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.
@ LAYER_SELECTION_SHADOWS
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.
wxString EllipsizeStatusText(wxWindow *aWindow, const wxString &aString)
Ellipsize text (at the end) to be no more than 1/3 of the window width.
Plot settings, and plotting engines (PostScript, Gerber, HPGL and DXF)
@ 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)