KiCad PCB EDA Suite
PCB_SHAPE Class Reference

#include <pcb_shape.h>

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

Classes

struct  cmp_drawings
 

Public Member Functions

 PCB_SHAPE (BOARD_ITEM *aParent, KICAD_T idtype, SHAPE_T shapetype)
 
 PCB_SHAPE (BOARD_ITEM *aParent=NULL, SHAPE_T shapetype=SHAPE_T::SEGMENT)
 
 ~PCB_SHAPE ()
 
wxString GetClass () const override
 Return the class name. More...
 
bool IsType (const KICAD_T aScanTypes[]) const override
 Check whether the item is one of the listed types. More...
 
void SetPosition (const wxPoint &aPos) override
 
wxPoint GetPosition () const override
 
wxPoint GetCenter () const override
 This defaults to the center of the bounding box if not overridden. More...
 
const wxPoint GetFocusPosition () const override
 Allows items to return their visual center rather than their anchor. More...
 
FOOTPRINTGetParentFootprint () const
 Return the parent footprint or NULL if PCB_SHAPE does not belong to a footprint. More...
 
std::shared_ptr< SHAPEGetEffectiveShape (PCB_LAYER_ID aLayer=UNDEFINED_LAYER) const override
 Make a set of SHAPE objects representing the PCB_SHAPE. More...
 
void GetMsgPanelInfo (EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
 Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes. More...
 
const EDA_RECT GetBoundingBox () const override
 Return the orthogonal bounding box of this object for display purposes. More...
 
bool HitTest (const wxPoint &aPosition, int aAccuracy=0) const override
 Test if aPosition is inside or on the boundary of this item. More...
 
bool HitTest (const EDA_RECT &aRect, bool aContained, int aAccuracy=0) const override
 Test if aRect intersects this item. More...
 
virtual void Move (const wxPoint &aMoveVector) override
 Move this object. More...
 
virtual void Rotate (const wxPoint &aRotCentre, double aAngle) override
 Rotate this object. More...
 
virtual void Flip (const wxPoint &aCentre, bool aFlipLeftRight) override
 Flip this object, i.e. More...
 
void Scale (double aScale)
 
void TransformShapeWithClearanceToPolygon (SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
 Convert the shape to a closed polygon. More...
 
virtual wxString GetSelectMenuText (EDA_UNITS aUnits) const override
 Return the text to display to be used in the selection clarification context menu when multiple items are found at the current cursor position. More...
 
virtual BITMAPS GetMenuImage () const override
 Return a pointer to an image to be used in menus. More...
 
virtual EDA_ITEMClone () const override
 Create a duplicate of this item with linked list members set to NULL. More...
 
virtual const BOX2I ViewBBox () const override
 Return the bounding box of the item covering all its layers. More...
 
virtual void SwapData (BOARD_ITEM *aImage) override
 Swap data between aItem and aImage. More...
 
void SetParentGroup (PCB_GROUP *aGroup)
 
PCB_GROUPGetParentGroup () const
 
int GetX () const
 
int GetY () const
 
void SetX (int aX)
 
void SetY (int aY)
 
virtual bool IsConnected () const
 Returns information if the object is derived from BOARD_CONNECTED_ITEM. More...
 
virtual bool IsOnCopperLayer () const
 
BOARD_ITEM_CONTAINERGetParent () const
 
virtual PCB_LAYER_ID GetLayer () const
 Return the primary layer this item is on. More...
 
virtual LSET GetLayerSet () const
 Return a std::bitset of all layers on which the item physically resides. More...
 
virtual void SetLayerSet (LSET aLayers)
 
virtual void SetLayer (PCB_LAYER_ID aLayer)
 Set the layer this item is on. More...
 
virtual BOARD_ITEMDuplicate () const
 Create a copy of this BOARD_ITEM. More...
 
virtual bool IsOnLayer (PCB_LAYER_ID aLayer) const
 Test to see if this object is on the given layer. More...
 
bool IsTrack () const
 Test to see if this object is a track or via (or microvia). More...
 
virtual bool IsLocked () const
 
virtual void SetLocked (bool aLocked)
 Modify the 'lock' status for of the item. More...
 
void DeleteStructure ()
 Delete this object after removing from its parent if it has one. More...
 
void Move (const VECTOR2I &aMoveVector)
 
void Rotate (const VECTOR2I &aRotCentre, double aAngle)
 
void Flip (const VECTOR2I &aCentre, bool aFlipLeftRight)
 
virtual const BOARDGetBoard () const
 Return the BOARD in which this BOARD_ITEM resides, or NULL if none. More...
 
virtual BOARDGetBoard ()
 
wxString GetLayerName () const
 Return the name of the PCB layer on which the item resides. More...
 
virtual void ViewGetLayers (int aLayers[], int &aCount) const override
 Return the all the layers within the VIEW the object is painted on. More...
 
KICAD_T Type () const
 Returns the type of object. More...
 
virtual void SetParent (EDA_ITEM *aParent)
 
bool IsModified () const
 
bool IsNew () const
 
bool IsMoving () const
 
bool IsDragging () const
 
bool IsWireImage () const
 
bool IsSelected () const
 
bool IsEntered () const
 
bool IsResized () const
 
bool IsBrightened () const
 
void SetWireImage ()
 
void SetSelected ()
 
void SetBrightened ()
 
void ClearSelected ()
 
void ClearBrightened ()
 
void SetModified ()
 
int GetState (EDA_ITEM_FLAGS type) const
 
void SetState (EDA_ITEM_FLAGS type, bool state)
 
EDA_ITEM_FLAGS GetStatus () const
 
void SetStatus (EDA_ITEM_FLAGS aStatus)
 
void SetFlags (EDA_ITEM_FLAGS aMask)
 
void ClearFlags (EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
 
EDA_ITEM_FLAGS GetFlags () const
 
bool HasFlag (EDA_ITEM_FLAGS aFlag) const
 
EDA_ITEM_FLAGS GetEditFlags () const
 
void ClearTempFlags ()
 
void ClearEditFlags ()
 
void SetForceVisible (bool aEnable)
 Set and clear force visible flag used to force the item to be drawn even if it's draw attribute is set to not visible. More...
 
bool IsForceVisible () const
 
virtual SEARCH_RESULT Visit (INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
 May be re-implemented for each derived class in order to handle all the types given by its member data. More...
 
virtual bool Matches (const wxFindReplaceData &aSearchData, void *aAuxData) const
 Compare the item against the search criteria in aSearchData. More...
 
virtual bool Replace (const wxFindReplaceData &aSearchData, void *aAuxData=nullptr)
 Perform a text replace using the find and replace criteria in aSearchData on items that support text find and replace. More...
 
virtual bool IsReplaceable () const
 Override this method in any derived object that supports test find and replace. More...
 
bool operator< (const EDA_ITEM &aItem) const
 Test if another item is less than this object. More...
 
virtual void ViewDraw (int aLayer, VIEW *aView) const
 Draw the parts of the object belonging to layer aLayer. More...
 
virtual double ViewGetLOD (int aLayer, VIEW *aView) const
 Return the level of detail (LOD) of the item. More...
 
VIEW_ITEM_DATA * viewPrivData () const
 
void ClearViewPrivData ()
 
bool Set (PROPERTY_BASE *aProperty, wxAny &aValue)
 
template<typename T >
bool Set (PROPERTY_BASE *aProperty, T aValue)
 
template<typename T >
bool Set (const wxString &aProperty, T aValue)
 
wxAny Get (PROPERTY_BASE *aProperty)
 
template<typename T >
Get (PROPERTY_BASE *aProperty)
 
template<typename T >
boost::optional< T > Get (const wxString &aProperty)
 
void SwapShape (EDA_SHAPE *aImage)
 
wxString ShowShape () const
 
wxString SHAPE_T_asString () const
 
void SetFillMode (FILL_T aFill)
 
FILL_T GetFillType () const
 
bool IsFilled () const
 
void SetFilled (bool aFlag)
 
void SetWidth (int aWidth)
 
int GetWidth () const
 
void SetShape (SHAPE_T aShape)
 
SHAPE_T GetShape () const
 
const wxPoint & GetStart () const
 Return the starting point of the graphic. More...
 
int GetStartY ()
 
int GetStartX ()
 
void SetStart (const wxPoint &aStart)
 
void SetStartY (int y)
 
void SetStartX (int x)
 
const wxPoint & GetEnd () const
 Return the ending point of the graphic. More...
 
int GetEndY ()
 
int GetEndX ()
 
void SetEnd (const wxPoint &aEnd)
 
void SetEndY (int y)
 
void SetEndX (int x)
 
void SetBezierC1 (const wxPoint &aPt)
 
const wxPoint & GetBezierC1 () const
 
void SetBezierC2 (const wxPoint &aPt)
 
const wxPoint & GetBezierC2 () const
 
wxPoint getCenter () const
 
void SetCenter (const wxPoint &aCenter)
 
void SetArcAngleAndEnd (double aAngle, bool aCheckNegativeAngle=false)
 Set the end point from the angle center and start. More...
 
double GetArcAngle () const
 
bool EndsSwapped () const
 Have the start and end points been swapped since they were set? More...
 
wxPoint GetArcMid () const
 
std::vector< wxPoint > GetRectCorners () const
 
void CalcArcAngles (double &aStartAngle, double &aEndAngle) const
 Calc arc start and end angles such that aStartAngle < aEndAngle. More...
 
int GetRadius () const
 
void SetArcGeometry (const wxPoint &aStart, const wxPoint &aMid, const wxPoint &aEnd)
 Set the three controlling points for an arc. More...
 
const std::vector< wxPoint > & GetBezierPoints () const
 
void DupPolyPointsList (std::vector< wxPoint > &aBuffer) const
 Duplicate the list of corners in a std::vector<wxPoint> More...
 
int GetPointCount () const
 
SHAPE_POLY_SETGetPolyShape ()
 
const SHAPE_POLY_SETGetPolyShape () const
 
bool IsPolyShapeValid () const
 
void SetPolyShape (const SHAPE_POLY_SET &aShape)
 
void SetBezierPoints (const std::vector< wxPoint > &aPoints)
 
void RebuildBezierToSegmentsPointsList (int aMinSegLen)
 Rebuild the m_BezierPoints vertex list that approximate the Bezier curve by a list of segments. More...
 
void SetPolyPoints (const std::vector< wxPoint > &aPoints)
 
std::vector< SHAPE * > MakeEffectiveShapes () const
 Make a set of SHAPE objects representing the EDA_SHAPE. More...
 
void ShapeGetMsgPanelInfo (EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
 
double GetLength () const
 Return the length of the track using the hypotenuse calculation. More...
 
void TransformShapeWithClearanceToPolygon (SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth) const
 Convert the shape to a closed polygon. More...
 
int Compare (const EDA_SHAPE *aOther) const
 

Static Public Member Functions

static bool ClassOf (const EDA_ITEM *aItem)
 
template<class T >
static SEARCH_RESULT IterateForward (std::deque< T > &aList, INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
 This changes first parameter to avoid the DList and use the main queue instead. More...
 
template<class T >
static SEARCH_RESULT IterateForward (std::vector< T > &aList, INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
 Change first parameter to avoid the DList and use std::vector instead. More...
 
static bool Replace (const wxFindReplaceData &aSearchData, wxString &aText)
 Perform a text replace on aText using the find and replace criteria in aSearchData on items that support text find and replace. More...
 
static bool Sort (const EDA_ITEM *aLeft, const EDA_ITEM *aRight)
 Helper function to be used by the C++ STL sort algorithm for sorting a STL container of EDA_ITEM pointers. More...
 

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

double getParentOrientation () const override
 
wxPoint getParentPosition () const override
 
virtual wxString layerMaskDescribe () const
 Return a string (to be shown to the user) describing a layer mask. More...
 
bool Matches (const wxString &aText, const wxFindReplaceData &aSearchData) const
 Compare aText against search criteria in aSearchData. More...
 
void setPosition (const wxPoint &aPos)
 
wxPoint getPosition () const
 
void move (const wxPoint &aMoveVector)
 
void rotate (const wxPoint &aRotCentre, double aAngle)
 
void flip (const wxPoint &aCentre, bool aFlipLeftRight)
 
void scale (double aScale)
 
const EDA_RECT getBoundingBox () const
 
void computeArcBBox (EDA_RECT &aBBox) const
 
bool hitTest (const wxPoint &aPosition, int aAccuracy=0) const
 
bool hitTest (const EDA_RECT &aRect, bool aContained, int aAccuracy=0) const
 
const std::vector< wxPoint > buildBezierToSegmentsPointsList (int aMinSegLen) const
 
void beginEdit (const wxPoint &aStartPoint)
 
bool continueEdit (const wxPoint &aPosition)
 
void calcEdit (const wxPoint &aPosition)
 
void endEdit (bool aClosed=true)
 Finishes editing the shape. More...
 
void setEditState (int aState)
 

Protected Attributes

PCB_LAYER_ID m_layer
 
PCB_GROUPm_group
 
EDA_ITEM_FLAGS m_status
 
EDA_ITEMm_parent
 Linked list: Link (parent struct) More...
 
bool m_forceVisible
 
EDA_ITEM_FLAGS m_flags
 
bool m_endsSwapped
 
SHAPE_T m_shape
 
int m_width
 
FILL_T m_fill
 
wxPoint m_start
 
wxPoint m_end
 
wxPoint m_arcCenter
 
wxPoint m_bezierC1
 
wxPoint m_bezierC2
 
std::vector< wxPoint > m_bezierPoints
 
SHAPE_POLY_SET m_poly
 
int m_editState
 
bool m_eeWinding
 

Detailed Description

Definition at line 38 of file pcb_shape.h.

Constructor & Destructor Documentation

◆ PCB_SHAPE() [1/2]

PCB_SHAPE::PCB_SHAPE ( BOARD_ITEM aParent,
KICAD_T  idtype,
SHAPE_T  shapetype 
)

Definition at line 36 of file pcb_shape.cpp.

36  :
37  BOARD_ITEM( aParent, idtype ),
39 {
40 }
EDA_SHAPE(SHAPE_T aType, int aLineWidth, FILL_T aFill, bool eeWinding)
Definition: eda_shape.cpp:40
#define DEFAULT_LINE_WIDTH
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype)
Definition: board_item.h:52
static constexpr int Millimeter2iu(double mm)

Referenced by Clone().

◆ PCB_SHAPE() [2/2]

PCB_SHAPE::PCB_SHAPE ( BOARD_ITEM aParent = NULL,
SHAPE_T  shapetype = SHAPE_T::SEGMENT 
)

Definition at line 43 of file pcb_shape.cpp.

43  :
44  BOARD_ITEM( aParent, PCB_SHAPE_T ),
46 {
47 }
EDA_SHAPE(SHAPE_T aType, int aLineWidth, FILL_T aFill, bool eeWinding)
Definition: eda_shape.cpp:40
#define DEFAULT_LINE_WIDTH
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype)
Definition: board_item.h:52
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90
static constexpr int Millimeter2iu(double mm)

◆ ~PCB_SHAPE()

PCB_SHAPE::~PCB_SHAPE ( )

Definition at line 50 of file pcb_shape.cpp.

51 {
52 }

Member Function Documentation

◆ beginEdit()

void EDA_SHAPE::beginEdit ( const wxPoint &  aStartPoint)
protectedinherited

Definition at line 1208 of file eda_shape.cpp.

1209 {
1210  switch( GetShape() )
1211  {
1212  case SHAPE_T::SEGMENT:
1213  case SHAPE_T::CIRCLE:
1214  case SHAPE_T::RECT:
1215  SetStart( aPosition );
1216  SetEnd( aPosition );
1217  break;
1218 
1219  case SHAPE_T::ARC:
1220  SetArcGeometry( aPosition, aPosition, aPosition );
1221  m_editState = 1;
1222  break;
1223 
1224  case SHAPE_T::POLY:
1225  m_poly.NewOutline();
1226  m_poly.Outline( 0 ).SetClosed( false );
1227 
1228  // Start and end of the first segment (co-located for now)
1229  m_poly.Outline( 0 ).Append( aPosition );
1230  m_poly.Outline( 0 ).Append( aPosition, true );
1231  break;
1232 
1233  default:
1235  }
1236 }
void SetEnd(const wxPoint &aEnd)
Definition: eda_shape.h:126
void SetArcGeometry(const wxPoint &aStart, const wxPoint &aMid, const wxPoint &aEnd)
Set the three controlling points for an arc.
Definition: eda_shape.cpp:489
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
void SetStart(const wxPoint &aStart)
Definition: eda_shape.h:101
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
SHAPE_LINE_CHAIN & Outline(int aIndex)
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:313
int m_editState
Definition: eda_shape.h:315
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:120
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:71
int NewOutline()
Creates a new hole in a given outline.
SHAPE_T GetShape() const
Definition: eda_shape.h:92

References SHAPE_LINE_CHAIN::Append(), ARC, CIRCLE, EDA_SHAPE::GetShape(), EDA_SHAPE::m_editState, EDA_SHAPE::m_poly, SHAPE_POLY_SET::NewOutline(), SHAPE_POLY_SET::Outline(), POLY, RECT, SEGMENT, EDA_SHAPE::SetArcGeometry(), SHAPE_LINE_CHAIN::SetClosed(), EDA_SHAPE::SetEnd(), EDA_SHAPE::SetStart(), EDA_SHAPE::SHAPE_T_asString(), and UNIMPLEMENTED_FOR.

Referenced by LIB_SHAPE::BeginEdit().

◆ buildBezierToSegmentsPointsList()

const std::vector< wxPoint > EDA_SHAPE::buildBezierToSegmentsPointsList ( int  aMinSegLen) const
protectedinherited

Definition at line 380 of file eda_shape.cpp.

381 {
382  std::vector<wxPoint> bezierPoints;
383 
384  // Rebuild the m_BezierPoints vertex list that approximate the Bezier curve
385  std::vector<wxPoint> ctrlPoints = { m_start, m_bezierC1, m_bezierC2, m_end };
386  BEZIER_POLY converter( ctrlPoints );
387  converter.GetPoly( bezierPoints, aMinSegLen );
388 
389  return bezierPoints;
390 }
wxPoint m_bezierC1
Definition: eda_shape.h:309
wxPoint m_end
Definition: eda_shape.h:305
wxPoint m_bezierC2
Definition: eda_shape.h:310
wxPoint m_start
Definition: eda_shape.h:304
Bezier curves to polygon converter.
Definition: bezier_curves.h:36

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

Referenced by EDA_SHAPE::MakeEffectiveShapes(), and EDA_SHAPE::RebuildBezierToSegmentsPointsList().

◆ CalcArcAngles()

void EDA_SHAPE::CalcArcAngles ( double &  aStartAngle,
double &  aEndAngle 
) const
inherited

Calc arc start and end angles such that aStartAngle < aEndAngle.

Each may be between -360.0 and 360.0.

Definition at line 445 of file eda_shape.cpp.

446 {
447  VECTOR2D startRadial( GetStart() - getCenter() );
448  VECTOR2D endRadial( GetEnd() - getCenter() );
449 
450  aStartAngle = 180.0 / M_PI * atan2( startRadial.y, startRadial.x );
451  aEndAngle = 180.0 / M_PI * atan2( endRadial.y, endRadial.x );
452 
453  if( aEndAngle == aStartAngle )
454  aEndAngle = aStartAngle + 360.0; // ring, not null
455 
456  if( aStartAngle > aEndAngle )
457  {
458  if( aEndAngle < 0 )
459  aEndAngle = NormalizeAngleDegrees( aEndAngle, 0.0, 360.0 );
460  else
461  aStartAngle = NormalizeAngleDegrees( aStartAngle, -360.0, 0.0 );
462  }
463 }
wxPoint getCenter() const
Definition: eda_shape.cpp:393
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:97
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:122
double NormalizeAngleDegrees(double Angle, double aMin, double aMax)
Normalize angle to be aMin < angle <= aMax angle is in degrees.
Definition: trigo.h:327

References EDA_SHAPE::getCenter(), EDA_SHAPE::GetEnd(), EDA_SHAPE::GetStart(), NormalizeAngleDegrees(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by EDA_SHAPE::computeArcBBox(), KIGFX::PCB_PAINTER::draw(), EDA_SHAPE::GetArcAngle(), and EDA_SHAPE::hitTest().

◆ calcEdit()

void EDA_SHAPE::calcEdit ( const wxPoint &  aPosition)
protectedinherited

Definition at line 1266 of file eda_shape.cpp.

1267 {
1268 #define sq( x ) pow( x, 2 )
1269 
1270  switch( GetShape() )
1271  {
1272  case SHAPE_T::SEGMENT:
1273  case SHAPE_T::CIRCLE:
1274  case SHAPE_T::RECT:
1275  SetEnd( aPosition );
1276  break;
1277 
1278  case SHAPE_T::ARC:
1279  {
1280  int radius = GetRadius();
1281 
1282  // Edit state 0: drawing: place start
1283  // Edit state 1: drawing: place end (center calculated for 90-degree subtended angle)
1284  // Edit state 2: point edit: move start (center calculated for invariant subtended angle)
1285  // Edit state 3: point edit: move end (center calculated for invariant subtended angle)
1286  // Edit state 4: point edit: move center
1287  // Edit state 5: point edit: move arc-mid-point
1288 
1289  switch( m_editState )
1290  {
1291  case 0:
1292  SetArcGeometry( aPosition, aPosition, aPosition );
1293  return;
1294 
1295  case 1:
1296  m_end = aPosition;
1297  radius = KiROUND( sqrt( sq( GetLineLength( m_start, m_end ) ) / 2.0 ) );
1298  break;
1299 
1300  case 2:
1301  case 3:
1302  {
1303  wxPoint v = m_start - m_end;
1304  double chordBefore = sq( v.x ) + sq( v.y );
1305 
1306  if( m_editState == 2 )
1307  m_start = aPosition;
1308  else
1309  m_end = aPosition;
1310 
1311  v = m_start - m_end;
1312  double chordAfter = sq( v.x ) + sq( v.y );
1313  double ratio = chordAfter / chordBefore;
1314 
1315  if( ratio != 0 )
1316  {
1317  radius = std::max( int( sqrt( sq( radius ) * ratio ) ) + 1,
1318  int( sqrt( chordAfter ) / 2 ) + 1 );
1319  }
1320  }
1321  break;
1322 
1323  case 4:
1324  {
1325  double chordA = GetLineLength( m_start, aPosition );
1326  double chordB = GetLineLength( m_end, aPosition );
1327  radius = int( ( chordA + chordB ) / 2.0 ) + 1;
1328  }
1329  break;
1330 
1331  case 5:
1332  SetArcGeometry( GetStart(), aPosition, GetEnd() );
1333  return;
1334  }
1335 
1336  // Calculate center based on start, end, and radius
1337  //
1338  // Let 'l' be the length of the chord and 'm' the middle point of the chord
1339  double l = GetLineLength( m_start, m_end );
1340  wxPoint m = ( m_start + m_end ) / 2;
1341 
1342  // Calculate 'd', the vector from the chord midpoint to the center
1343  wxPoint d;
1344  d.x = KiROUND( sqrt( sq( radius ) - sq( l/2 ) ) * ( m_start.y - m_end.y ) / l );
1345  d.y = KiROUND( sqrt( sq( radius ) - sq( l/2 ) ) * ( m_end.x - m_start.x ) / l );
1346 
1347  wxPoint c1 = m + d;
1348  wxPoint c2 = m - d;
1349 
1350  // Solution gives us 2 centers; we need to pick one:
1351  switch( m_editState )
1352  {
1353  case 1:
1354  {
1355  // Keep center clockwise from chord while drawing
1356  wxPoint chordVector = m_end - m_start;
1357  double chordAngle = ArcTangente( chordVector.y, chordVector.x );
1358  NORMALIZE_ANGLE_POS( chordAngle );
1359 
1360  wxPoint c1Test = c1;
1361  RotatePoint( &c1Test, m_start, -chordAngle );
1362 
1363  m_arcCenter = c1Test.x > 0 ? c2 : c1;
1364  }
1365  break;
1366 
1367  case 2:
1368  case 3:
1369  // Pick the one closer to the old center
1370  m_arcCenter = GetLineLength( c1, m_arcCenter ) < GetLineLength( c2, m_arcCenter ) ? c1 : c2;
1371  break;
1372 
1373  case 4:
1374  // Pick the one closer to the mouse position
1375  m_arcCenter = GetLineLength( c1, aPosition ) < GetLineLength( c2, aPosition ) ? c1 : c2;
1376  break;
1377  }
1378  }
1379  break;
1380 
1381  case SHAPE_T::POLY:
1382  m_poly.Outline( 0 ).SetPoint( m_poly.Outline( 0 ).GetPointCount() - 1, aPosition );
1383  break;
1384 
1385  default:
1387  }
1388 }
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:222
virtual size_t GetPointCount() const override
#define sq(x)
void SetEnd(const wxPoint &aEnd)
Definition: eda_shape.h:126
void SetArcGeometry(const wxPoint &aStart, const wxPoint &aMid, const wxPoint &aEnd)
Set the three controlling points for an arc.
Definition: eda_shape.cpp:489
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:97
void SetPoint(int aIndex, const VECTOR2I &aPos)
Move a point to a specific location.
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:290
wxPoint m_end
Definition: eda_shape.h:305
wxPoint m_arcCenter
Definition: eda_shape.h:307
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:122
SHAPE_LINE_CHAIN & Outline(int aIndex)
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:313
int m_editState
Definition: eda_shape.h:315
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:120
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:71
wxPoint m_start
Definition: eda_shape.h:304
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73
SHAPE_T GetShape() const
Definition: eda_shape.h:92
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:183
int GetRadius() const
Definition: eda_shape.cpp:466

References ARC, ArcTangente(), CIRCLE, EDA_SHAPE::GetEnd(), GetLineLength(), SHAPE_LINE_CHAIN::GetPointCount(), EDA_SHAPE::GetRadius(), EDA_SHAPE::GetShape(), EDA_SHAPE::GetStart(), KiROUND(), EDA_SHAPE::m_arcCenter, EDA_SHAPE::m_editState, EDA_SHAPE::m_end, EDA_SHAPE::m_poly, EDA_SHAPE::m_start, NORMALIZE_ANGLE_POS(), SHAPE_POLY_SET::Outline(), POLY, RECT, RotatePoint(), SEGMENT, EDA_SHAPE::SetArcGeometry(), EDA_SHAPE::SetEnd(), SHAPE_LINE_CHAIN::SetPoint(), EDA_SHAPE::SHAPE_T_asString(), sq, and UNIMPLEMENTED_FOR.

Referenced by LIB_SHAPE::CalcEdit().

◆ ClassOf()

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

Definition at line 50 of file pcb_shape.h.

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

References PCB_SHAPE_T, and EDA_ITEM::Type().

◆ ClearBrightened()

void EDA_ITEM::ClearBrightened ( )
inlineinherited

◆ ClearEditFlags()

◆ ClearFlags()

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

Definition at line 153 of file eda_item.h.

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

References EDA_ITEM::m_flags.

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

◆ ClearSelected()

◆ ClearTempFlags()

void EDA_ITEM::ClearTempFlags ( )
inlineinherited

Definition at line 165 of file eda_item.h.

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

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

Referenced by SCH_EDIT_FRAME::PutDataInPreviousState().

◆ ClearViewPrivData()

void KIGFX::VIEW_ITEM::ClearViewPrivData ( )
inlineinherited

Definition at line 143 of file view_item.h.

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

References KIGFX::VIEW_ITEM::m_viewPrivData.

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

◆ Clone()

EDA_ITEM * PCB_SHAPE::Clone ( ) const
overridevirtual

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

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

Returns
A clone of the item.

Reimplemented from EDA_ITEM.

Reimplemented in FP_SHAPE.

Definition at line 175 of file pcb_shape.cpp.

176 {
177  return new PCB_SHAPE( *this );
178 }
PCB_SHAPE(BOARD_ITEM *aParent, KICAD_T idtype, SHAPE_T shapetype)
Definition: pcb_shape.cpp:36

References PCB_SHAPE().

Referenced by DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run().

◆ Compare()

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

Definition at line 1440 of file eda_shape.cpp.

1441 {
1442 #define EPSILON 2 // Should be enough for rounding errors on calculated items
1443 
1444 #define TEST( a, b ) { if( a != b ) return a - b; }
1445 #define TEST_E( a, b ) { if( abs( a - b ) > EPSILON ) return a - b; }
1446 #define TEST_PT( a, b ) { TEST_E( a.x, b.x ); TEST_E( a.y, b.y ); }
1447 
1448  TEST_PT( m_start, aOther->m_start );
1449  TEST_PT( m_end, aOther->m_end );
1450 
1451  TEST( (int) m_shape, (int) aOther->m_shape );
1452 
1453  if( m_shape == SHAPE_T::ARC )
1454  {
1455  TEST_PT( m_arcCenter, aOther->m_arcCenter );
1456  }
1457  else if( m_shape == SHAPE_T::BEZIER )
1458  {
1459  TEST_PT( m_bezierC1, aOther->m_bezierC1 );
1460  TEST_PT( m_bezierC2, aOther->m_bezierC2 );
1461  }
1462  else if( m_shape == SHAPE_T::POLY )
1463  {
1464  TEST( m_poly.TotalVertices(), aOther->m_poly.TotalVertices() );
1465 
1466  for( int ii = 0; ii < m_poly.TotalVertices(); ++ii )
1467  TEST_PT( m_poly.CVertex( ii ), aOther->m_poly.CVertex( ii ) );
1468  }
1469 
1470  TEST_E( m_width, aOther->m_width );
1471  TEST( (int) m_fill, (int) aOther->m_fill );
1472 
1473  return 0;
1474 }
int TotalVertices() const
Delete aIdx-th polygon from the set.
SHAPE_T m_shape
Definition: eda_shape.h:301
wxPoint m_bezierC1
Definition: eda_shape.h:309
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Return the aGlobalIndex-th vertex in the poly set.
wxPoint m_end
Definition: eda_shape.h:305
wxPoint m_arcCenter
Definition: eda_shape.h:307
wxPoint m_bezierC2
Definition: eda_shape.h:310
#define TEST(a, b)
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:313
#define TEST_E(a, b)
FILL_T m_fill
Definition: eda_shape.h:303
wxPoint m_start
Definition: eda_shape.h:304
#define TEST_PT(a, b)
int m_width
Definition: eda_shape.h:302

References ARC, BEZIER, SHAPE_POLY_SET::CVertex(), EDA_SHAPE::m_arcCenter, EDA_SHAPE::m_bezierC1, EDA_SHAPE::m_bezierC2, EDA_SHAPE::m_end, EDA_SHAPE::m_fill, EDA_SHAPE::m_poly, EDA_SHAPE::m_shape, EDA_SHAPE::m_start, EDA_SHAPE::m_width, POLY, TEST, TEST_E, TEST_PT, and SHAPE_POLY_SET::TotalVertices().

Referenced by LIB_SHAPE::compare(), and BOARD::cmp_drawings::operator()().

◆ computeArcBBox()

void EDA_SHAPE::computeArcBBox ( EDA_RECT aBBox) const
protectedinherited

Definition at line 995 of file eda_shape.cpp.

996 {
997  wxPoint start = m_start;
998  wxPoint end = m_end;
999  double t1, t2;
1000 
1001  CalcArcAngles( t1, t2 );
1002 
1003  if( m_eeWinding && NormalizeAngleDegrees( t1 - t2, -180.0, 180.0 ) > 0 )
1004  std::swap( start, end );
1005 
1006  // Do not include the center, which is not necessarily inside the BB of an arc with a small
1007  // included angle
1008  aBBox.SetOrigin( start );
1009  aBBox.Merge( end );
1010 
1011  // Determine the starting quarter
1012  // 0 right-bottom
1013  // 1 left-bottom
1014  // 2 left-top
1015  // 3 right-top
1016  unsigned int quarter;
1017 
1018  if( start.x < m_arcCenter.x )
1019  {
1020  if( start.y <= m_arcCenter.y )
1021  quarter = 2;
1022  else
1023  quarter = 1;
1024  }
1025  else if( start.x == m_arcCenter.x )
1026  {
1027  if( start.y < m_arcCenter.y )
1028  quarter = 3;
1029  else
1030  quarter = 1;
1031  }
1032  else
1033  {
1034  if( start.y < m_arcCenter.y )
1035  quarter = 3;
1036  else
1037  quarter = 0;
1038  }
1039 
1040  int radius = GetRadius();
1041  VECTOR2I startRadial = start - m_arcCenter;
1042  VECTOR2I endRadial = end - m_arcCenter;
1043  double angleStart = ArcTangente( startRadial.y, startRadial.x );
1044  double arcAngle = RAD2DECIDEG( endRadial.Angle() - startRadial.Angle() );
1045  int angle = (int) NormalizeAnglePos( angleStart ) % 900 + NormalizeAnglePos( arcAngle );
1046 
1047  while( angle > 900 )
1048  {
1049  switch( quarter )
1050  {
1051  case 0: aBBox.Merge( wxPoint( m_arcCenter.x, m_arcCenter.y + radius ) ); break; // down
1052  case 1: aBBox.Merge( wxPoint( m_arcCenter.x - radius, m_arcCenter.y ) ); break; // left
1053  case 2: aBBox.Merge( wxPoint( m_arcCenter.x, m_arcCenter.y - radius ) ); break; // up
1054  case 3: aBBox.Merge( wxPoint( m_arcCenter.x + radius, m_arcCenter.y ) ); break; // right
1055  }
1056 
1057  ++quarter %= 4;
1058  angle -= 900;
1059  }
1060 }
void Merge(const EDA_RECT &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: eda_rect.cpp:432
double RAD2DECIDEG(double rad)
Definition: trigo.h:234
void CalcArcAngles(double &aStartAngle, double &aEndAngle) const
Calc arc start and end angles such that aStartAngle < aEndAngle.
Definition: eda_shape.cpp:445
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:121
wxPoint m_end
Definition: eda_shape.h:305
wxPoint m_arcCenter
Definition: eda_shape.h:307
double Angle() const
Compute the angle of the vector.
Definition: vector2d.h:307
wxPoint m_start
Definition: eda_shape.h:304
bool m_eeWinding
Definition: eda_shape.h:316
T NormalizeAnglePos(T Angle)
Normalize angle to be in the 0.0 .. 360.0 range: angle is in 1/10 degrees.
Definition: trigo.h:281
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
double NormalizeAngleDegrees(double Angle, double aMin, double aMax)
Normalize angle to be aMin < angle <= aMax angle is in degrees.
Definition: trigo.h:327
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:183
int GetRadius() const
Definition: eda_shape.cpp:466

References PNS::angle(), VECTOR2< T >::Angle(), ArcTangente(), EDA_SHAPE::CalcArcAngles(), EDA_SHAPE::GetRadius(), EDA_SHAPE::m_arcCenter, EDA_SHAPE::m_eeWinding, EDA_SHAPE::m_end, EDA_SHAPE::m_start, EDA_RECT::Merge(), NormalizeAngleDegrees(), NormalizeAnglePos(), RAD2DECIDEG(), EDA_RECT::SetOrigin(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by EDA_SHAPE::getBoundingBox().

◆ continueEdit()

bool EDA_SHAPE::continueEdit ( const wxPoint &  aPosition)
protectedinherited

Definition at line 1239 of file eda_shape.cpp.

1240 {
1241  switch( GetShape() )
1242  {
1243  case SHAPE_T::ARC:
1244  case SHAPE_T::SEGMENT:
1245  case SHAPE_T::CIRCLE:
1246  case SHAPE_T::RECT:
1247  return false;
1248 
1249  case SHAPE_T::POLY:
1250  {
1251  SHAPE_LINE_CHAIN& poly = m_poly.Outline( 0 );
1252 
1253  // do not add zero-length segments
1254  if( poly.CPoint( poly.GetPointCount() - 2 ) != poly.CLastPoint() )
1255  poly.Append( aPosition, true );
1256  }
1257  return true;
1258 
1259  default:
1261  return false;
1262  }
1263 }
virtual size_t GetPointCount() const override
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
SHAPE_LINE_CHAIN & Outline(int aIndex)
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:313
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:120
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:71
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const VECTOR2I & CLastPoint() const
Return the last point in the line chain.
SHAPE_T GetShape() const
Definition: eda_shape.h:92

References SHAPE_LINE_CHAIN::Append(), ARC, CIRCLE, SHAPE_LINE_CHAIN::CLastPoint(), SHAPE_LINE_CHAIN::CPoint(), SHAPE_LINE_CHAIN::GetPointCount(), EDA_SHAPE::GetShape(), EDA_SHAPE::m_poly, SHAPE_POLY_SET::Outline(), POLY, RECT, SEGMENT, EDA_SHAPE::SHAPE_T_asString(), and UNIMPLEMENTED_FOR.

Referenced by LIB_SHAPE::ContinueEdit().

◆ DeleteStructure()

void BOARD_ITEM::DeleteStructure ( )
inherited

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

Definition at line 128 of file board_item.cpp.

129 {
130  BOARD_ITEM_CONTAINER* parent = GetParent();
131 
132  if( parent )
133  parent->Remove( this );
134 
135  delete this;
136 }
virtual void Remove(BOARD_ITEM *aItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL)=0
Removes an item from the container.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:135

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

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

◆ Duplicate()

virtual BOARD_ITEM* BOARD_ITEM::Duplicate ( ) const
inlinevirtualinherited

Create a copy of this BOARD_ITEM.

Reimplemented in FOOTPRINT.

Definition at line 171 of file board_item.h.

172  {
173  EDA_ITEM* dupe = Clone();
174  const_cast<KIID&>( dupe->m_Uuid ) = KIID();
175 
176  return static_cast<BOARD_ITEM*>( dupe );
177  }
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:83
Definition: kiid.h:44
const KIID m_Uuid
Definition: eda_item.h:474
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99

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

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

◆ DupPolyPointsList()

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

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

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

Definition at line 1168 of file eda_shape.cpp.

1169 {
1170  if( m_poly.OutlineCount() )
1171  {
1172  int pointCount = m_poly.COutline( 0 ).PointCount();
1173 
1174  if( pointCount )
1175  {
1176  aBuffer.reserve( pointCount );
1177 
1178  for ( auto iter = m_poly.CIterate(); iter; iter++ )
1179  aBuffer.emplace_back( iter->x, iter->y );
1180  }
1181  }
1182 }
int OutlineCount() const
Return the number of vertices in a given outline/hole.
int PointCount() const
Return the number of points (vertices) in this line chain.
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:313
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(), EDA_SHAPE::m_poly, SHAPE_POLY_SET::OutlineCount(), and SHAPE_LINE_CHAIN::PointCount().

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

◆ endEdit()

void EDA_SHAPE::endEdit ( bool  aClosed = true)
protectedinherited

Finishes editing the shape.

Parameters
aClosedShould polygon shapes be closed (yes for pcbnew/fpeditor, no for libedit)

Definition at line 1391 of file eda_shape.cpp.

1392 {
1393  switch( GetShape() )
1394  {
1395  case SHAPE_T::ARC:
1396  case SHAPE_T::SEGMENT:
1397  case SHAPE_T::CIRCLE:
1398  case SHAPE_T::RECT:
1399  break;
1400 
1401  case SHAPE_T::POLY:
1402  {
1403  SHAPE_LINE_CHAIN& poly = m_poly.Outline( 0 );
1404 
1405  // do not include last point twice
1406  if( poly.GetPointCount() > 2 )
1407  {
1408  if( poly.CPoint( poly.GetPointCount() - 2 ) == poly.CLastPoint() )
1409  {
1410  poly.SetClosed( aClosed );
1411  poly.Remove( poly.GetPointCount() - 1 );
1412  }
1413  }
1414  }
1415  break;
1416 
1417  default:
1419  }
1420 }
virtual size_t GetPointCount() const override
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
SHAPE_LINE_CHAIN & Outline(int aIndex)
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:313
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:120
void Remove(int aStartIndex, int aEndIndex)
Remove the range of points [start_index, end_index] from the line chain.
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:71
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const VECTOR2I & CLastPoint() const
Return the last point in the line chain.
SHAPE_T GetShape() const
Definition: eda_shape.h:92

References ARC, CIRCLE, SHAPE_LINE_CHAIN::CLastPoint(), SHAPE_LINE_CHAIN::CPoint(), SHAPE_LINE_CHAIN::GetPointCount(), EDA_SHAPE::GetShape(), EDA_SHAPE::m_poly, SHAPE_POLY_SET::Outline(), POLY, RECT, SHAPE_LINE_CHAIN::Remove(), SEGMENT, SHAPE_LINE_CHAIN::SetClosed(), EDA_SHAPE::SHAPE_T_asString(), and UNIMPLEMENTED_FOR.

Referenced by LIB_SHAPE::EndEdit().

◆ EndsSwapped()

bool EDA_SHAPE::EndsSwapped ( ) const
inlineinherited

Have the start and end points been swapped since they were set?

Returns
true if they have

Definition at line 166 of file eda_shape.h.

166 { return m_endsSwapped; }
bool m_endsSwapped
Definition: eda_shape.h:300

References EDA_SHAPE::m_endsSwapped.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::makeTracksFromShapes().

◆ Flip() [1/2]

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

Flip this object, i.e.

change the board side for this object.

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

Reimplemented from BOARD_ITEM.

Reimplemented in FP_SHAPE.

Definition at line 115 of file pcb_shape.cpp.

116 {
117  flip( aCentre, aFlipLeftRight );
118 
119  SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) );
120 }
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:163
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Definition: lset.cpp:530
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:36
void flip(const wxPoint &aCentre, bool aFlipLeftRight)
Definition: eda_shape.cpp:281
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:142

References EDA_SHAPE::flip(), FlipLayer(), BOARD_ITEM::GetBoard(), BOARD_ITEM::GetLayer(), and BOARD_ITEM::SetLayer().

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::getShapeFromVertex().

◆ Flip() [2/2]

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

Definition at line 269 of file board_item.h.

270  {
271  Flip( wxPoint( aCentre.x, aCentre.y ), aFlipLeftRight );
272  }
virtual void Flip(const wxPoint &aCentre, bool aFlipLeftRight)
Flip this object, i.e.
Definition: board_item.cpp:196

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

◆ flip()

void EDA_SHAPE::flip ( const wxPoint &  aCentre,
bool  aFlipLeftRight 
)
protectedinherited

Definition at line 281 of file eda_shape.cpp.

282 {
283  switch ( m_shape )
284  {
285  case SHAPE_T::SEGMENT:
286  case SHAPE_T::RECT:
287  if( aFlipLeftRight )
288  {
289  m_start.x = aCentre.x - ( m_start.x - aCentre.x );
290  m_end.x = aCentre.x - ( m_end.x - aCentre.x );
291  }
292  else
293  {
294  m_start.y = aCentre.y - ( m_start.y - aCentre.y );
295  m_end.y = aCentre.y - ( m_end.y - aCentre.y );
296  }
297 
298  std::swap( m_start, m_end );
299  break;
300 
301  case SHAPE_T::CIRCLE:
302  if( aFlipLeftRight )
303  {
304  m_start.x = aCentre.x - ( m_start.x - aCentre.x );
305  m_end.x = aCentre.x - ( m_end.x - aCentre.x );
306  }
307  else
308  {
309  m_start.y = aCentre.y - ( m_start.y - aCentre.y );
310  m_end.y = aCentre.y - ( m_end.y - aCentre.y );
311  }
312  break;
313 
314  case SHAPE_T::ARC:
315  if( aFlipLeftRight )
316  {
317  m_start.x = aCentre.x - ( m_start.x - aCentre.x );
318  m_end.x = aCentre.x - ( m_end.x - aCentre.x );
319  m_arcCenter.x = aCentre.x - ( m_arcCenter.x - aCentre.x );
320  }
321  else
322  {
323  m_start.y = aCentre.y - ( m_start.y - aCentre.y );
324  m_end.y = aCentre.y - ( m_end.y - aCentre.y );
325  m_arcCenter.y = aCentre.y - ( m_arcCenter.y - aCentre.y );
326  }
327 
328  std::swap( m_start, m_end );
329  break;
330 
331  case SHAPE_T::POLY:
332  m_poly.Mirror( aFlipLeftRight, !aFlipLeftRight, VECTOR2I( aCentre ) );
333  break;
334 
335  case SHAPE_T::BEZIER:
336  if( aFlipLeftRight )
337  {
338  m_start.x = aCentre.x - ( m_start.x - aCentre.x );
339  m_end.x = aCentre.x - ( m_end.x - aCentre.x );
340  m_bezierC1.x = aCentre.x - ( m_bezierC1.x - aCentre.x );
341  m_bezierC2.x = aCentre.x - ( m_bezierC2.x - aCentre.x );
342  }
343  else
344  {
345  m_start.y = aCentre.y - ( m_start.y - aCentre.y );
346  m_end.y = aCentre.y - ( m_end.y - aCentre.y );
347  m_bezierC1.y = aCentre.y - ( m_bezierC1.y - aCentre.y );
348  m_bezierC2.y = aCentre.y - ( m_bezierC2.y - aCentre.y );
349  }
350 
351  // Rebuild the poly points shape
352  {
353  std::vector<wxPoint> ctrlPoints = { m_start, m_bezierC1, m_bezierC2, m_end };
354  BEZIER_POLY converter( ctrlPoints );
355  converter.GetPoly( m_bezierPoints, m_width );
356  }
357  break;
358 
359  default:
361  break;
362  }
363 }
SHAPE_T m_shape
Definition: eda_shape.h:301
wxPoint m_bezierC1
Definition: eda_shape.h:309
VECTOR2< int > VECTOR2I
Definition: vector2d.h:622
wxPoint m_end
Definition: eda_shape.h:305
wxPoint m_arcCenter
Definition: eda_shape.h:307
void Mirror(bool aX=true, bool aY=false, const VECTOR2I &aRef={ 0, 0 })
Mirror the line points about y or x (or both)
wxPoint m_bezierC2
Definition: eda_shape.h:310
std::vector< wxPoint > m_bezierPoints
Definition: eda_shape.h:312
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:313
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:120
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:71
wxPoint m_start
Definition: eda_shape.h:304
Bezier curves to polygon converter.
Definition: bezier_curves.h:36
int m_width
Definition: eda_shape.h:302

References ARC, BEZIER, CIRCLE, BEZIER_POLY::GetPoly(), EDA_SHAPE::m_arcCenter, EDA_SHAPE::m_bezierC1, EDA_SHAPE::m_bezierC2, EDA_SHAPE::m_bezierPoints, EDA_SHAPE::m_end, EDA_SHAPE::m_poly, EDA_SHAPE::m_shape, EDA_SHAPE::m_start, EDA_SHAPE::m_width, SHAPE_POLY_SET::Mirror(), POLY, RECT, SEGMENT, EDA_SHAPE::SHAPE_T_asString(), and UNIMPLEMENTED_FOR.

Referenced by Flip(), LIB_SHAPE::MirrorHorizontal(), and LIB_SHAPE::MirrorVertical().

◆ Get() [1/3]

wxAny INSPECTABLE::Get ( PROPERTY_BASE aProperty)
inlineinherited

Definition at line 86 of file inspectable.h.

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

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

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

◆ Get() [2/3]

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

Definition at line 95 of file inspectable.h.

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

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

◆ Get() [3/3]

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

Definition at line 104 of file inspectable.h.

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

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

◆ GetArcAngle()

◆ GetArcMid()

◆ GetBezierC1()

◆ GetBezierC2()

◆ GetBezierPoints()

const std::vector<wxPoint>& EDA_SHAPE::GetBezierPoints ( ) const
inlineinherited

◆ GetBoard() [1/2]

const BOARD * BOARD_ITEM::GetBoard ( ) const
virtualinherited

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

Definition at line 36 of file board_item.cpp.

37 {
38  if( Type() == PCB_T )
39  return static_cast<const BOARD*>( this );
40 
41  BOARD_ITEM* parent = GetParent();
42 
43  if( parent )
44  return parent->GetBoard();
45 
46  return nullptr;
47 }
Definition: typeinfo.h:84
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:36
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:135
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

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

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

◆ GetBoard() [2/2]

BOARD * BOARD_ITEM::GetBoard ( )
virtualinherited

Definition at line 50 of file board_item.cpp.

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

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

◆ GetBoundingBox()

const EDA_RECT PCB_SHAPE::GetBoundingBox ( ) const
inlineoverridevirtual

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

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

Reimplemented from EDA_ITEM.

Definition at line 101 of file pcb_shape.h.

101 { return getBoundingBox(); }
const EDA_RECT getBoundingBox() const
Definition: eda_shape.cpp:612

References EDA_SHAPE::getBoundingBox().

Referenced by BOARD_ADAPTER::addShapeWithClearance().

◆ getBoundingBox()

const EDA_RECT EDA_SHAPE::getBoundingBox ( ) const
protectedinherited

Definition at line 612 of file eda_shape.cpp.

613 {
614  EDA_RECT bbox;
615 
616  switch( m_shape )
617  {
618  case SHAPE_T::RECT:
619  for( wxPoint& pt : GetRectCorners() )
620  bbox.Merge( pt );
621 
622  break;
623 
624  case SHAPE_T::SEGMENT:
625  bbox.SetOrigin( GetStart() );
626  bbox.SetEnd( GetEnd() );
627  break;
628 
629  case SHAPE_T::CIRCLE:
630  bbox.SetOrigin( GetStart() );
631  bbox.Inflate( GetRadius() );
632  break;
633 
634  case SHAPE_T::ARC:
635  computeArcBBox( bbox );
636  break;
637 
638  case SHAPE_T::POLY:
639  if( m_poly.IsEmpty() )
640  break;
641 
642  for( auto iter = m_poly.CIterate(); iter; iter++ )
643  {
644  wxPoint pt( iter->x, iter->y );
645 
647  pt += getParentPosition();
648 
649  bbox.Merge( pt );
650  }
651 
652  break;
653 
654  case SHAPE_T::BEZIER:
655  bbox.SetOrigin( GetStart() );
656  bbox.Merge( GetBezierC1() );
657  bbox.Merge( GetBezierC2() );
658  bbox.Merge( GetEnd() );
659  break;
660 
661  default:
663  break;
664  }
665 
666  bbox.Inflate( std::max( 0, m_width / 2 ) );
667  bbox.Normalize();
668 
669  return bbox;
670 }
SHAPE_T m_shape
Definition: eda_shape.h:301
void Merge(const EDA_RECT &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: eda_rect.cpp:432
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:97
bool IsEmpty() const
void computeArcBBox(EDA_RECT &aBBox) const
Definition: eda_shape.cpp:995
virtual wxPoint getParentPosition() const =0
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:121
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
const wxPoint & GetBezierC1() const
Definition: eda_shape.h:145
std::vector< wxPoint > GetRectCorners() const
Definition: eda_shape.cpp:959
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:122
void SetEnd(int x, int y)
Definition: eda_rect.h:182
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:313
const wxPoint & GetBezierC2() const
Definition: eda_shape.h:148
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:120
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:71
CONST_ITERATOR CIterate(int aFirst, int aLast, bool aIterateHoles=false) const
void Normalize()
Ensures that the height ant width are positive.
Definition: eda_rect.cpp:35
virtual double getParentOrientation() const =0
Handle the component boundary box.
Definition: eda_rect.h:42
int m_width
Definition: eda_shape.h:302
int GetRadius() const
Definition: eda_shape.cpp:466
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:364

References ARC, BEZIER, CIRCLE, SHAPE_POLY_SET::CIterate(), EDA_SHAPE::computeArcBBox(), EDA_SHAPE::GetBezierC1(), EDA_SHAPE::GetBezierC2(), EDA_SHAPE::GetEnd(), EDA_SHAPE::getParentOrientation(), EDA_SHAPE::getParentPosition(), EDA_SHAPE::GetRadius(), EDA_SHAPE::GetRectCorners(), EDA_SHAPE::GetStart(), EDA_RECT::Inflate(), SHAPE_POLY_SET::IsEmpty(), EDA_SHAPE::m_poly, EDA_SHAPE::m_shape, EDA_SHAPE::m_width, EDA_RECT::Merge(), EDA_RECT::Normalize(), POLY, RECT, RotatePoint(), SEGMENT, EDA_RECT::SetEnd(), EDA_RECT::SetOrigin(), EDA_SHAPE::SHAPE_T_asString(), and UNIMPLEMENTED_FOR.

Referenced by LIB_SHAPE::GetBoundingBox(), GetBoundingBox(), EDA_SHAPE::getCenter(), and EDA_SHAPE::hitTest().

◆ GetCenter()

◆ getCenter()

wxPoint EDA_SHAPE::getCenter ( ) const
inherited

Definition at line 393 of file eda_shape.cpp.

394 {
395  switch( m_shape )
396  {
397  case SHAPE_T::ARC:
398  return m_arcCenter;
399 
400  case SHAPE_T::CIRCLE:
401  return m_start;
402 
403  case SHAPE_T::SEGMENT:
404  // Midpoint of the line
405  return ( m_start + m_end ) / 2;
406 
407  case SHAPE_T::POLY:
408  case SHAPE_T::RECT:
409  case SHAPE_T::BEZIER:
410  return getBoundingBox().Centre();
411 
412  default:
414  return wxPoint();
415  }
416 }
SHAPE_T m_shape
Definition: eda_shape.h:301
wxPoint m_end
Definition: eda_shape.h:305
wxPoint m_arcCenter
Definition: eda_shape.h:307
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:120
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:71
wxPoint m_start
Definition: eda_shape.h:304
const EDA_RECT getBoundingBox() const
Definition: eda_shape.cpp:612
wxPoint Centre() const
Definition: eda_rect.h:55

References ARC, BEZIER, EDA_RECT::Centre(), CIRCLE, EDA_SHAPE::getBoundingBox(), EDA_SHAPE::m_arcCenter, EDA_SHAPE::m_end, EDA_SHAPE::m_shape, EDA_SHAPE::m_start, POLY, RECT, SEGMENT, EDA_SHAPE::SHAPE_T_asString(), and UNIMPLEMENTED_FOR.

Referenced by EDA_SHAPE::CalcArcAngles(), GetCenter(), LIB_SHAPE::GetCenter(), EDA_SHAPE::getPosition(), EDA_SHAPE::hitTest(), EDA_SHAPE::MakeEffectiveShapes(), LIB_SHAPE::Plot(), LIB_SHAPE::print(), and EDA_SHAPE::TransformShapeWithClearanceToPolygon().

◆ GetClass()

wxString PCB_SHAPE::GetClass ( ) const
inlineoverridevirtual

Return the class name.

Implements EDA_ITEM.

Definition at line 55 of file pcb_shape.h.

56  {
57  return wxT( "PCB_SHAPE" );
58  }

◆ GetEditFlags()

EDA_ITEM_FLAGS EDA_ITEM::GetEditFlags ( ) const
inlineinherited

Definition at line 157 of file eda_item.h.

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

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

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

◆ GetEffectiveShape()

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

Make a set of SHAPE objects representing the PCB_SHAPE.

Caller owns the objects.

Reimplemented from BOARD_ITEM.

Definition at line 192 of file pcb_shape.cpp.

193 {
194  return std::make_shared<SHAPE_COMPOUND>( MakeEffectiveShapes() );
195 }
std::vector< SHAPE * > MakeEffectiveShapes() const
Make a set of SHAPE objects representing the EDA_SHAPE.
Definition: eda_shape.cpp:1073

References EDA_SHAPE::MakeEffectiveShapes().

◆ GetEnd()

const wxPoint& EDA_SHAPE::GetEnd ( ) const
inlineinherited

Return the ending point of the graphic.

Definition at line 122 of file eda_shape.h.

122 { return m_end; }
wxPoint m_end
Definition: eda_shape.h:305

References EDA_SHAPE::m_end.

Referenced by PCB_POINT_EDITOR::addCorner(), BOARD_ADAPTER::addShapeWithClearance(), GRAPHICS_CLEANER::areEquivalent(), LIB_SHAPE::CalcArcAngles(), EDA_SHAPE::CalcArcAngles(), EDA_SHAPE::calcEdit(), PCB_GRID_HELPER::computeAnchors(), ConvertOutlineToPolygon(), CreateBoardSection(), CONVERT_TOOL::CreateLines(), MICROWAVE_TOOL::createMicrowaveInductor(), KIGFX::SCH_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), PCB_POINT_EDITOR::editArcEndpointKeepTangent(), PCB_PLUGIN::format(), formatArc(), formatBezier(), formatRect(), EDA_SHAPE::getBoundingBox(), EDA_SHAPE::GetLength(), EDA_SHAPE::GetRectCorners(), CADSTAR_SCH_ARCHIVE_LOADER::getScaledLibPart(), CONVERT_TOOL::getStartEndPoints(), hash_fp_item(), EDA_SHAPE::hitTest(), idf_export_outline(), GRAPHICS_CLEANER::isNullShape(), SCH_LEGACY_PLUGIN_CACHE::loadArc(), SCH_EAGLE_PLUGIN::loadSymbolRectangle(), EDIT_POINTS_FACTORY::Make(), EDA_SHAPE::MakeEffectiveShapes(), DSN::SPECCTRA_DB::makeIMAGE(), PCB_POINT_EDITOR::makePoints(), CONVERT_TOOL::makePolysFromRects(), CONVERT_TOOL::makePolysFromSegs(), GRAPHICS_CLEANER::mergeRects(), PCB_PARSER::parsePAD(), BRDITEMS_PLOTTER::PlotFootprintGraphicItem(), BRDITEMS_PLOTTER::PlotPcbShape(), SCH_LEGACY_PLUGIN_CACHE::saveArc(), SCH_LEGACY_PLUGIN_CACHE::saveRectangle(), EDA_SHAPE::ShapeGetMsgPanelInfo(), AR_MATRIX::TraceSegmentPcb(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow(), DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataToWindow(), EDA_SHAPE::TransformShapeWithClearanceToPolygon(), EE_POINT_EDITOR::updatePoints(), and PCB_POINT_EDITOR::updatePoints().

◆ GetEndX()

int EDA_SHAPE::GetEndX ( )
inlineinherited

Definition at line 124 of file eda_shape.h.

124 { return m_end.x; }
wxPoint m_end
Definition: eda_shape.h:305

References EDA_SHAPE::m_end.

Referenced by EDA_SHAPE_DESC::EDA_SHAPE_DESC(), PCB_SHAPE_DESC::PCB_SHAPE_DESC(), and DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run().

◆ GetEndY()

int EDA_SHAPE::GetEndY ( )
inlineinherited

Definition at line 123 of file eda_shape.h.

123 { return m_end.y; }
wxPoint m_end
Definition: eda_shape.h:305

References EDA_SHAPE::m_end.

Referenced by EDA_SHAPE_DESC::EDA_SHAPE_DESC(), PCB_SHAPE_DESC::PCB_SHAPE_DESC(), and DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run().

◆ GetFillType()

◆ GetFlags()

◆ GetFocusPosition()

const wxPoint PCB_SHAPE::GetFocusPosition ( ) const
overridevirtual

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

For some shapes this is similar to GetCenter(), but for unfilled shapes a point on the outline is better.

Reimplemented from EDA_ITEM.

Definition at line 55 of file pcb_shape.cpp.

56 {
57  // For some shapes return the visual center, but for not filled polygonal shapes,
58  // the center is usually far from the shape: a point on the outline is better
59 
60  switch( m_shape )
61  {
62  case SHAPE_T::CIRCLE:
63  if( !IsFilled() )
64  return wxPoint( GetCenter().x + GetRadius(), GetCenter().y );
65  else
66  return GetCenter();
67 
68  case SHAPE_T::RECT:
69  if( !IsFilled() )
70  return GetStart();
71  else
72  return GetCenter();
73 
74  case SHAPE_T::POLY:
75  if( !IsFilled() )
76  {
77  VECTOR2I pos = GetPolyShape().Outline(0).CPoint(0);
78  return wxPoint( pos.x, pos.y );
79  }
80  else
81  {
82  return GetCenter();
83  }
84 
85  case SHAPE_T::ARC:
86  return GetArcMid();
87 
88  case SHAPE_T::BEZIER:
89  return GetStart();
90 
91  default:
92  return GetCenter();
93  }
94 }
SHAPE_T m_shape
Definition: eda_shape.h:301
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:97
bool IsFilled() const
Definition: eda_shape.h:81
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
SHAPE_LINE_CHAIN & Outline(int aIndex)
wxPoint GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_shape.h:79
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:207
wxPoint GetArcMid() const
Definition: eda_shape.cpp:437
int GetRadius() const
Definition: eda_shape.cpp:466

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

◆ GetLayer()

virtual PCB_LAYER_ID BOARD_ITEM::GetLayer ( ) const
inlinevirtualinherited

Return the primary layer this item is on.

Reimplemented in ZONE.

Definition at line 142 of file board_item.h.

142 { return m_layer; }
PCB_LAYER_ID m_layer
Definition: board_item.h:318

References BOARD_ITEM::m_layer.

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

◆ GetLayerName()

wxString BOARD_ITEM::GetLayerName ( ) const
inherited

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

Returns
the layer name associated with this item.

Definition at line 75 of file board_item.cpp.

76 {
77  const BOARD* board = GetBoard();
78 
79  if( board )
80  return board->GetLayerName( m_layer );
81 
82  // If no parent, return standard name
84 }
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:362
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:191
PCB_LAYER_ID m_layer
Definition: board_item.h:318
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:36
static wxString GetStandardLayerName(PCB_LAYER_ID aLayerId)
Return an "English Standard" name of a PCB layer when given aLayerNumber.
Definition: board.h:606

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

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

◆ GetLayerSet()

◆ GetLength()

double EDA_SHAPE::GetLength ( ) const
inherited

Return the length of the track using the hypotenuse calculation.

Returns
the length of the track

Definition at line 106 of file eda_shape.cpp.

107 {
108  double length = 0.0;
109 
110  switch( m_shape )
111  {
112  case SHAPE_T::BEZIER:
113  for( size_t ii = 1; ii < m_bezierPoints.size(); ++ii )
114  length += GetLineLength( m_bezierPoints[ ii - 1], m_bezierPoints[ii] );
115 
116  return length;
117 
118  case SHAPE_T::SEGMENT:
119  return GetLineLength( GetStart(), GetEnd() );
120 
121  case SHAPE_T::POLY:
122  for( int ii = 0; ii < m_poly.COutline( 0 ).SegmentCount(); ii++ )
123  length += m_poly.COutline( 0 ).CSegment( ii ).Length();
124 
125  return length;
126 
127  case SHAPE_T::ARC:
128  return 2 * M_PI * GetRadius() * ( GetArcAngle() / 3600.0 );
129 
130  default:
132  return 0.0;
133  }
134 }
int Length() const
Return the length (this).
Definition: seg.h:350
SHAPE_T m_shape
Definition: eda_shape.h:301
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:222
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:97
double GetArcAngle() const
Definition: eda_shape.cpp:514
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:122
std::vector< wxPoint > m_bezierPoints
Definition: eda_shape.h:312
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:313
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:120
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:71
int SegmentCount() const
Return the number of segments in this line chain.
const SEG CSegment(int aIndex) const
Return a constant copy of the aIndex segment in the line chain.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
int GetRadius() const
Definition: eda_shape.cpp:466

References ARC, BEZIER, SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CSegment(), EDA_SHAPE::GetArcAngle(), EDA_SHAPE::GetEnd(), GetLineLength(), EDA_SHAPE::GetRadius(), EDA_SHAPE::GetStart(), SEG::Length(), EDA_SHAPE::m_bezierPoints, EDA_SHAPE::m_poly, EDA_SHAPE::m_shape, POLY, SEGMENT, SHAPE_LINE_CHAIN::SegmentCount(), EDA_SHAPE::SHAPE_T_asString(), and UNIMPLEMENTED_FOR.

Referenced by EDA_SHAPE::ShapeGetMsgPanelInfo().

◆ GetMenuImage()

BITMAPS PCB_SHAPE::GetMenuImage ( ) const
overridevirtual

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

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

Returns
The menu image associated with the item.

Reimplemented from EDA_ITEM.

Reimplemented in FP_SHAPE.

Definition at line 169 of file pcb_shape.cpp.

References add_dashed_line.

◆ GetMsgPanelInfo()

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

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

Parameters
aListis the list to populate.

Reimplemented from EDA_ITEM.

Definition at line 150 of file pcb_shape.cpp.

151 {
152  aList.emplace_back( _( "Type" ), _( "Drawing" ) );
153 
154  if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )
155  aList.emplace_back( _( "Status" ), _( "Locked" ) );
156 
157  ShapeGetMsgPanelInfo( aFrame, aList );
158 
159  aList.emplace_back( _( "Layer" ), GetLayerName() );
160 }
void ShapeGetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
Definition: eda_shape.cpp:538
virtual bool IsLocked() const
Definition: board_item.cpp:64
#define _(s)
#define PCB_EDIT_FRAME_NAME
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
Definition: board_item.cpp:75

References _, BOARD_ITEM::GetLayerName(), BOARD_ITEM::IsLocked(), PCB_EDIT_FRAME_NAME, and EDA_SHAPE::ShapeGetMsgPanelInfo().

Referenced by FP_SHAPE::GetMsgPanelInfo().

◆ GetParent()

BOARD_ITEM_CONTAINER* BOARD_ITEM::GetParent ( void  ) const
inlineinherited

Definition at line 135 of file board_item.h.

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

References EDA_ITEM::m_parent.

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

◆ GetParentFootprint()

FOOTPRINT * PCB_SHAPE::GetParentFootprint ( ) const

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

Returns
the parent footprint or NULL.

Definition at line 123 of file pcb_shape.cpp.

124 {
125  if( !m_parent || m_parent->Type() != PCB_FOOTPRINT_T )
126  return nullptr;
127 
128  return (FOOTPRINT*) m_parent;
129 }
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:478
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

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

Referenced by ConvertOutlineToPolygon(), KIGFX::PCB_PAINTER::draw(), getParentOrientation(), getParentPosition(), and BRDITEMS_PLOTTER::PlotFootprintGraphicItem().

◆ GetParentGroup()

◆ getParentOrientation()

double PCB_SHAPE::getParentOrientation ( ) const
overrideprotectedvirtual

Implements EDA_SHAPE.

Definition at line 132 of file pcb_shape.cpp.

133 {
134  if( GetParentFootprint() )
136  else
137  return 0.0;
138 }
double GetOrientation() const
Definition: footprint.h:191
FOOTPRINT * GetParentFootprint() const
Return the parent footprint or NULL if PCB_SHAPE does not belong to a footprint.
Definition: pcb_shape.cpp:123

References FOOTPRINT::GetOrientation(), and GetParentFootprint().

◆ getParentPosition()

wxPoint PCB_SHAPE::getParentPosition ( ) const
overrideprotectedvirtual

Implements EDA_SHAPE.

Definition at line 141 of file pcb_shape.cpp.

142 {
143  if( GetParentFootprint() )
144  return GetParentFootprint()->GetPosition();
145  else
146  return wxPoint( 0, 0 );
147 }
FOOTPRINT * GetParentFootprint() const
Return the parent footprint or NULL if PCB_SHAPE does not belong to a footprint.
Definition: pcb_shape.cpp:123
wxPoint GetPosition() const override
Definition: footprint.h:187

References GetParentFootprint(), and FOOTPRINT::GetPosition().

◆ GetPointCount()

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

Definition at line 1197 of file eda_shape.cpp.

1198 {
1199  // return the number of corners of the polygonal shape
1200  // this shape is expected to be only one polygon without hole
1201  if( GetPolyShape().OutlineCount() )
1202  return GetPolyShape().VertexCount( 0 );
1203 
1204  return 0;
1205 }
int VertexCount(int aOutline=-1, int aHole=-1) const
Return the number of points in the shape poly set.
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:207

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

Referenced by GRAPHICS_CLEANER::isNullShape(), and EE_POINT_EDITOR::updatePoints().

◆ GetPolyShape() [1/2]

◆ GetPolyShape() [2/2]

const SHAPE_POLY_SET& EDA_SHAPE::GetPolyShape ( ) const
inlineinherited

Definition at line 208 of file eda_shape.h.

208 { return m_poly; }
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:313

References EDA_SHAPE::m_poly.

◆ GetPosition()

wxPoint PCB_SHAPE::GetPosition ( ) const
inlineoverridevirtual

Reimplemented from EDA_ITEM.

Definition at line 77 of file pcb_shape.h.

77 { return getPosition(); }
wxPoint getPosition() const
Definition: eda_shape.cpp:95

References EDA_SHAPE::getPosition().

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

◆ getPosition()

wxPoint EDA_SHAPE::getPosition ( ) const
protectedinherited

Definition at line 95 of file eda_shape.cpp.

96 {
97  if( m_shape == SHAPE_T::ARC )
98  return getCenter();
99  else if( m_shape == SHAPE_T::POLY )
100  return (wxPoint) m_poly.CVertex( 0 );
101  else
102  return m_start;
103 }
SHAPE_T m_shape
Definition: eda_shape.h:301
wxPoint getCenter() const
Definition: eda_shape.cpp:393
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Return the aGlobalIndex-th vertex in the poly set.
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:313
wxPoint m_start
Definition: eda_shape.h:304

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

Referenced by GetPosition(), LIB_SHAPE::GetPosition(), and EDA_SHAPE::setPosition().

◆ GetRadius()

int EDA_SHAPE::GetRadius ( ) const
inherited

Definition at line 466 of file eda_shape.cpp.

467 {
468  double radius = 0.0;
469 
470  switch( m_shape )
471  {
472  case SHAPE_T::ARC:
473  radius = GetLineLength( m_arcCenter, m_start );
474  break;
475 
476  case SHAPE_T::CIRCLE:
477  radius = GetLineLength( m_start, m_end );
478  break;
479 
480  default:
482  }
483 
484  // don't allow degenerate circles/arcs
485  return std::max( 1, KiROUND( radius ) );
486 }
SHAPE_T m_shape
Definition: eda_shape.h:301
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:222
wxPoint m_end
Definition: eda_shape.h:305
wxPoint m_arcCenter
Definition: eda_shape.h:307
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:120
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:71
wxPoint m_start
Definition: eda_shape.h:304
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73

References ARC, CIRCLE, GetLineLength(), KiROUND(), EDA_SHAPE::m_arcCenter, EDA_SHAPE::m_end, EDA_SHAPE::m_shape, EDA_SHAPE::m_start, EDA_SHAPE::SHAPE_T_asString(), and UNIMPLEMENTED_FOR.

Referenced by BOARD_ADAPTER::addShapeWithClearance(), EDA_SHAPE::calcEdit(), EDA_SHAPE::computeArcBBox(), ConvertOutlineToPolygon(), KIGFX::SCH_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), formatCircle(), EDA_SHAPE::getBoundingBox(), GetFocusPosition(), EDA_SHAPE::GetLength(), LIB_SHAPE::GetSelectMenuText(), hash_fp_item(), EDA_SHAPE::hitTest(), idf_export_outline(), GRAPHICS_CLEANER::isNullShape(), EDA_SHAPE::MakeEffectiveShapes(), DSN::SPECCTRA_DB::makeIMAGE(), CONVERT_TOOL::makePolysFromCircles(), ALTIUM_PCB::Parse(), PCB_PARSER::parsePAD(), LIB_SHAPE::Plot(), BRDITEMS_PLOTTER::PlotPcbShape(), LIB_SHAPE::print(), SCH_LEGACY_PLUGIN_CACHE::saveArc(), SCH_LEGACY_PLUGIN_CACHE::saveCircle(), EDA_SHAPE::scale(), EDA_SHAPE::ShapeGetMsgPanelInfo(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow(), DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataToWindow(), and EDA_SHAPE::TransformShapeWithClearanceToPolygon().

◆ GetRectCorners()

std::vector< wxPoint > EDA_SHAPE::GetRectCorners ( ) const
inherited

Definition at line 959 of file eda_shape.cpp.

960 {
961  std::vector<wxPoint> pts;
962  wxPoint topLeft = GetStart();
963  wxPoint botRight = GetEnd();
964 
965  // Un-rotate rect topLeft and botRight
966  if( KiROUND( getParentOrientation() ) % 900 != 0 )
967  {
968  topLeft -= getParentPosition();
969  RotatePoint( &topLeft, -getParentOrientation() );
970 
971  botRight -= getParentPosition();
972  RotatePoint( &botRight, -getParentOrientation() );
973  }
974 
975  // Set up the un-rotated 4 corners
976  pts.emplace_back( topLeft );
977  pts.emplace_back( botRight.x, topLeft.y );
978  pts.emplace_back( botRight );
979  pts.emplace_back( topLeft.x, botRight.y );
980 
981  // Now re-rotate the 4 corners to get a diamond
982  if( KiROUND( getParentOrientation() ) % 900 != 0 )
983  {
984  for( wxPoint& pt : pts )
985  {
987  pt += getParentPosition();
988  }
989  }
990 
991  return pts;
992 }
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:97
virtual wxPoint getParentPosition() const =0
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:122
virtual double getParentOrientation() const =0
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73

References EDA_SHAPE::GetEnd(), EDA_SHAPE::getParentOrientation(), EDA_SHAPE::getParentPosition(), EDA_SHAPE::GetStart(), KiROUND(), and RotatePoint().

Referenced by BOARD_ADAPTER::addShapeWithClearance(), ConvertOutlineToPolygon(), KIGFX::PCB_PAINTER::draw(), EDA_SHAPE::getBoundingBox(), EDA_SHAPE::hitTest(), EDA_SHAPE::MakeEffectiveShapes(), BRDITEMS_PLOTTER::PlotFootprintGraphicItem(), BRDITEMS_PLOTTER::PlotPcbShape(), and EDA_SHAPE::TransformShapeWithClearanceToPolygon().

◆ GetSelectMenuText()

wxString PCB_SHAPE::GetSelectMenuText ( EDA_UNITS  aUnits) const
overridevirtual

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

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

Returns
The menu text string.

Reimplemented from EDA_ITEM.

Reimplemented in FP_SHAPE.

Definition at line 163 of file pcb_shape.cpp.

164 {
165  return wxString::Format( _( "%s on %s" ), ShowShape(), GetLayerName() );
166 }
wxString ShowShape() const
Definition: eda_shape.cpp:56
#define _(s)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
Definition: board_item.cpp:75

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

◆ GetShape()

SHAPE_T EDA_SHAPE::GetShape ( ) const
inlineinherited

Definition at line 92 of file eda_shape.h.

92 { return m_shape; }
SHAPE_T m_shape
Definition: eda_shape.h:301

References EDA_SHAPE::m_shape.

Referenced by PCB_POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), LIB_SHAPE::AddPoint(), BOARD_ADAPTER::addShapeWithClearance(), GRAPHICS_CLEANER::areEquivalent(), EDA_SHAPE::beginEdit(), EDA_SHAPE::calcEdit(), PCB_POINT_EDITOR::canAddCorner(), GRAPHICS_CLEANER::cleanupSegments(), PCB_GRID_HELPER::computeAnchors(), EDA_SHAPE::continueEdit(), ConvertOutlineToPolygon(), CONVERT_TOOL::CreateLines(), KIGFX::SCH_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), EDA_SHAPE_DESC::EDA_SHAPE_DESC(), EDA_SHAPE::endEdit(), PAD_TOOL::explodePad(), CADSTAR_SCH_ARCHIVE_LOADER::fixUpLibraryPins(), FP_SHAPE::Flip(), FootprintWriteShape(), PCB_PLUGIN::format(), FOOTPRINT::GetCoverageArea(), LIB_SHAPE::GetMenuImage(), CADSTAR_SCH_ARCHIVE_LOADER::getScaledLibPart(), LIB_SHAPE::GetSelectMenuText(), EE_SELECTION_TOOL::GuessSelectionCandidates(), hash_fp_item(), idf_export_outline(), GRAPHICS_CLEANER::isNullShape(), EE_POINT_EDITOR::Main(), EDIT_POINTS_FACTORY::Make(), DSN::SPECCTRA_DB::makeIMAGE(), PCB_POINT_EDITOR::makePoints(), CONVERT_TOOL::makePolysFromCircles(), CONVERT_TOOL::makePolysFromRects(), GRAPHICS_CLEANER::mergeRects(), FP_SHAPE::Mirror(), FP_SHAPE::Move(), PCB_SHAPE::cmp_drawings::operator()(), FOOTPRINT::cmp_drawings::operator()(), ALTIUM_PCB::Parse(), LIB_SHAPE::Plot(), BRDITEMS_PLOTTER::PlotFootprintGraphicItem(), BRDITEMS_PLOTTER::PlotPcbShape(), LIB_SHAPE::print(), PAD_TOOL::recombinePad(), PCB_POINT_EDITOR::removeCorner(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run(), SCH_LEGACY_PLUGIN_CACHE::saveArc(), SCH_LEGACY_PLUGIN_CACHE::saveBezier(), SCH_LEGACY_PLUGIN_CACHE::saveCircle(), SCH_LEGACY_PLUGIN_CACHE::savePolyLine(), SCH_LEGACY_PLUGIN_CACHE::saveRectangle(), SCH_LEGACY_PLUGIN_CACHE::SaveSymbol(), SCH_SEXPR_PLUGIN_CACHE::saveSymbolDrawItem(), PNS_KICAD_IFACE_BASE::syncGraphicalItem(), AR_MATRIX::TraceSegmentPcb(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataFromWindow(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow(), DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataToWindow(), PCB_POINT_EDITOR::updateItem(), EE_POINT_EDITOR::updateParentItem(), EE_POINT_EDITOR::updatePoints(), PCB_POINT_EDITOR::updatePoints(), and DIALOG_GRAPHIC_ITEM_PROPERTIES::Validate().

◆ GetStart()

const wxPoint& EDA_SHAPE::GetStart ( ) const
inlineinherited

Return the starting point of the graphic.

Definition at line 97 of file eda_shape.h.

97 { return m_start; }
wxPoint m_start
Definition: eda_shape.h:304

References EDA_SHAPE::m_start.

Referenced by PCB_POINT_EDITOR::addCorner(), BOARD_ADAPTER::addShapeWithClearance(), GRAPHICS_CLEANER::areEquivalent(), LIB_SHAPE::CalcArcAngles(), EDA_SHAPE::CalcArcAngles(), EDA_SHAPE::calcEdit(), PCB_GRID_HELPER::computeAnchors(), ConvertOutlineToPolygon(), CreateBoardSection(), CONVERT_TOOL::CreateLines(), MICROWAVE_TOOL::createMicrowaveInductor(), KIGFX::PCB_PAINTER::draw(), PCB_POINT_EDITOR::editArcEndpointKeepCenter(), PCB_POINT_EDITOR::editArcEndpointKeepTangent(), PCB_PLUGIN::format(), formatArc(), formatBezier(), formatCircle(), formatRect(), EDA_SHAPE::getBoundingBox(), GetFocusPosition(), EDA_SHAPE::GetLength(), EDA_SHAPE::GetRectCorners(), CADSTAR_SCH_ARCHIVE_LOADER::getScaledLibPart(), CONVERT_TOOL::getStartEndPoints(), hash_fp_item(), EDA_SHAPE::hitTest(), idf_export_outline(), GRAPHICS_CLEANER::isNullShape(), SCH_LEGACY_PLUGIN_CACHE::loadArc(), EDIT_POINTS_FACTORY::Make(), DSN::SPECCTRA_DB::makeIMAGE(), PCB_POINT_EDITOR::makePoints(), CONVERT_TOOL::makePolysFromRects(), CONVERT_TOOL::makePolysFromSegs(), GRAPHICS_CLEANER::mergeRects(), PCB_PARSER::parsePAD(), BRDITEMS_PLOTTER::PlotFootprintGraphicItem(), BRDITEMS_PLOTTER::PlotPcbShape(), BRDITEMS_PLOTTER::PlotPcbTarget(), SCH_LEGACY_PLUGIN_CACHE::saveArc(), EDA_SHAPE::ShapeGetMsgPanelInfo(), AR_MATRIX::TraceSegmentPcb(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataFromWindow(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow(), DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataToWindow(), EDA_SHAPE::TransformShapeWithClearanceToPolygon(), EE_POINT_EDITOR::updatePoints(), and PCB_POINT_EDITOR::updatePoints().

◆ GetStartX()

int EDA_SHAPE::GetStartX ( )
inlineinherited

Definition at line 99 of file eda_shape.h.

99 { return m_start.x; }
wxPoint m_start
Definition: eda_shape.h:304

References EDA_SHAPE::m_start.

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

◆ GetStartY()

int EDA_SHAPE::GetStartY ( )
inlineinherited

Definition at line 98 of file eda_shape.h.

98 { return m_start.y; }
wxPoint m_start
Definition: eda_shape.h:304

References EDA_SHAPE::m_start.

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

◆ GetState()

int EDA_ITEM::GetState ( EDA_ITEM_FLAGS  type) const
inlineinherited

Definition at line 136 of file eda_item.h.

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

References EDA_ITEM::m_status.

Referenced by BOARD_ITEM::IsLocked().

◆ GetStatus()

EDA_ITEM_FLAGS EDA_ITEM::GetStatus ( ) const
inlineinherited

Definition at line 149 of file eda_item.h.

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

References EDA_ITEM::m_status.

◆ GetWidth()

int EDA_SHAPE::GetWidth ( ) const
inlineinherited

◆ GetX()

int BOARD_ITEM::GetX ( ) const
inlineinherited

◆ GetY()

int BOARD_ITEM::GetY ( ) const
inlineinherited

◆ HasFlag()

◆ HitTest() [1/2]

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

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

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

Reimplemented from EDA_ITEM.

Definition at line 103 of file pcb_shape.h.

104  {
105  return hitTest( aPosition, aAccuracy );
106  }
bool hitTest(const wxPoint &aPosition, int aAccuracy=0) const
Definition: eda_shape.cpp:673

References EDA_SHAPE::hitTest().

Referenced by GENERAL_COLLECTOR::Inspect().

◆ HitTest() [2/2]

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

Test if aRect intersects this item.

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

Reimplemented from EDA_ITEM.

Definition at line 108 of file pcb_shape.h.

109  {
110  return hitTest( aRect, aContained, aAccuracy );
111  }
bool hitTest(const wxPoint &aPosition, int aAccuracy=0) const
Definition: eda_shape.cpp:673

References EDA_SHAPE::hitTest().

◆ hitTest() [1/2]

bool EDA_SHAPE::hitTest ( const wxPoint &  aPosition,
int  aAccuracy = 0 
) const
protectedinherited

Definition at line 673 of file eda_shape.cpp.

674 {
675  int maxdist = aAccuracy;
676 
677  if( m_width > 0 )
678  maxdist += m_width / 2;
679 
680  switch( m_shape )
681  {
682  case SHAPE_T::CIRCLE:
683  {
684  int radius = GetRadius();
685  int dist = KiROUND( EuclideanNorm( aPosition - getCenter() ) );
686 
687  if( IsFilled() )
688  return dist <= radius + maxdist; // Filled circle hit-test
689  else
690  return abs( radius - dist ) <= maxdist; // Ring hit-test
691  }
692 
693  case SHAPE_T::ARC:
694  {
695  if( EuclideanNorm( aPosition - m_start ) <= maxdist )
696  return true;
697 
698  if( EuclideanNorm( aPosition - m_end ) <= maxdist )
699  return true;
700 
701  wxPoint relPos = aPosition - getCenter();
702  int radius = GetRadius();
703  int dist = KiROUND( EuclideanNorm( relPos ) );
704 
705  if( abs( radius - dist ) <= maxdist )
706  {
707  double startAngle;
708  double endAngle;
709  CalcArcAngles( startAngle, endAngle );
710 
711  if( m_eeWinding && NormalizeAngleDegrees( startAngle - endAngle, -180.0, 180.0 ) > 0 )
712  std::swap( startAngle, endAngle );
713 
714  double relPosAngle = 180.0 / M_PI * atan2( relPos.y, relPos.x );
715 
716  startAngle = NormalizeAngleDegrees( startAngle, 0.0, 360.0 );
717  endAngle = NormalizeAngleDegrees( endAngle, 0.0, 360.0 );
718  relPosAngle = NormalizeAngleDegrees( relPosAngle, 0.0, 360.0 );
719 
720  if( endAngle > startAngle )
721  return relPosAngle >= startAngle && relPosAngle <= endAngle;
722  else
723  return relPosAngle >= startAngle || relPosAngle <= endAngle;
724  }
725 
726  return false;
727  }
728 
729  case SHAPE_T::BEZIER:
730  const_cast<EDA_SHAPE*>( this )->RebuildBezierToSegmentsPointsList( m_width );
731 
732  for( unsigned int i= 1; i < m_bezierPoints.size(); i++)
733  {
734  if( TestSegmentHit( aPosition, m_bezierPoints[ i - 1], m_bezierPoints[i], maxdist ) )
735  return true;
736  }
737 
738  return false;
739 
740  case SHAPE_T::SEGMENT:
741  return TestSegmentHit( aPosition, GetStart(), GetEnd(), maxdist );
742 
743  case SHAPE_T::RECT:
744  if( IsFilled() ) // Filled rect hit-test
745  {
746  SHAPE_POLY_SET poly;
747  poly.NewOutline();
748 
749  for( const wxPoint& pt : GetRectCorners() )
750  poly.Append( pt );
751 
752  return poly.Collide( VECTOR2I( aPosition ), maxdist );
753  }
754  else // Open rect hit-test
755  {
756  std::vector<wxPoint> pts = GetRectCorners();
757 
758  return TestSegmentHit( aPosition, pts[0], pts[1], maxdist )
759  || TestSegmentHit( aPosition, pts[1], pts[2], maxdist )
760  || TestSegmentHit( aPosition, pts[2], pts[3], maxdist )
761  || TestSegmentHit( aPosition, pts[3], pts[0], maxdist );
762  }
763 
764  case SHAPE_T::POLY:
765  if( IsFilled() )
766  {
767  return m_poly.Collide( VECTOR2I( aPosition ), maxdist );
768  }
769  else
770  {
772  return m_poly.CollideEdge( VECTOR2I( aPosition ), dummy, maxdist );
773  }
774 
775  default:
777  return false;
778  }
779 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:146
SHAPE_T m_shape
Definition: eda_shape.h:301
wxPoint getCenter() const
Definition: eda_shape.cpp:393
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:97
void CalcArcAngles(double &aStartAngle, double &aEndAngle) const
Calc arc start and end angles such that aStartAngle < aEndAngle.
Definition: eda_shape.cpp:445
Structure to hold the necessary information in order to index a vertex on a SHAPE_POLY_SET object: th...
VECTOR2< int > VECTOR2I
Definition: vector2d.h:622
wxPoint m_end
Definition: eda_shape.h:305
bool IsFilled() const
Definition: eda_shape.h:81
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
std::vector< wxPoint > GetRectCorners() const
Definition: eda_shape.cpp:959
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:122
Represent a set of closed polygons.
std::vector< wxPoint > m_bezierPoints
Definition: eda_shape.h:312
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:313
bool TestSegmentHit(const wxPoint &aRefPoint, const wxPoint &aStart, const wxPoint &aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
Definition: trigo.cpp:129
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:120
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:71
int NewOutline()
Creates a new hole in a given outline.
wxPoint m_start
Definition: eda_shape.h:304
bool Collide(const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if the boundary of shape (this) lies closer to the shape aShape than aClearance,...
bool CollideEdge(const VECTOR2I &aPoint, VERTEX_INDEX &aClosestVertex, int aClearance=0) const
Check whether aPoint collides with any edge of any of the contours of the polygon.
bool m_eeWinding
Definition: eda_shape.h:316
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73
double NormalizeAngleDegrees(double Angle, double aMin, double aMax)
Normalize angle to be aMin < angle <= aMax angle is in degrees.
Definition: trigo.h:327
int m_width
Definition: eda_shape.h:302
int GetRadius() const
Definition: eda_shape.cpp:466
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...

References SHAPE_POLY_SET::Append(), ARC, BEZIER, EDA_SHAPE::CalcArcAngles(), CIRCLE, SHAPE_POLY_SET::Collide(), SHAPE_POLY_SET::CollideEdge(), dummy(), EuclideanNorm(), EDA_SHAPE::getCenter(), EDA_SHAPE::GetEnd(), EDA_SHAPE::GetRadius(), EDA_SHAPE::GetRectCorners(), EDA_SHAPE::GetStart(), EDA_SHAPE::IsFilled(), KiROUND(), EDA_SHAPE::m_bezierPoints, EDA_SHAPE::m_eeWinding, EDA_SHAPE::m_end, EDA_SHAPE::m_poly, EDA_SHAPE::m_shape, EDA_SHAPE::m_start, EDA_SHAPE::m_width, SHAPE_POLY_SET::NewOutline(), NormalizeAngleDegrees(), POLY, RECT, SEGMENT, EDA_SHAPE::SHAPE_T_asString(), TestSegmentHit(), and UNIMPLEMENTED_FOR.

Referenced by LIB_SHAPE::HitTest(), and HitTest().

◆ hitTest() [2/2]

bool EDA_SHAPE::hitTest ( const EDA_RECT aRect,
bool  aContained,
int  aAccuracy = 0 
) const
protectedinherited

Definition at line 782 of file eda_shape.cpp.

783 {
784  EDA_RECT arect = aRect;
785  arect.Normalize();
786  arect.Inflate( aAccuracy );
787 
788  EDA_RECT arcRect;
789  EDA_RECT bb = getBoundingBox();
790 
791  switch( m_shape )
792  {
793  case SHAPE_T::CIRCLE:
794  // Test if area intersects or contains the circle:
795  if( aContained )
796  {
797  return arect.Contains( bb );
798  }
799  else
800  {
801  // If the rectangle does not intersect the bounding box, this is a much quicker test
802  if( !aRect.Intersects( bb ) )
803  {
804  return false;
805  }
806  else
807  {
808  return arect.IntersectsCircleEdge( getCenter(), GetRadius(), GetWidth() );
809  }
810  }
811 
812  case SHAPE_T::ARC:
813  // Test for full containment of this arc in the rect
814  if( aContained )
815  {
816  return arect.Contains( bb );
817  }
818  // Test if the rect crosses the arc
819  else
820  {
821  arcRect = bb.Common( arect );
822 
823  /* All following tests must pass:
824  * 1. Rectangle must intersect arc BoundingBox
825  * 2. Rectangle must cross the outside of the arc
826  */
827  return arcRect.Intersects( arect ) &&
829  }
830 
831  case SHAPE_T::RECT:
832  if( aContained )
833  {
834  return arect.Contains( bb );
835  }
836  else
837  {
838  std::vector<wxPoint> pts = GetRectCorners();
839 
840  // Account for the width of the lines
841  arect.Inflate( GetWidth() / 2 );
842  return ( arect.Intersects( pts[0], pts[1] )
843  || arect.Intersects( pts[1], pts[2] )
844  || arect.Intersects( pts[2], pts[3] )
845  || arect.Intersects( pts[3], pts[0] ) );
846  }
847 
848  case SHAPE_T::SEGMENT:
849  if( aContained )
850  {
851  return arect.Contains( GetStart() ) && aRect.Contains( GetEnd() );
852  }
853  else
854  {
855  // Account for the width of the line
856  arect.Inflate( GetWidth() / 2 );
857  return arect.Intersects( GetStart(), GetEnd() );
858  }
859 
860  case SHAPE_T::POLY:
861  if( aContained )
862  {
863  return arect.Contains( bb );
864  }
865  else
866  {
867  // Fast test: if aRect is outside the polygon bounding box,
868  // rectangles cannot intersect
869  if( !arect.Intersects( bb ) )
870  return false;
871 
872  // Account for the width of the line
873  arect.Inflate( GetWidth() / 2 );
874 
875  // Polygons in footprints use coordinates relative to the footprint.
876  // Therefore, instead of using m_poly, we make a copy which is translated
877  // to the actual location in the board.
878  double orientation = 0.0;
879  wxPoint offset = getParentPosition();
880 
881  if( getParentOrientation() )
882  orientation = -DECIDEG2RAD( getParentOrientation() );
883 
884  SHAPE_LINE_CHAIN poly = m_poly.Outline( 0 );
885  poly.Rotate( orientation );
886  poly.Move( offset );
887 
888  int count = poly.GetPointCount();
889 
890  for( int ii = 0; ii < count; ii++ )
891  {
892  VECTOR2I vertex = poly.GetPoint( ii );
893 
894  // Test if the point is within aRect
895  if( arect.Contains( ( wxPoint ) vertex ) )
896  return true;
897 
898  if( ii + 1 < count )
899  {
900  VECTOR2I vertexNext = poly.GetPoint( ii + 1 );
901 
902  // Test if this edge intersects aRect
903  if( arect.Intersects( ( wxPoint ) vertex, ( wxPoint ) vertexNext ) )
904  return true;
905  }
906  else if( poly.IsClosed() )
907  {
908  VECTOR2I vertexNext = poly.GetPoint( 0 );
909 
910  // Test if this edge intersects aRect
911  if( arect.Intersects( ( wxPoint ) vertex, ( wxPoint ) vertexNext ) )
912  return true;
913  }
914  }
915 
916  return false;
917  }
918 
919  case SHAPE_T::BEZIER:
920  if( aContained )
921  {
922  return arect.Contains( bb );
923  }
924  else
925  {
926  // Fast test: if aRect is outside the polygon bounding box,
927  // rectangles cannot intersect
928  if( !arect.Intersects( bb ) )
929  return false;
930 
931  // Account for the width of the line
932  arect.Inflate( GetWidth() / 2 );
933  unsigned count = m_bezierPoints.size();
934 
935  for( unsigned ii = 1; ii < count; ii++ )
936  {
937  wxPoint vertex = m_bezierPoints[ ii - 1];
938  wxPoint vertexNext = m_bezierPoints[ii];
939 
940  // Test if the point is within aRect
941  if( arect.Contains( ( wxPoint ) vertex ) )
942  return true;
943 
944  // Test if this edge intersects aRect
945  if( arect.Intersects( vertex, vertexNext ) )
946  return true;
947  }
948 
949  return false;
950  }
951 
952  default:
954  return false;
955  }
956 }
SHAPE_T m_shape
Definition: eda_shape.h:301
int GetWidth() const
Definition: eda_shape.h:89
virtual size_t GetPointCount() const override
wxPoint getCenter() const
Definition: eda_shape.cpp:393
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:97
void Move(const VECTOR2I &aVector) override
virtual wxPoint getParentPosition() const =0
bool IntersectsCircleEdge(const wxPoint &aCenter, const int aRadius, const int aWidth) const
Test for intersection between this rect and the edge (radius) of a circle.
Definition: eda_rect.cpp:331
EDA_RECT Common(const EDA_RECT &aRect) const
Return the area that is common with another rectangle.
Definition: eda_rect.cpp:489
bool Contains(const wxPoint &aPoint) const
Definition: eda_rect.cpp:57
std::vector< wxPoint > GetRectCorners() const
Definition: eda_shape.cpp:959
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:122
bool IsClosed() const override
SHAPE_LINE_CHAIN & Outline(int aIndex)
std::vector< wxPoint > m_bezierPoints
Definition: eda_shape.h:312
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:313
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:120
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:71
virtual const VECTOR2I GetPoint(int aIndex) const override
void Rotate(double aAngle, const VECTOR2I &aCenter=VECTOR2I(0, 0)) override
Rotate all vertices by a given angle.
void Normalize()
Ensures that the height ant width are positive.
Definition: eda_rect.cpp:35
const EDA_RECT getBoundingBox() const
Definition: eda_shape.cpp:612
virtual double getParentOrientation() const =0
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Handle the component boundary box.
Definition: eda_rect.h:42
double DECIDEG2RAD(double deg)
Definition: trigo.h:233
bool Intersects(const EDA_RECT &aRect) const
Test for a common area between rectangles.
Definition: eda_rect.cpp:150
int GetRadius() const
Definition: eda_shape.cpp:466
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:364

References ARC, BEZIER, CIRCLE, EDA_RECT::Common(), EDA_RECT::Contains(), DECIDEG2RAD(), EDA_SHAPE::getBoundingBox(), EDA_SHAPE::getCenter(), EDA_SHAPE::GetEnd(), EDA_SHAPE::getParentOrientation(), EDA_SHAPE::getParentPosition(), SHAPE_LINE_CHAIN::GetPoint(), SHAPE_LINE_CHAIN::GetPointCount(), EDA_SHAPE::GetRadius(), EDA_SHAPE::GetRectCorners(), EDA_SHAPE::GetStart(), EDA_SHAPE::GetWidth(), EDA_RECT::Inflate(), EDA_RECT::Intersects(), EDA_RECT::IntersectsCircleEdge(), SHAPE_LINE_CHAIN::IsClosed(), EDA_SHAPE::m_bezierPoints, EDA_SHAPE::m_poly, EDA_SHAPE::m_shape, SHAPE_LINE_CHAIN::Move(), EDA_RECT::Normalize(), SHAPE_POLY_SET::Outline(), POLY, RECT, SHAPE_LINE_CHAIN::Rotate(), SEGMENT, EDA_SHAPE::SHAPE_T_asString(), and UNIMPLEMENTED_FOR.

◆ IsBrightened()

◆ IsConnected()

◆ IsDragging()

bool EDA_ITEM::IsDragging ( ) const
inlineinherited

Definition at line 120 of file eda_item.h.

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

References IS_DRAGGING, and EDA_ITEM::m_flags.

Referenced by DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES().

◆ IsEntered()

bool EDA_ITEM::IsEntered ( ) const
inlineinherited

Definition at line 123 of file eda_item.h.

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

References ENTERED, and EDA_ITEM::m_flags.

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

◆ IsFilled()

◆ IsForceVisible()

bool EDA_ITEM::IsForceVisible ( ) const
inlineinherited

Definition at line 205 of file eda_item.h.

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

References EDA_ITEM::m_forceVisible.

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

◆ IsLocked()

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

Reimplemented in FOOTPRINT, and PAD.

Definition at line 64 of file board_item.cpp.

65 {
66  if( GetParentGroup() )
67  return GetParentGroup()->IsLocked();
68 
69  const BOARD* board = GetBoard();
70 
71  return board && board->GetBoardUse() != BOARD_USE::FPHOLDER && GetState( LOCKED );
72 }
PCB_GROUP * GetParentGroup() const
Definition: board_item.h:60
virtual bool IsLocked() const
Definition: board_item.cpp:64
#define LOCKED
Pcbnew: locked from movement and deletion.
int GetState(EDA_ITEM_FLAGS type) const
Definition: eda_item.h:136
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:191
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:36
BOARD_USE GetBoardUse() const
Get what the board use is.
Definition: board.h:211

References FPHOLDER, BOARD_ITEM::GetBoard(), BOARD::GetBoardUse(), BOARD_ITEM::GetParentGroup(), EDA_ITEM::GetState(), BOARD_ITEM::IsLocked(), and LOCKED.

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

◆ IsModified()

bool EDA_ITEM::IsModified ( ) const
inlineinherited

Definition at line 117 of file eda_item.h.

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

References IS_CHANGED, and EDA_ITEM::m_flags.

Referenced by PCB_EDIT_FRAME::OpenProjectFiles().

◆ IsMoving()

◆ IsNew()

◆ IsOnCopperLayer()

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

Reimplemented in PAD, PCB_TRACK, and ZONE.

Definition at line 111 of file board_item.h.

112  {
113  return IsCopperLayer( GetLayer() );
114  }
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:797
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:142

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

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

◆ IsOnLayer()

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

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

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

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

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

Definition at line 200 of file board_item.h.

201  {
202  return m_layer == aLayer;
203  }
PCB_LAYER_ID m_layer
Definition: board_item.h:318

References BOARD_ITEM::m_layer.

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

◆ IsPolyShapeValid()

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

Definition at line 1185 of file eda_shape.cpp.

1186 {
1187  // return true if the polygonal shape is valid (has more than 2 points)
1188  if( GetPolyShape().OutlineCount() == 0 )
1189  return false;
1190 
1191  const SHAPE_LINE_CHAIN& outline = ( (SHAPE_POLY_SET&)GetPolyShape() ).Outline( 0 );
1192 
1193  return outline.PointCount() > 2;
1194 }
int PointCount() const
Return the number of points (vertices) in this line chain.
Represent a set of closed polygons.
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:207
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...

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

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

◆ IsReplaceable()

virtual bool EDA_ITEM::IsReplaceable ( ) const
inlinevirtualinherited

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

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

Reimplemented in SCH_SYMBOL, SCH_SHEET, SCH_LABEL, SCH_TEXT, SCH_FIELD, and SCH_SHEET_PIN.

Definition at line 402 of file eda_item.h.

402 { return false; }

Referenced by EDA_ITEM::Matches().

◆ IsResized()

bool EDA_ITEM::IsResized ( ) const
inlineinherited

Definition at line 124 of file eda_item.h.

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

References IS_RESIZING, and EDA_ITEM::m_flags.

◆ IsSelected()

bool EDA_ITEM::IsSelected ( ) const
inlineinherited

Definition at line 122 of file eda_item.h.

122 { return m_flags & SELECTED; }
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480
#define SELECTED

References EDA_ITEM::m_flags, and SELECTED.

Referenced by ALIGN_DISTRIBUTE_TOOL::AlignBottom(), ALIGN_DISTRIBUTE_TOOL::AlignCenterX(), ALIGN_DISTRIBUTE_TOOL::AlignCenterY(), ALIGN_DISTRIBUTE_TOOL::AlignTop(), SCH_EDIT_FRAME::ConvertPart(), DIALOG_CHANGE_SYMBOLS::DIALOG_CHANGE_SYMBOLS(), ALIGN_DISTRIBUTE_TOOL::doAlignLeft(), ALIGN_DISTRIBUTE_TOOL::doAlignRight(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersVertically(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsVertically(), KIGFX::SCH_PAINTER::draw(), KIGFX::PCB_PAINTER::Draw(), KIGFX::PCB_PAINTER::draw(), DS_PROXY_UNDO_ITEM::DS_PROXY_UNDO_ITEM(), KIGFX::DS_RENDER_SETTINGS::GetColor(), KIGFX::GERBVIEW_RENDER_SETTINGS::GetColor(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), SCH_MOVE_TOOL::getConnectedDragItems(), KIGFX::SCH_PAINTER::getLineWidth(), KIGFX::SCH_PAINTER::getRenderColor(), KIGFX::SCH_PAINTER::getTextThickness(), DIALOG_EXCHANGE_FOOTPRINTS::isMatch(), DIALOG_CHANGE_SYMBOLS::isMatch(), SCH_LINE::MergeOverlap(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SCH_MOVE_TOOL::moveItem(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), BOARD_COMMIT::Push(), PCB_SELECTION_TOOL::RebuildSelection(), EE_SELECTION_TOOL::RebuildSelection(), RENDER_3D_OPENGL::renderFootprint(), SCH_EDIT_TOOL::Rotate(), EE_TOOL_BASE< SCH_BASE_FRAME >::saveCopyInUndoList(), SCH_EDIT_FRAME::SchematicCleanUp(), GERBVIEW_SELECTION_TOOL::select(), PCB_SELECTION_TOOL::select(), PCB_SELECTION_TOOL::selectionContains(), PCB_SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), KIGFX::SCH_PAINTER::setDeviceColors(), GERBVIEW_SELECTION_TOOL::unselect(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::visitItem(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ IsTrack()

bool BOARD_ITEM::IsTrack ( ) const
inlineinherited

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

Returns
true if a track or via, else false.

Definition at line 210 of file board_item.h.

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

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

◆ IsType()

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

Check whether the item is one of the listed types.

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

Reimplemented from EDA_ITEM.

Definition at line 60 of file pcb_shape.h.

61  {
62  if( BOARD_ITEM::IsType( aScanTypes ) )
63  return true;
64 
65  for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
66  {
67  if( *p == PCB_LOCATE_GRAPHIC_T )
68  return true;
69  else if( *p == PCB_LOCATE_BOARD_EDGE_T )
70  return m_layer == Edge_Cuts;
71  }
72 
73  return false;
74  }
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
virtual bool IsType(const KICAD_T aScanTypes[]) const
Check whether the item is one of the listed types.
Definition: eda_item.h:182
PCB_LAYER_ID m_layer
Definition: board_item.h:318

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

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

References IS_WIRE_IMAGE, and EDA_ITEM::m_flags.

◆ IterateForward() [1/2]

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

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

Definition at line 294 of file eda_item.h.

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

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

Referenced by GERBER_FILE_IMAGE::Visit().

◆ IterateForward() [2/2]

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

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

Definition at line 313 of file eda_item.h.

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

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

◆ layerMaskDescribe()

wxString BOARD_ITEM::layerMaskDescribe ( ) const
protectedvirtualinherited

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

The BOARD is needed because layer names are customizable.

Reimplemented in PCB_VIA.

Definition at line 87 of file board_item.cpp.

88 {
89  const BOARD* board = GetBoard();
90  LSET layers = GetLayerSet();
91 
92  // Try to be smart and useful. Check all copper first.
93  if( layers[F_Cu] && layers[B_Cu] )
94  return _( "all copper layers" );
95 
96  LSET copperLayers = layers & board->GetEnabledLayers().AllCuMask();
97  LSET techLayers = layers & board->GetEnabledLayers().AllTechMask();
98 
99  for( LSET testLayers : { copperLayers, techLayers, layers } )
100  {
101  for( int bit = PCBNEW_LAYER_ID_START; bit < PCB_LAYER_ID_COUNT; ++bit )
102  {
103  if( testLayers[ bit ] )
104  {
105  wxString layerInfo = board->GetLayerName( static_cast<PCB_LAYER_ID>( bit ) );
106 
107  if( testLayers.count() > 1 )
108  layerInfo << wxS( " " ) + _( "and others" );
109 
110  return layerInfo;
111  }
112  }
113  }
114 
115  // No copper, no technicals: no layer
116  return _( "no layers" );
117 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:759
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:362
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:467
static LSET AllTechMask()
Return a mask holding all technical layers (no CU layer) on both side.
Definition: lset.cpp:829
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:505
#define _(s)
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:191
Definition: layer_ids.h:71
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:36
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:147

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

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

◆ MakeEffectiveShapes()

std::vector< SHAPE * > EDA_SHAPE::MakeEffectiveShapes ( ) const
inherited

Make a set of SHAPE objects representing the EDA_SHAPE.

Caller owns the objects.

Definition at line 1073 of file eda_shape.cpp.

1074 {
1075  std::vector<SHAPE*> effectiveShapes;
1076 
1077  switch( m_shape )
1078  {
1079  case SHAPE_T::ARC:
1080  effectiveShapes.emplace_back( new SHAPE_ARC( m_arcCenter, m_start, GetArcAngle() / 10.0,
1081  m_width ) );
1082  break;
1083 
1084  case SHAPE_T::SEGMENT:
1085  effectiveShapes.emplace_back( new SHAPE_SEGMENT( m_start, m_end, m_width ) );
1086  break;
1087 
1088  case SHAPE_T::RECT:
1089  {
1090  std::vector<wxPoint> pts = GetRectCorners();
1091 
1092  if( IsFilled() )
1093  effectiveShapes.emplace_back( new SHAPE_SIMPLE( pts ) );
1094 
1095  if( m_width > 0 || !IsFilled() )
1096  {
1097  effectiveShapes.emplace_back( new SHAPE_SEGMENT( pts[0], pts[1], m_width ) );
1098  effectiveShapes.emplace_back( new SHAPE_SEGMENT( pts[1], pts[2], m_width ) );
1099  effectiveShapes.emplace_back( new SHAPE_SEGMENT( pts[2], pts[3], m_width ) );
1100  effectiveShapes.emplace_back( new SHAPE_SEGMENT( pts[3], pts[0], m_width ) );
1101  }
1102  }
1103  break;
1104 
1105  case SHAPE_T::CIRCLE:
1106  {
1107  if( IsFilled() )
1108  effectiveShapes.emplace_back( new SHAPE_CIRCLE( getCenter(), GetRadius() ) );
1109 
1110  if( m_width > 0 || !IsFilled() )
1111  {
1112  // SHAPE_CIRCLE has no ConvertToPolyline() method, so use a 360.0 SHAPE_ARC
1113  SHAPE_ARC circle( getCenter(), GetEnd(), 360.0 );
1114  SHAPE_LINE_CHAIN l = circle.ConvertToPolyline();
1115 
1116  for( int i = 0; i < l.SegmentCount(); i++ )
1117  {
1118  effectiveShapes.emplace_back( new SHAPE_SEGMENT( l.Segment( i ).A, l.Segment( i ).B,
1119  m_width ) );
1120  }
1121  }
1122 
1123  break;
1124  }
1125 
1126  case SHAPE_T::BEZIER:
1127  {
1128  auto bezierPoints = buildBezierToSegmentsPointsList( GetWidth() );
1129  wxPoint start_pt = bezierPoints[0];
1130 
1131  for( unsigned int jj = 1; jj < bezierPoints.size(); jj++ )
1132  {
1133  wxPoint end_pt = bezierPoints[jj];
1134  effectiveShapes.emplace_back( new SHAPE_SEGMENT( start_pt, end_pt, m_width ) );
1135  start_pt = end_pt;
1136  }
1137 
1138  break;
1139  }
1140 
1141  case SHAPE_T::POLY:
1142  {
1144 
1146  l.Move( getParentPosition() );
1147 
1148  if( IsFilled() )
1149  effectiveShapes.emplace_back( new SHAPE_SIMPLE( l ) );
1150 
1151  if( m_width > 0 || !IsFilled() )
1152  {
1153  for( int i = 0; i < l.SegmentCount(); i++ )
1154  effectiveShapes.emplace_back( new SHAPE_SEGMENT( l.Segment( i ), m_width ) );
1155  }
1156  }
1157  break;
1158 
1159  default:
1161  break;
1162  }
1163 
1164  return effectiveShapes;
1165 }
SHAPE_T m_shape
Definition: eda_shape.h:301
Represent a simple polygon consisting of a zero-thickness closed chain of connected line segments.
Definition: shape_simple.h:41
int GetWidth() const
Definition: eda_shape.h:89
wxPoint getCenter() const
Definition: eda_shape.cpp:393
void Move(const VECTOR2I &aVector) override
double GetArcAngle() const
Definition: eda_shape.cpp:514
virtual wxPoint getParentPosition() const =0
wxPoint m_end
Definition: eda_shape.h:305
wxPoint m_arcCenter
Definition: eda_shape.h:307
bool IsFilled() const
Definition: eda_shape.h:81
std::vector< wxPoint > GetRectCorners() const
Definition: eda_shape.cpp:959
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:122
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:120
const std::vector< wxPoint > buildBezierToSegmentsPointsList(int aMinSegLen) const
Definition: eda_shape.cpp:380
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:71
int SegmentCount() const
Return the number of segments in this line chain.
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:207
wxPoint m_start
Definition: eda_shape.h:304
void Rotate(double aAngle, const VECTOR2I &aCenter=VECTOR2I(0, 0)) override
Rotate all vertices by a given angle.
SEG Segment(int aIndex)
Return a copy of the aIndex-th segment in the line chain.
virtual double getParentOrientation() const =0
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
VECTOR2I A
Definition: seg.h:48
double DECIDEG2RAD(double deg)
Definition: trigo.h:233
int m_width
Definition: eda_shape.h:302
int GetRadius() const
Definition: eda_shape.cpp:466
VECTOR2I B
Definition: seg.h:49

References SEG::A, ARC, SEG::B, BEZIER, EDA_SHAPE::buildBezierToSegmentsPointsList(), CIRCLE, SHAPE_ARC::ConvertToPolyline(), SHAPE_POLY_SET::COutline(), DECIDEG2RAD(), EDA_SHAPE::GetArcAngle(), EDA_SHAPE::getCenter(), EDA_SHAPE::GetEnd(), EDA_SHAPE::getParentOrientation(), EDA_SHAPE::getParentPosition(), EDA_SHAPE::GetPolyShape(), EDA_SHAPE::GetRadius(), EDA_SHAPE::GetRectCorners(), EDA_SHAPE::GetWidth(), EDA_SHAPE::IsFilled(), EDA_SHAPE::m_arcCenter, EDA_SHAPE::m_end, EDA_SHAPE::m_shape, EDA_SHAPE::m_start, EDA_SHAPE::m_width, SHAPE_LINE_CHAIN::Move(), POLY, RECT, SHAPE_LINE_CHAIN::Rotate(), SEGMENT, SHAPE_LINE_CHAIN::Segment(), SHAPE_LINE_CHAIN::SegmentCount(), EDA_SHAPE::SHAPE_T_asString(), and UNIMPLEMENTED_FOR.

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

◆ Matches() [1/2]

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

Compare the item against the search criteria in aSearchData.

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

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

Reimplemented in SCH_SYMBOL, SCH_SHEET, SCH_TEXT, SCH_FIELD, SCH_SHEET_PIN, ZONE, SCH_PIN, PCB_MARKER, SCH_MARKER, FP_TEXT, and PCB_TEXT.

Definition at line 364 of file eda_item.h.

365  {
366  return false;
367  }

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

◆ Matches() [2/2]

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

Compare aText against search criteria in aSearchData.

This is a helper function for simplify derived class logic.

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

Definition at line 118 of file eda_item.cpp.

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

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

◆ Move() [1/2]

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

Move this object.

Parameters
aMoveVectorthe move vector for this object.

Reimplemented from BOARD_ITEM.

Reimplemented in FP_SHAPE.

Definition at line 97 of file pcb_shape.cpp.

98 {
99  move( aMoveVector );
100 }
void move(const wxPoint &aMoveVector)
Definition: eda_shape.cpp:137

References EDA_SHAPE::move().

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

◆ Move() [2/2]

void BOARD_ITEM::Move ( const VECTOR2I aMoveVector)
inlineinherited

Definition at line 243 of file board_item.h.

244  {
245  Move( wxPoint( aMoveVector.x, aMoveVector.y ) );
246  }
virtual void Move(const wxPoint &aMoveVector)
Move this object.
Definition: board_item.h:238

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

◆ move()

void EDA_SHAPE::move ( const wxPoint &  aMoveVector)
protectedinherited

Definition at line 137 of file eda_shape.cpp.

138 {
139  switch ( m_shape )
140  {
141  case SHAPE_T::ARC:
142  case SHAPE_T::SEGMENT:
143  case SHAPE_T::RECT:
144  case SHAPE_T::CIRCLE:
145  m_start += aMoveVector;
146  m_end += aMoveVector;
147  m_arcCenter += aMoveVector;
148  break;
149 
150  case SHAPE_T::POLY:
151  m_poly.Move( VECTOR2I( aMoveVector ) );
152  break;
153 
154  case SHAPE_T::BEZIER:
155  m_start += aMoveVector;
156  m_end += aMoveVector;
157  m_bezierC1 += aMoveVector;
158  m_bezierC2 += aMoveVector;
159 
160  for( wxPoint& pt : m_bezierPoints)
161  pt += aMoveVector;
162 
163  break;
164 
165  default:
167  break;
168  }
169 }
SHAPE_T m_shape
Definition: eda_shape.h:301
wxPoint m_bezierC1
Definition: eda_shape.h:309
VECTOR2< int > VECTOR2I
Definition: vector2d.h:622
wxPoint m_end
Definition: eda_shape.h:305
wxPoint m_arcCenter
Definition: eda_shape.h:307
wxPoint m_bezierC2
Definition: eda_shape.h:310
void Move(const VECTOR2I &aVector) override
std::vector< wxPoint > m_bezierPoints
Definition: eda_shape.h:312
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:313
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:120
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:71
wxPoint m_start
Definition: eda_shape.h:304

References ARC, BEZIER, CIRCLE, EDA_SHAPE::m_arcCenter, EDA_SHAPE::m_bezierC1, EDA_SHAPE::m_bezierC2, EDA_SHAPE::m_bezierPoints, EDA_SHAPE::m_end, EDA_SHAPE::m_poly, EDA_SHAPE::m_shape, EDA_SHAPE::m_start, SHAPE_POLY_SET::Move(), POLY, RECT, SEGMENT, EDA_SHAPE::SHAPE_T_asString(), and UNIMPLEMENTED_FOR.

Referenced by Move(), LIB_SHAPE::Offset(), and EDA_SHAPE::setPosition().

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

235 {
236  wxFAIL_MSG( wxString::Format( wxT( "Less than operator not defined for item type %s." ),
237  GetClass() ) );
238 
239  return false;
240 }
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
virtual wxString GetClass() const =0
Return the class name.

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

◆ RebuildBezierToSegmentsPointsList()

void EDA_SHAPE::RebuildBezierToSegmentsPointsList ( int  aMinSegLen)
inherited

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

Has meaning only for BEZIER shape.

Parameters
aMinSegLenis the min length of segments approximating the bezier. The shape's last segment can be shorter. This parameter avoids having too many very short segment in list. Good values are between m_width/2 and m_width.

Definition at line 366 of file eda_shape.cpp.

367 {
368  // Has meaning only for S_CURVE DRAW_SEGMENT shape
369  if( m_shape != SHAPE_T::BEZIER )
370  {
371  m_bezierPoints.clear();
372  return;
373  }
374 
375  // Rebuild the m_BezierPoints vertex list that approximate the Bezier curve
377 }
SHAPE_T m_shape
Definition: eda_shape.h:301
std::vector< wxPoint > m_bezierPoints
Definition: eda_shape.h:312
const std::vector< wxPoint > buildBezierToSegmentsPointsList(int aMinSegLen) const
Definition: eda_shape.cpp:380

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

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

◆ Replace() [1/2]

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

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

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

Definition at line 170 of file eda_item.cpp.

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

References next(), and text.

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

◆ Replace() [2/2]

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

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

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

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

Reimplemented in SCH_TEXT, SCH_FIELD, SCH_SHEET_PIN, and SCH_PIN.

Definition at line 391 of file eda_item.h.

392  {
393  return false;
394  }

◆ Rotate() [1/2]

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

Rotate this object.

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

Reimplemented from BOARD_ITEM.

Reimplemented in FP_SHAPE.

Definition at line 109 of file pcb_shape.cpp.

110 {
111  rotate( aRotCentre, aAngle );
112 }
void rotate(const wxPoint &aRotCentre, double aAngle)
Definition: eda_shape.cpp:224

References EDA_SHAPE::rotate().

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

◆ Rotate() [2/2]

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

Definition at line 256 of file board_item.h.

257  {
258  Rotate( wxPoint( aRotCentre.x, aRotCentre.y ), aAngle );
259  }
virtual void Rotate(const wxPoint &aRotCentre, double aAngle)
Rotate this object.
Definition: board_item.cpp:190

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

◆ rotate()

void EDA_SHAPE::rotate ( const wxPoint &  aRotCentre,
double  aAngle 
)
protectedinherited

Definition at line 224 of file eda_shape.cpp.

225 {
226  switch( m_shape )
227  {
228  case SHAPE_T::SEGMENT:
229  case SHAPE_T::CIRCLE:
230  RotatePoint( &m_start, aRotCentre, aAngle );
231  RotatePoint( &m_end, aRotCentre, aAngle );
232  break;
233 
234  case SHAPE_T::ARC:
235  RotatePoint( &m_start, aRotCentre, aAngle );
236  RotatePoint( &m_end, aRotCentre, aAngle );
237  RotatePoint( &m_arcCenter, aRotCentre, aAngle );
238  break;
239 
240  case SHAPE_T::RECT:
241  if( KiROUND( aAngle ) % 900 == 0 )
242  {
243  RotatePoint( &m_start, aRotCentre, aAngle );
244  RotatePoint( &m_end, aRotCentre, aAngle );
245  break;
246  }
247 
248  // Convert non-cartesian-rotated rect to a diamond
251  m_poly.NewOutline();
252  m_poly.Append( m_start );
253  m_poly.Append( m_end.x, m_start.y );
254  m_poly.Append( m_end );
255  m_poly.Append( m_start.x, m_end.y );
256 
258 
259  case SHAPE_T::POLY:
260  m_poly.Rotate( -DECIDEG2RAD( aAngle ), VECTOR2I( aRotCentre ) );
261  break;
262 
263  case SHAPE_T::BEZIER:
264  RotatePoint( &m_start, aRotCentre, aAngle);
265  RotatePoint( &m_end, aRotCentre, aAngle);
266  RotatePoint( &m_bezierC1, aRotCentre, aAngle);
267  RotatePoint( &m_bezierC2, aRotCentre, aAngle);
268 
269  for( wxPoint& pt : m_bezierPoints )
270  RotatePoint( &pt, aRotCentre, aAngle);
271 
272  break;
273 
274  default:
276  break;
277  }
278 }
SHAPE_T m_shape
Definition: eda_shape.h:301
wxPoint m_bezierC1
Definition: eda_shape.h:309
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
void Rotate(double aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Rotate all vertices by a given angle.
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
VECTOR2< int > VECTOR2I
Definition: vector2d.h:622
wxPoint m_end
Definition: eda_shape.h:305
wxPoint m_arcCenter
Definition: eda_shape.h:307
wxPoint m_bezierC2
Definition: eda_shape.h:310
std::vector< wxPoint > m_bezierPoints
Definition: eda_shape.h:312
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:313
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:120
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:71
int NewOutline()
Creates a new hole in a given outline.
wxPoint m_start
Definition: eda_shape.h:304
double DECIDEG2RAD(double deg)
Definition: trigo.h:233
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...

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

Referenced by LIB_SHAPE::Rotate(), and Rotate().

◆ Scale()

void PCB_SHAPE::Scale ( double  aScale)

Definition at line 103 of file pcb_shape.cpp.

104 {
105  scale( aScale );
106 }
void scale(double aScale)
Definition: eda_shape.cpp:172

References EDA_SHAPE::scale().

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::getShapeFromVertex().

◆ scale()

void EDA_SHAPE::scale ( double  aScale)
protectedinherited

Definition at line 172 of file eda_shape.cpp.

173 {
174  auto scalePt = [&]( wxPoint& pt )
175  {
176  pt.x = KiROUND( pt.x * aScale );
177  pt.y = KiROUND( pt.y * aScale );
178  };
179 
180  switch( m_shape )
181  {
182  case SHAPE_T::ARC:
183  case SHAPE_T::SEGMENT:
184  case SHAPE_T::RECT:
185  scalePt( m_start );
186  scalePt( m_end );
187  scalePt( m_arcCenter );
188  break;
189 
190  case SHAPE_T::CIRCLE: // ring or circle
191  scalePt( m_start );
192  m_end.x = m_start.x + KiROUND( GetRadius() * aScale );
193  m_end.y = m_start.y;
194  break;
195 
196  case SHAPE_T::POLY: // polygon
197  {
198  std::vector<wxPoint> pts;
199 
200  for( const VECTOR2I& pt : m_poly.Outline( 0 ).CPoints() )
201  {
202  pts.emplace_back( pt );
203  scalePt( pts.back() );
204  }
205 
206  SetPolyPoints( pts );
207  }
208  break;
209 
210  case SHAPE_T::BEZIER:
211  scalePt( m_start );
212  scalePt( m_end );
213  scalePt( m_bezierC1 );
214  scalePt( m_bezierC2 );
215  break;
216 
217  default:
219  break;
220  }
221 }
SHAPE_T m_shape
Definition: eda_shape.h:301
wxPoint m_bezierC1
Definition: eda_shape.h:309
wxPoint m_end
Definition: eda_shape.h:305
wxPoint m_arcCenter
Definition: eda_shape.h:307
wxPoint m_bezierC2
Definition: eda_shape.h:310
const std::vector< VECTOR2I > & CPoints() const
SHAPE_LINE_CHAIN & Outline(int aIndex)
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:313
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:120
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:71
wxPoint m_start
Definition: eda_shape.h:304
void SetPolyPoints(const std::vector< wxPoint > &aPoints)
Definition: eda_shape.cpp:1063
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73
int GetRadius() const
Definition: eda_shape.cpp:466

References ARC, BEZIER, CIRCLE, SHAPE_LINE_CHAIN::CPoints(), EDA_SHAPE::GetRadius(), KiROUND(), EDA_SHAPE::m_arcCenter, EDA_SHAPE::m_bezierC1, EDA_SHAPE::m_bezierC2, EDA_SHAPE::m_end, EDA_SHAPE::m_poly, EDA_SHAPE::m_shape, EDA_SHAPE::m_start, SHAPE_POLY_SET::Outline(), POLY, RECT, SEGMENT, EDA_SHAPE::SetPolyPoints(), EDA_SHAPE::SHAPE_T_asString(), and UNIMPLEMENTED_FOR.

Referenced by Scale().

◆ Set() [1/3]

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

Definition at line 42 of file inspectable.h.

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

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

◆ Set() [2/3]

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

Definition at line 55 of file inspectable.h.

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

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

◆ Set() [3/3]

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

Definition at line 68 of file inspectable.h.

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

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

◆ SetArcAngleAndEnd()

void EDA_SHAPE::SetArcAngleAndEnd ( double  aAngle,
bool  aCheckNegativeAngle = false 
)
inherited

Set the end point from the angle center and start.

Parameters
aAngleis tenths of degrees.

Definition at line 525 of file eda_shape.cpp.

526 {
527  m_end = m_start;
529 
530  if( aCheckNegativeAngle && aAngle < 0 )
531  {
532  std::swap( m_start, m_end );
533  m_endsSwapped = true;
534  }
535 }
T NormalizeAngle360Max(T Angle)
Normalize angle to be >=-360.0 and <= 360.0 Angle can be equal to -360 or +360.
Definition: trigo.h:241
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
wxPoint m_end
Definition: eda_shape.h:305
wxPoint m_arcCenter
Definition: eda_shape.h:307
bool m_endsSwapped
Definition: eda_shape.h:300
wxPoint m_start
Definition: eda_shape.h:304

References EDA_SHAPE::m_arcCenter, EDA_SHAPE::m_end, EDA_SHAPE::m_endsSwapped, EDA_SHAPE::m_start, NormalizeAngle360Max(), and RotatePoint().

Referenced by PAD::AddPrimitiveArc(), PCAD2KICAD::PCB_ARC::AddToBoard(), DRAWING_TOOL::drawArc(), CADSTAR_PCB_ARCHIVE_LOADER::getShapeFromVertex(), EAGLE_PLUGIN::loadPlain(), ALTIUM_PCB::ParseArcs6Data(), and DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataFromWindow().

◆ SetArcGeometry()

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

Set the three controlling points for an arc.

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

If the input winding doesn't match our internal winding, the calculated midpoint will end up on the other side of the arc. In this case, we need to flip the start/end points and flag this change for the system

Definition at line 489 of file eda_shape.cpp.

490 {
491  m_start = aStart;
492  m_end = aEnd;
493  m_arcCenter = CalcArcCenter( aStart, aMid, aEnd );
494  m_endsSwapped = false;
495 
501  wxPoint new_mid = GetArcMid();
502  VECTOR2D dist( new_mid - aMid );
503  VECTOR2D dist2( new_mid - m_arcCenter );
504 
505  if( dist.SquaredEuclideanNorm() > dist2.SquaredEuclideanNorm() )
506  {
507  std::swap( m_start, m_end );
508  m_endsSwapped = true;
509  }
510 
511 }
wxPoint m_end
Definition: eda_shape.h:305
wxPoint m_arcCenter
Definition: eda_shape.h:307
bool m_endsSwapped
Definition: eda_shape.h:300
wxPoint m_start
Definition: eda_shape.h:304
wxPoint GetArcMid() const
Definition: eda_shape.cpp:437
const VECTOR2I CalcArcCenter(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Determine the center of an arc or circle given three points on its circumference.
Definition: trigo.cpp:454

References CalcArcCenter(), EDA_SHAPE::GetArcMid(), EDA_SHAPE::m_arcCenter, EDA_SHAPE::m_end, EDA_SHAPE::m_endsSwapped, EDA_SHAPE::m_start, and VECTOR2< T >::SquaredEuclideanNorm().

Referenced by EDA_SHAPE::beginEdit(), EDA_SHAPE::calcEdit(), PCB_POINT_EDITOR::editArcMidKeepEndpoints(), ALTIUM_PCB::HelperCreateBoardOutline(), and SCH_EAGLE_PLUGIN::loadSymbolWire().

◆ SetBezierC1()

◆ SetBezierC2()

◆ SetBezierPoints()

void EDA_SHAPE::SetBezierPoints ( const std::vector< wxPoint > &  aPoints)
inlineinherited

Definition at line 217 of file eda_shape.h.

217 { m_bezierPoints = aPoints; }
std::vector< wxPoint > m_bezierPoints
Definition: eda_shape.h:312

References EDA_SHAPE::m_bezierPoints.

◆ SetBrightened()

◆ SetCenter()

◆ setEditState()

void EDA_SHAPE::setEditState ( int  aState)
inlineprotectedinherited

Definition at line 297 of file eda_shape.h.

297 { m_editState = aState; }
int m_editState
Definition: eda_shape.h:315

References EDA_SHAPE::m_editState.

Referenced by LIB_SHAPE::SetEditState().

◆ SetEnd()

void EDA_SHAPE::SetEnd ( const wxPoint &  aEnd)
inlineinherited

Definition at line 126 of file eda_shape.h.

127  {
128  m_end = aEnd;
129  m_endsSwapped = false;
130  }
wxPoint m_end
Definition: eda_shape.h:305
bool m_endsSwapped
Definition: eda_shape.h:300

References EDA_SHAPE::m_end, and EDA_SHAPE::m_endsSwapped.

Referenced by PCB_POINT_EDITOR::addCorner(), PAD::AddPrimitiveCircle(), PAD::AddPrimitiveCurve(), PAD::AddPrimitiveRect(), PAD::AddPrimitiveSegment(), PCAD2KICAD::PCB_LINE::AddToBoard(), EDA_SHAPE::beginEdit(), EDA_SHAPE::calcEdit(), CONVERT_TOOL::CreateLines(), MICROWAVE_TOOL::createMicrowaveInductor(), PCB_POINT_EDITOR::editArcEndpointKeepCenter(), PCB_POINT_EDITOR::editArcEndpointKeepTangent(), PCB_POINT_EDITOR::editArcMidKeepCenter(), PAD_TOOL::explodePad(), CADSTAR_SCH_ARCHIVE_LOADER::getScaledLibPart(), CADSTAR_PCB_ARCHIVE_LOADER::getShapeFromVertex(), ALTIUM_PCB::HelperCreateBoardOutline(), HelperGeneratePowerPortGraphics(), ALTIUM_PCB::HelperParseDimensions6Leader(), ALTIUM_PCB::HelperParsePad6NonCopper(), SCH_LEGACY_PLUGIN_CACHE::loadArc(), SCH_LEGACY_PLUGIN_CACHE::loadBezier(), SCH_LEGACY_PLUGIN_CACHE::loadCircle(), CADSTAR_SCH_ARCHIVE_LOADER::loadLibrarySymbolShapeVertices(), EAGLE_PLUGIN::loadPlain(), SCH_LEGACY_PLUGIN_CACHE::loadRect(), SCH_EAGLE_PLUGIN::loadSymbolCircle(), SCH_EAGLE_PLUGIN::loadSymbolRectangle(), GRAPHICS_CLEANER::mergeRects(), SCH_ALTIUM_PLUGIN::ParseArc(), ALTIUM_PCB::ParseArcs6Data(), SCH_ALTIUM_PLUGIN::ParseBezier(), SCH_ALTIUM_PLUGIN::ParseRectangle(), SCH_ALTIUM_PLUGIN::ParseRoundRectangle(), ALTIUM_PCB::ParseTracks6Data(), BRDITEMS_PLOTTER::PlotDimension(), BRDITEMS_PLOTTER::PlotPcbTarget(), PAD_TOOL::recombinePad(), CONVERT_TOOL::SegmentToArc(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataFromWindow(), updateArcFromConstructionMgr(), PCB_POINT_EDITOR::updateItem(), EE_POINT_EDITOR::updateParentItem(), and updateSegmentFromGeometryMgr().

◆ SetEndX()

◆ SetEndY()

◆ SetFilled()

◆ SetFillMode()

◆ SetFlags()

void EDA_ITEM::SetFlags ( EDA_ITEM_FLAGS  aMask)
inlineinherited

Definition at line 152 of file eda_item.h.

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

References EDA_ITEM::m_flags.

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

◆ SetForceVisible()

void EDA_ITEM::SetForceVisible ( bool  aEnable)
inlineinherited

Set and clear force visible flag used to force the item to be drawn even if it's draw attribute is set to not visible.

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

Definition at line 203 of file eda_item.h.

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

References EDA_ITEM::m_forceVisible.

Referenced by SCH_EDITOR_CONTROL::UpdateFind().

◆ SetLayer()

virtual void BOARD_ITEM::SetLayer ( PCB_LAYER_ID  aLayer)
inlinevirtualinherited

Set the layer this item is on.

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

Parameters
aLayerThe layer number.

Reimplemented in PCB_DIMENSION_BASE, ZONE, and PCB_GROUP.

Definition at line 163 of file board_item.h.

164  {
165  m_layer = aLayer;
166  }
PCB_LAYER_ID m_layer
Definition: board_item.h:318

References BOARD_ITEM::m_layer.

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

◆ SetLayerSet()

virtual void BOARD_ITEM::SetLayerSet ( LSET  aLayers)
inlinevirtualinherited

Reimplemented in PAD, PCB_VIA, and ZONE.

Definition at line 148 of file board_item.h.

149  {
150  wxFAIL_MSG( "Attempted to SetLayerSet() on a single-layer object." );
151 
152  // Derived classes which support multiple layers must implement this
153  }

Referenced by PANEL_SETUP_LAYERS::TransferDataFromWindow().

◆ SetLocked()

◆ SetModified()

void EDA_ITEM::SetModified ( )
inherited

◆ SetParent()

virtual void EDA_ITEM::SetParent ( EDA_ITEM aParent)
inlinevirtualinherited

Reimplemented in PCB_DIMENSION_BASE.

Definition at line 115 of file eda_item.h.

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

References EDA_ITEM::m_parent.

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

◆ SetParentGroup()

void BOARD_ITEM::SetParentGroup ( PCB_GROUP aGroup)
inlineinherited

Definition at line 59 of file board_item.h.

59 { m_group = aGroup; }
PCB_GROUP * m_group
Definition: board_item.h:319

References BOARD_ITEM::m_group.

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

◆ SetPolyPoints()

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

Definition at line 1063 of file eda_shape.cpp.

1064 {
1066  m_poly.NewOutline();
1067 
1068  for ( const wxPoint& p : aPoints )
1069  m_poly.Append( p.x, p.y );
1070 }
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:313
int NewOutline()
Creates a new hole in a giv