2010-09-28 14:42:05 +00:00
|
|
|
/*
|
2011-09-30 18:15:37 +00:00
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
2010-09-28 14:42:05 +00:00
|
|
|
*
|
2016-05-26 11:57:43 +00:00
|
|
|
* Copyright (C) 1992-2016 <Jean-Pierre Charras>
|
2023-02-10 09:04:52 +00:00
|
|
|
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2010-09-28 14:42:05 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2018-01-29 12:26:58 +00:00
|
|
|
#ifndef GERBER_DRAW_ITEM_H
|
|
|
|
#define GERBER_DRAW_ITEM_H
|
2011-10-17 20:01:27 +00:00
|
|
|
|
2020-10-14 01:06:53 +00:00
|
|
|
#include <eda_item.h>
|
2021-07-29 09:47:43 +00:00
|
|
|
#include <layer_ids.h>
|
2012-09-01 13:38:27 +00:00
|
|
|
#include <gr_basic.h>
|
2016-08-16 10:56:20 +00:00
|
|
|
#include <gbr_netlist_metadata.h>
|
2016-07-27 13:27:19 +00:00
|
|
|
#include <dcode.h>
|
2017-09-17 22:43:20 +00:00
|
|
|
#include <geometry/shape_poly_set.h>
|
2022-01-15 01:12:24 +00:00
|
|
|
#include <geometry/eda_angle.h>
|
2011-10-17 20:01:27 +00:00
|
|
|
|
2016-05-25 14:48:38 +00:00
|
|
|
class GERBER_FILE_IMAGE;
|
2012-05-04 17:44:42 +00:00
|
|
|
class GBR_LAYOUT;
|
|
|
|
class D_CODE;
|
2013-01-12 17:32:24 +00:00
|
|
|
class MSG_PANEL_ITEM;
|
2016-06-02 09:30:39 +00:00
|
|
|
class GBR_DISPLAY_OPTIONS;
|
2019-05-31 12:15:25 +00:00
|
|
|
class PCB_BASE_FRAME;
|
2010-09-28 14:42:05 +00:00
|
|
|
|
2017-09-17 22:43:20 +00:00
|
|
|
namespace KIGFX
|
|
|
|
{
|
|
|
|
class VIEW;
|
2017-11-02 20:41:29 +00:00
|
|
|
}
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2011-10-17 20:01:27 +00:00
|
|
|
|
2023-02-10 09:04:52 +00:00
|
|
|
/* Shapes id for basic shapes ( .m_ShapeType member ) */
|
|
|
|
enum GBR_BASIC_SHAPE_TYPE
|
2021-09-09 20:49:16 +00:00
|
|
|
{
|
2010-09-28 14:42:05 +00:00
|
|
|
GBR_SEGMENT = 0, // usual segment : line with rounded ends
|
|
|
|
GBR_ARC, // Arcs (with rounded ends)
|
|
|
|
GBR_CIRCLE, // ring
|
|
|
|
GBR_POLYGON, // polygonal shape
|
|
|
|
GBR_SPOT_CIRCLE, // flashed shape: round shape (can have hole)
|
|
|
|
GBR_SPOT_RECT, // flashed shape: rectangular shape can have hole)
|
|
|
|
GBR_SPOT_OVAL, // flashed shape: oval shape
|
2011-10-17 20:01:27 +00:00
|
|
|
GBR_SPOT_POLY, // flashed shape: regular polygon, 3 to 12 edges
|
2023-02-10 10:18:09 +00:00
|
|
|
GBR_SPOT_MACRO // complex shape described by a macro
|
2010-09-28 14:42:05 +00:00
|
|
|
};
|
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
class GERBER_DRAW_ITEM : public EDA_ITEM
|
2010-09-28 14:42:05 +00:00
|
|
|
{
|
|
|
|
public:
|
2016-05-26 11:57:43 +00:00
|
|
|
GERBER_DRAW_ITEM( GERBER_FILE_IMAGE* aGerberparams );
|
2010-09-28 14:42:05 +00:00
|
|
|
~GERBER_DRAW_ITEM();
|
|
|
|
|
2016-08-16 10:56:20 +00:00
|
|
|
void SetNetAttributes( const GBR_NETLIST_METADATA& aNetAttributes );
|
2017-09-17 22:43:20 +00:00
|
|
|
const GBR_NETLIST_METADATA& GetNetAttributes() const { return m_netAttributes; }
|
2016-08-16 10:56:20 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
/**
|
2021-01-26 15:23:37 +00:00
|
|
|
* Return the layer this item is on.
|
2012-05-04 17:44:42 +00:00
|
|
|
*/
|
2016-05-26 11:57:43 +00:00
|
|
|
int GetLayer() const;
|
2010-09-28 14:42:05 +00:00
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
bool GetLayerPolarity() const { return m_LayerNegative; }
|
2010-12-18 18:47:58 +00:00
|
|
|
|
2017-11-13 10:30:23 +00:00
|
|
|
/**
|
2021-01-26 15:23:37 +00:00
|
|
|
* Return the best size and orientation to display the D_Code on screen.
|
|
|
|
*
|
2017-11-13 10:30:23 +00:00
|
|
|
* @param aSize is a reference to return the text size
|
|
|
|
* @param aPos is a reference to return the text position
|
|
|
|
* @param aOrientation is a reference to return the text orientation
|
|
|
|
* @return true if the parameters can be calculated, false for unknown D_Code
|
|
|
|
*/
|
2022-01-11 13:47:21 +00:00
|
|
|
bool GetTextD_CodePrms( int& aSize, VECTOR2I& aPos, EDA_ANGLE& aOrientation );
|
2017-11-13 10:30:23 +00:00
|
|
|
|
2010-12-15 20:15:24 +00:00
|
|
|
/**
|
2021-01-26 15:23:37 +00:00
|
|
|
* Optimize screen refresh (when no items are in background color refresh can be faster).
|
|
|
|
*
|
2010-12-15 20:15:24 +00:00
|
|
|
* @return true if this item or at least one shape (when using aperture macros
|
2021-01-26 15:23:37 +00:00
|
|
|
* must be drawn in background color.
|
2010-12-15 20:15:24 +00:00
|
|
|
*/
|
|
|
|
bool HasNegativeItems();
|
2010-09-28 14:42:05 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2021-01-26 15:23:37 +00:00
|
|
|
* Initialize parameters from Image and Layer parameters found in the gerber file:
|
2010-10-09 20:05:03 +00:00
|
|
|
* m_UnitsMetric,
|
|
|
|
* m_MirrorA, m_MirrorB,
|
|
|
|
* m_DrawScale, m_DrawOffset
|
|
|
|
*/
|
2011-10-17 20:01:27 +00:00
|
|
|
void SetLayerParameters();
|
2010-10-09 20:05:03 +00:00
|
|
|
|
2022-08-20 09:27:35 +00:00
|
|
|
void SetLayerPolarity( bool aNegative) { m_LayerNegative = aNegative; }
|
2010-10-15 18:59:26 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-26 15:23:37 +00:00
|
|
|
* Move this object.
|
|
|
|
*
|
|
|
|
* @param aMoveVector the move vector for this object, in XY gerber axis.
|
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
void MoveXY( const VECTOR2I& aMoveVector );
|
2010-09-28 14:42:05 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-26 15:23:37 +00:00
|
|
|
* Return the position of this object.
|
|
|
|
*
|
2010-10-09 20:05:03 +00:00
|
|
|
* This function exists mainly to satisfy the virtual GetPosition() in parent class
|
2021-01-26 15:23:37 +00:00
|
|
|
*
|
|
|
|
* @return The position of this object.
|
2010-09-28 14:42:05 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I GetPosition() const override { return m_Start; }
|
|
|
|
void SetPosition( const VECTOR2I& aPos ) override { m_Start = aPos; }
|
2011-11-29 17:25:30 +00:00
|
|
|
|
2010-10-09 20:05:03 +00:00
|
|
|
/**
|
2021-01-26 15:23:37 +00:00
|
|
|
* Return the image position of aPosition for this object.
|
|
|
|
*
|
2010-10-09 20:05:03 +00:00
|
|
|
* Image position is the value of aPosition, modified by image parameters:
|
|
|
|
* offsets, axis selection, scale, rotation
|
2021-01-26 15:23:37 +00:00
|
|
|
*
|
|
|
|
* @param aXYPosition is position in X,Y gerber axis
|
|
|
|
* @return The given position in plotter A,B axis.
|
2010-10-09 20:05:03 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I GetABPosition( const VECTOR2I& aXYPosition ) const;
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2010-10-10 17:57:54 +00:00
|
|
|
/**
|
2021-01-26 15:23:37 +00:00
|
|
|
* Return the image position of aPosition for this object.
|
|
|
|
*
|
2010-10-10 17:57:54 +00:00
|
|
|
* Image position is the value of aPosition, modified by image parameters:
|
|
|
|
* offsets, axis selection, scale, rotation
|
2021-01-26 15:23:37 +00:00
|
|
|
*
|
2010-10-10 17:57:54 +00:00
|
|
|
* @param aABPosition = position in A,B plotter axis
|
2021-01-26 15:23:37 +00:00
|
|
|
* @return The given position in X,Y axis.
|
2010-10-10 17:57:54 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I GetXYPosition( const VECTOR2I& aABPosition ) const;
|
2010-09-28 14:42:05 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-26 15:23:37 +00:00
|
|
|
* Return the GetDcodeDescr of this object, or NULL.
|
|
|
|
*
|
|
|
|
* @return a pointer to the DCode description (for flashed items).
|
2010-09-28 14:42:05 +00:00
|
|
|
*/
|
2017-09-17 22:43:20 +00:00
|
|
|
D_CODE* GetDcodeDescr() const;
|
2010-09-28 14:42:05 +00:00
|
|
|
|
2022-08-31 09:15:42 +00:00
|
|
|
const BOX2I GetBoundingBox() const override;
|
2010-09-28 14:42:05 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
void Print( wxDC* aDC, const VECTOR2I& aOffset, GBR_DISPLAY_OPTIONS* aOptions );
|
2010-09-28 14:42:05 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2021-01-26 15:23:37 +00:00
|
|
|
* Convert a line to an equivalent polygon.
|
|
|
|
*
|
2010-10-25 07:43:50 +00:00
|
|
|
* Useful when a line is plotted using a rectangular pen.
|
|
|
|
* In this case, the usual segment plot function cannot be used
|
2021-09-14 12:04:25 +00:00
|
|
|
* @param aPolygon is the SHAPE_POLY_SET to fill. If null (usual case),
|
|
|
|
* m_Polygon will be used
|
2010-10-25 07:43:50 +00:00
|
|
|
*/
|
2011-10-17 20:01:27 +00:00
|
|
|
void ConvertSegmentToPolygon();
|
2021-09-14 12:04:25 +00:00
|
|
|
void ConvertSegmentToPolygon( SHAPE_POLY_SET* aPolygon ) const;
|
2010-10-25 07:43:50 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2021-01-26 15:23:37 +00:00
|
|
|
* Print the polygon stored in m_PolyCorners.
|
2010-09-28 14:42:05 +00:00
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
void PrintGerberPoly( wxDC* aDC, const COLOR4D& aColor, const VECTOR2I& aOffset,
|
2021-07-26 17:28:37 +00:00
|
|
|
bool aFilledShape );
|
2010-09-28 14:42:05 +00:00
|
|
|
|
2023-02-10 09:04:52 +00:00
|
|
|
GBR_BASIC_SHAPE_TYPE ShapeType() const { return m_ShapeType; }
|
2010-09-28 14:42:05 +00:00
|
|
|
|
2020-04-24 13:36:10 +00:00
|
|
|
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
2010-09-28 14:42:05 +00:00
|
|
|
|
2017-09-17 22:43:20 +00:00
|
|
|
wxString ShowGBRShape() const;
|
2010-09-28 14:42:05 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-26 15:23:37 +00:00
|
|
|
* Test if the given wxPoint is within the bounds of this object.
|
|
|
|
*
|
2010-12-18 18:47:58 +00:00
|
|
|
* @param aRefPos a wxPoint to test
|
2010-09-28 14:42:05 +00:00
|
|
|
* @return bool - true if a hit, else false
|
|
|
|
*/
|
2022-01-01 06:04:08 +00:00
|
|
|
bool HitTest( const VECTOR2I& aRefPos, int aAccuracy = 0 ) const override;
|
2010-09-28 14:42:05 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-26 15:23:37 +00:00
|
|
|
* Test if the given wxRect intersect this object.
|
|
|
|
*
|
2010-09-28 14:42:05 +00:00
|
|
|
* For now, an ending point must be inside this rect.
|
2021-01-26 15:23:37 +00:00
|
|
|
*
|
2010-12-18 18:47:58 +00:00
|
|
|
* @param aRefArea a wxPoint to test
|
2021-01-26 15:23:37 +00:00
|
|
|
* @return true if a hit, else false
|
2010-09-28 14:42:05 +00:00
|
|
|
*/
|
2022-08-31 09:33:46 +00:00
|
|
|
bool HitTest( const BOX2I& aRefArea, bool aContained, int aAccuracy = 0 ) const override;
|
2010-09-28 14:42:05 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-26 15:23:37 +00:00
|
|
|
* @return the class name string.
|
2010-09-28 14:42:05 +00:00
|
|
|
*/
|
2016-09-25 17:06:49 +00:00
|
|
|
wxString GetClass() const override
|
2010-09-28 14:42:05 +00:00
|
|
|
{
|
|
|
|
return wxT( "GERBER_DRAW_ITEM" );
|
|
|
|
}
|
|
|
|
|
2010-09-29 06:05:36 +00:00
|
|
|
#if defined(DEBUG)
|
2016-09-25 17:06:49 +00:00
|
|
|
void Show( int nestLevel, std::ostream& os ) const override;
|
2010-09-29 06:05:36 +00:00
|
|
|
#endif
|
2011-12-14 17:25:42 +00:00
|
|
|
|
2017-09-17 22:43:20 +00:00
|
|
|
/// @copydoc VIEW_ITEM::ViewGetLayers()
|
|
|
|
virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
|
|
|
|
|
|
|
/// @copydoc VIEW_ITEM::ViewBBox()
|
|
|
|
virtual const BOX2I ViewBBox() const override;
|
|
|
|
|
|
|
|
/// @copydoc VIEW_ITEM::ViewGetLOD()
|
2020-09-21 15:03:08 +00:00
|
|
|
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2021-01-26 15:23:37 +00:00
|
|
|
///< @copydoc EDA_ITEM::Visit()
|
2022-08-20 09:27:35 +00:00
|
|
|
INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
|
2022-08-21 19:54:07 +00:00
|
|
|
const std::vector<KICAD_T>& aScanTypes ) override;
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2023-01-12 03:27:44 +00:00
|
|
|
///< @copydoc EDA_ITEM::GetItemDescription()
|
2024-06-27 09:11:55 +00:00
|
|
|
virtual wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2021-01-26 15:23:37 +00:00
|
|
|
///< @copydoc EDA_ITEM::GetMenuImage()
|
2021-03-08 02:59:07 +00:00
|
|
|
BITMAPS GetMenuImage() const override;
|
2021-01-26 15:23:37 +00:00
|
|
|
|
2021-09-09 20:49:16 +00:00
|
|
|
public:
|
2021-01-26 15:23:37 +00:00
|
|
|
bool m_UnitsMetric; // store here the gerber units (inch/mm). Used
|
|
|
|
// only to calculate aperture macros shapes sizes
|
2023-02-10 10:50:20 +00:00
|
|
|
GBR_BASIC_SHAPE_TYPE m_ShapeType; // Shape type of this gerber item
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I m_Start; // Line or arc start point or position of the shape
|
2021-01-26 15:23:37 +00:00
|
|
|
// for flashed items
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I m_End; // Line or arc end point
|
|
|
|
VECTOR2I m_ArcCentre; // for arcs only: Center of arc
|
2023-02-10 10:50:20 +00:00
|
|
|
SHAPE_POLY_SET m_ShapeAsPolygon; // Polygon shape data from G36 to G37 coordinates
|
2021-01-26 15:23:37 +00:00
|
|
|
// or for complex shapes which are converted to polygon
|
2023-02-19 03:40:07 +00:00
|
|
|
VECTOR2I m_Size; // Flashed shapes: size of the shape
|
2021-01-26 15:23:37 +00:00
|
|
|
// Lines : m_Size.x = m_Size.y = line width
|
|
|
|
bool m_Flashed; // True for flashed items
|
|
|
|
int m_DCode; // DCode used to draw this item.
|
|
|
|
// Allowed values are >= 10. 0 when unknown
|
|
|
|
// values 0 to 9 can be used for special purposes
|
|
|
|
// Regions (polygons) do not use DCode,
|
|
|
|
// so it is set to 0
|
|
|
|
wxString m_AperFunction; // the aperture function set by a %TA.AperFunction, xxx
|
|
|
|
// (stores the xxx value). Used for regions that do
|
|
|
|
// not have a attached DCode, but
|
|
|
|
// have a TA.AperFunction defined
|
|
|
|
GERBER_FILE_IMAGE* m_GerberImageFile; /* Gerber file image source of this item
|
|
|
|
* Note: some params stored in this class are common
|
|
|
|
* to the whole gerber file (i.e) the whole graphic
|
|
|
|
* layer and some can change when reading the file,
|
|
|
|
* so they are stored inside this item if there is no
|
|
|
|
* redundancy for these parameters
|
|
|
|
*/
|
|
|
|
|
2021-08-18 08:01:29 +00:00
|
|
|
// This polygon is to draw this item (mainly GBR_POLYGON), according to layer parameters
|
|
|
|
SHAPE_POLY_SET m_AbsolutePolygon; // the polygon to draw, in absolute coordinates
|
2021-09-09 20:49:16 +00:00
|
|
|
|
2021-01-26 15:23:37 +00:00
|
|
|
private:
|
|
|
|
// These values are used to draw this item, according to gerber layers parameters
|
|
|
|
// Because they can change inside a gerber image, they are stored here
|
|
|
|
// for each item
|
|
|
|
bool m_LayerNegative; // true = item in negative Layer
|
|
|
|
bool m_swapAxis; // false if A = X, B = Y; true if A =Y, B = Y
|
|
|
|
bool m_mirrorA; // true: mirror / axis A
|
|
|
|
bool m_mirrorB; // true: mirror / ax's B
|
2022-01-01 18:57:44 +00:00
|
|
|
VECTOR2I m_drawScale; // A and B scaling factor
|
|
|
|
VECTOR2I m_layerOffset; // Offset for A and B axis, from OF parameter
|
2021-01-26 15:23:37 +00:00
|
|
|
double m_lyrRotation; // Fine rotation, from OR parameter, in degrees
|
|
|
|
GBR_NETLIST_METADATA m_netAttributes; ///< the string given by a %TO attribute set in aperture
|
|
|
|
///< (dcode). Stored in each item, because %TO is
|
|
|
|
///< a dynamic object attribute
|
2017-09-17 22:43:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-01-29 12:26:58 +00:00
|
|
|
#endif /* GERBER_DRAW_ITEM_H */
|