KiCad PCB EDA Suite
Loading...
Searching...
No Matches
simple_overlay_item.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KICAD, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
21
23#include <view/view.h>
24
25
26using namespace KIGFX::PREVIEW;
27
28
30 EDA_ITEM( NOT_USED ), // this item is never added to a BOARD so it needs no type.
33 m_lineWidth( 1.0 )
34{
35}
36
37
38void SIMPLE_OVERLAY_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
39{
40 KIGFX::GAL& gal = *aView->GetGAL();
41
42 setupGal( gal );
43 drawPreviewShape( aView );
44}
45
46
47std::vector<int> SIMPLE_OVERLAY_ITEM::ViewGetLayers() const
48{
49 std::vector<int> aLayers{ LAYER_GP_OVERLAY };
50 return aLayers;
51}
52
53
55{
56 // default impl: set up the GAL options we have - the
57 // overriding class can add to this if needed
61 aGal.SetIsStroke( true );
62 aGal.SetIsFill( true );
63}
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:37
Abstract interface for drawing on a 2D-surface.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
void setupGal(KIGFX::GAL &aGal) const
Set up the GAL canvas - this provides a default implementation, that sets fill, stroke and width.
std::vector< int > ViewGetLayers() const override
Set the overlay layer only.
void ViewDraw(int aLayer, KIGFX::VIEW *aView) const override
Draw the preview - this is done by calling the two functions: setupGal() and drawPreviewShape().
virtual void drawPreviewShape(KIGFX::VIEW *aView) const
Draw the preview onto the given GAL.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:63
GAL * GetGAL() const
Return the GAL this view is using to draw graphical primitives.
Definition view.h:207
@ WHITE
Definition color4d.h:44
@ LAYER_GP_OVERLAY
General purpose overlay.
Definition layer_ids.h:275
@ NOT_USED
the 3d code uses this value
Definition typeinfo.h:72