KiCad PCB EDA Suite
PCB_SHAPE Class Reference

#include <pcb_shape.h>

Inheritance diagram for PCB_SHAPE:
BOARD_ITEM EDA_ITEM KIGFX::VIEW_ITEM INSPECTABLE FP_SHAPE

Classes

struct  cmp_drawings
 

Public Member Functions

 PCB_SHAPE (BOARD_ITEM *aParent=nullptr, KICAD_T idtype=PCB_SHAPE_T)
 
 ~PCB_SHAPE ()
 
bool IsType (const KICAD_T aScanTypes[]) const override
 Check whether the item is one of the listed types. More...
 
void SetFilled (bool aFlag)
 
bool IsFilled () const
 
void SetWidth (int aWidth)
 
int GetWidth () const
 
virtual void SetAngle (double aAngle, bool aUpdateEnd=true)
 Set the angle for arcs, and normalizes it within the range 0 - 360 degrees. More...
 
double GetAngle () const
 
void SetShape (SHAPE_T aShape)
 
SHAPE_T GetShape () const
 
void SetBezierC1 (const wxPoint &aPoint)
 
const wxPoint & GetBezierC1 () const
 
void SetBezierC2 (const wxPoint &aPoint)
 
const wxPoint & GetBezierC2 () const
 
void SetPosition (const wxPoint &aPos) override
 
wxPoint GetPosition () const override
 
const wxPoint & GetStart () const
 Return the starting point of the graphic. More...
 
int GetStartY ()
 
int GetStartX ()
 
void SetStart (const wxPoint &aStart)
 
void SetStartY (int y)
 
void SetStartX (int x)
 
const wxPoint & GetEnd () const
 Return the ending point of the graphic. More...
 
int GetEndY ()
 
int GetEndX ()
 
void SetEnd (const wxPoint &aEnd)
 
void SetEndY (int y)
 
void SetEndX (int x)
 
const wxPoint & GetThirdPoint () const
 Return the third point of the graphic. More...
 
int GetThirdPointY ()
 
int GetThirdPointX ()
 
void SetThirdPoint (const wxPoint &aPoint)
 
void SetThirdPointY (int y)
 
void SetThirdPointX (int x)
 
wxPoint GetCenter () const override
 This defaults to the center of the bounding box if not overridden. More...
 
wxPoint GetArcStart () const
 
wxPoint GetArcEnd () const
 
wxPoint GetArcMid () const
 
std::vector< wxPoint > GetRectCorners () const
 
double GetArcAngleStart () const
 
double GetArcAngleEnd () const
 
int GetRadius () const
 Return the radius of this item. More...
 
void SetArcStart (const wxPoint &aArcStartPoint)
 Initialize the start arc point. More...
 
void SetArcEnd (const wxPoint &aArcEndPoint)
 Initialize the end arc point. More...
 
void SetCenter (const wxPoint &aCenterPoint)
 
void SetArcGeometry (const wxPoint &aStart, const wxPoint &aMid, const wxPoint &aEnd)
 Set the three controlling points for an arc. More...
 
const wxPoint GetFocusPosition () const override
 Allows items to return their visual center rather than their anchor. More...
 
FOOTPRINTGetParentFootprint () const
 Return the parent footprint or NULL if PCB_SHAPE does not belong to a footprint. More...
 
const std::vector< wxPoint > & GetBezierPoints () const
 
void DupPolyPointsList (std::vector< wxPoint > &aBuffer) const
 Duplicate the list of corners in a std::vector<wxPoint> More...
 
int GetPointCount () const
 
SHAPE_POLY_SETGetPolyShape ()
 
const SHAPE_POLY_SETGetPolyShape () const
 
bool IsPolyShapeValid () const
 
void SetPolyShape (const SHAPE_POLY_SET &aShape)
 
void SetBezierPoints (const std::vector< wxPoint > &aPoints)
 
void RebuildBezierToSegmentsPointsList (int aMinSegLen)
 Rebuild the m_BezierPoints vertex list that approximate the Bezier curve by a list of segments. More...
 
void SetPolyPoints (const std::vector< wxPoint > &aPoints)
 
std::vector< SHAPE * > MakeEffectiveShapes () const
 Make a set of SHAPE objects representing the PCB_SHAPE. More...
 
std::shared_ptr< SHAPEGetEffectiveShape (PCB_LAYER_ID aLayer=UNDEFINED_LAYER) const override
 Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes. 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...
 
const EDA_RECT GetBoundingBox () const override
 Return the orthogonal bounding box of this object for display purposes. More...
 
bool HitTest (const wxPoint &aPosition, int aAccuracy=0) const override
 Test if aPosition is contained within or on the bounding box of an item. More...
 
bool HitTest (const EDA_RECT &aRect, bool aContained, int aAccuracy=0) const override
 Test if aRect intersects or is contained within the bounding box of an item. More...
 
wxString GetClass () const override
 Return the class name. More...
 
double GetLength () const
 Return the length of the track using the hypotenuse calculation. More...
 
virtual void Move (const wxPoint &aMoveVector) override
 Move this object. More...
 
virtual void Rotate (const wxPoint &aRotCentre, double aAngle) override
 Rotate this object. More...
 
virtual void Flip (const wxPoint &aCentre, bool aFlipLeftRight) override
 Flip this object, i.e. More...
 
void Scale (double aScale)
 
void TransformShapeWithClearanceToPolygon (SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
 Convert the draw segment to a closed polygon. More...
 
virtual 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...
 
virtual BITMAPS GetMenuImage () const override
 Return a pointer to an image to be used in menus. More...
 
virtual EDA_ITEMClone () const override
 Create a duplicate of this item with linked list members set to NULL. More...
 
virtual const BOX2I ViewBBox () const override
 Return the bounding box of the item covering all its layers. More...
 
virtual void SwapData (BOARD_ITEM *aImage) override
 Swap data between aItem and aImage. More...
 
void SetParentGroup (PCB_GROUP *aGroup)
 
PCB_GROUPGetParentGroup () const
 
int GetX () const
 
int GetY () const
 
void SetX (int aX)
 
void SetY (int aY)
 
virtual bool IsConnected () const
 Returns information if the object is derived from BOARD_CONNECTED_ITEM. More...
 
virtual bool IsOnCopperLayer () const
 
BOARD_ITEM_CONTAINERGetParent () const
 
virtual PCB_LAYER_ID GetLayer () const
 Return the primary layer this item is on. More...
 
virtual LSET GetLayerSet () const
 Return a std::bitset of all layers on which the item physically resides. More...
 
virtual void SetLayerSet (LSET aLayers)
 
virtual void SetLayer (PCB_LAYER_ID aLayer)
 Set the layer this item is on. More...
 
virtual BOARD_ITEMDuplicate () const
 Create a copy of this BOARD_ITEM. More...
 
virtual bool IsOnLayer (PCB_LAYER_ID aLayer) const
 Test to see if this object is on the given layer. More...
 
bool IsTrack () const
 Test to see if this object is a track or via (or microvia). More...
 
virtual bool IsLocked () const
 
virtual void SetLocked (bool aLocked)
 Modify the 'lock' status for of the item. More...
 
void DeleteStructure ()
 Delete this object after removing from its parent if it has one. More...
 
void Move (const VECTOR2I &aMoveVector)
 
void Rotate (const VECTOR2I &aRotCentre, double aAngle)
 
void Flip (const VECTOR2I &aCentre, bool aFlipLeftRight)
 
virtual const BOARDGetBoard () const
 Return the BOARD in which this BOARD_ITEM resides, or NULL if none. More...
 
virtual BOARDGetBoard ()
 
wxString GetLayerName () const
 Return the name of the PCB layer on which the item resides. More...
 
virtual void ViewGetLayers (int aLayers[], int &aCount) const override
 Return the all the layers within the VIEW the object is painted on. More...
 
KICAD_T Type () const
 Returns the type of object. More...
 
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 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 bool Matches (const wxFindReplaceData &aSearchData, void *aAuxData) const
 Compare the item against the search criteria in aSearchData. More...
 
virtual bool Replace (const wxFindReplaceData &aSearchData, void *aAuxData=nullptr)
 Perform a text replace using the find and replace criteria in aSearchData on items that support text find and replace. More...
 
virtual bool IsReplaceable () const
 Override this method in any derived object that supports test find and replace. More...
 
bool operator< (const EDA_ITEM &aItem) const
 Test if another item is less than this object. 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)
 

Static Public Member Functions

static bool ClassOf (const EDA_ITEM *aItem)
 
static wxString ShowShape (SHAPE_T aShape)
 Convert the enum #PCB_SHAPE_TYPE_T integer value to a wxString. More...
 
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...
 

Public Attributes

const KIID m_Uuid
 

Static Public Attributes

static wxPoint ZeroOffset
 A value of wxPoint(0,0) which can be passed to the Draw() functions. More...
 

Protected Member Functions

void computeArcBBox (EDA_RECT &aBBox) const
 
const std::vector< wxPoint > buildBezierToSegmentsPointsList (int aMinSegLen) const
 
virtual wxString layerMaskDescribe () const
 Return a string (to be shown to the user) describing a layer mask. More...
 
bool Matches (const wxString &aText, const wxFindReplaceData &aSearchData) const
 Compare aText against search criteria in aSearchData. More...
 

Protected Attributes

int m_width
 
bool m_filled
 
wxPoint m_start
 
wxPoint m_end
 
wxPoint m_thirdPoint
 
SHAPE_T m_shape
 
double m_angle
 
wxPoint m_bezierC1
 
wxPoint m_bezierC2
 
std::vector< wxPoint > m_bezierPoints
 
SHAPE_POLY_SET m_poly
 
PCB_LAYER_ID m_layer
 
PCB_GROUPm_group
 
EDA_ITEM_FLAGS m_status
 
EDA_ITEMm_parent
 Linked list: Link (parent struct) More...
 
bool m_forceVisible
 
EDA_ITEM_FLAGS m_flags
 

Detailed Description

Definition at line 42 of file pcb_shape.h.

Constructor & Destructor Documentation

◆ PCB_SHAPE()

PCB_SHAPE::PCB_SHAPE ( BOARD_ITEM aParent = nullptr,
KICAD_T  idtype = PCB_SHAPE_T 
)

Definition at line 48 of file pcb_shape.cpp.

48  :
49  BOARD_ITEM( aParent, idtype )
50 {
51  m_angle = 0;
52  m_filled = false;
53  m_flags = 0;
56 }
usual segment : line with rounded ends
#define DEFAULT_LINE_WIDTH
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:481
double m_angle
Definition: pcb_shape.h:350
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype)
Definition: board_item.h:83
int m_width
Definition: pcb_shape.h:343
bool m_filled
Definition: pcb_shape.h:344
SHAPE_T m_shape
Definition: pcb_shape.h:349
static constexpr int Millimeter2iu(double mm)

References DEFAULT_LINE_WIDTH, m_angle, m_filled, EDA_ITEM::m_flags, m_shape, m_width, Millimeter2iu(), and SEGMENT.

Referenced by Clone().

◆ ~PCB_SHAPE()

PCB_SHAPE::~PCB_SHAPE ( )

Definition at line 59 of file pcb_shape.cpp.

60 {
61 }

Member Function Documentation

◆ buildBezierToSegmentsPointsList()

const std::vector< wxPoint > PCB_SHAPE::buildBezierToSegmentsPointsList ( int  aMinSegLen) const
protected

Definition at line 372 of file pcb_shape.cpp.

373 {
374  std::vector<wxPoint> bezierPoints;
375 
376  // Rebuild the m_BezierPoints vertex list that approximate the Bezier curve
377  std::vector<wxPoint> ctrlPoints = { m_start, m_bezierC1, m_bezierC2, m_end };
378  BEZIER_POLY converter( ctrlPoints );
379  converter.GetPoly( bezierPoints, aMinSegLen );
380 
381  return bezierPoints;
382 }
wxPoint m_end
Definition: pcb_shape.h:346
wxPoint m_start
Definition: pcb_shape.h:345
Bezier curves to polygon converter.
Definition: bezier_curves.h:36
wxPoint m_bezierC1
Definition: pcb_shape.h:351
wxPoint m_bezierC2
Definition: pcb_shape.h:352

References BEZIER_POLY::GetPoly(), m_bezierC1, m_bezierC2, m_end, and m_start.

Referenced by MakeEffectiveShapes(), and RebuildBezierToSegmentsPointsList().

◆ ClassOf()

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

Definition at line 52 of file pcb_shape.h.

53  {
54  return aItem && PCB_SHAPE_T == aItem->Type();
55  }
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

References PCB_SHAPE_T, and EDA_ITEM::Type().

◆ ClearBrightened()

void EDA_ITEM::ClearBrightened ( )
inlineinherited

◆ ClearEditFlags()

◆ ClearFlags()

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

Definition at line 154 of file eda_item.h.

154 { m_flags &= ~aMask; }
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:481

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(), 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 166 of file eda_item.h.

167  {
169  DO_NOT_DRAW );
170  }
#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:154
#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 148 of file view_item.h.

149  {
150  m_viewPrivData = nullptr;
151  }
VIEW_ITEM_DATA * m_viewPrivData
Definition: view_item.h:156

References KIGFX::VIEW_ITEM::m_viewPrivData.

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

◆ Clone()

EDA_ITEM * PCB_SHAPE::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.

Reimplemented in FP_SHAPE.

Definition at line 1022 of file pcb_shape.cpp.

1023 {
1024  return new PCB_SHAPE( *this );
1025 }
PCB_SHAPE(BOARD_ITEM *aParent=nullptr, KICAD_T idtype=PCB_SHAPE_T)
Definition: pcb_shape.cpp:48

References PCB_SHAPE().

Referenced by DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run().

◆ computeArcBBox()

void PCB_SHAPE::computeArcBBox ( EDA_RECT aBBox) const
protected

Definition at line 1085 of file pcb_shape.cpp.

1086 {
1087  // Do not include the center, which is not necessarily
1088  // inside the BB of a arc with a small angle
1089  aBBox.SetOrigin( m_end );
1090 
1091  wxPoint end = m_end;
1092  RotatePoint( &end, m_start, -m_angle );
1093  aBBox.Merge( end );
1094 
1095  // Determine the starting quarter
1096  // 0 right-bottom
1097  // 1 left-bottom
1098  // 2 left-top
1099  // 3 right-top
1100  unsigned int quarter = 0; // assume right-bottom
1101 
1102  if( m_end.x < m_start.x )
1103  {
1104  if( m_end.y <= m_start.y )
1105  quarter = 2;
1106  else // ( m_End.y > m_Start.y )
1107  quarter = 1;
1108  }
1109  else if( m_end.x >= m_start.x )
1110  {
1111  if( m_end.y < m_start.y )
1112  quarter = 3;
1113  else if( m_end.x == m_start.x )
1114  quarter = 1;
1115  }
1116 
1117  int radius = GetRadius();
1118  int angle = (int) GetArcAngleStart() % 900 + m_angle;
1119  bool directionCW = ( m_angle > 0 ); // Is the direction of arc clockwise?
1120 
1121  // Make the angle positive, so we go clockwise and merge points belonging to the arc
1122  if( !directionCW )
1123  {
1124  angle = 900 - angle;
1125  quarter = ( quarter + 3 ) % 4; // -1 modulo arithmetic
1126  }
1127 
1128  while( angle > 900 )
1129  {
1130  switch( quarter )
1131  {
1132  case 0: aBBox.Merge( wxPoint( m_start.x, m_start.y + radius ) ); break; // down
1133  case 1: aBBox.Merge( wxPoint( m_start.x - radius, m_start.y ) ); break; // left
1134  case 2: aBBox.Merge( wxPoint( m_start.x, m_start.y - radius ) ); break; // up
1135  case 3: aBBox.Merge( wxPoint( m_start.x + radius, m_start.y ) ); break; // right
1136  }
1137 
1138  if( directionCW )
1139  ++quarter;
1140  else
1141  quarter += 3; // -1 modulo arithmetic
1142 
1143  quarter %= 4;
1144  angle -= 900;
1145  }
1146 
1147  aBBox.Inflate( m_width ); // Technically m_width / 2, but it doesn't hurt to have the
1148  // bounding box a bit large to account for drawing clearances,
1149  // etc.
1150 }
wxPoint m_end
Definition: pcb_shape.h:346
void Merge(const EDA_RECT &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: eda_rect.cpp:432
int GetRadius() const
Return the radius of this item.
Definition: pcb_shape.cpp:487
double GetArcAngleStart() const
Definition: pcb_shape.cpp:457
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:121
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
double m_angle
Definition: pcb_shape.h:350
wxPoint m_start
Definition: pcb_shape.h:345
int m_width
Definition: pcb_shape.h:343
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:364

References PNS::angle(), GetArcAngleStart(), GetRadius(), EDA_RECT::Inflate(), m_angle, m_end, m_start, m_width, EDA_RECT::Merge(), RotatePoint(), and EDA_RECT::SetOrigin().

Referenced by GetBoundingBox(), and ViewBBox().

◆ DeleteStructure()

void BOARD_ITEM::DeleteStructure ( )
inherited

Delete this object after removing from its parent if it has one.

Definition at line 140 of file board_item.cpp.

141 {
142  BOARD_ITEM_CONTAINER* parent = GetParent();
143 
144  if( parent )
145  parent->Remove( this );
146 
147  delete this;
148 }
virtual void Remove(BOARD_ITEM *aItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL)=0
Removes an item from the container.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:166

References BOARD_ITEM::GetParent(), and BOARD_ITEM_CONTAINER::Remove().

Referenced by BOARD::PadDelete(), and DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow().

◆ Duplicate()

virtual BOARD_ITEM* BOARD_ITEM::Duplicate ( ) const
inlinevirtualinherited

Create a copy of this BOARD_ITEM.

Reimplemented in FOOTPRINT.

Definition at line 200 of file board_item.h.

201  {
202  EDA_ITEM* dupe = Clone();
203  const_cast<KIID&>( dupe->m_Uuid ) = KIID();
204 
205  return static_cast<BOARD_ITEM*>( dupe );
206  }
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:83
Definition: kiid.h:44
const KIID m_Uuid
Definition: eda_item.h:475
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100

References EDA_ITEM::Clone(), and EDA_ITEM::m_Uuid.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::addAttribute(), PCB_GROUP::DeepDuplicate(), KIGFX::PCB_PAINTER::draw(), DRAWING_TOOL::DrawBoardCharacteristics(), CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText(), DRAWING_TOOL::DrawSpecificationStackup(), EDIT_TOOL::Duplicate(), and ARRAY_CREATOR::Invoke().

◆ DupPolyPointsList()

void PCB_SHAPE::DupPolyPointsList ( std::vector< wxPoint > &  aBuffer) const

Duplicate the list of corners in a std::vector<wxPoint>

It must be used only to convert the SHAPE_POLY_SET internal corner buffer to a list of wxPoints, and nothing else, because it duplicates the buffer, that is inefficient to know for instance the corner count

Definition at line 1277 of file pcb_shape.cpp.

1278 {
1279  if( m_poly.OutlineCount() )
1280  {
1281  int pointCount = m_poly.COutline( 0 ).PointCount();
1282 
1283  if( pointCount )
1284  {
1285  aBuffer.reserve( pointCount );
1286 
1287  for ( auto iter = m_poly.CIterate(); iter; iter++ )
1288  aBuffer.emplace_back( iter->x, iter->y );
1289  }
1290  }
1291 }
int OutlineCount() const
Return the number of vertices in a given outline/hole.
int PointCount() const
Return the number of points (vertices) in this line chain.
SHAPE_POLY_SET m_poly
Definition: pcb_shape.h:355
CONST_ITERATOR CIterate(int aFirst, int aLast, bool aIterateHoles=false) const
const SHAPE_LINE_CHAIN & COutline(int aIndex) const

References SHAPE_POLY_SET::CIterate(), SHAPE_POLY_SET::COutline(), m_poly, SHAPE_POLY_SET::OutlineCount(), and SHAPE_LINE_CHAIN::PointCount().

Referenced by PCB_GRID_HELPER::computeAnchors(), BRDITEMS_PLOTTER::PlotFootprintGraphicItem(), TransformShapeWithClearanceToPolygon(), and PCB_POINT_EDITOR::updatePoints().

◆ Flip() [1/2]

void PCB_SHAPE::Flip ( const wxPoint &  aCentre,
bool  aFlipLeftRight 
)
overridevirtual

Flip this object, i.e.

change the board side for this object.

Parameters
aCentrethe rotation point.
aFlipLeftRightmirror across Y axis instead of X (the default).

Reimplemented from BOARD_ITEM.

Reimplemented in FP_SHAPE.

Definition at line 296 of file pcb_shape.cpp.

297 {
298  if( aFlipLeftRight )
299  {
300  m_start.x = aCentre.x - ( m_start.x - aCentre.x );
301  m_end.x = aCentre.x - ( m_end.x - aCentre.x );
302  }
303  else
304  {
305  m_start.y = aCentre.y - ( m_start.y - aCentre.y );
306  m_end.y = aCentre.y - ( m_end.y - aCentre.y );
307  }
308 
309  switch ( m_shape )
310  {
311  case SHAPE_T::ARC:
312  if( aFlipLeftRight )
313  m_thirdPoint.x = aCentre.x - ( m_thirdPoint.x - aCentre.x );
314  else
315  m_thirdPoint.y = aCentre.y - ( m_thirdPoint.y - aCentre.y );
316 
317  m_angle = -m_angle;
318  break;
319 
320  case SHAPE_T::POLY:
321  m_poly.Mirror( aFlipLeftRight, !aFlipLeftRight, VECTOR2I( aCentre ) );
322  break;
323 
324  case SHAPE_T::BEZIER:
325  {
326  if( aFlipLeftRight )
327  {
328  m_bezierC1.x = aCentre.x - ( m_bezierC1.x - aCentre.x );
329  m_bezierC2.x = aCentre.x - ( m_bezierC2.x - aCentre.x );
330  }
331  else
332  {
333  m_bezierC1.y = aCentre.y - ( m_bezierC1.y - aCentre.y );
334  m_bezierC2.y = aCentre.y - ( m_bezierC2.y - aCentre.y );
335  }
336 
337  // Rebuild the poly points shape
338  std::vector<wxPoint> ctrlPoints = { m_start, m_bezierC1, m_bezierC2, m_end };
339  BEZIER_POLY converter( ctrlPoints );
340  converter.GetPoly( m_bezierPoints, m_width );
341  }
342  break;
343 
344  case SHAPE_T::SEGMENT:
345  case SHAPE_T::RECT:
346  case SHAPE_T::CIRCLE:
347  break;
348 
349  default:
350  wxFAIL_MSG( "PCB_SHAPE::Flip not implemented for "
351  + SHAPE_T_asString( m_shape ) );
352  break;
353  }
354 
355  SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) );
356 }
Arcs (with rounded ends)
Bezier Curve.
wxPoint m_end
Definition: pcb_shape.h:346
polygon (not yet used for tracks, but could be in microwave apps)
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:192
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Definition: lset.cpp:521
usual segment : line with rounded ends
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
void Mirror(bool aX=true, bool aY=false, const VECTOR2I &aRef={ 0, 0 })
Mirror the line points about y or x (or both)
wxPoint m_thirdPoint
Definition: pcb_shape.h:347
SHAPE_POLY_SET m_poly
Definition: pcb_shape.h:355
static wxString SHAPE_T_asString(SHAPE_T a)
Definition: board_item.h:57
double m_angle
Definition: pcb_shape.h:350
wxPoint m_start
Definition: pcb_shape.h:345
Bezier curves to polygon converter.
Definition: bezier_curves.h:36
int m_width
Definition: pcb_shape.h:343
wxPoint m_bezierC1
Definition: pcb_shape.h:351
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:50
segment with non rounded ends
std::vector< wxPoint > m_bezierPoints
Definition: pcb_shape.h:354
wxPoint m_bezierC2
Definition: pcb_shape.h:352
SHAPE_T m_shape
Definition: pcb_shape.h:349
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:171

References ARC, BEZIER, CIRCLE, FlipLayer(), BOARD_ITEM::GetBoard(), BOARD_ITEM::GetLayer(), BEZIER_POLY::GetPoly(), m_angle, m_bezierC1, m_bezierC2, m_bezierPoints, m_end, m_poly, m_shape, m_start, m_thirdPoint, m_width, SHAPE_POLY_SET::Mirror(), POLY, RECT, SEGMENT, BOARD_ITEM::SetLayer(), and SHAPE_T_asString().

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::getShapeFromVertex().

◆ Flip() [2/2]

void BOARD_ITEM::Flip ( const VECTOR2I aCentre,
bool  aFlipLeftRight 
)
inlineinherited

Definition at line 304 of file board_item.h.

305  {
306  Flip( wxPoint( aCentre.x, aCentre.y ), aFlipLeftRight );
307  }
virtual void Flip(const wxPoint &aCentre, bool aFlipLeftRight)
Flip this object, i.e.
Definition: board_item.cpp:197

References BOARD_ITEM::Flip(), VECTOR2< T >::x, and VECTOR2< T >::y.

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

◆ GetAngle()

◆ GetArcAngleEnd()

double PCB_SHAPE::GetArcAngleEnd ( ) const
Returns
the angle of the ending point of this arc, between 0 and 3600 in 0.1 deg.

Definition at line 472 of file pcb_shape.cpp.

473 {
474  // due to the Y axis orient atan2 needs - y value
475  double angleStart = ArcTangente( GetArcEnd().y - GetCenter().y,
476  GetArcEnd().x - GetCenter().x );
477 
478  // Normalize it to 0 ... 360 deg, to avoid discontinuity for angles near 180 deg
479  // because 180 deg and -180 are very near angles when mapping between -180 ... 180 deg.
480  // and this is not easy to handle in calculations
481  NORMALIZE_ANGLE_POS( angleStart );
482 
483  return angleStart;
484 }
wxPoint GetArcEnd() const
Definition: pcb_shape.cpp:417
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:290
wxPoint GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_shape.cpp:385
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:183

References ArcTangente(), GetArcEnd(), GetCenter(), and NORMALIZE_ANGLE_POS().

Referenced by DSN::SPECCTRA_DB::makeIMAGE().

◆ GetArcAngleStart()

double PCB_SHAPE::GetArcAngleStart ( ) const
Returns
the angle of the starting point of this arc, between 0 and 3600 in 0.1 deg.

Definition at line 457 of file pcb_shape.cpp.

458 {
459  // due to the Y axis orient atan2 needs - y value
460  double angleStart = ArcTangente( GetArcStart().y - GetCenter().y,
461  GetArcStart().x - GetCenter().x );
462 
463  // Normalize it to 0 ... 360 deg, to avoid discontinuity for angles near 180 deg
464  // because 180 deg and -180 are very near angles when mapping between -180 ... 180 deg.
465  // and this is not easy to handle in calculations
466  NORMALIZE_ANGLE_POS( angleStart );
467 
468  return angleStart;
469 }
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:290
wxPoint GetArcStart() const
Definition: pcb_shape.h:156
wxPoint GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_shape.cpp:385
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:183

References ArcTangente(), GetArcStart(), GetCenter(), and NORMALIZE_ANGLE_POS().

Referenced by computeArcBBox(), KIGFX::PCB_PAINTER::draw(), HitTest(), and DSN::SPECCTRA_DB::makeIMAGE().

◆ GetArcEnd()

wxPoint PCB_SHAPE::GetArcEnd ( ) const

Definition at line 417 of file pcb_shape.cpp.

418 {
419  wxPoint endPoint( m_end ); // start of arc
420 
421  switch( m_shape )
422  {
423  case SHAPE_T::ARC:
424  endPoint = m_thirdPoint;
425  break;
426 
427  default:
428  break;
429  }
430 
431  return endPoint; // after rotation, the end of the arc.
432 }
Arcs (with rounded ends)
wxPoint m_end
Definition: pcb_shape.h:346
wxPoint m_thirdPoint
Definition: pcb_shape.h:347
SHAPE_T m_shape
Definition: pcb_shape.h:349

References ARC, m_end, m_shape, and m_thirdPoint.

Referenced by PCB_GRID_HELPER::computeAnchors(), ConvertOutlineToPolygon(), PCB_POINT_EDITOR::editArcEndpointKeepTangent(), GetArcAngleEnd(), CONVERT_TOOL::getStartEndPoints(), DSN::SPECCTRA_DB::makeIMAGE(), PCB_POINT_EDITOR::makePoints(), CONVERT_TOOL::makePolysFromSegs(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow(), TransformShapeWithClearanceToPolygon(), and PCB_POINT_EDITOR::updatePoints().

◆ GetArcMid()

wxPoint PCB_SHAPE::GetArcMid ( ) const

Definition at line 435 of file pcb_shape.cpp.

436 {
437  wxPoint endPoint( m_end );
438 
439  switch( m_shape )
440  {
441  case SHAPE_T::ARC:
442  // rotate the starting point of the arc, given by m_End, through half
443  // the angle m_Angle to get the middle of the arc.
444  // m_Start is the arc center
445  endPoint = m_end; // m_End = start point of arc
446  RotatePoint( &endPoint, m_start, -m_angle / 2.0 );
447  break;
448 
449  default:
450  break;
451  }
452 
453  return endPoint; // after rotation, the end of the arc.
454 }
Arcs (with rounded ends)
wxPoint m_end
Definition: pcb_shape.h:346
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
double m_angle
Definition: pcb_shape.h:350
wxPoint m_start
Definition: pcb_shape.h:345
SHAPE_T m_shape
Definition: pcb_shape.h:349

References ARC, m_angle, m_end, m_shape, m_start, and RotatePoint().

Referenced by PCB_GRID_HELPER::computeAnchors(), PCB_POINT_EDITOR::editArcMidKeepEndpoints(), GetFocusPosition(), PCB_POINT_EDITOR::makePoints(), CONVERT_TOOL::makePolysFromSegs(), TransformShapeWithClearanceToPolygon(), and PCB_POINT_EDITOR::updatePoints().

◆ GetArcStart()

◆ GetBezierC1()

◆ GetBezierC2()

◆ GetBezierPoints()

const std::vector<wxPoint>& PCB_SHAPE::GetBezierPoints ( ) const
inline

Definition at line 223 of file pcb_shape.h.

223 { return m_bezierPoints; }
std::vector< wxPoint > m_bezierPoints
Definition: pcb_shape.h:354

References m_bezierPoints.

Referenced by GRAPHICS_CLEANER::areEquivalent(), ConvertOutlineToPolygon(), and GRAPHICS_CLEANER::isNullShape().

◆ GetBoard() [1/2]

const BOARD * BOARD_ITEM::GetBoard ( ) const
virtualinherited

Return the BOARD in which this BOARD_ITEM resides, or NULL if none.

Definition at line 50 of file board_item.cpp.

51 {
52  if( Type() == PCB_T )
53  return static_cast<const BOARD*>( this );
54 
55  BOARD_ITEM* parent = GetParent();
56 
57  if( parent )
58  return parent->GetBoard();
59 
60  return nullptr;
61 }
Definition: typeinfo.h:84
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:50
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:166
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

References BOARD_ITEM::GetBoard(), BOARD_ITEM::GetParent(), PCB_T, and EDA_ITEM::Type().

Referenced by ZONE_FILLER::addHoleKnockout(), PAD::BuildEffectivePolygon(), PAD::BuildEffectiveShapes(), ZONE::BuildSmoothedPoly(), calcIsInsideArea(), KIGFX::PCB_PAINTER::Draw(), KIGFX::PCB_PAINTER::draw(), PCB_LAYER_VALUE::EqualTo(), existsOnLayer(), exprFromTo(), PCB_VIA::FlashLayer(), PAD::FlashLayer(), PCB_TARGET::Flip(), PCB_TEXT::Flip(), PCB_TRACK::Flip(), FP_SHAPE::Flip(), FP_TEXT::Flip(), PCB_DIMENSION_BASE::Flip(), PCB_ARC::Flip(), Flip(), PCB_VIA::Flip(), ZONE::Flip(), PCB_EXPR_CONTEXT::GetBoard(), BOARD_ITEM::GetBoard(), FOOTPRINT::GetBoundingBox(), FOOTPRINT::GetBoundingHull(), BOARD_CONNECTED_ITEM::GetEffectiveNetclass(), PCB_VIA::GetEffectiveShape(), ZONE::GetInteractingZones(), BOARD_ITEM::GetLayerName(), PCB_VIA::GetMinAnnulus(), PCB_DRAW_PANEL_GAL::GetMsgPanelInfo(), ZONE::GetMsgPanelInfo(), NETINFO_ITEM::GetMsgPanelInfo(), PCB_TRACK::GetMsgPanelInfo(), PCB_TRACK::GetMsgPanelInfoBase_Common(), BOARD_CONNECTED_ITEM::GetNetClass(), BOARD_CONNECTED_ITEM::GetNetnameMsg(), BOARD_CONNECTED_ITEM::GetOwnClearance(), ZONE::GetSelectMenuText(), DRC_ENGINE::GetShape(), FP_TEXT::GetShownText(), PAD::GetSolderMaskMargin(), PAD::GetSolderPasteMargin(), BOARD::GetTrackLength(), PCB_TRACK::GetWidthConstraints(), inDiffPair(), insideArea(), insideBackCourtyard(), insideCourtyard(), insideFrontCourtyard(), isInsideArea(), isInsideCourtyard(), BOARD_ITEM::layerMaskDescribe(), PCB_VIA::layerMaskDescribe(), CONVERT_TOOL::makePolysFromCircles(), PAD::MergePrimitivesAsPolygon(), EAGLE_PLUGIN::packageWire(), PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), BOARD::ResolveDRCExclusions(), BOARD_CONNECTED_ITEM::SetNetCode(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataToWindow(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataToWindow(), ZONE::TransformSmoothedOutlineToPolygon(), ZONE::TransformSolidAreasShapesToPolygon(), PCB_TRACK::ViewBBox(), FOOTPRINT::ViewBBox(), PCB_VIA::ViewGetLOD(), and PAD::ViewGetLOD().

◆ GetBoard() [2/2]

BOARD * BOARD_ITEM::GetBoard ( )
virtualinherited

Definition at line 64 of file board_item.cpp.

65 {
66  if( Type() == PCB_T )
67  return static_cast<BOARD*>( this );
68 
69  BOARD_ITEM* parent = GetParent();
70 
71  if( parent )
72  return parent->GetBoard();
73 
74  return nullptr;
75 }
Definition: typeinfo.h:84
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:50
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:166
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

References BOARD_ITEM::GetBoard(), BOARD_ITEM::GetParent(), PCB_T, and EDA_ITEM::Type().

◆ GetBoundingBox()

const EDA_RECT PCB_SHAPE::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 622 of file pcb_shape.cpp.

623 {
624  EDA_RECT bbox;
625 
626  bbox.SetOrigin( m_start );
627 
628  switch( m_shape )
629  {
630  case SHAPE_T::RECT:
631  {
632  std::vector<wxPoint> pts = GetRectCorners();
633 
634  bbox = EDA_RECT(); // re-init for merging
635 
636  for( wxPoint& pt : pts )
637  bbox.Merge( pt );
638 
639  break;
640  }
641 
642  case SHAPE_T::SEGMENT:
643  bbox.SetEnd( m_end );
644  break;
645 
646  case SHAPE_T::CIRCLE:
647  bbox.Inflate( GetRadius() );
648  break;
649 
650  case SHAPE_T::ARC:
651  computeArcBBox( bbox );
652  break;
653 
654  case SHAPE_T::POLY:
655  {
656  if( m_poly.IsEmpty() )
657  break;
658 
659  FOOTPRINT* parentFootprint = GetParentFootprint();
660  bbox = EDA_RECT(); // re-init for merging
661 
662  for( auto iter = m_poly.CIterate(); iter; iter++ )
663  {
664  wxPoint pt( iter->x, iter->y );
665 
666  if( parentFootprint ) // Transform, if we belong to a footprint
667  {
668  RotatePoint( &pt, parentFootprint->GetOrientation() );
669  pt += parentFootprint->GetPosition();
670  }
671 
672  bbox.Merge( pt );
673  }
674 
675  break;
676  }
677 
678  case SHAPE_T::BEZIER:
679  bbox.Merge( m_bezierC1 );
680  bbox.Merge( m_bezierC2 );
681  bbox.Merge( m_end );
682  break;
683 
684  default:
685  wxFAIL_MSG( "PCB_SHAPE::GetBoundingBox not implemented for "
686  + SHAPE_T_asString( m_shape ) );
687  break;
688  }
689 
690  bbox.Inflate( m_width / 2 );
691  bbox.Normalize();
692 
693  return bbox;
694 }
Arcs (with rounded ends)
Bezier Curve.
wxPoint m_end
Definition: pcb_shape.h:346
void Merge(const EDA_RECT &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: eda_rect.cpp:432
polygon (not yet used for tracks, but could be in microwave apps)
int GetRadius() const
Return the radius of this item.
Definition: pcb_shape.cpp:487
bool IsEmpty() const
std::vector< wxPoint > GetRectCorners() const
Definition: pcb_shape.cpp:1048
void computeArcBBox(EDA_RECT &aBBox) const
Definition: pcb_shape.cpp:1085
usual segment : line with rounded ends
double GetOrientation() const
Definition: footprint.h:190
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:121
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
SHAPE_POLY_SET m_poly
Definition: pcb_shape.h:355
void SetEnd(int x, int y)
Definition: eda_rect.h:182
static wxString SHAPE_T_asString(SHAPE_T a)
Definition: board_item.h:57
CONST_ITERATOR CIterate(int aFirst, int aLast, bool aIterateHoles=false) const
wxPoint m_start
Definition: pcb_shape.h:345
void Normalize()
Ensures that the height ant width are positive.
Definition: eda_rect.cpp:35
int m_width
Definition: pcb_shape.h:343
FOOTPRINT * GetParentFootprint() const
Return the parent footprint or NULL if PCB_SHAPE does not belong to a footprint.
Definition: pcb_shape.cpp:532
Handle the component boundary box.
Definition: eda_rect.h:42
wxPoint GetPosition() const override
Definition: footprint.h:186
wxPoint m_bezierC1
Definition: pcb_shape.h:351
segment with non rounded ends
wxPoint m_bezierC2
Definition: pcb_shape.h:352
SHAPE_T m_shape
Definition: pcb_shape.h:349
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:364

References ARC, BEZIER, CIRCLE, SHAPE_POLY_SET::CIterate(), computeArcBBox(), FOOTPRINT::GetOrientation(), GetParentFootprint(), FOOTPRINT::GetPosition(), GetRadius(), GetRectCorners(), EDA_RECT::Inflate(), SHAPE_POLY_SET::IsEmpty(), m_bezierC1, m_bezierC2, m_end, m_poly, m_shape, m_start, m_width, EDA_RECT::Merge(), EDA_RECT::Normalize(), POLY, RECT, RotatePoint(), SEGMENT, EDA_RECT::SetEnd(), EDA_RECT::SetOrigin(), and SHAPE_T_asString().

Referenced by BOARD_ADAPTER::addShapeWithClearance(), GetCenter(), and HitTest().

◆ GetCenter()

wxPoint PCB_SHAPE::GetCenter ( ) const
overridevirtual

This defaults to the center of the bounding box if not overridden.

Returns
center point of the item

Reimplemented from BOARD_ITEM.

Definition at line 385 of file pcb_shape.cpp.

386 {
387  wxPoint c;
388 
389  switch( m_shape )
390  {
391  case SHAPE_T::ARC:
392  case SHAPE_T::CIRCLE:
393  c = m_start;
394  break;
395 
396  case SHAPE_T::SEGMENT:
397  // Midpoint of the line
398  c = ( GetStart() + GetEnd() ) / 2;
399  break;
400 
401  case SHAPE_T::POLY:
402  case SHAPE_T::RECT:
403  case SHAPE_T::BEZIER:
404  c = GetBoundingBox().Centre();
405  break;
406 
407  default:
408  wxFAIL_MSG( "PCB_SHAPE::GetCentre not implemented for "
409  + SHAPE_T_asString( m_shape ) );
410  break;
411  }
412 
413  return c;
414 }
Arcs (with rounded ends)
Bezier Curve.
polygon (not yet used for tracks, but could be in microwave apps)
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: pcb_shape.h:134
usual segment : line with rounded ends
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: pcb_shape.h:124
static wxString SHAPE_T_asString(SHAPE_T a)
Definition: board_item.h:57
wxPoint m_start
Definition: pcb_shape.h:345
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_shape.cpp:622
wxPoint Centre() const
Definition: eda_rect.h:55
segment with non rounded ends
SHAPE_T m_shape
Definition: pcb_shape.h:349

References ARC, BEZIER, EDA_RECT::Centre(), CIRCLE, GetBoundingBox(), GetEnd(), GetStart(), m_shape, m_start, POLY, RECT, SEGMENT, and SHAPE_T_asString().

Referenced by BOARD_ADAPTER::addShapeWithClearance(), GRAPHICS_CLEANER::areEquivalent(), PCB_GRID_HELPER::computeAnchors(), ConvertOutlineToPolygon(), GetArcAngleEnd(), GetArcAngleStart(), GetFocusPosition(), HitTest(), idf_export_outline(), GRAPHICS_CLEANER::isNullShape(), MakeEffectiveShapes(), DSN::SPECCTRA_DB::makeIMAGE(), PCB_POINT_EDITOR::makePoints(), EAGLE_PLUGIN::packageRectangle(), PCB_PARSER::parsePAD(), TransformShapeWithClearanceToPolygon(), PCB_POINT_EDITOR::updateItem(), and PCB_POINT_EDITOR::updatePoints().

◆ GetClass()

wxString PCB_SHAPE::GetClass ( ) const
inlineoverridevirtual

Return the class name.

Implements EDA_ITEM.

Definition at line 282 of file pcb_shape.h.

283  {
284  return wxT( "PCB_SHAPE" );
285  }

◆ GetEditFlags()

EDA_ITEM_FLAGS EDA_ITEM::GetEditFlags ( ) const
inlineinherited

Definition at line 158 of file eda_item.h.

159  {
160  constexpr int mask = ( IS_NEW | IS_PASTED | IS_MOVING | IS_RESIZING | IS_DRAGGING
162 
163  return m_flags & mask;
164  }
#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:481
#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().

◆ GetEffectiveShape()

std::shared_ptr< SHAPE > PCB_SHAPE::GetEffectiveShape ( PCB_LAYER_ID  aLayer = UNDEFINED_LAYER) const
overridevirtual

Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.

This routine returns a COMPOUND shape (set of simple shapes which make up the pad for use with routing, collision determination, etc).

Note
This list can contain a SHAPE_SIMPLE (a simple single-outline non-intersecting polygon), but should never contain a SHAPE_POLY_SET (a complex polygon consisting of multiple outlines and/or holes).
Parameters
aLayerin case of items spanning multiple layers, only the shapes belonging to aLayer will be returned. Pass UNDEFINED_LAYER to return shapes for all layers.

Reimplemented from BOARD_ITEM.

Definition at line 1271 of file pcb_shape.cpp.

1272 {
1273  return std::make_shared<SHAPE_COMPOUND>( MakeEffectiveShapes() );
1274 }
std::vector< SHAPE * > MakeEffectiveShapes() const
Make a set of SHAPE objects representing the PCB_SHAPE.
Definition: pcb_shape.cpp:1163

References MakeEffectiveShapes().

◆ GetEnd()

◆ GetEndX()

int PCB_SHAPE::GetEndX ( )
inline

Definition at line 136 of file pcb_shape.h.

136 { return m_end.x; }
wxPoint m_end
Definition: pcb_shape.h:346

References m_end.

Referenced by DRAWSEGMENT_DESC::DRAWSEGMENT_DESC(), and DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run().

◆ GetEndY()

int PCB_SHAPE::GetEndY ( )
inline

Definition at line 135 of file pcb_shape.h.

135 { return m_end.y; }
wxPoint m_end
Definition: pcb_shape.h:346

References m_end.

Referenced by DRAWSEGMENT_DESC::DRAWSEGMENT_DESC(), and DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run().

◆ GetFlags()

◆ GetFocusPosition()

const wxPoint PCB_SHAPE::GetFocusPosition ( ) const
overridevirtual

Allows items to return their visual center rather than their anchor.

For some shapes this is similar to GetPosition, but for polygonal shapes, the anchor is not suitable (shows nothing): a point on the outline is better

Reimplemented from EDA_ITEM.

Definition at line 79 of file pcb_shape.cpp.

80 {
81  // For some shapes return the visual center, but for not filled polygonal shapes,
82  // the center is usually far from the shape: a point on the outline is better
83 
84  switch( m_shape )
85  {
86  case SHAPE_T::CIRCLE:
87  if( !IsFilled() )
88  return wxPoint( GetCenter().x + GetRadius(), GetCenter().y );
89  break;
90 
91  case SHAPE_T::RECT:
92  if( !IsFilled() )
93  return GetStart();
94  break;
95 
96  case SHAPE_T::POLY:
97  if( !IsFilled() )
98  {
99  VECTOR2I pos = GetPolyShape().Outline(0).CPoint(0);
100  return wxPoint( pos.x, pos.y );
101  }
102  break;
103 
104  case SHAPE_T::ARC:
105  return GetArcMid();
106  break;
107 
108  case SHAPE_T::BEZIER:
109  return GetStart();
110  break;
111 
112  default:
113  break;
114  }
115 
116  return GetCenter();
117 }
Arcs (with rounded ends)
bool IsFilled() const
Definition: pcb_shape.h:75
Bezier Curve.
polygon (not yet used for tracks, but could be in microwave apps)
SHAPE_POLY_SET & GetPolyShape()
Definition: pcb_shape.h:240
int GetRadius() const
Return the radius of this item.
Definition: pcb_shape.cpp:487
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
SHAPE_LINE_CHAIN & Outline(int aIndex)
wxPoint GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_shape.cpp:385
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: pcb_shape.h:124
wxPoint GetArcMid() const
Definition: pcb_shape.cpp:435
segment with non rounded ends
SHAPE_T m_shape
Definition: pcb_shape.h:349

References ARC, BEZIER, CIRCLE, SHAPE_LINE_CHAIN::CPoint(), GetArcMid(), GetCenter(), GetPolyShape(), GetRadius(), GetStart(), IsFilled(), m_shape, SHAPE_POLY_SET::Outline(), POLY, RECT, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ GetLayer()

virtual PCB_LAYER_ID BOARD_ITEM::GetLayer ( ) const
inlinevirtualinherited

Return the primary layer this item is on.

Reimplemented in ZONE.

Definition at line 171 of file board_item.h.

171 { return m_layer; }
PCB_LAYER_ID m_layer
Definition: board_item.h:353

References BOARD_ITEM::m_layer.

Referenced by CN_LIST::Add(), BOARD_ADAPTER::addFootprintShapesWithClearance(), GRAPHICS_CLEANER::areEquivalent(), BOARD_CONNECTED_ITEM_DESC::BOARD_CONNECTED_ITEM_DESC(), BOARD_ITEM_DESC::BOARD_ITEM_DESC(), AR_AUTOPLACER::buildFpAreas(), TRACKS_CLEANER::cleanup(), CreateBoardSection(), MICROWAVE_TOOL::createMicrowaveInductor(), PCB_BASE_FRAME::CreateNewFootprint(), CreateRoutesSection(), DIALOG_DIMENSION_PROPERTIES::DIALOG_DIMENSION_PROPERTIES(), DIALOG_GRAPHIC_ITEM_PROPERTIES::DIALOG_GRAPHIC_ITEM_PROPERTIES(), DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES(), DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES(), EDIT_TOOL::DragArcTrack(), KIGFX::PCB_PAINTER::draw(), PCB_EDIT_FRAME::ExchangeFootprint(), EXPORTER_PCB_VRML::ExportVrmlFootprint(), extractDiffPairCoupledItems(), EDIT_TOOL::FilletTracks(), PCB_TARGET::Flip(), PCB_TEXT::Flip(), PCB_TRACK::Flip(), FP_SHAPE::Flip(), FP_TEXT::Flip(), PCB_DIMENSION_BASE::Flip(), FOOTPRINT::Flip(), PCB_ARC::Flip(), Flip(), FOOTPRINT_DESC::FOOTPRINT_DESC(), PCB_IO::FootprintSave(), FootprintWriteShape(), PCB_IO::format(), PCB_IO::formatLayer(), FP_TEXT::FP_TEXT(), DSN::SPECCTRA_DB::FromBOARD(), AR_AUTOPLACER::genModuleOnRoutingMatrix(), FOOTPRINT::GetBoundingBox(), ZONE::GetLayer(), getMatchingTextItem(), PCB_TRACK::GetMsgPanelInfo(), PCB_VIA::GetMsgPanelInfo(), PAD::GetMsgPanelInfo(), AR_AUTOPLACER::getOptimalFPPlacement(), BOARD::GetPad(), PCB_TRACK::GetWidthConstraints(), PCB_SELECTION_TOOL::GuessSelectionCandidates(), idf_export_footprint(), GENERAL_COLLECTOR::Inspect(), BOARD_INSPECTION_TOOL::InspectClearance(), BOARD_INSPECTION_TOOL::InspectConstraints(), BOARD_INSPECTION_TOOL::InspectDRCError(), isEdge(), PAD::IsFlipped(), FOOTPRINT::IsFlipped(), PNS_KICAD_IFACE::IsItemVisible(), BOARD_ITEM::IsOnCopperLayer(), FP_SHAPE::IsParentFlipped(), FP_TEXT::IsParentFlipped(), itemIsIncludedByFilter(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard(), CADSTAR_PCB_ARCHIVE_LOADER::makeTracksFromShapes(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnAddField(), DIALOG_FOOTPRINT_PROPERTIES::OnAddField(), DIALOG_FOOTPRINT_CHECKER::OnSelectItem(), PCB_TRACK::cmp_tracks::operator()(), PCB_SHAPE::cmp_drawings::operator()(), BOARD_ITEM::ptr_cmp::operator()(), FOOTPRINT::cmp_drawings::operator()(), EAGLE_PLUGIN::packagePad(), BRDITEMS_PLOTTER::PlotDimension(), BRDITEMS_PLOTTER::PlotFootprintGraphicItem(), BRDITEMS_PLOTTER::PlotFootprintGraphicItems(), BRDITEMS_PLOTTER::PlotFootprintTextItem(), BRDITEMS_PLOTTER::PlotFootprintTextItems(), BRDITEMS_PLOTTER::PlotPcbShape(), BRDITEMS_PLOTTER::PlotPcbTarget(), BRDITEMS_PLOTTER::PlotPcbText(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), processTextItem(), PAD_TOOL::recombinePad(), CLIPBOARD_IO::SaveSelection(), CONVERT_TOOL::SegmentToArc(), PCB_SELECTION_TOOL::Selectable(), GLOBAL_EDIT_TOOL::swapBoardItem(), PNS_KICAD_IFACE_BASE::syncArc(), PNS_KICAD_IFACE_BASE::syncGraphicalItem(), PNS_KICAD_IFACE_BASE::syncTrack(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::testAgainstEdge(), AR_AUTOPLACER::testFootprintOnBoard(), CONNECTIVITY_DATA::TestTrackEndpointDangling(), TRACK_VIA_DESC::TRACK_VIA_DESC(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow(), DIALOG_DIMENSION_PROPERTIES::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataToWindow(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataToWindow(), BOARD_ADAPTER::transformFPShapesToPolygon(), FOOTPRINT::TransformFPShapesWithClearanceToPolygon(), PCB_TRACK::ViewGetLayers(), FP_TEXT::ViewGetLayers(), FP_TEXT::ViewGetLOD(), FP_ZONE::ViewGetLOD(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::visitItem(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ GetLayerName()

wxString BOARD_ITEM::GetLayerName ( ) const
inherited

Return the name of the PCB layer on which the item resides.

Returns
the layer name associated with this item.

Definition at line 87 of file board_item.cpp.

88 {
89  const BOARD* board = GetBoard();
90 
91  if( board )
92  return board->GetLayerName( m_layer );
93 
94  // If no parent, return standard name
96 }
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:361
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
PCB_LAYER_ID m_layer
Definition: board_item.h:353
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:50
static wxString GetStandardLayerName(PCB_LAYER_ID aLayerId)
Return an "English Standard" name of a PCB layer when given aLayerNumber.
Definition: board.h:605

References BOARD_ITEM::GetBoard(), BOARD::GetLayerName(), BOARD::GetStandardLayerName(), and BOARD_ITEM::m_layer.

Referenced by PCB_TARGET::GetMsgPanelInfo(), PCB_TEXT::GetMsgPanelInfo(), FP_TEXT::GetMsgPanelInfo(), PCB_DIMENSION_BASE::GetMsgPanelInfo(), GetMsgPanelInfo(), PCB_DIM_LEADER::GetMsgPanelInfo(), PCB_TEXT::GetSelectMenuText(), FP_SHAPE::GetSelectMenuText(), PCB_TRACK::GetSelectMenuText(), PCB_DIMENSION_BASE::GetSelectMenuText(), GetSelectMenuText(), PCB_TEXT::GetShownText(), and FOOTPRINT::ResolveTextVar().

◆ GetLayerSet()

◆ GetLength()

double PCB_SHAPE::GetLength ( ) const

Return the length of the track using the hypotenuse calculation.

Returns
the length of the track

Definition at line 120 of file pcb_shape.cpp.

121 {
122  double length = 0.0;
123 
124  switch( m_shape )
125  {
126  case SHAPE_T::BEZIER:
127  for( size_t ii = 1; ii < m_bezierPoints.size(); ++ii )
128  length += GetLineLength( m_bezierPoints[ ii - 1], m_bezierPoints[ii] );
129 
130  break;
131 
132  case SHAPE_T::SEGMENT:
133  length = GetLineLength( GetStart(), GetEnd() );
134  break;
135 
136  case SHAPE_T::POLY:
137  for( int ii = 0; ii < m_poly.COutline( 0 ).SegmentCount(); ii++ )
138  length += m_poly.COutline( 0 ).CSegment( ii ).Length();
139 
140  break;
141 
142  case SHAPE_T::ARC:
143  length = 2 * M_PI * GetRadius() * ( GetAngle() / 3600.0 );
144  break;
145 
146  default:
147  wxASSERT_MSG( false, "PCB_SHAPE::GetLength not implemented for shape"
148  + ShowShape( GetShape() ) );
149  break;
150  }
151 
152  return length;
153 }
int Length() const
Return the length (this).
Definition: seg.h:350
Arcs (with rounded ends)
Bezier Curve.
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:222
polygon (not yet used for tracks, but could be in microwave apps)
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: pcb_shape.h:134
SHAPE_T GetShape() const
Definition: pcb_shape.h:110
int GetRadius() const
Return the radius of this item.
Definition: pcb_shape.cpp:487
usual segment : line with rounded ends
SHAPE_POLY_SET m_poly
Definition: pcb_shape.h:355
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: pcb_shape.h:124
int SegmentCount() const
Return the number of segments in this line chain.
const SEG CSegment(int aIndex) const
Return a constant copy of the aIndex segment in the line chain.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
double GetAngle() const
Definition: pcb_shape.h:107
std::vector< wxPoint > m_bezierPoints
Definition: pcb_shape.h:354
static wxString ShowShape(SHAPE_T aShape)
Convert the enum #PCB_SHAPE_TYPE_T integer value to a wxString.
Definition: board_item.cpp:35
SHAPE_T m_shape
Definition: pcb_shape.h:349

References ARC, BEZIER, SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CSegment(), GetAngle(), GetEnd(), GetLineLength(), GetRadius(), GetShape(), GetStart(), SEG::Length(), m_bezierPoints, m_poly, m_shape, POLY, SEGMENT, SHAPE_LINE_CHAIN::SegmentCount(), and BOARD_ITEM::ShowShape().

Referenced by GetMsgPanelInfo().

◆ GetMenuImage()

BITMAPS PCB_SHAPE::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.

Reimplemented in FP_SHAPE.

Definition at line 1016 of file pcb_shape.cpp.

1017 {
1018  return BITMAPS::add_dashed_line;
1019 }

References add_dashed_line.

◆ GetMsgPanelInfo()

void PCB_SHAPE::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 541 of file pcb_shape.cpp.

542 {
543  EDA_UNITS units = aFrame->GetUserUnits();
544  ORIGIN_TRANSFORMS originTransforms = aFrame->GetOriginTransforms();
545  wxString msg;
546 
547  aList.emplace_back( _( "Type" ), _( "Drawing" ) );
548 
549  if( IsLocked() )
550  aList.emplace_back( _( "Status" ), _( "Locked" ) );
551 
552  wxString shape = _( "Shape" );
553 
554  switch( m_shape )
555  {
556  case SHAPE_T::CIRCLE:
557  aList.emplace_back( shape, _( "Circle" ) );
558 
559  msg = MessageTextFromValue( units, GetLineLength( m_start, m_end ) );
560  aList.emplace_back( _( "Radius" ), msg );
561  break;
562 
563  case SHAPE_T::ARC:
564  aList.emplace_back( shape, _( "Arc" ) );
565 
566  msg.Printf( wxT( "%.1f" ), m_angle / 10.0 );
567  aList.emplace_back( _( "Angle" ), msg );
568 
569  msg = MessageTextFromValue( units, GetLineLength( m_start, m_end ) );
570  aList.emplace_back( _( "Radius" ), msg );
571  break;
572 
573  case SHAPE_T::BEZIER:
574  aList.emplace_back( shape, _( "Curve" ) );
575 
576  msg = MessageTextFromValue( units, GetLength() );
577  aList.emplace_back( _( "Length" ), msg );
578  break;
579 
580  case SHAPE_T::POLY:
581  aList.emplace_back( shape, _( "Polygon" ) );
582 
583  msg.Printf( "%d", GetPolyShape().Outline(0).PointCount() );
584  aList.emplace_back( _( "Points" ), msg );
585  break;
586 
587  case SHAPE_T::RECT:
588  aList.emplace_back( shape, _( "Rectangle" ) );
589 
590  msg = MessageTextFromValue( units, std::abs( m_end.x - m_start.x ) );
591  aList.emplace_back( _( "Width" ), msg );
592 
593  msg = MessageTextFromValue( units, std::abs( m_end.y - m_start.y ) );
594  aList.emplace_back( _( "Height" ), msg );
595  break;
596 
597  case SHAPE_T::SEGMENT:
598  {
599  aList.emplace_back( shape, _( "Segment" ) );
600 
601  msg = MessageTextFromValue( units, GetLineLength( m_start, m_end ) );
602  aList.emplace_back( _( "Length" ), msg );
603 
604  // angle counter-clockwise from 3'o-clock
605  const double deg = RAD2DEG( atan2( (double)( m_start.y - m_end.y ),
606  (double)( m_end.x - m_start.x ) ) );
607  aList.emplace_back( _( "Angle" ), wxString::Format( "%.1f", deg ) );
608  }
609  break;
610 
611  default:
612  aList.emplace_back( shape, _( "Unrecognized" ) );
613  break;
614  }
615 
616  aList.emplace_back( _( "Layer" ), GetLayerName() );
617 
618  aList.emplace_back( _( "Line width" ), MessageTextFromValue( units, m_width ) );
619 }
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
Arcs (with rounded ends)
Bezier Curve.
wxPoint m_end
Definition: pcb_shape.h:346
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:222
polygon (not yet used for tracks, but could be in microwave apps)
SHAPE_POLY_SET & GetPolyShape()
Definition: pcb_shape.h:240
double RAD2DEG(double rad)
Definition: trigo.h:230
usual segment : line with rounded ends
virtual ORIGIN_TRANSFORMS & GetOriginTransforms()
Return a reference to the default ORIGIN_TRANSFORMS object.
virtual bool IsLocked() const
Definition: board_item.cpp:78
#define _(s)
double m_angle
Definition: pcb_shape.h:350
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
wxPoint m_start
Definition: pcb_shape.h:345
EDA_UNITS
Definition: eda_units.h:38
int m_width
Definition: pcb_shape.h:343
A class to perform either relative or absolute display origin transforms for a single axis of a point...
segment with non rounded ends
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
Definition: board_item.cpp:87
SHAPE_T m_shape
Definition: pcb_shape.h:349
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
double GetLength() const
Return the length of the track using the hypotenuse calculation.
Definition: pcb_shape.cpp:120

References _, ARC, BEZIER, CIRCLE, Format(), BOARD_ITEM::GetLayerName(), GetLength(), GetLineLength(), EDA_DRAW_FRAME::GetOriginTransforms(), GetPolyShape(), EDA_BASE_FRAME::GetUserUnits(), BOARD_ITEM::IsLocked(), m_angle, m_end, m_shape, m_start, m_width, MessageTextFromValue(), POLY, RAD2DEG(), RECT, and SEGMENT.

Referenced by FP_SHAPE::GetMsgPanelInfo().

◆ GetParent()

BOARD_ITEM_CONTAINER* BOARD_ITEM::GetParent ( void  ) const
inlineinherited

Definition at line 166 of file board_item.h.

166 { return (BOARD_ITEM_CONTAINER*) m_parent; }
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:479
Abstract interface for BOARD_ITEMs capable of storing other items inside.

References EDA_ITEM::m_parent.

Referenced by PCB_POINT_EDITOR::addCorner(), ALIGN_DISTRIBUTE_TOOL::AlignBottom(), ALIGN_DISTRIBUTE_TOOL::AlignCenterX(), ALIGN_DISTRIBUTE_TOOL::AlignCenterY(), ALIGN_DISTRIBUTE_TOOL::AlignTop(), PNS_KICAD_IFACE::Commit(), EDIT_TOOL::copyToClipboard(), FOOTPRINT::CoverageRatio(), BOARD_ITEM::DeleteStructure(), ALIGN_DISTRIBUTE_TOOL::doAlignLeft(), ALIGN_DISTRIBUTE_TOOL::doAlignRight(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersVertically(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsVertically(), EDIT_TOOL::doMoveSelection(), EDIT_TOOL::Drag(), EDIT_TOOL::DragArcTrack(), KIGFX::PCB_PAINTER::draw(), EDIT_TOOL::Duplicate(), PCB_SELECTION_TOOL::FilterCollectorForHierarchy(), PCB_IO::format(), FormatProbeItem(), BOARD_ITEM::GetBoard(), PCB_MARKER::GetColorLayer(), ALIGN_DISTRIBUTE_TOOL::GetSelections(), FP_TEXT::GetSelectMenuText(), PCB_TEXT::GetShownText(), FP_TEXT::GetShownText(), getTopLevelGroup(), GENERAL_COLLECTOR::Inspect(), ARRAY_CREATOR::Invoke(), isInsideArea(), DRC_ENGINE::IsNetTie(), FP_SHAPE::IsParentFlipped(), FP_TEXT::IsParentFlipped(), LEGACY_PLUGIN::loadMODULE_TEXT(), memberOf(), EDIT_TOOL::MoveExact(), ALTIUM_PCB::ParseTexts6Data(), BRDITEMS_PLOTTER::PlotFootprintGraphicItem(), BRDITEMS_PLOTTER::PlotFootprintTextItem(), POSITION_RELATIVE_TOOL::PositionRelative(), BOARD_COMMIT::Push(), DRC_TEST_PROVIDER_SILK_CLEARANCE::Run(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), CLIPBOARD_IO::SaveSelection(), PCB_SELECTION_TOOL::select(), PCB_SELECTION_TOOL::Selectable(), SwapItemData(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), PCB_MARKER::ViewGetLayers(), FP_ZONE::ViewGetLOD(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ GetParentFootprint()

FOOTPRINT * PCB_SHAPE::GetParentFootprint ( ) const

Return the parent footprint or NULL if PCB_SHAPE does not belong to a footprint.

Returns
the parent footprint or NULL.

Definition at line 532 of file pcb_shape.cpp.

533 {
534  if( !m_parent || m_parent->Type() != PCB_FOOTPRINT_T )
535  return nullptr;
536 
537  return (FOOTPRINT*) m_parent;
538 }
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:479
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

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

Referenced by ConvertOutlineToPolygon(), KIGFX::PCB_PAINTER::draw(), GetBoundingBox(), GetRectCorners(), HitTest(), BRDITEMS_PLOTTER::PlotFootprintGraphicItem(), and TransformShapeWithClearanceToPolygon().

◆ GetParentGroup()

◆ GetPointCount()

int PCB_SHAPE::GetPointCount ( ) const
Returns
the number of corners of the polygonal shape

Definition at line 1306 of file pcb_shape.cpp.

1307 {
1308  // return the number of corners of the polygonal shape
1309  // this shape is expected to be only one polygon without hole
1310  if( GetPolyShape().OutlineCount() )
1311  return GetPolyShape().VertexCount( 0 );
1312 
1313  return 0;
1314 }
SHAPE_POLY_SET & GetPolyShape()
Definition: pcb_shape.h:240
int VertexCount(int aOutline=-1, int aHole=-1) const
Returns the number of holes in a given outline.

References GetPolyShape(), and SHAPE_POLY_SET::VertexCount().

Referenced by GRAPHICS_CLEANER::isNullShape().

◆ GetPolyShape() [1/2]

◆ GetPolyShape() [2/2]

const SHAPE_POLY_SET& PCB_SHAPE::GetPolyShape ( ) const
inline

Definition at line 241 of file pcb_shape.h.

241 { return m_poly; }
SHAPE_POLY_SET m_poly
Definition: pcb_shape.h:355

References m_poly.

◆ GetPosition()

wxPoint PCB_SHAPE::GetPosition ( ) const
overridevirtual

Reimplemented from EDA_ITEM.

Definition at line 70 of file pcb_shape.cpp.

71 {
72  if( m_shape == SHAPE_T::POLY )
73  return (wxPoint) m_poly.CVertex( 0 );
74  else
75  return m_start;
76 }
polygon (not yet used for tracks, but could be in microwave apps)
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Return the aGlobalIndex-th vertex in the poly set.
SHAPE_POLY_SET m_poly
Definition: pcb_shape.h:355
wxPoint m_start
Definition: pcb_shape.h:345
SHAPE_T m_shape
Definition: pcb_shape.h:349

References SHAPE_POLY_SET::CVertex(), m_poly, m_shape, m_start, and POLY.

Referenced by CONVERT_TOOL::makePolysFromCircles(), and ALTIUM_PCB::Parse().

◆ GetRadius()

int PCB_SHAPE::GetRadius ( ) const

Return the radius of this item.

Has meaning only for arcs and circles.

Definition at line 487 of file pcb_shape.cpp.

488 {
489  double radius = GetLineLength( m_start, m_end );
490 
491  // don't allow degenerate arcs
492  return std::max( 1, KiROUND( radius ) );
493 }
wxPoint m_end
Definition: pcb_shape.h:346
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:222
wxPoint m_start
Definition: pcb_shape.h:345
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 GetLineLength(), KiROUND(), m_end, and m_start.

Referenced by BOARD_ADAPTER::addShapeWithClearance(), computeArcBBox(), ConvertOutlineToPolygon(), KIGFX::PCB_PAINTER::draw(), GetBoundingBox(), GetFocusPosition(), GetLength(), hash_fp_item(), HitTest(), idf_export_outline(), GRAPHICS_CLEANER::isNullShape(), MakeEffectiveShapes(), DSN::SPECCTRA_DB::makeIMAGE(), CONVERT_TOOL::makePolysFromCircles(), ALTIUM_PCB::Parse(), PCB_PARSER::parsePAD(), Scale(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow(), DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataToWindow(), and TransformShapeWithClearanceToPolygon().

◆ GetRectCorners()

std::vector< wxPoint > PCB_SHAPE::GetRectCorners ( ) const

Definition at line 1048 of file pcb_shape.cpp.

1049 {
1050  std::vector<wxPoint> pts;
1051  FOOTPRINT* parentFootprint = GetParentFootprint();
1052  wxPoint topLeft = GetStart();
1053  wxPoint botRight = GetEnd();
1054 
1055  // Un-rotate rect topLeft and botRight
1056  if( parentFootprint && KiROUND( parentFootprint->GetOrientation() ) % 900 != 0 )
1057  {
1058  topLeft -= parentFootprint->GetPosition();
1059  RotatePoint( &topLeft, -parentFootprint->GetOrientation() );
1060 
1061  botRight -= parentFootprint->GetPosition();
1062  RotatePoint( &botRight, -parentFootprint->GetOrientation() );
1063  }
1064 
1065  // Set up the un-rotated 4 corners
1066  pts.emplace_back( topLeft );
1067  pts.emplace_back( botRight.x, topLeft.y );
1068  pts.emplace_back( botRight );
1069  pts.emplace_back( topLeft.x, botRight.y );
1070 
1071  // Now re-rotate the 4 corners to get a diamond
1072  if( parentFootprint && KiROUND( parentFootprint->GetOrientation() ) % 900 != 0 )
1073  {
1074  for( wxPoint& pt : pts )
1075  {
1076  RotatePoint( &pt, parentFootprint->GetOrientation() );
1077  pt += parentFootprint->GetPosition();
1078  }
1079  }
1080 
1081  return pts;
1082 }
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: pcb_shape.h:134
double GetOrientation() const
Definition: footprint.h:190
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: pcb_shape.h:124
FOOTPRINT * GetParentFootprint() const
Return the parent footprint or NULL if PCB_SHAPE does not belong to a footprint.
Definition: pcb_shape.cpp:532
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
wxPoint GetPosition() const override
Definition: footprint.h:186

References GetEnd(), FOOTPRINT::GetOrientation(), GetParentFootprint(), FOOTPRINT::GetPosition(), GetStart(), KiROUND(), and RotatePoint().

Referenced by BOARD_ADAPTER::addShapeWithClearance(), ConvertOutlineToPolygon(), KIGFX::PCB_PAINTER::draw(), GetBoundingBox(), HitTest(), MakeEffectiveShapes(), BRDITEMS_PLOTTER::PlotFootprintGraphicItem(), BRDITEMS_PLOTTER::PlotPcbShape(), and TransformShapeWithClearanceToPolygon().

◆ GetSelectMenuText()

wxString PCB_SHAPE::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.

Reimplemented in FP_SHAPE.

Definition at line 1010 of file pcb_shape.cpp.

1011 {
1012  return wxString::Format( _( "%s on %s" ), ShowShape( m_shape ), GetLayerName() );
1013 }
#define _(s)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
static wxString ShowShape(SHAPE_T aShape)
Convert the enum #PCB_SHAPE_TYPE_T integer value to a wxString.
Definition: board_item.cpp:35
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
Definition: board_item.cpp:87
SHAPE_T m_shape
Definition: pcb_shape.h:349

References _, Format(), BOARD_ITEM::GetLayerName(), m_shape, and BOARD_ITEM::ShowShape().

◆ GetShape()

SHAPE_T PCB_SHAPE::GetShape ( ) const
inline

Definition at line 110 of file pcb_shape.h.

110 { return m_shape; }
SHAPE_T m_shape
Definition: pcb_shape.h:349

References m_shape.

Referenced by PCB_POINT_EDITOR::addCorner(), BOARD_ADAPTER::addShapeWithClearance(), GRAPHICS_CLEANER::areEquivalent(), PCB_POINT_EDITOR::canAddCorner(), GRAPHICS_CLEANER::cleanupSegments(), PCB_GRID_HELPER::computeAnchors(), ConvertOutlineToPolygon(), CONVERT_TOOL::CreateLines(), KIGFX::PCB_PAINTER::draw(), FP_SHAPE::Flip(), FootprintWriteShape(), PCB_IO::format(), FOOTPRINT::GetCoverageArea(), GetLength(), CONVERT_TOOL::getStartEndPoints(), hash_fp_item(), idf_export_outline(), GRAPHICS_CLEANER::isNullShape(), DSN::SPECCTRA_DB::makeIMAGE(), PCB_POINT_EDITOR::makePoints(), CONVERT_TOOL::makePolysFromCircles(), CONVERT_TOOL::makePolysFromRects(), GRAPHICS_CLEANER::mergeRects(), FP_SHAPE::Mirror(), FP_SHAPE::Move(), PCB_SHAPE::cmp_drawings::operator()(), FOOTPRINT::cmp_drawings::operator()(), ALTIUM_PCB::Parse(), BRDITEMS_PLOTTER::PlotFootprintGraphicItem(), BRDITEMS_PLOTTER::PlotPcbShape(), PCB_POINT_EDITOR::removeCorner(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run(), PNS_KICAD_IFACE_BASE::syncGraphicalItem(), AR_MATRIX::TraceSegmentPcb(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataFromWindow(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow(), DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataToWindow(), PCB_POINT_EDITOR::updateItem(), PCB_POINT_EDITOR::updatePoints(), and DIALOG_GRAPHIC_ITEM_PROPERTIES::Validate().

◆ GetStart()

◆ GetStartX()

int PCB_SHAPE::GetStartX ( )
inline

Definition at line 126 of file pcb_shape.h.

126 { return m_start.x; }
wxPoint m_start
Definition: pcb_shape.h:345

References m_start.

Referenced by DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run().

◆ GetStartY()

int PCB_SHAPE::GetStartY ( )
inline

Definition at line 125 of file pcb_shape.h.

125 { return m_start.y; }
wxPoint m_start
Definition: pcb_shape.h:345

References m_start.

Referenced by DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run().

◆ GetState()

int EDA_ITEM::GetState ( EDA_ITEM_FLAGS  type) const
inlineinherited

Definition at line 137 of file eda_item.h.

138  {
139  return m_status & type;
140  }
EDA_ITEM_FLAGS m_status
Definition: eda_item.h:478

References EDA_ITEM::m_status.

Referenced by BOARD_ITEM::IsLocked().

◆ GetStatus()

EDA_ITEM_FLAGS EDA_ITEM::GetStatus ( ) const
inlineinherited

Definition at line 150 of file eda_item.h.

150 { return m_status; }
EDA_ITEM_FLAGS m_status
Definition: eda_item.h:478

References EDA_ITEM::m_status.

◆ GetThirdPoint()

const wxPoint& PCB_SHAPE::GetThirdPoint ( ) const
inline

Return the third point of the graphic.

Definition at line 144 of file pcb_shape.h.

144 { return m_thirdPoint; }
wxPoint m_thirdPoint
Definition: pcb_shape.h:347

References m_thirdPoint.

◆ GetThirdPointX()

int PCB_SHAPE::GetThirdPointX ( )
inline

Definition at line 146 of file pcb_shape.h.

146 { return m_thirdPoint.x; }
wxPoint m_thirdPoint
Definition: pcb_shape.h:347

References m_thirdPoint.

◆ GetThirdPointY()

int PCB_SHAPE::GetThirdPointY ( )
inline

Definition at line 145 of file pcb_shape.h.

145 { return m_thirdPoint.y; }
wxPoint m_thirdPoint
Definition: pcb_shape.h:347

References m_thirdPoint.

◆ GetWidth()

◆ GetX()

int BOARD_ITEM::GetX ( ) const
inlineinherited

◆ GetY()

int BOARD_ITEM::GetY ( ) const
inlineinherited

◆ HasFlag()

◆ HitTest() [1/2]

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

Test if aPosition is contained within or on the bounding box of an 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 697 of file pcb_shape.cpp.

698 {
699  int maxdist = aAccuracy + ( m_width / 2 );
700 
701  switch( m_shape )
702  {
703  case SHAPE_T::CIRCLE:
704  {
705  int radius = GetRadius();
706  int dist = KiROUND( EuclideanNorm( aPosition - GetCenter() ) );
707 
708  if( IsFilled() ) // Filled circle hit-test
709  {
710  if( dist <= radius + maxdist )
711  return true;
712  }
713  else // Ring hit-test
714  {
715  if( abs( radius - dist ) <= maxdist )
716  return true;
717  }
718 
719  break;
720  }
721 
722  case SHAPE_T::ARC:
723  {
724  wxPoint relPos = aPosition - GetCenter();
725  int radius = GetRadius();
726  int dist = KiROUND( EuclideanNorm( relPos ) );
727 
728  if( abs( radius - dist ) <= maxdist )
729  {
730  // For arcs, the test point angle must be >= arc angle start
731  // and <= arc angle end
732  // However angle values > 360 deg are not easy to handle
733  // so we calculate the relative angle between arc start point and test point
734  // this relative arc should be < arc angle if arc angle > 0 (CW arc)
735  // and > arc angle if arc angle < 0 (CCW arc)
736  double arc_angle_start = GetArcAngleStart(); // Always 0.0 ... 360 deg, in 0.1 deg
737 
738  double arc_hittest = ArcTangente( relPos.y, relPos.x );
739 
740  // Calculate relative angle between the starting point of the arc, and the test point
741  arc_hittest -= arc_angle_start;
742 
743  // Normalize arc_hittest between 0 ... 360 deg
744  NORMALIZE_ANGLE_POS( arc_hittest );
745 
746  // Check angle: inside the arc angle when it is > 0
747  // and outside the not drawn arc when it is < 0
748  if( GetAngle() >= 0.0 )
749  {
750  if( arc_hittest <= GetAngle() )
751  return true;
752  }
753  else
754  {
755  if( arc_hittest >= ( 3600.0 + GetAngle() ) )
756  return true;
757  }
758  }
759 
760  break;
761  }
762 
763  case SHAPE_T::BEZIER:
764  const_cast<PCB_SHAPE*>( this )->RebuildBezierToSegmentsPointsList( m_width );
765 
766  for( unsigned int i= 1; i < m_bezierPoints.size(); i++)
767  {
768  if( TestSegmentHit( aPosition, m_bezierPoints[ i - 1], m_bezierPoints[i], maxdist ) )
769  return true;
770  }
771 
772  break;
773 
774  case SHAPE_T::SEGMENT:
775  if( TestSegmentHit( aPosition, m_start, m_end, maxdist ) )
776  return true;
777 
778  break;
779 
780  case SHAPE_T::RECT:
781  {
782  std::vector<wxPoint> pts = GetRectCorners();
783 
784  if( IsFilled() ) // Filled rect hit-test
785  {
786  SHAPE_POLY_SET poly;
787  poly.NewOutline();
788 
789  for( const wxPoint& pt : pts )
790  poly.Append( pt );
791 
792  if( poly.Collide( VECTOR2I( aPosition ), maxdist ) )
793  return true;
794  }
795  else // Open rect hit-test
796  {
797  if( TestSegmentHit( aPosition, pts[0], pts[1], maxdist )
798  || TestSegmentHit( aPosition, pts[1], pts[2], maxdist )
799  || TestSegmentHit( aPosition, pts[2], pts[3], maxdist )
800  || TestSegmentHit( aPosition, pts[3], pts[0], maxdist ) )
801  {
802  return true;
803  }
804  }
805 
806  break;
807  }
808 
809  case SHAPE_T::POLY:
810  if( IsFilled() )
811  {
812  return m_poly.Collide( VECTOR2I( aPosition ), maxdist );
813  }
814  else
815  {
817  return m_poly.CollideEdge( VECTOR2I( aPosition ), dummy, maxdist );
818  }
819 
820  break;
821 
822  default:
823  wxFAIL_MSG( "PCB_SHAPE::HitTest (point) not implemented for "
824  + SHAPE_T_asString( m_shape ) );
825  break;
826  }
827 
828  return false;
829 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:146
Arcs (with rounded ends)
bool IsFilled() const
Definition: pcb_shape.h:75
Bezier Curve.
wxPoint m_end
Definition: pcb_shape.h:346
polygon (not yet used for tracks, but could be in microwave apps)
int GetRadius() const
Return the radius of this item.
Definition: pcb_shape.cpp:487
std::vector< wxPoint > GetRectCorners() const
Definition: pcb_shape.cpp:1048
double GetArcAngleStart() const
Definition: pcb_shape.cpp:457
usual segment : line with rounded ends
Structure to hold the necessary information in order to index a vertex on a SHAPE_POLY_SET object: th...
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:290
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
SHAPE_POLY_SET m_poly
Definition: pcb_shape.h:355
Represent a set of closed polygons.
wxPoint GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_shape.cpp:385
bool TestSegmentHit(const wxPoint &aRefPoint, const wxPoint &aStart, const wxPoint &aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
Definition: trigo.cpp:129
static wxString SHAPE_T_asString(SHAPE_T a)
Definition: board_item.h:57
int NewOutline()
Creates a new hole in a given outline.
wxPoint m_start
Definition: pcb_shape.h:345
bool Collide(const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if the boundary of shape (this) lies closer to the shape aShape than aClearance,...
bool CollideEdge(const VECTOR2I &aPoint, VERTEX_INDEX &aClosestVertex, int aClearance=0) const
Check whether aPoint collides with any edge of any of the contours of the polygon.
int m_width
Definition: pcb_shape.h:343
double GetAngle() const
Definition: pcb_shape.h:107
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
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:183
segment with non rounded ends
std::vector< wxPoint > m_bezierPoints
Definition: pcb_shape.h:354
SHAPE_T m_shape
Definition: pcb_shape.h:349
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...

References SHAPE_POLY_SET::Append(), ARC, ArcTangente(), BEZIER, CIRCLE, SHAPE_POLY_SET::Collide(), SHAPE_POLY_SET::CollideEdge(), dummy(), EuclideanNorm(), GetAngle(), GetArcAngleStart(), GetCenter(), GetRadius(), GetRectCorners(), IsFilled(), KiROUND(), m_bezierPoints, m_end, m_poly, m_shape, m_start, m_width, SHAPE_POLY_SET::NewOutline(), NORMALIZE_ANGLE_POS(), POLY, RECT, SEGMENT, SHAPE_T_asString(), and TestSegmentHit().

Referenced by GENERAL_COLLECTOR::Inspect().

◆ HitTest() [2/2]

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

Test if aRect intersects or is contained within the bounding box of an 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 832 of file pcb_shape.cpp.

833 {
834  EDA_RECT arect = aRect;
835  arect.Normalize();
836  arect.Inflate( aAccuracy );
837 
838  EDA_RECT arcRect;
839  EDA_RECT bb = GetBoundingBox();
840 
841  switch( m_shape )
842  {
843  case SHAPE_T::CIRCLE:
844  // Test if area intersects or contains the circle:
845  if( aContained )
846  {
847  return arect.Contains( bb );
848  }
849  else
850  {
851  // If the rectangle does not intersect the bounding box, this is a much quicker test
852  if( !aRect.Intersects( bb ) )
853  {
854  return false;
855  }
856  else
857  {
858  return arect.IntersectsCircleEdge( GetCenter(), GetRadius(), GetWidth() );
859  }
860  }
861 
862  break;
863 
864  case SHAPE_T::ARC:
865  // Test for full containment of this arc in the rect
866  if( aContained )
867  {
868  return arect.Contains( bb );
869  }
870  else
871  {
872  // Test if the rect crosses the arc
873  arcRect = bb.Common( arect );
874 
875  /* All following tests must pass:
876  * 1. Rectangle must intersect arc BoundingBox
877  * 2. Rectangle must cross the outside of the arc
878  */
879  return arcRect.Intersects( arect ) &&
881  }
882 
883  break;
884 
885  case SHAPE_T::RECT:
886  if( aContained )
887  {
888  return arect.Contains( bb );
889  }
890  else
891  {
892  std::vector<wxPoint> pts = GetRectCorners();
893 
894  // Account for the width of the lines
895  arect.Inflate( GetWidth() / 2 );
896  return ( arect.Intersects( pts[0], pts[1] )
897  || arect.Intersects( pts[1], pts[2] )
898  || arect.Intersects( pts[2], pts[3] )
899  || arect.Intersects( pts[3], pts[0] ) );
900  }
901 
902  break;
903 
904  case SHAPE_T::SEGMENT:
905  if( aContained )
906  {
907  return arect.Contains( GetStart() ) && aRect.Contains( GetEnd() );
908  }
909  else
910  {
911  // Account for the width of the line
912  arect.Inflate( GetWidth() / 2 );
913  return arect.Intersects( GetStart(), GetEnd() );
914  }
915 
916  break;
917 
918  case SHAPE_T::POLY:
919  if( aContained )
920  {
921  return arect.Contains( bb );
922  }
923  else
924  {
925  // Fast test: if aRect is outside the polygon bounding box,
926  // rectangles cannot intersect
927  if( !arect.Intersects( bb ) )
928  return false;
929 
930  // Account for the width of the line
931  arect.Inflate( GetWidth() / 2 );
932 
933  // Polygons in footprints use coordinates relative to the footprint.
934  // Therefore, instead of using m_poly, we make a copy which is translated
935  // to the actual location in the board.
936 
937  FOOTPRINT* fp{ GetParentFootprint() };
938  double orientation{ fp ? -DECIDEG2RAD( fp->GetOrientation() ) : 0.0 };
939  wxPoint offset;
940 
941  if( fp )
942  offset = fp->GetPosition();
943 
944  SHAPE_POLY_SET poly{ m_poly };
945  poly.Rotate( orientation );
946  poly.Move( offset );
947 
948  int count = poly.TotalVertices();
949 
950  for( int ii = 0; ii < count; ii++ )
951  {
952  auto vertex = poly.CVertex( ii );
953  auto vertexNext = poly.CVertex(( ii + 1 ) % count );
954 
955  // Test if the point is within aRect
956  if( arect.Contains( ( wxPoint ) vertex ) )
957  return true;
958 
959  // Test if this edge intersects aRect
960  if( arect.Intersects( ( wxPoint ) vertex, ( wxPoint ) vertexNext ) )
961  return true;
962  }
963  }
964 
965  break;
966 
967  case SHAPE_T::BEZIER:
968  if( aContained )
969  {
970  return arect.Contains( bb );
971  }
972  else
973  {
974  // Fast test: if aRect is outside the polygon bounding box,
975  // rectangles cannot intersect
976  if( !arect.Intersects( bb ) )
977  return false;
978 
979  // Account for the width of the line
980  arect.Inflate( GetWidth() / 2 );
981  unsigned count = m_bezierPoints.size();
982 
983  for( unsigned ii = 1; ii < count; ii++ )
984  {
985  wxPoint vertex = m_bezierPoints[ ii - 1];
986  wxPoint vertexNext = m_bezierPoints[ii];
987 
988  // Test if the point is within aRect
989  if( arect.Contains( ( wxPoint ) vertex ) )
990  return true;
991 
992  // Test if this edge intersects aRect
993  if( arect.Intersects( vertex, vertexNext ) )
994  return true;
995  }
996  }
997 
998  break;
999 
1000  default:
1001  wxFAIL_MSG( "PCB_SHAPE::HitTest (rect) not implemented for "
1002  + SHAPE_T_asString( m_shape ) );
1003  break;
1004  }
1005 
1006  return false;
1007 }
Arcs (with rounded ends)
Bezier Curve.
polygon (not yet used for tracks, but could be in microwave apps)
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: pcb_shape.h:134
int GetRadius() const
Return the radius of this item.
Definition: pcb_shape.cpp:487
std::vector< wxPoint > GetRectCorners() const
Definition: pcb_shape.cpp:1048
int GetWidth() const
Definition: pcb_shape.h:97
usual segment : line with rounded ends
bool IntersectsCircleEdge(const wxPoint &aCenter, const int aRadius, const int aWidth) const
Test for intersection between this rect and the edge (radius) of a circle.
Definition: eda_rect.cpp:331
EDA_RECT Common(const EDA_RECT &aRect) const
Return the area that is common with another rectangle.
Definition: eda_rect.cpp:489
void Rotate(double aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Rotate all vertices by a given angle.
bool Contains(const wxPoint &aPoint) const
Definition: eda_rect.cpp:57
SHAPE_POLY_SET m_poly
Definition: pcb_shape.h:355
Represent a set of closed polygons.
wxPoint GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_shape.cpp:385
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: pcb_shape.h:124
static wxString SHAPE_T_asString(SHAPE_T a)
Definition: board_item.h:57
void Normalize()
Ensures that the height ant width are positive.
Definition: eda_rect.cpp:35
FOOTPRINT * GetParentFootprint() const
Return the parent footprint or NULL if PCB_SHAPE does not belong to a footprint.
Definition: pcb_shape.cpp:532
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_shape.cpp:622
Handle the component boundary box.
Definition: eda_rect.h:42
double DECIDEG2RAD(double deg)
Definition: trigo.h:233
bool Intersects(const EDA_RECT &aRect) const
Test for a common area between rectangles.
Definition: eda_rect.cpp:150
segment with non rounded ends
std::vector< wxPoint > m_bezierPoints
Definition: pcb_shape.h:354
SHAPE_T m_shape
Definition: pcb_shape.h:349
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:364

References ARC, BEZIER, CIRCLE, EDA_RECT::Common(), EDA_RECT::Contains(), DECIDEG2RAD(), GetBoundingBox(), GetCenter(), GetEnd(), GetParentFootprint(), GetRadius(), GetRectCorners(), GetStart(), GetWidth(), EDA_RECT::Inflate(), EDA_RECT::Intersects(), EDA_RECT::IntersectsCircleEdge(), m_bezierPoints, m_poly, m_shape, EDA_RECT::Normalize(), POLY, RECT, SHAPE_POLY_SET::Rotate(), SEGMENT, and SHAPE_T_asString().

◆ IsBrightened()

◆ IsConnected()

◆ IsDragging()

bool EDA_ITEM::IsDragging ( ) const
inlineinherited

Definition at line 121 of file eda_item.h.

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

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 124 of file eda_item.h.

124 { return m_flags & ENTERED; }
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:481
#define ENTERED
indicates a group has been entered

References ENTERED, and EDA_ITEM::m_flags.

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

◆ IsFilled()

bool PCB_SHAPE::IsFilled ( ) const
inline

Definition at line 75 of file pcb_shape.h.

76  {
77  switch( m_shape )
78  {
79  case SHAPE_T::RECT:
80  case SHAPE_T::CIRCLE:
81  case SHAPE_T::POLY:
82  return m_filled;
83 
84  case SHAPE_T::SEGMENT:
85  case SHAPE_T::ARC:
86  case SHAPE_T::BEZIER:
87  return false;
88 
89  case SHAPE_T::LAST: // Make CLang compiler happy
90  return false;
91  }
92 
93  return false; // Make GCC compiler happy
94  }
Arcs (with rounded ends)
Bezier Curve.
polygon (not yet used for tracks, but could be in microwave apps)
usual segment : line with rounded ends
last value for this list
bool m_filled
Definition: pcb_shape.h:344
segment with non rounded ends
SHAPE_T m_shape
Definition: pcb_shape.h:349

References ARC, BEZIER, CIRCLE, LAST, m_filled, m_shape, POLY, RECT, and SEGMENT.

Referenced by BOARD_ADAPTER::addShapeWithClearance(), KIGFX::PCB_PAINTER::draw(), PCB_IO::format(), FOOTPRINT::GetCoverageArea(), GetFocusPosition(), hash_fp_item(), HitTest(), MakeEffectiveShapes(), PCB_PARSER::parsePAD(), BRDITEMS_PLOTTER::PlotFootprintGraphicItem(), BRDITEMS_PLOTTER::PlotPcbShape(), PNS_KICAD_IFACE_BASE::syncGraphicalItem(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow(), DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataToWindow(), DIALOG_PAD_PRIMITIVE_POLY_PROPS::TransferDataToWindow(), and TransformShapeWithClearanceToPolygon().

◆ IsForceVisible()

bool EDA_ITEM::IsForceVisible ( ) const
inlineinherited

Definition at line 206 of file eda_item.h.

206 { return m_forceVisible; }
bool m_forceVisible
Definition: eda_item.h:480

References EDA_ITEM::m_forceVisible.

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

◆ IsLocked()

bool BOARD_ITEM::IsLocked ( ) const
virtualinherited
Returns
true if the object is locked, else false.

Reimplemented in FOOTPRINT, and PAD.

Definition at line 78 of file board_item.cpp.

79 {
80  if( GetParentGroup() )
81  return GetParentGroup()->IsLocked();
82 
83  return GetState( LOCKED );
84 }
PCB_GROUP * GetParentGroup() const
Definition: board_item.h:91
virtual bool IsLocked() const
Definition: board_item.cpp:78
#define LOCKED
Pcbnew: locked from movement and deletion.
int GetState(EDA_ITEM_FLAGS type) const
Definition: eda_item.h:137

References BOARD_ITEM::GetParentGroup(), EDA_ITEM::GetState(), BOARD_ITEM::IsLocked(), and LOCKED.

Referenced by BOARD_ITEM_DESC::BOARD_ITEM_DESC(), PCB_CONTROL::DeleteItemCursor(), DIALOG_GROUP_PROPERTIES::DIALOG_GROUP_PROPERTIES(), DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES(), EDIT_TOOL::doMoveSelection(), EDIT_TOOL::DragArcTrack(), EDIT_TOOL::FilletTracks(), PCB_IO::format(), PCB_TEXT::GetMsgPanelInfo(), ZONE::GetMsgPanelInfo(), FP_TEXT::GetMsgPanelInfo(), PCB_GROUP::GetMsgPanelInfo(), PCB_DIMENSION_BASE::GetMsgPanelInfo(), GetMsgPanelInfo(), PCB_TRACK::GetMsgPanelInfoBase_Common(), ALIGN_DISTRIBUTE_TOOL::GetSelections(), ROUTER_TOOL::InlineDrag(), GENERAL_COLLECTOR::Inspect(), PAD::IsLocked(), BOARD_ITEM::IsLocked(), PCB_SELECTION_TOOL::itemPassesFilter(), CADSTAR_PCB_ARCHIVE_LOADER::makeTracksFromShapes(), TRACKS_CLEANER::mergeCollinearSegments(), BOARD_EDITOR_CONTROL::modifyLockSelected(), PCB_POINT_EDITOR::OnSelectionChange(), ZONE_SETTINGS::operator<<(), POSITION_RELATIVE_TOOL::PositionRelative(), processTextItem(), PCB_SELECTION_TOOL::RequestSelection(), PNS_KICAD_IFACE_BASE::syncArc(), PNS_KICAD_IFACE_BASE::syncTrack(), PNS_KICAD_IFACE_BASE::syncVia(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), and DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow().

◆ IsModified()

bool EDA_ITEM::IsModified ( ) const
inlineinherited

Definition at line 118 of file eda_item.h.

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

References IS_CHANGED, and EDA_ITEM::m_flags.

Referenced by PCB_EDIT_FRAME::OpenProjectFiles().

◆ IsMoving()

◆ IsNew()

◆ IsOnCopperLayer()

virtual bool BOARD_ITEM::IsOnCopperLayer ( ) const
inlinevirtualinherited
Returns
true if the object is on any copper layer, false otherwise.

Reimplemented in PAD, PCB_TRACK, and ZONE.

Definition at line 142 of file board_item.h.

143  {
144  return IsCopperLayer( GetLayer() );
145  }
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:787
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:171

References BOARD_ITEM::GetLayer(), and IsCopperLayer().

Referenced by CN_CONNECTIVITY_ALGO::Add(), DRC_ENGINE::EvalRules(), and BOARD_CONNECTED_ITEM::SetNetCode().

◆ IsOnLayer()

virtual bool BOARD_ITEM::IsOnLayer ( PCB_LAYER_ID  aLayer) const
inlinevirtualinherited

Test to see if this object is on the given layer.

Virtual so objects like PAD, which reside on multiple layers can do their own form of testing.

Parameters
aLayerThe layer to test for.
Returns
true if on given layer, else false.

Reimplemented in PAD, PCB_VIA, FOOTPRINT, ZONE, and PCB_GROUP.

Definition at line 229 of file board_item.h.

230  {
231  return m_layer == aLayer;
232  }
PCB_LAYER_ID m_layer
Definition: board_item.h:353

References BOARD_ITEM::m_layer.

Referenced by BOARD_ADAPTER::createLayers(), existsOnLayer(), GENERAL_COLLECTOR::Inspect(), PCB_LAYER_COLLECTOR::Inspect(), BOARD_INSPECTION_TOOL::InspectClearance(), and PNS_KICAD_IFACE::IsItemVisible().

◆ IsPolyShapeValid()

bool PCB_SHAPE::IsPolyShapeValid ( ) const
Returns
true if the polygonal shape is valid (has more than 2 points)

Definition at line 1294 of file pcb_shape.cpp.

1295 {
1296  // return true if the polygonal shape is valid (has more than 2 points)
1297  if( GetPolyShape().OutlineCount() == 0 )
1298  return false;
1299 
1300  const SHAPE_LINE_CHAIN& outline = ( (SHAPE_POLY_SET&)GetPolyShape() ).Outline( 0 );
1301 
1302  return outline.PointCount() > 2;
1303 }
SHAPE_POLY_SET & GetPolyShape()
Definition: pcb_shape.h:240
int PointCount() const
Return the number of points (vertices) in this line chain.
Represent a set of closed polygons.
Represent a polyline (an zero-thickness chain of connected line segments).

References GetPolyShape(), and SHAPE_LINE_CHAIN::PointCount().

Referenced by PCB_IO::format(), BRDITEMS_PLOTTER::PlotFootprintGraphicItem(), BRDITEMS_PLOTTER::PlotPcbShape(), and TransformShapeWithClearanceToPolygon().

◆ IsReplaceable()

virtual bool EDA_ITEM::IsReplaceable ( ) const
inlinevirtualinherited

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 in SCH_SYMBOL, SCH_SHEET, SCH_LABEL, SCH_TEXT, SCH_FIELD, and SCH_SHEET_PIN.

Definition at line 403 of file eda_item.h.

403 { return false; }

Referenced by EDA_ITEM::Matches().

◆ IsResized()

bool EDA_ITEM::IsResized ( ) const
inlineinherited

Definition at line 125 of file eda_item.h.

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

References IS_RESIZING, and EDA_ITEM::m_flags.

◆ IsSelected()

bool EDA_ITEM::IsSelected ( ) const
inlineinherited

Definition at line 123 of file eda_item.h.

123 { return m_flags & SELECTED; }
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:481
#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_LEGACY::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(), EE_SELECTION_TOOL::selectMultiple(), 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().

◆ IsTrack()

bool BOARD_ITEM::IsTrack ( ) const
inlineinherited

Test to see if this object is a track or via (or microvia).

Returns
true if a track or via, else false.

Definition at line 239 of file board_item.h.

240  {
241  return ( Type() == PCB_TRACE_T ) || ( Type() == PCB_VIA_T );
242  }
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

References PCB_TRACE_T, PCB_VIA_T, and EDA_ITEM::Type().

◆ IsType()

bool PCB_SHAPE::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 57 of file pcb_shape.h.

58  {
59  if( BOARD_ITEM::IsType( aScanTypes ) )
60  return true;
61 
62  for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
63  {
64  if( *p == PCB_LOCATE_GRAPHIC_T )
65  return true;
66  else if( *p == PCB_LOCATE_BOARD_EDGE_T )
67  return m_layer == Edge_Cuts;
68  }
69 
70  return false;
71  }
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
virtual bool IsType(const KICAD_T aScanTypes[]) const
Check whether the item is one of the listed types.
Definition: eda_item.h:183
PCB_LAYER_ID m_layer
Definition: board_item.h:353

References Edge_Cuts, EOT, EDA_ITEM::IsType(), BOARD_ITEM::m_layer, PCB_LOCATE_BOARD_EDGE_T, and PCB_LOCATE_GRAPHIC_T.

◆ IsWireImage()

bool EDA_ITEM::IsWireImage ( ) const
inlineinherited

Definition at line 122 of file eda_item.h.

122 { return m_flags & IS_WIRE_IMAGE; }
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:481
#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 295 of file eda_item.h.

299  {
300  for( auto it : aList )
301  {
302  if( static_cast<EDA_ITEM*>( it )->Visit( inspector, testData, scanTypes )
304  return SEARCH_RESULT::QUIT;
305  }
306 
308  }
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 314 of file eda_item.h.

316  {
317  for( auto it : aList )
318  {
319  if( static_cast<EDA_ITEM*>( it )->Visit( inspector, testData, scanTypes )
321  return SEARCH_RESULT::QUIT;
322  }
323 
325  }
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().

◆ layerMaskDescribe()

wxString BOARD_ITEM::layerMaskDescribe ( ) const
protectedvirtualinherited

Return a string (to be shown to the user) describing a layer mask.

The BOARD is needed because layer names are customizable.

Reimplemented in PCB_VIA.

Definition at line 99 of file board_item.cpp.

100 {
101  const BOARD* board = GetBoard();
102  LSET layers = GetLayerSet();
103 
104  // Try to be smart and useful. Check all copper first.
105  if( layers[F_Cu] && layers[B_Cu] )
106  return _( "all copper layers" );
107 
108  LSET copperLayers = layers & board->GetEnabledLayers().AllCuMask();
109  LSET techLayers = layers & board->GetEnabledLayers().AllTechMask();
110 
111  for( LSET testLayers : { copperLayers, techLayers, layers } )
112  {
113  for( int bit = PCBNEW_LAYER_ID_START; bit < PCB_LAYER_ID_COUNT; ++bit )
114  {
115  if( testLayers[ bit ] )
116  {
117  wxString layerInfo = board->GetLayerName( static_cast<PCB_LAYER_ID>( bit ) );
118 
119  if( testLayers.count() > 1 )
120  layerInfo << wxS( " " ) + _( "and others" );
121 
122  return layerInfo;
123  }
124  }
125  }
126 
127  // No copper, no technicals: no layer
128  return _( "no layers" );
129 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:750
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:361
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:466
static LSET AllTechMask()
Return a mask holding all technical layers (no CU layer) on both side.
Definition: lset.cpp:820
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:502
#define _(s)
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
Definition: layer_ids.h:70
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:50
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:176

References _, LSET::AllCuMask(), LSET::AllTechMask(), B_Cu, F_Cu, BOARD_ITEM::GetBoard(), BOARD::GetEnabledLayers(), BOARD::GetLayerName(), BOARD_ITEM::GetLayerSet(), PCB_LAYER_ID_COUNT, and PCBNEW_LAYER_ID_START.

Referenced by PCB_TRACK::GetMsgPanelInfo(), PAD::GetMsgPanelInfo(), and PAD::GetSelectMenuText().

◆ MakeEffectiveShapes()

std::vector< SHAPE * > PCB_SHAPE::MakeEffectiveShapes ( ) const

Make a set of SHAPE objects representing the PCB_SHAPE.

Caller owns the objects.

Definition at line 1163 of file pcb_shape.cpp.

1164 {
1165  std::vector<SHAPE*> effectiveShapes;
1166 
1167  switch( m_shape )
1168  {
1169  case SHAPE_T::ARC:
1170  effectiveShapes.emplace_back( new SHAPE_ARC( GetCenter(), GetArcStart(),
1171  GetAngle() / 10.0, m_width ) );
1172  break;
1173 
1174  case SHAPE_T::SEGMENT:
1175  effectiveShapes.emplace_back( new SHAPE_SEGMENT( GetStart(), GetEnd(), m_width ) );
1176  break;
1177 
1178  case SHAPE_T::RECT:
1179  {
1180  std::vector<wxPoint> pts = GetRectCorners();
1181 
1182  if( IsFilled() )
1183  {
1184  effectiveShapes.emplace_back( new SHAPE_SIMPLE( pts ) );
1185  }
1186 
1187  if( m_width > 0 || !IsFilled() )
1188  {
1189  effectiveShapes.emplace_back( new SHAPE_SEGMENT( pts[0], pts[1], m_width ) );
1190  effectiveShapes.emplace_back( new SHAPE_SEGMENT( pts[1], pts[2], m_width ) );
1191  effectiveShapes.emplace_back( new SHAPE_SEGMENT( pts[2], pts[3], m_width ) );
1192  effectiveShapes.emplace_back( new SHAPE_SEGMENT( pts[3], pts[0], m_width ) );
1193  }
1194 
1195  break;
1196  }
1197 
1198  case SHAPE_T::CIRCLE:
1199  {
1200  if( IsFilled() )
1201  {
1202  effectiveShapes.emplace_back( new SHAPE_CIRCLE( GetCenter(), GetRadius() ) );
1203  }
1204 
1205  if( m_width > 0 || !IsFilled() )
1206  {
1207  // SHAPE_CIRCLE has no ConvertToPolyline() method, so use a 360.0 SHAPE_ARC
1208  SHAPE_ARC circle( GetCenter(), GetEnd(), 360.0 );
1209  SHAPE_LINE_CHAIN l = circle.ConvertToPolyline();
1210 
1211  for( int i = 0; i < l.SegmentCount(); i++ )
1212  {
1213  effectiveShapes.emplace_back( new SHAPE_SEGMENT( l.Segment( i ).A,
1214  l.Segment( i ).B, m_width ) );
1215  }
1216  }
1217 
1218  break;
1219  }
1220 
1221  case SHAPE_T::BEZIER:
1222  {
1223  auto bezierPoints = buildBezierToSegmentsPointsList( GetWidth() );
1224  wxPoint start_pt = bezierPoints[0];
1225 
1226  for( unsigned int jj = 1; jj < bezierPoints.size(); jj++ )
1227  {
1228  wxPoint end_pt = bezierPoints[jj];
1229  effectiveShapes.emplace_back( new SHAPE_SEGMENT( start_pt, end_pt, m_width ) );
1230  start_pt = end_pt;
1231  }
1232 
1233  break;
1234  }
1235 
1236  case SHAPE_T::POLY:
1237  {
1239  FOOTPRINT* parentFootprint = dynamic_cast<FOOTPRINT*>( m_parent );
1240 
1241  if( parentFootprint )
1242  {
1243  l.Rotate( -parentFootprint->GetOrientationRadians() );
1244  l.Move( parentFootprint->GetPosition() );
1245  }
1246 
1247  if( IsFilled() )
1248  {
1249  effectiveShapes.emplace_back( new SHAPE_SIMPLE( l ) );
1250  }
1251 
1252  if( m_width > 0 || !IsFilled() )
1253  {
1254  for( int i = 0; i < l.SegmentCount(); i++ )
1255  effectiveShapes.emplace_back( new SHAPE_SEGMENT( l.Segment( i ), m_width ) );
1256  }
1257 
1258  break;
1259  }
1260 
1261  default:
1262  wxFAIL_MSG( "PCB_SHAPE::MakeEffectiveShapes unsupported PCB_SHAPE shape: "
1263  + SHAPE_T_asString( m_shape ) );
1264  break;
1265  }
1266 
1267  return effectiveShapes;
1268 }
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:479
Arcs (with rounded ends)
bool IsFilled() const
Definition: pcb_shape.h:75
Represent a simple polygon consisting of a zero-thickness closed chain of connected line segments.
Definition: shape_simple.h:41
Bezier Curve.
double GetOrientationRadians() const
Definition: footprint.h:192
polygon (not yet used for tracks, but could be in microwave apps)
SHAPE_POLY_SET & GetPolyShape()
Definition: pcb_shape.h:240
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: pcb_shape.h:134
int GetRadius() const
Return the radius of this item.
Definition: pcb_shape.cpp:487
void Move(const VECTOR2I &aVector) override
std::vector< wxPoint > GetRectCorners() const
Definition: pcb_shape.cpp:1048
int GetWidth() const
Definition: pcb_shape.h:97
usual segment : line with rounded ends
wxPoint GetArcStart() const
Definition: pcb_shape.h:156
wxPoint GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_shape.cpp:385
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: pcb_shape.h:124
static wxString SHAPE_T_asString(SHAPE_T a)
Definition: board_item.h:57
int SegmentCount() const
Return the number of segments in this line chain.
void Rotate(double aAngle, const VECTOR2I &aCenter=VECTOR2I(0, 0)) override
Rotate all vertices by a given angle.
SEG Segment(int aIndex)
Return a copy of the aIndex-th segment in the line chain.
int m_width
Definition: pcb_shape.h:343
Represent a polyline (an zero-thickness chain of connected line segments).
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
VECTOR2I A
Definition: seg.h:48
double GetAngle() const
Definition: pcb_shape.h:107
wxPoint GetPosition() const override
Definition: footprint.h:186
segment with non rounded ends
SHAPE_T m_shape
Definition: pcb_shape.h:349
const std::vector< wxPoint > buildBezierToSegmentsPointsList(int aMinSegLen) const
Definition: pcb_shape.cpp:372
VECTOR2I B
Definition: seg.h:49

References SEG::A, ARC, SEG::B, BEZIER, buildBezierToSegmentsPointsList(), CIRCLE, SHAPE_ARC::ConvertToPolyline(), SHAPE_POLY_SET::COutline(), GetAngle(), GetArcStart(), GetCenter(), GetEnd(), FOOTPRINT::GetOrientationRadians(), GetPolyShape(), FOOTPRINT::GetPosition(), GetRadius(), GetRectCorners(), GetStart(), GetWidth(), IsFilled(), EDA_ITEM::m_parent, m_shape, m_width, SHAPE_LINE_CHAIN::Move(), POLY, RECT, SHAPE_LINE_CHAIN::Rotate(), SEGMENT, SHAPE_LINE_CHAIN::Segment(), SHAPE_LINE_CHAIN::SegmentCount(), and SHAPE_T_asString().

Referenced by GetEffectiveShape(), and PNS_KICAD_IFACE_BASE::syncGraphicalItem().

◆ Matches() [1/2]

virtual bool EDA_ITEM::Matches ( const wxFindReplaceData &  aSearchData,
void *  aAuxData 
) const
inlinevirtualinherited

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 in SCH_SYMBOL, SCH_SHEET, SCH_TEXT, SCH_FIELD, SCH_SHEET_PIN, ZONE, SCH_PIN, SCH_MARKER, PCB_MARKER, FP_TEXT, and PCB_TEXT.

Definition at line 365 of file eda_item.h.

366  {
367  return false;
368  }

Referenced by SCH_EDITOR_CONTROL::HasMatch(), inDiffPair(), PCB_TEXT::Matches(), FP_TEXT::Matches(), PCB_MARKER::Matches(), SCH_MARKER::Matches(), SCH_PIN::Matches(), ZONE::Matches(), SCH_SHEET_PIN::Matches(), SCH_FIELD::Matches(), SCH_TEXT::Matches(), SCH_EDITOR_CONTROL::ReplaceAndFindNext(), and SCH_EDITOR_CONTROL::UpdateFind().

◆ 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  wxString searchText = aSearchData.GetFindString();
122 
123  // Don't match if searching for replaceable item and the item doesn't support text replace.
124  if( (aSearchData.GetFlags() & FR_SEARCH_REPLACE) && !IsReplaceable() )
125  return false;
126 
127  if( aSearchData.GetFlags() & wxFR_WHOLEWORD )
128  return aText.IsSameAs( searchText, aSearchData.GetFlags() & wxFR_MATCHCASE );
129 
130  if( aSearchData.GetFlags() & FR_MATCH_WILDCARD )
131  {
132  if( aSearchData.GetFlags() & wxFR_MATCHCASE )
133  return text.Matches( searchText );
134 
135  return text.MakeUpper().Matches( searchText.MakeUpper() );
136  }
137 
138  if( aSearchData.GetFlags() & wxFR_MATCHCASE )
139  return aText.Find( searchText ) != wxNOT_FOUND;
140 
141  return text.MakeUpper().Find( searchText.MakeUpper() ) != wxNOT_FOUND;
142 }
virtual bool IsReplaceable() const
Override this method in any derived object that supports test find and replace.
Definition: eda_item.h:403

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

◆ Move() [1/2]

void BOARD_ITEM::Move ( const VECTOR2I aMoveVector)
inlineinherited

Definition at line 278 of file board_item.h.

279  {
280  Move( wxPoint( aMoveVector.x, aMoveVector.y ) );
281  }
virtual void Move(const wxPoint &aMoveVector)
Move this object.
Definition: board_item.h:272

References BOARD_ITEM::Move(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ Move() [2/2]

void PCB_SHAPE::Move ( const wxPoint &  aMoveVector)
overridevirtual

Move this object.

Parameters
aMoveVectorthe move vector for this object.

Reimplemented from BOARD_ITEM.

Reimplemented in FP_SHAPE.

Definition at line 156 of file pcb_shape.cpp.

157 {
158  // Move vector should not affect start/end for polygon since it will
159  // be applied directly to polygon outline.
160  if( m_shape != SHAPE_T::POLY )
161  {
162  m_start += aMoveVector;
163  m_end += aMoveVector;
164  }
165 
166  switch ( m_shape )
167  {
168  case SHAPE_T::POLY:
169  m_poly.Move( VECTOR2I( aMoveVector ) );
170  break;
171 
172  case SHAPE_T::ARC:
173  m_thirdPoint += aMoveVector;
174  break;
175 
176  case SHAPE_T::BEZIER:
177  m_bezierC1 += aMoveVector;
178  m_bezierC2 += aMoveVector;
179 
180  for( wxPoint& pt : m_bezierPoints)
181  pt += aMoveVector;
182 
183  break;
184 
185  default:
186  break;
187  }
188 }
Arcs (with rounded ends)
Bezier Curve.
wxPoint m_end
Definition: pcb_shape.h:346
polygon (not yet used for tracks, but could be in microwave apps)
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
wxPoint m_thirdPoint
Definition: pcb_shape.h:347
void Move(const VECTOR2I &aVector) override
SHAPE_POLY_SET m_poly
Definition: pcb_shape.h:355
wxPoint m_start
Definition: pcb_shape.h:345
wxPoint m_bezierC1
Definition: pcb_shape.h:351
std::vector< wxPoint > m_bezierPoints
Definition: pcb_shape.h:354
wxPoint m_bezierC2
Definition: pcb_shape.h:352
SHAPE_T m_shape
Definition: pcb_shape.h:349

References ARC, BEZIER, m_bezierC1, m_bezierC2, m_bezierPoints, m_end, m_poly, m_shape, m_start, m_thirdPoint, SHAPE_POLY_SET::Move(), and POLY.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::getKiCadPad(), CADSTAR_PCB_ARCHIVE_LOADER::getShapeFromVertex(), PAD_TOOL::recombinePad(), DIALOG_PAD_PROPERTIES::redraw(), and PCB_POINT_EDITOR::updateItem().

◆ operator<()

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 171 of file eda_item.cpp.

172 {
173  wxFAIL_MSG( wxString::Format( wxT( "Less than operator not defined for item type %s." ),
174  GetClass() ) );
175 
176  return false;
177 }
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().

◆ RebuildBezierToSegmentsPointsList()

void PCB_SHAPE::RebuildBezierToSegmentsPointsList ( int  aMinSegLen)

Rebuild the m_BezierPoints vertex list that approximate the Bezier curve by a list of segments.

Has meaning only for S_CURVE DRAW_SEGMENT shape.

Parameters
aMinSegLenis the min length of segments approximating the he. shape last segment can be shorter. This parameter avoids having too many very short segment in list. A good value is m_Width/2 to m_Width.

Definition at line 359 of file pcb_shape.cpp.

360 {
361  // Has meaning only for S_CURVE DRAW_SEGMENT shape
362  if( m_shape != SHAPE_T::BEZIER )
363  {
364  m_bezierPoints.clear();
365  return;
366  }
367  // Rebuild the m_BezierPoints vertex list that approximate the Bezier curve
369 }
Bezier Curve.
std::vector< wxPoint > m_bezierPoints
Definition: pcb_shape.h:354
SHAPE_T m_shape
Definition: pcb_shape.h:349
const std::vector< wxPoint > buildBezierToSegmentsPointsList(int aMinSegLen) const
Definition: pcb_shape.cpp:372

References BEZIER, buildBezierToSegmentsPointsList(), m_bezierPoints, and m_shape.

Referenced by ConvertOutlineToPolygon(), FP_SHAPE::Flip(), GRAPHICS_CLEANER::isNullShape(), FP_SHAPE::SetDrawCoord(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow(), and PCB_POINT_EDITOR::updateItem().

◆ Replace() [1/2]

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 145 of file eda_item.cpp.

146 {
147  wxString searchString = (aSearchData.GetFlags() & wxFR_MATCHCASE) ? aText : aText.Upper();
148 
149  int result = searchString.Find( ( aSearchData.GetFlags() & wxFR_MATCHCASE ) ?
150  aSearchData.GetFindString() :
151  aSearchData.GetFindString().Upper() );
152 
153  if( result == wxNOT_FOUND )
154  return false;
155 
156  wxString prefix = aText.Left( result );
157  wxString suffix;
158 
159  if( aSearchData.GetFindString().length() + result < aText.length() )
160  suffix = aText.Right( aText.length() - ( aSearchData.GetFindString().length() + result ) );
161 
162  wxLogTrace( traceFindReplace, wxT( "Replacing '%s', prefix '%s', replace '%s', suffix '%s'." ),
163  aText, prefix, aSearchData.GetReplaceString(), suffix );
164 
165  aText = prefix + aSearchData.GetReplaceString() + suffix;
166 
167  return true;
168 }
const wxChar *const traceFindReplace
Flag to enable find and replace debug tracing.

References traceFindReplace.

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

◆ Replace() [2/2]

virtual bool EDA_ITEM::Replace ( const wxFindReplaceData &  aSearchData,
void *  aAuxData = nullptr 
)
inlinevirtualinherited

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 in SCH_TEXT, SCH_FIELD, SCH_SHEET_PIN, and SCH_PIN.

Definition at line 392 of file eda_item.h.

393  {
394  return false;
395  }

◆ Rotate() [1/2]

void BOARD_ITEM::Rotate ( const VECTOR2I aRotCentre,
double  aAngle 
)
inlineinherited

Definition at line 291 of file board_item.h.

292  {
293  Rotate( wxPoint( aRotCentre.x, aRotCentre.y ), aAngle );
294  }
virtual void Rotate(const wxPoint &aRotCentre, double aAngle)
Rotate this object.
Definition: board_item.cpp:191

References BOARD_ITEM::Rotate(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ Rotate() [2/2]

void PCB_SHAPE::Rotate ( const wxPoint &  aRotCentre,
double  aAngle 
)
overridevirtual

Rotate this object.

Parameters
aRotCentrethe rotation point.
aAnglethe rotation angle in 0.1 degree.

Reimplemented from BOARD_ITEM.

Reimplemented in FP_SHAPE.

Definition at line 241 of file pcb_shape.cpp.

242 {
243  switch( m_shape )
244  {
245  case SHAPE_T::ARC:
246  case SHAPE_T::SEGMENT:
247  case SHAPE_T::CIRCLE:
248  // these can all be done by just rotating the constituent points
249  RotatePoint( &m_start, aRotCentre, aAngle );
250  RotatePoint( &m_end, aRotCentre, aAngle );
251  RotatePoint( &m_thirdPoint, aRotCentre, aAngle );
252  break;
253 
254  case SHAPE_T::RECT:
255  if( KiROUND( aAngle ) % 900 == 0 )
256  {
257  RotatePoint( &m_start, aRotCentre, aAngle );
258  RotatePoint( &m_end, aRotCentre, aAngle );
259  break;
260  }
261 
262  // Convert non-cartesian-rotated rect to a diamond
265  m_poly.NewOutline();
266  m_poly.Append( m_start );
267  m_poly.Append( m_end.x, m_start.y );
268  m_poly.Append( m_end );
269  m_poly.Append( m_start.x, m_end.y );
270 
272 
273  case SHAPE_T::POLY:
274  m_poly.Rotate( -DECIDEG2RAD( aAngle ), VECTOR2I( aRotCentre ) );
275  break;
276 
277  case SHAPE_T::BEZIER:
278  RotatePoint( &m_start, aRotCentre, aAngle);
279  RotatePoint( &m_end, aRotCentre, aAngle);
280  RotatePoint( &m_bezierC1, aRotCentre, aAngle);
281  RotatePoint( &m_bezierC2, aRotCentre, aAngle);
282 
283  for( wxPoint& pt : m_bezierPoints )
284  RotatePoint( &pt, aRotCentre, aAngle);
285 
286  break;
287 
288  default:
289  wxFAIL_MSG( "PCB_SHAPE::Rotate not implemented for "
290  + SHAPE_T_asString( m_shape ) );
291  break;
292  }
293 }
Arcs (with rounded ends)
Bezier Curve.
wxPoint m_end
Definition: pcb_shape.h:346
polygon (not yet used for tracks, but could be in microwave apps)
usual segment : line with rounded ends
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
void Rotate(double aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Rotate all vertices by a given angle.
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
wxPoint m_thirdPoint
Definition: pcb_shape.h:347
SHAPE_POLY_SET m_poly
Definition: pcb_shape.h:355
static wxString SHAPE_T_asString(SHAPE_T a)
Definition: board_item.h:57
int NewOutline()
Creates a new hole in a given outline.
wxPoint m_start
Definition: pcb_shape.h:345
double DECIDEG2RAD(double deg)
Definition: trigo.h:233
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
wxPoint m_bezierC1
Definition: pcb_shape.h:351
segment with non rounded ends
std::vector< wxPoint > m_bezierPoints
Definition: pcb_shape.h:354
wxPoint m_bezierC2
Definition: pcb_shape.h:352
SHAPE_T m_shape
Definition: pcb_shape.h:349
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...

References SHAPE_POLY_SET::Append(), ARC, BEZIER, CIRCLE, DECIDEG2RAD(), KI_FALLTHROUGH, KiROUND(), m_bezierC1, m_bezierC2, m_bezierPoints, m_end, m_poly, m_shape, m_start, m_thirdPoint, SHAPE_POLY_SET::NewOutline(), POLY, RECT, SHAPE_POLY_SET::RemoveAllContours(), SHAPE_POLY_SET::Rotate(), RotatePoint(), SEGMENT, and SHAPE_T_asString().

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::getKiCadPad(), CADSTAR_PCB_ARCHIVE_LOADER::getShapeFromVertex(), ALTIUM_PCB::HelperParsePad6NonCopper(), ALTIUM_PCB::ParseFills6Data(), PAD_TOOL::recombinePad(), DIALOG_PAD_PROPERTIES::redraw(), and FP_SHAPE::Rotate().

◆ Scale()

void PCB_SHAPE::Scale ( double  aScale)

Definition at line 191 of file pcb_shape.cpp.

192 {
193  auto scalePt = [&]( wxPoint& pt )
194  {
195  pt.x = KiROUND( pt.x * aScale );
196  pt.y = KiROUND( pt.y * aScale );
197  };
198 
199  int radius = GetRadius();
200 
201  scalePt( m_start );
202  scalePt( m_end );
203 
204  // specific parameters:
205  switch( m_shape )
206  {
207  case SHAPE_T::BEZIER:
208  scalePt( m_bezierC1 );
209  scalePt( m_bezierC2 );
210  break;
211 
212  case SHAPE_T::ARC:
213  scalePt( m_thirdPoint );
214  break;
215 
216  case SHAPE_T::CIRCLE: // ring or circle
217  m_end.x = m_start.x + KiROUND( radius * aScale );
218  m_end.y = m_start.y;
219  break;
220 
221  case SHAPE_T::POLY: // polygon
222  {
223  std::vector<wxPoint> pts;
224 
225  for( const VECTOR2I& pt : m_poly.Outline( 0 ).CPoints() )
226  {
227  pts.emplace_back( pt );
228  scalePt( pts.back() );
229  }
230 
231  SetPolyPoints( pts );
232  break;
233  }
234 
235  default:
236  break;
237  }
238 }
Arcs (with rounded ends)
Bezier Curve.
wxPoint m_end
Definition: pcb_shape.h:346
polygon (not yet used for tracks, but could be in microwave apps)
int GetRadius() const
Return the radius of this item.
Definition: pcb_shape.cpp:487
wxPoint m_thirdPoint
Definition: pcb_shape.h:347
const std::vector< VECTOR2I > & CPoints() const
SHAPE_POLY_SET m_poly
Definition: pcb_shape.h:355
SHAPE_LINE_CHAIN & Outline(int aIndex)
wxPoint m_start
Definition: pcb_shape.h:345
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
wxPoint m_bezierC1
Definition: pcb_shape.h:351
wxPoint m_bezierC2
Definition: pcb_shape.h:352
SHAPE_T m_shape
Definition: pcb_shape.h:349
void SetPolyPoints(const std::vector< wxPoint > &aPoints)
Definition: pcb_shape.cpp:1153

References ARC, BEZIER, CIRCLE, SHAPE_LINE_CHAIN::CPoints(), GetRadius(), KiROUND(), m_bezierC1, m_bezierC2, m_end, m_poly, m_shape, m_start, m_thirdPoint, SHAPE_POLY_SET::Outline(), POLY, and SetPolyPoints().

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::getShapeFromVertex().

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

◆ SetAngle()

void PCB_SHAPE::SetAngle ( double  aAngle,
bool  aUpdateEnd = true 
)
virtual

Set the angle for arcs, and normalizes it within the range 0 - 360 degrees.

Parameters
aAngleis tenths of degrees, but will soon be degrees.
aUpdateEndset to true to update also arc end coordinates m_thirdPoint, so must be called after setting m_Start and m_End.

Reimplemented in FP_SHAPE.

Definition at line 519 of file pcb_shape.cpp.

520 {
521  // m_Angle must be >= -360 and <= +360 degrees
522  m_angle = NormalizeAngle360Max( aAngle );
523 
524  if( aUpdateEnd )
525  {
528  }
529 }
wxPoint m_end
Definition: pcb_shape.h:346
T NormalizeAngle360Max(T Angle)
Normalize angle to be >=-360.0 and <= 360.0 Angle can be equal to -360 or +360.
Definition: trigo.h:241
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
wxPoint m_thirdPoint
Definition: pcb_shape.h:347
double m_angle
Definition: pcb_shape.h:350
wxPoint m_start
Definition: pcb_shape.h:345

References m_angle, m_end, m_start, m_thirdPoint, NormalizeAngle360Max(), and RotatePoint().

Referenced by PAD::AddPrimitiveArc(), PCAD2KICAD::PCB_ARC::AddToBoard(), DRAWING_TOOL::drawArc(), PCB_POINT_EDITOR::editArcEndpointKeepCenter(), PCB_POINT_EDITOR::editArcEndpointKeepTangent(), CADSTAR_PCB_ARCHIVE_LOADER::getShapeFromVertex(), ALTIUM_PCB::HelperCreateBoardOutline(), EAGLE_PLUGIN::loadPlain(), ALTIUM_PCB::ParseArcs6Data(), PAD_TOOL::recombinePad(), CONVERT_TOOL::SegmentToArc(), FP_SHAPE::SetAngle(), SetArcGeometry(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataFromWindow(), and updateArcFromConstructionMgr().

◆ SetArcEnd()

void PCB_SHAPE::SetArcEnd ( const wxPoint &  aArcEndPoint)
inline

Initialize the end arc point.

Can be used for circles to initialize one point of the cicumference.

Definition at line 193 of file pcb_shape.h.

194  {
195  m_thirdPoint = aArcEndPoint;
196  }
wxPoint m_thirdPoint
Definition: pcb_shape.h:347

References m_thirdPoint.

Referenced by PCB_POINT_EDITOR::editArcEndpointKeepCenter(), PCB_POINT_EDITOR::editArcEndpointKeepTangent(), PCB_POINT_EDITOR::editArcMidKeepCenter(), CONVERT_TOOL::SegmentToArc(), SetArcGeometry(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow(), and updateArcFromConstructionMgr().

◆ SetArcGeometry()

void PCB_SHAPE::SetArcGeometry ( const wxPoint &  aStart,
const wxPoint &  aMid,
const wxPoint &  aEnd 
)

Set the three controlling points for an arc.

NB: these are NOT what's currently stored, so we have to do some calculations behind the scenes. However, they are what SHOULD be stored.

Definition at line 496 of file pcb_shape.cpp.

497 {
498  SetArcStart( aStart );
499  SetArcEnd( aEnd );
500 
501  // Sadly we currently store center and angle rather than mid. So we have to calculate
502  // those.
503  wxPoint center = GetArcCenter( aStart, aMid, aEnd );
504  VECTOR2D startLine = aStart - center;
505  VECTOR2D endLine = aEnd - center;
506  bool clockwise = GetAngle() > 0;
507  double angle = RAD2DECIDEG( endLine.Angle() - startLine.Angle() );
508 
509  if( clockwise && angle < 0.0 )
510  angle += 3600.0;
511  else if( !clockwise && angle > 0.0 )
512  angle -= 3600.0;
513 
514  SetAngle( angle, false );
515  SetCenter( center );
516 }
double RAD2DECIDEG(double rad)
Definition: trigo.h:234
void SetCenter(const wxPoint &aCenterPoint)
Definition: pcb_shape.h:198
double Angle() const
Compute the angle of the vector.
Definition: vector2d.h:307
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
double GetAngle() const
Definition: pcb_shape.h:107
void SetArcEnd(const wxPoint &aArcEndPoint)
Initialize the end arc point.
Definition: pcb_shape.h:193
const VECTOR2I GetArcCenter(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Determine the center of an arc or circle given three points on its circumference.
Definition: trigo.cpp:454
virtual void SetAngle(double aAngle, bool aUpdateEnd=true)
Set the angle for arcs, and normalizes it within the range 0 - 360 degrees.
Definition: pcb_shape.cpp:519
void SetArcStart(const wxPoint &aArcStartPoint)
Initialize the start arc point.
Definition: pcb_shape.h:183

References PNS::angle(), VECTOR2< T >::Angle(), GetAngle(), GetArcCenter(), RAD2DECIDEG(), SetAngle(), SetArcEnd(), SetArcStart(), and SetCenter().

Referenced by PCB_POINT_EDITOR::editArcMidKeepEndpoints().

◆ SetArcStart()

◆ SetBezierC1()

◆ SetBezierC2()

void PCB_SHAPE::SetBezierC2 ( const wxPoint &  aPoint)
inline

◆ SetBezierPoints()

void PCB_SHAPE::SetBezierPoints ( const std::vector< wxPoint > &  aPoints)
inline

Definition at line 250 of file pcb_shape.h.

251  {
252  m_bezierPoints = aPoints;
253  }
std::vector< wxPoint > m_bezierPoints
Definition: pcb_shape.h:354

References m_bezierPoints.

◆ SetBrightened()

◆ SetCenter()

◆ SetEnd()

◆ SetEndX()

◆ SetEndY()

◆ SetFilled()

◆ SetFlags()

void EDA_ITEM::SetFlags ( EDA_ITEM_FLAGS  aMask)
inlineinherited

Definition at line 153 of file eda_item.h.

153 { m_flags |= aMask; }
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:481

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::cleanupSegments(), 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(), BACK_ANNOTATE::processNetNameChange(), SCH_EDIT_FRAME::PutDataInPreviousState(), PCB_SELECTION_TOOL::RebuildSelection(), FOOTPRINT::Remove(), BOARD::Remove(), SCH_EDIT_TOOL::RepeatDrawItem(), SYMBOL_EDIT_FRAME::SaveCopyInUndoList(), EE_SELECTION_TOOL::selectMultiple(), 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 204 of file eda_item.h.

204 { m_forceVisible = aEnable; }
bool m_forceVisible
Definition: eda_item.h:480

References EDA_ITEM::m_forceVisible.

Referenced by SCH_EDITOR_CONTROL::UpdateFind().

◆ SetLayer()

virtual void BOARD_ITEM::SetLayer ( PCB_LAYER_ID  aLayer)
inlinevirtualinherited

Set the layer this item is on.

This method is virtual because some items (in fact: class DIMENSION) have a slightly different initialization.

Parameters
aLayerThe layer number.

Reimplemented in PCB_DIMENSION_BASE, ZONE, and PCB_GROUP.

Definition at line 192 of file board_item.h.

193  {
194  m_layer = aLayer;
195  }
PCB_LAYER_ID m_layer
Definition: board_item.h:353

References BOARD_ITEM::m_layer.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::addAttribute(), PNS_KICAD_IFACE::AddItem(), PCAD2KICAD::PCB_ARC::AddToBoard(), PCAD2KICAD::PCB_LINE::AddToBoard(), PCAD2KICAD::PCB_FOOTPRINT::AddToBoard(), PCAD2KICAD::PCB_ARC::AddToFootprint(), PCAD2KICAD::PCB_LINE::AddToFootprint(), PCAD2KICAD::PCB_POLYGON::AddToFootprint(), BOARD_CONNECTED_ITEM_DESC::BOARD_CONNECTED_ITEM_DESC(), BOARD_ITEM_DESC::BOARD_ITEM_DESC(), BOOST_AUTO_TEST_CASE(), ZONE_CREATE_HELPER::commitZone(), CONVERT_TOOL::CreateLines(), MICROWAVE_TOOL::createMicrowaveInductor(), PCB_BASE_FRAME::CreateNewFootprint(), MICROWAVE_TOOL::createPolygonShape(), CONVERT_TOOL::CreatePolys(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawBoardCharacteristics(), CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarShape(), CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText(), DRAWING_TOOL::DrawSpecificationStackup(), PAD_TOOL::explodePad(), EDIT_TOOL::FilletTracks(), PCB_TARGET::Flip(), PCB_TEXT::Flip(), PCB_TRACK::Flip(), FP_SHAPE::Flip(), FP_TEXT::Flip(), FOOTPRINT::Flip(), PCB_ARC::Flip(), Flip(), FOOTPRINT_DESC::FOOTPRINT_DESC(), FP_TEXT::FP_TEXT(), ALTIUM_PCB::HelperCreateBoardOutline(), ALTIUM_PCB::HelperParseDimensions6Datum(), ALTIUM_PCB::HelperParseDimensions6Leader(), ALTIUM_PCB::HelperParsePad6NonCopper(), initTextTable(), LEGACY_PLUGIN::loadFOOTPRINT(), FABMASTER::loadFootprints(), FABMASTER::loadGraphics(), LEGACY_PLUGIN::loadMODULE_TEXT(), CADSTAR_PCB_ARCHIVE_LOADER::loadNetTracks(), LEGACY_PLUGIN::loadPCB_TEXT(), EAGLE_PLUGIN::loadPlain(), FABMASTER::loadPolygon(), EAGLE_PLUGIN::loadSignals(), LEGACY_PLUGIN::loadTrackList(), main(), DSN::SPECCTRA_DB::makeTRACK(), CADSTAR_PCB_ARCHIVE_LOADER::makeTracksFromShapes(), GRAPHICS_CLEANER::mergeRects(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::OnAddField(), DIALOG_FOOTPRINT_PROPERTIES::OnAddField(), EAGLE_PLUGIN::packageCircle(), EAGLE_PLUGIN::packagePolygon(), EAGLE_PLUGIN::packageRectangle(), EAGLE_PLUGIN::packageText(), EAGLE_PLUGIN::packageWire(), ALTIUM_PCB::ParseArcs6Data(), ALTIUM_PCB::ParseComponents6Data(), ALTIUM_PCB::ParseFills6Data(), GPCB_FPL_CACHE::parseFOOTPRINT(), ALTIUM_PCB::ParseShapeBasedRegions6Data(), ALTIUM_PCB::ParseTexts6Data(), ALTIUM_PCB::ParseTracks6Data(), DRAWING_TOOL::PlaceCharacteristics(), DRAWING_TOOL::PlaceStackup(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), BRDITEMS_PLOTTER::PlotDimension(), BRDITEMS_PLOTTER::PlotPcbTarget(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::processItem(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), processTextItem(), PNS_PCBNEW_RULE_RESOLVER::QueryConstraint(), DIALOG_PAD_PROPERTIES::redraw(), CLIPBOARD_IO::SaveSelection(), CONVERT_TOOL::SegmentToArc(), PCB_DIMENSION_BASE::SetLayer(), GLOBAL_EDIT_TOOL::swapBoardItem(), TRACK_VIA_DESC::TRACK_VIA_DESC(), DIALOG_TRACK_VIA_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), and DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow().

◆ SetLayerSet()

virtual void BOARD_ITEM::SetLayerSet ( LSET  aLayers)
inlinevirtualinherited

Reimplemented in PAD, PCB_VIA, and ZONE.

Definition at line 177 of file board_item.h.

178  {
179  wxFAIL_MSG( "Attempted to SetLayerSet() on a single-layer object." );
180 
181  // Derived classes which support multiple layers must implement this
182  }

Referenced by PANEL_SETUP_LAYERS::TransferDataFromWindow().

◆ SetLocked()

◆ SetModified()

void EDA_ITEM::SetModified ( )
inherited

◆ SetParent()

virtual void EDA_ITEM::SetParent ( EDA_ITEM aParent)
inlinevirtualinherited

Reimplemented in PCB_DIMENSION_BASE.

Definition at line 116 of file eda_item.h.

116 { m_parent = aParent; }
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:479

References EDA_ITEM::m_parent.

Referenced by FOOTPRINT::Add(), BOARD::Add(), FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), BOARD_NETLIST_UPDATER::addNewFootprint(), SCH_SHEET::AddPin(), PAD::AddPrimitive(), PAD::AddPrimitiveArc(), PAD::AddPrimitiveCircle(), PAD::AddPrimitiveCurve(), PAD::AddPrimitivePoly(), PAD::AddPrimitiveRect(), PAD::AddPrimitiveSegment(), SYMBOL_EDITOR_CONTROL::AddSymbolToSchematic(), SCH_SCREEN::Append(), LIB_FIELD::Copy(), SYMBOL_EDIT_FRAME::CreateNewSymbol(), SCH_DRAWING_TOOLS::createNewText(), DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), PCB_EDIT_FRAME::ExchangeFootprint(), LIB_SYMBOL::Flatten(), FOOTPRINT::FOOTPRINT(), PCB_IO::FootprintSave(), DISPLAY_FOOTPRINTS_FRAME::GetFootprint(), CADSTAR_SCH_ARCHIVE_LOADER::getKiCadSchText(), LIB_SYMBOL::LIB_SYMBOL(), SCH_LEGACY_PLUGIN_CACHE::loadAliases(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard(), SCH_SEXPR_PLUGIN::loadHierarchy(), SCH_LEGACY_PLUGIN::loadHierarchy(), FOOTPRINT::operator=(), LIB_SYMBOL::operator=(), PCB_PARSER::parseFOOTPRINT_unchecked(), SCH_SEXPR_PARSER::ParseSchematic(), SCH_SEXPR_PARSER::ParseSymbol(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), PCB_CONTROL::Paste(), SCH_EDITOR_CONTROL::Paste(), pasteFootprintItemsToFootprintEditor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), BACK_ANNOTATE::processNetNameChange(), BOARD_COMMIT::Push(), SCH_SEXPR_PLUGIN_CACHE::removeSymbol(), SCH_LEGACY_PLUGIN_CACHE::removeSymbol(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), SaveCopyOfZones(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), SCH_SHEET_PIN::SCH_SHEET_PIN(), LIB_SYMBOL::SetFields(), PCB_DIMENSION_BASE::SetParent(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_LINE_WIRE_BUS_TOOL::startSegments(), SCH_SHEET::SwapData(), SCH_GLOBALLABEL::SwapData(), SCH_SYMBOL::SwapData(), and SwapItemData().

◆ SetParentGroup()

void BOARD_ITEM::SetParentGroup ( PCB_GROUP aGroup)
inlineinherited

Definition at line 90 of file board_item.h.

90 { m_group = aGroup; }
PCB_GROUP * m_group
Definition: board_item.h:354

References BOARD_ITEM::m_group.

Referenced by PCB_GROUP::AddItem(), and PCB_GROUP::RemoveItem().

◆ SetPolyPoints()

void PCB_SHAPE::SetPolyPoints ( const std::vector< wxPoint > &  aPoints)

Definition at line 1153 of file pcb_shape.cpp.

1154 {
1156  m_poly.NewOutline();
1157 
1158  for ( const wxPoint& p : aPoints )
1159  m_poly.Append( p.x, p.y );
1160 }
SHAPE_POLY_SET m_poly
Definition: pcb_shape.h:355
int NewOutline()
Creates a new hole in a given outline.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...

References SHAPE_POLY_SET::Append(), m_poly, SHAPE_POLY_SET::NewOutline(), and SHAPE_POLY_SET::RemoveAllContours().

Referenced by PAD::AddPrimitivePoly(), PCAD2KICAD::PCB_POLYGON::AddToFootprint(), MICROWAVE_TOOL::createPolygonShape(), ALTIUM_PCB::HelperParsePad6NonCopper(), EAGLE_PLUGIN::packagePolygon(), EAGLE_PLUGIN::packageRectangle(), ALTIUM_PCB::ParseFills6Data(), Scale(), and DIALOG_PAD_PRIMITIVE_POLY_PROPS::TransferDataFromWindow().

◆ SetPolyShape()

◆ SetPosition()

void PCB_SHAPE::SetPosition ( const wxPoint &  aPos)
overridevirtual

Reimplemented from EDA_ITEM.

Definition at line 64 of file pcb_shape.cpp.

65 {
66  m_start = aPos;
67 }
wxPoint m_start
Definition: pcb_shape.h:345

References m_start.

◆ SetSelected()

◆ SetShape()

void PCB_SHAPE::SetShape ( SHAPE_T  aShape)
inline

◆ SetStart()

◆ SetStartX()

void PCB_SHAPE::SetStartX ( int  x)
inline

◆ SetStartY()

void PCB_SHAPE::SetStartY ( int  y)
inline

◆ SetState()

void EDA_ITEM::SetState ( EDA_ITEM_FLAGS  type,
bool  state 
)
inlineinherited

Definition at line 142 of file eda_item.h.

143  {
144  if( state )
145  m_status |= type; // state = ON or OFF
146  else
147  m_status &= ~type;
148  }
EDA_ITEM_FLAGS m_status
Definition: eda_item.h:478

References EDA_ITEM::m_status.

Referenced by LEGACY_PLUGIN::loadTrackList(), TRACKS_CLEANER::mergeCollinearSegments(), and BOARD_ITEM::SetLocked().

◆ SetStatus()

void EDA_ITEM::SetStatus ( EDA_ITEM_FLAGS  aStatus)
inlineinherited

Definition at line 151 of file eda_item.h.

151 { m_status = aStatus; }
EDA_ITEM_FLAGS m_status
Definition: eda_item.h:478

References EDA_ITEM::m_status.

Referenced by BOARD_NETLIST_UPDATER::UpdateNetlist().

◆ SetThirdPoint()

void PCB_SHAPE::SetThirdPoint ( const wxPoint &  aPoint)
inline

Definition at line 147 of file pcb_shape.h.

147 { m_thirdPoint = aPoint; }
wxPoint m_thirdPoint
Definition: pcb_shape.h:347

References m_thirdPoint.

◆ SetThirdPointX()

void PCB_SHAPE::SetThirdPointX ( int  x)
inline

Definition at line 149 of file pcb_shape.h.

149 { m_thirdPoint.x = x; }
wxPoint m_thirdPoint
Definition: pcb_shape.h:347

References m_thirdPoint.

◆ SetThirdPointY()

void PCB_SHAPE::SetThirdPointY ( int  y)
inline

Definition at line 148 of file pcb_shape.h.

148 { m_thirdPoint.y = y; }
wxPoint m_thirdPoint
Definition: pcb_shape.h:347

References m_thirdPoint.

◆ SetWidth()

void PCB_SHAPE::SetWidth ( int  aWidth)
inline

Definition at line 96 of file pcb_shape.h.

96 { m_width = aWidth; }
int m_width
Definition: pcb_shape.h:343

References m_width.

Referenced by PAD::AddPrimitiveArc(), PAD::AddPrimitiveCircle(), PAD::AddPrimitiveCurve(), PAD::AddPrimitivePoly(), PAD::AddPrimitiveRect(), PAD::AddPrimitiveSegment(), PCAD2KICAD::PCB_ARC::AddToBoard(), PCAD2KICAD::PCB_LINE::AddToBoard(), PCAD2KICAD::PCB_ARC::AddToFootprint(), PCAD2KICAD::PCB_POLYGON::AddToFootprint(), PCAD2KICAD::PCB_LINE::AddToFootprint(), ZONE_CREATE_HELPER::commitZone(), MICROWAVE_TOOL::createMicrowaveInductor(), MICROWAVE_TOOL::createPolygonShape(), CONVERT_TOOL::CreatePolys(), DRAWING_TOOL::drawArc(), CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarShape(), DRAWSEGMENT_DESC::DRAWSEGMENT_DESC(), PAD_TOOL::explodePad(), CADSTAR_PCB_ARCHIVE_LOADER::getKiCadPad(), ALTIUM_PCB::HelperCreateBoardOutline(), ALTIUM_PCB::HelperParseDimensions6Datum(), ALTIUM_PCB::HelperParseDimensions6Leader(), ALTIUM_PCB::HelperParsePad6NonCopper(), FABMASTER::loadGraphics(), CADSTAR_PCB_ARCHIVE_LOADER::loadNetTracks(), EAGLE_PLUGIN::loadPlain(), FABMASTER::loadPolygon(), GRAPHICS_CLEANER::mergeRects(), DIALOG_PAD_PROPERTIES::onAddPrimitive(), EAGLE_PLUGIN::packageCircle(), EAGLE_PLUGIN::packagePolygon(), EAGLE_PLUGIN::packageRectangle(), EAGLE_PLUGIN::packageWire(), ALTIUM_PCB::ParseArcs6Data(), ALTIUM_PCB::ParseFills6Data(), GPCB_FPL_CACHE::parseFOOTPRINT(), ALTIUM_PCB::ParseShapeBasedRegions6Data(), ALTIUM_PCB::ParseTracks6Data(), BRDITEMS_PLOTTER::PlotDimension(), BRDITEMS_PLOTTER::PlotPcbTarget(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), PAD_TOOL::recombinePad(), CONVERT_TOOL::SegmentToArc(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataFromWindow(), and DIALOG_PAD_PRIMITIVE_POLY_PROPS::TransferDataFromWindow().

◆ SetWireImage()

void EDA_ITEM::SetWireImage ( )
inlineinherited

Definition at line 128 of file eda_item.h.

128 { SetFlags( IS_WIRE_IMAGE ); }
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:153
#define IS_WIRE_IMAGE
Item to be drawn as wireframe while editing.

References IS_WIRE_IMAGE, and EDA_ITEM::SetFlags().

◆ SetX()

void BOARD_ITEM::SetX ( int  aX)
inlineinherited

Definition at line 117 of file board_item.h.

118  {
119  wxPoint p( aX, GetY() );
120  SetPosition( p );
121  }
virtual void SetPosition(const wxPoint &aPos)
Definition: eda_item.h:253
int GetY() const
Definition: board_item.h:101

References BOARD_ITEM::GetY(), and EDA_ITEM::SetPosition().

Referenced by BOARD_ITEM_DESC::BOARD_ITEM_DESC(), and TRACK_VIA_DESC::TRACK_VIA_DESC().

◆ SetY()

void BOARD_ITEM::SetY ( int  aY)
inlineinherited

Definition at line 123 of file board_item.h.

124  {
125  wxPoint p( GetX(), aY );
126  SetPosition( p );
127  }
virtual void SetPosition(const wxPoint &aPos)
Definition: eda_item.h:253
int GetX() const
Definition: board_item.h:95

References BOARD_ITEM::GetX(), and EDA_ITEM::SetPosition().

Referenced by BOARD_ITEM_DESC::BOARD_ITEM_DESC(), and TRACK_VIA_DESC::TRACK_VIA_DESC().

◆ ShowShape()

wxString BOARD_ITEM::ShowShape ( SHAPE_T  aShape)
staticinherited

Convert the enum #PCB_SHAPE_TYPE_T integer value to a wxString.

Definition at line 35 of file board_item.cpp.

36 {
37  switch( aShape )
38  {
39  case SHAPE_T::SEGMENT: return _( "Line" );
40  case SHAPE_T::RECT: return _( "Rect" );
41  case SHAPE_T::ARC: return _( "Arc" );
42  case SHAPE_T::CIRCLE: return _( "Circle" );
43  case SHAPE_T::BEZIER: return _( "Bezier Curve" );
44  case SHAPE_T::POLY: return _( "Polygon" );
45  default: return wxT( "??" );
46  }
47 }
Arcs (with rounded ends)
Bezier Curve.
polygon (not yet used for tracks, but could be in microwave apps)
usual segment : line with rounded ends
#define _(s)
segment with non rounded ends

References _, ARC, BEZIER, CIRCLE, POLY, RECT, and SEGMENT.

Referenced by ConvertOutlineToPolygon(), GetLength(), FP_SHAPE::GetSelectMenuText(), GetSelectMenuText(), and DIALOG_GRAPHIC_ITEM_PROPERTIES::Validate().

◆ Sort()

static bool EDA_ITEM::Sort ( const EDA_ITEM aLeft,
const EDA_ITEM aRight 
)
inlinestaticinherited

Helper function to be used by the C++ STL sort algorithm for sorting a STL container of EDA_ITEM pointers.

Parameters
aLeftThe left hand item to compare.
aRightThe right hand item to compare.
Returns
True if aLeft is less than aRight.

Definition at line 421 of file eda_item.h.

421 { return *aLeft < *aRight; }

◆ SwapData()

void PCB_SHAPE::SwapData ( BOARD_ITEM aImage)
overridevirtual

Swap data between aItem and aImage.

aItem and aImage should have the same type.

Used in undo and redo commands to swap values between an item and its copy. Only values like layer, size .. which are modified by editing are swapped.

Parameters
aImagethe item image which contains data to swap.

Reimplemented from BOARD_ITEM.

Definition at line 1317 of file pcb_shape.cpp.

1318 {
1319  PCB_SHAPE* image = dynamic_cast<PCB_SHAPE*>( aImage );
1320  assert( image );
1321 
1322  std::swap( m_width, image->m_width );
1323  std::swap( m_start, image->m_start );
1324  std::swap( m_end, image->m_end );
1325  std::swap( m_thirdPoint, image->m_thirdPoint );
1326  std::swap( m_shape, image->m_shape );
1327  std::swap( m_angle, image->m_angle );
1328  std::swap( m_bezierC1, image->m_bezierC1 );
1329  std::swap( m_bezierC2, image->m_bezierC2 );
1330  std::swap( m_bezierPoints, image->m_bezierPoints );
1331  std::swap( m_poly, image->m_poly );
1332  std::swap( m_layer, image->m_layer );
1333  std::swap( m_flags, image->m_flags );
1334  std::swap( m_status, image->m_status );
1335  std::swap( m_parent, image->m_parent );
1336  std::swap( m_forceVisible, image->m_forceVisible );
1337 }
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:479
wxPoint m_end
Definition: pcb_shape.h:346
EDA_ITEM_FLAGS m_status
Definition: eda_item.h:478
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:481
wxPoint m_thirdPoint
Definition: pcb_shape.h:347
SHAPE_POLY_SET m_poly
Definition: pcb_shape.h:355
double m_angle
Definition: pcb_shape.h:350
wxPoint m_start
Definition: pcb_shape.h:345
int m_width
Definition: pcb_shape.h:343
PCB_LAYER_ID m_layer
Definition: board_item.h:353
wxPoint m_bezierC1
Definition: pcb_shape.h:351
std::vector< wxPoint > m_bezierPoints
Definition: pcb_shape.h:354
bool m_forceVisible
Definition: eda_item.h:480
wxPoint m_bezierC2
Definition: pcb_shape.h:352
SHAPE_T m_shape
Definition: pcb_shape.h:349

References image, m_angle, m_bezierC1, m_bezierC2, m_bezierPoints, m_end, EDA_ITEM::m_flags, EDA_ITEM::m_forceVisible, BOARD_ITEM::m_layer, EDA_ITEM::m_parent, m_poly, m_shape, m_start, EDA_ITEM::m_status, m_thirdPoint, and m_width.

◆ TransformShapeWithClearanceToPolygon()

void PCB_SHAPE::TransformShapeWithClearanceToPolygon ( SHAPE_POLY_SET aCornerBuffer,
PCB_LAYER_ID  aLayer,
int  aClearanceValue,
int  aError,
ERROR_LOC  aErrorLoc,
bool  ignoreLineWidth = false 
) const
overridevirtual

Convert the draw segment to a closed polygon.

Used in filling zones calculations. Circles and arcs are approximated by segments.

Parameters
aCornerBufferis a buffer to store the polygon.
aClearanceValueis the clearance around the pad.
aErroris the maximum deviation from a true arc.
ignoreLineWidthis used for edge cut items where the line width is only for visualization

Reimplemented from BOARD_ITEM.

Definition at line 418 of file board_items_to_polygon_shape_transform.cpp.

422 {
423  int width = ignoreLineWidth ? 0 : m_width;
424 
425  width += 2 * aClearanceValue;
426 
427  switch( m_shape )
428  {
429  case SHAPE_T::CIRCLE:
430  if( IsFilled() )
431  {
432  TransformCircleToPolygon( aCornerBuffer, GetCenter(), GetRadius() + width / 2, aError,
433  aErrorLoc );
434  }
435  else
436  {
437  TransformRingToPolygon( aCornerBuffer, GetCenter(), GetRadius(), width, aError,
438  aErrorLoc );
439  }
440 
441  break;
442 
443  case SHAPE_T::RECT:
444  {
445  std::vector<wxPoint> pts = GetRectCorners();
446 
447  if( IsFilled() )
448  {
449  aCornerBuffer.NewOutline();
450 
451  for( const wxPoint& pt : pts )
452  aCornerBuffer.Append( pt );
453  }
454 
455  if( width > 0 || !IsFilled() )
456  {
457  // Add in segments
458  TransformOvalToPolygon( aCornerBuffer, pts[0], pts[1], width, aError, aErrorLoc );
459  TransformOvalToPolygon( aCornerBuffer, pts[1], pts[2], width, aError, aErrorLoc );
460  TransformOvalToPolygon( aCornerBuffer, pts[2], pts[3], width, aError, aErrorLoc );
461  TransformOvalToPolygon( aCornerBuffer, pts[3], pts[0], width, aError, aErrorLoc );
462  }
463 
464  break;
465  }
466 
467  case SHAPE_T::ARC:
468  TransformArcToPolygon( aCornerBuffer, GetArcStart(), GetArcMid(), GetArcEnd(), width,
469  aError, aErrorLoc );
470  break;
471 
472  case SHAPE_T::SEGMENT:
473  TransformOvalToPolygon( aCornerBuffer, m_start, m_end, width, aError, aErrorLoc );
474  break;
475 
476  case SHAPE_T::POLY:
477  {
478  if( !IsPolyShapeValid() )
479  break;
480 
481  // The polygon is expected to be a simple polygon; not self intersecting, no hole.
482  FOOTPRINT* footprint = GetParentFootprint();
483  double orientation = footprint ? footprint->GetOrientation() : 0.0;
484  wxPoint offset;
485 
486  if( footprint )
487  offset = footprint->GetPosition();
488 
489  // Build the polygon with the actual position and orientation:
490  std::vector<wxPoint> poly;
491  DupPolyPointsList( poly );
492 
493  for( wxPoint& point : poly )
494  {
495  RotatePoint( &point, orientation );
496  point += offset;
497  }
498 
499  if( IsFilled() )
500  {
501  aCornerBuffer.NewOutline();
502 
503  for( const wxPoint& point : poly )
504  aCornerBuffer.Append( point.x, point.y );
505  }
506 
507  if( width > 0 || !IsFilled() )
508  {
509  wxPoint pt1( poly[ poly.size() - 1] );
510 
511  for( const wxPoint& pt2 : poly )
512  {
513  if( pt2 != pt1 )
514  TransformOvalToPolygon( aCornerBuffer, pt1, pt2, width, aError, aErrorLoc );
515 
516  pt1 = pt2;
517  }
518  }
519 
520  break;
521  }
522 
523  case SHAPE_T::BEZIER: // Bezier curve
524  {
525  std::vector<wxPoint> ctrlPoints = { m_start, m_bezierC1, m_bezierC2, m_end };
526  BEZIER_POLY converter( ctrlPoints );
527  std::vector< wxPoint> poly;
528  converter.GetPoly( poly, m_width );
529 
530  for( unsigned ii = 1; ii < poly.size(); ii++ )
531  {
532  TransformOvalToPolygon( aCornerBuffer, poly[ii - 1], poly[ii], width, aError,
533  aErrorLoc );
534  }
535 
536  break;
537  }
538 
539  default:
540  wxFAIL_MSG( "PCB_SHAPE::TransformShapeWithClearanceToPolygon no implementation for "
541  + SHAPE_T_asString( m_shape ) );
542  break;
543  }
544 }
wxPoint GetArcEnd() const
Definition: pcb_shape.cpp:417
bool IsPolyShapeValid() const
Definition: pcb_shape.cpp:1294
Arcs (with rounded ends)
bool IsFilled() const
Definition: pcb_shape.h:75
Bezier Curve.
wxPoint m_end
Definition: pcb_shape.h:346
polygon (not yet used for tracks, but could be in microwave apps)
int GetRadius() const
Return the radius of this item.
Definition: pcb_shape.cpp:487
std::vector< wxPoint > GetRectCorners() const
Definition: pcb_shape.cpp:1048
usual segment : line with rounded ends
double GetOrientation() const
Definition: footprint.h:190
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
void DupPolyPointsList(std::vector< wxPoint > &aBuffer) const
Duplicate the list of corners in a std::vector<wxPoint>
Definition: pcb_shape.cpp:1277
wxPoint GetArcStart() const
Definition: pcb_shape.h:156
wxPoint GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_shape.cpp:385
void TransformCircleToPolygon(SHAPE_LINE_CHAIN &aCornerBuffer, const wxPoint &aCenter, int aRadius, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a circle to a polygon, using multiple straight lines.
static wxString SHAPE_T_asString(SHAPE_T a)
Definition: board_item.h:57
int NewOutline()
Creates a new hole in a given outline.