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>
29 
30 
31 using namespace KIGFX::PREVIEW;
32 
33 
35  EDA_ITEM( NOT_USED ), // this item is never added to a BOARD so it needs no type.
36  m_fillColor( WHITE ),
37  m_strokeColor( WHITE ),
38  m_lineWidth( 1.0 )
39 {
40 }
41 
42 
43 void SIMPLE_OVERLAY_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
44 {
45  auto& gal = *aView->GetGAL();
46 
47  setupGal( gal );
48  drawPreviewShape( gal );
49 }
50 
51 
52 void SIMPLE_OVERLAY_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const
53 {
54  static const int SelectionLayer = ITEM_GAL_LAYER( GP_OVERLAY );
55 
56  aLayers[0] = SelectionLayer;
57  aCount = 1;
58 }
59 
60 
62 {
63  // default impl: set up the GAL options we have - the
64  // overriding class can add to this if needed
65  aGal.SetLineWidth( m_lineWidth );
67  aGal.SetFillColor( m_fillColor );
68  aGal.SetIsStroke( true );
69  aGal.SetIsFill( true );
70 }
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
void ViewDraw(int aLayer, KIGFX::VIEW *aView) const overridefinal
Draws the preview - this is done by calling the two functions: setupGal() and drawPreviewShape().
the 3d code uses this value
Definition: typeinfo.h:92
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
virtual void drawPreviewShape(KIGFX::GAL &aGal) const =0
Draw the preview onto the given GAL.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
#define ITEM_GAL_LAYER(layer)
macro for obtaining layer number for specific item (eg. pad or text)
Board layer functions and definitions.
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:151
Definition: colors.h:49
general purpose overlay
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.