2011-10-17 20:01:27 +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
|
2012-06-08 09:56:42 +00:00
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2015-01-22 12:06:34 +00:00
|
|
|
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-17 20:01:27 +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-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file class_zone.cpp
|
|
|
|
* @brief Implementation of class to handle copper zones.
|
|
|
|
*/
|
2007-12-09 12:59:06 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <wxstruct.h>
|
|
|
|
#include <trigo.h>
|
|
|
|
#include <class_pcb_screen.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <kicad_string.h>
|
|
|
|
#include <pcbcommon.h>
|
|
|
|
#include <colors_selection.h>
|
|
|
|
#include <richio.h>
|
|
|
|
#include <macros.h>
|
|
|
|
#include <wxBasePcbFrame.h>
|
2013-01-12 17:32:24 +00:00
|
|
|
#include <msgpanel.h>
|
2007-12-09 12:59:06 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_zone.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <zones.h>
|
2012-07-30 07:40:25 +00:00
|
|
|
#include <math_for_graphics.h>
|
2012-07-31 17:51:58 +00:00
|
|
|
#include <polygon_test_point_inside.h>
|
2009-08-01 19:26:05 +00:00
|
|
|
|
2007-12-09 12:59:06 +00:00
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
ZONE_CONTAINER::ZONE_CONTAINER( BOARD* aBoard ) :
|
|
|
|
BOARD_CONNECTED_ITEM( aBoard, PCB_ZONE_AREA_T )
|
2007-12-09 12:59:06 +00:00
|
|
|
{
|
2008-01-31 20:53:44 +00:00
|
|
|
m_CornerSelection = -1;
|
2011-01-20 18:40:33 +00:00
|
|
|
m_IsFilled = false; // fill status : true when the zone is filled
|
|
|
|
m_FillMode = 0; // How to fill areas: 0 = use filled polygons, != 0 fill with segments
|
2012-01-29 19:29:19 +00:00
|
|
|
m_priority = 0;
|
2012-07-13 18:55:29 +00:00
|
|
|
m_smoothedPoly = NULL;
|
|
|
|
m_cornerSmoothingType = ZONE_SETTINGS::SMOOTHING_NONE;
|
2012-07-14 16:27:25 +00:00
|
|
|
SetIsKeepout( false );
|
|
|
|
SetDoNotAllowCopperPour( false ); // has meaning only if m_isKeepout == true
|
|
|
|
SetDoNotAllowVias( true ); // has meaning only if m_isKeepout == true
|
|
|
|
SetDoNotAllowTracks( true ); // has meaning only if m_isKeepout == true
|
2012-07-13 18:55:29 +00:00
|
|
|
m_cornerRadius = 0;
|
2013-03-26 09:58:40 +00:00
|
|
|
SetLocalFlags( 0 ); // flags tempoarry used in zone calculations
|
2011-01-20 18:40:33 +00:00
|
|
|
m_Poly = new CPolyLine(); // Outlines
|
2012-02-06 05:44:19 +00:00
|
|
|
aBoard->GetZoneSettings().ExportSetting( *this );
|
2007-12-09 12:59:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-01-14 19:50:32 +00:00
|
|
|
ZONE_CONTAINER::ZONE_CONTAINER( const ZONE_CONTAINER& aZone ) :
|
|
|
|
BOARD_CONNECTED_ITEM( aZone )
|
|
|
|
{
|
2014-10-30 08:42:11 +00:00
|
|
|
m_smoothedPoly = NULL;
|
|
|
|
|
2012-01-14 19:50:32 +00:00
|
|
|
// Should the copy be on the same net?
|
2014-02-25 10:40:34 +00:00
|
|
|
SetNetCode( aZone.GetNetCode() );
|
2012-01-14 19:50:32 +00:00
|
|
|
m_Poly = new CPolyLine( *aZone.m_Poly );
|
|
|
|
|
|
|
|
// For corner moving, corner index to drag, or -1 if no selection
|
|
|
|
m_CornerSelection = -1;
|
2012-05-29 18:10:56 +00:00
|
|
|
m_IsFilled = aZone.m_IsFilled;
|
2012-01-14 19:50:32 +00:00
|
|
|
m_ZoneClearance = aZone.m_ZoneClearance; // clearance value
|
|
|
|
m_ZoneMinThickness = aZone.m_ZoneMinThickness;
|
|
|
|
m_FillMode = aZone.m_FillMode; // Filling mode (segments/polygons)
|
2012-01-29 19:29:19 +00:00
|
|
|
m_priority = aZone.m_priority;
|
2012-01-14 19:50:32 +00:00
|
|
|
m_ArcToSegmentsCount = aZone.m_ArcToSegmentsCount;
|
2012-02-24 23:23:46 +00:00
|
|
|
m_PadConnection = aZone.m_PadConnection;
|
2012-01-14 19:50:32 +00:00
|
|
|
m_ThermalReliefGap = aZone.m_ThermalReliefGap;
|
|
|
|
m_ThermalReliefCopperBridge = aZone.m_ThermalReliefCopperBridge;
|
2013-05-14 18:47:01 +00:00
|
|
|
m_FilledPolysList.Append( aZone.m_FilledPolysList );
|
|
|
|
m_FillSegmList = aZone.m_FillSegmList; // vector <> copy
|
2012-05-29 18:10:56 +00:00
|
|
|
|
2012-07-13 18:55:29 +00:00
|
|
|
m_isKeepout = aZone.m_isKeepout;
|
2012-07-14 16:27:25 +00:00
|
|
|
m_doNotAllowCopperPour = aZone.m_doNotAllowCopperPour;
|
2012-07-13 18:55:29 +00:00
|
|
|
m_doNotAllowVias = aZone.m_doNotAllowVias;
|
|
|
|
m_doNotAllowTracks = aZone.m_doNotAllowTracks;
|
|
|
|
|
|
|
|
m_cornerSmoothingType = aZone.m_cornerSmoothingType;
|
|
|
|
m_cornerRadius = aZone.m_cornerRadius;
|
|
|
|
|
2013-03-26 09:58:40 +00:00
|
|
|
SetLocalFlags( aZone.GetLocalFlags() );
|
2012-01-14 19:50:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-04 12:27:16 +00:00
|
|
|
ZONE_CONTAINER::~ZONE_CONTAINER()
|
2007-12-09 12:59:06 +00:00
|
|
|
{
|
2008-01-31 20:53:44 +00:00
|
|
|
delete m_Poly;
|
|
|
|
m_Poly = NULL;
|
2007-12-09 12:59:06 +00:00
|
|
|
}
|
|
|
|
|
2011-10-17 20:01:27 +00:00
|
|
|
|
2012-03-17 14:39:27 +00:00
|
|
|
EDA_ITEM* ZONE_CONTAINER::Clone() const
|
2012-01-14 19:50:32 +00:00
|
|
|
{
|
|
|
|
return new ZONE_CONTAINER( *this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-16 16:04:49 +00:00
|
|
|
bool ZONE_CONTAINER::UnFill()
|
|
|
|
{
|
2015-07-27 19:45:57 +00:00
|
|
|
bool change = ( !m_FilledPolysList.IsEmpty() ) ||
|
2013-05-09 19:08:12 +00:00
|
|
|
( m_FillSegmList.size() > 0 );
|
2011-07-16 16:04:49 +00:00
|
|
|
|
2013-05-14 18:47:01 +00:00
|
|
|
m_FilledPolysList.RemoveAllContours();
|
2011-07-16 16:04:49 +00:00
|
|
|
m_FillSegmList.clear();
|
|
|
|
m_IsFilled = false;
|
|
|
|
|
|
|
|
return change;
|
|
|
|
}
|
2007-12-09 12:59:06 +00:00
|
|
|
|
2011-10-17 20:01:27 +00:00
|
|
|
|
2012-02-20 04:33:54 +00:00
|
|
|
const wxPoint& ZONE_CONTAINER::GetPosition() const
|
2008-10-29 15:26:53 +00:00
|
|
|
{
|
2012-02-20 04:33:54 +00:00
|
|
|
static const wxPoint dummy;
|
2008-10-29 15:26:53 +00:00
|
|
|
|
2012-02-20 04:33:54 +00:00
|
|
|
return m_Poly ? GetCornerPosition( 0 ) : dummy;
|
2011-11-29 17:25:30 +00:00
|
|
|
}
|
2011-01-20 18:40:33 +00:00
|
|
|
|
2011-11-24 17:32:51 +00:00
|
|
|
|
2013-03-20 14:50:12 +00:00
|
|
|
void ZONE_CONTAINER::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE aDrawMode,
|
|
|
|
const wxPoint& offset )
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2014-06-29 13:05:51 +00:00
|
|
|
if( !DC )
|
2008-01-31 20:53:44 +00:00
|
|
|
return;
|
|
|
|
|
2014-06-29 13:05:51 +00:00
|
|
|
wxPoint seg_start, seg_end;
|
|
|
|
LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
|
|
|
|
BOARD* brd = GetBoard();
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2012-09-02 12:06:47 +00:00
|
|
|
EDA_COLOR_T color = brd->GetLayerColor( m_Layer );
|
2010-01-31 20:01:46 +00:00
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
if( brd->IsLayerVisible( m_Layer ) == false && ( color & HIGHLIGHT_FLAG ) != HIGHLIGHT_FLAG )
|
2007-12-29 19:15:58 +00:00
|
|
|
return;
|
|
|
|
|
2010-12-14 15:56:30 +00:00
|
|
|
GRSetDrawMode( DC, aDrawMode );
|
2015-01-10 10:27:49 +00:00
|
|
|
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions();
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2015-01-10 10:27:49 +00:00
|
|
|
if( displ_opts->m_ContrastModeDisplay )
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
|
|
|
if( !IsOnLayer( curr_layer ) )
|
2012-09-02 12:06:47 +00:00
|
|
|
ColorTurnToDarkDarkGray( &color );
|
2007-12-29 19:15:58 +00:00
|
|
|
}
|
|
|
|
|
2011-10-17 20:01:27 +00:00
|
|
|
if( aDrawMode & GR_HIGHLIGHT )
|
2012-09-02 12:06:47 +00:00
|
|
|
ColorChangeHighlightFlag( &color, !(aDrawMode & GR_AND) );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-04-04 21:35:01 +00:00
|
|
|
ColorApplyHighlightFlag( &color );
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2008-12-03 10:32:53 +00:00
|
|
|
SetAlpha( &color, 150 );
|
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
// draw the lines
|
|
|
|
int i_start_contour = 0;
|
2010-10-13 19:50:23 +00:00
|
|
|
std::vector<wxPoint> lines;
|
2011-01-20 18:40:33 +00:00
|
|
|
lines.reserve( (GetNumCorners() * 2) + 2 );
|
2010-12-14 15:56:30 +00:00
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
for( int ic = 0; ic < GetNumCorners(); ic++ )
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2008-09-26 19:51:36 +00:00
|
|
|
seg_start = GetCornerPosition( ic ) + offset;
|
2010-12-14 15:56:30 +00:00
|
|
|
|
2013-05-08 18:20:58 +00:00
|
|
|
if( !m_Poly->m_CornersList.IsEndContour( ic ) && ic < GetNumCorners() - 1 )
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2008-09-26 19:51:36 +00:00
|
|
|
seg_end = GetCornerPosition( ic + 1 ) + offset;
|
2007-12-29 19:15:58 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-09-26 19:51:36 +00:00
|
|
|
seg_end = GetCornerPosition( i_start_contour ) + offset;
|
2007-12-29 19:15:58 +00:00
|
|
|
i_start_contour = ic + 1;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-10-13 19:50:23 +00:00
|
|
|
lines.push_back( seg_start );
|
|
|
|
lines.push_back( seg_end );
|
2007-12-29 19:15:58 +00:00
|
|
|
}
|
2011-01-20 18:40:33 +00:00
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
GRLineArray( panel->GetClipBox(), DC, lines, 0, color );
|
2008-01-31 20:53:44 +00:00
|
|
|
|
|
|
|
// draw hatches
|
2010-10-13 19:50:23 +00:00
|
|
|
lines.clear();
|
2011-01-20 18:40:33 +00:00
|
|
|
lines.reserve( (m_Poly->m_HatchLines.size() * 2) + 2 );
|
2010-12-14 15:56:30 +00:00
|
|
|
|
2008-01-04 12:27:16 +00:00
|
|
|
for( unsigned ic = 0; ic < m_Poly->m_HatchLines.size(); ic++ )
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2012-07-13 18:55:29 +00:00
|
|
|
seg_start = m_Poly->m_HatchLines[ic].m_Start + offset;
|
|
|
|
seg_end = m_Poly->m_HatchLines[ic].m_End + offset;
|
2010-10-13 19:50:23 +00:00
|
|
|
lines.push_back( seg_start );
|
|
|
|
lines.push_back( seg_end );
|
2007-12-29 19:15:58 +00:00
|
|
|
}
|
2010-12-14 15:56:30 +00:00
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
GRLineArray( panel->GetClipBox(), DC, lines, 0, color );
|
2008-01-31 20:53:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel,
|
2012-09-01 13:38:27 +00:00
|
|
|
wxDC* DC, GR_DRAWMODE aDrawMode, const wxPoint& offset )
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2012-08-03 15:43:15 +00:00
|
|
|
static std::vector <wxPoint> CornersBuffer;
|
2015-01-10 10:27:49 +00:00
|
|
|
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions();
|
2009-01-05 05:21:35 +00:00
|
|
|
|
2008-12-12 21:30:07 +00:00
|
|
|
// outline_mode is false to show filled polys,
|
|
|
|
// and true to show polygons outlines only (test and debug purposes)
|
2015-01-10 10:27:49 +00:00
|
|
|
bool outline_mode = displ_opts->m_DisplayZonesMode == 2 ? true : false;
|
2008-09-26 19:51:36 +00:00
|
|
|
|
|
|
|
if( DC == NULL )
|
|
|
|
return;
|
|
|
|
|
2015-01-10 10:27:49 +00:00
|
|
|
if( displ_opts->m_DisplayZonesMode == 1 ) // Do not show filled areas
|
2008-09-26 19:51:36 +00:00
|
|
|
return;
|
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
if( m_FilledPolysList.IsEmpty() ) // Nothing to draw
|
2008-09-26 19:51:36 +00:00
|
|
|
return;
|
|
|
|
|
2014-06-29 13:05:51 +00:00
|
|
|
BOARD* brd = GetBoard();
|
|
|
|
LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
|
2012-09-02 12:06:47 +00:00
|
|
|
EDA_COLOR_T color = brd->GetLayerColor( m_Layer );
|
2008-09-26 19:51:36 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
if( brd->IsLayerVisible( m_Layer ) == false && ( color & HIGHLIGHT_FLAG ) != HIGHLIGHT_FLAG )
|
2008-09-26 19:51:36 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
GRSetDrawMode( DC, aDrawMode );
|
|
|
|
|
2015-01-10 10:27:49 +00:00
|
|
|
if( displ_opts->m_ContrastModeDisplay )
|
2008-09-26 19:51:36 +00:00
|
|
|
{
|
|
|
|
if( !IsOnLayer( curr_layer ) )
|
2012-09-02 12:06:47 +00:00
|
|
|
ColorTurnToDarkDarkGray( &color );
|
2008-09-26 19:51:36 +00:00
|
|
|
}
|
|
|
|
|
2011-10-17 20:01:27 +00:00
|
|
|
if( aDrawMode & GR_HIGHLIGHT )
|
2012-09-02 12:06:47 +00:00
|
|
|
ColorChangeHighlightFlag( &color, !(aDrawMode & GR_AND) );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-04-04 21:35:01 +00:00
|
|
|
ColorApplyHighlightFlag( &color );
|
2008-09-26 19:51:36 +00:00
|
|
|
|
2008-12-03 10:32:53 +00:00
|
|
|
SetAlpha( &color, 150 );
|
2008-09-26 19:51:36 +00:00
|
|
|
|
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
for ( int ic = 0; ic < m_FilledPolysList.OutlineCount(); ic++ )
|
2015-07-14 20:23:13 +00:00
|
|
|
{
|
2015-07-27 19:45:57 +00:00
|
|
|
const SHAPE_LINE_CHAIN& path = m_FilledPolysList.COutline( ic );
|
|
|
|
|
|
|
|
CornersBuffer.clear();
|
|
|
|
|
|
|
|
wxPoint p0;
|
2015-07-14 11:36:24 +00:00
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
for( int j = 0; j < path.PointCount(); j++ )
|
2015-07-14 11:36:24 +00:00
|
|
|
{
|
2015-07-27 19:45:57 +00:00
|
|
|
const VECTOR2I& corner = path.CPoint( j );
|
2015-07-14 20:23:13 +00:00
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
wxPoint coord( corner.x + offset.x, corner.y + offset.y );
|
|
|
|
|
|
|
|
if( j == 0 )
|
|
|
|
p0 = coord;
|
2015-07-14 11:36:24 +00:00
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
CornersBuffer.push_back( coord );
|
2015-07-14 20:23:13 +00:00
|
|
|
}
|
2015-07-27 19:45:57 +00:00
|
|
|
|
|
|
|
CornersBuffer.push_back( p0 );
|
|
|
|
|
|
|
|
// Draw outlines:
|
|
|
|
if( ( m_ZoneMinThickness > 1 ) || outline_mode )
|
|
|
|
{
|
|
|
|
int ilim = CornersBuffer.size() - 1;
|
|
|
|
|
|
|
|
for( int is = 0, ie = ilim; is <= ilim; ie = is, is++ )
|
|
|
|
{
|
|
|
|
int x0 = CornersBuffer[is].x;
|
|
|
|
int y0 = CornersBuffer[is].y;
|
|
|
|
int x1 = CornersBuffer[ie].x;
|
|
|
|
int y1 = CornersBuffer[ie].y;
|
|
|
|
|
|
|
|
// Draw only basic outlines, not extra segments.
|
|
|
|
if( !displ_opts->m_DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
|
|
|
|
GRCSegm( panel->GetClipBox(), DC,
|
|
|
|
x0, y0, x1, y1,
|
|
|
|
m_ZoneMinThickness, color );
|
|
|
|
else
|
|
|
|
GRFillCSegm( panel->GetClipBox(), DC,
|
|
|
|
x0, y0, x1, y1,
|
|
|
|
m_ZoneMinThickness, color );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw areas:
|
|
|
|
if( m_FillMode == 0 && !outline_mode )
|
|
|
|
GRPoly( panel->GetClipBox(), DC, CornersBuffer.size(), &CornersBuffer[0],
|
|
|
|
true, 0, color, color );
|
2008-09-26 19:51:36 +00:00
|
|
|
}
|
2009-08-06 18:30:46 +00:00
|
|
|
|
|
|
|
if( m_FillMode == 1 && !outline_mode ) // filled with segments
|
|
|
|
{
|
|
|
|
for( unsigned ic = 0; ic < m_FillSegmList.size(); ic++ )
|
|
|
|
{
|
2011-01-20 18:40:33 +00:00
|
|
|
wxPoint start = m_FillSegmList[ic].m_Start + offset;
|
|
|
|
wxPoint end = m_FillSegmList[ic].m_End + offset;
|
2010-12-10 19:47:44 +00:00
|
|
|
|
2015-01-10 10:27:49 +00:00
|
|
|
if( !displ_opts->m_DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
|
2011-12-29 20:11:42 +00:00
|
|
|
GRCSegm( panel->GetClipBox(), DC, start.x, start.y, end.x, end.y,
|
2010-12-10 19:47:44 +00:00
|
|
|
m_ZoneMinThickness, color );
|
2009-08-06 18:30:46 +00:00
|
|
|
else
|
2011-12-29 20:11:42 +00:00
|
|
|
GRFillCSegm( panel->GetClipBox(), DC, start.x, start.y, end.x, end.y,
|
2010-12-10 19:47:44 +00:00
|
|
|
m_ZoneMinThickness, color );
|
2009-08-06 18:30:46 +00:00
|
|
|
}
|
|
|
|
}
|
2008-09-26 19:51:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-24 17:48:14 +00:00
|
|
|
const EDA_RECT ZONE_CONTAINER::GetBoundingBox() const
|
2008-05-02 05:16:35 +00:00
|
|
|
{
|
2008-09-26 19:51:36 +00:00
|
|
|
const int PRELOAD = 0x7FFFFFFF; // Biggest integer (32 bits)
|
2008-05-02 05:16:35 +00:00
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
int ymax = -PRELOAD;
|
|
|
|
int ymin = PRELOAD;
|
|
|
|
int xmin = PRELOAD;
|
|
|
|
int xmax = -PRELOAD;
|
2008-05-02 05:16:35 +00:00
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
int count = GetNumCorners();
|
2008-05-02 05:16:35 +00:00
|
|
|
|
2011-01-20 18:40:33 +00:00
|
|
|
for( int i = 0; i<count; ++i )
|
2008-05-02 05:16:35 +00:00
|
|
|
{
|
2008-09-26 19:51:36 +00:00
|
|
|
wxPoint corner = GetCornerPosition( i );
|
2008-05-02 05:16:35 +00:00
|
|
|
|
2012-09-22 11:19:37 +00:00
|
|
|
ymax = std::max( ymax, corner.y );
|
|
|
|
xmax = std::max( xmax, corner.x );
|
|
|
|
ymin = std::min( ymin, corner.y );
|
|
|
|
xmin = std::min( xmin, corner.x );
|
2008-05-02 05:16:35 +00:00
|
|
|
}
|
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT ret( wxPoint( xmin, ymin ), wxSize( xmax - xmin + 1, ymax - ymin + 1 ) );
|
2008-05-02 05:16:35 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-01 13:38:27 +00:00
|
|
|
void ZONE_CONTAINER::DrawWhileCreateOutline( EDA_DRAW_PANEL* panel, wxDC* DC,
|
|
|
|
GR_DRAWMODE draw_mode )
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2012-09-01 13:38:27 +00:00
|
|
|
GR_DRAWMODE current_gr_mode = draw_mode;
|
2008-09-26 19:51:36 +00:00
|
|
|
bool is_close_segment = false;
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2014-06-29 13:05:51 +00:00
|
|
|
if( !DC )
|
2008-01-31 20:53:44 +00:00
|
|
|
return;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-06-29 13:05:51 +00:00
|
|
|
LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
|
|
|
|
BOARD* brd = GetBoard();
|
2012-09-02 12:06:47 +00:00
|
|
|
EDA_COLOR_T color = brd->GetLayerColor( m_Layer );
|
2015-01-10 10:27:49 +00:00
|
|
|
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions();
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2015-01-10 10:27:49 +00:00
|
|
|
if( displ_opts->m_ContrastModeDisplay )
|
2008-01-31 20:53:44 +00:00
|
|
|
{
|
|
|
|
if( !IsOnLayer( curr_layer ) )
|
2012-09-02 12:06:47 +00:00
|
|
|
ColorTurnToDarkDarkGray( &color );
|
2008-01-31 20:53:44 +00:00
|
|
|
}
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
// draw the lines
|
2008-09-26 19:51:36 +00:00
|
|
|
wxPoint start_contour_pos = GetCornerPosition( 0 );
|
2008-10-19 18:18:45 +00:00
|
|
|
int icmax = GetNumCorners() - 1;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-10-17 06:17:48 +00:00
|
|
|
for( int ic = 0; ic <= icmax; ic++ )
|
2008-01-31 20:53:44 +00:00
|
|
|
{
|
2008-09-26 19:51:36 +00:00
|
|
|
int xi = GetCornerPosition( ic ).x;
|
|
|
|
int yi = GetCornerPosition( ic ).y;
|
2008-01-31 20:53:44 +00:00
|
|
|
int xf, yf;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-05-08 18:20:58 +00:00
|
|
|
if( !m_Poly->m_CornersList.IsEndContour( ic ) && ic < icmax )
|
2008-01-31 20:53:44 +00:00
|
|
|
{
|
2008-03-04 04:22:27 +00:00
|
|
|
is_close_segment = false;
|
2008-09-26 19:51:36 +00:00
|
|
|
xf = GetCornerPosition( ic + 1 ).x;
|
|
|
|
yf = GetCornerPosition( ic + 1 ).y;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-05-08 18:20:58 +00:00
|
|
|
if( m_Poly->m_CornersList.IsEndContour( ic + 1 ) || (ic == icmax - 1) )
|
2008-03-04 04:22:27 +00:00
|
|
|
current_gr_mode = GR_XOR;
|
|
|
|
else
|
|
|
|
current_gr_mode = draw_mode;
|
2008-01-31 20:53:44 +00:00
|
|
|
}
|
2011-07-14 15:42:44 +00:00
|
|
|
else // Draw the line from last corner to the first corner of the current contour
|
2008-01-31 20:53:44 +00:00
|
|
|
{
|
2008-03-04 04:22:27 +00:00
|
|
|
is_close_segment = true;
|
2008-09-26 19:51:36 +00:00
|
|
|
current_gr_mode = GR_XOR;
|
2008-01-31 20:53:44 +00:00
|
|
|
xf = start_contour_pos.x;
|
|
|
|
yf = start_contour_pos.y;
|
2008-10-19 18:18:45 +00:00
|
|
|
|
2008-10-17 06:17:48 +00:00
|
|
|
// Prepare the next contour for drawing, if exists
|
2008-10-19 18:18:45 +00:00
|
|
|
if( ic < icmax )
|
2008-10-17 06:17:48 +00:00
|
|
|
start_contour_pos = GetCornerPosition( ic + 1 );
|
2008-01-31 20:53:44 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
GRSetDrawMode( DC, current_gr_mode );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
if( is_close_segment )
|
2011-12-29 20:11:42 +00:00
|
|
|
GRLine( panel->GetClipBox(), DC, xi, yi, xf, yf, 0, WHITE );
|
2008-03-04 04:22:27 +00:00
|
|
|
else
|
2011-12-29 20:11:42 +00:00
|
|
|
GRLine( panel->GetClipBox(), DC, xi, yi, xf, yf, 0, color );
|
2008-01-31 20:53:44 +00:00
|
|
|
}
|
2007-12-09 12:59:06 +00:00
|
|
|
}
|
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2012-03-08 20:44:03 +00:00
|
|
|
int ZONE_CONTAINER::GetThermalReliefGap( D_PAD* aPad ) const
|
|
|
|
{
|
|
|
|
if( aPad == NULL || aPad->GetThermalGap() == 0 )
|
|
|
|
return m_ThermalReliefGap;
|
|
|
|
else
|
|
|
|
return aPad->GetThermalGap();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ZONE_CONTAINER::GetThermalReliefCopperBridge( D_PAD* aPad ) const
|
|
|
|
{
|
|
|
|
if( aPad == NULL || aPad->GetThermalWidth() == 0 )
|
|
|
|
return m_ThermalReliefCopperBridge;
|
|
|
|
else
|
|
|
|
return aPad->GetThermalWidth();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-15 12:49:11 +00:00
|
|
|
void ZONE_CONTAINER::SetCornerRadius( unsigned int aRadius )
|
|
|
|
{
|
|
|
|
m_cornerRadius = aRadius;
|
|
|
|
if( m_cornerRadius > (unsigned int) Mils2iu( MAX_ZONE_CORNER_RADIUS_MILS ) )
|
|
|
|
m_cornerRadius = Mils2iu( MAX_ZONE_CORNER_RADIUS_MILS );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-05-04 17:08:36 +00:00
|
|
|
bool ZONE_CONTAINER::HitTest( const wxPoint& aPosition ) const
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2014-05-04 17:08:36 +00:00
|
|
|
if( HitTestForCorner( aPosition ) >= 0 )
|
2007-12-29 19:15:58 +00:00
|
|
|
return true;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-05-04 17:08:36 +00:00
|
|
|
if( HitTestForEdge( aPosition ) >= 0 )
|
2007-12-29 19:15:58 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-05-04 17:08:36 +00:00
|
|
|
void ZONE_CONTAINER::SetSelectedCorner( const wxPoint& aPosition )
|
|
|
|
{
|
|
|
|
m_CornerSelection = HitTestForCorner( aPosition );
|
|
|
|
|
|
|
|
if( m_CornerSelection < 0 )
|
|
|
|
m_CornerSelection = HitTestForEdge( aPosition );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-17 16:06:12 +00:00
|
|
|
// Zones outlines have no thickness, so it Hit Test functions
|
|
|
|
// we must have a default distance between the test point
|
|
|
|
// and a corner or a zone edge:
|
2013-12-29 10:15:06 +00:00
|
|
|
#define MAX_DIST_IN_MM 0.25
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2014-05-04 17:08:36 +00:00
|
|
|
int ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos ) const
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2013-12-29 10:15:06 +00:00
|
|
|
int distmax = Millimeter2iu( MAX_DIST_IN_MM );
|
2014-05-04 17:08:36 +00:00
|
|
|
return m_Poly->HitTestForCorner( refPos, distmax );
|
2007-12-29 19:15:58 +00:00
|
|
|
}
|
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2014-05-04 17:08:36 +00:00
|
|
|
int ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos ) const
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2013-12-29 10:15:06 +00:00
|
|
|
int distmax = Millimeter2iu( MAX_DIST_IN_MM );
|
2014-05-04 17:08:36 +00:00
|
|
|
return m_Poly->HitTestForEdge( refPos, distmax );
|
2007-12-29 19:15:58 +00:00
|
|
|
}
|
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2013-09-21 18:09:41 +00:00
|
|
|
bool ZONE_CONTAINER::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
|
2008-01-06 12:43:57 +00:00
|
|
|
{
|
2013-09-21 18:09:41 +00:00
|
|
|
EDA_RECT arect = aRect;
|
|
|
|
arect.Inflate( aAccuracy );
|
2014-11-08 12:25:29 +00:00
|
|
|
EDA_RECT bbox = m_Poly->GetBoundingBox();
|
|
|
|
bbox.Normalize();
|
2013-09-21 18:09:41 +00:00
|
|
|
|
|
|
|
if( aContained )
|
|
|
|
return arect.Contains( bbox );
|
|
|
|
else // Test for intersection between aRect and the polygon
|
|
|
|
// For a polygon, using its bounding box has no sense here
|
|
|
|
{
|
|
|
|
// Fast test: if aRect is outside the polygon bounding box,
|
|
|
|
// rectangles cannot intersect
|
|
|
|
if( ! bbox.Intersects( arect ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// aRect is inside the polygon bounding box,
|
|
|
|
// and can intersect the polygon: use a fine test.
|
|
|
|
// aRect intersects the polygon if at least one aRect corner
|
|
|
|
// is inside the polygon
|
|
|
|
wxPoint corner = arect.GetOrigin();
|
|
|
|
|
|
|
|
if( HitTestInsideZone( corner ) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
corner.x = arect.GetEnd().x;
|
2008-01-06 12:43:57 +00:00
|
|
|
|
2013-09-21 18:09:41 +00:00
|
|
|
if( HitTestInsideZone( corner ) )
|
|
|
|
return true;
|
2008-01-06 12:43:57 +00:00
|
|
|
|
2013-09-21 18:09:41 +00:00
|
|
|
corner = arect.GetEnd();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-09-21 18:09:41 +00:00
|
|
|
if( HitTestInsideZone( corner ) )
|
|
|
|
return true;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-09-21 18:09:41 +00:00
|
|
|
corner.x = arect.GetOrigin().x;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-09-21 18:09:41 +00:00
|
|
|
if( HitTestInsideZone( corner ) )
|
|
|
|
return true;
|
2008-01-06 12:43:57 +00:00
|
|
|
|
2013-09-21 18:09:41 +00:00
|
|
|
// No corner inside arect, but outlines can intersect arect
|
|
|
|
// if one of outline corners is inside arect
|
|
|
|
int count = m_Poly->GetCornersCount();
|
|
|
|
for( int ii =0; ii < count; ii++ )
|
|
|
|
{
|
|
|
|
if( arect.Contains( m_Poly->GetPos( ii ) ) )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2008-01-06 12:43:57 +00:00
|
|
|
}
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2011-01-20 18:40:33 +00:00
|
|
|
|
2011-08-09 03:41:20 +00:00
|
|
|
int ZONE_CONTAINER::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
|
|
|
|
{
|
|
|
|
int myClearance = m_ZoneClearance;
|
|
|
|
|
2011-08-09 14:13:01 +00:00
|
|
|
#if 0 // Maybe the netclass clearance should not come into play for a zone?
|
|
|
|
// At least the policy decision can be controlled by the zone
|
|
|
|
// itself, i.e. here. On reasons of insufficient documentation,
|
|
|
|
// the user will be less bewildered if we simply respect the
|
|
|
|
// "zone clearance" setting in the zone properties dialog. (At least
|
|
|
|
// until there is a UI boolean for this.)
|
2011-08-09 03:41:20 +00:00
|
|
|
|
2014-05-20 09:29:37 +00:00
|
|
|
NETCLASSPTR myClass = GetNetClass();
|
2011-08-09 14:13:01 +00:00
|
|
|
|
|
|
|
if( myClass )
|
|
|
|
myClearance = std::max( myClearance, myClass->GetClearance() );
|
2011-08-09 03:41:20 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if( aItem )
|
|
|
|
{
|
|
|
|
int hisClearance = aItem->GetClearance( NULL );
|
2012-08-03 15:43:15 +00:00
|
|
|
myClearance = std::max( hisClearance, myClearance );
|
2011-08-09 03:41:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return myClearance;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
bool ZONE_CONTAINER::HitTestFilledArea( const wxPoint& aRefPos ) const
|
2008-11-27 10:12:46 +00:00
|
|
|
{
|
2015-07-27 19:45:57 +00:00
|
|
|
return m_FilledPolysList.Contains( VECTOR2I( aRefPos.x, aRefPos.y ) );
|
2008-11-27 10:12:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
void ZONE_CONTAINER::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
2008-01-31 20:53:44 +00:00
|
|
|
|
|
|
|
msg = _( "Zone Outline" );
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2012-11-23 09:10:37 +00:00
|
|
|
// Display Cutout instead of Outline for holes inside a zone
|
|
|
|
// i.e. when num contour !=0
|
2008-01-31 20:53:44 +00:00
|
|
|
int ncont = m_Poly->GetContour( m_CornerSelection );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
if( ncont )
|
|
|
|
msg << wxT( " " ) << _( "(Cutout)" );
|
2008-01-05 13:37:51 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg, DARKCYAN ) );
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2012-11-23 09:10:37 +00:00
|
|
|
if( GetIsKeepout() )
|
|
|
|
{
|
|
|
|
msg.Empty();
|
2013-01-12 17:32:24 +00:00
|
|
|
|
2012-11-23 09:10:37 +00:00
|
|
|
if( GetDoNotAllowVias() )
|
2014-11-15 19:06:05 +00:00
|
|
|
AccumulateDescription( msg, _( "No via" ) );
|
2013-01-12 17:32:24 +00:00
|
|
|
|
2012-11-23 09:10:37 +00:00
|
|
|
if( GetDoNotAllowTracks() )
|
2013-04-07 11:55:18 +00:00
|
|
|
AccumulateDescription( msg, _("No track") );
|
2013-01-12 17:32:24 +00:00
|
|
|
|
2012-11-23 09:10:37 +00:00
|
|
|
if( GetDoNotAllowCopperPour() )
|
2013-04-07 11:55:18 +00:00
|
|
|
AccumulateDescription( msg, _("No copper pour") );
|
2012-11-23 09:10:37 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Keepout" ), msg, RED ) );
|
2012-11-23 09:10:37 +00:00
|
|
|
}
|
|
|
|
else if( IsOnCopperLayer() )
|
2008-01-31 20:53:44 +00:00
|
|
|
{
|
2014-02-25 10:40:34 +00:00
|
|
|
if( GetNetCode() >= 0 )
|
2008-09-26 19:51:36 +00:00
|
|
|
{
|
2015-01-22 12:06:34 +00:00
|
|
|
NETINFO_ITEM* net = GetNet();
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2015-01-22 12:06:34 +00:00
|
|
|
if( net )
|
|
|
|
msg = net->GetNetname();
|
|
|
|
else // Should not occur
|
|
|
|
msg = _( "<unknown>" );
|
2008-09-26 19:51:36 +00:00
|
|
|
}
|
2015-01-22 12:06:34 +00:00
|
|
|
else // a netcode < 0 is an error
|
|
|
|
msg = wxT( "<error>" );
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2013-01-12 17:32:24 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "NetName" ), msg, RED ) );
|
|
|
|
|
2012-01-29 19:29:19 +00:00
|
|
|
// Display net code : (useful in test or debug)
|
2014-02-25 10:40:34 +00:00
|
|
|
msg.Printf( wxT( "%d" ), GetNetCode() );
|
2013-01-12 17:32:24 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "NetCode" ), msg, RED ) );
|
2012-01-29 19:29:19 +00:00
|
|
|
|
|
|
|
// Display priority level
|
|
|
|
msg.Printf( wxT( "%d" ), GetPriority() );
|
2013-01-12 17:32:24 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Priority" ), msg, BLUE ) );
|
2008-09-26 19:51:36 +00:00
|
|
|
}
|
|
|
|
else
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2013-01-12 17:32:24 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Non Copper Zone" ), wxEmptyString, RED ) );
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2013-04-07 11:55:18 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), BROWN ) );
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2013-05-09 19:08:12 +00:00
|
|
|
msg.Printf( wxT( "%d" ), (int) m_Poly->m_CornersList.GetCornersCount() );
|
2013-01-12 17:32:24 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Corners" ), msg, BLUE ) );
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2008-12-03 10:32:53 +00:00
|
|
|
if( m_FillMode )
|
2012-05-29 18:10:56 +00:00
|
|
|
msg = _( "Segments" );
|
2008-10-08 12:36:27 +00:00
|
|
|
else
|
2008-12-03 10:32:53 +00:00
|
|
|
msg = _( "Polygons" );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-11-15 19:06:05 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Fill Mode" ), msg, BROWN ) );
|
2008-10-07 09:32:56 +00:00
|
|
|
|
2008-10-08 12:36:27 +00:00
|
|
|
// Useful for statistics :
|
2012-02-10 22:26:42 +00:00
|
|
|
msg.Printf( wxT( "%d" ), (int) m_Poly->m_HatchLines.size() );
|
2014-11-15 19:06:05 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Hatch Lines" ), msg, BLUE ) );
|
2008-10-08 12:36:27 +00:00
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
if( !m_FilledPolysList.IsEmpty() )
|
2008-10-08 12:36:27 +00:00
|
|
|
{
|
2015-11-04 08:48:34 +00:00
|
|
|
msg.Printf( wxT( "%d" ), m_FilledPolysList.TotalVertices() );
|
2014-11-15 19:06:05 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Corner Count" ), msg, BLUE ) );
|
2008-10-08 12:36:27 +00:00
|
|
|
}
|
2007-12-29 19:15:58 +00:00
|
|
|
}
|
2008-01-06 12:43:57 +00:00
|
|
|
|
|
|
|
|
2008-02-01 21:30:45 +00:00
|
|
|
/* Geometric transforms: */
|
2008-01-31 20:53:44 +00:00
|
|
|
|
|
|
|
void ZONE_CONTAINER::Move( const wxPoint& offset )
|
2008-01-06 12:43:57 +00:00
|
|
|
{
|
2008-12-03 10:32:53 +00:00
|
|
|
/* move outlines */
|
2013-05-09 19:08:12 +00:00
|
|
|
for( unsigned ii = 0; ii < m_Poly->m_CornersList.GetCornersCount(); ii++ )
|
2008-01-31 20:53:44 +00:00
|
|
|
{
|
2008-09-26 19:51:36 +00:00
|
|
|
SetCornerPosition( ii, GetCornerPosition( ii ) + offset );
|
2008-01-31 20:53:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_Poly->Hatch();
|
2008-12-03 10:32:53 +00:00
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
m_FilledPolysList.Move( VECTOR2I( offset.x, offset.y ) );
|
2011-01-20 18:40:33 +00:00
|
|
|
|
2009-08-06 18:30:46 +00:00
|
|
|
for( unsigned ic = 0; ic < m_FillSegmList.size(); ic++ )
|
|
|
|
{
|
|
|
|
m_FillSegmList[ic].m_Start += offset;
|
2011-01-20 18:40:33 +00:00
|
|
|
m_FillSegmList[ic].m_End += offset;
|
2009-08-06 18:30:46 +00:00
|
|
|
}
|
2008-01-06 12:43:57 +00:00
|
|
|
}
|
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
|
2014-05-04 17:08:36 +00:00
|
|
|
void ZONE_CONTAINER::MoveEdge( const wxPoint& offset, int aEdge )
|
2008-02-01 21:30:45 +00:00
|
|
|
{
|
2008-03-04 04:22:27 +00:00
|
|
|
// Move the start point of the selected edge:
|
2014-05-04 17:08:36 +00:00
|
|
|
SetCornerPosition( aEdge, GetCornerPosition( aEdge ) + offset );
|
2008-02-01 21:30:45 +00:00
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
// Move the end point of the selected edge:
|
2014-05-04 17:08:36 +00:00
|
|
|
if( m_Poly->m_CornersList.IsEndContour( aEdge ) || aEdge == GetNumCorners() - 1 )
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
2014-05-04 17:08:36 +00:00
|
|
|
int icont = m_Poly->GetContour( aEdge );
|
|
|
|
aEdge = m_Poly->GetContourStart( icont );
|
2008-03-04 04:22:27 +00:00
|
|
|
}
|
|
|
|
else
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2014-05-04 17:08:36 +00:00
|
|
|
aEdge++;
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
|
|
|
|
2014-05-04 17:08:36 +00:00
|
|
|
SetCornerPosition( aEdge, GetCornerPosition( aEdge ) + offset );
|
2008-02-01 21:30:45 +00:00
|
|
|
|
|
|
|
m_Poly->Hatch();
|
|
|
|
}
|
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
void ZONE_CONTAINER::Rotate( const wxPoint& centre, double angle )
|
2008-01-06 12:43:57 +00:00
|
|
|
{
|
2009-08-01 19:58:01 +00:00
|
|
|
wxPoint pos;
|
2011-01-20 18:40:33 +00:00
|
|
|
|
2013-05-09 19:08:12 +00:00
|
|
|
for( unsigned ic = 0; ic < m_Poly->m_CornersList.GetCornersCount(); ic++ )
|
2008-01-31 20:53:44 +00:00
|
|
|
{
|
2013-05-08 18:20:58 +00:00
|
|
|
pos = m_Poly->m_CornersList.GetPos( ic );
|
2008-01-31 20:53:44 +00:00
|
|
|
RotatePoint( &pos, centre, angle );
|
2013-05-08 18:20:58 +00:00
|
|
|
m_Poly->SetX( ic, pos.x );
|
|
|
|
m_Poly->SetY( ic, pos.y );
|
2008-01-31 20:53:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_Poly->Hatch();
|
2009-08-01 19:58:01 +00:00
|
|
|
|
|
|
|
/* rotate filled areas: */
|
2015-07-27 19:45:57 +00:00
|
|
|
for( SHAPE_POLY_SET::ITERATOR ic = m_FilledPolysList.Iterate(); ic; ++ic )
|
|
|
|
RotatePoint( &ic->x, &ic->y, centre.x, centre.y, angle );
|
2011-01-20 18:40:33 +00:00
|
|
|
|
2009-08-06 18:30:46 +00:00
|
|
|
for( unsigned ic = 0; ic < m_FillSegmList.size(); ic++ )
|
|
|
|
{
|
|
|
|
RotatePoint( &m_FillSegmList[ic].m_Start, centre, angle );
|
|
|
|
RotatePoint( &m_FillSegmList[ic].m_End, centre, angle );
|
|
|
|
}
|
2008-01-06 12:43:57 +00:00
|
|
|
}
|
|
|
|
|
2011-01-20 18:40:33 +00:00
|
|
|
|
|
|
|
void ZONE_CONTAINER::Flip( const wxPoint& aCentre )
|
2009-08-01 19:26:05 +00:00
|
|
|
{
|
|
|
|
Mirror( aCentre );
|
2016-02-09 00:16:07 +00:00
|
|
|
int copperLayerCount = GetBoard()->GetCopperLayerCount();
|
|
|
|
SetLayer( FlipLayer( GetLayer(), copperLayerCount ) );
|
2009-08-01 19:26:05 +00:00
|
|
|
}
|
2008-01-06 12:43:57 +00:00
|
|
|
|
2011-01-20 18:40:33 +00:00
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
void ZONE_CONTAINER::Mirror( const wxPoint& mirror_ref )
|
2008-01-06 12:43:57 +00:00
|
|
|
{
|
2013-05-09 19:08:12 +00:00
|
|
|
for( unsigned ic = 0; ic < m_Poly->m_CornersList.GetCornersCount(); ic++ )
|
2008-01-31 20:53:44 +00:00
|
|
|
{
|
2015-06-26 13:41:56 +00:00
|
|
|
int py = mirror_ref.y - m_Poly->m_CornersList.GetY( ic );
|
2013-05-08 18:20:58 +00:00
|
|
|
m_Poly->m_CornersList.SetY( ic, py + mirror_ref.y );
|
2008-01-31 20:53:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_Poly->Hatch();
|
2009-08-01 19:58:01 +00:00
|
|
|
|
2015-07-27 19:45:57 +00:00
|
|
|
for( SHAPE_POLY_SET::ITERATOR ic = m_FilledPolysList.Iterate(); ic; ++ic )
|
2009-08-01 19:58:01 +00:00
|
|
|
{
|
2015-07-27 19:45:57 +00:00
|
|
|
int py = mirror_ref.y - ic->y;
|
|
|
|
ic->y = py + mirror_ref.y;
|
2009-08-01 19:58:01 +00:00
|
|
|
}
|
2011-01-20 18:40:33 +00:00
|
|
|
|
2009-08-06 18:30:46 +00:00
|
|
|
for( unsigned ic = 0; ic < m_FillSegmList.size(); ic++ )
|
|
|
|
{
|
2015-06-26 13:41:56 +00:00
|
|
|
MIRROR( m_FillSegmList[ic].m_Start.y, mirror_ref.y );
|
|
|
|
MIRROR( m_FillSegmList[ic].m_End.y, mirror_ref.y );
|
2009-08-06 18:30:46 +00:00
|
|
|
}
|
2008-01-06 12:43:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
void ZONE_CONTAINER::Copy( ZONE_CONTAINER* src )
|
2008-01-06 12:43:57 +00:00
|
|
|
{
|
2008-01-31 20:53:44 +00:00
|
|
|
m_Parent = src->m_Parent;
|
|
|
|
m_Layer = src->m_Layer;
|
2014-02-25 10:40:34 +00:00
|
|
|
SetNetCode( src->GetNetCode() );
|
2011-12-12 08:37:05 +00:00
|
|
|
SetTimeStamp( src->m_TimeStamp );
|
2009-08-23 15:22:44 +00:00
|
|
|
m_Poly->RemoveAllContours();
|
2008-01-31 20:53:44 +00:00
|
|
|
m_Poly->Copy( src->m_Poly ); // copy outlines
|
2014-10-02 17:09:32 +00:00
|
|
|
m_CornerSelection = -1; // For corner moving, corner index to drag,
|
|
|
|
// or -1 if no selection
|
2011-01-20 18:40:33 +00:00
|
|
|
m_ZoneClearance = src->m_ZoneClearance; // clearance value
|
|
|
|
m_ZoneMinThickness = src->m_ZoneMinThickness;
|
|
|
|
m_FillMode = src->m_FillMode; // Filling mode (segments/polygons)
|
|
|
|
m_ArcToSegmentsCount = src->m_ArcToSegmentsCount;
|
2012-02-24 23:23:46 +00:00
|
|
|
m_PadConnection = src->m_PadConnection;
|
2011-11-30 21:15:56 +00:00
|
|
|
m_ThermalReliefGap = src->m_ThermalReliefGap;
|
|
|
|
m_ThermalReliefCopperBridge = src->m_ThermalReliefCopperBridge;
|
2012-04-11 09:47:57 +00:00
|
|
|
m_Poly->SetHatchStyle( src->m_Poly->GetHatchStyle() );
|
|
|
|
m_Poly->SetHatchPitch( src->m_Poly->GetHatchPitch() );
|
2009-09-17 17:48:40 +00:00
|
|
|
m_Poly->m_HatchLines = src->m_Poly->m_HatchLines; // Copy vector <CSegment>
|
2013-05-14 18:47:01 +00:00
|
|
|
m_FilledPolysList.RemoveAllContours();
|
|
|
|
m_FilledPolysList.Append( src->m_FilledPolysList );
|
2009-08-23 15:22:44 +00:00
|
|
|
m_FillSegmList.clear();
|
2009-08-06 18:30:46 +00:00
|
|
|
m_FillSegmList = src->m_FillSegmList;
|
2008-01-06 12:43:57 +00:00
|
|
|
}
|
2008-10-23 10:26:06 +00:00
|
|
|
|
2011-01-20 18:40:33 +00:00
|
|
|
|
2012-02-24 23:23:46 +00:00
|
|
|
ZoneConnection ZONE_CONTAINER::GetPadConnection( D_PAD* aPad ) const
|
|
|
|
{
|
2015-08-18 14:19:17 +00:00
|
|
|
if( aPad == NULL || aPad->GetZoneConnection() == PAD_ZONE_CONN_INHERITED )
|
2012-02-24 23:23:46 +00:00
|
|
|
return m_PadConnection;
|
|
|
|
else
|
|
|
|
return aPad->GetZoneConnection();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-09 17:00:13 +00:00
|
|
|
void ZONE_CONTAINER::AddPolygon( std::vector< wxPoint >& aPolygon )
|
|
|
|
{
|
|
|
|
if( aPolygon.empty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
for( unsigned i = 0; i < aPolygon.size(); i++ )
|
|
|
|
{
|
|
|
|
if( i == 0 )
|
|
|
|
m_Poly->Start( GetLayer(), aPolygon[i].x, aPolygon[i].y, GetHatchStyle() );
|
|
|
|
else
|
|
|
|
AppendCorner( aPolygon[i] );
|
|
|
|
}
|
|
|
|
|
2012-07-30 07:40:25 +00:00
|
|
|
m_Poly->CloseLastContour();
|
2012-06-09 17:00:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-07-14 15:42:44 +00:00
|
|
|
wxString ZONE_CONTAINER::GetSelectMenuText() const
|
|
|
|
{
|
|
|
|
wxString text;
|
|
|
|
NETINFO_ITEM* net;
|
|
|
|
BOARD* board = GetBoard();
|
|
|
|
|
|
|
|
int ncont = m_Poly->GetContour( m_CornerSelection );
|
|
|
|
|
|
|
|
if( ncont )
|
|
|
|
text << wxT( " " ) << _( "(Cutout)" );
|
|
|
|
|
2013-02-07 17:56:41 +00:00
|
|
|
if( GetIsKeepout() )
|
|
|
|
text << wxT( " " ) << _( "(Keepout)" );
|
|
|
|
|
2013-04-09 17:49:01 +00:00
|
|
|
text << wxString::Format( wxT( " (%08lX)" ), m_TimeStamp );
|
2011-07-14 15:42:44 +00:00
|
|
|
|
2013-02-09 20:03:20 +00:00
|
|
|
// Display net name for copper zones
|
|
|
|
if( !GetIsKeepout() )
|
2011-07-14 15:42:44 +00:00
|
|
|
{
|
2014-02-25 10:40:34 +00:00
|
|
|
if( GetNetCode() >= 0 )
|
2011-07-14 15:42:44 +00:00
|
|
|
{
|
2013-02-09 20:03:20 +00:00
|
|
|
if( board )
|
|
|
|
{
|
2014-02-25 10:40:34 +00:00
|
|
|
net = GetNet();
|
2011-07-14 15:42:44 +00:00
|
|
|
|
2013-02-09 20:03:20 +00:00
|
|
|
if( net )
|
|
|
|
{
|
|
|
|
text << wxT( " [" ) << net->GetNetname() << wxT( "]" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2011-07-14 15:42:44 +00:00
|
|
|
{
|
2013-02-09 20:03:20 +00:00
|
|
|
text << _( "** NO BOARD DEFINED **" );
|
2011-07-14 15:42:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2013-02-09 20:03:20 +00:00
|
|
|
{ // A netcode < 0 is an error:
|
|
|
|
// Netname not found or area not initialised
|
2014-01-14 10:41:06 +00:00
|
|
|
text << wxT( " [" ) << GetNetname() << wxT( "]" );
|
2013-02-09 20:03:20 +00:00
|
|
|
text << wxT( " <" ) << _( "Not Found" ) << wxT( ">" );
|
2011-07-14 15:42:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-18 17:27:47 +00:00
|
|
|
wxString msg;
|
|
|
|
msg.Printf( _( "Zone Outline %s on %s" ), GetChars( text ),
|
2013-04-09 17:49:01 +00:00
|
|
|
GetChars( GetLayerName() ) );
|
2011-07-14 15:42:44 +00:00
|
|
|
|
2013-06-18 17:27:47 +00:00
|
|
|
return msg;
|
2016-02-09 00:16:07 +00:00
|
|
|
}
|