2017-09-17 22:44:30 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2017 Jon Evans <jon@craftyjon.com>
|
2021-03-13 17:45:33 +00:00
|
|
|
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2017-09-17 22:44:30 +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 3 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GERBVIEW_PAINTER_H
|
|
|
|
#define __GERBVIEW_PAINTER_H
|
|
|
|
|
2021-07-29 09:47:43 +00:00
|
|
|
#include <layer_ids.h>
|
2023-09-07 00:23:19 +00:00
|
|
|
#include <gal/painter.h>
|
2019-03-23 18:26:44 +00:00
|
|
|
|
|
|
|
#include <dcode.h>
|
2018-01-29 12:26:58 +00:00
|
|
|
#include <gbr_display_options.h>
|
2017-09-17 22:44:30 +00:00
|
|
|
#include <geometry/shape_poly_set.h>
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
|
|
|
|
class EDA_ITEM;
|
|
|
|
class GERBER_DRAW_ITEM;
|
|
|
|
class GERBER_FILE_IMAGE;
|
|
|
|
|
|
|
|
|
|
|
|
namespace KIGFX
|
|
|
|
{
|
|
|
|
class GAL;
|
|
|
|
|
|
|
|
/**
|
2021-07-28 17:52:07 +00:00
|
|
|
* Store GerbView specific render settings.
|
2017-09-17 22:44:30 +00:00
|
|
|
*/
|
|
|
|
class GERBVIEW_RENDER_SETTINGS : public RENDER_SETTINGS
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
friend class GERBVIEW_PAINTER;
|
|
|
|
|
|
|
|
GERBVIEW_RENDER_SETTINGS();
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
void LoadColors( const COLOR_SETTINGS* aSettings ) override;
|
2017-09-17 22:44:30 +00:00
|
|
|
|
|
|
|
/// @copydoc RENDER_SETTINGS::GetColor()
|
2020-07-11 17:42:00 +00:00
|
|
|
virtual COLOR4D GetColor( const VIEW_ITEM* aItem, int aLayer ) const override;
|
2017-09-17 22:44:30 +00:00
|
|
|
|
|
|
|
/**
|
2021-07-28 17:52:07 +00:00
|
|
|
* Return the color used to draw a layer.
|
|
|
|
*
|
2017-09-17 22:44:30 +00:00
|
|
|
* @param aLayer is the layer number.
|
|
|
|
*/
|
|
|
|
inline const COLOR4D& GetLayerColor( int aLayer ) const
|
|
|
|
{
|
|
|
|
return m_layerColors[aLayer];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-07-28 17:52:07 +00:00
|
|
|
* Change the color used to draw a layer.
|
|
|
|
*
|
2017-09-17 22:44:30 +00:00
|
|
|
* @param aLayer is the layer number.
|
|
|
|
* @param aColor is the new color.
|
|
|
|
*/
|
|
|
|
inline void SetLayerColor( int aLayer, const COLOR4D& aColor )
|
|
|
|
{
|
|
|
|
m_layerColors[aLayer] = aColor;
|
|
|
|
|
|
|
|
update(); // recompute other shades of the color
|
|
|
|
}
|
|
|
|
|
2022-09-16 16:20:36 +00:00
|
|
|
const COLOR4D& GetBackgroundColor() const override
|
2021-07-28 17:52:07 +00:00
|
|
|
{
|
|
|
|
return m_layerColors[ LAYER_GERBVIEW_BACKGROUND ];
|
|
|
|
}
|
2018-09-17 23:19:58 +00:00
|
|
|
|
2018-10-03 07:50:05 +00:00
|
|
|
void SetBackgroundColor( const COLOR4D& aColor ) override
|
|
|
|
{
|
2020-01-13 01:44:19 +00:00
|
|
|
m_layerColors[ LAYER_GERBVIEW_BACKGROUND ] = aColor;
|
2018-10-03 07:50:05 +00:00
|
|
|
}
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
const COLOR4D& GetGridColor() override { return m_layerColors[ LAYER_GERBVIEW_GRID ]; }
|
2018-09-17 23:19:58 +00:00
|
|
|
|
|
|
|
const COLOR4D& GetCursorColor() override { return m_layerColors[ LAYER_CURSOR ]; }
|
|
|
|
|
2021-09-07 20:34:10 +00:00
|
|
|
bool GetShowPageLimits() const override;
|
2017-09-17 22:44:30 +00:00
|
|
|
|
2021-07-30 13:52:28 +00:00
|
|
|
/// Clear all highlight selections (dcode, net, component, attribute selection)
|
|
|
|
void ClearHighlightSelections();
|
|
|
|
|
2017-09-17 22:44:30 +00:00
|
|
|
/// If set to anything but an empty string, will highlight items with matching component
|
|
|
|
wxString m_componentHighlightString;
|
|
|
|
|
|
|
|
/// If set to anything but an empty string, will highlight items with matching net
|
|
|
|
wxString m_netHighlightString;
|
|
|
|
|
|
|
|
/// If set to anything but an empty string, will highlight items with matching attribute
|
|
|
|
wxString m_attributeHighlightString;
|
|
|
|
|
2021-03-13 17:45:33 +00:00
|
|
|
/// If set to anything but >0 (in fact 10 the min dcode value),
|
|
|
|
/// will highlight items with matching dcode
|
|
|
|
int m_dcodeHighlightValue;
|
|
|
|
|
2017-09-17 22:44:30 +00:00
|
|
|
protected:
|
|
|
|
/// Maximum font size for D-Codes and other strings
|
|
|
|
static const double MAX_FONT_SIZE;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-07-28 17:52:07 +00:00
|
|
|
* Methods for drawing GerbView specific items.
|
2017-09-17 22:44:30 +00:00
|
|
|
*/
|
|
|
|
class GERBVIEW_PAINTER : public PAINTER
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GERBVIEW_PAINTER( GAL* aGal );
|
|
|
|
|
2021-01-30 14:41:31 +00:00
|
|
|
/// @copydoc PAINTER::GetSettings()
|
2017-09-17 22:44:30 +00:00
|
|
|
virtual GERBVIEW_RENDER_SETTINGS* GetSettings() override
|
|
|
|
{
|
|
|
|
return &m_gerbviewSettings;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// @copydoc PAINTER::Draw()
|
|
|
|
virtual bool Draw( const VIEW_ITEM* aItem, int aLayer ) override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
GERBVIEW_RENDER_SETTINGS m_gerbviewSettings;
|
|
|
|
|
|
|
|
// Drawing functions
|
|
|
|
void draw( /*const*/ GERBER_DRAW_ITEM* aVia, int aLayer );
|
|
|
|
|
2019-03-23 18:26:44 +00:00
|
|
|
/**
|
2021-07-28 17:52:07 +00:00
|
|
|
* Helper routine to draw a polygon.
|
|
|
|
*
|
|
|
|
* @param aParent Pointer to the draw item for AB Position calculation.
|
|
|
|
* @param aPolygon the polygon to draw.
|
|
|
|
* @param aFilled If true, draw the polygon as filled, otherwise only outline.
|
|
|
|
* @param aShift If true, draw the polygon relative to the parent item position.
|
2019-03-23 18:26:44 +00:00
|
|
|
*/
|
2019-12-14 09:14:50 +00:00
|
|
|
void drawPolygon( GERBER_DRAW_ITEM* aParent, const SHAPE_POLY_SET& aPolygon,
|
|
|
|
bool aFilled, bool aShift = false );
|
2017-09-17 22:44:30 +00:00
|
|
|
|
|
|
|
/// Helper to draw a flashed shape (aka spot)
|
|
|
|
void drawFlashedShape( GERBER_DRAW_ITEM* aItem, bool aFilled );
|
|
|
|
|
|
|
|
/// Helper to draw an aperture macro shape
|
|
|
|
void drawApertureMacro( GERBER_DRAW_ITEM* aParent, bool aFilled );
|
|
|
|
|
|
|
|
/**
|
2021-07-28 17:52:07 +00:00
|
|
|
* Get the thickness to draw for a line (e.g. 0 thickness lines get a minimum value).
|
|
|
|
*
|
|
|
|
* @param aActualThickness line own thickness.
|
|
|
|
* @return the thickness to draw.
|
2017-09-17 22:44:30 +00:00
|
|
|
*/
|
|
|
|
int getLineThickness( int aActualThickness ) const;
|
|
|
|
};
|
|
|
|
} // namespace KIGFX
|
|
|
|
|
|
|
|
#endif /* __GERBVIEW_PAINTER_H */
|