KiCad PCB EDA Suite
DRAWSEGMENT Class Reference

#include <class_drawsegment.h>

Inheritance diagram for DRAWSEGMENT:
BOARD_ITEM EDA_ITEM KIGFX::VIEW_ITEM INSPECTABLE EDGE_MODULE

Classes

struct  cmp_drawings
 

Public Member Functions

 DRAWSEGMENT (BOARD_ITEM *aParent=NULL, KICAD_T idtype=PCB_LINE_T)
 
 ~DRAWSEGMENT ()
 
bool IsType (const KICAD_T aScanTypes[]) const override
 Function IsType Checks whether the item is one of the listed types. More...
 
bool IsPolygonFilled () const
 Polygonal shape is not always filled. More...
 
void SetWidth (int aWidth)
 
int GetWidth () const
 
virtual void SetAngle (double aAngle)
 Function SetAngle sets the angle for arcs, and normalizes it within the range 0 - 360 degrees. More...
 
double GetAngle () const
 
void SetType (int aType)
 
int GetType () const
 
void SetShape (STROKE_T aShape)
 
STROKE_T GetShape () const
 
void SetBezControl1 (const wxPoint &aPoint)
 
const wxPointGetBezControl1 () const
 
void SetBezControl2 (const wxPoint &aPoint)
 
const wxPointGetBezControl2 () const
 
void SetPosition (const wxPoint &aPos) override
 
wxPoint GetPosition () const override
 
const wxPointGetStart () const
 Function GetStart returns the starting point of the graphic. More...
 
int GetStartY ()
 
int GetStartX ()
 
void SetStart (const wxPoint &aStart)
 
void SetStartY (int y)
 
void SetStartX (int x)
 
const wxPointGetEnd () const
 Function GetEnd returns the ending point of the graphic. More...
 
int GetEndY ()
 
int GetEndX ()
 
void SetEnd (const wxPoint &aEnd)
 
void SetEndY (int y)
 
void SetEndX (int x)
 
const wxPointGetThirdPoint () const
 Function GetThirdPoint returns the third point point of the graphic. More...
 
int GetThirdPointY ()
 
int GetThirdPointX ()
 
void SetThirdPoint (const wxPoint &aPoint)
 
void SetThirdPointY (int y)
 
void SetThirdPointX (int x)
 
wxPoint GetCenter () const override
 Function GetCenter() More...
 
wxPoint GetArcStart () const
 
wxPoint GetArcEnd () const
 
wxPoint GetArcMid () const
 
std::vector< wxPointGetRectCorners () const
 
double GetArcAngleStart () const
 function GetArcAngleStart() More...
 
double GetArcAngleEnd () const
 function GetArcAngleEnd() More...
 
int GetRadius () const
 Function GetRadius returns the radius of this item Has meaning only for arc and circle. More...
 
void SetArcStart (const wxPoint &aArcStartPoint)
 Initialize the start arc point. More...
 
void SetArcEnd (const wxPoint &aArcEndPoint)
 Initialize the end arc point. More...
 
void SetCenter (const wxPoint &aCenterPoint)
 For arcs and circles: More...
 
const wxPoint GetFocusPosition () const override
 Function GetFocusPosition similar to GetPosition, but allows items to return their visual center rather than their anchor. More...
 
MODULEGetParentModule () const
 Function GetParentModule returns a pointer to the parent module, or NULL if DRAWSEGMENT does not belong to a module. More...
 
const std::vector< wxPoint > & GetBezierPoints () const
 
const std::vector< wxPointBuildPolyPointsList () const
 Build and return the list of corners in a std::vector<wxPoint> It must be used only to convert the SHAPE_POLY_SET internal corner buffer to a list of wxPoints, and nothing else, because it duplicates the buffer, that is inefficient to know for instance the corner count. More...
 
int GetPointCount () const
 
SHAPE_POLY_SETGetPolyShape ()
 
const SHAPE_POLY_SETGetPolyShape () const
 
bool IsPolyShapeValid () const
 
void SetPolyShape (const SHAPE_POLY_SET &aShape)
 
void SetBezierPoints (const std::vector< wxPoint > &aPoints)
 
void RebuildBezierToSegmentsPointsList (int aMinSegLen)
 Rebuild the m_BezierPoints vertex list that approximate the Bezier curve by a list of segments Has meaning only for S_CURVE DRAW_SEGMENT shape. More...
 
void SetPolyPoints (const std::vector< wxPoint > &aPoints)
 
std::vector< SHAPE * > MakeEffectiveShapes () const
 Makes a set of SHAPE objects representing the DRAWSEGMENT. More...
 
virtual std::shared_ptr< SHAPEGetEffectiveShape (PCB_LAYER_ID aLayer=UNDEFINED_LAYER) const override
 Function GetEffectiveShape Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes. More...
 
void GetMsgPanelInfo (EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
 Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for display purposes. More...
 
const EDA_RECT GetBoundingBox () const override
 Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes. More...
 
bool HitTest (const wxPoint &aPosition, int aAccuracy=0) const override
 Function HitTest tests if aPosition is contained within or on the bounding box of an item. More...
 
bool HitTest (const EDA_RECT &aRect, bool aContained, int aAccuracy=0) const override
 Function HitTest tests if aRect intersects or is contained within the bounding box of an item. More...
 
wxString GetClass () const override
 Function GetClass returns the class name. More...
 
double GetLength () const
 Function GetLength returns the length of the track using the hypotenuse calculation. More...
 
virtual void Move (const wxPoint &aMoveVector) override
 Function Move move this object. More...
 
virtual void Rotate (const wxPoint &aRotCentre, double aAngle) override
 Function Rotate Rotate this object. More...
 
virtual void Flip (const wxPoint &aCentre, bool aFlipLeftRight) override
 Function Flip Flip this object, i.e. More...
 
void Scale (double aScale)
 
void TransformShapeWithClearanceToPolygon (SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError=ARC_HIGH_DEF, bool ignoreLineWidth=false) const override
 Function TransformShapeWithClearanceToPolygon Convert the draw segment to a closed polygon Used in filling zones calculations Circles and arcs are approximated by segments. More...
 
virtual wxString GetSelectMenuText (EDA_UNITS aUnits) const override
 Function GetSelectMenuText returns the text to display to be used in the selection clarification context menu when multiple items are found at the current cursor position. More...
 
virtual BITMAP_DEF GetMenuImage () const override
 Function GetMenuImage returns a pointer to an image to be used in menus. More...
 
virtual EDA_ITEMClone () const override
 Function Clone creates a duplicate of this item with linked list members set to NULL. More...
 
virtual const BOX2I ViewBBox () const override
 Function ViewBBox() returns the bounding box of the item covering all its layers. More...
 
virtual void SwapData (BOARD_ITEM *aImage) override
 Swap data between aItem and aImage. More...
 
void SetGroup (const KIID &aGroup)
 Set the group that this item belongs to. More...
 
const KIIDGetGroup () const
 Get the group this item belongs to. More...
 
bool IsInGroup ()
 Test if this item is inside a group. More...
 
int GetX () const
 
int GetY () const
 
void SetX (int aX)
 
void SetY (int aY)
 
virtual bool IsConnected () const
 Function IsConnected() Returns information if the object is derived from BOARD_CONNECTED_ITEM. More...
 
virtual bool IsOnCopperLayer () const
 
BOARD_ITEM_CONTAINERGetParent () const
 
virtual PCB_LAYER_ID GetLayer () const
 Function GetLayer returns the primary layer this item is on. More...
 
virtual LSET GetLayerSet () const
 Function GetLayerSet returns a std::bitset of all layers on which the item physically resides. More...
 
virtual void SetLayerSet (LSET aLayers)
 
virtual void SetLayer (PCB_LAYER_ID aLayer)
 Function SetLayer sets the layer this item is on. More...
 
virtual BOARD_ITEMDuplicate () const
 Function Duplicate creates a copy of a BOARD_ITEM. More...
 
virtual bool IsOnLayer (PCB_LAYER_ID aLayer) const
 Function IsOnLayer tests to see if this object is on the given layer. More...
 
bool IsTrack () const
 Function IsTrack tests to see if this object is a track or via (or microvia). More...
 
virtual bool IsLocked () const
 Function IsLocked. More...
 
virtual void SetLocked (bool aLocked)
 Function SetLocked modifies 'lock' status for of the item. More...
 
void DeleteStructure ()
 Function DeleteStructure deletes this object after removing from its parent if it has one. More...
 
void Move (const VECTOR2I &aMoveVector)
 
void Rotate (const VECTOR2I &aRotCentre, double aAngle)
 
void Flip (const VECTOR2I &aCentre, bool aFlipLeftRight)
 
virtual BOARDGetBoard () const
 Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none. More...
 
wxString GetLayerName () const
 Function GetLayerName returns the name of the PCB layer on which the item resides. More...
 
virtual void ViewGetLayers (int aLayers[], int &aCount) const override
 Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on. More...
 
KICAD_T Type () const
 Function Type() More...
 
virtual void SetParent (EDA_ITEM *aParent)
 
bool IsModified () const
 
bool IsNew () const
 
bool IsMoving () const
 
bool IsDragging () const
 
bool IsWireImage () const
 
bool IsSelected () const
 
bool IsResized () const
 
bool IsBrightened () const
 
void SetWireImage ()
 
void SetSelected ()
 
void SetBrightened ()
 
void ClearSelected ()
 
void ClearBrightened ()
 
void SetModified ()
 
int GetState (int type) const
 
void SetState (int type, int state)
 
STATUS_FLAGS GetStatus () const
 
void SetStatus (STATUS_FLAGS aStatus)
 
void SetFlags (STATUS_FLAGS aMask)
 
void ClearFlags (STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
 
STATUS_FLAGS GetFlags () const
 
bool HasFlag (STATUS_FLAGS aFlag)
 
STATUS_FLAGS GetEditFlags () const
 
void ClearTempFlags ()
 
void ClearEditFlags ()
 
void SetForceVisible (bool aEnable)
 Function SetForceVisible is used to set and cleag force visible flag used to force the item to be drawn even if it's draw attribute is set to not visible. More...
 
bool IsForceVisible () const
 
virtual SEARCH_RESULT Visit (INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
 Function Visit may be re-implemented for each derived class in order to handle all the types given by its member data. More...
 
virtual bool Matches (wxFindReplaceData &aSearchData, void *aAuxData)
 Function Matches compares the item against the search criteria in aSearchData. More...
 
virtual bool Replace (wxFindReplaceData &aSearchData, void *aAuxData=NULL)
 Function Replace performs a text replace using the find and replace criteria in aSearchData on items that support text find and replace. More...
 
virtual bool IsReplaceable () const
 Function IsReplaceable. More...
 
bool operator< (const EDA_ITEM &aItem) const
 Test if another item is less than this object. More...
 
virtual void ViewDraw (int aLayer, VIEW *aView) const
 Function ViewDraw() Draws the parts of the object belonging to layer aLayer. More...
 
virtual double ViewGetLOD (int aLayer, VIEW *aView) const
 Function ViewGetLOD() Returns the level of detail (LOD) of the item. More...
 
VIEW_ITEM_DATA * viewPrivData () const
 
void ClearViewPrivData ()
 
bool Set (PROPERTY_BASE *aProperty, wxAny &aValue)
 
template<typename T >
bool Set (PROPERTY_BASE *aProperty, T aValue)
 
template<typename T >
bool Set (const wxString &aProperty, T aValue)
 
wxAny Get (PROPERTY_BASE *aProperty)
 
template<typename T >
Get (PROPERTY_BASE *aProperty)
 
template<typename T >
boost::optional< T > Get (const wxString &aProperty)
 

Static Public Member Functions

static bool ClassOf (const EDA_ITEM *aItem)
 
static wxString ShowShape (STROKE_T aShape)
 Function ShowShape converts the enum STROKE_T integer value to a wxString. More...
 
template<class T >
static SEARCH_RESULT IterateForward (std::deque< T > &aList, INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
 IterateForward( EDA_ITEM*, INSPECTOR, void*, const KICAD_T ) More...
 
template<class T >
static SEARCH_RESULT IterateForward (std::vector< T > &aList, INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
 IterateForward( EDA_ITEM*, INSPECTOR, void*, const KICAD_T ) More...
 
static bool Replace (wxFindReplaceData &aSearchData, wxString &aText)
 Helper function used in search and replace dialog Function Replace performs a text replace on aText using the find and replace criteria in aSearchData on items that support text find and replace. More...
 
static bool Sort (const EDA_ITEM *aLeft, const EDA_ITEM *aRight)
 Function Sort is a helper function to be used by the C++ STL sort algorithm for sorting a STL container of EDA_ITEM pointers. More...
 

Public Attributes

const KIID m_Uuid
 

Static Public Attributes

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

Protected Member Functions

void computeArcBBox (EDA_RECT &aBBox) const
 
const std::vector< wxPointbuildBezierToSegmentsPointsList (int aMinSegLen) const
 
virtual wxString LayerMaskDescribe () const
 Helper function Return a string (to be shown to the user) describing a layer mask. More...
 
bool Matches (const wxString &aText, wxFindReplaceData &aSearchData)
 Function Matches compares aText against search criteria in aSearchData. More...
 

Protected Attributes

int m_Width
 thickness of lines ... More...
 
wxPoint m_Start
 Line start point or Circle and Arc center. More...
 
wxPoint m_End
 Line end point or circle and arc start point. More...
 
wxPoint m_ThirdPoint
 Used only for Arcs: arc end point. More...
 
STROKE_T m_Shape
 Shape: line, Circle, Arc. More...
 
int m_Type
 Used in complex associations ( Dimensions.. ) More...
 
double m_Angle
 Used only for Arcs: Arc angle in 1/10 deg. More...
 
wxPoint m_BezierC1
 Bezier Control Point 1. More...
 
wxPoint m_BezierC2
 Bezier Control Point 2. More...
 
std::vector< wxPointm_BezierPoints
 
SHAPE_POLY_SET m_Poly
 Stores the S_POLYGON shape. More...
 
PCB_LAYER_ID m_Layer
 
KIID m_groupUuid
 
STATUS_FLAGS m_Status
 
EDA_ITEMm_Parent
 Linked list: Link (parent struct) More...
 
bool m_forceVisible
 
STATUS_FLAGS m_Flags
 

Detailed Description

Definition at line 48 of file class_drawsegment.h.

Constructor & Destructor Documentation

◆ DRAWSEGMENT()

DRAWSEGMENT::DRAWSEGMENT ( BOARD_ITEM aParent = NULL,
KICAD_T  idtype = PCB_LINE_T 
)

Definition at line 46 of file class_drawsegment.cpp.

46  :
47  BOARD_ITEM( aParent, idtype )
48 {
49  m_Type = 0;
50  m_Angle = 0;
51  m_Flags = 0;
54 }
#define DEFAULT_LINE_WIDTH
usual segment : line with rounded ends
double m_Angle
Used only for Arcs: Arc angle in 1/10 deg.
STROKE_T m_Shape
Shape: line, Circle, Arc.
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype)
int m_Type
Used in complex associations ( Dimensions.. )
STATUS_FLAGS m_Flags
Definition: base_struct.h:176
int m_Width
thickness of lines ...
static constexpr int Millimeter2iu(double mm)

References DEFAULT_LINE_WIDTH, m_Angle, EDA_ITEM::m_Flags, m_Shape, m_Type, m_Width, Millimeter2iu(), and S_SEGMENT.

Referenced by Clone().

◆ ~DRAWSEGMENT()

DRAWSEGMENT::~DRAWSEGMENT ( )

Definition at line 57 of file class_drawsegment.cpp.

58 {
59 }

Member Function Documentation

◆ buildBezierToSegmentsPointsList()

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

Definition at line 320 of file class_drawsegment.cpp.

321 {
322  std::vector<wxPoint> bezierPoints;
323 
324  // Rebuild the m_BezierPoints vertex list that approximate the Bezier curve
325  std::vector<wxPoint> ctrlPoints = { m_Start, m_BezierC1, m_BezierC2, m_End };
326  BEZIER_POLY converter( ctrlPoints );
327  converter.GetPoly( bezierPoints, aMinSegLen );
328 
329  return bezierPoints;
330 }
wxPoint m_BezierC1
Bezier Control Point 1.
wxPoint m_Start
Line start point or Circle and Arc center.
wxPoint m_End
Line end point or circle and arc start point.
Bezier curves to polygon converter.
Definition: bezier_curves.h:35
wxPoint m_BezierC2
Bezier Control Point 2.

References BEZIER_POLY::GetPoly(), m_BezierC1, m_BezierC2, m_End, and m_Start.

Referenced by MakeEffectiveShapes(), and RebuildBezierToSegmentsPointsList().

◆ BuildPolyPointsList()

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

Build and return the list of corners in a std::vector<wxPoint> It must be used only to convert the SHAPE_POLY_SET internal corner buffer to a list of wxPoints, and nothing else, because it duplicates the buffer, that is inefficient to know for instance the corner count.

Definition at line 1174 of file class_drawsegment.cpp.

1175 {
1176  std::vector<wxPoint> rv;
1177 
1178  if( m_Poly.OutlineCount() )
1179  {
1180  if( m_Poly.COutline( 0 ).PointCount() )
1181  {
1182  for ( auto iter = m_Poly.CIterate(); iter; iter++ )
1183  rv.emplace_back( iter->x, iter->y );
1184  }
1185  }
1186 
1187  return rv;
1188 }
int OutlineCount() const
Returns the number of outlines in the set
SHAPE_POLY_SET m_Poly
Stores the S_POLYGON shape.
int PointCount() const
Function PointCount()
CONST_ITERATOR CIterate(int aFirst, int aLast, bool aIterateHoles=false) const
const SHAPE_LINE_CHAIN & COutline(int aIndex) const

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

Referenced by GRID_HELPER::computeAnchors(), PCB_PARSER::parseD_PAD(), BRDITEMS_PLOTTER::PlotFootprintGraphicItem(), TransformShapeWithClearanceToPolygon(), and POINT_EDITOR::updatePoints().

◆ ClassOf()

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

Definition at line 78 of file class_drawsegment.h.

79  {
80  return aItem && PCB_LINE_T == aItem->Type();
81  }
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193

References PCB_LINE_T, and EDA_ITEM::Type().

◆ ClearBrightened()

void EDA_ITEM::ClearBrightened ( )
inlineinherited

◆ ClearEditFlags()

◆ ClearFlags()

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

Definition at line 233 of file base_struct.h.

233 { m_Flags &= ~aMask; }
STATUS_FLAGS m_Flags
Definition: base_struct.h:176

References EDA_ITEM::m_Flags.

Referenced by FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), PNS_KICAD_IFACE::AddItem(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), SCH_MOVE_TOOL::AlignElements(), EDA_ITEM::ClearBrightened(), EDA_ITEM::ClearEditFlags(), clearModuleItemFlags(), EDA_ITEM::ClearSelected(), EDA_ITEM::ClearTempFlags(), SCH_EDIT_FRAME::ConvertPart(), LIB_EDIT_TOOL::Copy(), LIB_PIN_TOOL::CreateImagePins(), MICROWAVE_TOOL::createMicrowaveInductor(), DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES(), KIGFX::SCH_PAINTER::draw(), LIB_EDIT_TOOL::Duplicate(), SCH_ITEM::Duplicate(), PCB_EDIT_FRAME::Exchange_Module(), LIB_EDIT_FRAME::GetComponentFromRedoList(), LIB_EDIT_FRAME::GetComponentFromUndoList(), FOOTPRINT_EDITOR_TOOLS::ImportFootprint(), FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD(), FOOTPRINT_EDIT_FRAME::LoadModuleFromLibrary(), FOOTPRINT_EDIT_FRAME::OpenProjectFiles(), PCB_BASE_FRAME::PlaceModule(), LIB_PIN_TOOL::PlacePin(), DRAWING_TOOL::PlaceText(), FOOTPRINT_EDIT_FRAME::Process_Special_Functions(), BOARD_COMMIT::Push(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_PIN_TOOL::RepeatPin(), LIB_EDIT_FRAME::RollbackPartFromUndo(), SCH_EDIT_FRAME::SaveCopyForRepeatItem(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), SCH_SEXPR_PLUGIN_CACHE::savePin(), SCH_LEGACY_PLUGIN_CACHE::savePin(), EE_SELECTION_TOOL::SelectPoint(), SCH_EDIT_FRAME::SelectUnit(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ ClearSelected()

◆ ClearTempFlags()

void EDA_ITEM::ClearTempFlags ( )
inlineinherited

Definition at line 245 of file base_struct.h.

246  {
248  DO_NOT_DRAW );
249  }
#define IS_LINKED
Used in calculation to mark linked items (temporary use)
Definition: base_struct.h:114
#define TEMP_SELECTED
flag indicating that the structure has already selected
Definition: base_struct.h:125
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Definition: base_struct.h:128
#define CANDIDATE
flag indicating that the structure is connected
Definition: base_struct.h:127
#define ENDPOINT
ends. (Used to support dragging.)
Definition: base_struct.h:123
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:233
#define DO_NOT_DRAW
Used to disable draw function.
Definition: base_struct.h:129
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: base_struct.h:122

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

Referenced by SCH_EDIT_FRAME::PutDataInPreviousState().

◆ ClearViewPrivData()

void KIGFX::VIEW_ITEM::ClearViewPrivData ( )
inlineinherited

Definition at line 154 of file view_item.h.

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

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

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

◆ Clone()

EDA_ITEM * DRAWSEGMENT::Clone ( ) const
overridevirtual

Function Clone creates a duplicate of this item with linked list members set to NULL.

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

Returns
A clone of the item.

Reimplemented from EDA_ITEM.

Reimplemented in EDGE_MODULE.

Definition at line 930 of file class_drawsegment.cpp.

931 {
932  return new DRAWSEGMENT( *this );
933 }
DRAWSEGMENT(BOARD_ITEM *aParent=NULL, KICAD_T idtype=PCB_LINE_T)

References DRAWSEGMENT().

◆ computeArcBBox()

void DRAWSEGMENT::computeArcBBox ( EDA_RECT aBBox) const
protected

Definition at line 989 of file class_drawsegment.cpp.

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

References PNS::angle(), GetArcAngleStart(), GetRadius(), m_Angle, m_End, m_Start, EDA_RECT::Merge(), RotatePoint(), EDA_RECT::SetOrigin(), wxPoint::x, and wxPoint::y.

Referenced by GetBoundingBox(), and ViewBBox().

◆ DeleteStructure()

void BOARD_ITEM::DeleteStructure ( )
inherited

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

Definition at line 115 of file class_board_item.cpp.

116 {
117  auto parent = GetParent();
118 
119  if( parent )
120  parent->Remove( this );
121 
122  delete this;
123 }
BOARD_ITEM_CONTAINER * GetParent() const

References BOARD_ITEM::GetParent().

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

◆ Duplicate()

virtual BOARD_ITEM* BOARD_ITEM::Duplicate ( ) const
inlinevirtualinherited

Function Duplicate creates a copy of a BOARD_ITEM.

Reimplemented in MODULE.

Definition at line 233 of file class_board_item.h.

234  {
235  EDA_ITEM* dupe = Clone();
236  const_cast<KIID&>( dupe->m_Uuid ) = KIID();
237 
238  return static_cast<BOARD_ITEM*>( dupe );
239  }
virtual EDA_ITEM * Clone() const
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: common.h:68
const KIID m_Uuid
Definition: base_struct.h:162
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159

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

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

◆ Flip() [1/2]

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

Function Flip Flip this object, i.e.

change the board side for this object

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

Reimplemented from BOARD_ITEM.

Reimplemented in EDGE_MODULE.

Definition at line 248 of file class_drawsegment.cpp.

249 {
250  if( aFlipLeftRight )
251  {
252  m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
253  m_End.x = aCentre.x - ( m_End.x - aCentre.x );
254  }
255  else
256  {
257  m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
258  m_End.y = aCentre.y - ( m_End.y - aCentre.y );
259  }
260 
261  switch ( m_Shape )
262  {
263  case S_ARC:
264  m_Angle = -m_Angle;
265  break;
266 
267  case S_POLYGON:
268  m_Poly.Mirror( aFlipLeftRight, !aFlipLeftRight, VECTOR2I( aCentre ) );
269  break;
270 
271  case S_CURVE:
272  {
273  if( aFlipLeftRight )
274  {
275  m_BezierC1.x = aCentre.x - ( m_BezierC1.x - aCentre.x );
276  m_BezierC2.x = aCentre.x - ( m_BezierC2.x - aCentre.x );
277  }
278  else
279  {
280  m_BezierC1.y = aCentre.y - ( m_BezierC1.y - aCentre.y );
281  m_BezierC2.y = aCentre.y - ( m_BezierC2.y - aCentre.y );
282  }
283 
284  // Rebuild the poly points shape
285  std::vector<wxPoint> ctrlPoints = { m_Start, m_BezierC1, m_BezierC2, m_End };
286  BEZIER_POLY converter( ctrlPoints );
287  converter.GetPoly( m_BezierPoints, m_Width );
288  }
289  break;
290 
291  case S_SEGMENT:
292  case S_RECT:
293  case S_CIRCLE:
294  break;
295 
296  default:
297  wxFAIL_MSG( "DRAWSEGMENT::Flip not implemented for " + STROKE_T_asString( m_Shape ) );
298  break;
299  }
300 
301  // DRAWSEGMENT items are not allowed on copper layers, so
302  // copper layers count is not taken in account in Flip transform
303  SetLayer( FlipLayer( GetLayer() ) );
304 }
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
SHAPE_POLY_SET m_Poly
Stores the S_POLYGON shape.
polygon (not yet used for tracks, but could be in microwave apps)
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Function FlippedLayerNumber.
Definition: lset.cpp:490
usual segment : line with rounded ends
double m_Angle
Used only for Arcs: Arc angle in 1/10 deg.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
void Mirror(bool aX=true, bool aY=false, const VECTOR2I &aRef={ 0, 0 })
Mirrors the line points about y or x (or both)
wxPoint m_BezierC1
Bezier Control Point 1.
segment with non rounded ends
wxPoint m_Start
Line start point or Circle and Arc center.
wxPoint m_End
Line end point or circle and arc start point.
Arcs (with rounded ends)
STROKE_T m_Shape
Shape: line, Circle, Arc.
Bezier Curve.
static wxString STROKE_T_asString(STROKE_T a)
Bezier curves to polygon converter.
Definition: bezier_curves.h:35
wxPoint m_BezierC2
Bezier Control Point 2.
int m_Width
thickness of lines ...
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
std::vector< wxPoint > m_BezierPoints

References FlipLayer(), BOARD_ITEM::GetLayer(), BEZIER_POLY::GetPoly(), m_Angle, m_BezierC1, m_BezierC2, m_BezierPoints, m_End, m_Poly, m_Shape, m_Start, m_Width, SHAPE_POLY_SET::Mirror(), S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, S_SEGMENT, BOARD_ITEM::SetLayer(), STROKE_T_asString(), wxPoint::x, and wxPoint::y.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::getDrawSegmentFromVertex().

◆ Flip() [2/2]

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

Definition at line 349 of file class_board_item.h.

350  {
351  Flip( wxPoint( aCentre.x, aCentre.y ), aFlipLeftRight );
352  }
virtual void Flip(const wxPoint &aCentre, bool aFlipLeftRight)
Function Flip Flip this object, i.e.

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

◆ Get() [1/3]

wxAny INSPECTABLE::Get ( PROPERTY_BASE aProperty)
inlineinherited

Definition at line 84 of file inspectable.h.

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

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

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

◆ Get() [2/3]

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

Definition at line 93 of file inspectable.h.

94  {
96  TYPE_ID thisType = TYPE_HASH( *this );
97  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
98  return object ? aProperty->get<T>( object ) : T();
99  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:61
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:53
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:38
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
Provides class metadata.
Definition: property_mgr.h:58
T get(void *aObject)
Definition: property.h:273
virtual size_t OwnerHash() const =0
Returns type-id of the Owner class.

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

◆ Get() [3/3]

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

Definition at line 102 of file inspectable.h.

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

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

◆ GetAngle()

◆ GetArcAngleEnd()

double DRAWSEGMENT::GetArcAngleEnd ( ) const

function GetArcAngleEnd()

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

Definition at line 418 of file class_drawsegment.cpp.

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

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

◆ GetArcAngleStart()

double DRAWSEGMENT::GetArcAngleStart ( ) const

function GetArcAngleStart()

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

Definition at line 404 of file class_drawsegment.cpp.

405 {
406  // due to the Y axis orient atan2 needs - y value
407  double angleStart = ArcTangente( GetArcStart().y - GetCenter().y,
408  GetArcStart().x - GetCenter().x );
409 
410  // Normalize it to 0 ... 360 deg, to avoid discontinuity for angles near 180 deg
411  // because 180 deg and -180 are very near angles when ampping betewwen -180 ... 180 deg.
412  // and this is not easy to handle in calculations
413  NORMALIZE_ANGLE_POS( angleStart );
414 
415  return angleStart;
416 }
wxPoint GetArcStart() const
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:276
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:162
wxPoint GetCenter() const override
Function GetCenter()

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

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

◆ GetArcEnd()

wxPoint DRAWSEGMENT::GetArcEnd ( ) const

Definition at line 364 of file class_drawsegment.cpp.

365 {
366  wxPoint endPoint( m_End ); // start of arc
367 
368  switch( m_Shape )
369  {
370  case S_ARC:
371  endPoint = m_ThirdPoint;
372  break;
373 
374  default:
375  break;
376  }
377 
378  return endPoint; // after rotation, the end of the arc.
379 }
wxPoint m_ThirdPoint
Used only for Arcs: arc end point.
wxPoint m_End
Line end point or circle and arc start point.
Arcs (with rounded ends)
STROKE_T m_Shape
Shape: line, Circle, Arc.

References m_End, m_Shape, m_ThirdPoint, and S_ARC.

Referenced by GRID_HELPER::computeAnchors(), ConvertOutlineToPolygon(), findPoint(), GetArcAngleEnd(), EDIT_POINTS_FACTORY::Make(), and POINT_EDITOR::updatePoints().

◆ GetArcMid()

wxPoint DRAWSEGMENT::GetArcMid ( ) const

Definition at line 382 of file class_drawsegment.cpp.

383 {
384  wxPoint endPoint( m_End );
385 
386  switch( m_Shape )
387  {
388  case S_ARC:
389  // rotate the starting point of the arc, given by m_End, through half
390  // the angle m_Angle to get the middle of the arc.
391  // m_Start is the arc centre
392  endPoint = m_End; // m_End = start point of arc
393  RotatePoint( &endPoint, m_Start, -m_Angle / 2.0 );
394  break;
395 
396  default:
397  break;
398  }
399 
400  return endPoint; // after rotation, the end of the arc.
401 }
double m_Angle
Used only for Arcs: Arc angle in 1/10 deg.
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
wxPoint m_Start
Line start point or Circle and Arc center.
wxPoint m_End
Line end point or circle and arc start point.
Arcs (with rounded ends)
STROKE_T m_Shape
Shape: line, Circle, Arc.

References m_Angle, m_End, m_Shape, m_Start, RotatePoint(), and S_ARC.

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

◆ GetArcStart()

◆ GetBezControl1()

◆ GetBezControl2()

◆ GetBezierPoints()

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

Definition at line 234 of file class_drawsegment.h.

234 { return m_BezierPoints; }
std::vector< wxPoint > m_BezierPoints

References m_BezierPoints.

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

◆ GetBoard()

BOARD * BOARD_ITEM::GetBoard ( ) const
virtualinherited

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

Definition at line 48 of file class_board_item.cpp.

49 {
50  if( Type() == PCB_T )
51  return (BOARD*) this;
52 
53  BOARD_ITEM* parent = GetParent();
54 
55  if( parent )
56  return parent->GetBoard();
57 
58  return NULL;
59 }
Definition: typeinfo.h:85
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
#define NULL
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:178
BOARD_ITEM_CONTAINER * GetParent() const
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193

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

Referenced by D_PAD::BuildEffectiveShapes(), ZONE_CONTAINER::BuildSmoothedPoly(), TEXTE_PCB::Flip(), TRACK::Flip(), ARC::Flip(), VIA::Flip(), ZONE_CONTAINER::Flip(), BOARD_ITEM::GetBoard(), MODULE::GetBoundingBox(), MODULE::GetBoundingPoly(), BOARD_CONNECTED_ITEM::GetClearance(), BOARD_CONNECTED_ITEM::GetEffectiveNetclass(), ZONE_CONTAINER::GetInteractingZones(), BOARD_ITEM::GetLayerName(), VIA::GetMinAnnulus(), PCB_DRAW_PANEL_GAL::GetMsgPanelInfo(), ZONE_CONTAINER::GetMsgPanelInfo(), TRACK::GetMsgPanelInfo(), NETINFO_ITEM::GetMsgPanelInfo(), D_PAD::GetMsgPanelInfo(), TRACK::GetMsgPanelInfoBase_Common(), BOARD_CONNECTED_ITEM::GetNetClass(), BOARD_CONNECTED_ITEM::GetNetnameMsg(), ZONE_CONTAINER::GetSelectMenuText(), TEXTE_MODULE::GetShownText(), D_PAD::GetSolderMaskMargin(), D_PAD::GetSolderPasteMargin(), BOARD::GetTrackLength(), TRACK::GetWidthConstraints(), insideArea(), insideCourtyard(), VIA::IsPadOnLayer(), D_PAD::IsPadOnLayer(), BOARD_ITEM::LayerMaskDescribe(), VIA::LayerMaskDescribe(), D_PAD::MergePrimitivesAsPolygon(), EAGLE_PLUGIN::packageWire(), PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), BOARD_CONNECTED_ITEM::SetNetCode(), setupDummyPadForHole(), ZONE_CONTAINER::TransformSmoothedOutlineWithClearanceToPolygon(), ZONE_CONTAINER::TransformSolidAreasShapesToPolygon(), MODULE::ViewBBox(), and D_PAD::ViewGetLOD().

◆ GetBoundingBox()

const EDA_RECT DRAWSEGMENT::GetBoundingBox ( ) const
overridevirtual

Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.

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

Reimplemented from EDA_ITEM.

Definition at line 558 of file class_drawsegment.cpp.

559 {
560  EDA_RECT bbox;
561 
562  bbox.SetOrigin( m_Start );
563 
564  switch( m_Shape )
565  {
566  case S_RECT:
567  {
568  std::vector<wxPoint> pts = GetRectCorners();
569 
570  bbox = EDA_RECT(); // re-init for merging
571 
572  for( wxPoint& pt : pts )
573  bbox.Merge( pt );
574  }
575  break;
576 
577  case S_SEGMENT:
578  bbox.SetEnd( m_End );
579  break;
580 
581  case S_CIRCLE:
582  bbox.Inflate( GetRadius() );
583  break;
584 
585  case S_ARC:
586  computeArcBBox( bbox );
587  break;
588 
589  case S_POLYGON:
590  if( m_Poly.IsEmpty() )
591  break;
592  {
593  MODULE* module = GetParentModule();
594  bbox = EDA_RECT(); // re-init for merging
595 
596  for( auto iter = m_Poly.CIterate(); iter; iter++ )
597  {
598  wxPoint pt ( iter->x, iter->y );
599 
600  if( module ) // Transform, if we belong to a module
601  {
602  RotatePoint( &pt, module->GetOrientation() );
603  pt += module->GetPosition();
604  }
605 
606  bbox.Merge( pt );
607  }
608  }
609  break;
610 
611  case S_CURVE:
612  bbox.Merge( m_BezierC1 );
613  bbox.Merge( m_BezierC2 );
614  bbox.Merge( m_End );
615  break;
616 
617  default:
618  wxFAIL_MSG( "DRAWSEGMENT::GetBoundingBox not implemented for "
619  + STROKE_T_asString( m_Shape ) );
620  break;
621  }
622 
623  bbox.Inflate( ((m_Width+1) / 2) + 1 );
624  bbox.Normalize();
625 
626  return bbox;
627 }
double GetOrientation() const
Definition: class_module.h:224
void Merge(const EDA_RECT &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect.
SHAPE_POLY_SET m_Poly
Stores the S_POLYGON shape.
polygon (not yet used for tracks, but could be in microwave apps)
bool IsEmpty() const
Returns true if the set is empty (no polygons at all)
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:131
usual segment : line with rounded ends
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
wxPoint m_BezierC1
Bezier Control Point 1.
segment with non rounded ends
wxPoint m_Start
Line start point or Circle and Arc center.
void computeArcBBox(EDA_RECT &aBBox) const
std::vector< wxPoint > GetRectCorners() const
wxPoint m_End
Line end point or circle and arc start point.
void SetEnd(int x, int y)
Definition: eda_rect.h:192
Arcs (with rounded ends)
MODULE * GetParentModule() const
Function GetParentModule returns a pointer to the parent module, or NULL if DRAWSEGMENT does not belo...
STROKE_T m_Shape
Shape: line, Circle, Arc.
int GetRadius() const
Function GetRadius returns the radius of this item Has meaning only for arc and circle.
Bezier Curve.
CONST_ITERATOR CIterate(int aFirst, int aLast, bool aIterateHoles=false) const
void Normalize()
Function Normalize ensures that the height ant width are positive.
static wxString STROKE_T_asString(STROKE_T a)
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
wxPoint m_BezierC2
Bezier Control Point 2.
wxPoint GetPosition() const override
Definition: class_module.h:219
int m_Width
thickness of lines ...
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.

References SHAPE_POLY_SET::CIterate(), computeArcBBox(), MODULE::GetOrientation(), GetParentModule(), MODULE::GetPosition(), GetRadius(), GetRectCorners(), EDA_RECT::Inflate(), SHAPE_POLY_SET::IsEmpty(), m_BezierC1, m_BezierC2, m_End, m_Poly, m_Shape, m_Start, m_Width, EDA_RECT::Merge(), EDA_RECT::Normalize(), RotatePoint(), S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, S_SEGMENT, EDA_RECT::SetEnd(), EDA_RECT::SetOrigin(), and STROKE_T_asString().

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

◆ GetCenter()

wxPoint DRAWSEGMENT::GetCenter ( ) const
overridevirtual

Function GetCenter()

This defaults to the same point as returned by GetPosition(), unless overridden

Returns
centre point of the item

Reimplemented from BOARD_ITEM.

Definition at line 333 of file class_drawsegment.cpp.

334 {
335  wxPoint c;
336 
337  switch( m_Shape )
338  {
339  case S_ARC:
340  case S_CIRCLE:
341  c = m_Start;
342  break;
343 
344  case S_SEGMENT:
345  // Midpoint of the line
346  c = ( GetStart() + GetEnd() ) / 2;
347  break;
348 
349  case S_POLYGON:
350  case S_RECT:
351  case S_CURVE:
352  c = GetBoundingBox().Centre();
353  break;
354 
355  default:
356  wxFAIL_MSG( "DRAWSEGMENT::GetCentre not implemented for " + STROKE_T_asString( m_Shape ) );
357  break;
358  }
359 
360  return c;
361 }
polygon (not yet used for tracks, but could be in microwave apps)
usual segment : line with rounded ends
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
segment with non rounded ends
wxPoint m_Start
Line start point or Circle and Arc center.
Arcs (with rounded ends)
STROKE_T m_Shape
Shape: line, Circle, Arc.
Bezier Curve.
static wxString STROKE_T_asString(STROKE_T a)
wxPoint Centre() const
Definition: eda_rect.h:62
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.

References EDA_RECT::Centre(), GetBoundingBox(), GetEnd(), GetStart(), m_Shape, m_Start, S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, S_SEGMENT, and STROKE_T_asString().

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

◆ GetClass()

wxString DRAWSEGMENT::GetClass ( ) const
inlineoverridevirtual

Function GetClass returns the class name.

Returns
wxString

Implements EDA_ITEM.

Reimplemented in EDGE_MODULE.

Definition at line 288 of file class_drawsegment.h.

289  {
290  return wxT( "DRAWSEGMENT" );
291  }

◆ GetEditFlags()

STATUS_FLAGS EDA_ITEM::GetEditFlags ( ) const
inlineinherited

Definition at line 237 of file base_struct.h.

238  {
239  constexpr int mask = ( IS_NEW | IS_PASTED | IS_MOVED | IS_RESIZED | IS_DRAGGED |
241 
242  return m_Flags & mask;
243  }
#define IS_NEW
New item, just created.
Definition: base_struct.h:117
#define IS_DRAGGED
Item being dragged.
Definition: base_struct.h:119
#define STRUCT_DELETED
flag indication structures to be erased
Definition: base_struct.h:126
#define IS_WIRE_IMAGE
Item to be drawn as wireframe while editing.
Definition: base_struct.h:121
STATUS_FLAGS m_Flags
Definition: base_struct.h:176
#define IS_RESIZED
Item being resized.
Definition: base_struct.h:118
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
Definition: base_struct.h:130
#define IS_MOVED
Item being moved.
Definition: base_struct.h:116

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

Referenced by SCH_EDIT_TOOL::ChangeTextType(), EDA_ITEM::ClearEditFlags(), SCH_EDIT_FRAME::DeleteJunction(), SCH_EDIT_TOOL::editFieldText(), LIB_PIN_TOOL::EditPinProperties(), SCH_EDITOR_CONTROL::EditWithLibEdit(), SCH_COMPONENT::GetMsgPanelInfo(), SELECTION_CONDITIONS::Idle(), SELECTION_CONDITIONS::IdleSelection(), LIB_MOVE_TOOL::Main(), POINT_EDITOR::OnSelectionChange(), LIB_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), PAD_TOOL::recombinePad(), SCH_EDIT_FRAME::SchematicCleanUp(), SCH_EDIT_FRAME::SelectUnit(), DIALOG_DIMENSION_PROPERTIES::TransferDataFromWindow(), DIALOG_TARGET_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow(), DIALOG_LABEL_EDITOR::TransferDataFromWindow(), DIALOG_FOOTPRINT_BOARD_EDITOR::TransferDataFromWindow(), and SCH_EDIT_FRAME::TrimWire().

◆ GetEffectiveShape()

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

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

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

Note that this list can contain a SHAPE_SIMPLE (a simple single-outline non-intersecting polygon), but should never contain a SHAPE_POLY_SET (a complex polygon consisting of multiple outlines and/or holes).

Parameters
aLayerin case of items spanning multiple layers, only the shapes belonging to aLayer will be returned. Pass UNDEFINED_LAYER to return shapes for all layers.

Reimplemented from BOARD_ITEM.

Definition at line 1168 of file class_drawsegment.cpp.

1169 {
1170  return std::shared_ptr<SHAPE>( new SHAPE_COMPOUND( MakeEffectiveShapes() ) );
1171 }
std::vector< SHAPE * > MakeEffectiveShapes() const
Makes a set of SHAPE objects representing the DRAWSEGMENT.

References MakeEffectiveShapes().

◆ GetEnd()

◆ GetEndX()

int DRAWSEGMENT::GetEndX ( )
inline

Definition at line 147 of file class_drawsegment.h.

147 { return m_End.x; }
wxPoint m_End
Line end point or circle and arc start point.

References m_End, and wxPoint::x.

Referenced by DRAWSEGMENT_DESC::DRAWSEGMENT_DESC().

◆ GetEndY()

int DRAWSEGMENT::GetEndY ( )
inline

Definition at line 146 of file class_drawsegment.h.

146 { return m_End.y; }
wxPoint m_End
Line end point or circle and arc start point.

References m_End, and wxPoint::y.

Referenced by DRAWSEGMENT_DESC::DRAWSEGMENT_DESC().

◆ GetFlags()

◆ GetFocusPosition()

const wxPoint DRAWSEGMENT::GetFocusPosition ( ) const
inlineoverridevirtual

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

Reimplemented from EDA_ITEM.

Definition at line 220 of file class_drawsegment.h.

221  {
222  return GetCenter();
223  }
wxPoint GetCenter() const override
Function GetCenter()

References GetCenter().

◆ GetGroup()

const KIID& BOARD_ITEM::GetGroup ( ) const
inlineinherited

Get the group this item belongs to.

Returns
the group this item is in

Definition at line 114 of file class_board_item.h.

114 { return m_groupUuid; }

References BOARD_ITEM::m_groupUuid.

◆ GetLayer()

virtual PCB_LAYER_ID BOARD_ITEM::GetLayer ( ) const
inlinevirtualinherited

Function GetLayer returns the primary layer this item is on.

Reimplemented in ZONE_CONTAINER.

Definition at line 203 of file class_board_item.h.

203 { return m_Layer; }
PCB_LAYER_ID m_Layer

References BOARD_ITEM::m_Layer.

Referenced by CN_LIST::Add(), BOARD_ADAPTER::AddGraphicsShapesWithClearanceToContainer(), GRAPHICS_CLEANER::areEquivalent(), BOARD_CONNECTED_ITEM_DESC::BOARD_CONNECTED_ITEM_DESC(), BOARD_ITEM_DESC::BOARD_ITEM_DESC(), AR_AUTOPLACER::buildFpAreas(), TRACKS_CLEANER::cleanupSegments(), CreateBoardSection(), MICROWAVE_TOOL::createMicrowaveInductor(), PCB_BASE_FRAME::CreateNewModule(), CreateRoutesSection(), DIALOG_DIMENSION_PROPERTIES::DIALOG_DIMENSION_PROPERTIES(), DIALOG_GRAPHIC_ITEM_PROPERTIES::DIALOG_GRAPHIC_ITEM_PROPERTIES(), DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES(), DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::doTrackDrc(), KIGFX::PCB_PAINTER::draw(), PCB_EDIT_FRAME::Exchange_Module(), export_vrml_drawsegment(), export_vrml_edge_module(), export_vrml_module(), export_vrml_pcbtext(), export_vrml_text_module(), export_vrml_tracks(), PCB_TARGET::Flip(), TEXTE_PCB::Flip(), TRACK::Flip(), EDGE_MODULE::Flip(), TEXTE_MODULE::Flip(), DIMENSION::Flip(), MODULE::Flip(), ARC::Flip(), Flip(), PCB_IO::FootprintSave(), FootprintWriteShape(), PCB_IO::formatLayer(), DSN::SPECCTRA_DB::FromBOARD(), AR_AUTOPLACER::genModuleOnRoutingMatrix(), MODULE::GetBoundingBox(), ZONE_CONTAINER::GetLayer(), getMatchingTextItem(), TRACK::GetMsgPanelInfo(), VIA::GetMsgPanelInfo(), D_PAD::GetMsgPanelInfo(), AR_AUTOPLACER::getOptimalModulePlacement(), BOARD::GetPad(), TEXT_MOD_GRID_TABLE::GetValueAsLong(), TRACK::GetWidthConstraints(), SELECTION_TOOL::GuessSelectionCandidates(), idf_export_module(), GENERAL_COLLECTOR::Inspect(), D_PAD::IsFlipped(), BOARD_ITEM::IsOnCopperLayer(), EDGE_MODULE::IsParentFlipped(), TEXTE_MODULE::IsParentFlipped(), itemIsIncludedByFilter(), FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD(), MODULE_DESC::MODULE_DESC(), DIALOG_FOOTPRINT_FP_EDITOR::OnAddField(), DIALOG_FOOTPRINT_BOARD_EDITOR::OnAddField(), DIALOG_DRC::OnDRCItemSelected(), TRACK::cmp_tracks::operator()(), DRAWSEGMENT::cmp_drawings::operator()(), BOARD_ITEM::ptr_cmp::operator()(), MODULE::cmp_drawings::operator()(), EAGLE_PLUGIN::packagePad(), BRDITEMS_PLOTTER::PlotDimension(), BRDITEMS_PLOTTER::PlotDrawSegment(), BRDITEMS_PLOTTER::PlotFootprintGraphicItem(), BRDITEMS_PLOTTER::PlotFootprintGraphicItems(), BRDITEMS_PLOTTER::PlotFootprintTextItems(), BRDITEMS_PLOTTER::PlotPcbTarget(), BRDITEMS_PLOTTER::PlotTextePcb(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), processTextItem(), PAD_TOOL::recombinePad(), CLIPBOARD_IO::SaveSelection(), CONVERT_TOOL::SegmentToArc(), SELECTION_TOOL::Selectable(), TEXT_MOD_GRID_TABLE::SetValueAsLong(), GLOBAL_EDIT_TOOL::swapBoardItem(), PNS_KICAD_IFACE_BASE::syncArc(), PNS_KICAD_IFACE_BASE::syncGraphicalItem(), PNS_KICAD_IFACE_BASE::syncTrack(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testCopperDrawItem(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testCopperTextAndGraphics(), AR_AUTOPLACER::testModuleOnBoard(), TEXTE_MODULE::TEXTE_MODULE(), TRACK_VIA_DESC::TRACK_VIA_DESC(), DIALOG_FOOTPRINT_BOARD_EDITOR::TransferDataFromWindow(), DIALOG_DIMENSION_PROPERTIES::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow(), DIALOG_FOOTPRINT_BOARD_EDITOR::TransferDataToWindow(), BOARD_ADAPTER::transformGraphicModuleEdgeToPolygonSet(), MODULE::TransformGraphicShapesWithClearanceToPolygonSet(), TRACK::ViewBBox(), TRACK::ViewGetLayers(), TEXTE_MODULE::ViewGetLayers(), TEXTE_MODULE::ViewGetLOD(), MODULE_ZONE_CONTAINER::ViewGetLOD(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::visitItem(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ GetLayerName()

wxString BOARD_ITEM::GetLayerName ( ) const
inherited

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

Returns
wxString containing the layer name associated with this item.

Definition at line 62 of file class_board_item.cpp.

63 {
64  BOARD* board = GetBoard();
65 
66  if( board )
67  return board->GetLayerName( m_Layer );
68 
69  // If no parent, return standard name
71 }
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Function GetLayerName returns the name of a layer.
PCB_LAYER_ID m_Layer
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:178
static wxString GetStandardLayerName(PCB_LAYER_ID aLayerId)
Function GetStandardLayerName returns an "English Standard" name of a PCB layer when given aLayerNumb...
Definition: class_board.h:628

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

Referenced by PCB_IO::format(), PCB_IO::formatLayer(), TEXTE_PCB::GetMsgPanelInfo(), TEXTE_MODULE::GetMsgPanelInfo(), GetMsgPanelInfo(), TEXTE_PCB::GetSelectMenuText(), EDGE_MODULE::GetSelectMenuText(), TRACK::GetSelectMenuText(), DIMENSION::GetSelectMenuText(), GetSelectMenuText(), TEXTE_PCB::GetShownText(), TEXT_MOD_GRID_TABLE::GetValue(), and MODULE::ResolveTextVar().

◆ GetLayerSet()

virtual LSET BOARD_ITEM::GetLayerSet ( ) const
inlinevirtualinherited

◆ GetLength()

double DRAWSEGMENT::GetLength ( ) const

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

Returns
double - the length of the track

Definition at line 77 of file class_drawsegment.cpp.

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

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

Referenced by GetMsgPanelInfo().

◆ GetMenuImage()

BITMAP_DEF DRAWSEGMENT::GetMenuImage ( ) const
overridevirtual

Function GetMenuImage returns a pointer to an image to be used in menus.

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

Returns
The menu image associated with the item.

Reimplemented from EDA_ITEM.

Reimplemented in EDGE_MODULE.

Definition at line 924 of file class_drawsegment.cpp.

925 {
926  return add_dashed_line_xpm;
927 }
const BITMAP_OPAQUE add_dashed_line_xpm[1]

References add_dashed_line_xpm.

◆ GetMsgPanelInfo()

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

Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.

Parameters
aListis the list to populate.

Reimplemented from EDA_ITEM.

Reimplemented in EDGE_MODULE.

Definition at line 453 of file class_drawsegment.cpp.

454 {
455  EDA_UNITS units = aFrame->GetUserUnits();
456  ORIGIN_TRANSFORMS originTransforms = aFrame->GetOriginTransforms();
457  wxString msg;
458 
459  msg = _( "Drawing" );
460 
461  aList.emplace_back( _( "Type" ), msg, DARKCYAN );
462 
463  wxString shape = _( "Shape" );
464 
465  switch( m_Shape )
466  {
467  case S_CIRCLE:
468  aList.emplace_back( shape, _( "Circle" ), RED );
469 
470  msg = MessageTextFromValue( units, GetLineLength( m_Start, m_End ) );
471  aList.emplace_back( _( "Radius" ), msg, RED );
472  break;
473 
474  case S_ARC:
475  aList.emplace_back( shape, _( "Arc" ), RED );
476  msg.Printf( wxT( "%.1f" ), m_Angle / 10.0 );
477  aList.emplace_back( _( "Angle" ), msg, RED );
478 
479  msg = MessageTextFromValue( units, GetLineLength( m_Start, m_End ) );
480  aList.emplace_back( _( "Radius" ), msg, RED );
481  break;
482 
483  case S_CURVE:
484  aList.emplace_back( shape, _( "Curve" ), RED );
485 
486  msg = MessageTextFromValue( units, GetLength() );
487  aList.emplace_back( _( "Length" ), msg, DARKGREEN );
488  break;
489 
490  case S_POLYGON:
491  aList.emplace_back( shape, _( "Polygon" ), RED );
492 
493  msg.Printf( "%d", GetPolyShape().Outline(0).PointCount() );
494  aList.emplace_back( _( "Points" ), msg, DARKGREEN );
495  break;
496 
497  case S_RECT:
498  aList.emplace_back( shape, _( "Rectangle" ), RED );
499 
500  msg = MessageTextFromValue( units, std::abs( m_End.x - m_Start.x ) );
501  aList.emplace_back( _( "Width" ), msg, DARKGREEN );
502 
503  msg = MessageTextFromValue( units, std::abs( m_End.y - m_Start.y ) );
504  aList.emplace_back( _( "Height" ), msg, DARKGREEN );
505  break;
506 
507  case S_SEGMENT:
508  {
509  aList.emplace_back( shape, _( "Segment" ), RED );
510 
511  msg = MessageTextFromValue( units, GetLineLength( m_Start, m_End ) );
512  aList.emplace_back( _( "Length" ), msg, DARKGREEN );
513 
514  // angle counter-clockwise from 3'o-clock
515  const double deg = RAD2DEG( atan2( (double)( m_Start.y - m_End.y ),
516  (double)( m_End.x - m_Start.x ) ) );
517  msg.Printf( wxT( "%.1f" ), deg );
518  aList.emplace_back( _( "Angle" ), msg, DARKGREEN );
519  }
520  break;
521 
522  default:
523  aList.emplace_back( shape, _( "Unrecognized" ), RED );
524  break;
525  }
526 
527  if( m_Shape == S_POLYGON )
528  {
529  VECTOR2I point0 = GetPolyShape().Outline(0).CPoint(0);
530  VECTOR2I coord0 = originTransforms.ToDisplayAbs( point0 );
531  wxString origin = wxString::Format( "@(%s, %s)",
532  MessageTextFromValue( units, coord0.x ),
533  MessageTextFromValue( units, coord0.y ) );
534 
535  aList.emplace_back( _( "Origin" ), origin, DARKGREEN );
536  }
537  else
538  {
539  wxPoint startCoord = originTransforms.ToDisplayAbs( GetStart() );
540  wxString start = wxString::Format( "@(%s, %s)",
541  MessageTextFromValue( units, startCoord.x ),
542  MessageTextFromValue( units, startCoord.y ) );
543  wxPoint endCoord = originTransforms.ToDisplayAbs( GetEnd() );
544  wxString end = wxString::Format( "@(%s, %s)",
545  MessageTextFromValue( units, endCoord.x ),
546  MessageTextFromValue( units, endCoord.y ) );
547 
548  aList.emplace_back( start, end, DARKGREEN );
549  }
550 
551  aList.emplace_back( _( "Layer" ), GetLayerName(), DARKBROWN );
552 
553  msg = MessageTextFromValue( units, m_Width, true );
554  aList.emplace_back( _( "Width" ), msg, DARKCYAN );
555 }
EDA_UNITS
Definition: common.h:198
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:211
polygon (not yet used for tracks, but could be in microwave apps)
double RAD2DEG(double rad)
Definition: trigo.h:220
virtual ORIGIN_TRANSFORMS & GetOriginTransforms()
Return a reference to the default ORIGIN_TRANSFORMS object.
usual segment : line with rounded ends
double m_Angle
Used only for Arcs: Arc angle in 1/10 deg.
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
const VECTOR2I & CPoint(int aIndex) const
Function Point()
segment with non rounded ends
wxPoint m_Start
Line start point or Circle and Arc center.
wxPoint m_End
Line end point or circle and arc start point.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
Arcs (with rounded ends)
STROKE_T m_Shape
Shape: line, Circle, Arc.
SHAPE_POLY_SET & GetPolyShape()
Bezier Curve.
Definition: color4d.h:59
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aUseMils, EDA_DATA_TYPE aType)
Definition: base_units.cpp:124
double GetLength() const
Function GetLength returns the length of the track using the hypotenuse calculation.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:201
A class to perform either relative or absolute display origin transforms for a single axis of a point...
#define _(s)
Definition: 3d_actions.cpp:33
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
int m_Width
thickness of lines ...
T ToDisplayAbs(const T &aValue)
wxString GetLayerName() const
Function GetLayerName returns the name of the PCB layer on which the item resides.
EDA_UNITS GetUserUnits() const
Return the user units currently in use.

References _, SHAPE_LINE_CHAIN::CPoint(), DARKBROWN, DARKCYAN, DARKGREEN, Format(), GetEnd(), BOARD_ITEM::GetLayerName(), GetLength(), GetLineLength(), EDA_DRAW_FRAME::GetOriginTransforms(), GetPolyShape(), GetStart(), EDA_BASE_FRAME::GetUserUnits(), m_Angle, m_End, m_Shape, m_Start, m_Width, MessageTextFromValue(), SHAPE_POLY_SET::Outline(), RAD2DEG(), RED, S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, S_SEGMENT, ORIGIN_TRANSFORMS::ToDisplayAbs(), wxPoint::x, VECTOR2< T >::x, wxPoint::y, and VECTOR2< T >::y.

Referenced by EDGE_MODULE::GetMsgPanelInfo().

◆ GetParent()

BOARD_ITEM_CONTAINER* BOARD_ITEM::GetParent ( void  ) const
inlineinherited

Definition at line 197 of file class_board_item.h.

197 { return (BOARD_ITEM_CONTAINER*) m_Parent; }
EDA_ITEM * m_Parent
Linked list: Link (parent struct)
Definition: base_struct.h:174
Abstract interface for BOARD_ITEMs capable of storing other items inside.

References EDA_ITEM::m_Parent.

Referenced by POINT_EDITOR::addCorner(), ALIGN_DISTRIBUTE_TOOL::AlignBottom(), ALIGN_DISTRIBUTE_TOOL::AlignCenterX(), ALIGN_DISTRIBUTE_TOOL::AlignCenterY(), ALIGN_DISTRIBUTE_TOOL::AlignTop(), BOARD_ITEM::DeleteStructure(), ALIGN_DISTRIBUTE_TOOL::doAlignLeft(), ALIGN_DISTRIBUTE_TOOL::doAlignRight(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersVertically(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsVertically(), KIGFX::PCB_PAINTER::draw(), EDIT_TOOL::Duplicate(), EditToolSelectionFilter(), PCB_IO::format(), FormatProbeItem(), BOARD_ITEM::GetBoard(), MARKER_PCB::GetColorLayer(), EDGE_MODULE::GetMsgPanelInfo(), TEXTE_MODULE::GetSelectMenuText(), TEXTE_PCB::GetShownText(), TEXTE_MODULE::GetShownText(), SELECTION_TOOL::GuessSelectionCandidates(), GENERAL_COLLECTOR::Inspect(), ARRAY_CREATOR::Invoke(), EDGE_MODULE::IsParentFlipped(), TEXTE_MODULE::IsParentFlipped(), LEGACY_PLUGIN::loadMODULE_TEXT(), ALTIUM_PCB::ParseTexts6Data(), BRDITEMS_PLOTTER::PlotFootprintGraphicItem(), BRDITEMS_PLOTTER::PlotFootprintTextItem(), BOARD_COMMIT::Push(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), CLIPBOARD_IO::SaveSelection(), SELECTION_TOOL::select(), SELECTION_TOOL::Selectable(), SwapItemData(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testCopperDrawItem(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), MARKER_PCB::ViewGetLayers(), MODULE_ZONE_CONTAINER::ViewGetLOD(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ GetParentModule()

MODULE * DRAWSEGMENT::GetParentModule ( ) const

Function GetParentModule returns a pointer to the parent module, or NULL if DRAWSEGMENT does not belong to a module.

Returns
MODULE* - pointer to the parent module or NULL.

Definition at line 444 of file class_drawsegment.cpp.

445 {
446  if( !m_Parent || m_Parent->Type() != PCB_MODULE_T )
447  return NULL;
448 
449  return (MODULE*) m_Parent;
450 }
EDA_ITEM * m_Parent
Linked list: Link (parent struct)
Definition: base_struct.h:174
class MODULE, a footprint
Definition: typeinfo.h:89
#define NULL
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193

References EDA_ITEM::m_Parent, NULL, PCB_MODULE_T, and EDA_ITEM::Type().

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

◆ GetPointCount()

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

Definition at line 1203 of file class_drawsegment.cpp.

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

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

Referenced by GRAPHICS_CLEANER::isNullSegment().

◆ GetPolyShape() [1/2]

◆ GetPolyShape() [2/2]

const SHAPE_POLY_SET& DRAWSEGMENT::GetPolyShape ( ) const
inline

Definition at line 249 of file class_drawsegment.h.

249 { return m_Poly; }
SHAPE_POLY_SET m_Poly
Stores the S_POLYGON shape.

References m_Poly.

◆ GetPosition()

wxPoint DRAWSEGMENT::GetPosition ( ) const
overridevirtual

Reimplemented from EDA_ITEM.

Definition at line 68 of file class_drawsegment.cpp.

69 {
70  if( m_Shape == S_POLYGON )
71  return (wxPoint) m_Poly.CVertex( 0 );
72  else
73  return m_Start;
74 }
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Returns the index-th vertex in a given hole outline within a given outline
SHAPE_POLY_SET m_Poly
Stores the S_POLYGON shape.
polygon (not yet used for tracks, but could be in microwave apps)
wxPoint m_Start
Line start point or Circle and Arc center.
STROKE_T m_Shape
Shape: line, Circle, Arc.

References SHAPE_POLY_SET::CVertex(), m_Poly, m_Shape, m_Start, and S_POLYGON.

Referenced by ConvertOutlineToPolygon().

◆ GetRadius()

int DRAWSEGMENT::GetRadius ( ) const
inline

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

Definition at line 190 of file class_drawsegment.h.

191  {
192  double radius = GetLineLength( m_Start, m_End );
193 
194  // don't allow degenerate arcs
195  return std::max( 1, KiROUND( radius ) );
196  }
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:211
wxPoint m_Start
Line start point or Circle and Arc center.
wxPoint m_End
Line end point or circle and arc start point.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68

References GetLineLength(), KiROUND(), m_End, and m_Start.

Referenced by BOARD_ADAPTER::AddShapeWithClearanceToContainer(), computeArcBBox(), ConvertOutlineToPolygon(), KIGFX::PCB_PAINTER::draw(), GetBoundingBox(), GetLength(), hash_eda(), HitTest(), idf_export_outline(), GRAPHICS_CLEANER::isNullSegment(), MakeEffectiveShapes(), PCB_PARSER::parseD_PAD(), Scale(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow(), DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataToWindow(), and TransformShapeWithClearanceToPolygon().

◆ GetRectCorners()

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

Definition at line 952 of file class_drawsegment.cpp.

953 {
954  std::vector<wxPoint> pts;
955  MODULE* module = GetParentModule();
956  wxPoint topLeft = GetStart();
957  wxPoint botRight = GetEnd();
958 
959  // Un-rotate rect topLeft and botRight
960  if( module && KiROUND( module->GetOrientation() ) % 900 != 0 )
961  {
962  topLeft -= module->GetPosition();
963  RotatePoint( &topLeft, -module->GetOrientation() );
964 
965  botRight -= module->GetPosition();
966  RotatePoint( &botRight, -module->GetOrientation() );
967  }
968 
969  // Set up the un-rotated 4 corners
970  pts.emplace_back( topLeft );
971  pts.emplace_back( botRight.x, topLeft.y );
972  pts.emplace_back( botRight );
973  pts.emplace_back( topLeft.x, botRight.y );
974 
975  // Now re-rotate the 4 corners to get a diamond
976  if( module && KiROUND( module->GetOrientation() ) % 900 != 0 )
977  {
978  for( wxPoint& pt : pts )
979  {
980  RotatePoint( &pt,module->GetOrientation() );
981  pt += module->GetPosition();
982  }
983  }
984 
985  return pts;
986 }
double GetOrientation() const
Definition: class_module.h:224
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
MODULE * GetParentModule() const
Function GetParentModule returns a pointer to the parent module, or NULL if DRAWSEGMENT does not belo...
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
wxPoint GetPosition() const override
Definition: class_module.h:219

References GetEnd(), MODULE::GetOrientation(), GetParentModule(), MODULE::GetPosition(), GetStart(), KiROUND(), RotatePoint(), wxPoint::x, and wxPoint::y.

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

◆ GetSelectMenuText()

wxString DRAWSEGMENT::GetSelectMenuText ( EDA_UNITS  aUnits) const
overridevirtual

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

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

Returns
The menu text string.

Reimplemented from EDA_ITEM.

Reimplemented in EDGE_MODULE.

Definition at line 916 of file class_drawsegment.cpp.

917 {
918  return wxString::Format( _( "%s on %s" ),
919  ShowShape( m_Shape ),
920  GetLayerName() );
921 }
static wxString ShowShape(STROKE_T aShape)
Function ShowShape converts the enum STROKE_T integer value to a wxString.
STROKE_T m_Shape
Shape: line, Circle, Arc.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:201
#define _(s)
Definition: 3d_actions.cpp:33
wxString GetLayerName() const
Function GetLayerName returns the name of the PCB layer on which the item resides.

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

◆ GetShape()

STROKE_T DRAWSEGMENT::GetShape ( ) const
inline

◆ GetStart()

◆ GetStartX()

int DRAWSEGMENT::GetStartX ( )
inline

Definition at line 136 of file class_drawsegment.h.

136 { return m_Start.x; }
wxPoint m_Start
Line start point or Circle and Arc center.

References m_Start, and wxPoint::x.

◆ GetStartY()

int DRAWSEGMENT::GetStartY ( )
inline

Definition at line 135 of file class_drawsegment.h.

135 { return m_Start.y; }
wxPoint m_Start
Line start point or Circle and Arc center.

References m_Start, and wxPoint::y.

◆ GetState()

int EDA_ITEM::GetState ( int  type) const
inlineinherited

Definition at line 216 of file base_struct.h.

217  {
218  return m_Status & type;
219  }
STATUS_FLAGS m_Status
Definition: base_struct.h:173

References EDA_ITEM::m_Status.

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

◆ GetStatus()

STATUS_FLAGS EDA_ITEM::GetStatus ( ) const
inlineinherited

Definition at line 229 of file base_struct.h.

229 { return m_Status; }
STATUS_FLAGS m_Status
Definition: base_struct.h:173

References EDA_ITEM::m_Status.

◆ GetThirdPoint()

const wxPoint& DRAWSEGMENT::GetThirdPoint ( ) const
inline

Function GetThirdPoint returns the third point point of the graphic.

Definition at line 156 of file class_drawsegment.h.

156 { return m_ThirdPoint; }
wxPoint m_ThirdPoint
Used only for Arcs: arc end point.

References m_ThirdPoint.

◆ GetThirdPointX()

int DRAWSEGMENT::GetThirdPointX ( )
inline

Definition at line 158 of file class_drawsegment.h.

158 { return m_ThirdPoint.x; }
wxPoint m_ThirdPoint
Used only for Arcs: arc end point.

References m_ThirdPoint, and wxPoint::x.

◆ GetThirdPointY()

int DRAWSEGMENT::GetThirdPointY ( )
inline

Definition at line 157 of file class_drawsegment.h.

157 { return m_ThirdPoint.y; }
wxPoint m_ThirdPoint
Used only for Arcs: arc end point.

References m_ThirdPoint, and wxPoint::y.

◆ GetType()

int DRAWSEGMENT::GetType ( ) const
inline

Definition at line 116 of file class_drawsegment.h.

116 { return m_Type; }
int m_Type
Used in complex associations ( Dimensions.. )

References m_Type.

Referenced by hash_eda().

◆ GetWidth()

◆ GetX()

int BOARD_ITEM::GetX ( ) const
inlineinherited

◆ GetY()

int BOARD_ITEM::GetY ( ) const
inlineinherited

◆ HasFlag()

◆ HitTest() [1/2]

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

Function HitTest tests if aPosition is contained within or on the bounding box of an item.

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

Reimplemented from EDA_ITEM.

Definition at line 630 of file class_drawsegment.cpp.

631 {
632  int maxdist = aAccuracy + ( m_Width / 2 );
633 
634  switch( m_Shape )
635  {
636  case S_CIRCLE:
637  {
638  int radius = GetRadius();
639  int dist = KiROUND( EuclideanNorm( aPosition - GetCenter() ) );
640 
641  if( m_Width == 0 ) // Filled circle hit-test
642  {
643  if( dist <= radius + maxdist )
644  return true;
645  }
646  else // Ring hit-test
647  {
648  if( abs( radius - dist ) <= maxdist )
649  return true;
650  }
651  }
652  break;
653 
654  case S_ARC:
655  {
656  wxPoint relPos = aPosition - GetCenter();
657  int radius = GetRadius();
658  int dist = KiROUND( EuclideanNorm( relPos ) );
659 
660  if( abs( radius - dist ) <= maxdist )
661  {
662  // For arcs, the test point angle must be >= arc angle start
663  // and <= arc angle end
664  // However angle values > 360 deg are not easy to handle
665  // so we calculate the relative angle between arc start point and teast point
666  // this relative arc should be < arc angle if arc angle > 0 (CW arc)
667  // and > arc angle if arc angle < 0 (CCW arc)
668  double arc_angle_start = GetArcAngleStart(); // Always 0.0 ... 360 deg, in 0.1 deg
669 
670  double arc_hittest = ArcTangente( relPos.y, relPos.x );
671 
672  // Calculate relative angle between the starting point of the arc, and the test point
673  arc_hittest -= arc_angle_start;
674 
675  // Normalise arc_hittest between 0 ... 360 deg
676  NORMALIZE_ANGLE_POS( arc_hittest );
677 
678  // Check angle: inside the arc angle when it is > 0
679  // and outside the not drawn arc when it is < 0
680  if( GetAngle() >= 0.0 )
681  {
682  if( arc_hittest <= GetAngle() )
683  return true;
684  }
685  else
686  {
687  if( arc_hittest >= (3600.0 + GetAngle()) )
688  return true;
689  }
690  }
691  }
692  break;
693 
694  case S_CURVE:
695  ((DRAWSEGMENT*)this)->RebuildBezierToSegmentsPointsList( m_Width );
696 
697  for( unsigned int i= 1; i < m_BezierPoints.size(); i++)
698  {
699  if( TestSegmentHit( aPosition, m_BezierPoints[i-1], m_BezierPoints[i], maxdist ) )
700  return true;
701  }
702  break;
703 
704  case S_SEGMENT:
705  if( TestSegmentHit( aPosition, m_Start, m_End, maxdist ) )
706  return true;
707  break;
708 
709  case S_RECT:
710  {
711  std::vector<wxPoint> pts = GetRectCorners();
712 
713  if( m_Width == 0 ) // Filled rect hit-test
714  {
715  SHAPE_POLY_SET poly;
716  poly.NewOutline();
717 
718  for( const wxPoint& pt : pts )
719  poly.Append( pt );
720 
721  if( poly.Collide( VECTOR2I( aPosition ), maxdist ) )
722  return true;
723  }
724  else // Open rect hit-test
725  {
726  if( TestSegmentHit( aPosition, pts[0], pts[1], maxdist )
727  || TestSegmentHit( aPosition, pts[1], pts[2], maxdist )
728  || TestSegmentHit( aPosition, pts[2], pts[3], maxdist )
729  || TestSegmentHit( aPosition, pts[3], pts[0], maxdist ) )
730  {
731  return true;
732  }
733  }
734  }
735  break;
736 
737  case S_POLYGON:
738  {
739  if( !IsPolygonFilled() )
740  {
742  return m_Poly.CollideEdge( VECTOR2I( aPosition ), dummy, maxdist );
743  }
744  else
745  return m_Poly.Collide( VECTOR2I( aPosition ), maxdist );
746  }
747  break;
748 
749  default:
750  wxFAIL_MSG( "DRAWSEGMENT::HitTest (point) not implemented for "
751  + STROKE_T_asString( m_Shape ) );
752  break;
753  }
754 
755  return false;
756 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:133
SHAPE_POLY_SET m_Poly
Stores the S_POLYGON shape.
polygon (not yet used for tracks, but could be in microwave apps)
double GetArcAngleStart() const
function GetArcAngleStart()
Struct VERTEX_INDEX.
usual segment : line with rounded ends
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:276
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
bool TestSegmentHit(const wxPoint &aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
Definition: trigo.cpp:129
segment with non rounded ends
wxPoint m_Start
Line start point or Circle and Arc center.
std::vector< wxPoint > GetRectCorners() const
wxPoint m_End
Line end point or circle and arc start point.
SHAPE_POLY_SET.
Arcs (with rounded ends)
STROKE_T m_Shape
Shape: line, Circle, Arc.
int GetRadius() const
Function GetRadius returns the radius of this item Has meaning only for arc and circle.
Bezier Curve.
int NewOutline()
Creates a new empty polygon in the set and returns its index
bool Collide(const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr) const override
Function Collide Checks whether the point aP is either inside or on the edge of the polygon set.
static wxString STROKE_T_asString(STROKE_T a)
double GetAngle() const
bool CollideEdge(const VECTOR2I &aPoint, VERTEX_INDEX &aClosestVertex, int aClearance=0) const
Function CollideEdge Checks whether aPoint collides with any edge of any of the contours of the polyg...
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68
int m_Width
thickness of lines ...
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:162
bool IsPolygonFilled() const
Polygonal shape is not always filled.
wxPoint GetCenter() const override
Function GetCenter()
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
std::vector< wxPoint > m_BezierPoints

References SHAPE_POLY_SET::Append(), ArcTangente(), SHAPE_POLY_SET::Collide(), SHAPE_POLY_SET::CollideEdge(), dummy(), EuclideanNorm(), GetAngle(), GetArcAngleStart(), GetCenter(), GetRadius(), GetRectCorners(), IsPolygonFilled(), KiROUND(), m_BezierPoints, m_End, m_Poly, m_Shape, m_Start, m_Width, SHAPE_POLY_SET::NewOutline(), NORMALIZE_ANGLE_POS(), S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, S_SEGMENT, STROKE_T_asString(), TestSegmentHit(), wxPoint::x, and wxPoint::y.

Referenced by GENERAL_COLLECTOR::Inspect().

◆ HitTest() [2/2]

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

Function HitTest tests if aRect intersects or is contained within the bounding box of an item.

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

Reimplemented from EDA_ITEM.

Definition at line 759 of file class_drawsegment.cpp.

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

References EDA_RECT::Common(), EDA_RECT::Contains(), SHAPE_POLY_SET::CVertex(), GetBoundingBox(), GetCenter(), GetEnd(), GetRadius(), GetRectCorners(), GetStart(), GetWidth(), EDA_RECT::Inflate(), EDA_RECT::Intersects(), EDA_RECT::IntersectsCircleEdge(), m_BezierPoints, m_Poly, m_Shape, EDA_RECT::Normalize(), S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, S_SEGMENT, STROKE_T_asString(), and SHAPE_POLY_SET::TotalVertices().

◆ IsBrightened()

◆ IsConnected()

virtual bool BOARD_ITEM::IsConnected ( ) const
inlinevirtualinherited

Function IsConnected() Returns information if the object is derived from BOARD_CONNECTED_ITEM.

Returns
True if the object is of BOARD_CONNECTED_ITEM type, false otherwise.

Reimplemented in BOARD_CONNECTED_ITEM.

Definition at line 164 of file class_board_item.h.

165  {
166  return false;
167  }

Referenced by PCB_INSPECTION_TOOL::InspectClearance(), CN_CONNECTIVITY_ALGO::markItemNetAsDirty(), and CONNECTIVITY_DATA::MarkItemNetAsDirty().

◆ IsDragging()

bool EDA_ITEM::IsDragging ( ) const
inlineinherited

Definition at line 201 of file base_struct.h.

201 { return m_Flags & IS_DRAGGED; }
#define IS_DRAGGED
Item being dragged.
Definition: base_struct.h:119
STATUS_FLAGS m_Flags
Definition: base_struct.h:176

References IS_DRAGGED, and EDA_ITEM::m_Flags.

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

◆ IsForceVisible()

bool EDA_ITEM::IsForceVisible ( ) const
inlineinherited

Definition at line 286 of file base_struct.h.

286 { return m_forceVisible; }
bool m_forceVisible
Definition: base_struct.h:175

References EDA_ITEM::m_forceVisible.

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

◆ IsInGroup()

bool BOARD_ITEM::IsInGroup ( )
inlineinherited

Test if this item is inside a group.

Returns
true if inside a group

Definition at line 121 of file class_board_item.h.

121 { return m_groupUuid != niluuid; }
KIID niluuid(0)

References BOARD_ITEM::m_groupUuid, and niluuid.

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

◆ IsLocked()

virtual bool BOARD_ITEM::IsLocked ( ) const
inlinevirtualinherited

Function IsLocked.

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

Reimplemented in MODULE, and TRACK.

Definition at line 278 of file class_board_item.h.

279  {
280  // only MODULEs & TRACKs can be locked at this time.
281  return false;
282  }

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

◆ IsModified()

bool EDA_ITEM::IsModified ( ) const
inlineinherited

Definition at line 198 of file base_struct.h.

198 { return m_Flags & IS_CHANGED; }
#define IS_CHANGED
std::function passed to nested users by ref, avoids copying std::function
Definition: base_struct.h:113
STATUS_FLAGS m_Flags
Definition: base_struct.h:176

References IS_CHANGED, and EDA_ITEM::m_Flags.

Referenced by PCB_EDIT_FRAME::OpenProjectFiles().

◆ IsMoving()

◆ IsNew()

◆ IsOnCopperLayer()

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

Reimplemented in TRACK, D_PAD, and ZONE_CONTAINER.

Definition at line 172 of file class_board_item.h.

173  {
174  return IsCopperLayer( GetLayer() );
175  }
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.

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

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

◆ IsOnLayer()

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

Function IsOnLayer tests to see if this object is on the given layer.

Is virtual so objects like D_PAD, which reside on multiple layers can do their own form of testing.

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

Reimplemented in D_PAD, VIA, ZONE_CONTAINER, and PCB_GROUP.

Definition at line 258 of file class_board_item.h.

259  {
260  return m_Layer == aLayer;
261  }
PCB_LAYER_ID m_Layer

References BOARD_ITEM::m_Layer.

Referenced by BOARD_ADAPTER::createLayers(), GENERAL_COLLECTOR::Inspect(), PCB_LAYER_COLLECTOR::Inspect(), and onLayer().

◆ IsPolygonFilled()

bool DRAWSEGMENT::IsPolygonFilled ( ) const
inline

◆ IsPolyShapeValid()

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

Definition at line 1191 of file class_drawsegment.cpp.

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

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

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

◆ IsReplaceable()

virtual bool EDA_ITEM::IsReplaceable ( ) const
inlinevirtualinherited

Function IsReplaceable.

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

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

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

Definition at line 502 of file base_struct.h.

502 { return false; }

Referenced by EDA_ITEM::Matches().

◆ IsResized()

bool EDA_ITEM::IsResized ( ) const
inlineinherited

Definition at line 204 of file base_struct.h.

204 { return m_Flags & IS_RESIZED; }
STATUS_FLAGS m_Flags
Definition: base_struct.h:176
#define IS_RESIZED
Item being resized.
Definition: base_struct.h:118

References IS_RESIZED, and EDA_ITEM::m_Flags.

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

◆ IsSelected()

◆ IsTrack()

bool BOARD_ITEM::IsTrack ( ) const
inlineinherited

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

form of testing.

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

Definition at line 269 of file class_board_item.h.

270  {
271  return ( Type() == PCB_TRACE_T ) || ( Type() == PCB_VIA_T );
272  }
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193

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

◆ IsType()

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

Function IsType Checks whether the item is one of the listed types.

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

Reimplemented from EDA_ITEM.

Reimplemented in EDGE_MODULE.

Definition at line 83 of file class_drawsegment.h.

84  {
85  if( BOARD_ITEM::IsType( aScanTypes ) )
86  return true;
87 
88  for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
89  {
90  if( *p == PCB_LOCATE_GRAPHIC_T )
91  return true;
92  else if( *p == PCB_LOCATE_BOARD_EDGE_T )
93  return m_Layer == Edge_Cuts;
94  }
95 
96  return false;
97  }
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
PCB_LAYER_ID m_Layer
virtual bool IsType(const KICAD_T aScanTypes[]) const
Function IsType Checks whether the item is one of the listed types.
Definition: base_struct.h:262

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

◆ IsWireImage()

bool EDA_ITEM::IsWireImage ( ) const
inlineinherited

Definition at line 202 of file base_struct.h.

202 { return m_Flags & IS_WIRE_IMAGE; }
#define IS_WIRE_IMAGE
Item to be drawn as wireframe while editing.
Definition: base_struct.h:121
STATUS_FLAGS m_Flags
Definition: base_struct.h:176

References IS_WIRE_IMAGE, and EDA_ITEM::m_Flags.

◆ IterateForward() [1/2]

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

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

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

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

Definition at line 384 of file base_struct.h.

388  {
389  for( auto it : aList )
390  {
391  if( static_cast<EDA_ITEM*>( it )->Visit( inspector, testData, scanTypes )
393  return SEARCH_RESULT::QUIT;
394  }
395 
397  }
virtual SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
Function Visit may be re-implemented for each derived class in order to handle all the types given by...

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

Referenced by GERBER_FILE_IMAGE::Visit().

◆ IterateForward() [2/2]

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

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

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

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

Definition at line 405 of file base_struct.h.

407  {
408  for( auto it : aList )
409  {
410  if( static_cast<EDA_ITEM*>( it )->Visit( inspector, testData, scanTypes )
412  return SEARCH_RESULT::QUIT;
413  }
414 
416  }
virtual SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
Function Visit may be re-implemented for each derived class in order to handle all the types given by...

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

◆ LayerMaskDescribe()

wxString BOARD_ITEM::LayerMaskDescribe ( ) const
protectedvirtualinherited

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

The BOARD is needed because layer names are (somewhat) customizable

Reimplemented in VIA.

Definition at line 74 of file class_board_item.cpp.

75 {
76  BOARD* board = GetBoard();
77  LSET layers = GetLayerSet();
78 
79  // Try to be smart and useful. Check all copper first.
80  if( layers[F_Cu] && layers[B_Cu] )
81  return _( "all copper layers" );
82 
83  LSET copperLayers = layers & board->GetEnabledLayers().AllCuMask();
84  LSET techLayers = layers & board->GetEnabledLayers().AllTechMask();
85 
86  for( LSET testLayers : { copperLayers, techLayers, layers } )
87  {
88  for( int bit = PCBNEW_LAYER_ID_START; bit < PCB_LAYER_ID_COUNT; ++bit )
89  {
90  if( testLayers[ bit ] )
91  {
92  wxString layerInfo = board->GetLayerName( static_cast<PCB_LAYER_ID>( bit ) );
93 
94  if( testLayers.count() > 1 )
95  layerInfo << _( " and others" );
96 
97  return layerInfo;
98  }
99  }
100  }
101 
102  // No copper, no technicals: no layer
103  return _( "no layers" );
104 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:719
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Function GetLayerName returns the name of a layer.
LSET GetEnabledLayers() const
Function GetEnabledLayers is a proxy function that calls the corresponding function in m_BoardSetting...
static LSET AllTechMask()
Function AllTechMask returns a mask holding all technical layers (no CU layer) on both side.
Definition: lset.cpp:789
LSET is a set of PCB_LAYER_IDs.
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:178
#define _(s)
Definition: 3d_actions.cpp:33
virtual LSET GetLayerSet() const
Function GetLayerSet returns a std::bitset of all layers on which the item physically resides.

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

Referenced by TRACK::GetMsgPanelInfo(), D_PAD::GetMsgPanelInfo(), and D_PAD::GetSelectMenuText().

◆ MakeEffectiveShapes()

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

Makes a set of SHAPE objects representing the DRAWSEGMENT.

Caller owns the objects.

Definition at line 1063 of file class_drawsegment.cpp.

1064 {
1065  std::vector<SHAPE*> effectiveShapes;
1066 
1067  switch( m_Shape )
1068  {
1069  case S_ARC:
1070  {
1071  SHAPE_ARC arc( GetCenter(), GetArcStart(), (double) GetAngle() / 10.0 );
1072  SHAPE_LINE_CHAIN l = arc.ConvertToPolyline();
1073 
1074  for( int i = 0; i < l.SegmentCount(); i++ )
1075  {
1076  effectiveShapes.emplace_back( new SHAPE_SEGMENT( l.Segment( i ).A,
1077  l.Segment( i ).B, m_Width ) );
1078  }
1079 
1080  break;
1081  }
1082 
1083  case S_SEGMENT:
1084  effectiveShapes.emplace_back( new SHAPE_SEGMENT( GetStart(), GetEnd(), m_Width ) );
1085  break;
1086 
1087  case S_RECT:
1088  {
1089  std::vector<wxPoint> pts = GetRectCorners();
1090 
1091  if( m_Width == 0 )
1092  {
1093  effectiveShapes.emplace_back( new SHAPE_SIMPLE( pts ) );
1094  }
1095  else
1096  {
1097  effectiveShapes.emplace_back( new SHAPE_SEGMENT( pts[0], pts[1], m_Width ) );
1098  effectiveShapes.emplace_back( new SHAPE_SEGMENT( pts[1], pts[2], m_Width ) );
1099  effectiveShapes.emplace_back( new SHAPE_SEGMENT( pts[2], pts[3], m_Width ) );
1100  effectiveShapes.emplace_back( new SHAPE_SEGMENT( pts[3], pts[0], m_Width ) );
1101  }
1102  }
1103  break;
1104 
1105  case S_CIRCLE:
1106  {
1107  if( m_Width == 0 )
1108  {
1109  effectiveShapes.emplace_back( new SHAPE_CIRCLE( GetCenter(), GetRadius() ) );
1110  }
1111  else
1112  {
1113  // SHAPE_CIRCLE has no ConvertToPolyline() method, so use a 360.0 SHAPE_ARC
1114  SHAPE_ARC circle( GetCenter(), GetEnd(), 360.0 );
1115  SHAPE_LINE_CHAIN l = circle.ConvertToPolyline();
1116 
1117  for( int i = 0; i < l.SegmentCount(); i++ )
1118  {
1119  effectiveShapes.emplace_back( new SHAPE_SEGMENT( l.Segment( i ).A,
1120  l.Segment( i ).B, m_Width ) );
1121  }
1122  }
1123 
1124  break;
1125  }
1126 
1127  case S_CURVE:
1128  {
1129  auto bezierPoints = buildBezierToSegmentsPointsList( GetWidth() );
1130  wxPoint start_pt = bezierPoints[0];
1131 
1132  for( unsigned int jj = 1; jj < bezierPoints.size(); jj++ )
1133  {
1134  wxPoint end_pt = bezierPoints[jj];
1135  effectiveShapes.emplace_back( new SHAPE_SEGMENT( start_pt, end_pt, m_Width ) );
1136  start_pt = end_pt;
1137  }
1138 
1139  break;
1140  }
1141 
1142  case S_POLYGON:
1143  {
1145 
1146  if( IsPolygonFilled() )
1147  {
1148  effectiveShapes.emplace_back( new SHAPE_SIMPLE( l ) );
1149  }
1150  else
1151  {
1152  for( int i = 0; i < l.SegmentCount(); i++ )
1153  effectiveShapes.emplace_back( new SHAPE_SEGMENT( l.Segment( i ) ) );
1154  }
1155  }
1156  break;
1157 
1158  default:
1159  wxFAIL_MSG( "DRAWSEGMENT::MakeEffectiveShapes unsupported DRAWSEGMENT shape: "
1160  + STROKE_T_asString( m_Shape ) );
1161  break;
1162  }
1163 
1164  return effectiveShapes;
1165 }
wxPoint GetArcStart() const
SHAPE_SIMPLE.
Definition: shape_simple.h:43
polygon (not yet used for tracks, but could be in microwave apps)
usual segment : line with rounded ends
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
segment with non rounded ends
std::vector< wxPoint > GetRectCorners() const
Arcs (with rounded ends)
STROKE_T m_Shape
Shape: line, Circle, Arc.
int GetRadius() const
Function GetRadius returns the radius of this item Has meaning only for arc and circle.
SHAPE_POLY_SET & GetPolyShape()
Bezier Curve.
int SegmentCount() const
Function SegmentCount()
int GetWidth() const
const std::vector< wxPoint > buildBezierToSegmentsPointsList(int aMinSegLen) const
static wxString STROKE_T_asString(STROKE_T a)
double GetAngle() const
SEG Segment(int aIndex)
Function Segment()
SHAPE_LINE_CHAIN.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
VECTOR2I A
Definition: seg.h:47
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
int m_Width
thickness of lines ...
bool IsPolygonFilled() const
Polygonal shape is not always filled.
wxPoint GetCenter() const override
Function GetCenter()
VECTOR2I B
Definition: seg.h:48

References SEG::A, SEG::B, buildBezierToSegmentsPointsList(), SHAPE_ARC::ConvertToPolyline(), SHAPE_POLY_SET::COutline(), GetAngle(), GetArcStart(), GetCenter(), GetEnd(), GetPolyShape(), GetRadius(), GetRectCorners(), GetStart(), GetWidth(), IsPolygonFilled(), m_Shape, m_Width, S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, S_SEGMENT, SHAPE_LINE_CHAIN::Segment(), SHAPE_LINE_CHAIN::SegmentCount(), and STROKE_T_asString().

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

◆ Matches() [1/2]

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

Function Matches compares the item against the search criteria in aSearchData.

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

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

Reimplemented in SCH_COMPONENT, SCH_SHEET, SCH_TEXT, SCH_SHEET_PIN, SCH_FIELD, SCH_PIN, TEXTE_MODULE, SCH_MARKER, MARKER_PCB, and TEXTE_PCB.

Definition at line 458 of file base_struct.h.

459  {
460  return false;
461  }

Referenced by SCH_EDITOR_CONTROL::HasMatch(), TEXTE_PCB::Matches(), MARKER_PCB::Matches(), SCH_MARKER::Matches(), TEXTE_MODULE::Matches(), SCH_PIN::Matches(), SCH_FIELD::Matches(), SCH_SHEET_PIN::Matches(), SCH_TEXT::Matches(), SCH_EDITOR_CONTROL::ReplaceAndFindNext(), and SCH_EDITOR_CONTROL::UpdateFind().

◆ Matches() [2/2]

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

Function Matches compares aText against search criteria in aSearchData.

This is a helper function for simplify derived class logic.

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

Definition at line 140 of file base_struct.cpp.

141 {
142  wxString text = aText;
143  wxString searchText = aSearchData.GetFindString();
144 
145  // Don't match if searching for replaceable item and the item doesn't support text replace.
146  if( (aSearchData.GetFlags() & FR_SEARCH_REPLACE) && !IsReplaceable() )
147  return false;
148 
149  if( aSearchData.GetFlags() & wxFR_WHOLEWORD )
150  return aText.IsSameAs( searchText, aSearchData.GetFlags() & wxFR_MATCHCASE );
151 
152  if( aSearchData.GetFlags() & FR_MATCH_WILDCARD )
153  {
154  if( aSearchData.GetFlags() & wxFR_MATCHCASE )
155  return text.Matches( searchText );
156 
157  return text.MakeUpper().Matches( searchText.MakeUpper() );
158  }
159 
160  if( aSearchData.GetFlags() & wxFR_MATCHCASE )
161  return aText.Find( searchText ) != wxNOT_FOUND;
162 
163  return text.MakeUpper().Find( searchText.MakeUpper() ) != wxNOT_FOUND;
164 }
virtual bool IsReplaceable() const
Function IsReplaceable.
Definition: base_struct.h:502

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

◆ Move() [1/2]

void DRAWSEGMENT::Move ( const wxPoint aMoveVector)
overridevirtual

Function Move move this object.

Parameters
aMoveVector- the move vector for this object.

Reimplemented from BOARD_ITEM.

Reimplemented in EDGE_MODULE.

Definition at line 113 of file class_drawsegment.cpp.

114 {
115  // Move vector should not affect start/end for polygon since it will
116  // be applied directly to polygon outline.
117  if( m_Shape != S_POLYGON )
118  {
119  m_Start += aMoveVector;
120  m_End += aMoveVector;
121  }
122 
123  switch ( m_Shape )
124  {
125  case S_POLYGON:
126  m_Poly.Move( VECTOR2I( aMoveVector ) );
127  break;
128 
129  case S_ARC:
130  m_ThirdPoint += aMoveVector;
131  break;
132 
133  case S_CURVE:
134  m_BezierC1 += aMoveVector;
135  m_BezierC2 += aMoveVector;
136 
137  for( wxPoint& pt : m_BezierPoints)
138  pt += aMoveVector;
139 
140  break;
141 
142  default:
143  break;
144  }
145 }
SHAPE_POLY_SET m_Poly
Stores the S_POLYGON shape.
polygon (not yet used for tracks, but could be in microwave apps)
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
wxPoint m_BezierC1
Bezier Control Point 1.
wxPoint m_Start
Line start point or Circle and Arc center.
void Move(const VECTOR2I &aVector) override
wxPoint m_ThirdPoint
Used only for Arcs: arc end point.
wxPoint m_End
Line end point or circle and arc start point.
Arcs (with rounded ends)
STROKE_T m_Shape
Shape: line, Circle, Arc.
Bezier Curve.
wxPoint m_BezierC2
Bezier Control Point 2.
std::vector< wxPoint > m_BezierPoints

References m_BezierC1, m_BezierC2, m_BezierPoints, m_End, m_Poly, m_Shape, m_Start, m_ThirdPoint, SHAPE_POLY_SET::Move(), S_ARC, S_CURVE, and S_POLYGON.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::getDrawSegmentFromVertex(), PAD_TOOL::recombinePad(), DIALOG_PAD_PROPERTIES::redraw(), and POINT_EDITOR::updateItem().

◆ Move() [2/2]

void BOARD_ITEM::Move ( const VECTOR2I aMoveVector)
inlineinherited

Definition at line 317 of file class_board_item.h.

318  {
319  Move( wxPoint( aMoveVector.x, aMoveVector.y ) );
320  }
virtual void Move(const wxPoint &aMoveVector)
Function Move move this object.

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

◆ operator<()

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

Test if another item is less than this object.

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

Definition at line 194 of file base_struct.cpp.

195 {
196  wxFAIL_MSG( wxString::Format( wxT( "Less than operator not defined for item type %s." ),
197  GetChars( GetClass() ) ) );
198 
199  return false;
200 }
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:153
virtual wxString GetClass() const =0
Function GetClass returns the class name.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:201

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

◆ RebuildBezierToSegmentsPointsList()

void DRAWSEGMENT::RebuildBezierToSegmentsPointsList ( int  aMinSegLen)

Rebuild the m_BezierPoints vertex list that approximate the Bezier curve by a list of segments Has meaning only for S_CURVE DRAW_SEGMENT shape.

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

Definition at line 307 of file class_drawsegment.cpp.

308 {
309  // Has meaning only for S_CURVE DRAW_SEGMENT shape
310  if( m_Shape != S_CURVE )
311  {
312  m_BezierPoints.clear();
313  return;
314  }
315  // Rebuild the m_BezierPoints vertex list that approximate the Bezier curve
317 }
STROKE_T m_Shape
Shape: line, Circle, Arc.
Bezier Curve.
const std::vector< wxPoint > buildBezierToSegmentsPointsList(int aMinSegLen) const
std::vector< wxPoint > m_BezierPoints

References buildBezierToSegmentsPointsList(), m_BezierPoints, m_Shape, and S_CURVE.

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

◆ Replace() [1/2]

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

Helper function used in search and replace dialog Function Replace performs a text replace on aText using the find and replace criteria in aSearchData on items that support text find and replace.

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

Definition at line 167 of file base_struct.cpp.

168 {
169  wxString searchString = (aSearchData.GetFlags() & wxFR_MATCHCASE) ? aText : aText.Upper();
170 
171  int result = searchString.Find( (aSearchData.GetFlags() & wxFR_MATCHCASE) ?
172  aSearchData.GetFindString() :
173  aSearchData.GetFindString().Upper() );
174 
175  if( result == wxNOT_FOUND )
176  return false;
177 
178  wxString prefix = aText.Left( result );
179  wxString suffix;
180 
181  if( aSearchData.GetFindString().length() + result < aText.length() )
182  suffix = aText.Right( aText.length() - ( aSearchData.GetFindString().length() + result ) );
183 
184  wxLogTrace( traceFindReplace, wxT( "Replacing '%s', prefix '%s', replace '%s', suffix '%s'." ),
185  GetChars( aText ), GetChars( prefix ), GetChars( aSearchData.GetReplaceString() ),
186  GetChars( suffix ) );
187 
188  aText = prefix + aSearchData.GetReplaceString() + suffix;
189 
190  return true;
191 }
const wxChar *const traceFindReplace
Flag to enable find and replace debug tracing.
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:153

References GetChars(), and traceFindReplace.

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

◆ Replace() [2/2]

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

Function Replace performs a text replace using the find and replace criteria in aSearchData on items that support text find and replace.

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

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

Reimplemented in SCH_TEXT, SCH_SHEET_PIN, SCH_FIELD, and SCH_PIN.

Definition at line 490 of file base_struct.h.

490 { return false; }

◆ Rotate() [1/2]

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

Function Rotate Rotate this object.

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

Reimplemented from BOARD_ITEM.

Reimplemented in EDGE_MODULE.

Definition at line 194 of file class_drawsegment.cpp.

195 {
196  switch( m_Shape )
197  {
198  case S_ARC:
199  case S_SEGMENT:
200  case S_CIRCLE:
201  // these can all be done by just rotating the constituent points
202  RotatePoint( &m_Start, aRotCentre, aAngle );
203  RotatePoint( &m_End, aRotCentre, aAngle );
204  RotatePoint( &m_ThirdPoint, aRotCentre, aAngle );
205  break;
206 
207  case S_RECT:
208  if( KiROUND( aAngle ) % 900 == 0 )
209  {
210  RotatePoint( &m_Start, aRotCentre, aAngle );
211  RotatePoint( &m_End, aRotCentre, aAngle );
212  break;
213  }
214 
215  // Convert non-cartesian-rotated rect to a diamond
216  m_Shape = S_POLYGON;
218  m_Poly.NewOutline();
219  m_Poly.Append( m_Start );
221  m_Poly.Append( m_End );
223 
225 
226  case S_POLYGON:
227  m_Poly.Rotate( -DECIDEG2RAD( aAngle ), VECTOR2I( aRotCentre ) );
228  break;
229 
230  case S_CURVE:
231  RotatePoint( &m_Start, aRotCentre, aAngle);
232  RotatePoint( &m_End, aRotCentre, aAngle);
233  RotatePoint( &m_BezierC1, aRotCentre, aAngle);
234  RotatePoint( &m_BezierC2, aRotCentre, aAngle);
235 
236  for( wxPoint& pt : m_BezierPoints )
237  RotatePoint( &pt, aRotCentre, aAngle);
238 
239  break;
240 
241  default:
242  wxFAIL_MSG( "DRAWSEGMENT::Rotate not implemented for " + STROKE_T_asString( m_Shape ) );
243  break;
244  }
245 }
SHAPE_POLY_SET m_Poly
Stores the S_POLYGON shape.
polygon (not yet used for tracks, but could be in microwave apps)
usual segment : line with rounded ends
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:88
void Rotate(double aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Function Rotate rotates all vertices by a given angle.
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
wxPoint m_BezierC1
Bezier Control Point 1.
segment with non rounded ends
wxPoint m_Start
Line start point or Circle and Arc center.
wxPoint m_ThirdPoint
Used only for Arcs: arc end point.
wxPoint m_End
Line end point or circle and arc start point.
Arcs (with rounded ends)
STROKE_T m_Shape
Shape: line, Circle, Arc.
Bezier Curve.
int NewOutline()
Creates a new empty polygon in the set and returns its index
static wxString STROKE_T_asString(STROKE_T a)
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.
double DECIDEG2RAD(double deg)
Definition: trigo.h:223
wxPoint m_BezierC2
Bezier Control Point 2.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
std::vector< wxPoint > m_BezierPoints

References SHAPE_POLY_SET::Append(), DECIDEG2RAD(), KI_FALLTHROUGH, KiROUND(), m_BezierC1, m_BezierC2, m_BezierPoints, m_End, m_Poly, m_Shape, m_Start, m_ThirdPoint, SHAPE_POLY_SET::NewOutline(), SHAPE_POLY_SET::RemoveAllContours(), SHAPE_POLY_SET::Rotate(), RotatePoint(), S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, S_SEGMENT, STROKE_T_asString(), wxPoint::x, and wxPoint::y.

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

◆ Rotate() [2/2]

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

Definition at line 333 of file class_board_item.h.

334  {
335  Rotate( wxPoint( aRotCentre.x, aRotCentre.y ), aAngle );
336  }
virtual void Rotate(const wxPoint &aRotCentre, double aAngle)
Function Rotate Rotate this object.

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

◆ Scale()

void DRAWSEGMENT::Scale ( double  aScale)

Definition at line 148 of file class_drawsegment.cpp.

149 {
150  auto scalePt = [&]( wxPoint& pt )
151  {
152  pt.x = KiROUND( pt.x * aScale );
153  pt.y = KiROUND( pt.y * aScale );
154  };
155 
156  int radius = GetRadius();
157 
158  scalePt( m_Start );
159  scalePt( m_End );
160 
161  // specific parameters:
162  switch( m_Shape )
163  {
164  case S_CURVE:
165  scalePt( m_BezierC1 );
166  scalePt( m_BezierC2 );
167  break;
168 
169  case S_CIRCLE: // ring or circle
170  m_End.x = m_Start.x + KiROUND( radius * aScale );
171  m_End.y = m_Start.y;
172  break;
173 
174  case S_POLYGON: // polygon
175  {
176  std::vector<wxPoint> pts;
177 
178  for( const VECTOR2I& pt : m_Poly.Outline( 0 ).CPoints() )
179  {
180  pts.emplace_back( pt );
181  scalePt( pts.back() );
182  }
183 
184  SetPolyPoints( pts );
185  }
186  break;
187 
188  default:
189  break;
190  }
191 }
SHAPE_POLY_SET m_Poly
Stores the S_POLYGON shape.
polygon (not yet used for tracks, but could be in microwave apps)
wxPoint m_BezierC1
Bezier Control Point 1.
wxPoint m_Start
Line start point or Circle and Arc center.
const std::vector< VECTOR2I > & CPoints() const
wxPoint m_End
Line end point or circle and arc start point.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
STROKE_T m_Shape
Shape: line, Circle, Arc.
int GetRadius() const
Function GetRadius returns the radius of this item Has meaning only for arc and circle.
Bezier Curve.
void SetPolyPoints(const std::vector< wxPoint > &aPoints)
wxPoint m_BezierC2
Bezier Control Point 2.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68

References SHAPE_LINE_CHAIN::CPoints(), GetRadius(), KiROUND(), m_BezierC1, m_BezierC2, m_End, m_Poly, m_Shape, m_Start, SHAPE_POLY_SET::Outline(), S_CIRCLE, S_CURVE, S_POLYGON, SetPolyPoints(), wxPoint::x, and wxPoint::y.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::getDrawSegmentFromVertex().

◆ Set() [1/3]

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

Definition at line 40 of file inspectable.h.

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

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

◆ Set() [2/3]

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

Definition at line 53 of file inspectable.h.

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

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

◆ Set() [3/3]

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

Definition at line 66 of file inspectable.h.

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

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

◆ SetAngle()

void DRAWSEGMENT::SetAngle ( double  aAngle)
virtual

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

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

Reimplemented in EDGE_MODULE.

Definition at line 433 of file class_drawsegment.cpp.

434 {
435  // Mark as depreciated.
436  // m_Angle does not define the arc anymore
437  // m_Angle must be >= -360 and <= +360 degrees
438  m_Angle = NormalizeAngle360Max( aAngle );
441 }
T NormalizeAngle360Max(T Angle)
Normalize angle to be >=-360.0 and <= 360.0 Angle can be equal to -360 or +360.
Definition: trigo.h:231
double m_Angle
Used only for Arcs: Arc angle in 1/10 deg.
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
wxPoint m_Start
Line start point or Circle and Arc center.
wxPoint m_ThirdPoint
Used only for Arcs: arc end point.
wxPoint m_End
Line end point or circle and arc start point.

References m_Angle, m_End, m_Start, m_ThirdPoint, NormalizeAngle360Max(), and RotatePoint().

Referenced by D_PAD::AddPrimitiveArc(), PCAD2KICAD::PCB_ARC::AddToBoard(), DRAWSEGMENT_DESC::DRAWSEGMENT_DESC(), POINT_EDITOR::editArcEndpointKeepCenter(), POINT_EDITOR::editArcEndpointKeepTangent(), POINT_EDITOR::editArcMidKeepEnpoints(), CADSTAR_PCB_ARCHIVE_LOADER::getDrawSegmentFromVertex(), ALTIUM_PCB::HelperCreateBoardOutline(), EAGLE_PLUGIN::loadPlain(), ALTIUM_PCB::ParseArcs6Data(), PAD_TOOL::recombinePad(), CONVERT_TOOL::SegmentToArc(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataFromWindow(), and updateArcFromConstructionMgr().

◆ SetArcEnd()

void DRAWSEGMENT::SetArcEnd ( const wxPoint aArcEndPoint)
inline

Initialize the end arc point.

can be used for circles to initialize one point of the cicumference

Definition at line 211 of file class_drawsegment.h.

212  {
213  m_ThirdPoint = aArcEndPoint;
214  }
wxPoint m_ThirdPoint
Used only for Arcs: arc end point.

References m_ThirdPoint.

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

◆ SetArcStart()

void DRAWSEGMENT::SetArcStart ( const wxPoint aArcStartPoint)
inline

Initialize the start arc point.

can be used for circles to initialize one point of the cicumference

Definition at line 202 of file class_drawsegment.h.

203  {
204  m_End = aArcStartPoint;
205  }
wxPoint m_End
Line end point or circle and arc start point.

References m_End.

Referenced by D_PAD::AddPrimitiveArc(), POINT_EDITOR::editArcEndpointKeepCenter(), POINT_EDITOR::editArcEndpointKeepTangent(), POINT_EDITOR::editArcMidKeepCenter(), CADSTAR_PCB_ARCHIVE_LOADER::getDrawSegmentFromVertex(), ALTIUM_PCB::HelperCreateBoardOutline(), ALTIUM_PCB::HelperParsePad6NonCopper(), ALTIUM_PCB::ParseArcs6Data(), CONVERT_TOOL::SegmentToArc(), and updateArcFromConstructionMgr().

◆ SetBezControl1()

void DRAWSEGMENT::SetBezControl1 ( const wxPoint aPoint)
inline

◆ SetBezControl2()

void DRAWSEGMENT::SetBezControl2 ( const wxPoint aPoint)
inline

◆ SetBezierPoints()

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

Definition at line 258 of file class_drawsegment.h.

259  {
260  m_BezierPoints = aPoints;
261  }
std::vector< wxPoint > m_BezierPoints

References m_BezierPoints.

◆ SetBrightened()

◆ SetCenter()

◆ SetEnd()

◆ SetEndX()

void DRAWSEGMENT::SetEndX ( int  x)
inline

Definition at line 150 of file class_drawsegment.h.

150 { m_End.x = x; }
wxPoint m_End
Line end point or circle and arc start point.

References m_End, and wxPoint::x.

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

◆ SetEndY()

void DRAWSEGMENT::SetEndY ( int  y)
inline

Definition at line 149 of file class_drawsegment.h.

149 { m_End.y = y; }
wxPoint m_End
Line end point or circle and arc start point.

References m_End, and wxPoint::y.

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

◆ SetFlags()

void EDA_ITEM::SetFlags ( STATUS_FLAGS  aMask)
inlineinherited

Definition at line 232 of file base_struct.h.

232 { m_Flags |= aMask; }
STATUS_FLAGS m_Flags
Definition: base_struct.h:176

References EDA_ITEM::m_Flags.

Referenced by SCH_EAGLE_PLUGIN::addBusEntries(), PCB_BASE_FRAME::AddModuleToBoard(), SCH_MOVE_TOOL::AlignElements(), PCBNEW_CONTROL::AppendBoard(), SCH_EDIT_TOOL::ChangeTextType(), GRAPHICS_CLEANER::cleanupSegments(), TRACKS_CLEANER::cleanupSegments(), SCH_EDIT_FRAME::ConvertPart(), SCH_DRAWING_TOOLS::createNewText(), LIB_PIN_TOOL::CreatePin(), SCH_EDIT_FRAME::CreateSheetPin(), SCH_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), KIGFX::SCH_PAINTER::draw(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawLine(), DRAWING_TOOL::DrawRectangle(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), SCH_EDIT_TOOL::Duplicate(), LIB_EDIT_FRAME::GetComponentFromRedoList(), LIB_EDIT_FRAME::GetComponentFromUndoList(), SCH_MOVE_TOOL::getConnectedDragItems(), EDIT_POINTS_FACTORY::Make(), TRACKS_CLEANER::mergeCollinearSegments(), LIB_MOVE_TOOL::moveItem(), SCH_MOVE_TOOL::moveItem(), KIGFX::ORIGIN_VIEWITEM::ORIGIN_VIEWITEM(), SCH_ALTIUM_PLUGIN::ParseBus(), SCH_ALTIUM_PLUGIN::ParseNetLabel(), SCH_ALTIUM_PLUGIN::ParseWire(), LIB_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), DRAWING_TOOL::PlaceText(), BACK_ANNOTATE::processNetNameChange(), SCH_EDIT_FRAME::PutDataInPreviousState(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_PIN_TOOL::RepeatPin(), LIB_EDIT_FRAME::SaveCopyInUndoList(), EE_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectPoint(), SCH_EDIT_FRAME::SelectUnit(), EDA_ITEM::SetBrightened(), EDA_ITEM::SetModified(), EDA_ITEM::SetSelected(), EDA_ITEM::SetWireImage(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_LINE_WIRE_BUS_TOOL::startSegments(), WS_DATA_ITEM::SyncDrawItems(), WS_DATA_ITEM_TEXT::SyncDrawItems(), DIALOG_DIMENSION_PROPERTIES::TransferDataFromWindow(), DIALOG_TARGET_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), LIB_DRAWING_TOOLS::TwoClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ SetForceVisible()

void EDA_ITEM::SetForceVisible ( bool  aEnable)
inlineinherited

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

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

Definition at line 284 of file base_struct.h.

284 { m_forceVisible = aEnable; }
bool m_forceVisible
Definition: base_struct.h:175

References EDA_ITEM::m_forceVisible.

Referenced by SCH_EDITOR_CONTROL::UpdateFind().

◆ SetGroup()

void BOARD_ITEM::SetGroup ( const KIID aGroup)
inlineinherited

Set the group that this item belongs to.

Parameters
aGroupis the group this belongs to

Definition at line 107 of file class_board_item.h.

107 { m_groupUuid = aGroup; }

References BOARD_ITEM::m_groupUuid.

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

◆ SetLayer()

virtual void BOARD_ITEM::SetLayer ( PCB_LAYER_ID  aLayer)
inlinevirtualinherited

Function SetLayer sets the layer this item is on.

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

Reimplemented in DIMENSION, ZONE_CONTAINER, and PCB_GROUP.

Definition at line 224 of file class_board_item.h.

225  {
226  m_Layer = aLayer;
227  }
PCB_LAYER_ID m_Layer

References BOARD_ITEM::m_Layer.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::addAttribute(), PNS_KICAD_IFACE::AddItem(), PCAD2KICAD::PCB_TEXT::AddToBoard(), PCAD2KICAD::PCB_LINE::AddToBoard(), PCAD2KICAD::PCB_ARC::AddToBoard(), PCAD2KICAD::PCB_PAD::AddToBoard(), PCAD2KICAD::PCB_MODULE::AddToBoard(), PCAD2KICAD::PCB_LINE::AddToModule(), PCAD2KICAD::PCB_ARC::AddToModule(), PCAD2KICAD::PCB_POLYGON::AddToModule(), BOARD_CONNECTED_ITEM_DESC::BOARD_CONNECTED_ITEM_DESC(), BOARD_ITEM_DESC::BOARD_ITEM_DESC(), BOOST_AUTO_TEST_CASE(), ZONE_FILLER::buildCopperItemClearances(), MICROWAVE_TOOL::createMicrowaveInductor(), PCB_BASE_FRAME::CreateNewModule(), MICROWAVE_TOOL::createPolygonShape(), DRAWING_TOOL::drawArc(), CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarShape(), CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarText(), PAD_TOOL::explodePad(), PCB_TARGET::Flip(), TEXTE_PCB::Flip(), TRACK::Flip(), EDGE_MODULE::Flip(), TEXTE_MODULE::Flip(), MODULE::Flip(), ARC::Flip(), Flip(), ALTIUM_PCB::HelperCreateBoardOutline(), ALTIUM_PCB::HelperParseDimensions6Center(), ALTIUM_PCB::HelperParseDimensions6Datum(), ALTIUM_PCB::HelperParseDimensions6Leader(), ALTIUM_PCB::HelperParsePad6NonCopper(), CONVERT_TOOL::LinesToPoly(), LEGACY_PLUGIN::loadMODULE(), LEGACY_PLUGIN::loadMODULE_TEXT(), CADSTAR_PCB_ARCHIVE_LOADER::loadNetTracks(), LEGACY_PLUGIN::loadPCB_TEXT(), EAGLE_PLUGIN::loadPlain(), EAGLE_PLUGIN::loadSignals(), LEGACY_PLUGIN::loadTrackList(), main(), DSN::SPECCTRA_DB::makeTRACK(), CADSTAR_PCB_ARCHIVE_LOADER::makeTracksFromDrawsegments(), GRAPHICS_CLEANER::mergeRects(), MODULE_DESC::MODULE_DESC(), DIALOG_FOOTPRINT_FP_EDITOR::OnAddField(), DIALOG_FOOTPRINT_BOARD_EDITOR::OnAddField(), EAGLE_PLUGIN::packageCircle(), EAGLE_PLUGIN::packagePolygon(), EAGLE_PLUGIN::packageRectangle(), EAGLE_PLUGIN::packageSMD(), EAGLE_PLUGIN::packageText(), EAGLE_PLUGIN::packageWire(), ALTIUM_PCB::ParseArcs6Data(), ALTIUM_PCB::ParseComponents6Data(), ALTIUM_PCB::ParseFills6Data(), GPCB_FPL_CACHE::parseMODULE(), ALTIUM_PCB::ParsePads6Data(), ALTIUM_PCB::ParseShapeBasedRegions6Data(), ALTIUM_PCB::ParseTexts6Data(), ALTIUM_PCB::ParseTracks6Data(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), BRDITEMS_PLOTTER::PlotDimension(), BRDITEMS_PLOTTER::PlotPcbTarget(), CONVERT_TOOL::PolyToLines(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::processItem(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), processTextItem(), DIALOG_PAD_PROPERTIES::redraw(), CLIPBOARD_IO::SaveSelection(), CONVERT_TOOL::SegmentToArc(), DIMENSION::SetLayer(), TEXT_MOD_GRID_TABLE::SetValueAsLong(), GLOBAL_EDIT_TOOL::swapBoardItem(), TEXTE_MODULE::TEXTE_MODULE(), TRACK_VIA_DESC::TRACK_VIA_DESC(), DIALOG_TRACK_VIA_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), and DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow().

◆ SetLayerSet()

virtual void BOARD_ITEM::SetLayerSet ( LSET  aLayers)
inlinevirtualinherited

Reimplemented in VIA, D_PAD, and ZONE_CONTAINER.

Definition at line 210 of file class_board_item.h.

211  {
212  wxFAIL_MSG( "Attempted to SetLayerSet() on a single-layer object." );
213 
214  // Derived classes which support multiple layers must implement this
215  }

Referenced by PANEL_SETUP_LAYERS::TransferDataFromWindow().

◆ SetLocked()

virtual void BOARD_ITEM::SetLocked ( bool  aLocked)
inlinevirtualinherited

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

Reimplemented in MODULE, and TRACK.

Definition at line 288 of file class_board_item.h.

289  {
290  // only MODULEs & TRACKs can be locked at this time.
291  }

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

◆ SetModified()

void EDA_ITEM::SetModified ( )
inherited

Definition at line 87 of file base_struct.cpp.

88 {
90 
91  // If this a child object, then the parent modification state also needs to be set.
92  if( m_Parent )
94 }
void SetModified()
Definition: base_struct.cpp:87
EDA_ITEM * m_Parent
Linked list: Link (parent struct)
Definition: base_struct.h:174
#define IS_CHANGED
std::function passed to nested users by ref, avoids copying std::function
Definition: base_struct.h:113
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:232

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

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

◆ SetParent()

virtual void EDA_ITEM::SetParent ( EDA_ITEM aParent)
inlinevirtualinherited

Reimplemented in DIMENSION.

Definition at line 196 of file base_struct.h.

196 { m_Parent = aParent; }
EDA_ITEM * m_Parent
Linked list: Link (parent struct)
Definition: base_struct.h:174

References EDA_ITEM::m_Parent.

Referenced by MODULE::Add(), BOARD::Add(), FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), BOARD_NETLIST_UPDATER::addNewComponent(), SCH_SHEET::AddPin(), LIB_CONTROL::AddSymbolToSchematic(), SCH_SCREEN::Append(), ZONE_FILLER::buildCopperItemClearances(), LIB_FIELD::Copy(), LIB_EDIT_FRAME::CreateNewPart(), SCH_DRAWING_TOOLS::createNewText(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), SCH_EDIT_TOOL::Duplicate(), PCB_EDIT_FRAME::Exchange_Module(), LIB_PART::Flatten(), PCB_IO::FootprintSave(), DISPLAY_FOOTPRINTS_FRAME::GetModule(), LIB_PART::LIB_PART(), FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD(), SCH_LEGACY_PLUGIN_CACHE::loadAliases(), SCH_SEXPR_PLUGIN::loadHierarchy(), SCH_LEGACY_PLUGIN::loadHierarchy(), LIB_EDIT_FRAME::LoadOneSymbol(), MODULE::MODULE(), MODULE::operator=(), LIB_PART::operator=(), PCB_PARSER::parseMODULE_unchecked(), SCH_SEXPR_PARSER::ParseSchematic(), SCH_SEXPR_PARSER::ParseSymbol(), LIB_EDIT_TOOL::Paste(), PCBNEW_CONTROL::Paste(), SCH_EDITOR_CONTROL::Paste(), pasteModuleItemsToModEdit(), SCH_DRAWING_TOOLS::PlaceComponent(), PCB_EDITOR_CONTROL::PlaceModule(), BACK_ANNOTATE::processNetNameChange(), BOARD_COMMIT::Push(), SCH_SEXPR_PLUGIN_CACHE::removeSymbol(), SCH_LEGACY_PLUGIN_CACHE::removeSymbol(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), SaveCopyOfZones(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), SCH_SHEET_PIN::SCH_SHEET_PIN(), LIB_PART::SetFields(), DIMENSION::SetParent(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_LINE_WIRE_BUS_TOOL::startSegments(), SCH_SHEET::SwapData(), SCH_COMPONENT::SwapData(), and SwapItemData().

◆ SetPolyPoints()

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

Definition at line 1053 of file class_drawsegment.cpp.

1054 {
1056  m_Poly.NewOutline();
1057 
1058  for ( const wxPoint& p : aPoints )
1059  m_Poly.Append( p.x, p.y );
1060 }
SHAPE_POLY_SET m_Poly
Stores the S_POLYGON shape.
int NewOutline()
Creates a new empty polygon in the set and returns its index
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)

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

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

◆ SetPolyShape()

void DRAWSEGMENT::SetPolyShape ( const SHAPE_POLY_SET aShape)
inline

Definition at line 256 of file class_drawsegment.h.

256 { m_Poly = aShape; }
SHAPE_POLY_SET m_Poly
Stores the S_POLYGON shape.

References m_Poly.

Referenced by CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarShape(), PAD_TOOL::explodePad(), CONVERT_TOOL::LinesToPoly(), and PAD_TOOL::recombinePad().

◆ SetPosition()

void DRAWSEGMENT::SetPosition ( const wxPoint aPos)
overridevirtual

Reimplemented from EDA_ITEM.

Definition at line 62 of file class_drawsegment.cpp.

63 {
64  m_Start = aPos;
65 }
wxPoint m_Start
Line start point or Circle and Arc center.

References m_Start.

◆ SetSelected()

◆ SetShape()

◆ SetStart()

◆ SetStartX()

void DRAWSEGMENT::SetStartX ( int  x)
inline

Definition at line 139 of file class_drawsegment.h.

139 { m_Start.x = x; }
wxPoint m_Start
Line start point or Circle and Arc center.

References m_Start, and wxPoint::x.

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

◆ SetStartY()

void DRAWSEGMENT::SetStartY ( int  y)
inline

Definition at line 138 of file class_drawsegment.h.

138 { m_Start.y = y; }
wxPoint m_Start
Line start point or Circle and Arc center.

References m_Start, and wxPoint::y.

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

◆ SetState()

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

Definition at line 221 of file base_struct.h.

222  {
223  if( state )
224  m_Status |= type; // state = ON or OFF
225  else
226  m_Status &= ~type;
227  }
STATUS_FLAGS m_Status
Definition: base_struct.h:173

References EDA_ITEM::m_Status.

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

◆ SetStatus()

void EDA_ITEM::SetStatus ( STATUS_FLAGS  aStatus)
inlineinherited

Definition at line 230 of file base_struct.h.

230 { m_Status = aStatus; }
STATUS_FLAGS m_Status
Definition: base_struct.h:173

References EDA_ITEM::m_Status.

Referenced by BOARD_NETLIST_UPDATER::UpdateNetlist().

◆ SetThirdPoint()

void DRAWSEGMENT::SetThirdPoint ( const wxPoint aPoint)
inline

Definition at line 159 of file class_drawsegment.h.

159 { m_ThirdPoint = aPoint; }
wxPoint m_ThirdPoint
Used only for Arcs: arc end point.

References m_ThirdPoint.

◆ SetThirdPointX()

void DRAWSEGMENT::SetThirdPointX ( int  x)
inline

Definition at line 161 of file class_drawsegment.h.

161 { m_ThirdPoint.x = x; }
wxPoint m_ThirdPoint
Used only for Arcs: arc end point.

References m_ThirdPoint, and wxPoint::x.

◆ SetThirdPointY()

void DRAWSEGMENT::SetThirdPointY ( int  y)
inline

Definition at line 160 of file class_drawsegment.h.

160 { m_ThirdPoint.y = y; }
wxPoint m_ThirdPoint
Used only for Arcs: arc end point.

References m_ThirdPoint, and wxPoint::y.

◆ SetType()

void DRAWSEGMENT::SetType ( int  aType)
inline

Definition at line 115 of file class_drawsegment.h.

115 { m_Type = aType; }
int m_Type
Used in complex associations ( Dimensions.. )

References m_Type.

◆ SetWidth()

void DRAWSEGMENT::SetWidth ( int  aWidth)
inline

Definition at line 104 of file class_drawsegment.h.

104 { m_Width = aWidth; }
int m_Width
thickness of lines ...

References m_Width.

Referenced by D_PAD::AddPrimitiveArc(), D_PAD::AddPrimitiveCircle(), D_PAD::AddPrimitiveCurve(), D_PAD::AddPrimitivePoly(), D_PAD::AddPrimitiveRect(), D_PAD::AddPrimitiveSegment(), PCAD2KICAD::PCB_LINE::AddToBoard(), PCAD2KICAD::PCB_ARC::AddToBoard(), PCAD2KICAD::PCB_LINE::AddToModule(), PCAD2KICAD::PCB_ARC::AddToModule(), PCAD2KICAD::PCB_POLYGON::AddToModule(), MICROWAVE_TOOL::createMicrowaveInductor(), MICROWAVE_TOOL::createPolygonShape(), DRAWING_TOOL::drawArc(), CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarShape(), DRAWSEGMENT_DESC::DRAWSEGMENT_DESC(), PAD_TOOL::explodePad(), ALTIUM_PCB::HelperCreateBoardOutline(), ALTIUM_PCB::HelperParseDimensions6Center(), ALTIUM_PCB::HelperParseDimensions6Datum(), ALTIUM_PCB::HelperParseDimensions6Leader(), ALTIUM_PCB::HelperParsePad6NonCopper(), CADSTAR_PCB_ARCHIVE_LOADER::loadNetTracks(), EAGLE_PLUGIN::loadPlain(), GRAPHICS_CLEANER::mergeRects(), DIALOG_PAD_PROPERTIES::onAddPrimitive(), EAGLE_PLUGIN::packageCircle(), EAGLE_PLUGIN::packagePolygon(), EAGLE_PLUGIN::packageRectangle(), EAGLE_PLUGIN::packageWire(), ALTIUM_PCB::ParseArcs6Data(), ALTIUM_PCB::ParseFills6Data(), GPCB_FPL_CACHE::parseMODULE(), ALTIUM_PCB::ParseShapeBasedRegions6Data(), 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(), and DIALOG_PAD_PRIMITIVE_POLY_PROPS::TransferDataFromWindow().

◆ SetWireImage()

void EDA_ITEM::SetWireImage ( )
inlineinherited

Definition at line 207 of file base_struct.h.

207 { SetFlags( IS_WIRE_IMAGE ); }
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:232
#define IS_WIRE_IMAGE
Item to be drawn as wireframe while editing.
Definition: base_struct.h:121

References IS_WIRE_IMAGE, and EDA_ITEM::SetFlags().

◆ SetX()

void BOARD_ITEM::SetX ( int  aX)
inlineinherited

Definition at line 147 of file class_board_item.h.

148  {
149  wxPoint p( aX, GetY() );
150  SetPosition( p );
151  }
virtual void SetPosition(const wxPoint &aPos)
Definition: base_struct.h:338
int GetY() const

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

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

◆ SetY()

void BOARD_ITEM::SetY ( int  aY)
inlineinherited

Definition at line 153 of file class_board_item.h.

154  {
155  wxPoint p( GetX(), aY );
156  SetPosition( p );
157  }
virtual void SetPosition(const wxPoint &aPos)
Definition: base_struct.h:338
int GetX() const

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

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

◆ ShowShape()

wxString BOARD_ITEM::ShowShape ( STROKE_T  aShape)
staticinherited

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

Definition at line 33 of file class_board_item.cpp.

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

References _, S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, and S_SEGMENT.

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

◆ Sort()

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

Function Sort is a helper function to be used by the C++ STL sort algorithm for sorting a STL container of EDA_ITEM pointers.

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

Definition at line 521 of file base_struct.h.

521 { return *aLeft < *aRight; }

◆ SwapData()

void DRAWSEGMENT::SwapData ( BOARD_ITEM aImage)
overridevirtual

Swap data between aItem and aImage.

aItem and aImage should have the same type Used in undo redo command to swap values between an item and its copy Only values like layer, size .. which are modified by editing are swapped

Parameters
aImage= the item image which contains data to swap

Reimplemented from BOARD_ITEM.

Definition at line 1214 of file class_drawsegment.cpp.

1215 {
1216  DRAWSEGMENT* image = dynamic_cast<DRAWSEGMENT*>( aImage );
1217  assert( image );
1218 
1219  std::swap( m_Width, image->m_Width );
1220  std::swap( m_Start, image->m_Start );
1221  std::swap( m_End, image->m_End );
1222  std::swap( m_ThirdPoint, image->m_ThirdPoint );
1223  std::swap( m_Shape, image->m_Shape );
1224  std::swap( m_Type, image->m_Type );
1225  std::swap( m_Angle, image->m_Angle );
1226  std::swap( m_BezierC1, image->m_BezierC1 );
1227  std::swap( m_BezierC2, image->m_BezierC2 );
1228  std::swap( m_BezierPoints, image->m_BezierPoints );
1229  std::swap( m_Poly, image->m_Poly );
1230  std::swap( m_Layer, image->m_Layer );
1231  std::swap( m_Flags, image->m_Flags );
1232  std::swap( m_Status, image->m_Status );
1233  std::swap( m_Parent, image->m_Parent );
1234  std::swap( m_forceVisible, image->m_forceVisible );
1235 }
EDA_ITEM * m_Parent
Linked list: Link (parent struct)
Definition: base_struct.h:174
SHAPE_POLY_SET m_Poly
Stores the S_POLYGON shape.
double m_Angle
Used only for Arcs: Arc angle in 1/10 deg.
wxPoint m_BezierC1
Bezier Control Point 1.
PCB_LAYER_ID m_Layer
wxPoint m_Start
Line start point or Circle and Arc center.
wxPoint m_ThirdPoint
Used only for Arcs: arc end point.
wxPoint m_End
Line end point or circle and arc start point.
STATUS_FLAGS m_Status
Definition: base_struct.h:173
STROKE_T m_Shape
Shape: line, Circle, Arc.
int m_Type
Used in complex associations ( Dimensions.. )
STATUS_FLAGS m_Flags
Definition: base_struct.h:176
wxPoint m_BezierC2
Bezier Control Point 2.
int m_Width
thickness of lines ...
bool m_forceVisible
Definition: base_struct.h:175
std::vector< wxPoint > m_BezierPoints

References m_Angle, m_BezierC1, m_BezierC2, m_BezierPoints, m_End, EDA_ITEM::m_Flags, EDA_ITEM::m_forceVisible, BOARD_ITEM::m_Layer, EDA_ITEM::m_Parent, m_Poly, m_Shape, m_Start, EDA_ITEM::m_Status, m_ThirdPoint, m_Type, and m_Width.

◆ TransformShapeWithClearanceToPolygon()

void DRAWSEGMENT::TransformShapeWithClearanceToPolygon ( SHAPE_POLY_SET aCornerBuffer,
PCB_LAYER_ID  aLayer,
int  aClearanceValue,
int  aError = ARC_HIGH_DEF,
bool  ignoreLineWidth = false 
) const
overridevirtual

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

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

Reimplemented from BOARD_ITEM.

Definition at line 382 of file board_items_to_polygon_shape_transform.cpp.

386 {
387  int width = ignoreLineWidth ? 0 : m_Width;
388 
389  width += 2 * aClearanceValue;
390 
391  // Creating a reliable clearance shape for circles and arcs is not so easy, due to
392  // the error created by segment approximation.
393  // for a circle this is not so hard: create a polygon from a circle slightly bigger:
394  // thickness = width + s_error_max, and radius = initial radius + s_error_max/2
395  // giving a shape with a suitable internal radius and external radius
396  // For an arc this is more tricky: TODO
397 
398  switch( m_Shape )
399  {
400  case S_CIRCLE:
401  if( width == 0 )
402  TransformCircleToPolygon( aCornerBuffer, GetCenter(), GetRadius(), aError );
403  else
404  TransformRingToPolygon( aCornerBuffer, GetCenter(), GetRadius(), aError, width );
405  break;
406 
407  case S_RECT:
408  {
409  std::vector<wxPoint> pts = GetRectCorners();
410 
411  if( width == 0 )
412  {
413  aCornerBuffer.NewOutline();
414 
415  for( const wxPoint& pt : pts )
416  aCornerBuffer.Append( pt );
417  }
418 
419  if( width > 0 )
420  {
421  // Add in segments
422  TransformOvalToPolygon( aCornerBuffer, pts[0], pts[1], width, aError );
423  TransformOvalToPolygon( aCornerBuffer, pts[1], pts[2], width, aError );
424  TransformOvalToPolygon( aCornerBuffer, pts[2], pts[3], width, aError );
425  TransformOvalToPolygon( aCornerBuffer, pts[3], pts[0], width, aError );
426  }
427  }
428  break;
429 
430  case S_ARC:
431  TransformArcToPolygon( aCornerBuffer, GetCenter(), GetArcStart(), m_Angle, aError, width );
432  break;
433 
434  case S_SEGMENT:
435  TransformOvalToPolygon( aCornerBuffer, m_Start, m_End, width, aError );
436  break;
437 
438  case S_POLYGON:
439  if( IsPolyShapeValid() )
440  {
441  // The polygon is expected to be a simple polygon
442  // not self intersecting, no hole.
443  MODULE* module = GetParentModule(); // NULL for items not in footprints
444  double orientation = module ? module->GetOrientation() : 0.0;
445  wxPoint offset;
446 
447  if( module )
448  offset = module->GetPosition();
449 
450  // Build the polygon with the actual position and orientation:
451  std::vector< wxPoint> poly;
452  poly = BuildPolyPointsList();
453 
454  for( wxPoint& point : poly )
455  {
456  RotatePoint( &point, orientation );
457  point += offset;
458  }
459 
460  if( IsPolygonFilled() || width == 0 )
461  {
462  aCornerBuffer.NewOutline();
463 
464  for( wxPoint& point : poly )
465  aCornerBuffer.Append( point.x, point.y );
466  }
467 
468  if( width > 0 )
469  {
470  wxPoint pt1( poly[ poly.size() - 1] );
471 
472  for( wxPoint pt2 : poly )
473  {
474  if( pt2 != pt1 )
475  TransformOvalToPolygon( aCornerBuffer, pt1, pt2, width, aError );
476 
477  pt1 = pt2;
478  }
479  }
480  }
481  break;
482 
483  case S_CURVE: // Bezier curve
484  {
485  std::vector<wxPoint> ctrlPoints = { m_Start, m_BezierC1, m_BezierC2, m_End };
486  BEZIER_POLY converter( ctrlPoints );
487  std::vector< wxPoint> poly;
488  converter.GetPoly( poly, m_Width );
489 
490  if( width != 0 )
491  {
492  for( unsigned ii = 1; ii < poly.size(); ii++ )
493  TransformOvalToPolygon( aCornerBuffer, poly[ii-1], poly[ii], width, aError );
494  }
495  }
496  break;
497 
498  default:
499  wxFAIL_MSG( "DRAWSEGMENT::TransformShapeWithClearanceToPolygon no implementation for "
500  + STROKE_T_asString( m_Shape ) );
501  break;
502  }
503 }
double GetOrientation() const
Definition: class_module.h:224
wxPoint GetArcStart() const
polygon (not yet used for tracks, but could be in microwave apps)
usual segment : line with rounded ends
void TransformArcToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aCentre, wxPoint aStart, double aArcAngle, int aError, int aWidth)
Function TransformArcToPolygon Creates a polygon from an Arc Convert arcs to multiple straight segmen...
double m_Angle
Used only for Arcs: Arc angle in 1/10 deg.
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
const std::vector< wxPoint > BuildPolyPointsList() const
Build and return the list of corners in a std::vector<wxPoint> It must be used only to convert the SH...
wxPoint m_BezierC1
Bezier Control Point 1.
segment with non rounded ends
wxPoint m_Start
Line start point or Circle and Arc center.
void TransformOvalToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aStart, wxPoint aEnd, int aWidth, int aError)
convert a oblong shape to a polygon, using multiple segments It is similar to TransformRoundedEndsSeg...
std::vector< wxPoint > GetRectCorners() const
wxPoint m_End
Line end point or circle and arc start point.
Arcs (with rounded ends)