2011-10-17 20:01:27 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
|
|
|
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* 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>
|
2007-12-09 12:59:06 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <protos.h>
|
|
|
|
#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>
|
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
|
|
|
{
|
2011-12-07 15:49:32 +00:00
|
|
|
SetNet( -1 ); // Net number for fast comparisons
|
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;
|
2011-02-21 19:43:59 +00:00
|
|
|
smoothedPoly = NULL;
|
2012-02-06 05:44:19 +00:00
|
|
|
cornerSmoothingType = ZONE_SETTINGS::SMOOTHING_NONE;
|
2011-02-21 19:43:59 +00:00
|
|
|
cornerRadius = 0;
|
2011-01-20 18:40:33 +00:00
|
|
|
utility = 0; // flags used in polygon calculations
|
|
|
|
utility2 = 0; // flags used in polygon calculations
|
|
|
|
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 )
|
|
|
|
{
|
|
|
|
// Should the copy be on the same net?
|
|
|
|
SetNet( aZone.GetNet() );
|
|
|
|
m_Poly = new CPolyLine( *aZone.m_Poly );
|
|
|
|
|
|
|
|
// For corner moving, corner index to drag, or -1 if no selection
|
|
|
|
m_CornerSelection = -1;
|
|
|
|
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;
|
|
|
|
m_FilledPolysList = aZone.m_FilledPolysList;
|
|
|
|
m_FillSegmList = aZone.m_FillSegmList;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
bool change = ( m_FilledPolysList.size() > 0 ) || ( m_FillSegmList.size() > 0 );
|
|
|
|
|
|
|
|
m_FilledPolysList.clear();
|
|
|
|
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
|
|
|
|
2011-10-17 20:01:27 +00:00
|
|
|
void ZONE_CONTAINER::SetNet( int aNetCode )
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2011-12-07 15:49:32 +00:00
|
|
|
BOARD_CONNECTED_ITEM::SetNet( aNetCode );
|
2007-12-09 12:59:06 +00:00
|
|
|
|
2011-10-17 20:01:27 +00:00
|
|
|
if( aNetCode < 0 )
|
2008-01-31 20:53:44 +00:00
|
|
|
return;
|
|
|
|
|
2009-10-21 19:16:25 +00:00
|
|
|
BOARD* board = GetBoard();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-10-21 19:16:25 +00:00
|
|
|
if( board )
|
2008-01-31 20:53:44 +00:00
|
|
|
{
|
2011-10-17 20:01:27 +00:00
|
|
|
NETINFO_ITEM* net = board->FindNet( aNetCode );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
if( net )
|
2008-12-14 19:45:05 +00:00
|
|
|
m_Netname = net->GetNetname();
|
2008-01-31 20:53:44 +00:00
|
|
|
else
|
|
|
|
m_Netname.Empty();
|
|
|
|
}
|
|
|
|
else
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2008-01-31 20:53:44 +00:00
|
|
|
m_Netname.Empty();
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
2008-01-31 20:53:44 +00:00
|
|
|
}
|
2007-12-09 12:59:06 +00:00
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void ZONE_CONTAINER::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, int aDrawMode, const wxPoint& offset )
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2008-01-31 20:53:44 +00:00
|
|
|
if( DC == NULL )
|
|
|
|
return;
|
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
wxPoint seg_start, seg_end;
|
2008-09-26 19:51:36 +00:00
|
|
|
int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2011-01-20 18:40:33 +00:00
|
|
|
BOARD* brd = GetBoard();
|
|
|
|
int 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 );
|
2007-12-29 19:15:58 +00:00
|
|
|
|
|
|
|
if( DisplayOpt.ContrastModeDisplay )
|
|
|
|
{
|
|
|
|
if( !IsOnLayer( curr_layer ) )
|
|
|
|
{
|
|
|
|
color &= ~MASKCOLOR;
|
|
|
|
color |= DARKDARKGRAY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-17 20:01:27 +00:00
|
|
|
if( aDrawMode & GR_HIGHLIGHT )
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2010-12-14 15:56:30 +00:00
|
|
|
if( aDrawMode & GR_AND )
|
2010-12-08 20:12:46 +00:00
|
|
|
color &= ~HIGHLIGHT_FLAG;
|
2007-12-29 19:15:58 +00:00
|
|
|
else
|
2010-12-08 20:12:46 +00:00
|
|
|
color |= HIGHLIGHT_FLAG;
|
2007-12-29 19:15:58 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
if( color & HIGHLIGHT_FLAG )
|
2007-12-29 19:15:58 +00:00
|
|
|
color = ColorRefs[color & MASKCOLOR].m_LightColor;
|
|
|
|
|
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
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
if( m_Poly->corner[ic].end_contour == false && 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
|
|
|
{
|
2011-01-20 18:40:33 +00:00
|
|
|
seg_start.x = m_Poly->m_HatchLines[ic].xi + offset.x;
|
|
|
|
seg_start.y = m_Poly->m_HatchLines[ic].yi + offset.y;
|
|
|
|
seg_end.x = m_Poly->m_HatchLines[ic].xf + offset.x;
|
|
|
|
seg_end.y = m_Poly->m_HatchLines[ic].yf + offset.y;
|
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,
|
|
|
|
wxDC* DC, int aDrawMode, const wxPoint& offset )
|
|
|
|
{
|
2011-01-20 18:40:33 +00:00
|
|
|
static vector <char> CornersTypeBuffer;
|
2008-12-29 18:02:54 +00:00
|
|
|
static vector <wxPoint> CornersBuffer;
|
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)
|
2009-01-05 05:21:35 +00:00
|
|
|
bool outline_mode = DisplayOpt.DisplayZonesMode == 2 ? true : false;
|
2008-09-26 19:51:36 +00:00
|
|
|
|
|
|
|
if( DC == NULL )
|
|
|
|
return;
|
|
|
|
|
2008-12-12 21:30:07 +00:00
|
|
|
if( DisplayOpt.DisplayZonesMode == 1 ) // Do not show filled areas
|
2008-09-26 19:51:36 +00:00
|
|
|
return;
|
|
|
|
|
2008-12-03 10:32:53 +00:00
|
|
|
if( m_FilledPolysList.size() == 0 ) // Nothing to draw
|
2008-09-26 19:51:36 +00:00
|
|
|
return;
|
|
|
|
|
2011-01-20 18:40:33 +00:00
|
|
|
BOARD* brd = GetBoard();
|
|
|
|
int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
|
|
|
|
int 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 );
|
|
|
|
|
|
|
|
if( DisplayOpt.ContrastModeDisplay )
|
|
|
|
{
|
|
|
|
if( !IsOnLayer( curr_layer ) )
|
|
|
|
{
|
|
|
|
color &= ~MASKCOLOR;
|
|
|
|
color |= DARKDARKGRAY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-17 20:01:27 +00:00
|
|
|
if( aDrawMode & GR_HIGHLIGHT )
|
2008-09-26 19:51:36 +00:00
|
|
|
{
|
|
|
|
if( aDrawMode & GR_AND )
|
2010-12-08 20:12:46 +00:00
|
|
|
color &= ~HIGHLIGHT_FLAG;
|
2008-09-26 19:51:36 +00:00
|
|
|
else
|
2010-12-08 20:12:46 +00:00
|
|
|
color |= HIGHLIGHT_FLAG;
|
2008-09-26 19:51:36 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
if( color & HIGHLIGHT_FLAG )
|
2008-09-26 19:51:36 +00:00
|
|
|
color = ColorRefs[color & MASKCOLOR].m_LightColor;
|
|
|
|
|
2008-12-03 10:32:53 +00:00
|
|
|
SetAlpha( &color, 150 );
|
2008-09-26 19:51:36 +00:00
|
|
|
|
2008-12-03 10:32:53 +00:00
|
|
|
CornersTypeBuffer.clear();
|
|
|
|
CornersBuffer.clear();
|
2008-09-26 19:51:36 +00:00
|
|
|
|
2008-09-27 19:26:29 +00:00
|
|
|
// Draw all filled areas
|
2008-12-03 10:32:53 +00:00
|
|
|
int imax = m_FilledPolysList.size() - 1;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-12-03 10:32:53 +00:00
|
|
|
for( int ic = 0; ic <= imax; ic++ )
|
2008-09-26 19:51:36 +00:00
|
|
|
{
|
|
|
|
CPolyPt* corner = &m_FilledPolysList[ic];
|
2009-01-05 05:21:35 +00:00
|
|
|
|
2011-01-20 18:40:33 +00:00
|
|
|
wxPoint coord( corner->x + offset.x, corner->y + offset.y );
|
2009-01-05 05:21:35 +00:00
|
|
|
|
2011-01-20 18:40:33 +00:00
|
|
|
CornersBuffer.push_back( coord );
|
2009-01-05 05:21:35 +00:00
|
|
|
|
2011-01-20 18:40:33 +00:00
|
|
|
CornersTypeBuffer.push_back( (char) corner->utility );
|
2009-01-05 05:21:35 +00:00
|
|
|
|
2008-12-03 10:32:53 +00:00
|
|
|
if( (corner->end_contour) || (ic == imax) ) // the last corner of a filled area is found: draw it
|
2009-01-05 05:21:35 +00:00
|
|
|
{
|
2011-07-14 15:42:44 +00:00
|
|
|
/* Draw the current filled area: draw segments outline first
|
|
|
|
* Curiously, draw segments outline first and after draw filled polygons
|
|
|
|
* with outlines thickness = 0 is a faster than
|
|
|
|
* just draw filled polygons but with outlines thickness = m_ZoneMinThickness
|
|
|
|
* So DO NOT use draw filled polygons with outlines having a thickness > 0
|
2008-12-29 18:02:54 +00:00
|
|
|
* Note: Extra segments ( added by kbool to joint holes with external outline) are not drawn
|
|
|
|
*/
|
2008-11-22 20:50:30 +00:00
|
|
|
{
|
|
|
|
// Draw outlines:
|
2009-01-05 05:21:35 +00:00
|
|
|
if( (m_ZoneMinThickness > 1) || outline_mode )
|
2008-11-22 20:50:30 +00:00
|
|
|
{
|
2011-01-20 18:40:33 +00:00
|
|
|
int ilim = CornersBuffer.size() - 1;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
for( int is = 0, ie = ilim; is <= ilim; ie = is, is++ )
|
2008-11-22 20:50:30 +00:00
|
|
|
{
|
2008-12-03 10:32:53 +00:00
|
|
|
int x0 = CornersBuffer[is].x;
|
|
|
|
int y0 = CornersBuffer[is].y;
|
|
|
|
int x1 = CornersBuffer[ie].x;
|
|
|
|
int y1 = CornersBuffer[ie].y;
|
2009-01-05 05:21:35 +00:00
|
|
|
|
|
|
|
if( CornersTypeBuffer[ie] == 0 ) // Draw only basic outlines, not extra segments
|
2008-12-03 10:32:53 +00:00
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
if( !DisplayOpt.DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
|
2011-12-29 20:11:42 +00:00
|
|
|
GRCSegm( panel->GetClipBox(), DC,
|
2011-01-20 18:40:33 +00:00
|
|
|
x0, y0, x1, y1,
|
|
|
|
m_ZoneMinThickness, color );
|
2008-12-03 10:32:53 +00:00
|
|
|
else
|
2011-12-29 20:11:42 +00:00
|
|
|
GRFillCSegm( panel->GetClipBox(), DC,
|
2011-01-20 18:40:33 +00:00
|
|
|
x0, y0, x1, y1,
|
|
|
|
m_ZoneMinThickness, color );
|
2008-12-03 10:32:53 +00:00
|
|
|
}
|
2008-11-22 20:50:30 +00:00
|
|
|
}
|
|
|
|
}
|
2009-01-05 05:21:35 +00:00
|
|
|
|
2008-11-22 20:50:30 +00:00
|
|
|
// Draw areas:
|
2009-01-05 05:21:35 +00:00
|
|
|
if( m_FillMode==0 && !outline_mode )
|
2011-12-29 20:11:42 +00:00
|
|
|
GRPoly( panel->GetClipBox(), DC, CornersBuffer.size(), &CornersBuffer[0],
|
2011-01-20 18:40:33 +00:00
|
|
|
true, 0, color, color );
|
2008-11-22 20:50:30 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-12-29 18:02:54 +00:00
|
|
|
CornersTypeBuffer.clear();
|
|
|
|
CornersBuffer.clear();
|
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
|
|
|
|
2009-08-06 18:30:46 +00:00
|
|
|
if( !DisplayOpt.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
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
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
|
|
|
|
|
|
|
ymax = MAX( ymax, corner.y );
|
|
|
|
xmax = MAX( xmax, corner.x );
|
|
|
|
ymin = MIN( ymin, corner.y );
|
|
|
|
xmin = MIN( xmin, corner.x );
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
void ZONE_CONTAINER::DrawWhileCreateOutline( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode )
|
|
|
|
{
|
2008-09-26 19:51:36 +00:00
|
|
|
int current_gr_mode = draw_mode;
|
|
|
|
bool is_close_segment = false;
|
2008-03-04 04:22:27 +00:00
|
|
|
wxPoint seg_start, seg_end;
|
2008-01-31 20:53:44 +00:00
|
|
|
|
|
|
|
if( DC == NULL )
|
|
|
|
return;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-01-20 18:40:33 +00:00
|
|
|
int curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
|
|
|
|
BOARD* brd = GetBoard();
|
|
|
|
int color = brd->GetLayerColor( m_Layer ) & MASKCOLOR;
|
2008-01-31 20:53:44 +00:00
|
|
|
|
|
|
|
if( DisplayOpt.ContrastModeDisplay )
|
|
|
|
{
|
|
|
|
if( !IsOnLayer( curr_layer ) )
|
|
|
|
{
|
|
|
|
color &= ~MASKCOLOR;
|
|
|
|
color |= DARKDARKGRAY;
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
|
|
|
if( m_Poly->corner[ic].end_contour == false && 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
|
|
|
|
2008-10-17 06:17:48 +00:00
|
|
|
if( (m_Poly->corner[ic + 1].end_contour) || (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();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
bool ZONE_CONTAINER::HitTest( const wxPoint& aPosition )
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2012-03-15 14:31:16 +00:00
|
|
|
if( HitTestForCorner( aPosition ) )
|
2007-12-29 19:15:58 +00:00
|
|
|
return true;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
if( HitTestForEdge( aPosition ) )
|
2007-12-29 19:15:58 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-14 15:08:44 +00:00
|
|
|
bool ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos )
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2011-03-01 13:59:21 +00:00
|
|
|
m_CornerSelection = -1; // Set to not found
|
|
|
|
|
2011-10-17 20:01:27 +00:00
|
|
|
// distance (in internal units) to detect a corner in a zone outline.
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
// @todo use a scaling factor here of actual screen coordinates, so that
|
|
|
|
// when nanometers come, it still works.
|
2011-10-17 20:01:27 +00:00
|
|
|
#define CORNER_MIN_DIST 100
|
|
|
|
|
2011-09-14 15:08:44 +00:00
|
|
|
int min_dist = CORNER_MIN_DIST + 1;
|
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
#if 0
|
|
|
|
// Dick: I don't see this as reasonable. The mouse distance from the zone is
|
|
|
|
// not a function of the grid, it is a fixed number of pixels, regardless of zoom.
|
2011-09-14 15:08:44 +00:00
|
|
|
if( GetBoard() && GetBoard()->m_PcbFrame )
|
|
|
|
{
|
|
|
|
// Use grid size because it is known
|
2011-12-22 13:28:11 +00:00
|
|
|
wxRealPoint grid = GetBoard()->m_PcbFrame->GetCanvas()->GetGrid();
|
2011-09-14 15:08:44 +00:00
|
|
|
min_dist = wxRound( MIN( grid.x, grid.y ) );
|
|
|
|
}
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
#endif
|
2011-09-14 15:08:44 +00:00
|
|
|
|
|
|
|
wxPoint delta;
|
2011-03-01 13:59:21 +00:00
|
|
|
unsigned lim = m_Poly->corner.size();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-03-01 13:59:21 +00:00
|
|
|
for( unsigned item_pos = 0; item_pos < lim; item_pos++ )
|
2008-01-31 20:53:44 +00:00
|
|
|
{
|
2011-09-14 15:08:44 +00:00
|
|
|
delta.x = refPos.x - m_Poly->corner[item_pos].x;
|
|
|
|
delta.y = refPos.y - m_Poly->corner[item_pos].y;
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
|
2011-03-01 13:59:21 +00:00
|
|
|
// Calculate a distance:
|
2011-09-14 15:08:44 +00:00
|
|
|
int dist = MAX( abs( delta.x ), abs( delta.y ) );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-09-14 15:08:44 +00:00
|
|
|
if( dist < min_dist ) // this corner is a candidate:
|
2008-01-31 20:53:44 +00:00
|
|
|
{
|
|
|
|
m_CornerSelection = item_pos;
|
2011-09-14 15:08:44 +00:00
|
|
|
min_dist = dist;
|
2008-01-31 20:53:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-01 13:59:21 +00:00
|
|
|
return m_CornerSelection >= 0;
|
2007-12-29 19:15:58 +00:00
|
|
|
}
|
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2011-09-14 15:08:44 +00:00
|
|
|
bool ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos )
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2011-03-01 13:59:21 +00:00
|
|
|
unsigned lim = m_Poly->corner.size();
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2011-03-01 13:59:21 +00:00
|
|
|
m_CornerSelection = -1; // Set to not found
|
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
// @todo use a scaling factor here of actual screen coordinates, so that
|
|
|
|
// when nanometers come, it still works. This should be done in screen coordinates
|
|
|
|
// not internal units.
|
2011-09-14 15:08:44 +00:00
|
|
|
#define EDGE_MIN_DIST 200 // distance (in internal units) to detect a zone outline
|
|
|
|
int min_dist = EDGE_MIN_DIST+1;
|
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
// Dick: I don't see this as reasonable. The mouse distance from the zone is
|
|
|
|
// not a function of the grid, it is a fixed number of pixels, regardless of zoom.
|
2011-09-14 15:08:44 +00:00
|
|
|
if( GetBoard() && GetBoard()->m_PcbFrame )
|
|
|
|
{
|
|
|
|
// Use grid size because it is known
|
2011-12-22 13:28:11 +00:00
|
|
|
wxRealPoint grid = GetBoard()->m_PcbFrame->GetCanvas()->GetGrid();
|
2011-09-14 15:08:44 +00:00
|
|
|
min_dist = wxRound( MIN( grid.x, grid.y ) );
|
|
|
|
}
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
#endif
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2011-03-01 13:59:21 +00:00
|
|
|
unsigned first_corner_pos = 0;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-03-01 13:59:21 +00:00
|
|
|
for( unsigned item_pos = 0; item_pos < lim; item_pos++ )
|
2008-01-31 20:53:44 +00:00
|
|
|
{
|
2011-03-01 13:59:21 +00:00
|
|
|
unsigned end_segm = item_pos + 1;
|
2008-01-31 20:53:44 +00:00
|
|
|
|
|
|
|
/* the last corner of the current outline is tested
|
|
|
|
* the last segment of the current outline starts at current corner, and ends
|
|
|
|
* at the first corner of the outline
|
|
|
|
*/
|
|
|
|
if( m_Poly->corner[item_pos].end_contour || end_segm >= lim )
|
|
|
|
{
|
|
|
|
unsigned tmp = first_corner_pos;
|
|
|
|
first_corner_pos = end_segm; // first_corner_pos is now the beginning of the next outline
|
|
|
|
end_segm = tmp; // end_segm is the beginning of the current outline
|
|
|
|
}
|
|
|
|
|
|
|
|
/* test the dist between segment and ref point */
|
2011-09-14 15:08:44 +00:00
|
|
|
int dist = (int) GetPointToLineSegmentDistance( refPos.x,
|
|
|
|
refPos.y,
|
2011-09-07 19:41:04 +00:00
|
|
|
m_Poly->corner[item_pos].x,
|
|
|
|
m_Poly->corner[item_pos].y,
|
|
|
|
m_Poly->corner[end_segm].x,
|
|
|
|
m_Poly->corner[end_segm].y );
|
|
|
|
|
2011-09-14 15:08:44 +00:00
|
|
|
if( dist < min_dist )
|
2008-01-31 20:53:44 +00:00
|
|
|
{
|
|
|
|
m_CornerSelection = item_pos;
|
2011-09-14 15:08:44 +00:00
|
|
|
min_dist = dist;
|
2008-01-31 20:53:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-01 13:59:21 +00:00
|
|
|
return m_CornerSelection >= 0;
|
2007-12-29 19:15:58 +00:00
|
|
|
}
|
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
bool ZONE_CONTAINER::HitTest( const EDA_RECT& aRect ) const
|
2008-01-06 12:43:57 +00:00
|
|
|
{
|
2008-01-31 20:53:44 +00:00
|
|
|
bool is_out_of_box = false;
|
2008-01-06 12:43:57 +00:00
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
CRect rect = m_Poly->GetCornerBounds();
|
2008-01-06 12:43:57 +00:00
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
if( rect.left < aRect.GetX() )
|
2008-01-06 12:43:57 +00:00
|
|
|
is_out_of_box = true;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
if( rect.top < aRect.GetY() )
|
2008-01-06 12:43:57 +00:00
|
|
|
is_out_of_box = true;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
if( rect.right > aRect.GetRight() )
|
2008-01-06 12:43:57 +00:00
|
|
|
is_out_of_box = true;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-03-15 14:31:16 +00:00
|
|
|
if( rect.bottom > aRect.GetBottom() )
|
2008-01-06 12:43:57 +00:00
|
|
|
is_out_of_box = true;
|
|
|
|
|
|
|
|
return is_out_of_box ? false : true;
|
|
|
|
}
|
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
|
|
|
|
2011-08-09 14:13:01 +00:00
|
|
|
NETCLASS* myClass = GetNetClass();
|
|
|
|
|
|
|
|
if( myClass )
|
|
|
|
myClearance = std::max( myClearance, myClass->GetClearance() );
|
2011-08-09 03:41:20 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if( aItem )
|
|
|
|
{
|
|
|
|
int hisClearance = aItem->GetClearance( NULL );
|
|
|
|
myClearance = max( hisClearance, myClearance );
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
unsigned indexstart = 0, indexend;
|
2011-01-20 18:40:33 +00:00
|
|
|
bool inside = false;
|
|
|
|
|
2008-11-27 10:12:46 +00:00
|
|
|
for( indexend = 0; indexend < m_FilledPolysList.size(); indexend++ )
|
|
|
|
{
|
|
|
|
if( m_FilledPolysList[indexend].end_contour ) // end of a filled sub-area found
|
|
|
|
{
|
2011-01-20 18:40:33 +00:00
|
|
|
if( TestPointInsidePolygon( m_FilledPolysList, indexstart, indexend, aRefPos.x,
|
|
|
|
aRefPos.y ) )
|
2008-11-27 10:12:46 +00:00
|
|
|
{
|
|
|
|
inside = true;
|
|
|
|
break;
|
|
|
|
}
|
2011-01-20 18:40:33 +00:00
|
|
|
|
2011-07-14 15:42:44 +00:00
|
|
|
// Prepare test of next area which starts after the current index end (if exists)
|
2011-01-20 18:40:33 +00:00
|
|
|
indexstart = indexend + 1;
|
2008-11-27 10:12:46 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-20 18:40:33 +00:00
|
|
|
|
2008-11-27 10:12:46 +00:00
|
|
|
return inside;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
void ZONE_CONTAINER::DisplayInfo( EDA_DRAW_FRAME* frame )
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
BOARD* board = (BOARD*) m_Parent;
|
|
|
|
|
|
|
|
wxASSERT( board );
|
|
|
|
|
2009-10-16 17:18:23 +00:00
|
|
|
frame->ClearMsgPanel();
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
msg = _( "Zone Outline" );
|
2007-12-29 19:15:58 +00:00
|
|
|
|
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
|
|
|
|
2009-10-16 17:18:23 +00:00
|
|
|
frame->AppendMsgPanel( _( "Type" ), msg, DARKCYAN );
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
if( IsOnCopperLayer() )
|
2008-01-31 20:53:44 +00:00
|
|
|
{
|
2008-09-26 19:51:36 +00:00
|
|
|
if( GetNet() >= 0 )
|
|
|
|
{
|
2011-03-01 19:26:17 +00:00
|
|
|
NETINFO_ITEM* equipot = ( (PCB_BASE_FRAME*) frame )->GetBoard()->FindNet( GetNet() );
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
if( equipot )
|
2008-12-14 19:45:05 +00:00
|
|
|
msg = equipot->GetNetname();
|
2008-09-26 19:51:36 +00:00
|
|
|
else
|
|
|
|
msg = wxT( "<noname>" );
|
|
|
|
}
|
|
|
|
else // a netcode < 0 is an error
|
|
|
|
{
|
|
|
|
msg = wxT( " [" );
|
|
|
|
msg << m_Netname + wxT( "]" );
|
|
|
|
msg << wxT( " <" ) << _( "Not Found" ) << wxT( ">" );
|
|
|
|
}
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2009-10-16 17:18:23 +00:00
|
|
|
frame->AppendMsgPanel( _( "NetName" ), msg, RED );
|
2012-01-29 19:29:19 +00:00
|
|
|
#if 1
|
|
|
|
// Display net code : (useful in test or debug)
|
|
|
|
msg.Printf( wxT( "%d" ), GetNet() );
|
|
|
|
frame->AppendMsgPanel( _( "NetCode" ), msg, RED );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Display priority level
|
|
|
|
msg.Printf( wxT( "%d" ), GetPriority() );
|
|
|
|
frame->AppendMsgPanel( _( "Priority" ), msg, BLUE );
|
2008-09-26 19:51:36 +00:00
|
|
|
}
|
|
|
|
else
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2009-10-16 17:18:23 +00:00
|
|
|
frame->AppendMsgPanel( _( "Non Copper Zone" ), wxEmptyString, RED );
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
msg = board->GetLayerName( m_Layer );
|
2009-10-16 17:18:23 +00:00
|
|
|
frame->AppendMsgPanel( _( "Layer" ), msg, BROWN );
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2012-02-10 22:26:42 +00:00
|
|
|
msg.Printf( wxT( "%d" ), (int) m_Poly->corner.size() );
|
2009-10-16 17:18:23 +00:00
|
|
|
frame->AppendMsgPanel( _( "Corners" ), msg, BLUE );
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2008-12-03 10:32:53 +00:00
|
|
|
if( m_FillMode )
|
|
|
|
msg.Printf( _( "Segments" ), m_FillMode );
|
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
|
|
|
|
2009-10-16 17:18:23 +00:00
|
|
|
frame->AppendMsgPanel( _( "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() );
|
2009-10-16 17:18:23 +00:00
|
|
|
frame->AppendMsgPanel( _( "Hatch lines" ), msg, BLUE );
|
2008-10-08 12:36:27 +00:00
|
|
|
|
|
|
|
if( m_FilledPolysList.size() )
|
|
|
|
{
|
2012-02-10 22:26:42 +00:00
|
|
|
msg.Printf( wxT( "%d" ), (int) m_FilledPolysList.size() );
|
2009-10-16 17:18:23 +00:00
|
|
|
frame->AppendMsgPanel( _( "Corners in DrawList" ), 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 */
|
2008-01-31 20:53:44 +00:00
|
|
|
for( unsigned ii = 0; ii < m_Poly->corner.size(); ii++ )
|
|
|
|
{
|
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
|
|
|
|
|
|
|
/* move filled areas: */
|
|
|
|
for( unsigned ic = 0; ic < m_FilledPolysList.size(); ic++ )
|
|
|
|
{
|
|
|
|
CPolyPt* corner = &m_FilledPolysList[ic];
|
|
|
|
corner->x += offset.x;
|
|
|
|
corner->y += 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
|
|
|
|
2008-02-01 21:30:45 +00:00
|
|
|
void ZONE_CONTAINER::MoveEdge( const wxPoint& offset )
|
|
|
|
{
|
2008-03-04 04:22:27 +00:00
|
|
|
int ii = m_CornerSelection;
|
2008-02-01 21:30:45 +00:00
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
// Move the start point of the selected edge:
|
2008-09-26 19:51:36 +00:00
|
|
|
SetCornerPosition( ii, GetCornerPosition( ii ) + 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:
|
2008-09-26 19:51:36 +00:00
|
|
|
if( m_Poly->corner[ii].end_contour || ii == GetNumCorners() - 1 )
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
|
|
|
int icont = m_Poly->GetContour( ii );
|
|
|
|
ii = m_Poly->GetContourStart( icont );
|
|
|
|
}
|
|
|
|
else
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2008-03-04 04:22:27 +00:00
|
|
|
ii++;
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
SetCornerPosition( ii, GetCornerPosition( ii ) + 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
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
for( unsigned ii = 0; ii < m_Poly->corner.size(); ii++ )
|
|
|
|
{
|
|
|
|
pos.x = m_Poly->corner[ii].x;
|
|
|
|
pos.y = m_Poly->corner[ii].y;
|
|
|
|
RotatePoint( &pos, centre, angle );
|
|
|
|
m_Poly->corner[ii].x = pos.x;
|
|
|
|
m_Poly->corner[ii].y = pos.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_Poly->Hatch();
|
2009-08-01 19:58:01 +00:00
|
|
|
|
|
|
|
/* rotate filled areas: */
|
|
|
|
for( unsigned ic = 0; ic < m_FilledPolysList.size(); ic++ )
|
|
|
|
{
|
|
|
|
CPolyPt* corner = &m_FilledPolysList[ic];
|
|
|
|
pos.x = corner->x;
|
|
|
|
pos.y = corner->y;
|
|
|
|
RotatePoint( &pos, centre, angle );
|
|
|
|
corner->x = pos.x;
|
|
|
|
corner->y = pos.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++ )
|
|
|
|
{
|
|
|
|
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 );
|
|
|
|
SetLayer( ChangeSideNumLayer( GetLayer() ) );
|
|
|
|
}
|
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
|
|
|
{
|
2008-01-31 20:53:44 +00:00
|
|
|
for( unsigned ii = 0; ii < m_Poly->corner.size(); ii++ )
|
|
|
|
{
|
|
|
|
m_Poly->corner[ii].y -= mirror_ref.y;
|
2011-01-20 18:40:33 +00:00
|
|
|
NEGATE( m_Poly->corner[ii].y );
|
2008-01-31 20:53:44 +00:00
|
|
|
m_Poly->corner[ii].y += mirror_ref.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_Poly->Hatch();
|
2009-08-01 19:58:01 +00:00
|
|
|
|
|
|
|
/* mirror filled areas: */
|
|
|
|
for( unsigned ic = 0; ic < m_FilledPolysList.size(); ic++ )
|
|
|
|
{
|
|
|
|
CPolyPt* corner = &m_FilledPolysList[ic];
|
|
|
|
corner->y -= mirror_ref.y;
|
2011-01-20 18:40:33 +00:00
|
|
|
NEGATE( corner->y );
|
2009-08-01 19:58:01 +00:00
|
|
|
corner->y += mirror_ref.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.y -= mirror_ref.y;
|
2011-01-20 18:40:33 +00:00
|
|
|
NEGATE( m_FillSegmList[ic].m_Start.y );
|
2009-08-06 18:30:46 +00:00
|
|
|
m_FillSegmList[ic].m_Start.y += mirror_ref.y;
|
2011-01-20 18:40:33 +00:00
|
|
|
m_FillSegmList[ic].m_End.y -= mirror_ref.y;
|
|
|
|
NEGATE( m_FillSegmList[ic].m_End.y );
|
2009-08-06 18:30:46 +00:00
|
|
|
m_FillSegmList[ic].m_End.y += mirror_ref.y;
|
|
|
|
}
|
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;
|
|
|
|
SetNet( src->GetNet() );
|
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
|
2011-01-20 18:40:33 +00:00
|
|
|
m_CornerSelection = -1; // For corner moving, corner index to drag, or -1 if no selection
|
|
|
|
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;
|
2009-09-17 17:48:40 +00:00
|
|
|
m_Poly->m_HatchStyle = src->m_Poly->GetHatchStyle();
|
|
|
|
m_Poly->m_HatchLines = src->m_Poly->m_HatchLines; // Copy vector <CSegment>
|
2009-08-23 15:22:44 +00:00
|
|
|
m_FilledPolysList.clear();
|
2009-08-06 18:30:46 +00:00
|
|
|
m_FilledPolysList = 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
|
|
|
|
2008-10-23 10:26:06 +00:00
|
|
|
bool ZONE_CONTAINER::SetNetNameFromNetCode( void )
|
|
|
|
{
|
2009-05-24 18:28:36 +00:00
|
|
|
NETINFO_ITEM* net;
|
2011-01-20 18:40:33 +00:00
|
|
|
|
|
|
|
if( m_Parent && ( net = ( (BOARD*) m_Parent )->FindNet( GetNet() ) ) )
|
2008-10-23 10:26:06 +00:00
|
|
|
{
|
2008-12-14 19:45:05 +00:00
|
|
|
m_Netname = net->GetNetname();
|
2008-10-23 10:26:06 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2011-07-14 15:42:44 +00:00
|
|
|
|
|
|
|
|
2012-02-24 23:23:46 +00:00
|
|
|
ZoneConnection ZONE_CONTAINER::GetPadConnection( D_PAD* aPad ) const
|
|
|
|
{
|
|
|
|
if( aPad == NULL || aPad->GetZoneConnection() == UNDEFINED_CONNECTION )
|
|
|
|
return m_PadConnection;
|
|
|
|
else
|
|
|
|
return aPad->GetZoneConnection();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-14 15:42:44 +00:00
|
|
|
wxString ZONE_CONTAINER::GetSelectMenuText() const
|
|
|
|
{
|
|
|
|
wxString text;
|
|
|
|
NETINFO_ITEM* net;
|
|
|
|
BOARD* board = GetBoard();
|
|
|
|
|
|
|
|
text = _( "Zone Outline" );
|
|
|
|
|
|
|
|
int ncont = m_Poly->GetContour( m_CornerSelection );
|
|
|
|
|
|
|
|
if( ncont )
|
|
|
|
text << wxT( " " ) << _( "(Cutout)" );
|
|
|
|
|
|
|
|
text << wxT( " " );
|
2012-02-10 22:26:42 +00:00
|
|
|
text << wxString::Format( wxT( "(%08lX)" ), m_TimeStamp );
|
2011-07-14 15:42:44 +00:00
|
|
|
|
|
|
|
if ( !IsOnCopperLayer() )
|
|
|
|
{
|
|
|
|
text << wxT( " [" ) << _( "Not on copper layer" ) << wxT( "]" );
|
|
|
|
}
|
|
|
|
else if( GetNet() >= 0 )
|
|
|
|
{
|
|
|
|
if( board )
|
|
|
|
{
|
|
|
|
net = board->FindNet( GetNet() );
|
|
|
|
|
|
|
|
if( net )
|
|
|
|
{
|
|
|
|
text << wxT( " [" ) << net->GetNetname() << wxT( "]" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
text << _( "** NO BOARD DEFINED **" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // A netcode < 0 is an error flag (Netname not found or area not initialised)
|
|
|
|
{
|
|
|
|
text << wxT( " [" ) << m_Netname << wxT( "]" );
|
|
|
|
text << wxT( " <" ) << _( "Not Found" ) << wxT( ">" );
|
|
|
|
}
|
|
|
|
|
|
|
|
text << _( " on " ) << GetLayerName();
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
2012-04-01 20:51:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
void ZONE_CONTAINER::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
|
|
|
|
throw( IO_ERROR )
|
|
|
|
{
|
|
|
|
aFormatter->Print( aNestLevel, "(zone (net %d %s) (layer %d) (tstamp %lX)\n",
|
2012-04-07 18:05:56 +00:00
|
|
|
GetNet(), aFormatter->Quotew( m_Netname ).c_str(),
|
|
|
|
GetLayer(), GetTimeStamp() );
|
2012-04-01 20:51:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Save the outline aux info
|
|
|
|
std::string hatch;
|
|
|
|
|
|
|
|
switch( GetHatchStyle() )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case CPolyLine::NO_HATCH: hatch = "none"; break;
|
|
|
|
case CPolyLine::DIAGONAL_EDGE: hatch = "edge"; break;
|
|
|
|
case CPolyLine::DIAGONAL_FULL: hatch = "full"; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
aFormatter->Print( aNestLevel+1, "(hatch %s)\n", hatch.c_str() );
|
|
|
|
|
|
|
|
if( m_priority > 0 )
|
|
|
|
aFormatter->Print( aNestLevel+1, "(priority %d)\n", m_priority );
|
|
|
|
|
|
|
|
// Save pad option and clearance
|
|
|
|
std::string padoption;
|
|
|
|
|
|
|
|
switch( GetPadConnection() )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case PAD_IN_ZONE: padoption = "yes"; break;
|
2012-04-07 18:05:56 +00:00
|
|
|
case THERMAL_PAD: padoption = "use_thermal"; break;
|
2012-04-01 20:51:56 +00:00
|
|
|
case PAD_NOT_IN_ZONE: padoption = "no"; break;
|
|
|
|
}
|
|
|
|
|
2012-04-07 18:05:56 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(connect_pads %s (clearance %s))\n",
|
2012-04-01 20:51:56 +00:00
|
|
|
padoption.c_str(), FormatBIU( m_ZoneClearance ).c_str() );
|
|
|
|
|
2012-04-07 18:05:56 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(min_thickness %s)\n",
|
2012-04-01 20:51:56 +00:00
|
|
|
FormatBIU( m_ZoneMinThickness ).c_str() );
|
|
|
|
|
|
|
|
aFormatter->Print( aNestLevel+1,
|
2012-04-07 18:05:56 +00:00
|
|
|
"(fill %s (mode %s) (arc_segments %d) (thermal_gap %s) (thermal_bridge_width %s)\n",
|
2012-04-01 20:51:56 +00:00
|
|
|
(m_IsFilled) ? "yes" : "no",
|
|
|
|
(m_FillMode) ? "segment" : "polygon",
|
|
|
|
m_ArcToSegmentsCount,
|
|
|
|
FormatBIU( m_ThermalReliefGap ).c_str(),
|
|
|
|
FormatBIU( m_ThermalReliefCopperBridge ).c_str() );
|
|
|
|
|
|
|
|
std::string smoothing;
|
|
|
|
|
|
|
|
switch( cornerSmoothingType )
|
|
|
|
{
|
|
|
|
case ZONE_SETTINGS::SMOOTHING_NONE: smoothing = "none"; break;
|
|
|
|
case ZONE_SETTINGS::SMOOTHING_CHAMFER: smoothing = "chamfer"; break;
|
|
|
|
case ZONE_SETTINGS::SMOOTHING_FILLET: smoothing = "fillet"; break;
|
|
|
|
default:
|
|
|
|
THROW_IO_ERROR( wxString::Format( _( "unknown zone corner smoothing type %d" ),
|
|
|
|
cornerSmoothingType ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
aFormatter->Print( aNestLevel+1, "(smoothing %s (radius %s))\n",
|
|
|
|
smoothing.c_str(), FormatBIU( cornerRadius ).c_str() );
|
|
|
|
|
|
|
|
const std::vector< CPolyPt >& cv = m_Poly->corner;
|
|
|
|
|
|
|
|
if( cv.size() )
|
|
|
|
{
|
2012-04-07 18:05:56 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(polygon\n");
|
|
|
|
aFormatter->Print( aNestLevel+2, "(pts\n" );
|
2012-04-01 20:51:56 +00:00
|
|
|
|
|
|
|
for( std::vector< CPolyPt >::const_iterator it = cv.begin(); it != cv.end(); ++it )
|
|
|
|
{
|
2012-04-07 18:05:56 +00:00
|
|
|
aFormatter->Print( aNestLevel+3, "(xy %s %s)\n",
|
2012-04-01 20:51:56 +00:00
|
|
|
FormatBIU( it->x ).c_str(), FormatBIU( it->y ).c_str() );
|
|
|
|
|
|
|
|
if( it->end_contour )
|
2012-04-07 18:05:56 +00:00
|
|
|
{
|
|
|
|
aFormatter->Print( aNestLevel+2, ")\n" );
|
|
|
|
|
|
|
|
if( it+1 != cv.end() )
|
|
|
|
{
|
|
|
|
aFormatter->Print( aNestLevel+1, ")\n" );
|
|
|
|
aFormatter->Print( aNestLevel+1, "(polygon\n" );
|
|
|
|
aFormatter->Print( aNestLevel+2, "(pts\n" );
|
|
|
|
}
|
|
|
|
}
|
2012-04-01 20:51:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
aFormatter->Print( aNestLevel+1, ")\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Save the PolysList
|
|
|
|
const std::vector< CPolyPt >& fv = m_FilledPolysList;
|
|
|
|
|
|
|
|
if( fv.size() )
|
|
|
|
{
|
2012-04-07 18:05:56 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(filled_polygon\n" );
|
|
|
|
aFormatter->Print( aNestLevel+2, "(pts\n" );
|
2012-04-01 20:51:56 +00:00
|
|
|
|
|
|
|
for( std::vector< CPolyPt >::const_iterator it = fv.begin(); it != fv.end(); ++it )
|
|
|
|
{
|
2012-04-07 18:05:56 +00:00
|
|
|
aFormatter->Print( aNestLevel+3, "(xy %s %s)\n",
|
2012-04-01 20:51:56 +00:00
|
|
|
FormatBIU( it->x ).c_str(), FormatBIU( it->y ).c_str() );
|
|
|
|
|
|
|
|
if( it->end_contour )
|
2012-04-07 18:05:56 +00:00
|
|
|
{
|
|
|
|
aFormatter->Print( aNestLevel+2, ")\n" );
|
|
|
|
|
|
|
|
if( it+1 != fv.end() )
|
|
|
|
{
|
|
|
|
aFormatter->Print( aNestLevel+1, ")\n" );
|
|
|
|
aFormatter->Print( aNestLevel+1, "(filled_polygon\n" );
|
|
|
|
aFormatter->Print( aNestLevel+2, "(pts\n" );
|
|
|
|
}
|
|
|
|
}
|
2012-04-01 20:51:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
aFormatter->Print( aNestLevel+1, ")\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Save the filling segments list
|
|
|
|
const std::vector< SEGMENT >& segs = m_FillSegmList;
|
|
|
|
|
|
|
|
if( segs.size() )
|
|
|
|
{
|
2012-04-07 18:05:56 +00:00
|
|
|
aFormatter->Print( aNestLevel+1, "(fill_segments\n" );
|
2012-04-01 20:51:56 +00:00
|
|
|
|
|
|
|
for( std::vector< SEGMENT >::const_iterator it = segs.begin(); it != segs.end(); ++it )
|
|
|
|
{
|
|
|
|
aFormatter->Print( aNestLevel+2, "(pts (xy %s) (xy %s))\n",
|
|
|
|
FormatBIU( it->m_Start ).c_str(),
|
|
|
|
FormatBIU( it->m_End ).c_str() );
|
|
|
|
}
|
|
|
|
|
|
|
|
aFormatter->Print( aNestLevel+1, ")\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
aFormatter->Print( aNestLevel, ")\n" );
|
|
|
|
}
|