2008-03-13 05:04:59 +00:00
|
|
|
/************************************/
|
2009-11-03 13:26:31 +00:00
|
|
|
/* delete.cpp */
|
2008-03-13 05:04:59 +00:00
|
|
|
/************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "common.h"
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "class_sch_screen.h"
|
|
|
|
#include "wxEeschemaStruct.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
2010-11-11 21:10:27 +00:00
|
|
|
#include "sch_marker.h"
|
2011-01-12 21:47:54 +00:00
|
|
|
#include "sch_junction.h"
|
2010-12-21 15:13:09 +00:00
|
|
|
#include "sch_line.h"
|
2010-11-11 21:10:27 +00:00
|
|
|
#include "sch_sheet.h"
|
|
|
|
#include "sch_text.h"
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-07-25 07:31:07 +00:00
|
|
|
// Imported function:
|
2011-01-21 19:30:59 +00:00
|
|
|
void DeleteItemsInList( EDA_DRAW_PANEL* panel, PICKED_ITEMS_LIST& aItemsList );
|
2009-07-25 07:31:07 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
/*
|
|
|
|
* Mark to "CANDIDATE" all wires or junction connected to "segment" in list
|
|
|
|
* "ListStruct"
|
|
|
|
* Search wire stop at an any pin
|
2008-03-13 05:04:59 +00:00
|
|
|
*
|
2010-12-08 20:12:46 +00:00
|
|
|
* Used by SCH_EDIT_FRAME::DeleteConnection()
|
2008-03-13 05:04:59 +00:00
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
static bool MarkConnected( SCH_EDIT_FRAME* frame, SCH_ITEM* ListStruct, SCH_LINE* segment )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM* Struct;
|
2008-03-13 05:04:59 +00:00
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
for( Struct = ListStruct; Struct != NULL; Struct = Struct->Next() )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
|
|
|
if( Struct->m_Flags )
|
|
|
|
continue;
|
2010-12-10 19:47:44 +00:00
|
|
|
if( Struct->Type() == SCH_JUNCTION_T )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
#define JUNCTION ( (SCH_JUNCTION*) Struct )
|
2010-12-10 19:47:44 +00:00
|
|
|
if( segment->IsEndPoint( JUNCTION->m_Pos ) )
|
2008-03-13 05:04:59 +00:00
|
|
|
Struct->m_Flags |= CANDIDATE;
|
|
|
|
continue;
|
|
|
|
#undef JUNCTION
|
|
|
|
}
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
if( Struct->Type() != SCH_LINE_T )
|
2008-03-13 05:04:59 +00:00
|
|
|
continue;
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
#define SEGM ( (SCH_LINE*) Struct )
|
2010-12-10 19:47:44 +00:00
|
|
|
if( segment->IsEndPoint( SEGM->m_Start ) )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
2011-01-10 20:35:24 +00:00
|
|
|
if( !frame->GetScreen()->GetPin( SEGM->m_Start, NULL, true ) )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
|
|
|
Struct->m_Flags |= CANDIDATE;
|
|
|
|
MarkConnected( frame, ListStruct, SEGM );
|
|
|
|
}
|
|
|
|
}
|
2010-12-10 19:47:44 +00:00
|
|
|
if( segment->IsEndPoint( SEGM->m_End ) )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
2011-01-10 20:35:24 +00:00
|
|
|
if( !frame->GetScreen()->GetPin( SEGM->m_End, NULL, true ) )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
|
|
|
Struct->m_Flags |= CANDIDATE;
|
|
|
|
MarkConnected( frame, ListStruct, SEGM );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#undef SEGM
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-03-13 05:04:59 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
/*
|
|
|
|
* Delete a connection, i.e wires or bus connected
|
|
|
|
* stop on a node (more than 2 wires (bus) connected)
|
2008-03-13 05:04:59 +00:00
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::DeleteConnection( bool DeleteFullConnection )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-12-13 15:59:00 +00:00
|
|
|
SCH_SCREEN* screen = GetScreen();
|
|
|
|
wxPoint refpos = screen->m_Curseur;
|
2008-04-14 19:22:48 +00:00
|
|
|
SCH_ITEM* DelStruct;
|
2009-07-25 07:31:07 +00:00
|
|
|
PICKED_ITEMS_LIST pickList;
|
2008-03-13 05:04:59 +00:00
|
|
|
|
|
|
|
/* Clear .m_Flags member for all items */
|
2010-12-13 15:59:00 +00:00
|
|
|
screen->ClearDrawingState();
|
2011-01-21 19:30:59 +00:00
|
|
|
screen->BreakSegmentsOnJunctions();
|
2008-03-13 05:04:59 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
/* Locate all the wires, bus or junction under the mouse cursor, and put
|
|
|
|
* them in a list of items to delete
|
2008-03-13 05:04:59 +00:00
|
|
|
*/
|
2010-12-13 15:59:00 +00:00
|
|
|
ITEM_PICKER picker( NULL, UR_DELETED );
|
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
// Save the list entry point of this screen
|
2010-12-08 20:12:46 +00:00
|
|
|
SCH_ITEM* savedItems = screen->GetDrawItems();
|
2010-12-13 15:59:00 +00:00
|
|
|
DelStruct = screen->GetDrawItems();
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2008-03-13 05:04:59 +00:00
|
|
|
while( DelStruct
|
2009-09-04 18:57:37 +00:00
|
|
|
&& ( DelStruct = PickStruct( screen->m_Curseur, screen,
|
2011-01-25 14:06:17 +00:00
|
|
|
JUNCTION_T | WIRE_T | BUS_T ) ) != NULL )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
|
|
|
DelStruct->m_Flags = SELECTEDNODE | STRUCT_DELETED;
|
|
|
|
|
|
|
|
/* Put this structure in the picked list: */
|
2009-07-31 05:33:11 +00:00
|
|
|
picker.m_PickedItem = DelStruct;
|
|
|
|
picker.m_PickedItemType = DelStruct->Type();
|
2010-12-13 15:59:00 +00:00
|
|
|
pickList.PushItem( picker );
|
2008-03-13 05:04:59 +00:00
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
DelStruct = DelStruct->Next();
|
2010-12-08 20:12:46 +00:00
|
|
|
screen->SetDrawItems( DelStruct );
|
2008-03-13 05:04:59 +00:00
|
|
|
}
|
|
|
|
|
2011-01-25 14:06:17 +00:00
|
|
|
screen->SetDrawItems( savedItems ); // Restore the list entry point.
|
2008-03-13 05:04:59 +00:00
|
|
|
|
|
|
|
/* Mark all wires, junctions, .. connected to one of the item to delete
|
|
|
|
*/
|
|
|
|
if( DeleteFullConnection )
|
|
|
|
{
|
2010-12-13 15:59:00 +00:00
|
|
|
for( DelStruct = screen->GetDrawItems(); DelStruct != NULL;
|
2009-09-04 18:57:37 +00:00
|
|
|
DelStruct = DelStruct->Next() )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
|
|
|
if( !(DelStruct->m_Flags & SELECTEDNODE) )
|
|
|
|
continue;
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
#define SEGM ( (SCH_LINE*) DelStruct )
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
if( DelStruct->Type() != SCH_LINE_T )
|
2008-03-13 05:04:59 +00:00
|
|
|
continue;
|
|
|
|
|
2010-12-13 15:59:00 +00:00
|
|
|
MarkConnected( this, screen->GetDrawItems(), SEGM );
|
2008-03-13 05:04:59 +00:00
|
|
|
#undef SEGM
|
|
|
|
}
|
|
|
|
|
|
|
|
// Search all removable wires (i.e wire with one new dangling end )
|
2010-12-13 15:59:00 +00:00
|
|
|
for( DelStruct = screen->GetDrawItems(); DelStruct != NULL;
|
2009-09-04 18:57:37 +00:00
|
|
|
DelStruct = DelStruct->Next() )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
|
|
|
bool noconnect = FALSE;
|
|
|
|
|
|
|
|
if( DelStruct->m_Flags & STRUCT_DELETED )
|
2009-09-04 18:57:37 +00:00
|
|
|
continue; // Already seen
|
2008-03-13 05:04:59 +00:00
|
|
|
|
|
|
|
if( !(DelStruct->m_Flags & CANDIDATE) )
|
2009-09-04 18:57:37 +00:00
|
|
|
continue; // Already seen
|
2008-03-13 05:04:59 +00:00
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
if( DelStruct->Type() != SCH_LINE_T )
|
2008-03-13 05:04:59 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
DelStruct->m_Flags |= SKIP_STRUCT;
|
2009-12-02 21:44:03 +00:00
|
|
|
#define SEGM ( (SCH_LINE*) DelStruct )
|
2008-03-13 05:04:59 +00:00
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
/* Test the SEGM->m_Start point: if this point was connected to
|
|
|
|
* an STRUCT_DELETED wire, and now is not connected, the wire can
|
|
|
|
* be deleted */
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM* removed_struct;
|
2010-12-13 15:59:00 +00:00
|
|
|
for( removed_struct = screen->GetDrawItems();
|
2008-03-13 05:04:59 +00:00
|
|
|
removed_struct != NULL;
|
2008-11-24 06:53:43 +00:00
|
|
|
removed_struct = removed_struct->Next() )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
if( ( removed_struct->m_Flags & STRUCT_DELETED ) == 0 )
|
2008-03-13 05:04:59 +00:00
|
|
|
continue;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
if( removed_struct->Type() != SCH_LINE_T )
|
2008-03-13 05:04:59 +00:00
|
|
|
continue;
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
#define WIRE ( (SCH_LINE*) removed_struct )
|
2010-12-10 19:47:44 +00:00
|
|
|
if( WIRE->IsEndPoint( SEGM->m_Start ) )
|
2008-03-13 05:04:59 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-12-13 15:59:00 +00:00
|
|
|
if( WIRE && !screen->CountConnectedItems( SEGM->m_Start, true ) )
|
2008-03-13 05:04:59 +00:00
|
|
|
noconnect = TRUE;
|
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
/* Test the SEGM->m_End point: if this point was connected to
|
|
|
|
* an STRUCT_DELETED wire, and now is not connected, the wire
|
|
|
|
* can be deleted */
|
2010-12-13 15:59:00 +00:00
|
|
|
for( removed_struct = screen->GetDrawItems();
|
2008-03-13 05:04:59 +00:00
|
|
|
removed_struct != NULL;
|
2008-11-24 06:53:43 +00:00
|
|
|
removed_struct = removed_struct->Next() )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
if( ( removed_struct->m_Flags & STRUCT_DELETED ) == 0 )
|
2008-03-13 05:04:59 +00:00
|
|
|
continue;
|
2010-12-10 19:47:44 +00:00
|
|
|
if( removed_struct->Type() != SCH_LINE_T )
|
2008-03-13 05:04:59 +00:00
|
|
|
continue;
|
2010-12-10 19:47:44 +00:00
|
|
|
if( WIRE->IsEndPoint( SEGM->m_End ) )
|
2008-03-13 05:04:59 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-12-13 15:59:00 +00:00
|
|
|
if( removed_struct && !screen->CountConnectedItems( SEGM->m_End, true ) )
|
2008-03-13 05:04:59 +00:00
|
|
|
noconnect = TRUE;
|
|
|
|
|
|
|
|
DelStruct->m_Flags &= ~SKIP_STRUCT;
|
|
|
|
|
|
|
|
if( noconnect )
|
|
|
|
{
|
|
|
|
DelStruct->m_Flags |= STRUCT_DELETED;
|
|
|
|
/* Put this structure in the picked list: */
|
2009-07-31 05:33:11 +00:00
|
|
|
picker.m_PickedItem = DelStruct;
|
|
|
|
picker.m_PickedItemType = DelStruct->Type();
|
2010-12-13 15:59:00 +00:00
|
|
|
pickList.PushItem( picker );
|
2008-03-13 05:04:59 +00:00
|
|
|
|
2010-12-13 15:59:00 +00:00
|
|
|
DelStruct = screen->GetDrawItems();
|
2008-03-13 05:04:59 +00:00
|
|
|
}
|
|
|
|
#undef SEGM
|
|
|
|
}
|
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
// Delete redundant junctions (junctions which connect < 3 end wires
|
|
|
|
// and no pin are removed)
|
2010-12-13 15:59:00 +00:00
|
|
|
for( DelStruct = screen->GetDrawItems(); DelStruct != NULL;
|
2009-09-04 18:57:37 +00:00
|
|
|
DelStruct = DelStruct->Next() )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
|
|
|
if( DelStruct->m_Flags & STRUCT_DELETED )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( !(DelStruct->m_Flags & CANDIDATE) )
|
|
|
|
continue;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
if( DelStruct->Type() == SCH_JUNCTION_T )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
#define JUNCTION ( (SCH_JUNCTION*) DelStruct )
|
2010-12-13 15:59:00 +00:00
|
|
|
|
|
|
|
if( screen->CountConnectedItems( JUNCTION->m_Pos, false ) <= 2 )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
|
|
|
DelStruct->m_Flags |= STRUCT_DELETED;
|
|
|
|
|
|
|
|
/* Put this structure in the picked list: */
|
2009-07-31 05:33:11 +00:00
|
|
|
picker.m_PickedItem = DelStruct;
|
|
|
|
picker.m_PickedItemType = DelStruct->Type();
|
2010-12-13 15:59:00 +00:00
|
|
|
pickList.PushItem( picker );
|
2008-03-13 05:04:59 +00:00
|
|
|
}
|
|
|
|
#undef JUNCTION
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delete labels attached to wires
|
2010-12-13 15:59:00 +00:00
|
|
|
wxPoint pos = screen->m_Curseur;
|
|
|
|
|
|
|
|
for( DelStruct = screen->GetDrawItems(); DelStruct != NULL;
|
2009-09-04 18:57:37 +00:00
|
|
|
DelStruct = DelStruct->Next() )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
|
|
|
if( DelStruct->m_Flags & STRUCT_DELETED )
|
|
|
|
continue;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
if( DelStruct->Type() != SCH_LABEL_T )
|
2008-03-13 05:04:59 +00:00
|
|
|
continue;
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
GetScreen()->m_Curseur = ( (SCH_TEXT*) DelStruct )->m_Pos;
|
2011-01-25 14:06:17 +00:00
|
|
|
EDA_ITEM* TstStruct = PickStruct( screen->m_Curseur, GetScreen(), WIRE_T | BUS_T );
|
2008-03-13 05:04:59 +00:00
|
|
|
|
|
|
|
if( TstStruct && TstStruct->m_Flags & STRUCT_DELETED )
|
|
|
|
{
|
|
|
|
DelStruct->m_Flags |= STRUCT_DELETED;
|
|
|
|
|
|
|
|
/* Put this structure in the picked list: */
|
2009-07-31 05:33:11 +00:00
|
|
|
picker.m_PickedItem = DelStruct;
|
|
|
|
picker.m_PickedItemType = DelStruct->Type();
|
2010-12-13 15:59:00 +00:00
|
|
|
pickList.PushItem( picker );
|
2008-03-13 05:04:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-13 15:59:00 +00:00
|
|
|
screen->m_Curseur = pos;
|
2008-03-13 05:04:59 +00:00
|
|
|
}
|
|
|
|
|
2010-12-13 15:59:00 +00:00
|
|
|
screen->ClearDrawingState();
|
2008-03-13 05:04:59 +00:00
|
|
|
|
2009-07-25 07:31:07 +00:00
|
|
|
if( pickList.GetCount() )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
2009-07-25 07:31:07 +00:00
|
|
|
DeleteItemsInList( DrawPanel, pickList );
|
2010-12-13 15:59:00 +00:00
|
|
|
OnModify();
|
2008-03-13 05:04:59 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
/*
|
2009-11-03 13:26:31 +00:00
|
|
|
* Locate and delete the item found under the mouse cursor
|
2009-09-04 18:57:37 +00:00
|
|
|
* If more than one item found: the priority order is:
|
|
|
|
* 1 : MARKER
|
|
|
|
* 2 : JUNCTION
|
|
|
|
* 2 : NOCONNECT
|
2009-11-03 13:26:31 +00:00
|
|
|
* 3 : WIRE or BUS
|
2011-01-25 14:06:17 +00:00
|
|
|
* 4 : GRAPHIC ITEM
|
2009-09-04 18:57:37 +00:00
|
|
|
* 5 : TEXT
|
2011-01-25 14:06:17 +00:00
|
|
|
* 6 : COMPONENT
|
2009-09-04 18:57:37 +00:00
|
|
|
* 7 : SHEET
|
2008-03-13 05:04:59 +00:00
|
|
|
*
|
2009-09-04 18:57:37 +00:00
|
|
|
* return TRUE if an item was deleted
|
2008-03-13 05:04:59 +00:00
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
bool LocateAndDeleteItem( SCH_EDIT_FRAME* frame, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-04-14 19:22:48 +00:00
|
|
|
SCH_ITEM* DelStruct;
|
2008-03-13 05:04:59 +00:00
|
|
|
SCH_SCREEN* screen = (SCH_SCREEN*) ( frame->GetScreen() );
|
|
|
|
bool item_deleted = FALSE;
|
|
|
|
|
2011-01-25 14:06:17 +00:00
|
|
|
DelStruct = PickStruct( screen->m_Curseur, screen, MARKER_T );
|
2008-03-13 05:04:59 +00:00
|
|
|
if( DelStruct == NULL )
|
2011-01-25 14:06:17 +00:00
|
|
|
DelStruct = PickStruct( screen->m_Curseur, screen, JUNCTION_T );
|
2008-03-13 05:04:59 +00:00
|
|
|
if( DelStruct == NULL )
|
2011-01-25 14:06:17 +00:00
|
|
|
DelStruct = PickStruct( screen->m_Curseur, screen, NO_CONNECT_T );
|
2008-03-13 05:04:59 +00:00
|
|
|
if( DelStruct == NULL )
|
2011-01-25 14:06:17 +00:00
|
|
|
DelStruct = PickStruct( screen->m_Curseur, screen, BUS_ENTRY_T );
|
2008-03-13 05:04:59 +00:00
|
|
|
if( DelStruct == NULL )
|
2011-01-25 14:06:17 +00:00
|
|
|
DelStruct = PickStruct( screen->m_Curseur, screen, WIRE_T | BUS_T );
|
2008-03-13 05:04:59 +00:00
|
|
|
if( DelStruct == NULL )
|
2011-01-25 14:06:17 +00:00
|
|
|
DelStruct = PickStruct( screen->m_Curseur, screen, DRAW_ITEM_T );
|
2008-03-13 05:04:59 +00:00
|
|
|
if( DelStruct == NULL )
|
2011-01-25 14:06:17 +00:00
|
|
|
DelStruct = PickStruct( screen->m_Curseur, screen, TEXT_T | LABEL_T );
|
2008-03-13 05:04:59 +00:00
|
|
|
if( DelStruct == NULL )
|
2011-01-25 14:06:17 +00:00
|
|
|
DelStruct = PickStruct( screen->m_Curseur, screen, COMPONENT_T );
|
2008-03-13 05:04:59 +00:00
|
|
|
if( DelStruct == NULL )
|
2011-01-25 14:06:17 +00:00
|
|
|
DelStruct = PickStruct( screen->m_Curseur, screen, SHEET_T );
|
2008-03-13 05:04:59 +00:00
|
|
|
|
|
|
|
if( DelStruct )
|
|
|
|
{
|
2011-01-12 21:47:54 +00:00
|
|
|
frame->SetRepeatItem( NULL );
|
2008-03-13 05:04:59 +00:00
|
|
|
DeleteStruct( frame->DrawPanel, DC, DelStruct );
|
2011-01-21 19:30:59 +00:00
|
|
|
frame->GetScreen()->TestDanglingEnds( frame->DrawPanel, DC );
|
2010-02-18 20:07:29 +00:00
|
|
|
frame->OnModify( );
|
2008-03-13 05:04:59 +00:00
|
|
|
item_deleted = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return item_deleted;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
/*
|
2009-11-03 13:26:31 +00:00
|
|
|
* Remove definition of a structure in a linked list
|
|
|
|
* Elements of Drawing
|
|
|
|
* DrawStruct * = pointer to the structure
|
|
|
|
* Screen = pointer on the screen of belonging
|
2008-03-13 05:04:59 +00:00
|
|
|
*
|
2009-11-03 13:26:31 +00:00
|
|
|
* Note:
|
2010-12-10 19:47:44 +00:00
|
|
|
* SCH_SHEET_T structures for the screen and structures
|
2009-11-03 13:26:31 +00:00
|
|
|
* Corresponding keys are not.
|
|
|
|
* They must be treated separately
|
2008-03-13 05:04:59 +00:00
|
|
|
*/
|
2009-09-04 18:57:37 +00:00
|
|
|
void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Screen )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM* DrawList;
|
2008-03-13 05:04:59 +00:00
|
|
|
|
|
|
|
if( DrawStruct == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( Screen == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
Screen->SetModify();
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
if( DrawStruct->Type() == SCH_SHEET_LABEL_T )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
2010-06-24 18:31:43 +00:00
|
|
|
// This structure is attached to a sheet, get the parent sheet object.
|
|
|
|
SCH_SHEET_PIN* sheetLabel = (SCH_SHEET_PIN*) DrawStruct;
|
|
|
|
SCH_SHEET* sheet = sheetLabel->GetParent();
|
|
|
|
wxASSERT_MSG( sheet != NULL,
|
|
|
|
wxT( "Sheet label parent not properly set, bad programmer!" ) );
|
|
|
|
sheet->RemoveLabel( sheetLabel );
|
2008-03-13 05:04:59 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-12-02 21:44:03 +00:00
|
|
|
else
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
if( DrawStruct == Screen->GetDrawItems() )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
Screen->SetDrawItems( DrawStruct->Next() );
|
2008-03-13 05:04:59 +00:00
|
|
|
SAFE_DELETE( DrawStruct );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
DrawList = Screen->GetDrawItems();
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
while( DrawList && DrawList->Next() )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
if( DrawList->Next() == DrawStruct )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
DrawList->SetNext( DrawStruct->Next() );
|
2008-03-13 05:04:59 +00:00
|
|
|
SAFE_DELETE( DrawStruct );
|
|
|
|
return;
|
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
DrawList = DrawList->Next();
|
2008-03-13 05:04:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-13 05:04:59 +00:00
|
|
|
void DeleteAllMarkers( int type )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-03-13 05:04:59 +00:00
|
|
|
SCH_SCREEN* screen;
|
2008-04-14 19:22:48 +00:00
|
|
|
SCH_ITEM * DrawStruct, * NextStruct;
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_MARKER* Marker;
|
2010-10-26 20:25:48 +00:00
|
|
|
SCH_SCREENS ScreenList;
|
2008-03-13 05:04:59 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
for( DrawStruct = screen->GetDrawItems(); DrawStruct != NULL; DrawStruct = NextStruct )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
2008-04-14 19:22:48 +00:00
|
|
|
NextStruct = DrawStruct->Next();
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
if( DrawStruct->Type() != SCH_MARKER_T )
|
2008-03-13 05:04:59 +00:00
|
|
|
continue;
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
Marker = (SCH_MARKER*) DrawStruct;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2009-07-06 18:02:26 +00:00
|
|
|
if( Marker->GetMarkerType() != type )
|
2008-03-13 05:04:59 +00:00
|
|
|
continue;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Remove marker */
|
2008-03-13 05:04:59 +00:00
|
|
|
EraseStruct( DrawStruct, screen );
|
|
|
|
}
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|