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 
30 using namespace KIGFX::PREVIEW;
31 
32 
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 
42 void SIMPLE_OVERLAY_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
43 {
44  auto& gal = *aView->GetGAL();
45 
46  setupGal( gal );
47  drawPreviewShape( aView );
48 }
49 
50 
51 void 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
64  aGal.SetLineWidth( m_lineWidth );
66  aGal.SetFillColor( m_fillColor );
67  aGal.SetIsStroke( true );
68  aGal.SetIsFill( true );
69 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
the 3d code uses this value
Definition: typeinfo.h:92
void ViewDraw(int aLayer, KIGFX::VIEW *aView) const override
Draws the preview - this is done by calling the two functions: setupGal() and drawPreviewShape().
virtual void SetLineWidth(double aLineWidth)
Set the line width.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
GAL * GetGAL() const
Function GetGAL() Returns the GAL this view is using to draw graphical primitives.
Definition: view.h:177
general purpose overlay
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
void ViewGetLayers(int aLayers[], int &aCount) const override
Sets the overlay layer only.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:165
Definition: colors.h:49
virtual void drawPreviewShape(KIGFX::VIEW *aView) const
Draw the preview onto the given GAL.
Class VIEW.
Definition: view.h:58
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...
Class GAL is the abstract interface for drawing on a 2D-surface.