2007-12-19 16:44:53 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2007-12-19 16:44:53 +00:00
|
|
|
// Name: zones_by_polygon.cpp
|
2008-01-10 20:53:41 +00:00
|
|
|
// Licence: GPL License
|
2007-12-19 16:44:53 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
#include "fctsys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2007-12-29 19:15:58 +00:00
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
2007-12-29 19:15:58 +00:00
|
|
|
#include "pcbnew.h"
|
2008-10-23 10:26:06 +00:00
|
|
|
#include "zones.h"
|
2008-01-04 12:27:16 +00:00
|
|
|
#include "id.h"
|
2007-12-29 19:15:58 +00:00
|
|
|
#include "protos.h"
|
2007-12-19 16:44:53 +00:00
|
|
|
|
2009-05-21 17:42:42 +00:00
|
|
|
using namespace std;
|
|
|
|
|
2008-02-04 11:26:56 +00:00
|
|
|
bool verbose = false; // false if zone outline diags must not be shown
|
2007-12-30 18:20:51 +00:00
|
|
|
|
2008-01-10 20:53:41 +00:00
|
|
|
// Outline creation:
|
2007-12-29 19:15:58 +00:00
|
|
|
static void Abort_Zone_Create_Outline( WinEDA_DrawPanel* Panel, wxDC* DC );
|
2008-02-01 21:30:45 +00:00
|
|
|
static void Show_New_Edge_While_Move_Mouse( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
|
2007-12-30 18:20:51 +00:00
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
// Corner moving
|
2008-01-16 20:37:50 +00:00
|
|
|
static void Abort_Zone_Move_Corner_Or_Outlines( WinEDA_DrawPanel* Panel, wxDC* DC );
|
2008-01-31 20:53:44 +00:00
|
|
|
static void Show_Zone_Corner_Or_Outline_While_Move_Mouse( WinEDA_DrawPanel* panel,
|
|
|
|
wxDC* DC,
|
|
|
|
bool erase );
|
2007-12-19 16:44:53 +00:00
|
|
|
|
|
|
|
/* Local variables */
|
2008-09-26 19:51:36 +00:00
|
|
|
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 s_AddCutoutToCurrentZone; // if true, the next outline will be addes to s_CurrentZone
|
|
|
|
static ZONE_CONTAINER* s_CurrentZone; // if != NULL, these ZONE_CONTAINER params will be used for the next zone
|
|
|
|
static wxPoint s_CursorLastPosition; // in move zone outline, last cursor position. Used to calculate the move vector
|
2007-12-19 16:44:53 +00:00
|
|
|
|
2008-10-09 19:13:25 +00:00
|
|
|
#include "dialog_copper_zones.h"
|
2007-12-19 16:44:53 +00:00
|
|
|
|
2008-01-04 12:27:16 +00:00
|
|
|
/**********************************************************************************/
|
|
|
|
void WinEDA_PcbFrame::Add_Similar_Zone( 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
|
|
|
|
*/
|
|
|
|
{
|
2008-10-17 06:17:48 +00:00
|
|
|
if ( zone_container == NULL )
|
|
|
|
return;
|
2008-01-04 12:27:16 +00:00
|
|
|
s_AddCutoutToCurrentZone = false;
|
|
|
|
s_CurrentZone = zone_container;
|
2008-10-19 18:18:45 +00:00
|
|
|
|
|
|
|
/* set zones setup to the current zone */
|
2008-10-23 10:26:06 +00:00
|
|
|
g_Zone_Default_Setting.ImportSetting( *zone_container );
|
2008-10-19 18:18:45 +00:00
|
|
|
|
|
|
|
// Use the general event handle to set others params (like toolbar) */
|
2008-01-04 12:27:16 +00:00
|
|
|
wxCommandEvent evt;
|
|
|
|
evt.SetId( ID_PCB_ZONES_BUTT );
|
|
|
|
Process_Special_Functions( evt );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************************/
|
|
|
|
void WinEDA_PcbFrame::Add_Zone_Cutout( wxDC* DC, ZONE_CONTAINER* zone_container )
|
|
|
|
/**********************************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Add_Zone_Cutout
|
|
|
|
* Add a cutout zone to a given zone outline
|
|
|
|
* @param DC = current Device Context
|
|
|
|
* @param zone_container = parent zone outline
|
|
|
|
*/
|
|
|
|
{
|
2008-10-17 06:17:48 +00:00
|
|
|
if ( zone_container == NULL )
|
|
|
|
return;
|
2008-01-04 12:27:16 +00:00
|
|
|
s_AddCutoutToCurrentZone = true;
|
|
|
|
s_CurrentZone = zone_container;
|
2008-10-19 18:18:45 +00:00
|
|
|
|
|
|
|
/* set zones setup to the current zone */
|
2008-10-23 10:26:06 +00:00
|
|
|
g_Zone_Default_Setting.ImportSetting( *zone_container );
|
2008-10-19 18:18:45 +00:00
|
|
|
|
|
|
|
// Use the general event handle to set others params (like toolbar) */
|
2008-01-04 12:27:16 +00:00
|
|
|
wxCommandEvent evt;
|
|
|
|
evt.SetId( ID_PCB_ZONES_BUTT );
|
|
|
|
Process_Special_Functions( evt );
|
|
|
|
}
|
|
|
|
|
2007-12-19 16:44:53 +00:00
|
|
|
|
2008-01-16 20:37:50 +00:00
|
|
|
/**********************************************************************************/
|
2008-01-05 13:37:51 +00:00
|
|
|
void WinEDA_PcbFrame::Delete_Zone_Fill( wxDC* DC, SEGZONE* aZone, long aTimestamp )
|
2008-01-16 20:37:50 +00:00
|
|
|
/**********************************************************************************/
|
2007-12-19 16:44:53 +00:00
|
|
|
|
2008-01-05 13:37:51 +00:00
|
|
|
/** Function Delete_Zone_Fill
|
|
|
|
* Remove the zone fillig which include the segment aZone, or the zone which have the given time stamp.
|
2007-12-19 16:44:53 +00:00
|
|
|
* A zone is a group of segments which have the same TimeStamp
|
2007-12-30 18:20:51 +00:00
|
|
|
* @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
|
2007-12-19 16:44:53 +00:00
|
|
|
*/
|
|
|
|
{
|
2008-01-01 11:46:47 +00:00
|
|
|
bool modify = false;
|
2007-12-30 18:20:51 +00:00
|
|
|
unsigned long TimeStamp;
|
2007-12-19 16:44:53 +00:00
|
|
|
|
2007-12-30 18:20:51 +00:00
|
|
|
if( aZone == NULL )
|
|
|
|
TimeStamp = aTimestamp;
|
|
|
|
else
|
|
|
|
TimeStamp = aZone->m_TimeStamp; // Save reference time stamp (aZone will be deleted)
|
2007-12-19 16:44:53 +00:00
|
|
|
|
2007-12-30 18:20:51 +00:00
|
|
|
SEGZONE* next;
|
2009-01-05 05:21:35 +00:00
|
|
|
for( SEGZONE* zone = GetBoard()->m_Zone; zone != NULL; zone = next )
|
2007-12-19 16:44:53 +00:00
|
|
|
{
|
|
|
|
next = zone->Next();
|
|
|
|
if( zone->m_TimeStamp == TimeStamp )
|
|
|
|
{
|
|
|
|
modify = TRUE;
|
|
|
|
/* remove item from linked list and free memory */
|
|
|
|
zone->DeleteStructure();
|
|
|
|
}
|
|
|
|
}
|
2009-04-17 08:51:02 +00:00
|
|
|
|
2009-02-19 14:57:15 +00:00
|
|
|
// Now delete the outlines of the corresponding copper areas
|
|
|
|
for( int ii = 0; ii < GetBoard()->GetAreaCount(); ii++ )
|
|
|
|
{
|
|
|
|
ZONE_CONTAINER* zone = GetBoard()->GetArea( ii );
|
|
|
|
if( zone->m_TimeStamp == TimeStamp )
|
2009-02-24 13:55:13 +00:00
|
|
|
{
|
|
|
|
modify = TRUE;
|
2009-02-19 14:57:15 +00:00
|
|
|
zone->m_FilledPolysList.clear();
|
2009-02-24 13:55:13 +00:00
|
|
|
}
|
2009-02-19 14:57:15 +00:00
|
|
|
}
|
2007-12-19 16:44:53 +00:00
|
|
|
|
|
|
|
if( modify )
|
|
|
|
{
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
GetScreen()->SetRefreshReq();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
/*******************************************************/
|
|
|
|
int WinEDA_PcbFrame::Delete_LastCreatedCorner( wxDC* DC )
|
2008-02-01 11:01:32 +00:00
|
|
|
/*******************************************************/
|
2007-12-30 18:20:51 +00:00
|
|
|
|
2008-02-01 11:01:32 +00:00
|
|
|
/** Used **only** while creating a new zone outline
|
2007-12-30 18:20:51 +00:00
|
|
|
* Remove and delete the current outline segment in progress
|
2008-01-31 20:53:44 +00:00
|
|
|
* @return 0 if no corner in list, or corner number
|
|
|
|
* if no corner in list, close the outline creation
|
2007-12-30 18:20:51 +00:00
|
|
|
*/
|
2007-12-19 16:44:53 +00:00
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
ZONE_CONTAINER* zone = GetBoard()->m_CurrentZoneContour;
|
2007-12-19 16:44:53 +00:00
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
if( zone == NULL )
|
|
|
|
return 0;
|
2007-12-19 16:44:53 +00:00
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
if( zone->GetNumCorners() == 0 )
|
|
|
|
return 0;
|
2007-12-19 16:44:53 +00:00
|
|
|
|
2008-02-01 11:01:32 +00:00
|
|
|
zone->DrawWhileCreateOutline( DrawPanel, DC, GR_XOR );
|
2007-12-19 16:44:53 +00:00
|
|
|
|
2008-02-01 11:01:32 +00:00
|
|
|
if( zone->GetNumCorners() > 2 )
|
2007-12-19 16:44:53 +00:00
|
|
|
{
|
2008-01-31 20:53:44 +00:00
|
|
|
zone->m_Poly->DeleteCorner( zone->GetNumCorners() - 1 );
|
2008-02-01 21:30:45 +00:00
|
|
|
if( DrawPanel->ManageCurseur )
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, false );
|
2007-12-19 16:44:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
|
|
|
SetCurItem( NULL );
|
2008-01-31 20:53:44 +00:00
|
|
|
zone->RemoveAllContours();
|
2008-02-01 21:30:45 +00:00
|
|
|
zone->m_Flags = 0;
|
2007-12-19 16:44:53 +00:00
|
|
|
}
|
2008-01-31 20:53:44 +00:00
|
|
|
return zone->GetNumCorners();
|
2007-12-19 16:44:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
static void Abort_Zone_Create_Outline( WinEDA_DrawPanel* Panel, wxDC* DC )
|
|
|
|
/*************************************************************************/
|
2007-12-19 16:44:53 +00:00
|
|
|
|
|
|
|
/**
|
2007-12-29 19:15:58 +00:00
|
|
|
* Function Abort_Zone_Create_Outline
|
2008-01-20 19:55:22 +00:00
|
|
|
* cancels the Begin_Zone command if at least one EDGE_ZONE was created.
|
2007-12-19 16:44:53 +00:00
|
|
|
*/
|
|
|
|
{
|
|
|
|
WinEDA_PcbFrame* pcbframe = (WinEDA_PcbFrame*) Panel->m_Parent;
|
2009-01-05 05:21:35 +00:00
|
|
|
ZONE_CONTAINER* zone = pcbframe->GetBoard()->m_CurrentZoneContour;
|
2007-12-19 16:44:53 +00:00
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
if( zone )
|
2007-12-19 16:44:53 +00:00
|
|
|
{
|
2008-01-31 20:53:44 +00:00
|
|
|
zone->DrawWhileCreateOutline( Panel, DC, GR_XOR );
|
|
|
|
zone->m_Flags = 0;
|
|
|
|
zone->RemoveAllContours();
|
2007-12-19 16:44:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Panel->ManageCurseur = NULL;
|
|
|
|
Panel->ForceCloseManageCurseur = NULL;
|
|
|
|
pcbframe->SetCurItem( NULL );
|
2008-01-04 12:27:16 +00:00
|
|
|
s_AddCutoutToCurrentZone = false;
|
|
|
|
s_CurrentZone = NULL;
|
2007-12-19 16:44:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
/*******************************************************************************************************/
|
2007-12-30 18:20:51 +00:00
|
|
|
void WinEDA_PcbFrame::Start_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_container,
|
|
|
|
int corner_id, bool IsNewCorner )
|
2007-12-29 19:15:58 +00:00
|
|
|
/*******************************************************************************************************/
|
2007-12-30 18:20:51 +00:00
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
/**
|
|
|
|
* Function Start_Move_Zone_Corner
|
|
|
|
* Initialise parametres to move an existing corner of a zone.
|
2008-01-16 20:37:50 +00:00
|
|
|
* if IsNewCorner is true, the Abort_Zone_Move_Corner_Or_Outlines will remove this corner, if called
|
2007-12-29 19:15:58 +00:00
|
|
|
*/
|
|
|
|
{
|
2008-09-26 19:51:36 +00:00
|
|
|
if( zone_container->IsOnCopperLayer() ) /* Show the Net */
|
2007-12-30 18:20:51 +00:00
|
|
|
{
|
2008-09-26 19:51:36 +00:00
|
|
|
if( g_HightLigt_Status && DC )
|
|
|
|
{
|
|
|
|
Hight_Light( DC ); // Remove old hightlight selection
|
|
|
|
}
|
2007-12-30 18:20:51 +00:00
|
|
|
|
2008-10-23 10:26:06 +00:00
|
|
|
g_HightLigth_NetCode = g_Zone_Default_Setting.m_NetcodeSelection = zone_container->GetNet();
|
2008-09-26 19:51:36 +00:00
|
|
|
if( DC )
|
|
|
|
Hight_Light( DC );
|
|
|
|
}
|
2007-12-30 18:20:51 +00:00
|
|
|
|
|
|
|
zone_container->m_Flags = IN_EDIT;
|
2008-01-16 20:37:50 +00:00
|
|
|
DrawPanel->ManageCurseur = Show_Zone_Corner_Or_Outline_While_Move_Mouse;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = Abort_Zone_Move_Corner_Or_Outlines;
|
2008-02-01 21:30:45 +00:00
|
|
|
s_CornerInitialPosition = zone_container->GetCornerPosition( corner_id );
|
2007-12-30 18:20:51 +00:00
|
|
|
s_CornerIsNew = IsNewCorner;
|
2008-01-04 12:27:16 +00:00
|
|
|
s_AddCutoutToCurrentZone = false;
|
|
|
|
s_CurrentZone = NULL;
|
2007-12-29 19:15:58 +00:00
|
|
|
}
|
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2008-02-01 21:30:45 +00:00
|
|
|
/**************************************************************************************/
|
|
|
|
void WinEDA_PcbFrame::Start_Move_Zone_Drag_Outline_Edge( wxDC* DC,
|
|
|
|
ZONE_CONTAINER* zone_container,
|
|
|
|
int corner_id )
|
|
|
|
/**************************************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Start_Move_Zone_Corner
|
|
|
|
* Prepares a drag edge for an existing zone outline,
|
|
|
|
*/
|
|
|
|
{
|
2008-09-26 19:51:36 +00:00
|
|
|
zone_container->m_Flags = IS_DRAGGED;
|
2008-04-01 05:21:50 +00:00
|
|
|
zone_container->m_CornerSelection = corner_id;
|
2008-02-01 21:30:45 +00:00
|
|
|
DrawPanel->ManageCurseur = Show_Zone_Corner_Or_Outline_While_Move_Mouse;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = Abort_Zone_Move_Corner_Or_Outlines;
|
2008-09-26 19:51:36 +00:00
|
|
|
s_CursorLastPosition = s_CornerInitialPosition = GetScreen()->m_Curseur;
|
2008-02-01 21:30:45 +00:00
|
|
|
s_AddCutoutToCurrentZone = false;
|
|
|
|
s_CurrentZone = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-16 20:37:50 +00:00
|
|
|
/*******************************************************************************************************/
|
|
|
|
void WinEDA_PcbFrame::Start_Move_Zone_Outlines( wxDC* DC, ZONE_CONTAINER* zone_container )
|
|
|
|
/*******************************************************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Start_Move_Zone_Outlines
|
|
|
|
* Initialise parametres to move an existing zone outlines.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
/* Show the Net */
|
2008-09-26 19:51:36 +00:00
|
|
|
if( zone_container->IsOnCopperLayer() ) /* Show the Net */
|
2008-01-16 20:37:50 +00:00
|
|
|
{
|
2008-09-26 19:51:36 +00:00
|
|
|
if( g_HightLigt_Status )
|
|
|
|
{
|
|
|
|
Hight_Light( DC ); // Remove old hightlight selection
|
|
|
|
}
|
2008-01-16 20:37:50 +00:00
|
|
|
|
2008-10-23 10:26:06 +00:00
|
|
|
g_HightLigth_NetCode = g_Zone_Default_Setting.m_NetcodeSelection = zone_container->GetNet();
|
2008-09-26 19:51:36 +00:00
|
|
|
Hight_Light( DC );
|
|
|
|
}
|
2008-01-16 20:37:50 +00:00
|
|
|
|
|
|
|
zone_container->m_Flags = IS_MOVED;
|
|
|
|
DrawPanel->ManageCurseur = Show_Zone_Corner_Or_Outline_While_Move_Mouse;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = Abort_Zone_Move_Corner_Or_Outlines;
|
2008-01-16 20:55:58 +00:00
|
|
|
s_CursorLastPosition = s_CornerInitialPosition = GetScreen()->m_Curseur;
|
2008-01-16 20:37:50 +00:00
|
|
|
s_CornerIsNew = false;
|
|
|
|
s_AddCutoutToCurrentZone = false;
|
|
|
|
s_CurrentZone = NULL;
|
|
|
|
}
|
|
|
|
|
2007-12-30 18:20:51 +00:00
|
|
|
|
2008-01-16 20:37:50 +00:00
|
|
|
/*************************************************************************************************/
|
|
|
|
void WinEDA_PcbFrame::End_Move_Zone_Corner_Or_Outlines( wxDC* DC, ZONE_CONTAINER* zone_container )
|
|
|
|
/*************************************************************************************************/
|
2007-12-30 18:20:51 +00:00
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
/**
|
2008-01-16 20:37:50 +00:00
|
|
|
* Function End_Move_Zone_Corner_Or_Outlines
|
|
|
|
* Terminates a move corner in a zone outline, or a move zone outlines
|
|
|
|
* @param DC = current Device Context (can be NULL)
|
|
|
|
* @param zone_container: the given zone
|
2007-12-29 19:15:58 +00:00
|
|
|
*/
|
|
|
|
{
|
2007-12-30 18:20:51 +00:00
|
|
|
zone_container->m_Flags = 0;
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
2008-01-31 20:53:44 +00:00
|
|
|
if( DC )
|
2008-04-01 05:21:50 +00:00
|
|
|
zone_container->Draw( DrawPanel, DC, GR_OR );
|
2007-12-30 18:20:51 +00:00
|
|
|
GetScreen()->SetModify();
|
2008-01-04 12:27:16 +00:00
|
|
|
s_AddCutoutToCurrentZone = false;
|
|
|
|
s_CurrentZone = NULL;
|
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
SetCurItem( NULL ); // This outline can be deleted when merging outlines
|
2008-01-04 12:27:16 +00:00
|
|
|
|
|
|
|
/* Combine zones if possible */
|
2008-01-31 20:53:44 +00:00
|
|
|
wxBusyCursor dummy;
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->AreaPolygonModified( zone_container, true, verbose );
|
2008-05-02 06:27:06 +00:00
|
|
|
DrawPanel->Refresh();
|
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
int ii = GetBoard()->GetAreaIndex( zone_container ); // test if zone_container exists
|
2008-01-31 20:53:44 +00:00
|
|
|
if( ii < 0 )
|
|
|
|
zone_container = NULL; // was removed by combining zones
|
2008-05-02 06:27:06 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
int error_count = GetBoard()->Test_Drc_Areas_Outlines_To_Areas_Outlines( zone_container, true );
|
2008-01-31 20:53:44 +00:00
|
|
|
if( error_count )
|
|
|
|
{
|
|
|
|
DisplayError( this, _( "Area: DRC outline error" ) );
|
|
|
|
}
|
2008-01-04 12:27:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************************/
|
2008-01-31 20:53:44 +00:00
|
|
|
void WinEDA_PcbFrame::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_container )
|
2008-01-04 12:27:16 +00:00
|
|
|
/*************************************************************************************/
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2008-01-04 12:27:16 +00:00
|
|
|
/**
|
2008-09-26 19:51:36 +00:00
|
|
|
* Function Remove_Zone_Corner
|
2008-01-04 12:27:16 +00:00
|
|
|
* Remove the currently selected corner in a zone outline
|
|
|
|
* the .m_CornerSelection is used as corner selection
|
2008-09-26 19:51:36 +00:00
|
|
|
* @param DC = Current deice context (can be NULL )
|
|
|
|
* @param zone_container = the zone that contains the selected corner
|
|
|
|
* the member .m_CornerSelection is used as selected corner
|
2008-01-04 12:27:16 +00:00
|
|
|
*/
|
|
|
|
{
|
2008-01-10 20:53:41 +00:00
|
|
|
GetScreen()->SetModify();
|
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
if( zone_container->m_Poly->GetNumCorners() <= 3 )
|
|
|
|
{
|
2008-05-02 05:16:35 +00:00
|
|
|
DrawPanel->PostDirtyRect( zone_container->GetBoundingBox() );
|
2008-09-26 19:51:36 +00:00
|
|
|
if( DC )
|
2008-11-28 20:10:05 +00:00
|
|
|
{ // Remove the full zone because this is no more an area
|
2008-09-26 19:51:36 +00:00
|
|
|
Delete_Zone_Fill( DC, NULL, zone_container->m_TimeStamp );
|
|
|
|
zone_container->DrawFilledArea( DrawPanel, DC, GR_XOR );
|
|
|
|
}
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->Delete( zone_container );
|
2008-01-31 20:53:44 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-01-04 12:27:16 +00:00
|
|
|
|
|
|
|
int layer = zone_container->GetLayer();
|
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
if( DC )
|
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->RedrawAreasOutlines( DrawPanel, DC, GR_XOR, layer );
|
|
|
|
GetBoard()->RedrawFilledAreas( DrawPanel, DC, GR_XOR, layer );
|
2008-09-26 19:51:36 +00:00
|
|
|
}
|
2008-01-31 20:53:44 +00:00
|
|
|
|
|
|
|
zone_container->m_Poly->DeleteCorner( zone_container->m_CornerSelection );
|
2008-01-04 12:27:16 +00:00
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
// modify zones outlines according to the new zone_container shape
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->AreaPolygonModified( zone_container, true, verbose );
|
2008-09-26 19:51:36 +00:00
|
|
|
if( DC )
|
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->RedrawAreasOutlines( DrawPanel, DC, GR_OR, layer );
|
|
|
|
GetBoard()->RedrawFilledAreas( DrawPanel, DC, GR_OR, layer );
|
2008-09-26 19:51:36 +00:00
|
|
|
}
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
int ii = GetBoard()->GetAreaIndex( zone_container ); // test if zone_container exists
|
2008-01-31 20:53:44 +00:00
|
|
|
if( ii < 0 )
|
|
|
|
zone_container = NULL; // zone_container does not exist anymaore, after combining zones
|
2009-01-05 05:21:35 +00:00
|
|
|
int error_count = GetBoard()->Test_Drc_Areas_Outlines_To_Areas_Outlines( zone_container, true );
|
2008-01-31 20:53:44 +00:00
|
|
|
if( error_count )
|
|
|
|
{
|
|
|
|
DisplayError( this, _( "Area: DRC outline error" ) );
|
|
|
|
}
|
2007-12-29 19:15:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-16 20:37:50 +00:00
|
|
|
/**************************************************************************/
|
|
|
|
void Abort_Zone_Move_Corner_Or_Outlines( WinEDA_DrawPanel* Panel, wxDC* DC )
|
|
|
|
/**************************************************************************/
|
2007-12-30 18:20:51 +00:00
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
/**
|
2008-01-16 20:37:50 +00:00
|
|
|
* Function Abort_Zone_Move_Corner_Or_Outlines
|
2007-12-29 19:15:58 +00:00
|
|
|
* cancels the Begin_Zone state if at least one EDGE_ZONE has been created.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
WinEDA_PcbFrame* pcbframe = (WinEDA_PcbFrame*) Panel->m_Parent;
|
2007-12-30 18:20:51 +00:00
|
|
|
ZONE_CONTAINER* zone_container = (ZONE_CONTAINER*) pcbframe->GetCurItem();
|
|
|
|
|
2008-05-02 06:27:06 +00:00
|
|
|
// zone_container->Draw( Panel, DC, GR_XOR );
|
2007-12-30 18:20:51 +00:00
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
if( zone_container->m_Flags == IS_MOVED )
|
|
|
|
{
|
|
|
|
wxPoint offset;
|
|
|
|
offset = s_CornerInitialPosition - s_CursorLastPosition;
|
|
|
|
zone_container->Move( offset );
|
|
|
|
}
|
2008-02-01 21:30:45 +00:00
|
|
|
else if( zone_container->m_Flags == IS_DRAGGED )
|
|
|
|
{
|
|
|
|
wxPoint offset;
|
|
|
|
offset = s_CornerInitialPosition - s_CursorLastPosition;
|
|
|
|
zone_container->MoveEdge( offset );
|
|
|
|
}
|
2008-01-31 20:53:44 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if( s_CornerIsNew )
|
|
|
|
{
|
|
|
|
zone_container->m_Poly->DeleteCorner( zone_container->m_CornerSelection );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxPoint pos = s_CornerInitialPosition;
|
|
|
|
zone_container->m_Poly->MoveCorner( zone_container->m_CornerSelection, pos.x, pos.y );
|
|
|
|
}
|
|
|
|
}
|
2008-05-02 06:27:06 +00:00
|
|
|
|
|
|
|
// zone_container->Draw( Panel, DC, GR_XOR );
|
|
|
|
Panel->Refresh();
|
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
|
|
|
|
Panel->ManageCurseur = NULL;
|
|
|
|
Panel->ForceCloseManageCurseur = NULL;
|
|
|
|
pcbframe->SetCurItem( NULL );
|
2008-01-04 12:27:16 +00:00
|
|
|
zone_container->m_Flags = 0;
|
|
|
|
s_AddCutoutToCurrentZone = false;
|
|
|
|
s_CurrentZone = NULL;
|
2007-12-29 19:15:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-16 20:37:50 +00:00
|
|
|
/*************************************************************************************************/
|
|
|
|
void Show_Zone_Corner_Or_Outline_While_Move_Mouse( WinEDA_DrawPanel* Panel, wxDC* DC, bool erase )
|
|
|
|
/*************************************************************************************************/
|
2007-12-30 18:20:51 +00:00
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
/* Redraws the zone outline when moving a corner according to the cursor position
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
WinEDA_PcbFrame* pcbframe = (WinEDA_PcbFrame*) Panel->m_Parent;
|
2008-02-01 21:30:45 +00:00
|
|
|
ZONE_CONTAINER* zone = (ZONE_CONTAINER*) pcbframe->GetCurItem();
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
if( erase ) /* Undraw edge in old position*/
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2008-04-01 05:21:50 +00:00
|
|
|
zone->Draw( Panel, DC, GR_XOR );
|
2007-12-29 19:15:58 +00:00
|
|
|
}
|
|
|
|
|
2007-12-30 18:20:51 +00:00
|
|
|
wxPoint pos = pcbframe->GetScreen()->m_Curseur;
|
2008-02-01 21:30:45 +00:00
|
|
|
if( zone->m_Flags == IS_MOVED )
|
2008-01-31 20:53:44 +00:00
|
|
|
{
|
|
|
|
wxPoint offset;
|
2008-02-01 21:30:45 +00:00
|
|
|
offset = pos - s_CursorLastPosition;
|
|
|
|
zone->Move( offset );
|
|
|
|
s_CursorLastPosition = pos;
|
|
|
|
}
|
|
|
|
else if( zone->m_Flags == IS_DRAGGED )
|
|
|
|
{
|
|
|
|
wxPoint offset;
|
|
|
|
offset = pos - s_CursorLastPosition;
|
|
|
|
zone->MoveEdge( offset );
|
2008-01-31 20:53:44 +00:00
|
|
|
s_CursorLastPosition = pos;
|
|
|
|
}
|
|
|
|
else
|
2008-02-01 21:30:45 +00:00
|
|
|
zone->m_Poly->MoveCorner( zone->m_CornerSelection, pos.x, pos.y );
|
2008-01-16 20:37:50 +00:00
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
zone->Draw( Panel, DC, GR_XOR );
|
2007-12-29 19:15:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************/
|
2008-01-31 20:53:44 +00:00
|
|
|
int WinEDA_PcbFrame::Begin_Zone( wxDC* DC )
|
2007-12-29 19:15:58 +00:00
|
|
|
/*************************************************/
|
2007-12-30 18:20:51 +00:00
|
|
|
|
2007-12-19 16:44:53 +00:00
|
|
|
/**
|
|
|
|
* Function Begin_Zone
|
|
|
|
* either initializes the first segment of a new zone, or adds an
|
|
|
|
* intermediate segment.
|
2008-10-17 06:17:48 +00:00
|
|
|
* A new zone can be:
|
|
|
|
* created from scratch: the user will be prompted to define parameters (layer, clearence ...)
|
|
|
|
* created from a similar zone (s_CurrentZone is used): parameters are copied from s_CurrentZone
|
|
|
|
* created as a cutout (an hole) inside s_CurrentZone
|
2007-12-19 16:44:53 +00:00
|
|
|
*/
|
|
|
|
{
|
2008-10-17 06:17:48 +00:00
|
|
|
// verify if s_CurrentZone exists (could be deleted since last selection) :
|
2008-01-31 20:53:44 +00:00
|
|
|
int ii;
|
2009-01-05 05:21:35 +00:00
|
|
|
for( ii = 0; ii < GetBoard()->GetAreaCount(); ii++ )
|
2007-12-30 18:20:51 +00:00
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
if( s_CurrentZone == GetBoard()->GetArea( ii ) )
|
2008-01-04 12:27:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
if( ii >= GetBoard()->GetAreaCount() ) // Not found: could be deleted since last selection
|
2008-01-04 12:27:16 +00:00
|
|
|
{
|
|
|
|
s_AddCutoutToCurrentZone = false;
|
|
|
|
s_CurrentZone = NULL;
|
|
|
|
}
|
2007-12-30 18:20:51 +00:00
|
|
|
|
2008-10-17 06:17:48 +00:00
|
|
|
// If no zone contour in progress, a new zone is beeing created:
|
2009-01-05 05:21:35 +00:00
|
|
|
if( GetBoard()->m_CurrentZoneContour == NULL )
|
|
|
|
GetBoard()->m_CurrentZoneContour = new ZONE_CONTAINER( GetBoard() );
|
2007-12-30 18:20:51 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
ZONE_CONTAINER* zone = GetBoard()->m_CurrentZoneContour;
|
2008-10-17 06:17:48 +00:00
|
|
|
if( zone->GetNumCorners() == 0 ) /* Start a new contour: init zone params (net, layer ...) */
|
2008-01-04 12:27:16 +00:00
|
|
|
{
|
2008-10-17 06:17:48 +00:00
|
|
|
if( s_CurrentZone == NULL ) // A new outline is created, from scratch
|
2008-01-04 12:27:16 +00:00
|
|
|
{
|
2008-09-26 19:51:36 +00:00
|
|
|
int diag;
|
2008-10-13 12:01:12 +00:00
|
|
|
// Init zone params to reasonnable values
|
2008-09-26 19:51:36 +00:00
|
|
|
zone->SetLayer( ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer );
|
2008-10-13 12:01:12 +00:00
|
|
|
|
2008-10-17 06:17:48 +00:00
|
|
|
// Prompt user for parameters:
|
2008-10-13 12:01:12 +00:00
|
|
|
DrawPanel->m_IgnoreMouseEvents = TRUE;
|
2008-09-26 19:51:36 +00:00
|
|
|
if( zone->IsOnCopperLayer() )
|
|
|
|
{ // Put a zone on a copper layer
|
2008-10-13 12:01:12 +00:00
|
|
|
if ( g_HightLigth_NetCode )
|
|
|
|
{
|
2008-10-23 10:26:06 +00:00
|
|
|
g_Zone_Default_Setting.m_NetcodeSelection = g_HightLigth_NetCode;
|
|
|
|
zone->SetNet( g_Zone_Default_Setting.m_NetcodeSelection );
|
|
|
|
zone->SetNetNameFromNetCode( );
|
2008-10-13 12:01:12 +00:00
|
|
|
}
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
wxGetApp().m_EDA_Config->Read( ZONE_THERMAL_RELIEF_GAP_STRING_KEY,
|
2008-10-23 10:26:06 +00:00
|
|
|
&g_Zone_Default_Setting.m_ThermalReliefGapValue );
|
2008-12-08 15:27:13 +00:00
|
|
|
wxGetApp().m_EDA_Config->Read( ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY,
|
2008-10-23 10:26:06 +00:00
|
|
|
&g_Zone_Default_Setting.m_ThermalReliefCopperBridgeValue );
|
|
|
|
|
|
|
|
dialog_copper_zone* frame = new dialog_copper_zone( this, &g_Zone_Default_Setting );
|
2008-09-26 19:51:36 +00:00
|
|
|
diag = frame->ShowModal();
|
|
|
|
frame->Destroy();
|
|
|
|
}
|
|
|
|
else // Put a zone on a non copper layer (technical layer)
|
|
|
|
{
|
|
|
|
diag = InstallDialogNonCopperZonesEditor( this, zone );
|
2008-10-23 10:26:06 +00:00
|
|
|
g_Zone_Default_Setting.m_NetcodeSelection = 0; // No net for non copper zones
|
2008-09-26 19:51:36 +00:00
|
|
|
}
|
2008-01-04 12:27:16 +00:00
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = FALSE;
|
2007-12-30 18:20:51 +00:00
|
|
|
|
2008-01-04 12:27:16 +00:00
|
|
|
if( diag == ZONE_ABORT )
|
2008-01-31 20:53:44 +00:00
|
|
|
return 0;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2008-10-23 10:26:06 +00:00
|
|
|
// Switch active layer to the selectec zonz layer
|
|
|
|
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = g_Zone_Default_Setting.m_CurrentZone_Layer;
|
2008-01-04 12:27:16 +00:00
|
|
|
}
|
2008-10-17 06:17:48 +00:00
|
|
|
else // Start a new contour: init zone params (net and layer) from an existing zone (add cutout or similar zone)
|
2008-01-04 12:27:16 +00:00
|
|
|
{
|
2008-10-23 10:26:06 +00:00
|
|
|
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = g_Zone_Default_Setting.m_CurrentZone_Layer =
|
2008-09-26 19:51:36 +00:00
|
|
|
s_CurrentZone->GetLayer();
|
2008-10-23 10:26:06 +00:00
|
|
|
g_Zone_Default_Setting.ImportSetting( * s_CurrentZone);
|
2008-01-04 12:27:16 +00:00
|
|
|
}
|
2008-01-08 17:44:20 +00:00
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
/* Show the Net for zones on copper layers */
|
2008-10-23 10:26:06 +00:00
|
|
|
if( g_Zone_Default_Setting.m_CurrentZone_Layer < FIRST_NO_COPPER_LAYER )
|
2007-12-30 18:20:51 +00:00
|
|
|
{
|
2008-10-17 06:17:48 +00:00
|
|
|
if( s_CurrentZone )
|
2008-10-23 10:26:06 +00:00
|
|
|
g_Zone_Default_Setting.m_NetcodeSelection = s_CurrentZone->GetNet();
|
2008-10-17 06:17:48 +00:00
|
|
|
if( g_HightLigt_Status )
|
2008-09-26 19:51:36 +00:00
|
|
|
{
|
|
|
|
Hight_Light( DC ); // Remove old hightlight selection
|
|
|
|
}
|
2008-01-04 12:27:16 +00:00
|
|
|
|
2008-10-23 10:26:06 +00:00
|
|
|
g_HightLigth_NetCode = g_Zone_Default_Setting.m_NetcodeSelection;
|
2008-09-26 19:51:36 +00:00
|
|
|
Hight_Light( DC );
|
|
|
|
}
|
2008-01-04 12:27:16 +00:00
|
|
|
if( !s_AddCutoutToCurrentZone )
|
2008-10-17 06:17:48 +00:00
|
|
|
s_CurrentZone = NULL; // the zone is used only once ("add similar zone" command)
|
2007-12-30 18:20:51 +00:00
|
|
|
}
|
2007-12-19 16:44:53 +00:00
|
|
|
|
|
|
|
// if first segment
|
2008-01-31 20:53:44 +00:00
|
|
|
if( zone->GetNumCorners() == 0 )
|
|
|
|
{
|
|
|
|
zone->m_Flags = IS_NEW;
|
|
|
|
zone->m_TimeStamp = GetTimeStamp();
|
2008-10-23 10:26:06 +00:00
|
|
|
g_Zone_Default_Setting.ExportSetting( *zone );
|
|
|
|
zone->m_Poly->Start( g_Zone_Default_Setting.m_CurrentZone_Layer,
|
2008-09-26 19:51:36 +00:00
|
|
|
GetScreen()->m_Curseur.x, GetScreen()->m_Curseur.y,
|
2008-10-23 10:26:06 +00:00
|
|
|
zone->GetHatchStyle() );
|
2008-01-31 20:53:44 +00:00
|
|
|
zone->AppendCorner( GetScreen()->m_Curseur );
|
2008-09-26 19:51:36 +00:00
|
|
|
if( Drc_On && (m_drc->Drc( zone, 0 ) == BAD_DRC) && zone->IsOnCopperLayer() )
|
2008-01-31 20:53:44 +00:00
|
|
|
{
|
|
|
|
zone->m_Flags = 0;
|
|
|
|
zone->RemoveAllContours();
|
|
|
|
|
|
|
|
// use the form of SetCurItem() which does not write to the msg panel,
|
|
|
|
// SCREEN::SetCurItem(), so the DRC error remains on screen.
|
2009-04-17 08:51:02 +00:00
|
|
|
// WinEDA_PcbFrame::SetCurItem() calls DisplayInfo().
|
2008-01-31 20:53:44 +00:00
|
|
|
GetScreen()->SetCurItem( NULL );
|
|
|
|
DisplayError( this,
|
2008-09-26 19:51:36 +00:00
|
|
|
_( "DRC error: this start point is inside or too close an other area" ) );
|
2008-01-31 20:53:44 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2007-12-19 16:44:53 +00:00
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
SetCurItem( zone );
|
2008-02-01 21:30:45 +00:00
|
|
|
DrawPanel->ManageCurseur = Show_New_Edge_While_Move_Mouse;
|
2007-12-29 19:15:58 +00:00
|
|
|
DrawPanel->ForceCloseManageCurseur = Abort_Zone_Create_Outline;
|
2007-12-19 16:44:53 +00:00
|
|
|
}
|
|
|
|
// edge in progress:
|
2007-12-29 19:15:58 +00:00
|
|
|
else
|
2007-12-30 18:20:51 +00:00
|
|
|
{
|
2008-01-31 20:53:44 +00:00
|
|
|
ii = zone->GetNumCorners() - 1;
|
|
|
|
|
2008-02-01 21:30:45 +00:00
|
|
|
/* edge in progress : the current corner coordinate was set by Show_New_Edge_While_Move_Mouse */
|
2008-01-31 20:53:44 +00:00
|
|
|
if( zone->GetCornerPosition( ii - 1 ) != zone->GetCornerPosition( ii ) )
|
2007-12-19 16:44:53 +00:00
|
|
|
{
|
2008-09-26 19:51:36 +00:00
|
|
|
if( (Drc_On && m_drc->Drc( zone, ii - 1 ) == OK_DRC)
|
|
|
|
|| !zone->IsOnCopperLayer() ) // Ok, we can add a new corner
|
2008-02-01 21:30:45 +00:00
|
|
|
{
|
2008-01-31 20:53:44 +00:00
|
|
|
zone->AppendCorner( GetScreen()->m_Curseur );
|
2009-04-17 08:51:02 +00:00
|
|
|
SetCurItem( zone ); // calls DisplayInfo().
|
2008-02-01 21:30:45 +00:00
|
|
|
}
|
2007-12-19 16:44:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
return zone->GetNumCorners();
|
2007-12-19 16:44:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************/
|
2008-01-20 19:55:22 +00:00
|
|
|
bool WinEDA_PcbFrame::End_Zone( wxDC* DC )
|
2007-12-19 16:44:53 +00:00
|
|
|
/*********************************************/
|
|
|
|
|
2007-12-30 18:20:51 +00:00
|
|
|
/** Function End_Zone
|
|
|
|
* Terminates a zone outline creation
|
2008-01-20 19:55:22 +00:00
|
|
|
* terminates (if no DRC error ) the zone edge creation process
|
|
|
|
* @param DC = current Device Context
|
|
|
|
* @return true if Ok, false if DRC error
|
2009-01-05 05:21:35 +00:00
|
|
|
* if ok, put it in the main list GetBoard()->m_ZoneDescriptorList (a vector<ZONE_CONTAINER*>)
|
2007-12-19 16:44:53 +00:00
|
|
|
*/
|
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
ZONE_CONTAINER* zone = GetBoard()->m_CurrentZoneContour;
|
2008-01-31 20:53:44 +00:00
|
|
|
|
|
|
|
if( zone == NULL )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// Validate the curren outline:
|
|
|
|
if( zone->GetNumCorners() <= 2 ) // An outline must have 3 corners or more
|
|
|
|
{
|
|
|
|
Abort_Zone_Create_Outline( DrawPanel, DC );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Validate the current edge:
|
|
|
|
int icorner = zone->GetNumCorners() - 1;
|
2008-09-26 19:51:36 +00:00
|
|
|
if( zone->IsOnCopperLayer() )
|
2008-01-31 20:53:44 +00:00
|
|
|
{
|
2008-09-26 19:51:36 +00:00
|
|
|
if( Drc_On && m_drc->Drc( zone, icorner - 1 ) == BAD_DRC ) // we can't validate last edge
|
|
|
|
return false;
|
|
|
|
if( Drc_On && m_drc->Drc( zone, icorner ) == BAD_DRC ) // we can't validate the closing edge
|
|
|
|
{
|
|
|
|
DisplayError( this,
|
|
|
|
_( "DRC error: closing this area creates a drc error with an other area" ) );
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
return false;
|
|
|
|
}
|
2008-01-31 20:53:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
zone->m_Flags = 0;
|
2007-12-19 16:44:53 +00:00
|
|
|
|
2008-02-01 21:30:45 +00:00
|
|
|
zone->DrawWhileCreateOutline( DrawPanel, DC, GR_XOR );
|
2007-12-19 16:44:53 +00:00
|
|
|
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
2007-12-30 18:20:51 +00:00
|
|
|
|
2008-01-04 12:27:16 +00:00
|
|
|
// Undraw old drawings, because they can have important changes
|
2008-01-31 20:53:44 +00:00
|
|
|
int layer = zone->GetLayer();
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->RedrawAreasOutlines( DrawPanel, DC, GR_XOR, layer );
|
|
|
|
GetBoard()->RedrawFilledAreas( DrawPanel, DC, GR_XOR, layer );
|
2008-01-04 12:27:16 +00:00
|
|
|
|
2007-12-30 18:20:51 +00:00
|
|
|
/* Put edges in list */
|
2008-01-04 12:27:16 +00:00
|
|
|
if( s_CurrentZone == NULL )
|
|
|
|
{
|
2008-01-31 20:53:44 +00:00
|
|
|
zone->m_Poly->Close(); // Close the current corner list
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->Add( zone );
|
|
|
|
GetBoard()->m_CurrentZoneContour = NULL;
|
2007-12-30 18:20:51 +00:00
|
|
|
}
|
2008-01-04 12:27:16 +00:00
|
|
|
else // Append this outline as a cutout to an existing zone
|
|
|
|
{
|
2008-01-31 20:53:44 +00:00
|
|
|
for( int ii = 0; ii < zone->GetNumCorners(); ii++ )
|
2008-01-04 12:27:16 +00:00
|
|
|
{
|
2008-01-31 20:53:44 +00:00
|
|
|
s_CurrentZone->AppendCorner( zone->GetCornerPosition( ii ) );
|
2008-01-04 12:27:16 +00:00
|
|
|
}
|
2007-12-30 18:20:51 +00:00
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
s_CurrentZone->m_Poly->Close(); // Close the current corner list
|
|
|
|
zone->RemoveAllContours(); // All corners are copied in s_CurrentZone. Free corner list.
|
|
|
|
zone = s_CurrentZone;
|
2008-01-04 12:27:16 +00:00
|
|
|
}
|
2007-12-30 18:20:51 +00:00
|
|
|
|
2008-01-04 12:27:16 +00:00
|
|
|
s_AddCutoutToCurrentZone = false;
|
|
|
|
s_CurrentZone = NULL;
|
2007-12-30 18:20:51 +00:00
|
|
|
|
2008-01-24 21:05:08 +00:00
|
|
|
GetScreen()->SetCurItem( NULL ); // This outine can be deleted when merging outlines
|
2008-01-04 12:27:16 +00:00
|
|
|
|
|
|
|
// Combine zones if possible :
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->AreaPolygonModified( zone, true, verbose );
|
2008-01-04 12:27:16 +00:00
|
|
|
|
|
|
|
// Redraw the real edge zone :
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->RedrawAreasOutlines( DrawPanel, DC, GR_OR, layer );
|
|
|
|
GetBoard()->RedrawFilledAreas( DrawPanel, DC, GR_OR, layer );
|
2007-12-30 18:20:51 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
int ii = GetBoard()->GetAreaIndex( zone ); // test if zone_container exists
|
2008-01-31 20:53:44 +00:00
|
|
|
if( ii < 0 )
|
|
|
|
zone = NULL; // was removed by combining zones
|
2009-01-05 05:21:35 +00:00
|
|
|
int error_count = GetBoard()->Test_Drc_Areas_Outlines_To_Areas_Outlines( zone, true );
|
2008-01-31 20:53:44 +00:00
|
|
|
if( error_count )
|
|
|
|
{
|
|
|
|
DisplayError( this, _( "Area: DRC outline error" ) );
|
|
|
|
}
|
2008-01-10 20:53:41 +00:00
|
|
|
|
2007-12-30 18:20:51 +00:00
|
|
|
GetScreen()->SetModify();
|
2008-01-31 20:53:44 +00:00
|
|
|
return true;
|
2007-12-19 16:44:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************************/
|
2008-02-01 21:30:45 +00:00
|
|
|
static void Show_New_Edge_While_Move_Mouse( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
|
2007-12-19 16:44:53 +00:00
|
|
|
/******************************************************************************************/
|
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
/* Redraws the edge zone when moving mouse
|
2007-12-19 16:44:53 +00:00
|
|
|
*/
|
|
|
|
{
|
|
|
|
WinEDA_PcbFrame* pcbframe = (WinEDA_PcbFrame*) panel->m_Parent;
|
2008-01-31 20:53:44 +00:00
|
|
|
wxPoint c_pos = pcbframe->GetScreen()->m_Curseur;
|
2009-01-05 05:21:35 +00:00
|
|
|
ZONE_CONTAINER* zone = pcbframe->GetBoard()->m_CurrentZoneContour;
|
2007-12-19 16:44:53 +00:00
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
if( zone == NULL )
|
2007-12-19 16:44:53 +00:00
|
|
|
return;
|
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
int icorner = zone->GetNumCorners() - 1;
|
2008-10-17 06:17:48 +00:00
|
|
|
if ( icorner < 1 )
|
|
|
|
return; // We must have 2 (or more) corners
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
if( erase ) /* Undraw edge in old position*/
|
2007-12-19 16:44:53 +00:00
|
|
|
{
|
2008-02-01 21:30:45 +00:00
|
|
|
zone->DrawWhileCreateOutline( panel, DC );
|
2007-12-19 16:44:53 +00:00
|
|
|
}
|
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
/* Redraw the curent edge in its new position */
|
2008-09-26 19:51:36 +00:00
|
|
|
if( g_Zone_45_Only )
|
2007-12-19 16:44:53 +00:00
|
|
|
{
|
2007-12-29 19:15:58 +00:00
|
|
|
// calculate the new position as allowed
|
2008-01-31 20:53:44 +00:00
|
|
|
wxPoint StartPoint = zone->GetCornerPosition( icorner - 1 );
|
|
|
|
Calcule_Coord_Extremite_45( StartPoint.x, StartPoint.y,
|
2008-09-26 19:51:36 +00:00
|
|
|
&c_pos.x, &c_pos.y );
|
2007-12-19 16:44:53 +00:00
|
|
|
}
|
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
zone->SetCornerPosition( icorner, c_pos );
|
|
|
|
|
|
|
|
zone->DrawWhileCreateOutline( panel, DC );
|
2007-12-19 16:44:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
/***********************************************************************************/
|
2007-12-30 18:20:51 +00:00
|
|
|
void WinEDA_PcbFrame::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container )
|
2007-12-29 19:15:58 +00:00
|
|
|
/***********************************************************************************/
|
2007-12-30 18:20:51 +00:00
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
/**
|
|
|
|
* Function Edit_Zone_Params
|
|
|
|
* Edit params (layer, clearance, ...) for a zone outline
|
2007-12-19 16:44:53 +00:00
|
|
|
*/
|
|
|
|
{
|
2008-09-26 19:51:36 +00:00
|
|
|
int diag;
|
2007-12-19 16:44:53 +00:00
|
|
|
DrawPanel->m_IgnoreMouseEvents = TRUE;
|
2008-09-26 19:51:36 +00:00
|
|
|
if( zone_container->GetLayer() < FIRST_NO_COPPER_LAYER )
|
|
|
|
{ // edit a zone on a copper layer
|
2008-10-23 10:26:06 +00:00
|
|
|
g_Zone_Default_Setting.ImportSetting(*zone_container);
|
|
|
|
dialog_copper_zone* frame = new dialog_copper_zone( this, &g_Zone_Default_Setting );
|
2008-09-26 19:51:36 +00:00
|
|
|
diag = frame->ShowModal();
|
|
|
|
frame->Destroy();
|
|
|
|
}
|
|
|
|
else // edit a zone on a non copper layer (technical layer)
|
|
|
|
diag = InstallDialogNonCopperZonesEditor( this, zone_container );
|
2007-12-19 16:44:53 +00:00
|
|
|
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
DrawPanel->m_IgnoreMouseEvents = FALSE;
|
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
if( diag == ZONE_ABORT )
|
2007-12-19 16:44:53 +00:00
|
|
|
return;
|
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
// Undraw old zone outlines
|
2009-01-05 05:21:35 +00:00
|
|
|
for( int ii = 0; ii < GetBoard()->GetAreaCount(); ii++ )
|
2008-01-04 12:27:16 +00:00
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
ZONE_CONTAINER* edge_zone = GetBoard()->GetArea( ii );
|
2008-04-01 05:21:50 +00:00
|
|
|
edge_zone->Draw( DrawPanel, DC, GR_XOR );
|
2008-01-04 12:27:16 +00:00
|
|
|
}
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2008-10-23 10:26:06 +00:00
|
|
|
g_Zone_Default_Setting.ExportSetting( *zone_container);
|
2009-05-24 18:28:36 +00:00
|
|
|
NETINFO_ITEM* net = GetBoard()->FindNet( g_Zone_Default_Setting.m_NetcodeSelection );
|
2008-10-23 10:26:06 +00:00
|
|
|
if( net ) // net === NULL should not occur
|
2008-12-14 19:45:05 +00:00
|
|
|
zone_container->m_Netname = net->GetNetname();
|
2008-10-10 11:31:46 +00:00
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2008-01-04 12:27:16 +00:00
|
|
|
// Combine zones if possible :
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->AreaPolygonModified( zone_container, true, verbose );
|
2008-01-04 12:27:16 +00:00
|
|
|
|
|
|
|
// Redraw the real new zone outlines:
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->RedrawAreasOutlines( DrawPanel, DC, GR_OR, -1 );
|
2007-12-30 18:20:51 +00:00
|
|
|
|
|
|
|
GetScreen()->SetModify();
|
2007-12-29 19:15:58 +00:00
|
|
|
}
|
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2008-01-05 13:37:51 +00:00
|
|
|
/************************************************************************************/
|
|
|
|
void WinEDA_PcbFrame::Delete_Zone_Contour( wxDC* DC, ZONE_CONTAINER* zone_container )
|
|
|
|
/************************************************************************************/
|
|
|
|
|
|
|
|
/** Function Delete_Zone_Contour
|
|
|
|
* 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 zone_container = zone to modify
|
|
|
|
* the member .m_CornerSelection is used to find the outline to remove.
|
|
|
|
* if the outline is the main outline, all the zone_container is removed (deleted)
|
|
|
|
* otherwise, the hole is deleted
|
|
|
|
*/
|
|
|
|
{
|
2008-09-26 19:51:36 +00:00
|
|
|
int ncont = zone_container->m_Poly->GetContour( zone_container->m_CornerSelection );
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2008-05-02 05:16:35 +00:00
|
|
|
EDA_Rect dirty = zone_container->GetBoundingBox();
|
2008-01-31 20:53:44 +00:00
|
|
|
|
|
|
|
Delete_Zone_Fill( DC, NULL, zone_container->m_TimeStamp ); // Remove fill segments
|
|
|
|
|
|
|
|
if( ncont == 0 ) // This is the main outline: remove all
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->Delete( zone_container );
|
2008-01-31 20:53:44 +00:00
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
zone_container->m_Poly->RemoveContour( ncont );
|
|
|
|
}
|
2008-05-02 05:16:35 +00:00
|
|
|
|
|
|
|
DrawPanel->PostDirtyRect( dirty );
|
|
|
|
|
2008-01-05 13:37:51 +00:00
|
|
|
GetScreen()->SetModify();
|
|
|
|
}
|
|
|
|
|
2007-12-30 18:20:51 +00:00
|
|
|
|
|
|
|
/***************************************************************************************/
|
|
|
|
int WinEDA_PcbFrame::Fill_Zone( wxDC* DC, ZONE_CONTAINER* zone_container, bool verbose )
|
|
|
|
/***************************************************************************************/
|
2007-12-29 19:15:58 +00:00
|
|
|
|
|
|
|
/** Function Fill_Zone()
|
2007-12-30 18:20:51 +00:00
|
|
|
* 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.
|
2008-11-24 20:46:41 +00:00
|
|
|
* If exists, the old filling is removed
|
2007-12-30 18:20:51 +00:00
|
|
|
* @param DC = current Device Context
|
|
|
|
* @param zone_container = zone to fill
|
|
|
|
* @param verbose = true to show error messages
|
|
|
|
* @return error level (0 = no error)
|
2007-12-29 19:15:58 +00:00
|
|
|
*/
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
MsgPanel->EraseMsgBox();
|
2009-01-05 05:21:35 +00:00
|
|
|
if( GetBoard()->ComputeBoundaryBox() == FALSE )
|
2007-12-19 16:44:53 +00:00
|
|
|
{
|
2007-12-30 18:20:51 +00:00
|
|
|
if( verbose )
|
|
|
|
DisplayError( this, wxT( "Board is empty!" ), 10 );
|
|
|
|
return -1;
|
2007-12-19 16:44:53 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 20:46:41 +00:00
|
|
|
/* Shows the Net */
|
2008-10-23 10:26:06 +00:00
|
|
|
g_Zone_Default_Setting.m_NetcodeSelection = zone_container->GetNet();
|
|
|
|
if( g_HightLigt_Status && (g_HightLigth_NetCode != g_Zone_Default_Setting.m_NetcodeSelection) && DC )
|
2007-12-19 16:44:53 +00:00
|
|
|
{
|
2008-11-24 20:46:41 +00:00
|
|
|
Hight_Light( DC ); // Remove old highlight selection
|
2007-12-30 18:20:51 +00:00
|
|
|
}
|
|
|
|
|
2008-10-23 10:26:06 +00:00
|
|
|
g_HightLigth_NetCode = g_Zone_Default_Setting.m_NetcodeSelection;
|
2008-01-05 13:37:51 +00:00
|
|
|
if( DC )
|
2007-12-20 22:27:32 +00:00
|
|
|
Hight_Light( DC );
|
2007-12-19 16:44:53 +00:00
|
|
|
|
|
|
|
if( g_HightLigth_NetCode > 0 )
|
|
|
|
{
|
2009-05-24 18:28:36 +00:00
|
|
|
NETINFO_ITEM* net = GetBoard()->FindNet( g_HightLigth_NetCode );
|
2007-12-29 19:15:58 +00:00
|
|
|
if( net == NULL )
|
2007-12-19 16:44:53 +00:00
|
|
|
{
|
|
|
|
if( g_HightLigth_NetCode > 0 )
|
2007-12-30 18:20:51 +00:00
|
|
|
{
|
|
|
|
if( verbose )
|
|
|
|
DisplayError( this, wxT( "Unable to find Net name" ) );
|
|
|
|
return -2;
|
|
|
|
}
|
2007-12-19 16:44:53 +00:00
|
|
|
}
|
|
|
|
else
|
2008-12-14 19:45:05 +00:00
|
|
|
msg = net->GetNetname();
|
2007-12-19 16:44:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
msg = _( "No Net" );
|
|
|
|
|
|
|
|
Affiche_1_Parametre( this, 22, _( "NetName" ), msg, RED );
|
2008-01-04 12:27:16 +00:00
|
|
|
wxBusyCursor dummy; // Shows an hourglass cursor (removed by its destructor)
|
2008-04-02 16:58:56 +00:00
|
|
|
|
2008-10-02 13:24:31 +00:00
|
|
|
int error_level = 0;
|
2008-10-19 18:18:45 +00:00
|
|
|
zone_container->m_FilledPolysList.clear();
|
2008-12-03 10:32:53 +00:00
|
|
|
Delete_Zone_Fill( NULL, NULL, zone_container->m_TimeStamp );
|
2009-01-05 05:21:35 +00:00
|
|
|
zone_container->BuildFilledPolysListData( GetBoard() );
|
2008-12-03 10:32:53 +00:00
|
|
|
if ( DC )
|
|
|
|
DrawPanel->Refresh();
|
2007-12-30 18:20:51 +00:00
|
|
|
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
|
|
|
|
return error_level;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************/
|
2008-12-04 20:53:11 +00:00
|
|
|
int WinEDA_PcbFrame::Fill_All_Zones( bool verbose )
|
2007-12-30 18:20:51 +00:00
|
|
|
/************************************************************/
|
|
|
|
|
|
|
|
/** Function Fill_All_Zones()
|
|
|
|
* Fill all zones on the board
|
|
|
|
* The old fillings are removed
|
|
|
|
* @param verbose = true to show error messages
|
|
|
|
* @return error level (0 = no error)
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
ZONE_CONTAINER* zone_container;
|
|
|
|
int error_level = 0;
|
|
|
|
|
2008-01-04 12:27:16 +00:00
|
|
|
// Remove all zones :
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->m_Zone.DeleteAll();
|
2008-01-01 11:46:47 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
for( int ii = 0; ii < GetBoard()->GetAreaCount(); ii++ )
|
2007-12-30 18:20:51 +00:00
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
zone_container = GetBoard()->GetArea( ii );
|
2008-01-01 11:46:47 +00:00
|
|
|
error_level = Fill_Zone( NULL, zone_container, verbose );
|
2008-01-04 12:27:16 +00:00
|
|
|
if( error_level && !verbose )
|
2007-12-30 18:20:51 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-11-24 20:46:41 +00:00
|
|
|
test_connexions( NULL );
|
|
|
|
Tst_Ratsnest( NULL, 0 ); // Recalculate the active ratsnest, i.e. the unconnected links */
|
2008-01-04 12:27:16 +00:00
|
|
|
DrawPanel->Refresh( true );
|
2007-12-30 18:20:51 +00:00
|
|
|
return error_level;
|
2007-12-19 16:44:53 +00:00
|
|
|
}
|
2008-01-06 20:58:27 +00:00
|
|
|
|
|
|
|
|