38 #include <wx/msgdlg.h> 121 aOrientation =
RAD2DECIDEG( atan2( (
double)delta.y, (
double)delta.x ) );
144 aSize = (double) size;
160 std::swap( abPos.x, abPos.y );
184 wxPoint xyPos = aABPosition;
202 std::swap( xyPos.x, xyPos.y );
236 return _(
"Circle" );
239 return wxT(
"spot_oval" );
242 return wxT(
"spot_circle" );
245 return wxT(
"spot_rect" );
248 return wxT(
"spot_poly" );
251 return wxT(
"polygon" );
255 wxString
name = wxT(
"apt_macro" );
297 bbox.
Inflate( bb.GetWidth() / 2, bb.GetHeight() / 2 );
298 bbox.
SetOrigin( bb.GetOrigin().x, bb.GetOrigin().y );
305 bbox.
Inflate( radius, radius );
315 arc_angle *= 180.0 / M_PI;
317 if( arc_angle < 0.0 )
335 int radius = code->
m_Size.x >> 1;
336 bbox.
Inflate( radius, radius );
386 bbox.
Inflate( bb.GetWidth() / 2, bb.GetHeight() / 2 );
387 bbox.
SetOrigin( bb.GetOrigin().x, bb.GetOrigin().y );
392 int radius = (
m_Size.x + 1 ) / 2;
400 bbox =
EDA_RECT( wxPoint( xmin, ymin ), wxSize( xmax - xmin + 1, ymax - ymin + 1 ) );
406 wxASSERT_MSG(
false, wxT(
"GERBER_DRAW_ITEM shape is unknown!" ) );
438 m_End += aMoveVector;
457 static D_CODE dummyD_CODE( 0 );
461 static bool show_err;
464 if( d_codeDescr ==
NULL )
465 d_codeDescr = &dummyD_CODE;
497 halfPenWidth =
m_Size.x >> 1;
568 wxMessageBox( wxT(
"Trace_Segment() type error" ) );
587 if( start.x > end.x )
588 std::swap( start, end );
591 wxPoint delta = end - start;
596 bool change = delta.y < 0;
609 wxPoint close = corner;
614 if( delta.x || delta.y)
625 if( delta.x || delta.y )
644 std::vector<wxPoint> points;
648 points.reserve( pointCount );
650 for(
int ii = 0; ii < pointCount; ii++ )
653 points[ii] = p + aOffset;
657 GRClosedPoly(
nullptr, aDC, pointCount, &points[0], aFilledShape, aColor, aColor );
667 aList.emplace_back(
_(
"Type" ), msg );
672 msg =
_(
"Attribute" );
675 text =
_(
"No attribute" );
681 msg.Printf(
_(
"D Code %d" ),
m_DCode );
685 text =
_(
"No attribute" );
690 aList.emplace_back( msg, text );
694 aList.emplace_back(
_(
"Graphic Layer" ), msg );
701 aList.emplace_back(
_(
"Rotation" ), msg );
705 aList.emplace_back(
_(
"Polarity" ), msg );
708 msg.Printf( wxT(
"A:%s B:%s" ),
711 aList.emplace_back(
_(
"Mirror" ), msg );
714 msg =
m_swapAxis ? wxT(
"A=Y B=X" ) : wxT(
"A=X B=Y" );
715 aList.emplace_back(
_(
"AB axis" ), msg );
723 wxString cmp_pad_msg;
727 net_msg =
_(
"Net:" );
731 net_msg <<
"<no net>";
739 cmp_pad_msg.Printf(
_(
"Cmp: %s Pad: %s" ),
743 cmp_pad_msg.Printf(
_(
"Cmp: %s Pad: %s Fct %s" ),
751 cmp_pad_msg =
_(
"Cmp:" );
755 aList.emplace_back( net_msg, cmp_pad_msg );
836 if( radius < MIN_HIT_TEST_RADIUS )
837 radius = MIN_HIT_TEST_RADIUS;
847 int size = ( (
m_Size.x < MIN_HIT_TEST_RADIUS ) ? MIN_HIT_TEST_RADIUS
851 bool radius_hit = ( std::fabs( test_radius.
EuclideanNorm() - radius) < size );
866 end_angle = 2 * M_PI;
868 else if( end_angle < start_angle )
870 end_angle += 2 * M_PI;
875 return ( test_angle > start_angle && test_angle < end_angle );
890 if( radius < MIN_HIT_TEST_RADIUS )
891 radius = MIN_HIT_TEST_RADIUS;
918 void GERBER_DRAW_ITEM::Show(
int nestLevel, std::ostream& os )
const 920 NestedSpace( nestLevel, os ) <<
'<' <<
GetClass().Lower().mb_str() <<
922 " shape=\"" <<
m_Shape <<
'"' <<
923 " addr=\"" << std::hex <<
this << std::dec <<
'"' <<
925 " size=\"" <<
m_Size <<
'"' <<
926 " flags=\"" <<
m_flags <<
'"' <<
929 "<end" <<
m_End <<
"/>";
931 os <<
"</" <<
GetClass().Lower().mb_str() <<
">\n";
981 return level / ( size + 1 );
994 if( stype ==
Type() )
void SetLayerParameters()
Function SetLayerParameters Initialize parameters from Image and Layer parameters found in the gerber...
#define TEXT_ANGLE_HORIZ
Frequent text rotations, used with {Set,Get}TextAngle(), in 0.1 degrees for now, hoping to migrate to...
bool m_DisplayPolygonsFill
Option to draw polygons (filled/sketch)
STATUS_FLAGS GetStatus() const
D_CODE * GetDcodeDescr() const
Function GetDcodeDescr returns the GetDcodeDescr of this object, or NULL.
bool IsDCodeLayer(int aLayer)
wxString name
The name of the aperture macro.
int OutlineCount() const
Returns the number of outlines in the set
wxString GetClass() const override
Function GetClass returns the class name.
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
PNG memory record (file in memory).
BITMAP_DEF GetMenuImage() const override
void MoveAB(const wxPoint &aMoveVector)
Function MoveAB move this object.
wxSize m_Size
Horizontal and vertical dimensions.
const wxString GetDisplayName(int aIdx, bool aNameOnly=false)
bool HasNegativeItems()
Function HasNegativeItems.
APERTURE_T m_Shape
shape ( Line, rectangle, circle , oval .. )
virtual const BOX2I ViewBBox() const override
int GetLayer() const
Function GetLayer returns the layer this item is on.
D_CODE * GetDCODE(int aDCODE) const
Function GetDCODE returns a pointer to the D_CODE within this GERBER for the given aDCODE.
GERBER_FILE_IMAGE holds the Image data and parameters for one gerber file and layer parameters (TODO:...
COLOR4D GetPositiveDrawColor() const
double RAD2DECIDEG(double rad)
GERBER_DRAW_ITEM(GERBER_FILE_IMAGE *aGerberparams)
void SetOrigin(const wxPoint &pos)
void Print(wxDC *aDC, const wxPoint &aOffset, GBR_DISPLAY_OPTIONS *aOptions)
void GRCSegm(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, int aPenSize, COLOR4D Color)
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
bool HitTest(const wxPoint &aRefPos, int aAccuracy=0) const override
Function HitTest tests if the given wxPoint is within the bounds of this object.
wxPoint m_ImageJustifyOffset
bool Contains(const VECTOR2I &aP, int aSubpolyIndex=-1, int aAccuracy=0, bool aUseBBoxCaches=false) const
Returns true if a given subpolygon contains the point aP.
void SetNetAttributes(const GBR_NETLIST_METADATA &aNetAttributes)
void RotatePoint(int *pX, int *pY, double angle)
double NormalizeAngleRadiansPos(double Angle)
The base class for create windows for drawing purpose.
int PointCount() const
Function PointCount()
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[]) override
void NORMALIZE_ANGLE_90(T &Angle)
bool Contains(const wxPoint &aPoint) const
const BITMAP_OPAQUE pad_xpm[1]
const INSPECTOR_FUNC & INSPECTOR
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
void Mirror(bool aX=true, bool aY=false, const VECTOR2I &aRef={ 0, 0 })
Mirrors the line points about y or x (or both)
bool m_DisplayLinesFill
Option to draw line items (filled/sketch)
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.
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.
#define GERBER_DCODE_LAYER(x)
const VECTOR2I & CPoint(int aIndex) const
Function Point()
const wxPoint GetEnd() const
const BITMAP_OPAQUE add_graphical_polygon_xpm[1]
COLOR4D m_NegativeDrawColor
The color used to draw negative objects, usually the background color, but not always,...
wxPoint GetABPosition(const wxPoint &aXYPosition) const
Function GetABPosition returns the image position of aPosition for this object.
SHAPE_POLY_SET * GetApertureMacroShape(const GERBER_DRAW_ITEM *aParent, wxPoint aShapePos)
Function GetApertureMacroShape Calculate the primitive shape for flashed items.
VECTOR2< double > VECTOR2D
void Move(const VECTOR2I &aVector) override
EDA_RECT GetBoundingBox() const
Returns the bounding box of the shape.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
const wxPoint GetOrigin() const
void SetEnd(int x, int y)
coord_type GetWidth() const
const BITMAP_OPAQUE add_line_xpm[1]
bool m_DisplayFlashedItemsFill
Option to draw flashed items (filled/sketch)
static GERBER_FILE_IMAGE_LIST & GetImagesList()
GBR_NETLIST_METADATA m_netAttributes
the string given by a TO attribute set in aperture (dcode).
bool GetTextD_CodePrms(int &aSize, wxPoint &aPos, double &aOrientation)
Returns the best size and orientation to display the D_Code on screen.
double Angle() const
Function Angle computes the angle of the vector.
const BITMAP_OPAQUE info_xpm[1]
int NewOutline()
Creates a new empty polygon in the set and returns its index
void ConvertSegmentToPolygon()
Function ConvertSegmentToPolygon convert a line to an equivalent polygon.
std::map< wxString, int > m_NetnamesList
wxString m_AperFunction
the aperture attribute (created by a TA.AperFunction command) attached to the D_CODE
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
virtual wxString GetSelectMenuText(EDA_UNITS aUnits) const override
void Normalize()
Ensures that the height ant width are positive.
void PrintGerberPoly(wxDC *aDC, COLOR4D aColor, const wxPoint &aOffset, bool aFilledShape)
Function PrintGerberPoly a helper function used to print the polygon stored in m_PolyCorners.
D_CODE holds a gerber DCODE (also called Aperture) definition.
void DrawFlashedShape(GERBER_DRAW_ITEM *aParent, EDA_RECT *aClipBox, wxDC *aDC, COLOR4D aColor, wxPoint aShapePos, bool aFilledShape)
Function DrawFlashedShape Draw the dcode shape for flashed items.
wxString UnescapeString(const wxString &aSource)
void GRFilledSegment(EDA_RECT *aClipBox, wxDC *aDC, wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor)
void GRCircle(EDA_RECT *ClipBox, wxDC *DC, int xc, int yc, int r, int width, COLOR4D Color)
bool HitTestPoints(const wxPoint &pointA, const wxPoint &pointB, double threshold)
Test, if two points are near each other.
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.
Handle the component boundary box.
double DECIDEG2RAD(double deg)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
A base class for most all the KiCad significant classes used in schematics and boards.
coord_type GetHeight() const
const BOX2I BBox(int aClearance=0) const override
Function BBox()
APERTURE_MACRO * GetMacro() const
T EuclideanNorm() const
Destructor.
wxPoint GetXYPosition(const wxPoint &aABPosition) const
Function GetXYPosition returns the image position of aPosition for this object.
#define GERBER_DRAW_LAYER(x)
void ConvertShapeToPolygon()
Function ConvertShapeToPolygon convert a shape to an equivalent polygon.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
void MoveXY(const wxPoint &aMoveVector)
Function MoveXY move this object.
Message panel definition file.
static constexpr int Millimeter2iu(double mm)
void GRClosedPoly(EDA_RECT *ClipBox, wxDC *DC, int n, const wxPoint *Points, bool Fill, COLOR4D Color, COLOR4D BgColor)
Draw a closed polygon onto the drawing context aDC and optionally fills and/or draws a border around ...
const BOX2I BBox(int aClearance=0) const override
Function BBox()
int GetShapeDim(GERBER_DRAW_ITEM *aParent)
Function GetShapeDim calculates a value that can be used to evaluate the size of text when displaying...
GERBER_FILE_IMAGE * m_GerberImageFile
std::map< wxString, int > m_ComponentsList
const wxString & GetValue() const
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
GERBER_LAYER & GetLayerParams()
Function GetLayerParams.
const wxSize GetSize() const
KICAD_T Type() const
Returns the type of object.
wxString ShowGBRShape() const
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
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)
void GRArc1(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int xc, int yc, COLOR4D Color)
A color representation with 4 components: red, green, blue, alpha.