KiCad PCB EDA Suite
SCH_FIELD Class Reference

Instances are attached to a symbol or sheet and provide a place for the symbol's value, reference designator, footprint, , a sheet's name, filename, and user definable name-value pairs of arbitrary purpose. More...

#include <sch_field.h>

Inheritance diagram for SCH_FIELD:
SCH_ITEM EDA_TEXT EDA_ITEM KIGFX::VIEW_ITEM INSPECTABLE

Public Member Functions

 SCH_FIELD (const VECTOR2I &aPos, int aFieldId, SCH_ITEM *aParent, const wxString &aName=wxEmptyString)
 
 SCH_FIELD (SCH_ITEM *aParent, int aFieldId, const wxString &aName=wxEmptyString)
 
 SCH_FIELD (const SCH_FIELD &aText)
 
 ~SCH_FIELD ()
 
SCH_FIELDoperator= (const SCH_FIELD &aField)
 
wxString GetClass () const override
 Return the class name. More...
 
bool IsType (const std::vector< KICAD_T > &aScanTypes) const override
 Check whether the item is one of the listed types. More...
 
bool IsHypertext () const override
 Allow items to support hypertext actions when hovered/clicked. More...
 
void DoHypertextAction (EDA_DRAW_FRAME *aFrame) const override
 
wxString GetName (bool aUseDefaultName=true) const
 Return the field name (not translated). More...
 
wxString GetCanonicalName () const
 Get a non-language-specific name for a field which can be used for storage, variable look-up, etc. More...
 
void SetName (const wxString &aName)
 
const wxString & GetInternalName ()
 Get the initial name of the field set at creation (or set by SetName()). More...
 
int GetId () const
 
void SetId (int aId)
 
wxString GetShownText (int aDepth=0, bool aAllowExtraText=true) const override
 Return the string actually shown after processing of the base text. More...
 
COLOR4D GetFieldColor () const
 
void SetLastResolvedState (const SCH_ITEM *aItem) override
 
EDA_ANGLE GetDrawRotation () const override
 Adjusters to allow EDA_TEXT to draw/print/etc. More...
 
const BOX2I GetBoundingBox () const override
 Return the orthogonal bounding box of this object for display purposes. More...
 
bool IsHorizJustifyFlipped () const
 Return whether the field will be rendered with the horizontal justification inverted due to rotation or mirroring of the parent. More...
 
bool IsVertJustifyFlipped () const
 
GR_TEXT_H_ALIGN_T GetEffectiveHorizJustify () const
 
GR_TEXT_V_ALIGN_T GetEffectiveVertJustify () const
 
bool IsNameShown () const
 
void SetNameShown (bool aShown=true)
 
bool CanAutoplace () const
 
void SetCanAutoplace (bool aCanPlace)
 
void SwapData (SCH_ITEM *aItem) override
 Swap the internal data structures aItem with the schematic item. More...
 
void ImportValues (const LIB_FIELD &aSource)
 Copy parameters from a LIB_FIELD source. More...
 
int GetPenWidth () const override
 
void ClearCaches () override
 
void ClearRenderCache () override
 
std::vector< std::unique_ptr< KIFONT::GLYPH > > * GetRenderCache (const wxString &forResolvedText, const VECTOR2I &forPosition, TEXT_ATTRIBUTES &aAttrs) const
 
void Print (const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
 Print a schematic item. More...
 
void Move (const VECTOR2I &aMoveVector) override
 Move the item by aMoveVector to a new position. More...
 
void Rotate (const VECTOR2I &aCenter) override
 Rotate the item around aCenter 90 degrees in the clockwise direction. More...
 
void MirrorVertically (int aCenter) override
 Mirror item vertically about aCenter. More...
 
void MirrorHorizontally (int aCenter) override
 Mirror item horizontally about aCenter. More...
 
bool Matches (const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
 Compare the item against the search criteria in aSearchData. More...
 
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 find and replace. More...
 
wxString GetItemDescription (UNITS_PROVIDER *aUnitsProvider) const override
 Return a user-visible description string of this item. More...
 
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. More...
 
BITMAPS GetMenuImage () const override
 Return a pointer to an image to be used in menus. More...
 
bool IsReplaceable () const override
 Override this method in any derived object that supports test find and replace. More...
 
VECTOR2I GetLibPosition () const
 
VECTOR2I GetPosition () const override
 
void SetPosition (const VECTOR2I &aPosition) override
 
VECTOR2I GetParentPosition () const
 
bool HitTest (const VECTOR2I &aPosition, int aAccuracy=0) const override
 Test if aPosition is inside or on the boundary of this item. More...
 
bool HitTest (const BOX2I &aRect, bool aContained, int aAccuracy=0) const override
 Test if aRect intersects this item. More...
 
void Plot (PLOTTER *aPlotter, bool aBackground) const override
 Plot the schematic item to aPlotter. More...
 
EDA_ITEMClone () const override
 Create a duplicate of this item with linked list members set to NULL. More...
 
bool operator< (const SCH_ITEM &aItem) const override
 
SCH_ITEMDuplicate (bool doClone=false) const
 Routine to create a new copy of given item. More...
 
virtual bool IsMovableFromAnchorPoint () const
 
VECTOR2IGetStoredPos ()
 
void SetStoredPos (const VECTOR2I &aPos)
 
SCHEMATICSchematic () const
 Searches the item hierarchy to find a SCHEMATIC. More...
 
virtual bool IsLocked () const
 
virtual void SetLocked (bool aLocked)
 Set the 'lock' status to aLocked for of this item. More...
 
SCH_LAYER_ID GetLayer () const
 Return the layer this item is on. More...
 
void SetLayer (SCH_LAYER_ID aLayer)
 Set the layer this item is on. More...
 
void ViewGetLayers (int aLayers[], int &aCount) const override
 Return the layers the item is drawn on (which may be more than its "home" layer) More...
 
const wxString & GetDefaultFont () const
 
bool RenderAsBitmap (double aWorldScale) const override
 
virtual void PrintBackground (const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset)
 Print the (optional) backaground elements if they exist. More...
 
virtual void GetEndPoints (std::vector< DANGLING_END_ITEM > &aItemList)
 Add the schematic item end points to aItemList if the item has end points. More...
 
virtual bool UpdateDanglingState (std::vector< DANGLING_END_ITEM > &aItemList, const SCH_SHEET_PATH *aPath=nullptr)
 Test the schematic item to aItemList to check if it's dangling state has changed. More...
 
virtual bool IsDangling () const
 
virtual bool CanConnect (const SCH_ITEM *aItem) const
 
virtual bool IsConnectable () const
 
virtual bool IsPointClickableAnchor (const VECTOR2I &aPos) const
 
virtual std::vector< VECTOR2IGetConnectionPoints () const
 Add all the connection points for this item to aPoints. More...
 
void ClearConnections ()
 Clears all of the connection items from the list. More...
 
bool IsConnected (const VECTOR2I &aPoint) const
 Test the item to see if it is connected to aPoint. More...
 
SCH_CONNECTIONConnection (const SCH_SHEET_PATH *aSheet=nullptr) const
 Retrieve the connection associated with this object in the given sheet. More...
 
SCH_ITEM_SETConnectedItems (const SCH_SHEET_PATH &aPath)
 Retrieve the set of items connected to this item on the given sheet. More...
 
void AddConnectionTo (const SCH_SHEET_PATH &aPath, SCH_ITEM *aItem)
 Add a connection link between this item and another. More...
 
SCH_CONNECTIONInitializeConnection (const SCH_SHEET_PATH &aPath, CONNECTION_GRAPH *aGraph)
 Create a new connection object associated with this object. More...
 
SCH_CONNECTIONGetOrInitConnection (const SCH_SHEET_PATH &aPath, CONNECTION_GRAPH *aGraph)
 
virtual bool ConnectionPropagatesTo (const EDA_ITEM *aItem) const
 Return true if this item should propagate connection info to aItem. More...
 
bool IsConnectivityDirty () const
 
void SetConnectivityDirty (bool aDirty=true)
 
std::shared_ptr< NETCLASSGetEffectiveNetClass (const SCH_SHEET_PATH *aSheet=nullptr) const
 
FIELDS_AUTOPLACED GetFieldsAutoplaced () const
 Return whether the fields have been automatically placed. More...
 
void SetFieldsAutoplaced ()
 
void ClearFieldsAutoplaced ()
 
void AutoAutoplaceFields (SCH_SCREEN *aScreen)
 Autoplace fields only if correct to do so automatically. More...
 
virtual void AutoplaceFields (SCH_SCREEN *aScreen, bool aManual)
 
virtual void RunOnChildren (const std::function< void(SCH_ITEM *)> &aFunction)
 
virtual bool HasLineStroke () const
 Check if this schematic item has line stoke properties. More...
 
virtual STROKE_PARAMS GetStroke () const
 
virtual void SetStroke (const STROKE_PARAMS &aStroke)
 
bool operator< (const EDA_ITEM &aItem) const
 Test if another item is less than this object. More...
 
KICAD_T Type () const
 Returns the type of object. More...
 
EDA_ITEMGetParent () const
 
virtual void SetParent (EDA_ITEM *aParent)
 
bool IsModified () const
 
bool IsNew () const
 
bool IsMoving () const
 
bool IsSelected () const
 
bool IsEntered () const
 
bool IsBrightened () const
 
bool IsRollover () const
 
void SetSelected ()
 
void SetBrightened ()
 
void ClearSelected ()
 
void ClearBrightened ()
 
void SetModified ()
 
int GetState (EDA_ITEM_FLAGS type) const
 
void SetState (EDA_ITEM_FLAGS type, bool state)
 
EDA_ITEM_FLAGS GetStatus () const
 
void SetStatus (EDA_ITEM_FLAGS aStatus)
 
void SetFlags (EDA_ITEM_FLAGS aMask)
 
void XorFlags (EDA_ITEM_FLAGS aMask)
 
void ClearFlags (EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
 
EDA_ITEM_FLAGS GetFlags () const
 
bool HasFlag (EDA_ITEM_FLAGS aFlag) const
 
EDA_ITEM_FLAGS GetEditFlags () const
 
void ClearTempFlags ()
 
void ClearEditFlags ()
 
void SetIsShownAsBitmap (bool aBitmap)
 
bool IsShownAsBitmap () const
 
void SetForceVisible (bool aEnable)
 Set and clear force visible flag used to force the item to be drawn even if it's draw attribute is set to not visible. More...
 
bool IsForceVisible () const
 
virtual wxString GetFriendlyName () const
 
virtual const VECTOR2I GetFocusPosition () const
 Similar to GetPosition, but allows items to return their visual center rather than their anchor. More...
 
virtual VECTOR2I GetSortPosition () const
 Return the coordinates that should be used for sorting this element visually compared to other elements. More...
 
virtual INSPECT_RESULT Visit (INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &aScanTypes)
 May be re-implemented for each derived class in order to handle all the types given by its member data. More...
 
wxString GetTypeDesc () const
 Return a translated description of the type for this EDA_ITEM for display in user facing messages. More...
 
virtual const BOX2I ViewBBox () const override
 Return the bounding box of the item covering all its layers. More...
 
virtual void ViewDraw (int aLayer, VIEW *aView) const
 Draw the parts of the object belonging to layer aLayer. More...
 
virtual double ViewGetLOD (int aLayer, VIEW *aView) const
 Return the level of detail (LOD) of the item. More...
 
VIEW_ITEM_DATA * viewPrivData () const
 
void ClearViewPrivData ()
 
bool Set (PROPERTY_BASE *aProperty, wxAny &aValue)
 
template<typename T >
bool Set (PROPERTY_BASE *aProperty, T aValue)
 
template<typename T >
bool Set (const wxString &aProperty, T aValue)
 
wxAny Get (PROPERTY_BASE *aProperty) const
 
template<typename T >
Get (PROPERTY_BASE *aProperty) const
 
template<typename T >
std::optional< T > Get (const wxString &aProperty) const
 
virtual const wxString & GetText () const
 Return the string associated with the text object. More...
 
bool HasTextVars () const
 Indicates the ShownText has text var references which need to be processed. More...
 
virtual void SetText (const wxString &aText)
 
void SetTextThickness (int aWidth)
 The TextThickness is that set by the user. More...
 
int GetTextThickness () const
 
int GetEffectiveTextPenWidth (int aDefaultPenWidth=0) const
 The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth. More...
 
virtual void SetTextAngle (const EDA_ANGLE &aAngle)
 
const EDA_ANGLEGetTextAngle () const
 
void SetTextAngleDegrees (double aOrientation)
 
double GetTextAngleDegrees () const
 
void SetItalic (bool aItalic)
 
bool IsItalic () const
 
void SetBold (bool aBold)
 
bool IsBold () const
 
virtual void SetVisible (bool aVisible)
 
virtual bool IsVisible () const
 
void SetMirrored (bool isMirrored)
 
bool IsMirrored () const
 
void SetMultilineAllowed (bool aAllow)
 
bool IsMultilineAllowed () const
 
void SetHorizJustify (GR_TEXT_H_ALIGN_T aType)
 
GR_TEXT_H_ALIGN_T GetHorizJustify () const
 
void SetVertJustify (GR_TEXT_V_ALIGN_T aType)
 
GR_TEXT_V_ALIGN_T GetVertJustify () const
 
void SetKeepUpright (bool aKeepUpright)
 
bool IsKeepUpright () const
 
void SetAttributes (const EDA_TEXT &aSrc)
 Set the text attributes from another instance. More...
 
void SetAttributes (const TEXT_ATTRIBUTES &aTextAttrs)
 
void SwapAttributes (EDA_TEXT &aTradingPartner)
 Swap the text attributes of the two involved instances. More...
 
void SwapText (EDA_TEXT &aTradingPartner)
 
void CopyText (const EDA_TEXT &aSrc)
 
const TEXT_ATTRIBUTESGetAttributes () const
 
bool Replace (const EDA_SEARCH_DATA &aSearchData)
 Helper function used in search and replace dialog. More...
 
bool IsDefaultFormatting () const
 
void SetFont (KIFONT::FONT *aFont)
 
KIFONT::FONTGetFont () const
 
wxString GetFontName () const
 
void SetLineSpacing (double aLineSpacing)
 
double GetLineSpacing () const
 
void SetTextSize (const VECTOR2I &aNewSize)
 
VECTOR2I GetTextSize () const
 
void SetTextWidth (int aWidth)
 
int GetTextWidth () const
 
void SetTextHeight (int aHeight)
 
int GetTextHeight () const
 
void SetTextColor (const COLOR4D &aColor)
 
COLOR4D GetTextColor () const
 
void SetTextPos (const VECTOR2I &aPoint)
 
const VECTOR2IGetTextPos () const
 
void SetTextX (int aX)
 
void SetTextY (int aY)
 
void Offset (const VECTOR2I &aOffset)
 
void Empty ()
 
void Print (const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset, const COLOR4D &aColor, OUTLINE_MODE aDisplay_mode=FILLED)
 Print this text object to the device context aDC. More...
 
void TransformBoundingBoxToPolygon (SHAPE_POLY_SET *aBuffer, int aClearance) const
 Convert the text bounding box to a rectangular polygon depending on the text orientation, the bounding box is not always horizontal or vertical. More...
 
std::shared_ptr< SHAPE_COMPOUNDGetEffectiveTextShape (bool aTriangulate=true, bool aUseTextRotation=true) const
 build a list of segments (SHAPE_SEGMENT) to describe a text shape. More...
 
virtual bool TextHitTest (const VECTOR2I &aPoint, int aAccuracy=0) const
 Test if aPoint is within the bounds of this object. More...
 
virtual bool TextHitTest (const BOX2I &aRect, bool aContains, int aAccuracy=0) const
 Test if object bounding box is contained within or intersects aRect. More...
 
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, locate functions....) More...
 
int GetInterline () const
 Return the distance between two lines of text. More...
 
wxString GetTextStyleName () const
 
void GetLinePositions (std::vector< VECTOR2I > &aPositions, int aLineCount) const
 Populate aPositions with the position of each line of a multiline text, according to the vertical justification and the rotation of the whole text. More...
 
virtual void Format (OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
 Output the object to aFormatter in s-expression form. More...
 
virtual VECTOR2I GetDrawPos () const
 
virtual void ClearBoundingBoxCache ()
 
std::vector< std::unique_ptr< KIFONT::GLYPH > > * GetRenderCache (const KIFONT::FONT *aFont, const wxString &forResolvedText, const VECTOR2I &aOffset={ 0, 0 }) const
 
void SetupRenderCache (const wxString &aResolvedText, const EDA_ANGLE &aAngle)
 
void AddRenderCacheGlyph (const SHAPE_POLY_SET &aPoly)
 
int Compare (const EDA_TEXT *aOther) const
 
virtual bool HasHyperlink () const
 
wxString GetHyperlink () const
 
void SetHyperlink (wxString aLink)
 
void RemoveHyperlink ()
 

Static Public Member Functions

static bool ClassOf (const EDA_ITEM *aItem)
 
template<class T >
static INSPECT_RESULT IterateForward (std::deque< T > &aList, INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &scanTypes)
 This changes first parameter to avoid the DList and use the main queue instead. More...
 
template<class T >
static INSPECT_RESULT IterateForward (std::vector< T > &aList, INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &scanTypes)
 Change first parameter to avoid the DList and use std::vector instead. More...
 
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 support text find and replace. More...
 
static bool Sort (const EDA_ITEM *aLeft, const EDA_ITEM *aRight)
 Helper function to be used by the C++ STL sort algorithm for sorting a STL container of EDA_ITEM pointers. More...
 
static GR_TEXT_H_ALIGN_T MapHorizJustify (int aHorizJustify)
 
static GR_TEXT_V_ALIGN_T MapVertJustify (int aVertJustify)
 
static bool ValidateHyperlink (const wxString &aURL)
 Check if aURL is a valid hyperlink. More...
 
static bool IsGotoPageHref (const wxString &aHref, wxString *aDestination=nullptr)
 Check if aHref is a valid internal hyperlink. More...
 
static wxString GotoPageHref (const wxString &aDestination)
 Generate a href to a page in the current schematic. More...
 

Public Attributes

const KIID m_Uuid
 

Protected Member Functions

KIFONT::FONTgetDrawFont () const override
 
bool Matches (const wxString &aText, const EDA_SEARCH_DATA &aSearchData) const
 Compare aText against search criteria in aSearchData. More...
 
void cacheShownText ()
 
void printOneLineOfText (const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset, const COLOR4D &aColor, OUTLINE_MODE aFillMode, const wxString &aText, const VECTOR2I &aPos)
 Print each line of this EDA_TEXT. More...
 

Protected Attributes

SCH_LAYER_ID m_layer
 
EDA_ITEMS m_connections
 
FIELDS_AUTOPLACED m_fieldsAutoplaced
 
VECTOR2I m_storedPos
 
std::map< SCH_SHEET_PATH, SCH_ITEM_SET, SHEET_PATH_CMPm_connected_items
 Store pointers to other items that are connected to this one, per sheet. More...
 
std::unordered_map< SCH_SHEET_PATH, SCH_CONNECTION * > m_connection_map
 Store connectivity information, per sheet. More...
 
bool m_connectivity_dirty
 
EDA_ITEM_FLAGS m_status
 
EDA_ITEMm_parent
 Linked list: Link (parent struct) More...
 
bool m_forceVisible
 
EDA_ITEM_FLAGS m_flags
 
wxString m_hyperlink
 A hyperlink URL. More...
 

Private Member Functions

virtual bool doIsConnected (const VECTOR2I &aPosition) const
 Provide the object specific test to see if it is connected to aPosition. More...
 

Private Attributes

int m_id
 Field index,. More...
 
wxString m_name
 
bool m_showName
 Render the field name in addition to its value. More...
 
bool m_allowAutoPlace
 This field can be autoplaced. More...
 
bool m_renderCacheValid
 
VECTOR2I m_renderCachePos
 
std::vector< std::unique_ptr< KIFONT::GLYPH > > m_renderCache
 
COLOR4D m_lastResolvedColor
 
KICAD_T m_structType
 Run time identification, keep private so it can never be changed after a ctor sets it. More...
 
VIEW_ITEM_DATA * m_viewPrivData
 
wxString m_text
 
wxString m_shown_text
 
bool m_shown_text_has_text_var_refs
 
std::reference_wrapper< const EDA_IU_SCALEm_IuScale
 
wxString m_render_cache_text
 
EDA_ANGLE m_render_cache_angle
 
VECTOR2I m_render_cache_offset
 
std::vector< std::unique_ptr< KIFONT::GLYPH > > m_render_cache
 
bool m_bounding_box_cache_valid
 
VECTOR2I m_bounding_box_cache_pos
 
int m_bounding_box_cache_line
 
bool m_bounding_box_cache_inverted
 
BOX2I m_bounding_box_cache
 
TEXT_ATTRIBUTES m_attributes
 
VECTOR2I m_pos
 

Detailed Description

Instances are attached to a symbol or sheet and provide a place for the symbol's value, reference designator, footprint, , a sheet's name, filename, and user definable name-value pairs of arbitrary purpose.

  • Field 0 is reserved for the symbol reference.
  • Field 1 is reserved for the symbol value.
  • Field 2 is reserved for the symbol footprint.
  • Field 3 is reserved for the symbol data sheet file.
  • Field 4 and higher are user definable.

Definition at line 50 of file sch_field.h.

Constructor & Destructor Documentation

◆ SCH_FIELD() [1/3]

SCH_FIELD::SCH_FIELD ( const VECTOR2I aPos,
int  aFieldId,
SCH_ITEM aParent,
const wxString &  aName = wxEmptyString 
)

Definition at line 59 of file sch_field.cpp.

60 :
61 SCH_ITEM( aParent, SCH_FIELD_T ),
62 EDA_TEXT( schIUScale, wxEmptyString ),
63 m_id( 0 ),
64 m_name( aName ),
65 m_showName( false ),
66 m_allowAutoPlace( true ),
67 m_renderCacheValid( false ),
68 m_lastResolvedColor( COLOR4D::UNSPECIFIED )
69{
70 SetTextPos( aPos );
71 SetId( aFieldId ); // will also set the layer
72 SetVisible( false );
73}
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
void SetTextPos(const VECTOR2I &aPoint)
Definition: eda_text.cpp:373
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:219
EDA_TEXT(const EDA_IU_SCALE &aIuScale, const wxString &aText=wxEmptyString)
Definition: eda_text.cpp:92
COLOR4D m_lastResolvedColor
Definition: sch_field.h:261
bool m_showName
Render the field name in addition to its value.
Definition: sch_field.h:254
bool m_renderCacheValid
Definition: sch_field.h:257
void SetId(int aId)
Definition: sch_field.cpp:138
int m_id
Field index,.
Definition: sch_field.h:250
wxString m_name
Definition: sch_field.h:252
bool m_allowAutoPlace
This field can be autoplaced.
Definition: sch_field.h:255
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType)
Definition: sch_item.cpp:52
@ SCH_FIELD_T
Definition: typeinfo.h:155

References SetId(), EDA_TEXT::SetTextPos(), EDA_TEXT::SetVisible(), and UNSPECIFIED.

Referenced by Clone().

◆ SCH_FIELD() [2/3]

SCH_FIELD::SCH_FIELD ( SCH_ITEM aParent,
int  aFieldId,
const wxString &  aName = wxEmptyString 
)

Definition at line 76 of file sch_field.cpp.

76 :
77 SCH_FIELD( VECTOR2I(), aFieldId, aParent, aName )
78{
79}
SCH_FIELD(const VECTOR2I &aPos, int aFieldId, SCH_ITEM *aParent, const wxString &aName=wxEmptyString)
Definition: sch_field.cpp:59
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590

◆ SCH_FIELD() [3/3]

SCH_FIELD::SCH_FIELD ( const SCH_FIELD aText)

Definition at line 82 of file sch_field.cpp.

82 :
83 SCH_ITEM( aField ),
84 EDA_TEXT( aField )
85{
86 m_id = aField.m_id;
87 m_name = aField.m_name;
88 m_showName = aField.m_showName;
89 m_allowAutoPlace = aField.m_allowAutoPlace;
90
91 m_renderCache.clear();
92
93 for( const std::unique_ptr<KIFONT::GLYPH>& glyph : aField.m_renderCache )
94 {
95 KIFONT::OUTLINE_GLYPH* outline_glyph = static_cast<KIFONT::OUTLINE_GLYPH*>( glyph.get() );
96 m_renderCache.emplace_back( std::make_unique<KIFONT::OUTLINE_GLYPH>( *outline_glyph ) );
97 }
98
99 m_renderCacheValid = aField.m_renderCacheValid;
100 m_renderCachePos = aField.m_renderCachePos;
101
102 m_lastResolvedColor = aField.m_lastResolvedColor;
103}
std::vector< std::unique_ptr< KIFONT::GLYPH > > m_renderCache
Definition: sch_field.h:259
VECTOR2I m_renderCachePos
Definition: sch_field.h:258

References m_allowAutoPlace, m_id, m_lastResolvedColor, m_name, m_renderCache, m_renderCachePos, m_renderCacheValid, and m_showName.

◆ ~SCH_FIELD()

SCH_FIELD::~SCH_FIELD ( )
inline

Definition at line 60 of file sch_field.h.

61 { }

Member Function Documentation

◆ AddConnectionTo()

void SCH_ITEM::AddConnectionTo ( const SCH_SHEET_PATH aPath,
SCH_ITEM aItem 
)
inherited

Add a connection link between this item and another.

Definition at line 193 of file sch_item.cpp.

194{
195 SCH_ITEM_SET& set = m_connected_items[ aSheet ];
196
197 // The vector elements are small, so reserve 1k at a time to prevent re-allocations
198 if( set.size() == set.capacity() )
199 set.reserve( set.size() + 4096 );
200
201 set.emplace_back( aItem );
202}
std::map< SCH_SHEET_PATH, SCH_ITEM_SET, SHEET_PATH_CMP > m_connected_items
Store pointers to other items that are connected to this one, per sheet.
Definition: sch_item.h:498
std::vector< SCH_ITEM * > SCH_ITEM_SET
Definition: sch_item.h:136

References SCH_ITEM::m_connected_items.

Referenced by SCH_LABEL_BASE::UpdateDanglingState(), and CONNECTION_GRAPH::updateItemConnectivity().

◆ AddRenderCacheGlyph()

void EDA_TEXT::AddRenderCacheGlyph ( const SHAPE_POLY_SET aPoly)
inherited

Definition at line 493 of file eda_text.cpp.

494{
495 m_render_cache.emplace_back( std::make_unique<KIFONT::OUTLINE_GLYPH>( aPoly ) );
496}
std::vector< std::unique_ptr< KIFONT::GLYPH > > m_render_cache
Definition: eda_text.h:398

References EDA_TEXT::m_render_cache.

◆ AutoAutoplaceFields()

void SCH_ITEM::AutoAutoplaceFields ( SCH_SCREEN aScreen)
inlineinherited

Autoplace fields only if correct to do so automatically.

Fields that have been moved by hand are not automatically placed.

Parameters
aScreenis the SCH_SCREEN associated with the current instance of the symbol.

Definition at line 436 of file sch_item.h.

437 {
438 if( GetFieldsAutoplaced() )
440 }
FIELDS_AUTOPLACED GetFieldsAutoplaced() const
Return whether the fields have been automatically placed.
Definition: sch_item.h:424
virtual void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual)
Definition: sch_item.h:442
@ FIELDS_AUTOPLACED_MANUAL
Definition: sch_item.h:58

References SCH_ITEM::AutoplaceFields(), FIELDS_AUTOPLACED_MANUAL, and SCH_ITEM::GetFieldsAutoplaced().

Referenced by SCH_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Rotate(), SCH_SHEET::SCH_SHEET(), SCH_EDIT_FRAME::SelectUnit(), and DIALOG_LABEL_PROPERTIES::TransferDataFromWindow().

◆ AutoplaceFields()

virtual void SCH_ITEM::AutoplaceFields ( SCH_SCREEN aScreen,
bool  aManual 
)
inlinevirtualinherited

◆ cacheShownText()

void EDA_TEXT::cacheShownText ( )
protectedinherited

Definition at line 410 of file eda_text.cpp.

411{
412 if( m_text.IsEmpty() )
413 {
414 m_shown_text = wxEmptyString;
416 }
417 else
418 {
420 m_shown_text_has_text_var_refs = m_shown_text.Contains( wxT( "${" ) );
421 }
422
425}
wxString m_text
Definition: eda_text.h:389
bool m_shown_text_has_text_var_refs
Definition: eda_text.h:391
wxString m_shown_text
Definition: eda_text.h:390
bool m_bounding_box_cache_valid
Definition: eda_text.h:400
virtual void ClearRenderCache()
Definition: eda_text.cpp:440
wxString UnescapeString(const wxString &aSource)

References EDA_TEXT::ClearRenderCache(), EDA_TEXT::m_bounding_box_cache_valid, EDA_TEXT::m_shown_text, EDA_TEXT::m_shown_text_has_text_var_refs, EDA_TEXT::m_text, and UnescapeString().

Referenced by EDA_TEXT::EDA_TEXT(), EDA_TEXT::Replace(), and EDA_TEXT::SetText().

◆ CanAutoplace()

bool SCH_FIELD::CanAutoplace ( ) const
inline

◆ CanConnect()

virtual bool SCH_ITEM::CanConnect ( const SCH_ITEM aItem) const
inlinevirtualinherited

Reimplemented in SCH_BUS_WIRE_ENTRY, SCH_BUS_BUS_ENTRY, SCH_JUNCTION, SCH_LABEL_BASE, SCH_LINE, SCH_NO_CONNECT, SCH_SHEET, and SCH_SYMBOL.

Definition at line 344 of file sch_item.h.

344{ return m_layer == aItem->GetLayer(); }
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:246
SCH_LAYER_ID m_layer
Definition: sch_item.h:491

References SCH_ITEM::GetLayer(), and SCH_ITEM::m_layer.

Referenced by SCH_MOVE_TOOL::getConnectedDragItems().

◆ ClassOf()

static bool SCH_FIELD::ClassOf ( const EDA_ITEM aItem)
inlinestatic

Definition at line 65 of file sch_field.h.

66 {
67 return aItem && SCH_FIELD_T == aItem->Type();
68 }
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97

References SCH_FIELD_T, and EDA_ITEM::Type().

◆ ClearBoundingBoxCache()

void EDA_TEXT::ClearBoundingBoxCache ( )
virtualinherited

◆ ClearBrightened()

void EDA_ITEM::ClearBrightened ( )
inlineinherited

Definition at line 119 of file eda_item.h.

void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:141
#define BRIGHTENED
item is drawn with a bright contour

References BRIGHTENED, and EDA_ITEM::ClearFlags().

Referenced by SCH_EDIT_FRAME::FocusOnItem(), PCB_BASE_FRAME::FocusOnItems(), EE_SELECTION_TOOL::unhighlight(), PL_SELECTION_TOOL::unhighlight(), PCB_SELECTION_TOOL::unhighlightInternal(), and SCH_EDITOR_CONTROL::UpdateNetHighlighting().

◆ ClearCaches()

void SCH_FIELD::ClearCaches ( )
overridevirtual

Reimplemented from SCH_ITEM.

Definition at line 262 of file sch_field.cpp.

263{
266}
virtual void ClearBoundingBoxCache()
Definition: eda_text.cpp:446
void ClearRenderCache() override
Definition: sch_field.cpp:269

References EDA_TEXT::ClearBoundingBoxCache(), and ClearRenderCache().

◆ ClearConnections()

void SCH_ITEM::ClearConnections ( )
inlineinherited

Clears all of the connection items from the list.

The vector release method is used to prevent the item pointers from being deleted. Do not use the vector erase method on the connection list.

Definition at line 372 of file sch_item.h.

372{ m_connections.clear(); }
EDA_ITEMS m_connections
Definition: sch_item.h:492

References SCH_ITEM::m_connections.

◆ ClearEditFlags()

◆ ClearFieldsAutoplaced()

◆ ClearFlags()

void EDA_ITEM::ClearFlags ( EDA_ITEM_FLAGS  aMask = EDA_ITEM_ALL_FLAGS)
inlineinherited

Definition at line 141 of file eda_item.h.

141{ m_flags &= ~aMask; }
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:498

References EDA_ITEM::m_flags.

Referenced by FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), PNS_KICAD_IFACE::AddItem(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), SCH_MOVE_TOOL::AlignElements(), SCH_EDIT_TOOL::BreakWire(), FOOTPRINT::BuildCourtyardCaches(), EDA_ITEM::ClearBrightened(), EDA_ITEM::ClearEditFlags(), EDA_ITEM::ClearSelected(), EDA_ITEM::ClearTempFlags(), SCH_EDIT_FRAME::ConvertPart(), SYMBOL_EDITOR_EDIT_TOOL::Copy(), FOOTPRINT_EDITOR_CONTROL::CreateFootprint(), SYMBOL_EDITOR_PIN_TOOL::CreateImagePins(), MICROWAVE_TOOL::createMicrowaveInductor(), DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES(), BOARD_COMMIT::dirtyIntersectingZones(), PCB_TOOL_BASE::doInteractiveItemPlacement(), KIGFX::SCH_PAINTER::draw(), SCH_ITEM::Duplicate(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PCB_EDIT_FRAME::ExchangeFootprint(), PCB_SELECTION_TOOL::ExitGroup(), SYMBOL_EDIT_FRAME::GetSymbolFromRedoList(), SYMBOL_EDIT_FRAME::GetSymbolFromUndoList(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), DRC_INTERACTIVE_COURTYARD_CLEARANCE::Init(), EE_COLLECTOR::Inspect(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromLibrary(), FOOTPRINT_EDITOR_CONTROL::NewFootprint(), DIALOG_SYMBOL_PROPERTIES::OnUnitChoice(), FOOTPRINT_EDIT_FRAME::OpenProjectFiles(), PCB_BASE_FRAME::PlaceFootprint(), SYMBOL_EDITOR_PIN_TOOL::PlacePin(), BOARD_COMMIT::Push(), PCB_SELECTION_TOOL::RebuildSelection(), PAD_TOOL::RecombinePad(), SCH_EDIT_TOOL::RepeatDrawItem(), SYMBOL_EDIT_FRAME::RollbackSymbolFromUndo(), DRC_TEST_PROVIDER_DISALLOW::Run(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), SCH_SEXPR_PLUGIN_CACHE::savePin(), EE_SELECTION_TOOL::selectMultiple(), SCH_EDIT_FRAME::SelectUnit(), EDA_ITEM::SetIsShownAsBitmap(), BOARD_COMMIT::Stage(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), SCH_DRAWING_TOOLS::TwoClickPlace(), and EE_SELECTION_TOOL::unhighlight().

◆ ClearRenderCache()

void SCH_FIELD::ClearRenderCache ( )
overridevirtual

Reimplemented from EDA_TEXT.

Definition at line 269 of file sch_field.cpp.

270{
272 m_renderCacheValid = false;
273}

References EDA_TEXT::ClearRenderCache(), and m_renderCacheValid.

Referenced by ClearCaches().

◆ ClearSelected()

◆ ClearTempFlags()

void EDA_ITEM::ClearTempFlags ( )
inlineinherited

Definition at line 153 of file eda_item.h.

154 {
156 }
#define IS_LINKED
Used in calculation to mark linked items (temporary use)
#define SELECTED_BY_DRAG
Item was algorithmically selected as a dragged item.
#define SKIP_STRUCT
flag indicating that the structure should be ignored
#define CANDIDATE
flag indicating that the structure is connected

References CANDIDATE, EDA_ITEM::ClearFlags(), IS_LINKED, SELECTED_BY_DRAG, and SKIP_STRUCT.

Referenced by PCB_EDIT_FRAME::OpenProjectFiles(), and SCH_EDIT_FRAME::PutDataInPreviousState().

◆ ClearViewPrivData()

void KIGFX::VIEW_ITEM::ClearViewPrivData ( )
inlineinherited

Definition at line 143 of file view_item.h.

144 {
145 m_viewPrivData = nullptr;
146 }
VIEW_ITEM_DATA * m_viewPrivData
Definition: view_item.h:151

References KIGFX::VIEW_ITEM::m_viewPrivData.

Referenced by KIGFX::VIEW::OnDestroy().

◆ Clone()

EDA_ITEM * SCH_FIELD::Clone ( ) const
overridevirtual

Create a duplicate of this item with linked list members set to NULL.

The default version will return NULL in release builds and likely crash the program. In debug builds, a warning message indicating the derived class has not implemented cloning. This really should be a pure virtual function. Due to the fact that there are so many objects derived from EDA_ITEM, the decision was made to return NULL until all the objects derived from EDA_ITEM implement cloning. Once that happens, this function should be made pure.

Returns
A clone of the item.

Reimplemented from EDA_ITEM.

Definition at line 132 of file sch_field.cpp.

133{
134 return new SCH_FIELD( *this );
135}

References SCH_FIELD().

◆ Compare()

int EDA_TEXT::Compare ( const EDA_TEXT aOther) const
inherited

Definition at line 913 of file eda_text.cpp.

914{
915#define EPSILON 2 // Should be enough for rounding errors on calculated items
916
917#define TEST( a, b ) { if( a != b ) return a - b; }
918#define TEST_E( a, b ) { if( abs( a - b ) > EPSILON ) return a - b; }
919#define TEST_PT( a, b ) { TEST_E( a.x, b.x ); TEST_E( a.y, b.y ); }
920
921 TEST_PT( m_pos, aOther->m_pos );
922
927
937
938 int val = GetFontName().Cmp( aOther->GetFontName() );
939
940 if( val != 0 )
941 return val;
942
943 return m_text.Cmp( aOther->m_text );
944}
double AsDegrees() const
Definition: eda_angle.h:149
VECTOR2I m_pos
Definition: eda_text.h:407
wxString GetFontName() const
Definition: eda_text.cpp:759
TEXT_ATTRIBUTES m_attributes
Definition: eda_text.h:406
bool m_KeepUpright
If true, keep rotation angle between -90...90 degrees for readability.
GR_TEXT_H_ALIGN_T m_Halign
GR_TEXT_V_ALIGN_T m_Valign
#define TEST_PT(a, b)
#define TEST(a, b)
#define TEST_E(a, b)

References EDA_ANGLE::AsDegrees(), EDA_TEXT::GetFontName(), TEXT_ATTRIBUTES::m_Angle, EDA_TEXT::m_attributes, TEXT_ATTRIBUTES::m_Bold, TEXT_ATTRIBUTES::m_Halign, TEXT_ATTRIBUTES::m_Italic, TEXT_ATTRIBUTES::m_KeepUpright, TEXT_ATTRIBUTES::m_LineSpacing, TEXT_ATTRIBUTES::m_Mirrored, TEXT_ATTRIBUTES::m_Multiline, EDA_TEXT::m_pos, TEXT_ATTRIBUTES::m_Size, TEXT_ATTRIBUTES::m_StrokeWidth, EDA_TEXT::m_text, TEXT_ATTRIBUTES::m_Underlined, TEXT_ATTRIBUTES::m_Valign, TEXT_ATTRIBUTES::m_Visible, TEST, TEST_E, and TEST_PT.

◆ ConnectedItems()

SCH_ITEM_SET & SCH_ITEM::ConnectedItems ( const SCH_SHEET_PATH aPath)
inherited

Retrieve the set of items connected to this item on the given sheet.

Definition at line 187 of file sch_item.cpp.

188{
189 return m_connected_items[ aSheet ];
190}

References SCH_ITEM::m_connected_items.

Referenced by addConnections(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), SCH_LINE::FindWireSegmentNetNameRecursive(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ Connection()

SCH_CONNECTION * SCH_ITEM::Connection ( const SCH_SHEET_PATH aSheet = nullptr) const
inherited

Retrieve the connection associated with this object in the given sheet.

Note
The returned value can be nullptr.

Definition at line 146 of file sch_item.cpp.

147{
148 if( !IsConnectable() )
149 return nullptr;
150
151 wxCHECK_MSG( !IsConnectivityDirty(), nullptr,
152 wxT( "Shouldn't be asking for connection if connectivity is dirty!" ) );
153
154 if( !aSheet )
155 aSheet = &Schematic()->CurrentSheet();
156
157 auto it = m_connection_map.find( *aSheet );
158
159 if( it == m_connection_map.end() )
160 return nullptr;
161 else
162 return it->second;
163}
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:122
virtual bool IsConnectable() const
Definition: sch_item.h:349
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:112
bool IsConnectivityDirty() const
Definition: sch_item.h:413
std::unordered_map< SCH_SHEET_PATH, SCH_CONNECTION * > m_connection_map
Store connectivity information, per sheet.
Definition: sch_item.h:501

References SCHEMATIC::CurrentSheet(), SCH_ITEM::IsConnectable(), SCH_ITEM::IsConnectivityDirty(), SCH_ITEM::m_connection_map, and SCH_ITEM::Schematic().

Referenced by CONNECTION_SUBGRAPH::Absorb(), CONNECTION_SUBGRAPH::AddItem(), CONNECTION_GRAPH::buildConnectionGraph(), KIGFX::SCH_PAINTER::draw(), CONNECTION_GRAPH::ercCheckBusToBusConflicts(), CONNECTION_GRAPH::ercCheckBusToBusEntryConflicts(), CONNECTION_GRAPH::GetBusesNeedingMigration(), SCH_ITEM::GetEffectiveNetClass(), SCH_BUS_ENTRY_BASE::GetMsgPanelInfo(), SCH_LABEL_BASE::GetMsgPanelInfo(), SCH_LINE::GetMsgPanelInfo(), SCH_PIN::GetMsgPanelInfo(), CONNECTION_SUBGRAPH::GetNetName(), SCH_ITEM::GetOrInitConnection(), highlightNet(), SCH_ITEM::InitializeConnection(), SCH_LABEL_BASE::Plot(), SCH_LINE::Plot(), SCH_TEXT::Plot(), SCH_LABEL_BASE::Print(), NETLIST_EXPORTER_SPICE_MODEL::readPorts(), SCH_EDIT_FRAME::RecalculateConnections(), SCH_LABEL_BASE::ResolveTextVar(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataToWindow(), BUS_UNFOLD_MENU::update(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ ConnectionPropagatesTo()

virtual bool SCH_ITEM::ConnectionPropagatesTo ( const EDA_ITEM aItem) const
inlinevirtualinherited

Return true if this item should propagate connection info to aItem.

Reimplemented in SCH_BUS_WIRE_ENTRY, SCH_LINE, and SCH_PIN.

Definition at line 411 of file sch_item.h.

411{ return true; }

◆ CopyText()

◆ DoHypertextAction()

void SCH_FIELD::DoHypertextAction ( EDA_DRAW_FRAME aFrame) const
overridevirtual

Reimplemented from SCH_ITEM.

Definition at line 765 of file sch_field.cpp.

766{
767 constexpr int START_ID = 1;
768
769 if( IsHypertext() )
770 {
771 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( m_parent );
772 std::vector<std::pair<wxString, wxString>> pages;
773 wxMenu menu;
774 wxString href;
775
776 label->GetIntersheetRefs( &pages );
777
778 for( int i = 0; i < (int) pages.size(); ++i )
779 {
780 menu.Append( i + START_ID, wxString::Format( _( "Go to Page %s (%s)" ),
781 pages[i].first,
782 pages[i].second ) );
783 }
784
785 menu.AppendSeparator();
786 menu.Append( 999 + START_ID, _( "Back to Previous Selected Sheet" ) );
787
788 int sel = aFrame->GetPopupMenuSelectionFromUser( menu ) - START_ID;
789
790 if( sel >= 0 && sel < (int) pages.size() )
791 href = wxT( "#" ) + pages[ sel ].first;
792 else if( sel == 999 )
794
795 if( !href.IsEmpty() )
796 {
798 navTool->HypertextCommand( href );
799 }
800 }
801}
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:496
bool IsHypertext() const override
Allow items to support hypertext actions when hovered/clicked.
Definition: sch_field.h:95
void GetIntersheetRefs(std::vector< std::pair< wxString, wxString > > *pages)
Builds an array of { pageNumber, pageName } pairs.
Definition: sch_label.cpp:447
Handle actions specific to the schematic editor.
static wxString g_BackLink
void HypertextCommand(const wxString &href)
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
#define _(s)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200

References _, Format(), SCH_NAVIGATE_TOOL::g_BackLink, SCH_LABEL_BASE::GetIntersheetRefs(), TOOL_MANAGER::GetTool(), TOOLS_HOLDER::GetToolManager(), SCH_NAVIGATE_TOOL::HypertextCommand(), IsHypertext(), and EDA_ITEM::m_parent.

◆ doIsConnected()

virtual bool SCH_ITEM::doIsConnected ( const VECTOR2I aPosition) const
inlineprivatevirtualinherited

Provide the object specific test to see if it is connected to aPosition.

Note
Override this function if the derived object can be connect to another object such as a wire, bus, or junction. Do not override this function for objects that cannot have connections. The default will always return false. This functions is call through the public function IsConnected() which performs tests common to all schematic items before calling the item specific connection testing.
Parameters
aPositionis a reference to a VECTOR2I object containing the test position.
Returns
True if connection to aPosition exists.

Reimplemented in SCH_BUS_ENTRY_BASE, SCH_JUNCTION, SCH_LABEL, SCH_GLOBALLABEL, SCH_HIERLABEL, SCH_LINE, SCH_NO_CONNECT, SCH_SHEET, and SCH_SYMBOL.

Definition at line 488 of file sch_item.h.

488{ return false; }

Referenced by SCH_ITEM::IsConnected().

◆ Duplicate()

SCH_ITEM * SCH_ITEM::Duplicate ( bool  doClone = false) const
inherited

Routine to create a new copy of given item.

The new object is not put in draw list (not linked).

Parameters
doClone(default = false) indicates unique values (such as timestamp and sheet name) should be duplicated. Use only for undo/redo operations.

Definition at line 93 of file sch_item.cpp.

94{
95 SCH_ITEM* newItem = (SCH_ITEM*) Clone();
96
97 if( !doClone )
98 const_cast<KIID&>( newItem->m_Uuid ) = KIID();
99
100 newItem->ClearFlags( SELECTED | BRIGHTENED );
101
102 newItem->RunOnChildren(
103 []( SCH_ITEM* aChild )
104 {
105 aChild->ClearFlags( SELECTED | BRIGHTENED );
106 } );
107
108 return newItem;
109}
const KIID m_Uuid
Definition: eda_item.h:492
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:82
Definition: kiid.h:48
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction)
Definition: sch_item.h:444

References BRIGHTENED, EDA_ITEM::ClearFlags(), EDA_ITEM::Clone(), EDA_ITEM::m_Uuid, SCH_ITEM::RunOnChildren(), and SELECTED.

Referenced by SCH_LINE::BreakAt(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), CADSTAR_SCH_ARCHIVE_LOADER::loadItemOntoKiCadSheet(), SCH_EAGLE_PLUGIN::loadSchematic(), SCH_DRAWING_TOOLS::PlaceSymbol(), SCH_EDIT_TOOL::RepeatDrawItem(), SCH_EDIT_FRAME::SaveCopyInUndoList(), and SCH_LINE_WIRE_BUS_TOOL::startSegments().

◆ Empty()

void EDA_TEXT::Empty ( )
inherited

◆ Format()

void EDA_TEXT::Format ( OUTPUTFORMATTER aFormatter,
int  aNestLevel,
int  aControlBits 
) const
virtualinherited

Output the object to aFormatter in s-expression form.

Parameters
aFormatterThe OUTPUTFORMATTER object to write to.
aNestLevelThe indentation next level.
aControlBitsThe control bit definition for object specific formatting.
Exceptions
IO_ERRORon write error.

Definition at line 783 of file eda_text.cpp.

784{
785 aFormatter->Print( aNestLevel + 1, "(effects" );
786
787 aFormatter->Print( 0, " (font" );
788
789 if( GetFont() && !GetFont()->GetName().IsEmpty() )
790 aFormatter->Print( 0, " (face \"%s\")", GetFont()->NameAsToken() );
791
792 // Text size
793 aFormatter->Print( 0, " (size %s %s)",
796
797 if( GetLineSpacing() != 1.0 )
798 {
799 aFormatter->Print( 0, " (line_spacing %s)",
800 FormatDouble2Str( GetLineSpacing() ).c_str() );
801 }
802
803 if( GetTextThickness() )
804 {
805 aFormatter->Print( 0, " (thickness %s)",
807 }
808
809 if( IsBold() )
810 aFormatter->Print( 0, " bold" );
811
812 if( IsItalic() )
813 aFormatter->Print( 0, " italic" );
814
815 if( GetTextColor() != COLOR4D::UNSPECIFIED )
816 {
817 aFormatter->Print( 0, " (color %d %d %d %s)",
818 KiROUND( GetTextColor().r * 255.0 ),
819 KiROUND( GetTextColor().g * 255.0 ),
820 KiROUND( GetTextColor().b * 255.0 ),
821 FormatDouble2Str( GetTextColor().a ).c_str() );
822 }
823
824 aFormatter->Print( 0, ")"); // (font
825
828 {
829 aFormatter->Print( 0, " (justify");
830
832 aFormatter->Print( 0, GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ? " left" : " right" );
833
835 aFormatter->Print( 0, GetVertJustify() == GR_TEXT_V_ALIGN_TOP ? " top" : " bottom" );
836
837 if( IsMirrored() )
838 aFormatter->Print( 0, " mirror" );
839
840 aFormatter->Print( 0, ")" ); // (justify
841 }
842
843 if( !( aControlBits & CTL_OMIT_HIDE ) && !IsVisible() )
844 aFormatter->Print( 0, " hide" );
845
846 if( HasHyperlink() )
847 {
848 aFormatter->Print( 0, " (href %s)", aFormatter->Quotew( GetHyperlink() ).c_str() );
849 }
850
851 aFormatter->Print( 0, ")\n" ); // (effects
852}
int GetTextHeight() const
Definition: eda_text.h:202
COLOR4D GetTextColor() const
Definition: eda_text.h:205
bool IsItalic() const
Definition: eda_text.h:130
virtual bool IsVisible() const
Definition: eda_text.h:136
KIFONT::FONT * GetFont() const
Definition: eda_text.h:188
int GetTextWidth() const
Definition: eda_text.h:199
virtual bool HasHyperlink() const
Definition: eda_text.h:333
wxString GetHyperlink() const
Definition: eda_text.h:334
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:149
std::reference_wrapper< const EDA_IU_SCALE > m_IuScale
Definition: eda_text.h:393
double GetLineSpacing() const
Definition: eda_text.h:193
bool IsMirrored() const
Definition: eda_text.h:139
bool IsBold() const
Definition: eda_text.h:133
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:152
int GetTextThickness() const
Definition: eda_text.h:112
std::string Quotew(const wxString &aWrapee) const
Definition: richio.cpp:501
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:433
#define CTL_OMIT_HIDE
Definition: eda_text.h:53
std::string FormatInternalUnits(const EDA_IU_SCALE &aIuScale, int aValue)
Converts aValue from internal units to a string appropriate for writing to file.
Definition: eda_units.cpp:142
std::string FormatDouble2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 This function is intended in...
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_TOP
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:85

References CTL_OMIT_HIDE, FormatDouble2Str(), EDA_UNIT_UTILS::FormatInternalUnits(), EDA_TEXT::GetFont(), EDA_TEXT::GetHorizJustify(), EDA_TEXT::GetHyperlink(), EDA_TEXT::GetLineSpacing(), EDA_TEXT::GetTextColor(), EDA_TEXT::GetTextHeight(), EDA_TEXT::GetTextThickness(), EDA_TEXT::GetTextWidth(), EDA_TEXT::GetVertJustify(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, EDA_TEXT::HasHyperlink(), EDA_TEXT::IsBold(), EDA_TEXT::IsItalic(), EDA_TEXT::IsMirrored(), EDA_TEXT::IsVisible(), KiROUND(), EDA_TEXT::m_IuScale, OUTPUTFORMATTER::Print(), and OUTPUTFORMATTER::Quotew().

Referenced by SCH_SEXPR_PLUGIN_CACHE::saveField(), and SCH_SEXPR_PLUGIN::saveField().

◆ Get() [1/3]

template<typename T >
std::optional< T > INSPECTABLE::Get ( const wxString &  aProperty) const
inlineinherited

Definition at line 104 of file inspectable.h.

105 {
107 TYPE_ID thisType = TYPE_HASH( *this );
108 PROPERTY_BASE* prop = propMgr.GetProperty( thisType, aProperty );
109 std::optional<T> ret;
110
111 if( prop )
112 {
113 const void* object = propMgr.TypeCast( this, thisType, prop->OwnerHash() );
114
115 if( object )
116 ret = prop->get<T>( object );
117 }
118
119 return ret;
120 }
virtual size_t OwnerHash() const =0
Return type-id of the Owner class.
T get(const void *aObject) const
Definition: property.h:352
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:74
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:76
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Return a property for a specific type.
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Cast a type to another type.
#define TYPE_HASH(x)
Definition: property.h:63
size_t TYPE_ID
Unique type identifier.
Definition: property_mgr.h:46

References PROPERTY_BASE::get(), PROPERTY_MANAGER::GetProperty(), PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

◆ Get() [2/3]

wxAny INSPECTABLE::Get ( PROPERTY_BASE aProperty) const
inlineinherited

Definition at line 84 of file inspectable.h.

85 {
87 const void* object = propMgr.TypeCast( this, TYPE_HASH( *this ), aProperty->OwnerHash() );
88 return object ? aProperty->getter( object ) : wxAny();
89 }
virtual wxAny getter(const void *aObject) const =0

References PROPERTY_BASE::getter(), PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

Referenced by BOOST_AUTO_TEST_CASE(), CLASS_D_DESC::CLASS_D_DESC(), EDA_SHAPE_DESC::EDA_SHAPE_DESC(), PROPERTIES_PANEL::getItemValue(), PCB_EXPR_VAR_REF::GetValue(), and PAD_DESC::PAD_DESC().

◆ Get() [3/3]

template<typename T >
T INSPECTABLE::Get ( PROPERTY_BASE aProperty) const
inlineinherited

Definition at line 92 of file inspectable.h.

93 {
95 const void* object = propMgr.TypeCast( this, TYPE_HASH( *this ), aProperty->OwnerHash() );
96
97 if( !object )
98 throw std::runtime_error( "Could not cast INSPECTABLE to the requested type" );
99
100 return aProperty->get<T>( object );
101 }

References PROPERTY_BASE::get(), PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

◆ GetAttributes()

◆ GetBoundingBox()

const BOX2I SCH_FIELD::GetBoundingBox ( ) const
overridevirtual

Return the orthogonal bounding box of this object for display purposes.

This box should be an enclosing perimeter for visible components of this object, and the units should be in the pcb or schematic coordinate system. It is OK to overestimate the size by a few counts.

Reimplemented from EDA_ITEM.

Definition at line 449 of file sch_field.cpp.

450{
451 // Calculate the text bounding box:
452 BOX2I bbox = GetTextBox();
453
454 // Calculate the bounding box position relative to the parent:
455 VECTOR2I origin = GetParentPosition();
456 VECTOR2I pos = GetTextPos() - origin;
457 VECTOR2I begin = bbox.GetOrigin() - origin;
458 VECTOR2I end = bbox.GetEnd() - origin;
459 RotatePoint( begin, pos, GetTextAngle() );
460 RotatePoint( end, pos, GetTextAngle() );
461
462 // Now, apply the symbol transform (mirror/rot)
463 TRANSFORM transform;
464
465 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
466 {
467 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
468
469 // Due to the Y axis direction, we must mirror the bounding box,
470 // relative to the text position:
471 MIRROR( begin.y, pos.y );
472 MIRROR( end.y, pos.y );
473
474 transform = parentSymbol->GetTransform();
475 }
476 else
477 {
478 transform = TRANSFORM( 1, 0, 0, 1 ); // identity transform
479 }
480
481 bbox.SetOrigin( transform.TransformCoordinate( begin ) );
482 bbox.SetEnd( transform.TransformCoordinate( end ) );
483
484 bbox.Move( origin );
485 bbox.Normalize();
486
487 return bbox;
488}
void SetOrigin(const Vec &pos)
Definition: box2.h:202
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:119
const Vec & GetOrigin() const
Definition: box2.h:183
const Vec GetEnd() const
Definition: box2.h:185
void Move(const Vec &aMoveVector)
Move the rectangle by the aMoveVector.
Definition: box2.h:111
void SetEnd(coord_type x, coord_type y)
Definition: box2.h:255
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,...
Definition: eda_text.cpp:505
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:208
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:120
VECTOR2I GetParentPosition() const
Definition: sch_field.cpp:1084
Schematic symbol object.
Definition: sch_symbol.h:81
TRANSFORM & GetTransform()
Definition: sch_symbol.h:283
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:47
VECTOR2I TransformCoordinate(const VECTOR2I &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:46
void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Definition: mirror.h:40
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183
@ SCH_SYMBOL_T
Definition: typeinfo.h:156

References BOX2< Vec >::GetEnd(), BOX2< Vec >::GetOrigin(), GetParentPosition(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextBox(), EDA_TEXT::GetTextPos(), SCH_SYMBOL::GetTransform(), EDA_ITEM::m_parent, MIRROR(), BOX2< Vec >::Move(), BOX2< Vec >::Normalize(), RotatePoint(), SCH_SYMBOL_T, BOX2< Vec >::SetEnd(), BOX2< Vec >::SetOrigin(), TRANSFORM::TransformCoordinate(), EDA_ITEM::Type(), and VECTOR2< T >::y.

Referenced by KIGFX::SCH_PAINTER::draw(), AUTOPLACER::fieldVPlacement(), HitTest(), IsHorizJustifyFlipped(), IsVertJustifyFlipped(), Plot(), and Print().

◆ GetCanonicalName()

wxString SCH_FIELD::GetCanonicalName ( ) const

Get a non-language-specific name for a field which can be used for storage, variable look-up, etc.

Definition at line 836 of file sch_field.cpp.

837{
838 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
839 {
840 switch( m_id )
841 {
842 case REFERENCE_FIELD: return wxT( "Reference" );
843 case VALUE_FIELD: return wxT( "Value" );
844 case FOOTPRINT_FIELD: return wxT( "Footprint" );
845 case DATASHEET_FIELD: return wxT( "Datasheet" );
846 default: return m_name;
847 }
848 }
849 else if( m_parent && m_parent->Type() == SCH_SHEET_T )
850 {
851 switch( m_id )
852 {
853 case SHEETNAME: return wxT( "Sheetname" );
854 case SHEETFILENAME: return wxT( "Sheetfile" );
855 default: return m_name;
856 }
857 }
858 else if( m_parent && m_parent->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
859 {
860 // These should be stored in canonical format, but just in case:
861 if( m_name == _( "Net Class" ) || m_name == wxT( "Net Class" ) )
862 return wxT( "Netclass" );
863 else if( m_name == _( "Sheet References" )
864 || m_name == wxT( "Sheet References" )
865 || m_name == wxT( "Intersheet References" ) )
866 return wxT( "Intersheetrefs" );
867 else
868 return m_name;
869 }
870 else
871 {
872 if( m_parent )
873 {
874 wxFAIL_MSG( wxString::Format( "Unhandled field owner type (id %d, parent type %d).",
875 m_id, m_parent->Type() ) );
876 }
877
878 return m_name;
879 }
880}
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition: eda_item.h:181
@ SHEETNAME
Definition: sch_sheet.h:45
@ SHEETFILENAME
Definition: sch_sheet.h:46
@ DATASHEET_FIELD
name of datasheet
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
@ SCH_SHEET_T
Definition: typeinfo.h:158

References _, DATASHEET_FIELD, FOOTPRINT_FIELD, Format(), EDA_ITEM::IsType(), m_id, m_name, EDA_ITEM::m_parent, REFERENCE_FIELD, SCH_SHEET_T, SCH_SYMBOL_T, SHEETFILENAME, SHEETNAME, EDA_ITEM::Type(), and VALUE_FIELD.

Referenced by DIALOG_CHANGE_SYMBOLS::processSymbols(), SCH_SEXPR_PLUGIN::saveField(), and SetId().

◆ GetClass()

wxString SCH_FIELD::GetClass ( ) const
inlineoverridevirtual

Return the class name.

Reimplemented from SCH_ITEM.

Definition at line 70 of file sch_field.h.

71 {
72 return wxT( "SCH_FIELD" );
73 }

◆ GetConnectionPoints()

virtual std::vector< VECTOR2I > SCH_ITEM::GetConnectionPoints ( ) const
inlinevirtualinherited

Add all the connection points for this item to aPoints.

Not all schematic items have connection points so the default method does nothing.

Parameters
aPointsis the list of connection points to add to.

Reimplemented in SCH_BUS_ENTRY_BASE, SCH_JUNCTION, SCH_LABEL_BASE, SCH_LINE, SCH_NO_CONNECT, SCH_SHEET, and SCH_SYMBOL.

Definition at line 364 of file sch_item.h.

364{ return {}; }

Referenced by SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), SCH_MOVE_TOOL::AlignElements(), EE_GRID_HELPER::computeAnchors(), SCH_EDIT_TOOL::DoDelete(), SCH_SCREEN::GetNeededJunctions(), SCH_MOVE_TOOL::Main(), SCH_EDITOR_CONTROL::Paste(), and SCH_LINE_WIRE_BUS_TOOL::TrimOverLappingWires().

◆ GetDefaultFont()

const wxString & SCH_ITEM::GetDefaultFont ( ) const
inherited

Definition at line 286 of file sch_item.cpp.

287{
288 EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
289
290 return cfg->m_Appearance.default_font;
291}
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111

References EESCHEMA_SETTINGS::APPEARANCE::default_font, EESCHEMA_SETTINGS::m_Appearance, and Pgm().

Referenced by getDrawFont(), SCH_TEXT::getDrawFont(), SCH_TEXTBOX::getDrawFont(), GetRenderCache(), and SCH_TEXTBOX::GetShownText().

◆ getDrawFont()

KIFONT::FONT * SCH_FIELD::getDrawFont ( ) const
overrideprotectedvirtual

Reimplemented from EDA_TEXT.

Definition at line 251 of file sch_field.cpp.

252{
254
255 if( !font )
257
258 return font;
259}
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:105
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false)
Definition: font.cpp:138
const wxString & GetDefaultFont() const
Definition: sch_item.cpp:286

References SCH_ITEM::GetDefaultFont(), EDA_TEXT::GetFont(), KIFONT::FONT::GetFont(), EDA_TEXT::IsBold(), and EDA_TEXT::IsItalic().

◆ GetDrawPos()

◆ GetDrawRotation()

EDA_ANGLE SCH_FIELD::GetDrawRotation ( ) const
overridevirtual

Adjusters to allow EDA_TEXT to draw/print/etc.

text in absolute coords.

Reimplemented from EDA_TEXT.

Definition at line 427 of file sch_field.cpp.

428{
429 // Calculate the text orientation according to the symbol orientation.
430 EDA_ANGLE orient = GetTextAngle();
431
432 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
433 {
434 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
435
436 if( parentSymbol && parentSymbol->GetTransform().y1 ) // Rotate symbol 90 degrees.
437 {
438 if( orient.IsHorizontal() )
439 orient = ANGLE_VERTICAL;
440 else
441 orient = ANGLE_HORIZONTAL;
442 }
443 }
444
445 return orient;
446}
bool IsHorizontal() const
Definition: eda_angle.h:174
int y1
Definition: transform.h:50
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
Definition: eda_angle.h:425
static constexpr EDA_ANGLE & ANGLE_VERTICAL
Definition: eda_angle.h:426

References ANGLE_HORIZONTAL, ANGLE_VERTICAL, EDA_TEXT::GetTextAngle(), SCH_SYMBOL::GetTransform(), EDA_ANGLE::IsHorizontal(), EDA_ITEM::m_parent, SCH_SYMBOL_T, EDA_ITEM::Type(), and TRANSFORM::y1.

Referenced by IsHorizJustifyFlipped(), and IsVertJustifyFlipped().

◆ GetEditFlags()

EDA_ITEM_FLAGS EDA_ITEM::GetEditFlags ( ) const
inlineinherited

Definition at line 145 of file eda_item.h.

146 {
147 constexpr int mask =
149
150 return m_flags & mask;
151 }
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
#define IS_CHANGED
Item was edited, and modified.
#define IS_NEW
New item, just created.
#define IS_BROKEN
Is a segment just broken by BreakSegment.
#define STRUCT_DELETED
flag indication structures to be erased
#define IS_MOVING
Item being moved.

References IS_BROKEN, IS_CHANGED, IS_MOVING, IS_NEW, IS_PASTED, EDA_ITEM::m_flags, and STRUCT_DELETED.

Referenced by SCH_EDIT_TOOL::ChangeTextType(), EDA_ITEM::ClearEditFlags(), SCH_EDIT_FRAME::DeleteJunction(), SCH_EDIT_TOOL::editFieldText(), SYMBOL_EDITOR_PIN_TOOL::EditPinProperties(), SCH_EDITOR_CONTROL::EditWithSymbolEditor(), SCH_SYMBOL::GetMsgPanelInfo(), SELECTION_CONDITIONS::Idle(), SELECTION_CONDITIONS::IdleSelection(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PCB_POINT_EDITOR::OnSelectionChange(), SYMBOL_EDITOR_EDIT_TOOL::Properties(), SCH_EDIT_FRAME::SelectUnit(), DIALOG_IMAGE_PROPERTIES::TransferDataFromWindow(), DIALOG_LABEL_PROPERTIES::TransferDataFromWindow(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_DIMENSION_PROPERTIES::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow(), DIALOG_TARGET_PROPERTIES::TransferDataFromWindow(), and DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow().

◆ GetEffectiveHorizJustify()

GR_TEXT_H_ALIGN_T SCH_FIELD::GetEffectiveHorizJustify ( ) const

Definition at line 514 of file sch_field.cpp.

515{
516 switch( GetHorizJustify() )
517 {
522 default:
524 }
525}
bool IsHorizJustifyFlipped() const
Return whether the field will be rendered with the horizontal justification inverted due to rotation ...
Definition: sch_field.cpp:491
@ GR_TEXT_H_ALIGN_RIGHT

References EDA_TEXT::GetHorizJustify(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_H_ALIGN_RIGHT, and IsHorizJustifyFlipped().

Referenced by DIALOG_SCH_FIELD_PROPERTIES::DIALOG_SCH_FIELD_PROPERTIES(), and DIALOG_SCH_FIELD_PROPERTIES::UpdateField().

◆ GetEffectiveNetClass()

std::shared_ptr< NETCLASS > SCH_ITEM::GetEffectiveNetClass ( const SCH_SHEET_PATH aSheet = nullptr) const
inherited

Definition at line 166 of file sch_item.cpp.

167{
168 static std::shared_ptr<NETCLASS> nullNetclass = std::make_shared<NETCLASS>( wxEmptyString );
169
170 SCHEMATIC* schematic = Schematic();
171
172 if( schematic )
173 {
174 std::shared_ptr<NET_SETTINGS>& netSettings = schematic->Prj().GetProjectFile().m_NetSettings;
175 SCH_CONNECTION* connection = Connection( aSheet );
176
177 if( connection )
178 return netSettings->GetEffectiveNetClass( connection->Name() );
179 else
180 return netSettings->m_DefaultNetClass;
181 }
182
183 return nullNetclass;
184}
std::shared_ptr< NET_SETTINGS > m_NetSettings
Net settings for this project (owned here)
Definition: project_file.h:168
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:149
Holds all the data relating to one schematic.
Definition: schematic.h:61
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:76
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
wxString Name(bool aIgnoreSheet=false) const
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:146

References SCH_ITEM::Connection(), PROJECT::GetProjectFile(), PROJECT_FILE::m_NetSettings, SCH_CONNECTION::Name(), SCHEMATIC::Prj(), and SCH_ITEM::Schematic().

Referenced by SCH_BUS_ENTRY_BASE::GetBusEntryColor(), SCH_LINE::GetEffectiveLineStyle(), SCH_JUNCTION::getEffectiveShape(), GetFieldColor(), SCH_JUNCTION::GetJunctionColor(), SCH_LABEL_BASE::GetLabelColor(), SCH_LINE::GetLineColor(), SCH_BUS_ENTRY_BASE::GetLineStyle(), SCH_BUS_ENTRY_BASE::GetMsgPanelInfo(), SCH_LABEL_BASE::GetMsgPanelInfo(), SCH_LINE::GetMsgPanelInfo(), SCH_BUS_WIRE_ENTRY::GetPenWidth(), SCH_BUS_BUS_ENTRY::GetPenWidth(), SCH_LINE::GetPenWidth(), SCH_LABEL_BASE::Plot(), SCH_LINE::Plot(), and SCH_LABEL_BASE::ResolveTextVar().

◆ GetEffectiveTextPenWidth()

int EDA_TEXT::GetEffectiveTextPenWidth ( int  aDefaultPenWidth = 0) const
inherited

The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.

Definition at line 299 of file eda_text.cpp.

300{
301 int penWidth = GetTextThickness();
302
303 if( penWidth <= 1 )
304 {
305 penWidth = aDefaultPenWidth;
306
307 if( IsBold() )
308 penWidth = GetPenSizeForBold( GetTextWidth() );
309 else if( penWidth <= 1 )
310 penWidth = GetPenSizeForNormal( GetTextWidth() );
311 }
312
313 // Clip pen size for small texts:
314 penWidth = Clamp_Text_PenSize( penWidth, GetTextSize() );
315
316 return penWidth;
317}
VECTOR2I GetTextSize() const
Definition: eda_text.h:196
int GetPenSizeForBold(int aTextSize)
Definition: gr_text.cpp:40
int GetPenSizeForNormal(int aTextSize)
Definition: gr_text.cpp:64
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aStrict)
Pen width should not allow characters to become cluttered up in their own fatness.
Definition: gr_text.cpp:87

References Clamp_Text_PenSize(), GetPenSizeForBold(), GetPenSizeForNormal(), EDA_TEXT::GetTextSize(), EDA_TEXT::GetTextThickness(), EDA_TEXT::GetTextWidth(), and EDA_TEXT::IsBold().

Referenced by BOARD_ADAPTER::addText(), KIGFX::DS_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), SCH_LABEL_BASE::GetBodyBoundingBox(), SCH_LABEL::GetBodyBoundingBox(), SCH_HIERLABEL::GetBodyBoundingBox(), FP_TEXT::GetEffectiveShape(), PCB_TEXT::GetEffectiveShape(), EDA_TEXT::GetEffectiveTextShape(), LIB_FIELD::GetPenWidth(), LIB_TEXT::GetPenWidth(), GetPenWidth(), SCH_DIRECTIVE_LABEL::GetPenWidth(), SCH_TEXT::GetPenWidth(), EDA_TEXT::GetTextBox(), Plot(), SCH_LABEL_BASE::Plot(), SCH_TEXT::Plot(), SCH_TEXTBOX::Plot(), LIB_TEXT::Plot(), LIB_TEXTBOX::Plot(), BRDITEMS_PLOTTER::PlotFootprintTextItem(), BRDITEMS_PLOTTER::PlotPcbText(), Print(), LIB_TEXT::print(), LIB_TEXTBOX::print(), EDA_TEXT::printOneLineOfText(), FP_TEXT::TransformTextToPolySet(), FP_TEXTBOX::TransformTextToPolySet(), PCB_TEXT::TransformTextToPolySet(), PCB_TEXTBOX::TransformTextToPolySet(), PCB_DIM_ALIGNED::updateGeometry(), PCB_DIM_ORTHOGONAL::updateGeometry(), PCB_DIM_RADIAL::updateGeometry(), PCB_DIM_LEADER::updateGeometry(), PCB_DIM_ALIGNED::updateText(), and PCB_DIM_ORTHOGONAL::updateText().

◆ GetEffectiveTextShape()

std::shared_ptr< SHAPE_COMPOUND > EDA_TEXT::GetEffectiveTextShape ( bool  aTriangulate = true,
bool  aUseTextRotation = true 
) const
inherited

build a list of segments (SHAPE_SEGMENT) to describe a text shape.

Parameters
aTriangulatetrue to build also the triangulation of each shape
aUseTextRotationtrue to use the actual text draw rotation. false to build a list of shape for a not rotated text ("native" shapes).

Definition at line 855 of file eda_text.cpp.

857{
858 std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
860 KIFONT::FONT* font = getDrawFont();
861 int penWidth = GetEffectiveTextPenWidth();
863
864 if( aUseTextRotation )
865 attrs.m_Angle = GetDrawRotation();
866 else
867 attrs.m_Angle = ANGLE_0;
868
869 if( aTriangulate )
870 {
871 CALLBACK_GAL callback_gal(
872 empty_opts,
873 // Stroke callback
874 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
875 {
876 shape->AddShape( new SHAPE_SEGMENT( aPt1, aPt2, penWidth ) );
877 },
878 // Triangulation callback
879 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2, const VECTOR2I& aPt3 )
880 {
881 SHAPE_SIMPLE* triShape = new SHAPE_SIMPLE;
882
883 for( const VECTOR2I& point : { aPt1, aPt2, aPt3 } )
884 triShape->Append( point.x, point.y );
885
886 shape->AddShape( triShape );
887 } );
888
889 font->Draw( &callback_gal, GetShownText(), GetDrawPos(), attrs );
890 }
891 else
892 {
893 CALLBACK_GAL callback_gal(
894 empty_opts,
895 // Stroke callback
896 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
897 {
898 shape->AddShape( new SHAPE_SEGMENT( aPt1, aPt2, penWidth ) );
899 },
900 // Outline callback
901 [&]( const SHAPE_LINE_CHAIN& aPoly )
902 {
903 shape->AddShape( aPoly.Clone() );
904 } );
905
906 font->Draw( &callback_gal, GetShownText(), GetDrawPos(), attrs );
907 }
908
909 return shape;
910}
virtual EDA_ANGLE GetDrawRotation() const
Definition: eda_text.h:317
virtual VECTOR2I GetDrawPos() const
Definition: eda_text.h:318
virtual KIFONT::FONT * getDrawFont() const
Definition: eda_text.cpp:428
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:172
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:299
virtual wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:98
void Draw(KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aCursor, const TEXT_ATTRIBUTES &aAttrs) const
Draw a string.
Definition: font.cpp:232
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Represent a simple polygon consisting of a zero-thickness closed chain of connected line segments.
Definition: shape_simple.h:42
void Append(int aX, int aY)
Append a new point at the end of the polygon.
Definition: shape_simple.h:135
static constexpr EDA_ANGLE & ANGLE_0
Definition: eda_angle.h:429

References ANGLE_0, SHAPE_SIMPLE::Append(), KIFONT::FONT::Draw(), EDA_TEXT::GetAttributes(), EDA_TEXT::getDrawFont(), EDA_TEXT::GetDrawPos(), EDA_TEXT::GetDrawRotation(), EDA_TEXT::GetEffectiveTextPenWidth(), EDA_TEXT::GetShownText(), and TEXT_ATTRIBUTES::m_Angle.

Referenced by PCB_DIMENSION_BASE::GetEffectiveShape(), FP_TEXT::GetEffectiveShape(), FP_TEXTBOX::GetEffectiveShape(), PCB_TEXT::GetEffectiveShape(), PCB_TEXTBOX::GetEffectiveShape(), PCB_SELECTION_TOOL::hitTestDistance(), PNS_KICAD_IFACE_BASE::syncTextItem(), and EDA_TEXT::TransformBoundingBoxToPolygon().

◆ GetEffectiveVertJustify()

◆ GetEndPoints()

virtual void SCH_ITEM::GetEndPoints ( std::vector< DANGLING_END_ITEM > &  aItemList)
inlinevirtualinherited

Add the schematic item end points to aItemList if the item has end points.

The default version doesn't do anything since many of the schematic object cannot be tested for dangling ends. If you add a new schematic item that can have a dangling end ( no connect ), override this method to provide the correct end points.

Parameters
aItemListis the list of DANGLING_END_ITEMS to add to.

Reimplemented in SCH_BUS_WIRE_ENTRY, SCH_BUS_BUS_ENTRY, SCH_JUNCTION, SCH_LABEL_BASE, SCH_LINE, SCH_NO_CONNECT, SCH_SHEET, SCH_SHEET_PIN, and SCH_SYMBOL.

Definition at line 318 of file sch_item.h.

318{}

Referenced by PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems().

◆ GetFieldColor()

COLOR4D SCH_FIELD::GetFieldColor ( ) const

Definition at line 407 of file sch_field.cpp.

408{
409 if( GetTextColor() != COLOR4D::UNSPECIFIED )
410 {
412 }
413 else
414 {
415 SCH_LABEL_BASE* parentLabel = dynamic_cast<SCH_LABEL_BASE*>( GetParent() );
416
417 if( parentLabel && !parentLabel->IsConnectivityDirty() )
418 m_lastResolvedColor = parentLabel->GetEffectiveNetClass()->GetSchematicColor();
419 else
421 }
422
423 return m_lastResolvedColor;
424}
EDA_ITEM * GetParent() const
Definition: eda_item.h:99
std::shared_ptr< NETCLASS > GetEffectiveNetClass(const SCH_SHEET_PATH *aSheet=nullptr) const
Definition: sch_item.cpp:166

References SCH_ITEM::GetEffectiveNetClass(), EDA_ITEM::GetParent(), EDA_TEXT::GetTextColor(), SCH_ITEM::IsConnectivityDirty(), and m_lastResolvedColor.

◆ GetFieldsAutoplaced()

FIELDS_AUTOPLACED SCH_ITEM::GetFieldsAutoplaced ( ) const
inlineinherited

Return whether the fields have been automatically placed.

Definition at line 424 of file sch_item.h.

424{ return m_fieldsAutoplaced; }

References SCH_ITEM::m_fieldsAutoplaced.

Referenced by SCH_ITEM::AutoAutoplaceFields(), SCH_SEXPR_PLUGIN::saveSheet(), SCH_SEXPR_PLUGIN::saveSymbol(), and SCH_SEXPR_PLUGIN::saveText().

◆ GetFlags()

◆ GetFocusPosition()

virtual const VECTOR2I EDA_ITEM::GetFocusPosition ( ) const
inlinevirtualinherited

Similar to GetPosition, but allows items to return their visual center rather than their anchor.

Reimplemented in BOARD, PCB_SHAPE, and PCB_TRACK.

Definition at line 256 of file eda_item.h.

256{ return GetPosition(); }
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:249

References EDA_ITEM::GetPosition().

Referenced by SCH_EDIT_FRAME::FocusOnItem().

◆ GetFont()

KIFONT::FONT * EDA_TEXT::GetFont ( ) const
inlineinherited

Definition at line 188 of file eda_text.h.

188{ return m_attributes.m_Font; }
KIFONT::FONT * m_Font

References EDA_TEXT::m_attributes, and TEXT_ATTRIBUTES::m_Font.

Referenced by BOARD_ADAPTER::addText(), SCH_EDIT_TOOL::ChangeTextType(), DIALOG_SCH_FIELD_PROPERTIES::DIALOG_SCH_FIELD_PROPERTIES(), KIGFX::DS_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), KIGFX::SCH_PAINTER::draw(), PCB_PLUGIN::format(), EDA_TEXT::Format(), PCB_PLUGIN::formatRenderCache(), EDA_TEXT::getDrawFont(), LIB_FIELD::getDrawFont(), LIB_TEXT::getDrawFont(), LIB_TEXTBOX::getDrawFont(), getDrawFont(), SCH_TEXT::getDrawFont(), SCH_TEXTBOX::getDrawFont(), KIGFX::SCH_PAINTER::getFont(), EDA_TEXT::GetFontName(), LIB_FIELD::GetMsgPanelInfo(), LIB_TEXT::GetMsgPanelInfo(), LIB_TEXTBOX::GetMsgPanelInfo(), GetMsgPanelInfo(), SCH_LABEL_BASE::GetMsgPanelInfo(), SCH_TEXT::GetMsgPanelInfo(), SCH_TEXTBOX::GetMsgPanelInfo(), FP_TEXT::GetMsgPanelInfo(), FP_TEXTBOX::GetMsgPanelInfo(), PCB_DIMENSION_BASE::GetMsgPanelInfo(), PCB_TEXT::GetMsgPanelInfo(), PCB_TEXTBOX::GetMsgPanelInfo(), GetRenderCache(), LIB_TEXTBOX::GetShownText(), SCH_TEXTBOX::GetShownText(), Plot(), SCH_LABEL_BASE::Plot(), SCH_TEXT::Plot(), SCH_TEXTBOX::Plot(), LIB_FIELD::Plot(), LIB_TEXT::Plot(), LIB_TEXTBOX::Plot(), BRDITEMS_PLOTTER::PlotFootprintTextItem(), BRDITEMS_PLOTTER::PlotPcbText(), Print(), LIB_FIELD::print(), LIB_TEXT::print(), LIB_TEXTBOX::print(), SCH_TEXT::Print(), EDA_TEXT::printOneLineOfText(), DIALOG_LABEL_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataToWindow(), DIALOG_SHEET_PIN_PROPERTIES::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_DIMENSION_PROPERTIES::TransferDataToWindow(), and DIALOG_TEXTBOX_PROPERTIES::TransferDataToWindow().

◆ GetFontName()

wxString EDA_TEXT::GetFontName ( ) const
inherited

Definition at line 759 of file eda_text.cpp.

760{
761 if( GetFont() )
762 return GetFont()->GetName();
763 else
764 return wxEmptyString;
765}
const wxString & GetName() const
Definition: font.h:121

References EDA_TEXT::GetFont(), and KIFONT::FONT::GetName().

Referenced by EDA_TEXT::Compare(), EDA_TEXT::IsDefaultFormatting(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem().

◆ GetFriendlyName()

wxString EDA_ITEM::GetFriendlyName ( ) const
virtualinherited

Reimplemented in PCB_SHAPE, PCB_TRACK, and ZONE.

Definition at line 310 of file eda_item.cpp.

311{
312 return GetTypeDesc();
313}
wxString GetTypeDesc() const
Return a translated description of the type for this EDA_ITEM for display in user facing messages.
Definition: eda_item.cpp:301

References EDA_ITEM::GetTypeDesc().

Referenced by PROPERTIES_PANEL::rebuildProperties().

◆ GetHorizJustify()

GR_TEXT_H_ALIGN_T EDA_TEXT::GetHorizJustify ( ) const
inlineinherited

Definition at line 149 of file eda_text.h.

149{ return m_attributes.m_Halign; };

References EDA_TEXT::m_attributes, and TEXT_ATTRIBUTES::m_Halign.

Referenced by SCH_EDIT_TOOL::ChangeTextType(), LIB_TEXTBOX::compare(), DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), EDA_TEXT_DESC::EDA_TEXT_DESC(), AUTOPLACER::fieldHPlacement(), EDA_TEXT::Format(), LIB_TEXTBOX::GetDrawPos(), SCH_TEXTBOX::GetDrawPos(), FP_TEXTBOX::GetDrawPos(), PCB_TEXTBOX::GetDrawPos(), GetEffectiveHorizJustify(), LIB_FIELD::GetMsgPanelInfo(), LIB_TEXT::GetMsgPanelInfo(), GetMsgPanelInfo(), EDA_TEXT::GetTextBox(), hash_fp_item(), EDA_TEXT::IsDefaultFormatting(), IsHorizJustifyFlipped(), FP_TEXT::KeepUpright(), SCH_EAGLE_PLUGIN::loadFieldAttributes(), LEGACY_PLUGIN::loadPCB_TEXT(), SCH_EDIT_TOOL::Mirror(), FP_TEXT::Mirror(), PCB_TEXT::Mirror(), LIB_TEXT::MirrorHorizontal(), LIB_TEXTBOX::MirrorHorizontally(), SCH_TEXTBOX::MirrorHorizontally(), LIB_TEXT::MirrorVertical(), LIB_TEXTBOX::MirrorVertically(), SCH_TEXTBOX::MirrorVertically(), LIB_TEXT::NormalizeJustification(), Plot(), positioningChanged(), LIB_FIELD::print(), EDA_TEXT::printOneLineOfText(), LIB_TEXT::Rotate(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveText(), textsNeedUpdate(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_DIMENSION_PROPERTIES::TransferDataToWindow(), and DIALOG_TEXTBOX_PROPERTIES::TransferDataToWindow().

◆ GetHyperlink()

wxString EDA_TEXT::GetHyperlink ( ) const
inlineinherited

◆ GetId()

◆ GetInterline()

int EDA_TEXT::GetInterline ( ) const
inherited

Return the distance between two lines of text.

Calculates the distance (pitch) between two lines of text. This distance includes the interline distance plus room for characters like j, {, and [. It also used for single line text, to calculate the text bounding box.

Definition at line 499 of file eda_text.cpp.

500{
502}
int GetInterline() const
Return the distance between two lines of text.
Definition: eda_text.cpp:499

References EDA_TEXT::getDrawFont(), EDA_TEXT::GetInterline(), EDA_TEXT::GetTextHeight(), and KiROUND().

Referenced by CADSTAR_ARCHIVE_PARSER::FixTextPositionNoAlignment(), EDA_TEXT::GetInterline(), and EDA_TEXT::GetLinePositions().

◆ GetInternalName()

const wxString & SCH_FIELD::GetInternalName ( )
inline

Get the initial name of the field set at creation (or set by SetName()).

This is the raw field name with no translation and no change.

Definition at line 123 of file sch_field.h.

123{ return m_name; }

References m_name.

Referenced by SCH_SEXPR_PARSER::parseSchText(), and SCH_SHEET_PATH::UpdateAllScreenReferences().

◆ GetItemDescription()

wxString SCH_FIELD::GetItemDescription ( UNITS_PROVIDER aUnitsProvider) const
overridevirtual

Return a user-visible description string of this item.

This description is used in disambiguation menus, the message panel, ERC/DRC reports, etc.

The default version of this function raises an assertion in the debug mode and returns a string to indicate that it was not overridden to provide the object specific text.

Returns
The menu text string.

Reimplemented from EDA_ITEM.

Definition at line 722 of file sch_field.cpp.

723{
725}
wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const override
Return the string actually shown after processing of the base text.
Definition: sch_field.cpp:175
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: sch_field.cpp:804
wxString EllipsizeMenuText(const wxString &aString)
Ellipsize text (at the end) to be no more than 36 characters.
Definition: ui_common.cpp:215

References KIUI::EllipsizeMenuText(), Format(), GetName(), and GetShownText().

◆ GetLayer()

◆ GetLibPosition()

VECTOR2I SCH_FIELD::GetLibPosition ( ) const
inline

Definition at line 226 of file sch_field.h.

226{ return EDA_TEXT::GetTextPos(); }

References EDA_TEXT::GetTextPos().

Referenced by operator<(), and SCH_LEGACY_PLUGIN::saveField().

◆ GetLinePositions()

void EDA_TEXT::GetLinePositions ( std::vector< VECTOR2I > &  aPositions,
int  aLineCount 
) const
inherited

Populate aPositions with the position of each line of a multiline text, according to the vertical justification and the rotation of the whole text.

Parameters
aPositionsis the list to populate by the VECTOR2I positions.
aLineCountis the number of lines (not recalculated here for efficiency reasons.

Definition at line 673 of file eda_text.cpp.

674{
675 VECTOR2I pos = GetDrawPos(); // Position of first line of the multiline text according
676 // to the center of the multiline text block
677
678 VECTOR2I offset; // Offset to next line.
679
680 offset.y = GetInterline();
681
682 if( aLineCount > 1 )
683 {
684 switch( GetVertJustify() )
685 {
687 break;
688
690 pos.y -= ( aLineCount - 1 ) * offset.y / 2;
691 break;
692
694 pos.y -= ( aLineCount - 1 ) * offset.y;
695 break;
696 }
697 }
698
699 // Rotate the position of the first line around the center of the multiline text block
701
702 // Rotate the offset lines to increase happened in the right direction
703 RotatePoint( offset, GetDrawRotation() );
704
705 for( int ii = 0; ii < aLineCount; ii++ )
706 {
707 aPositions.push_back( (VECTOR2I) pos );
708 pos += offset;
709 }
710}

References EDA_TEXT::GetDrawPos(), EDA_TEXT::GetDrawRotation(), EDA_TEXT::GetInterline(), EDA_TEXT::GetVertJustify(), GR_TEXT_V_ALIGN_BOTTOM, GR_TEXT_V_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, RotatePoint(), and VECTOR2< T >::y.

Referenced by SCH_TEXT::Plot(), SCH_TEXTBOX::Plot(), BRDITEMS_PLOTTER::PlotPcbText(), and EDA_TEXT::Print().

◆ GetLineSpacing()

double EDA_TEXT::GetLineSpacing ( ) const
inlineinherited

Definition at line 193 of file eda_text.h.

193{ return m_attributes.m_LineSpacing; }

References EDA_TEXT::m_attributes, and TEXT_ATTRIBUTES::m_LineSpacing.

Referenced by EDA_TEXT::Format().

◆ GetMenuImage()

BITMAPS SCH_FIELD::GetMenuImage ( ) const
overridevirtual

Return a pointer to an image to be used in menus.

The default version returns the right arrow image. Override this function to provide object specific menu images.

Returns
The menu image associated with the item.

Reimplemented from EDA_ITEM.

Definition at line 883 of file sch_field.cpp.

884{
885 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
886 {
887 switch( m_id )
888 {
892 default: return BITMAPS::text;
893 }
894 }
895
896 return BITMAPS::text;
897}
@ edit_comp_value
@ edit_comp_footprint
@ edit_comp_ref

References edit_comp_footprint, edit_comp_ref, edit_comp_value, FOOTPRINT_FIELD, m_id, EDA_ITEM::m_parent, REFERENCE_FIELD, SCH_SYMBOL_T, text, EDA_ITEM::Type(), and VALUE_FIELD.

◆ GetMsgPanelInfo()

void SCH_FIELD::GetMsgPanelInfo ( EDA_DRAW_FRAME aFrame,
std::vector< MSG_PANEL_ITEM > &  aList 
)
overridevirtual

Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.

Parameters
aListis the list to populate.

Reimplemented from EDA_ITEM.

Definition at line 728 of file sch_field.cpp.

729{
730 wxString msg;
731
732 aList.emplace_back( _( "Symbol Field" ), GetName() );
733
734 // Don't use GetShownText() here; we want to show the user the variable references
735 aList.emplace_back( _( "Text" ), UnescapeString( GetText() ) );
736
737 aList.emplace_back( _( "Visible" ), IsVisible() ? _( "Yes" ) : _( "No" ) );
738
739 aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
740
741 aList.emplace_back( _( "Style" ), GetTextStyleName() );
742
743 aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
744
745 switch ( GetHorizJustify() )
746 {
747 case GR_TEXT_H_ALIGN_LEFT: msg = _( "Left" ); break;
748 case GR_TEXT_H_ALIGN_CENTER: msg = _( "Center" ); break;
749 case GR_TEXT_H_ALIGN_RIGHT: msg = _( "Right" ); break;
750 }
751
752 aList.emplace_back( _( "H Justification" ), msg );
753
754 switch ( GetVertJustify() )
755 {
756 case GR_TEXT_V_ALIGN_TOP: msg = _( "Top" ); break;
757 case GR_TEXT_V_ALIGN_CENTER: msg = _( "Center" ); break;
758 case GR_TEXT_V_ALIGN_BOTTOM: msg = _( "Bottom" ); break;
759 }
760
761 aList.emplace_back( _( "V Justification" ), msg );
762}
wxString GetTextStyleName() const
Definition: eda_text.cpp:738
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().

References _, EDA_TEXT::GetFont(), EDA_TEXT::GetHorizJustify(), GetName(), EDA_TEXT::GetText(), EDA_TEXT::GetTextStyleName(), EDA_TEXT::GetTextWidth(), EDA_TEXT::GetVertJustify(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_BOTTOM, GR_TEXT_V_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, EDA_TEXT::IsVisible(), UNITS_PROVIDER::MessageTextFromValue(), and UnescapeString().

◆ GetName()

wxString SCH_FIELD::GetName ( bool  aUseDefaultName = true) const

Return the field name (not translated).

Parameters
aUseDefaultNameWhen true return the default field name if the field name is empty. Otherwise the default field name is returned.
Returns
the name of the field.

Definition at line 804 of file sch_field.cpp.

805{
806 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
807 {
808 if( m_id >= 0 && m_id < MANDATORY_FIELDS )
810 else if( m_name.IsEmpty() && aUseDefaultName )
812 else
813 return m_name;
814 }
815 else if( m_parent && m_parent->Type() == SCH_SHEET_T )
816 {
817 if( m_id >= 0 && m_id < SHEET_MANDATORY_FIELDS )
819 else if( m_name.IsEmpty() && aUseDefaultName )
821 else
822 return m_name;
823 }
824 else if( m_parent && m_parent->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
825 {
826 return SCH_LABEL_BASE::GetDefaultFieldName( m_name, aUseDefaultName );
827 }
828 else
829 {
830 wxFAIL_MSG( "Unhandled field owner type." );
831 return m_name;
832 }
833}
static const wxString GetDefaultFieldName(const wxString &aName, bool aUseDefaultName)
Definition: sch_label.cpp:183
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslated=true)
Definition: sch_sheet.cpp:55
@ SHEET_MANDATORY_FIELDS
The first 2 are mandatory, and must be instantiated in SCH_SHEET.
Definition: sch_sheet.h:49
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslateForHI=false)
Return a default symbol field name for field aFieldNdx for all components.
@ MANDATORY_FIELDS
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.

References SCH_LABEL_BASE::GetDefaultFieldName(), SCH_SHEET::GetDefaultFieldName(), TEMPLATE_FIELDNAME::GetDefaultFieldName(), EDA_ITEM::IsType(), m_id, m_name, EDA_ITEM::m_parent, MANDATORY_FIELDS, SCH_SHEET_T, SCH_SYMBOL_T, SHEET_MANDATORY_FIELDS, and EDA_ITEM::Type().

Referenced by NETLIST_EXPORTER_XML::addSymbolFields(), DIALOG_SCH_FIELD_PROPERTIES::DIALOG_SCH_FIELD_PROPERTIES(), SCH_EDIT_TOOL::editFieldText(), GetItemDescription(), GetMsgPanelInfo(), GetShownText(), CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances(), SYMBOL_EDIT_FRAME::LoadSymbolFromSchematic(), DIALOG_SYMBOL_PROPERTIES::OnEditSpiceModel(), operator<(), DIALOG_CHANGE_SYMBOLS::processSymbols(), SCH_SYMBOL::RemoveField(), SCH_LEGACY_PLUGIN::saveField(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow(), DIALOG_SHEET_PROPERTIES::Validate(), DIALOG_SYMBOL_PROPERTIES::Validate(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ GetOrInitConnection()

SCH_CONNECTION * SCH_ITEM::GetOrInitConnection ( const SCH_SHEET_PATH aPath,
CONNECTION_GRAPH aGraph 
)
inherited

Definition at line 228 of file sch_item.cpp.

230{
231 if( !IsConnectable() )
232 return nullptr;
233
234 SetConnectivityDirty( false );
235
236 SCH_CONNECTION* connection = Connection( &aSheet );
237
238 if( connection )
239 return connection;
240 else
241 return InitializeConnection( aSheet, aGraph );
242}
SCH_CONNECTION * InitializeConnection(const SCH_SHEET_PATH &aPath, CONNECTION_GRAPH *aGraph)
Create a new connection object associated with this object.
Definition: sch_item.cpp:205
void SetConnectivityDirty(bool aDirty=true)
Definition: sch_item.h:415

References SCH_ITEM::Connection(), SCH_ITEM::InitializeConnection(), SCH_ITEM::IsConnectable(), and SCH_ITEM::SetConnectivityDirty().

◆ GetParent()

◆ GetParentPosition()

VECTOR2I SCH_FIELD::GetParentPosition ( ) const

Definition at line 1084 of file sch_field.cpp.

1085{
1086 return m_parent ? m_parent->GetPosition() : VECTOR2I( 0, 0 );
1087}

References EDA_ITEM::GetPosition(), and EDA_ITEM::m_parent.

Referenced by KIGFX::SCH_PAINTER::draw(), and GetBoundingBox().

◆ GetPenWidth()

int SCH_FIELD::GetPenWidth ( ) const
overridevirtual
Returns
the size of the "pen" that be used to draw or plot this item

Reimplemented from SCH_ITEM.

Definition at line 245 of file sch_field.cpp.

246{
248}

References EDA_TEXT::GetEffectiveTextPenWidth().

◆ GetPosition()

VECTOR2I SCH_FIELD::GetPosition ( ) const
overridevirtual

◆ GetRenderCache() [1/2]

std::vector< std::unique_ptr< KIFONT::GLYPH > > * EDA_TEXT::GetRenderCache ( const KIFONT::FONT aFont,
const wxString &  forResolvedText,
const VECTOR2I aOffset = { 0, 0 } 
) const
inherited

Definition at line 453 of file eda_text.cpp.

455{
456 if( getDrawFont()->IsOutline() )
457 {
458 EDA_ANGLE resolvedAngle = GetDrawRotation();
459
460 if( m_render_cache.empty()
461 || m_render_cache_text != forResolvedText
462 || m_render_cache_angle != resolvedAngle
463 || m_render_cache_offset != aOffset )
464 {
465 m_render_cache.clear();
466
467 KIFONT::OUTLINE_FONT* font = static_cast<KIFONT::OUTLINE_FONT*>( getDrawFont() );
469
470 attrs.m_Angle = resolvedAngle;
471
472 font->GetLinesAsGlyphs( &m_render_cache, GetShownText(), GetDrawPos() + aOffset, attrs );
473 m_render_cache_angle = resolvedAngle;
474 m_render_cache_text = forResolvedText;
475 m_render_cache_offset = aOffset;
476 }
477
478 return &m_render_cache;
479 }
480
481 return nullptr;
482}
VECTOR2I m_render_cache_offset
Definition: eda_text.h:397
EDA_ANGLE m_render_cache_angle
Definition: eda_text.h:396
wxString m_render_cache_text
Definition: eda_text.h:395
Class OUTLINE_FONT implements outline font drawing.
Definition: outline_font.h:52
void GetLinesAsGlyphs(std::vector< std::unique_ptr< GLYPH > > *aGlyphs, const wxString &aText, const VECTOR2I &aPosition, const TEXT_ATTRIBUTES &aAttrs) const

References EDA_TEXT::GetAttributes(), EDA_TEXT::getDrawFont(), EDA_TEXT::GetDrawPos(), EDA_TEXT::GetDrawRotation(), KIFONT::OUTLINE_FONT::GetLinesAsGlyphs(), EDA_TEXT::GetShownText(), TEXT_ATTRIBUTES::m_Angle, EDA_TEXT::m_render_cache, EDA_TEXT::m_render_cache_angle, EDA_TEXT::m_render_cache_offset, and EDA_TEXT::m_render_cache_text.

Referenced by KIGFX::PCB_PAINTER::draw(), KIGFX::SCH_PAINTER::draw(), and PCB_PLUGIN::formatRenderCache().

◆ GetRenderCache() [2/2]

std::vector< std::unique_ptr< KIFONT::GLYPH > > * SCH_FIELD::GetRenderCache ( const wxString &  forResolvedText,
const VECTOR2I forPosition,
TEXT_ATTRIBUTES aAttrs 
) const

Definition at line 277 of file sch_field.cpp.

279{
280 KIFONT::FONT* font = GetFont();
281
282 if( !font )
284
285 if( font->IsOutline() )
286 {
287 KIFONT::OUTLINE_FONT* outlineFont = static_cast<KIFONT::OUTLINE_FONT*>( font );
288
289 if( m_renderCache.empty() || !m_renderCacheValid )
290 {
291 m_renderCache.clear();
292
293 outlineFont->GetLinesAsGlyphs( &m_renderCache, forResolvedText, forPosition, aAttrs );
294
295 m_renderCachePos = forPosition;
296 m_renderCacheValid = true;
297 }
298
299 if( m_renderCachePos != forPosition )
300 {
301 VECTOR2I delta = forPosition - m_renderCachePos;
302
303 for( std::unique_ptr<KIFONT::GLYPH>& glyph : m_renderCache )
304 static_cast<KIFONT::OUTLINE_GLYPH*>( glyph.get() )->Move( delta );
305
306 m_renderCachePos = forPosition;
307 }
308
309 return &m_renderCache;
310 }
311
312 return nullptr;
313}
virtual bool IsOutline() const
Definition: font.h:113
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_field.h:186
constexpr int delta

References delta, SCH_ITEM::GetDefaultFont(), EDA_TEXT::GetFont(), KIFONT::FONT::GetFont(), KIFONT::OUTLINE_FONT::GetLinesAsGlyphs(), EDA_TEXT::IsBold(), EDA_TEXT::IsItalic(), KIFONT::FONT::IsOutline(), m_renderCache, m_renderCachePos, m_renderCacheValid, and Move().

Referenced by KIGFX::SCH_PAINTER::draw().

◆ GetShownText()

wxString SCH_FIELD::GetShownText ( int  aDepth = 0,
bool  aAllowExtraText = true 
) const
overridevirtual

Return the string actually shown after processing of the base text.

Parameters
aDepthis used to prevent infinite recursions and loops when expanding text variables.
aAllowExtraTextis true to allow adding more text than the initial expanded text, for intance a title, a prefix for texts in display functions. False to disable any added text (for instance when writing the shown text in netlists).

Reimplemented from EDA_TEXT.

Definition at line 175 of file sch_field.cpp.

176{
177 std::function<bool( wxString* )> symbolResolver =
178 [&]( wxString* token ) -> bool
179 {
180 return static_cast<SCH_SYMBOL*>( m_parent )->ResolveTextVar( token, aDepth + 1 );
181 };
182
183 std::function<bool( wxString* )> sheetResolver =
184 [&]( wxString* token ) -> bool
185 {
186 return static_cast<SCH_SHEET*>( m_parent )->ResolveTextVar( token, aDepth + 1 );
187 };
188
189 std::function<bool( wxString* )> labelResolver =
190 [&]( wxString* token ) -> bool
191 {
192 return static_cast<SCH_LABEL_BASE*>( m_parent )->ResolveTextVar( token,
193 aDepth + 1 );
194 };
195
196 wxString text = EDA_TEXT::GetShownText();
197
198 if( IsNameShown() )
199 text = GetName() << wxS( ": " ) << text;
200
201 if( text == wxS( "~" ) ) // Legacy placeholder for empty string
202 {
203 text = wxS( "" );
204 }
205 else if( HasTextVars() )
206 {
207 if( aDepth < 10 )
208 {
209 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
210 text = ExpandTextVars( text, &symbolResolver );
211 else if( m_parent && m_parent->Type() == SCH_SHEET_T )
212 text = ExpandTextVars( text, &sheetResolver );
213 else if( m_parent && m_parent->IsType( { SCH_LABEL_LOCATE_ANY_T } ) )
214 text = ExpandTextVars( text, &labelResolver );
215 else if( Schematic() )
217 }
218 }
219
220 // WARNING: the IDs of FIELDS and SHEETS overlap, so one must check *both* the
221 // id and the parent's type.
222
223 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
224 {
225 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
226
227 if( m_id == REFERENCE_FIELD )
228 {
229 // For more than one part per package, we must add the part selection
230 // A, B, ... or 1, 2, .. to the reference.
231 if( parentSymbol->GetUnitCount() > 1 )
232 text << LIB_SYMBOL::SubReference( parentSymbol->GetUnit() );
233 }
234 }
235 else if( m_parent && m_parent->Type() == SCH_SHEET_T )
236 {
237 if( m_id == SHEETFILENAME && aAllowExtraText )
238 text = _( "File:" ) + wxS( " " )+ text;
239 }
240
241 return text;
242}
bool HasTextVars() const
Indicates the ShownText has text var references which need to be processed.
Definition: eda_text.h:103
static wxString SubReference(int aUnit, bool aAddSeparator=true)
Definition: lib_symbol.cpp:581
bool IsNameShown() const
Definition: sch_field.h:158
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
int GetUnitCount() const
Return the number of units per package of the symbol.
Definition: sch_symbol.cpp:427
int GetUnit() const
Definition: sch_symbol.h:228
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject)
Definition: common.cpp:58
PROJECT & Prj()
Definition: kicad.cpp:573

References _, ExpandTextVars(), GetName(), EDA_TEXT::GetShownText(), SCH_SYMBOL::GetUnit(), SCH_SYMBOL::GetUnitCount(), EDA_TEXT::HasTextVars(), IsNameShown(), EDA_ITEM::IsType(), m_id, EDA_ITEM::m_parent, Prj(), REFERENCE_FIELD, SCH_SHEET_T, SCH_SYMBOL_T, SCH_ITEM::Schematic(), SHEETFILENAME, LIB_SYMBOL::SubReference(), text, and EDA_ITEM::Type().

Referenced by NETLIST_EXPORTER_XML::addSymbolFields(), KIGFX::SCH_PAINTER::draw(), SCH_SYMBOL::GetFootprintFieldText(), GetItemDescription(), SCH_SYMBOL::GetValueFieldText(), HitTest(), Matches(), DIALOG_SHEET_PROPERTIES::OnUpdateUI(), Plot(), Print(), and EE_INSPECTION_TOOL::ShowDatasheet().

◆ GetSortPosition()

virtual VECTOR2I EDA_ITEM::GetSortPosition ( ) const
inlinevirtualinherited

Return the coordinates that should be used for sorting this element visually compared to other elements.

For instance, for lines the midpoint might be a better sorting point than either end.

Returns
X,Y coordinate of the sort point

Reimplemented in SCH_LINE.

Definition at line 265 of file eda_item.h.

265{ return GetPosition(); }

References EDA_ITEM::GetPosition().

◆ GetState()

int EDA_ITEM::GetState ( EDA_ITEM_FLAGS  type) const
inlineinherited

Definition at line 123 of file eda_item.h.

124 {
125 return m_status & type;
126 }
EDA_ITEM_FLAGS m_status
Definition: eda_item.h:495

References EDA_ITEM::m_status.

◆ GetStatus()

EDA_ITEM_FLAGS EDA_ITEM::GetStatus ( ) const
inlineinherited

Definition at line 136 of file eda_item.h.

136{ return m_status; }

References EDA_ITEM::m_status.

◆ GetStoredPos()

VECTOR2I & SCH_ITEM::GetStoredPos ( )
inlineinherited

Definition at line 209 of file sch_item.h.

209{ return m_storedPos; }
VECTOR2I m_storedPos
Definition: sch_item.h:494

References SCH_ITEM::m_storedPos.

◆ GetStroke()

virtual STROKE_PARAMS SCH_ITEM::GetStroke ( ) const
inlinevirtualinherited

Reimplemented in SCH_BUS_ENTRY_BASE, SCH_LINE, and SCH_SHAPE.

Definition at line 457 of file sch_item.h.

457{ wxCHECK( false, STROKE_PARAMS() ); }
Simple container to manage line stroke parameters.
Definition: stroke_params.h:88

Referenced by DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem().

◆ GetText()

virtual const wxString & EDA_TEXT::GetText ( ) const
inlinevirtualinherited

Return the string associated with the text object.

Returns
a const wxString reference containing the string of the item.

Definition at line 87 of file eda_text.h.

87{ return m_text; }

References EDA_TEXT::m_text.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::addAttribute(), SCH_EAGLE_PLUGIN::addImplicitConnections(), SCH_SHEET_PATH::AddNewSymbolInstances(), NETLIST_EXPORTER_XML::addSymbolFields(), CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings(), SCH_EDIT_FRAME::AutoRotateItem(), EE_SELECTION_TOOL::autostartEvent(), CONNECTION_GRAPH::buildConnectionGraph(), SCH_EDIT_TOOL::ChangeTextType(), CheckLibSymbol(), SCH_SHEET::CleanupSheet(), LIB_TEXT::Clone(), LIB_FIELD::compare(), LIB_TEXT::compare(), LIB_TEXTBOX::compare(), SCH_BUS_WIRE_ENTRY::ConnectionPropagatesTo(), SCH_DRAWING_TOOLS::createNewText(), SCH_DRAWING_TOOLS::createSheetPin(), DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES(), DIALOG_LIB_FIELD_PROPERTIES::DIALOG_LIB_FIELD_PROPERTIES(), DIALOG_SCH_FIELD_PROPERTIES::DIALOG_SCH_FIELD_PROPERTIES(), KIGFX::SCH_VIEW::DisplaySymbol(), KIGFX::SCH_PAINTER::draw(), EDA_TEXT_DESC::EDA_TEXT_DESC(), CONNECTION_GRAPH::ercCheckHierSheets(), CADSTAR_ARCHIVE_PARSER::FixTextPositionNoAlignment(), LIB_SYMBOL::Flatten(), PCB_PLUGIN::format(), LIB_SYMBOL::GetFootprint(), SCH_SYMBOL::GetFootprintFieldText(), LIB_FIELD::GetFullText(), SCH_LABEL_BASE::GetIntersheetRefs(), PCB_DIMENSION_BASE::GetItemDescription(), CADSTAR_PCB_ARCHIVE_LOADER::getKiCadNet(), FP_TEXT::GetLength(), LIB_FIELD::GetMsgPanelInfo(), LIB_TEXT::GetMsgPanelInfo(), LIB_TEXTBOX::GetMsgPanelInfo(), GetMsgPanelInfo(), SCH_LABEL_BASE::GetMsgPanelInfo(), SCH_TEXT::GetMsgPanelInfo(), SCH_TEXTBOX::GetMsgPanelInfo(), FP_TEXT::GetMsgPanelInfo(), FP_TEXTBOX::GetMsgPanelInfo(), PCB_TEXT::GetMsgPanelInfo(), PCB_TEXTBOX::GetMsgPanelInfo(), LIB_SYMBOL::GetPrefix(), SCH_SYMBOL::GetRef(), FOOTPRINT::GetReference(), LIB_SYMBOL::GetSearchText(), FOOTPRINT::GetValue(), SCH_SYMBOL::GetValueFieldText(), hash_fp_item(), SCH_SHEET::HasUndefinedPins(), LIB_FIELD::HitTest(), SCH_DRAWING_TOOLS::importHierLabel(), SCH_LABEL_BASE::IncrementLabel(), GENERAL_COLLECTOR::Inspect(), CADSTAR_SCH_ARCHIVE_LOADER::Load(), LEGACY_PLUGIN::loadPCB_TEXT(), SCH_EAGLE_PLUGIN::loadSchematic(), CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances(), SCH_EAGLE_PLUGIN::loadSegments(), SYMBOL_EDIT_FRAME::LoadSymbolFromSchematic(), LIB_TEXTBOX::Matches(), SCH_LABEL_BASE::Matches(), SCH_SHEET_PIN::Matches(), SCH_TEXT::Matches(), SCH_TEXTBOX::Matches(), DIALOG_SHEET_PIN_PROPERTIES::onComboBox(), DIALOG_UPDATE_SYMBOL_FIELDS::onOkButtonClicked(), operator<(), SCH_TEXT::operator<(), SCH_TEXTBOX::operator<(), LIB_FIELD::operator=(), PCB_PARSER::parseEDA_TEXT(), SCH_SEXPR_PARSER::parseEDA_TEXT(), SCH_EDITOR_CONTROL::Paste(), DRAWING_TOOL::PlaceText(), LIB_FIELD::Plot(), LIB_TEXT::Plot(), BRDITEMS_PLOTTER::PlotFootprintTextItems(), DIALOG_RESCUE_EACH::PopulateInstanceList(), LIB_FIELD::print(), DIALOG_CHANGE_SYMBOLS::processSymbols(), SCH_EDIT_FRAME::PutDataInPreviousState(), NETLIST_EXPORTER_SPICE_MODEL::readPorts(), SCHEMATIC::RecomputeIntersheetRefs(), SCH_GLOBALLABEL::ResolveTextVar(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_SEXPR_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN::saveField(), SCH_SEXPR_PLUGIN::saveField(), CLIPBOARD_IO::SaveSelection(), SCH_LEGACY_PLUGIN::saveSheet(), SCH_LEGACY_PLUGIN_CACHE::SaveSymbol(), SCH_LEGACY_PLUGIN::saveSymbol(), SCH_LEGACY_PLUGIN_CACHE::saveText(), SCH_SEXPR_PLUGIN_CACHE::saveText(), SCH_LEGACY_PLUGIN::saveText(), SCH_SEXPR_PLUGIN::saveText(), SCH_SEXPR_PLUGIN_CACHE::saveTextBox(), SCH_SEXPR_PLUGIN::saveTextBox(), SCH_EDIT_FRAME::SendSelectItemsToPcb(), SYMBOL_EDIT_FRAME::setupUIConditions(), SYMBOL_VIEWER_FRAME::setupUIConditions(), EE_INSPECTION_TOOL::ShowDatasheet(), SCH_SHEET::SymbolCount(), textsNeedUpdate(), DIALOG_EDIT_SYMBOLS_LIBID::TransferDataFromWindow(), DIALOG_LABEL_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataToWindow(), DIALOG_SHEET_PIN_PROPERTIES::TransferDataToWindow(), DIALOG_SHEET_PROPERTIES::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_TEXTBOX_PROPERTIES::TransferDataToWindow(), EDA_TEXT::TransformBoundingBoxToPolygon(), PCB_DIM_LEADER::updateGeometry(), SCH_EDITOR_CONTROL::updatePastedSymbol(), SCH_SYMBOL::UpdatePrefix(), SYMBOL_EDIT_FRAME::UpdateSymbolMsgPanelInfo(), and FP_TEXT::ViewGetLOD().

◆ GetTextAngle()

const EDA_ANGLE & EDA_TEXT::GetTextAngle ( ) const
inlineinherited

Definition at line 120 of file eda_text.h.

120{ return m_attributes.m_Angle; }

References TEXT_ATTRIBUTES::m_Angle, and EDA_TEXT::m_attributes.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::addAttribute(), CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings(), SCH_EDIT_TOOL::ChangeTextType(), LIB_TEXTBOX::compare(), DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES(), KIGFX::SCH_PAINTER::draw(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), CADSTAR_ARCHIVE_PARSER::FixTextPositionNoAlignment(), FP_TEXT::Flip(), FP_TEXTBOX::Flip(), PCB_TEXT::Flip(), PCB_TEXTBOX::Flip(), PCB_PLUGIN::format(), SCH_LABEL::GetBodyBoundingBox(), LIB_FIELD::GetBoundingBox(), LIB_TEXT::GetBoundingBox(), GetBoundingBox(), SCH_TEXT::GetBoundingBox(), PCB_TEXT::GetBoundingBox(), LIB_TEXTBOX::GetDrawPos(), SCH_TEXTBOX::GetDrawPos(), EDA_TEXT::GetDrawRotation(), GetDrawRotation(), FP_TEXT::GetDrawRotation(), FP_TEXTBOX::GetDrawRotation(), FP_TEXT::GetMsgPanelInfo(), FP_TEXTBOX::GetMsgPanelInfo(), PCB_TEXT::GetMsgPanelInfo(), PCB_TEXTBOX::GetMsgPanelInfo(), LIB_TEXTBOX::GetShownText(), SCH_TEXTBOX::GetShownText(), hash_fp_item(), LIB_FIELD::HitTest(), LIB_TEXT::HitTest(), FP_TEXT::KeepUpright(), SCH_EAGLE_PLUGIN::loadFieldAttributes(), CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary(), FP_TEXT::Mirror(), PCB_TEXT::Mirror(), PCB_DIMENSION_BASE::Mirror(), LIB_TEXT::MirrorHorizontal(), LIB_TEXTBOX::MirrorHorizontally(), SCH_TEXTBOX::MirrorHorizontally(), LIB_TEXT::MirrorVertical(), LIB_TEXTBOX::MirrorVertically(), SCH_TEXTBOX::MirrorVertically(), LIB_TEXT::NormalizeJustification(), KI_TEST::kitest_cmp_drawings::operator()(), EAGLE_PLUGIN::orientFPText(), Plot(), LIB_FIELD::Plot(), LIB_TEXT::Plot(), positioningChanged(), Print(), LIB_FIELD::print(), LIB_TEXT::print(), SCH_EDIT_TOOL::Rotate(), SCH_TEXTBOX::Rotate(), LIB_TEXTBOX::Rotate(), LIB_FIELD::Rotate(), LIB_TEXT::Rotate(), FP_TEXT::Rotate(), FP_TEXTBOX::Rotate(), PCB_DIMENSION_BASE::Rotate(), PCB_TEXT::Rotate(), PCB_TEXTBOX::Rotate(), SCH_TEXTBOX::Rotate90(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_SEXPR_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN::saveField(), SCH_SEXPR_PLUGIN::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveText(), SCH_SEXPR_PLUGIN_CACHE::saveText(), SCH_SEXPR_PLUGIN::saveText(), SCH_SEXPR_PLUGIN_CACHE::saveTextBox(), SCH_SEXPR_PLUGIN::saveTextBox(), FP_TEXTBOX::SetTextAngle(), PCB_TEXTBOX::SetTextAngle(), textsNeedUpdate(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_DIMENSION_PROPERTIES::TransferDataToWindow(), DIALOG_TEXTBOX_PROPERTIES::TransferDataToWindow(), DIALOG_SCH_FIELD_PROPERTIES::UpdateField(), PCB_DIM_ALIGNED::updateGeometry(), PCB_DIM_ORTHOGONAL::updateGeometry(), PCB_DIM_RADIAL::updateGeometry(), and PCB_DIM_LEADER::updateGeometry().

◆ GetTextAngleDegrees()

double EDA_TEXT::GetTextAngleDegrees ( ) const
inlineinherited

◆ GetTextBox()

BOX2I EDA_TEXT::GetTextBox ( int  aLine = -1,
bool  aInvertY = false 
) const
inherited

Useful in multiline texts to calculate the full text or a line area (for zones filling, locate functions....)

Parameters
aLineThe line of text to consider. Pass -1 for all lines.
aInvertYInvert the Y axis when calculating bounding box.
Returns
the rect containing the line of text (i.e. the position and the size of one line) this rectangle is calculated for 0 orient text. If orientation is not 0 the rect must be rotated to match the physical area

Definition at line 505 of file eda_text.cpp.

506{
507 VECTOR2I drawPos = GetDrawPos();
508
510 && m_bounding_box_cache_pos == drawPos
511 && m_bounding_box_cache_line == aLine
512 && m_bounding_box_cache_inverted == aInvertY )
513 {
515 }
516
517 BOX2I bbox;
518 wxArrayString strings;
519 wxString text = GetShownText();
520 int thickness = GetEffectiveTextPenWidth();
521
522 if( IsMultilineAllowed() )
523 {
524 wxStringSplit( text, strings, '\n' );
525
526 if( strings.GetCount() ) // GetCount() == 0 for void strings with multilines allowed
527 {
528 if( aLine >= 0 && ( aLine < static_cast<int>( strings.GetCount() ) ) )
529 text = strings.Item( aLine );
530 else
531 text = strings.Item( 0 );
532 }
533 }
534
535 // calculate the H and V size
536 KIFONT::FONT* font = getDrawFont();
537 VECTOR2D fontSize( GetTextSize() );
538 bool bold = IsBold();
539 bool italic = IsItalic();
540 VECTOR2I extents = font->StringBoundaryLimits( text, fontSize, thickness, bold, italic );
541 int overbarOffset = 0;
542
543 // Creates bounding box (rectangle) for horizontal, left and top justified text. The
544 // bounding box will be moved later according to the actual text options
545 VECTOR2I textsize = VECTOR2I( extents.x, extents.y );
546 VECTOR2I pos = drawPos;
547
548 if( IsMultilineAllowed() && aLine > 0 && aLine < (int) strings.GetCount() )
549 pos.y -= KiROUND( aLine * font->GetInterline( fontSize.y ) );
550
551 if( text.Contains( wxT( "~{" ) ) )
552 overbarOffset = extents.y / 14;
553
554 if( aInvertY )
555 pos.y = -pos.y;
556
557 bbox.SetOrigin( pos );
558
559 // for multiline texts and aLine < 0, merge all rectangles (aLine == -1 signals all lines)
560 if( IsMultilineAllowed() && aLine < 0 && strings.GetCount() )
561 {
562 for( unsigned ii = 1; ii < strings.GetCount(); ii++ )
563 {
564 text = strings.Item( ii );
565 extents = font->StringBoundaryLimits( text, fontSize, thickness, bold, italic );
566 textsize.x = std::max( textsize.x, extents.x );
567 }
568
569 // interline spacing is only *between* lines, so total height is the height of the first
570 // line plus the interline distance (with interline spacing) for all subsequent lines
571 textsize.y += KiROUND( ( strings.GetCount() - 1 ) * font->GetInterline( fontSize.y ) );
572 }
573
574 bbox.SetSize( textsize );
575
576 /*
577 * At this point the rectangle origin is the text origin (m_Pos). This is correct only for
578 * left and top justified, non-mirrored, non-overbarred texts. Recalculate for all others.
579 */
580 int italicOffset = IsItalic() ? KiROUND( fontSize.y * ITALIC_TILT ) : 0;
581
582 switch( GetHorizJustify() )
583 {
585 if( IsMirrored() )
586 bbox.SetX( bbox.GetX() - ( bbox.GetWidth() - italicOffset ) );
587 break;
588
590 bbox.SetX( bbox.GetX() - ( bbox.GetWidth() - italicOffset ) / 2 );
591 break;
592
594 if( !IsMirrored() )
595 bbox.SetX( bbox.GetX() - ( bbox.GetWidth() - italicOffset ) );
596 break;
597 }
598
599 switch( GetVertJustify() )
600 {
602 break;
603
605 bbox.SetY( bbox.GetY() - ( bbox.GetHeight() + overbarOffset ) / 2 );
606 break;
607
609 bbox.SetY( bbox.GetY() - ( bbox.GetHeight() + overbarOffset ) );
610 break;
611 }
612
613 bbox.Normalize(); // Make h and v sizes always >= 0
614
616 m_bounding_box_cache_pos = drawPos;
620
621 return bbox;
622}
void SetX(coord_type val)
Definition: box2.h:235
void SetY(coord_type val)
Definition: box2.h:240
coord_type GetHeight() const
Definition: box2.h:188
coord_type GetY() const
Definition: box2.h:181
coord_type GetWidth() const
Definition: box2.h:187
void SetSize(const Vec &size)
Definition: box2.h:213
coord_type GetX() const
Definition: box2.h:180
BOX2I m_bounding_box_cache
Definition: eda_text.h:404
bool IsMultilineAllowed() const
Definition: eda_text.h:146
int m_bounding_box_cache_line
Definition: eda_text.h:402
bool m_bounding_box_cache_inverted
Definition: eda_text.h:403
VECTOR2I m_bounding_box_cache_pos
Definition: eda_text.h:401
virtual double GetInterline(double aGlyphHeight, double aLineSpacing=1.0) const =0
Compute the distance (interline) between 2 lines of text (for multiline texts).
VECTOR2I StringBoundaryLimits(const wxString &aText, const VECTOR2I &aSize, int aThickness, bool aBold, bool aItalic) const
Compute the boundary limits of aText (the bounding box of all shapes).
Definition: font.cpp:357
static constexpr double ITALIC_TILT
Tilt factor for italic style (this is the scaling factor on dY relative coordinates to give a tilted ...
Definition: font.h:60
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.

References EDA_TEXT::getDrawFont(), EDA_TEXT::GetDrawPos(), EDA_TEXT::GetEffectiveTextPenWidth(), BOX2< Vec >::GetHeight(), EDA_TEXT::GetHorizJustify(), KIFONT::FONT::GetInterline(), EDA_TEXT::GetShownText(), EDA_TEXT::GetTextSize(), EDA_TEXT::GetVertJustify(), BOX2< Vec >::GetWidth(), BOX2< Vec >::GetX(), BOX2< Vec >::GetY(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_BOTTOM, GR_TEXT_V_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, EDA_TEXT::IsBold(), EDA_TEXT::IsItalic(), EDA_TEXT::IsMirrored(), EDA_TEXT::IsMultilineAllowed(), ITALIC_TILT, KiROUND(), EDA_TEXT::m_bounding_box_cache, EDA_TEXT::m_bounding_box_cache_inverted, EDA_TEXT::m_bounding_box_cache_line, EDA_TEXT::m_bounding_box_cache_pos, EDA_TEXT::m_bounding_box_cache_valid, BOX2< Vec >::Normalize(), BOX2< Vec >::SetOrigin(), BOX2< Vec >::SetSize(), BOX2< Vec >::SetX(), BOX2< Vec >::SetY(), KIFONT::FONT::StringBoundaryLimits(), text, wxStringSplit(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SCH_GLOBALLABEL::CreateGraphicShape(), KIGFX::SCH_PAINTER::draw(), SCH_LABEL::GetBodyBoundingBox(), SCH_HIERLABEL::GetBodyBoundingBox(), LIB_FIELD::GetBoundingBox(), LIB_TEXT::GetBoundingBox(), GetBoundingBox(), SCH_TEXT::GetBoundingBox(), DS_DRAW_ITEM_TEXT::GetBoundingBox(), FP_TEXT::GetBoundingBox(), PCB_DIMENSION_BASE::GetBoundingBox(), PCB_TEXT::GetBoundingBox(), ALTIUM_PCB::HelperParseDimensions6Radial(), LIB_TEXT::HitTest(), CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary(), LIB_TEXT::NormalizeJustification(), SCH_TEXT::Plot(), SCH_TEXT::Print(), EDA_TEXT::TextHitTest(), FP_TEXT::TextHitTest(), EDA_TEXT::TransformBoundingBoxToPolygon(), PCB_DIM_ALIGNED::updateGeometry(), PCB_DIM_ORTHOGONAL::updateGeometry(), PCB_DIM_RADIAL::updateGeometry(), PCB_DIM_LEADER::updateGeometry(), and FP_TEXT::ViewBBox().

◆ GetTextColor()

◆ GetTextHeight()

◆ GetTextPos()

const VECTOR2I & EDA_TEXT::GetTextPos ( ) const
inlineinherited

Definition at line 208 of file eda_text.h.

208{ return m_pos; }

References EDA_TEXT::m_pos.

Referenced by SCH_LABEL_BASE::AutoplaceFields(), LIB_FIELD::compare(), LIB_TEXT::compare(), PCB_GRID_HELPER::computeAnchors(), SCH_SHEET_PIN::ConstrainOnEdge(), DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES(), SCH_LABEL::doIsConnected(), SCH_GLOBALLABEL::doIsConnected(), SCH_HIERLABEL::doIsConnected(), KIGFX::DS_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), KIGFX::SCH_PAINTER::draw(), FP_TEXT::Flip(), FP_TEXTBOX::Flip(), PCB_TEXT::Flip(), PCB_PLUGIN::format(), SCH_LABEL_BASE::GetBodyBoundingBox(), SCH_LABEL::GetBodyBoundingBox(), SCH_HIERLABEL::GetBodyBoundingBox(), LIB_FIELD::GetBoundingBox(), LIB_TEXT::GetBoundingBox(), GetBoundingBox(), SCH_TEXT::GetBoundingBox(), FP_TEXT::GetBoundingBox(), PCB_TEXT::GetBoundingBox(), SCH_MOVE_TOOL::getConnectedDragItems(), SCH_LABEL_BASE::GetConnectionPoints(), EDA_TEXT::GetDrawPos(), SCH_LABEL_BASE::GetEndPoints(), SCH_SHEET_PIN::GetEndPoints(), GetLibPosition(), LIB_FIELD::GetPosition(), LIB_TEXT::GetPosition(), GetPosition(), SCH_TEXT::GetPosition(), DS_DRAW_ITEM_TEXT::GetPosition(), FP_TEXT::GetPosition(), PCB_TEXT::GetPosition(), ALTIUM_PCB::HelperParseDimensions6Radial(), LIB_FIELD::HitTest(), LIB_TEXT::HitTest(), CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary(), PCB_POINT_EDITOR::makePoints(), FP_TEXT::Mirror(), PCB_TEXT::Mirror(), PCB_DIMENSION_BASE::Mirror(), LIB_FIELD::MirrorHorizontal(), LIB_TEXT::MirrorHorizontal(), SCH_SHEET_PIN::MirrorHorizontally(), SCH_TEXT::MirrorHorizontally(), LIB_FIELD::MirrorVertical(), LIB_TEXT::MirrorVertical(), SCH_SHEET_PIN::MirrorVertically(), SCH_TEXT::MirrorVertically(), LIB_TEXT::NormalizeJustification(), DIALOG_UPDATE_SYMBOL_FIELDS::onOkButtonClicked(), DRAWING_TOOL::PlaceText(), Plot(), SCH_LABEL_BASE::Plot(), BRDITEMS_PLOTTER::PlotFootprintTextItem(), BRDITEMS_PLOTTER::PlotPcbText(), LIB_FIELD::print(), SCH_LABEL_BASE::Print(), DIALOG_CHANGE_SYMBOLS::processSymbols(), SCH_LABEL_BASE::Rotate(), SCH_SHEET_PIN::Rotate(), SCH_TEXT::Rotate(), LIB_FIELD::Rotate(), LIB_TEXT::Rotate(), FP_TEXT::Rotate(), PCB_DIMENSION_BASE::Rotate(), PCB_TEXT::Rotate(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveText(), FP_TEXT::SetDrawCoord(), FP_TEXT::SetLocalCoord(), FP_TEXT::TextHitTest(), DIALOG_DIMENSION_PROPERTIES::TransferDataToWindow(), FP_TEXT::TransformTextToPolySet(), PCB_TEXT::TransformTextToPolySet(), SCH_LABEL_BASE::UpdateDanglingState(), PCB_DIM_RADIAL::updateGeometry(), PCB_DIM_LEADER::updateGeometry(), PCB_POINT_EDITOR::updateItem(), PCB_POINT_EDITOR::updatePoints(), PCB_DIM_RADIAL::updateText(), and FP_TEXT::ViewBBox().

◆ GetTextSize()

◆ GetTextStyleName()

wxString EDA_TEXT::GetTextStyleName ( ) const
inherited
Returns
a wxString with the style name( Normal, Italic, Bold, Bold+Italic).

Definition at line 738 of file eda_text.cpp.

739{
740 int style = 0;
741
742 if( IsItalic() )
743 style = 1;
744
745 if( IsBold() )
746 style += 2;
747
748 wxString stylemsg[4] = {
749 _("Normal"),
750 _("Italic"),
751 _("Bold"),
752 _("Bold+Italic")
753 };
754
755 return stylemsg[style];
756}

References _, EDA_TEXT::IsBold(), and EDA_TEXT::IsItalic().

Referenced by LIB_FIELD::GetMsgPanelInfo(), LIB_TEXT::GetMsgPanelInfo(), and GetMsgPanelInfo().

◆ GetTextThickness()

◆ GetTextWidth()

int EDA_TEXT::GetTextWidth ( ) const
inlineinherited

Definition at line 199 of file eda_text.h.

199{ return m_attributes.m_Size.x; }

References EDA_TEXT::m_attributes, TEXT_ATTRIBUTES::m_Size, and VECTOR2< T >::x.

Referenced by LIB_FIELD::compare(), LIB_TEXT::compare(), LIB_TEXTBOX::compare(), DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES(), EDA_TEXT_DESC::EDA_TEXT_DESC(), EDA_TEXT::Format(), EDA_TEXT::GetEffectiveTextPenWidth(), PCB_TEXT::getKnockoutMargin(), LIB_FIELD::GetMsgPanelInfo(), LIB_TEXT::GetMsgPanelInfo(), LIB_TEXTBOX::GetMsgPanelInfo(), GetMsgPanelInfo(), SCH_LABEL_BASE::GetMsgPanelInfo(), SCH_TEXT::GetMsgPanelInfo(), SCH_TEXTBOX::GetMsgPanelInfo(), FP_TEXT::GetMsgPanelInfo(), FP_TEXTBOX::GetMsgPanelInfo(), PCB_DIMENSION_BASE::GetMsgPanelInfo(), PCB_TEXT::GetMsgPanelInfo(), PCB_TEXTBOX::GetMsgPanelInfo(), SCH_HIERLABEL::GetSchematicTextOffset(), hash_fp_item(), CADSTAR_SCH_ARCHIVE_LOADER::loadDocumentationSymbols(), SCH_EAGLE_PLUGIN::loadTextAttributes(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveText(), SCH_LEGACY_PLUGIN::saveText(), DIALOG_LABEL_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataFromWindow(), DIALOG_SHEET_PIN_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_LABEL_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataToWindow(), DIALOG_SHEET_PIN_PROPERTIES::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), PCB_DIM_ALIGNED::updateGeometry(), PCB_DIM_ORTHOGONAL::updateGeometry(), PCB_DIM_RADIAL::updateGeometry(), PCB_DIM_LEADER::updateGeometry(), and DIALOG_FIELD_PROPERTIES::updateText().

◆ GetTypeDesc()

wxString EDA_ITEM::GetTypeDesc ( ) const
inherited

Return a translated description of the type for this EDA_ITEM for display in user facing messages.

Definition at line 301 of file eda_item.cpp.

302{
303 //@see EDA_ITEM_DESC for definition of ENUM_MAP<KICAD_T>
304 wxString typeDescr = ENUM_MAP<KICAD_T>::Instance().ToString( Type() );
305
306 return wxGetTranslation( typeDescr );
307}
static ENUM_MAP< T > & Instance()
Definition: property.h:623

References ENUM_MAP< T >::Instance(), and EDA_ITEM::Type().

Referenced by PCB_GROUP::AddItem(), EDIT_TOOL::doMoveSelection(), and EDA_ITEM::GetFriendlyName().

◆ GetVertJustify()

◆ GotoPageHref()

wxString EDA_TEXT::GotoPageHref ( const wxString &  aDestination)
staticinherited

Generate a href to a page in the current schematic.

Parameters
aDestinationDestination sheet's page number.
Returns
A hyperlink href string that goes to the specified page.

Definition at line 1006 of file eda_text.cpp.

1007{
1008 return wxT( "#" ) + aDestination;
1009}

Referenced by SCH_SHEET::Plot().

◆ HasFlag()

◆ HasHyperlink()

virtual bool EDA_TEXT::HasHyperlink ( ) const
inlinevirtualinherited

◆ HasLineStroke()

virtual bool SCH_ITEM::HasLineStroke ( ) const
inlinevirtualinherited

Check if this schematic item has line stoke properties.

See also
STROKE_PARAMS
Returns
true if this schematic item support line stroke properties. Otherwise, false.

Reimplemented in SCH_BUS_ENTRY_BASE, SCH_LINE, and SCH_SHAPE.

Definition at line 455 of file sch_item.h.

455{ return false; }

Referenced by SCH_EDIT_TOOL::Init(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem().

◆ HasTextVars()

bool EDA_TEXT::HasTextVars ( ) const
inlineinherited

◆ HitTest() [1/2]

bool SCH_FIELD::HitTest ( const BOX2I aRect,
bool  aContained,
int  aAccuracy = 0 
) const
overridevirtual

Test if aRect intersects this item.

Parameters
aRectA reference to a BOX2I object containing the rectangle to test.
aContainedSet to true to test for containment instead of an intersection.
aAccuracyIncrease aRect by this amount.
Returns
True if aRect contains or intersects the item bounding box.

Reimplemented from EDA_ITEM.

Definition at line 920 of file sch_field.cpp.

921{
922 // Do not hit test hidden fields.
923 if( !IsVisible() || GetShownText().IsEmpty() )
924 return false;
925
926 BOX2I rect = aRect;
927
928 rect.Inflate( aAccuracy );
929
930 if( GetParent() && GetParent()->Type() == SCH_GLOBAL_LABEL_T )
931 {
932 SCH_GLOBALLABEL* label = static_cast<SCH_GLOBALLABEL*>( GetParent() );
933 rect.Offset( label->GetSchematicTextOffset( nullptr ) );
934 }
935
936 if( aContained )
937 return rect.Contains( GetBoundingBox() );
938
939 return rect.Intersects( GetBoundingBox() );
940}
void Offset(coord_type dx, coord_type dy)
Definition: box2.h:224
bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:269
bool Contains(const Vec &aPoint) const
Definition: box2.h:141
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:506
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_field.cpp:449
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...
Definition: sch_label.cpp:1300
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:152

References BOX2< Vec >::Contains(), GetBoundingBox(), EDA_ITEM::GetParent(), SCH_GLOBALLABEL::GetSchematicTextOffset(), GetShownText(), BOX2< Vec >::Inflate(), BOX2< Vec >::Intersects(), EDA_TEXT::IsVisible(), BOX2< Vec >::Offset(), SCH_GLOBAL_LABEL_T, and EDA_ITEM::Type().

◆ HitTest() [2/2]

bool SCH_FIELD::HitTest ( const VECTOR2I aPosition,
int  aAccuracy = 0 
) const
overridevirtual

Test if aPosition is inside or on the boundary of this item.

Parameters
aPositionA reference to a VECTOR2I object containing the coordinates to test.
aAccuracyIncrease the item bounding box by this amount.
Returns
True if aPosition is within the item bounding box.

Reimplemented from EDA_ITEM.

Definition at line 900 of file sch_field.cpp.

901{
902 // Do not hit test hidden or empty fields.
903 if( !IsVisible() || GetShownText().IsEmpty() )
904 return false;
905
906 BOX2I rect = GetBoundingBox();
907
908 rect.Inflate( aAccuracy );
909
910 if( GetParent() && GetParent()->Type() == SCH_GLOBAL_LABEL_T )
911 {
912 SCH_GLOBALLABEL* label = static_cast<SCH_GLOBALLABEL*>( GetParent() );
913 rect.Offset( label->GetSchematicTextOffset( nullptr ) );
914 }
915
916 return rect.Contains( aPosition );
917}

References BOX2< Vec >::Contains(), GetBoundingBox(), EDA_ITEM::GetParent(), SCH_GLOBALLABEL::GetSchematicTextOffset(), GetShownText(), BOX2< Vec >::Inflate(), EDA_TEXT::IsVisible(), BOX2< Vec >::Offset(), SCH_GLOBAL_LABEL_T, and EDA_ITEM::Type().

◆ ImportValues()

void SCH_FIELD::ImportValues ( const LIB_FIELD aSource)

Copy parameters from a LIB_FIELD source.

Pointers and specific values (position) are not copied.

Parameters
aSourceis the LIB_FIELD to read.

Definition at line 382 of file sch_field.cpp.

383{
384 SetAttributes( aSource );
385 SetNameShown( aSource.IsNameShown() );
386 SetCanAutoplace( aSource.CanAutoplace() );
387}
void SetAttributes(const EDA_TEXT &aSrc)
Set the text attributes from another instance.
Definition: eda_text.cpp:266
bool CanAutoplace() const
Definition: lib_field.h:183
bool IsNameShown() const
Definition: lib_field.h:180
void SetCanAutoplace(bool aCanPlace)
Definition: sch_field.h:162
void SetNameShown(bool aShown=true)
Definition: sch_field.h:159

References LIB_FIELD::CanAutoplace(), LIB_FIELD::IsNameShown(), EDA_TEXT::SetAttributes(), SetCanAutoplace(), and SetNameShown().

Referenced by SCH_SYMBOL::UpdateFields().

◆ InitializeConnection()

SCH_CONNECTION * SCH_ITEM::InitializeConnection ( const SCH_SHEET_PATH aPath,
CONNECTION_GRAPH aGraph 
)
inherited

Create a new connection object associated with this object.

Parameters
aPathis the sheet path to initialize.

Definition at line 205 of file sch_item.cpp.

207{
208 SetConnectivityDirty( false );
209
210 SCH_CONNECTION* connection = Connection( &aSheet );
211
212 if( connection )
213 {
214 connection->Reset();
215 }
216 else
217 {
218 connection = new SCH_CONNECTION( this );
219 m_connection_map.insert( std::make_pair( aSheet, connection ) );
220 }
221
222 connection->SetGraph( aGraph );
223 connection->SetSheet( aSheet );
224 return connection;
225}
void Reset()
Clears connectivity information.
void SetGraph(CONNECTION_GRAPH *aGraph)
void SetSheet(SCH_SHEET_PATH aSheet)

References SCH_ITEM::Connection(), SCH_ITEM::m_connection_map, SCH_CONNECTION::Reset(), SCH_ITEM::SetConnectivityDirty(), SCH_CONNECTION::SetGraph(), and SCH_CONNECTION::SetSheet().

Referenced by SCH_ITEM::GetOrInitConnection().

◆ IsBold()

bool EDA_TEXT::IsBold ( ) const
inlineinherited

Definition at line 133 of file eda_text.h.

133{ return m_attributes.m_Bold; }

References EDA_TEXT::m_attributes, and TEXT_ATTRIBUTES::m_Bold.

Referenced by BOARD_ADAPTER::addText(), SCH_EDIT_TOOL::ChangeTextType(), LIB_TEXTBOX::compare(), SCH_DRAWING_TOOLS::createNewText(), DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES(), KIGFX::DS_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), KIGFX::SCH_PAINTER::draw(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), EDA_TEXT_DESC::EDA_TEXT_DESC(), EDA_TEXT::Format(), EDA_TEXT::getDrawFont(), LIB_FIELD::getDrawFont(), LIB_TEXT::getDrawFont(), LIB_TEXTBOX::getDrawFont(), getDrawFont(), SCH_TEXT::getDrawFont(), SCH_TEXTBOX::getDrawFont(), EDA_TEXT::GetEffectiveTextPenWidth(), KIGFX::SCH_PAINTER::getFont(), LIB_TEXTBOX::GetMsgPanelInfo(), SCH_LABEL_BASE::GetMsgPanelInfo(), SCH_TEXT::GetMsgPanelInfo(), SCH_TEXTBOX::GetMsgPanelInfo(), GetRenderCache(), LIB_TEXTBOX::GetShownText(), SCH_TEXTBOX::GetShownText(), FP_TEXTBOX::GetShownText(), PCB_TEXTBOX::GetShownText(), EDA_TEXT::GetTextBox(), EDA_TEXT::GetTextStyleName(), hash_fp_item(), EDA_TEXT::IsDefaultFormatting(), SCH_EAGLE_PLUGIN::loadFieldAttributes(), PCB_PARSER::parseEDA_TEXT(), SCH_SEXPR_PARSER::parseEDA_TEXT(), Plot(), SCH_LABEL_BASE::Plot(), SCH_TEXT::Plot(), SCH_TEXTBOX::Plot(), LIB_FIELD::Plot(), LIB_TEXT::Plot(), LIB_TEXTBOX::Plot(), BRDITEMS_PLOTTER::PlotFootprintTextItem(), BRDITEMS_PLOTTER::PlotPcbText(), Print(), LIB_FIELD::print(), LIB_TEXT::print(), LIB_TEXTBOX::print(), SCH_TEXT::Print(), EDA_TEXT::printOneLineOfText(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveText(), textsNeedUpdate(), DIALOG_LABEL_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataFromWindow(), DIALOG_SHEET_PIN_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_LABEL_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataToWindow(), DIALOG_SHEET_PIN_PROPERTIES::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_DIMENSION_PROPERTIES::TransferDataToWindow(), and DIALOG_TEXTBOX_PROPERTIES::TransferDataToWindow().

◆ IsBrightened()

◆ IsConnectable()

◆ IsConnected()

bool SCH_ITEM::IsConnected ( const VECTOR2I aPoint) const
inherited

Test the item to see if it is connected to aPoint.

Parameters
aPointis a reference to a VECTOR2I object containing the coordinates to test.
Returns
True if connection to aPoint exists.

Definition at line 137 of file sch_item.cpp.

138{
139 if(( m_flags & STRUCT_DELETED ) || ( m_flags & SKIP_STRUCT ) )
140 return false;
141
142 return doIsConnected( aPosition );
143}
virtual bool doIsConnected(const VECTOR2I &aPosition) const
Provide the object specific test to see if it is connected to aPosition.
Definition: sch_item.h:488

References SCH_ITEM::doIsConnected(), EDA_ITEM::m_flags, SKIP_STRUCT, and STRUCT_DELETED.

Referenced by SCH_SCREEN::doIsJunction(), SCH_MOVE_TOOL::getConnectedItems(), SCH_SCREEN::IsTerminalPoint(), and SCH_SCREEN::MarkConnections().

◆ IsConnectivityDirty()

◆ IsDangling()

virtual bool SCH_ITEM::IsDangling ( ) const
inlinevirtualinherited

Reimplemented in SCH_BUS_ENTRY_BASE, SCH_LABEL_BASE, SCH_LINE, and SCH_PIN.

Definition at line 342 of file sch_item.h.

342{ return false; }

Referenced by SCH_EDIT_TOOL::ChangeTextType(), and KIGFX::SCH_PAINTER::draw().

◆ IsDefaultFormatting()

◆ IsEntered()

bool EDA_ITEM::IsEntered ( ) const
inlineinherited

Definition at line 107 of file eda_item.h.

107{ return m_flags & ENTERED; }
#define ENTERED
indicates a group has been entered

References ENTERED, and EDA_ITEM::m_flags.

Referenced by KIGFX::PCB_PAINTER::draw().

◆ IsForceVisible()

bool EDA_ITEM::IsForceVisible ( ) const
inlineinherited

Definition at line 201 of file eda_item.h.

201{ return m_forceVisible; }
bool m_forceVisible
Definition: eda_item.h:497

References EDA_ITEM::m_forceVisible.

Referenced by KIGFX::SCH_PAINTER::draw(), and Print().

◆ IsGotoPageHref()

bool EDA_TEXT::IsGotoPageHref ( const wxString &  aHref,
wxString *  aDestination = nullptr 
)
staticinherited

Check if aHref is a valid internal hyperlink.

Parameters
aHrefString to validate
aDestination[optional] pointer to populate with the destination page
Returns
true if aHref is a valid internal hyperlink. Does not check if the destination page actually exists.

Definition at line 1000 of file eda_text.cpp.

1001{
1002 return aHref.StartsWith( wxT( "#" ), aDestination );
1003}

Referenced by PDF_PLOTTER::EndPlot(), SCH_NAVIGATE_TOOL::HypertextCommand(), and EDA_TEXT::ValidateHyperlink().

◆ IsHorizJustifyFlipped()

bool SCH_FIELD::IsHorizJustifyFlipped ( ) const

Return whether the field will be rendered with the horizontal justification inverted due to rotation or mirroring of the parent.

Definition at line 491 of file sch_field.cpp.

492{
493 VECTOR2I render_center = GetBoundingBox().Centre();
494 VECTOR2I pos = GetPosition();
495
496 switch( GetHorizJustify() )
497 {
499 if( GetDrawRotation().IsVertical() )
500 return render_center.y > pos.y;
501 else
502 return render_center.x < pos.x;
504 if( GetDrawRotation().IsVertical() )
505 return render_center.y < pos.y;
506 else
507 return render_center.x > pos.x;
508 default:
509 return false;
510 }
511}
Vec Centre() const
Definition: box2.h:70
VECTOR2I GetPosition() const override
Definition: sch_field.cpp:1068
EDA_ANGLE GetDrawRotation() const override
Adjusters to allow EDA_TEXT to draw/print/etc.
Definition: sch_field.cpp:427

References BOX2< Vec >::Centre(), GetBoundingBox(), GetDrawRotation(), EDA_TEXT::GetHorizJustify(), GetPosition(), GR_TEXT_H_ALIGN_LEFT, GR_TEXT_H_ALIGN_RIGHT, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by AUTOPLACER::fieldHPlacement(), GetEffectiveHorizJustify(), AUTOPLACER::justifyField(), and DIALOG_SCH_FIELD_PROPERTIES::UpdateField().

◆ IsHypertext()

bool SCH_FIELD::IsHypertext ( ) const
inlineoverridevirtual

Allow items to support hypertext actions when hovered/clicked.

Reimplemented from SCH_ITEM.

Definition at line 95 of file sch_field.h.

96 {
97 return m_id == 0 && m_parent && m_parent->Type() == SCH_GLOBAL_LABEL_T;
98 }

References m_id, EDA_ITEM::m_parent, SCH_GLOBAL_LABEL_T, and EDA_ITEM::Type().

Referenced by DoHypertextAction(), KIGFX::SCH_PAINTER::draw(), and Plot().

◆ IsItalic()

bool EDA_TEXT::IsItalic ( ) const
inlineinherited

Definition at line 130 of file eda_text.h.

130{ return m_attributes.m_Italic; }

References EDA_TEXT::m_attributes, and TEXT_ATTRIBUTES::m_Italic.

Referenced by BOARD_ADAPTER::addText(), SCH_DIRECTIVE_LABEL::AutoplaceFields(), SCH_EDIT_TOOL::ChangeTextType(), LIB_TEXTBOX::compare(), SCH_DRAWING_TOOLS::createNewText(), DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES(), KIGFX::DS_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), KIGFX::SCH_PAINTER::draw(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), EDA_TEXT_DESC::EDA_TEXT_DESC(), EDA_TEXT::Format(), EDA_TEXT::getDrawFont(), LIB_FIELD::getDrawFont(), LIB_TEXT::getDrawFont(), LIB_TEXTBOX::getDrawFont(), getDrawFont(), SCH_TEXT::getDrawFont(), SCH_TEXTBOX::getDrawFont(), KIGFX::SCH_PAINTER::getFont(), LIB_TEXTBOX::GetMsgPanelInfo(), SCH_LABEL_BASE::GetMsgPanelInfo(), SCH_TEXT::GetMsgPanelInfo(), SCH_TEXTBOX::GetMsgPanelInfo(), GetRenderCache(), LIB_TEXTBOX::GetShownText(), SCH_TEXTBOX::GetShownText(), FP_TEXTBOX::GetShownText(), PCB_TEXTBOX::GetShownText(), EDA_TEXT::GetTextBox(), EDA_TEXT::GetTextStyleName(), hash_fp_item(), EDA_TEXT::IsDefaultFormatting(), PCB_PARSER::parseEDA_TEXT(), SCH_SEXPR_PARSER::parseEDA_TEXT(), Plot(), SCH_LABEL_BASE::Plot(), SCH_TEXT::Plot(), SCH_TEXTBOX::Plot(), LIB_FIELD::Plot(), LIB_TEXT::Plot(), LIB_TEXTBOX::Plot(), BRDITEMS_PLOTTER::PlotFootprintTextItem(), BRDITEMS_PLOTTER::PlotPcbText(), Print(), LIB_FIELD::print(), LIB_TEXT::print(), LIB_TEXTBOX::print(), SCH_TEXT::Print(), EDA_TEXT::printOneLineOfText(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveText(), SCH_LEGACY_PLUGIN::saveText(), textsNeedUpdate(), DIALOG_LABEL_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataToWindow(), DIALOG_SHEET_PIN_PROPERTIES::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_DIMENSION_PROPERTIES::TransferDataToWindow(), and DIALOG_TEXTBOX_PROPERTIES::TransferDataToWindow().

◆ IsKeepUpright()

bool EDA_TEXT::IsKeepUpright ( ) const
inlineinherited

◆ IsLocked()

virtual bool SCH_ITEM::IsLocked ( ) const
inlinevirtualinherited
Returns
true if the object is locked, else false.

Definition at line 229 of file sch_item.h.

229{ return false; }

◆ IsMirrored()

◆ IsModified()

bool EDA_ITEM::IsModified ( ) const
inlineinherited

Definition at line 102 of file eda_item.h.

102{ return m_flags & IS_CHANGED; }

References IS_CHANGED, and EDA_ITEM::m_flags.

Referenced by PCB_EDIT_FRAME::OpenProjectFiles().

◆ IsMovableFromAnchorPoint()

virtual bool SCH_ITEM::IsMovableFromAnchorPoint ( ) const
inlinevirtualinherited
Returns
true for items which are moved with the anchor point at mouse cursor and false for items moved with no reference to anchor Usually return true for small items (labels, junctions) and false for items which can be large (hierarchical sheets, symbols)

Reimplemented in SCH_BITMAP, SCH_BUS_ENTRY_BASE, SCH_SHEET, SCH_SHEET_PIN, and SCH_SYMBOL.

Definition at line 207 of file sch_item.h.

207{ return true; }

Referenced by SCH_MOVE_TOOL::Main().

◆ IsMoving()

◆ IsMultilineAllowed()

bool EDA_TEXT::IsMultilineAllowed ( ) const
inlineinherited

◆ IsNameShown()

bool SCH_FIELD::IsNameShown ( ) const
inline

◆ IsNew()

◆ IsPointClickableAnchor()

virtual bool SCH_ITEM::IsPointClickableAnchor ( const VECTOR2I aPos) const
inlinevirtualinherited
Returns
true if the given point can start drawing (usually means the anchor is unused/free/dangling).

Reimplemented in SCH_BUS_ENTRY_BASE, SCH_JUNCTION, SCH_LABEL, SCH_GLOBALLABEL, SCH_HIERLABEL, SCH_LINE, SCH_PIN, SCH_SHEET_PIN, and SCH_SYMBOL.

Definition at line 355 of file sch_item.h.

355{ return false; }

Referenced by EE_SELECTION_TOOL::autostartEvent().

◆ IsReplaceable()

bool SCH_FIELD::IsReplaceable ( ) const
overridevirtual

Override this method in any derived object that supports test find and replace.

Returns
True if the item has replaceable text that can be modified using the find and replace dialog.

Reimplemented from EDA_ITEM.

Definition at line 613 of file sch_field.cpp.

614{
615 if( m_parent && m_parent->Type() == SCH_SHEET_T )
616 {
617 // See comments in SCH_FIELD::Replace(), below.
618 if( m_id == SHEETFILENAME )
619 return false;
620 }
621 else if( m_parent && m_parent->Type() == SCH_GLOBAL_LABEL_T )
622 {
623 if( m_id == 0 /* IntersheetRefs */ )
624 return false;
625 }
626
627 return true;
628}

References m_id, EDA_ITEM::m_parent, SCH_GLOBAL_LABEL_T, SCH_SHEET_T, SHEETFILENAME, and EDA_ITEM::Type().

◆ IsRollover()

bool EDA_ITEM::IsRollover ( ) const
inlineinherited

Definition at line 110 of file eda_item.h.

111 {
112 return ( m_flags & ( IS_ROLLOVER | IS_MOVING ) ) == IS_ROLLOVER;
113 }
#define IS_ROLLOVER
Rollover active. Used for hyperlink highlighting.

References IS_MOVING, IS_ROLLOVER, and EDA_ITEM::m_flags.

Referenced by KIGFX::SCH_PAINTER::draw().

◆ IsSelected()

bool EDA_ITEM::IsSelected ( ) const
inlineinherited

Definition at line 106 of file eda_item.h.

106{ return m_flags & SELECTED; }

References EDA_ITEM::m_flags, and SELECTED.

Referenced by ALIGN_DISTRIBUTE_TOOL::AlignBottom(), ALIGN_DISTRIBUTE_TOOL::AlignCenterX(), ALIGN_DISTRIBUTE_TOOL::AlignCenterY(), ALIGN_DISTRIBUTE_TOOL::AlignTop(), SCH_EDIT_TOOL::ChangeTextType(), SCH_EDIT_FRAME::ConvertPart(), DIALOG_CHANGE_SYMBOLS::DIALOG_CHANGE_SYMBOLS(), ALIGN_DISTRIBUTE_TOOL::doAlignLeft(), ALIGN_DISTRIBUTE_TOOL::doAlignRight(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersVertically(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsVertically(), EDIT_TOOL::doMoveSelection(), KIGFX::SCH_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), KIGFX::PCB_PAINTER::Draw(), DS_PROXY_UNDO_ITEM::DS_PROXY_UNDO_ITEM(), RENDER_3D_OPENGL::get3dModelsFromFootprint(), KIGFX::GERBVIEW_RENDER_SETTINGS::GetColor(), KIGFX::DS_RENDER_SETTINGS::GetColor(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), SCH_MOVE_TOOL::getConnectedDragItems(), KIGFX::SCH_PAINTER::getLineWidth(), DIALOG_EXCHANGE_FOOTPRINTS::isMatch(), DIALOG_CHANGE_SYMBOLS::isMatch(), SCH_SCREEN::MarkConnections(), SCH_LINE::MergeOverlap(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SCH_MOVE_TOOL::moveItem(), KIGFX::SCH_PAINTER::nonCached(), SCH_MOVE_TOOL::orthoLineDrag(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), BOARD_COMMIT::Push(), EE_SELECTION_TOOL::RebuildSelection(), PCB_SELECTION_TOOL::RebuildSelection(), SCH_FIND_REPLACE_TOOL::ReplaceAll(), SCH_EDIT_TOOL::Rotate(), EE_TOOL_BASE< T >::saveCopyInUndoList(), GERBVIEW_SELECTION_TOOL::select(), PCB_SELECTION_TOOL::select(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), KIGFX::SCH_PAINTER::setDeviceColors(), GERBVIEW_SELECTION_TOOL::unselect(), SCH_FIND_REPLACE_TOOL::UpdateFind(), HIERARCHY_PANE::UpdateHierarchySelection(), PCB_BASE_FRAME::UpdateUserUnits(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem(), and DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::visitItem().

◆ IsShownAsBitmap()

bool EDA_ITEM::IsShownAsBitmap ( ) const
inlineinherited

Definition at line 173 of file eda_item.h.

173{ return m_flags & IS_SHOWN_AS_BITMAP; }
#define IS_SHOWN_AS_BITMAP

References IS_SHOWN_AS_BITMAP, and EDA_ITEM::m_flags.

◆ IsType()

bool SCH_FIELD::IsType ( const std::vector< KICAD_T > &  aScanTypes) const
inlineoverridevirtual

Check whether the item is one of the listed types.

Parameters
aScanTypesList of item types
Returns
true if the item type is contained in the list aScanTypes

Reimplemented from EDA_ITEM.

Definition at line 75 of file sch_field.h.

76 {
77 if( SCH_ITEM::IsType( aScanTypes ) )
78 return true;
79
80 for( KICAD_T scanType : aScanTypes )
81 {
83 return true;
84 else if ( scanType == SCH_FIELD_LOCATE_VALUE_T && m_id == VALUE_FIELD )
85 return true;
86 else if ( scanType == SCH_FIELD_LOCATE_FOOTPRINT_T && m_id == FOOTPRINT_FIELD )
87 return true;
88 else if ( scanType == SCH_FIELD_LOCATE_DATASHEET_T && m_id == DATASHEET_FIELD )
89 return true;
90 }
91
92 return false;
93 }
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
Definition: sch_item.h:162
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ SCH_FIELD_LOCATE_REFERENCE_T
Definition: typeinfo.h:164
@ SCH_FIELD_LOCATE_FOOTPRINT_T
Definition: typeinfo.h:166
@ SCH_FIELD_LOCATE_VALUE_T
Definition: typeinfo.h:165
@ SCH_FIELD_LOCATE_DATASHEET_T
Definition: typeinfo.h:167

References DATASHEET_FIELD, FOOTPRINT_FIELD, SCH_ITEM::IsType(), m_id, REFERENCE_FIELD, SCH_FIELD_LOCATE_DATASHEET_T, SCH_FIELD_LOCATE_FOOTPRINT_T, SCH_FIELD_LOCATE_REFERENCE_T, SCH_FIELD_LOCATE_VALUE_T, and VALUE_FIELD.

◆ IsVertJustifyFlipped()

bool SCH_FIELD::IsVertJustifyFlipped ( ) const

Definition at line 528 of file sch_field.cpp.

529{
530 VECTOR2I render_center = GetBoundingBox().Centre();
531 VECTOR2I pos = GetPosition();
532
533 switch( GetVertJustify() )
534 {
536 if( GetDrawRotation().IsVertical() )
537 return render_center.x < pos.x;
538 else
539 return render_center.y < pos.y;
541 if( GetDrawRotation().IsVertical() )
542 return render_center.x > pos.x;
543 else
544 return render_center.y > pos.y;
545 default:
546 return false;
547 }
548}

References BOX2< Vec >::Centre(), GetBoundingBox(), GetDrawRotation(), GetPosition(), EDA_TEXT::GetVertJustify(), GR_TEXT_V_ALIGN_BOTTOM, GR_TEXT_V_ALIGN_TOP, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by GetEffectiveVertJustify(), and DIALOG_SCH_FIELD_PROPERTIES::UpdateField().

◆ IsVisible()

◆ IterateForward() [1/2]

template<class T >
static INSPECT_RESULT EDA_ITEM::IterateForward ( std::deque< T > &  aList,
INSPECTOR  inspector,
void *  testData,
const std::vector< KICAD_T > &  scanTypes 
)
inlinestaticinherited

This changes first parameter to avoid the DList and use the main queue instead.

Definition at line 302 of file eda_item.h.

304 {
305 for( const auto& it : aList )
306 {
307 if( static_cast<EDA_ITEM*>( it )->Visit( inspector,
308 testData,
309 scanTypes ) == INSPECT_RESULT::QUIT )
310 {
312 }
313 }
314
316 }
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
virtual INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &aScanTypes)
May be re-implemented for each derived class in order to handle all the types given by its member dat...
Definition: eda_item.cpp:91

References CONTINUE, QUIT, and EDA_ITEM::Visit().

Referenced by GERBER_FILE_IMAGE::Visit().

◆ IterateForward() [2/2]

template<class T >
static INSPECT_RESULT EDA_ITEM::IterateForward ( std::vector< T > &  aList,
INSPECTOR  inspector,
void *  testData,
const std::vector< KICAD_T > &  scanTypes 
)
inlinestaticinherited

Change first parameter to avoid the DList and use std::vector instead.

Definition at line 322 of file eda_item.h.

324 {
325 for( const auto& it : aList )
326 {
327 if( static_cast<EDA_ITEM*>( it )->Visit( inspector,
328 testData,
329 scanTypes ) == INSPECT_RESULT::QUIT )
330 {
332 }
333 }
334
336 }

References CONTINUE, QUIT, and EDA_ITEM::Visit().

◆ MapHorizJustify()

GR_TEXT_H_ALIGN_T EDA_TEXT::MapHorizJustify ( int  aHorizJustify)
staticinherited

Definition at line 64 of file eda_text.cpp.

65{
66 wxASSERT( aHorizJustify >= GR_TEXT_H_ALIGN_LEFT && aHorizJustify <= GR_TEXT_H_ALIGN_RIGHT );
67
68 if( aHorizJustify > GR_TEXT_H_ALIGN_RIGHT )
70
71 if( aHorizJustify < GR_TEXT_H_ALIGN_LEFT )
73
74 return static_cast<GR_TEXT_H_ALIGN_T>( aHorizJustify );
75}
GR_TEXT_H_ALIGN_T

References GR_TEXT_H_ALIGN_LEFT, and GR_TEXT_H_ALIGN_RIGHT.

Referenced by DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), DIALOG_LIB_FIELD_PROPERTIES::UpdateField(), and DIALOG_SCH_FIELD_PROPERTIES::UpdateField().

◆ MapVertJustify()

GR_TEXT_V_ALIGN_T EDA_TEXT::MapVertJustify ( int  aVertJustify)
staticinherited

Definition at line 78 of file eda_text.cpp.

79{
80 wxASSERT( aVertJustify >= GR_TEXT_V_ALIGN_TOP && aVertJustify <= GR_TEXT_V_ALIGN_BOTTOM );
81
82 if( aVertJustify > GR_TEXT_V_ALIGN_BOTTOM )
84
85 if( aVertJustify < GR_TEXT_V_ALIGN_TOP )
87
88 return static_cast<GR_TEXT_V_ALIGN_T>( aVertJustify );
89}
GR_TEXT_V_ALIGN_T

References GR_TEXT_V_ALIGN_BOTTOM, and GR_TEXT_V_ALIGN_TOP.

Referenced by DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), DIALOG_LIB_FIELD_PROPERTIES::UpdateField(), and DIALOG_SCH_FIELD_PROPERTIES::UpdateField().

◆ Matches() [1/2]

bool SCH_FIELD::Matches ( const EDA_SEARCH_DATA aSearchData,
void *  aAuxData 
) const
overridevirtual

Compare the item against the search criteria in aSearchData.

The base class returns false since many of the objects derived from EDA_ITEM do not have any text to search.

Parameters
aSearchDataA reference to a wxFindReplaceData object containing the search criteria.
aAuxDataA pointer to optional data required for the search or NULL if not used.
Returns
True if the item's text matches the search criteria in aSearchData.

Reimplemented from EDA_ITEM.

Definition at line 565 of file sch_field.cpp.

566{
567 bool searchHiddenFields = false;
568 bool searchAndReplace = false;
569 bool replaceReferences = false;
570
571 try
572 {
573 const SCH_SEARCH_DATA& schSearchData = dynamic_cast<const SCH_SEARCH_DATA&>( aSearchData ); // downcast
574 searchHiddenFields = schSearchData.searchAllFields;
575 searchAndReplace = schSearchData.searchAndReplace;
576 replaceReferences = schSearchData.replaceReferences;
577 }
578 catch( const std::bad_cast& )
579 {
580 }
581
582 wxString text = GetShownText();
583
584 if( !IsVisible() && !searchHiddenFields )
585 return false;
586
588 {
589 if( searchAndReplace && !replaceReferences )
590 return false;
591
592 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
593 wxASSERT( aAuxData );
594
595 // Take sheet path into account which effects the reference field and the unit for
596 // symbols with multiple parts.
597 if( aAuxData )
598 {
599 text = parentSymbol->GetRef((SCH_SHEET_PATH*) aAuxData );
600
601 if( SCH_ITEM::Matches( text, aSearchData ) )
602 return true;
603
604 if( parentSymbol->GetUnitCount() > 1 )
605 text << LIB_SYMBOL::SubReference( parentSymbol->GetUnit() );
606 }
607 }
608
609 return SCH_ITEM::Matches( text, aSearchData );
610}
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:382
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:674

References SCH_SYMBOL::GetRef(), GetShownText(), SCH_SYMBOL::GetUnit(), SCH_SYMBOL::GetUnitCount(), EDA_TEXT::IsVisible(), m_id, EDA_ITEM::m_parent, EDA_ITEM::Matches(), REFERENCE_FIELD, SCH_SEARCH_DATA::replaceReferences, SCH_SYMBOL_T, SCH_SEARCH_DATA::searchAllFields, EDA_SEARCH_DATA::searchAndReplace, LIB_SYMBOL::SubReference(), text, and EDA_ITEM::Type().

◆ Matches() [2/2]

bool EDA_ITEM::Matches ( const wxString &  aText,
const EDA_SEARCH_DATA aSearchData 
) const
protectedinherited

Compare aText against search criteria in aSearchData.

This is a helper function for simplify derived class logic.

Parameters
aTextA reference to a wxString object containing the string to test.
aSearchDataThe criteria to search against.
Returns
True if aText matches the search criteria in aSearchData.

Definition at line 117 of file eda_item.cpp.

118{
119 wxString text = aText;
120 wxString searchText = aSearchData.findString;
121
122 // Don't match if searching for replaceable item and the item doesn't support text replace.
123 if( aSearchData.searchAndReplace && !IsReplaceable() )
124 return false;
125
126 if( !aSearchData.matchCase )
127 {
128 text.MakeUpper();
129 searchText.MakeUpper();
130 }
131
133 {
134 int ii = 0;
135
136 while( ii < (int) text.length() )
137 {
138 int next = text.find( searchText, ii );
139
140 if( next == wxNOT_FOUND )
141 return false;
142
143 ii = next;
144 next += searchText.length();
145
146 bool startOK = ( ii == 0 || !wxIsalnum( text.GetChar( ii - 1 ) ) );
147 bool endOK = ( next == (int) text.length() || !wxIsalnum( text.GetChar( next ) ) );
148
149 if( startOK && endOK )
150 return true;
151 else
152 ii++;
153 }
154
155 return false;
156 }
157 else if( aSearchData.matchMode == EDA_SEARCH_MATCH_MODE::WILDCARD )
158 {
159 return text.Matches( searchText );
160 }
161 else
162 {
163 return text.Find( searchText ) != wxNOT_FOUND;
164 }
165}
virtual bool IsReplaceable() const
Override this method in any derived object that supports test find and replace.
Definition: eda_item.h:420
CITER next(CITER it)
Definition: ptree.cpp:126
EDA_SEARCH_MATCH_MODE matchMode

References EDA_SEARCH_DATA::findString, EDA_ITEM::IsReplaceable(), EDA_SEARCH_DATA::matchCase, EDA_SEARCH_DATA::matchMode, next(), EDA_SEARCH_DATA::searchAndReplace, text, WHOLEWORD, and WILDCARD.

◆ MirrorHorizontally()

void SCH_FIELD::MirrorHorizontally ( int  aCenter)
inlineoverridevirtual

Mirror item horizontally about aCenter.

This overload does nothing. Fields are never mirrored alone. They are moved when the parent symbol is mirrored. This function is only needed by the pure function of the master class.

Implements SCH_ITEM.

Definition at line 211 of file sch_field.h.

212 {
213 }

◆ MirrorVertically()

void SCH_FIELD::MirrorVertically ( int  aCenter)
inlineoverridevirtual

Mirror item vertically about aCenter.

This overload does nothing. Fields are never mirrored alone. They are moved when the parent symbol is mirrored. This function is only needed by the pure function of the master class.

Implements SCH_ITEM.

Definition at line 200 of file sch_field.h.

201 {
202 }

◆ Move()

void SCH_FIELD::Move ( const VECTOR2I aMoveVector)
inlineoverridevirtual

Move the item by aMoveVector to a new position.

Implements SCH_ITEM.

Definition at line 186 of file sch_field.h.

187 {
188 Offset( aMoveVector );
189 }
void Offset(const VECTOR2I &aOffset)
Definition: eda_text.cpp:391

References EDA_TEXT::Offset().

Referenced by GetRenderCache().

◆ Offset()

◆ operator<() [1/2]

bool EDA_ITEM::operator< ( const EDA_ITEM aItem) const
inherited

Test if another item is less than this object.

Parameters
aItem- Item to compare against.
Returns
- True if aItem is less than the item.

Definition at line 231 of file eda_item.cpp.

232{
233 wxFAIL_MSG( wxString::Format( wxT( "Less than operator not defined for item type %s." ),
234 GetClass() ) );
235
236 return false;
237}
virtual wxString GetClass() const =0
Return the class name.

References Format(), and EDA_ITEM::GetClass().

◆ operator<() [2/2]

bool SCH_FIELD::operator< ( const SCH_ITEM aItem) const
overridevirtual

Reimplemented from SCH_ITEM.

Definition at line 1090 of file sch_field.cpp.

1091{
1092 if( Type() != aItem.Type() )
1093 return Type() < aItem.Type();
1094
1095 auto field = static_cast<const SCH_FIELD*>( &aItem );
1096
1097 if( GetId() != field->GetId() )
1098 return GetId() < field->GetId();
1099
1100 if( GetText() != field->GetText() )
1101 return GetText() < field->GetText();
1102
1103 if( GetLibPosition().x != field->GetLibPosition().x )
1104 return GetLibPosition().x < field->GetLibPosition().x;
1105
1106 if( GetLibPosition().y != field->GetLibPosition().y )
1107 return GetLibPosition().y < field->GetLibPosition().y;
1108
1109 return GetName() < field->GetName();
1110}
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:51
int GetId() const
Definition: sch_field.h:125
VECTOR2I GetLibPosition() const
Definition: sch_field.h:226

References GetId(), GetLibPosition(), GetName(), EDA_TEXT::GetText(), EDA_ITEM::Type(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ operator=()

SCH_FIELD & SCH_FIELD::operator= ( const SCH_FIELD aField)

Definition at line 106 of file sch_field.cpp.

107{
108 EDA_TEXT::operator=( aField );
109
110 m_id = aField.m_id;
111 m_name = aField.m_name;
112 m_showName = aField.m_showName;
114
115 m_renderCache.clear();
116
117 for( const std::unique_ptr<KIFONT::GLYPH>& glyph : aField.m_renderCache )
118 {
119 KIFONT::OUTLINE_GLYPH* outline_glyph = static_cast<KIFONT::OUTLINE_GLYPH*>( glyph.get() );
120 m_renderCache.emplace_back( std::make_unique<KIFONT::OUTLINE_GLYPH>( *outline_glyph ) );
121 }
122
125
127
128 return *this;
129}
EDA_TEXT & operator=(const EDA_TEXT &aItem)
Definition: eda_text.cpp:138

References m_allowAutoPlace, m_id, m_lastResolvedColor, m_name, m_renderCache, m_renderCachePos, m_renderCacheValid, m_showName, and EDA_TEXT::operator=().

◆ Plot()

void SCH_FIELD::Plot ( PLOTTER aPlotter,
bool  aBackground 
) const
overridevirtual

Plot the schematic item to aPlotter.

Parameters
aPlotteris the PLOTTER object to plot to.
aBackgrounda poor-man's Z-order. The routine will get called twice, first with aBackground true and then with aBackground false.

Reimplemented from SCH_ITEM.

Definition at line 943 of file sch_field.cpp.

944{
945 if( GetShownText().IsEmpty() || aBackground )
946 return;
947
948 RENDER_SETTINGS* settings = aPlotter->RenderSettings();
949 COLOR4D color = settings->GetLayerColor( GetLayer() );
950 int penWidth = GetEffectiveTextPenWidth( settings->GetDefaultPenWidth() );
951
952 COLOR4D bg = settings->GetBackgroundColor();;
953
954 if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() )
955 bg = COLOR4D::WHITE;
956
957 if( aPlotter->GetColorMode() && GetTextColor() != COLOR4D::UNSPECIFIED )
959
960 penWidth = std::max( penWidth, settings->GetMinPenWidth() );
961
962 // clamp the pen width to be sure the text is readable
963 penWidth = std::min( penWidth, std::min( GetTextSize().x, GetTextSize().y ) / 4 );
964
965 if( !IsVisible() )
966 return;
967
968 // Calculate the text orientation, according to the symbol orientation/mirror
969 EDA_ANGLE orient = GetTextAngle();
970 VECTOR2I textpos = GetTextPos();
973
974 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
975 {
976 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
977
978 if( parentSymbol->GetDNP() )
979 {
980 color.Desaturate();
981 color = color.Mix( bg, 0.5f );
982 }
983
984 if( parentSymbol->GetTransform().y1 ) // Rotate symbol 90 deg.
985 {
986 if( orient.IsHorizontal() )
987 orient = ANGLE_VERTICAL;
988 else
989 orient = ANGLE_HORIZONTAL;
990 }
991
992 /*
993 * Calculate the text justification, according to the symbol orientation/mirror. This is
994 * a bit complicated due to cumulative calculations:
995 * - numerous cases (mirrored or not, rotation)
996 * - the plotter's Text() function will also recalculate H and V justifications according
997 * to the text orientation
998 * - when a symbol is mirrored the text is not, and justifications become a nightmare
999 *
1000 * So the easier way is to use no justifications (centered text) and use GetBoundingBox to
1001 * know the text coordinate considered as centered.
1002 */
1003 hjustify = GR_TEXT_H_ALIGN_CENTER;
1004 vjustify = GR_TEXT_V_ALIGN_CENTER;
1005 textpos = GetBoundingBox().Centre();
1006 }
1007 else if( m_parent && m_parent->Type() == SCH_GLOBAL_LABEL_T )
1008 {
1009 SCH_GLOBALLABEL* label = static_cast<SCH_GLOBALLABEL*>( m_parent );
1010 textpos += label->GetSchematicTextOffset( settings );
1011 }
1012
1013 KIFONT::FONT* font = GetFont();
1014
1015 if( !font )
1016 font = KIFONT::FONT::GetFont( settings->GetDefaultFont(), IsBold(), IsItalic() );
1017
1019 attrs.m_StrokeWidth = penWidth;
1020 attrs.m_Halign = hjustify;
1021 attrs.m_Valign = vjustify;
1022 attrs.m_Angle = orient;
1023 attrs.m_Multiline = false;
1024
1025 aPlotter->PlotText( textpos, color, GetShownText(), attrs, font );
1026
1027 if( IsHypertext() )
1028 {
1029 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( m_parent );
1030 std::vector<std::pair<wxString, wxString>> pages;
1031 std::vector<wxString> pageHrefs;
1032 BOX2I bbox = GetBoundingBox();
1033
1034 wxCHECK( label, /* void */ );
1035
1036 label->GetIntersheetRefs( &pages );
1037
1038 for( const std::pair<wxString, wxString>& page : pages )
1039 pageHrefs.push_back( wxT( "#" ) + page.first );
1040
1041 bbox.Offset( label->GetSchematicTextOffset( settings ) );
1042
1043 aPlotter->HyperlinkMenu( bbox, pageHrefs );
1044 }
1045}
int color
Definition: DXF_plotter.cpp:57
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:102
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
int GetDefaultPenWidth() 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.
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:141
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont, void *aData=nullptr)
Definition: plotter.cpp:758
bool GetColorMode() const
Definition: plotter.h:138
virtual void HyperlinkMenu(const BOX2I &aBox, const std::vector< wxString > &aDestURLs)
Create a clickable hyperlink menu with a rectangular click area.
Definition: plotter.h:466
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...
Definition: sch_label.cpp:274
bool GetDNP() const
Definition: sch_symbol.h:753
@ WHITE
Definition: color4d.h:46

References ANGLE_HORIZONTAL, ANGLE_VERTICAL, BOX2< Vec >::Centre(), color, EDA_TEXT::GetAttributes(), KIGFX::RENDER_SETTINGS::GetBackgroundColor(), GetBoundingBox(), PLOTTER::GetColorMode(), KIGFX::RENDER_SETTINGS::GetDefaultFont(), KIGFX::RENDER_SETTINGS::GetDefaultPenWidth(), SCH_SYMBOL::GetDNP(), EDA_TEXT::GetEffectiveTextPenWidth(), EDA_TEXT::GetFont(), KIFONT::FONT::GetFont(), EDA_TEXT::GetHorizJustify(), SCH_LABEL_BASE::GetIntersheetRefs(), SCH_ITEM::GetLayer(), KIGFX::RENDER_SETTINGS::GetLayerColor(), KIGFX::RENDER_SETTINGS::GetMinPenWidth(), SCH_LABEL_BASE::GetSchematicTextOffset(), SCH_GLOBALLABEL::GetSchematicTextOffset(), GetShownText(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextColor(), EDA_TEXT::GetTextPos(), EDA_TEXT::GetTextSize(), SCH_SYMBOL::GetTransform(), EDA_TEXT::GetVertJustify(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_CENTER, PLOTTER::HyperlinkMenu(), EDA_TEXT::IsBold(), EDA_ANGLE::IsHorizontal(), IsHypertext(), EDA_TEXT::IsItalic(), EDA_TEXT::IsVisible(), TEXT_ATTRIBUTES::m_Angle, TEXT_ATTRIBUTES::m_Halign, TEXT_ATTRIBUTES::m_Multiline, EDA_ITEM::m_parent, TEXT_ATTRIBUTES::m_StrokeWidth, TEXT_ATTRIBUTES::m_Valign, BOX2< Vec >::Offset(), PLOTTER::PlotText(), PLOTTER::RenderSettings(), SCH_GLOBAL_LABEL_T, SCH_SYMBOL_T, EDA_ITEM::Type(), WHITE, and TRANSFORM::y1.

◆ Print() [1/2]

void SCH_FIELD::Print ( const RENDER_SETTINGS aSettings,
const VECTOR2I aOffset 
)
overridevirtual

Print a schematic item.

Each schematic item should have its own method

Parameters
aOffsetis the drawing offset (usually {0,0} but can be different when moving an object).

Implements SCH_ITEM.

Definition at line 316 of file sch_field.cpp.

317{
318 wxDC* DC = aSettings->GetPrintDC();
320 bool blackAndWhiteMode = GetGRForceBlackPenState();
321 VECTOR2I textpos;
322 int penWidth = GetEffectiveTextPenWidth( aSettings->GetDefaultPenWidth() );
323
324 if( ( !IsVisible() && !IsForceVisible() ) || GetShownText().IsEmpty() )
325 return;
326
327 COLOR4D bg = aSettings->GetBackgroundColor();
328
329 if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() )
330 bg = COLOR4D::WHITE;
331
332 if( IsForceVisible() )
333 bg = aSettings->GetLayerColor( LAYER_HIDDEN );
334
335 if( !blackAndWhiteMode && GetTextColor() != COLOR4D::UNSPECIFIED )
337
338 // Calculate the text orientation according to the symbol orientation.
339 EDA_ANGLE orient = GetTextAngle();
340
341 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
342 {
343 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
344
345 if( parentSymbol && parentSymbol->GetTransform().y1 ) // Rotate symbol 90 degrees.
346 {
347 if( orient == ANGLE_HORIZONTAL )
348 orient = ANGLE_VERTICAL;
349 else
350 orient = ANGLE_HORIZONTAL;
351 }
352
353 if( parentSymbol && parentSymbol->GetDNP() )
354 {
355 color.Desaturate();
356 color = color.Mix( bg, 0.5f );
357 }
358 }
359
360 KIFONT::FONT* font = GetFont();
361
362 if( !font )
363 font = KIFONT::FONT::GetFont( aSettings->GetDefaultFont(), IsBold(), IsItalic() );
364
365 /*
366 * Calculate the text justification, according to the symbol orientation/mirror.
367 * This is a bit complicated due to cumulative calculations:
368 * - numerous cases (mirrored or not, rotation)
369 * - the GRText function will also recalculate H and V justifications according to the text
370 * orientation.
371 * - When a symbol is mirrored, the text is not mirrored and justifications are complicated
372 * to calculate so the more easily way is to use no justifications (centered text) and use
373 * GetBoundingBox to know the text coordinate considered as centered
374 */
375 textpos = GetBoundingBox().Centre() + aOffset;
376
378 GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), IsBold(), font );
379}
bool IsForceVisible() const
Definition: eda_item.h:201
wxDC * GetPrintDC() const
bool GetGRForceBlackPenState(void)
Definition: gr_basic.cpp:165
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.
Definition: gr_text.cpp:141
@ LAYER_HIDDEN
Definition: layer_ids.h:380

References ANGLE_HORIZONTAL, ANGLE_VERTICAL, BOX2< Vec >::Centre(), color, KIGFX::RENDER_SETTINGS::GetBackgroundColor(), GetBoundingBox(), KIGFX::RENDER_SETTINGS::GetDefaultFont(), KIGFX::RENDER_SETTINGS::GetDefaultPenWidth(), SCH_SYMBOL::GetDNP(), EDA_TEXT::GetEffectiveTextPenWidth(), EDA_TEXT::GetFont(), KIFONT::FONT::GetFont(), GetGRForceBlackPenState(), KIGFX::RENDER_SETTINGS::GetLayerColor(), KIGFX::RENDER_SETTINGS::GetPrintDC(), GetShownText(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextColor(), EDA_TEXT::GetTextSize(), SCH_SYMBOL::GetTransform(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_CENTER, GRPrintText(), EDA_TEXT::IsBold(), EDA_ITEM::IsForceVisible(), EDA_TEXT::IsItalic(), EDA_TEXT::IsVisible(), LAYER_HIDDEN, SCH_ITEM::m_layer, EDA_ITEM::m_parent, SCH_SYMBOL_T, EDA_ITEM::Type(), WHITE, and TRANSFORM::y1.

◆ Print() [2/2]

void EDA_TEXT::Print ( const RENDER_SETTINGS aSettings,
const VECTOR2I aOffset,
const COLOR4D aColor,
OUTLINE_MODE  aDisplay_mode = FILLED 
)
inherited

Print this text object to the device context aDC.

Parameters
aDCthe current Device Context.
aOffsetdraw offset (usually (0,0)).
aColortext color.
aDisplay_modeFILLED or SKETCH.

Definition at line 650 of file eda_text.cpp.

652{
653 if( IsMultilineAllowed() )
654 {
655 std::vector<VECTOR2I> positions;
656 wxArrayString strings;
657 wxStringSplit( GetShownText(), strings, '\n' );
658
659 positions.reserve( strings.Count() );
660
661 GetLinePositions( positions, (int) strings.Count() );
662
663 for( unsigned ii = 0; ii < strings.Count(); ii++ )
664 printOneLineOfText( aSettings, aOffset, aColor, aFillMode, strings[ii], positions[ii] );
665 }
666 else
667 {
668 printOneLineOfText( aSettings, aOffset, aColor, aFillMode, GetShownText(), GetDrawPos() );
669 }
670}
void printOneLineOfText(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset, const COLOR4D &aColor, OUTLINE_MODE aFillMode, const wxString &aText, const VECTOR2I &aPos)
Print each line of this EDA_TEXT.
Definition: eda_text.cpp:713
void GetLinePositions(std::vector< VECTOR2I > &aPositions, int aLineCount) const
Populate aPositions with the position of each line of a multiline text, according to the vertical jus...
Definition: eda_text.cpp:673

References EDA_TEXT::GetDrawPos(), EDA_TEXT::GetLinePositions(), EDA_TEXT::GetShownText(), EDA_TEXT::IsMultilineAllowed(), EDA_TEXT::printOneLineOfText(), and wxStringSplit().

Referenced by SCH_LABEL_BASE::Print(), SCH_TEXT::Print(), SCH_TEXTBOX::Print(), and DS_DRAW_ITEM_TEXT::PrintWsItem().

◆ PrintBackground()

virtual void SCH_ITEM::PrintBackground ( const RENDER_SETTINGS aSettings,
const VECTOR2I aOffset 
)
inlinevirtualinherited

Print the (optional) backaground elements if they exist.

Parameters
aSettingsPrint settings
aOffsetis the drawing offset (usually {0,0} but can be different when moving an object).

Reimplemented in SCH_SHAPE, and SCH_SYMBOL.

Definition at line 286 of file sch_item.h.

286{};

◆ printOneLineOfText()

void EDA_TEXT::printOneLineOfText ( const RENDER_SETTINGS aSettings,
const VECTOR2I aOffset,
const COLOR4D aColor,
OUTLINE_MODE  aFillMode,
const wxString &  aText,
const VECTOR2I aPos 
)
protectedinherited

Print each line of this EDA_TEXT.

Parameters
aOffsetdraw offset (usually (0,0)).
aColortext color.
aFillModeFILLED or SKETCH
aTextthe single line of text to draw.
aPosthe position of this line ).

Definition at line 713 of file eda_text.cpp.

716{
717 wxDC* DC = aSettings->GetPrintDC();
718 int penWidth = GetEffectiveTextPenWidth( aSettings->GetDefaultPenWidth() );
719
720 if( aFillMode == SKETCH )
721 penWidth = -penWidth;
722
723 VECTOR2I size = GetTextSize();
724
725 if( IsMirrored() )
726 size.x = -size.x;
727
728 KIFONT::FONT* font = GetFont();
729
730 if( !font )
731 font = KIFONT::FONT::GetFont( aSettings->GetDefaultFont(), IsBold(), IsItalic() );
732
733 GRPrintText( DC, aOffset + aPos, aColor, aText, GetDrawRotation(), size, GetHorizJustify(),
734 GetVertJustify(), penWidth, IsItalic(), IsBold(), font );
735}
@ SKETCH
Definition: outline_mode.h:26

References KIGFX::RENDER_SETTINGS::GetDefaultFont(), KIGFX::RENDER_SETTINGS::GetDefaultPenWidth(), EDA_TEXT::GetDrawRotation(), EDA_TEXT::GetEffectiveTextPenWidth(), EDA_TEXT::GetFont(), KIFONT::FONT::GetFont(), EDA_TEXT::GetHorizJustify(), KIGFX::RENDER_SETTINGS::GetPrintDC(), EDA_TEXT::GetTextSize(), EDA_TEXT::GetVertJustify(), GRPrintText(), EDA_TEXT::IsBold(), EDA_TEXT::IsItalic(), EDA_TEXT::IsMirrored(), SKETCH, and VECTOR2< T >::x.

Referenced by EDA_TEXT::Print().

◆ RemoveHyperlink()

void EDA_TEXT::RemoveHyperlink ( )
inlineinherited

Definition at line 336 of file eda_text.h.

336{ m_hyperlink = wxEmptyString; }

References EDA_TEXT::m_hyperlink.

◆ RenderAsBitmap()

bool SCH_ITEM::RenderAsBitmap ( double  aWorldScale) const
overridevirtualinherited

Reimplemented from EDA_ITEM.

Definition at line 294 of file sch_item.cpp.

295{
296 if( IsHypertext() )
297 return false;
298
299 if( const EDA_TEXT* text = dynamic_cast<const EDA_TEXT*>( this ) )
300 return text->GetTextHeight() * aWorldScale < BITMAP_FONT_SIZE_THRESHOLD;
301
302 return false;
303}
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:72
virtual bool IsHypertext() const
Allow items to support hypertext actions when hovered/clicked.
Definition: sch_item.h:239
#define BITMAP_FONT_SIZE_THRESHOLD
Definition: sch_item.cpp:46

References BITMAP_FONT_SIZE_THRESHOLD, SCH_ITEM::IsHypertext(), and text.

Referenced by KIGFX::SCH_PAINTER::draw().

◆ Replace() [1/3]

bool EDA_TEXT::Replace ( const EDA_SEARCH_DATA aSearchData)
inherited

Helper function used in search and replace dialog.

Perform a text replace using the find and replace criteria in aSearchData.

Parameters
aSearchDataA reference to a EDA_SEARCH_DATA object containing the search and replace criteria.
Returns
True if the text item was modified, otherwise false.

Definition at line 320 of file eda_text.cpp.

321{
322 bool retval = EDA_ITEM::Replace( aSearchData, m_text );
323
325
328
329 return retval;
330}
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...
Definition: eda_item.cpp:168
void cacheShownText()
Definition: eda_text.cpp:410

References EDA_TEXT::cacheShownText(), EDA_TEXT::ClearRenderCache(), EDA_TEXT::m_bounding_box_cache_valid, EDA_TEXT::m_text, and EDA_ITEM::Replace().

Referenced by LIB_TEXTBOX::Replace(), SCH_LABEL_BASE::Replace(), SCH_TEXT::Replace(), SCH_TEXTBOX::Replace(), Replace(), and SCH_SHEET_PIN::Replace().

◆ Replace() [2/3]

bool SCH_FIELD::Replace ( const EDA_SEARCH_DATA aSearchData,
void *  aAuxData = nullptr 
)
overridevirtual

Perform a text replace using the find and replace criteria in aSearchData on items that support text find and replace.

This function must be overridden for items that support text replace.

Parameters
aSearchDataA reference to a wxFindReplaceData object containing the search and replace criteria.
aAuxDataA pointer to optional data required for the search or NULL if not used.
Returns
True if the item text was modified, otherwise false.

Reimplemented from EDA_ITEM.

Definition at line 631 of file sch_field.cpp.

632{
633 bool replaceReferences = false;
634
635 try
636 {
637 const SCH_SEARCH_DATA& schSearchData = dynamic_cast<const SCH_SEARCH_DATA&>( aSearchData );
638 replaceReferences = schSearchData.replaceReferences;
639 }
640 catch( const std::bad_cast& )
641 {
642 }
643
644 wxString text;
645 bool resolve = false; // Replace in source text, not shown text
646 bool isReplaced = false;
647
648 if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
649 {
650 SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
651
652 switch( m_id )
653 {
654 case REFERENCE_FIELD:
655 wxCHECK_MSG( aAuxData, false, wxT( "Need sheetpath to replace in refdes." ) );
656
657 if( !replaceReferences )
658 return false;
659
660 text = parentSymbol->GetRef( (SCH_SHEET_PATH*) aAuxData );
661 isReplaced = EDA_ITEM::Replace( aSearchData, text );
662
663 if( isReplaced )
664 parentSymbol->SetRef( (SCH_SHEET_PATH*) aAuxData, text );
665
666 break;
667
668 case VALUE_FIELD:
669 wxCHECK_MSG( aAuxData, false, wxT( "Need sheetpath to replace in value field." ) );
670
671 text = parentSymbol->GetValueFieldText( resolve );
672 isReplaced = EDA_ITEM::Replace( aSearchData, text );
673
674 if( isReplaced )
675 parentSymbol->SetValueFieldText( text );
676
677 break;
678
679 case FOOTPRINT_FIELD:
680 wxCHECK_MSG( aAuxData, false, wxT( "Need sheetpath to replace in footprint field." ) );
681
682 text = parentSymbol->GetFootprintFieldText( resolve );
683 isReplaced = EDA_ITEM::Replace( aSearchData, text );
684
685 if( isReplaced )
686 parentSymbol->SetFootprintFieldText( text );
687
688 break;
689
690 default:
691 isReplaced = EDA_TEXT::Replace( aSearchData );
692 }
693 }
694 else if( m_parent && m_parent->Type() == SCH_SHEET_T )
695 {
696 isReplaced = EDA_TEXT::Replace( aSearchData );
697
698 if( m_id == SHEETFILENAME && isReplaced )
699 {
700 // If we allowed this we'd have a bunch of work to do here, including warning
701 // about it not being undoable, checking for recursive hierarchies, reloading
702 // sheets, etc. See DIALOG_SHEET_PROPERTIES::TransferDataFromWindow().
703 }
704 }
705 else
706 {
707 isReplaced = EDA_TEXT::Replace( aSearchData );
708 }
709
710 return isReplaced;
711}
bool Replace(const EDA_SEARCH_DATA &aSearchData)
Helper function used in search and replace dialog.
Definition: eda_text.cpp:320
void SetValueFieldText(const wxString &aValue)
Definition: sch_symbol.cpp:844
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
Definition: sch_symbol.cpp:716
const wxString GetFootprintFieldText(bool aResolve) const
Definition: sch_symbol.cpp:850
void SetFootprintFieldText(const wxString &aFootprint)
Definition: sch_symbol.cpp:859
const wxString GetValueFieldText(bool aResolve) const
Definition: sch_symbol.cpp:835

References FOOTPRINT_FIELD, SCH_SYMBOL::GetFootprintFieldText(), SCH_SYMBOL::GetRef(), SCH_SYMBOL::GetValueFieldText(), m_id, EDA_ITEM::m_parent, REFERENCE_FIELD, EDA_TEXT::Replace(), EDA_ITEM::Replace(), SCH_SEARCH_DATA::replaceReferences, SCH_SHEET_T, SCH_SYMBOL_T, SCH_SYMBOL::SetFootprintFieldText(), SCH_SYMBOL::SetRef(), SCH_SYMBOL::SetValueFieldText(), SHEETFILENAME, text, EDA_ITEM::Type(), and VALUE_FIELD.

◆ Replace() [3/3]

bool EDA_ITEM::Replace ( const EDA_SEARCH_DATA aSearchData,
wxString &  aText 
)
staticinherited

Perform a text replace on aText using the find and replace criteria in aSearchData on items that support text find and replace.

Parameters
aSearchDataA reference to a wxFindReplaceData object containing the search and replace criteria.
aTextA reference to a wxString object containing the text to be replaced.
Returns
True if aText was modified, otherwise false.

Definition at line 168 of file eda_item.cpp.

169{
170 wxString text = aText;
171 wxString searchText = aSearchData.findString;
172 wxString result;
173 bool replaced = false;
174
175 if( !aSearchData.matchCase )
176 {
177 text = text.Upper();
178 searchText = searchText.Upper();
179 }
180
181 int ii = 0;
182
183 while( ii < (int) text.length() )
184 {
185 int next = text.find( searchText, ii );
186
187 if( next == wxNOT_FOUND )
188 {
189 result += aText.Mid( ii, wxString::npos );
190 break;
191 }
192
193 if( next > ii )
194 result += aText.Mid( ii, next - ii );
195
196 ii = next;
197 next += searchText.length();
198
199 bool startOK;
200 bool endOK;
201
203 {
204 startOK = ( ii == 0 || !wxIsalnum( text.GetChar( ii - 1 ) ) );
205 endOK = ( next == (int) text.length() || !wxIsalnum( text.GetChar( next ) ) );
206 }
207 else
208 {
209 startOK = true;
210 endOK = true;
211 }
212
213 if( startOK && endOK )
214 {
215 result += aSearchData.replaceString;
216 replaced = true;
217 ii = next;
218 }
219 else
220 {
221 result += aText.GetChar( ii );
222 ii++;
223 }
224 }
225
226 aText = result;
227 return replaced;
228}
wxString replaceString

References EDA_SEARCH_DATA::findString, EDA_SEARCH_DATA::matchCase, EDA_SEARCH_DATA::matchMode, next(), EDA_SEARCH_DATA::replaceString, text, and WHOLEWORD.

Referenced by EDA_TEXT::Replace(), Replace(), SCH_FIND_REPLACE_TOOL::ReplaceAll(), and SCH_FIND_REPLACE_TOOL::ReplaceAndFindNext().

◆ Rotate()

void SCH_FIELD::Rotate ( const VECTOR2I aCenter)
overridevirtual

Rotate the item around aCenter 90 degrees in the clockwise direction.

Implements SCH_ITEM.

Definition at line 714 of file sch_field.cpp.

715{
716 VECTOR2I pt = GetPosition();
717 RotatePoint( pt, aCenter, ANGLE_90 );
718 SetPosition( pt );
719}
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_field.cpp:1048
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:431

References ANGLE_90, GetPosition(), RotatePoint(), and SetPosition().

Referenced by SCH_EDIT_TOOL::Rotate().

◆ RunOnChildren()

virtual void SCH_ITEM::RunOnChildren ( const std::function< void(SCH_ITEM *)> &  aFunction)
inlinevirtualinherited

◆ Schematic()

SCHEMATIC * SCH_ITEM::Schematic ( ) const
inherited

Searches the item hierarchy to find a SCHEMATIC.

Every SCH_ITEM that lives on a SCH_SCREEN should be parented to either that screen or another SCH_ITEM on the same screen (for example, pins to their symbols).

Every SCH_SCREEN should be parented to the SCHEMATIC.

Note
This hierarchy is not the same as the sheet hierarchy!
Returns
the parent schematic this item lives on, or nullptr.

Definition at line 112 of file sch_item.cpp.

113{
114 EDA_ITEM* parent = GetParent();
115
116 while( parent )
117 {
118 if( parent->Type() == SCHEMATIC_T )
119 return static_cast<SCHEMATIC*>( parent );
120 else
121 parent = parent->GetParent();
122 }
123
124 return nullptr;
125}
@ SCHEMATIC_T
Definition: typeinfo.h:188

References EDA_ITEM::GetParent(), SCHEMATIC_T, and EDA_ITEM::Type().

Referenced by EE_SELECTION_TOOL::autostartEvent(), SCH_EDIT_TOOL::ChangeTextType(), SCH_ITEM::Connection(), SCH_DRAWING_TOOLS::createSheetPin(), DIALOG_SCH_FIELD_PROPERTIES::DIALOG_SCH_FIELD_PROPERTIES(), SCH_SHEET::findSelf(), SCH_MARKER::GetColorLayer(), SCH_SHEET::GetContextualTextVars(), SCH_ITEM::GetEffectiveNetClass(), SCH_JUNCTION::getEffectiveShape(), SCH_LABEL_BASE::GetIntersheetRefs(), SCH_LABEL_BASE::GetLabelBoxExpansion(), SCH_DIRECTIVE_LABEL::GetPenWidth(), SCH_LINE::GetPenWidth(), SCH_NO_CONNECT::GetPenWidth(), SCH_SHAPE::GetPenWidth(), SCH_SHEET::GetPenWidth(), SCH_SHEET_PIN::GetPenWidth(), SCH_SYMBOL::GetPins(), SCH_MARKER::GetSeverity(), GetShownText(), SCH_TEXT::GetShownText(), SCH_TEXTBOX::GetShownText(), SCH_TEXT::GetTextOffset(), SCH_PIN::HitTest(), SCH_SHEET::IsRootSheet(), SCH_LABEL_BASE::IsType(), DIALOG_SYMBOL_PROPERTIES::OnAddField(), DIALOG_SCH_FIELD_PROPERTIES::onScintillaCharAdded(), DIALOG_TEXT_PROPERTIES::onScintillaCharAdded(), SCH_LABEL_BASE::ResolveTextVar(), SCH_GLOBALLABEL::ResolveTextVar(), SCH_SHEET::ResolveTextVar(), SCH_SYMBOL::ResolveTextVar(), SCH_SYMBOL::SetRef(), DIALOG_LABEL_PROPERTIES::TransferDataFromWindow(), DIALOG_LABEL_PROPERTIES::TransferDataToWindow(), SCH_SHEET_PATH::UpdateAllScreenReferences(), DIALOG_SCH_FIELD_PROPERTIES::UpdateField(), and SCH_MARKER::ViewGetLayers().

◆ Set() [1/3]

template<typename T >
bool INSPECTABLE::Set ( const wxString &  aProperty,
aValue 
)
inlineinherited

Definition at line 66 of file inspectable.h.

67 {
69 TYPE_ID thisType = TYPE_HASH( *this );
70 PROPERTY_BASE* prop = propMgr.GetProperty( thisType, aProperty );
71 void* object = nullptr;
72
73 if( prop )
74 {
75 object = propMgr.TypeCast( this, thisType, prop->OwnerHash() );
76
77 if( object )
78 prop->set<T>( object, aValue );
79 }
80
81 return object != nullptr;
82 }
void set(void *aObject, T aValue)
Definition: property.h:325

References PROPERTY_MANAGER::GetProperty(), PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), PROPERTY_BASE::set(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

◆ Set() [2/3]

template<typename T >
bool INSPECTABLE::Set ( PROPERTY_BASE aProperty,
aValue 
)
inlineinherited

Definition at line 54 of file inspectable.h.

55 {
57 void* object = propMgr.TypeCast( this, TYPE_HASH( *this ), aProperty->OwnerHash() );
58
59 if( object )
60 aProperty->set<T>( object, aValue );
61
62 return