2009-11-03 13:26:31 +00:00
|
|
|
/***************************************************************/
|
|
|
|
/* Code for handling creation of buses, wires, and junctions. */
|
|
|
|
/***************************************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "wxEeschemaStruct.h"
|
|
|
|
#include "class_sch_screen.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2010-10-08 20:40:57 +00:00
|
|
|
#include "lib_draw_item.h"
|
2010-10-22 12:11:52 +00:00
|
|
|
#include "lib_pin.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
2010-12-21 15:13:09 +00:00
|
|
|
#include "sch_bus_entry.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"
|
|
|
|
#include "sch_no_connect.h"
|
|
|
|
#include "sch_polyline.h"
|
2010-11-11 21:10:27 +00:00
|
|
|
#include "sch_text.h"
|
|
|
|
#include "sch_component.h"
|
|
|
|
#include "sch_sheet.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Routines Locales */
|
2011-01-21 19:30:59 +00:00
|
|
|
static void Show_Polyline_in_Ghost( EDA_DRAW_PANEL* panel, wxDC* DC, bool erase );
|
|
|
|
static void AbortCreateNewLine( EDA_DRAW_PANEL* Panel, wxDC* DC );
|
2007-08-20 01:20:48 +00:00
|
|
|
static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer );
|
2010-12-08 20:12:46 +00:00
|
|
|
static bool IsJunctionNeeded( SCH_EDIT_FRAME* frame, wxPoint& pos );
|
2009-12-02 21:44:03 +00:00
|
|
|
static void ComputeBreakPoint( SCH_LINE* segment, const wxPoint& new_pos );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
SCH_ITEM* s_OldWiresList;
|
2009-11-03 13:26:31 +00:00
|
|
|
wxPoint s_ConnexionStartPoint;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
/* Replace the wires in screen->GetDrawItems() by s_OldWiresList wires.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
static void RestoreOldWires( SCH_SCREEN* screen )
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
SCH_ITEM* item;
|
|
|
|
SCH_ITEM* next_item;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
for( item = screen->GetDrawItems(); item != NULL; item = next_item )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-04-14 19:22:48 +00:00
|
|
|
next_item = item->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_JUNCTION_T:
|
|
|
|
case SCH_LINE_T:
|
2007-08-20 01:20:48 +00:00
|
|
|
screen->RemoveFromDrawList( item );
|
|
|
|
delete item;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while( s_OldWiresList )
|
|
|
|
{
|
2008-04-14 19:22:48 +00:00
|
|
|
next_item = s_OldWiresList->Next();
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
s_OldWiresList->SetNext( screen->GetDrawItems() );
|
|
|
|
screen->SetDrawItems( s_OldWiresList );
|
2009-11-03 13:26:31 +00:00
|
|
|
s_OldWiresList = next_item;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
/**
|
|
|
|
* Mouse capture callback for drawing line segments.
|
|
|
|
*/
|
2011-01-21 19:30:59 +00:00
|
|
|
static void DrawSegment( EDA_DRAW_PANEL* aPanel, wxDC* aDC, bool aErase )
|
2010-12-08 20:12:46 +00:00
|
|
|
{
|
|
|
|
SCH_LINE* CurrentLine = (SCH_LINE*) aPanel->GetScreen()->GetCurItem();
|
|
|
|
SCH_LINE* segment;
|
|
|
|
int color;
|
|
|
|
|
|
|
|
if( CurrentLine == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
color = ReturnLayerColor( CurrentLine->GetLayer() ) ^ HIGHLIGHT_FLAG;
|
|
|
|
|
|
|
|
if( aErase )
|
|
|
|
{
|
|
|
|
segment = CurrentLine;
|
|
|
|
|
|
|
|
while( segment )
|
|
|
|
{
|
|
|
|
if( !segment->IsNull() ) // Redraw if segment length != 0
|
2011-01-10 16:50:40 +00:00
|
|
|
segment->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, color );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
|
|
|
segment = segment->Next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wxPoint endpos = aPanel->GetScreen()->m_Curseur;
|
|
|
|
|
|
|
|
if( g_HVLines ) /* Coerce the line to vertical or horizontal one: */
|
|
|
|
ComputeBreakPoint( CurrentLine, endpos );
|
|
|
|
else
|
|
|
|
CurrentLine->m_End = endpos;
|
|
|
|
|
|
|
|
segment = CurrentLine;
|
|
|
|
|
|
|
|
while( segment )
|
|
|
|
{
|
|
|
|
if( !segment->IsNull() ) // Redraw if segment length != 0
|
2011-01-10 16:50:40 +00:00
|
|
|
segment->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, color );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
|
|
|
segment = segment->Next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-06 13:19:40 +00:00
|
|
|
/* Creates a new segment ( WIRE, BUS ),
|
|
|
|
* or terminates the current segment
|
2009-11-03 13:26:31 +00:00
|
|
|
* If the end of the current segment is on an other segment, place a junction
|
|
|
|
* if needed and terminates the command
|
2009-10-06 13:19:40 +00:00
|
|
|
* If the end of the current segment is on a pin, terminates the command
|
|
|
|
* In others cases starts a new segment
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type )
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
|
|
|
SCH_LINE* oldsegment, * newsegment, * nextsegment;
|
|
|
|
wxPoint cursorpos = GetScreen()->m_Curseur;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( GetScreen()->GetCurItem() && (GetScreen()->GetCurItem()->m_Flags == 0) )
|
|
|
|
GetScreen()->SetCurItem( NULL );
|
|
|
|
|
|
|
|
if( GetScreen()->GetCurItem() )
|
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( GetScreen()->GetCurItem()->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_LINE_T:
|
|
|
|
case SCH_POLYLINE_T:
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
oldsegment = newsegment = (SCH_LINE*) GetScreen()->GetCurItem();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
if( !newsegment ) /* first point : Create first wire or bus */
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
s_ConnexionStartPoint = cursorpos;
|
2010-12-10 19:47:44 +00:00
|
|
|
s_OldWiresList = GetScreen()->ExtractWires( TRUE );
|
2011-01-21 19:30:59 +00:00
|
|
|
GetScreen()->SchematicCleanUp( DrawPanel );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
switch( type )
|
|
|
|
{
|
|
|
|
default:
|
2009-12-02 21:44:03 +00:00
|
|
|
newsegment = new SCH_LINE( cursorpos, LAYER_NOTES );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LAYER_WIRE:
|
2009-12-02 21:44:03 +00:00
|
|
|
newsegment = new SCH_LINE( cursorpos, LAYER_WIRE );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* A junction will be created later, when we'll know the
|
|
|
|
* segment end position, and if the junction is really needed */
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LAYER_BUS:
|
2009-12-02 21:44:03 +00:00
|
|
|
newsegment = new SCH_LINE( cursorpos, LAYER_BUS );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
newsegment->m_Flags = IS_NEW;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
|
|
|
if( g_HVLines ) // We need 2 segments to go from a given start pin to an end point
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-12-21 15:13:09 +00:00
|
|
|
nextsegment = new SCH_LINE( *newsegment );
|
2007-08-20 01:20:48 +00:00
|
|
|
nextsegment->m_Flags = IS_NEW;
|
2008-11-24 06:53:43 +00:00
|
|
|
newsegment->SetNext( nextsegment );
|
|
|
|
nextsegment->SetBack( newsegment );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->SetCurItem( newsegment );
|
2010-12-08 20:12:46 +00:00
|
|
|
DrawPanel->ManageCurseur = DrawSegment;
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->ForceCloseManageCurseur = AbortCreateNewLine;
|
2011-01-12 21:47:54 +00:00
|
|
|
m_itemToRepeat = NULL;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2010-12-08 20:12:46 +00:00
|
|
|
else // A segment is in progress: terminates the current segment and add a new segment.
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
nextsegment = oldsegment->Next();
|
2010-12-08 20:12:46 +00:00
|
|
|
|
|
|
|
if( !g_HVLines )
|
2009-11-03 13:26:31 +00:00
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
// if only one segment is needed and it has length = 0, do not create a new one.
|
2007-08-20 01:20:48 +00:00
|
|
|
if( oldsegment->IsNull() )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
/* if we want 2 segment and the last two have len = 0, do not
|
|
|
|
* create a new one */
|
2007-08-20 01:20:48 +00:00
|
|
|
if( oldsegment->IsNull() && nextsegment && nextsegment->IsNull() )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
|
2009-10-06 13:19:40 +00:00
|
|
|
/* Creates the new segment, or terminates the command
|
2009-11-03 13:26:31 +00:00
|
|
|
* if the end point is on a pin, junction or an other wire or bus */
|
2009-10-06 13:19:40 +00:00
|
|
|
if( IsTerminalPoint( GetScreen(), cursorpos, oldsegment->GetLayer() ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
EndSegment( DC );
|
|
|
|
return;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
oldsegment->SetNext( GetScreen()->GetDrawItems() );
|
|
|
|
GetScreen()->SetDrawItems( oldsegment );
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->CursorOff( DC ); // Erase schematic cursor
|
2011-01-10 16:50:40 +00:00
|
|
|
oldsegment->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->CursorOn( DC ); // Display schematic cursor
|
|
|
|
|
|
|
|
/* Create a new segment, and chain it after the current new segment */
|
|
|
|
if( nextsegment )
|
|
|
|
{
|
2010-12-21 15:13:09 +00:00
|
|
|
newsegment = new SCH_LINE( *nextsegment );
|
2007-08-20 01:20:48 +00:00
|
|
|
nextsegment->m_Start = newsegment->m_End;
|
2008-11-24 06:53:43 +00:00
|
|
|
nextsegment->SetNext( NULL );
|
|
|
|
nextsegment->SetBack( newsegment );
|
|
|
|
newsegment->SetNext( nextsegment );
|
|
|
|
newsegment->SetBack( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-12-21 15:13:09 +00:00
|
|
|
newsegment = new SCH_LINE( *oldsegment );
|
2007-08-20 01:20:48 +00:00
|
|
|
newsegment->m_Start = oldsegment->m_End;
|
|
|
|
}
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
newsegment->m_End = cursorpos;
|
|
|
|
oldsegment->m_Flags = SELECTED;
|
|
|
|
newsegment->m_Flags = IS_NEW;
|
|
|
|
GetScreen()->SetCurItem( newsegment );
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
2009-11-03 13:26:31 +00:00
|
|
|
|
|
|
|
/* This is the first segment: Now we know the start segment position.
|
|
|
|
* Create a junction if needed. Note: a junction can be needed later,
|
|
|
|
* if the new segment is merged (after a cleanup) with an older one
|
|
|
|
* (tested when the connection will be finished)*/
|
2007-08-20 01:20:48 +00:00
|
|
|
if( oldsegment->m_Start == s_ConnexionStartPoint )
|
2009-11-03 13:26:31 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( IsJunctionNeeded( this, s_ConnexionStartPoint ) )
|
|
|
|
CreateNewJunctionStruct( DC, s_ConnexionStartPoint );
|
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Called to terminate a bus, wire, or line creation
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::EndSegment( wxDC* DC )
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
|
|
|
SCH_LINE* firstsegment = (SCH_LINE*) GetScreen()->GetCurItem();
|
|
|
|
SCH_LINE* lastsegment = firstsegment;
|
|
|
|
SCH_LINE* segment;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( firstsegment == NULL )
|
|
|
|
return;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
if( ( firstsegment->m_Flags & IS_NEW ) == 0 )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* Delete Null segments and Put line it in Drawlist */
|
|
|
|
lastsegment = firstsegment;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
while( lastsegment )
|
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_LINE* nextsegment = lastsegment->Next();
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( lastsegment->IsNull() )
|
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_LINE* previous_segment = lastsegment->Back();
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( firstsegment == lastsegment )
|
|
|
|
firstsegment = nextsegment;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( nextsegment )
|
2008-11-24 06:53:43 +00:00
|
|
|
nextsegment->SetBack( NULL );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( previous_segment )
|
2008-11-24 06:53:43 +00:00
|
|
|
previous_segment->SetNext( nextsegment );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
delete lastsegment;
|
|
|
|
}
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
lastsegment = nextsegment;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* put the segment list to the main linked list */
|
|
|
|
segment = lastsegment = firstsegment;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
while( segment )
|
|
|
|
{
|
|
|
|
lastsegment = segment;
|
2009-11-03 13:26:31 +00:00
|
|
|
segment = segment->Next();
|
2010-12-08 20:12:46 +00:00
|
|
|
lastsegment->SetNext( GetScreen()->GetDrawItems() );
|
|
|
|
GetScreen()->SetDrawItems( lastsegment );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
|
|
|
GetScreen()->SetCurItem( NULL );
|
|
|
|
|
|
|
|
wxPoint end_point, alt_end_point;
|
|
|
|
|
|
|
|
/* A junction can be needed to connect the last segment
|
|
|
|
* usually to m_End coordinate.
|
2009-11-03 13:26:31 +00:00
|
|
|
* But if the last segment is removed by a cleanup, because of redundancy,
|
|
|
|
* a junction can be needed to connect the previous segment m_End
|
|
|
|
* coordinate with is also the lastsegment->m_Start coordinate */
|
2007-08-20 01:20:48 +00:00
|
|
|
if( lastsegment )
|
|
|
|
{
|
|
|
|
end_point = lastsegment->m_End;
|
|
|
|
alt_end_point = lastsegment->m_Start;
|
|
|
|
}
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
GetScreen()->SchematicCleanUp( DrawPanel );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
/* clear flags and find last segment entered, for repeat function */
|
2010-12-08 20:12:46 +00:00
|
|
|
segment = (SCH_LINE*) GetScreen()->GetDrawItems();
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
while( segment )
|
|
|
|
{
|
|
|
|
if( segment->m_Flags )
|
|
|
|
{
|
2011-01-12 21:47:54 +00:00
|
|
|
if( !m_itemToRepeat )
|
|
|
|
m_itemToRepeat = segment;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
segment->m_Flags = 0;
|
2008-11-24 06:53:43 +00:00
|
|
|
segment = segment->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Automatic place of a junction on the end point, if needed
|
|
|
|
if( lastsegment )
|
|
|
|
{
|
|
|
|
if( IsJunctionNeeded( this, end_point ) )
|
|
|
|
CreateNewJunctionStruct( DC, end_point );
|
|
|
|
else if( IsJunctionNeeded( this, alt_end_point ) )
|
|
|
|
CreateNewJunctionStruct( DC, alt_end_point );
|
|
|
|
}
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Automatic place of a junction on the start point if necessary because
|
|
|
|
* the cleanup can suppress intermediate points by merging wire segments */
|
2007-08-20 01:20:48 +00:00
|
|
|
if( IsJunctionNeeded( this, s_ConnexionStartPoint ) )
|
|
|
|
CreateNewJunctionStruct( DC, s_ConnexionStartPoint );
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
GetScreen()->TestDanglingEnds( DrawPanel, DC );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
/* Redraw wires and junctions which can be changed by TestDanglingEnds() */
|
|
|
|
DrawPanel->CursorOff( DC ); // Erase schematic cursor
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM* item = GetScreen()->GetDrawItems();
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
while( item )
|
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-12-10 19:47:44 +00:00
|
|
|
case SCH_JUNCTION_T:
|
|
|
|
case SCH_LINE_T:
|
2009-11-03 13:26:31 +00:00
|
|
|
DrawPanel->PostDirtyRect( item->GetBoundingBox() );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
item = item->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DrawPanel->CursorOn( DC ); // Display schematic cursor
|
|
|
|
|
2009-07-26 17:16:42 +00:00
|
|
|
SaveCopyInUndoList( s_OldWiresList, UR_WIRE_IMAGE );
|
2007-08-20 01:20:48 +00:00
|
|
|
s_OldWiresList = NULL;
|
|
|
|
|
2010-02-18 20:07:29 +00:00
|
|
|
OnModify( );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* compute the middle coordinate for 2 segments, from the start point to
|
|
|
|
* new_pos
|
2007-08-20 01:20:48 +00:00
|
|
|
* with the 2 segments kept H or V only
|
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
static void ComputeBreakPoint( SCH_LINE* segment, const wxPoint& new_pos )
|
|
|
|
{
|
|
|
|
SCH_LINE* nextsegment = segment->Next();
|
|
|
|
wxPoint middle_position = new_pos;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( nextsegment == NULL )
|
|
|
|
return;
|
|
|
|
#if 0
|
|
|
|
if( ABS( middle_position.x - segment->m_Start.x ) <
|
2009-12-02 21:44:03 +00:00
|
|
|
ABS( middle_position.y - segment->m_Start.y ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
middle_position.x = segment->m_Start.x;
|
|
|
|
else
|
|
|
|
middle_position.y = segment->m_Start.y;
|
2007-05-06 16:03:28 +00:00
|
|
|
#else
|
2007-08-20 01:20:48 +00:00
|
|
|
int iDx = segment->m_End.x - segment->m_Start.x;
|
|
|
|
int iDy = segment->m_End.y - segment->m_Start.y;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
|
|
|
if( iDy != 0 ) // keep the first segment orientation (currently horizontal)
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
middle_position.x = segment->m_Start.x;
|
|
|
|
}
|
2010-12-08 20:12:46 +00:00
|
|
|
else if( iDx != 0 ) // keep the first segment orientation (currently vertical)
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
middle_position.y = segment->m_Start.y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( ABS( middle_position.x - segment->m_Start.x ) <
|
2009-12-02 21:44:03 +00:00
|
|
|
ABS( middle_position.y - segment->m_Start.y ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
middle_position.x = segment->m_Start.x;
|
|
|
|
else
|
|
|
|
middle_position.y = segment->m_Start.y;
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
#endif
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
segment->m_End = middle_position;
|
|
|
|
|
|
|
|
nextsegment->m_Start = middle_position;
|
|
|
|
nextsegment->m_End = new_pos;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
/* Drawing Polyline phantom at the displacement of the cursor
|
|
|
|
*/
|
2011-01-21 19:30:59 +00:00
|
|
|
static void Show_Polyline_in_Ghost( EDA_DRAW_PANEL* panel, wxDC* DC, bool erase )
|
2009-11-03 13:26:31 +00:00
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_POLYLINE* NewPoly = (SCH_POLYLINE*) panel->GetScreen()->GetCurItem();
|
|
|
|
int color;
|
|
|
|
wxPoint endpos;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
endpos = panel->GetScreen()->m_Curseur;
|
2008-04-14 19:22:48 +00:00
|
|
|
color = ReturnLayerColor( NewPoly->GetLayer() );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
GRSetDrawMode( DC, g_XorMode );
|
|
|
|
|
2009-01-02 17:07:50 +00:00
|
|
|
int idx = NewPoly->GetCornerCount() - 1;
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( g_HVLines )
|
|
|
|
{
|
|
|
|
/* Coerce the line to vertical or horizontal one: */
|
2009-01-02 17:07:50 +00:00
|
|
|
if( ABS( endpos.x - NewPoly->m_PolyPoints[idx].x ) <
|
|
|
|
ABS( endpos.y - NewPoly->m_PolyPoints[idx].y ) )
|
|
|
|
endpos.x = NewPoly->m_PolyPoints[idx].x;
|
2007-08-20 01:20:48 +00:00
|
|
|
else
|
2009-01-02 17:07:50 +00:00
|
|
|
endpos.y = NewPoly->m_PolyPoints[idx].y;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( erase )
|
2011-01-10 16:50:40 +00:00
|
|
|
NewPoly->Draw( panel, DC, wxPoint( 0, 0 ), g_XorMode, color );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-01-02 17:07:50 +00:00
|
|
|
NewPoly->m_PolyPoints[idx] = endpos;
|
2011-01-10 16:50:40 +00:00
|
|
|
NewPoly->Draw( panel, DC, wxPoint( 0, 0 ), g_XorMode, color );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*
|
2009-11-03 13:26:31 +00:00
|
|
|
* Erase the last trace or the element at the current mouse position.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::DeleteCurrentSegment( wxDC* DC )
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2011-01-12 21:47:54 +00:00
|
|
|
m_itemToRepeat = NULL;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
if( ( GetScreen()->GetCurItem() == NULL )
|
|
|
|
|| ( ( GetScreen()->GetCurItem()->m_Flags & IS_NEW ) == 0 ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Cancel trace in progress */
|
2010-12-10 19:47:44 +00:00
|
|
|
if( GetScreen()->GetCurItem()->Type() == SCH_POLYLINE_T )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
Show_Polyline_in_Ghost( DrawPanel, DC, FALSE );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
DrawSegment( DrawPanel, DC, FALSE );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2010-12-10 19:47:44 +00:00
|
|
|
EraseStruct( (SCH_ITEM*) GetScreen()->GetCurItem(), GetScreen() );
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
GetScreen()->SetCurItem( NULL );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Routine to create new connection struct.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
SCH_JUNCTION* SCH_EDIT_FRAME::CreateNewJunctionStruct( wxDC* DC,
|
|
|
|
const wxPoint& pos,
|
|
|
|
bool PutInUndoList )
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
|
|
|
SCH_JUNCTION* NewJunction;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
NewJunction = new SCH_JUNCTION( pos );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-01-12 21:47:54 +00:00
|
|
|
m_itemToRepeat = NewJunction;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->CursorOff( DC ); // Erase schematic cursor
|
2011-01-10 16:50:40 +00:00
|
|
|
NewJunction->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->CursorOn( DC ); // Display schematic cursor
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
NewJunction->SetNext( GetScreen()->GetDrawItems() );
|
|
|
|
GetScreen()->SetDrawItems( NewJunction );
|
|
|
|
OnModify();
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( PutInUndoList )
|
2009-07-26 17:16:42 +00:00
|
|
|
SaveCopyInUndoList( NewJunction, UR_NEW );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
return NewJunction;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Routine to create new NoConnect struct. */
|
2010-12-08 20:12:46 +00:00
|
|
|
SCH_NO_CONNECT* SCH_EDIT_FRAME::CreateNewNoConnectStruct( wxDC* DC )
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
|
|
|
SCH_NO_CONNECT* NewNoConnect;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
NewNoConnect = new SCH_NO_CONNECT( GetScreen()->m_Curseur );
|
2011-01-12 21:47:54 +00:00
|
|
|
m_itemToRepeat = NewNoConnect;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->CursorOff( DC ); // Erase schematic cursor
|
2011-01-10 16:50:40 +00:00
|
|
|
NewNoConnect->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->CursorOn( DC ); // Display schematic cursor
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
NewNoConnect->SetNext( GetScreen()->GetDrawItems() );
|
|
|
|
GetScreen()->SetDrawItems( NewNoConnect );
|
|
|
|
OnModify();
|
2009-07-26 17:16:42 +00:00
|
|
|
SaveCopyInUndoList( NewNoConnect, UR_NEW );
|
2007-08-20 01:20:48 +00:00
|
|
|
return NewNoConnect;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Abort function for wire, bus or line creation
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2011-01-21 19:30:59 +00:00
|
|
|
static void AbortCreateNewLine( EDA_DRAW_PANEL* Panel, wxDC* DC )
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
SCH_SCREEN* Screen = (SCH_SCREEN*) Panel->GetScreen();
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
if( Screen->GetCurItem() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
Panel->ManageCurseur = NULL;
|
|
|
|
Panel->ForceCloseManageCurseur = NULL;
|
2008-04-14 19:22:48 +00:00
|
|
|
EraseStruct( (SCH_ITEM*) Screen->GetCurItem(), (SCH_SCREEN*) Screen );
|
2007-08-20 01:20:48 +00:00
|
|
|
Screen->SetCurItem( NULL );
|
|
|
|
RestoreOldWires( Screen );
|
2009-08-28 07:11:56 +00:00
|
|
|
Panel->Refresh();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
2011-01-12 21:47:54 +00:00
|
|
|
{
|
|
|
|
SCH_EDIT_FRAME* parent = ( SCH_EDIT_FRAME* ) Panel->GetParent();
|
|
|
|
|
|
|
|
parent->SetRepeatItem( NULL );
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Clear m_Flags which is used in edit functions: */
|
2010-12-08 20:12:46 +00:00
|
|
|
SCH_ITEM* item = Screen->GetDrawItems();
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
while( item )
|
|
|
|
{
|
|
|
|
item->m_Flags = 0;
|
2008-04-14 19:22:48 +00:00
|
|
|
item = item->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Repeat the last item placement.
|
|
|
|
* Bus lines, text, labels
|
|
|
|
* Labels that end with a number will be incremented.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC )
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2011-01-12 21:47:54 +00:00
|
|
|
if( m_itemToRepeat == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
|
2011-01-12 21:47:54 +00:00
|
|
|
m_itemToRepeat = m_itemToRepeat->Clone();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-01-12 21:47:54 +00:00
|
|
|
if( m_itemToRepeat->Type() == SCH_COMPONENT_T ) // If repeat component then put in move mode
|
2010-12-21 15:13:09 +00:00
|
|
|
{
|
2011-01-12 21:47:54 +00:00
|
|
|
wxPoint pos = GetScreen()->m_Curseur - ( (SCH_COMPONENT*) m_itemToRepeat )->m_Pos;
|
|
|
|
m_itemToRepeat->m_Flags = IS_NEW;
|
|
|
|
( (SCH_COMPONENT*) m_itemToRepeat )->m_TimeStamp = GetTimeStamp();
|
|
|
|
m_itemToRepeat->Move( pos );
|
|
|
|
m_itemToRepeat->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
|
|
|
|
StartMovePart( (SCH_COMPONENT*) m_itemToRepeat, DC );
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
2010-12-21 15:13:09 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-01-12 21:47:54 +00:00
|
|
|
m_itemToRepeat->Move( wxPoint( g_RepeatStep.GetWidth(), g_RepeatStep.GetHeight() ) );
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2011-01-12 21:47:54 +00:00
|
|
|
if( m_itemToRepeat->Type() == SCH_TEXT_T
|
|
|
|
|| m_itemToRepeat->Type() == SCH_LABEL_T
|
|
|
|
|| m_itemToRepeat->Type() == SCH_HIERARCHICAL_LABEL_T
|
|
|
|
|| m_itemToRepeat->Type() == SCH_GLOBAL_LABEL_T )
|
2010-12-21 15:13:09 +00:00
|
|
|
{
|
2011-01-12 21:47:54 +00:00
|
|
|
( (SCH_TEXT*) m_itemToRepeat )->IncrementLabel();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2011-01-12 21:47:54 +00:00
|
|
|
if( m_itemToRepeat )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-01-12 21:47:54 +00:00
|
|
|
m_itemToRepeat->SetNext( GetScreen()->GetDrawItems() );
|
|
|
|
GetScreen()->SetDrawItems( m_itemToRepeat );
|
2011-01-21 19:30:59 +00:00
|
|
|
GetScreen()->TestDanglingEnds();
|
2011-01-12 21:47:54 +00:00
|
|
|
m_itemToRepeat->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
|
|
|
|
SaveCopyInUndoList( m_itemToRepeat, UR_NEW );
|
|
|
|
m_itemToRepeat->m_Flags = 0;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Routine incrementing labels, ie for the text ending with a number, adding
|
|
|
|
* that a number <RepeatDeltaLabel>
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
void IncrementLabelMember( wxString& name )
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int ii, nn;
|
|
|
|
long number = 0;
|
|
|
|
|
|
|
|
ii = name.Len() - 1; nn = 0;
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( !isdigit( name.GetChar( ii ) ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
while( (ii >= 0) && isdigit( name.GetChar( ii ) ) )
|
|
|
|
{
|
|
|
|
ii--; nn++;
|
|
|
|
}
|
|
|
|
|
|
|
|
ii++; /* digits are starting at ii position */
|
|
|
|
wxString litt_number = name.Right( nn );
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( litt_number.ToLong( &number ) )
|
|
|
|
{
|
|
|
|
number += g_RepeatDeltaLabel;
|
|
|
|
name.Remove( ii ); name << number;
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-10-06 13:19:40 +00:00
|
|
|
/* Return TRUE if pos can be a terminal point for a wire or a bus
|
|
|
|
* i.e. :
|
|
|
|
* for a WIRE, if at pos is found:
|
|
|
|
* - a junction
|
|
|
|
* - or a pin
|
|
|
|
* - or an other wire
|
2008-03-20 01:50:21 +00:00
|
|
|
*
|
2009-10-06 13:19:40 +00:00
|
|
|
* - for a BUS, if at pos is found:
|
|
|
|
* - a BUS
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
|
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM* item;
|
|
|
|
LIB_PIN* pin;
|
|
|
|
SCH_COMPONENT* LibItem = NULL;
|
|
|
|
SCH_SHEET_PIN* pinsheet;
|
|
|
|
wxPoint itempos;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
switch( layer )
|
|
|
|
{
|
|
|
|
case LAYER_BUS:
|
2008-02-12 21:12:46 +00:00
|
|
|
item = PickStruct( pos, screen, BUSITEM );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( item )
|
|
|
|
return TRUE;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2011-01-11 20:34:29 +00:00
|
|
|
pinsheet = screen->GetSheetLabel( pos );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( pinsheet && IsBusLabel( pinsheet->m_Text ) )
|
|
|
|
{
|
|
|
|
itempos = pinsheet->m_Pos;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( (itempos.x == pos.x) && (itempos.y == pos.y) )
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAYER_NOTES:
|
2008-02-12 21:12:46 +00:00
|
|
|
item = PickStruct( pos, screen, DRAWITEM );
|
2007-08-20 01:20:48 +00:00
|
|
|
if( item )
|
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LAYER_WIRE:
|
2008-02-12 21:12:46 +00:00
|
|
|
item = PickStruct( pos, screen, RACCORDITEM | JUNCTIONITEM );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( item )
|
|
|
|
return TRUE;
|
|
|
|
|
2010-12-13 15:59:00 +00:00
|
|
|
pin = screen->GetPin( pos, &LibItem );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( pin && LibItem )
|
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
// Calculate the exact position of the connection point of the pin,
|
|
|
|
// depending on orientation of the component.
|
2010-12-07 16:10:42 +00:00
|
|
|
itempos = LibItem->GetScreenCoord( pin->GetPosition() );
|
2007-08-20 01:20:48 +00:00
|
|
|
itempos.x += LibItem->m_Pos.x;
|
|
|
|
itempos.y += LibItem->m_Pos.y;
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
if( ( itempos.x == pos.x ) && ( itempos.y == pos.y ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
item = PickStruct( pos, screen, WIREITEM );
|
2010-12-21 15:13:09 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( item )
|
|
|
|
return TRUE;
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
item = PickStruct( pos, screen, LABELITEM );
|
2010-12-10 19:47:44 +00:00
|
|
|
if( item && (item->Type() != SCH_TEXT_T)
|
2008-03-20 01:50:21 +00:00
|
|
|
&& ( ( (SCH_GLOBALLABEL*) item )->m_Pos.x == pos.x )
|
|
|
|
&& ( ( (SCH_GLOBALLABEL*) item )->m_Pos.y == pos.y ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
return TRUE;
|
|
|
|
|
2011-01-11 20:34:29 +00:00
|
|
|
pinsheet = screen->GetSheetLabel( pos );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( pinsheet && !IsBusLabel( pinsheet->m_Text ) )
|
|
|
|
{
|
|
|
|
itempos = pinsheet->m_Pos;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
if( ( itempos.x == pos.x ) && ( itempos.y == pos.y ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Return True when a wire is located at pos "pos" if
|
2007-08-20 01:20:48 +00:00
|
|
|
* - there is no junction.
|
|
|
|
* - The wire has no ends at pos "pos",
|
|
|
|
* and therefore it is considered as no connected.
|
|
|
|
* - One (or more) wire has one end at pos "pos"
|
|
|
|
* or
|
|
|
|
* - a pin is on location pos
|
|
|
|
*/
|
2010-12-08 20:12:46 +00:00
|
|
|
bool IsJunctionNeeded( SCH_EDIT_FRAME* frame, wxPoint& pos )
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
if( PickStruct( pos, frame->GetScreen(), JUNCTIONITEM ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
if( PickStruct( pos, frame->GetScreen(), WIREITEM | EXCLUDE_WIRE_BUS_ENDPOINTS ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
if( PickStruct( pos, frame->GetScreen(), WIREITEM | WIRE_BUS_ENDPOINTS_ONLY ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
return TRUE;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2011-01-10 20:35:24 +00:00
|
|
|
if( frame->GetScreen()->GetPin( pos, NULL, true ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|