KiCad PCB EDA Suite
polygon_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 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, 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 
29 #include <view/view.h>
30 
31 using namespace KIGFX::PREVIEW;
32 
33 
36 {
37 }
38 
39 void POLYGON_ITEM::SetPoints( const std::vector<VECTOR2I>& aLockedPts,
40  const std::vector<VECTOR2I>& aLeaderPts )
41 {
44 
47 
48  for( auto& pt: aLockedPts )
49  {
50  m_lockedChain.Append( pt, false );
51  m_polyfill.Append( pt );
52  }
53 
54  for( auto& pt: aLeaderPts )
55  {
56  m_leaderChain.Append( pt, false );
57  m_polyfill.Append( pt );
58  }
59 }
60 
61 
63 {
65  aGal.DrawPolygon( m_polyfill );
66 
67  // draw the leader line in a different color
70 }
71 
72 
74 {
75  return m_polyfill.BBox();
76 }
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
virtual const BOX2I ViewBBox() const override
Gets the bounding box of the polygon
COLOR4D PreviewOverlayDefaultColor()
The default fill/stroke color of preview overlay items.
SIMPLE_OVERLAY_ITEM is class that represents a visual area drawn on a canvas, used to temporarily dem...
void SetPoints(const std::vector< VECTOR2I > &aLockedInPts, const std::vector< VECTOR2I > &aLeaderPts)
Set the polygon points.
SHAPE_POLY_SET m_polyfill
polygon fill
Definition: polygon_item.h:76
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
int NewOutline()
Creates a new empty polygon in the set and returns its index
SHAPE_LINE_CHAIN m_leaderChain
Definition: polygon_item.h:73
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.
void Clear()
Function Clear() Removes all points from the line chain.
void drawPreviewShape(KIGFX::GAL &aGal) const override
Draw rectangle and centre line onto GAL
SHAPE_LINE_CHAIN m_lockedChain
complete polyline of locked in and leader points
Definition: polygon_item.h:73
const BOX2I BBox(int aClearance=0) const override
Function BBox()
Class GAL is the abstract interface for drawing on a 2D-surface.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline) ...