121 aOrientation =
angle.Normalize90();
142 std::swap( abPos.
x, abPos.
y );
185 std::swap( xyPos.
x, xyPos.
y );
223 wxString
name = wxT(
"apt_macro" );
232 default:
return wxT(
"??" );
272 bbox.
Inflate( radius, radius );
298 int radius = code->
m_Size.
x >> 1;
299 bbox.
Inflate( radius, radius );
344 bbox = poly_shape.
BBox();
354 int radius = (
m_Size.
x + 1 ) / 2;
368 wxASSERT_MSG(
false, wxT(
"GERBER_DRAW_ITEM shape is unknown!" ) );
388 m_End += aMoveVector;
407 static D_CODE dummyD_CODE( 0 );
411 static bool show_err;
414 if( d_codeDescr ==
nullptr )
415 d_codeDescr = &dummyD_CODE;
515 wxMessageBox( wxT(
"Trace_Segment() type error" ) );
534 if( start.
x > end.
x )
535 std::swap( start, end );
543 bool change =
delta.y < 0;
582 aPolygon->
Mirror(
false,
true );
597 std::vector<VECTOR2I> points;
601 points.reserve( pointCount );
603 for(
int ii = 0; ii < pointCount; ii++ )
606 points[ii] = p + aOffset;
610 GRClosedPoly( aDC, pointCount, &points[0], aFilledShape, aColor );
620 aList.emplace_back(
_(
"Type" ), msg );
625 msg =
_(
"Attribute" );
628 text =
_(
"No attribute" );
634 msg.Printf(
_(
"D Code %d" ),
m_DCode );
638 text =
_(
"No attribute" );
643 aList.emplace_back( msg,
text );
647 aList.emplace_back(
_(
"Graphic Layer" ), msg );
657 msg.Printf( wxT(
"(%.4f, %.4f)" ), xStart, yStart );
658 aList.emplace_back(
_(
"Position" ), msg );
662 msg.Printf( wxT(
"(%.4f, %.4f)" ), xStart, yStart );
663 aList.emplace_back(
_(
"Start" ), msg );
665 msg.Printf( wxT(
"(%.4f, %.4f)" ), xEnd, yEnd );
666 aList.emplace_back(
_(
"End" ), msg );
674 aList.emplace_back(
_(
"Rotation" ), msg );
678 aList.emplace_back(
_(
"Polarity" ), msg );
681 msg.Printf( wxT(
"A:%s B:%s" ),
m_mirrorA ?
_(
"Yes" ) :
_(
"No" ),
683 aList.emplace_back(
_(
"Mirror" ), msg );
686 msg =
m_swapAxis ? wxT(
"A=Y B=X" ) : wxT(
"A=X B=Y" );
687 aList.emplace_back(
_(
"AB axis" ), msg );
695 wxString cmp_pad_msg;
699 net_msg =
_(
"Net:" );
700 net_msg << wxS(
" " );
703 net_msg <<
_(
"<no net>" );
712 cmp_pad_msg.Printf(
_(
"Cmp: %s Pad: %s" ),
718 cmp_pad_msg.Printf(
_(
"Cmp: %s Pad: %s Fct %s" ),
727 cmp_pad_msg =
_(
"Cmp:" );
731 aList.emplace_back( net_msg, cmp_pad_msg );
814 if( radius < MIN_HIT_TEST_RADIUS )
815 radius = MIN_HIT_TEST_RADIUS;
825 int size = ( (
m_Size.
x < MIN_HIT_TEST_RADIUS ) ? MIN_HIT_TEST_RADIUS :
m_Size.
x );
828 bool radius_hit = ( std::fabs( test_radius.
EuclideanNorm() - radius) < size );
847 else if( end_angle < start_angle )
855 return ( test_angle > start_angle && test_angle < end_angle );
873 if( radius < MIN_HIT_TEST_RADIUS )
874 radius = MIN_HIT_TEST_RADIUS;
901void GERBER_DRAW_ITEM::Show(
int nestLevel, std::ostream& os )
const
903 NestedSpace( nestLevel, os ) <<
'<' <<
GetClass().Lower().mb_str() <<
905 " addr=\"" << std::hex <<
this << std::dec <<
'"' <<
907 " size=\"" <<
m_Size <<
'"' <<
908 " flags=\"" <<
m_flags <<
'"' <<
911 "<end" <<
m_End <<
"/>";
913 os <<
"</" <<
GetClass().Lower().mb_str() <<
">\n";
961 return level / ( size + 1 );
970 const std::vector<KICAD_T>& aScanTypes )
972 for(
KICAD_T scanType : aScanTypes )
974 if( scanType ==
Type() )
constexpr EDA_IU_SCALE gerbIUScale
BITMAPS
A list of all bitmap identifiers.
wxString m_AmName
The name of the aperture macro as defined like AMVB_RECTANGLE* (name is VB_RECTANGLE)
void SetOrigin(const Vec &pos)
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
const Vec & GetOrigin() const
coord_type GetHeight() const
coord_type GetWidth() const
bool Contains(const Vec &aPoint) const
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
void SetEnd(coord_type x, coord_type y)
A gerber DCODE (also called Aperture) definition.
APERTURE_MACRO * GetMacro() const
void DrawFlashedShape(const GERBER_DRAW_ITEM *aParent, wxDC *aDC, const COLOR4D &aColor, const VECTOR2I &aShapePos, bool aFilledShape)
Draw the dcode shape for flashed items.
wxString m_AperFunction
the aperture attribute (created by a TA.AperFunction command).
int GetShapeDim(GERBER_DRAW_ITEM *aParent)
Calculate a value that can be used to evaluate the size of text when displaying the D-Code of an item...
VECTOR2I m_Size
Horizontal and vertical dimensions.
APERTURE_T m_ApertType
Aperture type ( Line, rectangle, circle, oval poly, macro )
void ConvertShapeToPolygon(const GERBER_DRAW_ITEM *aParent)
Convert a shape to an equivalent polygon.
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
EDA_ITEM_FLAGS GetStatus() const
const wxString & GetValue() const
bool m_DisplayFlashedItemsFill
Option to draw flashed items (filled/sketch)
COLOR4D m_NegativeDrawColor
The color used to draw negative objects, usually the background color, but not always,...
bool m_DisplayPolygonsFill
Option to draw polygons (filled/sketch)
bool m_DisplayLinesFill
Option to draw line items (filled/sketch)
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
bool GetTextD_CodePrms(int &aSize, VECTOR2I &aPos, EDA_ANGLE &aOrientation)
Return the best size and orientation to display the D_Code on screen.
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
D_CODE * GetDcodeDescr() const
Return the GetDcodeDescr of this object, or NULL.
void SetLayerParameters()
Initialize parameters from Image and Layer parameters found in the gerber file: m_UnitsMetric,...
wxString ShowGBRShape() const
bool HasNegativeItems()
Optimize screen refresh (when no items are in background color refresh can be faster).
VECTOR2I GetABPosition(const VECTOR2I &aXYPosition) const
Return the image position of aPosition for this object.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
VECTOR2I GetXYPosition(const VECTOR2I &aABPosition) const
Return the image position of aPosition for this object.
void MoveXY(const VECTOR2I &aMoveVector)
Move this object.
SHAPE_POLY_SET m_ShapeAsPolygon
int GetLayer() const
Return the layer this item is on.
virtual wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a pointer to an image to be used in menus.
void ConvertSegmentToPolygon()
Convert a line to an equivalent polygon.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
GBR_BASIC_SHAPE_TYPE m_ShapeType
GERBER_DRAW_ITEM(GERBER_FILE_IMAGE *aGerberparams)
GERBER_FILE_IMAGE * m_GerberImageFile
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
wxString GetClass() const override
void PrintGerberPoly(wxDC *aDC, const COLOR4D &aColor, const VECTOR2I &aOffset, bool aFilledShape)
Print the polygon stored in m_PolyCorners.
INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &aScanTypes) override
Return a user-visible description string of this item.
void SetNetAttributes(const GBR_NETLIST_METADATA &aNetAttributes)
SHAPE_POLY_SET m_AbsolutePolygon
virtual const BOX2I ViewBBox() const override
bool HitTest(const VECTOR2I &aRefPos, int aAccuracy=0) const override
Test if the given wxPoint is within the bounds of this object.
GBR_NETLIST_METADATA m_netAttributes
the string given by a TO attribute set in aperture (dcode).
void Print(wxDC *aDC, const VECTOR2I &aOffset, GBR_DISPLAY_OPTIONS *aOptions)
static GERBER_FILE_IMAGE_LIST & GetImagesList()
const wxString GetDisplayName(int aIdx, bool aNameOnly=false, bool aFullName=false)
Get the display name for the layer at aIdx.
Hold the image data and parameters for one gerber file and layer parameters.
bool m_SwapAxis
false if A = X and B = Y (default); true if A = Y, B = X
double m_LocalRotation
Local rotation added to m_ImageRotation.
VECTOR2I m_Offset
Coord Offset, from OF command.
bool m_ImageNegative
true = Negative image
COLOR4D GetPositiveDrawColor() const
std::map< wxString, int > m_ComponentsList
bool m_MirrorB
true: mirror / axis B (Y)
D_CODE * GetDCODE(int aDCODE) const
Return a pointer to the D_CODE within this GERBER for the given aDCODE.
int m_ImageRotation
Image rotation (0, 90, 180, 270 only) in degrees.
VECTOR2I m_ImageOffset
Coord Offset, from IO command.
std::map< wxString, int > m_NetnamesList
int m_GraphicLayer
Graphic layer Number.
bool m_GerbMetric
false = Inches, true = metric
bool m_MirrorA
true: mirror / axis A (X)
VECTOR2I m_Scale
scale (X and Y) of layer.
VECTOR2I m_ImageJustifyOffset
Image Justify Offset on XY axis (default = 0,0)
GERBER_LAYER & GetLayerParams()
A color representation with 4 components: red, green, blue, alpha.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
int PointCount() const
Return the number of points (vertices) in this line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
Represent a set of closed polygons.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...
void Mirror(bool aX=true, bool aY=false, const VECTOR2I &aRef={ 0, 0 })
Mirror the line points about y or x (or both)
SHAPE_LINE_CHAIN & Outline(int aIndex)
int NewOutline()
Creates a new hole in a given outline.
int OutlineCount() const
Return the number of vertices in a given outline/hole.
void Move(const VECTOR2I &aVector) override
bool Contains(const VECTOR2I &aP, int aSubpolyIndex=-1, int aAccuracy=0, bool aUseBBoxCaches=false) const
Return true if a given subpolygon contains the point aP.
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
EDA_UNITS GetUserUnits() const
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
static constexpr EDA_ANGLE & ANGLE_360
static constexpr EDA_ANGLE & ANGLE_0
const INSPECTOR_FUNC & INSPECTOR
void GRCSegm(wxDC *DC, const VECTOR2I &A, const VECTOR2I &B, int width, const COLOR4D &Color)
void GRCircle(wxDC *aDC, const VECTOR2I &aPos, int aRadius, int aWidth, const COLOR4D &aColor)
void GRFilledSegment(wxDC *aDC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor)
void GRClosedPoly(wxDC *DC, int n, const VECTOR2I *Points, bool Fill, const COLOR4D &Color)
Draw a closed polyline and fill it if Fill, in object space.
void GRArc(wxDC *aDC, const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCenter, int aWidth, const COLOR4D &aColor)
#define GERBER_DCODE_LAYER(x)
bool IsDCodeLayer(int aLayer)
#define GERBER_DRAW_LAYER(x)
Message panel definition file.
double ToUserUnit(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnit, double aValue)
Function To_User_Unit convert aValue in internal units to the appropriate user units defined by aUnit...
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
wxString UnescapeString(const wxString &aSource)
constexpr int mmToIU(double mm) const
bool TestSegmentHit(const VECTOR2I &aRefPoint, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
bool HitTestPoints(const VECTOR2I &pointA, const VECTOR2I &pointB, double threshold)
Test, if two points are near each other.
double GetLineLength(const VECTOR2I &aPointA, const VECTOR2I &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
VECTOR2< double > VECTOR2D