145 std::swap( abPos.
x, abPos.
y );
202 std::swap( xyPos.
x, xyPos.
y );
240 wxString
name = wxT(
"apt_macro" );
249 default:
return wxT(
"??" );
361 bbox = poly_shape.
BBox();
385 wxASSERT_MSG(
false, wxT(
"GERBER_DRAW_ITEM shape is unknown!" ) );
402 corners[2] = bbox.
GetEnd();
403 corners[1] =
VECTOR2I( corners[2].x, corners[0].y );
404 corners[3] =
VECTOR2I( corners[0].x, corners[2].y );
413 for(
int ii = 0; ii < 4; ii++ )
417 org.
x = std::min( org.
x, corners[ii].
x );
418 org.
y = std::min( org.
y, corners[ii].
y );
420 end.
x = std::max(
end.
x, corners[ii].
x );
421 end.
y = std::max(
end.
y, corners[ii].
y );
436 m_End += aMoveVector;
455 static D_CODE dummyD_CODE( 0 );
459 static bool show_err;
462 if( d_codeDescr ==
nullptr )
463 d_codeDescr = &dummyD_CODE;
563 wxMessageBox( wxT(
"Trace_Segment() type error" ) );
582 if( start.
x >
end.
x )
583 std::swap( start,
end );
591 bool change =
delta.y < 0;
630 aPolygon->
Mirror( { 0, 0 }, FLIP_DIRECTION::TOP_BOTTOM );
645 std::vector<VECTOR2I> points;
649 points.reserve( pointCount );
651 for(
int ii = 0; ii < pointCount; ii++ )
654 points[ii] = p + aOffset;
658 GRClosedPoly( aDC, pointCount, &points[0], aFilledShape, aColor );
668 aList.emplace_back(
_(
"Type" ), msg );
673 msg =
_(
"Attribute" );
676 text =
_(
"No attribute" );
682 msg.Printf(
_(
"D Code %d" ),
m_DCode );
686 text =
_(
"No attribute" );
691 aList.emplace_back( msg,
text );
695 aList.emplace_back(
_(
"Graphic Layer" ), msg );
705 msg.Printf( wxT(
"(%.4f, %.4f)" ), xStart, yStart );
706 aList.emplace_back(
_(
"Position" ), msg );
710 msg.Printf( wxT(
"(%.4f, %.4f)" ), xStart, yStart );
711 aList.emplace_back(
_(
"Start" ), msg );
713 msg.Printf( wxT(
"(%.4f, %.4f)" ), xEnd, yEnd );
714 aList.emplace_back(
_(
"End" ), msg );
722 aList.emplace_back(
_(
"Rotation" ), msg );
726 aList.emplace_back(
_(
"Polarity" ), msg );
729 msg.Printf( wxT(
"A:%s B:%s" ),
m_mirrorA ?
_(
"Yes" ) :
_(
"No" ),
731 aList.emplace_back(
_(
"Mirror" ), msg );
734 msg =
m_swapAxis ? wxT(
"A=Y B=X" ) : wxT(
"A=X B=Y" );
735 aList.emplace_back(
_(
"AB axis" ), msg );
743 wxString cmp_pad_msg;
747 net_msg =
_(
"Net:" );
748 net_msg << wxS(
" " );
751 net_msg <<
_(
"<no net>" );
760 cmp_pad_msg.Printf(
_(
"Cmp: %s Pad: %s" ),
766 cmp_pad_msg.Printf(
_(
"Cmp: %s Pad: %s Fct %s" ),
775 cmp_pad_msg =
_(
"Cmp:" );
779 aList.emplace_back( net_msg, cmp_pad_msg );
793 return BITMAPS::add_line;
804 return BITMAPS::add_graphical_polygon;
807 return BITMAPS::info;
862 if(
radius < MIN_HIT_TEST_RADIUS )
863 radius = MIN_HIT_TEST_RADIUS;
873 int size = ( (
m_Size.
x < MIN_HIT_TEST_RADIUS ) ? MIN_HIT_TEST_RADIUS :
m_Size.
x );
895 else if( end_angle < start_angle )
903 return ( test_angle > start_angle && test_angle < end_angle );
921 if(
radius < MIN_HIT_TEST_RADIUS )
922 radius = MIN_HIT_TEST_RADIUS;
949void GERBER_DRAW_ITEM::Show(
int nestLevel, std::ostream& os )
const
951 NestedSpace( nestLevel, os ) <<
'<' <<
GetClass().Lower().mb_str() <<
953 " addr=\"" << std::hex <<
this << std::dec <<
'"' <<
955 " size=\"" <<
m_Size <<
'"' <<
956 " flags=\"" <<
m_flags <<
'"' <<
958 "<end" <<
m_End <<
"/>";
960 os <<
"</" <<
GetClass().Lower().mb_str() <<
">\n";
968 std::vector<int> layers( 2 );
1017 const std::vector<KICAD_T>& aScanTypes )
1019 for(
KICAD_T scanType : aScanTypes )
1021 if( scanType ==
Type() )
1023 if( INSPECT_RESULT::QUIT == inspector(
this, testData ) )
1024 return INSPECT_RESULT::QUIT;
1028 return INSPECT_RESULT::CONTINUE;
1036 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...
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.
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)
virtual std::vector< int > ViewGetLayers() 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.
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 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
virtual wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a pointer to an image to be used in menus.
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
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
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.
EDA_ANGLE m_DisplayRotation
VECTOR2I m_DisplayOffset
< Parameters used only to draw (display) items on this layer.
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.
static constexpr double LOD_SHOW
Return this constant from ViewGetLOD() to show the item unconditionally.
static constexpr double lodScaleForThreshold(int aWhatIu, int aThresholdIu)
Get the scale at which aWhatIu would be drawn at the same size as aThresholdIu on screen.
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)
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
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
double Distance(const VECTOR2< extended_type > &aVector) const
Compute the distance between two vectors.
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 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.
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)
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)
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