2007-12-09 12:59:06 +00:00
|
|
|
/**********************************/
|
|
|
|
/* classes to handle copper zones */
|
|
|
|
/**********************************/
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "wxstruct.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "trigo.h"
|
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "kicad_string.h"
|
|
|
|
|
2008-01-04 12:27:16 +00:00
|
|
|
#include "PolyLine.h"
|
2007-12-09 12:59:06 +00:00
|
|
|
#include "pcbnew.h"
|
2008-10-19 18:18:45 +00:00
|
|
|
#include "zones.h"
|
2009-10-28 11:48:47 +00:00
|
|
|
#include "class_board_design_settings.h"
|
2010-01-29 20:36:12 +00:00
|
|
|
#include "colors_selection.h"
|
2007-12-09 12:59:06 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
#include "protos.h"
|
2011-01-14 17:43:30 +00:00
|
|
|
#include "richio.h"
|
2011-02-21 19:43:59 +00:00
|
|
|
#include "class_zone_setting.h"
|
2009-08-01 19:26:05 +00:00
|
|
|
|
2007-12-09 12:59:06 +00:00
|
|
|
/************************/
|
|
|
|
/* class ZONE_CONTAINER */
|
|
|
|
/************************/
|
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
ZONE_CONTAINER::ZONE_CONTAINER( BOARD* parent ) :
|
2009-10-21 19:16:25 +00:00
|
|
|
BOARD_CONNECTED_ITEM( parent, TYPE_ZONE_CONTAINER )
|
2007-12-09 12:59:06 +00:00
|
|
|
{
|
2011-01-20 18:40:33 +00:00
|
|
|
m_NetCode = -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
|
2011-02-21 19:43:59 +00:00
|
|
|
smoothedPoly = NULL;
|
|
|
|
cornerSmoothingType = ZONE_SETTING::SMOOTHING_NONE;
|
|
|
|
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
|
|
|
|
g_Zone_Default_Setting.ExportSetting( *this );
|
2007-12-09 12:59:06 +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
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function GetPosition (virtual)
|
|
|
|
* @return a wxPoint, position of the first point of the outline
|
|
|
|
*/
|
2008-10-29 15:26:53 +00:00
|
|
|
wxPoint& ZONE_CONTAINER::GetPosition()
|
|
|
|
{
|
|
|
|
static wxPoint pos;
|
2011-01-20 18:40:33 +00:00
|
|
|
|
|
|
|
if( m_Poly )
|
2008-10-29 15:26:53 +00:00
|
|
|
{
|
2011-01-20 18:40:33 +00:00
|
|
|
pos = GetCornerPosition( 0 );
|
2008-10-29 15:26:53 +00:00
|
|
|
}
|
2011-01-20 18:40:33 +00:00
|
|
|
else
|
|
|
|
pos = wxPoint( 0, 0 );
|
2008-10-29 15:26:53 +00:00
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
2011-01-20 18:40:33 +00:00
|
|
|
|
2008-01-04 12:27:16 +00:00
|
|
|
/*******************************************/
|
|
|
|
void ZONE_CONTAINER::SetNet( int anet_code )
|
2011-01-20 18:40:33 +00:00
|
|
|
{
|
2008-01-04 12:27:16 +00:00
|
|
|
/*******************************************/
|
2008-01-06 20:58:27 +00:00
|
|
|
/**
|
2008-01-31 20:53:44 +00:00
|
|
|
* Set the netcode and the netname
|
2008-01-06 20:58:27 +00:00
|
|
|
* if netcode >= 0, set the netname
|
|
|
|
* if netcode < 0: keep old netname (used to set an necode error flag)
|
|
|
|
*/
|
2008-01-31 20:53:44 +00:00
|
|
|
m_NetCode = anet_code;
|
2007-12-09 12:59:06 +00:00
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
if( anet_code < 0 )
|
|
|
|
return;
|
|
|
|
|
2009-10-21 19:16:25 +00:00
|
|
|
BOARD* board = GetBoard();
|
|
|
|
if( board )
|
2008-01-31 20:53:44 +00:00
|
|
|
{
|
2009-05-24 18:28:36 +00:00
|
|
|
NETINFO_ITEM* net = board->FindNet( anet_code );
|
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
|
|
|
|
m_Netname.Empty();
|
|
|
|
}
|
2007-12-09 12:59:06 +00:00
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
|
|
|
|
/********************************************/
|
|
|
|
bool ZONE_CONTAINER::Save( FILE* aFile ) const
|
|
|
|
/********************************************/
|
2007-12-09 12:59:06 +00:00
|
|
|
{
|
2008-01-31 20:53:44 +00:00
|
|
|
unsigned item_pos;
|
|
|
|
int ret;
|
|
|
|
unsigned corners_count = m_Poly->corner.size();
|
|
|
|
int outline_hatch;
|
2008-04-02 16:58:56 +00:00
|
|
|
char padoption;
|
2008-01-31 20:53:44 +00:00
|
|
|
|
|
|
|
fprintf( aFile, "$CZONE_OUTLINE\n" );
|
|
|
|
|
|
|
|
// Save the outline main info
|
|
|
|
ret = fprintf( aFile, "ZInfo %8.8lX %d \"%s\"\n",
|
2011-01-20 18:40:33 +00:00
|
|
|
m_TimeStamp, m_NetCode,
|
2011-02-28 18:36:19 +00:00
|
|
|
TO_UTF8( m_Netname ) );
|
2008-01-31 20:53:44 +00:00
|
|
|
if( ret < 3 )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Save the ouline layer info
|
|
|
|
ret = fprintf( aFile, "ZLayer %d\n", m_Layer );
|
|
|
|
if( ret < 1 )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Save the ouline aux info
|
|
|
|
switch( m_Poly->GetHatchStyle() )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case CPolyLine::NO_HATCH:
|
|
|
|
outline_hatch = 'N';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CPolyLine::DIAGONAL_EDGE:
|
|
|
|
outline_hatch = 'E';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CPolyLine::DIAGONAL_FULL:
|
|
|
|
outline_hatch = 'F';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = fprintf( aFile, "ZAux %d %c\n", corners_count, outline_hatch );
|
|
|
|
if( ret < 2 )
|
|
|
|
return false;
|
|
|
|
|
2008-04-02 16:58:56 +00:00
|
|
|
// Save pad option and clearance
|
|
|
|
switch( m_PadOption )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case PAD_IN_ZONE:
|
|
|
|
padoption = 'I';
|
|
|
|
break;
|
2008-09-26 19:51:36 +00:00
|
|
|
|
2008-04-02 16:58:56 +00:00
|
|
|
case THERMAL_PAD:
|
|
|
|
padoption = 'T';
|
|
|
|
break;
|
2008-09-26 19:51:36 +00:00
|
|
|
|
2008-04-02 16:58:56 +00:00
|
|
|
case PAD_NOT_IN_ZONE:
|
|
|
|
padoption = 'X';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = fprintf( aFile, "ZClearance %d %c\n", m_ZoneClearance, padoption );
|
|
|
|
if( ret < 2 )
|
|
|
|
return false;
|
|
|
|
|
2008-11-22 20:50:30 +00:00
|
|
|
ret = fprintf( aFile, "ZMinThickness %d\n", m_ZoneMinThickness );
|
|
|
|
if( ret < 1 )
|
|
|
|
return false;
|
|
|
|
|
2011-01-20 18:40:33 +00:00
|
|
|
ret = fprintf( aFile,
|
|
|
|
"ZOptions %d %d %c %d %d\n",
|
|
|
|
m_FillMode,
|
|
|
|
m_ArcToSegmentsCount,
|
|
|
|
m_IsFilled ? 'S' : 'F',
|
|
|
|
m_ThermalReliefGapValue,
|
|
|
|
m_ThermalReliefCopperBridgeValue );
|
2008-10-15 17:14:51 +00:00
|
|
|
if( ret < 3 )
|
2008-10-07 09:32:56 +00:00
|
|
|
return false;
|
|
|
|
|
2011-02-21 19:43:59 +00:00
|
|
|
ret = fprintf( aFile,
|
|
|
|
"ZSmoothing %d %d\n",
|
|
|
|
cornerSmoothingType, cornerRadius );
|
|
|
|
if( ret < 2 )
|
|
|
|
return false;
|
2008-10-07 09:32:56 +00:00
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
// Save the corner list
|
|
|
|
for( item_pos = 0; item_pos < corners_count; item_pos++ )
|
|
|
|
{
|
2008-05-05 19:49:25 +00:00
|
|
|
ret = fprintf( aFile, "ZCorner %d %d %d\n",
|
2011-01-20 18:40:33 +00:00
|
|
|
m_Poly->corner[item_pos].x, m_Poly->corner[item_pos].y,
|
|
|
|
m_Poly->corner[item_pos].end_contour );
|
2008-01-31 20:53:44 +00:00
|
|
|
if( ret < 3 )
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-10-08 12:36:27 +00:00
|
|
|
// Save the PolysList
|
|
|
|
if( m_FilledPolysList.size() )
|
|
|
|
{
|
|
|
|
fprintf( aFile, "$POLYSCORNERS\n" );
|
2009-08-06 18:30:46 +00:00
|
|
|
for( unsigned ii = 0; ii < m_FilledPolysList.size(); ii++ )
|
2008-10-08 12:36:27 +00:00
|
|
|
{
|
2009-08-06 18:30:46 +00:00
|
|
|
const CPolyPt* corner = &m_FilledPolysList[ii];
|
2011-01-20 18:40:33 +00:00
|
|
|
ret = fprintf( aFile,
|
|
|
|
"%d %d %d %d\n",
|
|
|
|
corner->x,
|
|
|
|
corner->y,
|
|
|
|
corner->end_contour,
|
|
|
|
corner->utility );
|
2009-08-06 18:30:46 +00:00
|
|
|
if( ret < 4 )
|
2008-10-08 12:36:27 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf( aFile, "$endPOLYSCORNERS\n" );
|
|
|
|
}
|
|
|
|
|
2009-08-06 18:30:46 +00:00
|
|
|
// Save the filling segments list
|
|
|
|
if( m_FillSegmList.size() )
|
|
|
|
{
|
|
|
|
fprintf( aFile, "$FILLSEGMENTS\n" );
|
|
|
|
for( unsigned ii = 0; ii < m_FillSegmList.size(); ii++ )
|
|
|
|
{
|
|
|
|
ret = fprintf( aFile, "%d %d %d %d\n",
|
2011-01-20 18:40:33 +00:00
|
|
|
m_FillSegmList[ii].m_Start.x, m_FillSegmList[ii].m_Start.y,
|
|
|
|
m_FillSegmList[ii].m_End.x, m_FillSegmList[ii].m_End.y );
|
2009-08-06 18:30:46 +00:00
|
|
|
if( ret < 4 )
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf( aFile, "$endFILLSEGMENTS\n" );
|
|
|
|
}
|
2008-01-31 20:53:44 +00:00
|
|
|
fprintf( aFile, "$endCZONE_OUTLINE\n" );
|
|
|
|
|
|
|
|
return true;
|
2007-12-29 19:15:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************/
|
2011-01-14 17:43:30 +00:00
|
|
|
int ZONE_CONTAINER::ReadDescr( LINE_READER* aReader )
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2011-01-20 18:40:33 +00:00
|
|
|
/**********************************************************/
|
2011-01-14 17:43:30 +00:00
|
|
|
char* Line, * text;
|
|
|
|
char netname_buffer[1024];
|
|
|
|
int ret;
|
|
|
|
int n_corner_item = 0;
|
|
|
|
int outline_hatch = CPolyLine::NO_HATCH;
|
|
|
|
bool error = false, has_corner = false;
|
2008-01-31 20:53:44 +00:00
|
|
|
|
|
|
|
netname_buffer[0] = 0;
|
2011-01-14 17:43:30 +00:00
|
|
|
while( aReader->ReadLine() )
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2011-01-14 17:43:30 +00:00
|
|
|
Line = aReader->Line();
|
2008-01-31 20:53:44 +00:00
|
|
|
if( strnicmp( Line, "ZCorner", 7 ) == 0 ) // new corner found
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2009-02-05 18:17:01 +00:00
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int flag;
|
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
text = Line + 7;
|
|
|
|
ret = sscanf( text, "%d %d %d", &x, &y, &flag );
|
|
|
|
if( ret < 3 )
|
|
|
|
error = true;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( !has_corner )
|
|
|
|
m_Poly->Start( m_Layer, x, y, outline_hatch );
|
|
|
|
else
|
2008-09-26 19:51:36 +00:00
|
|
|
AppendCorner( wxPoint( x, y ) );
|
2009-02-05 18:17:01 +00:00
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
has_corner = true;
|
|
|
|
if( flag )
|
|
|
|
m_Poly->Close();
|
|
|
|
}
|
|
|
|
}
|
2009-02-05 18:17:01 +00:00
|
|
|
else if( strnicmp( Line, "ZInfo", 5 ) == 0 ) // general info found
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2009-02-05 18:17:01 +00:00
|
|
|
int ts;
|
|
|
|
int netcode;
|
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
text = Line + 5;
|
|
|
|
ret = sscanf( text, "%X %d %s", &ts, &netcode, netname_buffer );
|
|
|
|
if( ret < 3 )
|
|
|
|
error = true;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_TimeStamp = ts;
|
|
|
|
m_NetCode = netcode;
|
|
|
|
ReadDelimitedText( netname_buffer, netname_buffer, 1024 );
|
2011-02-28 18:36:19 +00:00
|
|
|
m_Netname = FROM_UTF8( netname_buffer );
|
2008-01-31 20:53:44 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-05 18:17:01 +00:00
|
|
|
else if( strnicmp( Line, "ZLayer", 6 ) == 0 ) // layer found
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2009-02-05 18:17:01 +00:00
|
|
|
int x;
|
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
text = Line + 6;
|
|
|
|
ret = sscanf( text, "%d", &x );
|
|
|
|
if( ret < 1 )
|
|
|
|
error = true;
|
|
|
|
else
|
|
|
|
m_Layer = x;
|
|
|
|
}
|
2009-02-05 18:17:01 +00:00
|
|
|
else if( strnicmp( Line, "ZAux", 4 ) == 0 ) // aux info found
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2009-02-05 18:17:01 +00:00
|
|
|
int x;
|
2008-01-31 20:53:44 +00:00
|
|
|
char hopt[10];
|
2009-02-05 18:17:01 +00:00
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
text = Line + 4;
|
|
|
|
ret = sscanf( text, "%d %c", &x, hopt );
|
|
|
|
if( ret < 2 )
|
|
|
|
error = true;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
n_corner_item = x;
|
|
|
|
|
|
|
|
switch( hopt[0] )
|
|
|
|
{
|
|
|
|
case 'n':
|
|
|
|
case 'N':
|
|
|
|
outline_hatch = CPolyLine::NO_HATCH;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'e':
|
|
|
|
case 'E':
|
|
|
|
outline_hatch = CPolyLine::DIAGONAL_EDGE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'f':
|
|
|
|
case 'F':
|
|
|
|
outline_hatch = CPolyLine::DIAGONAL_FULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-10-15 17:14:51 +00:00
|
|
|
/* Set hatch mode later, after reading outlines corners data */
|
2008-01-31 20:53:44 +00:00
|
|
|
}
|
2011-02-21 19:43:59 +00:00
|
|
|
else if( strnicmp( Line, "ZSmoothing", 10 ) == 0 )
|
|
|
|
{
|
|
|
|
int tempSmoothingType;
|
|
|
|
int tempCornerRadius;
|
|
|
|
text = Line + 10;
|
|
|
|
ret = sscanf( text, "%d %d", &tempSmoothingType, &tempCornerRadius );
|
|
|
|
|
|
|
|
if( ret < 2 )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( tempSmoothingType >= ZONE_SETTING::SMOOTHING_LAST)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( tempSmoothingType < 0 )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
cornerSmoothingType = tempSmoothingType;
|
|
|
|
SetCornerRadius( tempCornerRadius );
|
|
|
|
}
|
2009-02-05 18:17:01 +00:00
|
|
|
else if( strnicmp( Line, "ZOptions", 8 ) == 0 ) // Options info found
|
2008-10-07 09:32:56 +00:00
|
|
|
{
|
2008-12-03 10:32:53 +00:00
|
|
|
int fillmode = 1;
|
2010-01-12 13:15:13 +00:00
|
|
|
int arcsegmentcount = ARC_APPROX_SEGMENTS_COUNT_LOW_DEF;
|
2009-08-06 18:30:46 +00:00
|
|
|
char fillstate = 'F';
|
2008-10-07 09:32:56 +00:00
|
|
|
text = Line + 8;
|
2009-08-06 18:30:46 +00:00
|
|
|
ret = sscanf( text, "%d %d %c %d %d", &fillmode, &arcsegmentcount, &fillstate,
|
2011-01-20 18:40:33 +00:00
|
|
|
&m_ThermalReliefGapValue, &m_ThermalReliefCopperBridgeValue );
|
2009-02-05 18:17:01 +00:00
|
|
|
|
2008-10-17 06:17:48 +00:00
|
|
|
if( ret < 1 ) // Must find 1 or more args.
|
2008-10-07 09:32:56 +00:00
|
|
|
return false;
|
|
|
|
else
|
2008-12-03 10:32:53 +00:00
|
|
|
m_FillMode = fillmode ? 1 : 0;
|
2008-10-15 17:14:51 +00:00
|
|
|
|
2010-01-12 13:15:13 +00:00
|
|
|
if( arcsegmentcount >= ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF )
|
|
|
|
m_ArcToSegmentsCount = ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF;
|
2008-10-15 17:14:51 +00:00
|
|
|
|
2011-01-27 14:54:21 +00:00
|
|
|
m_IsFilled = (fillstate == 'S') ? true : false;
|
2008-10-07 09:32:56 +00:00
|
|
|
}
|
2009-02-05 18:17:01 +00:00
|
|
|
else if( strnicmp( Line, "ZClearance", 10 ) == 0 ) // Clearence and pad options info found
|
2008-04-02 16:58:56 +00:00
|
|
|
{
|
|
|
|
int clearance = 200;
|
|
|
|
char padoption;
|
|
|
|
text = Line + 10;
|
|
|
|
ret = sscanf( text, "%d %1c", &clearance, &padoption );
|
|
|
|
if( ret < 2 )
|
|
|
|
error = true;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_ZoneClearance = clearance;
|
|
|
|
|
|
|
|
switch( padoption )
|
|
|
|
{
|
|
|
|
case 'i':
|
|
|
|
case 'I':
|
|
|
|
m_PadOption = PAD_IN_ZONE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 't':
|
|
|
|
case 'T':
|
|
|
|
m_PadOption = THERMAL_PAD;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'x':
|
|
|
|
case 'X':
|
|
|
|
m_PadOption = PAD_NOT_IN_ZONE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-02-05 18:17:01 +00:00
|
|
|
else if( strnicmp( Line, "ZMinThickness", 13 ) == 0 ) // Min Thickness info found
|
2008-11-22 20:50:30 +00:00
|
|
|
{
|
|
|
|
int thickness;
|
|
|
|
text = Line + 13;
|
|
|
|
ret = sscanf( text, "%d", &thickness );
|
|
|
|
if( ret < 1 )
|
|
|
|
error = true;
|
|
|
|
else
|
2011-01-20 18:40:33 +00:00
|
|
|
m_ZoneMinThickness = thickness;
|
2008-11-22 20:50:30 +00:00
|
|
|
}
|
2009-02-05 18:17:01 +00:00
|
|
|
else if( strnicmp( Line, "$POLYSCORNERS", 13 ) == 0 ) // Read the PolysList (polygons used for fill areas in the zone)
|
2008-10-08 12:36:27 +00:00
|
|
|
{
|
2011-01-14 17:43:30 +00:00
|
|
|
while( aReader->ReadLine() )
|
2008-10-08 12:36:27 +00:00
|
|
|
{
|
2011-01-14 17:43:30 +00:00
|
|
|
Line = aReader->Line();
|
2008-10-08 12:36:27 +00:00
|
|
|
if( strnicmp( Line, "$endPOLYSCORNERS", 4 ) == 0 )
|
|
|
|
break;
|
|
|
|
CPolyPt corner;
|
2008-12-03 10:32:53 +00:00
|
|
|
int end_contour, utility;
|
|
|
|
utility = 0;
|
2011-01-20 18:40:33 +00:00
|
|
|
ret = sscanf( Line,
|
|
|
|
"%d %d %d %d",
|
|
|
|
&corner.x,
|
|
|
|
&corner.y,
|
|
|
|
&end_contour,
|
|
|
|
&utility );
|
2009-08-06 18:30:46 +00:00
|
|
|
if( ret < 4 )
|
2008-10-08 12:36:27 +00:00
|
|
|
return false;
|
2008-12-03 10:32:53 +00:00
|
|
|
corner.end_contour = end_contour ? true : false;
|
2011-01-20 18:40:33 +00:00
|
|
|
corner.utility = utility;
|
2008-10-08 12:36:27 +00:00
|
|
|
m_FilledPolysList.push_back( corner );
|
|
|
|
}
|
|
|
|
}
|
2011-01-20 18:40:33 +00:00
|
|
|
else if( strnicmp( Line, "$FILLSEGMENTS", 13 ) == 0 )
|
2009-08-06 18:30:46 +00:00
|
|
|
{
|
|
|
|
SEGMENT segm;
|
2011-01-14 17:43:30 +00:00
|
|
|
while( aReader->ReadLine() )
|
2009-08-06 18:30:46 +00:00
|
|
|
{
|
2011-01-14 17:43:30 +00:00
|
|
|
Line = aReader->Line();
|
2009-08-06 18:30:46 +00:00
|
|
|
if( strnicmp( Line, "$endFILLSEGMENTS", 4 ) == 0 )
|
|
|
|
break;
|
2011-01-20 18:40:33 +00:00
|
|
|
ret = sscanf( Line,
|
|
|
|
"%d %d %d %d",
|
|
|
|
&segm.m_Start.x,
|
|
|
|
&segm.m_Start.y,
|
|
|
|
&segm.m_End.x,
|
|
|
|
&segm.m_End.y );
|
2009-08-06 18:30:46 +00:00
|
|
|
if( ret < 4 )
|
|
|
|
return false;
|
|
|
|
m_FillSegmList.push_back( segm );
|
|
|
|
}
|
|
|
|
}
|
2009-02-05 18:17:01 +00:00
|
|
|
else if( strnicmp( Line, "$end", 4 ) == 0 ) // end of description
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2008-01-31 20:53:44 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
if( !IsOnCopperLayer() )
|
2008-10-09 19:13:25 +00:00
|
|
|
{
|
2008-12-03 10:32:53 +00:00
|
|
|
m_FillMode = 0;
|
2008-09-26 19:51:36 +00:00
|
|
|
SetNet( 0 );
|
2008-10-09 19:13:25 +00:00
|
|
|
}
|
2008-09-26 19:51:36 +00:00
|
|
|
|
2008-10-12 15:58:52 +00:00
|
|
|
/* Set hatch here, when outlines corners are read */
|
2008-10-17 06:17:48 +00:00
|
|
|
m_Poly->SetHatch( outline_hatch );
|
2008-10-12 15:58:52 +00:00
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
return error ? 0 : 1;
|
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-01-20 18:40:33 +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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-14 15:56:30 +00:00
|
|
|
if( aDrawMode & GR_SURBRILL )
|
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
|
|
|
}
|
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
|
|
|
|
2008-01-31 20:53:44 +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;
|
|
|
|
}
|
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
|
|
|
|
|
|
|
GRLineArray( &panel->m_ClipBox, 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
|
|
|
|
|
|
|
GRLineArray( &panel->m_ClipBox, DC, lines, 0, color );
|
2008-01-31 20:53:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
/************************************************************************************/
|
2011-01-21 19:30:59 +00:00
|
|
|
void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel,
|
2008-09-26 19:51:36 +00:00
|
|
|
wxDC* DC, int aDrawMode, const wxPoint& offset )
|
2011-01-20 18:40:33 +00:00
|
|
|
{
|
2008-09-26 19:51:36 +00:00
|
|
|
/************************************************************************************/
|
|
|
|
/**
|
|
|
|
* Function DrawDrawFilledArea
|
2008-09-27 19:26:29 +00:00
|
|
|
* Draws the filled areas for this zone (polygon list .m_FilledPolysList)
|
2008-09-26 19:51:36 +00:00
|
|
|
* @param panel = current Draw Panel
|
|
|
|
* @param DC = current Device Context
|
|
|
|
* @param offset = Draw offset (usually wxPoint(0,0))
|
|
|
|
* @param aDrawMode = GR_OR, GR_XOR, GR_COPY ..
|
|
|
|
*/
|
2011-01-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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aDrawMode & GR_SURBRILL )
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
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;
|
|
|
|
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
|
|
|
{
|
2008-12-29 18:02:54 +00:00
|
|
|
/* Draw the current filled area: draw segments ouline first
|
|
|
|
* Curiously, draw segments ouline first and after draw filled polygons
|
|
|
|
* with oulines thickness = 0 is a faster than
|
|
|
|
* just draw filled polygons but with oulines thickness = m_ZoneMinThickness
|
|
|
|
* So DO NOT use draw filled polygons with oulines having a thickness > 0
|
|
|
|
* 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;
|
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 ) )
|
2008-12-03 10:32:53 +00:00
|
|
|
GRCSegm( &panel->m_ClipBox, 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
|
|
|
|
GRFillCSegm( &panel->m_ClipBox, 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 )
|
2008-12-29 18:02:54 +00:00
|
|
|
GRPoly( &panel->m_ClipBox, 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
|
|
|
}
|
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 ) )
|
2010-12-10 19:47:44 +00:00
|
|
|
GRCSegm( &panel->m_ClipBox, DC, start.x, start.y, end.x, end.y,
|
|
|
|
m_ZoneMinThickness, color );
|
2009-08-06 18:30:46 +00:00
|
|
|
else
|
2010-12-10 19:47:44 +00:00
|
|
|
GRFillCSegm( &panel->m_ClipBox, DC, start.x, start.y, end.x, end.y,
|
|
|
|
m_ZoneMinThickness, color );
|
2009-08-06 18:30:46 +00:00
|
|
|
}
|
|
|
|
}
|
2008-09-26 19:51:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-10 19:47:44 +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-01-20 18:40:33 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
/**********************************************************************************************/
|
2011-01-21 19:30:59 +00:00
|
|
|
void ZONE_CONTAINER::DrawWhileCreateOutline( EDA_DRAW_PANEL* panel, wxDC* DC, int draw_mode )
|
2011-01-20 18:40:33 +00:00
|
|
|
{
|
2008-01-31 20:53:44 +00:00
|
|
|
/***********************************************************************************************/
|
|
|
|
/**
|
|
|
|
* Function DrawWhileCreateOutline
|
|
|
|
* Draws the zone outline when ir is created.
|
|
|
|
* The moving edges (last segment and the closing edge segment) are in XOR graphic mode,
|
|
|
|
* old segment in OR graphic mode
|
|
|
|
* The closing edge has its owm shape
|
|
|
|
* @param panel = current Draw Panel
|
|
|
|
* @param DC = current Device Context
|
|
|
|
* @param draw_mode = draw mode: OR, XOR ..
|
|
|
|
*/
|
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-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;
|
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;
|
2008-10-17 06:17:48 +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;
|
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
|
|
|
}
|
2008-10-17 06:17:48 +00:00
|
|
|
else // Draw the line from last corner to the first corner of the current coutour
|
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
|
|
|
}
|
2008-03-04 04:22:27 +00:00
|
|
|
GRSetDrawMode( DC, current_gr_mode );
|
2008-09-26 19:51:36 +00:00
|
|
|
if( is_close_segment )
|
2008-03-04 04:22:27 +00:00
|
|
|
GRLine( &panel->m_ClipBox, DC, xi, yi, xf, yf, 0, WHITE );
|
|
|
|
else
|
|
|
|
GRLine( &panel->m_ClipBox, 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
|
|
|
|
|
|
|
/**
|
|
|
|
* Function HitTest
|
|
|
|
* tests if the given wxPoint is within the bounds of this object.
|
|
|
|
* @param refPos A wxPoint to test
|
|
|
|
* @return bool - true if a hit, else false
|
|
|
|
* return true if refPos is near a corner or an edge
|
|
|
|
*/
|
|
|
|
bool ZONE_CONTAINER::HitTest( const wxPoint& refPos )
|
|
|
|
{
|
|
|
|
if( HitTestForCorner( refPos ) >= 0 )
|
|
|
|
return true;
|
|
|
|
if( HitTestForEdge( refPos ) >= 0 )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function HitTestForCorner
|
|
|
|
* tests if the given wxPoint near a corner, or near the segment define by 2 corners.
|
2008-01-24 19:51:13 +00:00
|
|
|
* Choose the nearest corner
|
2008-01-20 19:55:22 +00:00
|
|
|
* "near" means CORNER_MIN_DIST_IN_PIXELS pixels
|
2010-12-14 15:56:30 +00:00
|
|
|
* @return -1 if none, corner index in .corner <vector>
|
2007-12-29 19:15:58 +00:00
|
|
|
* @param refPos : A wxPoint to test
|
|
|
|
*/
|
|
|
|
int ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos )
|
|
|
|
{
|
2008-01-31 20:53:44 +00:00
|
|
|
#define CORNER_MIN_DIST 500 // distance (in internal units) to detect a corner in a zone outline
|
|
|
|
int dist, min_dist;
|
|
|
|
unsigned item_pos, lim;
|
|
|
|
lim = m_Poly->corner.size();
|
|
|
|
m_CornerSelection = -1;
|
|
|
|
|
|
|
|
min_dist = CORNER_MIN_DIST;
|
|
|
|
for( item_pos = 0; item_pos < lim; item_pos++ )
|
|
|
|
{
|
|
|
|
dist = abs( m_Poly->corner[item_pos].x - refPos.x ) + abs(
|
|
|
|
m_Poly->corner[item_pos].y - refPos.y );
|
|
|
|
if( dist <= min_dist )
|
|
|
|
{
|
|
|
|
m_CornerSelection = item_pos;
|
|
|
|
min_dist = dist;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_CornerSelection >= 0 )
|
|
|
|
return item_pos;
|
2008-01-24 19:51:13 +00:00
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
/**
|
|
|
|
* Function HitTestForEdge
|
|
|
|
* tests if the given wxPoint near a corner, or near the segment define by 2 corners.
|
2008-01-24 19:51:13 +00:00
|
|
|
* choose the nearest segment
|
2008-01-20 19:55:22 +00:00
|
|
|
* "near" means EDGE_MIN_DIST_IN_PIXELS pixels
|
2010-12-14 15:56:30 +00:00
|
|
|
* @return -1 if none, or index of the starting corner in .corner <vector>
|
2007-12-29 19:15:58 +00:00
|
|
|
* @param refPos : A wxPoint to test
|
|
|
|
*/
|
|
|
|
int ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos )
|
|
|
|
{
|
2008-01-31 20:53:44 +00:00
|
|
|
#define EDGE_MIN_DIST 200 // distance (in internal units) to detect a zone outline
|
|
|
|
int dist, min_dist;
|
|
|
|
unsigned item_pos, lim;
|
|
|
|
lim = m_Poly->corner.size();
|
2007-12-29 19:15:58 +00:00
|
|
|
|
|
|
|
/* Test for an entire segment */
|
|
|
|
unsigned first_corner_pos = 0, end_segm;
|
2008-01-31 20:53:44 +00:00
|
|
|
m_CornerSelection = -1;
|
|
|
|
min_dist = EDGE_MIN_DIST;
|
|
|
|
|
|
|
|
for( item_pos = 0; item_pos < lim; item_pos++ )
|
|
|
|
{
|
|
|
|
end_segm = item_pos + 1;
|
|
|
|
|
|
|
|
/* 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 */
|
|
|
|
dist = (int) GetPointToLineSegmentDistance( refPos.x,
|
2011-01-20 18:40:33 +00:00
|
|
|
refPos.y,
|
|
|
|
m_Poly->corner[item_pos].x,
|
|
|
|
m_Poly->corner[item_pos].y,
|
|
|
|
m_Poly->corner[end_segm].x,
|
|
|
|
m_Poly->corner[end_segm].y );
|
2008-01-31 20:53:44 +00:00
|
|
|
if( dist <= min_dist )
|
|
|
|
{
|
|
|
|
m_CornerSelection = item_pos;
|
|
|
|
min_dist = dist;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_CornerSelection >= 0 )
|
|
|
|
return item_pos;
|
2008-01-24 19:51:13 +00:00
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2008-01-06 12:43:57 +00:00
|
|
|
/**
|
|
|
|
* Function HitTest (overlayed)
|
|
|
|
* tests if the given EDA_Rect contains the bounds of this object.
|
|
|
|
* @param refArea : the given EDA_Rect
|
|
|
|
* @return bool - true if a hit, else false
|
|
|
|
*/
|
2008-01-31 20:53:44 +00:00
|
|
|
bool ZONE_CONTAINER::HitTest( EDA_Rect& refArea )
|
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
|
|
|
|
|
|
|
if( rect.left < refArea.GetX() )
|
|
|
|
is_out_of_box = true;
|
|
|
|
if( rect.top < refArea.GetY() )
|
|
|
|
is_out_of_box = true;
|
|
|
|
if( rect.right > refArea.GetRight() )
|
|
|
|
is_out_of_box = true;
|
|
|
|
if( rect.bottom > refArea.GetBottom() )
|
|
|
|
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
|
|
|
|
2008-11-27 10:12:46 +00:00
|
|
|
/**
|
|
|
|
* Function HitTestFilledArea
|
|
|
|
* tests if the given wxPoint is within the bounds of a filled area of this zone.
|
|
|
|
* @param aRefPos A wxPoint to test
|
|
|
|
* @return bool - true if a hit, else false
|
|
|
|
*/
|
|
|
|
bool ZONE_CONTAINER::HitTestFilledArea( const wxPoint& aRefPos )
|
|
|
|
{
|
|
|
|
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
|
|
|
|
|
|
|
// Prepare test of next area which starts after the current indexend (if exists)
|
|
|
|
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 );
|
|
|
|
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 )
|
|
|
|
{
|
2009-07-30 11:04:07 +00:00
|
|
|
NETINFO_ITEM* equipot = ( (WinEDA_BasePcbFrame*) 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 );
|
2008-09-26 19:51:36 +00:00
|
|
|
}
|
|
|
|
else
|
2009-10-16 17:18:23 +00:00
|
|
|
frame->AppendMsgPanel( _( "Non Copper Zone" ), wxEmptyString, RED );
|
2008-01-31 20:53:44 +00:00
|
|
|
|
|
|
|
/* Display net code : (usefull in test or debug) */
|
|
|
|
msg.Printf( wxT( "%d" ), GetNet() );
|
2009-10-16 17:18:23 +00:00
|
|
|
frame->AppendMsgPanel( _( "NetCode" ), msg, RED );
|
2007-12-29 19:15:58 +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
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
msg.Printf( wxT( "%d" ), 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" );
|
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 :
|
2008-01-31 20:53:44 +00:00
|
|
|
msg.Printf( wxT( "%d" ), 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() )
|
|
|
|
{
|
|
|
|
msg.Printf( wxT( "%d" ), 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
|
|
|
|
2008-01-06 12:43:57 +00:00
|
|
|
/**
|
|
|
|
* Function Move
|
|
|
|
* Move the outlines
|
|
|
|
* @param offset = moving vector
|
|
|
|
*/
|
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
|
|
|
/**
|
|
|
|
* Function MoveEdge
|
|
|
|
* Move the outline Edge. m_CornerSelection is the start point of the outline edge
|
|
|
|
* @param offset = moving vector
|
|
|
|
*/
|
|
|
|
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
|
|
|
|
ii++;
|
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
|
|
|
|
2008-01-06 12:43:57 +00:00
|
|
|
/**
|
2008-02-01 21:30:45 +00:00
|
|
|
* Function Rotate
|
2008-01-06 12:43:57 +00:00
|
|
|
* Move the outlines
|
|
|
|
* @param centre = rot centre
|
|
|
|
* @param angle = in 0.1 degree
|
|
|
|
*/
|
2008-01-31 20:53:44 +00:00
|
|
|
void ZONE_CONTAINER::Rotate( const wxPoint& centre, int 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
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
/**
|
|
|
|
* Function Flip
|
|
|
|
* Flip this object, i.e. change the board side for this object
|
|
|
|
* (like Mirror() but changes layer)
|
2010-12-14 15:56:30 +00:00
|
|
|
* @param aCentre - the rotation point.
|
2009-08-01 19:26:05 +00:00
|
|
|
*/
|
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-06 12:43:57 +00:00
|
|
|
/**
|
|
|
|
* Function Mirror
|
|
|
|
* flip the outlines , relative to a given horizontal axis
|
|
|
|
* @param mirror_ref = vertical axis position
|
|
|
|
*/
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function copy
|
2008-01-06 17:19:36 +00:00
|
|
|
* copy usefull data from the source.
|
|
|
|
* flags and linked list pointers are NOT copied
|
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() );
|
|
|
|
m_TimeStamp = 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;
|
2008-01-31 20:53:44 +00:00
|
|
|
m_PadOption = src->m_PadOption;
|
2011-01-20 18:40:33 +00:00
|
|
|
m_ThermalReliefGapValue = src->m_ThermalReliefGapValue;
|
|
|
|
m_ThermalReliefCopperBridgeValue = src->m_ThermalReliefCopperBridgeValue;
|
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
|
|
|
/**
|
|
|
|
* Function SetNetNameFromNetCode
|
2009-08-08 06:07:08 +00:00
|
|
|
* Find the net name corresponding to the net code.
|
2008-10-23 10:26:06 +00:00
|
|
|
* @return bool - true if net found, else false
|
|
|
|
*/
|
|
|
|
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;
|
|
|
|
}
|