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"
|
|
|
|
|
|
|
|
#include "program.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
2009-07-07 17:50:02 +00:00
|
|
|
#include "class_marker_sch.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-07-25 07:31:07 +00:00
|
|
|
// Imported function:
|
2009-09-04 18:57:37 +00:00
|
|
|
void DeleteItemsInList( WinEDA_DrawPanel* 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
|
|
|
/*
|
|
|
|
* Count number of items connected to point pos :
|
|
|
|
* pins, end wire or bus, and junctions if TstJunction == TRUE
|
|
|
|
* Return this count
|
2008-03-13 05:04:59 +00:00
|
|
|
*
|
2009-09-04 18:57:37 +00:00
|
|
|
* Used by WinEDA_SchematicFrame::DeleteConnection()
|
2008-03-13 05:04:59 +00:00
|
|
|
*/
|
2009-09-04 18:57:37 +00:00
|
|
|
static int CountConnectedItems( WinEDA_SchematicFrame* frame,
|
|
|
|
SCH_ITEM* ListStruct, wxPoint pos,
|
|
|
|
bool TstJunction )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-04-14 19:22:48 +00:00
|
|
|
SCH_ITEM* Struct;
|
2008-03-13 05:04:59 +00:00
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
if( frame->LocatePinEnd( ListStruct, pos ) )
|
|
|
|
count++;
|
|
|
|
|
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 & STRUCT_DELETED )
|
|
|
|
continue;
|
|
|
|
if( Struct->m_Flags & SKIP_STRUCT )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
if( TstJunction && ( Struct->Type() == DRAW_JUNCTION_STRUCT_TYPE ) )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
#define JUNCTION ( (SCH_JUNCTION*) Struct )
|
2009-11-03 13:26:31 +00:00
|
|
|
if( JUNCTION->m_Pos == pos )
|
2008-03-13 05:04:59 +00:00
|
|
|
count++;
|
|
|
|
#undef JUNCTION
|
|
|
|
}
|
|
|
|
|
|
|
|
if( Struct->Type() != DRAW_SEGMENT_STRUCT_TYPE )
|
|
|
|
continue;
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
#define SEGM ( (SCH_LINE*) Struct )
|
2008-03-13 05:04:59 +00:00
|
|
|
if( SEGM->IsOneEndPointAt( pos ) )
|
|
|
|
count++;
|
|
|
|
#undef SEGM
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-03-13 05:04:59 +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
|
|
|
*
|
2009-09-04 18:57:37 +00:00
|
|
|
* Used by WinEDA_SchematicFrame::DeleteConnection()
|
2008-03-13 05:04:59 +00:00
|
|
|
*/
|
2009-09-04 18:57:37 +00:00
|
|
|
static bool MarkConnected( WinEDA_SchematicFrame* frame, SCH_ITEM* ListStruct,
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_LINE* segment )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-03-13 05:04:59 +00:00
|
|
|
EDA_BaseStruct* Struct;
|
|
|
|
|
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;
|
|
|
|
if( Struct->Type() == DRAW_JUNCTION_STRUCT_TYPE )
|
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
#define JUNCTION ( (SCH_JUNCTION*) Struct )
|
2008-03-13 05:04:59 +00:00
|
|
|
if( segment->IsOneEndPointAt( JUNCTION->m_Pos ) )
|
|
|
|
Struct->m_Flags |= CANDIDATE;
|
|
|
|
continue;
|
|
|
|
#undef JUNCTION
|
|
|
|
}
|
|
|
|
|
|
|
|
if( Struct->Type() != DRAW_SEGMENT_STRUCT_TYPE )
|
|
|
|
continue;
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
#define SEGM ( (SCH_LINE*) Struct )
|
2008-03-13 05:04:59 +00:00
|
|
|
if( segment->IsOneEndPointAt( SEGM->m_Start ) )
|
|
|
|
{
|
|
|
|
if( !frame->LocatePinEnd( ListStruct, SEGM->m_Start ) )
|
|
|
|
{
|
|
|
|
Struct->m_Flags |= CANDIDATE;
|
|
|
|
MarkConnected( frame, ListStruct, SEGM );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( segment->IsOneEndPointAt( SEGM->m_End ) )
|
|
|
|
{
|
|
|
|
if( !frame->LocatePinEnd( ListStruct, SEGM->m_End ) )
|
|
|
|
{
|
|
|
|
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
|
|
|
*/
|
2009-09-04 18:57:37 +00:00
|
|
|
void WinEDA_SchematicFrame::DeleteConnection( bool DeleteFullConnection )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-03-13 05:04:59 +00:00
|
|
|
wxPoint refpos = GetScreen()->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 */
|
2009-09-04 18:57:37 +00:00
|
|
|
for( DelStruct = GetScreen()->EEDrawList; DelStruct != NULL;
|
|
|
|
DelStruct = DelStruct->Next() )
|
2008-03-13 05:04:59 +00:00
|
|
|
DelStruct->m_Flags = 0;
|
|
|
|
|
|
|
|
BreakSegmentOnJunction( (SCH_SCREEN*) GetScreen() );
|
|
|
|
|
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
|
|
|
*/
|
2009-07-26 17:16:42 +00:00
|
|
|
ITEM_PICKER picker(NULL, UR_DELETED);
|
2008-03-13 05:04:59 +00:00
|
|
|
SCH_SCREEN* screen = (SCH_SCREEN*) GetScreen();
|
2009-09-04 18:57:37 +00:00
|
|
|
// Save the list entry point of this screen
|
|
|
|
SCH_ITEM* savedEEDrawList = screen->EEDrawList;
|
2009-07-25 07:31:07 +00:00
|
|
|
DelStruct = GetScreen()->EEDrawList;
|
2008-03-13 05:04:59 +00:00
|
|
|
while( DelStruct
|
2009-09-04 18:57:37 +00:00
|
|
|
&& ( DelStruct = PickStruct( screen->m_Curseur, screen,
|
|
|
|
JUNCTIONITEM | WIREITEM | BUSITEM ) ) != 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();
|
2009-07-25 07:31:07 +00:00
|
|
|
pickList.PushItem(picker);
|
2008-03-13 05:04:59 +00:00
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
DelStruct = DelStruct->Next();
|
2008-03-13 05:04:59 +00:00
|
|
|
screen->EEDrawList = DelStruct;
|
|
|
|
}
|
|
|
|
|
|
|
|
GetScreen()->EEDrawList = savedEEDrawList;
|
|
|
|
|
|
|
|
/* Mark all wires, junctions, .. connected to one of the item to delete
|
|
|
|
*/
|
|
|
|
if( DeleteFullConnection )
|
|
|
|
{
|
2009-09-04 18:57:37 +00:00
|
|
|
for( DelStruct = GetScreen()->EEDrawList; DelStruct != NULL;
|
|
|
|
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 )
|
2008-03-13 05:04:59 +00:00
|
|
|
if( DelStruct->Type() != DRAW_SEGMENT_STRUCT_TYPE )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
MarkConnected( this, GetScreen()->EEDrawList, SEGM );
|
|
|
|
#undef SEGM
|
|
|
|
}
|
|
|
|
|
|
|
|
// Search all removable wires (i.e wire with one new dangling end )
|
2009-09-04 18:57:37 +00:00
|
|
|
for( DelStruct = GetScreen()->EEDrawList; DelStruct != NULL;
|
|
|
|
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
|
|
|
|
|
|
|
if( DelStruct->Type() != DRAW_SEGMENT_STRUCT_TYPE )
|
|
|
|
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 */
|
2008-03-13 05:04:59 +00:00
|
|
|
EDA_BaseStruct* removed_struct;
|
|
|
|
for( removed_struct = GetScreen()->EEDrawList;
|
|
|
|
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;
|
|
|
|
|
|
|
|
if( removed_struct->Type() != DRAW_SEGMENT_STRUCT_TYPE )
|
|
|
|
continue;
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
#define WIRE ( (SCH_LINE*) removed_struct )
|
2008-03-13 05:04:59 +00:00
|
|
|
if( WIRE->IsOneEndPointAt( SEGM->m_Start ) )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
if( WIRE && !CountConnectedItems( this, GetScreen()->EEDrawList,
|
|
|
|
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 */
|
2008-03-13 05:04:59 +00:00
|
|
|
for( removed_struct = GetScreen()->EEDrawList;
|
|
|
|
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;
|
|
|
|
if( removed_struct->Type() != DRAW_SEGMENT_STRUCT_TYPE )
|
|
|
|
continue;
|
|
|
|
if( WIRE->IsOneEndPointAt( SEGM->m_End ) )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( removed_struct &&
|
2009-09-04 18:57:37 +00:00
|
|
|
!CountConnectedItems( this, GetScreen()->EEDrawList,
|
|
|
|
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();
|
2009-07-25 07:31:07 +00:00
|
|
|
pickList.PushItem(picker);
|
2008-03-13 05:04:59 +00:00
|
|
|
|
|
|
|
DelStruct = GetScreen()->EEDrawList;
|
|
|
|
}
|
|
|
|
#undef SEGM
|
|
|
|
}
|
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
// Delete redundant junctions (junctions which connect < 3 end wires
|
|
|
|
// and no pin are removed)
|
|
|
|
for( DelStruct = GetScreen()->EEDrawList; DelStruct != NULL;
|
|
|
|
DelStruct = DelStruct->Next() )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
|
|
|
int count;
|
|
|
|
if( DelStruct->m_Flags & STRUCT_DELETED )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( !(DelStruct->m_Flags & CANDIDATE) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( DelStruct->Type() == DRAW_JUNCTION_STRUCT_TYPE )
|
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
#define JUNCTION ( (SCH_JUNCTION*) DelStruct )
|
2009-09-04 18:57:37 +00:00
|
|
|
count = CountConnectedItems( this, GetScreen()->EEDrawList,
|
|
|
|
JUNCTION->m_Pos, FALSE );
|
2008-03-13 05:04:59 +00:00
|
|
|
if( count <= 2 )
|
|
|
|
{
|
|
|
|
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();
|
2009-07-25 07:31:07 +00:00
|
|
|
pickList.PushItem(picker);
|
2008-03-13 05:04:59 +00:00
|
|
|
}
|
|
|
|
#undef JUNCTION
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delete labels attached to wires
|
|
|
|
wxPoint pos = GetScreen()->m_Curseur;
|
2009-09-04 18:57:37 +00:00
|
|
|
for( DelStruct = GetScreen()->EEDrawList; DelStruct != NULL;
|
|
|
|
DelStruct = DelStruct->Next() )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
|
|
|
if( DelStruct->m_Flags & STRUCT_DELETED )
|
|
|
|
continue;
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
if( DelStruct->Type() != TYPE_SCH_LABEL )
|
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;
|
2008-03-13 05:04:59 +00:00
|
|
|
EDA_BaseStruct* TstStruct =
|
2009-09-04 18:57:37 +00:00
|
|
|
PickStruct( GetScreen()->m_Curseur, GetScreen(),
|
|
|
|
WIREITEM | BUSITEM );
|
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();
|
2009-07-25 07:31:07 +00:00
|
|
|
pickList.PushItem(picker);
|
2008-03-13 05:04:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GetScreen()->m_Curseur = pos;
|
|
|
|
}
|
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
for( DelStruct = GetScreen()->EEDrawList; DelStruct != NULL;
|
|
|
|
DelStruct = DelStruct->Next() )
|
2008-03-13 05:04:59 +00:00
|
|
|
DelStruct->m_Flags = 0;
|
|
|
|
|
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 );
|
2008-03-13 05:04:59 +00:00
|
|
|
GetScreen()->SetModify();
|
|
|
|
}
|
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
|
2009-09-04 18:57:37 +00:00
|
|
|
* 4 : DRAWITEM
|
|
|
|
* 5 : TEXT
|
|
|
|
* 6 : COMPOSANT
|
|
|
|
* 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
|
|
|
*/
|
2009-09-04 18:57:37 +00:00
|
|
|
bool LocateAndDeleteItem( WinEDA_SchematicFrame* 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;
|
|
|
|
|
|
|
|
DelStruct = PickStruct( screen->m_Curseur, screen, MARKERITEM );
|
|
|
|
if( DelStruct == NULL )
|
|
|
|
DelStruct = PickStruct( screen->m_Curseur, screen, JUNCTIONITEM );
|
|
|
|
if( DelStruct == NULL )
|
|
|
|
DelStruct = PickStruct( screen->m_Curseur, screen, NOCONNECTITEM );
|
|
|
|
if( DelStruct == NULL )
|
|
|
|
DelStruct = PickStruct( screen->m_Curseur, screen, RACCORDITEM );
|
|
|
|
if( DelStruct == NULL )
|
|
|
|
DelStruct = PickStruct( screen->m_Curseur, screen, WIREITEM | BUSITEM );
|
|
|
|
if( DelStruct == NULL )
|
|
|
|
DelStruct = PickStruct( screen->m_Curseur, screen, DRAWITEM );
|
|
|
|
if( DelStruct == NULL )
|
2009-09-04 18:57:37 +00:00
|
|
|
DelStruct = PickStruct( screen->m_Curseur, screen,
|
|
|
|
TEXTITEM | LABELITEM );
|
2008-03-13 05:04:59 +00:00
|
|
|
if( DelStruct == NULL )
|
|
|
|
DelStruct = PickStruct( screen->m_Curseur, screen, LIBITEM );
|
|
|
|
if( DelStruct == NULL )
|
|
|
|
DelStruct = PickStruct( screen->m_Curseur, screen, SHEETITEM );
|
|
|
|
|
|
|
|
if( DelStruct )
|
|
|
|
{
|
|
|
|
g_ItemToRepeat = NULL;
|
|
|
|
DeleteStruct( frame->DrawPanel, DC, DelStruct );
|
|
|
|
frame->TestDanglingEnds( frame->GetScreen()->EEDrawList, DC );
|
|
|
|
frame->GetScreen()->SetModify();
|
|
|
|
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:
|
|
|
|
* DRAW_SHEET_STRUCT_TYPE structures for the screen and structures
|
|
|
|
* 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
|
|
|
{
|
2008-03-13 05:04:59 +00:00
|
|
|
EDA_BaseStruct* DrawList;
|
2009-11-04 20:46:53 +00:00
|
|
|
SCH_SHEET_PIN* SheetLabel, * NextLabel;
|
2008-03-13 05:04:59 +00:00
|
|
|
|
|
|
|
if( DrawStruct == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( Screen == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
Screen->SetModify();
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
if( DrawStruct->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
2009-07-25 07:31:07 +00:00
|
|
|
//this structure is attached to a sheet , which we must find.
|
2008-03-13 05:04:59 +00:00
|
|
|
DrawList = Screen->EEDrawList;
|
2008-11-24 06:53:43 +00:00
|
|
|
for( ; DrawList != NULL; DrawList = DrawList->Next() )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
|
|
|
if( DrawList->Type() != DRAW_SHEET_STRUCT_TYPE )
|
|
|
|
continue;
|
|
|
|
|
2009-07-25 07:31:07 +00:00
|
|
|
/* See if our item is in this Sheet */
|
2009-11-04 20:46:53 +00:00
|
|
|
SheetLabel = ( (SCH_SHEET*) DrawList )->m_Label;
|
2008-03-13 05:04:59 +00:00
|
|
|
if( SheetLabel == NULL )
|
|
|
|
continue;
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
if( SheetLabel == (SCH_SHEET_PIN*) DrawStruct )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
( (SCH_SHEET*) DrawList )->m_Label =
|
|
|
|
(SCH_SHEET_PIN*) SheetLabel->Next();
|
2008-03-13 05:04:59 +00:00
|
|
|
|
|
|
|
SAFE_DELETE( DrawStruct );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
while( SheetLabel->Next() )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
NextLabel = (SCH_SHEET_PIN*) SheetLabel->Next();
|
2009-09-04 18:57:37 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
if( NextLabel == (SCH_SHEET_PIN*) DrawStruct )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
SheetLabel->SetNext( (EDA_BaseStruct*) NextLabel->Next() );
|
2008-03-13 05:04:59 +00:00
|
|
|
SAFE_DELETE( DrawStruct );
|
|
|
|
return;
|
2009-09-04 18:57:37 +00:00
|
|
|
|
2008-03-13 05:04:59 +00:00
|
|
|
}
|
|
|
|
SheetLabel = NextLabel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-09-04 18:57:37 +00:00
|
|
|
|
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
|
|
|
{
|
|
|
|
if( DrawStruct == Screen->EEDrawList )
|
|
|
|
{
|
2008-04-14 19:22:48 +00:00
|
|
|
Screen->EEDrawList = DrawStruct->Next();
|
2008-03-13 05:04:59 +00:00
|
|
|
SAFE_DELETE( DrawStruct );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DrawList = Screen->EEDrawList;
|
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;
|
2008-03-13 05:04:59 +00:00
|
|
|
|
|
|
|
EDA_ScreenList ScreenList;
|
|
|
|
|
2009-09-04 18:57:37 +00:00
|
|
|
for( screen = ScreenList.GetFirst(); screen != NULL;
|
|
|
|
screen = ScreenList.GetNext() )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
2009-09-04 18:57:37 +00:00
|
|
|
for( DrawStruct = screen->EEDrawList; DrawStruct != NULL;
|
|
|
|
DrawStruct = NextStruct )
|
2008-03-13 05:04:59 +00:00
|
|
|
{
|
2008-04-14 19:22:48 +00:00
|
|
|
NextStruct = DrawStruct->Next();
|
2009-12-02 21:44:03 +00:00
|
|
|
if( DrawStruct->Type() != TYPE_SCH_MARKER )
|
2008-03-13 05:04:59 +00:00
|
|
|
continue;
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
Marker = (SCH_MARKER*) DrawStruct;
|
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
|
|
|
}
|