KiCad PCB EDA Suite
LIB_SHAPE Class Reference

#include <lib_shape.h>

Inheritance diagram for LIB_SHAPE:
LIB_ITEM EDA_SHAPE EDA_ITEM KIGFX::VIEW_ITEM INSPECTABLE

Public Types

enum  LIB_CONVERT : int { BASE = 1, DEMORGAN = 2 }
 
enum  COMPARE_FLAGS : int { NORMAL = 0x00, UNIT = 0x01 }
 The list of flags used by the compare function. More...
 

Public Member Functions

 LIB_SHAPE (LIB_SYMBOL *aParent, SHAPE_T aShape, int aLineWidth=0, FILL_T aFillType=FILL_T::NO_FILL)
 
 ~LIB_SHAPE ()
 
wxString GetClass () const override
 Return the class name. More...
 
wxString GetTypeName () const override
 Provide a user-consumable name of the object type. More...
 
bool HitTest (const wxPoint &aPosition, int aAccuracy=0) const override
 Test if aPosition is contained within or on the bounding box of an item. More...
 
bool HitTest (const EDA_RECT &aRect, bool aContained, int aAccuracy=0) const override
 Test if aRect intersects or is contained within the bounding box of an item. More...
 
int GetPenWidth () const override
 
int GetEffectivePenWidth (const RENDER_SETTINGS *aSettings) const override
 
const EDA_RECT GetBoundingBox () const override
 
void GetMsgPanelInfo (EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
 Display basic info (type, part and convert) about the current item in message panel. More...
 
void BeginEdit (const wxPoint &aStartPoint) override
 Begin drawing a symbol library draw item at aPosition. More...
 
bool ContinueEdit (const wxPoint &aPosition) override
 Continue an edit in progress at aPosition. More...
 
void CalcEdit (const wxPoint &aPosition) override
 Calculate the attributes of an item at aPosition when it is being edited. More...
 
void EndEdit () override
 End an object editing action. More...
 
void SetEditState (int aState)
 
void AddPoint (const wxPoint &aPosition)
 
void Offset (const wxPoint &aOffset) override
 Set the drawing object by aOffset from the current position. More...
 
void MoveTo (const wxPoint &aPosition) override
 Move a draw object to aPosition. More...
 
wxPoint GetPosition () const override
 
void SetPosition (const wxPoint &aPosition) override
 
wxPoint GetCenter () const
 
void CalcArcAngles (int &aStartAngle, int &aEndAngle) const
 
void MirrorHorizontal (const wxPoint &aCenter) override
 Mirror the draw object along the horizontal (X) axis about aCenter point. More...
 
void MirrorVertical (const wxPoint &aCenter) override
 Mirror the draw object along the MirrorVertical (Y) axis about aCenter point. More...
 
void Rotate (const wxPoint &aCenter, bool aRotateCCW=true) override
 Rotate the object about aCenter point. More...
 
void Plot (PLOTTER *aPlotter, const wxPoint &aOffset, bool aFill, const TRANSFORM &aTransform) const override
 Plot the draw item using the plot object. More...
 
wxString GetSelectMenuText (EDA_UNITS aUnits) const override
 Return the text to display to be used in the selection clarification context menu when multiple items are found at the current cursor position. More...
 
BITMAPS GetMenuImage () const override
 Return a pointer to an image to be used in menus. More...
 
EDA_ITEMClone () const override
 Create a duplicate of this item with linked list members set to NULL. More...
 
virtual void Print (const RENDER_SETTINGS *aSettings, const wxPoint &aOffset, void *aData, const TRANSFORM &aTransform)
 Draw an item. More...
 
LIB_SYMBOLGetParent () const
 
void ViewGetLayers (int aLayers[], int &aCount) const override
 Return the all the layers within the VIEW the object is painted on. More...
 
bool operator== (const LIB_ITEM &aOther) const
 Test LIB_ITEM objects for equivalence. More...
 
bool operator== (const LIB_ITEM *aOther) const
 
bool operator< (const LIB_ITEM &aOther) const
 Test if another draw item is less than this draw object. More...
 
bool operator< (const EDA_ITEM &aItem) const
 Test if another item is less than this object. More...
 
void SetUnit (int aUnit)
 
int GetUnit () const
 
void SetConvert (int aConvert)
 
int GetConvert () const
 
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 ()
 
virtual bool IsType (const KICAD_T aScanTypes[]) const
 Check whether the item is one of the listed types. More...
 
void SetForceVisible (bool aEnable)
 Set and clear force visible flag used to force the item to be drawn even if it's draw attribute is set to not visible. More...
 
bool IsForceVisible () const
 
virtual const wxPoint GetFocusPosition () const
 Similar to GetPosition, but allows items to return their visual center rather than their anchor. More...
 
virtual SEARCH_RESULT Visit (INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
 May be re-implemented for each derived class in order to handle all the types given by its member data. More...
 
virtual 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...
 
virtual const BOX2I ViewBBox () const override
 Return the bounding box of the item covering all its layers. More...
 
virtual void ViewDraw (int aLayer, VIEW *aView) const
 Draw the parts of the object belonging to layer aLayer. More...
 
virtual double ViewGetLOD (int aLayer, VIEW *aView) const
 Return the level of detail (LOD) of the item. More...
 
VIEW_ITEM_DATA * viewPrivData () const
 
void ClearViewPrivData ()
 
bool Set (PROPERTY_BASE *aProperty, wxAny &aValue)
 
template<typename T >
bool Set (PROPERTY_BASE *aProperty, T aValue)
 
template<typename T >
bool Set (const wxString &aProperty, T aValue)
 
wxAny Get (PROPERTY_BASE *aProperty)
 
template<typename T >
Get (PROPERTY_BASE *aProperty)
 
template<typename T >
boost::optional< T > Get (const wxString &aProperty)
 
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

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
 

Protected Member Functions

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 ()
 
void setEditState (int aState)
 

Protected Attributes

int m_unit
 Unit identification for multiple parts per package. More...
 
int m_convert
 Shape identification for alternate body styles. More...
 
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
 

Private Member Functions

int compare (const LIB_ITEM &aOther, LIB_ITEM::COMPARE_FLAGS aCompareFlags=LIB_ITEM::COMPARE_FLAGS::NORMAL) const override
 Provide the draw object specific comparison called by the == and < operators. More...
 
void print (const RENDER_SETTINGS *aSettings, const wxPoint &aOffset, void *aData, const TRANSFORM &aTransform) override
 Print the item to aDC. More...
 
double getParentOrientation () const override
 
wxPoint getParentPosition () const override
 

Detailed Description

Definition at line 32 of file lib_shape.h.

Member Enumeration Documentation

◆ COMPARE_FLAGS

enum LIB_ITEM::COMPARE_FLAGS : int
inherited

The list of flags used by the compare function.

  • NORMAL This compares everything between two LIB_ITEM objects.
  • UNIT This compare flag ignores unit and convert and pin number information when comparing LIB_ITEM objects for unit comparison.
Enumerator
NORMAL 
UNIT 

Definition at line 80 of file lib_item.h.

80 : int { NORMAL = 0x00, UNIT = 0x01 };

◆ LIB_CONVERT

enum LIB_ITEM::LIB_CONVERT : int
inherited
Enumerator
BASE 
DEMORGAN 

Definition at line 71 of file lib_item.h.

71 : int { BASE = 1, DEMORGAN = 2 };

Constructor & Destructor Documentation

◆ LIB_SHAPE()

LIB_SHAPE::LIB_SHAPE ( LIB_SYMBOL aParent,
SHAPE_T  aShape,
int  aLineWidth = 0,
FILL_T  aFillType = FILL_T::NO_FILL 
)

Definition at line 36 of file lib_shape.cpp.

37  :
38  LIB_ITEM( LIB_SHAPE_T, aParent ),
39  EDA_SHAPE( aShape, aDefaultLineWidth, aFillType, true )
40 {
41  m_editState = 0;
42 }
EDA_SHAPE(SHAPE_T aType, int aLineWidth, FILL_T aFill, bool eeWinding)
Definition: eda_shape.cpp:40
LIB_ITEM(KICAD_T aType, LIB_SYMBOL *aSymbol=nullptr, int aUnit=0, int aConvert=0)
Definition: lib_item.cpp:35
int m_editState
Definition: eda_shape.h:310

References EDA_SHAPE::m_editState.

Referenced by Clone().

◆ ~LIB_SHAPE()

LIB_SHAPE::~LIB_SHAPE ( )
inline

Definition at line 40 of file lib_shape.h.

40 { }

Member Function Documentation

◆ AddPoint()

void LIB_SHAPE::AddPoint ( const wxPoint &  aPosition)

Definition at line 407 of file lib_shape.cpp.

408 {
409  if( GetShape() == SHAPE_T::POLY )
410  {
411  if( m_poly.IsEmpty() )
412  m_poly.NewOutline();
413 
414  m_poly.Outline( 0 ).Append( aPosition, true );
415  }
416  else
417  {
418  wxFAIL_MSG( "LIB_SHAPE::AddPoint not implemented for " + SHAPE_T_asString() );
419  }
420 }
bool IsEmpty() const
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
SHAPE_LINE_CHAIN & Outline(int aIndex)
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:308
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(), EDA_SHAPE::GetShape(), SHAPE_POLY_SET::IsEmpty(), EDA_SHAPE::m_poly, SHAPE_POLY_SET::NewOutline(), SHAPE_POLY_SET::Outline(), POLY, and EDA_SHAPE::SHAPE_T_asString().

Referenced by PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems(), HelperGeneratePowerPortGraphics(), SCH_EAGLE_PLUGIN::loadFrame(), CADSTAR_SCH_ARCHIVE_LOADER::loadLibrarySymbolShapeVertices(), SCH_LEGACY_PLUGIN_CACHE::loadPolyLine(), SCH_EAGLE_PLUGIN::loadSymbolPolyLine(), SCH_EAGLE_PLUGIN::loadSymbolWire(), SCH_ALTIUM_PLUGIN::ParseBezier(), SCH_ALTIUM_PLUGIN::ParseLine(), SCH_ALTIUM_PLUGIN::ParsePolygon(), and SCH_ALTIUM_PLUGIN::ParsePolyline().

◆ BeginEdit()

void LIB_SHAPE::BeginEdit ( const wxPoint &  aPosition)
inlineoverridevirtual

Begin drawing a symbol library draw item at aPosition.

It typically would be called on a left click when a draw tool is selected in the symbol library editor and one of the graphics tools is selected.

Parameters
aPositionThe position in drawing coordinates where the drawing was started. May or may not be required depending on the item being drawn.

Reimplemented from LIB_ITEM.

Definition at line 74 of file lib_shape.h.

74 { beginEdit( aStartPoint ); }
void beginEdit(const wxPoint &aStartPoint)
Definition: eda_shape.cpp:1192

References EDA_SHAPE::beginEdit().

◆ beginEdit()

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

Definition at line 1192 of file eda_shape.cpp.

1193 {
1194  switch( GetShape() )
1195  {
1196  case SHAPE_T::SEGMENT:
1197  case SHAPE_T::CIRCLE:
1198  case SHAPE_T::RECT:
1199  SetStart( aPosition );
1200  SetEnd( aPosition );
1201  break;
1202 
1203  case SHAPE_T::ARC:
1204  SetArcGeometry( aPosition, aPosition, aPosition );
1205  m_editState = 1;
1206  break;
1207 
1208  case SHAPE_T::POLY:
1209  m_poly.NewOutline();
1210  m_poly.Outline( 0 ).SetClosed( false );
1211 
1212  // Start and end of the first segment (co-located for now)
1213  m_poly.Outline( 0 ).Append( aPosition );
1214  m_poly.Outline( 0 ).Append( aPosition, true );
1215  break;
1216 
1217  default:
1219  }
1220 }
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:308
int m_editState
Definition: eda_shape.h:310
#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 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:304
wxPoint m_end
Definition: eda_shape.h:300
wxPoint m_bezierC2
Definition: eda_shape.h:305
wxPoint m_start
Definition: eda_shape.h:299
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() [1/2]

void LIB_SHAPE::CalcArcAngles ( int &  aStartAngle,
int &  aEndAngle 
) const

Definition at line 423 of file lib_shape.cpp.

424 {
425  wxPoint centerStartVector = GetStart() - GetCenter();
426  wxPoint centerEndVector = GetEnd() - GetCenter();
427 
428  // Angles in Eeschema are still integers
429  aStartAngle = KiROUND( ArcTangente( centerStartVector.y, centerStartVector.x ) );
430  aEndAngle = KiROUND( ArcTangente( centerEndVector.y, centerEndVector.x ) );
431 
432  NORMALIZE_ANGLE_POS( aStartAngle );
433  NORMALIZE_ANGLE_POS( aEndAngle ); // angles = 0 .. 3600
434 
435  // Restrict angle to less than 180 to avoid PBS display mirror Trace because it is
436  // assumed that the arc is less than 180 deg to find orientation after rotate or mirror.
437  if( ( aEndAngle - aStartAngle ) > 1800 )
438  aEndAngle -= 3600;
439  else if( ( aEndAngle - aStartAngle ) <= -1800 )
440  aEndAngle += 3600;
441 
442  while( ( aEndAngle - aStartAngle ) >= 1800 )
443  {
444  aEndAngle--;
445  aStartAngle++;
446  }
447 
448  while( ( aStartAngle - aEndAngle ) >= 1800 )
449  {
450  aEndAngle++;
451  aStartAngle--;
452  }
453 
454  NORMALIZE_ANGLE_POS( aStartAngle );
455 
456  if( !IsMoving() )
457  NORMALIZE_ANGLE_POS( aEndAngle );
458 }
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:97
bool IsMoving() const
Definition: eda_item.h:119
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:290
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:122
wxPoint GetCenter() const
Definition: lib_shape.h:89
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:183

References ArcTangente(), GetCenter(), EDA_SHAPE::GetEnd(), EDA_SHAPE::GetStart(), EDA_ITEM::IsMoving(), KiROUND(), and NORMALIZE_ANGLE_POS().

Referenced by KIGFX::SCH_PAINTER::draw(), Plot(), print(), SCH_LEGACY_PLUGIN_CACHE::saveArc(), and SCH_SEXPR_PLUGIN_CACHE::saveSymbolDrawItem().

◆ CalcArcAngles() [2/2]

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 LIB_SHAPE::CalcEdit ( const wxPoint &  aPosition)
inlineoverridevirtual

Calculate the attributes of an item at aPosition when it is being edited.

This method gets called by the Draw() method when the item is being edited. This probably should be a pure virtual method but bezier curves are not yet editable in the symbol library editor. Therefore, the default method does nothing.

Parameters
aPositionThe current mouse position in drawing coordinates.

Reimplemented from LIB_ITEM.

Definition at line 76 of file lib_shape.h.

76 { calcEdit( aPosition ); }
void calcEdit(const wxPoint &aPosition)
Definition: eda_shape.cpp:1250

References EDA_SHAPE::calcEdit().

Referenced by EE_POINT_EDITOR::updateParentItem().

◆ calcEdit()

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

Definition at line 1250 of file eda_shape.cpp.

1251 {
1252 #define sq( x ) pow( x, 2 )
1253 
1254  switch( GetShape() )
1255  {
1256  case SHAPE_T::SEGMENT:
1257  case SHAPE_T::CIRCLE:
1258  case SHAPE_T::RECT:
1259  SetEnd( aPosition );
1260  break;
1261 
1262  case SHAPE_T::ARC:
1263  {
1264  int radius = GetRadius();
1265 
1266  // Edit state 0: drawing: place start
1267  // Edit state 1: drawing: place end (center calculated for 90-degree subtended angle)
1268  // Edit state 2: point edit: move start (center calculated for invariant subtended angle)
1269  // Edit state 3: point edit: move end (center calculated for invariant subtended angle)
1270  // Edit state 4: point edit: move center
1271  // Edit state 5: point edit: move arc-mid-point
1272 
1273  switch( m_editState )
1274  {
1275  case 0:
1276  SetArcGeometry( aPosition, aPosition, aPosition );
1277  return;
1278 
1279  case 1:
1280  m_end = aPosition;
1281  radius = KiROUND( sqrt( sq( GetLineLength( m_start, m_end ) ) / 2.0 ) );
1282  break;
1283 
1284  case 2:
1285  case 3:
1286  {
1287  wxPoint v = m_start - m_end;
1288  double chordBefore = sq( v.x ) + sq( v.y );
1289 
1290  if( m_editState == 2 )
1291  m_start = aPosition;
1292  else
1293  m_end = aPosition;
1294 
1295  v = m_start - m_end;
1296  double chordAfter = sq( v.x ) + sq( v.y );
1297  double ratio = chordAfter / chordBefore;
1298 
1299  if( ratio != 0 )
1300  {
1301  radius = std::max( int( sqrt( sq( radius ) * ratio ) ) + 1,
1302  int( sqrt( chordAfter ) / 2 ) + 1 );
1303  }
1304  }
1305  break;
1306 
1307  case 4:
1308  {
1309  double chordA = GetLineLength( m_start, aPosition );
1310  double chordB = GetLineLength( m_end, aPosition );
1311  radius = int( ( chordA + chordB ) / 2.0 ) + 1;
1312  }
1313  break;
1314 
1315  case 5:
1316  SetArcGeometry( GetStart(), aPosition, GetEnd() );
1317  return;
1318  }
1319 
1320  // Calculate center based on start, end, and radius
1321  //
1322  // Let 'l' be the length of the chord and 'm' the middle point of the chord
1323  double l = GetLineLength( m_start, m_end );
1324  wxPoint m = ( m_start + m_end ) / 2;
1325 
1326  // Calculate 'd', the vector from the chord midpoint to the center
1327  wxPoint d;
1328  d.x = KiROUND( sqrt( sq( radius ) - sq( l/2 ) ) * ( m_start.y - m_end.y ) / l );
1329  d.y = KiROUND( sqrt( sq( radius ) - sq( l/2 ) ) * ( m_end.x - m_start.x ) / l );
1330 
1331  wxPoint c1 = m + d;
1332  wxPoint c2 = m - d;
1333 
1334  // Solution gives us 2 centers; we need to pick one:
1335  switch( m_editState )
1336  {
1337  case 1:
1338  {
1339  // Keep center clockwise from chord while drawing
1340  wxPoint chordVector = m_end - m_start;
1341  double chordAngle = ArcTangente( chordVector.y, chordVector.x );
1342  NORMALIZE_ANGLE_POS( chordAngle );
1343 
1344  wxPoint c1Test = c1;
1345  RotatePoint( &c1Test, m_start, -chordAngle );
1346 
1347  m_arcCenter = c1Test.x > 0 ? c2 : c1;
1348  }
1349  break;
1350 
1351  case 2:
1352  case 3:
1353  // Pick the one closer to the old center
1354  m_arcCenter = GetLineLength( c1, m_arcCenter ) < GetLineLength( c2, m_arcCenter ) ? c1 : c2;
1355  break;
1356 
1357  case 4:
1358  // Pick the one closer to the mouse position
1359  m_arcCenter = GetLineLength( c1, aPosition ) < GetLineLength( c2, aPosition ) ? c1 : c2;
1360  break;
1361  }
1362  }
1363  break;
1364 
1365  case SHAPE_T::POLY:
1366  m_poly.Outline( 0 ).SetPoint( m_poly.Outline( 0 ).GetPointCount() - 1, aPosition );
1367  break;
1368 
1369  default:
1371  }
1372 }
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:300
wxPoint m_arcCenter
Definition: eda_shape.h:302
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:308
int m_editState
Definition: eda_shape.h:310
#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:299
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 CalcEdit().

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

Definition at line 63 of file lib_shape.cpp.

64 {
65  return new LIB_SHAPE( *this );
66 }
LIB_SHAPE(LIB_SYMBOL *aParent, SHAPE_T aShape, int aLineWidth=0, FILL_T aFillType=FILL_T::NO_FILL)
Definition: lib_shape.cpp:36

References LIB_SHAPE().

◆ compare()

int LIB_SHAPE::compare ( const LIB_ITEM aOther,
LIB_ITEM::COMPARE_FLAGS  aCompareFlags = LIB_ITEM::COMPARE_FLAGS::NORMAL 
) const
overrideprivatevirtual

Provide the draw object specific comparison called by the == and < operators.

The base object sort order which always proceeds the derived object sort order is as follows:

  • Symbol alternate part (DeMorgan) number.
  • Symbol part number.
  • KICAD_T enum value.
  • Result of derived classes comparison.
Note
Make sure you call down to LIB_ITEM::compare before doing any derived object comparisons or you will break the sorting using the symbol library file format.
Parameters
aOtherA reference to the other LIB_ITEM to compare the arc against.
aCompareFlagsThe flags used to perform the comparison.
Returns
An integer value less than 0 if the object is less than aOther object, zero if the object is equal to aOther object, or greater than 0 if the object is greater than aOther object.

The circle specific sort order is as follows:

  • Circle horizontal (X) position.
  • Circle vertical (Y) position.
  • Circle radius.

Reimplemented from LIB_ITEM.

Definition at line 69 of file lib_shape.cpp.

70 {
71  int retv = LIB_ITEM::compare( aOther, aCompareFlags );
72 
73  if( retv )
74  return retv;
75 
76  return EDA_SHAPE::Compare( &static_cast<const LIB_SHAPE&>( aOther ) );
77 }
int Compare(const EDA_SHAPE *aOther) const
Definition: eda_shape.cpp:1424
virtual int compare(const LIB_ITEM &aOther, LIB_ITEM::COMPARE_FLAGS aCompareFlags=LIB_ITEM::COMPARE_FLAGS::NORMAL) const
Provide the draw object specific comparison called by the == and < operators.
Definition: lib_item.cpp:67

References EDA_SHAPE::Compare(), and LIB_ITEM::compare().

◆ Compare()

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

Definition at line 1424 of file eda_shape.cpp.

1425 {
1426 #define EPSILON 2 // Should be enough for rounding errors on calculated items
1427 
1428 #define TEST( a, b ) { if( a != b ) return a - b; }
1429 #define TEST_E( a, b ) { if( abs( a - b ) > EPSILON ) return a - b; }
1430 #define TEST_PT( a, b ) { TEST_E( a.x, b.x ); TEST_E( a.y, b.y ); }
1431 
1432  TEST_PT( m_start, aOther->m_start );
1433  TEST_PT( m_end, aOther->m_end );
1434 
1435  TEST( (int) m_shape, (int) aOther->m_shape );
1436 
1437  if( m_shape == SHAPE_T::ARC )
1438  {
1439  TEST_PT( m_arcCenter, aOther->m_arcCenter );
1440  }
1441  else if( m_shape == SHAPE_T::BEZIER )
1442  {
1443  TEST_PT( m_bezierC1, aOther->m_bezierC1 );
1444  TEST_PT( m_bezierC2, aOther->m_bezierC2 );
1445  }
1446  else if( m_shape == SHAPE_T::POLY )
1447  {
1448  TEST( m_poly.TotalVertices(), aOther->m_poly.TotalVertices() );
1449 
1450  for( int ii = 0; ii < m_poly.TotalVertices(); ++ii )
1451  TEST_PT( m_poly.CVertex( ii ), aOther->m_poly.CVertex( ii ) );
1452  }
1453 
1454  TEST_E( m_width, aOther->m_width );
1455  TEST( (int) m_fill, (int) aOther->m_fill );
1456 
1457  return 0;
1458 }
int TotalVertices() const
Delete aIdx-th polygon from the set.
SHAPE_T m_shape
Definition: eda_shape.h:296
wxPoint m_bezierC1
Definition: eda_shape.h:304
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:300
wxPoint m_arcCenter
Definition: eda_shape.h:302
wxPoint m_bezierC2
Definition: eda_shape.h:305
#define TEST(a, b)
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:308
#define TEST_E(a, b)
FILL_T m_fill
Definition: eda_shape.h:298
wxPoint m_start
Definition: eda_shape.h:299
#define TEST_PT(a, b)
int m_width
Definition: eda_shape.h:297

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 compare(), and BOARD::cmp_drawings::operator()().

◆ computeArcBBox()

void EDA_SHAPE::computeArcBBox ( EDA_RECT aBBox) const
protectedinherited

Definition at line 979 of file eda_shape.cpp.

980 {
981  wxPoint start = m_start;
982  wxPoint end = m_end;
983  double t1, t2;
984 
985  CalcArcAngles( t1, t2 );
986 
987  if( m_eeWinding && NormalizeAngleDegrees( t1 - t2, -180.0, 180.0 ) > 0 )
988  std::swap( start, end );
989 
990  // Do not include the center, which is not necessarily inside the BB of an arc with a small
991  // included angle
992  aBBox.SetOrigin( start );
993  aBBox.Merge( end );
994 
995  // Determine the starting quarter
996  // 0 right-bottom
997  // 1 left-bottom
998  // 2 left-top
999  // 3 right-top
1000  unsigned int quarter;
1001 
1002  if( start.x < m_arcCenter.x )
1003  {
1004  if( start.y <= m_arcCenter.y )
1005  quarter = 2;
1006  else
1007  quarter = 1;
1008  }
1009  else if( start.x == m_arcCenter.x )
1010  {
1011  if( start.y < m_arcCenter.y )
1012  quarter = 3;
1013  else
1014  quarter = 1;
1015  }
1016  else
1017  {
1018  if( start.y < m_arcCenter.y )
1019  quarter = 3;
1020  else
1021  quarter = 0;
1022  }
1023 
1024  int radius = GetRadius();
1025  VECTOR2I startRadial = start - m_arcCenter;
1026  VECTOR2I endRadial = end - m_arcCenter;
1027  double angleStart = ArcTangente( startRadial.y, startRadial.x );
1028  double arcAngle = RAD2DECIDEG( endRadial.Angle() - startRadial.Angle() );
1029  int angle = (int) NormalizeAnglePos( angleStart ) % 900 + NormalizeAnglePos( arcAngle );
1030 
1031  while( angle > 900 )
1032  {
1033  switch( quarter )
1034  {
1035  case 0: aBBox.Merge( wxPoint( m_arcCenter.x, m_arcCenter.y + radius ) ); break; // down
1036  case 1: aBBox.Merge( wxPoint( m_arcCenter.x - radius, m_arcCenter.y ) ); break; // left
1037  case 2: aBBox.Merge( wxPoint( m_arcCenter.x, m_arcCenter.y - radius ) ); break; // up
1038  case 3: aBBox.Merge( wxPoint( m_arcCenter.x + radius, m_arcCenter.y ) ); break; // right
1039  }
1040 
1041  ++quarter %= 4;
1042  angle -= 900;
1043  }
1044 }
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:300
wxPoint m_arcCenter
Definition: eda_shape.h:302
double Angle() const
Compute the angle of the vector.
Definition: vector2d.h:307
wxPoint m_start
Definition: eda_shape.h:299
bool m_eeWinding
Definition: eda_shape.h:311
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 LIB_SHAPE::ContinueEdit ( const wxPoint &  aPosition)
inlineoverridevirtual

Continue an edit in progress at aPosition.

This is used to perform the next action while drawing an item. This would be called for each additional left click when the mouse is captured while the item is being drawn.

Parameters
aPositionThe position of the mouse left click in drawing coordinates.
Returns
True if additional mouse clicks are required to complete the edit in progress.

Reimplemented from LIB_ITEM.

Definition at line 75 of file lib_shape.h.

75 { return continueEdit( aPosition ); }
bool continueEdit(const wxPoint &aPosition)
Definition: eda_shape.cpp:1223

References EDA_SHAPE::continueEdit().

◆ continueEdit()

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

Definition at line 1223 of file eda_shape.cpp.

1224 {
1225  switch( GetShape() )
1226  {
1227  case SHAPE_T::ARC:
1228  case SHAPE_T::SEGMENT:
1229  case SHAPE_T::CIRCLE:
1230  case SHAPE_T::RECT:
1231  return false;
1232 
1233  case SHAPE_T::POLY:
1234  {
1235  SHAPE_LINE_CHAIN& poly = m_poly.Outline( 0 );
1236 
1237  // do not add zero-length segments
1238  if( poly.CPoint( poly.GetPointCount() - 2 ) != poly.CLastPoint() )
1239  poly.Append( aPosition, true );
1240  }
1241  return true;
1242 
1243  default:
1245  return false;
1246  }
1247 }
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:308
#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 ContinueEdit().

◆ 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 1152 of file eda_shape.cpp.

1153 {
1154  if( m_poly.OutlineCount() )
1155  {
1156  int pointCount = m_poly.COutline( 0 ).PointCount();
1157 
1158  if( pointCount )
1159  {
1160  aBuffer.reserve( pointCount );
1161 
1162  for ( auto iter = m_poly.CIterate(); iter; iter++ )
1163  aBuffer.emplace_back( iter->x, iter->y );
1164  }
1165  }
1166 }
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:308
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 LIB_SHAPE::EndEdit ( )
inlineoverridevirtual

End an object editing action.

This is used to end or abort an edit action in progress initiated by BeginEdit().

Reimplemented from LIB_ITEM.

Definition at line 77 of file lib_shape.h.

77 { endEdit(); }
void endEdit()
Definition: eda_shape.cpp:1375

References EDA_SHAPE::endEdit().

◆ endEdit()

void EDA_SHAPE::endEdit ( )
protectedinherited

Definition at line 1375 of file eda_shape.cpp.

1376 {
1377  switch( GetShape() )
1378  {
1379  case SHAPE_T::ARC:
1380  case SHAPE_T::SEGMENT:
1381  case SHAPE_T::CIRCLE:
1382  case SHAPE_T::RECT:
1383  break;
1384 
1385  case SHAPE_T::POLY:
1386  {
1387  SHAPE_LINE_CHAIN& poly = m_poly.Outline( 0 );
1388 
1389  // do not include last point twice
1390  if( poly.GetPointCount() > 2 )
1391  {
1392  if( poly.CPoint( poly.GetPointCount() - 2 ) == poly.CLastPoint() )
1393  {
1394  poly.SetClosed( true );
1395  poly.Remove( poly.GetPointCount() - 1 );
1396  }
1397  }
1398  }
1399  break;
1400 
1401  default:
1403  }
1404 }
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:308
#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 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:295

References EDA_SHAPE::m_endsSwapped.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::makeTracksFromShapes().

◆ 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:296
wxPoint m_bezierC1
Definition: eda_shape.h:304
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
wxPoint m_end
Definition: eda_shape.h:300
wxPoint m_arcCenter
Definition: eda_shape.h:302
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:305
std::vector< wxPoint > m_bezierPoints
Definition: eda_shape.h:307
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:308
#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:299
Bezier curves to polygon converter.
Definition: bezier_curves.h:36
int m_width
Definition: eda_shape.h:297

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 PCB_SHAPE::Flip(), MirrorHorizontal(), and 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()

wxPoint EDA_SHAPE::GetArcMid ( ) const
inherited

◆ GetBezierC1()

◆ GetBezierC2()

◆ GetBezierPoints()

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

◆ GetBoundingBox()

const EDA_RECT LIB_SHAPE::GetBoundingBox ( ) const
overridevirtual
Returns
the boundary box for this, in library coordinates

Reimplemented from LIB_ITEM.

Definition at line 340 of file lib_shape.cpp.

341 {
342  EDA_RECT rect = getBoundingBox();
343 
344  rect.RevertYAxis();
345 
346  return rect;
347 }
void RevertYAxis()
Mirror the rectangle from the X axis (negate Y pos and size).
Definition: eda_rect.h:198
const EDA_RECT getBoundingBox() const
Definition: eda_shape.cpp:596
Handle the component boundary box.
Definition: eda_rect.h:42

References EDA_SHAPE::getBoundingBox(), and EDA_RECT::RevertYAxis().

◆ getBoundingBox()

const EDA_RECT EDA_SHAPE::getBoundingBox ( ) const
protectedinherited

Definition at line 596 of file eda_shape.cpp.

597 {
598  EDA_RECT bbox;
599 
600  switch( m_shape )
601  {
602  case SHAPE_T::RECT:
603  for( wxPoint& pt : GetRectCorners() )
604  bbox.Merge( pt );
605 
606  break;
607 
608  case SHAPE_T::SEGMENT:
609  bbox.SetOrigin( GetStart() );
610  bbox.SetEnd( GetEnd() );
611  break;
612 
613  case SHAPE_T::CIRCLE:
614  bbox.SetOrigin( GetStart() );
615  bbox.Inflate( GetRadius() );
616  break;
617 
618  case SHAPE_T::ARC:
619  computeArcBBox( bbox );
620  break;
621 
622  case SHAPE_T::POLY:
623  if( m_poly.IsEmpty() )
624  break;
625 
626  for( auto iter = m_poly.CIterate(); iter; iter++ )
627  {
628  wxPoint pt( iter->x, iter->y );
629 
631  pt += getParentPosition();
632 
633  bbox.Merge( pt );
634  }
635 
636  break;
637 
638  case SHAPE_T::BEZIER:
639  bbox.SetOrigin( GetStart() );
640  bbox.Merge( GetBezierC1() );
641  bbox.Merge( GetBezierC2() );
642  bbox.Merge( GetEnd() );
643  break;
644 
645  default:
647  break;
648  }
649 
650  bbox.Inflate( std::max( 0, m_width / 2 ) );
651  bbox.Normalize();
652 
653  return bbox;
654 }
SHAPE_T m_shape
Definition: eda_shape.h:296
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:979
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:943
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:308
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:297
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 GetBoundingBox(), PCB_SHAPE::GetBoundingBox(), EDA_SHAPE::getCenter(), and EDA_SHAPE::hitTest().

◆ GetCenter()

wxPoint LIB_SHAPE::GetCenter ( ) const
inline

Definition at line 89 of file lib_shape.h.

89 { return getCenter(); }
wxPoint getCenter() const
Definition: eda_shape.cpp:393

References EDA_SHAPE::getCenter().

Referenced by CalcArcAngles(), KIGFX::SCH_PAINTER::draw(), SCH_LEGACY_PLUGIN_CACHE::loadArc(), and SCH_ALTIUM_PLUGIN::ParseArc().

◆ 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:296
wxPoint m_end
Definition: eda_shape.h:300
wxPoint m_arcCenter
Definition: eda_shape.h:302
#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:299
const EDA_RECT getBoundingBox() const
Definition: eda_shape.cpp:596
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(), PCB_SHAPE::GetCenter(), GetCenter(), EDA_SHAPE::getPosition(), EDA_SHAPE::hitTest(), EDA_SHAPE::MakeEffectiveShapes(), Plot(), print(), and EDA_SHAPE::TransformShapeWithClearanceToPolygon().

◆ GetClass()

wxString LIB_SHAPE::GetClass ( ) const
inlineoverridevirtual

Return the class name.

Implements EDA_ITEM.

Definition at line 42 of file lib_shape.h.

43  {
44  return wxT( "LIB_SHAPE" );
45  }

◆ GetConvert()

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

◆ GetEffectivePenWidth()

int LIB_SHAPE::GetEffectivePenWidth ( const RENDER_SETTINGS aSettings) const
inlineoverridevirtual

Reimplemented from LIB_ITEM.

Definition at line 57 of file lib_shape.h.

58  {
59  // For historical reasons, a stored value of 0 means "default width" and negative
60  // numbers meant "don't stroke".
61 
62  if( GetPenWidth() < 0 && GetFillType() != FILL_T::NO_FILL )
63  return 0;
64  else if( GetPenWidth() == 0 )
65  return aSettings->GetDefaultPenWidth();
66  else
67  return std::max( GetPenWidth(), aSettings->GetMinPenWidth() );
68  }
int GetPenWidth() const override
Definition: lib_shape.cpp:208
int GetDefaultPenWidth() const
FILL_T GetFillType() const
Definition: eda_shape.h:79

References KIGFX::RENDER_SETTINGS::GetDefaultPenWidth(), EDA_SHAPE::GetFillType(), KIGFX::RENDER_SETTINGS::GetMinPenWidth(), GetPenWidth(), and NO_FILL.

Referenced by Plot(), and print().

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

References EDA_SHAPE::m_end.

Referenced by PCB_POINT_EDITOR::addCorner(), BOARD_ADAPTER::addShapeWithClearance(), GRAPHICS_CLEANER::areEquivalent(), 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(), 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:300

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:300

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

virtual const wxPoint EDA_ITEM::GetFocusPosition ( ) const
inlinevirtualinherited

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

Reimplemented in BOARD, PCB_TRACK, and PCB_SHAPE.

Definition at line 258 of file eda_item.h.

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

References EDA_ITEM::GetPosition().

Referenced by PCB_BASE_FRAME::FocusOnItem(), and SCH_EDIT_FRAME::FocusOnItem().

◆ 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:296
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:498
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:307
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:308
#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 LIB_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.

Definition at line 390 of file lib_shape.cpp.

References add_arc, add_circle, add_graphical_segments, add_line, add_rectangle, ARC, CIRCLE, EDA_SHAPE::GetShape(), POLY, question_mark, RECT, SEGMENT, EDA_SHAPE::SHAPE_T_asString(), and UNIMPLEMENTED_FOR.

◆ GetMsgPanelInfo()

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

Display basic info (type, part and convert) about the current item in message panel.

This base function is used to display the information common to the all library items. Call the base class from the derived class or the common information will not be updated in the message panel.

Parameters
aListis the list to populate.

Reimplemented from LIB_ITEM.

Definition at line 350 of file lib_shape.cpp.

351 {
352  LIB_ITEM::GetMsgPanelInfo( aFrame, aList );
353 
354  ShapeGetMsgPanelInfo( aFrame, aList );
355 }
void ShapeGetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
Definition: eda_shape.cpp:522
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Display basic info (type, part and convert) about the current item in message panel.
Definition: lib_item.cpp:43

References LIB_ITEM::GetMsgPanelInfo(), and EDA_SHAPE::ShapeGetMsgPanelInfo().

◆ GetParent()

◆ getParentOrientation()

double LIB_SHAPE::getParentOrientation ( ) const
inlineoverrideprivatevirtual

Implements EDA_SHAPE.

Definition at line 121 of file lib_shape.h.

121 { return 0.0; }

◆ getParentPosition()

wxPoint LIB_SHAPE::getParentPosition ( ) const
inlineoverrideprivatevirtual

Implements EDA_SHAPE.

Definition at line 122 of file lib_shape.h.

122 { return wxPoint(); }

◆ GetPenWidth()

int LIB_SHAPE::GetPenWidth ( ) const
overridevirtual

Implements LIB_ITEM.

Definition at line 208 of file lib_shape.cpp.

209 {
210  return GetWidth();
211 }
int GetWidth() const
Definition: eda_shape.h:89

References EDA_SHAPE::GetWidth().

Referenced by GetEffectivePenWidth().

◆ GetPointCount()

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

Definition at line 1181 of file eda_shape.cpp.

1182 {
1183  // return the number of corners of the polygonal shape
1184  // this shape is expected to be only one polygon without hole
1185  if( GetPolyShape().OutlineCount() )
1186  return GetPolyShape().VertexCount( 0 );
1187 
1188  return 0;
1189 }
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:308

References EDA_SHAPE::m_poly.

◆ GetPosition()

◆ 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:296
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:308
wxPoint m_start
Definition: eda_shape.h:299

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 PCB_SHAPE::GetPosition(), 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:296
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:300
wxPoint m_arcCenter
Definition: eda_shape.h:302
#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:299
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(), PCB_SHAPE::GetFocusPosition(), EDA_SHAPE::GetLength(), 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(), Plot(), BRDITEMS_PLOTTER::PlotPcbShape(), 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 943 of file eda_shape.cpp.

944 {
945  std::vector<wxPoint> pts;
946  wxPoint topLeft = GetStart();
947  wxPoint botRight = GetEnd();
948 
949  // Un-rotate rect topLeft and botRight
950  if( KiROUND( getParentOrientation() ) % 900 != 0 )
951  {
952  topLeft -= getParentPosition();
953  RotatePoint( &topLeft, -getParentOrientation() );
954 
955  botRight -= getParentPosition();
956  RotatePoint( &botRight, -getParentOrientation() );
957  }
958 
959  // Set up the un-rotated 4 corners
960  pts.emplace_back( topLeft );
961  pts.emplace_back( botRight.x, topLeft.y );
962  pts.emplace_back( botRight );
963  pts.emplace_back( topLeft.x, botRight.y );
964 
965  // Now re-rotate the 4 corners to get a diamond
966  if( KiROUND( getParentOrientation() ) % 900 != 0 )
967  {
968  for( wxPoint& pt : pts )
969  {
971  pt += getParentPosition();
972  }
973  }
974 
975  return pts;
976 }
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 LIB_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.

Definition at line 358 of file lib_shape.cpp.

359 {
360  switch( GetShape() )
361  {
362  case SHAPE_T::ARC:
363  return wxString::Format( _( "Arc, radius %s" ),
364  MessageTextFromValue( aUnits, GetRadius() ) );
365 
366  case SHAPE_T::CIRCLE:
367  return wxString::Format( _( "Circle, radius %s" ),
368  MessageTextFromValue( aUnits, GetRadius() ) );
369 
370  case SHAPE_T::RECT:
371  return wxString::Format( _( "Rectangle, width %s height %s" ),
372  MessageTextFromValue( aUnits, std::abs( m_start.x - m_end.x ) ),
373  MessageTextFromValue( aUnits, std::abs( m_start.y - m_end.y ) ) );
374 
375  case SHAPE_T::POLY:
376  return wxString::Format( _( "Polyline, %d points" ),
377  int( m_poly.Outline( 0 ).GetPointCount() ) );
378 
379  case SHAPE_T::BEZIER:
380  return wxString::Format( _( "Bezier Curve, %d points" ),
381  int( m_bezierPoints.size() ) );
382 
383  default:
385  return wxEmptyString;
386  }
387 }
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
Definition: base_units.cpp:104
virtual size_t GetPointCount() const override
wxPoint m_end
Definition: eda_shape.h:300
SHAPE_LINE_CHAIN & Outline(int aIndex)
std::vector< wxPoint > m_bezierPoints
Definition: eda_shape.h:307
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:308
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:120
#define _(s)
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:71
wxPoint m_start
Definition: eda_shape.h:299
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
SHAPE_T GetShape() const
Definition: eda_shape.h:92
int GetRadius() const
Definition: eda_shape.cpp:466

References _, ARC, BEZIER, CIRCLE, Format(), SHAPE_LINE_CHAIN::GetPointCount(), EDA_SHAPE::GetRadius(), EDA_SHAPE::GetShape(), EDA_SHAPE::m_bezierPoints, EDA_SHAPE::m_end, EDA_SHAPE::m_poly, EDA_SHAPE::m_start, MessageTextFromValue(), SHAPE_POLY_SET::Outline(), POLY, RECT, EDA_SHAPE::SHAPE_T_asString(), and UNIMPLEMENTED_FOR.

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

References EDA_SHAPE::m_shape.

Referenced by PCB_POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), 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(), GetMenuImage(), CADSTAR_SCH_ARCHIVE_LOADER::getScaledLibPart(), 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(), Plot(), BRDITEMS_PLOTTER::PlotFootprintGraphicItem(), BRDITEMS_PLOTTER::PlotPcbShape(), 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:299

References EDA_SHAPE::m_start.

Referenced by PCB_POINT_EDITOR::addCorner(), BOARD_ADAPTER::addShapeWithClearance(), GRAPHICS_CLEANER::areEquivalent(), 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(), PCB_SHAPE::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:299

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:299

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.

◆ GetTypeName()

wxString LIB_SHAPE::GetTypeName ( ) const
inlineoverridevirtual

Provide a user-consumable name of the object type.

Perform localization when called so that run-time language selection works.

Implements LIB_ITEM.

Definition at line 47 of file lib_shape.h.

48  {
49  return ShowShape();
50  }
wxString ShowShape() const
Definition: eda_shape.cpp:56

References EDA_SHAPE::ShowShape().

◆ GetUnit()

◆ GetWidth()

int EDA_SHAPE::GetWidth ( ) const
inlineinherited

◆ HasFlag()

◆ HitTest() [1/2]

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

Test if aPosition is contained within or on the bounding box of an item.

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

Reimplemented from LIB_ITEM.

Definition at line 45 of file lib_shape.cpp.

46 {
47  if( aAccuracy < Mils2iu( MINIMUM_SELECTION_DISTANCE ) )
48  aAccuracy = Mils2iu( MINIMUM_SELECTION_DISTANCE );
49 
50  return hitTest( DefaultTransform.TransformCoordinate( aPosRef ), aAccuracy );
51 }
bool hitTest(const wxPoint &aPosition, int aAccuracy=0) const
Definition: eda_shape.cpp:657
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:42
#define MINIMUM_SELECTION_DISTANCE
Definition: lib_item.h:47
TRANSFORM DefaultTransform
Definition: eeschema.cpp:56

References DefaultTransform, EDA_SHAPE::hitTest(), MINIMUM_SELECTION_DISTANCE, and TRANSFORM::TransformCoordinate().

Referenced by EE_POINT_EDITOR::addCornerCondition().

◆ HitTest() [2/2]

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

Test if aRect intersects or is contained within the bounding box of an item.

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

Reimplemented from LIB_ITEM.

Definition at line 54 of file lib_shape.cpp.

55 {
57  return false;
58 
59  return hitTest( DefaultTransform.TransformCoordinate( aRect ), aContained, aAccuracy );
60 }
bool hitTest(const wxPoint &aPosition, int aAccuracy=0) const
Definition: eda_shape.cpp:657
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:42
#define STRUCT_DELETED
flag indication structures to be erased
TRANSFORM DefaultTransform
Definition: eeschema.cpp:56
#define SKIP_STRUCT
flag indicating that the structure should be ignored

References DefaultTransform, EDA_SHAPE::hitTest(), EDA_ITEM::m_flags, SKIP_STRUCT, STRUCT_DELETED, and TRANSFORM::TransformCoordinate().

◆ hitTest() [1/2]

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

Definition at line 657 of file eda_shape.cpp.

658 {
659  int maxdist = aAccuracy;
660 
661  if( m_width > 0 )
662  maxdist += m_width / 2;
663 
664  switch( m_shape )
665  {
666  case SHAPE_T::CIRCLE:
667  {
668  int radius = GetRadius();
669  int dist = KiROUND( EuclideanNorm( aPosition - getCenter() ) );
670 
671  if( IsFilled() )
672  return dist <= radius + maxdist; // Filled circle hit-test
673  else
674  return abs( radius - dist ) <= maxdist; // Ring hit-test
675  }
676 
677  case SHAPE_T::ARC:
678  {
679  if( EuclideanNorm( aPosition - m_start ) <= maxdist )
680  return true;
681 
682  if( EuclideanNorm( aPosition - m_end ) <= maxdist )
683  return true;
684 
685  wxPoint relPos = aPosition - getCenter();
686  int radius = GetRadius();
687  int dist = KiROUND( EuclideanNorm( relPos ) );
688 
689  if( abs( radius - dist ) <= maxdist )
690  {
691  double startAngle;
692  double endAngle;
693  CalcArcAngles( startAngle, endAngle );
694 
695  if( m_eeWinding && NormalizeAngleDegrees( startAngle - endAngle, -180.0, 180.0 ) > 0 )
696  std::swap( startAngle, endAngle );
697 
698  double relPosAngle = 180.0 / M_PI * atan2( relPos.y, relPos.x );
699 
700  startAngle = NormalizeAngleDegrees( startAngle, 0.0, 360.0 );
701  endAngle = NormalizeAngleDegrees( endAngle, 0.0, 360.0 );
702  relPosAngle = NormalizeAngleDegrees( relPosAngle, 0.0, 360.0 );
703 
704  if( endAngle > startAngle )
705  return relPosAngle >= startAngle && relPosAngle <= endAngle;
706  else
707  return relPosAngle >= startAngle || relPosAngle <= endAngle;
708  }
709 
710  return false;
711  }
712 
713  case SHAPE_T::BEZIER:
714  const_cast<EDA_SHAPE*>( this )->RebuildBezierToSegmentsPointsList( m_width );
715 
716  for( unsigned int i= 1; i < m_bezierPoints.size(); i++)
717  {
718  if( TestSegmentHit( aPosition, m_bezierPoints[ i - 1], m_bezierPoints[i], maxdist ) )
719  return true;
720  }
721 
722  return false;
723 
724  case SHAPE_T::SEGMENT:
725  return TestSegmentHit( aPosition, GetStart(), GetEnd(), maxdist );
726 
727  case SHAPE_T::RECT:
728  if( IsFilled() ) // Filled rect hit-test
729  {
730  SHAPE_POLY_SET poly;
731  poly.NewOutline();
732 
733  for( const wxPoint& pt : GetRectCorners() )
734  poly.Append( pt );
735 
736  return poly.Collide( VECTOR2I( aPosition ), maxdist );
737  }
738  else // Open rect hit-test
739  {
740  std::vector<wxPoint> pts = GetRectCorners();
741 
742  return TestSegmentHit( aPosition, pts[0], pts[1], maxdist )
743  || TestSegmentHit( aPosition, pts[1], pts[2], maxdist )
744  || TestSegmentHit( aPosition, pts[2], pts[3], maxdist )
745  || TestSegmentHit( aPosition, pts[3], pts[0], maxdist );
746  }
747 
748  case SHAPE_T::POLY:
749  if( IsFilled() )
750  {
751  return m_poly.Collide( VECTOR2I( aPosition ), maxdist );
752  }
753  else
754  {
756  return m_poly.CollideEdge( VECTOR2I( aPosition ), dummy, maxdist );
757  }
758 
759  default:
761  return false;
762  }
763 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:146
SHAPE_T m_shape
Definition: eda_shape.h:296
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:623
wxPoint m_end
Definition: eda_shape.h:300
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:943
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:307
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:308
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:299
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:311
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:297
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 HitTest(), and PCB_SHAPE::HitTest().

◆ hitTest() [2/2]

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

Definition at line 766 of file eda_shape.cpp.

767 {
768  EDA_RECT arect = aRect;
769  arect.Normalize();
770  arect.Inflate( aAccuracy );
771 
772  EDA_RECT arcRect;
773  EDA_RECT bb = getBoundingBox();
774 
775  switch( m_shape )
776  {
777  case SHAPE_T::CIRCLE:
778  // Test if area intersects or contains the circle:
779  if( aContained )
780  {
781  return arect.Contains( bb );
782  }
783  else
784  {
785  // If the rectangle does not intersect the bounding box, this is a much quicker test
786  if( !aRect.Intersects( bb ) )
787  {
788  return false;
789  }
790  else
791  {
792  return arect.IntersectsCircleEdge( getCenter(), GetRadius(), GetWidth() );
793  }
794  }
795 
796  case SHAPE_T::ARC:
797  // Test for full containment of this arc in the rect
798  if( aContained )
799  {
800  return arect.Contains( bb );
801  }
802  // Test if the rect crosses the arc
803  else
804  {
805  arcRect = bb.Common( arect );
806 
807  /* All following tests must pass:
808  * 1. Rectangle must intersect arc BoundingBox
809  * 2. Rectangle must cross the outside of the arc
810  */
811  return arcRect.Intersects( arect ) &&
813  }
814 
815  case SHAPE_T::RECT:
816  if( aContained )
817  {
818  return arect.Contains( bb );
819  }
820  else
821  {
822  std::vector<wxPoint> pts = GetRectCorners();
823 
824  // Account for the width of the lines
825  arect.Inflate( GetWidth() / 2 );
826  return ( arect.Intersects( pts[0], pts[1] )
827  || arect.Intersects( pts[1], pts[2] )
828  || arect.Intersects( pts[2], pts[3] )
829  || arect.Intersects( pts[3], pts[0] ) );
830  }
831 
832  case SHAPE_T::SEGMENT:
833  if( aContained )
834  {
835  return arect.Contains( GetStart() ) && aRect.Contains( GetEnd() );
836  }
837  else
838  {
839  // Account for the width of the line
840  arect.Inflate( GetWidth() / 2 );
841  return arect.Intersects( GetStart(), GetEnd() );
842  }
843 
844  case SHAPE_T::POLY:
845  if( aContained )
846  {
847  return arect.Contains( bb );
848  }
849  else
850  {
851  // Fast test: if aRect is outside the polygon bounding box,
852  // rectangles cannot intersect
853  if( !arect.Intersects( bb ) )
854  return false;
855 
856  // Account for the width of the line
857  arect.Inflate( GetWidth() / 2 );
858 
859  // Polygons in footprints use coordinates relative to the footprint.
860  // Therefore, instead of using m_poly, we make a copy which is translated
861  // to the actual location in the board.
862  double orientation = 0.0;
863  wxPoint offset = getParentPosition();
864 
865  if( getParentOrientation() )
866  orientation = -DECIDEG2RAD( getParentOrientation() );
867 
868  SHAPE_LINE_CHAIN poly = m_poly.Outline( 0 );
869  poly.Rotate( orientation );
870  poly.Move( offset );
871 
872  int count = poly.GetPointCount();
873 
874  for( int ii = 0; ii < count; ii++ )
875  {
876  VECTOR2I vertex = poly.GetPoint( ii );
877 
878  // Test if the point is within aRect
879  if( arect.Contains( ( wxPoint ) vertex ) )
880  return true;
881 
882  if( ii + 1 < count )
883  {
884  VECTOR2I vertexNext = poly.GetPoint( ii + 1 );
885 
886  // Test if this edge intersects aRect
887  if( arect.Intersects( ( wxPoint ) vertex, ( wxPoint ) vertexNext ) )
888  return true;
889  }
890  else if( poly.IsClosed() )
891  {
892  VECTOR2I vertexNext = poly.GetPoint( 0 );
893 
894  // Test if this edge intersects aRect
895  if( arect.Intersects( ( wxPoint ) vertex, ( wxPoint ) vertexNext ) )
896  return true;
897  }
898  }
899 
900  return false;
901  }
902 
903  case SHAPE_T::BEZIER:
904  if( aContained )
905  {
906  return arect.Contains( bb );
907  }
908  else
909  {
910  // Fast test: if aRect is outside the polygon bounding box,
911  // rectangles cannot intersect
912  if( !arect.Intersects( bb ) )
913  return false;
914 
915  // Account for the width of the line
916  arect.Inflate( GetWidth() / 2 );
917  unsigned count = m_bezierPoints.size();
918 
919  for( unsigned ii = 1; ii < count; ii++ )
920  {
921  wxPoint vertex = m_bezierPoints[ ii - 1];
922  wxPoint vertexNext = m_bezierPoints[ii];
923 
924  // Test if the point is within aRect
925  if( arect.Contains( ( wxPoint ) vertex ) )
926  return true;
927 
928  // Test if this edge intersects aRect
929  if( arect.Intersects( vertex, vertexNext ) )
930  return true;
931  }
932 
933  return false;
934  }
935 
936  default:
938  return false;
939  }
940 }
SHAPE_T m_shape
Definition: eda_shape.h:296
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:943
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:307
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:308
#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:596
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()

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

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

◆ IsPolyShapeValid()

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

Definition at line 1169 of file eda_shape.cpp.

1170 {
1171  // return true if the polygonal shape is valid (has more than 2 points)
1172  if( GetPolyShape().OutlineCount() == 0 )
1173  return false;
1174 
1175  const SHAPE_LINE_CHAIN& outline = ( (SHAPE_POLY_SET&)GetPolyShape() ).Outline( 0 );
1176 
1177  return outline.PointCount() > 2;
1178 }
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(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), KIGFX::SCH_PAINTER::setDeviceColors(), GERBVIEW_SELECTION_TOOL::unselect(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::visitItem(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ IsType()

virtual bool EDA_ITEM::IsType ( const KICAD_T  aScanTypes[]) const
inlinevirtualinherited

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 in PCB_VIA, SCH_LABEL, PCB_DIMENSION_BASE, PAD, SCH_FIELD, FP_TEXT, SCH_LINE, PCB_SHAPE, FP_SHAPE, and PCB_TEXT.

Definition at line 182 of file eda_item.h.

183  {
184  if( aScanTypes[0] == SCH_LOCATE_ANY_T )
185  return true;
186 
187  for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
188  {
189  if( m_structType == *p )
190  return true;
191  }
192 
193  return false;
194  }
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
KICAD_T m_structType
Run time identification, keep private so it can never be changed after a ctor sets it.
Definition: eda_item.h:487

References EOT, EDA_ITEM::m_structType, and SCH_LOCATE_ANY_T.

Referenced by SCH_EDIT_TOOL::AutoplaceFields(), ROUTER_TOOL::CanInlineDrag(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingBus(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingLine(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingWire(), PCB_TEXT::IsType(), FP_SHAPE::IsType(), PCB_SHAPE::IsType(), SCH_LINE::IsType(), FP_TEXT::IsType(), SCH_FIELD::IsType(), PAD::IsType(), PCB_DIMENSION_BASE::IsType(), SCH_LABEL::IsType(), PCB_VIA::IsType(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), EE_SELECTION_TOOL::RequestSelection(), SCH_BASE_FRAME::UpdateItem(), EDA_ITEM::Visit(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

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

◆ 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 1057 of file eda_shape.cpp.

1058 {
1059  std::vector<SHAPE*> effectiveShapes;
1060 
1061  switch( m_shape )
1062  {
1063  case SHAPE_T::ARC:
1064  effectiveShapes.emplace_back( new SHAPE_ARC( m_arcCenter, m_start, GetArcAngle() / 10.0,
1065  m_width ) );
1066  break;
1067 
1068  case SHAPE_T::SEGMENT:
1069  effectiveShapes.emplace_back( new SHAPE_SEGMENT( m_start, m_end, m_width ) );
1070  break;
1071 
1072  case SHAPE_T::RECT:
1073  {
1074  std::vector<wxPoint> pts = GetRectCorners();
1075 
1076  if( IsFilled() )
1077  effectiveShapes.emplace_back( new SHAPE_SIMPLE( pts ) );
1078 
1079  if( m_width > 0 || !IsFilled() )
1080  {
1081  effectiveShapes.emplace_back( new SHAPE_SEGMENT( pts[0], pts[1], m_width ) );
1082  effectiveShapes.emplace_back( new SHAPE_SEGMENT( pts[1], pts[2], m_width ) );
1083  effectiveShapes.emplace_back( new SHAPE_SEGMENT( pts[2], pts[3], m_width ) );
1084  effectiveShapes.emplace_back( new SHAPE_SEGMENT( pts[3], pts[0], m_width ) );
1085  }
1086  }
1087  break;
1088 
1089  case SHAPE_T::CIRCLE:
1090  {
1091  if( IsFilled() )
1092  effectiveShapes.emplace_back( new SHAPE_CIRCLE( getCenter(), GetRadius() ) );
1093 
1094  if( m_width > 0 || !IsFilled() )
1095  {
1096  // SHAPE_CIRCLE has no ConvertToPolyline() method, so use a 360.0 SHAPE_ARC
1097  SHAPE_ARC circle( getCenter(), GetEnd(), 360.0 );
1098  SHAPE_LINE_CHAIN l = circle.ConvertToPolyline();
1099 
1100  for( int i = 0; i < l.SegmentCount(); i++ )
1101  {
1102  effectiveShapes.emplace_back( new SHAPE_SEGMENT( l.Segment( i ).A, l.Segment( i ).B,
1103  m_width ) );
1104  }
1105  }
1106 
1107  break;
1108  }
1109 
1110  case SHAPE_T::BEZIER:
1111  {
1112  auto bezierPoints = buildBezierToSegmentsPointsList( GetWidth() );
1113  wxPoint start_pt = bezierPoints[0];
1114 
1115  for( unsigned int jj = 1; jj < bezierPoints.size(); jj++ )
1116  {
1117  wxPoint end_pt = bezierPoints[jj];
1118  effectiveShapes.emplace_back( new SHAPE_SEGMENT( start_pt, end_pt, m_width ) );
1119  start_pt = end_pt;
1120  }
1121 
1122  break;
1123  }
1124 
1125  case SHAPE_T::POLY:
1126  {
1128 
1130  l.Move( getParentPosition() );
1131 
1132  if( IsFilled() )
1133  effectiveShapes.emplace_back( new SHAPE_SIMPLE( l ) );
1134 
1135  if( m_width > 0 || !IsFilled() )
1136  {
1137  for( int i = 0; i < l.SegmentCount(); i++ )
1138  effectiveShapes.emplace_back( new SHAPE_SEGMENT( l.Segment( i ), m_width ) );
1139  }
1140  }
1141  break;
1142 
1143  default:
1145  break;
1146  }
1147 
1148  return effectiveShapes;
1149 }
SHAPE_T m_shape
Definition: eda_shape.h:296
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:498
virtual wxPoint getParentPosition() const =0
wxPoint m_end
Definition: eda_shape.h:300
wxPoint m_arcCenter
Definition: eda_shape.h:302
bool IsFilled() const
Definition: eda_shape.h:81
std::vector< wxPoint > GetRectCorners() const
Definition: eda_shape.cpp:943
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:299
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:297
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 PCB_SHAPE::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.

◆ MirrorHorizontal()

void LIB_SHAPE::MirrorHorizontal ( const wxPoint &  aCenter)
overridevirtual

Mirror the draw object along the horizontal (X) axis about aCenter point.

Parameters
aCenterPoint to mirror around.

Implements LIB_ITEM.

Definition at line 92 of file lib_shape.cpp.

93 {
94  flip( aCenter, true );
95 }
void flip(const wxPoint &aCentre, bool aFlipLeftRight)
Definition: eda_shape.cpp:281

References EDA_SHAPE::flip().

◆ MirrorVertical()

void LIB_SHAPE::MirrorVertical ( const wxPoint &  aCenter)
overridevirtual

Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.

Parameters
aCenterPoint to mirror around.

Implements LIB_ITEM.

Definition at line 98 of file lib_shape.cpp.

99 {
100  flip( aCenter, false );
101 }
void flip(const wxPoint &aCentre, bool aFlipLeftRight)
Definition: eda_shape.cpp:281

References EDA_SHAPE::flip().

◆ 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:296
wxPoint m_bezierC1
Definition: eda_shape.h:304
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
wxPoint m_end
Definition: eda_shape.h:300
wxPoint m_arcCenter
Definition: eda_shape.h:302
wxPoint m_bezierC2
Definition: eda_shape.h:305
void Move(const VECTOR2I &aVector) override
std::vector< wxPoint > m_bezierPoints
Definition: eda_shape.h:307
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:308
#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:299

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 PCB_SHAPE::Move(), Offset(), and EDA_SHAPE::setPosition().

◆ MoveTo()

void LIB_SHAPE::MoveTo ( const wxPoint &  aPosition)
overridevirtual

Move a draw object to aPosition.

Parameters
aPositionPosition to move draw item to.

Implements LIB_ITEM.

Definition at line 86 of file lib_shape.cpp.

87 {
88  setPosition( aPosition );
89 }
void setPosition(const wxPoint &aPos)
Definition: eda_shape.cpp:89

References EDA_SHAPE::setPosition().

◆ Offset()

void LIB_SHAPE::Offset ( const wxPoint &  aOffset)
overridevirtual

Set the drawing object by aOffset from the current position.

Parameters
aOffsetCoordinates to offset the item position.

Implements LIB_ITEM.

Definition at line 80 of file lib_shape.cpp.

81 {
82  move( aOffset );
83 }
void move(const wxPoint &aMoveVector)
Definition: eda_shape.cpp:137

References EDA_SHAPE::move().

◆ operator<() [1/2]

bool LIB_ITEM::operator< ( const LIB_ITEM aOther) const
inherited

Test if another draw item is less than this draw object.

Parameters
aOther- Draw item to compare against.
Returns
- True if object is less than this object.

Definition at line 92 of file lib_item.cpp.

93 {
94  if( Type() != aOther.Type() )
95  return Type() < aOther.Type();
96 
97  return ( compare( aOther ) < 0 );
98 }
virtual int compare(const LIB_ITEM &aOther, LIB_ITEM::COMPARE_FLAGS aCompareFlags=LIB_ITEM::COMPARE_FLAGS::NORMAL) const
Provide the draw object specific comparison called by the == and < operators.
Definition: lib_item.cpp:67
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References LIB_ITEM::compare(), and EDA_ITEM::Type().

◆ operator<() [2/2]

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

Test if another item is less than this object.

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

Definition at line 234 of file eda_item.cpp.

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

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

◆ operator==() [1/2]

bool LIB_ITEM::operator== ( const LIB_ITEM aOther) const
inherited

Test LIB_ITEM objects for equivalence.

Parameters
aOtherObject to test against.
Returns
True if object is identical to this object.

Definition at line 83 of file lib_item.cpp.

84 {
85  if( Type() != aOther.Type() )
86  return false;
87 
88  return compare( aOther ) == 0;
89 }
virtual int compare(const LIB_ITEM &aOther, LIB_ITEM::COMPARE_FLAGS aCompareFlags=LIB_ITEM::COMPARE_FLAGS::NORMAL) const
Provide the draw object specific comparison called by the == and < operators.
Definition: lib_item.cpp:67
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References LIB_ITEM::compare(), and EDA_ITEM::Type().

◆ operator==() [2/2]

bool LIB_ITEM::operator== ( const LIB_ITEM aOther) const
inlineinherited

Definition at line 195 of file lib_item.h.

196  {
197  return *this == *aOther;
198  }

◆ Plot()

void LIB_SHAPE::Plot ( PLOTTER aPlotter,
const wxPoint &  aOffset,
bool  aFill,
const TRANSFORM aTransform 
) const
overridevirtual

Plot the draw item using the plot object.

Parameters
aPlotterThe plot object to plot to.
aOffsetPlot offset position.
aFillFlag to indicate whether or not the object is filled.
aTransformThe plot transform.

Implements LIB_ITEM.

Definition at line 112 of file lib_shape.cpp.

114 {
115  wxPoint start = aTransform.TransformCoordinate( m_start ) + aOffset;
116  wxPoint end = aTransform.TransformCoordinate( m_end ) + aOffset;
117  wxPoint center;
118  int startAngle = 0;
119  int endAngle = 0;
120  int pen_size = GetEffectivePenWidth( aPlotter->RenderSettings() );
121  FILL_T fill = aFill ? m_fill : FILL_T::NO_FILL;
122 
123  static std::vector<wxPoint> cornerList;
124 
125  if( GetShape() == SHAPE_T::POLY )
126  {
127  const SHAPE_LINE_CHAIN& poly = m_poly.Outline( 0 );
128  cornerList.clear();
129 
130  for( const VECTOR2I& pt : poly.CPoints() )
131  cornerList.push_back( aTransform.TransformCoordinate( (wxPoint) pt ) + aOffset );
132  }
133  else if( GetShape() == SHAPE_T::BEZIER )
134  {
135  cornerList.clear();
136 
137  for( const wxPoint& pt : m_bezierPoints )
138  cornerList.push_back( aTransform.TransformCoordinate( pt ) + aOffset );
139  }
140  else if( GetShape() == SHAPE_T::ARC )
141  {
142  center = aTransform.TransformCoordinate( getCenter() ) + aOffset;
143 
144  CalcArcAngles( startAngle, endAngle );
145  aTransform.MapAngles( &startAngle, &endAngle );
146  }
147 
149  {
150  aPlotter->SetColor( aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE_BACKGROUND ) );
151 
152  switch( GetShape() )
153  {
154  case SHAPE_T::ARC:
155  aPlotter->Arc( center, -endAngle, -startAngle, GetRadius(), fill, 0 );
156  break;
157 
158  case SHAPE_T::CIRCLE:
159  aPlotter->Circle( start, GetRadius() * 2, fill, 0 );
160  break;
161 
162  case SHAPE_T::RECT:
163  aPlotter->Rect( start, end, fill, 0 );
164  break;
165 
166  case SHAPE_T::POLY:
167  case SHAPE_T::BEZIER:
168  aPlotter->PlotPoly( cornerList, fill, 0 );
169  break;
170 
171  default:
173  }
174 
175  if( pen_size <= 0 )
176  return;
177  else
178  fill = FILL_T::NO_FILL;
179  }
180 
181  aPlotter->SetColor( aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE ) );
182 
183  switch( GetShape() )
184  {
185  case SHAPE_T::ARC:
186  aPlotter->Arc( center, -endAngle, -startAngle, GetRadius(), fill, pen_size );
187  break;
188 
189  case SHAPE_T::CIRCLE:
190  aPlotter->Circle( start, GetRadius() * 2, fill, pen_size );
191  break;
192 
193  case SHAPE_T::RECT:
194  aPlotter->Rect( start, end, fill, pen_size );
195  break;
196 
197  case SHAPE_T::POLY:
198  case SHAPE_T::BEZIER:
199  aPlotter->PlotPoly( cornerList, fill, pen_size );
200  break;
201 
202  default:
204  }
205 }
void CalcArcAngles(int &aStartAngle, int &aEndAngle) const
Definition: lib_shape.cpp:423
wxPoint getCenter() const
Definition: eda_shape.cpp:393
virtual void PlotPoly(const std::vector< wxPoint > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr)=0
Draw a polygon ( filled or not ).
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
wxPoint m_end
Definition: eda_shape.h:300
FILL_T
Definition: eda_shape.h:53
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:42
int GetEffectivePenWidth(const RENDER_SETTINGS *aSettings) const override
Definition: lib_shape.h:57
const std::vector< VECTOR2I > & CPoints() const
SHAPE_LINE_CHAIN & Outline(int aIndex)
std::vector< wxPoint > m_bezierPoints
Definition: eda_shape.h:307
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:308
FILL_T m_fill
Definition: eda_shape.h:298
#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:299
virtual void SetColor(const COLOR4D &color)=0
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:156
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
virtual void Arc(const wxPoint &centre, double StAngle, double EndAngle, int rayon, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)
Generic fallback: arc rendered as a polyline.
Definition: plotter.cpp:164
SHAPE_T GetShape() const
Definition: eda_shape.h:92
bool MapAngles(int *aAngle1, int *aAngle2) const
Calculate new angles according to the transform.
Definition: transform.cpp:79
int GetRadius() const
Definition: eda_shape.cpp:466
virtual void Circle(const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0

References ARC, PLOTTER::Arc(), BEZIER, CalcArcAngles(), CIRCLE, PLOTTER::Circle(), SHAPE_LINE_CHAIN::CPoints(), FILLED_WITH_BG_BODYCOLOR, EDA_SHAPE::getCenter(), GetEffectivePenWidth(), KIGFX::RENDER_SETTINGS::GetLayerColor(), EDA_SHAPE::GetRadius(), EDA_SHAPE::GetShape(), LAYER_DEVICE, LAYER_DEVICE_BACKGROUND, EDA_SHAPE::m_bezierPoints, EDA_SHAPE::m_end, EDA_SHAPE::m_fill, EDA_SHAPE::m_poly, EDA_SHAPE::m_start, TRANSFORM::MapAngles(), NO_FILL, SHAPE_POLY_SET::Outline(), PLOTTER::PlotPoly(), POLY, RECT, PLOTTER::Rect(), PLOTTER::RenderSettings(), PLOTTER::SetColor(), EDA_SHAPE::SHAPE_T_asString(), TRANSFORM::TransformCoordinate(), and UNIMPLEMENTED_FOR.

Referenced by LIB_SYMBOL::Plot().

◆ print()

void LIB_SHAPE::print ( const RENDER_SETTINGS aSettings,
const wxPoint &  aOffset,
void *  aData,
const TRANSFORM aTransform 
)
overrideprivatevirtual

Print the item to aDC.

Parameters
aOffsetA reference to a wxPoint object containing the offset where to draw from the object's current position.
aDataA pointer to any object specific data required to perform the draw.
aTransformA reference to a TRANSFORM object containing drawing transform.

Implements LIB_ITEM.

Definition at line 214 of file lib_shape.cpp.

216 {
217  bool forceNoFill = static_cast<bool>( aData );
218  int penWidth = GetEffectivePenWidth( aSettings );
219 
220  if( forceNoFill && IsFilled() && penWidth == 0 )
221  return;
222 
223  wxDC* DC = aSettings->GetPrintDC();
224  wxPoint pt1 = aTransform.TransformCoordinate( m_start ) + aOffset;
225  wxPoint pt2 = aTransform.TransformCoordinate( m_end ) + aOffset;
226  wxPoint c;
227  COLOR4D color = aSettings->GetLayerColor( LAYER_DEVICE );
228  COLOR4D fillColor = color;
229 
230  unsigned ptCount = 0;
231  wxPoint* buffer = nullptr;
232 
233  if( GetShape() == SHAPE_T::POLY )
234  {
235  const SHAPE_LINE_CHAIN& poly = m_poly.Outline( 0 );
236 
237  ptCount = poly.GetPointCount();
238  buffer = new wxPoint[ ptCount ];
239 
240  for( unsigned ii = 0; ii < ptCount; ++ii )
241  buffer[ii] = aTransform.TransformCoordinate( (wxPoint) poly.CPoint( ii ) ) + aOffset;
242  }
243  else if( GetShape() == SHAPE_T::BEZIER )
244  {
245  ptCount = m_bezierPoints.size();
246  buffer = new wxPoint[ ptCount ];
247 
248  for( size_t ii = 0; ii < ptCount; ++ii )
249  buffer[ii] = aTransform.TransformCoordinate( m_bezierPoints[ii] ) + aOffset;
250  }
251  else if( GetShape() == SHAPE_T::ARC )
252  {
253  c = aTransform.TransformCoordinate( getCenter() ) + aOffset;
254 
255  int t1, t2;
256 
257  CalcArcAngles( t1, t2 );
258 
259  if( NormalizeAngle180( t1 - t2 ) > 0 )
260  std::swap( pt1, pt2 );
261  }
262 
263  if( forceNoFill || GetFillType() == FILL_T::NO_FILL )
264  {
265  penWidth = std::max( penWidth, aSettings->GetDefaultPenWidth() );
266 
267  switch( GetShape() )
268  {
269  case SHAPE_T::ARC:
270  GRArc1( nullptr, DC, pt1, pt2, c, penWidth, color );
271  break;
272 
273  case SHAPE_T::CIRCLE:
274  GRCircle( nullptr, DC, pt1.x, pt1.y, GetRadius(), penWidth, color );
275  break;
276 
277  case SHAPE_T::RECT:
278  GRRect( nullptr, DC, pt1.x, pt1.y, pt2.x, pt2.y, penWidth, color );
279  break;
280 
281  case SHAPE_T::POLY:
282  GRPoly( nullptr, DC, ptCount, buffer, false, penWidth, color, color );
283  break;
284 
285  case SHAPE_T::BEZIER:
286  GRPoly( nullptr, DC, ptCount, buffer, false, penWidth, color, color );
287  break;
288 
289  default:
291  }
292  }
293  else
294  {
296  fillColor = aSettings->GetLayerColor( LAYER_DEVICE_BACKGROUND );
297 
298  switch( GetShape() )
299  {
300  case SHAPE_T::ARC:
301  // If we stroke in GRFilledArc it will stroke the two radials too, so we have to
302  // fill and stroke separately
303 
304  GRFilledArc1( nullptr, DC, pt1, pt2, c, 0, fillColor, fillColor );
305 
306  GRArc1( nullptr, DC, pt1, pt2, c, penWidth, color );
307  break;
308 
309  case SHAPE_T::CIRCLE:
310  GRFilledCircle( nullptr, DC, pt1.x, pt1.y, GetRadius(), 0, color, fillColor );
311  break;
312 
313  case SHAPE_T::RECT:
314  GRFilledRect( nullptr, DC, pt1.x, pt1.y, pt2.x, pt2.y, penWidth, color, fillColor );
315  break;
316 
317  case SHAPE_T::POLY:
318  if( penWidth > 0 )
319  GRPoly( nullptr, DC, ptCount, buffer, true, penWidth, color, fillColor );
320  else
321  GRPoly( nullptr, DC, ptCount, buffer, true, 0, fillColor, fillColor );
322  break;
323 
324  case SHAPE_T::BEZIER:
325  if( penWidth > 0 )
326  GRPoly( nullptr, DC, ptCount, buffer, true, penWidth, color, fillColor );
327  else
328  GRPoly( nullptr, DC, ptCount, buffer, true, 0, fillColor, fillColor );
329  break;
330 
331  default:
333  }
334  }
335 
336  delete[] buffer;
337 }
void CalcArcAngles(int &aStartAngle, int &aEndAngle) const
Definition: lib_shape.cpp:423
virtual size_t GetPointCount() const override
wxPoint getCenter() const
Definition: eda_shape.cpp:393
void GRFilledRect(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, const COLOR4D &Color, const COLOR4D &BgColor)
Definition: gr_basic.cpp:708
int color
Definition: DXF_plotter.cpp:57
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
void GRRect(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color)
Definition: gr_basic.cpp:701
wxPoint m_end
Definition: eda_shape.h:300
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:42
bool IsFilled() const
Definition: eda_shape.h:81
T NormalizeAngle180(T Angle)
Normalize angle to be in the -180.0 .. 180.0 range.
Definition: trigo.h:387
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
int GetEffectivePenWidth(const RENDER_SETTINGS *aSettings) const override
Definition: lib_shape.h:57
SHAPE_LINE_CHAIN & Outline(int aIndex)
std::vector< wxPoint > m_bezierPoints
Definition: eda_shape.h:307
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:308
void GRCircle(EDA_RECT *ClipBox, wxDC *DC, int xc, int yc, int r, int width, const COLOR4D &Color)
Draw a circle onto the drawing context aDC centered at the user coordinates (x,y).
Definition: gr_basic.cpp:507
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:120
wxDC * GetPrintDC() const
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:71
wxPoint m_start
Definition: eda_shape.h:299
void GRArc1(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int xc, int yc, int width, const COLOR4D &Color)
Definition: gr_basic.cpp:544
void GRFilledArc1(EDA_RECT *ClipBox, wxDC *DC, const wxPoint &aStart, const wxPoint &aEnd, const wxPoint &aCenter, int width, const COLOR4D &Color, const COLOR4D &BgColor)
Definition: gr_basic.cpp:584
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
int GetDefaultPenWidth() const
SHAPE_T GetShape() const
Definition: eda_shape.h:92
void GRPoly(EDA_RECT *ClipBox, wxDC *DC, int n, const wxPoint *Points, bool Fill, int width, const COLOR4D &Color, const COLOR4D &BgColor)
Draw a new polyline and fill it if Fill, in drawing space.
Definition: gr_basic.cpp:453
int GetRadius() const
Definition: eda_shape.cpp:466
FILL_T GetFillType() const
Definition: eda_shape.h:79
void GRFilledCircle(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int r, int width, const COLOR4D &Color, const COLOR4D &BgColor)
Definition: gr_basic.cpp:525
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References ARC, BEZIER, CalcArcAngles(), CIRCLE, color, SHAPE_LINE_CHAIN::CPoint(), FILLED_WITH_BG_BODYCOLOR, EDA_SHAPE::getCenter(), KIGFX::RENDER_SETTINGS::GetDefaultPenWidth(), GetEffectivePenWidth(), EDA_SHAPE::GetFillType(), KIGFX::RENDER_SETTINGS::GetLayerColor(), SHAPE_LINE_CHAIN::GetPointCount(), KIGFX::RENDER_SETTINGS::GetPrintDC(), EDA_SHAPE::GetRadius(), EDA_SHAPE::GetShape(), GRArc1(), GRCircle(), GRFilledArc1(), GRFilledCircle(), GRFilledRect(), GRPoly(), GRRect(), EDA_SHAPE::IsFilled(), LAYER_DEVICE, LAYER_DEVICE_BACKGROUND, EDA_SHAPE::m_bezierPoints, EDA_SHAPE::m_end, EDA_SHAPE::m_poly, EDA_SHAPE::m_start, NO_FILL, NormalizeAngle180(), SHAPE_POLY_SET::Outline(), POLY, RECT, EDA_SHAPE::SHAPE_T_asString(), TRANSFORM::TransformCoordinate(), and UNIMPLEMENTED_FOR.

◆ Print()

void LIB_ITEM::Print ( const RENDER_SETTINGS aSettings,
const wxPoint &  aOffset,
void *  aData,
const TRANSFORM aTransform 
)
virtualinherited

Draw an item.

Parameters
aDCDevice Context (can be null)
aOffsetOffset to draw
aDataValue or pointer used to pass others parameters, depending on body items. Used for some items to force to force no fill mode ( has meaning only for items what can be filled ). used in printing or moving objects mode or to pass reference to the lib symbol for pins.
aTransformTransform Matrix (rotation, mirror ..)

Definition at line 118 of file lib_item.cpp.

120 {
121  print( aSettings, aOffset, aData, aTransform );
122 }
virtual void print(const RENDER_SETTINGS *aSettings, const wxPoint &aOffset, void *aData, const TRANSFORM &aTransform)=0
Print the item to aDC.

References LIB_ITEM::print().

Referenced by DIALOG_PIN_PROPERTIES::OnPaintShowPanel(), and LIB_SYMBOL::Print().

◆ 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:296
std::vector< wxPoint > m_bezierPoints
Definition: eda_shape.h:307
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()

void LIB_SHAPE::Rotate ( const wxPoint &  aCenter,
bool  aRotateCCW = true 
)
overridevirtual

Rotate the object about aCenter point.

Parameters
aCenterPoint to rotate around.
aRotateCCWTrue to rotate counter clockwise. False to rotate clockwise.

Implements LIB_ITEM.

Definition at line 104 of file lib_shape.cpp.

105 {
106  int rot_angle = aRotateCCW ? -900 : 900;
107 
108  rotate( aCenter, rot_angle );
109 }
void rotate(const wxPoint &aRotCentre, double aAngle)
Definition: eda_shape.cpp:224

References EDA_SHAPE::rotate().

◆ 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:296
wxPoint m_bezierC1
Definition: eda_shape.h:304
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
void Rotate(double aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Rotate all vertices by a given angle.
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
wxPoint m_end
Definition: eda_shape.h:300
wxPoint m_arcCenter
Definition: eda_shape.h:302
wxPoint m_bezierC2
Definition: eda_shape.h:305
std::vector< wxPoint > m_bezierPoints
Definition: eda_shape.h:307
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:308
#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:299
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 Rotate(), and PCB_SHAPE::Rotate().

◆ 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:296
wxPoint m_bezierC1
Definition: eda_shape.h:304
wxPoint m_end
Definition: eda_shape.h:300
wxPoint m_arcCenter
Definition: eda_shape.h:302
wxPoint m_bezierC2
Definition: eda_shape.h:305
const std::vector< VECTOR2I > & CPoints() const
SHAPE_LINE_CHAIN & Outline(int aIndex)
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:308
#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:299
void SetPolyPoints(const std::vector< wxPoint > &aPoints)
Definition: eda_shape.cpp:1047
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 PCB_SHAPE::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 509 of file eda_shape.cpp.

510 {
511  m_end = m_start;
513 
514  if( aCheckNegativeAngle && aAngle < 0 )
515  {
516  std::swap( m_start, m_end );
517  m_endsSwapped = true;
518  }
519 }
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:300
wxPoint m_arcCenter
Definition: eda_shape.h:302
bool m_endsSwapped
Definition: eda_shape.h:295
wxPoint m_start
Definition: eda_shape.h:299

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(), ALTIUM_PCB::HelperCreateBoardOutline(), 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.

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 }
wxPoint m_end
Definition: eda_shape.h:300
wxPoint m_arcCenter
Definition: eda_shape.h:302
bool m_endsSwapped
Definition: eda_shape.h:295
wxPoint m_start
Definition: eda_shape.h:299
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::m_arcCenter, EDA_SHAPE::m_end, EDA_SHAPE::m_endsSwapped, and EDA_SHAPE::m_start.

Referenced by EDA_SHAPE::beginEdit(), EDA_SHAPE::calcEdit(), PCB_POINT_EDITOR::editArcMidKeepEndpoints(), 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:307

References EDA_SHAPE::m_bezierPoints.

◆ SetBrightened()

◆ SetCenter()

◆ SetConvert()

◆ SetEditState()

void LIB_SHAPE::SetEditState ( int  aState)
inline

Definition at line 78 of file lib_shape.h.

78 { setEditState( aState ); }
void setEditState(int aState)
Definition: eda_shape.h:292

References EDA_SHAPE::setEditState().

Referenced by EE_POINT_EDITOR::updateParentItem().

◆ setEditState()

void EDA_SHAPE::setEditState ( int  aState)
inlineprotectedinherited

Definition at line 292 of file eda_shape.h.

292 { m_editState = aState; }
int m_editState
Definition: eda_shape.h:310

References EDA_SHAPE::m_editState.

Referenced by 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:300
bool m_endsSwapped
Definition: eda_shape.h:295

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(), EE_SELECTION_TOOL::selectMultiple(), SCH_EDIT_FRAME::SelectUnit(), EDA_ITEM::SetBrightened(), EDA_ITEM::SetModified(), EDA_ITEM::SetSelected(), EDA_ITEM::SetWireImage(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_LINE_WIRE_BUS_TOOL::startSegments(), DS_DATA_ITEM::SyncDrawItems(), DS_DATA_ITEM_BITMAP::SyncDrawItems(), DIALOG_DIMENSION_PROPERTIES::TransferDataFromWindow(), DIALOG_TARGET_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ SetForceVisible()

void EDA_ITEM::SetForceVisible ( bool  aEnable)
inlineinherited

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

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

Definition at line 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().

◆ SetModified()

void EDA_ITEM::SetModified ( )
inherited

◆ SetParent()