141 std::swap( abPos.
x, abPos.
y );
198 std::swap( xyPos.
x, xyPos.
y );
236 wxString
name = wxT(
"apt_macro" );
245 default:
return wxT(
"??" );
350 bbox = poly_shape.
BBox();
374 wxASSERT_MSG(
false, wxT(
"GERBER_DRAW_ITEM shape is unknown!" ) );
391 corners[2] = bbox.
GetEnd();
392 corners[1] =
VECTOR2I( corners[2].x, corners[0].y );
393 corners[3] =
VECTOR2I( corners[0].x, corners[2].y );
402 for(
int ii = 0; ii < 4; ii++ )
406 org.
x = std::min( org.
x, corners[ii].
x );
407 org.
y = std::min( org.
y, corners[ii].
y );
409 end.x = std::max(
end.x, corners[ii].
x );
410 end.y = std::max(
end.y, corners[ii].
y );
425 m_End += aMoveVector;
444 static D_CODE dummyD_CODE( 0 );
448 static bool show_err;
451 if( d_codeDescr ==
nullptr )
452 d_codeDescr = &dummyD_CODE;
484 halfPenWidth =
m_Size.x >> 1;
552 wxMessageBox( wxT(
"Trace_Segment() type error" ) );
571 if( start.
x >
end.x )
572 std::swap( start,
end );
580 bool change =
delta.y < 0;
640 if( pointCount <= 0 )
643 std::vector<VECTOR2I> points( pointCount );
645 for(
int ii = 0; ii < pointCount; ii++ )
648 points[ii] = p + aOffset;
652 GRClosedPoly( aDC, pointCount, &points[0], aFilledShape, aColor );
662 aList.emplace_back(
_(
"Type" ), msg );
667 msg =
_(
"Attribute" );
670 text =
_(
"No attribute" );
676 msg.Printf(
_(
"D Code %d" ),
m_DCode );
680 text =
_(
"No attribute" );
685 aList.emplace_back( msg,
text );
689 aList.emplace_back(
_(
"Graphic Layer" ), msg );
699 msg.Printf( wxT(
"(%.4f, %.4f)" ), xStart, yStart );
700 aList.emplace_back(
_(
"Position" ), msg );
704 msg.Printf( wxT(
"(%.4f, %.4f)" ), xStart, yStart );
705 aList.emplace_back(
_(
"Start" ), msg );
707 msg.Printf( wxT(
"(%.4f, %.4f)" ), xEnd, yEnd );
708 aList.emplace_back(
_(
"End" ), msg );
716 aList.emplace_back(
_(
"Rotation" ), msg );
720 aList.emplace_back(
_(
"Polarity" ), msg );
723 msg.Printf( wxT(
"A:%s B:%s" ),
m_mirrorA ?
_(
"Yes" ) :
_(
"No" ),
725 aList.emplace_back(
_(
"Mirror" ), msg );
728 msg =
m_swapAxis ? wxT(
"A=Y B=X" ) : wxT(
"A=X B=Y" );
729 aList.emplace_back(
_(
"AB axis" ), msg );
737 wxString cmp_pad_msg;
741 net_msg =
_(
"Net:" );
742 net_msg << wxS(
" " );
745 net_msg <<
_(
"<no net>" );
754 cmp_pad_msg.Printf(
_(
"Cmp: %s Pad: %s" ),
760 cmp_pad_msg.Printf(
_(
"Cmp: %s Pad: %s Fct %s" ),
769 cmp_pad_msg =
_(
"Cmp:" );
773 aList.emplace_back( net_msg, cmp_pad_msg );
808 const int MIN_HIT_TEST_RADIUS =
gerbIUScale.mmToIU( 0.01 );
856 if(
radius < MIN_HIT_TEST_RADIUS )
857 radius = MIN_HIT_TEST_RADIUS;
867 int size = ( (
m_Size.x < MIN_HIT_TEST_RADIUS ) ? MIN_HIT_TEST_RADIUS :
m_Size.x );
889 else if( end_angle < start_angle )
897 return ( test_angle > start_angle && test_angle < end_angle );
915 if(
radius < MIN_HIT_TEST_RADIUS )
916 radius = MIN_HIT_TEST_RADIUS;
943void GERBER_DRAW_ITEM::Show(
int nestLevel, std::ostream& os )
const
945 NestedSpace( nestLevel, os ) <<
'<' <<
GetClass().Lower().mb_str() <<
947 " addr=\"" << std::hex <<
this << std::dec <<
'"' <<
949 " size=\"" <<
m_Size <<
'"' <<
950 " flags=\"" <<
m_flags <<
'"' <<
952 "<end" <<
m_End <<
"/>";
954 os <<
"</" <<
GetClass().Lower().mb_str() <<
">\n";
962 std::vector<int> layers( 2 );
1011 const std::vector<KICAD_T>& aScanTypes )
1013 for(
KICAD_T scanType : aScanTypes )
1015 if( scanType ==
Type() )
1030 return wxString::Format(
_(
"%s (D%d) on layer %d: %s" ),
constexpr EDA_IU_SCALE gerbIUScale
BITMAPS
A list of all bitmap identifiers.
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
wxString m_AmName
The name of the aperture macro as defined like AMVB_RECTANGLE* (name is VB_RECTANGLE)
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
constexpr const Vec GetEnd() const
constexpr void SetOrigin(const Vec &pos)
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
constexpr size_type GetWidth() const
constexpr Vec Centre() const
constexpr size_type GetHeight() const
constexpr bool Contains(const Vec &aPoint) const
constexpr const Vec & GetOrigin() const
constexpr 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...
static bool IsValidDcodeValue(int aDcodeValue)
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.
KICAD_T Type() const
Returns the type of object.
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
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)
virtual std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
bool GetTextD_CodePrms(int &aSize, VECTOR2I &aPos, EDA_ANGLE &aOrientation)
Return the best size and orientation to display the D_Code on screen.
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.
void ConvertSegmentToPolygon()
Convert a lines in m_ShapeAsPolygon 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
virtual wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
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.
void SetNetAttributes(const GBR_NETLIST_METADATA &aNetAttributes)
SHAPE_POLY_SET m_AbsolutePolygon
INSPECT_RESULT Visit(INSPECTOR aInspector, void *aTestData, const std::vector< KICAD_T > &aScanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
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.
A color representation with 4 components: red, green, blue, alpha.
static double lodScaleForThreshold(const KIGFX::VIEW *aView, int aWhatIu, int aThresholdIu)
Get the scale at which aWhatIu would be drawn at the same size as aThresholdIu on screen.
static constexpr double LOD_SHOW
Return this constant from ViewGetLOD() to show the item unconditionally.
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.
void RemoveAllContours()
Remove 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)
int NewOutline()
Creates a new empty polygon in the set and returns its index.
void Mirror(const VECTOR2I &aRef, FLIP_DIRECTION aFlipDirection)
Mirror the line points about y or x (or both)
int OutlineCount() const
Return the number of outlines in the set.
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_0
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
static constexpr EDA_ANGLE ANGLE_360
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
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 polygon onto the drawing context aDC and optionally fills and/or draws a border around ...
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)
@ TOP_BOTTOM
Flip top to bottom (around the X axis)
Message panel definition file.
KICOMMON_API double ToUserUnit(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnit, double aValue)
Convert aValue in internal units to the appropriate user units defined by aUnit.
wxString UnescapeString(const wxString &aSource)
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)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D