KiCad PCB EDA Suite
DRAWSEGMENT Class Reference

#include <class_drawsegment.h>

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

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
 
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
 
const wxPoint GetPosition () const override
 
const wxPointGetStart () const
 Function GetStart returns the starting point of the graphic. More...
 
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...
 
void SetEnd (const wxPoint &aEnd)
 
void SetEndY (int y)
 
void SetEndX (int x)
 
const wxPoint GetCenter () const override
 Function GetCenter() More...
 
const wxPointGetArcStart () const
 
const wxPoint GetArcEnd () const
 
const wxPoint GetArcMid () const
 
void GetRectCorners (std::vector< wxPoint > *pts) const
 
double GetArcAngleStart () const
 function GetArcAngleStart() 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 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 ()
 Makes a set of SHAPE objects representing the DRAWSEGMENT. 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, 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...
 
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 "layer mask", which is a bitmap of all layers on which the TRACK segment or VIA physically resides. More...
 
virtual void SetLayer (PCB_LAYER_ID aLayer)
 Function SetLayer sets the layer this item is on. More...
 
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 unsigned int 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 ()
 

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
 
bool Matches (const wxString &aText, wxFindReplaceData &aSearchData)
 Function Matches compares aText against search criteria in aSearchData. More...
 

Static Protected Member Functions

static wxString LayerMaskDescribe (const BOARD *aBoard, LSET aMask)
 Helper function Return a string (to be shown to the user) describing a layer mask. 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...
 
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
 
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 44 of file class_drawsegment.cpp.

44  :
45  BOARD_ITEM( aParent, idtype )
46 {
47  m_Type = 0;
48  m_Angle = 0;
49  m_Flags = 0;
51  m_Width = Millimeter2iu( DEFAULT_LINE_WIDTH );
52 }
#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 ...

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

Referenced by Clone().

◆ ~DRAWSEGMENT()

DRAWSEGMENT::~DRAWSEGMENT ( )

Definition at line 55 of file class_drawsegment.cpp.

56 {
57 }

Member Function Documentation

◆ 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 1123 of file class_drawsegment.cpp.

1124 {
1125  std::vector<wxPoint> rv;
1126 
1127  if( m_Poly.OutlineCount() )
1128  {
1129  if( m_Poly.COutline( 0 ).PointCount() )
1130  {
1131  for ( auto iter = m_Poly.CIterate(); iter; iter++ )
1132  rv.emplace_back( iter->x, iter->y );
1133  }
1134  }
1135 
1136  return rv;
1137 }
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 75 of file class_drawsegment.h.

76  {
77  return aItem && PCB_LINE_T == aItem->Type();
78  }
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_SCREEN::ClearAnnotation(), EDA_ITEM::ClearBrightened(), EDA_ITEM::ClearEditFlags(), clearModuleItemFlags(), EDA_ITEM::ClearSelected(), EDA_ITEM::ClearTempFlags(), SCH_EDIT_FRAME::ConvertPart(), LIB_EDIT_TOOL::Copy(), MICROWAVE_TOOL::createMicrowaveInductor(), DIALOG_LIB_EDIT_PIN::DIALOG_LIB_EDIT_PIN(), 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 153 of file view_item.h.

154  {
156  }
VIEW_ITEM_DATA * m_viewPrivData
Definition: view_item.h:161
#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 887 of file class_drawsegment.cpp.

888 {
889  return new DRAWSEGMENT( *this );
890 }
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 943 of file class_drawsegment.cpp.

944 {
945  // Do not include the center, which is not necessarily
946  // inside the BB of a arc with a small angle
947  aBBox.SetOrigin( m_End );
948 
949  wxPoint end = m_End;
950  RotatePoint( &end, m_Start, -m_Angle );
951  aBBox.Merge( end );
952 
953  // Determine the starting quarter
954  // 0 right-bottom
955  // 1 left-bottom
956  // 2 left-top
957  // 3 right-top
958  unsigned int quarter = 0; // assume right-bottom
959 
960  if( m_End.x < m_Start.x )
961  {
962  if( m_End.y <= m_Start.y )
963  quarter = 2;
964  else // ( m_End.y > m_Start.y )
965  quarter = 1;
966  }
967  else if( m_End.x >= m_Start.x )
968  {
969  if( m_End.y < m_Start.y )
970  quarter = 3;
971  else if( m_End.x == m_Start.x )
972  quarter = 1;
973  }
974 
975  int radius = GetRadius();
976  int angle = (int) GetArcAngleStart() % 900 + m_Angle;
977  bool directionCW = ( m_Angle > 0 ); // Is the direction of arc clockwise?
978 
979  // Make the angle positive, so we go clockwise and merge points belonging to the arc
980  if( !directionCW )
981  {
982  angle = 900 - angle;
983  quarter = ( quarter + 3 ) % 4; // -1 modulo arithmetic
984  }
985 
986  while( angle > 900 )
987  {
988  switch( quarter )
989  {
990  case 0: aBBox.Merge( wxPoint( m_Start.x, m_Start.y + radius ) ); break; // down
991  case 1: aBBox.Merge( wxPoint( m_Start.x - radius, m_Start.y ) ); break; // left
992  case 2: aBBox.Merge( wxPoint( m_Start.x, m_Start.y - radius ) ); break; // up
993  case 3: aBBox.Merge( wxPoint( m_Start.x + radius, m_Start.y ) ); break; // right
994  }
995 
996  if( directionCW )
997  ++quarter;
998  else
999  quarter += 3; // -1 modulo arithmetic
1000 
1001  quarter %= 4;
1002  angle -= 900;
1003  }
1004 }
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 124 of file class_board_item.cpp.

125 {
126  auto parent = GetParent();
127 
128  if( parent )
129  parent->Remove( this );
130 
131  delete this;
132 }
BOARD_ITEM_CONTAINER * GetParent() const

References BOARD_ITEM::GetParent().

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

◆ Duplicate()

BOARD_ITEM* BOARD_ITEM::Duplicate ( ) const
inlineinherited

Function Duplicate creates a copy of a BOARD_ITEM.

Definition at line 170 of file class_board_item.h.

171  {
172  EDA_ITEM* dupe = Clone();
173  const_cast<KIID&>( dupe->m_Uuid ) = KIID();
174 
175  return static_cast<BOARD_ITEM*>( dupe );
176  }
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 FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), EDIT_TOOL::Duplicate(), GPCB_PLUGIN::FootprintLoad(), PCB_IO::FootprintLoad(), PCB_IO::FootprintSave(), ARRAY_CREATOR::Invoke(), and FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD().

◆ 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 231 of file class_drawsegment.cpp.

232 {
233  if( aFlipLeftRight )
234  {
235  m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
236  m_End.x = aCentre.x - ( m_End.x - aCentre.x );
237  }
238  else
239  {
240  m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
241  m_End.y = aCentre.y - ( m_End.y - aCentre.y );
242  }
243 
244  switch ( m_Shape )
245  {
246  case S_ARC:
247  m_Angle = -m_Angle;
248  break;
249 
250  case S_POLYGON:
251  m_Poly.Mirror( aFlipLeftRight, !aFlipLeftRight, VECTOR2I( aCentre ) );
252  break;
253 
254  case S_CURVE:
255  {
256  if( aFlipLeftRight )
257  {
258  m_BezierC1.x = aCentre.x - ( m_BezierC1.x - aCentre.x );
259  m_BezierC2.x = aCentre.x - ( m_BezierC2.x - aCentre.x );
260  }
261  else
262  {
263  m_BezierC1.y = aCentre.y - ( m_BezierC1.y - aCentre.y );
264  m_BezierC2.y = aCentre.y - ( m_BezierC2.y - aCentre.y );
265  }
266 
267  // Rebuild the poly points shape
268  std::vector<wxPoint> ctrlPoints = { m_Start, m_BezierC1, m_BezierC2, m_End };
269  BEZIER_POLY converter( ctrlPoints );
270  converter.GetPoly( m_BezierPoints, m_Width );
271  }
272  break;
273 
274  case S_SEGMENT:
275  case S_RECT:
276  case S_CIRCLE:
277  break;
278 
279  default:
280  wxFAIL_MSG( "DRAWSEGMENT::Flip not implemented for " + STROKE_T_asString( m_Shape ) );
281  break;
282  }
283 
284  // DRAWSEGMENT items are not allowed on copper layers, so
285  // copper layers count is not taken in account in Flip transform
286  SetLayer( FlipLayer( GetLayer() ) );
287 }
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:485
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.

◆ Flip() [2/2]

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

Definition at line 286 of file class_board_item.h.

287  {
288  Flip( wxPoint( aCentre.x, aCentre.y ), aFlipLeftRight );
289  }
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.

◆ GetAngle()

◆ 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 380 of file class_drawsegment.cpp.

381 {
382  // due to the Y axis orient atan2 needs - y value
383  double angleStart = ArcTangente( GetArcStart().y - GetCenter().y,
384  GetArcStart().x - GetCenter().x );
385 
386  // Normalize it to 0 ... 360 deg, to avoid discontinuity for angles near 180 deg
387  // because 180 deg and -180 are very near angles when ampping betewwen -180 ... 180 deg.
388  // and this is not easy to handle in calculations
389  NORMALIZE_ANGLE_POS( angleStart );
390 
391  return angleStart;
392 }
const wxPoint GetCenter() const override
Function GetCenter()
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:257
const wxPoint & GetArcStart() const
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:162

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

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

◆ GetArcEnd()

const wxPoint DRAWSEGMENT::GetArcEnd ( ) const

Definition at line 336 of file class_drawsegment.cpp.

337 {
338  wxPoint endPoint( m_End ); // start of arc
339 
340  switch( m_Shape )
341  {
342  case S_ARC:
343  // rotate the starting point of the arc, given by m_End, through the
344  // angle m_Angle to get the ending point of the arc.
345  // m_Start is the arc centre
346  endPoint = m_End; // m_End = start point of arc
347  RotatePoint( &endPoint, m_Start, -m_Angle );
348  break;
349 
350  default:
351  break;
352  }
353 
354  return endPoint; // after rotation, the end of the arc.
355 }
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 GRID_HELPER::computeAnchors(), ConvertOutlineToPolygon(), findPoint(), EDIT_POINTS_FACTORY::Make(), POINT_EDITOR::updateItem(), and POINT_EDITOR::updatePoints().

◆ GetArcMid()

const wxPoint DRAWSEGMENT::GetArcMid ( ) const

Definition at line 358 of file class_drawsegment.cpp.

359 {
360  wxPoint endPoint( m_End );
361 
362  switch( m_Shape )
363  {
364  case S_ARC:
365  // rotate the starting point of the arc, given by m_End, through half
366  // the angle m_Angle to get the middle of the arc.
367  // m_Start is the arc centre
368  endPoint = m_End; // m_End = start point of arc
369  RotatePoint( &endPoint, m_Start, -m_Angle / 2.0 );
370  break;
371 
372  default:
373  break;
374  }
375 
376  return endPoint; // after rotation, the end of the arc.
377 }
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(), POINT_EDITOR::updateItem(), and POINT_EDITOR::updatePoints().

◆ GetArcStart()

◆ GetBezControl1()

◆ GetBezControl2()

◆ GetBezierPoints()

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

◆ 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 54 of file class_board_item.cpp.

55 {
56  if( Type() == PCB_T )
57  return (BOARD*) this;
58 
59  BOARD_ITEM* parent = GetParent();
60 
61  if( parent )
62  return parent->GetBoard();
63 
64  return NULL;
65 }
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:180
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(), DRC::checkClearanceSegmToPad(), TEXTE_PCB::Flip(), TRACK::Flip(), ARC::Flip(), VIA::Flip(), ZONE_CONTAINER::Flip(), BOARD_ITEM::GetBoard(), MODULE::GetBoundingPoly(), BOARD_CONNECTED_ITEM::GetClearance(), BOARD_CONNECTED_ITEM::GetEffectiveNetclass(), BOARD_ITEM::GetLayerName(), VIA::GetMinAnnulus(), PCB_DRAW_PANEL_GAL::GetMsgPanelInfo(), ZONE_CONTAINER::GetMsgPanelInfo(), TRACK::GetMsgPanelInfo(), NETINFO_ITEM::GetMsgPanelInfo(), VIA::GetMsgPanelInfo(), D_PAD::GetMsgPanelInfo(), TRACK::GetMsgPanelInfoBase_Common(), BOARD_CONNECTED_ITEM::GetNetClass(), BOARD_CONNECTED_ITEM::GetNetnameMsg(), GetRule(), VIA::GetSelectMenuText(), D_PAD::GetSelectMenuText(), ZONE_CONTAINER::GetSelectMenuText(), D_PAD::GetSolderMaskMargin(), D_PAD::GetSolderPasteMargin(), BOARD::GetTrackLength(), TRACK::GetWidthConstraints(), D_PAD::MergePrimitivesAsPolygon(), EAGLE_PLUGIN::packageWire(), PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), BOARD_CONNECTED_ITEM::SetNet(), BOARD_CONNECTED_ITEM::SetNetCode(), ZONE_CONTAINER::TransformOutlinesShapeWithClearanceToPolygon(), ZONE_CONTAINER::TransformSolidAreasShapesToPolygonSet(), 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 512 of file class_drawsegment.cpp.

513 {
514  EDA_RECT bbox;
515 
516  bbox.SetOrigin( m_Start );
517 
518  switch( m_Shape )
519  {
520  case S_RECT:
521  {
522  std::vector<wxPoint> pts;
523  GetRectCorners( &pts );
524 
525  bbox = EDA_RECT(); // re-init for merging
526 
527  for( wxPoint& pt : pts )
528  bbox.Merge( pt );
529  }
530  break;
531 
532  case S_SEGMENT:
533  bbox.SetEnd( m_End );
534  break;
535 
536  case S_CIRCLE:
537  bbox.Inflate( GetRadius() );
538  break;
539 
540  case S_ARC:
541  computeArcBBox( bbox );
542  break;
543 
544  case S_POLYGON:
545  if( m_Poly.IsEmpty() )
546  break;
547  {
548  MODULE* module = GetParentModule();
549  bbox = EDA_RECT(); // re-init for merging
550 
551  for( auto iter = m_Poly.CIterate(); iter; iter++ )
552  {
553  wxPoint pt ( iter->x, iter->y );
554 
555  if( module ) // Transform, if we belong to a module
556  {
557  RotatePoint( &pt, module->GetOrientation() );
558  pt += module->GetPosition();
559  }
560 
561  bbox.Merge( pt );
562  }
563  }
564  break;
565 
566  case S_CURVE:
567  bbox.Merge( m_BezierC1 );
568  bbox.Merge( m_BezierC2 );
569  bbox.Merge( m_End );
570  break;
571 
572  default:
573  wxFAIL_MSG( "DRAWSEGMENT::GetBoundingBox not implemented for "
574  + STROKE_T_asString( m_Shape ) );
575  break;
576  }
577 
578  bbox.Inflate( ((m_Width+1) / 2) + 1 );
579  bbox.Normalize();
580 
581  return bbox;
582 }
double GetOrientation() const
Definition: class_module.h:211
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
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.
int m_Width
thickness of lines ...
void GetRectCorners(std::vector< wxPoint > *pts) const
const wxPoint GetPosition() const override
Definition: class_module.h:206
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(), HitTest(), and DRC::testCopperDrawItem().

◆ GetCenter()

const 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 305 of file class_drawsegment.cpp.

306 {
307  wxPoint c;
308 
309  switch( m_Shape )
310  {
311  case S_ARC:
312  case S_CIRCLE:
313  c = m_Start;
314  break;
315 
316  case S_SEGMENT:
317  // Midpoint of the line
318  c = ( GetStart() + GetEnd() ) / 2;
319  break;
320 
321  case S_POLYGON:
322  case S_RECT:
323  case S_CURVE:
324  c = GetBoundingBox().Centre();
325  break;
326 
327  default:
328  wxFAIL_MSG( "DRAWSEGMENT::GetCentre not implemented for " + STROKE_T_asString( m_Shape ) );
329  break;
330  }
331 
332  return c;
333 }
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(), export_vrml_drawsegment(), GetArcAngleStart(), GetFocusPosition(), HitTest(), idf_export_outline(), GRAPHICS_CLEANER::isNullSegment(), EDIT_POINTS_FACTORY::Make(), MakeEffectiveShapes(), EAGLE_PLUGIN::packageRectangle(), PCB_PARSER::parseD_PAD(), DRC::testCopperDrawItem(), 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 252 of file class_drawsegment.h.

253  {
254  return wxT( "DRAWSEGMENT" );
255  }

◆ 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(), SCH_EDITOR_CONTROL::EditWithLibEdit(), SCH_COMPONENT::GetMsgPanelInfo(), 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_TARGET_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_EDIT_PIN::TransferDataFromWindow(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_LABEL_EDITOR::TransferDataFromWindow(), DIALOG_FOOTPRINT_BOARD_EDITOR::TransferDataFromWindow(), and SCH_EDIT_FRAME::TrimWire().

◆ GetEnd()

◆ 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 185 of file class_drawsegment.h.

186  {
187  return GetCenter();
188  }
const wxPoint GetCenter() const override
Function GetCenter()

References GetCenter().

◆ GetLayer()

virtual PCB_LAYER_ID BOARD_ITEM::GetLayer ( ) const
inlinevirtualinherited

Function GetLayer returns the primary layer this item is on.

Reimplemented in ZONE_CONTAINER.

Definition at line 142 of file class_board_item.h.

142 { return m_Layer; }
PCB_LAYER_ID m_Layer

References BOARD_ITEM::m_Layer.

Referenced by CN_LIST::Add(), BOARD_ADAPTER::AddGraphicsShapesWithClearanceToContainer(), DIMENSION::AdjustDimensionDetails(), GRAPHICS_CLEANER::areEquivalent(), AR_AUTOPLACER::buildFpAreas(), TRACKS_CLEANER::cleanupSegments(), CreateBoardSection(), MICROWAVE_TOOL::createMicrowaveInductor(), PCB_BASE_FRAME::CreateNewModule(), CreateRoutesSection(), DIALOG_GRAPHIC_ITEM_PROPERTIES::DIALOG_GRAPHIC_ITEM_PROPERTIES(), DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES(), DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES(), DRC::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(), EDGE_MODULE::Flip(), TRACK::Flip(), TEXTE_MODULE::Flip(), DIMENSION::Flip(), Flip(), MODULE::Flip(), ARC::Flip(), PCB_IO::FootprintSave(), FootprintWriteShape(), PCB_IO::formatLayer(), DSN::SPECCTRA_DB::FromBOARD(), AR_AUTOPLACER::genModuleOnRoutingMatrix(), BOARD_CONNECTED_ITEM::GetClearance(), ZONE_CONTAINER::GetLayer(), DRC::GetLocation(), getMatchingTextItem(), AR_AUTOPLACER::getOptimalModulePlacement(), BOARD::GetPad(), TEXT_MOD_GRID_TABLE::GetValueAsLong(), SELECTION_TOOL::GuessSelectionCandidates(), idf_export_module(), GENERAL_COLLECTOR::Inspect(), PCB_LAYER_COLLECTOR::Inspect(), D_PAD::IsFlipped(), BOARD_ITEM::IsOnCopperLayer(), EDGE_MODULE::IsParentFlipped(), TEXTE_MODULE::IsParentFlipped(), itemIsIncludedByFilter(), FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD(), DIALOG_FOOTPRINT_FP_EDITOR::OnAddField(), DIALOG_FOOTPRINT_BOARD_EDITOR::OnAddField(), 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(), 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::testCopperDrawItem(), DRC::testCopperTextAndGraphics(), DRC::testDisabledLayers(), AR_AUTOPLACER::testModuleOnBoard(), TEXTE_MODULE::TEXTE_MODULE(), DIALOG_FOOTPRINT_BOARD_EDITOR::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataToWindow(), DIALOG_FOOTPRINT_BOARD_EDITOR::TransferDataToWindow(), BOARD_ADAPTER::transformGraphicModuleEdgeToPolygonSet(), MODULE::TransformGraphicShapesWithClearanceToPolygonSet(), 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 68 of file class_board_item.cpp.

69 {
70  BOARD* board = GetBoard();
71 
72  if( board )
73  return board->GetLayerName( m_Layer );
74 
75  // If no parent, return standard name
77 }
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:180
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:648

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(), TEXTE_MODULE::GetSelectMenuText(), DIMENSION::GetSelectMenuText(), GetSelectMenuText(), MODULE::GetSelectMenuText(), TEXTE_PCB::GetShownText(), TEXT_MOD_GRID_TABLE::GetValue(), MODULE::ResolveTextVar(), and DRC::testDisabledLayers().

◆ GetLayerSet()

virtual LSET BOARD_ITEM::GetLayerSet ( ) const
inlinevirtualinherited

Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segment or VIA physically resides.

Returns
int - a layer mask, see layers_id_colors_visibility.h.

Reimplemented in VIA, D_PAD, and ZONE_CONTAINER.

Definition at line 150 of file class_board_item.h.

150 { return LSET( m_Layer ); }
PCB_LAYER_ID m_Layer
LSET is a set of PCB_LAYER_IDs.

References BOARD_ITEM::m_Layer.

Referenced by GRID_HELPER::BestSnapAnchor(), build_pad_testpoints(), DRC::doTrackDrc(), DRAWING_TOOL::DrawVia(), GetRule(), and hash_board_item().

◆ 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 75 of file class_drawsegment.cpp.

76 {
77  double length = 0.0;
78 
79  switch( m_Shape )
80  {
81  case S_CURVE:
82  for( size_t ii = 1; ii < m_BezierPoints.size(); ++ii )
83  length += GetLineLength( m_BezierPoints[ii - 1], m_BezierPoints[ii] );
84 
85  break;
86 
87  case S_SEGMENT:
88  length = GetLineLength( GetStart(), GetEnd() );
89  break;
90 
91  default:
92  wxASSERT_MSG( false, "DRAWSEGMENT::GetLength not implemented for shape"
93  + ShowShape( GetShape() ) );
94  break;
95  }
96 
97  return length;
98 }
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:206
STROKE_T GetShape() const
usual segment : line with rounded ends
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
STROKE_T m_Shape
Shape: line, Circle, Arc.
Bezier Curve.
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
std::vector< wxPoint > m_BezierPoints

References GetEnd(), GetLineLength(), GetShape(), GetStart(), m_BezierPoints, m_Shape, S_CURVE, S_SEGMENT, 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 881 of file class_drawsegment.cpp.

882 {
883  return add_dashed_line_xpm;
884 }
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 411 of file class_drawsegment.cpp.

412 {
413  EDA_UNITS units = aFrame->GetUserUnits();
414  wxString msg;
415 
416  msg = _( "Drawing" );
417 
418  aList.emplace_back( _( "Type" ), msg, DARKCYAN );
419 
420  wxString shape = _( "Shape" );
421 
422  switch( m_Shape )
423  {
424  case S_CIRCLE:
425  aList.emplace_back( shape, _( "Circle" ), RED );
426 
427  msg = MessageTextFromValue( units, GetLineLength( m_Start, m_End ) );
428  aList.emplace_back( _( "Radius" ), msg, RED );
429  break;
430 
431  case S_ARC:
432  aList.emplace_back( shape, _( "Arc" ), RED );
433  msg.Printf( wxT( "%.1f" ), m_Angle / 10.0 );
434  aList.emplace_back( _( "Angle" ), msg, RED );
435 
436  msg = MessageTextFromValue( units, GetLineLength( m_Start, m_End ) );
437  aList.emplace_back( _( "Radius" ), msg, RED );
438  break;
439 
440  case S_CURVE:
441  aList.emplace_back( shape, _( "Curve" ), RED );
442 
443  msg = MessageTextFromValue( units, GetLength() );
444  aList.emplace_back( _( "Length" ), msg, DARKGREEN );
445  break;
446 
447  case S_POLYGON:
448  aList.emplace_back( shape, _( "Polygon" ), RED );
449 
450  msg.Printf( "%d", GetPolyShape().Outline(0).PointCount() );
451  aList.emplace_back( _( "Points" ), msg, DARKGREEN );
452  break;
453 
454  case S_RECT:
455  aList.emplace_back( shape, _( "Rectangle" ), RED );
456 
457  msg = MessageTextFromValue( units, std::abs( m_End.x - m_Start.x ) );
458  aList.emplace_back( _( "Width" ), msg, DARKGREEN );
459 
460  msg = MessageTextFromValue( units, std::abs( m_End.y - m_Start.y ) );
461  aList.emplace_back( _( "Height" ), msg, DARKGREEN );
462  break;
463 
464  case S_SEGMENT:
465  {
466  aList.emplace_back( shape, _( "Segment" ), RED );
467 
468  msg = MessageTextFromValue( units, GetLineLength( m_Start, m_End ) );
469  aList.emplace_back( _( "Length" ), msg, DARKGREEN );
470 
471  // angle counter-clockwise from 3'o-clock
472  const double deg = RAD2DEG( atan2( (double)( m_Start.y - m_End.y ),
473  (double)( m_End.x - m_Start.x ) ) );
474  msg.Printf( wxT( "%.1f" ), deg );
475  aList.emplace_back( _( "Angle" ), msg, DARKGREEN );
476  }
477  break;
478 
479  default:
480  aList.emplace_back( shape, _( "Unrecognized" ), RED );
481  break;
482  }
483 
484  if( m_Shape == S_POLYGON )
485  {
486  VECTOR2I point0 = GetPolyShape().Outline(0).CPoint(0);
487  wxString origin = wxString::Format( "@(%s, %s)",
488  MessageTextFromValue( units, point0.x ),
489  MessageTextFromValue( units, point0.y ) );
490 
491  aList.emplace_back( _( "Origin" ), origin, DARKGREEN );
492  }
493  else
494  {
495  wxString start = wxString::Format( "@(%s, %s)",
496  MessageTextFromValue( units, GetStart().x ),
497  MessageTextFromValue( units, GetStart().y ) );
498  wxString end = wxString::Format( "@(%s, %s)",
499  MessageTextFromValue( units, GetEnd().x ),
500  MessageTextFromValue( units, GetEnd().y ) );
501 
502  aList.emplace_back( start, end, DARKGREEN );
503  }
504 
505  aList.emplace_back( _( "Layer" ), GetLayerName(), DARKBROWN );
506 
507  msg = MessageTextFromValue( units, m_Width, true );
508  aList.emplace_back( _( "Width" ), msg, DARKCYAN );
509 }
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:206
polygon (not yet used for tracks, but could be in microwave apps)
double RAD2DEG(double rad)
Definition: trigo.h:215
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:205
#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 ...
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(), 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, 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 136 of file class_board_item.h.

136 { 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(), EDGE_MODULE::GetSelectMenuText(), 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(), SELECTION_TOOL::select(), SELECTION_TOOL::Selectable(), SwapItemData(), DRC::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 402 of file class_drawsegment.cpp.

403 {
404  if( !m_Parent || m_Parent->Type() != PCB_MODULE_T )
405  return NULL;
406 
407  return (MODULE*) m_Parent;
408 }
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 1152 of file class_drawsegment.cpp.

1153 {
1154  // return the number of corners of the polygonal shape
1155  // this shape is expected to be only one polygon without hole
1156  if( GetPolyShape().OutlineCount() )
1157  return GetPolyShape().VertexCount( 0 );
1158 
1159  return 0;
1160 }
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 214 of file class_drawsegment.h.

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

References m_Poly.

◆ GetPosition()

const wxPoint DRAWSEGMENT::GetPosition ( ) const
overridevirtual

Reimplemented from EDA_ITEM.

Definition at line 66 of file class_drawsegment.cpp.

67 {
68  if( m_Shape == S_POLYGON )
69  return (wxPoint) m_Poly.CVertex( 0 );
70  else
71  return m_Start;
72 }
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 166 of file class_drawsegment.h.

167  {
168  double radius = GetLineLength( m_Start, m_End );
169 
170  // don't allow degenerate arcs
171  return std::max( 1, KiROUND( radius ) );
172  }
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:206
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(), 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()

void DRAWSEGMENT::GetRectCorners ( std::vector< wxPoint > *  pts) const

Definition at line 909 of file class_drawsegment.cpp.

910 {
911  MODULE* module = GetParentModule();
912  wxPoint topLeft = GetStart();
913  wxPoint botRight = GetEnd();
914 
915  // Un-rotate rect topLeft and botRight
916  if( module && KiROUND( module->GetOrientation() ) % 900 != 0 )
917  {
918  topLeft -= module->GetPosition();
919  RotatePoint( &topLeft, -module->GetOrientation() );
920 
921  botRight -= module->GetPosition();
922  RotatePoint( &botRight, -module->GetOrientation() );
923  }
924 
925  // Set up the un-rotated 4 corners
926  pts->emplace_back( topLeft );
927  pts->emplace_back( botRight.x, topLeft.y );
928  pts->emplace_back( botRight );
929  pts->emplace_back( topLeft.x, botRight.y );
930 
931  // Now re-rotate the 4 corners to get a diamond
932  if( module && KiROUND( module->GetOrientation() ) % 900 != 0 )
933  {
934  for( wxPoint& pt : *pts )
935  {
936  RotatePoint( &pt,module->GetOrientation() );
937  pt += module->GetPosition();
938  }
939  }
940 }
double GetOrientation() const
Definition: class_module.h:211
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.
const wxPoint GetPosition() const override
Definition: class_module.h:206

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::PlotFootprintGraphicItem(), DRC::testCopperDrawItem(), 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 873 of file class_drawsegment.cpp.

874 {
875  return wxString::Format( _( "Pcb Graphic %s on %s" ),
876  ShowShape( m_Shape ),
877  GetLayerName() );
878 }
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:205
#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()

◆ GetStart()

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

Referenced by PCB_IO::format().

◆ GetType()

int DRAWSEGMENT::GetType ( ) const
inline

Definition at line 113 of file class_drawsegment.h.

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

References m_Type.

Referenced by hash_eda().

◆ GetWidth()

◆ 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 585 of file class_drawsegment.cpp.

586 {
587  int maxdist = aAccuracy + ( m_Width / 2 );
588 
589  switch( m_Shape )
590  {
591  case S_CIRCLE:
592  {
593  int radius = GetRadius();
594  int dist = KiROUND( EuclideanNorm( aPosition - GetCenter() ) );
595 
596  if( m_Width == 0 ) // Filled circle hit-test
597  {
598  if( dist <= radius + maxdist )
599  return true;
600  }
601  else // Ring hit-test
602  {
603  if( abs( radius - dist ) <= maxdist )
604  return true;
605  }
606  }
607  break;
608 
609  case S_ARC:
610  {
611  wxPoint relPos = aPosition - GetCenter();
612  int radius = GetRadius();
613  int dist = KiROUND( EuclideanNorm( relPos ) );
614 
615  if( abs( radius - dist ) <= maxdist )
616  {
617  // For arcs, the test point angle must be >= arc angle start
618  // and <= arc angle end
619  // However angle values > 360 deg are not easy to handle
620  // so we calculate the relative angle between arc start point and teast point
621  // this relative arc should be < arc angle if arc angle > 0 (CW arc)
622  // and > arc angle if arc angle < 0 (CCW arc)
623  double arc_angle_start = GetArcAngleStart(); // Always 0.0 ... 360 deg, in 0.1 deg
624 
625  double arc_hittest = ArcTangente( relPos.y, relPos.x );
626 
627  // Calculate relative angle between the starting point of the arc, and the test point
628  arc_hittest -= arc_angle_start;
629 
630  // Normalise arc_hittest between 0 ... 360 deg
631  NORMALIZE_ANGLE_POS( arc_hittest );
632 
633  // Check angle: inside the arc angle when it is > 0
634  // and outside the not drawn arc when it is < 0
635  if( GetAngle() >= 0.0 )
636  {
637  if( arc_hittest <= GetAngle() )
638  return true;
639  }
640  else
641  {
642  if( arc_hittest >= (3600.0 + GetAngle()) )
643  return true;
644  }
645  }
646  }
647  break;
648 
649  case S_CURVE:
650  ((DRAWSEGMENT*)this)->RebuildBezierToSegmentsPointsList( m_Width );
651 
652  for( unsigned int i= 1; i < m_BezierPoints.size(); i++)
653  {
654  if( TestSegmentHit( aPosition, m_BezierPoints[i-1], m_BezierPoints[i], maxdist ) )
655  return true;
656  }
657  break;
658 
659  case S_SEGMENT:
660  if( TestSegmentHit( aPosition, m_Start, m_End, maxdist ) )
661  return true;
662  break;
663 
664  case S_RECT:
665  {
666  std::vector<wxPoint> pts;
667  GetRectCorners( &pts );
668 
669  if( m_Width == 0 ) // Filled rect hit-test
670  {
671  SHAPE_POLY_SET poly;
672  poly.NewOutline();
673 
674  for( const wxPoint& pt : pts )
675  poly.Append( pt );
676 
677  if( poly.Collide( VECTOR2I( aPosition ), maxdist ) )
678  return true;
679  }
680  else // Open rect hit-test
681  {
682  if( TestSegmentHit( aPosition, pts[0], pts[1], maxdist )
683  || TestSegmentHit( aPosition, pts[1], pts[2], maxdist )
684  || TestSegmentHit( aPosition, pts[2], pts[3], maxdist )
685  || TestSegmentHit( aPosition, pts[3], pts[0], maxdist ) )
686  {
687  return true;
688  }
689  }
690  }
691  break;
692 
693  case S_POLYGON:
694  {
695  if( !IsPolygonFilled() )
696  {
698  return m_Poly.CollideEdge( VECTOR2I( aPosition ), dummy, maxdist );
699  }
700  else
701  return m_Poly.Collide( VECTOR2I( aPosition ), maxdist );
702  }
703  break;
704 
705  default:
706  wxFAIL_MSG( "DRAWSEGMENT::HitTest (point) not implemented for "
707  + STROKE_T_asString( m_Shape ) );
708  break;
709  }
710 
711  return false;
712 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:128
const wxPoint GetCenter() const override
Function GetCenter()
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:257
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
double dist(const double ax, const double ay, const double bx, const double by)
Definition: delauney.h:168
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_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
void GetRectCorners(std::vector< wxPoint > *pts) const
bool IsPolygonFilled() const
Polygonal shape is not always filled.
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(), dist(), 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 DRC::doTrackDrc(), and 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 715 of file class_drawsegment.cpp.

716 {
717  EDA_RECT arect = aRect;
718  arect.Normalize();
719  arect.Inflate( aAccuracy );
720 
721  EDA_RECT arcRect;
722  EDA_RECT bb = GetBoundingBox();
723 
724  switch( m_Shape )
725  {
726  case S_CIRCLE:
727  // Test if area intersects or contains the circle:
728  if( aContained )
729  return arect.Contains( bb );
730  else
731  {
732  // If the rectangle does not intersect the bounding box, this is a much quicker test
733  if( !aRect.Intersects( bb ) )
734  {
735  return false;
736  }
737  else
738  {
739  return arect.IntersectsCircleEdge( GetCenter(), GetRadius(), GetWidth() );
740  }
741  }
742  break;
743 
744  case S_ARC:
745  // Test for full containment of this arc in the rect
746  if( aContained )
747  {
748  return arect.Contains( bb );
749  }
750  // Test if the rect crosses the arc
751  else
752  {
753  arcRect = bb.Common( arect );
754 
755  /* All following tests must pass:
756  * 1. Rectangle must intersect arc BoundingBox
757  * 2. Rectangle must cross the outside of the arc
758  */
759  return arcRect.Intersects( arect ) &&
761  }
762  break;
763 
764  case S_RECT:
765  if( aContained )
766  {
767  return arect.Contains( bb );
768  }
769  else
770  {
771  std::vector<wxPoint> pts;
772  GetRectCorners( &pts );
773 
774  // Account for the width of the lines
775  arect.Inflate( GetWidth() / 2 );
776  return ( arect.Intersects( pts[0], pts[1] )
777  || arect.Intersects( pts[1], pts[2] )
778  || arect.Intersects( pts[2], pts[3] )
779  || arect.Intersects( pts[3], pts[0] ) );
780  }
781 
782  break;
783 
784  case S_SEGMENT:
785  if( aContained )
786  {
787  return arect.Contains( GetStart() ) && aRect.Contains( GetEnd() );
788  }
789  else
790  {
791  // Account for the width of the line
792  arect.Inflate( GetWidth() / 2 );
793  return arect.Intersects( GetStart(), GetEnd() );
794  }
795 
796  break;
797 
798  case S_POLYGON:
799  if( aContained )
800  {
801  return arect.Contains( bb );
802  }
803  else
804  {
805  // Fast test: if aRect is outside the polygon bounding box,
806  // rectangles cannot intersect
807  if( !arect.Intersects( bb ) )
808  return false;
809 
810  // Account for the width of the line
811  arect.Inflate( GetWidth() / 2 );
812  int count = m_Poly.TotalVertices();
813 
814  for( int ii = 0; ii < count; ii++ )
815  {
816  auto vertex = m_Poly.CVertex( ii );
817  auto vertexNext = m_Poly.CVertex( ( ii + 1 ) % count );
818 
819  // Test if the point is within aRect
820  if( arect.Contains( ( wxPoint ) vertex ) )
821  return true;
822 
823  // Test if this edge intersects aRect
824  if( arect.Intersects( ( wxPoint ) vertex, ( wxPoint ) vertexNext ) )
825  return true;
826  }
827  }
828  break;
829 
830  case S_CURVE:
831  if( aContained )
832  {
833  return arect.Contains( bb );
834  }
835  else
836  {
837  // Fast test: if aRect is outside the polygon bounding box,
838  // rectangles cannot intersect
839  if( !arect.Intersects( bb ) )
840  return false;
841 
842  // Account for the width of the line
843  arect.Inflate( GetWidth() / 2 );
844  unsigned count = m_BezierPoints.size();
845 
846  for( unsigned ii = 1; ii < count; ii++ )
847  {
848  wxPoint vertex = m_BezierPoints[ii-1];
849  wxPoint vertexNext = m_BezierPoints[ii];
850 
851  // Test if the point is within aRect
852  if( arect.Contains( ( wxPoint ) vertex ) )
853  return true;
854 
855  // Test if this edge intersects aRect
856  if( arect.Intersects( vertex, vertexNext ) )
857  return true;
858  }
859  }
860  break;
861 
862 
863  default:
864  wxFAIL_MSG( "DRAWSEGMENT::HitTest (rect) not implemented for "
865  + STROKE_T_asString( m_Shape ) );
866  break;
867  }
868 
869  return false;
870 }
int TotalVertices() const
Returns total number of vertices stored in the set.
const wxPoint GetCenter() const override
Function GetCenter()
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
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.
void GetRectCorners(std::vector< wxPoint > *pts) const
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
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()

bool EDA_ITEM::IsBrightened ( ) const
inlineinherited

◆ 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 118 of file class_board_item.h.

119  {
120  return false;
121  }

Referenced by GetRule(), 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().

◆ 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 215 of file class_board_item.h.

216  {
217  // only MODULEs & TRACKs can be locked at this time.
218  return false;
219  }

Referenced by 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 126 of file class_board_item.h.

127  {
128  return IsCopperLayer( GetLayer() );
129  }
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 MARKER_PCB.

Definition at line 195 of file class_board_item.h.

196  {
197  return m_Layer == aLayer;
198  }
PCB_LAYER_ID m_Layer

References BOARD_ITEM::m_Layer.

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

◆ 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 1140 of file class_drawsegment.cpp.

1141 {
1142  // return true if the polygonal shape is valid (has more than 2 points)
1143  if( GetPolyShape().OutlineCount() == 0 )
1144  return false;
1145 
1146  const SHAPE_LINE_CHAIN& outline = ((SHAPE_POLY_SET&)GetPolyShape()).Outline( 0 );
1147 
1148  return outline.PointCount() > 2;
1149 }
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 501 of file base_struct.h.

501 { 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 206 of file class_board_item.h.

207  {
208  return ( Type() == PCB_TRACE_T ) || ( Type() == PCB_VIA_T );
209  }
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 80 of file class_drawsegment.h.

81  {
82  if( BOARD_ITEM::IsType( aScanTypes ) )
83  return true;
84 
85  for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
86  {
87  if( *p == PCB_LOCATE_GRAPHIC_T )
88  return true;
89  else if( *p == PCB_LOCATE_BOARD_EDGE_T )
90  return m_Layer == Edge_Cuts;
91  }
92 
93  return false;
94  }
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 383 of file base_struct.h.

387  {
388  for( auto it : aList )
389  {
390  if( static_cast<EDA_ITEM*>( it )->Visit( inspector, testData, scanTypes )
392  return SEARCH_RESULT::QUIT;
393  }
394 
396  }
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(), and BOARD::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 404 of file base_struct.h.

406  {
407  for( auto it : aList )
408  {
409  if( static_cast<EDA_ITEM*>( it )->Visit( inspector, testData, scanTypes )
411  return SEARCH_RESULT::QUIT;
412  }
413 
415  }
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 BOARD aBoard,
LSET  aMask 
)
staticprotectedinherited

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

Definition at line 80 of file class_board_item.cpp.

81 {
82  // Try to be smart and useful. Check all copper first.
83  if( aMask[F_Cu] && aMask[B_Cu] )
84  return _( "All copper layers" );
85 
86  // Check for copper.
87  auto layer = aBoard->GetEnabledLayers().AllCuMask() & aMask;
88 
89  for( int i = 0; i < 3; i++ )
90  {
91  for( int bit = PCBNEW_LAYER_ID_START; bit < PCB_LAYER_ID_COUNT; ++bit )
92  {
93  if( layer[ bit ] )
94  {
95  wxString layerInfo = aBoard->GetLayerName( static_cast<PCB_LAYER_ID>( bit ) );
96 
97  if( aMask.count() > 1 )
98  layerInfo << _( " and others" );
99 
100  return layerInfo;
101  }
102  }
103 
104  // No copper; first, check for technicals and then for all layers.
105  if( i < 1 ) // first, check for technicals
106  layer = aBoard->GetEnabledLayers().AllTechMask() & aMask;
107  else // then check for all other layers
108  layer = aMask;
109  }
110 
111  // No copper, no technicals: no layer
112  return _( "no layers" );
113 }
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:712
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:782
#define _(s)
Definition: 3d_actions.cpp:33

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

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

◆ MakeEffectiveShapes()

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

Makes a set of SHAPE objects representing the DRAWSEGMENT.

Caller owns the objects.

Definition at line 1017 of file class_drawsegment.cpp.

1018 {
1019  std::vector<SHAPE*> effectiveShapes;
1020 
1021  switch( m_Shape )
1022  {
1023  case S_ARC:
1024  {
1025  SHAPE_ARC arc( GetCenter(), GetArcStart(), (double) GetAngle() / 10.0 );
1026  SHAPE_LINE_CHAIN l = arc.ConvertToPolyline();
1027 
1028  for( int i = 0; i < l.SegmentCount(); i++ )
1029  {
1030  effectiveShapes.emplace_back( new SHAPE_SEGMENT( l.Segment( i ).A,
1031  l.Segment( i ).B, m_Width ) );
1032  }
1033 
1034  break;
1035  }
1036 
1037  case S_SEGMENT:
1038  effectiveShapes.emplace_back( new SHAPE_SEGMENT( GetStart(), GetEnd(), m_Width ) );
1039  break;
1040 
1041  case S_RECT:
1042  {
1043  std::vector<wxPoint> pts;
1044  GetRectCorners( &pts );
1045 
1046  if( m_Width == 0 )
1047  {
1048  effectiveShapes.emplace_back( new SHAPE_SIMPLE( pts ) );
1049  }
1050  else
1051  {
1052  effectiveShapes.emplace_back( new SHAPE_SEGMENT( pts[0], pts[1], m_Width ) );
1053  effectiveShapes.emplace_back( new SHAPE_SEGMENT( pts[1], pts[2], m_Width ) );
1054  effectiveShapes.emplace_back( new SHAPE_SEGMENT( pts[2], pts[3], m_Width ) );
1055  effectiveShapes.emplace_back( new SHAPE_SEGMENT( pts[3], pts[0], m_Width ) );
1056  }
1057  }
1058  break;
1059 
1060  case S_CIRCLE:
1061  {
1062  if( m_Width == 0 )
1063  {
1064  effectiveShapes.emplace_back( new SHAPE_CIRCLE( GetCenter(), GetRadius() ) );
1065  }
1066  else
1067  {
1068  // SHAPE_CIRCLE has no ConvertToPolyline() method, so use a 360.0 SHAPE_ARC
1069  SHAPE_ARC circle( GetCenter(), GetEnd(), 360.0 );
1070  SHAPE_LINE_CHAIN l = circle.ConvertToPolyline();
1071 
1072  for( int i = 0; i < l.SegmentCount(); i++ )
1073  {
1074  effectiveShapes.emplace_back( new SHAPE_SEGMENT( l.Segment( i ).A,
1075  l.Segment( i ).B, m_Width ) );
1076  }
1077  }
1078 
1079  break;
1080  }
1081 
1082  case S_CURVE:
1083  {
1085  wxPoint start_pt = GetBezierPoints()[0];
1086 
1087  for( unsigned int jj = 1; jj < GetBezierPoints().size(); jj++ )
1088  {
1089  wxPoint end_pt = GetBezierPoints()[jj];
1090  effectiveShapes.emplace_back( new SHAPE_SEGMENT( start_pt, end_pt, m_Width ) );
1091  start_pt = end_pt;
1092  }
1093 
1094  break;
1095  }
1096 
1097  case S_POLYGON:
1098  {
1100 
1101  if( IsPolygonFilled() )
1102  {
1103  effectiveShapes.emplace_back( new SHAPE_SIMPLE( l ) );
1104  }
1105  else
1106  {
1107  for( int i = 0; i < l.SegmentCount(); i++ )
1108  effectiveShapes.emplace_back( new SHAPE_SEGMENT( l.Segment( i ) ) );
1109  }
1110  }
1111  break;
1112 
1113  default:
1114  wxFAIL_MSG( "DRAWSEGMENT::MakeEffectiveShapes unsupported DRAWSEGMENT shape: "
1115  + STROKE_T_asString( m_Shape ) );
1116  break;
1117  }
1118 
1119  return effectiveShapes;
1120 }
SHAPE_SIMPLE.
Definition: shape_simple.h:42
const wxPoint GetCenter() const override
Function GetCenter()
polygon (not yet used for tracks, but could be in microwave apps)
void RebuildBezierToSegmentsPointsList(int aMinSegLen)
Rebuild the m_BezierPoints vertex list that approximate the Bezier curve by a list of segments Has me...
usual segment : line with rounded ends
const std::vector< wxPoint > & GetBezierPoints() const
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
segment with non rounded ends
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.
const wxPoint & GetArcStart() const
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
static wxString STROKE_T_asString(STROKE_T a)
double GetAngle() const
SEG Segment(int aIndex)
Function Segment()
SHAPE_LINE_CHAIN.
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 ...
void GetRectCorners(std::vector< wxPoint > *pts) const
bool IsPolygonFilled() const
Polygonal shape is not always filled.
VECTOR2I B
Definition: seg.h:48

References SEG::A, SEG::B, SHAPE_ARC::ConvertToPolyline(), GetAngle(), GetArcStart(), GetBezierPoints(), GetCenter(), GetEnd(), GetPolyShape(), GetRadius(), GetRectCorners(), GetStart(), GetWidth(), IsPolygonFilled(), m_Shape, m_Width, SHAPE_POLY_SET::Outline(), RebuildBezierToSegmentsPointsList(), 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 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, LIB_PIN, SCH_PIN, TEXTE_MODULE, SCH_MARKER, MARKER_PCB, and TEXTE_PCB.

Definition at line 457 of file base_struct.h.

458  {
459  return false;
460  }

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

◆ 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 143 of file base_struct.cpp.

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

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

◆ Move() [1/2]

void BOARD_ITEM::Move ( const VECTOR2I aMoveVector)
inlineinherited

Definition at line 254 of file class_board_item.h.

255  {
256  Move( wxPoint( aMoveVector.x, aMoveVector.y ) );
257  }
virtual void Move(const wxPoint &aMoveVector)
Function Move move this object.

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

◆ Move() [2/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 101 of file class_drawsegment.cpp.

102 {
103  // Move vector should not affect start/end for polygon since it will
104  // be applied directly to polygon outline.
105  if( m_Shape != S_POLYGON )
106  {
107  m_Start += aMoveVector;
108  m_End += aMoveVector;
109  }
110 
111  switch ( m_Shape )
112  {
113  case S_POLYGON:
114  m_Poly.Move( VECTOR2I( aMoveVector ) );
115  break;
116 
117  case S_CURVE:
118  m_BezierC1 += aMoveVector;
119  m_BezierC2 += aMoveVector;
120 
121  for( wxPoint& pt : m_BezierPoints)
122  pt += aMoveVector;
123 
124  break;
125 
126  default:
127  break;
128  }
129 }
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_End
Line end point or circle and arc start point.
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, SHAPE_POLY_SET::Move(), S_CURVE, and S_POLYGON.

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

◆ operator<()

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

Test if another item is less than this object.

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

Definition at line 197 of file base_struct.cpp.

198 {
199  wxFAIL_MSG( wxString::Format( wxT( "Less than operator not defined for item type %s." ),
200  GetChars( GetClass() ) ) );
201 
202  return false;
203 }
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:205

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 290 of file class_drawsegment.cpp.

291 {
292  // Has meaning only for S_CURVE DRAW_SEGMENT shape
293  if( m_Shape != S_CURVE )
294  {
295  m_BezierPoints.clear();
296  return;
297  }
298  // Rebuild the m_BezierPoints vertex list that approximate the Bezier curve
299  std::vector<wxPoint> ctrlPoints = { m_Start, m_BezierC1, m_BezierC2, m_End };
300  BEZIER_POLY converter( ctrlPoints );
301  converter.GetPoly( m_BezierPoints, aMinSegLen );
302 }
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.
STROKE_T m_Shape
Shape: line, Circle, Arc.
Bezier Curve.
Bezier curves to polygon converter.
Definition: bezier_curves.h:35
wxPoint m_BezierC2
Bezier Control Point 2.
std::vector< wxPoint > m_BezierPoints

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

Referenced by ConvertOutlineToPolygon(), EDGE_MODULE::Flip(), GRAPHICS_CLEANER::isNullSegment(), MakeEffectiveShapes(), EDGE_MODULE::SetDrawCoord(), DRC::testCopperDrawItem(), 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 170 of file base_struct.cpp.

171 {
172  wxString searchString = (aSearchData.GetFlags() & wxFR_MATCHCASE) ? aText : aText.Upper();
173 
174  int result = searchString.Find( (aSearchData.GetFlags() & wxFR_MATCHCASE) ?
175  aSearchData.GetFindString() :
176  aSearchData.GetFindString().Upper() );
177 
178  if( result == wxNOT_FOUND )
179  return false;
180 
181  wxString prefix = aText.Left( result );
182  wxString suffix;
183 
184  if( aSearchData.GetFindString().length() + result < aText.length() )
185  suffix = aText.Right( aText.length() - ( aSearchData.GetFindString().length() + result ) );
186 
187  wxLogTrace( traceFindReplace, wxT( "Replacing '%s', prefix '%s', replace '%s', suffix '%s'." ),
188  GetChars( aText ), GetChars( prefix ), GetChars( aSearchData.GetReplaceString() ),
189  GetChars( suffix ) );
190 
191  aText = prefix + aSearchData.GetReplaceString() + suffix;
192 
193  return true;
194 }
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, and SCH_FIELD.

Definition at line 489 of file base_struct.h.

489 { 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 178 of file class_drawsegment.cpp.

179 {
180  switch( m_Shape )
181  {
182  case S_ARC:
183  case S_SEGMENT:
184  case S_CIRCLE:
185  // these can all be done by just rotating the start and end points
186  RotatePoint( &m_Start, aRotCentre, aAngle);
187  RotatePoint( &m_End, aRotCentre, aAngle);
188  break;
189 
190  case S_RECT:
191  if( KiROUND( aAngle ) % 900 == 0 )
192  {
193  RotatePoint( &m_Start, aRotCentre, aAngle );
194  RotatePoint( &m_End, aRotCentre, aAngle );
195  break;
196  }
197 
198  // Convert non-cartesian-rotated rect to a diamond
199  m_Shape = S_POLYGON;
201  m_Poly.NewOutline();
202  m_Poly.Append( m_Start );
204  m_Poly.Append( m_End );
206 
208 
209  case S_POLYGON:
210  m_Poly.Rotate( -DECIDEG2RAD( aAngle ), VECTOR2I( aRotCentre ) );
211  break;
212 
213  case S_CURVE:
214  RotatePoint( &m_Start, aRotCentre, aAngle);
215  RotatePoint( &m_End, aRotCentre, aAngle);
216  RotatePoint( &m_BezierC1, aRotCentre, aAngle);
217  RotatePoint( &m_BezierC2, aRotCentre, aAngle);
218 
219  for( wxPoint& pt : m_BezierPoints )
220  RotatePoint( &pt, aRotCentre, aAngle);
221 
222  break;
223 
224  default:
225  wxFAIL_MSG( "DRAWSEGMENT::Rotate not implemented for " + STROKE_T_asString( m_Shape ) );
226  break;
227  }
228 }
#define KI_FALLTHROUGH
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
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_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:218
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, 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 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 270 of file class_board_item.h.

271  {
272  Rotate( wxPoint( aRotCentre.x, aRotCentre.y ), aAngle );
273  }
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 132 of file class_drawsegment.cpp.

133 {
134  auto scalePt = [&]( wxPoint& pt )
135  {
136  pt.x = KiROUND( pt.x * aScale );
137  pt.y = KiROUND( pt.y * aScale );
138  };
139 
140  int radius = GetRadius();
141 
142  scalePt( m_Start );
143  scalePt( m_End );
144 
145  // specific parameters:
146  switch( m_Shape )
147  {
148  case S_CURVE:
149  scalePt( m_BezierC1 );
150  scalePt( m_BezierC2 );
151  break;
152 
153  case S_CIRCLE: // ring or circle
154  m_End.x = m_Start.x + KiROUND( radius * aScale );
155  m_End.y = m_Start.y;
156  break;
157 
158  case S_POLYGON: // polygon
159  {
160  std::vector<wxPoint> pts;
161 
162  for( const VECTOR2I& pt : m_Poly.Outline( 0 ).CPoints() )
163  {
164  pts.emplace_back( pt );
165  scalePt( pts.back() );
166  }
167 
168  SetPolyPoints( pts );
169  }
170  break;
171 
172  default:
173  break;
174  }
175 }
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.

◆ SetAngle()

void DRAWSEGMENT::SetAngle ( double  aAngle)

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.

Definition at line 395 of file class_drawsegment.cpp.

396 {
397  // m_Angle must be >= -360 and <= +360 degrees
398  m_Angle = NormalizeAngle360Max( aAngle );
399 }
T NormalizeAngle360Max(T Angle)
Normalize angle to be >=-360.0 and <= 360.0 Angle can be equal to -360 or +360.
Definition: trigo.h:226
double m_Angle
Used only for Arcs: Arc angle in 1/10 deg.

References m_Angle, and NormalizeAngle360Max().

Referenced by D_PAD::AddPrimitiveArc(), PCAD2KICAD::PCB_ARC::AddToBoard(), PCAD2KICAD::PCB_ARC::AddToModule(), PAD_TOOL::explodePad(), EDGE_MODULE::Flip(), ALTIUM_PCB::HelperCreateBoardOutline(), EAGLE_PLUGIN::loadPlain(), EDGE_MODULE::Mirror(), EAGLE_PLUGIN::packageWire(), ALTIUM_PCB::ParseArcs6Data(), GPCB_FPL_CACHE::parseMODULE(), PAD_TOOL::recombinePad(), DIALOG_GRAPHIC_ITEM_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PRIMITIVES_PROPERTIES::TransferDataFromWindow(), updateArcFromConstructionMgr(), and POINT_EDITOR::updateItem().

◆ 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 178 of file class_drawsegment.h.

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

References m_End.

Referenced by D_PAD::AddPrimitiveArc(), ALTIUM_PCB::HelperCreateBoardOutline(), ALTIUM_PCB::HelperParsePad6NonCopper(), ALTIUM_PCB::ParseArcs6Data(), updateArcFromConstructionMgr(), and POINT_EDITOR::updateItem().

◆ 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 223 of file class_drawsegment.h.

224  {
225  m_BezierPoints = aPoints;
226  }
std::vector< wxPoint > m_BezierPoints

References m_BezierPoints.

◆ SetBrightened()

void EDA_ITEM::SetBrightened ( )
inlineinherited

◆ SetCenter()

void DRAWSEGMENT::SetCenter ( const wxPoint aCenterPoint)
inline

For arcs and circles:

Definition at line 183 of file class_drawsegment.h.

183 { m_Start = aCenterPoint; }
wxPoint m_Start
Line start point or Circle and Arc center.

References m_Start.

Referenced by D_PAD::AddPrimitiveArc(), ALTIUM_PCB::HelperCreateBoardOutline(), ALTIUM_PCB::HelperParsePad6NonCopper(), ALTIUM_PCB::ParseArcs6Data(), updateArcFromConstructionMgr(), and POINT_EDITOR::updateItem().

◆ SetEnd()

◆ SetEndX()

void DRAWSEGMENT::SetEndX ( int  x)
inline

Definition at line 143 of file class_drawsegment.h.

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

References m_End, and wxPoint::x.

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

◆ SetEndY()

void DRAWSEGMENT::SetEndY ( int  y)
inline

Definition at line 142 of file class_drawsegment.h.

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

References m_End, and wxPoint::y.

Referenced by 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(), 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(), 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(), SCH_EDIT_FRAME::PutDataInPreviousState(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_PIN_TOOL::RepeatPin(), LIB_EDIT_FRAME::SaveCopyInUndoList(), SELECTION_TOOL::selectConnectedTracks(), EE_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectPoint(), SCH_EDIT_FRAME::SelectUnit(), EDA_ITEM::SetBrightened(), LIB_PIN::SetConversion(), 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_TARGET_PROPERTIES::TransferDataFromWindow(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), LIB_DRAWING_TOOLS::TwoClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ SetForceVisible()

void EDA_ITEM::SetForceVisible ( bool  aEnable)
inlineinherited

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

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

Definition at line 284 of file base_struct.h.

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

References EDA_ITEM::m_forceVisible.

◆ 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 ZONE_CONTAINER, and DIMENSION.

Definition at line 159 of file class_board_item.h.

160  {
161  // trap any invalid layers, then go find the caller and fix it.
162  // wxASSERT( unsigned( aLayer ) < unsigned( NB_PCB_LAYERS ) );
163  m_Layer = aLayer;
164  }
PCB_LAYER_ID m_Layer

References BOARD_ITEM::m_Layer.

Referenced by 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(), DIMENSION::AdjustDimensionDetails(), ZONE_FILLER::buildCopperItemClearances(), MICROWAVE_TOOL::createMicrowaveInductor(), PCB_BASE_FRAME::CreateNewModule(), MICROWAVE_TOOL::createPolygonShape(), DRC::doTrackDrc(), DRAWING_TOOL::drawArc(), PAD_TOOL::explodePad(), PCB_TARGET::Flip(), TEXTE_PCB::Flip(), EDGE_MODULE::Flip(), TRACK::Flip(), TEXTE_MODULE::Flip(), Flip(), MODULE::Flip(), ARC::Flip(), ALTIUM_PCB::HelperCreateBoardOutline(), ALTIUM_PCB::HelperParseDimensions6Center(), ALTIUM_PCB::HelperParseDimensions6Datum(), ALTIUM_PCB::HelperParseDimensions6Leader(), ALTIUM_PCB::HelperParsePad6NonCopper(), LEGACY_PLUGIN::loadMODULE(), LEGACY_PLUGIN::loadMODULE_TEXT(), LEGACY_PLUGIN::loadPCB_TEXT(), EAGLE_PLUGIN::loadPlain(), EAGLE_PLUGIN::loadSignals(), LEGACY_PLUGIN::loadTrackList(), DSN::SPECCTRA_DB::makeTRACK(), GRAPHICS_CLEANER::mergeRects(), 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(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::processItem(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), processTextItem(), DIALOG_PAD_PROPERTIES::redraw(), DIMENSION::SetLayer(), TEXT_MOD_GRID_TABLE::SetValueAsLong(), GLOBAL_EDIT_TOOL::swapBoardItem(), DRC::testPadClearances(), TEXTE_MODULE::TEXTE_MODULE(), DIALOG_TRACK_VIA_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), and DIALOG_GRAPHIC_ITEM_PROPERTIES::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 225 of file class_board_item.h.

226  {
227  // only MODULEs & TRACKs can be locked at this time.
228  }

Referenced by PCB_EDITOR_CONTROL::modifyLockSelected(), ALTIUM_PCB::ParsePads6Data(), and ALTIUM_PCB::ParsePolygons6Data().

◆ SetModified()

◆ SetParent()

virtual void EDA_ITEM::SetParent ( EDA_ITEM aParent)
inlinevirtualinherited

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(), LIB_FIELD::Copy(), LIB_EDIT_FRAME::CreateNewPart(), SCH_DRAWING_TOOLS::createNewText(), DIALOG_LIB_EDIT_PIN::DIALOG_LIB_EDIT_PIN(), 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(), DIALOG_LIB_EDIT_PIN::OnPaintShowPanel(), 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(), 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(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_SHEET::SwapData(), SCH_COMPONENT::SwapData(), SwapItemData(), and DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::UpdateFieldsFromLibrary().

◆ SetPolyPoints()

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

Definition at line 1007 of file class_drawsegment.cpp.

1008 {
1010  m_Poly.NewOutline();
1011 
1012  for ( const wxPoint& p : aPoints )
1013  m_Poly.Append( p.x, p.y );
1014 }
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 221 of file class_drawsegment.h.

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

References m_Poly.

Referenced by PAD_TOOL::explodePad(), and PAD_TOOL::recombinePad().

◆ SetPosition()

void DRAWSEGMENT::SetPosition ( const wxPoint aPos)
overridevirtual

Implements BOARD_ITEM.

Definition at line 60 of file class_drawsegment.cpp.

61 {
62  m_Start = aPos;
63 }
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 134 of file class_drawsegment.h.

134 { 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 133 of file class_drawsegment.h.

133 { 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(), 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().

◆ SetType()

void DRAWSEGMENT::SetType ( int  aType)
inline

Definition at line 112 of file class_drawsegment.h.

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

References m_Type.

◆ SetWidth()

void DRAWSEGMENT::SetWidth ( int  aWidth)
inline

Definition at line 101 of file class_drawsegment.h.

101 { 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(), PAD_TOOL::explodePad(), ALTIUM_PCB::HelperCreateBoardOutline(), ALTIUM_PCB::HelperParseDimensions6Center(), ALTIUM_PCB::HelperParseDimensions6Datum(), ALTIUM_PCB::HelperParseDimensions6Leader(), ALTIUM_PCB::HelperParsePad6NonCopper(), 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(), 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().

◆ ShowShape()

wxString BOARD_ITEM::ShowShape ( STROKE_T  aShape)
staticinherited

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

Definition at line 39 of file class_board_item.cpp.

40 {
41  switch( aShape )
42  {
43  case S_SEGMENT: return _( "Line" );
44  case S_RECT: return _( "Rect" );
45  case S_ARC: return _( "Arc" );
46  case S_CIRCLE: return _( "Circle" );
47  case S_CURVE: return _( "Bezier Curve" );
48  case S_POLYGON: return _( "Polygon" );
49  default: return wxT( "??" );
50  }
51 }
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(), DSN::SPECCTRA_DB::makeIMAGE(), 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 520 of file base_struct.h.

520 { 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 1163 of file class_drawsegment.cpp.

1164 {
1165  DRAWSEGMENT* image = dynamic_cast<DRAWSEGMENT*>( aImage );
1166  assert( image );
1167 
1168  std::swap( m_Width, image->m_Width );
1169  std::swap( m_Start, image->m_Start );
1170  std::swap( m_End, image->m_End );
1171  std::swap( m_Shape, image->m_Shape );
1172  std::swap( m_Type, image->m_Type );
1173  std::swap( m_Angle, image->m_Angle );
1174  std::swap( m_BezierC1, image->m_BezierC1 );
1175  std::swap( m_BezierC2, image->m_BezierC2 );
1176  std::swap( m_BezierPoints, image->m_BezierPoints );
1177  std::swap( m_Poly, image->m_Poly );
1178 }
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.
wxPoint m_Start
Line start point or Circle and Arc center.
wxPoint m_End
Line end point or circle and arc start point.
STROKE_T m_Shape
Shape: line, Circle, Arc.
int m_Type
Used in complex associations ( Dimensions.. )
wxPoint m_BezierC2
Bezier Control Point 2.
int m_Width
thickness of lines ...
std::vector< wxPoint > m_BezierPoints

References m_Angle, m_BezierC1, m_BezierC2, m_BezierPoints, m_End, m_Poly, m_Shape, m_Start, m_Type, and m_Width.

◆ TransformShapeWithClearanceToPolygon()

void DRAWSEGMENT::TransformShapeWithClearanceToPolygon ( SHAPE_POLY_SET aCornerBuffer,
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 354 of file board_items_to_polygon_shape_transform.cpp.

357 {
358  int width = ignoreLineWidth ? 0 : m_Width;
359 
360  width += 2 * aClearanceValue;
361 
362  // Creating a reliable clearance shape for circles and arcs is not so easy, due to
363  // the error created by segment approximation.
364  // for a circle this is not so hard: create a polygon from a circle slightly bigger:
365  // thickness = width + s_error_max, and radius = initial radius + s_error_max/2
366  // giving a shape with a suitable internal radius and external radius
367  // For an arc this is more tricky: TODO
368 
369  switch( m_Shape )
370  {
371  case S_CIRCLE:
372  if( width == 0 )
373  TransformCircleToPolygon( aCornerBuffer, GetCenter(), GetRadius(), aError );
374  else
375  TransformRingToPolygon( aCornerBuffer, GetCenter(), GetRadius(), aError, width );
376  break;
377 
378  case S_RECT:
379  {
380  std::vector<wxPoint> pts;
381  GetRectCorners( &pts );
382 
383  if( width == 0 )
384  {
385  aCornerBuffer.NewOutline();
386 
387  for( const wxPoint& pt : pts )
388  aCornerBuffer.Append( pt );
389  }
390 
391  if( width > 0 )
392  {
393  // Add in segments
394  TransformSegmentToPolygon( aCornerBuffer, pts[0], pts[1], aError, width );
395  TransformSegmentToPolygon( aCornerBuffer, pts[1], pts[2], aError, width );
396  TransformSegmentToPolygon( aCornerBuffer, pts[2], pts[3], aError, width );
397  TransformSegmentToPolygon( aCornerBuffer, pts[3], pts[0], aError, width );
398  }
399  }
400  break;
401 
402  case S_ARC:
403  TransformArcToPolygon( aCornerBuffer, GetCenter(), GetArcStart(), m_Angle, aError, width );
404  break;
405 
406  case S_SEGMENT:
407  TransformOvalToPolygon( aCornerBuffer, m_Start, m_End, width, aError );
408  break;
409 
410  case S_POLYGON:
411  if( IsPolyShapeValid() )
412  {
413  // The polygon is expected to be a simple polygon
414  // not self intersecting, no hole.
415  MODULE* module = GetParentModule(); // NULL for items not in footprints
416  double orientation = module ? module->GetOrientation() : 0.0;
417  wxPoint offset;
418 
419  if( module )
420  offset = module->GetPosition();
421 
422  // Build the polygon with the actual position and orientation:
423  std::vector< wxPoint> poly;
424  poly = BuildPolyPointsList();
425 
426  for( wxPoint& point : poly )
427  {
428  RotatePoint( &point, orientation );
429  point += offset;
430  }
431 
432  if( IsPolygonFilled() || width == 0 )
433  {
434  aCornerBuffer.NewOutline();
435 
436  for( wxPoint& point : poly )
437  aCornerBuffer.Append( point.x, point.y );
438  }
439 
440  if( width > 0 )
441  {
442  wxPoint pt1( poly[ poly.size() - 1] );
443 
444  for( wxPoint pt2 : poly )
445  {
446  if( pt2 != pt1 )
447  TransformSegmentToPolygon( aCornerBuffer, pt1, pt2, aError, width );
448 
449  pt1 = pt2;
450  }
451  }
452  }
453  break;
454 
455  case S_CURVE: // Bezier curve
456  {
457  std::vector<wxPoint> ctrlPoints = { m_Start, m_BezierC1, m_BezierC2, m_End };
458  BEZIER_POLY converter( ctrlPoints );
459  std::vector< wxPoint> poly;
460  converter.GetPoly( poly, m_Width );
461 
462  if( width != 0 )
463  {
464  for( unsigned ii = 1; ii < poly.size(); ii++ )
465  TransformSegmentToPolygon( aCornerBuffer, poly[ii-1], poly[ii], aError, width );
466  }
467  }
468  break;
469 
470  default:
471  wxFAIL_MSG( "DRAWSEGMENT::TransformShapeWithClearanceToPolygon no implementation for "
472  + STROKE_T_asString( m_Shape ) );
473  break;
474  }
475 }
double GetOrientation() const
Definition: class_module.h:211
const wxPoint GetCenter() const override
Function GetCenter()
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...
wxPoint m_End
Line end point or circle and arc start point.
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.
const wxPoint & GetArcStart() const
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
static wxString STROKE_T_asString(STROKE_T a)
Bezier curves to polygon converter.
Definition: bezier_curves.h:35
void TransformCircleToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aCenter, int aRadius, int aError)
Function TransformCircleToPolygon convert a circle to a polygon, using multiple straight lines.
wxPoint m_BezierC2
Bezier Control Point 2.
bool IsPolyShapeValid() const
void TransformSegmentToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aStart, wxPoint aEnd, int aError, int aWidth)
Function TransformRoundedEndsSegmentToPolygon convert a segment with rounded ends to a polygon Conver...
void TransformRingToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aCentre, int aRadius, int aError, int aWidth)
Function TransformRingToPolygon Creates a polygon from a ring Convert arcs to multiple straight segme...
int m_Width
thickness of lines ...
void GetRectCorners(std::vector< wxPoint > *pts) const
bool IsPolygonFilled() const
Polygonal shape is not always filled.
const wxPoint GetPosition() const override
Definition: class_module.h:206
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)

References SHAPE_POLY_SET::Append(), BuildPolyPointsList(), GetArcStart(), GetCenter(), MODULE::GetOrientation(), GetParentModule(), BEZIER_POLY::GetPoly(), MODULE::GetPosition(), GetRadius(), GetRectCorners(), IsPolygonFilled(), IsPolyShapeValid(), m_Angle, m_BezierC1, m_BezierC2, m_End, m_Shape, m_Start, m_Width, SHAPE_POLY_SET::NewOutline(), RotatePoint(), S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, S_SEGMENT, STROKE_T_asString(), TransformArcToPolygon(), TransformCircleToPolygon(), TransformOvalToPolygon(), TransformRingToPolygon(), and TransformSegmentToPolygon().

Referenced by ZONE_FILLER::addKnockout(), BOARD_ADAPTER::AddShapeWithClearanceToContainer(), ALTIUM_PCB::ParseArcs6Data(), ALTIUM_PCB::ParseTracks6Data(), PAD_TOOL::recombinePad(), BOARD_ADAPTER::transformGraphicModuleEdgeToPolygonSet(), and MODULE::TransformGraphicShapesWithClearanceToPolygonSet().

◆ Type()

KICAD_T EDA_ITEM::Type ( ) const
inlineinherited

Function Type()

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

Returns
KICAD_T - the type of object.

Definition at line 193 of file base_struct.h.

193 { return m_StructType; }
KICAD_T m_StructType
Run time identification, keep private so it can never be changed after a constructor sets it.
Definition: base_struct.h:170

References EDA_ITEM::m_StructType.

Referenced by MODULE::Add(), CN_CONNECTIVITY_ALGO::Add(), BOARD::Add(), CN_CLUSTER::Add(), POINT_EDITOR::addCorner(), CONNECTION_SUBGRAPH::AddItem(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), SCH_LINE_WIRE_BUS_TOOL::AddJunctionsIfNeeded(), ZONE_FILLER::addKnockout(), SCH_SHEET::AddPin(), ALIGN_DISTRIBUTE_TOOL::AlignBottom(), ALIGN_DISTRIBUTE_TOOL::AlignCenterX(), ALIGN_DISTRIBUTE_TOOL::AlignCenterY(), ALIGN_DISTRIBUTE_TOOL::AlignTop(), CN_ITEM::AnchorCount(), SCH_SCREEN::Append(), CONNECTION_GRAPH::buildConnectionGraph(), SCH_SCREENS::buildScreenList(), calcArea(), calcMaxArea(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), POINT_EDITOR::canAddCorner(), SCH_JUNCTION::CanConnect(), SCH_NO_CONNECT::CanConnect(), SCH_BUS_WIRE_ENTRY::CanConnect(), SCH_LINE::CanConnect(), SCH_BUS_BUS_ENTRY::CanConnect(), SCH_LABEL::CanConnect(), SCH_GLOBALLABEL::CanConnect(), SCH_HIERLABEL::CanConnect(), SCH_SHEET::CanConnect(), SCH_COMPONENT::CanConnect(), ROUTER_TOOL::CanInlineDrag(), SCH_EDIT_TOOL::ChangeTextType(), SCH_MARKER::ClassOf(), SCH_JUNCTION::ClassOf(), TEXTE_PCB::ClassOf(), MARKER_PCB::ClassOf(), SCH_NO_CONNECT::ClassOf(), BOARD_CONNECTED_ITEM::ClassOf(), SCH_PIN::ClassOf(), EDGE_MODULE::ClassOf(), SCH_LINE::ClassOf(), PCB_TARGET::ClassOf(), SCH_FIELD::ClassOf(), TEXTE_MODULE::ClassOf(), ClassOf(), ZONE_CONTAINER::ClassOf(), SCH_BITMAP::ClassOf(), D_PAD::ClassOf(), DIMENSION::ClassOf(), TRACK::ClassOf(), NETINFO_ITEM::ClassOf(), SCH_SHEET_PIN::ClassOf(), MODULE::ClassOf(), SCH_BUS_WIRE_ENTRY::ClassOf(), SCH_COMPONENT::ClassOf(), SCH_SCREEN::ClassOf(), SCH_BUS_BUS_ENTRY::ClassOf(), SCH_TEXT::ClassOf(), SCH_SHEET::ClassOf(), BOARD::ClassOf(), ARC::ClassOf(), SCH_LABEL::ClassOf(), VIA::ClassOf(), SCH_GLOBALLABEL::ClassOf(), SCH_HIERLABEL::ClassOf(), TRACKS_CLEANER::cleanupSegments(), LIB_BEZIER::compare(), LIB_CIRCLE::compare(), LIB_RECTANGLE::compare(), LIB_TEXT::compare(), LIB_POLYLINE::compare(), LIB_ARC::compare(), LIB_FIELD::compare(), LIB_ITEM::compare(), LIB_PIN::compare(), GRID_HELPER::computeAnchors(), SCH_BUS_WIRE_ENTRY::ConnectionPropagatesTo(), EE_RTREE::contains(), DIALOG_TEXT_PROPERTIES::convertKIIDsToReferences(), DIALOG_LABEL_EDITOR::convertKIIDsToReferences(), MODULE::CoverageRatio(), BOARD_ADAPTER::createLayers(), PCB_BASE_FRAME::CreateNewModule(), SCH_DRAWING_TOOLS::createNewText(), BOARD_ADAPTER::createNewTrack(), D_PAD::D_PAD(), SCH_SCREEN::DeleteItem(), DIALOG_LABEL_EDITOR::DIALOG_LABEL_EDITOR(), DIALOG_SCH_EDIT_ONE_FIELD::DIALOG_SCH_EDIT_ONE_FIELD(), DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES(), ALIGN_DISTRIBUTE_TOOL::doAlignLeft(), ALIGN_DISTRIBUTE_TOOL::doAlignRight(), SCH_EDITOR_CONTROL::doCopy(), SCH_EDIT_TOOL::DoDelete(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersVertically(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsVertically(), DRC::doTrackDrc(), KIGFX::SCH_PAINTER::draw(), KIGFX::GERBVIEW_PAINTER::Draw(), KIGFX::PCB_PAINTER::Draw(), CN_ITEM::Dump(), EDIT_TOOL::Duplicate(), SCH_ITEM::Duplicate(), MODULE::DuplicateItem(), SCH_EDIT_TOOL::EditField(), SCH_EDIT_TOOL::editFieldText(), LIB_EDIT_TOOL::editTextProperties(), EditToolSelectionFilter(), CONNECTION_GRAPH::ercCheckBusToBusEntryConflicts(), CONNECTION_GRAPH::ercCheckLabels(), NETLIST_EXPORTER::findNextComponent(), PCB_BASE_FRAME::FocusOnItem(), EDIT_TOOL::FootprintFilter(), SCH_SEXPR_PLUGIN::Format(), SCH_LEGACY_PLUGIN::Format(), PCB_IO::Format(), PCB_IO::format(), FormatProbeItem(), POINT_EDITOR::get45DegConstrainer(), CN_ITEM::GetAnchor(), BOARD_ITEM::GetBoard(), SCH_FIELD::GetBoundingBox(), TRACK::GetBoundingBox(), SCH_FIELD::GetCanonicalName(), KIGFX::GERBVIEW_RENDER_SETTINGS::GetColor(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), NETLIST_OBJECT::GetComponentParent(), SCH_MOVE_TOOL::getConnectedDragItems(), SCH_TEXT::GetConnectionPoints(), SCH_TEXT::GetContextualTextVars(), CONNECTION_GRAPH::getDefaultConnection(), CONNECTION_SUBGRAPH::GetDriverPriority(), SCH_TEXT::GetEndPoints(), PL_EDITOR_FRAME::GetLayoutFromRedoList(), PL_EDITOR_FRAME::GetLayoutFromUndoList(), SCH_FIELD::GetMenuImage(), TEXTE_PCB::GetMsgPanelInfo(), SCH_TEXT::GetMsgPanelInfo(), SCH_FIELD::GetName(), CONNECTION_SUBGRAPH::GetNameForDriver(), CONNECTIVITY_DATA::GetNetItems(), LIB_PART::GetNextDrawItem(), GetParentModule(), LIB_PART::GetPin(), SCH_COMPONENT::GetPinPhysicalPosition(), SCH_FIELD::GetPosition(), getRect(), KIGFX::SCH_PAINTER::getRenderColor(), TEXTE_PCB::GetShownText(), SCH_FIELD::GetShownText(), SCH_TEXT::GetShownText(), EE_SELECTION_TOOL::GuessSelectionCandidates(), SELECTION_TOOL::GuessSelectionCandidates(), hash_eda(), EE_SELECTION_TOOL::highlight(), SELECTION_TOOL::highlight(), highlightNet(), SCH_EDIT_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), EE_RTREE::insert(), EE_COLLECTOR::Inspect(), GENERAL_COLLECTOR::Inspect(), PCB_LAYER_COLLECTOR::Inspect(), ARRAY_CREATOR::Invoke(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingLineWireOrBus(), TRACK::IsNull(), SCH_LINE::IsParallel(), SCH_FIELD::IsReplaceable(), SCH_SCREEN::IsTerminalPoint(), BOARD_ITEM::IsTrack(), itemIsIncludedByFilter(), SELECTION_TOOL::itemPassesFilter(), CLIPBOARD_IO::Load(), PNS_PCBNEW_RULE_RESOLVER::localPadClearance(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), EE_SELECTION_TOOL::Main(), EDIT_POINTS_FACTORY::Make(), SCH_SCREEN::MarkConnections(), CN_CONNECTIVITY_ALGO::markItemNetAsDirty(), CONNECTIVITY_DATA::MarkItemNetAsDirty(), SCH_FIELD::Matches(), SCH_LINE::MergeOverlap(), SCH_EDIT_TOOL::Mirror(), SCH_MOVE_TOOL::moveItem(), SCH_EDITOR_CONTROL::nextMatch(), FOOTPRINT_EDIT_FRAME::OnEditItemRequest(), PCB_EDIT_FRAME::OnEditItemRequest(), SCH_JUNCTION::operator<(), SCH_BUS_ENTRY_BASE::operator<(), SCH_FIELD::operator<(), SCH_LINE::operator<(), LIB_ITEM::operator<(), SCH_TEXT::operator<(), SCH_ITEM::operator<(), SCH_SHEET::operator<(), SCH_COMPONENT::operator<(), SCH_BITMAP::operator=(), SCH_SHEET::operator=(), SCH_COMPONENT::operator=(), EDIT_TOOL::PadFilter(), BOARD_COMMIT::parentObject(), PCBNEW_CONTROL::Paste(), SCH_EDITOR_CONTROL::Paste(), DRAWING_TOOL::PlaceImportedGraphics(), SCH_FIELD::Plot(), SCH_SCREEN::Plot(), BRDITEMS_PLOTTER::PlotFootprintGraphicItem(), SCH_FIELD::Print(), SCH_SCREEN::Print(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::processItem(), LIB_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), BOARD_COMMIT::Push(), PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), SELECTION_TOOL::RebuildSelection(), SCH_CONNECTION::recacheName(), SCH_BASE_FRAME::RefreshItem(), SCH_BASE_FRAME::RefreshSelection(), EE_RTREE::remove(), MODULE::Remove(), CN_CONNECTIVITY_ALGO::Remove(), SCH_SCREEN::Remove(), BOARD::Remove(), POINT_EDITOR::removeCorner(), POINT_EDITOR::removeCornerCondition(), LIB_PART::RemoveDrawItem(), SCH_SHEET::RemovePin(), SCH_EDIT_TOOL::RepeatDrawItem(), SCH_FIELD::Replace(), WS_PROXY_UNDO_ITEM::Restore(), PL_EDITOR_FRAME::RollbackFromUndo(), SCH_EDIT_TOOL::Rotate(), SCH_TEXT::Rotate(), DRC_TEXTVAR_TESTER::RunDRC(), SCH_SEXPR_PLUGIN_CACHE::saveArc(), SCH_LEGACY_PLUGIN_CACHE::saveArc(), SCH_SEXPR_PLUGIN_CACHE::saveBezier(), SCH_LEGACY_PLUGIN_CACHE::saveBezier(), SCH_SEXPR_PLUGIN_CACHE::saveCircle(), SCH_LEGACY_PLUGIN_CACHE::saveCircle(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), EE_TOOL_BASE< SCH_BASE_FRAME >::saveCopyInUndoList(), SCH_SEXPR_PLUGIN::saveField(), SCH_SEXPR_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_SEXPR_PLUGIN_CACHE::savePin(), SCH_LEGACY_PLUGIN_CACHE::savePin(), SCH_SEXPR_PLUGIN_CACHE::savePolyLine(), SCH_LEGACY_PLUGIN_CACHE::savePolyLine(), SCH_SEXPR_PLUGIN_CACHE::saveRectangle(), SCH_LEGACY_PLUGIN_CACHE::saveRectangle(), SCH_SEXPR_PLUGIN_CACHE::saveSymbolDrawItem(), SCH_SEXPR_PLUGIN::saveText(), SCH_SEXPR_PLUGIN_CACHE::saveText(), SCH_LEGACY_PLUGIN_CACHE::saveText(), SCH_SCREEN::Schematic(), SCH_ITEM::Schematic(), SELECTION_TOOL::select(), EE_SELECTION_TOOL::Selectable(), SELECTION_TOOL::Selectable(), SELECTION_TOOL::selectConnectedTracks(), SCH_FIELD::SetId(), ITEM_PICKER::SetItem(), SCH_FIELD::SetPosition(), DIALOG_LABEL_EDITOR::SetTitle(), PCB_EDIT_FRAME::SetTrackSegmentWidth(), BOARD_COMMIT::Stage(), SCH_JUNCTION::SwapData(), SCH_NO_CONNECT::SwapData(), SCH_BITMAP::SwapData(), PCB_TARGET::SwapData(), SCH_SHEET_PIN::SwapData(), SCH_FIELD::SwapData(), TEXTE_PCB::SwapData(), TRACK::SwapData(), DIMENSION::SwapData(), ARC::SwapData(), SCH_SHEET::SwapData(), VIA::SwapData(), SCH_COMPONENT::SwapData(), D_PAD::SwapData(), MODULE::SwapData(), ZONE_CONTAINER::SwapData(), SwapItemData(), TEXTE_MODULE::TEXTE_MODULE(), DIALOG_LABEL_EDITOR::TransferDataFromWindow(), DIALOG_FIELDS_EDITOR_GLOBAL::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_LABEL_EDITOR::TransferDataToWindow(), TRACK::TransformShapeWithClearanceToPolygon(), LIB_DRAWING_TOOLS::TwoClickPlace(), EE_SELECTION_TOOL::unhighlight(), SELECTION_TOOL::unhighlight(), SCH_TEXT::UpdateDanglingState(), DIALOG_SCH_EDIT_ONE_FIELD::UpdateField(), EE_POINT_EDITOR::updateItem(), PL_POINT_EDITOR::updateItem(), POINT_EDITOR::updateItem(), CONNECTION_GRAPH::updateItemConnectivity(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), POINT_EDITOR::updatePoints(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateView(), PCB_BRIGHT_BOX::ViewDraw(), SCH_BUS_ENTRY_BASE::ViewGetLayers(), TRACK::Visit(), GERBER_DRAW_ITEM::Visit(), SCH_SHEET::Visit(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ ViewBBox()

const BOX2I DRAWSEGMENT::ViewBBox ( ) const
overridevirtual

Function ViewBBox() returns the bounding box of the item covering all its layers.

Returns
BOX2I - the current bounding box

Reimplemented from EDA_ITEM.

Definition at line 893 of file class_drawsegment.cpp.

894 {
895  // For arcs - do not include the center point in the bounding box,
896  // it is redundant for displaying an arc
897  if( m_Shape == S_ARC )
898  {
899  EDA_RECT bbox;
900  bbox.SetOrigin( m_End );
901  computeArcBBox( bbox );
902  return BOX2I( bbox.GetOrigin(), bbox.GetSize() );
903  }
904 
905  return EDA_ITEM::ViewBBox();
906 }
BOX2< VECTOR2I > BOX2I
Definition: box2.h:521
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:131
void computeArcBBox(EDA_RECT &aBBox) const
wxPoint m_End
Line end point or circle and arc start point.
const wxPoint GetOrigin() const
Definition: eda_rect.h:114
Arcs (with rounded ends)
STROKE_T m_Shape
Shape: line, Circle, Arc.
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
virtual const BOX2I ViewBBox() const override
Function ViewBBox() returns the bounding box of the item covering all its layers.
const wxSize GetSize() const
Definition: eda_rect.h:103

References computeArcBBox(), EDA_RECT::GetOrigin(), EDA_RECT::GetSize(), m_End, m_Shape, S_ARC, EDA_RECT::SetOrigin(), and EDA_ITEM::ViewBBox().

◆ ViewDraw()

virtual void KIGFX::VIEW_ITEM::ViewDraw ( int  aLayer,
VIEW aView 
) const
inlinevirtualinherited

Function ViewDraw() Draws the parts of the object belonging to layer aLayer.

viewDraw() is an alternative way for drawing objects if if there is no PAINTER assigned for the view or if the PAINTER doesn't know how to paint this particular implementation of VIEW_ITEM. The preferred way of drawing is to design an appropriate PAINTER object, the method below is intended only for quick hacks and debugging purposes.

Parameters
aLayercurrent drawing layer
aViewpointer to the VIEW device we are drawing on

Reimplemented in EDIT_POINTS, ROUTER_PREVIEW_ITEM, KIGFX::VIEW_GROUP, KIGFX::WS_PROXY_VIEW_ITEM, KIGFX::PREVIEW::SELECTION_AREA, MY_DRAWING, KIGFX::PREVIEW::SIMPLE_OVERLAY_ITEM, KIGFX::VIEW_OVERLAY, KIGFX::ORIGIN_VIEWITEM, KIGFX::PREVIEW::TWO_POINT_ASSISTANT, BRIGHT_BOX, KIGFX::PREVIEW::RULER_ITEM, KIGFX::RATSNEST_VIEWITEM, KIGFX::PREVIEW::ARC_ASSISTANT, and PCB_BRIGHT_BOX.

Definition at line 116 of file view_item.h.

117  {}

Referenced by KIGFX::VIEW::draw(), and KIGFX::VIEW::updateItemGeometry().

◆ ViewGetLayers()

void BOARD_ITEM::ViewGetLayers ( int  aLayers[],
int &  aCount 
) const
overridevirtualinherited

Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on.

For instance, a D_PAD spans zero or more copper layers and a few technical layers. ViewDraw() or PAINTER::Draw() is repeatedly called for each of the layers returned by ViewGetLayers(), depending on the rendering order.

Parameters
aLayers[]output layer index array
aCountnumber of layer indices in aLayers[]

Reimplemented from EDA_ITEM.

Reimplemented in MODULE, D_PAD, VIA, TEXTE_MODULE, TRACK, ZONE_CONTAINER, MARKER_PCB, and KIGFX::ORIGIN_VIEWITEM.

Definition at line 116 of file class_board_item.cpp.

117 {
118  // Basic fallback
119  aCount = 1;
120  aLayers[0] = m_Layer;
121 }
PCB_LAYER_ID m_Layer

References BOARD_ITEM::m_Layer.

Referenced by SELECTION_TOOL::Selectable().

◆ ViewGetLOD()

virtual unsigned int KIGFX::VIEW_ITEM::ViewGetLOD ( int  aLayer,
VIEW aView 
) const
inlinevirtualinherited

Function ViewGetLOD() Returns the level of detail (LOD) of the item.

A level of detail is the minimal VIEW scale that is sufficient for an item to be shown on a given layer.

Parameters
aLayercurrent drawing layer
aViewpointer to the VIEW device we are drawing on
Returns
the level of detail. 0 always show the item, because the actual zoom level (or VIEW scale) is always > 0

Reimplemented in MODULE_ZONE_CONTAINER, MODULE, D_PAD, VIA, GERBER_DRAW_ITEM, TEXTE_MODULE, TRACK, and EDGE_MODULE.

Definition at line 140 of file view_item.h.

141  {
142  // By default always show the item
143  return 0;
144  }

Referenced by KIGFX::VIEW::drawItem::operator()(), GRID_HELPER::queryVisible(), and SELECTION_TOOL::Selectable().

◆ viewPrivData()

◆ Visit()

SEARCH_RESULT EDA_ITEM::Visit ( INSPECTOR  inspector,
void *  testData,
const KICAD_T  scanTypes[] 
)
virtualinherited

Function Visit may be re-implemented for each derived class in order to handle all the types given by its member data.

Implementations should call inspector->Inspect() on types in scanTypes[], and may use IterateForward() to do so on lists of such data.

Parameters
inspectorAn INSPECTOR instance to use in the inspection.
testDataArbitrary data used by the inspector.
scanTypesWhich KICAD_T types are of interest and the order is significant too, terminated by EOT.
Returns
SEARCH_RESULT SEARCH_QUIT if the Iterator is to stop the scan, else SCAN_CONTINUE, and determined by the inspector.

Reimplemented in BOARD, SCH_COMPONENT, MODULE, SCH_SHEET, LIB_PART, GERBER_FILE_IMAGE, GERBER_DRAW_ITEM, TRACK, and GBR_LAYOUT.

Definition at line 118 of file base_struct.cpp.

119 {
120 #if 0 && defined(DEBUG)
121  std::cout << GetClass().mb_str() << ' ';
122 #endif
123 
124  if( IsType( scanTypes ) )
125  {
126  if( SEARCH_RESULT::QUIT == inspector( this, testData ) )
127  return SEARCH_RESULT::QUIT;
128  }
129 
131 }
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
virtual wxString GetClass() const =0
Function GetClass returns the class name.

References CONTINUE, EDA_ITEM::GetClass(), EDA_ITEM::IsType(), and QUIT.

Referenced by GERBER_COLLECTOR::Collect(), GENERAL_COLLECTOR::Collect(), PCB_TYPE_COLLECTOR::Collect(), PCB_LAYER_COLLECTOR::Collect(), and EDA_ITEM::IterateForward().

Member Data Documentation

◆ m_Angle

double DRAWSEGMENT::m_Angle
protected

◆ m_BezierC1

◆ m_BezierC2

◆ m_BezierPoints

std::vector<wxPoint> DRAWSEGMENT::m_BezierPoints
protected

◆ m_End

◆ m_Flags

◆ m_forceVisible

bool EDA_ITEM::m_forceVisible
protectedinherited

◆ m_Layer

◆ m_Parent

◆ m_Poly

◆ m_Shape

◆ m_Start

◆ m_Status

STATUS_FLAGS EDA_ITEM::m_Status
protectedinherited

◆ m_Type

int DRAWSEGMENT::m_Type
protected

Used in complex associations ( Dimensions.. )

Definition at line 56 of file class_drawsegment.h.

Referenced by DRAWSEGMENT(), GetType(), SetType(), and SwapData().

◆ m_Uuid

const KIID EDA_ITEM::m_Uuid
inherited

Definition at line 162 of file base_struct.h.

Referenced by FIELDS_EDITOR_GRID_DATA_MODEL::AddColumn(), SCH_COMPONENT::AddHierarchicalReference(), SCH_EDIT_FRAME::AnnotateComponents(), FIELDS_EDITOR_GRID_DATA_MODEL::ApplyData(), SCH_SHEET_PATH::Cmp(), DIALOG_LABEL_EDITOR::convertReferencesToKIIDs(), BOARD_ITEM::Duplicate(), SCH_ITEM::Duplicate(), PAD_TOOL::EditPad(), PCB_EDIT_FRAME::Exchange_Module(), PAD_TOOL::explodePad(), PCB_BASE_FRAME::FocusOnItem(), SCH_EDIT_FRAME::FocusOnItem(), PCB_IO::format(), FormatProbeItem(), SCH_PIN::GetDefaultNetName(), BOARD::GetItem(), SCH_SHEET::GetMsgPanelInfo(), SCH_REFERENCE::GetPath(), SCH_COMPONENT::GetRef(), SCH_MARKER::GetUUID(), MARKER_PCB::GetUUID(), FIELDS_EDITOR_GRID_DATA_MODEL::groupMatch(), FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD(), SCH_LEGACY_PLUGIN::loadComponent(), LEGACY_PLUGIN::loadMODULE(), LEGACY_PLUGIN::loadPCB_TARGET(), LEGACY_PLUGIN::loadPCB_TEXT(), LEGACY_PLUGIN::loadTrackList(), NETLIST_EXPORTER_GENERIC::makeComponents(), SCH_EDIT_FRAME::mapExistingAnnotation(), SCH_ITEM::operator<(), SCH_COMPONENT::operator<(), PCB_PARSER::parseDIMENSION(), SCH_EDITOR_CONTROL::Paste(), SCH_SHEET_PATH::PathAsString(), SCH_SCREENS::ReplaceDuplicateTimeStamps(), SCH_COMPONENT::ReplaceInstanceSheetPath(), SCH_LEGACY_PLUGIN::saveComponent(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), SCH_EDIT_FRAME::SaveProject(), SCH_SEXPR_PLUGIN::saveSheet(), SCH_LEGACY_PLUGIN::saveSheet(), SCH_SEXPR_PLUGIN::saveSymbol(), SCH_COMPONENT::SCH_COMPONENT(), SCH_REFERENCE::SCH_REFERENCE(), SCH_SHEET::SCH_SHEET(), RC_ITEM::SetItems(), SwapItemData(), DIALOG_SCH_SHEET_PROPS::TransferDataToWindow(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataToWindow(), and NETLIST_EXPORTER_ORCADPCB2::WriteNetlist().

◆ m_Width

◆ ZeroOffset

wxPoint BOARD_ITEM::ZeroOffset
staticinherited

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

Definition at line 134 of file class_board_item.h.

Referenced by BOARD::GetPosition().


The documentation for this class was generated from the following files: