KiCad PCB EDA Suite
bright_box.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) 2013 CERN
5  * @author Maciej Suminski <maciej.suminski@cern.ch>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
27 #include <class_track.h>
28 
29 using namespace KIGFX;
30 
31 const double BRIGHT_BOX::LINE_WIDTH = 10000.0;
32 const COLOR4D BRIGHT_BOX::BOX_COLOR = KIGFX::COLOR4D( 0.0, 1.0, 0.0, 1.0 );
33 
35  EDA_ITEM( NOT_USED ), // this item is never added to a BOARD so it needs no type
36  m_item( nullptr ),
37  m_lineWidth( LINE_WIDTH ),
38  m_color( BOX_COLOR )
39 {
40 }
41 
42 
43 void BRIGHT_BOX::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
44 {
45  if( !m_item )
46  return;
47 
48  auto gal = aView->GetGAL();
49 
50  gal->SetIsStroke( true );
51  gal->SetIsFill( false );
52  gal->SetLineWidth( m_lineWidth );
53  gal->SetStrokeColor( m_color );
54 
55  BOX2I box = m_item->ViewBBox();
56 
57  gal->DrawRectangle( box.GetOrigin(), box.GetOrigin() + box.GetSize() );
58 }
59 
60 
62 {
63  m_item = aItem;
64 }
const Vec & GetOrigin() const
Definition: box2.h:181
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:56
void ViewDraw(int aLayer, KIGFX::VIEW *aView) const override
Function ViewDraw() Draws the parts of the object belonging to layer aLayer.
Definition: bright_box.cpp:43
the 3d code uses this value
Definition: typeinfo.h:92
const Vec & GetSize() const
Definition: box2.h:177
Functions relatives to tracks, vias and segments used to fill zones.
void SetItem(EDA_ITEM *aItem)
Definition: bright_box.cpp:61
GAL * GetGAL() const
Function GetGAL() Returns the GAL this view is using to draw graphical primitives.
Definition: view.h:177
KIGFX::COLOR4D m_color
Definition: bright_box.h:97
static const KIGFX::COLOR4D BOX_COLOR
Definition: bright_box.h:92
EDA_ITEM * m_item
Definition: bright_box.h:95
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
Class VIEW.
Definition: view.h:58
virtual const BOX2I ViewBBox() const override
static const double LINE_WIDTH
Definition: bright_box.h:93
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
double m_lineWidth
Definition: bright_box.h:96
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
#define LINE_WIDTH
Definition: export_idf.cpp:50