Commit 738d00ba authored by CHARRAS's avatar CHARRAS

more about new zone handling: fill zones now exists

parent cbea44a6
......@@ -554,7 +554,7 @@ enum main_id {
ID_POPUP_PCB_DELETE_ZONE_CORNER,
ID_POPUP_PCB_STOP_CURRENT_EDGE_ZONE,
ID_POPUP_PCB_DELETE_EDGE_ZONE,
ID_POPUP_PCB_DELETE_ZONE_LIMIT,
ID_POPUP_PCB_FILL_ALL_ZONES,
ID_POPUP_PCB_FILL_ZONE,
ID_POPUP_PCB_DELETE_ZONE_CONTAINER,
ID_POPUP_PCB_PLACE_ZONE_CORNER,
......
......@@ -748,7 +748,15 @@ public:
bool Genere_Pad_Connexion( wxDC* DC, int layer );
// zone handling
void Delete_Zone( wxDC* DC, SEGZONE* Track );
/** Function Delete_Zone
* Remove the zone which include the segment aZone, or the zone which have the given time stamp.
* A zone is a group of segments which have the same TimeStamp
* @param DC = current Device Context (can be NULL)
* @param aZone = zone segment within the zone to delete. Can be NULL
* @param aTimestamp = Timestamp for the zone to delete, used if aZone == NULL
*/
void Delete_Zone( wxDC* DC, SEGZONE* Track, long aTimestamp = 0 );
EDGE_ZONE* Del_SegmEdgeZone( wxDC* DC, EDGE_ZONE* edge_zone );
/**
* Function Begin_Zone
......@@ -760,14 +768,31 @@ public:
/**
* Function End_Zone
* terminates the zone edge creation process
* @param DC = current Device Context
*/
void End_Zone( wxDC* DC );
/**
* Function Fill_Zone
* Fills an outline.
*/
void Fill_Zone( wxDC* DC, ZONE_CONTAINER * zone_container );
/** Function Fill_Zone()
* Calculate the zone filling for the outline zone_container
* The zone outline is a frontier, and can be complex (with holes)
* The filling starts from starting points like pads, tracks.
* If exists the old filling is removed
* @param DC = current Device Context
* @param zone_container = zone to fill
* @param verbose = true to show error messages
* @return error level (0 = no error)
*/
int Fill_Zone( wxDC* DC, ZONE_CONTAINER * zone_container, bool verbose = TRUE );
/** Function Fill_All_Zones()
* Fill all zones on the board
* The old fillings are removed
* @param frame = reference to the main frame
* @param DC = current Device Context
* @param verbose = true to show error messages
* @return error level (0 = no error)
*/
int Fill_All_Zones( wxDC* DC, bool verbose = TRUE );
/**
* Function Edit_Zone_Params
......
No preview for this file type
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -12,22 +12,38 @@ KICAD_BIN = /f/kicad/winexe
# DLL use wxWin STATIC 0 0 1
#
# turn on/OFF debugging for all executables, only tested without KICAD_PYTHON
DEBUG = 0
#comment this for static wxWidgets link
#WXUSINGDLL = 1
#Define the wxWidget path (if not found in environment variables):
ifndef WXWIN
ifeq ($(DEBUG), 1)
WXWIN=f:/wxMSW-2.8.7-debug
else
WXWIN=f:/wxMSW-2.8.7
endif
endif
LIBVERSION = 2.8
# You must comment or uncomment this line to disable/enable python support
#KICAD_PYTHON = 1
ifeq ($(DEBUG), 1)
CPPFLAGS = -Wall -g3 -ggdb3 -DDEBUG ${WXXFLAGS} -fno-strict-aliasing
ALL_LDFLAGS = -g3 -ggdb3 #-v
else
CPPFLAGS = -Wall -O2 ${WXXFLAGS} -fno-strict-aliasing
ALL_LDFLAGS = -s #-v
FINAL = 1
endif
ALL_CPPFLAGS = `$(WXWIN)/wx-config --cppflags`
ALL_CPPFLAGS = `$(WXWIN)/wx-config --cppflags` $(CPPFLAGS)
EDACPPFLAGS = $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) $(EXTRACPPFLAGS)
EDALIBS = $(EXTRALIBS)
......
......@@ -73,7 +73,6 @@ SET(PCBNEW_SRCS
edtxtmod.cpp
export_gencad.cpp
files.cpp
filling_zone_algorithm.cpp
find.cpp
gendrill.cpp
gen_modules_placefile.cpp
......@@ -135,6 +134,7 @@ SET(PCBNEW_SRCS
work.cpp
xchgmod.cpp
zones_by_polygon.cpp
zone_filling_algorithm.cpp
# zones.cpp
)
......
......@@ -19,8 +19,11 @@ ZONE_CONTAINER::ZONE_CONTAINER( BOARD* parent ) :
, CPolyLine( NULL )
{
m_NetCode = -1; // Net number for fast comparisons
m_NetCode = -1; // Net number for fast comparisons
m_CornerSelection = -1;
m_ZoneClearance = 200; // a reasonnable clerance value
m_GridFillValue = 50; // a reasonnable grid used for filling
m_PadOption = THERMAL_PAD;
}
......
......@@ -18,11 +18,19 @@
class ZONE_CONTAINER : public BOARD_ITEM, public CPolyLine
{
public:
wxString m_Netname; /* Net Name */
enum m_PadInZone { // How pads are covered by copper in zone
PAD_NOT_IN_ZONE, // Pads are not covered
THERMAL_PAD, // Use thermal relief for pads
PAD_IN_ZONE // pads are covered by copper
};
wxString m_Netname; // Net Name
int m_CornerSelection; // For corner moving, corner index to drag, or -1 if no selection
int m_ZoneClearance; // clearance value
int m_GridFillValue; // Grid used for filling
m_PadInZone m_PadOption; // see m_PadInZone
private:
int m_NetCode; // Net number for fast comparisons
int m_NetCode; // Net number for fast comparisons
public:
ZONE_CONTAINER(BOARD * parent);
......@@ -70,6 +78,19 @@ public:
* @param refPos : A wxPoint to test
*/
int HitTestForEdge( const wxPoint& refPos );
/** Function Fill_Zone()
* Calculate the zone filling
* The zone outline is a frontier, and can be complex (with holes)
* The filling starts from starting points like pads, tracks.
* If exists the old filling is removed
* @param frame = reference to the main frame
* @param DC = current Device Context
* @param verbose = true to show error messages
* @return error level (0 = no error)
*/
int Fill_Zone( WinEDA_PcbFrame* frame, wxDC* DC, bool verbose = TRUE);
};
/*******************/
......
......@@ -267,14 +267,21 @@ void WinEDA_ZoneFrame::CreateControls()
m_GridCtrl->SetSelection( selection );
if( Zone_Exclude_Pads )
switch( s_Zone_Pad_Options )
{
if( s_Zone_Create_Thermal_Relief )
m_FillOpt->SetSelection( 1 );
else
case ZONE_CONTAINER::PAD_NOT_IN_ZONE: // Pads are not covered
m_FillOpt->SetSelection( 2 );
}
break;
case ZONE_CONTAINER::THERMAL_PAD: // Use thermal relief for pads
m_FillOpt->SetSelection( 1 );
break;
case ZONE_CONTAINER::PAD_IN_ZONE: // pads are covered by copper
m_FillOpt->SetSelection( 0 );
break;
}
if ( m_Zone_Container )
s_Zone_Hatching = m_Zone_Container->GetHatch();
switch( s_Zone_Hatching )
{
case CPolyLine::NO_HATCH:
......@@ -296,7 +303,7 @@ void WinEDA_ZoneFrame::CreateControls()
for( int ii = 0; ii < g_DesignSettings.m_CopperLayerCount; ii++ )
{
wxString msg;
int layer_number;
int layer_number = COPPER_LAYER_N;
if( layer_cnt == 0 || ii < layer_cnt - 1 )
layer_number = ii;
else if( ii == layer_cnt - 1 )
......@@ -396,19 +403,16 @@ bool WinEDA_ZoneFrame::AcceptOptions(bool aPromptForErrors)
{
switch( m_FillOpt->GetSelection() )
{
case 0:
Zone_Exclude_Pads = FALSE;
s_Zone_Create_Thermal_Relief = FALSE;
case 2:
s_Zone_Pad_Options = ZONE_CONTAINER::PAD_NOT_IN_ZONE; // Pads are not covered
break;
case 1:
Zone_Exclude_Pads = TRUE;
s_Zone_Create_Thermal_Relief = TRUE;
s_Zone_Pad_Options = ZONE_CONTAINER::THERMAL_PAD; // Use thermal relief for pads
break;
case 2:
Zone_Exclude_Pads = TRUE;
s_Zone_Create_Thermal_Relief = FALSE;
case 0:
s_Zone_Pad_Options = ZONE_CONTAINER::PAD_IN_ZONE; // pads are covered by copper
break;
}
......
......@@ -66,7 +66,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS:
case ID_POPUP_PCB_STOP_CURRENT_EDGE_ZONE:
case ID_POPUP_PCB_DELETE_EDGE_ZONE:
case ID_POPUP_PCB_DELETE_ZONE_LIMIT:
case ID_POPUP_PCB_FILL_ALL_ZONES:
case ID_POPUP_PCB_PLACE_ZONE_CORNER:
case ID_POPUP_PCB_EDIT_ZONE_PARAMS:
case ID_POPUP_PCB_DELETE_ZONE:
......@@ -450,19 +450,31 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_PCB_DELETE_ZONE_CONTAINER:
{
DrawPanel->MouseToCursorSchema();
((ZONE_CONTAINER*)GetCurItem())->Draw(DrawPanel,&dc, wxPoint(0,0), GR_XOR);
m_Pcb->Delete( GetCurItem() );
ZONE_CONTAINER * zone_cont = (ZONE_CONTAINER*)GetCurItem();
zone_cont->Draw(DrawPanel,&dc, wxPoint(0,0), GR_XOR);
Delete_Zone( &dc, NULL, zone_cont->m_TimeStamp );
m_Pcb->Delete( zone_cont );
SetCurItem( NULL );
break;
}
case ID_POPUP_PCB_DELETE_ZONE_CORNER:
{
DrawPanel->MouseToCursorSchema();
ZONE_CONTAINER * zone_cont = (ZONE_CONTAINER*)GetCurItem();
zone_cont->Draw(DrawPanel,&dc, wxPoint(0,0), GR_XOR);
zone_cont->DeleteCorner(zone_cont->m_CornerSelection);
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 );
break;
}
......@@ -500,9 +512,9 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break;
}
case ID_POPUP_PCB_DELETE_ZONE_LIMIT:
case ID_POPUP_PCB_FILL_ALL_ZONES:
DrawPanel->MouseToCursorSchema();
DelLimitesZone( &dc, TRUE );
Fill_All_Zones( &dc );
break;
case ID_POPUP_PCB_FILL_ZONE:
......
......@@ -12,7 +12,7 @@ ZONE_FILES = zones_by_polygon.o
OBJECTS= $(TARGET).o classpcb.o\
$(ZONE_FILES)\
filling_zone_algorithm.o\
zone_filling_algorithm.o\
lay2plot.o\
modedit_undo_redo.o\
block_module_editor.o\
......
......@@ -302,6 +302,9 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
_( "Create Corner" ), move_xpm );
}
aPopMenu->AppendSeparator();
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_FILL_ZONE,
_( "Fill zone" ), fill_zone_xpm );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_EDIT_ZONE_PARAMS,
_( "Edit Zone Params" ), edit_xpm );
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_ZONE_CONTAINER,
......@@ -387,17 +390,13 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
{
case ID_PCB_ZONES_BUTT:
{
bool add_separator = FALSE;
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_FILL_ZONE,
_( "Fill zone" ), fill_zone_xpm );
if( m_Pcb->m_CurrentLimitZone )
{
add_separator = TRUE;
aPopMenu->Append( ID_POPUP_PCB_DELETE_ZONE_LIMIT, _( "Delete Zone Limit" ) );
}
if( add_separator )
if ( m_Pcb->m_ZoneDescriptorList.size() > 0 )
{
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_FILL_ALL_ZONES,
_( "Fill or Refill All Zones" ), fill_zone_xpm );
aPopMenu->AppendSeparator();
}
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_SELECT_LAYER,
_( "Select Working Layer" ), Select_W_Layer_xpm );
aPopMenu->AppendSeparator();
......
/* filling_zone_algorithm:
Algos used to fill a zone defined by a polygon and a filling starting point
*/
* Algos used to fill a zone defined by a polygon and a filling starting point
*/
#include "fctsys.h"
#include "gr_basic.h"
......@@ -14,46 +14,47 @@ Algos used to fill a zone defined by a polygon and a filling starting point
#include "protos.h"
/* Local functions */
static void Genere_Segments_Zone( WinEDA_PcbFrame* frame, wxDC* DC, int net_code );
static void Genere_Segments_Zone( WinEDA_PcbFrame* frame, wxDC* DC, int net_code, int layer );
/* Local variables */
static bool Zone_Debug = FALSE;
static bool Zone_Debug = FALSE;
static unsigned long s_TimeStamp; /* Time stamp common to all segments relative to the new created zone */
/****************************************************************************************/
void Build_Zone( WinEDA_PcbFrame* frame, wxDC* DC, int net_code,
bool Zone_Exclude_Pads, bool Zone_Create_Thermal_Relief )
/****************************************************************************************/
/** Function Build_Zone()
* Init the zone filling
* If a zone edge is found, it is used.
* Otherwise the whole board is filled by the zone
* The zone edge is a frontier, and can be complex. So non filled zones can be achieved
* The zone is put on the active layer
* If a net is hightlighted, the zone will be attached to this net
* The filling start from a starting point.
* If a net is selected, all tracks attached to this net are also starting points
/*****************************************************************************/
int ZONE_CONTAINER::Fill_Zone( WinEDA_PcbFrame* frame, wxDC* DC, bool verbose )
/*****************************************************************************/
/** Function Fill_Zone()
* Calculate the zone filling
* The zone outline is a frontier, and can be complex (with holes)
* The filling starts from starting points like pads, tracks.
* @param frame = reference to the main frame
* @param DC = current Device Context
* @param verbose = true to show error messages
* @return error level (0 = no error)
*/
{
int ii, jj;
EDGE_ZONE* PtLim;
int lp_tmp, lay_tmp_TOP, lay_tmp_BOTTOM;
int save_isol = g_DesignSettings.m_TrackClearence;
wxPoint ZoneStartFill;
wxString msg;
PCB_SCREEN * Screen = frame->GetScreen();
BOARD * Pcb = frame->m_Pcb;
int ii, jj;
int error_level = 0;
int lp_tmp, lay_tmp_TOP, lay_tmp_BOTTOM;
int save_isol = g_DesignSettings.m_TrackClearence;
wxPoint ZoneStartFill;
wxString msg;
PCB_SCREEN* Screen = frame->GetScreen();
BOARD* Pcb = frame->m_Pcb;
g_DesignSettings.m_TrackClearence = g_DesignSettings.m_ZoneClearence;
g_HightLigth_NetCode = m_NetCode;
// Screen->m_Active_Layer = m_Layer;
s_TimeStamp = m_TimeStamp;
s_TimeStamp = time( NULL );
// Delete the old filling, if any :
frame->Delete_Zone( DC, NULL, m_TimeStamp );
// calculate the fixed step of the routing matrix as 5 mils or more
E_scale = g_GridRoutingSize / 50;
E_scale = g_GridRoutingSize / 50;
if( g_GridRoutingSize < 1 )
g_GridRoutingSize = 1;
......@@ -61,83 +62,103 @@ void Build_Zone( WinEDA_PcbFrame* frame, wxDC* DC, int net_code,
ComputeMatriceSize( frame, g_GridRoutingSize );
// Determine the cell pointed to by the mouse
ZoneStartFill.x = ( Screen->m_Curseur.x - Pcb->m_BoundaryBox.m_Pos.x +
(g_GridRoutingSize / 2) ) / g_GridRoutingSize;
ZoneStartFill.y = ( Screen->m_Curseur.y - Pcb->m_BoundaryBox.m_Pos.y +
(g_GridRoutingSize / 2) ) / g_GridRoutingSize;
if( ZoneStartFill.x < 0 )
ZoneStartFill.x = 0;
if( ZoneStartFill.x >= Ncols )
ZoneStartFill.x = Ncols - 1;
if( ZoneStartFill.y < 0 )
ZoneStartFill.y = 0;
if( ZoneStartFill.y >= Nrows )
ZoneStartFill.y = Nrows - 1;
// create the routing matrix in autorout.h's eda_global BOARDHEAD Board
Nb_Sides = ONE_SIDE;
if( Board.InitBoard() < 0 )
{
DisplayError( frame, wxT( "Mo memory for creating zones" ) );
return;
if( verbose )
DisplayError( frame, wxT( "Mo memory for creating zones" ) );
error_level = 1;
return error_level;
}
msg.Printf( wxT( "%d" ), Ncols );
Affiche_1_Parametre( frame, 1, wxT( "Cols" ), msg, GREEN );
msg.Printf( wxT( "%d" ), Nrows );
Affiche_1_Parametre( frame, 7, wxT( "Lines" ), msg, GREEN );
msg.Printf( wxT( "%d" ), Board.m_MemSize / 1024 );
Affiche_1_Parametre( frame, 14, wxT( "Mem(Ko)" ), msg, CYAN );
lay_tmp_BOTTOM = Route_Layer_BOTTOM;
lay_tmp_TOP = Route_Layer_TOP;
Route_Layer_BOTTOM = Route_Layer_TOP = Screen->m_Active_Layer;
Route_Layer_BOTTOM = Route_Layer_TOP = m_Layer;
lp_tmp = g_DesignSettings.m_CurrentTrackWidth;
g_DesignSettings.m_CurrentTrackWidth = g_GridRoutingSize;
/* Create the starting point for thz zone:
/* Create the starting point for the zone:
* The starting point and all the tracks are suitable "starting points" */
TRACK* pt_segm = Pcb->m_Track;
for( ; pt_segm != NULL; pt_segm = pt_segm->Next() )
{
if( g_HightLigth_NetCode != pt_segm->GetNet() )
continue;
if( pt_segm->GetLayer() != Screen->m_Active_Layer )
if( pt_segm->GetLayer() != m_Layer )
continue;
if( pt_segm->Type() != TYPETRACK )
continue;
TraceSegmentPcb( Pcb, pt_segm, CELL_is_FRIEND, 0, WRITE_CELL );
}
// trace the pcb edges (pcb contour) into the routing matrix
Route_Layer_BOTTOM = Route_Layer_TOP = EDGE_N;
PlaceCells( Pcb, -1, 0 );
Route_Layer_BOTTOM = Route_Layer_TOP = Screen->m_Active_Layer;
Route_Layer_BOTTOM = Route_Layer_TOP = m_Layer;
// trace the zone edges into the routing matrix
for( PtLim = Pcb->m_CurrentLimitZone; PtLim; PtLim=PtLim->Next() )
int i_start_contour = 0;
for( unsigned ic = 0; ic < corner.size(); ic++ )
{
int ux0, uy0, ux1, uy1;
ux0 = PtLim->m_Start.x - Pcb->m_BoundaryBox.m_Pos.x;
uy0 = PtLim->m_Start.y - Pcb->m_BoundaryBox.m_Pos.y;
ux1 = PtLim->m_End.x - Pcb->m_BoundaryBox.m_Pos.x;
uy1 = PtLim->m_End.y - Pcb->m_BoundaryBox.m_Pos.y;
TraceLignePcb( ux0, uy0, ux1, uy1, -1, HOLE | CELL_is_EDGE, WRITE_CELL );
int xi = corner[ic].x - Pcb->m_BoundaryBox.m_Pos.x;
int yi = corner[ic].y - Pcb->m_BoundaryBox.m_Pos.y;
int xf, yf;
if( corner[ic].end_contour == FALSE && ic < corner.size() - 1 )
{
xf = corner[ic + 1].x - Pcb->m_BoundaryBox.m_Pos.x;
yf = corner[ic + 1].y - Pcb->m_BoundaryBox.m_Pos.y;
}
else
{
xf = corner[i_start_contour].x - Pcb->m_BoundaryBox.m_Pos.x;
yf = corner[i_start_contour].y - Pcb->m_BoundaryBox.m_Pos.y;
i_start_contour = ic + 1;
}
TraceLignePcb( xi, yi, xf, yf, -1, HOLE | CELL_is_EDGE, WRITE_CELL );
}
OrCell( ZoneStartFill.y, ZoneStartFill.x, BOTTOM, CELL_is_ZONE );
/* Create a starting point to create the zone filling */
LISTE_PAD* pad;
int cells_count = 0;
for( ii = 0, pad = frame->m_Pcb->m_Pads; ii < frame->m_Pcb->m_NbPads; ii++, pad++ )
{
int icont = 0;
wxPoint pos;
if( TestPointInsideContour( icont, (*pad)->m_Pos.x, (*pad)->m_Pos.y ) )
{
ZoneStartFill.x = ( (*pad)->m_Pos.x - Pcb->m_BoundaryBox.m_Pos.x +
(g_GridRoutingSize / 2) ) / g_GridRoutingSize;
ZoneStartFill.y = ( (*pad)->m_Pos.y - Pcb->m_BoundaryBox.m_Pos.y +
(g_GridRoutingSize / 2) ) / g_GridRoutingSize;
OrCell( ZoneStartFill.y, ZoneStartFill.x, BOTTOM, CELL_is_ZONE );
cells_count++;
}
}
if( cells_count == 0 )
{
if( verbose )
DisplayError( frame, _( "No pads or starting point found to fill this zone outline" ) );
error_level = 2;
goto end_of_zone_fill;
}
// mark the cells forming part of the zone
ii = 1; jj = 1;
......@@ -164,36 +185,59 @@ void Build_Zone( WinEDA_PcbFrame* frame, wxDC* DC, int net_code,
// now, all the cell candidates are marked
// place all the obstacles into the matrix, such as (pads, tracks, vias,
// place all the obstacles into the matrix, such as (pads, tracks, vias,
// pcb edges or segments)
ii = 0;
if( Zone_Exclude_Pads )
if( m_PadOption == PAD_NOT_IN_ZONE )
ii = FORCE_PADS;
Affiche_1_Parametre( frame, 42, wxT( "GenZone" ), wxEmptyString, RED );
PlaceCells( Pcb, g_HightLigth_NetCode, ii );
Affiche_1_Parametre( frame, -1, wxEmptyString, _( "Ok" ), RED );
/* Create zone limits on the routing matrix
* (colud be deleted by PlaceCells()) : */
for( PtLim = Pcb->m_CurrentLimitZone; PtLim; PtLim = PtLim->Next() )
/* Recreate zone limits on the routing matrix
* (could be deleted by PlaceCells()) : */
i_start_contour = 0;
for( unsigned ic = 0; ic < corner.size(); ic++ )
{
int ux0, uy0, ux1, uy1;
ux0 = PtLim->m_Start.x - Pcb->m_BoundaryBox.m_Pos.x;
uy0 = PtLim->m_Start.y - Pcb->m_BoundaryBox.m_Pos.y;
ux1 = PtLim->m_End.x - Pcb->m_BoundaryBox.m_Pos.x;
uy1 = PtLim->m_End.y - Pcb->m_BoundaryBox.m_Pos.y;
TraceLignePcb( ux0, uy0, ux1, uy1, -1, HOLE | CELL_is_EDGE, WRITE_CELL );
int xi = corner[ic].x - Pcb->m_BoundaryBox.m_Pos.x;
int yi = corner[ic].y - Pcb->m_BoundaryBox.m_Pos.y;
int xf, yf;
if( corner[ic].end_contour == FALSE && ic < corner.size() - 1 )
{
xf = corner[ic + 1].x - Pcb->m_BoundaryBox.m_Pos.x;
yf = corner[ic + 1].y - Pcb->m_BoundaryBox.m_Pos.y;
}
else
{
xf = corner[i_start_contour].x - Pcb->m_BoundaryBox.m_Pos.x;
yf = corner[i_start_contour].y - Pcb->m_BoundaryBox.m_Pos.y;
i_start_contour = ic + 1;
}
TraceLignePcb( xi, yi, xf, yf, -1, HOLE | CELL_is_EDGE, WRITE_CELL );
}
/* Init the starting point for zone filling : this is the mouse position
* (could be deleted by PlaceCells()) : */
OrCell( ZoneStartFill.y, ZoneStartFill.x, BOTTOM, CELL_is_ZONE );
for( ii = 0, pad = frame->m_Pcb->m_Pads; ii < frame->m_Pcb->m_NbPads; ii++, pad++ )
{
int icont = 0;
wxPoint pos;
if( TestPointInsideContour( icont, (*pad)->m_Pos.x, (*pad)->m_Pos.y ) )
{
ZoneStartFill.x = ( (*pad)->m_Pos.x - Pcb->m_BoundaryBox.m_Pos.x +
(g_GridRoutingSize / 2) ) / g_GridRoutingSize;
ZoneStartFill.y = ( (*pad)->m_Pos.y - Pcb->m_BoundaryBox.m_Pos.y +
(g_GridRoutingSize / 2) ) / g_GridRoutingSize;
OrCell( ZoneStartFill.y, ZoneStartFill.x, BOTTOM, CELL_is_ZONE );
}
}
if( Zone_Debug )
DisplayBoard( frame->DrawPanel, DC );
/* Filling the cells of the matrix (tjis is the zone building)*/
/* Filling the cells of the matrix (this is the zone building)*/
ii = 1; jj = 1;
while( ii )
{
......@@ -202,20 +246,25 @@ void Build_Zone( WinEDA_PcbFrame* frame, wxDC* DC, int net_code,
ii = Propagation( frame );
}
// replace obstacles into the matrix(pads)
if( m_PadOption == THERMAL_PAD )
PlaceCells( Pcb, g_HightLigth_NetCode, FORCE_PADS );
if( Zone_Debug )
DisplayBoard( frame->DrawPanel, DC );
/* Convert the matrix information (cells) to segments which are actually the zone */
if( g_HightLigth_NetCode < 0 )
Genere_Segments_Zone( frame, DC, 0 );
Genere_Segments_Zone( frame, DC, 0, m_Layer );
else
Genere_Segments_Zone( frame, DC, g_HightLigth_NetCode );
Genere_Segments_Zone( frame, DC, g_HightLigth_NetCode, m_Layer );
/* Create the thermal reliefs */
g_DesignSettings.m_CurrentTrackWidth = lp_tmp;
if( Zone_Exclude_Pads && Zone_Create_Thermal_Relief )
frame->Genere_Pad_Connexion( DC, Screen->m_Active_Layer );
if( m_PadOption == THERMAL_PAD )
frame->Genere_Pad_Connexion( DC, m_Layer );
end_of_zone_fill:
g_DesignSettings.m_TrackClearence = save_isol;
// free the memory
......@@ -224,21 +273,22 @@ void Build_Zone( WinEDA_PcbFrame* frame, wxDC* DC, int net_code,
// restore original values unchanged
Route_Layer_TOP = lay_tmp_TOP;
Route_Layer_BOTTOM = lay_tmp_BOTTOM;
}
return error_level;
}
/*******************************************************************************/
static void Genere_Segments_Zone( WinEDA_PcbFrame* frame, wxDC* DC, int net_code )
/*******************************************************************************/
/*******************************************************************************************/
static void Genere_Segments_Zone( WinEDA_PcbFrame* frame, wxDC* DC, int net_code, int layer )
/*******************************************************************************************/
/** Function Genere_Segments_Zone()
* Create the zone segments from the routing matrix structure
* Create the zone segments from the routing matrix structure
* Algorithm:
* Search for consecutive cells (flagged "zone") , and create segments
* from the first cell to the last cell in the matrix
* from the first cell to the last cell in the matrix
* 2 searchs are made
* 1 - From left to right and create horizontal zone segments
* 1 - From left to right and create horizontal zone segments
* 2 - From top to bottom, and create vertical zone segments
* @param net_code = net_code common to all segment zone created
* @param DC = current device context
......@@ -252,11 +302,10 @@ static void Genere_Segments_Zone( WinEDA_PcbFrame* frame, wxDC* DC, int net_code
int Xmin = frame->m_Pcb->m_BoundaryBox.m_Pos.x;
int Ymin = frame->m_Pcb->m_BoundaryBox.m_Pos.y;
SEGZONE* pt_track;
int layer = frame->GetScreen()->m_Active_Layer;
int nbsegm = 0;
wxString msg;
/* balayage Gauche-> droite */
/* Create horizontal segments */
Affiche_1_Parametre( frame, 64, wxT( "Segm H" ), wxT( "0" ), BROWN );
for( row = 0; row < Nrows; row++ )
{
......@@ -280,17 +329,17 @@ static void Genere_Segments_Zone( WinEDA_PcbFrame* frame, wxDC* DC, int net_code
pt_track = new SEGZONE( frame->m_Pcb );
pt_track->SetLayer( layer );
pt_track->SetNet( net_code );
pt_track->m_Width = g_GridRoutingSize;
pt_track->m_Start.x = ux0;
pt_track->m_Start.y = uy0;
pt_track->m_End.x = ux1;
pt_track->m_End.y = uy1;
pt_track->m_Width = g_GridRoutingSize;
pt_track->m_Start.x = ux0;
pt_track->m_Start.y = uy0;
pt_track->m_End.x = ux1;
pt_track->m_End.y = uy1;
pt_track->m_TimeStamp = s_TimeStamp;
pt_track->Insert( frame->m_Pcb, NULL );
pt_track->Draw( frame->DrawPanel, DC, GR_OR );
nbsegm++;
......@@ -303,6 +352,7 @@ static void Genere_Segments_Zone( WinEDA_PcbFrame* frame, wxDC* DC, int net_code
Affiche_1_Parametre( frame, -1, wxEmptyString, msg, BROWN );
}
/* Create vertical segments */
Affiche_1_Parametre( frame, 72, wxT( "Segm V" ), wxT( "0" ), BROWN );
for( col = 0; col < Ncols; col++ )
{
......@@ -324,15 +374,15 @@ static void Genere_Segments_Zone( WinEDA_PcbFrame* frame, wxDC* DC, int net_code
/* un segment avait debute de longueur > 0 */
pt_track = new SEGZONE( frame->m_Pcb );
pt_track->SetLayer( layer );
pt_track->m_Width = g_GridRoutingSize;
pt_track->m_Width = g_GridRoutingSize;
pt_track->SetNet( net_code );
pt_track->m_Start.x = ux0;
pt_track->m_Start.y = uy0;
pt_track->m_End.x = ux1;
pt_track->m_End.y = uy1;
pt_track->m_Start.x = ux0;
pt_track->m_Start.y = uy0;
pt_track->m_End.x = ux1;
pt_track->m_End.y = uy1;
pt_track->m_TimeStamp = s_TimeStamp;
pt_track->Insert( frame->m_Pcb, NULL );
pt_track->Draw( frame->DrawPanel, DC, GR_OR );
......@@ -368,7 +418,7 @@ int Propagation( WinEDA_PcbFrame* frame )
* 2 - Right to left and top to bottom
* 3 - bottom to top and Right to left
* 4 - bottom to top and Left to right
* Given the current cell, for each search, we consider the 2 neightbour cells
* Given the current cell, for each search, we consider the 2 neightbour cells
* the previous cell on the same line and the previous cell on the same column.
*
* This funtion can request some iterations
......@@ -471,7 +521,7 @@ int Propagation( WinEDA_PcbFrame* frame )
if( current_cell == 0 ) /* a free cell is found */
{
if( (old_cell_H & CELL_is_ZONE)
|| (pt_cell_V[row] & CELL_is_ZONE) )
|| (pt_cell_V[row] & CELL_is_ZONE) )
{
OrCell( row, col, BOTTOM, CELL_is_ZONE );
current_cell = CELL_is_ZONE;
......@@ -506,9 +556,9 @@ bool WinEDA_PcbFrame::Genere_Pad_Connexion( wxDC* DC, int layer )
wxString msg;
if( m_Pcb->m_Zone == NULL )
return FALSE; /* error: no zone */
if( m_Pcb->m_Zone->m_TimeStamp != s_TimeStamp ) /* error: this is not the new zone */
return FALSE; /* error: no zone */
if( m_Pcb->m_Zone->m_TimeStamp != s_TimeStamp ) /* error: this is not the new zone */
return FALSE;
/* Count the pads, i.e. the thermal relief to create count, and displays it */
......@@ -531,7 +581,7 @@ bool WinEDA_PcbFrame::Genere_Pad_Connexion( wxDC* DC, int layer )
msg.Printf( wxT( "%d" ), Npads );
Affiche_1_Parametre( this, -1, wxEmptyString, msg, CYAN );
/* Create the thermal reliefs */
/* Create the thermal reliefs */
Affiche_1_Parametre( this, 57, wxT( "Pads" ), wxT( " " ), CYAN );
pt_liste_pad = (LISTE_PAD*) m_Pcb->m_Pads;
for( ii = 0, Npads = 0; ii < m_Pcb->m_NbPads; ii++, pt_liste_pad++ )
......@@ -546,17 +596,17 @@ bool WinEDA_PcbFrame::Genere_Pad_Connexion( wxDC* DC, int layer )
continue;
/* Create the theram relief for the current pad */
Npads++;
Npads++;
msg.Printf( wxT( "%d" ), Npads );
Affiche_1_Parametre( this, -1, wxEmptyString, msg, CYAN );
cX = pt_pad->GetPosition().x;
cX = pt_pad->GetPosition().x;
cY = pt_pad->GetPosition().y;
dx = pt_pad->m_Size.x / 2;
dy = pt_pad->m_Size.y / 2;
dx = pt_pad->m_Size.x / 2;
dy = pt_pad->m_Size.y / 2;
dx += g_DesignSettings.m_TrackClearence + g_GridRoutingSize;
dy += g_DesignSettings.m_TrackClearence + g_GridRoutingSize;
......@@ -580,7 +630,7 @@ bool WinEDA_PcbFrame::Genere_Pad_Connexion( wxDC* DC, int layer )
pt_track = new SEGZONE( m_Pcb );
pt_track->SetLayer( layer );
pt_track->m_Width = g_DesignSettings.m_CurrentTrackWidth;
pt_track->m_Width = g_DesignSettings.m_CurrentTrackWidth;
pt_track->SetNet( g_HightLigth_NetCode );
pt_track->start = pt_pad;
pt_track->m_Start.x = cX; pt_track->m_Start.y = cY;
......@@ -591,7 +641,7 @@ bool WinEDA_PcbFrame::Genere_Pad_Connexion( wxDC* DC, int layer )
/* Test if the segment is allowed */
if( BAD_DRC==m_drc->DrcBlind( pt_track, m_Pcb->m_Track ) )
{
delete pt_track;
delete pt_track;
continue;
}
......@@ -599,7 +649,7 @@ bool WinEDA_PcbFrame::Genere_Pad_Connexion( wxDC* DC, int layer )
loctrack = Locate_Zone( m_Pcb->m_Zone, pt_track->m_End, layer );
if( (loctrack == NULL) || (loctrack->m_TimeStamp != s_TimeStamp) )
{
delete pt_track;
delete pt_track;
continue;
}
......
......@@ -34,56 +34,58 @@ using namespace std;
#include "protos.h"
/* Imported functions */
void Build_Zone( WinEDA_PcbFrame* frame, wxDC* DC, int net_code,
bool Zone_Exclude_Pads, bool Zone_Create_Thermal_Relief );
/* Local functions */
// Outile creation:
static void Abort_Zone_Create_Outline( WinEDA_DrawPanel* Panel, wxDC* DC );
static void Show_New_Zone_Edge_While_Move_Mouse( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
// Corner moving
static void Abort_Zone_Move_Corner( WinEDA_DrawPanel* Panel, wxDC* DC );
static void Show_Zone_Corner_While_Move_Mouse( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
/* Local variables */
static bool Zone_45_Only = FALSE;
static bool Zone_Exclude_Pads = TRUE;
static bool s_Zone_Create_Thermal_Relief = TRUE;
static int s_Zone_Layer; // Layer used to create the current zone
static int s_Zone_Hatching; // Option to show the zone area (outlines only, short hatches or full hatches
static int s_NetcodeSelection; // Net code selection for the current zone
static wxPoint s_CornerInitialPosition; // Used to abort a move corner command
static bool s_CornerIsNew; // Used to abort a move corner command (if it is a new corner, it must be deleted)
static bool Zone_45_Only = FALSE;
static ZONE_CONTAINER::m_PadInZone s_Zone_Pad_Options = ZONE_CONTAINER::THERMAL_PAD;
static int s_Zone_Layer; // Layer used to create the current zone
static int s_Zone_Hatching; // Option to show the zone area (outlines only, short hatches or full hatches
static int s_NetcodeSelection; // Net code selection for the current zone
static wxPoint s_CornerInitialPosition; // Used to abort a move corner command
static bool s_CornerIsNew; // Used to abort a move corner command (if it is a new corner, it must be deleted)
// key used to store net sort option in config file :
#define ZONE_NET_SORT_OPTION_KEY wxT("Zone_NetSort_Opt")
#define ZONE_NET_SORT_OPTION_KEY wxT( "Zone_NetSort_Opt" )
enum zone_cmd {
ZONE_ABORT,
ZONE_OK
ZONE_ABORT,
ZONE_OK
};
#include "dialog_zones_by_polygon.cpp"
/*****************************************************************************/
void WinEDA_PcbFrame::Delete_Zone( wxDC* DC, SEGZONE* aZone, long aTimestamp )
/******************************************************************************/
/**********************************************************/
void WinEDA_PcbFrame::Delete_Zone( wxDC* DC, SEGZONE* aZone )
/**********************************************************/
/* Remove the zone which include the segment aZone.
/** Function Delete_Zone
* Remove the zone which include the segment aZone, or the zone which have the given time stamp.
* A zone is a group of segments which have the same TimeStamp
* @param DC = current Device Context (can be NULL)
* @param aZone = zone segment within the zone to delete. Can be NULL
* @param aTimestamp = Timestamp for the zone to delete, used if aZone == NULL
*/
{
if( aZone == NULL )
return;
int nb_segm = 0;
bool modify = FALSE;
unsigned long TimeStamp;
int nb_segm = 0;
bool modify = FALSE;
unsigned long TimeStamp = aZone->m_TimeStamp; // Save reference time stamp (aZone will be deleted)
if( aZone == NULL )
TimeStamp = aTimestamp;
else
TimeStamp = aZone->m_TimeStamp; // Save reference time stamp (aZone will be deleted)
SEGZONE* next;
SEGZONE* next;
for( SEGZONE* zone = m_Pcb->m_Zone; zone != NULL; zone = next )
{
next = zone->Next();
......@@ -92,7 +94,8 @@ void WinEDA_PcbFrame::Delete_Zone( wxDC* DC, SEGZONE* aZone )
modify = TRUE;
/* Erase segment from screen */
Trace_Une_Piste( DrawPanel, DC, zone, nb_segm, GR_XOR );
if( DC )
Trace_Une_Piste( DrawPanel, DC, zone, nb_segm, GR_XOR );
/* remove item from linked list and free memory */
zone->DeleteStructure();
}
......@@ -109,7 +112,10 @@ void WinEDA_PcbFrame::Delete_Zone( wxDC* DC, SEGZONE* aZone )
/*****************************************************************************/
EDGE_ZONE* WinEDA_PcbFrame::Del_SegmEdgeZone( wxDC* DC, EDGE_ZONE* edge_zone )
/*****************************************************************************/
/* Routine d'effacement du segment de limite zone en cours de trace */
/* Used only while creating a new zonz outline
* Remove and delete the current outline segment in progress
*/
{
EDGE_ZONE* segm;
......@@ -151,7 +157,7 @@ static void Abort_Zone_Create_Outline( WinEDA_DrawPanel* Panel, wxDC* DC )
/**
* Function Abort_Zone_Create_Outline
* cancels the Begin_Zone state if at least one EDGE_ZONE has been created.
* cancels the Begin_Zone command if at least one EDGE_ZONE has been created.
*/
{
WinEDA_PcbFrame* pcbframe = (WinEDA_PcbFrame*) Panel->m_Parent;
......@@ -181,7 +187,7 @@ void WinEDA_BasePcbFrame::DelLimitesZone( wxDC* DC, bool Redraw )
if( m_Pcb->m_CurrentLimitZone == NULL )
return;
// erase the old zone border, one segment at a time
// erase the old zone outline, one segment at a time
for( segment = m_Pcb->m_CurrentLimitZone; segment; segment = next )
{
next = segment->Next();
......@@ -197,104 +203,111 @@ void WinEDA_BasePcbFrame::DelLimitesZone( wxDC* DC, bool Redraw )
SetCurItem( NULL );
}
/*******************************************************************************************************/
void WinEDA_PcbFrame::Start_Move_Zone_Corner( wxDC* DC , ZONE_CONTAINER * zone_container,
int corner_id, bool IsNewCorner )
void WinEDA_PcbFrame::Start_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_container,
int corner_id, bool IsNewCorner )
/*******************************************************************************************************/
/**
* Function Start_Move_Zone_Corner
* Initialise parametres to move an existing corner of a zone.
* if IsNewCorner is true, the Abort_Zone_Move_Corner will remove this corner, if called
*/
{
/* Show the Net */
if( (g_HightLigth_NetCode > 0) && (g_HightLigth_NetCode != s_NetcodeSelection) )
{
Hight_Light( DC ); // Remove old hightlight selection
}
g_HightLigth_NetCode = s_NetcodeSelection;
if ( ! g_HightLigt_Status )
Hight_Light( DC );
zone_container->m_Flags = IN_EDIT;
DrawPanel->ManageCurseur = Show_Zone_Corner_While_Move_Mouse;
DrawPanel->ForceCloseManageCurseur = Abort_Zone_Move_Corner;
s_CornerInitialPosition.x = zone_container->GetX(corner_id);
s_CornerInitialPosition.y = zone_container->GetY(corner_id);
s_CornerIsNew = IsNewCorner;
/* Show the Net */
if( (g_HightLigth_NetCode > 0) && (g_HightLigth_NetCode != s_NetcodeSelection) )
{
Hight_Light( DC ); // Remove old hightlight selection
}
g_HightLigth_NetCode = s_NetcodeSelection;
if( !g_HightLigt_Status )
Hight_Light( DC );
zone_container->m_Flags = IN_EDIT;
DrawPanel->ManageCurseur = Show_Zone_Corner_While_Move_Mouse;
DrawPanel->ForceCloseManageCurseur = Abort_Zone_Move_Corner;
s_CornerInitialPosition.x = zone_container->GetX( corner_id );
s_CornerInitialPosition.y = zone_container->GetY( corner_id );
s_CornerIsNew = IsNewCorner;
}
/***************************************************************************************/
void WinEDA_PcbFrame::End_Move_Zone_Corner( wxDC* DC , ZONE_CONTAINER * zone_container )
void WinEDA_PcbFrame::End_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_container )
/****************************************************************************************/
/**
* Function End_Move_Zone_Corner
* Terminates a move corner in a zone outline
*/
{
zone_container->m_Flags = 0;
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
zone_container->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR);
zone_container->m_Flags = 0;
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
zone_container->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
GetScreen()->SetModify();
}
/**************************************************************/
void Abort_Zone_Move_Corner( WinEDA_DrawPanel* Panel, wxDC* DC )
/**************************************************************/
/**
* Function Abort_Zone_Move_Corner
* cancels the Begin_Zone state if at least one EDGE_ZONE has been created.
*/
{
WinEDA_PcbFrame* pcbframe = (WinEDA_PcbFrame*) Panel->m_Parent;
ZONE_CONTAINER* zone_container = (ZONE_CONTAINER*) pcbframe->GetCurItem();
zone_container->Draw(Panel, DC, wxPoint(0,0), GR_XOR);
if ( s_CornerIsNew )
{
zone_container->DeleteCorner( zone_container->m_CornerSelection );
}
else
{
wxPoint pos = s_CornerInitialPosition;
zone_container->MoveCorner( zone_container->m_CornerSelection, pos.x, pos.y );
}
zone_container->Draw(Panel, DC, wxPoint(0,0), GR_XOR);
ZONE_CONTAINER* zone_container = (ZONE_CONTAINER*) pcbframe->GetCurItem();
zone_container->Draw( Panel, DC, wxPoint( 0, 0 ), GR_XOR );
if( s_CornerIsNew )
{
zone_container->DeleteCorner( zone_container->m_CornerSelection );
}
else
{
wxPoint pos = s_CornerInitialPosition;
zone_container->MoveCorner( zone_container->m_CornerSelection, pos.x, pos.y );
}
zone_container->Draw( Panel, DC, wxPoint( 0, 0 ), GR_XOR );
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
pcbframe->SetCurItem( NULL );
zone_container->m_Flags = 0;
zone_container->m_Flags = 0;
}
/**************************************************************************************/
void Show_Zone_Corner_While_Move_Mouse( WinEDA_DrawPanel* Panel, wxDC* DC, bool erase )
/**************************************************************************************/
/* Redraws the zone outline when moving a corner according to the cursor position
*/
{
WinEDA_PcbFrame* pcbframe = (WinEDA_PcbFrame*) Panel->m_Parent;
ZONE_CONTAINER* zone_container = (ZONE_CONTAINER*) pcbframe->GetCurItem();
ZONE_CONTAINER* zone_container = (ZONE_CONTAINER*) pcbframe->GetCurItem();
// if( erase ) /* Undraw edge in old position*/
{
zone_container->Draw(Panel, DC, wxPoint(0,0), GR_XOR);
zone_container->Draw( Panel, DC, wxPoint( 0, 0 ), GR_XOR );
}
wxPoint pos = pcbframe->GetScreen()->m_Curseur;
wxPoint pos = pcbframe->GetScreen()->m_Curseur;
zone_container->MoveCorner( zone_container->m_CornerSelection, pos.x, pos.y );
zone_container->Draw(Panel, DC, wxPoint(0,0), GR_XOR);
zone_container->Draw( Panel, DC, wxPoint( 0, 0 ), GR_XOR );
}
/*************************************************/
EDGE_ZONE* WinEDA_PcbFrame::Begin_Zone( wxDC* DC )
/*************************************************/
/**
* Function Begin_Zone
* either initializes the first segment of a new zone, or adds an
......@@ -305,35 +318,35 @@ EDGE_ZONE* WinEDA_PcbFrame::Begin_Zone( wxDC* DC )
EDGE_ZONE* newedge = NULL;
oldedge = m_Pcb->m_CurrentLimitZone;
if( m_Pcb->m_CurrentLimitZone == NULL ) /* Start a new contour: init zone params (net and layer) */
{
DrawPanel->m_IgnoreMouseEvents = TRUE;
WinEDA_ZoneFrame* frame = new WinEDA_ZoneFrame( this );
int diag = frame->ShowModal();
frame->Destroy();
DrawPanel->MouseToCursorSchema();
DrawPanel->m_IgnoreMouseEvents = FALSE;
if( diag == ZONE_ABORT )
return NULL;
GetScreen()->m_Active_Layer = s_Zone_Layer;
/* Show the Net */
if( (g_HightLigth_NetCode > 0) && (g_HightLigth_NetCode != s_NetcodeSelection) )
{
Hight_Light( DC ); // Remove old hightlight selection
}
g_HightLigth_NetCode = s_NetcodeSelection;
if ( ! g_HightLigt_Status )
Hight_Light( DC );
}
{
DrawPanel->m_IgnoreMouseEvents = TRUE;
WinEDA_ZoneFrame* frame = new WinEDA_ZoneFrame( this );
int diag = frame->ShowModal();
frame->Destroy();
DrawPanel->MouseToCursorSchema();
DrawPanel->m_IgnoreMouseEvents = FALSE;
if( diag == ZONE_ABORT )
return NULL;
GetScreen()->m_Active_Layer = s_Zone_Layer;
/* Show the Net */
if( (g_HightLigth_NetCode > 0) && (g_HightLigth_NetCode != s_NetcodeSelection) )
{
Hight_Light( DC ); // Remove old hightlight selection
}
g_HightLigth_NetCode = s_NetcodeSelection;
if( !g_HightLigt_Status )
Hight_Light( DC );
}
// if first segment
if( (m_Pcb->m_CurrentLimitZone == NULL ) /* debut reel du trace */
if( (m_Pcb->m_CurrentLimitZone == NULL ) /* Initial startt of a new outline */
|| (DrawPanel->ManageCurseur == NULL) ) /* reprise d'un trace complementaire */
{
newedge = new EDGE_ZONE( m_Pcb );
......@@ -354,7 +367,8 @@ EDGE_ZONE* WinEDA_PcbFrame::Begin_Zone( wxDC* DC )
}
// edge in progress:
else
{ /* edge in progress : the ending point coordinate was set by Show_New_Zone_Edge_While_Move_Mouse */
{
/* edge in progress : the ending point coordinate was set by Show_New_Zone_Edge_While_Move_Mouse */
if( oldedge->m_Start != oldedge->m_End )
{
oldedge->m_Flags &= ~(IS_NEW | IS_MOVED);
......@@ -379,9 +393,9 @@ EDGE_ZONE* WinEDA_PcbFrame::Begin_Zone( wxDC* DC )
void WinEDA_PcbFrame::End_Zone( wxDC* DC )
/*********************************************/
/*
* Terminates an edge zone creation
* Close the current edge zone considered as a polygon
/** Function End_Zone
* Terminates a zone outline creation
* Close the current zone outline considered as a polygon
* put it in the main list m_Pcb->m_ZoneDescriptorList (a vector<ZONE_CONTAINER*>)
*/
{
......@@ -393,7 +407,7 @@ void WinEDA_PcbFrame::End_Zone( wxDC* DC )
/* The last segment is a stub: its lenght is 0.
* Use it to close the polygon by setting its ending point coordinate = start point of first segment
*/
*/
edge = m_Pcb->m_CurrentLimitZone;
edge->m_Flags &= ~(IS_NEW | IS_MOVED);
......@@ -416,38 +430,42 @@ void WinEDA_PcbFrame::End_Zone( wxDC* DC )
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
/* Put edges in list */
ZONE_CONTAINER * polygon = new ZONE_CONTAINER( m_Pcb );
polygon->SetLayer( GetScreen()->m_Active_Layer );
polygon->SetNet( g_HightLigth_NetCode );
polygon->m_TimeStamp = GetTimeStamp();
EQUIPOT* net = m_Pcb->FindNet( g_HightLigth_NetCode );
if ( net ) polygon->m_Netname = net->m_Netname;
/* Put edges in list */
ZONE_CONTAINER* polygon = new ZONE_CONTAINER( m_Pcb );
polygon->SetLayer( GetScreen()->m_Active_Layer );
polygon->SetNet( g_HightLigth_NetCode );
polygon->m_TimeStamp = GetTimeStamp();
EQUIPOT* net = m_Pcb->FindNet( g_HightLigth_NetCode );
if( net )
polygon->m_Netname = net->m_Netname;
edge = m_Pcb->m_CurrentLimitZone;
polygon->Start( GetScreen()->m_Active_Layer, 0, NULL,
edge->m_Start.x, edge->m_Start.y,
s_Zone_Hatching );
polygon->Start( GetScreen()->m_Active_Layer, 0, NULL,
edge->m_Start.x, edge->m_Start.y,
s_Zone_Hatching );
edge = edge->Next();
while( edge )
{
polygon->AppendCorner( edge->m_Start.x, edge->m_Start.y );
while( edge )
{
polygon->AppendCorner( edge->m_Start.x, edge->m_Start.y );
edge = edge->Next();
}
polygon->Close(); // Close the current corner list
polygon->Hatch();
m_Pcb->m_ZoneDescriptorList.push_back(polygon);
/* Remove the current temporary list */
}
polygon->Close(); // Close the current corner list
polygon->SetHatch( s_Zone_Hatching );
polygon->m_PadOption = s_Zone_Pad_Options;
polygon->m_ZoneClearance = g_DesignSettings.m_ZoneClearence;
polygon->m_GridFillValue = g_GridRoutingSize;
m_Pcb->m_ZoneDescriptorList.push_back( polygon );
/* Remove the current temporary list */
DelLimitesZone( DC, TRUE );
/* Redraw the real edge zone */
polygon->CPolyLine::Draw( ); // Build the line list
polygon->Draw( DrawPanel, DC, wxPoint(0,0), GR_OR );
GetScreen()->SetModify();
/* Redraw the real edge zone */
polygon->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
GetScreen()->SetModify();
}
......@@ -503,8 +521,9 @@ static void Show_New_Zone_Edge_While_Move_Mouse( WinEDA_DrawPanel* panel, wxDC*
/***********************************************************************************/
void WinEDA_PcbFrame::Edit_Zone_Params( wxDC* DC , ZONE_CONTAINER * zone_container )
void WinEDA_PcbFrame::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container )
/***********************************************************************************/
/**
* Function Edit_Zone_Params
* Edit params (layer, clearance, ...) for a zone outline
......@@ -521,55 +540,71 @@ void WinEDA_PcbFrame::Edit_Zone_Params( wxDC* DC , ZONE_CONTAINER * zone_contain
if( diag == ZONE_ABORT )
return;
zone_container->Draw( DrawPanel, DC, wxPoint(0,0), GR_XOR );
zone_container->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
zone_container->SetLayer( s_Zone_Layer );
zone_container->SetNet( s_NetcodeSelection );
EQUIPOT* net = m_Pcb->FindNet( s_NetcodeSelection );
if ( net ) zone_container->m_Netname = net->m_Netname;
zone_container->SetHatch(s_Zone_Hatching);
zone_container->SetLayer( s_Zone_Layer );
zone_container->SetNet( s_NetcodeSelection );
EQUIPOT* net = m_Pcb->FindNet( s_NetcodeSelection );
if( net )
zone_container->m_Netname = net->m_Netname;
zone_container->SetHatch( s_Zone_Hatching );
zone_container->m_PadOption = s_Zone_Pad_Options;
zone_container->m_ZoneClearance = g_DesignSettings.m_ZoneClearence;
zone_container->m_GridFillValue = g_GridRoutingSize;
zone_container->Draw( DrawPanel, DC, wxPoint(0,0), GR_OR );
zone_container->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
GetScreen()->SetModify();
}
/***************************************************************************/
void WinEDA_PcbFrame::Fill_Zone( wxDC* DC, ZONE_CONTAINER * zone_container )
/***************************************************************************/
/***************************************************************************************/
int WinEDA_PcbFrame::Fill_Zone( wxDC* DC, ZONE_CONTAINER* zone_container, bool verbose )
/***************************************************************************************/
/** Function Fill_Zone()
* Fillst the zone defined in zone_container
* Calculate the zone filling for the outline zone_container
* The zone outline is a frontier, and can be complex (with holes)
* The filling starts from starting points like pads, tracks.
* If exists the old filling is removed
* @param DC = current Device Context
* @param zone_container = zone to fill
* @param verbose = true to show error messages
* @return error level (0 = no error)
*/
{
wxPoint ZoneStartFill;
wxString msg;
MsgPanel->EraseMsgBox();
if( m_Pcb->ComputeBoundaryBox() == FALSE )
{
DisplayError( this, wxT( "Board is empty!" ), 10 );
return;
if( verbose )
DisplayError( this, wxT( "Board is empty!" ), 10 );
return -1;
}
/* Show the Net */
s_NetcodeSelection = zone_container->GetNet();
if( (g_HightLigth_NetCode > 0) && (g_HightLigth_NetCode != s_NetcodeSelection) )
{
Hight_Light( DC ); // Remove old hightlight selection
}
Hight_Light( DC ); // Remove old hightlight selection
}
g_HightLigth_NetCode = s_NetcodeSelection;
if ( ! g_HightLigt_Status )
if( !g_HightLigt_Status )
Hight_Light( DC );
if( g_HightLigth_NetCode > 0 )
{
EQUIPOT* net = m_Pcb->FindNet( g_HightLigth_NetCode );
EQUIPOT* net = m_Pcb->FindNet( g_HightLigth_NetCode );
if( net == NULL )
{
if( g_HightLigth_NetCode > 0 )
{
DisplayError( this, wxT( "Unable to find Net name" ) );
return;
}
{
if( verbose )
DisplayError( this, wxT( "Unable to find Net name" ) );
return -2;
}
}
else
msg = net->m_Netname;
......@@ -579,6 +614,40 @@ void WinEDA_PcbFrame::Fill_Zone( wxDC* DC, ZONE_CONTAINER * zone_container )
Affiche_1_Parametre( this, 22, _( "NetName" ), msg, RED );
Build_Zone( this, DC, g_HightLigth_NetCode, Zone_Exclude_Pads, s_Zone_Create_Thermal_Relief );
GetScreen()->SetModify();
zone_container->m_PadOption = s_Zone_Pad_Options;
zone_container->m_ZoneClearance = g_DesignSettings.m_ZoneClearence;
zone_container->m_GridFillValue = g_GridRoutingSize;
int error_level = zone_container->Fill_Zone( this, DC, verbose );
GetScreen()->SetModify();
return error_level;
}
/************************************************************/
int WinEDA_PcbFrame::Fill_All_Zones( wxDC* DC, bool verbose )
/************************************************************/
/** Function Fill_All_Zones()
* Fill all zones on the board
* The old fillings are removed
* @param frame = reference to the main frame
* @param DC = current Device Context
* @param verbose = true to show error messages
* @return error level (0 = no error)
*/
{
ZONE_CONTAINER* zone_container;
int error_level = 0;
for( unsigned ii = 0; ii < m_Pcb->m_ZoneDescriptorList.size(); ii++ )
{
zone_container = m_Pcb->m_ZoneDescriptorList[ii];
error_level = Fill_Zone( DC, zone_container, verbose );
if( error_level && ! verbose )
break;
}
return error_level;
}
......@@ -993,7 +993,7 @@ void CPolyLine::StartDraggingToMoveCorner( CDC * pDC, int ic, int x, int y )
// get indexes for preceding and following corners
int pre_c, post_c;
int poly_side_style1, poly_side_style2;
int style1, style2;
int style1 = DSS_STRAIGHT, style2 = DSS_STRAIGHT;
if( ic == istart )
{
pre_c = iend;
......@@ -1057,7 +1057,7 @@ void CPolyLine::HighlightSide( int is )
if( !GetClosed() && is >= (int)(corner.size()-1) )
return;
int style;
int style = DL_LINE;
if( side_style[is] == CPolyLine::STRAIGHT )
style = DL_LINE;
else if( side_style[is] == CPolyLine::ARC_CW )
......@@ -1319,7 +1319,7 @@ void CPolyLine::Hatch()
min_a = (int)(min_y - slope*min_x);
}
min_a = (min_a/spacing)*spacing;
int offset;
int offset = 0;
if( layer < (LAY_TOP_COPPER+2) )
offset = 0;
else if( layer < (LAY_TOP_COPPER+4) )
......@@ -1400,7 +1400,7 @@ void CPolyLine::Hatch()
for( int istart=0; istart<(npts-1); istart++ )
{
int max_x = INT_MIN;
int imax;
int imax = INT_MIN;
for( int i=istart; i<npts; i++ )
{
if( xx[i] > max_x )
......
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