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=NULL, KICAD_T idtype=PCB_SHAPE_T)
 
 ~PCB_SHAPE ()
 
bool IsType (const KICAD_T aScanTypes[]) const override
 Function IsType Checks 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)
 Function SetAngle sets the angle for arcs, and normalizes it within the range 0 - 360 degrees. More...
 
double GetAngle () const
 
void SetShape (PCB_SHAPE_TYPE_T aShape)
 
PCB_SHAPE_TYPE_T GetShape () const
 
void SetBezControl1 (const wxPoint &aPoint)
 
const wxPoint & GetBezControl1 () const
 
void SetBezControl2 (const wxPoint &aPoint)
 
const wxPoint & GetBezControl2 () const
 
void SetPosition (const wxPoint &aPos) override
 
wxPoint GetPosition () const override
 
const wxPoint & GetStart () const
 Function GetStart returns 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
 Function GetEnd returns 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
 Function GetThirdPoint returns the third point 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
 Function GetCenter() More...
 
wxPoint GetArcStart () const
 
wxPoint GetArcEnd () const
 
wxPoint GetArcMid () const
 
std::vector< wxPoint > GetRectCorners () const
 
double GetArcAngleStart () const
 function GetArcAngleStart() More...
 
double GetArcAngleEnd () const
 function GetArcAngleEnd() More...
 
int GetRadius () const
 Function GetRadius returns the radius of this item Has meaning only for arc and circle. 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)
 For arcs and circles: More...
 
const wxPoint GetFocusPosition () const override
 Function GetFocusPosition similar to GetPosition, but allows items to return their visual center rather than their anchor. More...
 
FOOTPRINTGetParentFootprint () const
 Function GetParentFootprint returns a pointer to the parent footprint, or NULL if PCB_SHAPE does not belong to a footprint. More...
 
const std::vector< wxPoint > & GetBezierPoints () const
 
const std::vector< wxPoint > BuildPolyPointsList () const
 Build and return 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. 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 Has meaning only for S_CURVE DRAW_SEGMENT shape. More...
 
void SetPolyPoints (const std::vector< wxPoint > &aPoints)
 
std::vector< SHAPE * > MakeEffectiveShapes () const
 Makes a set of SHAPE objects representing the PCB_SHAPE. More...
 
std::shared_ptr< SHAPEGetEffectiveShape (PCB_LAYER_ID aLayer=UNDEFINED_LAYER) const override
 Function GetEffectiveShape 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
 Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for display purposes. More...
 
const EDA_RECT GetBoundingBox () const override
 Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes. More...
 
bool HitTest (const wxPoint &aPosition, int aAccuracy=0) const override
 Function HitTest tests 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
 Function HitTest tests if aRect intersects or is contained within the bounding box of an item. More...
 
wxString GetClass () const override
 Function GetClass returns the class name. More...
 
double GetLength () const
 Function GetLength returns the length of the track using the hypotenuse calculation. More...
 
virtual void Move (const wxPoint &aMoveVector) override
 Function Move move this object. More...
 
virtual void Rotate (const wxPoint &aRotCentre, double aAngle) override
 Function Rotate Rotate this object. More...
 
virtual void Flip (const wxPoint &aCentre, bool aFlipLeftRight) override
 Function Flip 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
 Function TransformShapeWithClearanceToPolygon Convert the draw segment to a closed polygon Used in filling zones calculations Circles and arcs are approximated by segments. More...
 
virtual wxString GetSelectMenuText (EDA_UNITS aUnits) const override
 Function GetSelectMenuText returns 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 BITMAP_DEF GetMenuImage () const override
 Function GetMenuImage returns a pointer to an image to be used in menus. More...
 
virtual EDA_ITEMClone () const override
 Function Clone creates a duplicate of this item with linked list members set to NULL. More...
 
virtual const BOX2I ViewBBox () const override
 Function ViewBBox() returns 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
 Function IsConnected() 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
 Function GetLayer returns the primary layer this item is on. More...
 
virtual LSET GetLayerSet () const
 Function GetLayerSet returns 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)
 Function SetLayer sets the layer this item is on. More...
 
virtual BOARD_ITEMDuplicate () const
 Function Duplicate creates a copy of a BOARD_ITEM. More...
 
virtual bool IsOnLayer (PCB_LAYER_ID aLayer) const
 Function IsOnLayer tests to see if this object is on the given layer. More...
 
bool IsTrack () const
 Function IsTrack tests to see if this object is a track or via (or microvia). More...
 
virtual bool IsLocked () const
 Function IsLocked. More...
 
virtual void SetLocked (bool aLocked)
 Function SetLocked modifies 'lock' status for of the item. More...
 
void DeleteStructure ()
 Function DeleteStructure deletes 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 BOARDGetBoard () const
 Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none. More...
 
wxString GetLayerName () const
 Function GetLayerName returns the name of the PCB layer on which the item resides. More...
 
virtual void ViewGetLayers (int aLayers[], int &aCount) const override
 Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on. More...
 
KICAD_T Type () const
 Function Type() 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 IsResized () const
 
bool IsBrightened () const
 
void SetWireImage ()
 
void SetSelected ()
 
void SetBrightened ()
 
void ClearSelected ()
 
void ClearBrightened ()
 
void SetModified ()
 
int GetState (int type) const
 
void SetState (int type, int state)
 
STATUS_FLAGS GetStatus () const
 
void SetStatus (STATUS_FLAGS aStatus)
 
void SetFlags (STATUS_FLAGS aMask)
 
void ClearFlags (STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
 
STATUS_FLAGS GetFlags () const
 
bool HasFlag (STATUS_FLAGS aFlag)
 
STATUS_FLAGS GetEditFlags () const
 
void ClearTempFlags ()
 
void ClearEditFlags ()
 
void SetForceVisible (bool aEnable)
 Function SetForceVisible is used to set and cleag 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[])
 Function Visit may be re-implemented for each derived class in order to handle all the types given by its member data. More...
 
virtual bool Matches (wxFindReplaceData &aSearchData, void *aAuxData)
 Function Matches compares the item against the search criteria in aSearchData. More...
 
virtual bool Replace (wxFindReplaceData &aSearchData, void *aAuxData=NULL)
 Function Replace performs a text replace using the find and replace criteria in aSearchData on items that support text find and replace. More...
 
virtual bool IsReplaceable () const
 Function IsReplaceable. 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
 Function ViewDraw() Draws the parts of the object belonging to layer aLayer. More...
 
virtual double ViewGetLOD (int aLayer, VIEW *aView) const
 Function ViewGetLOD() Returns 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 (PCB_SHAPE_TYPE_T aShape)
 Function ShowShape converts 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[])
 IterateForward( EDA_ITEM*, INSPECTOR, void*, const KICAD_T ) More...
 
template<class T >
static SEARCH_RESULT IterateForward (std::vector< T > &aList, INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
 IterateForward( EDA_ITEM*, INSPECTOR, void*, const KICAD_T ) More...
 
static bool Replace (wxFindReplaceData &aSearchData, wxString &aText)
 Helper function used in search and replace dialog Function Replace performs 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)
 Function Sort is a 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, wxFindReplaceData &aSearchData)
 Function Matches compares aText against search criteria in aSearchData. More...
 

Protected Attributes

int m_width
 
bool m_filled
 
wxPoint m_start
 
wxPoint m_end
 
wxPoint m_thirdPoint
 
PCB_SHAPE_TYPE_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
 
STATUS_FLAGS m_status
 
EDA_ITEMm_parent
 Linked list: Link (parent struct) More...
 
bool m_forceVisible
 
STATUS_FLAGS m_flags
 

Detailed Description

Definition at line 43 of file pcb_shape.h.

Constructor & Destructor Documentation

◆ PCB_SHAPE()

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

Definition at line 45 of file pcb_shape.cpp.

45  :
46  BOARD_ITEM( aParent, idtype )
47 {
48  m_angle = 0;
49  m_filled = false;
50  m_flags = 0;
53 }
PCB_SHAPE_TYPE_T m_shape
Definition: pcb_shape.h:52
#define DEFAULT_LINE_WIDTH
usual segment : line with rounded ends
Definition: board_item.h:52
double m_angle
Definition: pcb_shape.h:53
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype)
Definition: board_item.h:93
int m_width
Definition: pcb_shape.h:46
bool m_filled
Definition: pcb_shape.h:47
STATUS_FLAGS m_flags
Definition: eda_item.h:164
static constexpr int Millimeter2iu(double mm)

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

Referenced by Clone().

◆ ~PCB_SHAPE()

PCB_SHAPE::~PCB_SHAPE ( )

Definition at line 56 of file pcb_shape.cpp.

57 {
58 }

Member Function Documentation

◆ buildBezierToSegmentsPointsList()

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

Definition at line 330 of file pcb_shape.cpp.

331 {
332  std::vector<wxPoint> bezierPoints;
333 
334  // Rebuild the m_BezierPoints vertex list that approximate the Bezier curve
335  std::vector<wxPoint> ctrlPoints = { m_start, m_bezierC1, m_bezierC2, m_end };
336  BEZIER_POLY converter( ctrlPoints );
337  converter.GetPoly( bezierPoints, aMinSegLen );
338 
339  return bezierPoints;
340 }
wxPoint m_end
Definition: pcb_shape.h:49
wxPoint m_start
Definition: pcb_shape.h:48
Bezier curves to polygon converter.
Definition: bezier_curves.h:35
wxPoint m_bezierC1
Definition: pcb_shape.h:54
wxPoint m_bezierC2
Definition: pcb_shape.h:55

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

Referenced by MakeEffectiveShapes(), and RebuildBezierToSegmentsPointsList().

◆ BuildPolyPointsList()

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

Build and return 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 1174 of file pcb_shape.cpp.

1175 {
1176  std::vector<wxPoint> rv;
1177 
1178  if( m_poly.OutlineCount() )
1179  {
1180  if( m_poly.COutline( 0 ).PointCount() )
1181  {
1182  for ( auto iter = m_poly.CIterate(); iter; iter++ )
1183  rv.emplace_back( iter->x, iter->y );
1184  }
1185  }
1186 
1187  return rv;
1188 }
int OutlineCount() const
Returns the number of outlines in the set
int PointCount() const
Function PointCount()
SHAPE_POLY_SET m_poly
Definition: pcb_shape.h:58
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 GRID_HELPER::computeAnchors(), PCB_PARSER::parsePAD(), BRDITEMS_PLOTTER::PlotFootprintGraphicItem(), TransformShapeWithClearanceToPolygon(), and POINT_EDITOR::updatePoints().

◆ ClassOf()

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

Definition at line 73 of file pcb_shape.h.

74  {
75  return aItem && PCB_SHAPE_T == aItem->Type();
76  }
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:91
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181

References PCB_SHAPE_T, and EDA_ITEM::Type().

◆ ClearBrightened()

void EDA_ITEM::ClearBrightened ( )
inlineinherited

◆ ClearEditFlags()

◆ ClearFlags()

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

Definition at line 221 of file eda_item.h.

221 { m_flags &= ~aMask; }
STATUS_FLAGS m_flags
Definition: eda_item.h:164

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(), LIB_EDIT_TOOL::Copy(), FOOTPRINT_EDITOR_TOOLS::CreateFootprint(), LIB_PIN_TOOL::CreateImagePins(), MICROWAVE_TOOL::createMicrowaveInductor(), DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES(), KIGFX::SCH_PAINTER::draw(), LIB_EDIT_TOOL::Duplicate(), SCH_ITEM::Duplicate(), PCB_EDIT_FRAME::ExchangeFootprint(), SYMBOL_EDIT_FRAME::GetSymbolFromRedoList(), SYMBOL_EDIT_FRAME::GetSymbolFromUndoList(), FOOTPRINT_EDITOR_TOOLS::ImportFootprint(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromLibrary(), EE_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::narrowSelection(), FOOTPRINT_EDITOR_TOOLS::NewFootprint(), FOOTPRINT_EDIT_FRAME::OpenProjectFiles(), PCB_BASE_FRAME::PlaceFootprint(), LIB_PIN_TOOL::PlacePin(), DRAWING_TOOL::PlaceText(), BOARD_COMMIT::Push(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_PIN_TOOL::RepeatPin(), SYMBOL_EDIT_FRAME::RollbackSymbolFromUndo(), SCH_EDIT_FRAME::SaveCopyForRepeatItem(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), SCH_SEXPR_PLUGIN_CACHE::savePin(), SCH_LEGACY_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 233 of file eda_item.h.

234  {
236  DO_NOT_DRAW );
237  }
#define TEMP_SELECTED
flag indicating that the structure has already selected
Definition: eda_item.h:114
#define IS_LINKED
Used in calculation to mark linked items (temporary use)
Definition: eda_item.h:103
#define CANDIDATE
flag indicating that the structure is connected
Definition: eda_item.h:116
#define DO_NOT_DRAW
Used to disable draw function.
Definition: eda_item.h:118
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: eda_item.h:111
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:221
#define ENDPOINT
ends. (Used to support dragging.)
Definition: eda_item.h:112
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Definition: eda_item.h:117

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

155  {
157  }
VIEW_ITEM_DATA * m_viewPrivData
Definition: view_item.h:162
#define NULL

References KIGFX::VIEW_ITEM::m_viewPrivData, and NULL.

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

◆ Clone()

EDA_ITEM * PCB_SHAPE::Clone ( ) const
overridevirtual

Function Clone creates 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 920 of file pcb_shape.cpp.

921 {
922  return new PCB_SHAPE( *this );
923 }
PCB_SHAPE(BOARD_ITEM *aParent=NULL, KICAD_T idtype=PCB_SHAPE_T)
Definition: pcb_shape.cpp:45

References PCB_SHAPE().

Referenced by DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run().

◆ computeArcBBox()

void PCB_SHAPE::computeArcBBox ( EDA_RECT aBBox) const
protected

Definition at line 979 of file pcb_shape.cpp.

980 {
981  // Do not include the center, which is not necessarily
982  // inside the BB of a arc with a small angle
983  aBBox.SetOrigin( m_end );
984 
985  wxPoint end = m_end;
986  RotatePoint( &end, m_start, -m_angle );
987  aBBox.Merge( end );
988 
989  // Determine the starting quarter
990  // 0 right-bottom
991  // 1 left-bottom
992  // 2 left-top
993  // 3 right-top
994  unsigned int quarter = 0; // assume right-bottom
995 
996  if( m_end.x < m_start.x )
997  {
998  if( m_end.y <= m_start.y )
999  quarter = 2;
1000  else // ( m_End.y > m_Start.y )
1001  quarter = 1;
1002  }
1003  else if( m_end.x >= m_start.x )
1004  {
1005  if( m_end.y < m_start.y )
1006  quarter = 3;
1007  else if( m_end.x == m_start.x )
1008  quarter = 1;
1009  }
1010 
1011  int radius = GetRadius();
1012  int angle = (int) GetArcAngleStart() % 900 + m_angle;
1013  bool directionCW = ( m_angle > 0 ); // Is the direction of arc clockwise?
1014 
1015  // Make the angle positive, so we go clockwise and merge points belonging to the arc
1016  if( !directionCW )
1017  {
1018  angle = 900 - angle;
1019  quarter = ( quarter + 3 ) % 4; // -1 modulo arithmetic
1020  }
1021 
1022  while( angle > 900 )
1023  {
1024  switch( quarter )
1025  {
1026  case 0: aBBox.Merge( wxPoint( m_start.x, m_start.y + radius ) ); break; // down
1027  case 1: aBBox.Merge( wxPoint( m_start.x - radius, m_start.y ) ); break; // left
1028  case 2: aBBox.Merge( wxPoint( m_start.x, m_start.y - radius ) ); break; // up
1029  case 3: aBBox.Merge( wxPoint( m_start.x + radius, m_start.y ) ); break; // right
1030  }
1031 
1032  if( directionCW )
1033  ++quarter;
1034  else
1035  quarter += 3; // -1 modulo arithmetic
1036 
1037  quarter %= 4;
1038  angle -= 900;
1039  }
1040 }
wxPoint m_end
Definition: pcb_shape.h:49
void Merge(const EDA_RECT &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect.
Definition: eda_rect.cpp:431
int GetRadius() const
Function GetRadius returns the radius of this item Has meaning only for arc and circle.
Definition: pcb_shape.h:200
double GetArcAngleStart() const
function GetArcAngleStart()
Definition: pcb_shape.cpp:415
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:131
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
double m_angle
Definition: pcb_shape.h:53
wxPoint m_start
Definition: pcb_shape.h:48
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)

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

Referenced by GetBoundingBox(), and ViewBBox().

◆ DeleteStructure()

void BOARD_ITEM::DeleteStructure ( )
inherited

Function DeleteStructure deletes this object after removing from its parent if it has one.

Definition at line 113 of file board_item.cpp.

114 {
115  BOARD_ITEM_CONTAINER* parent = GetParent();
116 
117  if( parent )
118  parent->Remove( this );
119 
120  delete this;
121 }
virtual void Remove(BOARD_ITEM *aItem)=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:179

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

Function Duplicate creates a copy of a BOARD_ITEM.

Reimplemented in FOOTPRINT.

Definition at line 215 of file board_item.h.

216  {
217  EDA_ITEM* dupe = Clone();
218  const_cast<KIID&>( dupe->m_Uuid ) = KIID();
219 
220  return static_cast<BOARD_ITEM*>( dupe );
221  }
virtual EDA_ITEM * Clone() const
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:97
Definition: kiid.h:44
const KIID m_Uuid
Definition: eda_item.h:151
EDA_ITEM is a base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148

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

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::addAttribute(), PCB_GROUP::DeepDuplicate(), CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText(), EDIT_TOOL::Duplicate(), and ARRAY_CREATOR::Invoke().

◆ Flip() [1/2]

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

Function Flip Flip this object, i.e.

change the board side for this object

Parameters
aCentre- the rotation point.
aFlipLeftRight- mirror across Y axis instead of X (the default)

Reimplemented from BOARD_ITEM.

Reimplemented in FP_SHAPE.

Definition at line 252 of file pcb_shape.cpp.

253 {
254  if( aFlipLeftRight )
255  {
256  m_start.x = aCentre.x - ( m_start.x - aCentre.x );
257  m_end.x = aCentre.x - ( m_end.x - aCentre.x );
258  }
259  else
260  {
261  m_start.y = aCentre.y - ( m_start.y - aCentre.y );
262  m_end.y = aCentre.y - ( m_end.y - aCentre.y );
263  }
264 
265  switch ( m_shape )
266  {
267  case S_ARC:
268  if( aFlipLeftRight )
269  m_thirdPoint.x = aCentre.x - ( m_thirdPoint.x - aCentre.x );
270  else
271  m_thirdPoint.y = aCentre.y - ( m_thirdPoint.y - aCentre.y );
272 
273  m_angle = -m_angle;
274  break;
275 
276  case S_POLYGON:
277  m_poly.Mirror( aFlipLeftRight, !aFlipLeftRight, VECTOR2I( aCentre ) );
278  break;
279 
280  case S_CURVE:
281  {
282  if( aFlipLeftRight )
283  {
284  m_bezierC1.x = aCentre.x - ( m_bezierC1.x - aCentre.x );
285  m_bezierC2.x = aCentre.x - ( m_bezierC2.x - aCentre.x );
286  }
287  else
288  {
289  m_bezierC1.y = aCentre.y - ( m_bezierC1.y - aCentre.y );
290  m_bezierC2.y = aCentre.y - ( m_bezierC2.y - aCentre.y );
291  }
292 
293  // Rebuild the poly points shape
294  std::vector<wxPoint> ctrlPoints = { m_start, m_bezierC1, m_bezierC2, m_end };
295  BEZIER_POLY converter( ctrlPoints );
296  converter.GetPoly( m_bezierPoints, m_width );
297  }
298  break;
299 
300  case S_SEGMENT:
301  case S_RECT:
302  case S_CIRCLE:
303  break;
304 
305  default:
306  wxFAIL_MSG( "PCB_SHAPE::Flip not implemented for "
308  break;
309  }
310 
311  // PCB_SHAPE items are not allowed on copper layers, so
312  // copper layers count is not taken in account in Flip transform
313  SetLayer( FlipLayer( GetLayer() ) );
314 }
wxPoint m_end
Definition: pcb_shape.h:49
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
Definition: board_item.h:206
PCB_SHAPE_TYPE_T m_shape
Definition: pcb_shape.h:52
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Definition: lset.cpp:521
polygon (not yet used for tracks, but could be in microwave apps)
Definition: board_item.h:56
usual segment : line with rounded ends
Definition: board_item.h:52
Arcs (with rounded ends)
Definition: board_item.h:54
segment with non rounded ends
Definition: board_item.h:53
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
void Mirror(bool aX=true, bool aY=false, const VECTOR2I &aRef={ 0, 0 })
Mirrors the line points about y or x (or both)
wxPoint m_thirdPoint
Definition: pcb_shape.h:50
SHAPE_POLY_SET m_poly
Definition: pcb_shape.h:58
static wxString PCB_SHAPE_TYPE_T_asString(PCB_SHAPE_TYPE_T a)
Definition: board_item.h:61
double m_angle
Definition: pcb_shape.h:53
wxPoint m_start
Definition: pcb_shape.h:48
Bezier curves to polygon converter.
Definition: bezier_curves.h:35
int m_width
Definition: pcb_shape.h:46
ring
Definition: board_item.h:55
wxPoint m_bezierC1
Definition: pcb_shape.h:54
std::vector< wxPoint > m_bezierPoints
Definition: pcb_shape.h:57
wxPoint m_bezierC2
Definition: pcb_shape.h:55
Bezier Curve.
Definition: board_item.h:57
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
Definition: board_item.h:185

References FlipLayer(), 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(), PCB_SHAPE_TYPE_T_asString(), S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, S_SEGMENT, and BOARD_ITEM::SetLayer().

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::getDrawSegmentFromVertex().

◆ Flip() [2/2]

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

Definition at line 330 of file board_item.h.

331  {
332  Flip( wxPoint( aCentre.x, aCentre.y ), aFlipLeftRight );
333  }
virtual void Flip(const wxPoint &aCentre, bool aFlipLeftRight)
Function Flip Flip this object, i.e.
Definition: board_item.h:325

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

◆ Get() [1/3]

wxAny INSPECTABLE::Get ( PROPERTY_BASE aProperty)
inlineinherited

Definition at line 84 of file inspectable.h.

85  {
87  TYPE_ID thisType = TYPE_HASH( *this );
88  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
89  return object ? aProperty->getter( object ) : wxAny();
90  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:64
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:55
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:41
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
virtual wxAny getter(void *aObject) const =0
Provides class metadata.
Definition: property_mgr.h:61
virtual size_t OwnerHash() const =0
Returns type-id of the Owner class.

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

Referenced by 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 93 of file inspectable.h.

94  {
96  TYPE_ID thisType = TYPE_HASH( *this );
97  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
98  return object ? aProperty->get<T>( object ) : T();
99  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:64
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:55
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:41
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
Provides class metadata.
Definition: property_mgr.h:61
T get(void *aObject)
Definition: property.h:275
virtual size_t OwnerHash() const =0
Returns 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 102 of file inspectable.h.

103  {
105  TYPE_ID thisType = TYPE_HASH( *this );
106  PROPERTY_BASE* prop = propMgr.GetProperty( thisType, aProperty );
107  boost::optional<T> ret;
108 
109  if( prop )
110  {
111  void* object = propMgr.TypeCast( this, thisType, prop->OwnerHash() );
112 
113  if( object )
114  ret = prop->get<T>( object );
115  }
116 
117  return ret;
118  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:64
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:55
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:41
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Returns a property for a specific type.
Provides class metadata.
Definition: property_mgr.h:61
T get(void *aObject)
Definition: property.h:275
virtual size_t OwnerHash() const =0
Returns 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

function GetArcAngleEnd()

Returns
the angle of the ending point of this arc, between 0 and 3600 in 0.1 deg

Definition at line 429 of file pcb_shape.cpp.

430 {
431  // due to the Y axis orient atan2 needs - y value
432  double angleStart = ArcTangente( GetArcEnd().y - GetCenter().y,
433  GetArcEnd().x - GetCenter().x );
434 
435  // Normalize it to 0 ... 360 deg, to avoid discontinuity for angles near 180 deg
436  // because 180 deg and -180 are very near angles when ampping betewwen -180 ... 180 deg.
437  // and this is not easy to handle in calculations
438  NORMALIZE_ANGLE_POS( angleStart );
439 
440  return angleStart;
441 }
wxPoint GetArcEnd() const
Definition: pcb_shape.cpp:375
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:274
wxPoint GetCenter() const override
Function GetCenter()
Definition: pcb_shape.cpp:343
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:162

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

◆ GetArcAngleStart()

double PCB_SHAPE::GetArcAngleStart ( ) const

function GetArcAngleStart()

Returns
the angle of the starting point of this arc, between 0 and 3600 in 0.1 deg

Definition at line 415 of file pcb_shape.cpp.

416 {
417  // due to the Y axis orient atan2 needs - y value
418  double angleStart = ArcTangente( GetArcStart().y - GetCenter().y,
419  GetArcStart().x - GetCenter().x );
420 
421  // Normalize it to 0 ... 360 deg, to avoid discontinuity for angles near 180 deg
422  // because 180 deg and -180 are very near angles when ampping betewwen -180 ... 180 deg.
423  // and this is not easy to handle in calculations
424  NORMALIZE_ANGLE_POS( angleStart );
425 
426  return angleStart;
427 }
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:274
wxPoint GetArcStart() const
Definition: pcb_shape.h:178
wxPoint GetCenter() const override
Function GetCenter()
Definition: pcb_shape.cpp:343
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:162

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

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

◆ GetArcEnd()

wxPoint PCB_SHAPE::GetArcEnd ( ) const

Definition at line 375 of file pcb_shape.cpp.

376 {
377  wxPoint endPoint( m_end ); // start of arc
378 
379  switch( m_shape )
380  {
381  case S_ARC:
382  endPoint = m_thirdPoint;
383  break;
384 
385  default:
386  break;
387  }
388 
389  return endPoint; // after rotation, the end of the arc.
390 }
wxPoint m_end
Definition: pcb_shape.h:49
PCB_SHAPE_TYPE_T m_shape
Definition: pcb_shape.h:52
Arcs (with rounded ends)
Definition: board_item.h:54
wxPoint m_thirdPoint
Definition: pcb_shape.h:50

References m_end, m_shape, m_thirdPoint, and S_ARC.

Referenced by GRID_HELPER::computeAnchors(), ConvertOutlineToPolygon(), findNext(), GetArcAngleEnd(), EDIT_POINTS_FACTORY::Make(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow(), TransformShapeWithClearanceToPolygon(), and POINT_EDITOR::updatePoints().

◆ GetArcMid()

wxPoint PCB_SHAPE::GetArcMid ( ) const

Definition at line 393 of file pcb_shape.cpp.

394 {
395  wxPoint endPoint( m_end );
396 
397  switch( m_shape )
398  {
399  case S_ARC:
400  // rotate the starting point of the arc, given by m_End, through half
401  // the angle m_Angle to get the middle of the arc.
402  // m_Start is the arc centre
403  endPoint = m_end; // m_End = start point of arc
404  RotatePoint( &endPoint, m_start, -m_angle / 2.0 );
405  break;
406 
407  default:
408  break;
409  }
410 
411  return endPoint; // after rotation, the end of the arc.
412 }
wxPoint m_end
Definition: pcb_shape.h:49
PCB_SHAPE_TYPE_T m_shape
Definition: pcb_shape.h:52
Arcs (with rounded ends)
Definition: board_item.h:54
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
double m_angle
Definition: pcb_shape.h:53
wxPoint m_start
Definition: pcb_shape.h:48

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

Referenced by GRID_HELPER::computeAnchors(), EDIT_POINTS_FACTORY::Make(), TransformShapeWithClearanceToPolygon(), and POINT_EDITOR::updatePoints().

◆ GetArcStart()

◆ GetBezControl1()

◆ GetBezControl2()

◆ GetBezierPoints()

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

Definition at line 244 of file pcb_shape.h.

244 { return m_bezierPoints; }
std::vector< wxPoint > m_bezierPoints
Definition: pcb_shape.h:57

References m_bezierPoints.

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

◆ GetBoard()

BOARD * BOARD_ITEM::GetBoard ( ) const
virtualinherited

Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.

Definition at line 46 of file board_item.cpp.

47 {
48  if( Type() == PCB_T )
49  return (BOARD*) this;
50 
51  BOARD_ITEM* parent = GetParent();
52 
53  if( parent )
54  return parent->GetBoard();
55 
56  return NULL;
57 }
Definition: typeinfo.h:85
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
Definition: board_item.h:86
#define NULL
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:46
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:186
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:179
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181

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

Referenced by PAD::BuildEffectiveShapes(), ZONE::BuildSmoothedPoly(), KIGFX::PCB_PAINTER::draw(), exprFromTo(), VIA::FlashLayer(), PAD::FlashLayer(), PCB_TEXT::Flip(), TRACK::Flip(), ARC::Flip(), VIA::Flip(), ZONE::Flip(), BOARD_ITEM::GetBoard(), FOOTPRINT::GetBoundingBox(), BOARD_CONNECTED_ITEM::GetEffectiveNetclass(), ZONE::GetInteractingZones(), BOARD_ITEM::GetLayerName(), VIA::GetMinAnnulus(), PCB_DRAW_PANEL_GAL::GetMsgPanelInfo(), ZONE::GetMsgPanelInfo(), TRACK::GetMsgPanelInfo(), NETINFO_ITEM::GetMsgPanelInfo(), TRACK::GetMsgPanelInfoBase_Common(), BOARD_CONNECTED_ITEM::GetNetClass(), BOARD_CONNECTED_ITEM::GetNetnameMsg(), BOARD_CONNECTED_ITEM::GetOwnClearance(), ZONE::GetSelectMenuText(), getShape(), FP_TEXT::GetShownText(), PAD::GetSolderMaskMargin(), PAD::GetSolderPasteMargin(), BOARD::GetTrackLength(), TRACK::GetWidthConstraints(), insideArea(), insideCourtyard(), isDiffPair(), BOARD_ITEM::layerMaskDescribe(), VIA::layerMaskDescribe(), PAD::MergePrimitivesAsPolygon(), EAGLE_PLUGIN::packageWire(), PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), BOARD::ResolveDRCExclusions(), BOARD_CONNECTED_ITEM::SetNetCode(), ZONE::TransformSmoothedOutlineToPolygon(), ZONE::TransformSolidAreasShapesToPolygon(), FOOTPRINT::ViewBBox(), and PAD::ViewGetLOD().

◆ GetBoundingBox()

const EDA_RECT PCB_SHAPE::GetBoundingBox ( ) const
overridevirtual

Function GetBoundingBox returns 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 544 of file pcb_shape.cpp.

545 {
546  EDA_RECT bbox;
547 
548  bbox.SetOrigin( m_start );
549 
550  switch( m_shape )
551  {
552  case S_RECT:
553  {
554  std::vector<wxPoint> pts = GetRectCorners();
555 
556  bbox = EDA_RECT(); // re-init for merging
557 
558  for( wxPoint& pt : pts )
559  bbox.Merge( pt );
560  }
561  break;
562 
563  case S_SEGMENT:
564  bbox.SetEnd( m_end );
565  break;
566 
567  case S_CIRCLE:
568  bbox.Inflate( GetRadius() );
569  break;
570 
571  case S_ARC:
572  computeArcBBox( bbox );
573  break;
574 
575  case S_POLYGON:
576  {
577  if( m_poly.IsEmpty() )
578  break;
579 
580  FOOTPRINT* parentFootprint = GetParentFootprint();
581  bbox = EDA_RECT(); // re-init for merging
582 
583  for( auto iter = m_poly.CIterate(); iter; iter++ )
584  {
585  wxPoint pt( iter->x, iter->y );
586 
587  if( parentFootprint ) // Transform, if we belong to a footprint
588  {
589  RotatePoint( &pt, parentFootprint->GetOrientation() );
590  pt += parentFootprint->GetPosition();
591  }
592 
593  bbox.Merge( pt );
594  }
595  }
596  break;
597 
598  case S_CURVE:
599  bbox.Merge( m_bezierC1 );
600  bbox.Merge( m_bezierC2 );
601  bbox.Merge( m_end );
602  break;
603 
604  default:
605  wxFAIL_MSG( "PCB_SHAPE::GetBoundingBox not implemented for "
607  break;
608  }
609 
610  bbox.Inflate( m_width / 2 );
611  bbox.Normalize();
612 
613  return bbox;
614 }
wxPoint m_end
Definition: pcb_shape.h:49
void Merge(const EDA_RECT &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect.
Definition: eda_rect.cpp:431
PCB_SHAPE_TYPE_T m_shape
Definition: pcb_shape.h:52
int GetRadius() const
Function GetRadius returns the radius of this item Has meaning only for arc and circle.
Definition: pcb_shape.h:200
bool IsEmpty() const
Returns true if the set is empty (no polygons at all)
std::vector< wxPoint > GetRectCorners() const
Definition: pcb_shape.cpp:942
void computeArcBBox(EDA_RECT &aBBox) const
Definition: pcb_shape.cpp:979
polygon (not yet used for tracks, but could be in microwave apps)
Definition: board_item.h:56
double GetOrientation() const
Definition: footprint.h:204
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:131
usual segment : line with rounded ends
Definition: board_item.h:52
Arcs (with rounded ends)
Definition: board_item.h:54
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
segment with non rounded ends
Definition: board_item.h:53
SHAPE_POLY_SET m_poly
Definition: pcb_shape.h:58
void SetEnd(int x, int y)
Definition: eda_rect.h:192
static wxString PCB_SHAPE_TYPE_T_asString(PCB_SHAPE_TYPE_T a)
Definition: board_item.h:61
CONST_ITERATOR CIterate(int aFirst, int aLast, bool aIterateHoles=false) const
wxPoint m_start
Definition: pcb_shape.h:48
void Normalize()
Function Normalize ensures that the height ant width are positive.
Definition: eda_rect.cpp:35
int m_width
Definition: pcb_shape.h:46
FOOTPRINT * GetParentFootprint() const
Function GetParentFootprint returns a pointer to the parent footprint, or NULL if PCB_SHAPE does not ...
Definition: pcb_shape.cpp:457
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
wxPoint GetPosition() const override
Definition: footprint.h:200
ring
Definition: board_item.h:55
wxPoint m_bezierC1
Definition: pcb_shape.h:54
wxPoint m_bezierC2
Definition: pcb_shape.h:55
Bezier Curve.
Definition: board_item.h:57
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:363

References 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(), PCB_SHAPE_TYPE_T_asString(), RotatePoint(), S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, S_SEGMENT, EDA_RECT::SetEnd(), and EDA_RECT::SetOrigin().

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

◆ GetCenter()

wxPoint PCB_SHAPE::GetCenter ( ) const
overridevirtual

Function GetCenter()

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

Returns
centre point of the item

Reimplemented from BOARD_ITEM.

Definition at line 343 of file pcb_shape.cpp.

344 {
345  wxPoint c;
346 
347  switch( m_shape )
348  {
349  case S_ARC:
350  case S_CIRCLE:
351  c = m_start;
352  break;
353 
354  case S_SEGMENT:
355  // Midpoint of the line
356  c = ( GetStart() + GetEnd() ) / 2;
357  break;
358 
359  case S_POLYGON:
360  case S_RECT:
361  case S_CURVE:
362  c = GetBoundingBox().Centre();
363  break;
364 
365  default:
366  wxFAIL_MSG( "PCB_SHAPE::GetCentre not implemented for "
368  break;
369  }
370 
371  return c;
372 }
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
Definition: pcb_shape.h:155
PCB_SHAPE_TYPE_T m_shape
Definition: pcb_shape.h:52
polygon (not yet used for tracks, but could be in microwave apps)
Definition: board_item.h:56
usual segment : line with rounded ends
Definition: board_item.h:52
Arcs (with rounded ends)
Definition: board_item.h:54
segment with non rounded ends
Definition: board_item.h:53
static wxString PCB_SHAPE_TYPE_T_asString(PCB_SHAPE_TYPE_T a)
Definition: board_item.h:61
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
Definition: pcb_shape.h:144
wxPoint m_start
Definition: pcb_shape.h:48
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: pcb_shape.cpp:544
wxPoint Centre() const
Definition: eda_rect.h:62
ring
Definition: board_item.h:55
Bezier Curve.
Definition: board_item.h:57

References EDA_RECT::Centre(), GetBoundingBox(), GetEnd(), GetStart(), m_shape, m_start, PCB_SHAPE_TYPE_T_asString(), S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, and S_SEGMENT.

Referenced by BOARD_ADAPTER::AddShapeWithClearanceToContainer(), GRAPHICS_CLEANER::areEquivalent(), GRID_HELPER::computeAnchors(), ConvertOutlineToPolygon(), POINT_EDITOR::editArcMidKeepEnpoints(), export_vrml_drawsegment(), GetArcAngleEnd(), GetArcAngleStart(), GetFocusPosition(), HitTest(), idf_export_outline(), GRAPHICS_CLEANER::isNullSegment(), EDIT_POINTS_FACTORY::Make(), MakeEffectiveShapes(), EAGLE_PLUGIN::packageRectangle(), PCB_PARSER::parsePAD(), TransformShapeWithClearanceToPolygon(), POINT_EDITOR::updateItem(), and POINT_EDITOR::updatePoints().

◆ GetClass()

wxString PCB_SHAPE::GetClass ( ) const
inlineoverridevirtual

Function GetClass returns the class name.

Returns
wxString

Implements EDA_ITEM.

Definition at line 299 of file pcb_shape.h.

300  {
301  return wxT( "PCB_SHAPE" );
302  }

◆ GetEditFlags()

STATUS_FLAGS EDA_ITEM::GetEditFlags ( ) const
inlineinherited

Definition at line 225 of file eda_item.h.

226  {
227  constexpr int mask = ( IS_NEW | IS_PASTED | IS_MOVED | IS_RESIZED | IS_DRAGGED |
229 
230  return m_flags & mask;
231  }
#define IS_RESIZED
Item being resized.
Definition: eda_item.h:107
#define STRUCT_DELETED
flag indication structures to be erased
Definition: eda_item.h:115
#define IS_MOVED
Item being moved.
Definition: eda_item.h:105
#define IS_DRAGGED
Item being dragged.
Definition: eda_item.h:108
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
Definition: eda_item.h:119
#define IS_WIRE_IMAGE
Item to be drawn as wireframe while editing.
Definition: eda_item.h:110
STATUS_FLAGS m_flags
Definition: eda_item.h:164
#define IS_NEW
New item, just created.
Definition: eda_item.h:106

References IS_DRAGGED, IS_MOVED, IS_NEW, IS_PASTED, IS_RESIZED, IS_WIRE_IMAGE, EDA_ITEM::m_flags, and STRUCT_DELETED.

Referenced by SCH_EDIT_TOOL::ChangeTextType(), EDA_ITEM::ClearEditFlags(), SCH_EDIT_FRAME::DeleteJunction(), SCH_EDIT_TOOL::editFieldText(), LIB_PIN_TOOL::EditPinProperties(), SCH_EDITOR_CONTROL::EditWithLibEdit(), SCH_COMPONENT::GetMsgPanelInfo(), SELECTION_CONDITIONS::Idle(), SELECTION_CONDITIONS::IdleSelection(), LIB_MOVE_TOOL::Main(), POINT_EDITOR::OnSelectionChange(), LIB_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_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_LABEL_EDITOR::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow(), and SCH_EDIT_FRAME::TrimWire().

◆ GetEffectiveShape()

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

Function GetEffectiveShape 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 fod use with routing, collision determiniation, etc).

Note that 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 1168 of file pcb_shape.cpp.

1169 {
1170  return std::make_shared<SHAPE_COMPOUND>( MakeEffectiveShapes() );
1171 }
std::vector< SHAPE * > MakeEffectiveShapes() const
Makes a set of SHAPE objects representing the PCB_SHAPE.
Definition: pcb_shape.cpp:1053

References MakeEffectiveShapes().

◆ GetEnd()

◆ GetEndX()

int PCB_SHAPE::GetEndX ( )
inline

Definition at line 157 of file pcb_shape.h.

157 { return m_end.x; }
wxPoint m_end
Definition: pcb_shape.h:49

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 156 of file pcb_shape.h.

156 { return m_end.y; }
wxPoint m_end
Definition: pcb_shape.h:49

References m_end.

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

◆ GetFlags()

◆ GetFocusPosition()

const wxPoint PCB_SHAPE::GetFocusPosition ( ) const
inlineoverridevirtual

Function GetFocusPosition similar to GetPosition, but allows items to return their visual center rather than their anchor.

Reimplemented from EDA_ITEM.

Definition at line 230 of file pcb_shape.h.

231  {
232  return GetCenter();
233  }
wxPoint GetCenter() const override
Function GetCenter()
Definition: pcb_shape.cpp:343

References GetCenter().

◆ GetLayer()

virtual PCB_LAYER_ID BOARD_ITEM::GetLayer ( ) const
inlinevirtualinherited

Function GetLayer returns the primary layer this item is on.

Reimplemented in ZONE.

Definition at line 185 of file board_item.h.

185 { return m_layer; }
PCB_LAYER_ID m_layer
Definition: board_item.h:89

References BOARD_ITEM::m_layer.

Referenced by CN_LIST::Add(), BOARD_ADAPTER::AddFPShapesWithClearanceToContainer(), 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(), KIGFX::PCB_PAINTER::draw(), PCB_EDIT_FRAME::ExchangeFootprint(), export_vrml_drawsegment(), export_vrml_footprint(), export_vrml_fp_shape(), export_vrml_fp_text(), export_vrml_pcbtext(), export_vrml_tracks(), extractDiffPairCoupledItems(), EDIT_TOOL::FilletTracks(), PCB_TARGET::Flip(), PCB_TEXT::Flip(), FP_SHAPE::Flip(), TRACK::Flip(), FP_TEXT::Flip(), DIMENSION_BASE::Flip(), FOOTPRINT::Flip(), 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(), TRACK::GetMsgPanelInfo(), VIA::GetMsgPanelInfo(), PAD::GetMsgPanelInfo(), AR_AUTOPLACER::getOptimalFPPlacement(), BOARD::GetPad(), TEXT_MOD_GRID_TABLE::GetValueAsLong(), TRACK::GetWidthConstraints(), SELECTION_TOOL::GuessSelectionCandidates(), idf_export_footprint(), GENERAL_COLLECTOR::Inspect(), PCB_INSPECTION_TOOL::InspectClearance(), PAD::IsFlipped(), PNS_KICAD_IFACE::IsItemVisible(), BOARD_ITEM::IsOnCopperLayer(), FP_SHAPE::IsParentFlipped(), FP_TEXT::IsParentFlipped(), itemIsIncludedByFilter(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard(), DIALOG_FOOTPRINT_FP_EDITOR::OnAddField(), DIALOG_FOOTPRINT_PROPERTIES::OnAddField(), DIALOG_DRC::OnDRCItemSelected(), TRACK::cmp_tracks::operator()(), PCB_SHAPE::cmp_drawings::operator()(), BOARD_ITEM::ptr_cmp::operator()(), FOOTPRINT::cmp_drawings::operator()(), EAGLE_PLUGIN::packagePad(), BRDITEMS_PLOTTER::PlotBoardGraphicItems(), BRDITEMS_PLOTTER::PlotDimension(), BRDITEMS_PLOTTER::PlotFootprintGraphicItem(), BRDITEMS_PLOTTER::PlotFootprintGraphicItems(), BRDITEMS_PLOTTER::PlotFootprintTextItems(), BRDITEMS_PLOTTER::PlotPcbShape(), BRDITEMS_PLOTTER::PlotPcbTarget(), BRDITEMS_PLOTTER::PlotPcbText(), CONVERT_TOOL::PolyToLines(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), processTextItem(), PAD_TOOL::recombinePad(), CLIPBOARD_IO::SaveSelection(), CONVERT_TOOL::SegmentToArc(), SELECTION_TOOL::Selectable(), TEXT_MOD_GRID_TABLE::SetValueAsLong(), GLOBAL_EDIT_TOOL::swapBoardItem(), PNS_KICAD_IFACE_BASE::syncArc(), PNS_KICAD_IFACE_BASE::syncGraphicalItem(), PNS_KICAD_IFACE_BASE::syncTrack(), AR_AUTOPLACER::testFootprintOnBoard(), TRACK_VIA_DESC::TRACK_VIA_DESC(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow(), DIALOG_DIMENSION_PROPERTIES::TransferDataToWindow(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataToWindow(), BOARD_ADAPTER::transformFPShapesToPolygon(), FOOTPRINT::TransformFPShapesWithClearanceToPolygon(), TRACK::ViewBBox(), FP_TEXT::ViewGetLayers(), TRACK::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

Function GetLayerName returns the name of the PCB layer on which the item resides.

Returns
wxString containing the layer name associated with this item.

Definition at line 60 of file board_item.cpp.

61 {
62  BOARD* board = GetBoard();
63 
64  if( board )
65  return board->GetLayerName( m_layer );
66 
67  // If no parent, return standard name
69 }
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:332
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:46
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:186
PCB_LAYER_ID m_layer
Definition: board_item.h:89
static wxString GetStandardLayerName(PCB_LAYER_ID aLayerId)
Return an "English Standard" name of a PCB layer when given aLayerNumber.
Definition: board.h:641

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

Referenced by PCB_TEXT::GetMsgPanelInfo(), FP_TEXT::GetMsgPanelInfo(), DIMENSION_BASE::GetMsgPanelInfo(), GetMsgPanelInfo(), LEADER::GetMsgPanelInfo(), PCB_TEXT::GetSelectMenuText(), FP_SHAPE::GetSelectMenuText(), TRACK::GetSelectMenuText(), DIMENSION_BASE::GetSelectMenuText(), GetSelectMenuText(), PCB_TEXT::GetShownText(), TEXT_MOD_GRID_TABLE::GetValue(), and FOOTPRINT::ResolveTextVar().

◆ GetLayerSet()

virtual LSET BOARD_ITEM::GetLayerSet ( ) const
inlinevirtualinherited

◆ GetLength()

double PCB_SHAPE::GetLength ( ) const

Function GetLength returns the length of the track using the hypotenuse calculation.

Returns
double - the length of the track

Definition at line 76 of file pcb_shape.cpp.

77 {
78  double length = 0.0;
79 
80  switch( m_shape )
81  {
82  case S_CURVE:
83  for( size_t ii = 1; ii < m_bezierPoints.size(); ++ii )
84  length += GetLineLength( m_bezierPoints[ ii - 1], m_bezierPoints[ii] );
85 
86  break;
87 
88  case S_SEGMENT:
89  length = GetLineLength( GetStart(), GetEnd() );
90  break;
91 
92  case S_POLYGON:
93  for( int ii = 0; ii < m_poly.COutline( 0 ).SegmentCount(); ii++ )
94  length += m_poly.COutline( 0 ).CSegment( ii ).Length();
95 
96  break;
97 
98  case S_ARC:
99  length = 2 * M_PI * GetRadius() * ( GetAngle() / 3600.0 );
100  break;
101 
102  default:
103  wxASSERT_MSG( false, "PCB_SHAPE::GetLength not implemented for shape"
104  + ShowShape( GetShape() ) );
105  break;
106  }
107 
108  return length;
109 }
int Length() const
Function Length()
Definition: seg.h:319
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:209
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
Definition: pcb_shape.h:155
PCB_SHAPE_TYPE_T m_shape
Definition: pcb_shape.h:52
int GetRadius() const
Function GetRadius returns the radius of this item Has meaning only for arc and circle.
Definition: pcb_shape.h:200
polygon (not yet used for tracks, but could be in microwave apps)
Definition: board_item.h:56
static wxString ShowShape(PCB_SHAPE_TYPE_T aShape)
Function ShowShape converts the enum PCB_SHAPE_TYPE_T integer value to a wxString.
Definition: board_item.cpp:31
usual segment : line with rounded ends
Definition: board_item.h:52
Arcs (with rounded ends)
Definition: board_item.h:54
SHAPE_POLY_SET m_poly
Definition: pcb_shape.h:58
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
Definition: pcb_shape.h:144
int SegmentCount() const
Function SegmentCount()
const SEG CSegment(int aIndex) const
Function CSegment()
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
double GetAngle() const
Definition: pcb_shape.h:126
PCB_SHAPE_TYPE_T GetShape() const
Definition: pcb_shape.h:129
std::vector< wxPoint > m_bezierPoints
Definition: pcb_shape.h:57
Bezier Curve.
Definition: board_item.h:57

References SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CSegment(), GetAngle(), GetEnd(), GetLineLength(), GetRadius(), GetShape(), GetStart(), SEG::Length(), m_bezierPoints, m_poly, m_shape, S_ARC, S_CURVE, S_POLYGON, S_SEGMENT, SHAPE_LINE_CHAIN::SegmentCount(), and BOARD_ITEM::ShowShape().

Referenced by GetMsgPanelInfo().

◆ GetMenuImage()

BITMAP_DEF PCB_SHAPE::GetMenuImage ( ) const
overridevirtual

Function GetMenuImage returns 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 914 of file pcb_shape.cpp.

915 {
916  return add_dashed_line_xpm;
917 }
const BITMAP_OPAQUE add_dashed_line_xpm[1]

References add_dashed_line_xpm.

◆ GetMsgPanelInfo()

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

Function GetMsgPanelInfo populates 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 466 of file pcb_shape.cpp.

467 {
468  EDA_UNITS units = aFrame->GetUserUnits();
469  ORIGIN_TRANSFORMS originTransforms = aFrame->GetOriginTransforms();
470  wxString msg;
471 
472  aList.emplace_back( _( "Type" ), _( "Drawing" ) );
473 
474  wxString shape = _( "Shape" );
475 
476  switch( m_shape )
477  {
478  case S_CIRCLE:
479  aList.emplace_back( shape, _( "Circle" ) );
480 
481  msg = MessageTextFromValue( units, GetLineLength( m_start, m_end ) );
482  aList.emplace_back( _( "Radius" ), msg );
483  break;
484 
485  case S_ARC:
486  aList.emplace_back( shape, _( "Arc" ) );
487 
488  msg.Printf( wxT( "%.1f" ), m_angle / 10.0 );
489  aList.emplace_back( _( "Angle" ), msg );
490 
491  msg = MessageTextFromValue( units, GetLineLength( m_start, m_end ) );
492  aList.emplace_back( _( "Radius" ), msg );
493  break;
494 
495  case S_CURVE:
496  aList.emplace_back( shape, _( "Curve" ) );
497 
498  msg = MessageTextFromValue( units, GetLength() );
499  aList.emplace_back( _( "Length" ), msg );
500  break;
501 
502  case S_POLYGON:
503  aList.emplace_back( shape, _( "Polygon" ) );
504 
505  msg.Printf( "%d", GetPolyShape().Outline(0).PointCount() );
506  aList.emplace_back( _( "Points" ), msg );
507  break;
508 
509  case S_RECT:
510  aList.emplace_back( shape, _( "Rectangle" ) );
511 
512  msg = MessageTextFromValue( units, std::abs( m_end.x - m_start.x ) );
513  aList.emplace_back( _( "Width" ), msg );
514 
515  msg = MessageTextFromValue( units, std::abs( m_end.y - m_start.y ) );
516  aList.emplace_back( _( "Height" ), msg );
517  break;
518 
519  case S_SEGMENT:
520  {
521  aList.emplace_back( shape, _( "Segment" ) );
522 
523  msg = MessageTextFromValue( units, GetLineLength( m_start, m_end ) );
524  aList.emplace_back( _( "Length" ), msg );
525 
526  // angle counter-clockwise from 3'o-clock
527  const double deg = RAD2DEG( atan2( (double)( m_start.y - m_end.y ),
528  (double)( m_end.x - m_start.x ) ) );
529  aList.emplace_back( _( "Angle" ), wxString::Format( "%.1f", deg ) );
530  }
531  break;
532 
533  default:
534  aList.emplace_back( shape, _( "Unrecognized" ) );
535  break;
536  }
537 
538  aList.emplace_back( _( "Layer" ), GetLayerName() );
539 
540  aList.emplace_back( _( "Width" ), MessageTextFromValue( units, m_width ) );
541 }
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Definition: base_units.cpp:123
wxPoint m_end
Definition: pcb_shape.h:49
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:209
SHAPE_POLY_SET & GetPolyShape()
Definition: pcb_shape.h:259
PCB_SHAPE_TYPE_T m_shape
Definition: pcb_shape.h:52
double RAD2DEG(double rad)
Definition: trigo.h:218
polygon (not yet used for tracks, but could be in microwave apps)
Definition: board_item.h:56
usual segment : line with rounded ends
Definition: board_item.h:52
virtual ORIGIN_TRANSFORMS & GetOriginTransforms()
Return a reference to the default ORIGIN_TRANSFORMS object.
Arcs (with rounded ends)
Definition: board_item.h:54
segment with non rounded ends
Definition: board_item.h:53
double m_angle
Definition: pcb_shape.h:53
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
wxPoint m_start
Definition: pcb_shape.h:48
EDA_UNITS
Definition: eda_units.h:38
int m_width
Definition: pcb_shape.h:46
A class to perform either relative or absolute display origin transforms for a single axis of a point...
#define _(s)
Definition: 3d_actions.cpp:33
ring
Definition: board_item.h:55
wxString GetLayerName() const
Function GetLayerName returns the name of the PCB layer on which the item resides.
Definition: board_item.cpp:60
Bezier Curve.
Definition: board_item.h:57
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
double GetLength() const
Function GetLength returns the length of the track using the hypotenuse calculation.
Definition: pcb_shape.cpp:76

References _, Format(), BOARD_ITEM::GetLayerName(), GetLength(), GetLineLength(), EDA_DRAW_FRAME::GetOriginTransforms(), GetPolyShape(), EDA_BASE_FRAME::GetUserUnits(), m_angle, m_end, m_shape, m_start, m_width, MessageTextFromValue(), RAD2DEG(), S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, and S_SEGMENT.

Referenced by FP_SHAPE::GetMsgPanelInfo().

◆ GetParent()

BOARD_ITEM_CONTAINER* BOARD_ITEM::GetParent ( void  ) const
inlineinherited

Definition at line 179 of file board_item.h.

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

References EDA_ITEM::m_parent.

Referenced by POINT_EDITOR::addCorner(), ALIGN_DISTRIBUTE_TOOL::AlignBottom(), ALIGN_DISTRIBUTE_TOOL::AlignCenterX(), ALIGN_DISTRIBUTE_TOOL::AlignCenterY(), ALIGN_DISTRIBUTE_TOOL::AlignTop(), 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(), KIGFX::PCB_PAINTER::draw(), EDIT_TOOL::Duplicate(), EditToolSelectionFilter(), PCB_IO::format(), FormatProbeItem(), BOARD_ITEM::GetBoard(), PCB_MARKER::GetColorLayer(), FP_TEXT::GetSelectMenuText(), PCB_TEXT::GetShownText(), FP_TEXT::GetShownText(), GENERAL_COLLECTOR::Inspect(), ARRAY_CREATOR::Invoke(), isNetTie(), FP_SHAPE::IsParentFlipped(), FP_TEXT::IsParentFlipped(), LEGACY_PLUGIN::loadMODULE_TEXT(), memberOf(), ALTIUM_PCB::ParseTexts6Data(), BRDITEMS_PLOTTER::PlotFootprintGraphicItem(), BRDITEMS_PLOTTER::PlotFootprintTextItem(), BOARD_COMMIT::Push(), DRC_TEST_PROVIDER_SILK_CLEARANCE::Run(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), CLIPBOARD_IO::SaveSelection(), SELECTION_TOOL::select(), SELECTION_TOOL::Selectable(), SwapItemData(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem(), PCB_GROUP::TopLevelGroup(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), PCB_MARKER::ViewGetLayers(), FP_ZONE::ViewGetLOD(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem(), and PCB_GROUP::WithinScope().

◆ GetParentFootprint()

FOOTPRINT * PCB_SHAPE::GetParentFootprint ( ) const

Function GetParentFootprint returns a pointer to the parent footprint, or NULL if PCB_SHAPE does not belong to a footprint.

Returns
FOOTPRINT* - pointer to the parent footprint or NULL.

Definition at line 457 of file pcb_shape.cpp.

458 {
459  if( !m_parent || m_parent->Type() != PCB_FOOTPRINT_T )
460  return NULL;
461 
462  return (FOOTPRINT*) m_parent;
463 }
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:162
#define NULL
class FOOTPRINT, a footprint
Definition: typeinfo.h:89
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181

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

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

◆ GetParentGroup()

◆ GetPointCount()

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

Definition at line 1203 of file pcb_shape.cpp.

1204 {
1205  // return the number of corners of the polygonal shape
1206  // this shape is expected to be only one polygon without hole
1207  if( GetPolyShape().OutlineCount() )
1208  return GetPolyShape().VertexCount( 0 );
1209 
1210  return 0;
1211 }
SHAPE_POLY_SET & GetPolyShape()
Definition: pcb_shape.h:259
int VertexCount(int aOutline=-1, int aHole=-1) const
Returns the number of vertices in a given outline/hole

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

Referenced by GRAPHICS_CLEANER::isNullSegment().

◆ GetPolyShape() [1/2]

◆ GetPolyShape() [2/2]

const SHAPE_POLY_SET& PCB_SHAPE::GetPolyShape ( ) const
inline

Definition at line 260 of file pcb_shape.h.

260 { return m_poly; }
SHAPE_POLY_SET m_poly
Definition: pcb_shape.h:58

References m_poly.

◆ GetPosition()

wxPoint PCB_SHAPE::GetPosition ( ) const
overridevirtual

Reimplemented from EDA_ITEM.

Definition at line 67 of file pcb_shape.cpp.

68 {
69  if( m_shape == S_POLYGON )
70  return (wxPoint) m_poly.CVertex( 0 );
71  else
72  return m_start;
73 }
PCB_SHAPE_TYPE_T m_shape
Definition: pcb_shape.h:52
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Returns the index-th vertex in a given hole outline within a given outline
polygon (not yet used for tracks, but could be in microwave apps)
Definition: board_item.h:56
SHAPE_POLY_SET m_poly
Definition: pcb_shape.h:58
wxPoint m_start
Definition: pcb_shape.h:48

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

◆ GetRadius()

int PCB_SHAPE::GetRadius ( ) const
inline

Function GetRadius returns the radius of this item Has meaning only for arc and circle.

Definition at line 200 of file pcb_shape.h.

201  {
202  double radius = GetLineLength( m_start, m_end );
203 
204  // don't allow degenerate arcs
205  return std::max( 1, KiROUND( radius ) );
206  }
wxPoint m_end
Definition: pcb_shape.h:49
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:209
wxPoint m_start
Definition: pcb_shape.h:48
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:68

References GetLineLength(), KiROUND(), m_end, and m_start.

Referenced by BOARD_ADAPTER::AddShapeWithClearanceToContainer(), computeArcBBox(), ConvertOutlineToPolygon(), KIGFX::PCB_PAINTER::draw(), GetBoundingBox(), GetLength(), hash_fp_item(), HitTest(), idf_export_outline(), GRAPHICS_CLEANER::isNullSegment(), MakeEffectiveShapes(), 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 942 of file pcb_shape.cpp.

943 {
944  std::vector<wxPoint> pts;
945  FOOTPRINT* parentFootprint = GetParentFootprint();
946  wxPoint topLeft = GetStart();
947  wxPoint botRight = GetEnd();
948 
949  // Un-rotate rect topLeft and botRight
950  if( parentFootprint && KiROUND( parentFootprint->GetOrientation() ) % 900 != 0 )
951  {
952  topLeft -= parentFootprint->GetPosition();
953  RotatePoint( &topLeft, -parentFootprint->GetOrientation() );
954 
955  botRight -= parentFootprint->GetPosition();
956  RotatePoint( &botRight, -parentFootprint->GetOrientation() );
957  }
958 
959  // Set up the un-rotated 4 corners
960  pts.emplace_back( topLeft );
961  pts.emplace_back( botRight.x, topLeft.y );
962  pts.emplace_back( botRight );
963  pts.emplace_back( topLeft.x, botRight.y );
964 
965  // Now re-rotate the 4 corners to get a diamond
966  if( parentFootprint && KiROUND( parentFootprint->GetOrientation() ) % 900 != 0 )
967  {
968  for( wxPoint& pt : pts )
969  {
970  RotatePoint( &pt, parentFootprint->GetOrientation() );
971  pt += parentFootprint->GetPosition();
972  }
973  }
974 
975  return pts;
976 }
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
Definition: pcb_shape.h:155
double GetOrientation() const
Definition: footprint.h:204
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
Definition: pcb_shape.h:144
FOOTPRINT * GetParentFootprint() const
Function GetParentFootprint returns a pointer to the parent footprint, or NULL if PCB_SHAPE does not ...
Definition: pcb_shape.cpp:457
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:68
wxPoint GetPosition() const override
Definition: footprint.h:200

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

Referenced by BOARD_ADAPTER::AddShapeWithClearanceToContainer(), 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

Function GetSelectMenuText returns 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 906 of file pcb_shape.cpp.

907 {
908  return wxString::Format( _( "%s on %s" ),
909  ShowShape( m_shape ),
910  GetLayerName() );
911 }
PCB_SHAPE_TYPE_T m_shape
Definition: pcb_shape.h:52
static wxString ShowShape(PCB_SHAPE_TYPE_T aShape)
Function ShowShape converts the enum PCB_SHAPE_TYPE_T integer value to a wxString.
Definition: board_item.cpp:31
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
#define _(s)
Definition: 3d_actions.cpp:33
wxString GetLayerName() const
Function GetLayerName returns the name of the PCB layer on which the item resides.
Definition: board_item.cpp:60

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

◆ GetShape()

PCB_SHAPE_TYPE_T PCB_SHAPE::GetShape ( ) const
inline

◆ GetStart()

◆ GetStartX()

int PCB_SHAPE::GetStartX ( )
inline

Definition at line 146 of file pcb_shape.h.

146 { return m_start.x; }
wxPoint m_start
Definition: pcb_shape.h:48

References m_start.

Referenced by DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run().

◆ GetStartY()

int PCB_SHAPE::GetStartY ( )
inline

Definition at line 145 of file pcb_shape.h.

145 { return m_start.y; }
wxPoint m_start
Definition: pcb_shape.h:48

References m_start.

Referenced by DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run().

◆ GetState()

int EDA_ITEM::GetState ( int  type) const
inlineinherited

Definition at line 204 of file eda_item.h.

205  {
206  return m_status & type;
207  }
STATUS_FLAGS m_status
Definition: eda_item.h:161

References EDA_ITEM::m_status.

Referenced by TRACK::GetMsgPanelInfoBase_Common(), and TRACK::IsLocked().

◆ GetStatus()

STATUS_FLAGS EDA_ITEM::GetStatus ( ) const
inlineinherited

Definition at line 217 of file eda_item.h.

217 { return m_status; }
STATUS_FLAGS m_status
Definition: eda_item.h:161

References EDA_ITEM::m_status.

◆ GetThirdPoint()

const wxPoint& PCB_SHAPE::GetThirdPoint ( ) const
inline

Function GetThirdPoint returns the third point point of the graphic.

Definition at line 166 of file pcb_shape.h.

166 { return m_thirdPoint; }
wxPoint m_thirdPoint
Definition: pcb_shape.h:50

References m_thirdPoint.

◆ GetThirdPointX()

int PCB_SHAPE::GetThirdPointX ( )
inline

Definition at line 168 of file pcb_shape.h.

168 { return m_thirdPoint.x; }
wxPoint m_thirdPoint
Definition: pcb_shape.h:50

References m_thirdPoint.

◆ GetThirdPointY()

int PCB_SHAPE::GetThirdPointY ( )
inline

Definition at line 167 of file pcb_shape.h.

167 { return m_thirdPoint.y; }
wxPoint m_thirdPoint
Definition: pcb_shape.h:50

References m_thirdPoint.

◆ GetWidth()

◆ GetX()

int BOARD_ITEM::GetX ( ) const
inlineinherited

Definition at line 105 of file board_item.h.

106  {
107  wxPoint p = GetPosition();
108  return p.x;
109  }
virtual wxPoint GetPosition() const
Definition: eda_item.h:325

References EDA_ITEM::GetPosition().

Referenced by BOARD_ITEM_DESC::BOARD_ITEM_DESC(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsHorizontally(), BOARD_ITEM::SetY(), and TRACK_VIA_DESC::TRACK_VIA_DESC().

◆ GetY()

int BOARD_ITEM::GetY ( ) const
inlineinherited

Definition at line 111 of file board_item.h.

112  {
113  wxPoint p = GetPosition();
114  return p.y;
115  }
virtual wxPoint GetPosition() const
Definition: eda_item.h:325

References EDA_ITEM::GetPosition().

Referenced by BOARD_ITEM_DESC::BOARD_ITEM_DESC(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsVertically(), BOARD_ITEM::SetX(), and TRACK_VIA_DESC::TRACK_VIA_DESC().

◆ HasFlag()

◆ HitTest() [1/2]

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

Function HitTest tests 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 617 of file pcb_shape.cpp.

618 {
619  int maxdist = aAccuracy + ( m_width / 2 );
620 
621  switch( m_shape )
622  {
623  case S_CIRCLE:
624  {
625  int radius = GetRadius();
626  int dist = KiROUND( EuclideanNorm( aPosition - GetCenter() ) );
627 
628  if( IsFilled() ) // Filled circle hit-test
629  {
630  if( dist <= radius + maxdist )
631  return true;
632  }
633  else // Ring hit-test
634  {
635  if( abs( radius - dist ) <= maxdist )
636  return true;
637  }
638  }
639  break;
640 
641  case S_ARC:
642  {
643  wxPoint relPos = aPosition - GetCenter();
644  int radius = GetRadius();
645  int dist = KiROUND( EuclideanNorm( relPos ) );
646 
647  if( abs( radius - dist ) <= maxdist )
648  {
649  // For arcs, the test point angle must be >= arc angle start
650  // and <= arc angle end
651  // However angle values > 360 deg are not easy to handle
652  // so we calculate the relative angle between arc start point and teast point
653  // this relative arc should be < arc angle if arc angle > 0 (CW arc)
654  // and > arc angle if arc angle < 0 (CCW arc)
655  double arc_angle_start = GetArcAngleStart(); // Always 0.0 ... 360 deg, in 0.1 deg
656 
657  double arc_hittest = ArcTangente( relPos.y, relPos.x );
658 
659  // Calculate relative angle between the starting point of the arc, and the test point
660  arc_hittest -= arc_angle_start;
661 
662  // Normalise arc_hittest between 0 ... 360 deg
663  NORMALIZE_ANGLE_POS( arc_hittest );
664 
665  // Check angle: inside the arc angle when it is > 0
666  // and outside the not drawn arc when it is < 0
667  if( GetAngle() >= 0.0 )
668  {
669  if( arc_hittest <= GetAngle() )
670  return true;
671  }
672  else
673  {
674  if( arc_hittest >= ( 3600.0 + GetAngle() ) )
675  return true;
676  }
677  }
678  }
679  break;
680 
681  case S_CURVE:
682  const_cast<PCB_SHAPE*>( this )->RebuildBezierToSegmentsPointsList( m_width );
683 
684  for( unsigned int i= 1; i < m_bezierPoints.size(); i++)
685  {
686  if( TestSegmentHit( aPosition, m_bezierPoints[ i - 1], m_bezierPoints[i], maxdist ) )
687  return true;
688  }
689 
690  break;
691 
692  case S_SEGMENT:
693  if( TestSegmentHit( aPosition, m_start, m_end, maxdist ) )
694  return true;
695 
696  break;
697 
698  case S_RECT:
699  {
700  std::vector<wxPoint> pts = GetRectCorners();
701 
702  if( IsFilled() ) // Filled rect hit-test
703  {
704  SHAPE_POLY_SET poly;
705  poly.NewOutline();
706 
707  for( const wxPoint& pt : pts )
708  poly.Append( pt );
709 
710  if( poly.Collide( VECTOR2I( aPosition ), maxdist ) )
711  return true;
712  }
713  else // Open rect hit-test
714  {
715  if( TestSegmentHit( aPosition, pts[0], pts[1], maxdist )
716  || TestSegmentHit( aPosition, pts[1], pts[2], maxdist )
717  || TestSegmentHit( aPosition, pts[2], pts[3], maxdist )
718  || TestSegmentHit( aPosition, pts[3], pts[0], maxdist ) )
719  {
720  return true;
721  }
722  }
723  }
724  break;
725 
726  case S_POLYGON:
727  if( IsFilled() )
728  {
729  return m_poly.Collide( VECTOR2I( aPosition ), maxdist );
730  }
731  else
732  {
734  return m_poly.CollideEdge( VECTOR2I( aPosition ), dummy, maxdist );
735  }
736 
737  break;
738 
739  default:
740  wxFAIL_MSG( "PCB_SHAPE::HitTest (point) not implemented for "
742  break;
743  }
744 
745  return false;
746 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:134
bool IsFilled() const
Definition: pcb_shape.h:96
wxPoint m_end
Definition: pcb_shape.h:49
PCB_SHAPE_TYPE_T m_shape
Definition: pcb_shape.h:52
int GetRadius() const
Function GetRadius returns the radius of this item Has meaning only for arc and circle.
Definition: pcb_shape.h:200
std::vector< wxPoint > GetRectCorners() const
Definition: pcb_shape.cpp:942
double GetArcAngleStart() const
function GetArcAngleStart()
Definition: pcb_shape.cpp:415
polygon (not yet used for tracks, but could be in microwave apps)
Definition: board_item.h:56
Struct VERTEX_INDEX.
usual segment : line with rounded ends
Definition: board_item.h:52
Arcs (with rounded ends)
Definition: board_item.h:54
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:274
segment with non rounded ends
Definition: board_item.h:53
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
bool TestSegmentHit(const wxPoint &aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
Definition: trigo.cpp:129
SHAPE_POLY_SET m_poly
Definition: pcb_shape.h:58
SHAPE_POLY_SET.
static wxString PCB_SHAPE_TYPE_T_asString(PCB_SHAPE_TYPE_T a)
Definition: board_item.h:61
wxPoint GetCenter() const override
Function GetCenter()
Definition: pcb_shape.cpp:343
int NewOutline()
Creates a new empty polygon in the set and returns its index
wxPoint m_start
Definition: pcb_shape.h:48
bool Collide(const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Function Collide()
bool CollideEdge(const VECTOR2I &aPoint, VERTEX_INDEX &aClosestVertex, int aClearance=0) const
Function CollideEdge Checks whether aPoint collides with any edge of any of the contours of the polyg...
int m_width
Definition: pcb_shape.h:46
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
double GetAngle() const
Definition: pcb_shape.h:126
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:68
ring
Definition: board_item.h:55
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:162
std::vector< wxPoint > m_bezierPoints
Definition: pcb_shape.h:57
Bezier Curve.
Definition: board_item.h:57
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)

References SHAPE_POLY_SET::Append(), ArcTangente(), 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(), PCB_SHAPE_TYPE_T_asString(), S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, S_SEGMENT, 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

Function HitTest tests 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 749 of file pcb_shape.cpp.

750 {
751  EDA_RECT arect = aRect;
752  arect.Normalize();
753  arect.Inflate( aAccuracy );
754 
755  EDA_RECT arcRect;
756  EDA_RECT bb = GetBoundingBox();
757 
758  switch( m_shape )
759  {
760  case S_CIRCLE:
761  // Test if area intersects or contains the circle:
762  if( aContained )
763  return arect.Contains( bb );
764  else
765  {
766  // If the rectangle does not intersect the bounding box, this is a much quicker test
767  if( !aRect.Intersects( bb ) )
768  {
769  return false;
770  }
771  else
772  {
773  return arect.IntersectsCircleEdge( GetCenter(), GetRadius(), GetWidth() );
774  }
775  }
776  break;
777 
778  case S_ARC:
779  // Test for full containment of this arc in the rect
780  if( aContained )
781  {
782  return arect.Contains( bb );
783  }
784  // Test if the rect crosses the arc
785  else
786  {
787  arcRect = bb.Common( arect );
788 
789  /* All following tests must pass:
790  * 1. Rectangle must intersect arc BoundingBox
791  * 2. Rectangle must cross the outside of the arc
792  */
793  return arcRect.Intersects( arect ) &&
795  }
796  break;
797 
798  case S_RECT:
799  if( aContained )
800  {
801  return arect.Contains( bb );
802  }
803  else
804  {
805  std::vector<wxPoint> pts = GetRectCorners();
806 
807  // Account for the width of the lines
808  arect.Inflate( GetWidth() / 2 );
809  return ( arect.Intersects( pts[0], pts[1] )
810  || arect.Intersects( pts[1], pts[2] )
811  || arect.Intersects( pts[2], pts[3] )
812  || arect.Intersects( pts[3], pts[0] ) );
813  }
814 
815  break;
816 
817  case S_SEGMENT:
818  if( aContained )
819  {
820  return arect.Contains( GetStart() ) && aRect.Contains( GetEnd() );
821  }
822  else
823  {
824  // Account for the width of the line
825  arect.Inflate( GetWidth() / 2 );
826  return arect.Intersects( GetStart(), GetEnd() );
827  }
828 
829  break;
830 
831  case S_POLYGON:
832  if( aContained )
833  {
834  return arect.Contains( bb );
835  }
836  else
837  {
838  // Fast test: if aRect is outside the polygon bounding box,
839  // rectangles cannot intersect
840  if( !arect.Intersects( bb ) )
841  return false;
842 
843  // Account for the width of the line
844  arect.Inflate( GetWidth() / 2 );
845  int count = m_poly.TotalVertices();
846 
847  for( int ii = 0; ii < count; ii++ )
848  {
849  auto vertex = m_poly.CVertex( ii );
850  auto vertexNext = m_poly.CVertex(( ii + 1 ) % count );
851 
852  // Test if the point is within aRect
853  if( arect.Contains( ( wxPoint ) vertex ) )
854  return true;
855 
856  // Test if this edge intersects aRect
857  if( arect.Intersects( ( wxPoint ) vertex, ( wxPoint ) vertexNext ) )
858  return true;
859  }
860  }
861  break;
862 
863  case S_CURVE:
864  if( aContained )
865  {
866  return arect.Contains( bb );
867  }
868  else
869  {
870  // Fast test: if aRect is outside the polygon bounding box,
871  // rectangles cannot intersect
872  if( !arect.Intersects( bb ) )
873  return false;
874 
875  // Account for the width of the line
876  arect.Inflate( GetWidth() / 2 );
877  unsigned count = m_bezierPoints.size();
878 
879  for( unsigned ii = 1; ii < count; ii++ )
880  {
881  wxPoint vertex = m_bezierPoints[ ii - 1];
882  wxPoint vertexNext = m_bezierPoints[ii];
883 
884  // Test if the point is within aRect
885  if( arect.Contains( ( wxPoint ) vertex ) )
886  return true;
887 
888  // Test if this edge intersects aRect
889  if( arect.Intersects( vertex, vertexNext ) )
890  return true;
891  }
892  }
893  break;
894 
895 
896  default:
897  wxFAIL_MSG( "PCB_SHAPE::HitTest (rect) not implemented for "
899  break;
900  }
901 
902  return false;
903 }
int TotalVertices() const
Returns total number of vertices stored in the set.
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
Definition: pcb_shape.h:155
PCB_SHAPE_TYPE_T m_shape
Definition: pcb_shape.h:52
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Returns the index-th vertex in a given hole outline within a given outline
int GetRadius() const
Function GetRadius returns the radius of this item Has meaning only for arc and circle.
Definition: pcb_shape.h:200
std::vector< wxPoint > GetRectCorners() const
Definition: pcb_shape.cpp:942
int GetWidth() const
Definition: pcb_shape.h:118
polygon (not yet used for tracks, but could be in microwave apps)
Definition: board_item.h:56
usual segment : line with rounded ends
Definition: board_item.h:52
bool IntersectsCircleEdge(const wxPoint &aCenter, const int aRadius, const int aWidth) const
IntersectsCircleEdge Tests for intersection between this rect and the edge (radius) of a circle.
Definition: eda_rect.cpp:330
EDA_RECT Common(const EDA_RECT &aRect) const
Function Common returns the area that is common with another rectangle.
Definition: eda_rect.cpp:487
Arcs (with rounded ends)
Definition: board_item.h:54
segment with non rounded ends
Definition: board_item.h:53
bool Contains(const wxPoint &aPoint) const
Function Contains.
Definition: eda_rect.cpp:57
SHAPE_POLY_SET m_poly
Definition: pcb_shape.h:58
static wxString PCB_SHAPE_TYPE_T_asString(PCB_SHAPE_TYPE_T a)
Definition: board_item.h:61
wxPoint GetCenter() const override
Function GetCenter()
Definition: pcb_shape.cpp:343
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
Definition: pcb_shape.h:144
void Normalize()
Function Normalize ensures that the height ant width are positive.
Definition: eda_rect.cpp:35
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: pcb_shape.cpp:544
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
Definition: eda_rect.cpp:150
ring
Definition: board_item.h:55
std::vector< wxPoint > m_bezierPoints
Definition: pcb_shape.h:57
Bezier Curve.
Definition: board_item.h:57
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:363

References EDA_RECT::Common(), EDA_RECT::Contains(), SHAPE_POLY_SET::CVertex(), GetBoundingBox(), GetCenter(), GetEnd(), GetRadius(), GetRectCorners(), GetStart(), GetWidth(), EDA_RECT::Inflate(), EDA_RECT::Intersects(), EDA_RECT::IntersectsCircleEdge(), m_bezierPoints, m_poly, m_shape, EDA_RECT::Normalize(), PCB_SHAPE_TYPE_T_asString(), S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, S_SEGMENT, and SHAPE_POLY_SET::TotalVertices().

◆ IsBrightened()

◆ IsConnected()

virtual bool BOARD_ITEM::IsConnected ( ) const
inlinevirtualinherited

◆ IsDragging()

bool EDA_ITEM::IsDragging ( ) const
inlineinherited

Definition at line 189 of file eda_item.h.

189 { return m_flags & IS_DRAGGED; }
#define IS_DRAGGED
Item being dragged.
Definition: eda_item.h:108
STATUS_FLAGS m_flags
Definition: eda_item.h:164

References IS_DRAGGED, and EDA_ITEM::m_flags.

Referenced by DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES(), and KIGFX::SCH_PAINTER::setDeviceColors().

◆ IsFilled()

bool PCB_SHAPE::IsFilled ( ) const
inline

Definition at line 96 of file pcb_shape.h.

97  {
98  switch( m_shape )
99  {
100  case S_RECT:
101  case S_CIRCLE:
102  case S_POLYGON:
103  return m_filled;
104 
105  case S_SEGMENT:
106  case S_ARC:
107  case S_CURVE:
108  return false;
109 
110  case S_LAST: // Make CLang compiler happy
111  return false;
112  }
113 
114  return false; // Make GCC compiler happy
115  }
PCB_SHAPE_TYPE_T m_shape
Definition: pcb_shape.h:52
polygon (not yet used for tracks, but could be in microwave apps)
Definition: board_item.h:56
usual segment : line with rounded ends
Definition: board_item.h:52
Arcs (with rounded ends)
Definition: board_item.h:54
segment with non rounded ends
Definition: board_item.h:53
last value for this list
Definition: board_item.h:58
ring
Definition: board_item.h:55
bool m_filled
Definition: pcb_shape.h:47
Bezier Curve.
Definition: board_item.h:57

References m_filled, m_shape, S_ARC, S_CIRCLE, S_CURVE, S_LAST, S_POLYGON, S_RECT, and S_SEGMENT.

Referenced by BOARD_ADAPTER::AddShapeWithClearanceToContainer(), KIGFX::PCB_PAINTER::draw(), PCB_IO::format(), 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 274 of file eda_item.h.

274 { return m_forceVisible; }
bool m_forceVisible
Definition: eda_item.h:163

References EDA_ITEM::m_forceVisible.

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

◆ IsLocked()

virtual bool BOARD_ITEM::IsLocked ( ) const
inlinevirtualinherited

Function IsLocked.

Returns
bool - true if the object is locked, else false

Reimplemented in FOOTPRINT, and TRACK.

Definition at line 259 of file board_item.h.

260  {
261  // only footprints & TRACKs can be locked at this time.
262  return false;
263  }

Referenced by BOARD_ITEM_DESC::BOARD_ITEM_DESC(), PCBNEW_CONTROL::DeleteItemCursor(), EditToolSelectionFilter(), GENERAL_COLLECTOR::Inspect(), SELECTION_TOOL::itemPassesFilter(), and PCB_EDITOR_CONTROL::modifyLockSelected().

◆ IsModified()

bool EDA_ITEM::IsModified ( ) const
inlineinherited

Definition at line 186 of file eda_item.h.

186 { return m_flags & IS_CHANGED; }
#define IS_CHANGED
std::function passed to nested users by ref, avoids copying std::function
Definition: eda_item.h:102
STATUS_FLAGS m_flags
Definition: eda_item.h:164

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 TRACK, PAD, and ZONE.

Definition at line 154 of file board_item.h.

155  {
156  return IsCopperLayer( GetLayer() );
157  }
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
Definition: board_item.h:185

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

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

◆ IsOnLayer()

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

Function IsOnLayer tests 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
bool - true if on given layer, else false.

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

Definition at line 239 of file board_item.h.

240  {
241  return m_layer == aLayer;
242  }
PCB_LAYER_ID m_layer
Definition: board_item.h:89

References BOARD_ITEM::m_layer.

Referenced by BOARD_ADAPTER::createLayers(), existsOnLayer(), GENERAL_COLLECTOR::Inspect(), PCB_LAYER_COLLECTOR::Inspect(), 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 1191 of file pcb_shape.cpp.

1192 {
1193  // return true if the polygonal shape is valid (has more than 2 points)
1194  if( GetPolyShape().OutlineCount() == 0 )
1195  return false;
1196 
1197  const SHAPE_LINE_CHAIN& outline = ( (SHAPE_POLY_SET&)GetPolyShape() ).Outline( 0 );
1198 
1199  return outline.PointCount() > 2;
1200 }
SHAPE_POLY_SET & GetPolyShape()
Definition: pcb_shape.h:259
int PointCount() const
Function PointCount()
SHAPE_POLY_SET.
SHAPE_LINE_CHAIN.

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

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

◆ IsReplaceable()

virtual bool EDA_ITEM::IsReplaceable ( ) const
inlinevirtualinherited

Function IsReplaceable.

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

Definition at line 490 of file eda_item.h.

490 { return false; }

Referenced by EDA_ITEM::Matches().

◆ IsResized()

bool EDA_ITEM::IsResized ( ) const
inlineinherited

Definition at line 192 of file eda_item.h.

192 { return m_flags & IS_RESIZED; }
#define IS_RESIZED
Item being resized.
Definition: eda_item.h:107
STATUS_FLAGS m_flags
Definition: eda_item.h:164

References IS_RESIZED, and EDA_ITEM::m_flags.

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

◆ IsSelected()

◆ IsTrack()

bool BOARD_ITEM::IsTrack ( ) const
inlineinherited

Function IsTrack tests to see if this object is a track or via (or microvia).

form of testing.

Returns
bool - true if a track or via, else false.

Definition at line 250 of file board_item.h.

251  {
252  return ( Type() == PCB_TRACE_T ) || ( Type() == PCB_VIA_T );
253  }
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181

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

◆ IsType()

bool PCB_SHAPE::IsType ( const KICAD_T  aScanTypes[]) const
inlineoverridevirtual

Function IsType Checks 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 78 of file pcb_shape.h.

79  {
80  if( BOARD_ITEM::IsType( aScanTypes ) )
81  return true;
82 
83  for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
84  {
85  if( *p == PCB_LOCATE_GRAPHIC_T )
86  return true;
87  else if( *p == PCB_LOCATE_BOARD_EDGE_T )
88  return m_layer == Edge_Cuts;
89  }
90 
91  return false;
92  }
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
virtual bool IsType(const KICAD_T aScanTypes[]) const
Function IsType Checks whether the item is one of the listed types.
Definition: eda_item.h:250
PCB_LAYER_ID m_layer
Definition: board_item.h:89

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

190 { return m_flags & IS_WIRE_IMAGE; }
#define IS_WIRE_IMAGE
Item to be drawn as wireframe while editing.
Definition: eda_item.h:110
STATUS_FLAGS m_flags
Definition: eda_item.h:164

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

IterateForward( EDA_ITEM*, INSPECTOR, void*, const KICAD_T )

IterateForward( EDA_ITEM*, INSPECTOR, void*, const KICAD_T )

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

Definition at line 372 of file eda_item.h.

376  {
377  for( auto it : aList )
378  {
379  if( static_cast<EDA_ITEM*>( it )->Visit( inspector, testData, scanTypes )
381  return SEARCH_RESULT::QUIT;
382  }
383 
385  }
virtual SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
Function Visit may be re-implemented for each derived class in order to handle all the types given by...
Definition: eda_item.cpp:107

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

IterateForward( EDA_ITEM*, INSPECTOR, void*, const KICAD_T )

IterateForward( EDA_ITEM*, INSPECTOR, void*, const KICAD_T )

This changes first parameter to avoid the DList and use std::vector instead

Definition at line 393 of file eda_item.h.

395  {
396  for( auto it : aList )
397  {
398  if( static_cast<EDA_ITEM*>( it )->Visit( inspector, testData, scanTypes )
400  return SEARCH_RESULT::QUIT;
401  }
402 
404  }
virtual SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
Function Visit may be re-implemented for each derived class in order to handle all the types given by...
Definition: eda_item.cpp:107

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 VIA.

Definition at line 72 of file board_item.cpp.

73 {
74  BOARD* board = GetBoard();
75  LSET layers = GetLayerSet();
76 
77  // Try to be smart and useful. Check all copper first.
78  if( layers[F_Cu] && layers[B_Cu] )
79  return _( "all copper layers" );
80 
81  LSET copperLayers = layers & board->GetEnabledLayers().AllCuMask();
82  LSET techLayers = layers & board->GetEnabledLayers().AllTechMask();
83 
84  for( LSET testLayers : { copperLayers, techLayers, layers } )
85  {
86  for( int bit = PCBNEW_LAYER_ID_START; bit < PCB_LAYER_ID_COUNT; ++bit )
87  {
88  if( testLayers[ bit ] )
89  {
90  wxString layerInfo = board->GetLayerName( static_cast<PCB_LAYER_ID>( bit ) );
91 
92  if( testLayers.count() > 1 )
93  layerInfo << wxS( " " ) + _( "and others" );
94 
95  return layerInfo;
96  }
97  }
98  }
99 
100  // No copper, no technicals: no layer
101  return _( "no layers" );
102 }
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:332
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings Returns a bit-mask of all t...
Definition: board.cpp:437
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.
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:46
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:186
#define _(s)
Definition: 3d_actions.cpp:33
virtual LSET GetLayerSet() const
Function GetLayerSet returns a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:191

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 TRACK::GetMsgPanelInfo(), PAD::GetMsgPanelInfo(), and PAD::GetSelectMenuText().

◆ MakeEffectiveShapes()

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

Makes a set of SHAPE objects representing the PCB_SHAPE.

Caller owns the objects.

Definition at line 1053 of file pcb_shape.cpp.

1054 {
1055  std::vector<SHAPE*> effectiveShapes;
1056 
1057  switch( m_shape )
1058  {
1059  case S_ARC:
1060  {
1061  SHAPE_ARC arc( GetCenter(), GetArcStart(), (double) GetAngle() / 10.0 );
1062  SHAPE_LINE_CHAIN l = arc.ConvertToPolyline();
1063 
1064  for( int i = 0; i < l.SegmentCount(); i++ )
1065  {
1066  effectiveShapes.emplace_back( new SHAPE_SEGMENT( l.Segment( i ).A,
1067  l.Segment( i ).B, m_width ) );
1068  }
1069 
1070  break;
1071  }
1072 
1073  case S_SEGMENT:
1074  effectiveShapes.emplace_back( new SHAPE_SEGMENT( GetStart(), GetEnd(), m_width ) );
1075  break;
1076 
1077  case S_RECT:
1078  {
1079  std::vector<wxPoint> pts = GetRectCorners();
1080 
1081  if( IsFilled() )
1082  {
1083  effectiveShapes.emplace_back( new SHAPE_SIMPLE( pts ) );
1084  }
1085 
1086  if( m_width > 0 || !IsFilled() )
1087  {
1088  effectiveShapes.emplace_back( new SHAPE_SEGMENT( pts[0], pts[1], m_width ) );
1089  effectiveShapes.emplace_back( new SHAPE_SEGMENT( pts[1], pts[2], m_width ) );
1090  effectiveShapes.emplace_back( new SHAPE_SEGMENT( pts[2], pts[3], m_width ) );
1091  effectiveShapes.emplace_back( new SHAPE_SEGMENT( pts[3], pts[0], m_width ) );
1092  }
1093  }
1094  break;
1095 
1096  case S_CIRCLE:
1097  {
1098  if( IsFilled() )
1099  {
1100  effectiveShapes.emplace_back( new SHAPE_CIRCLE( GetCenter(), GetRadius() ) );
1101  }
1102 
1103  if( m_width > 0 || !IsFilled() )
1104  {
1105  // SHAPE_CIRCLE has no ConvertToPolyline() method, so use a 360.0 SHAPE_ARC
1106  SHAPE_ARC circle( GetCenter(), GetEnd(), 360.0 );
1107  SHAPE_LINE_CHAIN l = circle.ConvertToPolyline();
1108 
1109  for( int i = 0; i < l.SegmentCount(); i++ )
1110  {
1111  effectiveShapes.emplace_back( new SHAPE_SEGMENT( l.Segment( i ).A,
1112  l.Segment( i ).B, m_width ) );
1113  }
1114  }
1115 
1116  break;
1117  }
1118 
1119  case S_CURVE:
1120  {
1121  auto bezierPoints = buildBezierToSegmentsPointsList( GetWidth() );
1122  wxPoint start_pt = bezierPoints[0];
1123 
1124  for( unsigned int jj = 1; jj < bezierPoints.size(); jj++ )
1125  {
1126  wxPoint end_pt = bezierPoints[jj];
1127  effectiveShapes.emplace_back( new SHAPE_SEGMENT( start_pt, end_pt, m_width ) );
1128  start_pt = end_pt;
1129  }
1130 
1131  break;
1132  }
1133 
1134  case S_POLYGON:
1135  {
1137  FOOTPRINT* parentFootprint = dynamic_cast<FOOTPRINT*>( m_parent );
1138 
1139  if( parentFootprint )
1140  {
1141  l.Rotate( -parentFootprint->GetOrientationRadians() );
1142  l.Move( parentFootprint->GetPosition() );
1143  }
1144 
1145  if( IsFilled() )
1146  {
1147  effectiveShapes.emplace_back( new SHAPE_SIMPLE( l ) );
1148  }
1149 
1150  if( m_width > 0 || !IsFilled() )
1151  {
1152  for( int i = 0; i < l.SegmentCount(); i++ )
1153  effectiveShapes.emplace_back( new SHAPE_SEGMENT( l.Segment( i ), m_width ) );
1154  }
1155  }
1156  break;
1157 
1158  default:
1159  wxFAIL_MSG( "PCB_SHAPE::MakeEffectiveShapes unsupported PCB_SHAPE shape: "
1161  break;
1162  }
1163 
1164  return effectiveShapes;
1165 }
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:162
bool IsFilled() const
Definition: pcb_shape.h:96
SHAPE_SIMPLE.
Definition: shape_simple.h:43
double GetOrientationRadians() const
Definition: footprint.h:206
SHAPE_POLY_SET & GetPolyShape()
Definition: pcb_shape.h:259
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
Definition: pcb_shape.h:155
PCB_SHAPE_TYPE_T m_shape
Definition: pcb_shape.h:52
int GetRadius() const
Function GetRadius returns the radius of this item Has meaning only for arc and circle.
Definition: pcb_shape.h:200
void Move(const VECTOR2I &aVector) override
std::vector< wxPoint > GetRectCorners() const
Definition: pcb_shape.cpp:942
int GetWidth() const
Definition: pcb_shape.h:118
polygon (not yet used for tracks, but could be in microwave apps)
Definition: board_item.h:56
usual segment : line with rounded ends
Definition: board_item.h:52
Arcs (with rounded ends)
Definition: board_item.h:54
segment with non rounded ends
Definition: board_item.h:53
wxPoint GetArcStart() const
Definition: pcb_shape.h:178
static wxString PCB_SHAPE_TYPE_T_asString(PCB_SHAPE_TYPE_T a)
Definition: board_item.h:61
wxPoint GetCenter() const override
Function GetCenter()
Definition: pcb_shape.cpp:343
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
Definition: pcb_shape.h:144
int SegmentCount() const
Function SegmentCount()
void Rotate(double aAngle, const VECTOR2I &aCenter=VECTOR2I(0, 0)) override
Function Rotate rotates all vertices by a given angle.
SEG Segment(int aIndex)
Function Segment()
int m_width
Definition: pcb_shape.h:46
SHAPE_LINE_CHAIN.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
VECTOR2I A
Definition: seg.h:47
double GetAngle() const
Definition: pcb_shape.h:126
wxPoint GetPosition() const override
Definition: footprint.h:200
ring
Definition: board_item.h:55
Bezier Curve.
Definition: board_item.h:57
const std::vector< wxPoint > buildBezierToSegmentsPointsList(int aMinSegLen) const
Definition: pcb_shape.cpp:330
VECTOR2I B
Definition: seg.h:48

References SEG::A, SEG::B, buildBezierToSegmentsPointsList(), 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(), PCB_SHAPE_TYPE_T_asString(), SHAPE_LINE_CHAIN::Rotate(), S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, S_SEGMENT, SHAPE_LINE_CHAIN::Segment(), and SHAPE_LINE_CHAIN::SegmentCount().

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

◆ Matches() [1/2]

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

Function Matches compares 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_COMPONENT, SCH_SHEET, SCH_TEXT, SCH_SHEET_PIN, SCH_FIELD, SCH_PIN, SCH_MARKER, PCB_MARKER, FP_TEXT, and PCB_TEXT.

Definition at line 446 of file eda_item.h.

447  {
448  return false;
449  }

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

◆ Matches() [2/2]

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

Function Matches compares 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 132 of file eda_item.cpp.

133 {
134  wxString text = aText;
135  wxString searchText = aSearchData.GetFindString();
136 
137  // Don't match if searching for replaceable item and the item doesn't support text replace.
138  if( (aSearchData.GetFlags() & FR_SEARCH_REPLACE) && !IsReplaceable() )
139  return false;
140 
141  if( aSearchData.GetFlags() & wxFR_WHOLEWORD )
142  return aText.IsSameAs( searchText, aSearchData.GetFlags() & wxFR_MATCHCASE );
143 
144  if( aSearchData.GetFlags() & FR_MATCH_WILDCARD )
145  {
146  if( aSearchData.GetFlags() & wxFR_MATCHCASE )
147  return text.Matches( searchText );
148 
149  return text.MakeUpper().Matches( searchText.MakeUpper() );
150  }
151 
152  if( aSearchData.GetFlags() & wxFR_MATCHCASE )
153  return aText.Find( searchText ) != wxNOT_FOUND;
154 
155  return text.MakeUpper().Find( searchText.MakeUpper() ) != wxNOT_FOUND;
156 }
virtual bool IsReplaceable() const
Function IsReplaceable.
Definition: eda_item.h:490

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

◆ Move() [1/2]

void BOARD_ITEM::Move ( const VECTOR2I aMoveVector)
inlineinherited

Definition at line 298 of file board_item.h.

299  {
300  Move( wxPoint( aMoveVector.x, aMoveVector.y ) );
301  }
virtual void Move(const wxPoint &aMoveVector)
Function Move move this object.
Definition: board_item.h:292

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

◆ Move() [2/2]

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

Function Move move this object.

Parameters
aMoveVector- the move vector for this object.

Reimplemented from BOARD_ITEM.

Reimplemented in FP_SHAPE.

Definition at line 112 of file pcb_shape.cpp.

113 {
114  // Move vector should not affect start/end for polygon since it will
115  // be applied directly to polygon outline.
116  if( m_shape != S_POLYGON )
117  {
118  m_start += aMoveVector;
119  m_end += aMoveVector;
120  }
121 
122  switch ( m_shape )
123  {
124  case S_POLYGON:
125  m_poly.Move( VECTOR2I( aMoveVector ) );
126  break;
127 
128  case S_ARC:
129  m_thirdPoint += aMoveVector;
130  break;
131 
132  case S_CURVE:
133  m_bezierC1 += aMoveVector;
134  m_bezierC2 += aMoveVector;
135 
136  for( wxPoint& pt : m_bezierPoints)
137  pt += aMoveVector;
138 
139  break;
140 
141  default:
142  break;
143  }
144 }
wxPoint m_end
Definition: pcb_shape.h:49
PCB_SHAPE_TYPE_T m_shape
Definition: pcb_shape.h:52
polygon (not yet used for tracks, but could be in microwave apps)
Definition: board_item.h:56
Arcs (with rounded ends)
Definition: board_item.h:54
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
wxPoint m_thirdPoint
Definition: pcb_shape.h:50
void Move(const VECTOR2I &aVector) override
SHAPE_POLY_SET m_poly
Definition: pcb_shape.h:58
wxPoint m_start
Definition: pcb_shape.h:48
wxPoint m_bezierC1
Definition: pcb_shape.h:54
std::vector< wxPoint > m_bezierPoints
Definition: pcb_shape.h:57
wxPoint m_bezierC2
Definition: pcb_shape.h:55
Bezier Curve.
Definition: board_item.h:57

References m_bezierC1, m_bezierC2, m_bezierPoints, m_end, m_poly, m_shape, m_start, m_thirdPoint, SHAPE_POLY_SET::Move(), S_ARC, S_CURVE, and S_POLYGON.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::getDrawSegmentFromVertex(), CADSTAR_PCB_ARCHIVE_LOADER::getKiCadPad(), PAD_TOOL::recombinePad(), DIALOG_PAD_PROPERTIES::redraw(), and 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 185 of file eda_item.cpp.

186 {
187  wxFAIL_MSG( wxString::Format( wxT( "Less than operator not defined for item type %s." ),
188  GetClass() ) );
189 
190  return false;
191 }
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
virtual wxString GetClass() const =0
Function GetClass returns 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 shape. the last segment can be shorter This param avoid having too many very short segment in list. a good value is m_Width/2 to m_Width

Definition at line 317 of file pcb_shape.cpp.

318 {
319  // Has meaning only for S_CURVE DRAW_SEGMENT shape
320  if( m_shape != S_CURVE )
321  {
322  m_bezierPoints.clear();
323  return;
324  }
325  // Rebuild the m_BezierPoints vertex list that approximate the Bezier curve
327 }
PCB_SHAPE_TYPE_T m_shape
Definition: pcb_shape.h:52
std::vector< wxPoint > m_bezierPoints
Definition: pcb_shape.h:57
Bezier Curve.
Definition: board_item.h:57
const std::vector< wxPoint > buildBezierToSegmentsPointsList(int aMinSegLen) const
Definition: pcb_shape.cpp:330

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

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

◆ Replace() [1/2]

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

Helper function used in search and replace dialog Function Replace performs 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 159 of file eda_item.cpp.

160 {
161  wxString searchString = (aSearchData.GetFlags() & wxFR_MATCHCASE) ? aText : aText.Upper();
162 
163  int result = searchString.Find( (aSearchData.GetFlags() & wxFR_MATCHCASE) ?
164  aSearchData.GetFindString() :
165  aSearchData.GetFindString().Upper() );
166 
167  if( result == wxNOT_FOUND )
168  return false;
169 
170  wxString prefix = aText.Left( result );
171  wxString suffix;
172 
173  if( aSearchData.GetFindString().length() + result < aText.length() )
174  suffix = aText.Right( aText.length() - ( aSearchData.GetFindString().length() + result ) );
175 
176  wxLogTrace( traceFindReplace, wxT( "Replacing '%s', prefix '%s', replace '%s', suffix '%s'." ),
177  aText, prefix, aSearchData.GetReplaceString(), suffix );
178 
179  aText = prefix + aSearchData.GetReplaceString() + suffix;
180 
181  return true;
182 }
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 ( wxFindReplaceData &  aSearchData,
void *  aAuxData = NULL 
)
inlinevirtualinherited

Function Replace performs 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_SHEET_PIN, SCH_FIELD, and SCH_PIN.

Definition at line 478 of file eda_item.h.

478 { return false; }

◆ Rotate() [1/2]

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

Function Rotate Rotate this object.

Parameters
aRotCentre- the rotation point.
aAngle- the rotation angle in 0.1 degree.

Reimplemented from BOARD_ITEM.

Reimplemented in FP_SHAPE.

Definition at line 197 of file pcb_shape.cpp.

198 {
199  switch( m_shape )
200  {
201  case S_ARC:
202  case S_SEGMENT:
203  case S_CIRCLE:
204  // these can all be done by just rotating the constituent points
205  RotatePoint( &m_start, aRotCentre, aAngle );
206  RotatePoint( &m_end, aRotCentre, aAngle );
207  RotatePoint( &m_thirdPoint, aRotCentre, aAngle );
208  break;
209 
210  case S_RECT:
211  if( KiROUND( aAngle ) % 900 == 0 )
212  {
213  RotatePoint( &m_start, aRotCentre, aAngle );
214  RotatePoint( &m_end, aRotCentre, aAngle );
215  break;
216  }
217 
218  // Convert non-cartesian-rotated rect to a diamond
219  m_shape = S_POLYGON;
221  m_poly.NewOutline();
222  m_poly.Append( m_start );
223  m_poly.Append( m_end.x, m_start.y );
224  m_poly.Append( m_end );
225  m_poly.Append( m_start.x, m_end.y );
226 
228 
229  case S_POLYGON:
230  m_poly.Rotate( -DECIDEG2RAD( aAngle ), VECTOR2I( aRotCentre ) );
231  break;
232 
233  case S_CURVE:
234  RotatePoint( &m_start, aRotCentre, aAngle);
235  RotatePoint( &m_end, aRotCentre, aAngle);
236  RotatePoint( &m_bezierC1, aRotCentre, aAngle);
237  RotatePoint( &m_bezierC2, aRotCentre, aAngle);
238 
239  for( wxPoint& pt : m_bezierPoints )
240  RotatePoint( &pt, aRotCentre, aAngle);
241 
242  break;
243 
244  default:
245  wxFAIL_MSG( "PCB_SHAPE::Rotate not implemented for "
247  break;
248  }
249 }
wxPoint m_end
Definition: pcb_shape.h:49
PCB_SHAPE_TYPE_T m_shape
Definition: pcb_shape.h:52
polygon (not yet used for tracks, but could be in microwave apps)
Definition: board_item.h:56
usual segment : line with rounded ends
Definition: board_item.h:52
Arcs (with rounded ends)
Definition: board_item.h:54
#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
Function Rotate rotates all vertices by a given angle.
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
segment with non rounded ends
Definition: board_item.h:53
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
wxPoint m_thirdPoint
Definition: pcb_shape.h:50
SHAPE_POLY_SET m_poly
Definition: pcb_shape.h:58
static wxString PCB_SHAPE_TYPE_T_asString(PCB_SHAPE_TYPE_T a)
Definition: board_item.h:61
int NewOutline()
Creates a new empty polygon in the set and returns its index
wxPoint m_start
Definition: pcb_shape.h:48
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.
double DECIDEG2RAD(double deg)
Definition: trigo.h:221
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:68
ring
Definition: board_item.h:55
wxPoint m_bezierC1
Definition: pcb_shape.h:54
std::vector< wxPoint > m_bezierPoints
Definition: pcb_shape.h:57
wxPoint m_bezierC2
Definition: pcb_shape.h:55
Bezier Curve.
Definition: board_item.h:57
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)

References SHAPE_POLY_SET::Append(), DECIDEG2RAD(), KI_FALLTHROUGH, KiROUND(), m_bezierC1, m_bezierC2, m_bezierPoints, m_end, m_poly, m_shape, m_start, m_thirdPoint, SHAPE_POLY_SET::NewOutline(), PCB_SHAPE_TYPE_T_asString(), SHAPE_POLY_SET::RemoveAllContours(), SHAPE_POLY_SET::Rotate(), RotatePoint(), S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, and S_SEGMENT.

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

◆ Rotate() [2/2]

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

Definition at line 314 of file board_item.h.

315  {
316  Rotate( wxPoint( aRotCentre.x, aRotCentre.y ), aAngle );
317  }
virtual void Rotate(const wxPoint &aRotCentre, double aAngle)
Function Rotate Rotate this object.
Definition: board_item.h:309

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

◆ Scale()

void PCB_SHAPE::Scale ( double  aScale)

Definition at line 147 of file pcb_shape.cpp.

148 {
149  auto scalePt = [&]( wxPoint& pt )
150  {
151  pt.x = KiROUND( pt.x * aScale );
152  pt.y = KiROUND( pt.y * aScale );
153  };
154 
155  int radius = GetRadius();
156 
157  scalePt( m_start );
158  scalePt( m_end );
159 
160  // specific parameters:
161  switch( m_shape )
162  {
163  case S_CURVE:
164  scalePt( m_bezierC1 );
165  scalePt( m_bezierC2 );
166  break;
167 
168  case S_ARC:
169  scalePt( m_thirdPoint );
170  break;
171 
172  case S_CIRCLE: // ring or circle
173  m_end.x = m_start.x + KiROUND( radius * aScale );
174  m_end.y = m_start.y;
175  break;
176 
177  case S_POLYGON: // polygon
178  {
179  std::vector<wxPoint> pts;
180 
181  for( const VECTOR2I& pt : m_poly.Outline( 0 ).CPoints() )
182  {
183  pts.emplace_back( pt );
184  scalePt( pts.back() );
185  }
186 
187  SetPolyPoints( pts );
188  }
189  break;
190 
191  default:
192  break;
193  }
194 }
wxPoint m_end
Definition: pcb_shape.h:49
PCB_SHAPE_TYPE_T m_shape
Definition: pcb_shape.h:52
int GetRadius() const
Function GetRadius returns the radius of this item Has meaning only for arc and circle.
Definition: pcb_shape.h:200
polygon (not yet used for tracks, but could be in microwave apps)
Definition: board_item.h:56
Arcs (with rounded ends)
Definition: board_item.h:54
wxPoint m_thirdPoint
Definition: pcb_shape.h:50
const std::vector< VECTOR2I > & CPoints() const
SHAPE_POLY_SET m_poly
Definition: pcb_shape.h:58
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
wxPoint m_start
Definition: pcb_shape.h:48
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:68
ring
Definition: board_item.h:55
wxPoint m_bezierC1
Definition: pcb_shape.h:54
wxPoint m_bezierC2
Definition: pcb_shape.h:55
Bezier Curve.
Definition: board_item.h:57
void SetPolyPoints(const std::vector< wxPoint > &aPoints)
Definition: pcb_shape.cpp:1043

References SHAPE_LINE_CHAIN::CPoints(), GetRadius(), KiROUND(), m_bezierC1, m_bezierC2, m_end, m_poly, m_shape, m_start, m_thirdPoint, SHAPE_POLY_SET::Outline(), S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, and SetPolyPoints().

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::getDrawSegmentFromVertex().

◆ Set() [1/3]

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

Definition at line 40 of file inspectable.h.

41  {
43  TYPE_ID thisType = TYPE_HASH( *this );
44  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
45 
46  if( object )
47  aProperty->setter( object, aValue );
48 
49  return object != nullptr;
50  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:64
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:55
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:41
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
virtual void setter(void *aObject, wxAny &aValue)=0
Provides class metadata.
Definition: property_mgr.h:61
virtual size_t OwnerHash() const =0
Returns 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 53 of file inspectable.h.

54  {
56  TYPE_ID thisType = TYPE_HASH( *this );
57  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
58 
59  if( object )
60  aProperty->set<T>( object, aValue );
61 
62  return object != nullptr;
63  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:64
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:55
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:41
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
Provides class metadata.
Definition: property_mgr.h:61
void set(void *aObject, T aValue)
Definition: property.h:268
virtual size_t OwnerHash() const =0
Returns 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 66 of file inspectable.h.

67  {
69  TYPE_ID thisType = TYPE_HASH( *this );
70  PROPERTY_BASE* prop = propMgr.GetProperty( thisType, aProperty );
71  void* object = nullptr;
72 
73  if( prop )
74  {
75  object = propMgr.TypeCast( this, thisType, prop->OwnerHash() );
76 
77  if( object )
78  prop->set<T>( object, aValue );
79  }
80 
81  return object != nullptr;
82  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:64
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:55
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:41
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Returns a property for a specific type.
Provides class metadata.
Definition: property_mgr.h:61
void set(void *aObject, T aValue)
Definition: property.h:268
virtual size_t OwnerHash() const =0
Returns 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

Function SetAngle sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.

Parameters
aAngleis tenths of degrees, but will soon be degrees.

Reimplemented in FP_SHAPE.

Definition at line 444 of file pcb_shape.cpp.

445 {
446  // m_Angle must be >= -360 and <= +360 degrees
447  m_angle = NormalizeAngle360Max( aAngle );
448 
449  if( aUpdateEnd )
450  {
453  }
454 }
wxPoint m_end
Definition: pcb_shape.h:49
T NormalizeAngle360Max(T Angle)
Normalize angle to be >=-360.0 and <= 360.0 Angle can be equal to -360 or +360.
Definition: trigo.h:229
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
wxPoint m_thirdPoint
Definition: pcb_shape.h:50
double m_angle
Definition: pcb_shape.h:53
wxPoint m_start
Definition: pcb_shape.h:48

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

Referenced by PAD::AddPrimitiveArc(), PCAD2KICAD::PCB_ARC::AddToBoard(), DRAWING_TOOL::drawArc(), POINT_EDITOR::editArcEndpointKeepCenter(), POINT_EDITOR::editArcEndpointKeepTangent(), POINT_EDITOR::editArcMidKeepEnpoints(), CADSTAR_PCB_ARCHIVE_LOADER::getDrawSegmentFromVertex(), ALTIUM_PCB::HelperCreateBoardOutline(), EAGLE_PLUGIN::loadPlain(), ALTIUM_PCB::ParseArcs6Data(), PAD_TOOL::recombinePad(), CONVERT_TOOL::SegmentToArc(), 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 221 of file pcb_shape.h.

222  {
223  m_thirdPoint = aArcEndPoint;
224  }
wxPoint m_thirdPoint
Definition: pcb_shape.h:50

References m_thirdPoint.

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

◆ SetArcStart()

void PCB_SHAPE::SetArcStart ( const wxPoint &  aArcStartPoint)
inline

◆ SetBezControl1()

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

◆ SetBezControl2()

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

◆ SetBezierPoints()

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

Definition at line 269 of file pcb_shape.h.

270  {
271  m_bezierPoints = aPoints;
272  }
std::vector< wxPoint > m_bezierPoints
Definition: pcb_shape.h:57

References m_bezierPoints.

◆ SetBrightened()

void EDA_ITEM::SetBrightened ( )
inlineinherited

◆ SetCenter()

◆ SetEnd()

◆ SetEndX()

void PCB_SHAPE::SetEndX ( int  x)
inline

◆ SetEndY()

void PCB_SHAPE::SetEndY ( int  y)
inline

◆ SetFilled()

◆ SetFlags()

void EDA_ITEM::SetFlags ( STATUS_FLAGS  aMask)
inlineinherited

Definition at line 220 of file eda_item.h.

220 { m_flags |= aMask; }
STATUS_FLAGS m_flags
Definition: eda_item.h:164

References EDA_ITEM::m_flags.

Referenced by SCH_EAGLE_PLUGIN::addBusEntries(), PCB_BASE_FRAME::AddFootprintToBoard(), SCH_MOVE_TOOL::AlignElements(), PCBNEW_CONTROL::AppendBoard(), FOOTPRINT::BuildPolyCourtyards(), SCH_EDIT_TOOL::ChangeTextType(), TRACKS_CLEANER::cleanup(), GRAPHICS_CLEANER::cleanupSegments(), ConvertOutlineToPolygon(), SCH_EDIT_FRAME::ConvertPart(), SCH_DRAWING_TOOLS::createNewText(), LIB_PIN_TOOL::CreatePin(), SCH_DRAWING_TOOLS::createSheetPin(), SCH_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), KIGFX::SCH_PAINTER::draw(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), SCH_EDIT_TOOL::Duplicate(), SCH_MOVE_TOOL::getConnectedDragItems(), SYMBOL_EDIT_FRAME::GetSymbolFromRedoList(), SYMBOL_EDIT_FRAME::GetSymbolFromUndoList(), EE_SELECTION_TOOL::Main(), TRACKS_CLEANER::mergeCollinearSegments(), LIB_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(), LIB_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), DRAWING_TOOL::PlaceText(), BACK_ANNOTATE::processNetNameChange(), SCH_EDIT_FRAME::PutDataInPreviousState(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_PIN_TOOL::RepeatPin(), 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(), WS_DATA_ITEM::SyncDrawItems(), WS_DATA_ITEM_TEXT::SyncDrawItems(), WS_DATA_ITEM_BITMAP::SyncDrawItems(), DIALOG_DIMENSION_PROPERTIES::TransferDataFromWindow(), DIALOG_TARGET_PROPERTIES::TransferDataFromWindow(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), LIB_DRAWING_TOOLS::TwoClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ SetForceVisible()

void EDA_ITEM::SetForceVisible ( bool  aEnable)
inlineinherited

Function SetForceVisible is used to set and cleag 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 272 of file eda_item.h.

272 { m_forceVisible = aEnable; }
bool m_forceVisible
Definition: eda_item.h:163

References EDA_ITEM::m_forceVisible.

Referenced by SCH_EDITOR_CONTROL::UpdateFind().

◆ SetLayer()

virtual void BOARD_ITEM::SetLayer ( PCB_LAYER_ID  aLayer)
inlinevirtualinherited

Function SetLayer sets the layer this item is on.

Parameters
aLayerThe layer number. is virtual because some items (in fact: class DIMENSION) have a slightly different initialization

Reimplemented in DIMENSION_BASE, ZONE, and PCB_GROUP.

Definition at line 206 of file board_item.h.

207  {
208  m_layer = aLayer;
209  }
PCB_LAYER_ID m_layer
Definition: board_item.h:89

References BOARD_ITEM::m_layer.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::addAttribute(), PNS_KICAD_IFACE::AddItem(), PCAD2KICAD::PCB_LINE::AddToBoard(), PCAD2KICAD::PCB_ARC::AddToBoard(), PCAD2KICAD::PCB_PAD::AddToBoard(), PCAD2KICAD::PCB_FOOTPRINT::AddToBoard(), PCAD2KICAD::PCB_LINE::AddToFootprint(), PCAD2KICAD::PCB_ARC::AddToFootprint(), PCAD2KICAD::PCB_POLYGON::AddToFootprint(), BOARD_CONNECTED_ITEM_DESC::BOARD_CONNECTED_ITEM_DESC(), BOARD_ITEM_DESC::BOARD_ITEM_DESC(), BOOST_AUTO_TEST_CASE(), MICROWAVE_TOOL::createMicrowaveInductor(), PCB_BASE_FRAME::CreateNewFootprint(), MICROWAVE_TOOL::createPolygonShape(), DRAWING_TOOL::drawArc(), CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarShape(), CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText(), PAD_TOOL::explodePad(), EDIT_TOOL::FilletTracks(), PCB_TARGET::Flip(), PCB_TEXT::Flip(), FP_SHAPE::Flip(), TRACK::Flip(), FP_TEXT::Flip(), FOOTPRINT::Flip(), ARC::Flip(), Flip(), FOOTPRINT_DESC::FOOTPRINT_DESC(), FP_TEXT::FP_TEXT(), ALTIUM_PCB::HelperCreateBoardOutline(), ALTIUM_PCB::HelperParseDimensions6Datum(), ALTIUM_PCB::HelperParseDimensions6Leader(), ALTIUM_PCB::HelperParsePad6NonCopper(), CONVERT_TOOL::LinesToPoly(), LEGACY_PLUGIN::loadFOOTPRINT(), LEGACY_PLUGIN::loadMODULE_TEXT(), CADSTAR_PCB_ARCHIVE_LOADER::loadNetTracks(), LEGACY_PLUGIN::loadPCB_TEXT(), EAGLE_PLUGIN::loadPlain(), EAGLE_PLUGIN::loadSignals(), LEGACY_PLUGIN::loadTrackList(), main(), DSN::SPECCTRA_DB::makeTRACK(), CADSTAR_PCB_ARCHIVE_LOADER::makeTracksFromDrawsegments(), GRAPHICS_CLEANER::mergeRects(), DIALOG_FOOTPRINT_FP_EDITOR::OnAddField(), DIALOG_FOOTPRINT_PROPERTIES::OnAddField(), EAGLE_PLUGIN::packageCircle(), EAGLE_PLUGIN::packagePolygon(), EAGLE_PLUGIN::packageRectangle(), EAGLE_PLUGIN::packageSMD(), EAGLE_PLUGIN::packageText(), EAGLE_PLUGIN::packageWire(), ALTIUM_PCB::ParseArcs6Data(), ALTIUM_PCB::ParseComponents6Data(), ALTIUM_PCB::ParseFills6Data(), GPCB_FPL_CACHE::parseFOOTPRINT(), ALTIUM_PCB::ParsePads6Data(), ALTIUM_PCB::ParseShapeBasedRegions6Data(), ALTIUM_PCB::ParseTexts6Data(), ALTIUM_PCB::ParseTracks6Data(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), BRDITEMS_PLOTTER::PlotDimension(), BRDITEMS_PLOTTER::PlotPcbTarget(), CONVERT_TOOL::PolyToLines(), 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(), DIMENSION_BASE::SetLayer(), TEXT_MOD_GRID_TABLE::SetValueAsLong(), GLOBAL_EDIT_TOOL::swapBoardItem(), TRACK_VIA_DESC::TRACK_VIA_DESC(), DIALOG_TRACK_VIA_PROPERTIES::TransferDataFromWindow(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow(), and DIALOG_TEXT_PROPERTIES::TransferDataFromWindow().

◆ SetLayerSet()

virtual void BOARD_ITEM::SetLayerSet ( LSET  aLayers)
inlinevirtualinherited

Reimplemented in VIA, PAD, and ZONE.

Definition at line 192 of file board_item.h.

193  {
194  wxFAIL_MSG( "Attempted to SetLayerSet() on a single-layer object." );
195 
196  // Derived classes which support multiple layers must implement this
197  }

Referenced by PANEL_SETUP_LAYERS::TransferDataFromWindow().

◆ SetLocked()

virtual void BOARD_ITEM::SetLocked ( bool  aLocked)
inlinevirtualinherited

Function SetLocked modifies 'lock' status for of the item.

Reimplemented in FOOTPRINT, and TRACK.

Definition at line 269 of file board_item.h.

270  {
271  // only footprints & TRACKs can be locked at this time.
272  }

Referenced by BOARD_ITEM_DESC::BOARD_ITEM_DESC(), CADSTAR_PCB_ARCHIVE_LOADER::loadGroups(), PCB_EDITOR_CONTROL::modifyLockSelected(), ALTIUM_PCB::ParsePads6Data(), ALTIUM_PCB::ParsePolygons6Data(), and CLIPBOARD_IO::SaveSelection().

◆ SetModified()

void EDA_ITEM::SetModified ( )
inherited

Definition at line 79 of file eda_item.cpp.

80 {
82 
83  // If this a child object, then the parent modification state also needs to be set.
84  if( m_parent )
86 }
void SetModified()
Definition: eda_item.cpp:79
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:162
#define IS_CHANGED
std::function passed to nested users by ref, avoids copying std::function
Definition: eda_item.h:102
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:220

References IS_CHANGED, EDA_ITEM::m_parent, EDA_ITEM::SetFlags(), and EDA_ITEM::SetModified().

Referenced by LIB_PIN_TOOL::EditPinProperties(), LEGACY_PLUGIN::loadZONE_CONTAINER(), SCH_LINE::Move(), SCH_COMPONENT::Move(), SCH_LINE::MoveEnd(), SCH_LINE::MoveStart(), LIB_PIN::MoveTo(), PCB_EDIT_FRAME::OpenProjectFiles(), SCH_ALTIUM_PLUGIN::Parse(), ALTIUM_PCB::Parse(), LIB_PART::RemoveDrawItem(), SCH_COMPONENT::SetConvert(), SCH_COMPONENT::SetLibId(), EDA_ITEM::SetModified(), LIB_FIELD::SetName(), SCH_COMPONENT::SetTransform(), and SCH_COMPONENT::SetUnit().

◆ SetParent()

virtual void EDA_ITEM::SetParent ( EDA_ITEM aParent)
inlinevirtualinherited

Reimplemented in DIMENSION_BASE.

Definition at line 184 of file eda_item.h.

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

References EDA_ITEM::m_parent.

Referenced by FOOTPRINT::Add(), BOARD::Add(), FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), BOARD_NETLIST_UPDATER::addNewComponent(), SCH_SHEET::AddPin(), LIB_CONTROL::AddSymbolToSchematic(), SCH_SCREEN::Append(), LIB_FIELD::Copy(), SYMBOL_EDIT_FRAME::CreateNewPart(), SCH_DRAWING_TOOLS::createNewText(), DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), SCH_EDIT_TOOL::Duplicate(), PCB_EDIT_FRAME::ExchangeFootprint(), LIB_PART::Flatten(), FOOTPRINT::FOOTPRINT(), PCB_IO::FootprintSave(), DISPLAY_FOOTPRINTS_FRAME::GetFootprint(), LIB_PART::LIB_PART(), SCH_LEGACY_PLUGIN_CACHE::loadAliases(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard(), SCH_SEXPR_PLUGIN::loadHierarchy(), SCH_LEGACY_PLUGIN::loadHierarchy(), SYMBOL_EDIT_FRAME::LoadOneSymbol(), FOOTPRINT::operator=(), LIB_PART::operator=(), PCB_PARSER::parseFOOTPRINT_unchecked(), SCH_SEXPR_PARSER::ParseSchematic(), SCH_SEXPR_PARSER::ParseSymbol(), LIB_EDIT_TOOL::Paste(), PCBNEW_CONTROL::Paste(), SCH_EDITOR_CONTROL::Paste(), pasteFootprintItemsToFootprintEditor(), SCH_DRAWING_TOOLS::PlaceComponent(), PCB_EDITOR_CONTROL::PlaceModule(), 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_PART::SetFields(), DIMENSION_BASE::SetParent(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_LINE_WIRE_BUS_TOOL::startSegments(), SCH_GLOBALLABEL::SwapData(), SCH_SHEET::SwapData(), SCH_COMPONENT::SwapData(), and SwapItemData().

◆ SetParentGroup()

void BOARD_ITEM::SetParentGroup ( PCB_GROUP aGroup)
inlineinherited

Definition at line 100 of file board_item.h.

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

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 1043 of file pcb_shape.cpp.

1044 {
1046  m_poly.NewOutline();
1047 
1048  for ( const wxPoint& p : aPoints )
1049  m_poly.Append( p.x, p.y );
1050 }
SHAPE_POLY_SET m_poly
Definition: pcb_shape.h:58
int NewOutline()
Creates a new empty polygon in the set and returns its index
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)

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

void PCB_SHAPE::SetPolyShape ( const SHAPE_POLY_SET aShape)
inline

◆ SetPosition()

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

Reimplemented from EDA_ITEM.

Definition at line 61 of file pcb_shape.cpp.

62 {
63  m_start = aPos;
64 }
wxPoint m_start
Definition: pcb_shape.h:48

References m_start.

◆ SetSelected()

◆ SetShape()

◆ SetStart()

◆ SetStartX()

void PCB_SHAPE::SetStartX ( int  x)
inline

Definition at line 149 of file pcb_shape.h.

149 { m_start.x = x; }
wxPoint m_start
Definition: pcb_shape.h:48

References m_start.

Referenced by DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow(), and POINT_EDITOR::updateItem().

◆ SetStartY()

void PCB_SHAPE::SetStartY ( int  y)
inline

Definition at line 148 of file pcb_shape.h.

148 { m_start.y = y; }
wxPoint m_start
Definition: pcb_shape.h:48

References m_start.

Referenced by DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow(), and POINT_EDITOR::updateItem().

◆ SetState()

void EDA_ITEM::SetState ( int  type,
int  state 
)
inlineinherited

Definition at line 209 of file eda_item.h.

210  {
211  if( state )
212  m_status |= type; // state = ON or OFF
213  else
214  m_status &= ~type;
215  }
STATUS_FLAGS m_status
Definition: eda_item.h:161

References EDA_ITEM::m_status.

Referenced by LEGACY_PLUGIN::loadTrackList(), TRACKS_CLEANER::mergeCollinearSegments(), SELECTION_TOOL::selectConnectedTracks(), and TRACK::SetLocked().

◆ SetStatus()

void EDA_ITEM::SetStatus ( STATUS_FLAGS  aStatus)
inlineinherited

Definition at line 218 of file eda_item.h.

218 { m_status = aStatus; }
STATUS_FLAGS m_status
Definition: eda_item.h:161

References EDA_ITEM::m_status.

Referenced by BOARD_NETLIST_UPDATER::UpdateNetlist().

◆ SetThirdPoint()

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

Definition at line 169 of file pcb_shape.h.

169 { m_thirdPoint = aPoint; }
wxPoint m_thirdPoint
Definition: pcb_shape.h:50

References m_thirdPoint.

◆ SetThirdPointX()

void PCB_SHAPE::SetThirdPointX ( int  x)
inline

Definition at line 171 of file pcb_shape.h.

171 { m_thirdPoint.x = x; }
wxPoint m_thirdPoint
Definition: pcb_shape.h:50

References m_thirdPoint.

◆ SetThirdPointY()

void PCB_SHAPE::SetThirdPointY ( int  y)
inline

Definition at line 170 of file pcb_shape.h.

170 { m_thirdPoint.y = y; }
wxPoint m_thirdPoint
Definition: pcb_shape.h:50

References m_thirdPoint.

◆ SetWidth()

void PCB_SHAPE::SetWidth ( int  aWidth)
inline

Definition at line 117 of file pcb_shape.h.

117 { m_width = aWidth; }
int m_width
Definition: pcb_shape.h:46

References m_width.

Referenced by PAD::AddPrimitiveArc(), PAD::AddPrimitiveCircle(), PAD::AddPrimitiveCurve(), PAD::AddPrimitivePoly(), PAD::AddPrimitiveRect(), PAD::AddPrimitiveSegment(), PCAD2KICAD::PCB_LINE::AddToBoard(), PCAD2KICAD::PCB_ARC::AddToBoard(), PCAD2KICAD::PCB_ARC::AddToFootprint(), PCAD2KICAD::PCB_LINE::AddToFootprint(), PCAD2KICAD::PCB_POLYGON::AddToFootprint(), MICROWAVE_TOOL::createMicrowaveInductor(), MICROWAVE_TOOL::createPolygonShape(), 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(), CADSTAR_PCB_ARCHIVE_LOADER::loadNetTracks(), EAGLE_PLUGIN::loadPlain(), 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 195 of file eda_item.h.

195 { SetFlags( IS_WIRE_IMAGE ); }
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:220
#define IS_WIRE_IMAGE
Item to be drawn as wireframe while editing.
Definition: eda_item.h:110

References IS_WIRE_IMAGE, and EDA_ITEM::SetFlags().

◆ SetX()

void BOARD_ITEM::SetX ( int  aX)
inlineinherited

Definition at line 129 of file board_item.h.

130  {
131  wxPoint p( aX, GetY() );
132  SetPosition( p );
133  }
virtual void SetPosition(const wxPoint &aPos)
Definition: eda_item.h:326
int GetY() const
Definition: board_item.h:111

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 135 of file board_item.h.

136  {
137  wxPoint p( GetX(), aY );
138  SetPosition( p );
139  }
virtual void SetPosition(const wxPoint &aPos)
Definition: eda_item.h:326
int GetX() const
Definition: board_item.h:105

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 ( PCB_SHAPE_TYPE_T  aShape)
staticinherited

Function ShowShape converts the enum PCB_SHAPE_TYPE_T integer value to a wxString.

Definition at line 31 of file board_item.cpp.

32 {
33  switch( aShape )
34  {
35  case S_SEGMENT: return _( "Line" );
36  case S_RECT: return _( "Rect" );
37  case S_ARC: return _( "Arc" );
38  case S_CIRCLE: return _( "Circle" );
39  case S_CURVE: return _( "Bezier Curve" );
40  case S_POLYGON: return _( "Polygon" );
41  default: return wxT( "??" );
42  }
43 }
polygon (not yet used for tracks, but could be in microwave apps)
Definition: board_item.h:56
usual segment : line with rounded ends
Definition: board_item.h:52
Arcs (with rounded ends)
Definition: board_item.h:54
segment with non rounded ends
Definition: board_item.h:53
#define _(s)
Definition: 3d_actions.cpp:33
ring
Definition: board_item.h:55
Bezier Curve.
Definition: board_item.h:57

References _, S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, and S_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

Function Sort is a 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 509 of file eda_item.h.

509 { 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 redo command to swap values between an item and its copy Only values like layer, size .. which are modified by editing are swapped

Parameters
aImage= the item image which contains data to swap

Reimplemented from BOARD_ITEM.

Definition at line 1214 of file pcb_shape.cpp.

1215 {
1216  PCB_SHAPE* image = dynamic_cast<PCB_SHAPE*>( aImage );
1217  assert( image );
1218 
1219  std::swap( m_width, image->m_width );
1220  std::swap( m_start, image->m_start );
1221  std::swap( m_end, image->m_end );
1222  std::swap( m_thirdPoint, image->m_thirdPoint );
1223  std::swap( m_shape, image->m_shape );
1224  std::swap( m_angle, image->m_angle );
1225  std::swap( m_bezierC1, image->m_bezierC1 );
1226  std::swap( m_bezierC2, image->m_bezierC2 );
1227  std::swap( m_bezierPoints, image->m_bezierPoints );
1228  std::swap( m_poly, image->m_poly );
1229  std::swap( m_layer, image->m_layer );
1230  std::swap( m_flags, image->m_flags );
1231  std::swap( m_status, image->m_status );
1232  std::swap( m_parent, image->m_parent );
1233  std::swap( m_forceVisible, image->m_forceVisible );
1234 }
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:162
wxPoint m_end
Definition: pcb_shape.h:49
PCB_SHAPE_TYPE_T m_shape
Definition: pcb_shape.h:52
STATUS_FLAGS m_status
Definition: eda_item.h:161
wxPoint m_thirdPoint
Definition: pcb_shape.h:50
SHAPE_POLY_SET m_poly
Definition: pcb_shape.h:58
double m_angle
Definition: pcb_shape.h:53
wxPoint m_start
Definition: pcb_shape.h:48
int m_width
Definition: pcb_shape.h:46
PCB_LAYER_ID m_layer
Definition: board_item.h:89
wxPoint m_bezierC1
Definition: pcb_shape.h:54
std::vector< wxPoint > m_bezierPoints
Definition: pcb_shape.h:57
STATUS_FLAGS m_flags
Definition: eda_item.h:164
bool m_forceVisible
Definition: eda_item.h:163
wxPoint m_bezierC2
Definition: pcb_shape.h:55

References 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

Function TransformShapeWithClearanceToPolygon Convert the draw segment to a closed polygon Used in filling zones calculations Circles and arcs are approximated by segments.

Parameters
aCornerBuffer= a buffer to store the polygon
aClearanceValue= the clearance around the pad
aError= the maximum deviation from a true arc
ignoreLineWidth= used for edge cut items where the line width is only for visualization

Reimplemented from BOARD_ITEM.

Definition at line 435 of file board_items_to_polygon_shape_transform.cpp.

439 {
440  int width = ignoreLineWidth ? 0 : m_width;
441 
442  width += 2 * aClearanceValue;
443 
444  switch( m_shape )
445  {
446  case S_CIRCLE:
447  if( IsFilled() )
448  {
449  TransformCircleToPolygon( aCornerBuffer, GetCenter(), GetRadius() + width / 2, aError,
450  aErrorLoc );
451  }
452  else
453  {
454  TransformRingToPolygon( aCornerBuffer, GetCenter(), GetRadius(), width, aError,
455  aErrorLoc );
456  }
457  break;
458 
459  case S_RECT:
460  {
461  std::vector<wxPoint> pts = GetRectCorners();
462 
463  if( IsFilled() )
464  {
465  aCornerBuffer.NewOutline();
466 
467  for( const wxPoint& pt : pts )
468  aCornerBuffer.Append( pt );
469  }
470 
471  if( width > 0 || !IsFilled() )
472  {
473  // Add in segments
474  TransformOvalToPolygon( aCornerBuffer, pts[0], pts[1], width, aError, aErrorLoc );
475  TransformOvalToPolygon( aCornerBuffer, pts[1], pts[2], width, aError, aErrorLoc );
476  TransformOvalToPolygon( aCornerBuffer, pts[2], pts[3], width, aError, aErrorLoc );
477  TransformOvalToPolygon( aCornerBuffer, pts[3], pts[0], width, aError, aErrorLoc );
478  }
479  }
480  break;
481 
482  case S_ARC:
483  TransformArcToPolygon( aCornerBuffer, GetArcStart(), GetArcMid(), GetArcEnd(), width,
484  aError, aErrorLoc );
485  break;
486 
487  case S_SEGMENT:
488  TransformOvalToPolygon( aCornerBuffer, m_start, m_end, width, aError, aErrorLoc );
489  break;
490 
491  case S_POLYGON:
492  {
493  if( !IsPolyShapeValid() )
494  break;
495 
496  // The polygon is expected to be a simple polygon; not self intersecting, no hole.
497  FOOTPRINT* footprint = GetParentFootprint();
498  double orientation = footprint ? footprint->GetOrientation() : 0.0;
499  wxPoint offset;
500 
501  if( footprint )
502  offset = footprint->GetPosition();
503 
504  // Build the polygon with the actual position and orientation:
505  std::vector< wxPoint> poly;
506  poly = BuildPolyPointsList();
507 
508  for( wxPoint& point : poly )
509  {
510  RotatePoint( &point, orientation );
511  point += offset;
512  }
513 
514  if( IsFilled() )
515  {
516  aCornerBuffer.NewOutline();
517 
518  for( wxPoint& point : poly )
519  aCornerBuffer.Append( point.x, point.y );
520  }
521 
522  if( width > 0 || !IsFilled() )
523  {
524  wxPoint pt1( poly[ poly.size() - 1] );
525 
526  for( wxPoint pt2 : poly )
527  {
528  if( pt2 != pt1 )
529  TransformOvalToPolygon( aCornerBuffer, pt1, pt2, width, aError, aErrorLoc );
530 
531  pt1 = pt2;
532  }
533  }
534  }
535  break;
536 
537  case S_CURVE: // Bezier curve
538  {
539  std::vector<wxPoint> ctrlPoints = { m_start, m_bezierC1, m_bezierC2, m_end };
540  BEZIER_POLY converter( ctrlPoints );
541  std::vector< wxPoint> poly;
542  converter.GetPoly( poly, m_width );
543 
544  for( unsigned ii = 1; ii < poly.size(); ii++ )
545  {
546  TransformOvalToPolygon( aCornerBuffer, poly[ii-1], poly[ii], width, aError, aErrorLoc );
547  }
548  }
549  break;
550 
551  default:
552  wxFAIL_MSG( "PCB_SHAPE::TransformShapeWithClearanceToPolygon no implementation for "
554  break;
555  }
556 }
wxPoint GetArcEnd() const
Definition: pcb_shape.cpp:375
bool IsPolyShapeValid() const
Definition: pcb_shape.cpp:1191
bool IsFilled() const
Definition: pcb_shape.h:96
wxPoint m_end
Definition: pcb_shape.h:49
PCB_SHAPE_TYPE_T m_shape
Definition: pcb_shape.h:52
int GetRadius() const
Function GetRadius returns the radius of this item Has meaning only for arc and circle.
Definition: pcb_shape.h:200
std::vector< wxPoint > GetRectCorners() const
Definition: pcb_shape.cpp:942
polygon (not yet used for tracks, but could be in microwave apps)
Definition: board_item.h:56
double GetOrientation() const
Definition: footprint.h:204
usual segment : line with rounded ends
Definition: board_item.h:52
Arcs (with rounded ends)
Definition: board_item.h:54
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
segment with non rounded ends
Definition: board_item.h:53
wxPoint GetArcStart() const
Definition: pcb_shape.h:178
void TransformOvalToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aStart, wxPoint aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc)
convert a oblong shape to a polygon, using multiple segments It is similar to TransformRoundedEndsSeg...
const std::vector< wxPoint > BuildPolyPointsList() const
Build and return the list of corners in a std::vector<wxPoint> It must be used only to convert the SH...
Definition: pcb_shape.cpp:1174
static wxString PCB_SHAPE_TYPE_T_asString(PCB_SHAPE_TYPE_T a)
Definition: board_item.h:61
wxPoint GetCenter() const override
Function GetCenter()
Definition: pcb_shape.cpp:343
int NewOutline()
Creates a new empty polygon in the set and returns its index
wxPoint m_start
Definition: pcb_shape.h:48
void TransformCircleToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aCenter, int aRadius, int aError, ERROR_LOC aErrorLoc)
Function TransformCircleToPolygon convert a circle to a polygon, using multiple straight lines.
Bezier curves to polygon converter.
Definition: bezier_curves.h:35
int m_width
Definition: pcb_shape.h:46
FOOTPRINT * GetParentFootprint() const
Function GetParentFootprint returns a pointer to the parent footprint, or NULL if PCB_SHAPE does not ...
Definition: pcb_shape.cpp:457
wxPoint GetPosition() const override
Definition: footprint.h:200
ring
Definition: board_item.h:55
wxPoint m_bezierC1
Definition: pcb_shape.h:54
wxPoint GetArcMid() const
Definition: pcb_shape.cpp:393
wxPoint m_bezierC2
Definition: pcb_shape.h:55
Bezier Curve.
Definition: board_item.h:57
void TransformArcToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aStart, wxPoint aMid, wxPoint aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc)
Function TransformArcToPolygon Creates a polygon from an Arc Convert arcs to multiple straight segmen...
void TransformRingToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aCentre, int aRadius, int aWidth, int aError, ERROR_LOC aErrorLoc)
Function TransformRingToPolygon Creates a polygon from a ring Convert arcs to multiple straight segme...
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)

References SHAPE_POLY_SET::Append(), BuildPolyPointsList(), GetArcEnd(), GetArcMid(), GetArcStart(), GetCenter(), FOOTPRINT::GetOrientation(), GetParentFootprint(), BEZIER_POLY::GetPoly(), FOOTPRINT::GetPosition(), GetRadius(), GetRectCorners(), IsFilled(), IsPolyShapeValid(), m_bezierC1, m_bezierC2, m_end, m_shape, m_start, m_width, SHAPE_POLY_SET::NewOutline(), PCB_SHAPE_TYPE_T_asString(), RotatePoint(), S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, S_SEGMENT, TransformArcToPolygon(), TransformCircleToPolygon(), TransformOvalToPolygon(), and TransformRingToPolygon().

Referenced by BOARD_ADAPTER::AddShapeWithClearanceToContainer(), BOARD::ConvertBrdLayerToPolygonalContours(), ALTIUM_PCB::ParseArcs6Data(), ALTIUM_PCB::ParseTracks6Data(), PAD_TOOL::recombinePad(), BOARD_ADAPTER::transformFPShapesToPolygon(), and FOOTPRINT::TransformFPShapesWithClearanceToPolygon().

◆ Type()

KICAD_T EDA_ITEM::Type ( ) const
inlineinherited

Function Type()

returns the type of object. This attribute should never be changed after a ctor sets it, so there is no public "setter" method.

Returns
KICAD_T - the type of object.

Definition at line 181 of file eda_item.h.

181 { return m_structType; }
KICAD_T m_structType
Run time identification, keep private so it can never be changed after a ctor sets it.
Definition: eda_item.h:158

References EDA_ITEM::m_structType.

Referenced by FOOTPRINT::Add(), CN_CONNECTIVITY_ALGO::Add(), BOARD::Add(), CN_CLUSTER::Add(), POINT_EDITOR::addCorner(), CONNECTION_SUBGRAPH::AddItem(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), SCH_LINE_WIRE_BUS_TOOL::AddJunctionsIfNeeded(), ZONE_FILLER::addKnockout(), SCH_SHEET::AddPin(), ALIGN_DISTRIBUTE_TOOL::AlignBottom(), ALIGN_DISTRIBUTE_TOOL::AlignCenterX(), ALIGN_DISTRIBUTE_TOOL::AlignCenterY(), ALIGN_DISTRIBUTE_TOOL::AlignTop(), CN_ITEM::AnchorCount(), SCH_SCREEN::Append(), CONNECTION_GRAPH::buildConnectionGraph(), DIALOG_NET_INSPECTOR::buildNewItem(), SCH_SCREENS::buildScreenList(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), POINT_EDITOR::canAddCorner(), SCH_JUNCTION::CanConnect(), SCH_NO_CONNECT::CanConnect(), SCH_BUS_WIRE_ENTRY::CanConnect(), SCH_BUS_BUS_ENTRY::CanConnect(), SCH_LINE::CanConnect(), SCH_LABEL::CanConnect(), SCH_GLOBALLABEL::CanConnect(), SCH_HIERLABEL::CanConnect(), SCH_SHEET::CanConnect(), SCH_COMPONENT::CanConnect(), ROUTER_TOOL::CanInlineDrag(), SCH_EDIT_TOOL::ChangeTextType(), CN_VISITOR::checkZoneItemConnection(), SCH_MARKER::ClassOf(), PCB_TEXT::ClassOf(), PCB_MARKER::ClassOf(), SCH_JUNCTION::ClassOf(), FP_SHAPE::ClassOf(), SCH_NO_CONNECT::ClassOf(), BOARD_CONNECTED_ITEM::ClassOf(), PCB_GROUP::ClassOf(), PCB_TARGET::ClassOf(), SCH_PIN::ClassOf(), SCH_LINE::ClassOf(), FP_TEXT::ClassOf(), SCH_FIELD::ClassOf(), ClassOf(), ZONE::ClassOf(), PAD::ClassOf(), SCH_BITMAP::ClassOf(), TRACK::ClassOf(), NETINFO_ITEM::ClassOf(), SCH_SHEET_PIN::ClassOf(), FOOTPRINT::ClassOf(), SCH_BUS_WIRE_ENTRY::ClassOf(), SCH_COMPONENT::ClassOf(), SCH_SCREEN::ClassOf(), SCH_BUS_BUS_ENTRY::ClassOf(), SCH_TEXT::ClassOf(), BOARD::ClassOf(), SCH_SHEET::ClassOf(), ARC::ClassOf(), SCH_LABEL::ClassOf(), ALIGNED_DIMENSION::ClassOf(), VIA::ClassOf(), SCH_GLOBALLABEL::ClassOf(), ORTHOGONAL_DIMENSION::ClassOf(), SCH_HIERLABEL::ClassOf(), LEADER::ClassOf(), CENTER_DIMENSION::ClassOf(), TRACKS_CLEANER::cleanup(), LIB_BEZIER::compare(), LIB_CIRCLE::compare(), LIB_RECTANGLE::compare(), LIB_TEXT::compare(), LIB_POLYLINE::compare(), LIB_ARC::compare(), LIB_FIELD::compare(), LIB_PIN::compare(), LIB_ITEM::compare(), EE_GRID_HELPER::computeAnchors(), GRID_HELPER::computeAnchors(), SCH_BUS_WIRE_ENTRY::ConnectionPropagatesTo(), EE_RTREE::contains(), BOARD::ConvertKIIDsToCrossReferences(), SCHEMATIC::ConvertKIIDsToRefs(), PAD_TOOL::copyPadSettings(), FOOTPRINT::CoverageRatio(), BOARD_ADAPTER::createLayers(), PCB_BASE_FRAME::CreateNewFootprint(), SCH_DRAWING_TOOLS::createNewText(), BOARD_ADAPTER::createNewTrack(), ZONE_CREATE_HELPER::createNewZone(), SCH_SCREEN::DeleteItem(), DIALOG_DIMENSION_PROPERTIES::DIALOG_DIMENSION_PROPERTIES(), DIALOG_LABEL_EDITOR::DIALOG_LABEL_EDITOR(), DIALOG_SCH_EDIT_ONE_FIELD::DIALOG_SCH_EDIT_ONE_FIELD(), DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES(), ALIGN_DISTRIBUTE_TOOL::doAlignLeft(), ALIGN_DISTRIBUTE_TOOL::doAlignRight(), SCH_EDITOR_CONTROL::doCopy(), SCH_EDIT_TOOL::DoDelete(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersVertically(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsVertically(), KIGFX::SCH_PAINTER::draw(), KIGFX::GERBVIEW_PAINTER::Draw(), KIGFX::PCB_PAINTER::Draw(), DRAWING_TOOL::DrawDimension(), CN_ITEM::Dump(), EDIT_TOOL::Duplicate(), FOOTPRINT::DuplicateItem(), EDA_ITEM_DESC::EDA_ITEM_DESC(), SCH_EDIT_TOOL::EditField(), SCH_EDIT_TOOL::editFieldText(), LIB_EDIT_TOOL::editTextProperties(), EditToolSelectionFilter(), CONNECTION_GRAPH::ercCheckBusToBusEntryConflicts(), CONNECTION_GRAPH::ercCheckFloatingWires(), CONNECTION_GRAPH::ercCheckLabels(), CONNECTION_GRAPH::ercCheckNoConnects(), DRC_ENGINE::EvalRulesForItems(), EDIT_TOOL::FilletTracks(), NETLIST_EXPORTER_BASE::findNextSymbol(), PCB_BASE_FRAME::FocusOnItem(), EDIT_TOOL::FootprintFilter(), SCH_SEXPR_PLUGIN::Format(), SCH_LEGACY_PLUGIN::Format(), PCB_IO::Format(), PCB_IO::format(), FormatProbeItem(), FP_TEXT::FP_TEXT(), POINT_EDITOR::get45DegConstrainer(), CN_ITEM::GetAnchor(), BOARD_ITEM::GetBoard(), SCH_FIELD::GetBoundingBox(), TRACK::GetBoundingBox(), SCH_FIELD::GetCanonicalName(), KIGFX::GERBVIEW_RENDER_SETTINGS::GetColor(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), SCH_MOVE_TOOL::getConnectedDragItems(), SCH_TEXT::GetConnectionPoints(), SCH_TEXT::GetContextualTextVars(), FOOTPRINT::GetCoverageArea(), CONNECTION_GRAPH::getDefaultConnection(), getDrilledHoleShape(), CONNECTION_SUBGRAPH::GetDriverPriority(), SCH_TEXT::GetEndPoints(), PL_EDITOR_FRAME::GetLayoutFromRedoList(), PL_EDITOR_FRAME::GetLayoutFromUndoList(), SCH_FIELD::GetMenuImage(), DIMENSION_BASE::GetMsgPanelInfo(), SCH_TEXT::GetMsgPanelInfo(), SCH_FIELD::GetName(), CONNECTION_SUBGRAPH::GetNameForDriver(), CONNECTIVITY_DATA::GetNetItems(), LIB_PART::GetNextDrawItem(), GetParentFootprint(), LIB_PART::GetPin(), SCH_COMPONENT::GetPinPhysicalPosition(), SCH_FIELD::GetPosition(), KIGFX::SCH_PAINTER::getRenderColor(), getShape(), PCB_TEXT::GetShownText(), SCH_FIELD::GetShownText(), SCH_TEXT::GetShownText(), CONVERT_TOOL::getStartEndPoints(), BOARD::GroupLegalOps(), SELECTION_TOOL::GuessSelectionCandidates(), EE_SELECTION_TOOL::GuessSelectionCandidates(), hash_fp_item(), EE_SELECTION_TOOL::highlight(), SELECTION_TOOL::highlightInternal(), PCB_INSPECTION_TOOL::HighlightItem(), PCB_INSPECTION_TOOL::highlightNet(), highlightNet(), SCH_EDIT_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), EE_RTREE::insert(), DRC_RTREE::Insert(), insideArea(), EE_COLLECTOR::Inspect(), GENERAL_COLLECTOR::Inspect(), PCB_INSPECTION_TOOL::InspectClearance(), PCB_INSPECTION_TOOL::InspectConstraints(), ARRAY_CREATOR::Invoke(), CN_ANCHOR::IsDangling(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingLineWireOrBus(), CADSTAR_PCB_ARCHIVE_LOADER::isFootprint(), SCH_FIELD::IsHypertext(), isKeepoutZone(), isNetTie(), TRACK::IsNull(), PNS_KICAD_IFACE::IsOnLayer(), SCH_LINE::IsParallel(), SCH_FIELD::IsReplaceable(), SCH_SCREEN::IsTerminalPoint(), BOARD_ITEM::IsTrack(), itemIsIncludedByFilter(), SELECTION_TOOL::itemPassesFilter(), CONVERT_TOOL::LinesToPoly(), CLIPBOARD_IO::Load(), CADSTAR_SCH_ARCHIVE_LOADER::loadHierarchicalSheetPins(), CADSTAR_SCH_ARCHIVE_LOADER::loadNets(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), EE_SELECTION_TOOL::Main(), EDIT_POINTS_FACTORY::Make(), NETLIST_EXPORTER_XML::makeListOfNets(), SCH_SCREEN::MarkConnections(), CN_CONNECTIVITY_ALGO::markItemNetAsDirty(), CONNECTIVITY_DATA::MarkItemNetAsDirty(), SCH_FIELD::Matches(), memberOf(), SCH_LINE::MergeOverlap(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SCH_MOVE_TOOL::moveItem(), SCH_EDITOR_CONTROL::nextMatch(), APPEARANCE_CONTROLS::OnBoardItemAdded(), APPEARANCE_CONTROLS::OnBoardItemChanged(), APPEARANCE_CONTROLS::OnBoardItemRemoved(), FOOTPRINT_EDIT_FRAME::OnEditItemRequest(), PCB_EDIT_FRAME::OnEditItemRequest(), EDA_3D_CANVAS::OnMouseMove(), TRACK::cmp_tracks::operator()(), CN_VISITOR::operator()(), PCB_SHAPE::cmp_drawings::operator()(), BOARD_ITEM::ptr_cmp::operator()(), FOOTPRINT::cmp_drawings::operator()(), SCH_JUNCTION::operator<(), SCH_BUS_ENTRY_BASE::operator<(), SCH_FIELD::operator<(), SCH_LINE::operator<(), LIB_ITEM::operator<(), SCH_TEXT::operator<(), SCH_ITEM::operator<(), SCH_SHEET::operator<(), SCH_COMPONENT::operator<(), SCH_BITMAP::operator=(), SCH_SHEET::operator=(), SCH_COMPONENT::operator=(), PAD::PAD(), EDIT_TOOL::PadFilter(), BOARD_COMMIT::parentObject(), PCBNEW_CONTROL::Paste(), SCH_EDITOR_CONTROL::Paste(), DRAWING_TOOL::PlaceImportedGraphics(), SCH_FIELD::Plot(), SCH_SCREEN::Plot(), BRDITEMS_PLOTTER::PlotFootprintGraphicItem(), CONVERT_TOOL::PolyToLines(), SCH_FIELD::Print(), SCH_SCREEN::Print(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::processItem(), BACK_ANNOTATE::processNetNameChange(), LIB_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), BOARD_COMMIT::Push(), PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), SCH_EDIT_FRAME::PutDataInPreviousState(), SELECTION_TOOL::RebuildSelection(), SCH_CONNECTION::recacheName(), SCH_BASE_FRAME::RefreshSelection(), EE_RTREE::remove(), FOOTPRINT::Remove(), CN_CONNECTIVITY_ALGO::Remove(), SCH_SCREEN::Remove(), BOARD::Remove(), POINT_EDITOR::removeCorner(), POINT_EDITOR::removeCornerCondition(), LIB_PART::RemoveDrawItem(), SCH_SHEET::RemovePin(), SCH_EDIT_TOOL::RepeatDrawItem(), SCH_FIELD::Replace(), SCHEMATIC::ResolveCrossReference(), CONNECTION_SUBGRAPH::ResolveDrivers(), PCB_PARSER::resolveGroups(), WS_PROXY_UNDO_ITEM::Restore(), PL_EDITOR_FRAME::RollbackFromUndo(), SCH_EDIT_TOOL::Rotate(), DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal(), SCH_SEXPR_PLUGIN_CACHE::saveArc(), SCH_LEGACY_PLUGIN_CACHE::saveArc(), SCH_SEXPR_PLUGIN_CACHE::saveBezier(), SCH_LEGACY_PLUGIN_CACHE::saveBezier(), SCH_SEXPR_PLUGIN_CACHE::saveCircle(), SCH_LEGACY_PLUGIN_CACHE::saveCircle(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), EE_TOOL_BASE< SCH_BASE_FRAME >::saveCopyInUndoList(), SCH_SEXPR_PLUGIN::saveField(), SCH_SEXPR_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_SEXPR_PLUGIN_CACHE::savePin(), SCH_LEGACY_PLUGIN_CACHE::savePin(), SCH_SEXPR_PLUGIN_CACHE::savePolyLine(), SCH_LEGACY_PLUGIN_CACHE::savePolyLine(), SCH_SEXPR_PLUGIN_CACHE::saveRectangle(), SCH_LEGACY_PLUGIN_CACHE::saveRectangle(), CLIPBOARD_IO::SaveSelection(), SCH_SEXPR_PLUGIN_CACHE::saveSymbolDrawItem(), SCH_SEXPR_PLUGIN::saveText(), SCH_SEXPR_PLUGIN_CACHE::saveText(), SCH_LEGACY_PLUGIN_CACHE::saveText(), SCH_SCREEN::Schematic(), SCH_ITEM::Schematic(), CONVERT_TOOL::SegmentToArc(), SELECTION_TOOL::select(), SELECTION_TOOL::Selectable(), EE_SELECTION_TOOL::Selectable(), SELECTION_TOOL::selectConnectedTracks(), SCH_FIELD::SetId(), ITEM_PICKER::SetItem(), SCH_FIELD::SetPosition(), DIALOG_LABEL_EDITOR::SetTitle(), PCB_EDIT_FRAME::SetTrackSegmentWidth(), BOARD_COMMIT::Stage(), SCH_JUNCTION::SwapData(), SCH_NO_CONNECT::SwapData(), SCH_BITMAP::SwapData(), PCB_TARGET::SwapData(), PCB_GROUP::SwapData(), SCH_SHEET_PIN::SwapData(), SCH_FIELD::SwapData(), PCB_TEXT::SwapData(), TRACK::SwapData(), ARC::SwapData(), ALIGNED_DIMENSION::SwapData(), ORTHOGONAL_DIMENSION::SwapData(), SCH_SHEET::SwapData(), LEADER::SwapData(), SCH_COMPONENT::SwapData(), VIA::SwapData(), CENTER_DIMENSION::SwapData(), PAD::SwapData(), FOOTPRINT::SwapData(), ZONE::SwapData(), SwapItemData(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZones(), ERC_TESTER::TestMultUnitPinConflicts(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem(), ERC_TESTER::TestPinToPin(), ERC_TESTER::TestSimilarLabels(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem(), PCB_GROUP::TopLevelGroup(), DIALOG_LABEL_EDITOR::TransferDataFromWindow(), DIALOG_FIELDS_EDITOR_GLOBAL::TransferDataToWindow(), DIALOG_DIMENSION_PROPERTIES::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_LABEL_EDITOR::TransferDataToWindow(), TRACK::TransformShapeWithClearanceToPolygon(), LIB_DRAWING_TOOLS::TwoClickPlace(), EE_SELECTION_TOOL::unhighlight(), SELECTION_TOOL::unhighlightInternal(), KIGFX::PCB_VIEW::Update(), SCH_TEXT::UpdateDanglingState(), DIALOG_DIMENSION_PROPERTIES::updateDimensionFromDialog(), DIALOG_SCH_EDIT_ONE_FIELD::UpdateField(), PL_POINT_EDITOR::updateItem(), POINT_EDITOR::updateItem(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateItem(), SCH_BASE_FRAME::UpdateItem(), CONNECTION_GRAPH::updateItemConnectivity(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updateParentItem(), SCH_EDITOR_CONTROL::updatePastedInstances(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), POINT_EDITOR::updatePoints(), PCB_BRIGHT_BOX::ViewDraw(), SCH_BUS_ENTRY_BASE::ViewGetLayers(), PCB_GROUP::Visit(), TRACK::Visit(), GERBER_DRAW_ITEM::Visit(), SCH_GLOBALLABEL::Visit(), SCH_SHEET::Visit(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem(), PCB_GROUP::WithinScope(), and NETLIST_EXPORTER_CADSTAR::writeListOfNets().

◆ ViewBBox()

const BOX2I PCB_SHAPE::ViewBBox ( ) const
override<