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 wxPoint &aPos, int aFieldId, SCH_ITEM *aParent, const wxString &aName=wxEmptyString)
 
 ~SCH_FIELD ()
 
wxString GetClass () const override
 Return the class name. More...
 
bool IsType (const 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 DoHypertextMenu (EDA_DRAW_FRAME *aFrame) override
 
wxString GetName (bool aUseDefaultName=true) const
 Return the field name. 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)
 
int GetId () const
 
void SetId (int aId)
 
wxString GetShownText (int aDepth=0) const override
 Return the string actually shown after processing of the base text. More...
 
double GetDrawRotation () const override
 Adjusters to allow EDA_TEXT to draw/print/etc. More...
 
wxPoint GetDrawPos () const override
 
EDA_TEXT_HJUSTIFY_T GetDrawHorizJustify () const override
 
EDA_TEXT_VJUSTIFY_T GetDrawVertJustify () const override
 
const EDA_RECT 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
 
EDA_TEXT_HJUSTIFY_T GetEffectiveHorizJustify () const
 
EDA_TEXT_VJUSTIFY_T GetEffectiveVertJustify () const
 
bool IsVoid () const
 
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 Print (const RENDER_SETTINGS *aSettings, const wxPoint &aOffset) override
 Print a schematic item. More...
 
void Move (const wxPoint &aMoveVector) override
 Move the item by aMoveVector to a new position. More...
 
void Rotate (const wxPoint &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 wxFindReplaceData &aSearchData, void *aAuxData) const override
 Compare the item against the search criteria in aSearchData. More...
 
bool Replace (const wxFindReplaceData &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 GetSelectMenuText (EDA_UNITS aUnits) const override
 Return the text to display to be used in the selection clarification context menu when multiple items are found at the current cursor position. 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...
 
wxPoint GetLibPosition () const
 
wxPoint GetPosition () const override
 
void SetPosition (const wxPoint &aPosition) override
 
wxPoint GetParentPosition () const
 
bool HitTest (const wxPoint &aPosition, int aAccuracy=0) const override
 Test if aPosition is inside or on the boundary of this item. More...
 
bool HitTest (const EDA_RECT &aRect, bool aContained, int aAccuracy=0) const override
 Test if aRect intersects this item. More...
 
void Plot (PLOTTER *aPlotter) 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
 
wxPoint & GetStoredPos ()
 
void SetStoredPos (const wxPoint &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...
 
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 wxPoint &aPos) const
 
virtual std::vector< wxPoint > GetConnectionPoints () 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 wxPoint &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)
 
virtual void SetLastResolvedState (const SCH_ITEM *aItem)
 
NETCLASSPTR NetClass (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 IsDragging () const
 
bool IsWireImage () const
 
bool IsSelected () const
 
bool IsEntered () const
 
bool IsResized () const
 
bool IsBrightened () const
 
void SetWireImage ()
 
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 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 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 const wxPoint GetFocusPosition () const
 Similar to GetPosition, but allows items to return their visual center rather than their anchor. More...
 
virtual SEARCH_RESULT Visit (INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
 May be re-implemented for each derived class in order to handle all the types given by its member data. 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)
 
template<typename T >
Get (PROPERTY_BASE *aProperty)
 
template<typename T >
boost::optional< T > Get (const wxString &aProperty)
 
virtual const wxString & GetText () const
 Return the string associated with the text object. More...
 
wxString ShortenedShownText () const
 Returns a shortened version (max 15 characters) of the shown text. 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 aDefaultWidth=0) const
 The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth. More...
 
virtual void SetTextAngle (double aAngle)
 
double GetTextAngle () const
 
double GetTextAngleDegrees () const
 
double GetTextAngleRadians () const
 
void SetItalic (bool isItalic)
 
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
 
EDA_TEXT_HJUSTIFY_T GetHorizJustify () const
 
EDA_TEXT_VJUSTIFY_T GetVertJustify () const
 
void SetHorizJustify (EDA_TEXT_HJUSTIFY_T aType)
 
void SetVertJustify (EDA_TEXT_VJUSTIFY_T aType)
 
void SetEffects (const EDA_TEXT &aSrc)
 Set the text effects from another instance. More...
 
void SwapEffects (EDA_TEXT &aTradingPartner)
 Swap the text effects of the two involved instances. More...
 
void SwapText (EDA_TEXT &aTradingPartner)
 
void CopyText (const EDA_TEXT &aSrc)
 
bool Replace (const wxFindReplaceData &aSearchData)
 Helper function used in search and replace dialog. More...
 
bool IsDefaultFormatting () const
 
void SetTextSize (const wxSize &aNewSize)
 
const wxSize & GetTextSize () const
 
void SetTextWidth (int aWidth)
 
int GetTextWidth () const
 
void SetTextHeight (int aHeight)
 
int GetTextHeight () const
 
void SetTextPos (const wxPoint &aPoint)
 
const wxPoint & GetTextPos () const
 
void SetTextX (int aX)
 
void SetTextY (int aY)
 
void Offset (const wxPoint &aOffset)
 
void Empty ()
 
void Print (const RENDER_SETTINGS *aSettings, const wxPoint &aOffset, const COLOR4D &aColor, OUTLINE_MODE aDisplay_mode=FILLED)
 Print this text object to the device context aDC. More...
 
std::vector< wxPoint > TransformToSegmentList () const
 Convert the text shape to a list of segment. More...
 
void TransformBoundingBoxWithClearanceToPolygon (SHAPE_POLY_SET *aCornerBuffer, int aClearanceValue) 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 () const
 
virtual bool TextHitTest (const wxPoint &aPoint, int aAccuracy=0) const
 Test if aPoint is within the bounds of this object. More...
 
virtual bool TextHitTest (const EDA_RECT &aRect, bool aContains, int aAccuracy=0) const
 Test if object bounding box is contained within or intersects aRect. More...
 
int LenSize (const wxString &aLine, int aThickness) const
 
EDA_RECT 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< wxPoint > &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...
 
int Compare (const EDA_TEXT *aOther) const
 

Static Public Member Functions

static bool ClassOf (const EDA_ITEM *aItem)
 
template<class T >
static SEARCH_RESULT IterateForward (std::deque< T > &aList, INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
 This changes first parameter to avoid the DList and use the main queue instead. More...
 
template<class T >
static SEARCH_RESULT IterateForward (std::vector< T > &aList, INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
 Change first parameter to avoid the DList and use std::vector instead. More...
 
static bool Replace (const wxFindReplaceData &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 EDA_TEXT_HJUSTIFY_T MapHorizJustify (int aHorizJustify)
 
static EDA_TEXT_VJUSTIFY_T MapVertJustify (int aVertJustify)
 

Public Attributes

const KIID m_Uuid
 

Protected Member Functions

bool Matches (const wxString &aText, const wxFindReplaceData &aSearchData) const
 Compare aText against search criteria in aSearchData. More...
 

Protected Attributes

SCH_LAYER_ID m_layer
 
EDA_ITEMS m_connections
 
FIELDS_AUTOPLACED m_fieldsAutoplaced
 
wxPoint m_storedPos
 
std::unordered_map< SCH_SHEET_PATH, SCH_ITEM_SETm_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
 

Private Attributes

int m_id
 Field index,. More...
 
wxString m_name
 

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 49 of file sch_field.h.

Constructor & Destructor Documentation

◆ SCH_FIELD()

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

Definition at line 56 of file sch_field.cpp.

57  :
58  SCH_ITEM( aParent, SCH_FIELD_T ),
59  EDA_TEXT( wxEmptyString ),
60  m_id( 0 ),
61  m_name( aName )
62 {
63  SetTextPos( aPos );
64  SetId( aFieldId ); // will also set the layer
65  SetVisible( false );
66 }
EDA_TEXT(const wxString &text=wxEmptyString)
Definition: eda_text.cpp:101
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:267
wxString m_name
Definition: sch_field.h:222
virtual void SetVisible(bool aVisible)
Definition: eda_text.h:206
void SetId(int aId)
Definition: sch_field.cpp:80
int m_id
Field index,.
Definition: sch_field.h:220
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType)
Definition: sch_item.cpp:44

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

Referenced by Clone().

◆ ~SCH_FIELD()

SCH_FIELD::~SCH_FIELD ( )

Definition at line 69 of file sch_field.cpp.

70 {
71 }

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 183 of file sch_item.cpp.

184 {
185  SCH_ITEM_SET& set = m_connected_items[ aSheet ];
186 
187  // The vector elements are small, so reserve 1k at a time to prevent re-allocations
188  if( set.size() == set.capacity() )
189  set.reserve( set.size() + 4096 );
190 
191  set.emplace_back( aItem );
192 }
std::vector< SCH_ITEM * > SCH_ITEM_SET
Definition: sch_item.h:134
std::unordered_map< SCH_SHEET_PATH, SCH_ITEM_SET > m_connected_items
Store pointers to other items that are connected to this one, per sheet.
Definition: sch_item.h:494

References SCH_ITEM::m_connected_items.

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

◆ 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

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

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

◆ AutoplaceFields()

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

◆ CanConnect()

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

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

Definition at line 344 of file sch_item.h.

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

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 59 of file sch_field.h.

60  {
61  return aItem && SCH_FIELD_T == aItem->Type();
62  }
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References SCH_FIELD_T, and EDA_ITEM::Type().

◆ ClearBrightened()

void EDA_ITEM::ClearBrightened ( )
inlineinherited

◆ 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:488

References SCH_ITEM::m_connections.

◆ ClearEditFlags()

◆ ClearFieldsAutoplaced()

void SCH_ITEM::ClearFieldsAutoplaced ( )
inlineinherited

◆ ClearFlags()

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

Definition at line 153 of file eda_item.h.

153 { m_flags &= ~aMask; }
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480

References EDA_ITEM::m_flags.

Referenced by FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), PNS_KICAD_IFACE::AddItem(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), SCH_MOVE_TOOL::AlignElements(), FOOTPRINT::BuildPolyCourtyards(), EDA_ITEM::ClearBrightened(), EDA_ITEM::ClearEditFlags(), EDA_ITEM::ClearSelected(), EDA_ITEM::ClearTempFlags(), ConvertOutlineToPolygon(), 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(), KIGFX::SCH_PAINTER::draw(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), SCH_ITEM::Duplicate(), PCB_EDIT_FRAME::ExchangeFootprint(), PCB_SELECTION_TOOL::ExitGroup(), SYMBOL_EDIT_FRAME::GetSymbolFromRedoList(), SYMBOL_EDIT_FRAME::GetSymbolFromUndoList(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromLibrary(), EE_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::narrowSelection(), FOOTPRINT_EDITOR_CONTROL::NewFootprint(), FOOTPRINT_EDIT_FRAME::OpenProjectFiles(), PCB_BASE_FRAME::PlaceFootprint(), SYMBOL_EDITOR_PIN_TOOL::PlacePin(), BOARD_COMMIT::Push(), PCB_SELECTION_TOOL::RebuildSelection(), SCH_EDIT_TOOL::RepeatDrawItem(), SYMBOL_EDIT_FRAME::RollbackSymbolFromUndo(), SCH_EDIT_FRAME::SaveCopyForRepeatItem(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), SCH_SEXPR_PLUGIN_CACHE::savePin(), EE_SELECTION_TOOL::selectMultiple(), SCH_EDIT_FRAME::SelectUnit(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ ClearSelected()

◆ ClearTempFlags()

void EDA_ITEM::ClearTempFlags ( )
inlineinherited

Definition at line 165 of file eda_item.h.

166  {
168  DO_NOT_DRAW );
169  }
#define DO_NOT_DRAW
Used to disable draw function.
#define STARTPOINT
When a line is selected, these flags indicate which.
#define ENDPOINT
ends. (Used to support dragging.)
#define IS_LINKED
Used in calculation to mark linked items (temporary use)
#define CANDIDATE
flag indicating that the structure is connected
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:153
#define SKIP_STRUCT
flag indicating that the structure should be ignored
#define TEMP_SELECTED
flag indicating that the structure has already selected

References CANDIDATE, EDA_ITEM::ClearFlags(), DO_NOT_DRAW, ENDPOINT, IS_LINKED, SKIP_STRUCT, STARTPOINT, and TEMP_SELECTED.

Referenced by 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 74 of file sch_field.cpp.

75 {
76  return new SCH_FIELD( *this );
77 }
SCH_FIELD(const wxPoint &aPos, int aFieldId, SCH_ITEM *aParent, const wxString &aName=wxEmptyString)
Definition: sch_field.cpp:56

References SCH_FIELD().

◆ Compare()

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

Definition at line 659 of file eda_text.cpp.

660 {
661 #define EPSILON 2 // Should be enough for rounding errors on calculated items
662 
663 #define TEST( a, b ) { if( a != b ) return a - b; }
664 #define TEST_E( a, b ) { if( abs( a - b ) > EPSILON ) return a - b; }
665 #define TEST_PT( a, b ) { TEST_E( a.x, b.x ); TEST_E( a.y, b.y ); }
666 
667  TEST_PT( m_e.pos, aOther->m_e.pos );
668 
669  TEST_PT( m_e.size, aOther->m_e.size );
670  TEST_E( m_e.penwidth, aOther->m_e.penwidth );
671  TEST( m_e.angle, aOther->m_e.angle );
672 
673  TEST( m_e.hjustify, aOther->m_e.hjustify );
674  TEST( m_e.vjustify, aOther->m_e.vjustify );
675  TEST( m_e.bits, aOther->m_e.bits );
676 
677  return m_text.Cmp( aOther->m_text );
678 }
#define TEST(a, b)
TEXT_EFFECTS m_e
Definition: eda_text.h:415
signed char vjustify
vertical justification
Definition: eda_text.h:123
#define TEST_PT(a, b)
wxPoint pos
Definition: eda_text.h:127
wxSize size
Definition: eda_text.h:124
#define TEST_E(a, b)
wxString m_text
Definition: eda_text.h:411
int bits
any set of booleans a client uses.
Definition: eda_text.h:121
double angle
now: 0.1 degrees; future: degrees
Definition: eda_text.h:126
signed char hjustify
horizontal justification
Definition: eda_text.h:122
int penwidth
Definition: eda_text.h:125

References TEXT_EFFECTS::angle, TEXT_EFFECTS::bits, TEXT_EFFECTS::hjustify, EDA_TEXT::m_e, EDA_TEXT::m_text, TEXT_EFFECTS::penwidth, TEXT_EFFECTS::pos, TEXT_EFFECTS::size, TEST, TEST_E, TEST_PT, and TEXT_EFFECTS::vjustify.

◆ 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 177 of file sch_item.cpp.

178 {
179  return m_connected_items[ aSheet ];
180 }
std::unordered_map< SCH_SHEET_PATH, SCH_ITEM_SET > m_connected_items
Store pointers to other items that are connected to this one, per sheet.
Definition: sch_item.h:494

References SCH_ITEM::m_connected_items.

Referenced by addConnections(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), CONNECTION_GRAPH::updateItemConnectivity(), 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 138 of file sch_item.cpp.

139 {
140  if( !IsConnectable() )
141  return nullptr;
142 
143  wxCHECK_MSG( !IsConnectivityDirty(), nullptr,
144  wxT( "Shouldn't be asking for connection if connectivity is dirty!" ) );
145 
146  if( !aSheet )
147  aSheet = &Schematic()->CurrentSheet();
148 
149  auto it = m_connection_map.find( *aSheet );
150 
151  if( it == m_connection_map.end() )
152  return nullptr;
153  else
154  return it->second;
155 }
virtual bool IsConnectable() const
Definition: sch_item.h:349
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:104
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:497
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:121

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_PIN::GetMsgPanelInfo(), SCH_BUS_ENTRY_BASE::GetMsgPanelInfo(), SCH_LINE::GetMsgPanelInfo(), SCH_TEXT::GetMsgPanelInfo(), CONNECTION_SUBGRAPH::GetNetName(), SCH_ITEM::GetOrInitConnection(), highlightNet(), SCH_ITEM::InitializeConnection(), SCH_ITEM::NetClass(), SCH_TEXT::Plot(), SCH_GLOBALLABEL::Print(), SCH_HIERLABEL::Print(), SCH_EDIT_FRAME::RecalculateConnections(), CONNECTION_SUBGRAPH::ResolveDrivers(), 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_LINE, SCH_BUS_WIRE_ENTRY, and SCH_PIN.

Definition at line 411 of file sch_item.h.

411 { return true; }

Referenced by CONNECTION_GRAPH::updateItemConnectivity().

◆ CopyText()

void EDA_TEXT::CopyText ( const EDA_TEXT aSrc)
inherited

Definition at line 131 of file eda_text.cpp.

132 {
133  m_text = aSrc.m_text;
134  m_shown_text = aSrc.m_shown_text;
136 }
wxString m_shown_text
Definition: eda_text.h:412
bool m_shown_text_has_text_var_refs
Definition: eda_text.h:413
wxString m_text
Definition: eda_text.h:411

References EDA_TEXT::m_shown_text, EDA_TEXT::m_shown_text_has_text_var_refs, and EDA_TEXT::m_text.

Referenced by LIB_FIELD::Copy(), and CLIPBOARD_IO::SaveSelection().

◆ DoHypertextMenu()

void SCH_FIELD::DoHypertextMenu ( EDA_DRAW_FRAME aFrame)
overridevirtual

Reimplemented from SCH_ITEM.

Definition at line 612 of file sch_field.cpp.

613 {
614  constexpr int START_ID = 1;
615 
616  static wxString back = wxT( "HYPERTEXT_BACK" );
617  wxMenu menu;
618  SCH_TEXT* label = dynamic_cast<SCH_TEXT*>( m_parent );
619 
620  if( label && Schematic() )
621  {
622  auto it = Schematic()->GetPageRefsMap().find( label->GetText() );
623 
624  if( it != Schematic()->GetPageRefsMap().end() )
625  {
626  std::map<wxString, wxString> sheetNames;
627  std::vector<wxString> pageListCopy;
628 
629  pageListCopy.insert( pageListCopy.end(), it->second.begin(), it->second.end() );
631  {
632  wxString currentPage = Schematic()->CurrentSheet().GetPageNumber();
633  alg::delete_matching( pageListCopy, currentPage );
634 
635  if( pageListCopy.empty() )
636  return;
637  }
638 
639  std::sort( pageListCopy.begin(), pageListCopy.end(),
640  []( const wxString& a, const wxString& b ) -> bool
641  {
642  return StrNumCmp( a, b, true ) < 0;
643  } );
644 
645  for( const SCH_SHEET_PATH& sheet : Schematic()->GetSheets() )
646  {
647  if( sheet.size() == 1 )
648  sheetNames[ sheet.GetPageNumber() ] = _( "<root sheet>" );
649  else
650  sheetNames[ sheet.GetPageNumber() ] = sheet.Last()->GetName();
651  }
652 
653  for( int i = 0; i < (int) pageListCopy.size(); ++i )
654  {
655  menu.Append( i + START_ID, wxString::Format( _( "Go to Page %s (%s)" ),
656  pageListCopy[i],
657  sheetNames[ pageListCopy[i] ] ) );
658  }
659 
660  menu.AppendSeparator();
661  menu.Append( 999, _( "Back to Previous Selected Sheet" ) );
662 
663  int sel = aFrame->GetPopupMenuSelectionFromUser( menu ) - START_ID;
664  void* param = nullptr;
665 
666  if( sel >= 0 && sel < (int) pageListCopy.size() )
667  param = (void*) &pageListCopy[ sel ];
668  else if( sel == 999 )
669  param = (void*) &back;
670 
671  if( param )
672  aFrame->GetToolManager()->RunAction( EE_ACTIONS::hypertextCommand, true, param );
673  }
674  }
675 }
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:478
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:167
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:104
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
wxString GetPageNumber() const
#define _(s)
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
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
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:87
std::map< wxString, std::set< wxString > > & GetPageRefsMap()
Definition: schematic.h:162
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
void delete_matching(_Container &__c, _Value __value)
Covers for the horrifically named std::remove and std::remove_if (neither of which remove anything).
Definition: kicad_algo.h:164
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:121
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:154
static TOOL_ACTION hypertextCommand
Definition: ee_actions.h:188

References _, SCHEMATIC::CurrentSheet(), alg::delete_matching(), Format(), SCH_SHEET_PATH::GetPageNumber(), SCHEMATIC::GetPageRefsMap(), SCHEMATIC::GetSheets(), EDA_TEXT::GetText(), TOOLS_HOLDER::GetToolManager(), EE_ACTIONS::hypertextCommand, SCHEMATIC_SETTINGS::m_IntersheetRefsListOwnPage, EDA_ITEM::m_parent, TOOL_MANAGER::RunAction(), SCH_ITEM::Schematic(), SCHEMATIC::Settings(), and StrNumCmp().

◆ 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 85 of file sch_item.cpp.

86 {
87  SCH_ITEM* newItem = (SCH_ITEM*) Clone();
88 
89  if( !doClone )
90  const_cast<KIID&>( newItem->m_Uuid ) = KIID();
91 
92  newItem->ClearFlags( SELECTED | BRIGHTENED );
93 
94  newItem->RunOnChildren(
95  []( SCH_ITEM* aChild )
96  {
97  aChild->ClearFlags( SELECTED | BRIGHTENED );
98  } );
99 
100  return newItem;
101 }
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:83
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction)
Definition: sch_item.h:444
Definition: kiid.h:44
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:153
#define SELECTED
const KIID m_Uuid
Definition: eda_item.h:474
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
#define BRIGHTENED
item is drawn with a bright contour

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

Referenced by SCH_EDIT_FRAME::BreakSegment(), 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 ( )
inlineinherited

Definition at line 275 of file eda_text.h.

275 { m_text.Empty(); }
wxString m_text
Definition: eda_text.h:411

References EDA_TEXT::m_text.

Referenced by SCH_LEGACY_PLUGIN_CACHE::LoadPart().

◆ 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 539 of file eda_text.cpp.

540 {
541 #ifndef GERBVIEW // Gerbview does not use EDA_TEXT::Format
542  // and does not define FormatInternalUnits, used here
543  // however this function should exist
544 
545  aFormatter->Print( aNestLevel + 1, "(effects" );
546 
547  // Text size
548  aFormatter->Print( 0, " (font" );
549 
550  aFormatter->Print( 0, " (size %s %s)",
551  FormatInternalUnits( GetTextHeight() ).c_str(),
552  FormatInternalUnits( GetTextWidth() ).c_str() );
553 
554  if( GetTextThickness() )
555  {
556  aFormatter->Print( 0, " (thickness %s)",
557  FormatInternalUnits( GetTextThickness() ).c_str() );
558  }
559 
560  if( IsBold() )
561  aFormatter->Print( 0, " bold" );
562 
563  if( IsItalic() )
564  aFormatter->Print( 0, " italic" );
565 
566  aFormatter->Print( 0, ")"); // (font
567 
570  {
571  aFormatter->Print( 0, " (justify");
572 
574  aFormatter->Print( 0, GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT ? " left" : " right" );
575 
577  aFormatter->Print( 0, GetVertJustify() == GR_TEXT_VJUSTIFY_TOP ? " top" : " bottom" );
578 
579  if( IsMirrored() )
580  aFormatter->Print( 0, " mirror" );
581 
582  aFormatter->Print( 0, ")" ); // (justify
583  }
584 
585  if( !(aControlBits & CTL_OMIT_HIDE) && !IsVisible() )
586  aFormatter->Print( 0, " hide" );
587 
588  aFormatter->Print( 0, ")\n" ); // (justify
589 
590 #endif
591 }
bool IsBold() const
Definition: eda_text.h:204
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:220
bool IsMirrored() const
Definition: eda_text.h:210
int GetTextThickness() const
Definition: eda_text.h:181
int GetTextHeight() const
Definition: eda_text.h:265
bool IsItalic() const
Definition: eda_text.h:201
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:219
virtual bool IsVisible() const
Definition: eda_text.h:207
int GetTextWidth() const
Definition: eda_text.h:262
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:426
#define CTL_OMIT_HIDE
Definition: eda_text.h:77
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:480

References CTL_OMIT_HIDE, FormatInternalUnits(), EDA_TEXT::GetHorizJustify(), EDA_TEXT::GetTextHeight(), EDA_TEXT::GetTextThickness(), EDA_TEXT::GetTextWidth(), EDA_TEXT::GetVertJustify(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, EDA_TEXT::IsBold(), EDA_TEXT::IsItalic(), EDA_TEXT::IsMirrored(), EDA_TEXT::IsVisible(), and OUTPUTFORMATTER::Print().

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

◆ Get() [1/3]

wxAny INSPECTABLE::Get ( PROPERTY_BASE aProperty)
inlineinherited

Definition at line 86 of file inspectable.h.

87  {
89  TYPE_ID thisType = TYPE_HASH( *this );
90  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
91  return object ? aProperty->getter( object ) : wxAny();
92  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:65
#define TYPE_HASH(x)
Definition: property.h:59
size_t TYPE_ID
Unique type identifier.
Definition: property_mgr.h:42
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Cast a type to another type.
virtual wxAny getter(void *aObject) const =0
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:62
virtual size_t OwnerHash() const =0
Return type-id of the Owner class.

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(), PCB_EXPR_VAR_REF::GetValue(), and PAD_DESC::PAD_DESC().

◆ Get() [2/3]

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

Definition at line 95 of file inspectable.h.

96  {
98  TYPE_ID thisType = TYPE_HASH( *this );
99  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
100  return object ? aProperty->get<T>( object ) : T();
101  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:65
#define TYPE_HASH(x)
Definition: property.h:59
size_t TYPE_ID
Unique type identifier.
Definition: property_mgr.h:42
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Cast a type to another type.
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:62
T get(void *aObject)
Definition: property.h:268
virtual size_t OwnerHash() const =0
Return type-id of the Owner class.

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

◆ Get() [3/3]

template<typename T >
boost::optional<T> INSPECTABLE::Get ( const wxString &  aProperty)
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  boost::optional<T> ret = T();
110 
111  if( prop )
112  {
113  void* object = propMgr.TypeCast( this, thisType, prop->OwnerHash() );
114 
115  if( object )
116  ret = prop->get<T>( object );
117  }
118 
119  return ret;
120  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:65
#define TYPE_HASH(x)
Definition: property.h:59
size_t TYPE_ID
Unique type identifier.
Definition: property_mgr.h:42
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Cast a type to another type.
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Return a property for a specific type.
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:62
T get(void *aObject)
Definition: property.h:268
virtual size_t OwnerHash() const =0
Return type-id of the Owner class.

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

◆ GetBoundingBox()

const EDA_RECT 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 305 of file sch_field.cpp.

306 {
307  // Calculate the text bounding box:
308  EDA_RECT rect = GetTextBox();
309 
310  // Calculate the bounding box position relative to the parent:
311  wxPoint origin = GetParentPosition();
312  wxPoint pos = GetTextPos() - origin;
313  wxPoint begin = rect.GetOrigin() - origin;
314  wxPoint end = rect.GetEnd() - origin;
315  RotatePoint( &begin, pos, GetTextAngle() );
316  RotatePoint( &end, pos, GetTextAngle() );
317 
318  // Now, apply the symbol transform (mirror/rot)
319  TRANSFORM transform;
320 
321  if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
322  {
323  SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
324 
325  // Due to the Y axis direction, we must mirror the bounding box,
326  // relative to the text position:
327  MIRROR( begin.y, pos.y );
328  MIRROR( end.y, pos.y );
329 
330  transform = parentSymbol->GetTransform();
331  }
332  else
333  {
334  transform = TRANSFORM( 1, 0, 0, 1 ); // identity transform
335  }
336 
337  rect.SetOrigin( transform.TransformCoordinate( begin ) );
338  rect.SetEnd( transform.TransformCoordinate( end ) );
339 
340  rect.Move( origin );
341  rect.Normalize();
342 
343  return rect;
344 }
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:478
void Move(const wxPoint &aMoveVector)
Move the rectangle by the aMoveVector.
Definition: eda_rect.cpp:51
EDA_RECT 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:239
double GetTextAngle() const
Definition: eda_text.h:195
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:130
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
TRANSFORM & GetTransform()
Definition: sch_symbol.h:232
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:42
void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Definition: mirror.h:40
const wxPoint GetEnd() const
Definition: eda_rect.h:112
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
const wxPoint GetOrigin() const
Definition: eda_rect.h:110
void SetEnd(int x, int y)
Definition: eda_rect.h:191
void Normalize()
Ensures that the height ant width are positive.
Definition: eda_rect.cpp:35
Schematic symbol object.
Definition: sch_symbol.h:78
Handle the component boundary box.
Definition: eda_rect.h:42
const wxPoint & GetTextPos() const
Definition: eda_text.h:268
wxPoint GetParentPosition() const
Definition: sch_field.cpp:858
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References EDA_RECT::GetEnd(), EDA_RECT::GetOrigin(), GetParentPosition(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextBox(), EDA_TEXT::GetTextPos(), SCH_SYMBOL::GetTransform(), EDA_ITEM::m_parent, MIRROR(), EDA_RECT::Move(), EDA_RECT::Normalize(), RotatePoint(), SCH_SYMBOL_T, EDA_RECT::SetEnd(), EDA_RECT::SetOrigin(), TRANSFORM::TransformCoordinate(), and EDA_ITEM::Type().

Referenced by KIGFX::SCH_PAINTER::draw(), AUTOPLACER::fieldVPlacement(), SCH_GLOBALLABEL::GetBoundingBox(), GetDrawPos(), HitTest(), SCH_GLOBALLABEL::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 696 of file sch_field.cpp.

697 {
698  if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
699  {
700  switch( m_id )
701  {
702  case REFERENCE_FIELD: return wxT( "Reference" );
703  case VALUE_FIELD: return wxT( "Value" );
704  case FOOTPRINT_FIELD: return wxT( "Footprint" );
705  case DATASHEET_FIELD: return wxT( "Datasheet" );
706  }
707  }
708  else if( m_parent && m_parent->Type() == SCH_SHEET_T )
709  {
710  switch( m_id )
711  {
712  case SHEETNAME: return wxT( "Sheetname" );
713  case SHEETFILENAME: return wxT( "Sheetfile" );
714  }
715  }
716  else if( m_parent && m_parent->Type() == SCH_GLOBAL_LABEL_T )
717  {
718  return wxT( "Intersheet References" );
719  }
720 
721  return m_name;
722 }
Field Reference of part, i.e. "IC21".
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:478
wxString m_name
Definition: sch_field.h:222
name of datasheet
Field Value of part, i.e. "3.3K".
int m_id
Field index,.
Definition: sch_field.h:220
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
Field Name Module PCB, i.e. "16DIP300".

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

Referenced by DIALOG_CHANGE_SYMBOLS::processSymbol(), and SCH_SYMBOL::UpdateFields().

◆ GetClass()

wxString SCH_FIELD::GetClass ( ) const
inlineoverridevirtual

Return the class name.

Reimplemented from SCH_ITEM.

Definition at line 64 of file sch_field.h.

65  {
66  return wxT( "SCH_FIELD" );
67  }

◆ GetConnectionPoints()

virtual std::vector<wxPoint> 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_SYMBOL, SCH_SHEET, SCH_TEXT, SCH_LINE, SCH_BUS_ENTRY_BASE, SCH_NO_CONNECT, and SCH_JUNCTION.

Definition at line 364 of file sch_item.h.

364 { return {}; }

Referenced by SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), SCH_LINE_WIRE_BUS_TOOL::AddJunctionsIfNeeded(), EE_GRID_HELPER::computeAnchors(), SCH_EDIT_TOOL::DoDelete(), SCH_MOVE_TOOL::Main(), and SCH_LINE_WIRE_BUS_TOOL::TrimOverLappingWires().

◆ GetDrawHorizJustify()

EDA_TEXT_HJUSTIFY_T SCH_FIELD::GetDrawHorizJustify ( ) const
overridevirtual

Reimplemented from EDA_TEXT.

Definition at line 293 of file sch_field.cpp.

294 {
296 }

References GR_TEXT_HJUSTIFY_CENTER.

◆ GetDrawPos()

wxPoint SCH_FIELD::GetDrawPos ( ) const
overridevirtual

Reimplemented from EDA_TEXT.

Definition at line 287 of file sch_field.cpp.

288 {
289  return GetBoundingBox().Centre();
290 }
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_field.cpp:305
wxPoint Centre() const
Definition: eda_rect.h:64

References EDA_RECT::Centre(), and GetBoundingBox().

◆ GetDrawRotation()

double 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 265 of file sch_field.cpp.

266 {
267  // Calculate the text orientation according to the symbol orientation.
268  int orient = GetTextAngle();
269 
270  if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
271  {
272  SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
273 
274  if( parentSymbol && parentSymbol->GetTransform().y1 ) // Rotate symbol 90 degrees.
275  {
276  if( orient == TEXT_ANGLE_HORIZ )
277  orient = TEXT_ANGLE_VERT;
278  else
279  orient = TEXT_ANGLE_HORIZ;
280  }
281  }
282 
283  return orient;
284 }
#define TEXT_ANGLE_HORIZ
Frequent text rotations, used with {Set,Get}TextAngle(), in 0.1 degrees for now, hoping to migrate to...
Definition: eda_text.h:71
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:478
double GetTextAngle() const
Definition: eda_text.h:195
TRANSFORM & GetTransform()
Definition: sch_symbol.h:232
int y1
Definition: transform.h:49
Schematic symbol object.
Definition: sch_symbol.h:78
#define TEXT_ANGLE_VERT
Definition: eda_text.h:72
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References EDA_TEXT::GetTextAngle(), SCH_SYMBOL::GetTransform(), EDA_ITEM::m_parent, SCH_SYMBOL_T, TEXT_ANGLE_HORIZ, TEXT_ANGLE_VERT, EDA_ITEM::Type(), and TRANSFORM::y1.

Referenced by IsHorizJustifyFlipped(), and IsVertJustifyFlipped().

◆ GetDrawVertJustify()

EDA_TEXT_VJUSTIFY_T SCH_FIELD::GetDrawVertJustify ( ) const
overridevirtual

Reimplemented from EDA_TEXT.

Definition at line 299 of file sch_field.cpp.

300 {
302 }

References GR_TEXT_VJUSTIFY_CENTER.

◆ GetEditFlags()

EDA_ITEM_FLAGS EDA_ITEM::GetEditFlags ( ) const
inlineinherited

Definition at line 157 of file eda_item.h.

158  {
159  constexpr int mask = ( IS_NEW | IS_PASTED | IS_MOVING | IS_RESIZING | IS_DRAGGING
161 
162  return m_flags & mask;
163  }
#define IS_NEW
New item, just created.
#define IS_RESIZING
Item being resized.
#define IS_DRAGGING
Item being dragged.
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
#define IS_MOVING
Item being moved.
#define STRUCT_DELETED
flag indication structures to be erased
#define IS_WIRE_IMAGE
Item to be drawn as wireframe while editing.

References IS_DRAGGING, IS_MOVING, IS_NEW, IS_PASTED, IS_RESIZING, IS_WIRE_IMAGE, EDA_ITEM::m_flags, and STRUCT_DELETED.

Referenced by 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_TOOL::Properties(), PAD_TOOL::recombinePad(), SCH_EDIT_FRAME::SchematicCleanUp(), SCH_EDIT_FRAME::SelectUnit(), DIALOG_DIMENSION_PROPERTIES::TransferDataFromWindow(), DIALOG_TARGET_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_AND_LABEL_PROPERTIES::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow(), and DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow().

◆ GetEffectiveHorizJustify()

EDA_TEXT_HJUSTIFY_T SCH_FIELD::GetEffectiveHorizJustify ( ) const

Definition at line 370 of file sch_field.cpp.

371 {
372  switch( GetHorizJustify() )
373  {
378  default:
380  }
381 }
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:219
bool IsHorizJustifyFlipped() const
Return whether the field will be rendered with the horizontal justification inverted due to rotation ...
Definition: sch_field.cpp:347

References EDA_TEXT::GetHorizJustify(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, and IsHorizJustifyFlipped().

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

◆ GetEffectiveTextPenWidth()

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

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

Definition at line 159 of file eda_text.cpp.

160 {
161  int width = GetTextThickness();
162 
163  if( width <= 1 )
164  {
165  width = aDefaultWidth;
166 
167  if( IsBold() )
168  width = GetPenSizeForBold( GetTextWidth() );
169  else if( width <= 1 )
170  width = GetPenSizeForNormal( GetTextWidth() );
171  }
172 
173  // Clip pen size for small texts:
175 
176  return width;
177 }
bool IsBold() const
Definition: eda_text.h:204
int GetPenSizeForBold(int aTextSize)
Definition: gr_text.cpp:46
int GetTextThickness() const
Definition: eda_text.h:181
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aBold)
Don't allow text to become cluttered up in its own fatness.
Definition: gr_text.cpp:67
const wxSize & GetTextSize() const
Definition: eda_text.h:259
int GetPenSizeForNormal(int aTextSize)
Definition: gr_text.cpp:52
#define ALLOW_BOLD_THICKNESS
Definition: base_units.h:56
int GetTextWidth() const
Definition: eda_text.h:262

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

Referenced by BOARD_ADAPTER::addShapeWithClearance(), KIGFX::DS_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), SCH_HIERLABEL::GetBoundingBox(), SCH_GLOBALLABEL::GetBoundingBoxBase(), EDA_TEXT::GetEffectiveTextShape(), LIB_TEXT::GetPenWidth(), LIB_FIELD::GetPenWidth(), GetPenWidth(), SCH_TEXT::GetPenWidth(), EDA_TEXT::GetTextBox(), KIGFX::SCH_PAINTER::getTextThickness(), LIB_TEXT::Plot(), Plot(), SCH_TEXT::Plot(), BRDITEMS_PLOTTER::PlotFootprintTextItem(), BRDITEMS_PLOTTER::PlotPcbText(), LIB_TEXT::print(), Print(), EDA_TEXT::printOneLineOfText(), PNS_KICAD_IFACE_BASE::syncTextItem(), PCB_TEXT::TransformTextShapeWithClearanceToPolygon(), FP_TEXT::TransformTextShapeWithClearanceToPolygon(), PCB_DIM_LEADER::updateGeometry(), PCB_DIM_ALIGNED::updateText(), and PCB_DIM_ORTHOGONAL::updateText().

◆ GetEffectiveTextShape()

std::shared_ptr< SHAPE_COMPOUND > EDA_TEXT::GetEffectiveTextShape ( ) const
inherited

Definition at line 646 of file eda_text.cpp.

647 {
648  std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
649  int penWidth = GetEffectiveTextPenWidth();
650  std::vector<wxPoint> pts = TransformToSegmentList();
651 
652  for( unsigned jj = 0; jj < pts.size(); jj += 2 )
653  shape->AddShape( new SHAPE_SEGMENT( pts[jj], pts[jj+1], penWidth ) );
654 
655  return shape;
656 }
std::vector< wxPoint > TransformToSegmentList() const
Convert the text shape to a list of segment.
Definition: eda_text.cpp:606
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:159

References EDA_TEXT::GetEffectiveTextPenWidth(), and EDA_TEXT::TransformToSegmentList().

Referenced by PCB_TEXT::GetEffectiveShape(), and FP_TEXT::GetEffectiveShape().

◆ 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_SYMBOL, SCH_SHEET, SCH_TEXT, SCH_BUS_BUS_ENTRY, SCH_LINE, SCH_SHEET_PIN, SCH_BUS_WIRE_ENTRY, SCH_JUNCTION, and SCH_NO_CONNECT.

Definition at line 318 of file sch_item.h.

318 {}

Referenced by PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems().

◆ 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; }
FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:489

References SCH_ITEM::m_fieldsAutoplaced.

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

◆ GetFlags()

◆ GetFocusPosition()

virtual const wxPoint EDA_ITEM::GetFocusPosition ( ) const
inlinevirtualinherited

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

Reimplemented in BOARD, PCB_TRACK, and PCB_SHAPE.

Definition at line 258 of file eda_item.h.

258 { return GetPosition(); }
virtual wxPoint GetPosition() const
Definition: eda_item.h:251

References EDA_ITEM::GetPosition().

Referenced by SCH_EDIT_FRAME::FocusOnItem().

◆ GetHorizJustify()

EDA_TEXT_HJUSTIFY_T EDA_TEXT::GetHorizJustify ( ) const
inlineinherited

Definition at line 219 of file eda_text.h.

219 { return EDA_TEXT_HJUSTIFY_T( m_e.hjustify ); };
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:82
TEXT_EFFECTS m_e
Definition: eda_text.h:415
signed char hjustify
horizontal justification
Definition: eda_text.h:122

References TEXT_EFFECTS::hjustify, and EDA_TEXT::m_e.

Referenced by BOARD_ADAPTER::addShapeWithClearance(), DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES(), EDA_TEXT_DESC::EDA_TEXT_DESC(), AUTOPLACER::fieldHPlacement(), EDA_TEXT::Format(), EDA_TEXT::GetDrawHorizJustify(), GetEffectiveHorizJustify(), LIB_TEXT::GetMsgPanelInfo(), LIB_FIELD::GetMsgPanelInfo(), GetMsgPanelInfo(), EDA_TEXT::GetTextBox(), EDA_TEXT::IsDefaultFormatting(), IsHorizJustifyFlipped(), FP_TEXT::KeepUpright(), SCH_EAGLE_PLUGIN::loadFieldAttributes(), LEGACY_PLUGIN::loadPCB_TEXT(), SCH_EDIT_TOOL::Mirror(), LIB_TEXT::MirrorHorizontal(), SCH_GLOBALLABEL::MirrorHorizontally(), SCH_GLOBALLABEL::MirrorSpinStyle(), LIB_TEXT::MirrorVertical(), LIB_TEXT::NormalizeJustification(), SCH_TEXT::Plot(), BRDITEMS_PLOTTER::PlotFootprintTextItem(), BRDITEMS_PLOTTER::PlotPcbText(), positioningChanged(), LIB_FIELD::print(), EDA_TEXT::printOneLineOfText(), LIB_TEXT::Rotate(), SCH_GLOBALLABEL::Rotate90(), SCH_LEGACY_PLUGIN::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveText(), KIGFX::GAL::SetTextAttributes(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), PCB_TEXT::TransformTextShapeWithClearanceToPolygon(), and FP_TEXT::TransformTextShapeWithClearanceToPolygon().

◆ 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 233 of file eda_text.cpp.

234 {
236 }
static double GetInterline(double aGlyphHeight)
Compute the distance (interline) between 2 lines of text (for multiline texts).
int GetTextHeight() const
Definition: eda_text.h:265
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:73

References KIGFX::STROKE_FONT::GetInterline(), EDA_TEXT::GetTextHeight(), and KiROUND().

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

◆ GetLayer()

SCH_LAYER_ID SCH_ITEM::GetLayer ( ) const
inlineinherited

◆ GetLibPosition()

wxPoint SCH_FIELD::GetLibPosition ( ) const
inline

Definition at line 199 of file sch_field.h.

199 { return EDA_TEXT::GetTextPos(); }
const wxPoint & GetTextPos() const
Definition: eda_text.h:268

References EDA_TEXT::GetTextPos().

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

◆ GetLinePositions()

void EDA_TEXT::GetLinePositions ( std::vector< wxPoint > &  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 wxPoint positions.
aLineCountis the number of lines (not recalculated here for efficiency reasons.

Definition at line 443 of file eda_text.cpp.

444 {
445  wxPoint pos = GetTextPos(); // Position of first line of the
446  // multiline text according to
447  // the center of the multiline text block
448 
449  wxPoint offset; // Offset to next line.
450 
451  offset.y = GetInterline();
452 
453  if( aLineCount > 1 )
454  {
455  switch( GetVertJustify() )
456  {
458  break;
459 
461  pos.y -= ( aLineCount - 1 ) * offset.y / 2;
462  break;
463 
465  pos.y -= ( aLineCount - 1 ) * offset.y;
466  break;
467  }
468  }
469 
470  // Rotate the position of the first line
471  // around the center of the multiline text block
472  RotatePoint( &pos, GetTextPos(), GetTextAngle() );
473 
474  // Rotate the offset lines to increase happened in the right direction
475  RotatePoint( &offset, GetTextAngle() );
476 
477  for( int ii = 0; ii < aLineCount; ii++ )
478  {
479  aPositions.push_back( pos );
480  pos += offset;
481  }
482 }
int GetInterline() const
Return the distance between two lines of text.
Definition: eda_text.cpp:233
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:220
double GetTextAngle() const
Definition: eda_text.h:195
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
const wxPoint & GetTextPos() const
Definition: eda_text.h:268

References EDA_TEXT::GetInterline(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextPos(), EDA_TEXT::GetVertJustify(), GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, and RotatePoint().

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

◆ 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 725 of file sch_field.cpp.

726 {
727  if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
728  {
729  switch( m_id )
730  {
734  default: return BITMAPS::text;
735  }
736  }
737 
738  return BITMAPS::text;
739 }
Field Reference of part, i.e. "IC21".
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:478
Field Value of part, i.e. "3.3K".
int m_id
Field index,.
Definition: sch_field.h:220
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
Field Name Module PCB, i.e. "16DIP300".

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 576 of file sch_field.cpp.

577 {
578  wxString msg;
579 
580  aList.emplace_back( _( "Symbol Field" ), GetName() );
581 
582  // Don't use GetShownText() here; we want to show the user the variable references
583  aList.emplace_back( _( "Text" ), UnescapeString( GetText() ) );
584 
585  aList.emplace_back( _( "Visible" ), IsVisible() ? _( "Yes" ) : _( "No" ) );
586 
587  aList.emplace_back( _( "Style" ), GetTextStyleName() );
588 
589  aList.emplace_back( _( "Text Size" ), MessageTextFromValue( aFrame->GetUserUnits(),
590  GetTextWidth() ) );
591 
592  switch ( GetHorizJustify() )
593  {
594  case GR_TEXT_HJUSTIFY_LEFT: msg = _( "Left" ); break;
595  case GR_TEXT_HJUSTIFY_CENTER: msg = _( "Center" ); break;
596  case GR_TEXT_HJUSTIFY_RIGHT: msg = _( "Right" ); break;
597  }
598 
599  aList.emplace_back( _( "H Justification" ), msg );
600 
601  switch ( GetVertJustify() )
602  {
603  case GR_TEXT_VJUSTIFY_TOP: msg = _( "Top" ); break;
604  case GR_TEXT_VJUSTIFY_CENTER: msg = _( "Center" ); break;
605  case GR_TEXT_VJUSTIFY_BOTTOM: msg = _( "Bottom" ); break;
606  }
607 
608  aList.emplace_back( _( "V Justification" ), msg );
609 }
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
Definition: base_units.cpp:104
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:220
wxString GetTextStyleName() const
Definition: eda_text.cpp:504
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:219
virtual bool IsVisible() const
Definition: eda_text.h:207
#define _(s)
wxString UnescapeString(const wxString &aSource)
int GetTextWidth() const
Definition: eda_text.h:262
wxString GetName(bool aUseDefaultName=true) const
Return the field name.
Definition: sch_field.cpp:678
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:154
EDA_UNITS GetUserUnits() const
Return the user units currently in use.

References _, EDA_TEXT::GetHorizJustify(), GetName(), EDA_TEXT::GetText(), EDA_TEXT::GetTextStyleName(), EDA_TEXT::GetTextWidth(), EDA_BASE_FRAME::GetUserUnits(), EDA_TEXT::GetVertJustify(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, EDA_TEXT::IsVisible(), MessageTextFromValue(), and UnescapeString().

◆ GetName()

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

Return the field name.

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 678 of file sch_field.cpp.

679 {
680  if( !m_name.IsEmpty() )
681  return m_name;
682  else if( aUseDefaultName )
683  {
684  if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
686  else if( m_parent && m_parent->Type() == SCH_SHEET_T )
688  else if( m_parent && m_parent->Type() == SCH_GLOBAL_LABEL_T )
689  return _( "Intersheet References" );
690  }
691 
692  return wxEmptyString;
693 }
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:478
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslated=true)
Definition: sch_sheet.cpp:53
wxString m_name
Definition: sch_field.h:222
#define _(s)
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslate=true)
Return a default symbol field name for field aFieldNdx for all components.
int m_id
Field index,.
Definition: sch_field.h:220
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References _, TEMPLATE_FIELDNAME::GetDefaultFieldName(), SCH_SHEET::GetDefaultFieldName(), m_id, m_name, EDA_ITEM::m_parent, SCH_GLOBAL_LABEL_T, SCH_SHEET_T, SCH_SYMBOL_T, and EDA_ITEM::Type().

Referenced by NETLIST_EXPORTER_XML::addSymbolFields(), DIALOG_SCH_FIELD_PROPERTIES::DIALOG_SCH_FIELD_PROPERTIES(), SCH_EDIT_TOOL::editFieldText(), GetMsgPanelInfo(), GetSelectMenuText(), CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances(), SYMBOL_EDIT_FRAME::LoadSymbolFromSchematic(), operator<(), DIALOG_CHANGE_SYMBOLS::processSymbol(), SCH_SEXPR_PLUGIN::saveField(), SCH_LEGACY_PLUGIN::saveField(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_SPICE_MODEL::TransferDataFromWindow(), 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 218 of file sch_item.cpp.

220 {
221  if( !IsConnectable() )
222  return nullptr;
223 
224  SetConnectivityDirty( false );
225 
226  SCH_CONNECTION* connection = Connection( &aSheet );
227 
228  if( connection )
229  return connection;
230  else
231  return InitializeConnection( aSheet, aGraph );
232 }
virtual bool IsConnectable() const
Definition: sch_item.h:349
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:138
SCH_CONNECTION * InitializeConnection(const SCH_SHEET_PATH &aPath, CONNECTION_GRAPH *aGraph)
Create a new connection object associated with this object.
Definition: sch_item.cpp:195
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
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()

wxPoint SCH_FIELD::GetParentPosition ( ) const

Definition at line 858 of file sch_field.cpp.

859 {
860  return m_parent ? m_parent->GetPosition() : wxPoint( 0, 0 );
861 }
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:478
virtual wxPoint GetPosition() const
Definition: eda_item.h:251

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 196 of file sch_field.cpp.

197 {
198  return GetEffectiveTextPenWidth();
199 }
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:159

References EDA_TEXT::GetEffectiveTextPenWidth().

◆ GetPosition()

wxPoint SCH_FIELD::GetPosition ( ) const
overridevirtual

Reimplemented from EDA_ITEM.

Definition at line 842 of file sch_field.cpp.

843 {
844  if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
845  {
846  SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
847  wxPoint relativePos = GetTextPos() - parentSymbol->GetPosition();
848 
849  relativePos = parentSymbol->GetTransform().TransformCoordinate( relativePos );
850 
851  return relativePos + parentSymbol->GetPosition();
852  }
853 
854  return GetTextPos();
855 }
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:478
TRANSFORM & GetTransform()
Definition: sch_symbol.h:232
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:42
Schematic symbol object.
Definition: sch_symbol.h:78
wxPoint GetPosition() const override
Definition: sch_symbol.h:645
const wxPoint & GetTextPos() const
Definition: eda_text.h:268
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References SCH_SYMBOL::GetPosition(), EDA_TEXT::GetTextPos(), SCH_SYMBOL::GetTransform(), EDA_ITEM::m_parent, SCH_SYMBOL_T, TRANSFORM::TransformCoordinate(), and EDA_ITEM::Type().

Referenced by DIALOG_SCH_FIELD_PROPERTIES::DIALOG_SCH_FIELD_PROPERTIES(), IsHorizJustifyFlipped(), IsVertJustifyFlipped(), SYMBOL_EDIT_FRAME::LoadSymbolFromSchematic(), positioningChanged(), DIALOG_CHANGE_SYMBOLS::processSymbol(), Rotate(), SCH_SEXPR_PLUGIN::saveField(), and DIALOG_SCH_FIELD_PROPERTIES::UpdateField().

◆ GetSelectMenuText()

wxString SCH_FIELD::GetSelectMenuText ( EDA_UNITS  aUnits) const
overridevirtual

Return the text to display to be used in the selection clarification context menu when multiple items are found at the current cursor position.

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 570 of file sch_field.cpp.

571 {
572  return wxString::Format( wxT( "%s '%s'" ), GetName(), ShortenedShownText() );
573 }
wxString ShortenedShownText() const
Returns a shortened version (max 15 characters) of the shown text.
Definition: eda_text.cpp:218
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
wxString GetName(bool aUseDefaultName=true) const
Return the field name.
Definition: sch_field.cpp:678

References Format(), GetName(), and EDA_TEXT::ShortenedShownText().

Referenced by Matches().

◆ GetShownText()

wxString SCH_FIELD::GetShownText ( int  aDepth = 0) 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.

Reimplemented from EDA_TEXT.

Definition at line 105 of file sch_field.cpp.

106 {
107  std::function<bool( wxString* )> symbolResolver =
108  [&]( wxString* token ) -> bool
109  {
110  if( token->Contains( ':' ) )
111  {
112  if( Schematic()->ResolveCrossReference( token, aDepth ) )
113  return true;
114  }
115  else
116  {
117  SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
118 
119  if( parentSymbol->ResolveTextVar( token, aDepth + 1 ) )
120  return true;
121 
122  SCHEMATIC* schematic = parentSymbol->Schematic();
123  SCH_SHEET* sheet = schematic ? schematic->CurrentSheet().Last() : nullptr;
124 
125  if( sheet && sheet->ResolveTextVar( token, aDepth + 1 ) )
126  return true;
127  }
128 
129  return false;
130  };
131 
132  std::function<bool( wxString* )> sheetResolver =
133  [&]( wxString* token ) -> bool
134  {
135  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( m_parent );
136  return sheet->ResolveTextVar( token, aDepth + 1 );
137  };
138 
139  std::function<bool( wxString* )> globalLabelResolver =
140  [&]( wxString* token ) -> bool
141  {
142  SCH_GLOBALLABEL* globalLabel = static_cast<SCH_GLOBALLABEL*>( m_parent );
143  return globalLabel->ResolveTextVar( token, aDepth + 1 );
144  };
145 
146  PROJECT* project = nullptr;
147  wxString text = EDA_TEXT::GetShownText();
148 
149  if( text == wxT( "~" ) ) // Legacy placeholder for empty string
150  {
151  text = "";
152  }
153  else if( HasTextVars() )
154  {
155  if( Schematic() )
156  project = &Schematic()->Prj();
157 
158  if( aDepth < 10 )
159  {
160  if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
161  text = ExpandTextVars( text, &symbolResolver, nullptr, project );
162  else if( m_parent && m_parent->Type() == SCH_SHEET_T )
163  text = ExpandTextVars( text, &sheetResolver, nullptr, project );
164  else if( m_parent && m_parent->Type() == SCH_GLOBAL_LABEL_T )
165  text = ExpandTextVars( text, &globalLabelResolver, nullptr, project );
166  else
168  }
169  }
170 
171  // WARNING: the IDs of FIELDS and SHEETS overlap, so one must check *both* the
172  // id and the parent's type.
173 
174  if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
175  {
176  SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
177 
178  if( m_id == REFERENCE_FIELD )
179  {
180  // For more than one part per package, we must add the part selection
181  // A, B, ... or 1, 2, .. to the reference.
182  if( parentSymbol->GetUnitCount() > 1 )
183  text << LIB_SYMBOL::SubReference( parentSymbol->GetUnit() );
184  }
185  }
186  else if( m_parent && m_parent->Type() == SCH_SHEET_T )
187  {
188  if( m_id == SHEETFILENAME )
189  text = _( "File:" ) + wxS( " " )+ text;
190  }
191 
192  return text;
193 }
Field Reference of part, i.e. "IC21".
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:478
Container for project specific data.
Definition: project.h:62
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject)
Definition: common.cpp:57
Holds all the data relating to one schematic.
Definition: schematic.h:59
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
int GetUnitCount() const
Return the number of units per package of the symbol.
Definition: sch_symbol.cpp:393
bool ResolveTextVar(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the symbol.
Definition: sch_symbol.cpp:972
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:104
static wxString SubReference(int aUnit, bool aAddSeparator=true)
Definition: lib_symbol.cpp:495
bool ResolveTextVar(wxString *token, int aDepth) const
Definition: sch_text.cpp:1259
bool HasTextVars() const
Indicates the ShownText has text var references which need to be processed.
Definition: eda_text.h:172
bool ResolveCrossReference(wxString *token, int aDepth) const
Resolves text vars that refer to other items.
Definition: schematic.cpp:255
#define _(s)
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:75
Schematic symbol object.
Definition: sch_symbol.h:78
bool ResolveTextVar(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
Definition: sch_sheet.cpp:229
int GetUnit() const
Definition: sch_symbol.h:196
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:121
int m_id
Field index,.
Definition: sch_field.h:220
virtual wxString GetShownText(int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:162
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References _, SCHEMATIC::CurrentSheet(), ExpandTextVars(), EDA_TEXT::GetShownText(), SCH_SYMBOL::GetUnit(), SCH_SYMBOL::GetUnitCount(), EDA_TEXT::HasTextVars(), SCH_SHEET_PATH::Last(), m_id, EDA_ITEM::m_parent, SCHEMATIC::Prj(), project, REFERENCE_FIELD, SCHEMATIC::ResolveCrossReference(), SCH_SHEET::ResolveTextVar(), SCH_SYMBOL::ResolveTextVar(), SCH_GLOBALLABEL::ResolveTextVar(), SCH_GLOBAL_LABEL_T, 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::GetFootprint(), NETLIST_EXPORTER_PSPICE::GetSpiceField(), NETLIST_EXPORTER_PSPICE::GetSpiceFieldDefVal(), SCH_SYMBOL::GetValue(), Matches(), DIALOG_SHEET_PROPERTIES::OnUpdateUI(), Plot(), Print(), NETLIST_EXPORTER_PSPICE::ProcessNetlist(), EE_INSPECTION_TOOL::ShowDatasheet(), and NETLIST_EXPORTER_CADSTAR::WriteNetlist().

◆ GetState()

int EDA_ITEM::GetState ( EDA_ITEM_FLAGS  type) const
inlineinherited

Definition at line 136 of file eda_item.h.

137  {
138  return m_status & type;
139  }
EDA_ITEM_FLAGS m_status
Definition: eda_item.h:477

References EDA_ITEM::m_status.

Referenced by BOARD_ITEM::IsLocked().

◆ GetStatus()

EDA_ITEM_FLAGS EDA_ITEM::GetStatus ( ) const
inlineinherited

Definition at line 149 of file eda_item.h.

149 { return m_status; }
EDA_ITEM_FLAGS m_status
Definition: eda_item.h:477

References EDA_ITEM::m_status.

◆ GetStoredPos()

wxPoint& SCH_ITEM::GetStoredPos ( )
inlineinherited

Definition at line 222 of file sch_item.h.

222 { return m_storedPos; }
wxPoint m_storedPos
Definition: sch_item.h:490

References SCH_ITEM::m_storedPos.

◆ GetStroke()

virtual STROKE_PARAMS SCH_ITEM::GetStroke ( ) const
inlinevirtualinherited

Reimplemented in SCH_LINE, and SCH_BUS_ENTRY_BASE.

Definition at line 455 of file sch_item.h.

455 { wxCHECK( false, STROKE_PARAMS() ); }
Simple container to manage line stroke parameters.
Definition: sch_item.h:140

Referenced by DIALOG_LINE_WIRE_BUS_PROPERTIES::TransferDataToWindow().

◆ 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 154 of file eda_text.h.

154 { return m_text; }
wxString m_text
Definition: eda_text.h:411

References EDA_TEXT::m_text.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::addAttribute(), SCH_EAGLE_PLUGIN::addImplicitConnections(), NETLIST_EXPORTER_XML::addSymbolFields(), SIM_PLOT_FRAME::AddTuner(), CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings(), CONNECTION_GRAPH::buildConnectionGraph(), LIB_TEXT::Clone(), LIB_TEXT::compare(), LIB_FIELD::compare(), 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(), DoHypertextMenu(), KIGFX::SCH_PAINTER::draw(), EDA_TEXT_DESC::EDA_TEXT_DESC(), CONNECTION_GRAPH::ercCheckHierSheets(), CADSTAR_ARCHIVE_PARSER::FixTextPositionNoAlignment(), LIB_SYMBOL::Flatten(), PCB_PLUGIN::format(), FormatProbeItem(), SCH_SYMBOL::GetFootprint(), LIB_FIELD::GetFullText(), FOOTPRINT_INFO_GENERATOR::GetHtmlFieldRow(), CADSTAR_PCB_ARCHIVE_LOADER::getKiCadNet(), FP_TEXT::GetLength(), getMatchingTextItem(), PCB_TEXT::GetMsgPanelInfo(), LIB_TEXT::GetMsgPanelInfo(), LIB_FIELD::GetMsgPanelInfo(), FP_TEXT::GetMsgPanelInfo(), GetMsgPanelInfo(), SCH_TEXT::GetMsgPanelInfo(), SCH_SYMBOL::GetRef(), FOOTPRINT::GetReference(), LIB_SYMBOL::GetSearchText(), PCB_DIMENSION_BASE::GetText(), FOOTPRINT::GetValue(), SCH_SYMBOL::GetValue(), LIB_FIELD::HitTest(), SCH_DRAWING_TOOLS::importHierLabel(), SCH_TEXT::IncrementLabel(), GENERAL_COLLECTOR::Inspect(), IsVoid(), 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(), SCH_SHEET_PIN::Matches(), SCH_TEXT::Matches(), DIALOG_UPDATE_SYMBOL_FIELDS::onOkButtonClicked(), SCH_TEXT::operator<(), operator<(), LIB_FIELD::operator=(), SCH_SEXPR_PARSER::parseEDA_TEXT(), PCB_PARSER::parseEDA_TEXT(), SCH_SEXPR_PARSER::parseSchematicSymbol(), SCH_EDITOR_CONTROL::Paste(), DRAWING_TOOL::PlaceText(), LIB_TEXT::Plot(), LIB_FIELD::Plot(), BRDITEMS_PLOTTER::PlotFootprintTextItems(), DIALOG_RESCUE_EACH::PopulateInstanceList(), LIB_FIELD::print(), DIALOG_CHANGE_SYMBOLS::processSymbol(), processTextItem(), SCH_EDIT_FRAME::RecomputeIntersheetRefs(), SCH_GLOBALLABEL::ResolveTextVar(), SCH_SEXPR_PLUGIN::saveField(), SCH_LEGACY_PLUGIN::saveField(), SCH_SEXPR_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN::saveSheet(), SCH_LEGACY_PLUGIN::saveSymbol(), SCH_LEGACY_PLUGIN_CACHE::SaveSymbol(), SCH_SEXPR_PLUGIN::saveText(), SCH_LEGACY_PLUGIN::saveText(), SCH_SEXPR_PLUGIN_CACHE::saveText(), SCH_LEGACY_PLUGIN_CACHE::saveText(), SYMBOL_VIEWER_FRAME::setupUIConditions(), SYMBOL_EDIT_FRAME::setupUIConditions(), EE_INSPECTION_TOOL::ShowDatasheet(), SCH_SHEET::SymbolCount(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_EDIT_SYMBOLS_LIBID::TransferDataFromWindow(), DIALOG_SHEET_PIN_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_TEXT_AND_LABEL_PROPERTIES::TransferDataToWindow(), DIALOG_SHEET_PROPERTIES::TransferDataToWindow(), EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon(), TUNER_SLIDER::TUNER_SLIDER(), SCH_EDITOR_CONTROL::updatePastedSymbol(), SYMBOL_EDIT_FRAME::UpdateSymbolMsgPanelInfo(), and FP_TEXT::ViewGetLOD().

◆ GetTextAngle()

double EDA_TEXT::GetTextAngle ( ) const
inlineinherited

Definition at line 195 of file eda_text.h.

195 { return m_e.angle; }
TEXT_EFFECTS m_e
Definition: eda_text.h:415
double angle
now: 0.1 degrees; future: degrees
Definition: eda_text.h:126

References TEXT_EFFECTS::angle, and EDA_TEXT::m_e.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::addAttribute(), BOARD_ADAPTER::addShapeWithClearance(), CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings(), DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES(), KIGFX::DS_PAINTER::draw(), KIGFX::SCH_PAINTER::draw(), PCB_TEXT::Flip(), FP_TEXT::Flip(), PCB_PLUGIN::format(), LIB_TEXT::GetBoundingBox(), GetBoundingBox(), LIB_FIELD::GetBoundingBox(), PCB_TEXT::GetBoundingBox(), SCH_TEXT::GetBoundingBox(), SCH_LABEL::GetBoundingBox(), GetDrawRotation(), FP_TEXT::GetDrawRotation(), EDA_TEXT::GetDrawRotation(), EDA_TEXT::GetLinePositions(), EDA_TEXT::GetTextAngleDegrees(), EDA_TEXT::GetTextAngleRadians(), LIB_TEXT::HitTest(), LIB_FIELD::HitTest(), FP_TEXT::KeepUpright(), SCH_EAGLE_PLUGIN::loadFieldAttributes(), CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary(), PCB_DIMENSION_BASE::Mirror(), LIB_TEXT::MirrorHorizontal(), SCH_GLOBALLABEL::MirrorSpinStyle(), LIB_TEXT::MirrorVertical(), LIB_TEXT::NormalizeJustification(), EAGLE_PLUGIN::orientFPText(), ALTIUM_PCB::ParseTexts6Data(), LIB_TEXT::Plot(), LIB_FIELD::Plot(), Plot(), SCH_TEXT::Plot(), BRDITEMS_PLOTTER::PlotPcbText(), positioningChanged(), LIB_TEXT::print(), Print(), LIB_FIELD::print(), EDA_TEXT::printOneLineOfText(), SCH_EDIT_TOOL::Rotate(), PCB_TEXT::Rotate(), LIB_TEXT::Rotate(), FP_TEXT::Rotate(), LIB_FIELD::Rotate(), PCB_DIMENSION_BASE::Rotate(), SCH_GLOBALLABEL::Rotate90(), SCH_LEGACY_PLUGIN::saveField(), SCH_SEXPR_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_SEXPR_PLUGIN::saveText(), SCH_SEXPR_PLUGIN_CACHE::saveText(), SCH_LEGACY_PLUGIN_CACHE::saveText(), EDA_TEXT::TextHitTest(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon(), FP_TEXT::TransformShapeWithClearanceToPolygon(), PCB_TEXT::TransformTextShapeWithClearanceToPolygon(), and DIALOG_SCH_FIELD_PROPERTIES::UpdateField().

◆ GetTextAngleDegrees()

double EDA_TEXT::GetTextAngleDegrees ( ) const
inlineinherited

◆ GetTextAngleRadians()

double EDA_TEXT::GetTextAngleRadians ( ) const
inlineinherited

◆ GetTextBox()

EDA_RECT 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 239 of file eda_text.cpp.

240 {
241  EDA_RECT rect;
242  wxArrayString strings;
243  wxString text = GetShownText();
244  int thickness = GetEffectiveTextPenWidth();
245  int linecount = 1;
246  bool hasOverBar = false; // true if the first line of text as an overbar
247 
248  if( IsMultilineAllowed() )
249  {
250  wxStringSplit( text, strings, '\n' );
251 
252  if( strings.GetCount() ) // GetCount() == 0 for void strings
253  {
254  if( aLine >= 0 && ( aLine < static_cast<int>( strings.GetCount() ) ) )
255  text = strings.Item( aLine );
256  else
257  text = strings.Item( 0 );
258 
259  linecount = strings.GetCount();
260  }
261  }
262 
263  // Search for overbar symbol. Only text is scanned,
264  // because only this line can change the bounding box
265  for( unsigned ii = 1; ii < text.size(); ii++ )
266  {
267  if( text[ii-1] == '~' && text[ii] == '{' )
268  {
269  hasOverBar = true;
270  break;
271  }
272  }
273 
274  // calculate the H and V size
275  const auto& font = basic_gal.GetStrokeFont();
276  VECTOR2D fontSize( GetTextSize() );
277  double penWidth( thickness );
278  VECTOR2D extents = font.ComputeStringBoundaryLimits( text, fontSize, penWidth );
279  double interline = KIGFX::STROKE_FONT::GetInterline( fontSize.y );
280 
281  // Creates bounding box (rectangle) for horizontal, left and top justified text. The
282  // bounding box will be moved later according to the actual text options
283  wxSize textsize = wxSize( KiROUND( extents.x ), KiROUND( extents.y ) );
284  wxPoint pos = GetTextPos();
285 
286  if( IsMultilineAllowed() && aLine > 0 && ( aLine < static_cast<int>( strings.GetCount() ) ) )
287  pos.y -= KiROUND( aLine * interline );
288 
289  if( aInvertY )
290  pos.y = -pos.y;
291 
292  rect.SetOrigin( pos );
293 
294  if( hasOverBar )
295  { // A overbar adds an extra size to the text
296  // Height from the base line text of chars like [ or {
297  double curr_height = GetTextHeight() * 1.15;
298  double overbarPosition = font.ComputeOverbarVerticalPosition( fontSize.y );
299  int extra_height = KiROUND( overbarPosition - curr_height );
300 
301  extra_height += thickness / 2;
302  textsize.y += extra_height;
303  rect.Move( wxPoint( 0, -extra_height ) );
304  }
305 
306  // for multiline texts and aLine < 0, merge all rectangles
307  // ( if aLine < 0, we want the full text bounding box )
308  if( IsMultilineAllowed() && aLine < 0 )
309  {
310  for( unsigned ii = 1; ii < strings.GetCount(); ii++ )
311  {
312  text = strings.Item( ii );
313  extents = font.ComputeStringBoundaryLimits( text, fontSize, penWidth );
314  textsize.x = std::max( textsize.x, KiROUND( extents.x ) );
315  }
316 
317  // interline spacing is only *between* lines, so total height is the height of the first
318  // line plus the interline distance (with interline spacing) for all subsequent lines
319  // Don't add interline spacing to empty textboxes
320  if( strings.GetCount() )
321  textsize.y += KiROUND( ( strings.GetCount() - 1 ) * interline );
322  }
323 
324  rect.SetSize( textsize );
325 
326  /* Now, calculate the rect origin, according to text justification
327  * At this point the rectangle origin is the text origin (m_Pos).
328  * This is true only for left and top text justified texts (using top to bottom Y axis
329  * orientation). and must be recalculated for others justifications
330  * also, note the V justification is relative to the first line
331  */
332  switch( GetHorizJustify() )
333  {
335  if( IsMirrored() )
336  rect.SetX( rect.GetX() - rect.GetWidth() );
337  break;
338 
340  rect.SetX( rect.GetX() - ( rect.GetWidth() / 2 ) );
341  break;
342 
344  if( !IsMirrored() )
345  rect.SetX( rect.GetX() - rect.GetWidth() );
346  break;
347  }
348 
349  switch( GetVertJustify() )
350  {
352  break;
353 
355  rect.SetY( rect.GetY() - KiROUND( interline / 2.0 ) );
356  break;
357 
359  rect.SetY( rect.GetY() - KiROUND( interline ) );
360  break;
361  }
362 
363  if( linecount > 1 )
364  {
365  int yoffset;
366  linecount -= 1;
367 
368  switch( GetVertJustify() )
369  {
371  break;
372 
374  yoffset = KiROUND( linecount * interline / 2.0 );
375  rect.SetY( rect.GetY() - yoffset );
376  break;
377 
379  yoffset = KiROUND( linecount * interline );
380  rect.SetY( rect.GetY() - yoffset );
381  break;
382  }
383  }
384 
385  // Many fonts draw diacriticals, descenders, etc. outside the X-height of the font. This
386  // will cacth most (but probably not all) of them.
387  rect.Inflate( 0, KiROUND( thickness * 0.75 ) );
388 
389  rect.Normalize(); // Make h and v sizes always >= 0
390 
391  return rect;
392 }
const STROKE_FONT & GetStrokeFont() const
void Move(const wxPoint &aMoveVector)
Move the rectangle by the aMoveVector.
Definition: eda_rect.cpp:51
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:220
bool IsMirrored() const
Definition: eda_text.h:210
static double GetInterline(double aGlyphHeight)
Compute the distance (interline) between 2 lines of text (for multiline texts).
int GetX() const
Definition: eda_rect.h:107
int GetWidth() const
Definition: eda_rect.h:118
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:130
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:159
int GetTextHeight() const
Definition: eda_text.h:265
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:219
const wxSize & GetTextSize() const
Definition: eda_text.h:259
void SetX(int val)
Definition: eda_rect.h:167
bool IsMultilineAllowed() const
Definition: eda_text.h:217
void SetY(int val)
Definition: eda_rect.h:173
void Normalize()
Ensures that the height ant width are positive.
Definition: eda_rect.cpp:35
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
void SetSize(const wxSize &size)
Definition: eda_rect.h:143
Handle the component boundary box.
Definition: eda_rect.h:42
int GetY() const
Definition: eda_rect.h:108
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:73
const wxPoint & GetTextPos() const
Definition: eda_text.h:268
BASIC_GAL basic_gal(basic_displayOptions)
virtual wxString GetShownText(int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:162
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:364

References basic_gal, EDA_TEXT::GetEffectiveTextPenWidth(), EDA_TEXT::GetHorizJustify(), KIGFX::STROKE_FONT::GetInterline(), EDA_TEXT::GetShownText(), KIGFX::GAL::GetStrokeFont(), EDA_TEXT::GetTextHeight(), EDA_TEXT::GetTextPos(), EDA_TEXT::GetTextSize(), EDA_TEXT::GetVertJustify(), EDA_RECT::GetWidth(), EDA_RECT::GetX(), EDA_RECT::GetY(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, EDA_RECT::Inflate(), EDA_TEXT::IsMirrored(), EDA_TEXT::IsMultilineAllowed(), KiROUND(), EDA_RECT::Move(), EDA_RECT::Normalize(), EDA_RECT::SetOrigin(), EDA_RECT::SetSize(), EDA_RECT::SetX(), EDA_RECT::SetY(), text, wxStringSplit(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by LIB_TEXT::GetBoundingBox(), GetBoundingBox(), LIB_FIELD::GetBoundingBox(), PCB_TEXT::GetBoundingBox(), FP_TEXT::GetBoundingBox(), SCH_TEXT::GetBoundingBox(), PCB_DIMENSION_BASE::GetBoundingBox(), SCH_LABEL::GetBoundingBox(), DS_DRAW_ITEM_TEXT::GetBoundingBox(), LIB_TEXT::HitTest(), CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary(), LIB_TEXT::NormalizeJustification(), FP_TEXT::TextHitTest(), EDA_TEXT::TextHitTest(), EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon(), PCB_DIM_ALIGNED::updateGeometry(), PCB_DIM_ORTHOGONAL::updateGeometry(), PCB_DIM_LEADER::updateGeometry(), and FP_TEXT::ViewBBox().

◆ GetTextHeight()

◆ GetTextPos()

const wxPoint& EDA_TEXT::GetTextPos ( ) const
inlineinherited

Definition at line 268 of file eda_text.h.

268 { return m_e.pos; }
TEXT_EFFECTS m_e
Definition: eda_text.h:415
wxPoint pos
Definition: eda_text.h:127

References EDA_TEXT::m_e, and TEXT_EFFECTS::pos.

Referenced by BOARD_ADAPTER::addShapeWithClearance(), LIB_TEXT::compare(), LIB_FIELD::compare(), SCH_SHEET_PIN::ConstrainOnEdge(), DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES(), SCH_LABEL::doIsConnected(), SCH_GLOBALLABEL::doIsConnected(), SCH_HIERLABEL::doIsConnected(), KIGFX::DS_PAINTER::draw(), KIGFX::SCH_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), PCB_TEXT::Flip(), FP_TEXT::Flip(), PCB_PLUGIN::format(), LIB_TEXT::GetBoundingBox(), GetBoundingBox(), LIB_FIELD::GetBoundingBox(), PCB_TEXT::GetBoundingBox(), FP_TEXT::GetBoundingBox(), SCH_TEXT::GetBoundingBox(), SCH_LABEL::GetBoundingBox(), SCH_HIERLABEL::GetBoundingBox(), SCH_GLOBALLABEL::GetBoundingBoxBase(), SCH_MOVE_TOOL::getConnectedDragItems(), SCH_TEXT::GetConnectionPoints(), EDA_TEXT::GetDrawPos(), SCH_SHEET_PIN::GetEndPoints(), SCH_TEXT::GetEndPoints(), GetLibPosition(), EDA_TEXT::GetLinePositions(), PCB_TEXT::GetPosition(), FP_TEXT::GetPosition(), LIB_TEXT::GetPosition(), LIB_FIELD::GetPosition(), GetPosition(), SCH_TEXT::GetPosition(), DS_DRAW_ITEM_TEXT::GetPosition(), EDA_TEXT::GetTextBox(), LIB_TEXT::HitTest(), LIB_FIELD::HitTest(), CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary(), FP_TEXT::Mirror(), PCB_DIMENSION_BASE::Mirror(), LIB_TEXT::MirrorHorizontal(), LIB_FIELD::MirrorHorizontal(), SCH_SHEET_PIN::MirrorHorizontally(), SCH_TEXT::MirrorHorizontally(), SCH_GLOBALLABEL::MirrorHorizontally(), SCH_GLOBALLABEL::MirrorSpinStyle(), LIB_TEXT::MirrorVertical(), LIB_FIELD::MirrorVertical(), SCH_SHEET_PIN::MirrorVertically(), SCH_TEXT::MirrorVertically(), SCH_GLOBALLABEL::MirrorVertically(), LIB_TEXT::NormalizeJustification(), DIALOG_UPDATE_SYMBOL_FIELDS::onOkButtonClicked(), DRAWING_TOOL::PlaceText(), SCH_TEXT::Plot(), BRDITEMS_PLOTTER::PlotFootprintTextItem(), BRDITEMS_PLOTTER::PlotPcbText(), LIB_FIELD::print(), EDA_TEXT::Print(), SCH_GLOBALLABEL::Print(), SCH_HIERLABEL::Print(), DIALOG_CHANGE_SYMBOLS::processSymbol(), PCB_TEXT::Rotate(), LIB_TEXT::Rotate(), FP_TEXT::Rotate(), LIB_FIELD::Rotate(), SCH_SHEET_PIN::Rotate(), SCH_TEXT::Rotate(), PCB_DIMENSION_BASE::Rotate(), SCH_GLOBALLABEL::Rotate(), SCH_GLOBALLABEL::Rotate90(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveText(), FP_TEXT::SetDrawCoord(), FP_TEXT::SetLocalCoord(), FP_TEXT::TextHitTest(), EDA_TEXT::TextHitTest(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon(), PCB_TEXT::TransformTextShapeWithClearanceToPolygon(), FP_TEXT::TransformTextShapeWithClearanceToPolygon(), SCH_TEXT::UpdateDanglingState(), 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 504 of file eda_text.cpp.

505 {
506  int style = 0;
507 
508  if( IsItalic() )
509  style = 1;
510 
511  if( IsBold() )
512  style += 2;
513 
514  wxString stylemsg[4] = {
515  _("Normal"),
516  _("Italic"),
517  _("Bold"),
518  _("Bold+Italic")
519  };
520 
521  return stylemsg[style];
522 }
bool IsBold() const
Definition: eda_text.h:204
bool IsItalic() const
Definition: eda_text.h:201
#define _(s)

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

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

◆ GetTextThickness()

◆ GetTextWidth()

◆ GetVertJustify()

◆ HasFlag()

◆ 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_LINE, and SCH_BUS_ENTRY_BASE.

Definition at line 453 of file sch_item.h.

453 { return false; }

Referenced by EE_SELECTION::AllItemsHaveLineStroke(), and SCH_EDIT_TOOL::Properties().

◆ HasTextVars()

bool EDA_TEXT::HasTextVars ( ) const
inlineinherited

Indicates the ShownText has text var references which need to be processed.

Definition at line 172 of file eda_text.h.

bool m_shown_text_has_text_var_refs
Definition: eda_text.h:413

References EDA_TEXT::m_shown_text_has_text_var_refs.

Referenced by PCB_TEXT::GetShownText(), GetShownText(), SCH_TEXT::GetShownText(), and FP_TEXT::GetShownText().

◆ HitTest() [1/2]

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

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

Parameters
aPositionA reference to a wxPoint 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 742 of file sch_field.cpp.

743 {
744  // Do not hit test hidden or empty fields.
745  if( !IsVisible() || IsVoid() )
746  return false;
747 
748  EDA_RECT rect = GetBoundingBox();
749 
750  rect.Inflate( aAccuracy );
751 
752  return rect.Contains( aPosition );
753 }
bool Contains(const wxPoint &aPoint) const
Definition: eda_rect.cpp:57
bool IsVoid() const
Definition: sch_field.cpp:421
virtual bool IsVisible() const
Definition: eda_text.h:207
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_field.cpp:305
Handle the component boundary box.
Definition: eda_rect.h:42
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:364

References EDA_RECT::Contains(), GetBoundingBox(), EDA_RECT::Inflate(), EDA_TEXT::IsVisible(), and IsVoid().

◆ HitTest() [2/2]

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

Test if aRect intersects this item.

Parameters
aRectA reference to a EDA_RECT 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 756 of file sch_field.cpp.

757 {
758  // Do not hit test hidden fields.
759  if( !IsVisible() || IsVoid() )
760  return false;
761 
762  EDA_RECT rect = aRect;
763 
764  rect.Inflate( aAccuracy );
765 
766  if( aContained )
767  return rect.Contains( GetBoundingBox() );
768 
769  return rect.Intersects( GetBoundingBox() );
770 }
bool Contains(const wxPoint &aPoint) const
Definition: eda_rect.cpp:57
bool IsVoid() const
Definition: sch_field.cpp:421
virtual bool IsVisible() const
Definition: eda_text.h:207
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_field.cpp:305
Handle the component boundary box.
Definition: eda_rect.h:42
bool Intersects(const EDA_RECT &aRect) const
Test for a common area between rectangles.
Definition: eda_rect.cpp:150
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:364

References EDA_RECT::Contains(), GetBoundingBox(), EDA_RECT::Inflate(), EDA_RECT::Intersects(), EDA_TEXT::IsVisible(), and IsVoid().

◆ 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 246 of file sch_field.cpp.

247 {
248  SetEffects( aSource );
249 }
void SetEffects(const EDA_TEXT &aSrc)
Set the text effects from another instance.
Definition: eda_text.cpp:139

References EDA_TEXT::SetEffects().

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 195 of file sch_item.cpp.

197 {
198  SetConnectivityDirty( false );
199 
200  SCH_CONNECTION* connection = Connection( &aSheet );
201 
202  if( connection )
203  {
204  connection->Reset();
205  }
206  else
207  {
208  connection = new SCH_CONNECTION( this );
209  m_connection_map.insert( std::make_pair( aSheet, connection ) );
210  }
211 
212  connection->SetGraph( aGraph );
213  connection->SetSheet( aSheet );
214  return connection;
215 }
void SetSheet(SCH_SHEET_PATH aSheet)
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:138
void Reset()
Clears connectivity information.
void SetGraph(CONNECTION_GRAPH *aGraph)
std::unordered_map< SCH_SHEET_PATH, SCH_CONNECTION * > m_connection_map
Store connectivity information, per sheet.
Definition: sch_item.h:497
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
void SetConnectivityDirty(bool aDirty=true)
Definition: sch_item.h:415

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()

◆ IsBrightened()

◆ IsConnectable()

◆ IsConnected()

bool SCH_ITEM::IsConnected ( const wxPoint &  aPoint) const
inherited

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

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

Definition at line 129 of file sch_item.cpp.

130 {
131  if(( m_flags & STRUCT_DELETED ) || ( m_flags & SKIP_STRUCT ) )
132  return false;
133 
134  return doIsConnected( aPosition );
135 }
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480
#define STRUCT_DELETED
flag indication structures to be erased
#define SKIP_STRUCT
flag indicating that the structure should be ignored
virtual bool doIsConnected(const wxPoint &aPosition) const
Provide the object specific test to see if it is connected to aPosition.
Definition: sch_item.h:484

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

Referenced by SCH_SCREEN::doIsJunction(), and SCH_SCREEN::IsTerminalPoint().

◆ IsConnectivityDirty()

◆ IsDangling()

virtual bool SCH_ITEM::IsDangling ( ) const
inlinevirtualinherited

Reimplemented in SCH_TEXT, SCH_LINE, SCH_BUS_ENTRY_BASE, and SCH_PIN.

Definition at line 342 of file sch_item.h.

342 { return false; }

◆ IsDefaultFormatting()

bool EDA_TEXT::IsDefaultFormatting ( ) const
inherited

Definition at line 525 of file eda_text.cpp.

526 {
527  return ( IsVisible()
528  && !IsMirrored()
531  && GetTextThickness() == 0
532  && !IsItalic()
533  && !IsBold()
534  && !IsMultilineAllowed()
535  );
536 }
bool IsBold() const
Definition: eda_text.h:204
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:220
bool IsMirrored() const
Definition: eda_text.h:210
int GetTextThickness() const
Definition: eda_text.h:181
bool IsItalic() const
Definition: eda_text.h:201
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:219
virtual bool IsVisible() const
Definition: eda_text.h:207
bool IsMultilineAllowed() const
Definition: eda_text.h:217

References EDA_TEXT::GetHorizJustify(), EDA_TEXT::GetTextThickness(), EDA_TEXT::GetVertJustify(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, EDA_TEXT::IsBold(), EDA_TEXT::IsItalic(), EDA_TEXT::IsMirrored(), EDA_TEXT::IsMultilineAllowed(), and EDA_TEXT::IsVisible().

Referenced by SCH_SEXPR_PLUGIN::saveField().

◆ IsDragging()

bool EDA_ITEM::IsDragging ( ) const
inlineinherited

Definition at line 120 of file eda_item.h.

120 { return m_flags & IS_DRAGGING; }
#define IS_DRAGGING
Item being dragged.
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480

References IS_DRAGGING, and EDA_ITEM::m_flags.

Referenced by DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES().

◆ IsEntered()

bool EDA_ITEM::IsEntered ( ) const
inlineinherited

Definition at line 123 of file eda_item.h.

123 { return m_flags & ENTERED; }
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480
#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 205 of file eda_item.h.

205 { return m_forceVisible; }
bool m_forceVisible
Definition: eda_item.h:479

References EDA_ITEM::m_forceVisible.

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

◆ 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 347 of file sch_field.cpp.

348 {
349  wxPoint render_center = GetBoundingBox().Centre();
350  wxPoint pos = GetPosition();
351 
352  switch( GetHorizJustify() )
353  {
356  return render_center.y > pos.y;
357  else
358  return render_center.x < pos.x;
361  return render_center.y < pos.y;
362  else
363  return render_center.x > pos.x;
364  default:
365  return false;
366  }
367 }
wxPoint GetPosition() const override
Definition: sch_field.cpp:842
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:219
double GetDrawRotation() const override
Adjusters to allow EDA_TEXT to draw/print/etc.
Definition: sch_field.cpp:265
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_field.cpp:305
wxPoint Centre() const
Definition: eda_rect.h:64
#define TEXT_ANGLE_VERT
Definition: eda_text.h:72

References EDA_RECT::Centre(), GetBoundingBox(), GetDrawRotation(), EDA_TEXT::GetHorizJustify(), GetPosition(), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, and TEXT_ANGLE_VERT.

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 89 of file sch_field.h.

90  {
91  return m_parent && m_parent->Type() == SCH_GLOBAL_LABEL_T;
92  }
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:478
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

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

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

◆ IsItalic()

◆ IsLocked()

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

Definition at line 242 of file sch_item.h.

242 { return false; }

◆ IsMirrored()

◆ IsModified()

bool EDA_ITEM::IsModified ( ) const
inlineinherited

Definition at line 117 of file eda_item.h.

117 { return m_flags & IS_CHANGED; }
#define IS_CHANGED
Item was edited, and modified.
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480

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_SYMBOL, SCH_BITMAP, SCH_SHEET_PIN, SCH_SHEET, and SCH_BUS_ENTRY_BASE.

Definition at line 220 of file sch_item.h.

220 { return true; }

Referenced by SCH_MOVE_TOOL::Main().

◆ IsMoving()

◆ IsMultilineAllowed()

◆ IsNew()

◆ IsPointClickableAnchor()

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

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

Definition at line 355 of file sch_item.h.

355 { return false; }

◆ 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 467 of file sch_field.cpp.

468 {
469  if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
470  {
471  SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
472 
473  if( m_id == VALUE_FIELD )
474  {
475  if( parentSymbol->GetLibSymbolRef() && parentSymbol->GetLibSymbolRef()->IsPower() )
476  return false;
477  }
478  }
479  else if( m_parent && m_parent->Type() == SCH_SHEET_T )
480  {
481  // See comments in SCH_FIELD::Replace(), below.
482  if( m_id == SHEETFILENAME )
483  return false;
484  }
485  else if( m_parent && m_parent->Type() == SCH_GLOBAL_LABEL_T )
486  {
487  return false;
488  }
489 
490  return true;
491 }
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:478
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:165
Field Value of part, i.e. "3.3K".
Schematic symbol object.
Definition: sch_symbol.h:78
int m_id
Field index,.
Definition: sch_field.h:220
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References SCH_SYMBOL::GetLibSymbolRef(), m_id, EDA_ITEM::m_parent, SCH_GLOBAL_LABEL_T, SCH_SHEET_T, SCH_SYMBOL_T, SHEETFILENAME, EDA_ITEM::Type(), and VALUE_FIELD.

◆ IsResized()

bool EDA_ITEM::IsResized ( ) const
inlineinherited

Definition at line 124 of file eda_item.h.

124 { return m_flags & IS_RESIZING; }
#define IS_RESIZING
Item being resized.
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480

References IS_RESIZING, and EDA_ITEM::m_flags.

◆ IsSelected()

bool EDA_ITEM::IsSelected ( ) const
inlineinherited

Definition at line 122 of file eda_item.h.

122 { return m_flags & SELECTED; }
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480
#define 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_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(), KIGFX::SCH_PAINTER::draw(), KIGFX::PCB_PAINTER::Draw(), KIGFX::PCB_PAINTER::draw(), DS_PROXY_UNDO_ITEM::DS_PROXY_UNDO_ITEM(), KIGFX::DS_RENDER_SETTINGS::GetColor(), KIGFX::GERBVIEW_RENDER_SETTINGS::GetColor(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), SCH_MOVE_TOOL::getConnectedDragItems(), KIGFX::SCH_PAINTER::getLineWidth(), KIGFX::SCH_PAINTER::getRenderColor(), KIGFX::SCH_PAINTER::getTextThickness(), DIALOG_EXCHANGE_FOOTPRINTS::isMatch(), DIALOG_CHANGE_SYMBOLS::isMatch(), SCH_LINE::MergeOverlap(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SCH_MOVE_TOOL::moveItem(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), BOARD_COMMIT::Push(), PCB_SELECTION_TOOL::RebuildSelection(), EE_SELECTION_TOOL::RebuildSelection(), RENDER_3D_OPENGL::renderFootprint(), SCH_EDIT_TOOL::Rotate(), EE_TOOL_BASE< SCH_BASE_FRAME >::saveCopyInUndoList(), SCH_EDIT_FRAME::SchematicCleanUp(), GERBVIEW_SELECTION_TOOL::select(), PCB_SELECTION_TOOL::select(), PCB_SELECTION_TOOL::selectionContains(), PCB_SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), KIGFX::SCH_PAINTER::setDeviceColors(), GERBVIEW_SELECTION_TOOL::unselect(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::visitItem(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ IsType()

bool SCH_FIELD::IsType ( const 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 69 of file sch_field.h.

70  {
71  if( SCH_ITEM::IsType( aScanTypes ) )
72  return true;
73 
74  for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
75  {
77  return true;
78  else if ( *p == SCH_FIELD_LOCATE_VALUE_T && m_id == VALUE_FIELD )
79  return true;
80  else if ( *p == SCH_FIELD_LOCATE_FOOTPRINT_T && m_id == FOOTPRINT_FIELD )
81  return true;
82  else if ( *p == SCH_FIELD_LOCATE_DATASHEET_T && m_id == DATASHEET_FIELD )
83  return true;
84  }
85 
86  return false;
87  }
Field Reference of part, i.e. "IC21".
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
name of datasheet
Field Value of part, i.e. "3.3K".
virtual bool IsType(const KICAD_T aScanTypes[]) const
Check whether the item is one of the listed types.
Definition: eda_item.h:182
int m_id
Field index,.
Definition: sch_field.h:220
Field Name Module PCB, i.e. "16DIP300".

References DATASHEET_FIELD, EOT, FOOTPRINT_FIELD, EDA_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 384 of file sch_field.cpp.

385 {
386  wxPoint render_center = GetBoundingBox().Centre();
387  wxPoint pos = GetPosition();
388 
389  switch( GetVertJustify() )
390  {
393  return render_center.x < pos.x;
394  else
395  return render_center.y < pos.y;
398  return render_center.x > pos.x;
399  else
400  return render_center.y > pos.y;
401  default:
402  return false;
403  }
404 }
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:220
wxPoint GetPosition() const override
Definition: sch_field.cpp:842
double GetDrawRotation() const override
Adjusters to allow EDA_TEXT to draw/print/etc.
Definition: sch_field.cpp:265
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_field.cpp:305
wxPoint Centre() const
Definition: eda_rect.h:64
#define TEXT_ANGLE_VERT
Definition: eda_text.h:72

References EDA_RECT::Centre(), GetBoundingBox(), GetDrawRotation(), GetPosition(), EDA_TEXT::GetVertJustify(), GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_TOP, and TEXT_ANGLE_VERT.

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

◆ IsVisible()

◆ IsVoid()

bool SCH_FIELD::IsVoid ( ) const
Returns
true if the field is either empty or holds "~".

Definition at line 421 of file sch_field.cpp.

422 {
423  return GetText().Len() == 0;
424 }
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:154

References EDA_TEXT::GetText().

Referenced by NETLIST_EXPORTER_XML::addSymbolFields(), KIGFX::SCH_PAINTER::draw(), HitTest(), Plot(), Print(), and NETLIST_EXPORTER_CADSTAR::WriteNetlist().

◆ IsWireImage()

bool EDA_ITEM::IsWireImage ( ) const
inlineinherited

Definition at line 121 of file eda_item.h.

121 { return m_flags & IS_WIRE_IMAGE; }
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480
#define IS_WIRE_IMAGE
Item to be drawn as wireframe while editing.

References IS_WIRE_IMAGE, and EDA_ITEM::m_flags.

◆ IterateForward() [1/2]

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

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

Definition at line 294 of file eda_item.h.

298  {
299  for( auto it : aList )
300  {
301  if( static_cast<EDA_ITEM*>( it )->Visit( inspector, testData, scanTypes )
303  return SEARCH_RESULT::QUIT;
304  }
305 
307  }
virtual SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
May be re-implemented for each derived class in order to handle all the types given by its member dat...
Definition: eda_item.cpp:93

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

Referenced by GERBER_FILE_IMAGE::Visit().

◆ IterateForward() [2/2]

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

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

Definition at line 313 of file eda_item.h.

315  {
316  for( auto it : aList )
317  {
318  if( static_cast<EDA_ITEM*>( it )->Visit( inspector, testData, scanTypes )
320  return SEARCH_RESULT::QUIT;
321  }
322 
324  }
virtual SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
May be re-implemented for each derived class in order to handle all the types given by its member dat...
Definition: eda_item.cpp:93

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

◆ LenSize()

int EDA_TEXT::LenSize ( const wxString &  aLine,
int  aThickness 
) const
inherited
Returns
the text length in internal units.
Parameters
aLinethe line of text to consider. For single line text, this parameter is always m_Text.
aThicknessthe stroke width of the text.

Definition at line 204 of file eda_text.cpp.

205 {
208  basic_gal.SetFontUnderlined( false );
209  basic_gal.SetLineWidth( (float) aThickness );
211 
212  VECTOR2D tsize = basic_gal.GetTextLineSize( aLine );
213 
214  return KiROUND( tsize.x );
215 }
bool IsBold() const
Definition: eda_text.h:204
void SetFontBold(bool aBold)
Set bold property of current font.
VECTOR2D GetTextLineSize(const UTF8 &aText) const
Compute the X and Y size of a given text.
virtual void SetLineWidth(float aLineWidth)
Set the line width.
bool IsItalic() const
Definition: eda_text.h:201
VECTOR2< double > VECTOR2D
Definition: vector2d.h:621
const wxSize & GetTextSize() const
Definition: eda_text.h:259
void SetFontItalic(bool aItalic)
Set italic property of current font.
void SetGlyphSize(const VECTOR2D &aSize)
Set the font glyph size.
void SetFontUnderlined(bool aUnderlined)
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:73
BASIC_GAL basic_gal(basic_displayOptions)

References basic_gal, KIGFX::GAL::GetTextLineSize(), EDA_TEXT::GetTextSize(), EDA_TEXT::IsBold(), EDA_TEXT::IsItalic(), KiROUND(), KIGFX::GAL::SetFontBold(), KIGFX::GAL::SetFontItalic(), KIGFX::GAL::SetFontUnderlined(), KIGFX::GAL::SetGlyphSize(), KIGFX::GAL::SetLineWidth(), and VECTOR2< T >::x.

Referenced by SCH_GLOBALLABEL::CreateGraphicShape(), SCH_HIERLABEL::GetBoundingBox(), and SCH_GLOBALLABEL::GetBoundingBoxBase().

◆ MapHorizJustify()

EDA_TEXT_HJUSTIFY_T EDA_TEXT::MapHorizJustify ( int  aHorizJustify)
staticinherited

Definition at line 73 of file eda_text.cpp.

74 {
75  wxASSERT( aHorizJustify >= GR_TEXT_HJUSTIFY_LEFT && aHorizJustify <= GR_TEXT_HJUSTIFY_RIGHT );
76 
77  if( aHorizJustify > GR_TEXT_HJUSTIFY_RIGHT )
79 
80  if( aHorizJustify < GR_TEXT_HJUSTIFY_LEFT )
81  return GR_TEXT_HJUSTIFY_LEFT;
82 
83  return static_cast<EDA_TEXT_HJUSTIFY_T>( aHorizJustify );
84 }

References GR_TEXT_HJUSTIFY_LEFT, and GR_TEXT_HJUSTIFY_RIGHT.

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

◆ MapVertJustify()

EDA_TEXT_VJUSTIFY_T EDA_TEXT::MapVertJustify ( int  aVertJustify)
staticinherited

Definition at line 87 of file eda_text.cpp.

88 {
89  wxASSERT( aVertJustify >= GR_TEXT_VJUSTIFY_TOP && aVertJustify <= GR_TEXT_VJUSTIFY_BOTTOM );
90 
91  if( aVertJustify > GR_TEXT_VJUSTIFY_BOTTOM )
93 
94  if( aVertJustify < GR_TEXT_VJUSTIFY_TOP )
95  return GR_TEXT_VJUSTIFY_TOP;
96 
97  return static_cast<EDA_TEXT_VJUSTIFY_T>( aVertJustify );
98 }

References GR_TEXT_VJUSTIFY_BOTTOM, and GR_TEXT_VJUSTIFY_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 wxFindReplaceData &  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 427 of file sch_field.cpp.

428 {
429  wxString text = GetShownText();
430  int flags = aSearchData.GetFlags();
431  bool searchHiddenFields = flags & FR_SEARCH_ALL_FIELDS;
432  bool searchAndReplace = flags & FR_SEARCH_REPLACE;
433  bool replaceReferences = flags & FR_REPLACE_REFERENCES;
434 
435  wxLogTrace( traceFindItem, wxT( " child item " )
437 
438  if( !IsVisible() && !searchHiddenFields )
439  return false;
440 
442  {
443  if( searchAndReplace && !replaceReferences )
444  return false;
445 
446  SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
447  wxASSERT( aAuxData );
448 
449  // Take sheet path into account which effects the reference field and the unit for
450  // symbols with multiple parts.
451  if( aAuxData )
452  {
453  text = parentSymbol->GetRef((SCH_SHEET_PATH*) aAuxData );
454 
455  if( SCH_ITEM::Matches( text, aSearchData ) )
456  return true;
457 
458  if( parentSymbol->GetUnitCount() > 1 )
459  text << LIB_SYMBOL::SubReference( parentSymbol->GetUnit() );
460  }
461  }
462 
463  return SCH_ITEM::Matches( text, aSearchData );
464 }
Field Reference of part, i.e. "IC21".
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:478
virtual bool Matches(const wxFindReplaceData &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:364
int GetUnitCount() const
Return the number of units per package of the symbol.
Definition: sch_symbol.cpp:393
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: sch_field.cpp:570
static wxString SubReference(int aUnit, bool aAddSeparator=true)
Definition: lib_symbol.cpp:495
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:464
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: sch_field.cpp:105
virtual bool IsVisible() const
Definition: eda_text.h:207
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Schematic symbol object.
Definition: sch_symbol.h:78
const wxChar *const traceFindItem
Flag to enable find debug tracing.
int GetUnit() const
Definition: sch_symbol.h:196
int m_id
Field index,.
Definition: sch_field.h:220
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References FR_REPLACE_REFERENCES, FR_SEARCH_ALL_FIELDS, FR_SEARCH_REPLACE, SCH_SYMBOL::GetRef(), GetSelectMenuText(), GetShownText(), SCH_SYMBOL::GetUnit(), SCH_SYMBOL::GetUnitCount(), EDA_TEXT::IsVisible(), m_id, EDA_ITEM::m_parent, EDA_ITEM::Matches(), MILLIMETRES, REFERENCE_FIELD, SCH_SYMBOL_T, LIB_SYMBOL::SubReference(), text, traceFindItem, and EDA_ITEM::Type().

◆ Matches() [2/2]

bool EDA_ITEM::Matches ( const wxString &  aText,
const wxFindReplaceData &  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 118 of file eda_item.cpp.

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

References FR_MATCH_WILDCARD, FR_SEARCH_REPLACE, EDA_ITEM::IsReplaceable(), next(), and text.

◆ 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 184 of file sch_field.h.

185  {
186  }

◆ 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 173 of file sch_field.h.

174  {
175  }

◆ Move()

void SCH_FIELD::Move ( const wxPoint &  aMoveVector)
inlineoverridevirtual

Move the item by aMoveVector to a new position.

Implements SCH_ITEM.

Definition at line 159 of file sch_field.h.

160  {
161  Offset( aMoveVector );
162  }
void Offset(const wxPoint &aOffset)
Definition: eda_text.h:273

References EDA_TEXT::Offset().

Referenced by SCH_GLOBALLABEL::Move().

◆ NetClass()

NETCLASSPTR SCH_ITEM::NetClass ( const SCH_SHEET_PATH aSheet = nullptr) const
inherited

Definition at line 158 of file sch_item.cpp.

159 {
160  if( m_connection_map.size() )
161  {
162  SCH_CONNECTION* connection = Connection( aSheet );
163 
164  if( connection )
165  {
166  NET_SETTINGS& netSettings = Schematic()->Prj().GetProjectFile().NetSettings();
167  const wxString& netclassName = netSettings.GetNetclassName( connection->Name() );
168 
169  return netSettings.m_NetClasses.Find( netclassName );
170  }
171  }
172 
173  return nullptr;
174 }
NETCLASSPTR Find(const wxString &aName) const
Search this container for a NETCLASS given by aName.
Definition: netclass.cpp:132
const wxString & GetNetclassName(const wxString &aNetName) const
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:145
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:104
NET_SETTINGS & NetSettings()
Definition: project_file.h:96
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:138
NETCLASSES m_NetClasses
Definition: net_settings.h:40
wxString Name(bool aIgnoreSheet=false) const
NET_SETTINGS stores various net-related settings in a project context.
Definition: net_settings.h:32
std::unordered_map< SCH_SHEET_PATH, SCH_CONNECTION * > m_connection_map
Store connectivity information, per sheet.
Definition: sch_item.h:497
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:75
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).

References SCH_ITEM::Connection(), NETCLASSES::Find(), NET_SETTINGS::GetNetclassName(), PROJECT::GetProjectFile(), SCH_ITEM::m_connection_map, NET_SETTINGS::m_NetClasses, SCH_CONNECTION::Name(), PROJECT_FILE::NetSettings(), SCHEMATIC::Prj(), and SCH_ITEM::Schematic().

Referenced by SCH_LINE::GetEffectiveLineStyle(), SCH_JUNCTION::getEffectiveShape(), SCH_JUNCTION::GetJunctionColor(), SCH_LINE::GetLineColor(), SCH_BUS_WIRE_ENTRY::GetPenWidth(), SCH_LINE::GetPenWidth(), SCH_BUS_BUS_ENTRY::GetPenWidth(), SCH_BUS_ENTRY_BASE::GetStrokeColor(), and SCH_BUS_ENTRY_BASE::GetStrokeStyle().

◆ Offset()

◆ operator<() [1/2]

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

Reimplemented from SCH_ITEM.

Definition at line 864 of file sch_field.cpp.

865 {
866  if( Type() != aItem.Type() )
867  return Type() < aItem.Type();
868 
869  auto field = static_cast<const SCH_FIELD*>( &aItem );
870 
871  if( GetId() != field->GetId() )
872  return GetId() < field->GetId();
873 
874  if( GetText() != field->GetText() )
875  return GetText() < field->GetText();
876 
877  if( GetLibPosition().x != field->GetLibPosition().x )
878  return GetLibPosition().x < field->GetLibPosition().x;
879 
880  if( GetLibPosition().y != field->GetLibPosition().y )
881  return GetLibPosition().y < field->GetLibPosition().y;
882 
883  return GetName() < field->GetName();
884 }
int GetId() const
Definition: sch_field.h:113
wxPoint GetLibPosition() const
Definition: sch_field.h:199
wxString GetName(bool aUseDefaultName=true) const
Return the field name.
Definition: sch_field.cpp:678
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:154
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References GetId(), GetLibPosition(), GetName(), EDA_TEXT::GetText(), and EDA_ITEM::Type().

◆ operator<() [2/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 234 of file eda_item.cpp.

235 {
236  wxFAIL_MSG( wxString::Format( wxT( "Less than operator not defined for item type %s." ),
237  GetClass() ) );
238 
239  return false;
240 }
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
virtual wxString GetClass() const =0
Return the class name.

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

◆ Plot()

void SCH_FIELD::Plot ( PLOTTER aPlotter) const
overridevirtual

Plot the schematic item to aPlotter.

Parameters
aPlotteris the PLOTTER object to plot to.

Reimplemented from SCH_ITEM.

Definition at line 773 of file sch_field.cpp.

774 {
775  RENDER_SETTINGS* settings = aPlotter->RenderSettings();
776  COLOR4D color = settings->GetLayerColor( GetLayer() );
777  int penWidth = GetEffectiveTextPenWidth( settings->GetDefaultPenWidth() );
778 
779  penWidth = std::max( penWidth, settings->GetMinPenWidth() );
780 
781  if( !IsVisible() )
782  return;
783 
784  if( IsVoid() )
785  return;
786 
787  // Calculate the text orientation, according to the symbol orientation/mirror
788  int orient = GetTextAngle();
789 
790  if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
791  {
792  SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
793 
794  if( parentSymbol->GetTransform().y1 ) // Rotate symbol 90 deg.
795  {
796  if( orient == TEXT_ANGLE_HORIZ )
797  orient = TEXT_ANGLE_VERT;
798  else
799  orient = TEXT_ANGLE_HORIZ;
800  }
801  }
802 
803  /*
804  * Calculate the text justification, according to the symbol orientation/mirror.
805  * This is a bit complicated due to cumulative calculations:
806  * - numerous cases (mirrored or not, rotation)
807  * - the plotter's Text function will also recalculate H and V justifications according to
808  * the text orientation.
809  * - When a symbol is mirrored, the text is not mirrored and justifications are complicated
810  * to calculate so the easier way is to use no justifications (centered text) and use
811  * GetBoundingBox to know the text coordinate considered as centered
812  */
815  wxPoint textpos = GetBoundingBox().Centre();
816 
817  aPlotter->Text( textpos, color, GetShownText(), orient, GetTextSize(), hjustify, vjustify,
818  penWidth, IsItalic(), IsBold() );
819 }
#define TEXT_ANGLE_HORIZ
Frequent text rotations, used with {Set,Get}TextAngle(), in 0.1 degrees for now, hoping to migrate to...
Definition: eda_text.h:71
bool IsBold() const
Definition: eda_text.h:204
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:478
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:82
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
int color
Definition: DXF_plotter.cpp:57
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
double GetTextAngle() const
Definition: eda_text.h:195
TRANSFORM & GetTransform()
Definition: sch_symbol.h:232
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: sch_field.cpp:105
bool IsVoid() const
Definition: sch_field.cpp:421
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:159
bool IsItalic() const
Definition: eda_text.h:201
int y1
Definition: transform.h:49
virtual bool IsVisible() const
Definition: eda_text.h:207
const wxSize & GetTextSize() const
Definition: eda_text.h:259
EDA_TEXT_VJUSTIFY_T
Definition: eda_text.h:89
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:259
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:156
Schematic symbol object.
Definition: sch_symbol.h:78
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_field.cpp:305
wxPoint Centre() const
Definition: eda_rect.h:64
int GetDefaultPenWidth() const
virtual void Text(const wxPoint &aPos, const COLOR4D &aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed=false, void *aData=nullptr)
Draw text with the plotter.
Definition: gr_text.cpp:219
#define TEXT_ANGLE_VERT
Definition: eda_text.h:72
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References EDA_RECT::Centre(), color, GetBoundingBox(), KIGFX::RENDER_SETTINGS::GetDefaultPenWidth(), EDA_TEXT::GetEffectiveTextPenWidth(), SCH_ITEM::GetLayer(), KIGFX::RENDER_SETTINGS::GetLayerColor(), KIGFX::RENDER_SETTINGS::GetMinPenWidth(), GetShownText(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextSize(), SCH_SYMBOL::GetTransform(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, EDA_TEXT::IsBold(), EDA_TEXT::IsItalic(), EDA_TEXT::IsVisible(), IsVoid(), EDA_ITEM::m_parent, PLOTTER::RenderSettings(), SCH_SYMBOL_T, PLOTTER::Text(), TEXT_ANGLE_HORIZ, TEXT_ANGLE_VERT, EDA_ITEM::Type(), and TRANSFORM::y1.

Referenced by SCH_GLOBALLABEL::Plot().

◆ Print() [1/2]

void SCH_FIELD::Print ( const RENDER_SETTINGS aSettings,
const wxPoint &  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 202 of file sch_field.cpp.

203 {
204  wxDC* DC = aSettings->GetPrintDC();
206  int orient;
207  wxPoint textpos;
208  int penWidth = GetEffectiveTextPenWidth( aSettings->GetDefaultPenWidth() );
209 
210  if( ( !IsVisible() && !IsForceVisible() ) || IsVoid() )
211  return;
212 
213  // Calculate the text orientation according to the symbol orientation.
214  orient = GetTextAngle();
215 
216  if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
217  {
218  SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
219 
220  if( parentSymbol && parentSymbol->GetTransform().y1 ) // Rotate symbol 90 degrees.
221  {
222  if( orient == TEXT_ANGLE_HORIZ )
223  orient = TEXT_ANGLE_VERT;
224  else
225  orient = TEXT_ANGLE_HORIZ;
226  }
227  }
228 
229  /*
230  * Calculate the text justification, according to the symbol orientation/mirror.
231  * This is a bit complicated due to cumulative calculations:
232  * - numerous cases (mirrored or not, rotation)
233  * - the GRText function will also recalculate H and V justifications according to the text
234  * orientation.
235  * - When a symbol is mirrored, the text is not mirrored and justifications are complicated
236  * to calculate so the more easily way is to use no justifications (centered text) and use
237  * GetBoundingBox to know the text coordinate considered as centered
238  */
239  textpos = GetBoundingBox().Centre() + aOffset;
240 
241  GRText( DC, textpos, color, GetShownText(), orient, GetTextSize(), GR_TEXT_HJUSTIFY_CENTER,
242  GR_TEXT_VJUSTIFY_CENTER, penWidth, IsItalic(), IsBold() );
243 }
#define TEXT_ANGLE_HORIZ
Frequent text rotations, used with {Set,Get}TextAngle(), in 0.1 degrees for now, hoping to migrate to...
Definition: eda_text.h:71
bool IsBold() const
Definition: eda_text.h:204
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:478
int color
Definition: DXF_plotter.cpp:57
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
double GetTextAngle() const
Definition: eda_text.h:195
void GRText(wxDC *aDC, const wxPoint &aPos, const COLOR4D &aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, void(*aCallback)(int x0, int y0, int xf, int yf, void *aData), void *aCallbackData, PLOTTER *aPlotter)
Draw a graphic text (like footprint texts).
Definition: gr_text.cpp:129
TRANSFORM & GetTransform()
Definition: sch_symbol.h:232
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: sch_field.cpp:105
bool IsVoid() const
Definition: sch_field.cpp:421
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
Definition: eda_text.cpp:159
bool IsItalic() const
Definition: eda_text.h:201
int y1
Definition: transform.h:49
SCH_LAYER_ID m_layer
Definition: sch_item.h:487
virtual bool IsVisible() const
Definition: eda_text.h:207
const wxSize & GetTextSize() const
Definition: eda_text.h:259
wxDC * GetPrintDC() const
bool IsForceVisible() const
Definition: eda_item.h:205
Schematic symbol object.
Definition: sch_symbol.h:78
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_field.cpp:305
wxPoint Centre() const
Definition: eda_rect.h:64
int GetDefaultPenWidth() const
#define TEXT_ANGLE_VERT
Definition: eda_text.h:72
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References EDA_RECT::Centre(), color, GetBoundingBox(), KIGFX::RENDER_SETTINGS::GetDefaultPenWidth(), EDA_TEXT::GetEffectiveTextPenWidth(), KIGFX::RENDER_SETTINGS::GetLayerColor(), KIGFX::RENDER_SETTINGS::GetPrintDC(), GetShownText(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextSize(), SCH_SYMBOL::GetTransform(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GRText(), EDA_TEXT::IsBold(), EDA_ITEM::IsForceVisible(), EDA_TEXT::IsItalic(), EDA_TEXT::IsVisible(), IsVoid(), LAYER_HIDDEN, SCH_ITEM::m_layer, EDA_ITEM::m_parent, SCH_SYMBOL_T, TEXT_ANGLE_HORIZ, TEXT_ANGLE_VERT, EDA_ITEM::Type(), and TRANSFORM::y1.

Referenced by SCH_GLOBALLABEL::Print().

◆ Print() [2/2]

void EDA_TEXT::Print ( const RENDER_SETTINGS aSettings,
const wxPoint &  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 420 of file eda_text.cpp.

422 {
423  if( IsMultilineAllowed() )
424  {
425  std::vector<wxPoint> positions;
426  wxArrayString strings;
427  wxStringSplit( GetShownText(), strings, '\n' );
428 
429  positions.reserve( strings.Count() );
430 
431  GetLinePositions( positions, strings.Count() );
432 
433  for( unsigned ii = 0; ii < strings.Count(); ii++ )
434  printOneLineOfText( aSettings, aOffset, aColor, aFillMode, strings[ii], positions[ii] );
435  }
436  else
437  {
438  printOneLineOfText( aSettings, aOffset, aColor, aFillMode, GetShownText(), GetTextPos() );
439  }
440 }
void printOneLineOfText(const RENDER_SETTINGS *aSettings, const wxPoint &aOffset, const COLOR4D &aColor, OUTLINE_MODE aFillMode, const wxString &aText, const wxPoint &aPos)
Print each line of this EDA_TEXT.
Definition: eda_text.cpp:484
bool IsMultilineAllowed() const
Definition: eda_text.h:217
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
void GetLinePositions(std::vector< wxPoint > &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:443
const wxPoint & GetTextPos() const
Definition: eda_text.h:268
virtual wxString GetShownText(int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:162

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

Referenced by SCH_TEXT::Print(), SCH_GLOBALLABEL::Print(), SCH_HIERLABEL::Print(), and DS_DRAW_ITEM_TEXT::PrintWsItem().

◆ Replace() [1/3]

bool SCH_FIELD::Replace ( const wxFindReplaceData &  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 494 of file sch_field.cpp.

495 {
496  wxString text;
497  bool resolve = false; // Replace in source text, not shown text
498  bool isReplaced = false;
499 
500  if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
501  {
502  SCH_SYMBOL* parentSymbol = static_cast<SCH_SYMBOL*>( m_parent );
503 
504  switch( m_id )
505  {
506  case REFERENCE_FIELD:
507  wxCHECK_MSG( aAuxData, false, wxT( "Need sheetpath to replace in refdes." ) );
508 
509  if( !( aSearchData.GetFlags() & FR_REPLACE_REFERENCES ) )
510  return false;
511 
512  text = parentSymbol->GetRef( (SCH_SHEET_PATH*) aAuxData );
513  isReplaced = EDA_ITEM::Replace( aSearchData, text );
514 
515  if( isReplaced )
516  parentSymbol->SetRef( (SCH_SHEET_PATH*) aAuxData, text );
517 
518  break;
519 
520  case VALUE_FIELD:
521  wxCHECK_MSG( aAuxData, false, wxT( "Need sheetpath to replace in value field." ) );
522 
523  text = parentSymbol->GetValue((SCH_SHEET_PATH*) aAuxData, resolve );
524  isReplaced = EDA_ITEM::Replace( aSearchData, text );
525 
526  if( isReplaced )
527  parentSymbol->SetValue( (SCH_SHEET_PATH*) aAuxData, text );
528 
529  break;
530 
531  case FOOTPRINT_FIELD:
532  wxCHECK_MSG( aAuxData, false, wxT( "Need sheetpath to replace in footprint field." ) );
533 
534  text = parentSymbol->GetFootprint((SCH_SHEET_PATH*) aAuxData, resolve );
535  isReplaced = EDA_ITEM::Replace( aSearchData, text );
536 
537  if( isReplaced )
538  parentSymbol->SetFootprint( (SCH_SHEET_PATH*) aAuxData, text );
539 
540  break;
541 
542  default:
543  isReplaced = EDA_TEXT::Replace( aSearchData );
544  }
545  }
546  else if( m_parent && m_parent->Type() == SCH_SHEET_T )
547  {
548  isReplaced = EDA_TEXT::Replace( aSearchData );
549 
550  if( m_id == SHEETFILENAME && isReplaced )
551  {
552  // If we allowed this we'd have a bunch of work to do here, including warning
553  // about it not being undoable, checking for recursive hierarchies, reloading
554  // sheets, etc. See DIALOG_SHEET_PROPERTIES::TransferDataFromWindow().
555  }
556  }
557 
558  return isReplaced;
559 }
Field Reference of part, i.e. "IC21".
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:478
bool Replace(const wxFindReplaceData &aSearchData)
Helper function used in search and replace dialog.
Definition: eda_text.cpp:180
void SetValue(const SCH_SHEET_PATH *sheet, const wxString &aValue)
Definition: sch_symbol.cpp:624
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:464
void SetFootprint(const SCH_SHEET_PATH *sheet, const wxString &aFootprint)
Definition: sch_symbol.cpp:675
Field Value of part, i.e. "3.3K".
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
static bool Replace(const wxFindReplaceData &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:170
const wxString GetValue(const SCH_SHEET_PATH *sheet, bool aResolve) const
Return the instance-specific value for the given sheet path.
Definition: sch_symbol.cpp:596
Schematic symbol object.
Definition: sch_symbol.h:78
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:504
const wxString GetFootprint(const SCH_SHEET_PATH *sheet, bool aResolve) const
Return the instance-specific footprint assignment for the given sheet path.
Definition: sch_symbol.cpp:654
int m_id
Field index,.
Definition: sch_field.h:220
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
Field Name Module PCB, i.e. "16DIP300".

References FOOTPRINT_FIELD, FR_REPLACE_REFERENCES, SCH_SYMBOL::GetFootprint(), SCH_SYMBOL::GetRef(), SCH_SYMBOL::GetValue(), m_id, EDA_ITEM::m_parent, REFERENCE_FIELD, EDA_TEXT::Replace(), EDA_ITEM::Replace(), SCH_SHEET_T, SCH_SYMBOL_T, SCH_SYMBOL::SetFootprint(), SCH_SYMBOL::SetRef(), SCH_SYMBOL::SetValue(), SHEETFILENAME, text, EDA_ITEM::Type(), and VALUE_FIELD.

◆ Replace() [2/3]

bool EDA_TEXT::Replace ( const wxFindReplaceData &  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 wxFindReplaceData object containing the search and replace criteria.
Returns
True if the text item was modified, otherwise false.

Definition at line 180 of file eda_text.cpp.

181 {
182  bool retval = EDA_ITEM::Replace( aSearchData, m_text );
183  cacheShownText();
184 
185  return retval;
186 }
void cacheShownText()
Definition: eda_text.cpp:189
wxString m_text
Definition: eda_text.h:411
static bool Replace(const wxFindReplaceData &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:170

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

Referenced by SCH_SHEET_PIN::Replace(), Replace(), and SCH_TEXT::Replace().

◆ Replace() [3/3]

bool EDA_ITEM::Replace ( const wxFindReplaceData &  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 170 of file eda_item.cpp.

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

References next(), and text.

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

◆ Rotate()

void SCH_FIELD::Rotate ( const wxPoint &  aCenter)
overridevirtual

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

Implements SCH_ITEM.

Definition at line 562 of file sch_field.cpp.

563 {
564  wxPoint pt = GetPosition();
565  RotatePoint( &pt, aCenter, 900 );
566  SetPosition( pt );
567 }
wxPoint GetPosition() const override
Definition: sch_field.cpp:842
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
void SetPosition(const wxPoint &aPosition) override
Definition: sch_field.cpp:822

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

Referenced by SCH_EDIT_TOOL::Rotate().

◆ RunOnChildren()

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

Reimplemented in SCH_SYMBOL, SCH_SHEET, and SCH_GLOBALLABEL.

Definition at line 444 of file sch_item.h.

444 { }

Referenced by SCH_ITEM::Duplicate(), SCH_SHEET_LIST::GetItem(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ 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 104 of file sch_item.cpp.

105 {
106  EDA_ITEM* parent = GetParent();
107 
108  while( parent )
109  {
110  if( parent->Type() == SCHEMATIC_T )
111  return static_cast<SCHEMATIC*>( parent );
112  else
113  parent = parent->GetParent();
114  }
115 
116  return nullptr;
117 }
EDA_ITEM * GetParent() const
Definition: eda_item.h:114
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

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

Referenced by SCH_ITEM::Connection(), SCH_DRAWING_TOOLS::createSheetPin(), DIALOG_SCH_FIELD_PROPERTIES::DIALOG_SCH_FIELD_PROPERTIES(), DoHypertextMenu(), SCH_GLOBALLABEL::GetBoundingBox(), SCH_MARKER::GetColorLayer(), SCH_JUNCTION::getEffectiveShape(), SCH_TEXT::GetLabelBoxExpansion(), SCH_BUS_ENTRY_BASE::GetMsgPanelInfo(), SCH_LINE::GetMsgPanelInfo(), SCH_TEXT::GetMsgPanelInfo(), SCH_NO_CONNECT::GetPenWidth(), SCH_SHEET_PIN::GetPenWidth(), SCH_LINE::GetPenWidth(), SCH_SHEET::GetPenWidth(), SCH_SYMBOL::GetPins(), GetShownText(), SCH_TEXT::GetShownText(), SCH_TEXT::GetTextOffset(), SCH_PIN::HitTest(), SCH_GLOBALLABEL::HitTest(), inheritNetclass(), SCH_SHEET::IsRootSheet(), SCH_LABEL::IsType(), SCH_ITEM::NetClass(), DIALOG_SYMBOL_PROPERTIES::OnAddField(), DIALOG_TEXT_AND_LABEL_PROPERTIES::onScintillaCharAdded(), DIALOG_SCH_FIELD_PROPERTIES::onScintillaCharAdded(), SCH_GLOBALLABEL::Plot(), SCH_GLOBALLABEL::Print(), SCH_HIERLABEL::Print(), SCH_SHEET::ResolveTextVar(), SCH_SYMBOL::ResolveTextVar(), SCH_GLOBALLABEL::ResolveTextVar(), DIALOG_SCH_FIELD_PROPERTIES::UpdateField(), and SCH_MARKER::ViewGetLayers().

◆ Set() [1/3]

bool INSPECTABLE::Set ( PROPERTY_BASE aProperty,
wxAny &  aValue 
)
inlineinherited

Definition at line 42 of file inspectable.h.

43  {
45  TYPE_ID thisType = TYPE_HASH( *this );
46  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
47 
48  if( object )
49  aProperty->setter( object, aValue );
50 
51  return object != nullptr;
52  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:65
#define TYPE_HASH(x)
Definition: property.h:59
size_t TYPE_ID
Unique type identifier.
Definition: property_mgr.h:42
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Cast a type to another type.
virtual void setter(void *aObject, wxAny &aValue)=0
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:62
virtual size_t OwnerHash() const =0
Return type-id of the Owner class.

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

◆ Set() [2/3]

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

Definition at line 55 of file inspectable.h.

56  {
58  TYPE_ID thisType = TYPE_HASH( *this );
59  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
60 
61  if( object )
62  aProperty->set<T>( object, aValue );
63 
64  return object != nullptr;
65  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:65
#define TYPE_HASH(x)
Definition: property.h:59
size_t TYPE_ID
Unique type identifier.
Definition: property_mgr.h:42
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Cast a type to another type.
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:62
void set(void *aObject, T aValue)
Definition: property.h:261
virtual size_t OwnerHash() const =0
Return type-id of the Owner class.

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

◆ Set() [3/3]

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

Definition at line 68 of file inspectable.h.

69  {
71  TYPE_ID thisType = TYPE_HASH( *this );
72  PROPERTY_BASE* prop = propMgr.GetProperty( thisType, aProperty );
73  void* object = nullptr;
74 
75  if( prop )
76  {
77  object = propMgr.TypeCast( this, thisType, prop->OwnerHash() );
78 
79  if( object )
80  prop->set<T>( object, aValue );
81  }
82 
83  return object != nullptr;
84  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:65
#define TYPE_HASH(x)
Definition: property.h:59
size_t TYPE_ID
Unique type identifier.
Definition: property_mgr.h:42
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Cast a type to another type.
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Return a property for a specific type.
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:62
void set(void *aObject, T aValue)
Definition: property.h:261
virtual size_t OwnerHash() const =0
Return type-id of the Owner class.

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

◆ SetBold()

◆ SetBrightened()

◆ SetConnectivityDirty()

void SCH_ITEM::SetConnectivityDirty ( bool  aDirty = true)
inlineinherited

◆ SetEffects()

void EDA_TEXT::SetEffects ( const EDA_TEXT aSrc)
inherited

Set the text effects from another instance.

TEXT_EFFECTS is not exposed in the public API, but includes everything except the actual text string itself.

Definition at line 139 of file eda_text.cpp.

140 {
141  m_e = aSrc.m_e;
142 }
TEXT_EFFECTS m_e
Definition: eda_text.h:415

References EDA_TEXT::m_e.

Referenced by LIB_TEXT::Clone(), LIB_FIELD::Copy(), ImportValues(), DIALOG_UPDATE_SYMBOL_FIELDS::onOkButtonClicked(), LIB_FIELD::operator=(), DIALOG_CHANGE_SYMBOLS::processSymbol(), CLIPBOARD_IO::SaveSelection(), and FP_TEXT::SetEffects().

◆ SetFieldsAutoplaced()

void SCH_ITEM::SetFieldsAutoplaced ( )
inlineinherited

Definition at line 426 of file sch_item.h.

References FIELDS_AUTOPLACED_AUTO, and SCH_ITEM::m_fieldsAutoplaced.

◆ SetFlags()

void EDA_ITEM::SetFlags ( EDA_ITEM_FLAGS  aMask)
inlineinherited

Definition at line 152 of file eda_item.h.

152 { m_flags |= aMask; }
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480

References EDA_ITEM::m_flags.

Referenced by SCH_EAGLE_PLUGIN::addBusEntries(), PCB_BASE_FRAME::AddFootprintToBoard(), FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), SCH_MOVE_TOOL::AlignElements(), PCB_CONTROL::AppendBoard(), FOOTPRINT::BuildPolyCourtyards(), SCH_EDIT_TOOL::ChangeTextType(), GRAPHICS_CLEANER::cleanupShapes(), ConvertOutlineToPolygon(), SCH_EDIT_FRAME::ConvertPart(), SCH_DRAWING_TOOLS::createNewText(), SCH_DRAWING_TOOLS::createSheetPin(), SCH_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), EDIT_TOOL::DragArcTrack(), KIGFX::SCH_PAINTER::draw(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), PCB_SELECTION_TOOL::EnterGroup(), PCB_SELECTION_TOOL::FilterCollectorForHierarchy(), SCH_MOVE_TOOL::getConnectedDragItems(), SYMBOL_EDIT_FRAME::GetSymbolFromRedoList(), SYMBOL_EDIT_FRAME::GetSymbolFromUndoList(), EE_SELECTION_TOOL::Main(), TRACKS_CLEANER::mergeCollinearSegments(), SYMBOL_EDITOR_MOVE_TOOL::moveItem(), SCH_MOVE_TOOL::moveItem(), EE_SELECTION_TOOL::narrowSelection(), KIGFX::ORIGIN_VIEWITEM::ORIGIN_VIEWITEM(), SCH_ALTIUM_PLUGIN::ParseBezier(), SCH_ALTIUM_PLUGIN::ParseBus(), SCH_ALTIUM_PLUGIN::ParseBusEntry(), SCH_ALTIUM_PLUGIN::ParseJunction(), SCH_ALTIUM_PLUGIN::ParseLabel(), SCH_ALTIUM_PLUGIN::ParseLine(), SCH_ALTIUM_PLUGIN::ParseNetLabel(), SCH_ALTIUM_PLUGIN::ParseNoERC(), SCH_ALTIUM_PLUGIN::ParsePolygon(), SCH_ALTIUM_PLUGIN::ParsePolyline(), SCH_ALTIUM_PLUGIN::ParsePort(), SCH_ALTIUM_PLUGIN::ParseRectangle(), SCH_ALTIUM_PLUGIN::ParseRoundRectangle(), SCH_ALTIUM_PLUGIN::ParseSheetSymbol(), SCH_ALTIUM_PLUGIN::ParseWire(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), BOARD_EDITOR_CONTROL::PlaceFootprint(), PL_DRAWING_TOOLS::PlaceItem(), DRAWING_TOOL::PlaceText(), SCH_SYMBOL::Plot(), BACK_ANNOTATE::processNetNameChange(), SCH_EDIT_FRAME::PutDataInPreviousState(), PCB_SELECTION_TOOL::RebuildSelection(), FOOTPRINT::Remove(), BOARD::Remove(), SCH_EDIT_TOOL::RepeatDrawItem(), SCH_EDIT_TOOL::Rotate(), SYMBOL_EDIT_FRAME::SaveCopyInUndoList(), SCH_EDIT_FRAME::SelectUnit(), EDA_ITEM::SetBrightened(), EDA_ITEM::SetModified(), EDA_ITEM::SetSelected(), EDA_ITEM::SetWireImage(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_LINE_WIRE_BUS_TOOL::startSegments(), DS_DATA_ITEM::SyncDrawItems(), DS_DATA_ITEM_BITMAP::SyncDrawItems(), DIALOG_DIMENSION_PROPERTIES::TransferDataFromWindow(), DIALOG_TARGET_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ SetForceVisible()

void EDA_ITEM::SetForceVisible ( bool  aEnable)
inlineinherited

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.

Parameters
aEnableTrue forces the item to be drawn. False uses the item's visibility setting to determine if the item is to be drawn.

Definition at line 203 of file eda_item.h.

203 { m_forceVisible = aEnable; }
bool m_forceVisible
Definition: eda_item.h:479

References EDA_ITEM::m_forceVisible.

Referenced by SCH_EDITOR_CONTROL::UpdateFind().

◆ SetHorizJustify()

void EDA_TEXT::SetHorizJustify ( EDA_TEXT_HJUSTIFY_T  aType)
inlineinherited

Definition at line 222 of file eda_text.h.

222 { m_e.hjustify = aType; };
TEXT_EFFECTS m_e
Definition: eda_text.h:415
signed char hjustify
horizontal justification
Definition: eda_text.h:122

References TEXT_EFFECTS::hjustify, and EDA_TEXT::m_e.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::addAttribute(), GRAPHICS_IMPORTER_PCBNEW::AddText(), CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings(), SCH_GLOBALLABEL::AutoplaceFields(), PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems(), CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText(), eagleToKicadAlignment(), EDA_TEXT_DESC::EDA_TEXT_DESC(), ALTIUM_PCB::HelperParseDimensions6Radial(), AUTOPLACER::justifyField(), FP_TEXT::KeepUpright(), CADSTAR_PCB_ARCHIVE_LOADER::loadDimensions(), SCH_LEGACY_PLUGIN_CACHE::loadField(), SCH_EAGLE_PLUGIN::loadFieldAttributes(), FABMASTER::loadFootprints(), LEGACY_PLUGIN::loadMODULE_TEXT(), LEGACY_PLUGIN::loadPCB_TEXT(), EAGLE_PLUGIN::loadPlain(), SCH_LEGACY_PLUGIN::loadSymbol(), SCH_EDIT_TOOL::Mirror(), LIB_TEXT::MirrorHorizontal(), SCH_GLOBALLABEL::MirrorHorizontally(), SCH_GLOBALLABEL::MirrorSpinStyle(), LIB_TEXT::MirrorVertical(), EAGLE_PLUGIN::orientFPText(), EAGLE_PLUGIN::packageText(), SCH_SEXPR_PARSER::parseEDA_TEXT(), PCB_PARSER::parseEDA_TEXT(), SCH_ALTIUM_PLUGIN::ParsePowerPort(), ALTIUM_PCB::ParseTexts6Data(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), LIB_TEXT::Rotate(), SCH_GLOBALLABEL::Rotate90(), SCH_TEXT::SetLabelSpinStyle(), SCH_GLOBALLABEL::SetLabelSpinStyle(), SCH_HIERLABEL::SetLabelSpinStyle(), PCAD2KICAD::SetTextJustify(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_FIELD_PROPERTIES::UpdateField(), and DIALOG_SCH_FIELD_PROPERTIES::UpdateField().

◆ SetId()

void SCH_FIELD::SetId ( int  aId)

Definition at line 80 of file sch_field.cpp.

81 {
82  m_id = aId;
83 
84  if( m_parent && m_parent->Type() == SCH_SHEET_T )
85  {
86  switch( m_id )
87  {
88  case SHEETNAME: SetLayer( LAYER_SHEETNAME ); break;
90  default: SetLayer( LAYER_SHEETFIELDS ); break;
91  }
92  }
93  else
94  {
95  switch( m_id )
96  {
98  case VALUE_FIELD: SetLayer( LAYER_VALUEPART ); break;
99  default: SetLayer( LAYER_FIELDS ); break;
100  }
101  }
102 }
Field Reference of part, i.e. "IC21".
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:478
Field Value of part, i.e. "3.3K".
void SetLayer(SCH_LAYER_ID aLayer)
Set the layer this item is on.
Definition: sch_item.h:266
int m_id
Field index,.
Definition: sch_field.h:220
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References LAYER_FIELDS, LAYER_REFERENCEPART, LAYER_SHEETFIELDS, LAYER_SHEETFILENAME, LAYER_SHEETNAME, LAYER_VALUEPART, m_id, EDA_ITEM::m_parent, REFERENCE_FIELD, SCH_SHEET_T, SCH_ITEM::SetLayer(), SHEETFILENAME, SHEETNAME, EDA_ITEM::Type(), and VALUE_FIELD.

Referenced by SCH_SEXPR_PARSER::parseSchematicSymbol(), SCH_SEXPR_PARSER::parseSheet(), SCH_SEXPR_PLUGIN::saveField(), and SCH_FIELD().

◆ SetItalic()

void EDA_TEXT::SetItalic ( bool  isItalic)
inlineinherited

◆ SetLastResolvedState()

virtual void SCH_ITEM::SetLastResolvedState ( const SCH_ITEM aItem)
inlinevirtualinherited

Reimplemented in SCH_LINE, SCH_JUNCTION, and SCH_BUS_ENTRY_BASE.

Definition at line 417 of file sch_item.h.

417 { }

Referenced by SCH_EDITOR_CONTROL::Paste().

◆ SetLayer()

void SCH_ITEM::SetLayer ( SCH_LAYER_ID  aLayer)
inlineinherited

◆ SetLocked()

virtual void SCH_ITEM::SetLocked ( bool  aLocked)
inlinevirtualinherited

Set the 'lock' status to aLocked for of this item.

Definition at line 247 of file sch_item.h.

247 {}

◆ SetMirrored()