2013-03-18 19:36:07 +00:00
|
|
|
|
2012-01-14 19:50:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-01-22 12:06:34 +00:00
|
|
|
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-01-14 19:50:32 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-09-20 13:57:40 +00:00
|
|
|
/**
|
|
|
|
* @file class_zone.h
|
|
|
|
* @brief Classes to handle copper zones
|
|
|
|
*/
|
2007-12-09 12:59:06 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
#ifndef CLASS_ZONE_H_
|
|
|
|
#define CLASS_ZONE_H_
|
2007-12-09 12:59:06 +00:00
|
|
|
|
2011-09-20 13:57:40 +00:00
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
#include <vector>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <class_board_item.h>
|
|
|
|
#include <class_board_connected_item.h>
|
|
|
|
#include <layers_id_colors_and_visibility.h>
|
|
|
|
#include <PolyLine.h>
|
2012-02-06 05:44:19 +00:00
|
|
|
#include <class_zone_settings.h>
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2011-08-01 15:29:27 +00:00
|
|
|
|
2011-09-20 13:57:40 +00:00
|
|
|
class EDA_RECT;
|
2011-09-20 15:07:52 +00:00
|
|
|
class LINE_READER;
|
2011-09-20 13:57:40 +00:00
|
|
|
class EDA_DRAW_PANEL;
|
|
|
|
class PCB_EDIT_FRAME;
|
|
|
|
class BOARD;
|
|
|
|
class ZONE_CONTAINER;
|
2013-01-12 17:32:24 +00:00
|
|
|
class MSG_PANEL_ITEM;
|
|
|
|
|
2011-09-20 13:57:40 +00:00
|
|
|
|
2011-11-30 21:15:56 +00:00
|
|
|
/**
|
|
|
|
* Struct SEGMENT
|
|
|
|
* is a simple container used when filling areas with segments
|
|
|
|
*/
|
|
|
|
struct SEGMENT
|
2009-08-06 18:30:46 +00:00
|
|
|
{
|
|
|
|
wxPoint m_Start; // starting point of a segment
|
|
|
|
wxPoint m_End; // ending point of a segment
|
2011-09-20 13:57:40 +00:00
|
|
|
|
2009-08-06 18:30:46 +00:00
|
|
|
SEGMENT() {}
|
2011-09-20 15:07:52 +00:00
|
|
|
|
2011-11-30 21:15:56 +00:00
|
|
|
SEGMENT( const wxPoint& aStart, const wxPoint& aEnd )
|
2009-08-06 18:30:46 +00:00
|
|
|
{
|
|
|
|
m_Start = aStart;
|
|
|
|
m_End = aEnd;
|
|
|
|
}
|
2011-12-14 04:29:25 +00:00
|
|
|
};
|
2008-10-23 10:26:06 +00:00
|
|
|
|
2011-08-01 15:29:27 +00:00
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
/**
|
|
|
|
* Class ZONE_CONTAINER
|
|
|
|
* handles a list of polygons defining a copper zone.
|
|
|
|
* A zone is described by a main polygon, a time stamp, a layer, and a net name.
|
|
|
|
* Other polygons inside the main polygon are holes in the zone.
|
2008-01-23 22:39:09 +00:00
|
|
|
*/
|
2009-10-21 19:16:25 +00:00
|
|
|
class ZONE_CONTAINER : public BOARD_CONNECTED_ITEM
|
2007-12-09 12:59:06 +00:00
|
|
|
{
|
|
|
|
public:
|
2011-09-20 15:07:52 +00:00
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
ZONE_CONTAINER( BOARD* parent );
|
2012-01-14 19:50:32 +00:00
|
|
|
|
|
|
|
ZONE_CONTAINER( const ZONE_CONTAINER& aZone );
|
|
|
|
|
2008-01-23 22:39:09 +00:00
|
|
|
~ZONE_CONTAINER();
|
|
|
|
|
2011-09-20 15:07:52 +00:00
|
|
|
/**
|
|
|
|
* Function GetPosition
|
2009-08-06 18:30:46 +00:00
|
|
|
* @return a wxPoint, position of the first point of the outline
|
|
|
|
*/
|
2012-02-20 04:33:54 +00:00
|
|
|
const wxPoint& GetPosition() const; // was overload
|
2012-02-20 04:48:25 +00:00
|
|
|
void SetPosition( const wxPoint& aPos ) {} // was overload
|
2011-11-24 17:32:51 +00:00
|
|
|
|
2012-01-29 19:29:19 +00:00
|
|
|
/**
|
|
|
|
* Function SetPriority
|
|
|
|
* @param aPriority = the priority level
|
|
|
|
*/
|
|
|
|
void SetPriority( unsigned aPriority ) { m_priority = aPriority; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetPriority
|
|
|
|
* @return the priority level of this zone
|
|
|
|
*/
|
|
|
|
unsigned GetPriority() const { return m_priority; }
|
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
/**
|
2008-01-23 22:39:09 +00:00
|
|
|
* Function copy
|
2011-07-14 15:42:44 +00:00
|
|
|
* copy useful data from the source.
|
2008-01-23 22:39:09 +00:00
|
|
|
* flags and linked list pointers are NOT copied
|
|
|
|
*/
|
2011-09-20 15:07:52 +00:00
|
|
|
void Copy( ZONE_CONTAINER* src );
|
2008-01-23 22:39:09 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
|
2008-01-23 22:39:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Draw
|
|
|
|
* Draws the zone outline.
|
|
|
|
* @param panel = current Draw Panel
|
|
|
|
* @param DC = current Device Context
|
2008-04-01 05:21:50 +00:00
|
|
|
* @param aDrawMode = GR_OR, GR_XOR, GR_COPY ..
|
2010-12-14 15:56:30 +00:00
|
|
|
* @param offset = Draw offset (usually wxPoint(0,0))
|
2008-01-23 22:39:09 +00:00
|
|
|
*/
|
2011-09-20 15:07:52 +00:00
|
|
|
void Draw( EDA_DRAW_PANEL* panel,
|
|
|
|
wxDC* DC,
|
2012-09-01 13:38:27 +00:00
|
|
|
GR_DRAWMODE aDrawMode,
|
2011-09-20 15:07:52 +00:00
|
|
|
const wxPoint& offset = ZeroOffset );
|
2008-01-23 22:39:09 +00:00
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
/**
|
|
|
|
* Function DrawDrawFilledArea
|
|
|
|
* Draws the filled area for this zone (polygon list .m_FilledPolysList)
|
|
|
|
* @param panel = current Draw Panel
|
|
|
|
* @param DC = current Device Context
|
|
|
|
* @param offset = Draw offset (usually wxPoint(0,0))
|
|
|
|
* @param aDrawMode = GR_OR, GR_XOR, GR_COPY ..
|
|
|
|
*/
|
2011-01-21 19:30:59 +00:00
|
|
|
void DrawFilledArea( EDA_DRAW_PANEL* panel,
|
|
|
|
wxDC* DC,
|
2012-09-01 13:38:27 +00:00
|
|
|
GR_DRAWMODE aDrawMode,
|
2011-01-21 19:30:59 +00:00
|
|
|
const wxPoint& offset = ZeroOffset );
|
2008-01-31 20:53:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function DrawWhileCreateOutline
|
2011-09-20 15:07:52 +00:00
|
|
|
* Draws the zone outline when it is created.
|
|
|
|
* The moving edges are in XOR graphic mode, old segment in draw_mode graphic mode
|
|
|
|
* (usually GR_OR). The closing edge has its own shape.
|
2008-01-31 20:53:44 +00:00
|
|
|
* @param panel = current Draw Panel
|
|
|
|
* @param DC = current Device Context
|
|
|
|
* @param draw_mode = draw mode: OR, XOR ..
|
|
|
|
*/
|
2012-09-01 13:38:27 +00:00
|
|
|
void DrawWhileCreateOutline( EDA_DRAW_PANEL* panel, wxDC* DC,
|
|
|
|
GR_DRAWMODE draw_mode = GR_OR );
|
2008-09-26 19:51:36 +00:00
|
|
|
|
2013-11-24 17:48:14 +00:00
|
|
|
/** Function GetBoundingBox (virtual)
|
2011-03-29 19:33:07 +00:00
|
|
|
* @return an EDA_RECT that is the bounding box of the zone outline
|
2008-11-18 18:13:55 +00:00
|
|
|
*/
|
2013-11-24 17:48:14 +00:00
|
|
|
const EDA_RECT GetBoundingBox() const;
|
2008-11-18 18:13:55 +00:00
|
|
|
|
2011-08-09 03:41:20 +00:00
|
|
|
int GetClearance( BOARD_CONNECTED_ITEM* aItem = NULL ) const;
|
|
|
|
|
2008-11-18 18:13:55 +00:00
|
|
|
/**
|
2013-03-20 14:50:12 +00:00
|
|
|
* Function TestForCopperIslandAndRemoveInsulatedIslands
|
2008-11-18 18:13:55 +00:00
|
|
|
* Remove insulated copper islands found in m_FilledPolysList.
|
2011-07-14 15:42:44 +00:00
|
|
|
* @param aPcb = the board to analyze
|
2008-11-18 18:13:55 +00:00
|
|
|
*/
|
2013-03-20 14:50:12 +00:00
|
|
|
void TestForCopperIslandAndRemoveInsulatedIslands( BOARD* aPcb );
|
2008-11-18 18:13:55 +00:00
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
/**
|
|
|
|
* Function IsOnCopperLayer
|
|
|
|
* @return true if this zone is on a copper layer, false if on a technical layer
|
|
|
|
*/
|
2014-06-24 16:17:18 +00:00
|
|
|
bool IsOnCopperLayer() const
|
2008-09-26 19:51:36 +00:00
|
|
|
{
|
2014-06-24 18:30:39 +00:00
|
|
|
return IsCopperLayer( GetLayer() );
|
2008-09-26 19:51:36 +00:00
|
|
|
}
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2012-06-11 00:47:15 +00:00
|
|
|
/// How to fill areas: 0 = use filled polygons, 1 => fill with segments.
|
2012-05-29 18:10:56 +00:00
|
|
|
void SetFillMode( int aFillMode ) { m_FillMode = aFillMode; }
|
|
|
|
int GetFillMode() const { return m_FillMode; }
|
2011-11-30 21:15:56 +00:00
|
|
|
|
2012-05-29 18:10:56 +00:00
|
|
|
void SetThermalReliefGap( int aThermalReliefGap ) { m_ThermalReliefGap = aThermalReliefGap; }
|
2012-03-08 20:44:03 +00:00
|
|
|
int GetThermalReliefGap( D_PAD* aPad = NULL ) const;
|
2011-11-30 21:15:56 +00:00
|
|
|
|
2012-01-14 19:50:32 +00:00
|
|
|
void SetThermalReliefCopperBridge( int aThermalReliefCopperBridge )
|
|
|
|
{
|
|
|
|
m_ThermalReliefCopperBridge = aThermalReliefCopperBridge;
|
|
|
|
}
|
2012-03-08 20:44:03 +00:00
|
|
|
int GetThermalReliefCopperBridge( D_PAD* aPad = NULL ) const;
|
2011-11-30 21:15:56 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
void SetArcSegmentCount( int aArcSegCount ) { m_ArcToSegmentsCount = aArcSegCount; }
|
|
|
|
int GetArcSegmentCount() const { return m_ArcToSegmentsCount; }
|
2011-11-30 21:15:56 +00:00
|
|
|
|
|
|
|
bool IsFilled() const { return m_IsFilled; }
|
|
|
|
void SetIsFilled( bool isFilled ) { m_IsFilled = isFilled; }
|
|
|
|
|
|
|
|
int GetZoneClearance() const { return m_ZoneClearance; }
|
|
|
|
void SetZoneClearance( int aZoneClearance ) { m_ZoneClearance = aZoneClearance; }
|
|
|
|
|
2012-02-24 23:23:46 +00:00
|
|
|
ZoneConnection GetPadConnection( D_PAD* aPad = NULL ) const;
|
|
|
|
void SetPadConnection( ZoneConnection aPadConnection ) { m_PadConnection = aPadConnection; }
|
2011-11-30 21:15:56 +00:00
|
|
|
|
|
|
|
int GetMinThickness() const { return m_ZoneMinThickness; }
|
|
|
|
void SetMinThickness( int aMinThickness ) { m_ZoneMinThickness = aMinThickness; }
|
2011-02-25 20:37:48 +00:00
|
|
|
|
2013-03-20 14:50:12 +00:00
|
|
|
int GetSelectedCorner() const { return m_CornerSelection; }
|
|
|
|
void SetSelectedCorner( int aCorner ) { m_CornerSelection = aCorner; }
|
|
|
|
|
2014-05-04 17:08:36 +00:00
|
|
|
///
|
|
|
|
// Like HitTest but selects the current corner to be operated on
|
|
|
|
void SetSelectedCorner( const wxPoint& aPosition );
|
|
|
|
|
2013-03-26 09:58:40 +00:00
|
|
|
int GetLocalFlags() const { return m_localFlgs; }
|
|
|
|
void SetLocalFlags( int aFlags ) { m_localFlgs = aFlags; }
|
2013-03-20 14:50:12 +00:00
|
|
|
|
|
|
|
std::vector <SEGMENT>& FillSegments() { return m_FillSegmList; }
|
|
|
|
const std::vector <SEGMENT>& FillSegments() const { return m_FillSegmList; }
|
|
|
|
|
|
|
|
CPolyLine* Outline() { return m_Poly; }
|
|
|
|
const CPolyLine* Outline() const { return const_cast< CPolyLine* >( m_Poly ); }
|
|
|
|
|
|
|
|
void SetOutline( CPolyLine* aOutline ) { m_Poly = aOutline; }
|
|
|
|
|
2013-09-21 18:09:41 +00:00
|
|
|
/**
|
|
|
|
* Function HitTest
|
|
|
|
* tests if a point is near an outline edge or a corner of this zone.
|
2014-11-02 16:25:04 +00:00
|
|
|
* @param aPosition the wxPoint to test
|
2013-09-21 18:09:41 +00:00
|
|
|
* @return bool - true if a hit, else false
|
|
|
|
*/
|
2014-05-04 17:08:36 +00:00
|
|
|
virtual bool HitTest( const wxPoint& aPosition ) const;
|
2008-09-26 19:51:36 +00:00
|
|
|
|
2013-09-21 18:09:41 +00:00
|
|
|
/**
|
|
|
|
* Function HitTest
|
|
|
|
* tests if a point is inside the zone area, i.e. inside the main outline
|
|
|
|
* and outside holes.
|
2014-11-02 16:25:04 +00:00
|
|
|
* @param aPosition : the wxPoint to test
|
2013-09-21 18:09:41 +00:00
|
|
|
* @return bool - true if a hit, else false
|
|
|
|
*/
|
|
|
|
bool HitTestInsideZone( const wxPoint& aPosition ) const
|
|
|
|
{
|
|
|
|
return m_Poly->TestPointInside( aPosition.x, aPosition.y );
|
|
|
|
}
|
|
|
|
|
2008-11-27 10:12:46 +00:00
|
|
|
/**
|
|
|
|
* Function HitTestFilledArea
|
|
|
|
* tests if the given wxPoint is within the bounds of a filled area of this zone.
|
|
|
|
* @param aRefPos A wxPoint to test
|
|
|
|
* @return bool - true if a hit, else false
|
|
|
|
*/
|
2012-03-15 14:31:16 +00:00
|
|
|
bool HitTestFilledArea( const wxPoint& aRefPos ) const;
|
2008-11-27 10:12:46 +00:00
|
|
|
|
2013-05-01 19:01:14 +00:00
|
|
|
/**
|
|
|
|
* Function TransformSolidAreasShapesToPolygonSet
|
|
|
|
* Convert solid areas full shapes to polygon set
|
|
|
|
* (the full shape is the polygon area with a thick outline)
|
|
|
|
* Used in 3D view
|
|
|
|
* Arcs (ends of segments) are approximated by segments
|
|
|
|
* @param aCornerBuffer = a buffer to store the polygons
|
|
|
|
* @param aCircleToSegmentsCount = the number of segments to approximate a circle
|
|
|
|
* @param aCorrectionFactor = the correction to apply to arcs radius to roughly
|
|
|
|
* keep arc radius when approximated by segments
|
|
|
|
*/
|
2015-07-27 19:45:57 +00:00
|
|
|
void TransformSolidAreasShapesToPolygonSet( SHAPE_POLY_SET& aCornerBuffer,
|
2014-11-30 17:07:02 +00:00
|
|
|
int aCircleToSegmentsCount,
|
2016-07-19 17:35:25 +00:00
|
|
|
double aCorrectionFactor ) const;
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2013-05-01 19:01:14 +00:00
|
|
|
* Function BuildFilledSolidAreasPolygons
|
|
|
|
* Build the filled solid areas data from real outlines (stored in m_Poly)
|
2014-11-30 17:07:02 +00:00
|
|
|
* The solid areas can be more than one on copper layers, and do not have holes
|
2013-05-01 19:01:14 +00:00
|
|
|
( holes are linked by overlapping segments to the main outline)
|
2008-09-26 19:51:36 +00:00
|
|
|
* in order to have drawable (and plottable) filled polygons
|
2014-11-30 17:07:02 +00:00
|
|
|
* @return true if OK, false if the solid polygons cannot be built
|
2008-10-02 13:24:31 +00:00
|
|
|
* @param aPcb: the current board (can be NULL for non copper zones)
|
2013-05-01 19:01:14 +00:00
|
|
|
* @param aCornerBuffer: A reference to a buffer to store polygon corners, or NULL
|
|
|
|
* if NULL (default:
|
|
|
|
* - m_FilledPolysList is used to store solid areas polygons.
|
|
|
|
* - on copper layers, tracks and other items shapes of other nets are
|
|
|
|
* removed from solid areas
|
|
|
|
* if not null:
|
2014-11-30 17:07:02 +00:00
|
|
|
* Only the zone outline (with holes, if any) is stored in aOutlineBuffer
|
|
|
|
* with holes linked. Therefore only one polygon is created
|
|
|
|
*
|
|
|
|
* When aOutlineBuffer is not null, his function calls
|
|
|
|
* AddClearanceAreasPolygonsToPolysList() to add holes for pads and tracks
|
|
|
|
* and other items not in net.
|
2013-05-01 19:01:14 +00:00
|
|
|
*/
|
2015-07-27 19:45:57 +00:00
|
|
|
bool BuildFilledSolidAreasPolygons( BOARD* aPcb, SHAPE_POLY_SET* aOutlineBuffer = NULL );
|
2012-08-04 16:33:04 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function AddClearanceAreasPolygonsToPolysList
|
2011-07-14 15:42:44 +00:00
|
|
|
* Add non copper areas polygons (pads and tracks with clearance)
|
2008-10-02 13:24:31 +00:00
|
|
|
* to a filled copper area
|
2013-05-01 19:01:14 +00:00
|
|
|
* used in BuildFilledSolidAreasPolygons when calculating filled areas in a zone
|
2008-10-02 13:24:31 +00:00
|
|
|
* Non copper areas are pads and track and their clearance area
|
|
|
|
* The filled copper area must be computed before
|
2013-05-01 19:01:14 +00:00
|
|
|
* BuildFilledSolidAreasPolygons() call this function just after creating the
|
2011-07-14 15:42:44 +00:00
|
|
|
* filled copper area polygon (without clearance areas
|
2008-10-02 13:24:31 +00:00
|
|
|
* @param aPcb: the current board
|
2015-06-12 15:13:18 +00:00
|
|
|
* _NG version uses SHAPE_POLY_SET instead of Boost.Polygon
|
2008-10-02 13:24:31 +00:00
|
|
|
*/
|
2008-10-17 06:17:48 +00:00
|
|
|
void AddClearanceAreasPolygonsToPolysList( BOARD* aPcb );
|
2015-06-12 15:13:18 +00:00
|
|
|
void AddClearanceAreasPolygonsToPolysList_NG( BOARD* aPcb );
|
2008-11-23 17:43:53 +00:00
|
|
|
|
2013-05-01 19:01:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function TransformOutlinesShapeWithClearanceToPolygon
|
|
|
|
* Convert the outlines shape to a polygon with no holes
|
|
|
|
* inflated (optional) by max( aClearanceValue, the zone clearance)
|
|
|
|
* (holes are linked to external outline by overlapping segments)
|
|
|
|
* Used in filling zones calculations
|
|
|
|
* Circles (vias) and arcs (ends of tracks) are approximated by segments
|
|
|
|
* @param aCornerBuffer = a buffer to store the polygon
|
2014-12-19 19:09:53 +00:00
|
|
|
* @param aMinClearanceValue = the min clearance around outlines
|
|
|
|
* @param aUseNetClearance = true to use a clearance which is the max value between
|
|
|
|
* aMinClearanceValue and the net clearance
|
|
|
|
* false to use aMinClearanceValue only
|
|
|
|
* if both aMinClearanceValue = 0 and aUseNetClearance = false: create the zone outline polygon.
|
2013-05-01 19:01:14 +00:00
|
|
|
*/
|
2015-07-27 19:45:57 +00:00
|
|
|
void TransformOutlinesShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
|
2014-12-19 19:09:53 +00:00
|
|
|
int aMinClearanceValue,
|
|
|
|
bool aUseNetClearance );
|
2009-08-06 18:30:46 +00:00
|
|
|
/**
|
2008-01-23 22:39:09 +00:00
|
|
|
* Function HitTestForCorner
|
2011-09-14 15:08:44 +00:00
|
|
|
* tests if the given wxPoint near a corner
|
2011-03-01 13:59:21 +00:00
|
|
|
* Set m_CornerSelection to -1 if nothing found, or index of corner
|
|
|
|
* @return true if found
|
2011-09-14 15:08:44 +00:00
|
|
|
* @param refPos : A wxPoint to test
|
2008-01-23 22:39:09 +00:00
|
|
|
*/
|
2014-05-04 17:08:36 +00:00
|
|
|
int HitTestForCorner( const wxPoint& refPos ) const;
|
2008-01-23 22:39:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function HitTestForEdge
|
2011-03-01 13:59:21 +00:00
|
|
|
* tests if the given wxPoint is near a segment defined by 2 corners.
|
|
|
|
* Set m_CornerSelection to -1 if nothing found, or index of the starting corner of vertice
|
|
|
|
* @return true if found
|
2011-09-14 15:08:44 +00:00
|
|
|
* @param refPos : A wxPoint to test
|
2008-01-23 22:39:09 +00:00
|
|
|
*/
|
2014-05-04 17:08:36 +00:00
|
|
|
int HitTestForEdge( const wxPoint& refPos ) const;
|
2008-01-23 22:39:09 +00:00
|
|
|
|
2013-09-21 18:09:41 +00:00
|
|
|
/** @copydoc BOARD_ITEM::HitTest(const EDA_RECT& aRect,
|
|
|
|
* bool aContained = true, int aAccuracy ) const
|
|
|
|
*/
|
|
|
|
bool HitTest( const EDA_RECT& aRect, bool aContained = true, int aAccuracy = 0 ) const;
|
2008-01-06 12:43:57 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2013-03-20 14:50:12 +00:00
|
|
|
* Function FillZoneAreasWithSegments
|
2008-12-03 10:32:53 +00:00
|
|
|
* Fill sub areas in a zone with segments with m_ZoneMinThickness width
|
|
|
|
* A scan is made line per line, on the whole filled areas, with a step of m_ZoneMinThickness.
|
|
|
|
* all intersecting points with the horizontal infinite line and polygons to fill are calculated
|
|
|
|
* a list of SEGZONE items is built, line per line
|
2016-07-14 07:27:32 +00:00
|
|
|
* @return true if success, false on error
|
2008-12-03 10:32:53 +00:00
|
|
|
*/
|
2016-07-14 07:27:32 +00:00
|
|
|
bool FillZoneAreasWithSegments();
|
2008-12-03 10:32:53 +00:00
|
|
|
|
2011-07-16 16:04:49 +00:00
|
|
|
/**
|
|
|
|
* Function UnFill
|
|
|
|
* Removes the zone filling
|
|
|
|
* @return true if a previous filling is removed, false if no change
|
|
|
|
* (when no filling found)
|
|
|
|
*/
|
2011-09-20 15:07:52 +00:00
|
|
|
bool UnFill();
|
2008-12-03 10:32:53 +00:00
|
|
|
|
2008-01-23 22:39:09 +00:00
|
|
|
/* Geometric transformations: */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Move
|
|
|
|
* Move the outlines
|
|
|
|
* @param offset = moving vector
|
|
|
|
*/
|
2011-09-20 15:07:52 +00:00
|
|
|
void Move( const wxPoint& offset );
|
2008-01-23 22:39:09 +00:00
|
|
|
|
|
|
|
/**
|
2008-02-01 21:30:45 +00:00
|
|
|
* Function MoveEdge
|
2014-05-04 17:08:36 +00:00
|
|
|
* Move the outline Edge
|
2008-02-01 21:30:45 +00:00
|
|
|
* @param offset = moving vector
|
2014-05-04 17:08:36 +00:00
|
|
|
* @param aEdge = start point of the outline edge
|
2008-02-01 21:30:45 +00:00
|
|
|
*/
|
2014-05-04 17:08:36 +00:00
|
|
|
void MoveEdge( const wxPoint& offset, int aEdge );
|
2008-02-01 21:30:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Rotate
|
2008-01-23 22:39:09 +00:00
|
|
|
* Move the outlines
|
|
|
|
* @param centre = rot centre
|
|
|
|
* @param angle = in 0.1 degree
|
|
|
|
*/
|
2011-12-14 04:29:25 +00:00
|
|
|
void Rotate( const wxPoint& centre, double angle );
|
2008-01-23 22:39:09 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
/**
|
|
|
|
* Function Flip
|
|
|
|
* Flip this object, i.e. change the board side for this object
|
|
|
|
* (like Mirror() but changes layer)
|
2010-12-14 15:56:30 +00:00
|
|
|
* @param aCentre - the rotation point.
|
2009-08-01 19:26:05 +00:00
|
|
|
*/
|
2009-08-06 18:30:46 +00:00
|
|
|
virtual void Flip( const wxPoint& aCentre );
|
2009-08-01 19:26:05 +00:00
|
|
|
|
2008-01-23 22:39:09 +00:00
|
|
|
/**
|
|
|
|
* Function Mirror
|
|
|
|
* Mirror the outlines , relative to a given horizontal axis
|
|
|
|
* the layer is not changed
|
|
|
|
* @param mirror_ref = vertical axis position
|
|
|
|
*/
|
2011-09-20 15:07:52 +00:00
|
|
|
void Mirror( const wxPoint& mirror_ref );
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2008-01-23 22:39:09 +00:00
|
|
|
/**
|
|
|
|
* Function GetClass
|
|
|
|
* returns the class name.
|
|
|
|
* @return wxString
|
|
|
|
*/
|
|
|
|
wxString GetClass() const
|
|
|
|
{
|
|
|
|
return wxT( "ZONE_CONTAINER" );
|
|
|
|
}
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2011-07-14 15:42:44 +00:00
|
|
|
/** Access to m_Poly parameters
|
2008-09-26 19:51:36 +00:00
|
|
|
*/
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
int GetNumCorners( void ) const
|
2008-04-01 05:21:50 +00:00
|
|
|
{
|
2013-05-09 19:08:12 +00:00
|
|
|
return m_Poly->GetCornersCount();
|
2008-04-01 05:21:50 +00:00
|
|
|
}
|
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
void RemoveAllContours( void )
|
2008-04-01 05:21:50 +00:00
|
|
|
{
|
|
|
|
m_Poly->RemoveAllContours();
|
|
|
|
}
|
|
|
|
|
2012-02-20 04:33:54 +00:00
|
|
|
const wxPoint& GetCornerPosition( int aCornerIndex ) const
|
2008-04-01 05:21:50 +00:00
|
|
|
{
|
2012-02-20 04:33:54 +00:00
|
|
|
return m_Poly->GetPos( aCornerIndex );
|
2008-04-01 05:21:50 +00:00
|
|
|
}
|
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
void SetCornerPosition( int aCornerIndex, wxPoint new_pos )
|
2008-04-01 05:21:50 +00:00
|
|
|
{
|
2008-09-26 19:51:36 +00:00
|
|
|
m_Poly->SetX( aCornerIndex, new_pos.x );
|
|
|
|
m_Poly->SetY( aCornerIndex, new_pos.y );
|
2008-04-01 05:21:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AppendCorner( wxPoint position )
|
|
|
|
{
|
|
|
|
m_Poly->AppendCorner( position.x, position.y );
|
|
|
|
}
|
2008-10-23 10:26:06 +00:00
|
|
|
|
|
|
|
int GetHatchStyle() const
|
|
|
|
{
|
|
|
|
return m_Poly->GetHatchStyle();
|
|
|
|
}
|
2011-02-21 19:43:59 +00:00
|
|
|
|
2012-07-30 07:40:25 +00:00
|
|
|
void SetHatchStyle( CPolyLine::HATCH_STYLE aStyle )
|
2012-06-09 17:00:13 +00:00
|
|
|
{
|
|
|
|
m_Poly->SetHatchStyle( aStyle );
|
|
|
|
}
|
|
|
|
|
2013-05-01 19:01:14 +00:00
|
|
|
/**
|
2010-11-12 16:59:16 +00:00
|
|
|
* Function IsSame
|
2011-11-30 21:15:56 +00:00
|
|
|
* tests if 2 zones are equivalent:
|
2009-08-23 15:22:44 +00:00
|
|
|
* 2 zones are equivalent if they have same parameters and same outlines
|
2011-11-30 21:15:56 +00:00
|
|
|
* info, filling is not taken into account
|
2009-08-23 15:22:44 +00:00
|
|
|
* @param aZoneToCompare = zone to compare with "this"
|
|
|
|
*/
|
2011-11-30 21:15:56 +00:00
|
|
|
bool IsSame( const ZONE_CONTAINER &aZoneToCompare );
|
2011-02-21 19:43:59 +00:00
|
|
|
|
2012-06-02 21:19:17 +00:00
|
|
|
/**
|
|
|
|
* Function ClearFilledPolysList
|
|
|
|
* clears the list of filled polygons.
|
|
|
|
*/
|
|
|
|
void ClearFilledPolysList()
|
|
|
|
{
|
2013-05-14 18:47:01 +00:00
|
|
|
m_FilledPolysList.RemoveAllContours();
|
2012-06-02 21:19:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetFilledPolysList
|
|
|
|
* returns a reference to the list of filled polygons.
|
|
|
|
* @return Reference to the list of filled polygons.
|
|
|
|
*/
|
2015-07-27 19:45:57 +00:00
|
|
|
const SHAPE_POLY_SET& GetFilledPolysList() const
|
2012-06-02 21:19:17 +00:00
|
|
|
{
|
|
|
|
return m_FilledPolysList;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function AddFilledPolysList
|
|
|
|
* sets the list of filled polygons.
|
|
|
|
*/
|
2015-07-27 19:45:57 +00:00
|
|
|
void AddFilledPolysList( SHAPE_POLY_SET& aPolysList )
|
2012-06-02 21:19:17 +00:00
|
|
|
{
|
|
|
|
m_FilledPolysList = aPolysList;
|
|
|
|
}
|
|
|
|
|
2011-02-21 19:43:59 +00:00
|
|
|
/**
|
|
|
|
* Function GetSmoothedPoly
|
|
|
|
* returns a pointer to the corner-smoothed version of
|
|
|
|
* m_Poly if it exists, otherwise it returns m_Poly.
|
|
|
|
* @return CPolyLine* - pointer to the polygon.
|
|
|
|
*/
|
|
|
|
CPolyLine* GetSmoothedPoly() const
|
|
|
|
{
|
2012-07-13 18:55:29 +00:00
|
|
|
if( m_smoothedPoly )
|
|
|
|
return m_smoothedPoly;
|
2011-02-21 19:43:59 +00:00
|
|
|
else
|
|
|
|
return m_Poly;
|
|
|
|
};
|
|
|
|
|
2012-07-13 18:55:29 +00:00
|
|
|
void SetCornerSmoothingType( int aType ) { m_cornerSmoothingType = aType; };
|
2011-09-20 15:07:52 +00:00
|
|
|
|
2012-07-13 18:55:29 +00:00
|
|
|
int GetCornerSmoothingType() const { return m_cornerSmoothingType; };
|
2011-02-21 19:43:59 +00:00
|
|
|
|
2015-05-15 12:49:11 +00:00
|
|
|
void SetCornerRadius( unsigned int aRadius );
|
2011-02-21 19:43:59 +00:00
|
|
|
|
2012-07-13 18:55:29 +00:00
|
|
|
unsigned int GetCornerRadius() const { return m_cornerRadius; };
|
2011-07-14 15:42:44 +00:00
|
|
|
|
2012-06-09 17:00:13 +00:00
|
|
|
void AddPolygon( std::vector< wxPoint >& aPolygon );
|
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
void AddFilledPolygon( SHAPE_POLY_SET& aPolygon )
|
2012-06-09 17:00:13 +00:00
|
|
|
{
|
2013-05-08 18:20:58 +00:00
|
|
|
m_FilledPolysList.Append( aPolygon );
|
2012-06-09 17:00:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AddFillSegments( std::vector< SEGMENT >& aSegments )
|
|
|
|
{
|
|
|
|
m_FillSegmList.insert( m_FillSegmList.end(), aSegments.begin(), aSegments.end() );
|
|
|
|
}
|
|
|
|
|
2011-07-14 15:42:44 +00:00
|
|
|
virtual wxString GetSelectMenuText() const;
|
|
|
|
|
2011-08-29 03:04:59 +00:00
|
|
|
virtual BITMAP_DEF GetMenuImage() const { return add_zone_xpm; }
|
2011-12-14 17:25:42 +00:00
|
|
|
|
2012-03-17 14:39:27 +00:00
|
|
|
virtual EDA_ITEM* Clone() const;
|
|
|
|
|
2012-07-13 18:55:29 +00:00
|
|
|
/**
|
|
|
|
* Accessors to parameters used in Keepout zones:
|
|
|
|
*/
|
|
|
|
bool GetIsKeepout() const { return m_isKeepout; }
|
2012-07-14 16:27:25 +00:00
|
|
|
bool GetDoNotAllowCopperPour() const { return m_doNotAllowCopperPour; }
|
2012-07-13 18:55:29 +00:00
|
|
|
bool GetDoNotAllowVias() const { return m_doNotAllowVias; }
|
|
|
|
bool GetDoNotAllowTracks() const { return m_doNotAllowTracks; }
|
|
|
|
|
|
|
|
void SetIsKeepout( bool aEnable ) { m_isKeepout = aEnable; }
|
2012-07-14 16:27:25 +00:00
|
|
|
void SetDoNotAllowCopperPour( bool aEnable ) { m_doNotAllowCopperPour = aEnable; }
|
2012-07-13 18:55:29 +00:00
|
|
|
void SetDoNotAllowVias( bool aEnable ) { m_doNotAllowVias = aEnable; }
|
|
|
|
void SetDoNotAllowTracks( bool aEnable ) { m_doNotAllowTracks = aEnable; }
|
|
|
|
|
2011-12-14 17:25:42 +00:00
|
|
|
#if defined(DEBUG)
|
2013-05-05 10:23:18 +00:00
|
|
|
virtual void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
|
2011-12-14 17:25:42 +00:00
|
|
|
#endif
|
2012-05-29 18:10:56 +00:00
|
|
|
|
|
|
|
|
2015-06-12 15:13:18 +00:00
|
|
|
|
2012-05-29 18:10:56 +00:00
|
|
|
private:
|
2015-07-27 19:45:57 +00:00
|
|
|
void buildFeatureHoleList( BOARD* aPcb, SHAPE_POLY_SET& aFeatures );
|
2015-06-12 15:13:18 +00:00
|
|
|
|
2013-03-20 14:50:12 +00:00
|
|
|
CPolyLine* m_Poly; ///< Outline of the zone.
|
|
|
|
CPolyLine* m_smoothedPoly; // Corner-smoothed version of m_Poly
|
2012-07-13 18:55:29 +00:00
|
|
|
int m_cornerSmoothingType;
|
|
|
|
unsigned int m_cornerRadius;
|
|
|
|
|
|
|
|
/* Priority: when a zone outline is inside and other zone, if its priority is higher
|
|
|
|
* the other zone priority, it will be created inside.
|
|
|
|
* if priorities are equal, a DRC error is set
|
|
|
|
*/
|
2012-05-29 18:10:56 +00:00
|
|
|
unsigned m_priority;
|
2012-07-13 18:55:29 +00:00
|
|
|
|
|
|
|
/* A zone outline can be a keepout zone.
|
|
|
|
* It will be never filled, and DRC should test for pads, tracks and vias
|
|
|
|
*/
|
|
|
|
bool m_isKeepout;
|
|
|
|
|
|
|
|
/* For keepout zones only:
|
|
|
|
* what is not allowed inside the keepout ( pads, tracks and vias )
|
|
|
|
*/
|
2012-07-14 16:27:25 +00:00
|
|
|
bool m_doNotAllowCopperPour;
|
2012-07-13 18:55:29 +00:00
|
|
|
bool m_doNotAllowVias;
|
|
|
|
bool m_doNotAllowTracks;
|
|
|
|
|
2012-05-29 18:10:56 +00:00
|
|
|
ZoneConnection m_PadConnection;
|
2013-03-18 19:36:07 +00:00
|
|
|
int m_ZoneClearance; ///< Clearance value in internal units.
|
|
|
|
int m_ZoneMinThickness; ///< Minimum thickness value in filled areas.
|
|
|
|
|
|
|
|
/** The number of segments to convert a circle to a polygon. Valid values are
|
|
|
|
#ARC_APPROX_SEGMENTS_COUNT_LOW_DEF or #ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF. */
|
|
|
|
int m_ArcToSegmentsCount;
|
|
|
|
|
|
|
|
/** True when a zone was filled, false after deleting the filled areas. */
|
|
|
|
bool m_IsFilled;
|
|
|
|
|
|
|
|
///< Width of the gap in thermal reliefs.
|
|
|
|
int m_ThermalReliefGap;
|
|
|
|
|
|
|
|
///< Width of the copper bridge in thermal reliefs.
|
|
|
|
int m_ThermalReliefCopperBridge;
|
|
|
|
|
|
|
|
|
|
|
|
/// How to fill areas: 0 => use filled polygons, 1 => fill with segments.
|
|
|
|
int m_FillMode;
|
2012-06-02 21:19:17 +00:00
|
|
|
|
2013-03-20 14:50:12 +00:00
|
|
|
/// The index of the corner being moved or -1 if no corner is selected.
|
|
|
|
int m_CornerSelection;
|
|
|
|
|
2015-01-22 12:06:34 +00:00
|
|
|
/// Variable used in polygon calculations.
|
|
|
|
int m_localFlgs;
|
2013-03-20 14:50:12 +00:00
|
|
|
|
|
|
|
/** Segments used to fill the zone (#m_FillMode ==1 ), when fill zone by segment is used.
|
|
|
|
* In this case the segments have #m_ZoneMinThickness width.
|
|
|
|
*/
|
|
|
|
std::vector <SEGMENT> m_FillSegmList;
|
|
|
|
|
2012-06-02 21:19:17 +00:00
|
|
|
/* set of filled polygons used to draw a zone as a filled area.
|
|
|
|
* from outlines (m_Poly) but unlike m_Poly these filled polygons have no hole
|
2012-07-25 18:46:25 +00:00
|
|
|
* (they are all in one piece) In very simple cases m_FilledPolysList is same
|
2012-06-02 21:19:17 +00:00
|
|
|
* as m_Poly. In less simple cases (when m_Poly has holes) m_FilledPolysList is
|
2013-03-18 19:36:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2012-06-02 21:19:17 +00:00
|
|
|
* a polygon equivalent to m_Poly, without holes but with extra outline segment
|
|
|
|
* connecting "holes" with external main outline. In complex cases an outline
|
|
|
|
* described by m_Poly can have many filled areas
|
|
|
|
*/
|
2015-07-27 19:45:57 +00:00
|
|
|
SHAPE_POLY_SET m_FilledPolysList;
|
2007-12-09 12:59:06 +00:00
|
|
|
};
|
|
|
|
|
2008-01-23 22:39:09 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
#endif // CLASS_ZONE_H_
|