2018-10-13 18:37:28 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KICAD, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2016 CERN
|
2023-03-30 11:49:23 +00:00
|
|
|
* Copyright (C) 2018-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2021-01-27 22:15:38 +00:00
|
|
|
*
|
2018-10-13 18:37:28 +00:00
|
|
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GRAPHICS_IMPORTER_PCBNEW_H
|
|
|
|
#define GRAPHICS_IMPORTER_PCBNEW_H
|
|
|
|
|
2023-08-18 12:55:01 +00:00
|
|
|
#include <import_gfx/graphics_importer.h>
|
2018-10-13 18:37:28 +00:00
|
|
|
|
2021-07-29 09:47:43 +00:00
|
|
|
#include <layer_ids.h>
|
2018-10-13 18:37:28 +00:00
|
|
|
|
|
|
|
class BOARD;
|
2020-11-13 15:15:52 +00:00
|
|
|
class FOOTPRINT;
|
2020-10-04 23:34:59 +00:00
|
|
|
class PCB_SHAPE;
|
2023-03-30 11:49:23 +00:00
|
|
|
class PCB_TEXT;
|
2018-10-13 18:37:28 +00:00
|
|
|
|
|
|
|
class GRAPHICS_IMPORTER_PCBNEW : public GRAPHICS_IMPORTER
|
|
|
|
{
|
|
|
|
public:
|
2018-11-05 16:04:05 +00:00
|
|
|
GRAPHICS_IMPORTER_PCBNEW();
|
2018-10-13 18:37:28 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Set the target layer for the imported shapes.
|
|
|
|
*
|
2018-10-13 18:37:28 +00:00
|
|
|
* @param aLayer is the layer to be used by the imported shapes.
|
|
|
|
*/
|
|
|
|
void SetLayer( PCB_LAYER_ID aLayer )
|
|
|
|
{
|
|
|
|
m_layer = aLayer;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Return the target layer for the imported shapes.
|
2018-10-13 18:37:28 +00:00
|
|
|
*/
|
|
|
|
PCB_LAYER_ID GetLayer() const
|
|
|
|
{
|
|
|
|
return m_layer;
|
|
|
|
}
|
|
|
|
|
2023-08-18 18:27:48 +00:00
|
|
|
void AddLine( const VECTOR2D& aOrigin, const VECTOR2D& aEnd, double aWidth,
|
|
|
|
const COLOR4D& aColor ) override;
|
2018-10-13 18:37:28 +00:00
|
|
|
|
2023-08-18 18:27:48 +00:00
|
|
|
void AddCircle( const VECTOR2D& aOrigin, double aRadius, double aWidth, bool aFilled,
|
|
|
|
const COLOR4D& aColor ) override;
|
2018-10-13 18:37:28 +00:00
|
|
|
|
2022-01-20 23:08:48 +00:00
|
|
|
void AddArc( const VECTOR2D& aCenter, const VECTOR2D& aStart, const EDA_ANGLE& aAngle,
|
2023-08-18 18:27:48 +00:00
|
|
|
double aWidth, const COLOR4D& aColor ) override;
|
2018-10-13 18:37:28 +00:00
|
|
|
|
2023-08-18 18:27:48 +00:00
|
|
|
void AddPolygon( const std::vector<VECTOR2D>& aVertices, double aWidth,
|
|
|
|
const COLOR4D& aColor ) override;
|
2018-10-13 18:37:28 +00:00
|
|
|
|
2021-12-28 22:13:54 +00:00
|
|
|
void AddText( const VECTOR2D& aOrigin, const wxString& aText, double aHeight, double aWidth,
|
|
|
|
double aThickness, double aOrientation, GR_TEXT_H_ALIGN_T aHJustify,
|
2023-08-18 18:27:48 +00:00
|
|
|
GR_TEXT_V_ALIGN_T aVJustify, const COLOR4D& aColor ) override;
|
2018-10-13 18:37:28 +00:00
|
|
|
|
2018-11-01 09:47:41 +00:00
|
|
|
void AddSpline( const VECTOR2D& aStart, const VECTOR2D& aBezierControl1,
|
2023-08-18 18:27:48 +00:00
|
|
|
const VECTOR2D& aBezierControl2, const VECTOR2D& aEnd, double aWidth,
|
|
|
|
const COLOR4D& aColor ) override;
|
2018-11-01 09:47:41 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
/**
|
|
|
|
* Convert an imported coordinate to a board coordinate, according to the internal units,
|
|
|
|
* user scale and offset
|
|
|
|
*
|
|
|
|
* @param aCoordinate is the imported coordinate in mm.
|
2018-11-05 16:04:05 +00:00
|
|
|
*/
|
2023-02-19 03:40:07 +00:00
|
|
|
VECTOR2I MapCoordinate( const VECTOR2D& aCoordinate );
|
2018-11-05 16:04:05 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
/**
|
|
|
|
* If aLineWidth < 0, the default line thickness value is returned.
|
|
|
|
*
|
|
|
|
* @param aLineWidth is the line thickness in mm to convert.
|
|
|
|
* @return a line thickness in a board Iu value, according to the internal units.
|
2018-11-05 16:04:05 +00:00
|
|
|
*/
|
|
|
|
int MapLineWidth( double aLineWidth );
|
|
|
|
|
2018-10-13 18:37:28 +00:00
|
|
|
protected:
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Create an object representing a graphical shape.
|
2020-10-04 23:34:59 +00:00
|
|
|
virtual std::unique_ptr<PCB_SHAPE> createDrawing() = 0;
|
2018-10-13 18:37:28 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
///< Create an object representing a text.
|
|
|
|
virtual std::unique_ptr<PCB_TEXT> createText() = 0;
|
2018-10-13 18:37:28 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Target layer for the imported shapes.
|
2018-10-13 18:37:28 +00:00
|
|
|
PCB_LAYER_ID m_layer;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class GRAPHICS_IMPORTER_BOARD : public GRAPHICS_IMPORTER_PCBNEW
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GRAPHICS_IMPORTER_BOARD( BOARD* aBoard )
|
|
|
|
: m_board( aBoard )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2020-10-04 23:34:59 +00:00
|
|
|
std::unique_ptr<PCB_SHAPE> createDrawing() override;
|
2023-03-30 11:49:23 +00:00
|
|
|
std::unique_ptr<PCB_TEXT> createText() override;
|
2018-10-13 18:37:28 +00:00
|
|
|
|
|
|
|
BOARD* m_board;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-11-13 01:33:30 +00:00
|
|
|
class GRAPHICS_IMPORTER_FOOTPRINT : public GRAPHICS_IMPORTER_PCBNEW
|
2018-10-13 18:37:28 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-11-13 15:15:52 +00:00
|
|
|
GRAPHICS_IMPORTER_FOOTPRINT( FOOTPRINT* aFootprint )
|
2020-11-13 01:33:30 +00:00
|
|
|
: m_footprint( aFootprint )
|
2018-10-13 18:37:28 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2020-10-04 23:34:59 +00:00
|
|
|
std::unique_ptr<PCB_SHAPE> createDrawing() override;
|
2023-03-30 11:49:23 +00:00
|
|
|
std::unique_ptr<PCB_TEXT> createText() override;
|
2018-10-13 18:37:28 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* m_footprint;
|
2018-10-13 18:37:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* GRAPHICS_IMPORTER_PCBNEW */
|