2007-05-06 16:03:28 +00:00
|
|
|
|
/*********************************************************/
|
|
|
|
|
/* Modules de creations de Traits, Wires, Bus, Junctions */
|
|
|
|
|
/*********************************************************/
|
|
|
|
|
|
|
|
|
|
#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"
|
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
#include "program.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
|
#include "classes_body_items.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
|
#include "general.h"
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Routines Locales */
|
2007-08-20 01:20:48 +00:00
|
|
|
|
static void Show_Polyline_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
|
|
|
|
|
static void Segment_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
|
|
|
|
|
static void AbortCreateNewLine( WinEDA_DrawPanel* Panel, wxDC* DC );
|
|
|
|
|
static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer );
|
|
|
|
|
static bool IsJunctionNeeded( WinEDA_SchematicFrame* frame, wxPoint& pos );
|
|
|
|
|
static void ComputeBreakPoint( EDA_DrawLineStruct* 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;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
wxPoint s_ConnexionStartPoint;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
/*********************************************************/
|
2008-04-14 19:22:48 +00:00
|
|
|
|
SCH_ITEM* SCH_SCREEN::ExtractWires( bool CreateCopy )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*********************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Extract the old wires, junctions and busses, an if CreateCopy replace them by a copy.
|
2007-08-20 01:20:48 +00:00
|
|
|
|
* Old ones must be put in undo list, and the new ones can be modified by clean up
|
|
|
|
|
* safely.
|
|
|
|
|
* If an abord command is made, old wires must be put in EEDrawList, and copies must be deleted
|
|
|
|
|
* This is because previously stored undo commands can handle pointers on wires or bus,
|
|
|
|
|
* and we do not delete wires or bus, we must put they in undo list.
|
2008-03-20 01:50:21 +00:00
|
|
|
|
*
|
2007-08-20 01:20:48 +00:00
|
|
|
|
* Because cleanup delete and/or modify bus and wires, the more easy is to put all wires in undo list
|
|
|
|
|
* and use a new copy of wires for cleanup
|
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2008-04-14 19:22:48 +00:00
|
|
|
|
SCH_ITEM* item, * next_item, * new_item, * List = NULL;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
|
for( item = EEDrawList; item != NULL; item = next_item )
|
|
|
|
|
{
|
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
|
|
|
|
{
|
|
|
|
|
case DRAW_JUNCTION_STRUCT_TYPE:
|
|
|
|
|
case DRAW_SEGMENT_STRUCT_TYPE:
|
|
|
|
|
RemoveFromDrawList( item );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
item->SetNext( List );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
List = item;
|
|
|
|
|
if( CreateCopy )
|
|
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
|
if( item->Type() == DRAW_JUNCTION_STRUCT_TYPE )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
new_item = ( (DrawJunctionStruct*) item )->GenCopy();
|
|
|
|
|
else
|
|
|
|
|
new_item = ( (EDA_DrawLineStruct*) item )->GenCopy();
|
2008-11-24 06:53:43 +00:00
|
|
|
|
new_item->SetNext( EEDrawList );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
EEDrawList = new_item;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return List;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
static void RestoreOldWires( SCH_SCREEN* screen )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Replace the wires in screen->EEDrawList by s_OldWiresList wires.
|
2007-08-20 01:20:48 +00:00
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
|
SCH_ITEM* item;
|
|
|
|
|
SCH_ITEM* next_item;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
|
for( item = screen->EEDrawList; item != NULL; item = next_item )
|
|
|
|
|
{
|
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
|
|
|
|
{
|
|
|
|
|
case DRAW_JUNCTION_STRUCT_TYPE:
|
|
|
|
|
case DRAW_SEGMENT_STRUCT_TYPE:
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
s_OldWiresList->SetNext( screen->EEDrawList );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
screen->EEDrawList = s_OldWiresList;
|
|
|
|
|
s_OldWiresList = next_item;
|
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Create a new segment ( WIRE, BUS ).
|
2007-08-20 01:20:48 +00:00
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
EDA_DrawLineStruct* oldsegment, * newsegment, * nextsegment;
|
|
|
|
|
wxPoint cursorpos = GetScreen()->m_Curseur;
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
|
case DRAW_SEGMENT_STRUCT_TYPE:
|
|
|
|
|
case DRAW_POLYLINE_STRUCT_TYPE:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
oldsegment = newsegment =
|
|
|
|
|
(EDA_DrawLineStruct*) GetScreen()->GetCurItem();
|
|
|
|
|
|
|
|
|
|
if( !newsegment ) /* first point : Create first wire ou bus */
|
|
|
|
|
{
|
|
|
|
|
s_ConnexionStartPoint = cursorpos;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
s_OldWiresList = ((SCH_SCREEN*)GetScreen())->ExtractWires( TRUE );
|
|
|
|
|
((SCH_SCREEN*)GetScreen())->SchematicCleanUp( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
|
switch( type )
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
newsegment = new EDA_DrawLineStruct( cursorpos, LAYER_NOTES );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LAYER_WIRE:
|
|
|
|
|
newsegment = new EDA_DrawLineStruct( cursorpos, LAYER_WIRE );
|
|
|
|
|
|
|
|
|
|
/* A junction will be created later, when w'll know the
|
|
|
|
|
* segment end position, and if the junction is really needed */
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LAYER_BUS:
|
|
|
|
|
newsegment = new EDA_DrawLineStruct( cursorpos, LAYER_BUS );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
newsegment->m_Flags = IS_NEW;
|
|
|
|
|
if( g_HVLines ) // We need 2 segments to go from a given start pint to an end point
|
|
|
|
|
{
|
|
|
|
|
nextsegment = newsegment->GenCopy();
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
GetScreen()->SetCurItem( newsegment );
|
|
|
|
|
DrawPanel->ManageCurseur = Segment_in_Ghost;
|
|
|
|
|
DrawPanel->ForceCloseManageCurseur = AbortCreateNewLine;
|
|
|
|
|
g_ItemToRepeat = NULL;
|
|
|
|
|
}
|
|
|
|
|
else /* Trace en cours: Placement d'un point supplementaire */
|
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
|
nextsegment = oldsegment->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
if( !g_HVLines )
|
|
|
|
|
{ /* if only one segment is needed and the current is has len = 0, do not create a new one*/
|
|
|
|
|
if( oldsegment->IsNull() )
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* if we want 2 segment and the last two have len = 0, do not create a new one*/
|
|
|
|
|
if( oldsegment->IsNull() && nextsegment && nextsegment->IsNull() )
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
|
/* Creation du segment suivant ou fin de trac<61> si point sur pin, jonction ...*/
|
2008-04-14 19:22:48 +00:00
|
|
|
|
if( IsTerminalPoint( (SCH_SCREEN*)GetScreen(), cursorpos, oldsegment->GetLayer() ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
{
|
|
|
|
|
EndSegment( DC ); return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Placement en liste generale */
|
2008-11-24 06:53:43 +00:00
|
|
|
|
oldsegment->SetNext( GetScreen()->EEDrawList );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
GetScreen()->EEDrawList = oldsegment;
|
|
|
|
|
DrawPanel->CursorOff( DC ); // Erase schematic cursor
|
|
|
|
|
RedrawOneStruct( DrawPanel, DC, oldsegment, GR_DEFAULT_DRAWMODE );
|
|
|
|
|
DrawPanel->CursorOn( DC ); // Display schematic cursor
|
|
|
|
|
|
|
|
|
|
/* Create a new segment, and chain it after the current new segment */
|
|
|
|
|
if( nextsegment )
|
|
|
|
|
{
|
|
|
|
|
newsegment = nextsegment->GenCopy();
|
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
newsegment = oldsegment->GenCopy();
|
|
|
|
|
newsegment->m_Start = oldsegment->m_End;
|
|
|
|
|
}
|
|
|
|
|
newsegment->m_End = cursorpos;
|
|
|
|
|
oldsegment->m_Flags = SELECTED;
|
|
|
|
|
newsegment->m_Flags = IS_NEW;
|
|
|
|
|
GetScreen()->SetCurItem( newsegment );
|
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
|
if( oldsegment->m_Start == s_ConnexionStartPoint )
|
|
|
|
|
{ /* 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)*/
|
|
|
|
|
if( IsJunctionNeeded( this, s_ConnexionStartPoint ) )
|
|
|
|
|
CreateNewJunctionStruct( DC, s_ConnexionStartPoint );
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void WinEDA_SchematicFrame::EndSegment( wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/***********************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
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
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
EDA_DrawLineStruct* firstsegment = (EDA_DrawLineStruct*) GetScreen()->GetCurItem();
|
|
|
|
|
EDA_DrawLineStruct* lastsegment = firstsegment;
|
|
|
|
|
EDA_DrawLineStruct* segment;
|
|
|
|
|
|
|
|
|
|
if( firstsegment == NULL )
|
|
|
|
|
return;
|
|
|
|
|
if( (firstsegment->m_Flags & IS_NEW) == 0 )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* Delete Null segments and Put line it in Drawlist */
|
|
|
|
|
lastsegment = firstsegment;
|
|
|
|
|
while( lastsegment )
|
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
|
EDA_DrawLineStruct* nextsegment = lastsegment->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
if( lastsegment->IsNull() )
|
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
|
EDA_DrawLineStruct* previous_segment = lastsegment->Back();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
if( firstsegment == lastsegment )
|
|
|
|
|
firstsegment = nextsegment;
|
|
|
|
|
if( nextsegment )
|
2008-11-24 06:53:43 +00:00
|
|
|
|
nextsegment->SetBack( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
if( previous_segment )
|
2008-11-24 06:53:43 +00:00
|
|
|
|
previous_segment->SetNext( nextsegment );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
delete lastsegment;
|
|
|
|
|
}
|
|
|
|
|
lastsegment = nextsegment;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* put the segment list to the main linked list */
|
|
|
|
|
segment = lastsegment = firstsegment;
|
|
|
|
|
while( segment )
|
|
|
|
|
{
|
|
|
|
|
lastsegment = segment;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
segment = segment->Next();
|
|
|
|
|
lastsegment->SetNext( GetScreen()->EEDrawList );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
GetScreen()->EEDrawList = lastsegment;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Fin de trace */
|
|
|
|
|
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.
|
|
|
|
|
* But if the last segment is removed by a cleanup, because od redundancy,
|
|
|
|
|
* a junction can be needed to connect the previous segment m_End coordinate
|
|
|
|
|
* with is also the lastsegment->m_Start coordinate */
|
|
|
|
|
if( lastsegment )
|
|
|
|
|
{
|
|
|
|
|
end_point = lastsegment->m_End;
|
|
|
|
|
alt_end_point = lastsegment->m_Start;
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
|
((SCH_SCREEN*)GetScreen())->SchematicCleanUp( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
|
/* clear flags and find last segment entered, for repeat function */
|
|
|
|
|
segment = (EDA_DrawLineStruct*) GetScreen()->EEDrawList;
|
|
|
|
|
while( segment )
|
|
|
|
|
{
|
|
|
|
|
if( segment->m_Flags )
|
|
|
|
|
{
|
|
|
|
|
if( !g_ItemToRepeat )
|
|
|
|
|
g_ItemToRepeat = segment;
|
|
|
|
|
}
|
|
|
|
|
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 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Automatic place of a junction on the start point if necessary because the
|
|
|
|
|
* Cleanup can suppress intermediate points by merging wire segments*/
|
|
|
|
|
if( IsJunctionNeeded( this, s_ConnexionStartPoint ) )
|
|
|
|
|
CreateNewJunctionStruct( DC, s_ConnexionStartPoint );
|
|
|
|
|
|
|
|
|
|
TestDanglingEnds( GetScreen()->EEDrawList, DC );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Redraw wires and junctions which can be changed by TestDanglingEnds() */
|
|
|
|
|
DrawPanel->CursorOff( DC ); // Erase schematic cursor
|
|
|
|
|
EDA_BaseStruct* item = GetScreen()->EEDrawList;
|
|
|
|
|
while( item )
|
|
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
{
|
|
|
|
|
case DRAW_JUNCTION_STRUCT_TYPE:
|
|
|
|
|
case DRAW_SEGMENT_STRUCT_TYPE:
|
2008-03-30 14:43:24 +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;
|
|
|
|
|
|
|
|
|
|
GetScreen()->SetModify();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/****************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
static void Segment_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/****************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Redraw the segment (g_HVLines == FALSE ) or the two segments (g_HVLines == TRUE )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
* from the start point to the cursor, when moving the mouse
|
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
EDA_DrawLineStruct* CurrentLine =
|
2008-04-17 16:25:29 +00:00
|
|
|
|
(EDA_DrawLineStruct*) panel->GetScreen()->GetCurItem();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
EDA_DrawLineStruct* segment;
|
|
|
|
|
int color;
|
|
|
|
|
|
|
|
|
|
if( CurrentLine == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
|
color = ReturnLayerColor( CurrentLine->GetLayer() ) ^ HIGHT_LIGHT_FLAG;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
|
if( erase )
|
|
|
|
|
{
|
|
|
|
|
segment = CurrentLine;
|
|
|
|
|
while( segment )
|
|
|
|
|
{
|
|
|
|
|
if( !segment->IsNull() ) // Redraw if segment lengtht != 0
|
|
|
|
|
RedrawOneStruct( panel, DC, segment, g_XorMode, color );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
segment = segment->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
wxPoint endpos = panel->GetScreen()->m_Curseur;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
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 lengtht != 0
|
|
|
|
|
RedrawOneStruct( panel, DC, segment, g_XorMode, color );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
segment = segment->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
static void ComputeBreakPoint( EDA_DrawLineStruct* segment, const wxPoint& new_pos )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/**************************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +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
|
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
|
EDA_DrawLineStruct* nextsegment = segment->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
wxPoint middle_position = new_pos;
|
|
|
|
|
|
|
|
|
|
if( nextsegment == NULL )
|
|
|
|
|
return;
|
|
|
|
|
#if 0
|
|
|
|
|
if( ABS( middle_position.x - segment->m_Start.x ) <
|
|
|
|
|
ABS( middle_position.y - segment->m_Start.y ) )
|
|
|
|
|
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;
|
|
|
|
|
if( iDy != 0 ) // keep the first segment orientation (currently horizontal)
|
|
|
|
|
{
|
|
|
|
|
middle_position.x = segment->m_Start.x;
|
|
|
|
|
}
|
|
|
|
|
else if( iDx != 0 ) // keep the first segment orientation (currently vertical)
|
|
|
|
|
{
|
|
|
|
|
middle_position.y = segment->m_Start.y;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if( ABS( middle_position.x - segment->m_Start.x ) <
|
|
|
|
|
ABS( middle_position.y - segment->m_Start.y ) )
|
|
|
|
|
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
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*****************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
static void Show_Polyline_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*****************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Dessin du du Polyline Fantome lors des deplacements du curseur
|
2007-08-20 01:20:48 +00:00
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
DrawPolylineStruct* NewPoly =
|
2008-04-17 16:25:29 +00:00
|
|
|
|
(DrawPolylineStruct*) panel->GetScreen()->GetCurItem();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
int color;
|
|
|
|
|
wxPoint endpos;
|
|
|
|
|
|
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;
|
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 )
|
|
|
|
|
RedrawOneStruct( panel, DC, NewPoly, g_XorMode, color );
|
|
|
|
|
|
2009-01-02 17:07:50 +00:00
|
|
|
|
NewPoly->m_PolyPoints[idx] = endpos;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
RedrawOneStruct( panel, DC, NewPoly, 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
|
|
|
|
/**********************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void WinEDA_SchematicFrame::DeleteCurrentSegment( wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/**********************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*
|
2007-08-20 01:20:48 +00:00
|
|
|
|
* Routine effacant le dernier trait trace, ou l'element pointe par la souris
|
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
g_ItemToRepeat = NULL;
|
|
|
|
|
|
|
|
|
|
if( (GetScreen()->GetCurItem() == NULL)
|
|
|
|
|
|| ( (GetScreen()->GetCurItem()->m_Flags & IS_NEW) == 0 ) )
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Trace en cours: annulation */
|
2007-09-01 12:00:30 +00:00
|
|
|
|
if( GetScreen()->GetCurItem()->Type() == DRAW_POLYLINE_STRUCT_TYPE )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
{
|
|
|
|
|
Show_Polyline_in_Ghost( DrawPanel, DC, FALSE ); /* Effacement du trace en cours */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Segment_in_Ghost( DrawPanel, DC, FALSE ); /* Effacement du trace en cours */
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
|
EraseStruct( (SCH_ITEM*) GetScreen()->GetCurItem(), (SCH_SCREEN*)GetScreen() );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
|
GetScreen()->SetCurItem( NULL );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
DrawJunctionStruct* WinEDA_SchematicFrame::CreateNewJunctionStruct(
|
|
|
|
|
wxDC* DC, const wxPoint& pos, bool PutInUndoList )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/***************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Routine to create new connection struct.
|
2007-08-20 01:20:48 +00:00
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
DrawJunctionStruct* NewJunction;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
NewJunction = new DrawJunctionStruct( pos );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
g_ItemToRepeat = NewJunction;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
DrawPanel->CursorOff( DC ); // Erase schematic cursor
|
|
|
|
|
RedrawOneStruct( DrawPanel, DC, NewJunction, GR_DEFAULT_DRAWMODE );
|
|
|
|
|
DrawPanel->CursorOn( DC ); // Display schematic cursor
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
|
NewJunction->SetNext( GetScreen()->EEDrawList );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
GetScreen()->EEDrawList = NewJunction;
|
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
|
if( PutInUndoList )
|
2009-07-26 17:16:42 +00:00
|
|
|
|
SaveCopyInUndoList( NewJunction, UR_NEW );
|
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
|
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
DrawNoConnectStruct* WinEDA_SchematicFrame::CreateNewNoConnectStruct( wxDC* DC )
|
|
|
|
|
/*******************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*Routine to create new NoConnect struct. ( Symbole de Non Connexion)
|
2007-08-20 01:20:48 +00:00
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
DrawNoConnectStruct* NewNoConnect;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
NewNoConnect = new DrawNoConnectStruct( GetScreen()->m_Curseur );
|
|
|
|
|
g_ItemToRepeat = NewNoConnect;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
DrawPanel->CursorOff( DC ); // Erase schematic cursor
|
|
|
|
|
RedrawOneStruct( DrawPanel, DC, NewNoConnect, GR_DEFAULT_DRAWMODE );
|
|
|
|
|
DrawPanel->CursorOn( DC ); // Display schematic cursor
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
|
NewNoConnect->SetNext( GetScreen()->EEDrawList );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
GetScreen()->EEDrawList = NewNoConnect;
|
|
|
|
|
GetScreen()->SetModify();
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
static void AbortCreateNewLine( WinEDA_DrawPanel* Panel, wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*****************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Abort function for wire, bus or line creation
|
2007-08-20 01:20:48 +00:00
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
SCH_SCREEN* Screen = (SCH_SCREEN*) Panel->GetScreen();
|
|
|
|
|
|
|
|
|
|
if( Screen->GetCurItem() ) /* trace en cours */
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
g_ItemToRepeat = NULL; // Fin de commande generale
|
|
|
|
|
|
|
|
|
|
/* Clear m_Flags wich is used in edit functions: */
|
2008-04-14 19:22:48 +00:00
|
|
|
|
SCH_ITEM* item = Screen->EEDrawList;
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/***************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Routine de recopie du dernier element dessine
|
2007-08-20 01:20:48 +00:00
|
|
|
|
* Les elements duplicables sont
|
|
|
|
|
* fils, bus, traits, textes, labels
|
|
|
|
|
* Les labels termines par un nombre seront incrementes
|
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
wxPoint new_pos;
|
|
|
|
|
|
|
|
|
|
if( g_ItemToRepeat == NULL )
|
|
|
|
|
return;
|
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
|
switch( g_ItemToRepeat->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
{
|
|
|
|
|
case DRAW_JUNCTION_STRUCT_TYPE:
|
2008-10-06 05:44:29 +00:00
|
|
|
|
#undef STRUCT
|
|
|
|
|
#define STRUCT ( (DrawJunctionStruct*) g_ItemToRepeat )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
g_ItemToRepeat = STRUCT->GenCopy();
|
|
|
|
|
STRUCT->m_Pos += g_RepeatStep;
|
|
|
|
|
new_pos = STRUCT->m_Pos;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case DRAW_NOCONNECT_STRUCT_TYPE:
|
2008-10-06 05:44:29 +00:00
|
|
|
|
#undef STRUCT
|
|
|
|
|
#define STRUCT ( (DrawNoConnectStruct*) g_ItemToRepeat )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
g_ItemToRepeat = STRUCT->GenCopy();
|
|
|
|
|
STRUCT->m_Pos += g_RepeatStep;
|
|
|
|
|
new_pos = STRUCT->m_Pos;
|
|
|
|
|
break;
|
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
|
case TYPE_SCH_TEXT:
|
2008-10-06 05:44:29 +00:00
|
|
|
|
#undef STRUCT
|
|
|
|
|
#define STRUCT ( (SCH_TEXT*) g_ItemToRepeat )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
g_ItemToRepeat = STRUCT->GenCopy();
|
|
|
|
|
STRUCT->m_Pos += g_RepeatStep;
|
|
|
|
|
new_pos = STRUCT->m_Pos;
|
|
|
|
|
/*** Increment du numero de label ***/
|
|
|
|
|
IncrementLabelMember( STRUCT->m_Text );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
|
case TYPE_SCH_LABEL:
|
2008-10-06 05:44:29 +00:00
|
|
|
|
#undef STRUCT
|
|
|
|
|
#define STRUCT ( (SCH_LABEL*) g_ItemToRepeat )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
g_ItemToRepeat = STRUCT->GenCopy();
|
|
|
|
|
STRUCT->m_Pos += g_RepeatStep;
|
|
|
|
|
new_pos = STRUCT->m_Pos;
|
|
|
|
|
/*** Increment du numero de label ***/
|
|
|
|
|
IncrementLabelMember( STRUCT->m_Text );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
|
case TYPE_SCH_HIERLABEL:
|
2008-10-06 05:44:29 +00:00
|
|
|
|
#undef STRUCT
|
|
|
|
|
#define STRUCT ( (SCH_HIERLABEL*) g_ItemToRepeat )
|
2008-02-12 21:12:46 +00:00
|
|
|
|
g_ItemToRepeat = STRUCT->GenCopy();
|
|
|
|
|
STRUCT->m_Pos += g_RepeatStep;
|
|
|
|
|
new_pos = STRUCT->m_Pos;
|
|
|
|
|
/*** Increment du numero de label ***/
|
|
|
|
|
IncrementLabelMember( STRUCT->m_Text );
|
|
|
|
|
break;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
|
|
|
|
|
case TYPE_SCH_GLOBALLABEL:
|
2008-10-06 05:44:29 +00:00
|
|
|
|
#undef STRUCT
|
|
|
|
|
#define STRUCT ( (SCH_GLOBALLABEL*) g_ItemToRepeat )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
g_ItemToRepeat = STRUCT->GenCopy();
|
|
|
|
|
STRUCT->m_Pos += g_RepeatStep;
|
|
|
|
|
new_pos = STRUCT->m_Pos;
|
|
|
|
|
/*** Increment du numero de label ***/
|
|
|
|
|
IncrementLabelMember( STRUCT->m_Text );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case DRAW_SEGMENT_STRUCT_TYPE:
|
2008-10-06 05:44:29 +00:00
|
|
|
|
#undef STRUCT
|
|
|
|
|
#define STRUCT ( (EDA_DrawLineStruct*) g_ItemToRepeat )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
g_ItemToRepeat = STRUCT->GenCopy();
|
|
|
|
|
STRUCT->m_Start += g_RepeatStep;
|
|
|
|
|
new_pos = STRUCT->m_Start;
|
|
|
|
|
STRUCT->m_End += g_RepeatStep;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case DRAW_BUSENTRY_STRUCT_TYPE:
|
|
|
|
|
#undef STRUCT
|
|
|
|
|
#define STRUCT ( (DrawBusEntryStruct*) g_ItemToRepeat )
|
|
|
|
|
g_ItemToRepeat = STRUCT->GenCopy();
|
|
|
|
|
STRUCT->m_Pos += g_RepeatStep;
|
|
|
|
|
new_pos = STRUCT->m_Pos;
|
|
|
|
|
break;
|
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
|
case TYPE_SCH_COMPONENT: // In repeat command the new component is put in move mode
|
2008-10-06 05:44:29 +00:00
|
|
|
|
#undef STRUCT
|
|
|
|
|
#define STRUCT ( (SCH_COMPONENT*) g_ItemToRepeat )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
|
// Create the duplicate component, position = mouse cursor
|
|
|
|
|
g_ItemToRepeat = STRUCT->GenCopy();
|
2008-02-12 21:12:46 +00:00
|
|
|
|
new_pos.x = GetScreen()->m_Curseur.x - STRUCT->m_Pos.x;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
new_pos.y = GetScreen()->m_Curseur.y - STRUCT->m_Pos.y;
|
|
|
|
|
STRUCT->m_Pos = GetScreen()->m_Curseur;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
STRUCT->m_Flags = IS_NEW;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
STRUCT->m_TimeStamp = GetTimeStamp();
|
2008-10-06 05:44:29 +00:00
|
|
|
|
|
|
|
|
|
for( int ii = 0; ii < STRUCT->GetFieldCount(); ii++ )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
{
|
2008-10-06 05:44:29 +00:00
|
|
|
|
STRUCT->GetField(ii)->m_Pos += new_pos;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RedrawOneStruct( DrawPanel, DC, STRUCT, g_XorMode );
|
|
|
|
|
StartMovePart( STRUCT, DC );
|
|
|
|
|
return;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
g_ItemToRepeat = NULL;
|
|
|
|
|
DisplayError( this, wxT( "Repeat Type Error" ), 10 );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( g_ItemToRepeat )
|
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
|
g_ItemToRepeat->SetNext( GetScreen()->EEDrawList );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
GetScreen()->EEDrawList = g_ItemToRepeat;
|
|
|
|
|
TestDanglingEnds( GetScreen()->EEDrawList, NULL );
|
|
|
|
|
RedrawOneStruct( DrawPanel, DC, g_ItemToRepeat, GR_DEFAULT_DRAWMODE );
|
2009-07-26 17:16:42 +00:00
|
|
|
|
SaveCopyInUndoList( g_ItemToRepeat, UR_NEW );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
g_ItemToRepeat->m_Flags = 0;
|
|
|
|
|
|
|
|
|
|
// GetScreen()->Curseur = new_pos;
|
2009-01-17 20:31:19 +00:00
|
|
|
|
// DrawPanel->MouseTo( DrawPanel->CursorScreenPosition() );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void IncrementLabelMember( wxString& name )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/******************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Routine incrementant les labels, c'est a dire pour les textes finissant
|
2007-08-20 01:20:48 +00:00
|
|
|
|
* par un nombre, ajoutant <RepeatDeltaLabel> a ce nombre
|
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
int ii, nn;
|
|
|
|
|
long number = 0;
|
|
|
|
|
|
|
|
|
|
ii = name.Len() - 1; nn = 0;
|
|
|
|
|
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 );
|
|
|
|
|
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
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/***************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/***************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/* Returne TRUE si pos est un point possible pour terminer automatiquement un
|
2007-08-20 01:20:48 +00:00
|
|
|
|
* segment, c'est a dire pour
|
|
|
|
|
* - type WIRE, si il y a
|
|
|
|
|
* - une jonction
|
|
|
|
|
* - ou une pin
|
2008-02-12 21:12:46 +00:00
|
|
|
|
* - ou une extr<EFBFBD>mit<EFBFBD> unique de fil
|
2008-03-20 01:50:21 +00:00
|
|
|
|
*
|
2007-08-20 01:20:48 +00:00
|
|
|
|
* - type BUS, si il y a
|
2008-02-12 21:12:46 +00:00
|
|
|
|
* - ou une extr<EFBFBD>mit<EFBFBD> unique de BUS
|
2007-08-20 01:20:48 +00:00
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
EDA_BaseStruct* item;
|
|
|
|
|
LibDrawPin* pin;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
SCH_COMPONENT* LibItem = NULL;
|
2008-04-15 19:38:19 +00:00
|
|
|
|
Hierarchical_PIN_Sheet_Struct* pinsheet;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
wxPoint itempos;
|
|
|
|
|
|
|
|
|
|
switch( layer )
|
|
|
|
|
{
|
|
|
|
|
case LAYER_BUS:
|
2008-02-12 21:12:46 +00:00
|
|
|
|
item = PickStruct( pos, screen, BUSITEM );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
if( item )
|
|
|
|
|
return TRUE;
|
|
|
|
|
pinsheet = LocateAnyPinSheet( pos, screen->EEDrawList );
|
|
|
|
|
if( pinsheet && IsBusLabel( pinsheet->m_Text ) )
|
|
|
|
|
{
|
|
|
|
|
itempos = pinsheet->m_Pos;
|
|
|
|
|
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 );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
if( item )
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
pin = LocateAnyPin( screen->EEDrawList, pos, &LibItem );
|
|
|
|
|
if( pin && LibItem )
|
|
|
|
|
{
|
|
|
|
|
// calcul de la position exacte du point de connexion de la pin,
|
|
|
|
|
// selon orientation du composant:
|
|
|
|
|
itempos = LibItem->GetScreenCoord( pin->m_Pos );
|
|
|
|
|
itempos.x += LibItem->m_Pos.x;
|
|
|
|
|
itempos.y += LibItem->m_Pos.y;
|
|
|
|
|
if( (itempos.x == pos.x) && (itempos.y == pos.y) )
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
|
item = PickStruct( pos, screen, WIREITEM );
|
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 );
|
2008-03-20 01:50:21 +00:00
|
|
|
|
if( item && (item->Type() != TYPE_SCH_TEXT)
|
|
|
|
|
&& ( ( (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;
|
|
|
|
|
|
2008-04-14 19:22:48 +00:00
|
|
|
|
pinsheet = LocateAnyPinSheet( pos, screen->EEDrawList );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
if( pinsheet && !IsBusLabel( pinsheet->m_Text ) )
|
|
|
|
|
{
|
|
|
|
|
itempos = pinsheet->m_Pos;
|
|
|
|
|
if( (itempos.x == pos.x) && (itempos.y == pos.y) )
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
bool IsJunctionNeeded( WinEDA_SchematicFrame* frame, wxPoint& pos )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/****************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
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
|
|
|
|
|
*/
|
2007-05-06 16:03:28 +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;
|
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
|
if( PickStruct( pos, frame->GetScreen(), WIREITEM | EXCLUDE_WIRE_BUS_ENDPOINTS ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
{
|
2008-02-12 21:12:46 +00:00
|
|
|
|
if( PickStruct( pos, frame->GetScreen(), WIREITEM | WIRE_BUS_ENDPOINTS_ONLY ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
return TRUE;
|
2008-04-14 19:22:48 +00:00
|
|
|
|
if( frame->LocatePinEnd( frame->GetScreen()->EEDrawList, pos ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|