2009-11-03 13:26:31 +00:00
|
|
|
/**************************************/
|
|
|
|
/* Code to handle schematic clean up. */
|
|
|
|
/**************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
2009-06-13 17:06:07 +00:00
|
|
|
#include "trigo.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "confirm.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "macros.h"
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "class_sch_screen.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "netlist.h"
|
2010-11-11 21:10:27 +00:00
|
|
|
#include "sch_items.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Routine to start/end segment (BUS or wires) on junctions.
|
2007-09-20 21:06:49 +00:00
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
void BreakSegmentOnJunction( SCH_SCREEN* Screen )
|
|
|
|
{
|
2008-04-14 19:22:48 +00:00
|
|
|
SCH_ITEM* DrawList;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
|
|
|
if( Screen == NULL )
|
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
DisplayError( NULL,
|
2009-11-03 13:26:31 +00:00
|
|
|
wxT( "BreakSegmentOnJunction() error: NULL screen" ) );
|
2007-09-20 21:06:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
DrawList = Screen->GetDrawItems();
|
|
|
|
|
2007-09-20 21:06:49 +00:00
|
|
|
while( DrawList )
|
|
|
|
{
|
|
|
|
switch( DrawList->Type() )
|
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_JUNCTION_T:
|
2007-09-20 21:06:49 +00:00
|
|
|
#undef STRUCT
|
2009-12-02 21:44:03 +00:00
|
|
|
#define STRUCT ( (SCH_JUNCTION*) DrawList )
|
2007-09-20 21:06:49 +00:00
|
|
|
BreakSegment( Screen, STRUCT->m_Pos );
|
|
|
|
break;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_BUS_ENTRY_T:
|
2007-09-20 21:06:49 +00:00
|
|
|
#undef STRUCT
|
2009-12-02 21:44:03 +00:00
|
|
|
#define STRUCT ( (SCH_BUS_ENTRY*) DrawList )
|
2007-09-20 21:06:49 +00:00
|
|
|
BreakSegment( Screen, STRUCT->m_Pos );
|
|
|
|
BreakSegment( Screen, STRUCT->m_End() );
|
|
|
|
break;
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_LINE_T:
|
|
|
|
case SCH_NO_CONNECT_T:
|
|
|
|
case SCH_LABEL_T:
|
|
|
|
case SCH_GLOBAL_LABEL_T:
|
|
|
|
case SCH_HIERARCHICAL_LABEL_T:
|
|
|
|
case SCH_COMPONENT_T:
|
|
|
|
case SCH_POLYLINE_T:
|
|
|
|
case SCH_MARKER_T:
|
|
|
|
case SCH_TEXT_T:
|
|
|
|
case SCH_SHEET_T:
|
|
|
|
case SCH_SHEET_LABEL_T:
|
2007-09-20 21:06:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-04-14 19:22:48 +00:00
|
|
|
DrawList = DrawList->Next();
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-25 07:31:07 +00:00
|
|
|
/* Break a segment ( BUS, WIRE ) int 2 segments at location aBreakpoint,
|
|
|
|
* if aBreakpoint in on segment segment
|
|
|
|
* ( excluding ends)
|
|
|
|
* fill aPicklist with modified items if non null
|
2007-09-20 21:06:49 +00:00
|
|
|
*/
|
2009-11-03 13:26:31 +00:00
|
|
|
void BreakSegment( SCH_SCREEN* aScreen, wxPoint aBreakpoint )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_LINE* segment, * NewSegment;
|
2009-11-03 13:26:31 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
for( SCH_ITEM* DrawList = aScreen->GetDrawItems(); DrawList; DrawList = DrawList->Next() )
|
2007-09-20 21:06:49 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
if( DrawList->Type() != SCH_LINE_T )
|
2009-11-03 13:26:31 +00:00
|
|
|
continue;
|
2009-06-13 17:06:07 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
segment = (SCH_LINE*) DrawList;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-07-25 07:31:07 +00:00
|
|
|
if( !TestSegmentHit( aBreakpoint, segment->m_Start, segment->m_End, 0 ) )
|
|
|
|
continue;
|
2007-09-20 21:06:49 +00:00
|
|
|
|
2009-11-23 20:18:47 +00:00
|
|
|
/* ???
|
|
|
|
* Segment connecte: doit etre coupe en 2 si px,py
|
2009-11-03 13:26:31 +00:00
|
|
|
* n'est
|
2009-07-25 07:31:07 +00:00
|
|
|
* pas une extremite */
|
2009-11-03 13:26:31 +00:00
|
|
|
if( ( segment->m_Start == aBreakpoint )
|
|
|
|
|| ( segment->m_End == aBreakpoint ) )
|
2009-07-25 07:31:07 +00:00
|
|
|
continue;
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Here we must cut the segment into 2. */
|
2009-07-25 07:31:07 +00:00
|
|
|
NewSegment = segment->GenCopy();
|
|
|
|
NewSegment->m_Start = aBreakpoint;
|
|
|
|
segment->m_End = NewSegment->m_Start;
|
|
|
|
NewSegment->SetNext( segment->Next() );
|
|
|
|
segment->SetNext( NewSegment );
|
|
|
|
DrawList = NewSegment;
|
2007-09-20 21:06:49 +00:00
|
|
|
}
|
|
|
|
}
|