2011-10-17 20:01:27 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file zones_by_polygon.cpp
|
|
|
|
*/
|
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"
|
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
2009-07-30 11:04:07 +00:00
|
|
|
#include "wxPcbStruct.h"
|
2011-09-23 13:57:12 +00:00
|
|
|
|
|
|
|
#include "class_board.h"
|
|
|
|
#include "class_zone.h"
|
|
|
|
|
|
|
|
#include "pcbnew.h"
|
2008-10-23 10:26:06 +00:00
|
|
|
#include "zones.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "pcbnew_id.h"
|
2007-12-29 19:15:58 +00:00
|
|
|
#include "protos.h"
|
2009-08-23 15:22:44 +00:00
|
|
|
#include "zones_functions_for_undo_redo.h"
|
2010-09-18 08:29:40 +00:00
|
|
|
#include "drc_stuff.h"
|
2007-12-19 16:44:53 +00:00
|
|
|
|
2009-08-23 15:22:44 +00:00
|
|
|
bool s_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:
|
2011-01-21 19:30:59 +00:00
|
|
|
static void Abort_Zone_Create_Outline( EDA_DRAW_PANEL* Panel, wxDC* DC );
|
2011-02-03 19:27:28 +00:00
|
|
|
static void Show_New_Edge_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
|
|
|
const wxPoint& aPosition, bool aErase );
|
2007-12-30 18:20:51 +00:00
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
// Corner moving
|
2011-01-21 19:30:59 +00:00
|
|
|
static void Abort_Zone_Move_Corner_Or_Outlines( EDA_DRAW_PANEL* Panel, wxDC* DC );
|
2011-02-03 19:27:28 +00:00
|
|
|
static void Show_Zone_Corner_Or_Outline_While_Move_Mouse( EDA_DRAW_PANEL* aPanel,
|
|
|
|
wxDC* aDC,
|
|
|
|
const wxPoint& aPosition,
|
|
|
|
bool aErase );
|
2007-12-19 16:44:53 +00:00
|
|
|
|
|
|
|
/* Local variables */
|
2009-08-23 15:22:44 +00:00
|
|
|
static wxPoint s_CornerInitialPosition; // Used to abort a move corner command
|
2011-09-23 13:57:12 +00:00
|
|
|
static bool s_CornerIsNew; // Used to abort a move corner command (if it is a new corner, it must be deleted)
|
2011-10-17 20:01:27 +00:00
|
|
|
static bool s_AddCutoutToCurrentZone; // if true, the next outline will be added to s_CurrentZone
|
2011-09-23 13:57:12 +00:00
|
|
|
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
|
2009-08-23 15:22:44 +00:00
|
|
|
static PICKED_ITEMS_LIST s_PickedList; // a picked list to save zones for undo/redo command
|
2011-09-23 13:57:12 +00:00
|
|
|
static PICKED_ITEMS_LIST _AuxiliaryList; // a picked list to store zones that are deleted or added when combined
|
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
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
void PCB_EDIT_FRAME::Add_Similar_Zone( wxDC* DC, ZONE_CONTAINER* zone_container )
|
2008-01-04 12:27:16 +00:00
|
|
|
{
|
2008-10-17 06:17:48 +00:00
|
|
|
if ( zone_container == NULL )
|
|
|
|
return;
|
2011-10-17 20:01:27 +00:00
|
|
|
|
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 );
|
2011-02-23 21:34:28 +00:00
|
|
|
OnSelectTool( evt );
|
2008-01-04 12:27:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
void PCB_EDIT_FRAME::Add_Zone_Cutout( wxDC* DC, ZONE_CONTAINER* zone_container )
|
2008-01-04 12:27:16 +00:00
|
|
|
{
|
2008-10-17 06:17:48 +00:00
|
|
|
if ( zone_container == NULL )
|
|
|
|
return;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
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 );
|
2011-02-23 21:34:28 +00:00
|
|
|
OnSelectTool( evt );
|
2008-01-04 12:27:16 +00:00
|
|
|
}
|
|
|
|
|
2007-12-19 16:44:53 +00:00
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
int PCB_EDIT_FRAME::Delete_LastCreatedCorner( wxDC* DC )
|
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 );
|
2011-02-03 19:27:28 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
if( DrawPanel->IsMouseCaptured() )
|
|
|
|
DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false );
|
2007-12-19 16:44:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->SetMouseCapture( NULL, NULL );
|
2007-12-19 16:44:53 +00:00
|
|
|
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
|
|
|
}
|
2011-09-07 19:41:04 +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
|
|
|
* 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
|
|
|
*/
|
2011-09-07 19:41:04 +00:00
|
|
|
static void Abort_Zone_Create_Outline( EDA_DRAW_PANEL* Panel, wxDC* DC )
|
2007-12-19 16:44:53 +00:00
|
|
|
{
|
2011-03-01 19:26:17 +00:00
|
|
|
PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Panel->GetParent();
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
pcbframe->SetCurItem( NULL );
|
2008-01-04 12:27:16 +00:00
|
|
|
s_AddCutoutToCurrentZone = false;
|
|
|
|
s_CurrentZone = NULL;
|
2011-02-13 09:07:30 +00:00
|
|
|
Panel->SetMouseCapture( NULL, NULL );
|
2007-12-19 16:44:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
void PCB_EDIT_FRAME::Start_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_container,
|
|
|
|
int corner_id, bool IsNewCorner )
|
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
|
|
|
{
|
2011-09-14 20:04:58 +00:00
|
|
|
if( GetBoard()->IsHighLightNetON() && DC )
|
2008-09-26 19:51:36 +00:00
|
|
|
{
|
2011-10-17 20:01:27 +00:00
|
|
|
HighLight( DC ); // Remove old highlight selection
|
2008-09-26 19:51:36 +00:00
|
|
|
}
|
2007-12-30 18:20:51 +00:00
|
|
|
|
2011-04-05 17:49:14 +00:00
|
|
|
g_Zone_Default_Setting.m_NetcodeSelection = zone_container->GetNet();
|
2011-09-14 20:04:58 +00:00
|
|
|
GetBoard()->SetHighLightNet( zone_container->GetNet() );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
if( DC )
|
2011-10-17 20:01:27 +00:00
|
|
|
HighLight( DC );
|
2008-09-26 19:51:36 +00:00
|
|
|
}
|
2007-12-30 18:20:51 +00:00
|
|
|
|
2009-08-23 15:22:44 +00:00
|
|
|
|
|
|
|
// Prepare copy of old zones, for undo/redo.
|
|
|
|
// if the corner is new, remove it from list, save and insert it in list
|
|
|
|
int cx = zone_container->m_Poly->GetX( corner_id );
|
|
|
|
int cy = zone_container->m_Poly->GetY( corner_id );
|
|
|
|
|
|
|
|
if ( IsNewCorner )
|
|
|
|
zone_container->m_Poly->DeleteCorner( corner_id );
|
|
|
|
|
|
|
|
_AuxiliaryList.ClearListAndDeleteItems();
|
|
|
|
s_PickedList.ClearListAndDeleteItems();
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
SaveCopyOfZones( s_PickedList, GetBoard(), zone_container->GetNet(),
|
|
|
|
zone_container->GetLayer() );
|
|
|
|
|
2009-08-23 15:22:44 +00:00
|
|
|
if ( IsNewCorner )
|
|
|
|
zone_container->m_Poly->InsertCorner(corner_id-1, cx, cy );
|
|
|
|
|
2007-12-30 18:20:51 +00:00
|
|
|
zone_container->m_Flags = IN_EDIT;
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->SetMouseCapture( Show_Zone_Corner_Or_Outline_While_Move_Mouse,
|
|
|
|
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
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
void PCB_EDIT_FRAME::Start_Move_Zone_Drag_Outline_Edge( wxDC* DC,
|
|
|
|
ZONE_CONTAINER* zone_container,
|
|
|
|
int corner_id )
|
2008-02-01 21:30:45 +00:00
|
|
|
{
|
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;
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->SetMouseCapture( Show_Zone_Corner_Or_Outline_While_Move_Mouse,
|
2011-09-07 19:41:04 +00:00
|
|
|
Abort_Zone_Move_Corner_Or_Outlines );
|
2011-02-11 20:48:13 +00:00
|
|
|
s_CursorLastPosition = s_CornerInitialPosition = GetScreen()->GetCrossHairPosition();
|
2008-02-01 21:30:45 +00:00
|
|
|
s_AddCutoutToCurrentZone = false;
|
|
|
|
s_CurrentZone = NULL;
|
2009-08-23 15:22:44 +00:00
|
|
|
|
|
|
|
s_PickedList.ClearListAndDeleteItems();
|
|
|
|
_AuxiliaryList.ClearListAndDeleteItems();
|
2011-09-07 19:41:04 +00:00
|
|
|
SaveCopyOfZones( s_PickedList, GetBoard(), zone_container->GetNet(),
|
|
|
|
zone_container->GetLayer() );
|
2008-02-01 21:30:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
void PCB_EDIT_FRAME::Start_Move_Zone_Outlines( wxDC* DC, ZONE_CONTAINER* zone_container )
|
2008-01-16 20:37:50 +00:00
|
|
|
{
|
|
|
|
/* 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
|
|
|
{
|
2011-09-14 20:04:58 +00:00
|
|
|
if( GetBoard()->IsHighLightNetON() )
|
2008-09-26 19:51:36 +00:00
|
|
|
{
|
2011-10-17 20:01:27 +00:00
|
|
|
HighLight( DC ); // Remove old highlight selection
|
2008-09-26 19:51:36 +00:00
|
|
|
}
|
2008-01-16 20:37:50 +00:00
|
|
|
|
2011-04-05 17:49:14 +00:00
|
|
|
g_Zone_Default_Setting.m_NetcodeSelection = zone_container->GetNet();
|
2011-09-14 20:04:58 +00:00
|
|
|
GetBoard()->SetHighLightNet( zone_container->GetNet() );
|
2011-10-17 20:01:27 +00:00
|
|
|
HighLight( DC );
|
2008-09-26 19:51:36 +00:00
|
|
|
}
|
2008-01-16 20:37:50 +00:00
|
|
|
|
2009-08-23 15:22:44 +00:00
|
|
|
s_PickedList.ClearListAndDeleteItems();
|
|
|
|
_AuxiliaryList.ClearListAndDeleteItems();
|
2011-09-07 19:41:04 +00:00
|
|
|
SaveCopyOfZones( s_PickedList, GetBoard(), zone_container->GetNet(),
|
|
|
|
zone_container->GetLayer() );
|
2009-08-23 15:22:44 +00:00
|
|
|
|
2008-01-16 20:37:50 +00:00
|
|
|
zone_container->m_Flags = IS_MOVED;
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->SetMouseCapture( Show_Zone_Corner_Or_Outline_While_Move_Mouse,
|
2011-09-07 19:41:04 +00:00
|
|
|
Abort_Zone_Move_Corner_Or_Outlines );
|
2011-02-11 20:48:13 +00:00
|
|
|
s_CursorLastPosition = s_CornerInitialPosition = GetScreen()->GetCrossHairPosition();
|
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
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
void PCB_EDIT_FRAME::End_Move_Zone_Corner_Or_Outlines( wxDC* DC, ZONE_CONTAINER* zone_container )
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2007-12-30 18:20:51 +00:00
|
|
|
zone_container->m_Flags = 0;
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->SetMouseCapture( NULL, 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 );
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
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-08-23 15:22:44 +00:00
|
|
|
GetBoard()->AreaPolygonModified( &_AuxiliaryList, zone_container, true, s_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
|
2011-09-07 19:41:04 +00:00
|
|
|
|
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-08-23 15:22:44 +00:00
|
|
|
UpdateCopyOfZonesList( s_PickedList, _AuxiliaryList, GetBoard() );
|
|
|
|
SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED);
|
|
|
|
s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
int error_count = GetBoard()->Test_Drc_Areas_Outlines_To_Areas_Outlines( zone_container, true );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
void PCB_EDIT_FRAME::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_container )
|
2008-01-04 12:27:16 +00:00
|
|
|
{
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2008-01-10 20:53:41 +00:00
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
if( zone_container->m_Poly->GetNumCorners() <= 3 )
|
|
|
|
{
|
2011-01-30 22:22:38 +00:00
|
|
|
DrawPanel->RefreshDrawingRect( zone_container->GetBoundingBox() );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
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
|
2011-07-16 16:04:49 +00:00
|
|
|
zone_container->UnFill();
|
2008-09-26 19:51:36 +00:00
|
|
|
zone_container->DrawFilledArea( DrawPanel, DC, GR_XOR );
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
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
|
|
|
|
2009-08-23 15:22:44 +00:00
|
|
|
_AuxiliaryList.ClearListAndDeleteItems();
|
|
|
|
s_PickedList. ClearListAndDeleteItems();
|
2011-09-07 19:41:04 +00:00
|
|
|
SaveCopyOfZones( s_PickedList, GetBoard(), zone_container->GetNet(),
|
|
|
|
zone_container->GetLayer() );
|
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-08-23 15:22:44 +00:00
|
|
|
GetBoard()->AreaPolygonModified( &_AuxiliaryList, zone_container, true, s_Verbose );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
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-08-23 15:22:44 +00:00
|
|
|
UpdateCopyOfZonesList( s_PickedList, _AuxiliaryList, GetBoard() );
|
|
|
|
SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED);
|
|
|
|
s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
|
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
int ii = GetBoard()->GetAreaIndex( zone_container ); // test if zone_container exists
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
if( ii < 0 )
|
2011-10-17 20:01:27 +00:00
|
|
|
zone_container = NULL; // zone_container does not exist anymore, after combining zones
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
int error_count = GetBoard()->Test_Drc_Areas_Outlines_To_Areas_Outlines( zone_container, true );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
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
|
|
|
* 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.
|
|
|
|
*/
|
2011-09-07 19:41:04 +00:00
|
|
|
void Abort_Zone_Move_Corner_Or_Outlines( EDA_DRAW_PANEL* Panel, wxDC* DC )
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2011-03-01 19:26:17 +00:00
|
|
|
PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Panel->GetParent();
|
2007-12-30 18:20:51 +00:00
|
|
|
ZONE_CONTAINER* zone_container = (ZONE_CONTAINER*) pcbframe->GetCurItem();
|
|
|
|
|
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
|
|
|
|
2011-02-13 09:07:30 +00:00
|
|
|
Panel->SetMouseCapture( NULL, NULL );
|
2009-08-23 15:22:44 +00:00
|
|
|
_AuxiliaryList.ClearListAndDeleteItems();
|
|
|
|
s_PickedList. ClearListAndDeleteItems();
|
2008-05-02 06:27:06 +00:00
|
|
|
Panel->Refresh();
|
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Redraws the zone outline when moving a corner according to the cursor position
|
|
|
|
*/
|
2011-02-03 19:27:28 +00:00
|
|
|
void Show_Zone_Corner_Or_Outline_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
|
|
|
const wxPoint& aPosition, bool aErase )
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2011-03-01 19:26:17 +00:00
|
|
|
PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) aPanel->GetParent();
|
|
|
|
ZONE_CONTAINER* zone = (ZONE_CONTAINER*) pcbframe->GetCurItem();
|
2007-12-29 19:15:58 +00:00
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
if( aErase ) /* Undraw edge in old position*/
|
2007-12-29 19:15:58 +00:00
|
|
|
{
|
2011-02-03 19:27:28 +00:00
|
|
|
zone->Draw( aPanel, aDC, GR_XOR );
|
2007-12-29 19:15:58 +00:00
|
|
|
}
|
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
wxPoint pos = pcbframe->GetScreen()->GetCrossHairPosition();
|
2011-02-03 19:27:28 +00:00
|
|
|
|
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
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2008-02-01 21:30:45 +00:00
|
|
|
zone->m_Poly->MoveCorner( zone->m_CornerSelection, pos.x, pos.y );
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
2008-01-16 20:37:50 +00:00
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
zone->Draw( aPanel, aDC, GR_XOR );
|
2007-12-29 19:15:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-17 20:01:27 +00:00
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC )
|
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;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
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
|
|
|
|
2011-10-17 20:01:27 +00:00
|
|
|
// If no zone contour in progress, a new zone is being 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;
|
2011-09-07 19:41:04 +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;
|
2011-10-17 20:01:27 +00:00
|
|
|
// Init zone params to reasonable values
|
2010-01-24 02:05:07 +00:00
|
|
|
zone->SetLayer( getActiveLayer() );
|
2008-10-13 12:01:12 +00:00
|
|
|
|
2008-10-17 06:17:48 +00:00
|
|
|
// Prompt user for parameters:
|
2011-09-07 19:41:04 +00:00
|
|
|
DrawPanel->m_IgnoreMouseEvents = true;
|
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
if( zone->IsOnCopperLayer() )
|
|
|
|
{ // Put a zone on a copper layer
|
2011-09-14 20:04:58 +00:00
|
|
|
if ( GetBoard()->GetHighLightNetCode() > 0 )
|
2008-10-13 12:01:12 +00:00
|
|
|
{
|
2011-09-14 20:04:58 +00:00
|
|
|
g_Zone_Default_Setting.m_NetcodeSelection = GetBoard()->GetHighLightNetCode();
|
2011-04-05 17:49:14 +00:00
|
|
|
|
2008-10-23 10:26:06 +00:00
|
|
|
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,
|
2011-11-30 21:15:56 +00:00
|
|
|
&g_Zone_Default_Setting.m_ThermalReliefGap );
|
2008-12-08 15:27:13 +00:00
|
|
|
wxGetApp().m_EDA_Config->Read( ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY,
|
2011-11-30 21:15:56 +00:00
|
|
|
&g_Zone_Default_Setting.m_ThermalReliefCopperBridge );
|
2008-10-23 10:26:06 +00:00
|
|
|
|
2009-09-10 13:04:04 +00:00
|
|
|
g_Zone_Default_Setting.m_CurrentZone_Layer = zone->GetLayer();
|
2011-03-01 22:36:38 +00:00
|
|
|
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)
|
|
|
|
{
|
2010-11-18 21:16:28 +00:00
|
|
|
diag = InstallDialogNonCopperZonesEditor( 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
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2011-09-07 19:41:04 +00:00
|
|
|
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
|
|
|
|
2011-10-17 20:01:27 +00:00
|
|
|
// Switch active layer to the selected zone layer
|
2010-01-24 02:05:07 +00:00
|
|
|
setActiveLayer( g_Zone_Default_Setting.m_CurrentZone_Layer );
|
2008-01-04 12:27:16 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
else // Start a new contour: init zone params (net and layer) from an existing
|
|
|
|
{ // zone (add cutout or similar zone)
|
2010-01-24 02:05:07 +00:00
|
|
|
g_Zone_Default_Setting.m_CurrentZone_Layer = s_CurrentZone->GetLayer();
|
|
|
|
setActiveLayer( 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();
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-09-14 20:04:58 +00:00
|
|
|
if( GetBoard()->IsHighLightNetON() )
|
2008-09-26 19:51:36 +00:00
|
|
|
{
|
2011-10-17 20:01:27 +00:00
|
|
|
HighLight( DC ); // Remove old highlight selection
|
2008-09-26 19:51:36 +00:00
|
|
|
}
|
2008-01-04 12:27:16 +00:00
|
|
|
|
2011-09-14 20:04:58 +00:00
|
|
|
GetBoard()->SetHighLightNet( g_Zone_Default_Setting.m_NetcodeSelection );
|
2011-10-17 20:01:27 +00:00
|
|
|
HighLight( DC );
|
2008-09-26 19:51:36 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
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;
|
2011-12-07 15:49:32 +00:00
|
|
|
zone->m_TimeStamp = GetNewTimeStamp();
|
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,
|
2011-02-11 20:48:13 +00:00
|
|
|
GetScreen()->GetCrossHairPosition().x,
|
|
|
|
GetScreen()->GetCrossHairPosition().y,
|
|
|
|
zone->GetHatchStyle() );
|
|
|
|
zone->AppendCorner( GetScreen()->GetCrossHairPosition() );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
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.
|
2011-03-01 19:26:17 +00:00
|
|
|
// PCB_EDIT_FRAME::SetCurItem() calls DisplayInfo().
|
2008-01-31 20:53:44 +00:00
|
|
|
GetScreen()->SetCurItem( NULL );
|
|
|
|
DisplayError( this,
|
2011-09-07 19:41:04 +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 );
|
2011-09-07 19:41:04 +00:00
|
|
|
DrawPanel->SetMouseCapture( Show_New_Edge_While_Move_Mouse, Abort_Zone_Create_Outline );
|
2007-12-19 16:44:53 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
else // edge in progress:
|
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
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
if( !Drc_On || !zone->IsOnCopperLayer() || ( m_drc->Drc( zone, ii - 1 ) == OK_DRC ) )
|
2009-12-03 09:33:48 +00:00
|
|
|
{ // Ok, we can add a new corner
|
2011-02-11 20:48:13 +00:00
|
|
|
zone->AppendCorner( GetScreen()->GetCrossHairPosition() );
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
bool PCB_EDIT_FRAME::End_Zone( wxDC* DC )
|
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;
|
|
|
|
|
2009-08-23 15:22:44 +00:00
|
|
|
// Validate the current outline:
|
2008-01-31 20:53:44 +00:00
|
|
|
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;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-09-26 19:51:36 +00:00
|
|
|
if( Drc_On && m_drc->Drc( zone, icorner ) == BAD_DRC ) // we can't validate the closing edge
|
|
|
|
{
|
|
|
|
DisplayError( this,
|
2011-09-07 19:41:04 +00:00
|
|
|
_( "DRC error: closing this area creates a drc error with an other area" ) );
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2008-09-26 19:51:36 +00:00
|
|
|
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
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->SetMouseCapture( NULL, 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
|
|
|
|
2009-08-23 15:22:44 +00:00
|
|
|
// Save initial zones configuration, for undo/redo, before adding new zone
|
|
|
|
_AuxiliaryList.ClearListAndDeleteItems();
|
|
|
|
s_PickedList.ClearListAndDeleteItems();
|
|
|
|
SaveCopyOfZones(s_PickedList, GetBoard(), zone->GetNet(), zone->GetLayer() );
|
|
|
|
|
|
|
|
/* Put new zone 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;
|
2009-08-23 15:22:44 +00:00
|
|
|
// Add this zone in picked list, as new item
|
|
|
|
ITEM_PICKER picker( zone, UR_NEW );
|
|
|
|
s_PickedList.PushItem( picker );
|
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
|
|
|
|
2011-10-17 20:01:27 +00:00
|
|
|
GetScreen()->SetCurItem( NULL ); // This outline can be deleted when merging outlines
|
2008-01-04 12:27:16 +00:00
|
|
|
|
|
|
|
// Combine zones if possible :
|
2009-08-23 15:22:44 +00:00
|
|
|
GetBoard()->AreaPolygonModified( &_AuxiliaryList, zone, true, s_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
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
if( ii < 0 )
|
|
|
|
zone = NULL; // was removed by combining zones
|
2009-08-23 15:22:44 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
int error_count = GetBoard()->Test_Drc_Areas_Outlines_To_Areas_Outlines( zone, true );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
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
|
|
|
|
2009-08-23 15:22:44 +00:00
|
|
|
UpdateCopyOfZonesList( s_PickedList, _AuxiliaryList, GetBoard() );
|
|
|
|
SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED);
|
|
|
|
s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
|
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2008-01-31 20:53:44 +00:00
|
|
|
return true;
|
2007-12-19 16:44:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-23 15:22:44 +00:00
|
|
|
/* Redraws the zone outlines when moving mouse
|
2007-12-19 16:44:53 +00:00
|
|
|
*/
|
2011-02-03 19:27:28 +00:00
|
|
|
static void Show_New_Edge_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
|
|
|
|
const wxPoint& aPosition, bool aErase )
|
2007-12-19 16:44:53 +00:00
|
|
|
{
|
2011-03-01 19:26:17 +00:00
|
|
|
PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) aPanel->GetParent();
|
|
|
|
wxPoint c_pos = pcbframe->GetScreen()->GetCrossHairPosition();
|
|
|
|
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;
|
2011-02-03 19:27:28 +00:00
|
|
|
|
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
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
if( aErase ) /* Undraw edge in old position*/
|
2007-12-19 16:44:53 +00:00
|
|
|
{
|
2011-02-03 19:27:28 +00:00
|
|
|
zone->DrawWhileCreateOutline( aPanel, aDC );
|
2007-12-19 16:44:53 +00:00
|
|
|
}
|
|
|
|
|
2011-10-17 20:01:27 +00:00
|
|
|
/* Redraw the current 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 );
|
2011-09-07 19:41:04 +00:00
|
|
|
CalculateSegmentEndPoint( c_pos, StartPoint.x, StartPoint.y, &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 );
|
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
zone->DrawWhileCreateOutline( aPanel, aDC );
|
2007-12-19 16:44:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
void PCB_EDIT_FRAME::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container )
|
2007-12-19 16:44:53 +00:00
|
|
|
{
|
2008-09-26 19:51:36 +00:00
|
|
|
int diag;
|
2011-09-07 19:41:04 +00:00
|
|
|
DrawPanel->m_IgnoreMouseEvents = true;
|
2009-08-23 15:22:44 +00:00
|
|
|
|
|
|
|
/* Save initial zones configuration, for undo/redo, before adding new zone
|
|
|
|
* note the net name and the layer can be changed, so we must save all zones
|
|
|
|
*/
|
|
|
|
_AuxiliaryList.ClearListAndDeleteItems();
|
|
|
|
s_PickedList.ClearListAndDeleteItems();
|
|
|
|
SaveCopyOfZones(s_PickedList, GetBoard(), -1, -1 );
|
|
|
|
|
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);
|
2011-03-01 22:36:38 +00:00
|
|
|
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)
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2010-11-18 21:16:28 +00:00
|
|
|
diag = InstallDialogNonCopperZonesEditor( zone_container );
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
2007-12-19 16:44:53 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2011-09-07 19:41:04 +00:00
|
|
|
DrawPanel->m_IgnoreMouseEvents = false;
|
2007-12-19 16:44:53 +00:00
|
|
|
|
2007-12-29 19:15:58 +00:00
|
|
|
if( diag == ZONE_ABORT )
|
2009-08-23 15:22:44 +00:00
|
|
|
{
|
|
|
|
_AuxiliaryList.ClearListAndDeleteItems();
|
|
|
|
s_PickedList.ClearListAndDeleteItems();
|
|
|
|
return;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-08-23 15:22:44 +00:00
|
|
|
if( diag == ZONE_EXPORT_VALUES )
|
|
|
|
{
|
|
|
|
UpdateCopyOfZonesList( s_PickedList, _AuxiliaryList, GetBoard() );
|
|
|
|
SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED);
|
|
|
|
s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
|
2007-12-19 16:44:53 +00:00
|
|
|
return;
|
2009-08-23 15:22:44 +00:00
|
|
|
}
|
2007-12-19 16:44:53 +00:00
|
|
|
|
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 );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-08-23 15:22:44 +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
|
|
|
|
2008-01-04 12:27:16 +00:00
|
|
|
// Combine zones if possible :
|
2009-08-23 15:22:44 +00:00
|
|
|
GetBoard()->AreaPolygonModified( &_AuxiliaryList, zone_container, true, s_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
|
|
|
|
2009-08-23 15:22:44 +00:00
|
|
|
UpdateCopyOfZonesList( s_PickedList, _AuxiliaryList, GetBoard() );
|
|
|
|
SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED);
|
|
|
|
s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
|
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2007-12-29 19:15:58 +00:00
|
|
|
}
|
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
void PCB_EDIT_FRAME::Delete_Zone_Contour( wxDC* DC, ZONE_CONTAINER* zone_container )
|
2008-01-05 13:37:51 +00:00
|
|
|
{
|
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
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT dirty = zone_container->GetBoundingBox();
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2011-07-16 16:04:49 +00:00
|
|
|
// For compatibility with old boards: remove old SEGZONE fill segments
|
|
|
|
Delete_OldZone_Fill( NULL, zone_container->m_TimeStamp );
|
|
|
|
|
|
|
|
// Remove current filling:
|
|
|
|
zone_container->UnFill();
|
2008-01-31 20:53:44 +00:00
|
|
|
|
2009-07-31 05:33:11 +00:00
|
|
|
if( ncont == 0 ) // This is the main outline: remove all
|
|
|
|
{
|
|
|
|
SaveCopyInUndoList( zone_container, UR_DELETED );
|
|
|
|
GetBoard()->Remove( 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
|
|
|
|
2011-01-30 22:22:38 +00:00
|
|
|
DrawPanel->RefreshDrawingRect( dirty );
|
2008-05-02 05:16:35 +00:00
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2008-01-05 13:37:51 +00:00
|
|
|
}
|