Commit ffd3a713 authored by CHARRAS's avatar CHARRAS

more about zones. current No DRC for outlines

parent 945c14d4
...@@ -11,12 +11,12 @@ const char * add_zone_cutout[] = { ...@@ -11,12 +11,12 @@ const char * add_zone_cutout[] = {
" ..............", " ..............",
".... ........", ".... ........",
"... ++++ .......", "... ++++ .......",
".. + + .....", ".. +++++++ .....",
". + + ...", ". ++ ++ ...",
". + + ..", ". ++ ++ ..",
". + + ..", ". ++ ++ ..",
". + + .", ". ++ ++ .",
".. + + ..", ".. ++++++++++ ..",
"... +++++++ ... ", "... +++++++ ... ",
".... .... ", ".... .... ",
"............ ", "............ ",
......
...@@ -4,6 +4,14 @@ Started 2007-June-11 ...@@ -4,6 +4,14 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2008-jan-04 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+pcbnew:
More about zones:
Outlines can be edited. Outlines are merged if needeed.
Current No DRC for outlines
2008-jan-01 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> 2008-jan-01 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================ ================================================================================
+all +all
......
...@@ -529,6 +529,24 @@ public: ...@@ -529,6 +529,24 @@ public:
*/ */
int Fill_All_Zones( wxDC* DC, bool verbose = TRUE ); int Fill_All_Zones( wxDC* DC, bool verbose = TRUE );
/**
* Function Add_Zone_Cutout
* Add a cutout zone to a given zone outline
* @param DC = current Device Context
* @param zone_container = parent zone outline
*/
void Add_Zone_Cutout( wxDC* DC , ZONE_CONTAINER * zone_container );
/**
* Function Add_Similar_Zone
* Add a zone to a given zone outline.
* if the zones are overlappeing they will be merged
* @param DC = current Device Context
* @param zone_container = parent zone outline
*/
void Add_Similar_Zone( wxDC* DC , ZONE_CONTAINER * zone_container );
/** /**
* Function Edit_Zone_Params * Function Edit_Zone_Params
* Edit params (layer, clearance, ...) for a zone outline * Edit params (layer, clearance, ...) for a zone outline
...@@ -548,6 +566,13 @@ public: ...@@ -548,6 +566,13 @@ public:
*/ */
void End_Move_Zone_Corner( wxDC* DC , ZONE_CONTAINER * zone_container ); void End_Move_Zone_Corner( wxDC* DC , ZONE_CONTAINER * zone_container );
/**
* Function End_Move_Zone_Corner
* Remove the currently selected corner in a zone outline
* the .m_CornerSelection is used as corner selection
*/
void Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER * zone_container );
// Target handling // Target handling
MIREPCB* Create_Mire( wxDC* DC ); MIREPCB* Create_Mire( wxDC* DC );
void Delete_Mire( MIREPCB* MirePcb, wxDC* DC ); void Delete_Mire( MIREPCB* MirePcb, wxDC* DC );
......
No preview for this file type
This diff is collapsed.
...@@ -224,6 +224,123 @@ public: ...@@ -224,6 +224,123 @@ public:
void Show( int nestLevel, std::ostream& os ); void Show( int nestLevel, std::ostream& os );
#endif #endif
/* Functions used in test, merge and cut outlines */
/**
* Function AddArea
* add empty copper area to net
* @return pointer to the new area
*/
ZONE_CONTAINER* AddArea( int netcode, int layer, int x, int y, int hatch );
/**
* remove copper area from net
* @param area = area to remove
* @return 0
*/
int RemoveArea( ZONE_CONTAINER* area_to_remove );
/**
* Function InsertArea
* add empty copper area to net, inserting after m_ZoneDescriptorList[iarea]
* @return pointer to the new area
*/
ZONE_CONTAINER* InsertArea( int netcode, int iarea, int layer, int x, int y, int hatch );
/**
Function CompleteArea
* complete copper area contour by adding a line from last to first corner
* if there is only 1 or 2 corners, remove (delete) the area
* @param area_to_complete = area to complete or remove
* @param style = style of last corner
* @return 1 if Ok, 0 if area removed
*/
int CompleteArea( ZONE_CONTAINER* area_to_complete, int style );
/**
* Function TestAreaPolygon
* Test an area for self-intersection.
*
* @param CurrArea = copper area to test
* @return :
* -1 if arcs intersect other sides
* 0 if no intersecting sides
* 1 if intersecting sides, but no intersecting arcs
* Also sets utility2 flag of area with return value
*/
int TestAreaPolygon( ZONE_CONTAINER* CurrArea );
/**
* Function ClipAreaPolygon
* Process an area that has been modified, by clipping its polygon against itself.
* This may change the number and order of copper areas in the net.
* @param bMessageBoxInt == TRUE, shows message when clipping occurs.
* @param bMessageBoxArc == TRUE, shows message when clipping can't be done due to arcs.
* @return:
* -1 if arcs intersect other sides, so polygon can't be clipped
* 0 if no intersecting sides
* 1 if intersecting sides
* Also sets areas->utility1 flags if areas are modified
*/
int ClipAreaPolygon( ZONE_CONTAINER* CurrArea,
bool bMessageBoxArc, bool bMessageBoxInt, bool bRetainArcs = TRUE );
/**
* Process an area that has been modified, by clipping its polygon against
* itself and the polygons for any other areas on the same net.
* This may change the number and order of copper areas in the net.
* @param modified_area = area to test
* @param bMessageBox : if TRUE, shows message boxes when clipping occurs.
* @return :
* -1 if arcs intersect other sides, so polygon can't be clipped
* 0 if no intersecting sides
* 1 if intersecting sides, polygon clipped
*/
int AreaPolygonModified( ZONE_CONTAINER* modified_area,
bool bMessageBoxArc,
bool bMessageBoxInt );
/**
* Function CombineAllAreasInNet
* Checks all copper areas in net for intersections, combining them if found
* @param aNetCode = net to consider
* @param bMessageBox : if true display warning message box
* @param bUseUtility : if true, don't check areas if both utility flags are 0
* Sets utility flag = 1 for any areas modified
* If an area has self-intersecting arcs, doesn't try to combine it
*/
int CombineAllAreasInNet( int aNetCode, bool bMessageBox, bool bUseUtility );
/**
* Function TestAreaIntersections
* Check for intersection of a given copper area with other areas in same net
* @param area_to_test = area to compare to all other areas in the same net
*/
bool TestAreaIntersections( ZONE_CONTAINER* area_to_test );
/**
* Function TestAreaIntersection
* Test for intersection of 2 copper areas
* area_to_test must be after area_ref in m_ZoneDescriptorList
* @param area_ref = area reference
* @param area_to_test = area to compare for intersection calculations
* @return : 0 if no intersection
* 1 if intersection
* 2 if arcs intersect
*/
int TestAreaIntersection( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_to_test );
/**
* Function CombineAreas
* If possible, combine 2 copper areas
* area_ref must be BEFORE area_to_combine
* area_to_combine will be deleted, if areas are combined
* @return : 0 if no intersection
* 1 if intersection
* 2 if arcs intersect
*/
int CombineAreas( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_to_combine );
}; };
#endif // #ifndef CLASS_BOARD_H #endif // #ifndef CLASS_BOARD_H
...@@ -8,15 +8,40 @@ ...@@ -8,15 +8,40 @@
#include "gr_basic.h" #include "gr_basic.h"
#include "common.h" #include "common.h"
#include "PolyLine.h"
#include "pcbnew.h" #include "pcbnew.h"
/**********************/
/* Class EDGE_ZONE */
/**********************/
/* Constructor */
EDGE_ZONE::EDGE_ZONE( BOARD_ITEM* parent ) :
DRAWSEGMENT( parent, TYPEEDGEZONE )
{
m_Width = 2; // a minimum for visibility, while dragging
}
/* Destructor */
EDGE_ZONE:: ~EDGE_ZONE()
{
}
/****************************************/
bool EDGE_ZONE::Save( FILE* aFile ) const
/****************************************/
{
return true;
}
/************************/ /************************/
/* class ZONE_CONTAINER */ /* class ZONE_CONTAINER */
/************************/ /************************/
ZONE_CONTAINER::ZONE_CONTAINER( BOARD* parent ) : ZONE_CONTAINER::ZONE_CONTAINER( BOARD* parent ) :
BOARD_ITEM( parent, TYPEZONE_CONTAINER ) BOARD_ITEM( parent, TYPEZONE_CONTAINER )
, CPolyLine( NULL )
{ {
m_NetCode = -1; // Net number for fast comparisons m_NetCode = -1; // Net number for fast comparisons
...@@ -24,38 +49,36 @@ ZONE_CONTAINER::ZONE_CONTAINER( BOARD* parent ) : ...@@ -24,38 +49,36 @@ ZONE_CONTAINER::ZONE_CONTAINER( BOARD* parent ) :
m_ZoneClearance = 200; // a reasonnable clerance value m_ZoneClearance = 200; // a reasonnable clerance value
m_GridFillValue = 50; // a reasonnable grid used for filling m_GridFillValue = 50; // a reasonnable grid used for filling
m_PadOption = THERMAL_PAD; m_PadOption = THERMAL_PAD;
} utility = 0; // flags used in polygon calculations
utility2 = 0; // flags used in polygon calculations
m_Poly = new CPolyLine( NULL ); // Outlines
ZONE_CONTAINER::~ZONE_CONTAINER()
{
} }
/**********************/ ZONE_CONTAINER::~ZONE_CONTAINER()
/* Class EDGE_ZONE */
/**********************/
/* Constructor */
EDGE_ZONE::EDGE_ZONE( BOARD_ITEM* parent ) :
DRAWSEGMENT( parent, TYPEEDGEZONE )
{ {
m_Width = 2; // a minimum for visibility, while dragging delete m_Poly;
m_Poly = NULL;
} }
/* Destructor */ /*******************************************/
EDGE_ZONE:: ~EDGE_ZONE() void ZONE_CONTAINER::SetNet( int anet_code )
/*******************************************/
{ {
m_NetCode = anet_code;
if ( m_Parent )
{
EQUIPOT* net = ((BOARD*) m_Parent)->FindNet( g_HightLigth_NetCode );
if( net )
m_Netname = net->m_Netname;
else m_Netname.Empty();
}
else m_Netname.Empty();
} }
/****************************************/
bool EDGE_ZONE::Save( FILE* aFile ) const
/****************************************/
{
return true;
}
/********************************************/ /********************************************/
bool ZONE_CONTAINER::Save( FILE* aFile ) const bool ZONE_CONTAINER::Save( FILE* aFile ) const
...@@ -66,7 +89,7 @@ bool ZONE_CONTAINER::Save( FILE* aFile ) const ...@@ -66,7 +89,7 @@ bool ZONE_CONTAINER::Save( FILE* aFile ) const
unsigned item_pos; unsigned item_pos;
int ret; int ret;
unsigned corners_count = corner.size(); unsigned corners_count = m_Poly->corner.size();
int outline_hatch; int outline_hatch;
fprintf( aFile, "$CZONE_OUTLINE\n"); fprintf( aFile, "$CZONE_OUTLINE\n");
...@@ -79,16 +102,16 @@ bool ZONE_CONTAINER::Save( FILE* aFile ) const ...@@ -79,16 +102,16 @@ bool ZONE_CONTAINER::Save( FILE* aFile ) const
ret = fprintf( aFile, "ZLayer %d\n", m_Layer ); ret = fprintf( aFile, "ZLayer %d\n", m_Layer );
if ( ret < 1 ) return false; if ( ret < 1 ) return false;
// Save the ouline aux info // Save the ouline aux info
switch ( m_HatchStyle ) switch ( m_Poly->GetHatchStyle() )
{ {
default: default:
case NO_HATCH: case CPolyLine::NO_HATCH:
outline_hatch = 'N'; outline_hatch = 'N';
break; break;
case DIAGONAL_EDGE: case CPolyLine::DIAGONAL_EDGE:
outline_hatch = 'E'; outline_hatch = 'E';
break; break;
case DIAGONAL_FULL: case CPolyLine::DIAGONAL_FULL:
outline_hatch = 'F'; outline_hatch = 'F';
break; break;
} }
...@@ -99,8 +122,8 @@ bool ZONE_CONTAINER::Save( FILE* aFile ) const ...@@ -99,8 +122,8 @@ bool ZONE_CONTAINER::Save( FILE* aFile ) const
for ( item_pos = 0; item_pos < corners_count; item_pos++ ) for ( item_pos = 0; item_pos < corners_count; item_pos++ )
{ {
ret = fprintf( aFile, "ZCorner %d %d %d \n", ret = fprintf( aFile, "ZCorner %d %d %d \n",
corner[item_pos].x, corner[item_pos].y, m_Poly->corner[item_pos].x, m_Poly->corner[item_pos].y,
corner[item_pos].end_contour ); m_Poly->corner[item_pos].end_contour );
if ( ret < 3 ) return false; if ( ret < 3 ) return false;
} }
fprintf( aFile, "$endCZONE_OUTLINE\n"); fprintf( aFile, "$endCZONE_OUTLINE\n");
...@@ -122,7 +145,7 @@ int ZONE_CONTAINER::ReadDescr( FILE* aFile, int* aLineNum ) ...@@ -122,7 +145,7 @@ int ZONE_CONTAINER::ReadDescr( FILE* aFile, int* aLineNum )
char netname_buffer[1024]; char netname_buffer[1024];
int ret; int ret;
int n_corner_item = 0; int n_corner_item = 0;
int outline_hatch = NO_HATCH; int outline_hatch = CPolyLine::NO_HATCH;
bool error = false, has_corner = false; bool error = false, has_corner = false;
netname_buffer[0] = 0; netname_buffer[0] = 0;
...@@ -137,13 +160,13 @@ int ZONE_CONTAINER::ReadDescr( FILE* aFile, int* aLineNum ) ...@@ -137,13 +160,13 @@ int ZONE_CONTAINER::ReadDescr( FILE* aFile, int* aLineNum )
else else
{ {
if ( ! has_corner ) if ( ! has_corner )
Start( m_Layer, 0, 0, m_Poly->Start( m_Layer, 0, 0,
x, y, x, y,
outline_hatch ); outline_hatch );
else else
AppendCorner( x, y ); m_Poly->AppendCorner( x, y );
has_corner = true; has_corner = true;
if ( flag ) Close(); if ( flag ) m_Poly->Close();
} }
} }
if( strnicmp(Line, "ZInfo", 5 ) == 0 ) // general info found if( strnicmp(Line, "ZInfo", 5 ) == 0 ) // general info found
...@@ -182,15 +205,15 @@ int ZONE_CONTAINER::ReadDescr( FILE* aFile, int* aLineNum ) ...@@ -182,15 +205,15 @@ int ZONE_CONTAINER::ReadDescr( FILE* aFile, int* aLineNum )
{ {
case 'n': case 'n':
case 'N': case 'N':
outline_hatch = NO_HATCH; outline_hatch = CPolyLine::NO_HATCH;
break; break;
case 'e': case 'e':
case 'E': case 'E':
outline_hatch = DIAGONAL_EDGE; outline_hatch = CPolyLine::DIAGONAL_EDGE;
break; break;
case 'f': case 'f':
case 'F': case 'F':
outline_hatch = DIAGONAL_FULL; outline_hatch = CPolyLine::DIAGONAL_FULL;
break; break;
} }
} }
...@@ -245,32 +268,32 @@ void ZONE_CONTAINER::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& off ...@@ -245,32 +268,32 @@ void ZONE_CONTAINER::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& off
// draw the lines // draw the lines
int i_start_contour = 0; int i_start_contour = 0;
for( unsigned ic = 0; ic < corner.size(); ic++ ) for( unsigned ic = 0; ic < m_Poly->corner.size(); ic++ )
{ {
int xi = corner[ic].x + offset.x; int xi = m_Poly->corner[ic].x + offset.x;
int yi = corner[ic].y + offset.y; int yi = m_Poly->corner[ic].y + offset.y;
int xf, yf; int xf, yf;
if( corner[ic].end_contour == FALSE && ic < corner.size() - 1 ) if( m_Poly->corner[ic].end_contour == FALSE && ic < m_Poly->corner.size() - 1 )
{ {
xf = corner[ic + 1].x + offset.x; xf = m_Poly->corner[ic + 1].x + offset.x;
yf = corner[ic + 1].y + offset.y; yf = m_Poly->corner[ic + 1].y + offset.y;
} }
else else
{ {
xf = corner[i_start_contour].x + offset.x; xf = m_Poly->corner[i_start_contour].x + offset.x;
yf = corner[i_start_contour].y + offset.y; yf = m_Poly->corner[i_start_contour].y + offset.y;
i_start_contour = ic + 1; i_start_contour = ic + 1;
} }
GRLine( &panel->m_ClipBox, DC, xi, yi, xf, yf, 0, color ); GRLine( &panel->m_ClipBox, DC, xi, yi, xf, yf, 0, color );
} }
// draw hatches // draw hatches
for( unsigned ic = 0; ic < m_HatchLines.size(); ic++ ) for( unsigned ic = 0; ic < m_Poly->m_HatchLines.size(); ic++ )
{ {
int xi = m_HatchLines[ic].xi + offset.x; int xi = m_Poly->m_HatchLines[ic].xi + offset.x;
int yi = m_HatchLines[ic].yi + offset.y; int yi = m_Poly->m_HatchLines[ic].yi + offset.y;
int xf = m_HatchLines[ic].xf + offset.x; int xf = m_Poly->m_HatchLines[ic].xf + offset.x;
int yf =m_HatchLines[ic].yf + offset.y; int yf =m_Poly->m_HatchLines[ic].yf + offset.y;
GRLine( &panel->m_ClipBox, DC, xi, yi, xf, yf, 0, color ); GRLine( &panel->m_ClipBox, DC, xi, yi, xf, yf, 0, color );
} }
...@@ -307,7 +330,7 @@ int ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos ) ...@@ -307,7 +330,7 @@ int ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos )
#define MIN_DIST_IN_PIXELS 5 #define MIN_DIST_IN_PIXELS 5
int dist; int dist;
unsigned item_pos, lim; unsigned item_pos, lim;
lim = corner.size(); lim = m_Poly->corner.size();
// Min distance to hit = MIN_DIST_IN_PIXELS pixels : // Min distance to hit = MIN_DIST_IN_PIXELS pixels :
WinEDA_BasePcbFrame* frame = ((BOARD*)GetParent())->m_PcbFrame; WinEDA_BasePcbFrame* frame = ((BOARD*)GetParent())->m_PcbFrame;
...@@ -315,7 +338,7 @@ int ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos ) ...@@ -315,7 +338,7 @@ int ZONE_CONTAINER::HitTestForCorner( const wxPoint& refPos )
for ( item_pos = 0; item_pos < lim; item_pos++ ) for ( item_pos = 0; item_pos < lim; item_pos++ )
{ {
dist = abs( corner[item_pos].x - refPos.x ) + abs( corner[item_pos].y - refPos.y ); dist = abs( m_Poly->corner[item_pos].x - refPos.x ) + abs( m_Poly->corner[item_pos].y - refPos.y );
if( dist <= min_dist ) if( dist <= min_dist )
return item_pos; return item_pos;
} }
...@@ -335,7 +358,7 @@ int ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos ) ...@@ -335,7 +358,7 @@ int ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos )
#define MIN_DIST_IN_PIXELS 5 #define MIN_DIST_IN_PIXELS 5
int dist; int dist;
unsigned item_pos, lim; unsigned item_pos, lim;
lim = corner.size(); lim = m_Poly->corner.size();
// Min distance to hit = MIN_DIST_IN_PIXELS pixels : // Min distance to hit = MIN_DIST_IN_PIXELS pixels :
WinEDA_BasePcbFrame* frame = ((BOARD*)GetParent())->m_PcbFrame; WinEDA_BasePcbFrame* frame = ((BOARD*)GetParent())->m_PcbFrame;
...@@ -351,7 +374,7 @@ int ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos ) ...@@ -351,7 +374,7 @@ int ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos )
* the last segment of the current outline starts at current corner, and ends * the last segment of the current outline starts at current corner, and ends
* at the first corner of the outline * at the first corner of the outline
*/ */
if( corner[item_pos].end_contour || end_segm >= lim) if( m_Poly->corner[item_pos].end_contour || end_segm >= lim)
{ {
unsigned tmp = first_corner_pos; unsigned tmp = first_corner_pos;
first_corner_pos = end_segm; // first_corner_pos is now the beginning of the next outline first_corner_pos = end_segm; // first_corner_pos is now the beginning of the next outline
...@@ -361,10 +384,10 @@ int ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos ) ...@@ -361,10 +384,10 @@ int ZONE_CONTAINER::HitTestForEdge( const wxPoint& refPos )
/* test the dist between segment and ref point */ /* test the dist between segment and ref point */
dist = (int) GetPointToLineSegmentDistance( refPos.x, dist = (int) GetPointToLineSegmentDistance( refPos.x,
refPos.y, refPos.y,
corner[item_pos].x, m_Poly->corner[item_pos].x,
corner[item_pos].y, m_Poly->corner[item_pos].y,
corner[end_segm].x, m_Poly->corner[end_segm].x,
corner[end_segm].y ); m_Poly->corner[end_segm].y );
if( dist <= min_dist ) if( dist <= min_dist )
return item_pos; return item_pos;
} }
...@@ -407,10 +430,10 @@ void ZONE_CONTAINER::Display_Infos( WinEDA_DrawFrame* frame ) ...@@ -407,10 +430,10 @@ void ZONE_CONTAINER::Display_Infos( WinEDA_DrawFrame* frame )
Affiche_1_Parametre( frame, text_pos, _( "Layer" ), msg, BROWN ); Affiche_1_Parametre( frame, text_pos, _( "Layer" ), msg, BROWN );
text_pos += 8; text_pos += 8;
msg.Printf( wxT( "%d" ), corner.size() ); msg.Printf( wxT( "%d" ), m_Poly->corner.size() );
Affiche_1_Parametre( frame, text_pos, _( "Corners" ), msg, BLUE ); Affiche_1_Parametre( frame, text_pos, _( "Corners" ), msg, BLUE );
text_pos += 8; text_pos += 8;
msg.Printf( wxT( "%d" ), m_HatchLines.size() ); msg.Printf( wxT( "%d" ), m_Poly->m_HatchLines.size() );
Affiche_1_Parametre( frame, text_pos, _( "Hatch lines" ), msg, BLUE ); Affiche_1_Parametre( frame, text_pos, _( "Hatch lines" ), msg, BLUE );
} }
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* others polygons inside this main polygon are holes. * others polygons inside this main polygon are holes.
*/ */
class ZONE_CONTAINER : public BOARD_ITEM, public CPolyLine class ZONE_CONTAINER : public BOARD_ITEM
{ {
public: public:
enum m_PadInZone { // How pads are covered by copper in zone enum m_PadInZone { // How pads are covered by copper in zone
...@@ -24,10 +24,12 @@ public: ...@@ -24,10 +24,12 @@ public:
PAD_IN_ZONE // pads are covered by copper PAD_IN_ZONE // pads are covered by copper
}; };
wxString m_Netname; // Net Name wxString m_Netname; // Net Name
CPolyLine * m_Poly; // outlines
int m_CornerSelection; // For corner moving, corner index to drag, or -1 if no selection int m_CornerSelection; // For corner moving, corner index to drag, or -1 if no selection
int m_ZoneClearance; // clearance value int m_ZoneClearance; // clearance value
int m_GridFillValue; // Grid used for filling int m_GridFillValue; // Grid used for filling
m_PadInZone m_PadOption; // see m_PadInZone m_PadInZone m_PadOption; // see m_PadInZone
int utility, utility2; // flags used in polygon calculations
private: private:
int m_NetCode; // Net number for fast comparisons int m_NetCode; // Net number for fast comparisons
...@@ -55,7 +57,7 @@ public: ...@@ -55,7 +57,7 @@ public:
const wxPoint& offset, int draw_mode ); const wxPoint& offset, int draw_mode );
int GetNet( void ) { return m_NetCode; } int GetNet( void ) { return m_NetCode; }
void SetNet( int anet_code ) { m_NetCode = anet_code; } void SetNet( int anet_code );
/** /**
* Function HitTest * Function HitTest
* tests if the given wxPoint is within the bounds of this object. * tests if the given wxPoint is within the bounds of this object.
...@@ -90,7 +92,6 @@ public: ...@@ -90,7 +92,6 @@ public:
* @return error level (0 = no error) * @return error level (0 = no error)
*/ */
int Fill_Zone( WinEDA_PcbFrame* frame, wxDC* DC, bool verbose = TRUE); int Fill_Zone( WinEDA_PcbFrame* frame, wxDC* DC, bool verbose = TRUE);
}; };
/*******************/ /*******************/
......
...@@ -281,7 +281,7 @@ void WinEDA_ZoneFrame::CreateControls() ...@@ -281,7 +281,7 @@ void WinEDA_ZoneFrame::CreateControls()
} }
if ( m_Zone_Container ) if ( m_Zone_Container )
s_Zone_Hatching = m_Zone_Container->GetHatch(); s_Zone_Hatching = m_Zone_Container->m_Poly->GetHatchStyle();
switch( s_Zone_Hatching ) switch( s_Zone_Hatching )
{ {
case CPolyLine::NO_HATCH: case CPolyLine::NO_HATCH:
......
...@@ -450,11 +450,13 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -450,11 +450,13 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_PCB_ZONE_ADD_SIMILAR_ZONE: case ID_POPUP_PCB_ZONE_ADD_SIMILAR_ZONE:
wxMessageBox(wxT("ToDo")); DrawPanel->MouseToCursorSchema();
Add_Similar_Zone( &dc, (ZONE_CONTAINER*) GetCurItem() );
break; break;
case ID_POPUP_PCB_ZONE_ADD_CUTOUT_ZONE: case ID_POPUP_PCB_ZONE_ADD_CUTOUT_ZONE:
wxMessageBox(wxT("ToDo")); DrawPanel->MouseToCursorSchema();
Add_Zone_Cutout( &dc, (ZONE_CONTAINER*) GetCurItem() );
break; break;
case ID_POPUP_PCB_DELETE_ZONE_CONTAINER: case ID_POPUP_PCB_DELETE_ZONE_CONTAINER:
...@@ -469,23 +471,9 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -469,23 +471,9 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
} }
case ID_POPUP_PCB_DELETE_ZONE_CORNER: case ID_POPUP_PCB_DELETE_ZONE_CORNER:
{ Remove_Zone_Corner( &dc, (ZONE_CONTAINER*)GetCurItem() );
DrawPanel->MouseToCursorSchema();
ZONE_CONTAINER * zone_cont = (ZONE_CONTAINER*)GetCurItem();
zone_cont->Draw(DrawPanel,&dc, wxPoint(0,0), GR_XOR);
if ( zone_cont->GetNumCorners() <= 3 )
{
Delete_Zone( &dc, NULL, zone_cont->m_TimeStamp );
m_Pcb->Delete( zone_cont );
}
else
{
zone_cont->DeleteCorner(zone_cont->m_CornerSelection);
zone_cont->Draw(DrawPanel,&dc, wxPoint(0,0), GR_XOR);
}
SetCurItem( NULL ); SetCurItem( NULL );
break; break;
}
case ID_POPUP_PCB_MOVE_ZONE_CORNER: case ID_POPUP_PCB_MOVE_ZONE_CORNER:
{ {
...@@ -505,7 +493,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -505,7 +493,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
* and start move the new corner * and start move the new corner
*/ */
zone_cont->Draw(DrawPanel, &dc, wxPoint(0,0), GR_XOR); zone_cont->Draw(DrawPanel, &dc, wxPoint(0,0), GR_XOR);
zone_cont->InsertCorner( zone_cont->m_CornerSelection, pos.x, pos.y ); zone_cont->m_Poly->InsertCorner( zone_cont->m_CornerSelection, pos.x, pos.y );
zone_cont->m_CornerSelection++; zone_cont->m_CornerSelection++;
zone_cont->Draw(DrawPanel, &dc, wxPoint(0,0), GR_XOR); zone_cont->Draw(DrawPanel, &dc, wxPoint(0,0), GR_XOR);
Start_Move_Zone_Corner(&dc, zone_cont, zone_cont->m_CornerSelection, true); Start_Move_Zone_Corner(&dc, zone_cont, zone_cont->m_CornerSelection, true);
......
...@@ -10,8 +10,10 @@ LIBVIEWER3D = ../3d-viewer/3d-viewer.a ...@@ -10,8 +10,10 @@ LIBVIEWER3D = ../3d-viewer/3d-viewer.a
ZONE_FILES = zones_by_polygon.o ZONE_FILES = zones_by_polygon.o
#ZONE_FILES = zones.o #ZONE_FILES = zones.o
OBJECTS= $(TARGET).o classpcb.o\ OBJECTS= $(TARGET).o classpcb.o\
$(ZONE_FILES)\ $(ZONE_FILES)\
zones_test_and_combine_areas.o\
zone_filling_algorithm.o\ zone_filling_algorithm.o\
lay2plot.o\ lay2plot.o\
modedit_undo_redo.o\ modedit_undo_redo.o\
......
...@@ -658,10 +658,10 @@ void WinEDA_PcbFrame::createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu ...@@ -658,10 +658,10 @@ void WinEDA_PcbFrame::createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu
aPopMenu->AppendSeparator(); aPopMenu->AppendSeparator();
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_ZONE_ADD_SIMILAR_ZONE, ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_ZONE_ADD_SIMILAR_ZONE,
_( "Add Similar Zone" ), fill_zone_xpm ); _( "Add Similar Zone" ), add_zone_xpm );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_ZONE_ADD_CUTOUT_ZONE, ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_ZONE_ADD_CUTOUT_ZONE,
_( "Add Cutout Zone" ), add_zone_cutout ); _( "Add Cutout Area" ), add_zone_cutout );
aPopMenu->AppendSeparator(); aPopMenu->AppendSeparator();
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_FILL_ZONE, ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_FILL_ZONE,
......
...@@ -112,20 +112,20 @@ int ZONE_CONTAINER::Fill_Zone( WinEDA_PcbFrame* frame, wxDC* DC, bool verbose ) ...@@ -112,20 +112,20 @@ int ZONE_CONTAINER::Fill_Zone( WinEDA_PcbFrame* frame, wxDC* DC, bool verbose )
// trace the zone edges into the routing matrix // trace the zone edges into the routing matrix
int i_start_contour = 0; int i_start_contour = 0;
for( unsigned ic = 0; ic < corner.size(); ic++ ) for( unsigned ic = 0; ic < m_Poly->corner.size(); ic++ )
{ {
int xi = corner[ic].x - Pcb->m_BoundaryBox.m_Pos.x; int xi = m_Poly->corner[ic].x - Pcb->m_BoundaryBox.m_Pos.x;
int yi = corner[ic].y - Pcb->m_BoundaryBox.m_Pos.y; int yi = m_Poly->corner[ic].y - Pcb->m_BoundaryBox.m_Pos.y;
int xf, yf; int xf, yf;
if( corner[ic].end_contour == FALSE && ic < corner.size() - 1 ) if( m_Poly->corner[ic].end_contour == FALSE && ic < m_Poly->corner.size() - 1 )
{ {
xf = corner[ic + 1].x - Pcb->m_BoundaryBox.m_Pos.x; xf = m_Poly->corner[ic + 1].x - Pcb->m_BoundaryBox.m_Pos.x;
yf = corner[ic + 1].y - Pcb->m_BoundaryBox.m_Pos.y; yf = m_Poly->corner[ic + 1].y - Pcb->m_BoundaryBox.m_Pos.y;
} }
else else
{ {
xf = corner[i_start_contour].x - Pcb->m_BoundaryBox.m_Pos.x; xf = m_Poly->corner[i_start_contour].x - Pcb->m_BoundaryBox.m_Pos.x;
yf = corner[i_start_contour].y - Pcb->m_BoundaryBox.m_Pos.y; yf = m_Poly->corner[i_start_contour].y - Pcb->m_BoundaryBox.m_Pos.y;
i_start_contour = ic + 1; i_start_contour = ic + 1;
} }
TraceLignePcb( xi, yi, xf, yf, -1, HOLE | CELL_is_EDGE, WRITE_CELL ); TraceLignePcb( xi, yi, xf, yf, -1, HOLE | CELL_is_EDGE, WRITE_CELL );
...@@ -136,9 +136,8 @@ int ZONE_CONTAINER::Fill_Zone( WinEDA_PcbFrame* frame, wxDC* DC, bool verbose ) ...@@ -136,9 +136,8 @@ int ZONE_CONTAINER::Fill_Zone( WinEDA_PcbFrame* frame, wxDC* DC, bool verbose )
int cells_count = 0; int cells_count = 0;
for( ii = 0, pad = frame->m_Pcb->m_Pads; ii < frame->m_Pcb->m_NbPads; ii++, pad++ ) for( ii = 0, pad = frame->m_Pcb->m_Pads; ii < frame->m_Pcb->m_NbPads; ii++, pad++ )
{ {
int icont = 0;
wxPoint pos; wxPoint pos;
if( TestPointInsideContour( icont, (*pad)->m_Pos.x, (*pad)->m_Pos.y ) ) if( m_Poly->TestPointInside( (*pad)->m_Pos.x, (*pad)->m_Pos.y ) )
{ {
ZoneStartFill.x = ( (*pad)->m_Pos.x - Pcb->m_BoundaryBox.m_Pos.x + ZoneStartFill.x = ( (*pad)->m_Pos.x - Pcb->m_BoundaryBox.m_Pos.x +
(g_GridRoutingSize / 2) ) / g_GridRoutingSize; (g_GridRoutingSize / 2) ) / g_GridRoutingSize;
...@@ -196,20 +195,20 @@ int ZONE_CONTAINER::Fill_Zone( WinEDA_PcbFrame* frame, wxDC* DC, bool verbose ) ...@@ -196,20 +195,20 @@ int ZONE_CONTAINER::Fill_Zone( WinEDA_PcbFrame* frame, wxDC* DC, bool verbose )
/* Recreate zone limits on the routing matrix /* Recreate zone limits on the routing matrix
* (could be deleted by PlaceCells()) : */ * (could be deleted by PlaceCells()) : */
i_start_contour = 0; i_start_contour = 0;
for( unsigned ic = 0; ic < corner.size(); ic++ ) for( unsigned ic = 0; ic < m_Poly->corner.size(); ic++ )
{ {
int xi = corner[ic].x - Pcb->m_BoundaryBox.m_Pos.x; int xi = m_Poly->corner[ic].x - Pcb->m_BoundaryBox.m_Pos.x;
int yi = corner[ic].y - Pcb->m_BoundaryBox.m_Pos.y; int yi = m_Poly->corner[ic].y - Pcb->m_BoundaryBox.m_Pos.y;
int xf, yf; int xf, yf;
if( corner[ic].end_contour == FALSE && ic < corner.size() - 1 ) if( m_Poly->corner[ic].end_contour == FALSE && ic < m_Poly->corner.size() - 1 )
{ {
xf = corner[ic + 1].x - Pcb->m_BoundaryBox.m_Pos.x; xf = m_Poly->corner[ic + 1].x - Pcb->m_BoundaryBox.m_Pos.x;
yf = corner[ic + 1].y - Pcb->m_BoundaryBox.m_Pos.y; yf = m_Poly->corner[ic + 1].y - Pcb->m_BoundaryBox.m_Pos.y;
} }
else else
{ {
xf = corner[i_start_contour].x - Pcb->m_BoundaryBox.m_Pos.x; xf = m_Poly->corner[i_start_contour].x - Pcb->m_BoundaryBox.m_Pos.x;
yf = corner[i_start_contour].y - Pcb->m_BoundaryBox.m_Pos.y; yf = m_Poly->corner[i_start_contour].y - Pcb->m_BoundaryBox.m_Pos.y;
i_start_contour = ic + 1; i_start_contour = ic + 1;
} }
TraceLignePcb( xi, yi, xf, yf, -1, HOLE | CELL_is_EDGE, WRITE_CELL ); TraceLignePcb( xi, yi, xf, yf, -1, HOLE | CELL_is_EDGE, WRITE_CELL );
...@@ -219,9 +218,8 @@ int ZONE_CONTAINER::Fill_Zone( WinEDA_PcbFrame* frame, wxDC* DC, bool verbose ) ...@@ -219,9 +218,8 @@ int ZONE_CONTAINER::Fill_Zone( WinEDA_PcbFrame* frame, wxDC* DC, bool verbose )
* (could be deleted by PlaceCells()) : */ * (could be deleted by PlaceCells()) : */
for( ii = 0, pad = frame->m_Pcb->m_Pads; ii < frame->m_Pcb->m_NbPads; ii++, pad++ ) for( ii = 0, pad = frame->m_Pcb->m_Pads; ii < frame->m_Pcb->m_NbPads; ii++, pad++ )
{ {
int icont = 0;
wxPoint pos; wxPoint pos;
if( TestPointInsideContour( icont, (*pad)->m_Pos.x, (*pad)->m_Pos.y ) ) if( m_Poly->TestPointInside( (*pad)->m_Pos.x, (*pad)->m_Pos.y ) )
{ {
ZoneStartFill.x = ( (*pad)->m_Pos.x - Pcb->m_BoundaryBox.m_Pos.x + ZoneStartFill.x = ( (*pad)->m_Pos.x - Pcb->m_BoundaryBox.m_Pos.x +
(g_GridRoutingSize / 2) ) / g_GridRoutingSize; (g_GridRoutingSize / 2) ) / g_GridRoutingSize;
......
This diff is collapsed.
This diff is collapsed.
...@@ -748,6 +748,19 @@ void CPolyLine::RemoveContour( int icont ) ...@@ -748,6 +748,19 @@ void CPolyLine::RemoveContour( int icont )
Draw(); Draw();
} }
void CPolyLine::RemoveAllContours( void )
/**
* function RemoveAllContours
* removes all corners from the lists.
* Others params are not chnaged
*/
{
corner.clear( );
side_style.clear( );
}
/** Function InsertCorner /** Function InsertCorner
* insert a new corner between two existing corners * insert a new corner between two existing corners
* @param ic = index for the insertion point: the corner is inserted AFTER ic * @param ic = index for the insertion point: the corner is inserted AFTER ic
......
...@@ -81,6 +81,7 @@ public: ...@@ -81,6 +81,7 @@ public:
void MoveCorner( int ic, int x, int y ); void MoveCorner( int ic, int x, int y );
void Close( int style = STRAIGHT, BOOL bDraw=TRUE ); void Close( int style = STRAIGHT, BOOL bDraw=TRUE );
void RemoveContour( int icont ); void RemoveContour( int icont );
void RemoveAllContours( void );
// drawing functions // drawing functions
void HighlightSide( int is ); void HighlightSide( int is );
...@@ -107,6 +108,7 @@ public: ...@@ -107,6 +108,7 @@ public:
// access functions // access functions
int GetLayer() { return m_layer;}
int GetNumCorners(); int GetNumCorners();
int GetNumSides(); int GetNumSides();
int GetClosed(); int GetClosed();
...@@ -125,7 +127,7 @@ public: ...@@ -125,7 +127,7 @@ public:
id GetId(); id GetId();
int GetSelBoxSize(); int GetSelBoxSize();
CDisplayList * GetDisplayList(){ return m_dlist; }; CDisplayList * GetDisplayList(){ return m_dlist; };
int GetHatch(){ return m_HatchStyle; } int GetHatchStyle(){ return m_HatchStyle; }
void SetHatch( int hatch ){ Undraw(); m_HatchStyle = hatch; Draw(); }; void SetHatch( int hatch ){ Undraw(); m_HatchStyle = hatch; Draw(); };
void SetX( int ic, int x ); void SetX( int ic, int x );
void SetY( int ic, int y ); void SetY( int ic, int y );
...@@ -159,14 +161,14 @@ private: ...@@ -159,14 +161,14 @@ private:
int m_Width; // line width int m_Width; // line width
int m_sel_box; // corner selection box width/2 int m_sel_box; // corner selection box width/2
int utility; int utility;
protected: public:
std::vector <CPolyPt> corner; // array of points for corners std::vector <CPolyPt> corner; // array of points for corners
std::vector <int> side_style; // array of styles for sides std::vector <int> side_style; // array of styles for sides
private: private:
std::vector <dl_element*> dl_side; // graphic elements std::vector <dl_element*> dl_side; // graphic elements
std::vector <dl_element*> dl_side_sel; std::vector <dl_element*> dl_side_sel;
std::vector <dl_element*> dl_corner_sel; std::vector <dl_element*> dl_corner_sel;
protected: public:
int m_HatchStyle; // hatch style, see enum above int m_HatchStyle; // hatch style, see enum above
std::vector <CSegment> m_HatchLines; // hatch lines std::vector <CSegment> m_HatchLines; // hatch lines
private: private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment