KiCad PCB EDA Suite
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 (C) 2017 Kicad Developers, see change_log.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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
25
27#include <view/view.h>
28
29
30using namespace KIGFX::PREVIEW;
31
32
33SIMPLE_OVERLAY_ITEM::SIMPLE_OVERLAY_ITEM():
34 EDA_ITEM( NOT_USED ), // this item is never added to a BOARD so it needs no type.
35 m_fillColor( WHITE ),
36 m_strokeColor( WHITE ),
37 m_lineWidth( 1.0 )
38{
39}
40
41
42void SIMPLE_OVERLAY_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
43{
44 KIGFX::GAL& gal = *aView->GetGAL();
45
46 setupGal( gal );
47 drawPreviewShape( aView );
48}
49
50
51void SIMPLE_OVERLAY_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const
52{
53 static const int SelectionLayer = LAYER_GP_OVERLAY;
54
55 aLayers[0] = SelectionLayer;
56 aCount = 1;
57}
58
59
61{
62 // default impl: set up the GAL options we have - the
63 // overriding class can add to this if needed
67 aGal.SetIsStroke( true );
68 aGal.SetIsFill( true );
69}
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
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.
void ViewGetLayers(int aLayers[], int &aCount) 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:69
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:195
@ WHITE
Definition: color4d.h:48
@ LAYER_GP_OVERLAY
general purpose overlay
Definition: layer_ids.h:218
@ NOT_USED
the 3d code uses this value
Definition: typeinfo.h:79