2007-05-06 16:03:28 +00:00
|
|
|
/****************************************************/
|
|
|
|
/* BLOCK.CPP */
|
|
|
|
/* Gestion des Operations sur Blocks et Effacements */
|
|
|
|
/****************************************************/
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2009-01-29 14:26:20 +00:00
|
|
|
#include "gr_basic.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
|
|
|
#include "block_commande.h"
|
2009-04-05 20:49:15 +00:00
|
|
|
#include "class_drawpickedstruct.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "program.h"
|
|
|
|
#include "libcmp.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
|
|
|
|
2008-02-27 19:38:16 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* Variables Locales */
|
|
|
|
|
|
|
|
/* Fonctions exportees */
|
|
|
|
|
|
|
|
/* Fonctions Locales */
|
2009-02-12 08:12:41 +00:00
|
|
|
static SCH_ITEM* CopyStruct( WinEDA_DrawPanel* panel,
|
|
|
|
wxDC* DC,
|
|
|
|
BASE_SCREEN* screen,
|
|
|
|
SCH_ITEM* DrawStruct );
|
|
|
|
static void CollectStructsToDrag( SCH_SCREEN* screen );
|
|
|
|
static void AddPickedItem( SCH_SCREEN* screen, wxPoint aPosition );
|
|
|
|
static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
|
|
|
|
wxPoint& aPosition );
|
|
|
|
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel,
|
|
|
|
wxDC* DC,
|
|
|
|
bool erase );
|
|
|
|
static SCH_ITEM* SaveStructListForPaste( SCH_ITEM* DrawStruct );
|
|
|
|
static bool MirrorStruct( WinEDA_DrawPanel* panel, wxDC* DC,
|
|
|
|
SCH_ITEM* DrawStruct, wxPoint& Center );
|
|
|
|
static void MirrorOneStruct( SCH_ITEM* DrawStruct,
|
|
|
|
wxPoint& Center );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
/*************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
int WinEDA_SchematicFrame::ReturnBlockCommand( int key )
|
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 the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to
|
2007-08-20 01:20:48 +00:00
|
|
|
* the key (ALT, SHIFT ALT ..)
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int cmd;
|
|
|
|
|
|
|
|
switch( key )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
cmd = key & 0xFF;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
cmd = BLOCK_MOVE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GR_KB_ALT:
|
|
|
|
case GR_KB_SHIFT:
|
|
|
|
cmd = BLOCK_COPY;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GR_KB_CTRL:
|
|
|
|
cmd = BLOCK_DRAG;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GR_KB_SHIFTCTRL:
|
|
|
|
cmd = BLOCK_DELETE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MOUSE_MIDDLE:
|
|
|
|
cmd = BLOCK_ZOOM;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cmd;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*************************************************/
|
|
|
|
void WinEDA_SchematicFrame::InitBlockPasteInfos()
|
|
|
|
/*************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* Init the parameters used by the block paste command
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-02-28 19:27:25 +00:00
|
|
|
DrawBlockStruct* block = &GetScreen()->BlockLocate;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
block->m_BlockDrawStruct = g_BlockSaveDataList;
|
|
|
|
DrawPanel->ManageCurseur = DrawMovingBlockOutlines;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_SchematicFrame::HandleBlockPlace( 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 to handle the BLOCK PLACE commande
|
2007-08-20 01:20:48 +00:00
|
|
|
* Last routine for block operation for:
|
|
|
|
* - block move & drag
|
|
|
|
* - block copie & paste
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
bool err = FALSE;
|
2008-02-28 19:27:25 +00:00
|
|
|
DrawBlockStruct* block = &GetScreen()->BlockLocate;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
SCH_ITEM* NewStruct = NULL;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( DrawPanel->ManageCurseur == NULL )
|
|
|
|
{
|
|
|
|
err = TRUE;
|
|
|
|
DisplayError( this, wxT( "HandleBlockPLace() : ManageCurseur = NULL" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( block->m_BlockDrawStruct == NULL )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
err = TRUE;
|
2008-12-08 15:27:13 +00:00
|
|
|
msg.Printf( wxT( "HandleBlockPLace() : m_BlockDrawStruct = " \
|
|
|
|
"NULL (cmd %d, state %d)" ),
|
2007-08-20 01:20:48 +00:00
|
|
|
block->m_Command, block->m_State );
|
|
|
|
DisplayError( this, msg );
|
|
|
|
}
|
|
|
|
|
|
|
|
block->m_State = STATE_BLOCK_STOP;
|
|
|
|
|
|
|
|
switch( block->m_Command )
|
|
|
|
{
|
|
|
|
case BLOCK_IDLE:
|
|
|
|
err = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_DRAG: /* Drag */
|
|
|
|
case BLOCK_MOVE: /* Move */
|
|
|
|
if( DrawPanel->ManageCurseur )
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
SaveCopyInUndoList( (SCH_ITEM*) block->m_BlockDrawStruct, IS_CHANGED );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
MoveStruct( DrawPanel, DC, (SCH_ITEM*) block->m_BlockDrawStruct );
|
2007-08-20 01:20:48 +00:00
|
|
|
block->m_BlockDrawStruct = NULL;
|
2008-03-30 11:00:04 +00:00
|
|
|
DrawPanel->Refresh( TRUE );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_COPY: /* Copy */
|
|
|
|
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
|
|
|
|
if( DrawPanel->ManageCurseur )
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
NewStruct = CopyStruct( DrawPanel, DC,
|
|
|
|
GetScreen(),
|
|
|
|
(SCH_ITEM*) block->m_BlockDrawStruct );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
SaveCopyInUndoList(
|
|
|
|
NewStruct,
|
|
|
|
(block->m_Command ==
|
|
|
|
BLOCK_PRESELECT_MOVE) ? IS_CHANGED : IS_NEW );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
block->m_BlockDrawStruct = NULL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_PASTE: /* Paste (recopie du dernier bloc sauve */
|
|
|
|
if( DrawPanel->ManageCurseur )
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
PasteStruct( DC );
|
|
|
|
block->m_BlockDrawStruct = NULL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_ZOOM: // Handled by HandleBlockEnd()
|
|
|
|
case BLOCK_DELETE:
|
|
|
|
case BLOCK_SAVE:
|
|
|
|
case BLOCK_ROTATE:
|
|
|
|
case BLOCK_MIRROR_X:
|
|
|
|
case BLOCK_MIRROR_Y:
|
|
|
|
case BLOCK_INVERT:
|
|
|
|
case BLOCK_ABORT:
|
|
|
|
case BLOCK_SELECT_ITEMS_ONLY:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
|
|
|
|
/* clear struct.m_Flags */
|
2008-04-14 19:22:48 +00:00
|
|
|
SCH_ITEM* Struct;
|
2009-01-02 13:19:34 +00:00
|
|
|
for( Struct = GetScreen()->EEDrawList; Struct != NULL; Struct = Struct->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
Struct->m_Flags = 0;
|
|
|
|
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
|
|
|
block->m_Flags = 0;
|
|
|
|
block->m_State = STATE_NO_BLOCK;
|
|
|
|
block->m_Command = BLOCK_IDLE;
|
|
|
|
GetScreen()->SetCurItem( NULL );
|
|
|
|
|
|
|
|
TestDanglingEnds( GetScreen()->EEDrawList, DC );
|
|
|
|
|
|
|
|
if( block->m_BlockDrawStruct )
|
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
DisplayError( this,
|
|
|
|
wxT( "HandleBlockPLace() error: DrawStruct != Null" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
block->m_BlockDrawStruct = NULL;
|
|
|
|
}
|
|
|
|
|
2009-01-02 13:19:34 +00:00
|
|
|
SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString );
|
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
|
|
|
int WinEDA_SchematicFrame::HandleBlockEnd( 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 gestion de la commande BLOCK END
|
2007-08-20 01:20:48 +00:00
|
|
|
* retourne :
|
|
|
|
* 0 si aucun composant selectionne
|
|
|
|
* 1 sinon
|
2008-04-14 19:22:48 +00:00
|
|
|
* -1 si commande terminee et composants trouves (block delete, block save)
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-02-12 08:12:41 +00:00
|
|
|
int ii = 0;
|
2007-08-20 01:20:48 +00:00
|
|
|
bool zoom_command = FALSE;
|
2008-02-28 19:27:25 +00:00
|
|
|
DrawBlockStruct* block = &GetScreen()->BlockLocate;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( block->m_BlockDrawStruct )
|
|
|
|
{
|
|
|
|
BlockState state = block->m_State;
|
|
|
|
CmdBlockType command = block->m_Command;
|
|
|
|
if( DrawPanel->ForceCloseManageCurseur )
|
|
|
|
DrawPanel->ForceCloseManageCurseur( DrawPanel, DC );
|
|
|
|
block->m_State = state;
|
|
|
|
block->m_Command = command;
|
|
|
|
DrawPanel->ManageCurseur = DrawAndSizingBlockOutlines;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = AbortBlockCurrentCommand;
|
|
|
|
GetScreen()->m_Curseur.x = block->GetRight();
|
|
|
|
GetScreen()->m_Curseur.y = block->GetBottom();
|
|
|
|
if( block->m_Command != BLOCK_ABORT )
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( DrawPanel->ManageCurseur != NULL )
|
|
|
|
switch( block->m_Command )
|
|
|
|
{
|
|
|
|
case BLOCK_IDLE:
|
|
|
|
DisplayError( this, wxT( "Error in HandleBlockPLace()" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_DRAG: /* Drag */
|
2008-02-28 19:27:25 +00:00
|
|
|
BreakSegmentOnJunction( (SCH_SCREEN*) GetScreen() );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
case BLOCK_MOVE: /* Move */
|
|
|
|
case BLOCK_COPY: /* Copy */
|
|
|
|
block->m_BlockDrawStruct =
|
2008-02-12 21:12:46 +00:00
|
|
|
PickStruct( GetScreen()->BlockLocate, GetScreen(), SEARCHALL );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
|
|
|
|
if( block->m_BlockDrawStruct != NULL )
|
|
|
|
{
|
|
|
|
ii = 1;
|
2008-02-28 19:27:25 +00:00
|
|
|
CollectStructsToDrag( (SCH_SCREEN*) GetScreen() );
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
DrawPanel->ManageCurseur = DrawMovingBlockOutlines;
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
block->m_State = STATE_BLOCK_MOVE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_DELETE: /* Delete */
|
|
|
|
block->m_BlockDrawStruct =
|
|
|
|
PickStruct( GetScreen()->BlockLocate,
|
2008-02-12 21:12:46 +00:00
|
|
|
GetScreen(), SEARCHALL );
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE );
|
|
|
|
if( block->m_BlockDrawStruct != NULL )
|
|
|
|
{
|
|
|
|
ii = -1;
|
2008-12-08 15:27:13 +00:00
|
|
|
DeleteStruct( DrawPanel,
|
|
|
|
DC,
|
|
|
|
(SCH_ITEM*) block->m_BlockDrawStruct );
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->SetModify();
|
|
|
|
}
|
|
|
|
block->m_BlockDrawStruct = NULL;
|
|
|
|
TestDanglingEnds( GetScreen()->EEDrawList, DC );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_SAVE: /* Save */
|
|
|
|
block->m_BlockDrawStruct =
|
|
|
|
PickStruct( GetScreen()->BlockLocate,
|
2008-02-12 21:12:46 +00:00
|
|
|
GetScreen(), SEARCHALL );
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE );
|
|
|
|
if( block->m_BlockDrawStruct != NULL )
|
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
wxPoint oldpos = GetScreen()->m_Curseur;
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->m_Curseur = wxPoint( 0, 0 );
|
2008-12-08 15:27:13 +00:00
|
|
|
SCH_ITEM* DrawStructCopy =
|
|
|
|
SaveStructListForPaste(
|
2009-02-12 08:12:41 +00:00
|
|
|
(SCH_ITEM*) block->m_BlockDrawStruct );
|
2007-08-20 01:20:48 +00:00
|
|
|
PlaceStruct( GetScreen(), DrawStructCopy );
|
|
|
|
GetScreen()->m_Curseur = oldpos;
|
|
|
|
ii = -1;
|
|
|
|
}
|
|
|
|
block->m_BlockDrawStruct = NULL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_PASTE:
|
|
|
|
block->m_State = STATE_BLOCK_MOVE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_INVERT: /* pcbnew only! */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_ROTATE:
|
|
|
|
case BLOCK_MIRROR_X:
|
|
|
|
case BLOCK_MIRROR_Y:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_ZOOM: /* Window Zoom */
|
|
|
|
zoom_command = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_SELECT_ITEMS_ONLY: /* Not used */
|
|
|
|
case BLOCK_ABORT: /* not executed here */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( block->m_Command == BLOCK_ABORT )
|
|
|
|
{ /* clear struct.m_Flags */
|
|
|
|
EDA_BaseStruct* Struct;
|
2008-12-08 15:27:13 +00:00
|
|
|
for( Struct = GetScreen()->EEDrawList;
|
|
|
|
Struct != NULL;
|
|
|
|
Struct = Struct->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
Struct->m_Flags = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ii <= 0 )
|
|
|
|
{
|
|
|
|
block->m_Flags = 0;
|
|
|
|
block->m_State = STATE_NO_BLOCK;
|
|
|
|
block->m_Command = BLOCK_IDLE;
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
|
|
|
GetScreen()->SetCurItem( NULL );
|
2008-12-08 15:27:13 +00:00
|
|
|
SetToolID( m_ID_current_state,
|
|
|
|
DrawPanel->m_PanelDefaultCursor,
|
|
|
|
wxEmptyString );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( zoom_command )
|
|
|
|
Window_Zoom( GetScreen()->BlockLocate );
|
|
|
|
|
|
|
|
return ii;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, 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 gestion de la commande BLOCK END by PopUp
|
2007-08-20 01:20:48 +00:00
|
|
|
* Appelee apres HandleBlockEnd.
|
|
|
|
* A partir de la commande bloc move, peut executer une commande autre que bloc move.
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int ii = 0;
|
2008-02-28 19:27:25 +00:00
|
|
|
DrawBlockStruct* block = &GetScreen()->BlockLocate;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( block->m_Command != BLOCK_MOVE )
|
|
|
|
return;
|
|
|
|
if( Command == BLOCK_MOVE )
|
|
|
|
return;
|
|
|
|
|
|
|
|
block->m_Command = (CmdBlockType) Command;
|
|
|
|
block->SetMessageBlock( this );
|
|
|
|
|
|
|
|
switch( block->m_Command )
|
|
|
|
{
|
|
|
|
case BLOCK_COPY: /* move to copy */
|
|
|
|
block->m_State = STATE_BLOCK_MOVE;
|
|
|
|
ii = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_DRAG: /* move to Drag */
|
|
|
|
|
|
|
|
/* Effacement de la liste des structures de pointage,
|
|
|
|
* qui est devenue erronnee */
|
|
|
|
if( DrawPanel->ManageCurseur )
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
if( block->m_BlockDrawStruct )
|
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
if( block->m_BlockDrawStruct->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{ /* Delete the picked wrapper if this is a picked list. */
|
|
|
|
DrawPickedStruct* PickedList;
|
|
|
|
PickedList = (DrawPickedStruct*) block->m_BlockDrawStruct;
|
|
|
|
PickedList->DeleteWrapperList();
|
|
|
|
}
|
|
|
|
block->m_BlockDrawStruct = NULL;
|
|
|
|
}
|
2008-02-28 19:27:25 +00:00
|
|
|
BreakSegmentOnJunction( (SCH_SCREEN*) GetScreen() );
|
2007-08-20 01:20:48 +00:00
|
|
|
block->m_BlockDrawStruct =
|
|
|
|
PickStruct( GetScreen()->BlockLocate,
|
2008-02-12 21:12:46 +00:00
|
|
|
GetScreen(), SEARCHALL );
|
2007-08-20 01:20:48 +00:00
|
|
|
if( block->m_BlockDrawStruct != NULL )
|
|
|
|
{
|
|
|
|
ii = 1;
|
2008-02-28 19:27:25 +00:00
|
|
|
CollectStructsToDrag( (SCH_SCREEN*) GetScreen() );
|
2007-08-20 01:20:48 +00:00
|
|
|
if( DrawPanel->ManageCurseur )
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
block->m_State = STATE_BLOCK_MOVE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_DELETE: /* move to Delete */
|
|
|
|
if( DrawPanel->ManageCurseur )
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
if( block->m_BlockDrawStruct != NULL )
|
|
|
|
{
|
|
|
|
ii = -1;
|
2008-04-14 19:22:48 +00:00
|
|
|
DeleteStruct( DrawPanel, DC, (SCH_ITEM*) block->m_BlockDrawStruct );
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->SetModify();
|
|
|
|
}
|
|
|
|
TestDanglingEnds( GetScreen()->EEDrawList, DC );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_SAVE: /* Save */
|
|
|
|
if( DrawPanel->ManageCurseur )
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
if( block->m_BlockDrawStruct != NULL )
|
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
wxPoint oldpos = GetScreen()->m_Curseur;
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->m_Curseur = wxPoint( 0, 0 );
|
2008-12-08 15:27:13 +00:00
|
|
|
SCH_ITEM* DrawStructCopy =
|
2008-04-14 19:22:48 +00:00
|
|
|
SaveStructListForPaste( (SCH_ITEM*) block->m_BlockDrawStruct );
|
2007-08-20 01:20:48 +00:00
|
|
|
PlaceStruct( GetScreen(), DrawStructCopy );
|
|
|
|
GetScreen()->m_Curseur = oldpos;
|
|
|
|
ii = -1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_ZOOM: /* Window Zoom */
|
|
|
|
DrawPanel->ForceCloseManageCurseur( DrawPanel, DC );
|
2008-12-08 15:27:13 +00:00
|
|
|
DrawPanel->SetCursor(
|
|
|
|
DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor );
|
2007-08-20 01:20:48 +00:00
|
|
|
Window_Zoom( GetScreen()->BlockLocate );
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case BLOCK_ROTATE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_MIRROR_X:
|
|
|
|
case BLOCK_MIRROR_Y:
|
|
|
|
if( DrawPanel->ManageCurseur )
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
if( block->m_BlockDrawStruct != NULL )
|
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
SaveCopyInUndoList( (SCH_ITEM*) block->m_BlockDrawStruct,
|
|
|
|
IS_CHANGED );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
ii = -1;
|
|
|
|
/* Compute the mirror centre and put it on grid */
|
|
|
|
wxPoint Center = block->Centre();
|
|
|
|
PutOnGrid( &Center );
|
2008-12-08 15:27:13 +00:00
|
|
|
MirrorStruct( DrawPanel,
|
|
|
|
DC,
|
|
|
|
(SCH_ITEM*) block->m_BlockDrawStruct,
|
|
|
|
Center );
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->SetModify();
|
|
|
|
}
|
|
|
|
TestDanglingEnds( GetScreen()->EEDrawList, DC );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ii <= 0 )
|
|
|
|
{
|
|
|
|
block->m_BlockDrawStruct = NULL;
|
|
|
|
block->m_Flags = 0;
|
|
|
|
block->m_State = STATE_NO_BLOCK;
|
|
|
|
block->m_Command = BLOCK_IDLE;
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
|
|
|
GetScreen()->SetCurItem( NULL );
|
2008-12-08 15:27:13 +00:00
|
|
|
SetToolID( m_ID_current_state,
|
|
|
|
DrawPanel->m_PanelDefaultCursor,
|
|
|
|
wxEmptyString );
|
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 DrawMovingBlockOutlines( 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
|
|
|
/* Retrace le contour du block de recherche de structures
|
2007-08-20 01:20:48 +00:00
|
|
|
* L'ensemble du block suit le curseur
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawBlockStruct* PtBlock;
|
|
|
|
DrawPickedStruct* PickedList;
|
2008-04-17 16:25:29 +00:00
|
|
|
BASE_SCREEN* screen = panel->GetScreen();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
PtBlock = &panel->GetScreen()->BlockLocate;
|
|
|
|
GRSetDrawMode( DC, g_XorMode );
|
|
|
|
|
|
|
|
/* Effacement ancien cadre */
|
|
|
|
if( erase && PtBlock->m_BlockDrawStruct )
|
|
|
|
{
|
|
|
|
PtBlock->Offset( PtBlock->m_MoveVector );
|
|
|
|
PtBlock->Draw( panel, DC );
|
|
|
|
PtBlock->Offset( -PtBlock->m_MoveVector.x, -PtBlock->m_MoveVector.y );
|
|
|
|
|
|
|
|
/* Effacement ancien affichage */
|
2007-09-01 12:00:30 +00:00
|
|
|
if( PtBlock->m_BlockDrawStruct->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
PickedList = (DrawPickedStruct*) PtBlock->m_BlockDrawStruct;
|
|
|
|
while( PickedList )
|
|
|
|
{
|
|
|
|
DrawStructsInGhost( panel,
|
|
|
|
DC,
|
2008-12-08 15:27:13 +00:00
|
|
|
(SCH_ITEM*) PickedList->m_PickedStruct,
|
2007-08-20 01:20:48 +00:00
|
|
|
PtBlock->m_MoveVector.x,
|
|
|
|
PtBlock->m_MoveVector.y );
|
2008-11-24 06:53:43 +00:00
|
|
|
PickedList = (DrawPickedStruct*) PickedList->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
DrawStructsInGhost( panel,
|
|
|
|
DC,
|
2008-12-08 15:27:13 +00:00
|
|
|
(SCH_ITEM*) PtBlock->m_BlockDrawStruct,
|
2007-08-20 01:20:48 +00:00
|
|
|
PtBlock->m_MoveVector.x,
|
|
|
|
PtBlock->m_MoveVector.y );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Redessin nouvel affichage */
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
PtBlock->m_MoveVector.x = screen->m_Curseur.x -
|
|
|
|
PtBlock->m_BlockLastCursorPosition.x;
|
|
|
|
PtBlock->m_MoveVector.y = screen->m_Curseur.y -
|
|
|
|
PtBlock->m_BlockLastCursorPosition.y;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
GRSetDrawMode( DC, g_XorMode );
|
|
|
|
PtBlock->Offset( PtBlock->m_MoveVector );
|
|
|
|
PtBlock->Draw( panel, DC );
|
|
|
|
PtBlock->Offset( -PtBlock->m_MoveVector.x, -PtBlock->m_MoveVector.y );
|
|
|
|
|
|
|
|
if( PtBlock->m_BlockDrawStruct )
|
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
if( PtBlock->m_BlockDrawStruct->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
PickedList = (DrawPickedStruct*) PtBlock->m_BlockDrawStruct;
|
|
|
|
while( PickedList )
|
|
|
|
{
|
|
|
|
DrawStructsInGhost( panel,
|
|
|
|
DC,
|
2008-12-08 15:27:13 +00:00
|
|
|
(SCH_ITEM*) PickedList->m_PickedStruct,
|
2007-08-20 01:20:48 +00:00
|
|
|
PtBlock->m_MoveVector.x,
|
|
|
|
PtBlock->m_MoveVector.y );
|
2008-11-24 06:53:43 +00:00
|
|
|
PickedList = (DrawPickedStruct*) PickedList->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
DrawStructsInGhost( panel,
|
|
|
|
DC,
|
2008-12-08 15:27:13 +00:00
|
|
|
(SCH_ITEM*) PtBlock->m_BlockDrawStruct,
|
2007-08-20 01:20:48 +00:00
|
|
|
PtBlock->m_MoveVector.x,
|
|
|
|
PtBlock->m_MoveVector.y );
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Routine to move an object(s) to a new position. *
|
|
|
|
* If DrawStruct is of type DrawPickedStruct, a list of objects picked is *
|
|
|
|
* assumed, otherwise exactly one structure is assumed been picked. *
|
|
|
|
*****************************************************************************/
|
2008-04-14 19:22:48 +00:00
|
|
|
bool MoveStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM* DrawStruct )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( !DrawStruct )
|
|
|
|
return FALSE;
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
if( DrawStruct->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
DrawPickedStruct* pickedList = (DrawPickedStruct*) DrawStruct;
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( DC )
|
2008-03-20 01:50:21 +00:00
|
|
|
panel->PostDirtyRect( pickedList->GetBoundingBoxUnion() );
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
PlaceStruct( panel->GetScreen(), (SCH_ITEM *) pickedList ); // Place it in its new position.
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( DC )
|
2009-04-05 20:49:15 +00:00
|
|
|
RedrawStructList( panel, DC, (SCH_ITEM *) pickedList,
|
|
|
|
GR_DEFAULT_DRAWMODE );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
// Free the wrapper DrawPickedStruct chain
|
|
|
|
pickedList->DeleteWrapperList();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( DC )
|
2008-12-08 15:27:13 +00:00
|
|
|
panel->PostDirtyRect( DrawStruct->GetBoundingBox() );
|
2007-08-20 01:20:48 +00:00
|
|
|
PlaceStruct( panel->GetScreen(), DrawStruct ); /* Place it in its new position. */
|
|
|
|
if( DC )
|
|
|
|
RedrawOneStruct( panel, DC, DrawStruct, GR_DEFAULT_DRAWMODE );
|
|
|
|
}
|
|
|
|
return TRUE;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
static void MirrorYPoint( wxPoint& point, wxPoint& Center )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
point.x -= Center.x;
|
|
|
|
point.x = -point.x;
|
|
|
|
point.x += Center.x;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/**************************************************************/
|
2008-12-08 15:27:13 +00:00
|
|
|
void MirrorOneStruct( SCH_ITEM* DrawStruct, wxPoint& Center )
|
2007-05-06 16:03:28 +00:00
|
|
|
/**************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* Given a structure rotate it to 90 degrees refer to the Center point.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-01-02 17:07:50 +00:00
|
|
|
int dx;
|
2008-12-08 15:27:13 +00:00
|
|
|
DrawPolylineStruct* DrawPoly;
|
|
|
|
DrawJunctionStruct* DrawConnect;
|
|
|
|
EDA_DrawLineStruct* DrawSegment;
|
|
|
|
DrawBusEntryStruct* DrawRaccord;
|
|
|
|
SCH_COMPONENT* DrawLibItem;
|
|
|
|
DrawSheetStruct* DrawSheet;
|
|
|
|
Hierarchical_PIN_Sheet_Struct* DrawSheetLabel;
|
|
|
|
DrawMarkerStruct* DrawMarker;
|
|
|
|
DrawNoConnectStruct* DrawNoConnect;
|
2009-02-12 08:12:41 +00:00
|
|
|
SCH_TEXT* DrawText;
|
|
|
|
wxPoint px;
|
2008-12-08 15:27:13 +00:00
|
|
|
WinEDA_SchematicFrame* frame;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( !DrawStruct )
|
|
|
|
return;
|
|
|
|
|
2009-02-12 08:12:41 +00:00
|
|
|
frame = (WinEDA_SchematicFrame*) wxGetApp().GetTopWindow();
|
2008-12-08 15:27:13 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( DrawStruct->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
case TYPE_NOT_INIT:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_POLYLINE_STRUCT_TYPE:
|
|
|
|
DrawPoly = (DrawPolylineStruct*) DrawStruct;
|
2009-01-02 17:07:50 +00:00
|
|
|
for( unsigned ii = 0; ii < DrawPoly->GetCornerCount(); ii++ )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
wxPoint point;
|
2009-01-02 17:07:50 +00:00
|
|
|
point = DrawPoly->m_PolyPoints[ii];
|
2007-08-20 01:20:48 +00:00
|
|
|
MirrorYPoint( point, Center );
|
2009-01-02 17:07:50 +00:00
|
|
|
DrawPoly->m_PolyPoints[ii] = point;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_SEGMENT_STRUCT_TYPE:
|
|
|
|
DrawSegment = (EDA_DrawLineStruct*) DrawStruct;
|
|
|
|
if( (DrawSegment->m_Flags & STARTPOINT) == 0 )
|
|
|
|
{
|
|
|
|
MirrorYPoint( DrawSegment->m_Start, Center );
|
|
|
|
}
|
|
|
|
if( (DrawSegment->m_Flags & ENDPOINT) == 0 )
|
|
|
|
{
|
|
|
|
MirrorYPoint( DrawSegment->m_End, Center );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_BUSENTRY_STRUCT_TYPE:
|
|
|
|
DrawRaccord = (DrawBusEntryStruct*) DrawStruct;
|
|
|
|
MirrorYPoint( DrawRaccord->m_Pos, Center );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_JUNCTION_STRUCT_TYPE:
|
|
|
|
DrawConnect = (DrawJunctionStruct*) DrawStruct;
|
|
|
|
MirrorYPoint( DrawConnect->m_Pos, Center );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_MARKER_STRUCT_TYPE:
|
|
|
|
DrawMarker = (DrawMarkerStruct*) DrawStruct;
|
|
|
|
MirrorYPoint( DrawMarker->m_Pos, Center );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_NOCONNECT_STRUCT_TYPE:
|
|
|
|
DrawNoConnect = (DrawNoConnectStruct*) DrawStruct;
|
|
|
|
MirrorYPoint( DrawNoConnect->m_Pos, Center );
|
|
|
|
break;
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_TEXT:
|
|
|
|
case TYPE_SCH_LABEL:
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
// Text is not really mirrored; it is moved to a suitable position
|
|
|
|
// which is the closest position for a true mirrored text
|
|
|
|
// The center position is mirrored and the text is moved for half horizontal len
|
2008-03-20 01:50:21 +00:00
|
|
|
DrawText = (SCH_TEXT*) DrawStruct;
|
2007-08-20 01:20:48 +00:00
|
|
|
px = DrawText->m_Pos;
|
2008-02-28 19:27:25 +00:00
|
|
|
if( DrawText->m_Orient == 0 ) /* horizontal text */
|
2007-08-20 01:20:48 +00:00
|
|
|
dx = DrawText->Len_Size() / 2;
|
2008-02-28 19:27:25 +00:00
|
|
|
else if( DrawText->m_Orient == 2 ) /* invert horizontal text*/
|
2007-08-20 01:20:48 +00:00
|
|
|
dx = -DrawText->Len_Size() / 2;
|
|
|
|
else
|
|
|
|
dx = 0;
|
|
|
|
px.x += dx;
|
|
|
|
MirrorYPoint( px, Center );
|
|
|
|
px.x -= dx;
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
frame->PutOnGrid( &px );
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawText->m_Pos.x = px.x;
|
|
|
|
break;
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_HIERLABEL:
|
|
|
|
case TYPE_SCH_GLOBALLABEL:
|
2008-02-28 19:27:25 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
// Text is not really mirrored: Orientation is changed
|
2008-03-20 01:50:21 +00:00
|
|
|
DrawText = (SCH_LABEL*) DrawStruct;
|
2008-02-28 19:27:25 +00:00
|
|
|
if( DrawText->m_Orient == 0 ) /* horizontal text */
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawText->m_Orient = 2;
|
2008-02-28 19:27:25 +00:00
|
|
|
else if( DrawText->m_Orient == 2 ) /* invert horizontal text*/
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawText->m_Orient = 0;
|
|
|
|
|
|
|
|
px = DrawText->m_Pos;
|
|
|
|
MirrorYPoint( px, Center );
|
2008-12-08 15:27:13 +00:00
|
|
|
frame->PutOnGrid( &px );
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawText->m_Pos.x = px.x;
|
|
|
|
break;
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_COMPONENT:
|
|
|
|
DrawLibItem = (SCH_COMPONENT*) DrawStruct;
|
2007-08-20 01:20:48 +00:00
|
|
|
dx = DrawLibItem->m_Pos.x;
|
2008-12-08 15:27:13 +00:00
|
|
|
frame->CmpRotationMiroir( DrawLibItem, NULL, CMP_MIROIR_Y );
|
2007-08-20 01:20:48 +00:00
|
|
|
MirrorYPoint( DrawLibItem->m_Pos, Center );
|
|
|
|
dx -= DrawLibItem->m_Pos.x;
|
|
|
|
|
2009-01-02 17:07:50 +00:00
|
|
|
for( int ii = 0; ii < DrawLibItem->GetFieldCount(); ii++ )
|
2008-10-06 05:44:29 +00:00
|
|
|
{
|
|
|
|
/* move the fields to the new position because the component itself has moved */
|
2008-12-08 15:27:13 +00:00
|
|
|
DrawLibItem->GetField( ii )->m_Pos.x -= dx;
|
2008-10-06 05:44:29 +00:00
|
|
|
}
|
2008-12-08 15:27:13 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_SHEET_STRUCT_TYPE:
|
|
|
|
DrawSheet = (DrawSheetStruct*) DrawStruct;
|
|
|
|
MirrorYPoint( DrawSheet->m_Pos, Center );
|
|
|
|
DrawSheet->m_Pos.x -= DrawSheet->m_Size.x;
|
|
|
|
|
|
|
|
DrawSheetLabel = DrawSheet->m_Label;
|
|
|
|
while( DrawSheetLabel != NULL )
|
|
|
|
{
|
|
|
|
MirrorYPoint( DrawSheetLabel->m_Pos, Center );
|
|
|
|
DrawSheetLabel->m_Edge = DrawSheetLabel->m_Edge ? 0 : 1;
|
2008-12-08 15:27:13 +00:00
|
|
|
DrawSheetLabel =
|
|
|
|
(Hierarchical_PIN_Sheet_Struct*) DrawSheetLabel->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
|
|
|
|
DrawSheetLabel = (Hierarchical_PIN_Sheet_Struct*) DrawStruct;
|
2007-08-20 01:20:48 +00:00
|
|
|
MirrorYPoint( DrawSheetLabel->m_Pos, Center );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_PICK_ITEM_STRUCT_TYPE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Routine to Mirror an object(s). *
|
|
|
|
* If DrawStruct is of type DrawPickedStruct, a list of objects picked is *
|
|
|
|
* assumed, otherwise exactly one structure is assumed been picked. *
|
|
|
|
*****************************************************************************/
|
2008-12-08 15:27:13 +00:00
|
|
|
bool MirrorStruct( WinEDA_DrawPanel* panel,
|
|
|
|
wxDC* DC,
|
|
|
|
SCH_ITEM* DrawStruct,
|
|
|
|
wxPoint& Center )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( !DrawStruct )
|
|
|
|
return FALSE;
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
if( DrawStruct->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
DrawPickedStruct* pickedList = (DrawPickedStruct*) DrawStruct;
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( DC )
|
2008-03-20 01:50:21 +00:00
|
|
|
panel->PostDirtyRect( pickedList->GetBoundingBoxUnion() );
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
for( DrawPickedStruct* cur = pickedList; cur; cur = cur->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-04-14 19:22:48 +00:00
|
|
|
MirrorOneStruct( (SCH_ITEM*) cur->m_PickedStruct, Center );
|
2008-03-20 01:50:21 +00:00
|
|
|
cur->m_PickedStruct->m_Flags = 0;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( DC )
|
2009-04-05 20:49:15 +00:00
|
|
|
RedrawStructList( panel, DC, (SCH_ITEM*) pickedList,
|
|
|
|
GR_DEFAULT_DRAWMODE );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
// Free the wrapper DrawPickedStruct chain
|
|
|
|
pickedList->DeleteWrapperList();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( DC )
|
2008-03-20 01:50:21 +00:00
|
|
|
panel->PostDirtyRect( DrawStruct->GetBoundingBox() );
|
|
|
|
|
|
|
|
MirrorOneStruct( DrawStruct, Center ); // Place it in its new position.
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( DC )
|
|
|
|
RedrawOneStruct( panel, DC, DrawStruct, GR_DEFAULT_DRAWMODE );
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawStruct->m_Flags = 0;
|
|
|
|
}
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
return true;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2008-12-08 15:27:13 +00:00
|
|
|
static SCH_ITEM* CopyStruct( WinEDA_DrawPanel* panel,
|
|
|
|
wxDC* DC,
|
|
|
|
BASE_SCREEN* screen,
|
|
|
|
SCH_ITEM* DrawStruct )
|
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 copy a new entity of an object and reposition it.
|
2007-08-20 01:20:48 +00:00
|
|
|
* If DrawStruct is of type DrawPickedStruct, a list of objects picked is
|
|
|
|
* assumed, otherwise exactly one structure is assumed been picked.
|
|
|
|
* Return the new created struct
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
SCH_ITEM* NewDrawStruct;
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPickedStruct* PickedList = NULL;
|
|
|
|
|
|
|
|
if( !DrawStruct )
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
NewDrawStruct = DuplicateStruct( DrawStruct );
|
|
|
|
if( NewDrawStruct == NULL )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
PlaceStruct( screen, NewDrawStruct );
|
|
|
|
/* Draw the new structure and chain it in: */
|
2007-09-01 12:00:30 +00:00
|
|
|
if( NewDrawStruct->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
PickedList = (DrawPickedStruct*) NewDrawStruct;
|
|
|
|
while( PickedList ) // Clear annotation for new components
|
|
|
|
{
|
|
|
|
EDA_BaseStruct* Struct = PickedList->m_PickedStruct;
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( Struct->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_COMPONENT:
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
( (SCH_COMPONENT*) Struct )->m_TimeStamp = GetTimeStamp();
|
2008-12-08 15:27:13 +00:00
|
|
|
( (SCH_COMPONENT*) Struct )->ClearAnnotation( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2009-02-12 08:12:41 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
case DRAW_SHEET_STRUCT_TYPE:
|
|
|
|
{
|
2008-02-28 19:27:25 +00:00
|
|
|
//DuplicateStruct calls GenCopy, which should handle
|
|
|
|
//m_AssociatedScreen and m_sRefCount properly.
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawSheetStruct* sheet = (DrawSheetStruct*) Struct;
|
|
|
|
sheet->m_TimeStamp = GetTimeStamp();
|
2008-02-28 19:27:25 +00:00
|
|
|
|
|
|
|
//sheet->m_AssociatedScreen->m_UndoList = NULL;
|
|
|
|
//sheet->m_AssociatedScreen->m_RedoList = NULL;
|
|
|
|
//keep m_AssociatedScreen pointer & associated.
|
2008-02-12 21:12:46 +00:00
|
|
|
//sheet->m_Son = NULL; m_son is involved in undo and redo.
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-02-28 19:27:25 +00:00
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
default:
|
|
|
|
;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
SetaParent( Struct, screen );
|
2008-11-24 06:53:43 +00:00
|
|
|
PickedList = (DrawPickedStruct*) PickedList->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RedrawStructList( panel, DC, NewDrawStruct, GR_DEFAULT_DRAWMODE );
|
|
|
|
/* Chain the new items */
|
|
|
|
PickedList = (DrawPickedStruct*) NewDrawStruct;
|
|
|
|
while( PickedList )
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
PickedList->m_PickedStruct->SetNext( screen->EEDrawList );
|
2009-04-05 20:49:15 +00:00
|
|
|
screen->EEDrawList = (SCH_ITEM*) PickedList->m_PickedStruct;
|
2007-08-20 01:20:48 +00:00
|
|
|
PickedList = PickedList->Next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( NewDrawStruct->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
case DRAW_POLYLINE_STRUCT_TYPE:
|
|
|
|
case DRAW_JUNCTION_STRUCT_TYPE:
|
|
|
|
case DRAW_SEGMENT_STRUCT_TYPE:
|
|
|
|
case DRAW_BUSENTRY_STRUCT_TYPE:
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_TEXT:
|
|
|
|
case TYPE_SCH_LABEL:
|
|
|
|
case TYPE_SCH_GLOBALLABEL:
|
|
|
|
case TYPE_SCH_HIERLABEL:
|
2008-04-15 19:38:19 +00:00
|
|
|
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
|
2007-08-20 01:20:48 +00:00
|
|
|
case DRAW_PICK_ITEM_STRUCT_TYPE:
|
|
|
|
case DRAW_MARKER_STRUCT_TYPE:
|
|
|
|
case DRAW_NOCONNECT_STRUCT_TYPE:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_SHEET_STRUCT_TYPE:
|
|
|
|
{
|
|
|
|
DrawSheetStruct* sheet = (DrawSheetStruct*) NewDrawStruct;
|
|
|
|
sheet->m_TimeStamp = GetTimeStamp();
|
2008-11-24 06:53:43 +00:00
|
|
|
sheet->SetSon( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_COMPONENT:
|
|
|
|
( (SCH_COMPONENT*) NewDrawStruct )->m_TimeStamp = GetTimeStamp();
|
2008-12-08 15:27:13 +00:00
|
|
|
( (SCH_COMPONENT*) NewDrawStruct )->ClearAnnotation( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
RedrawOneStruct( panel, DC, NewDrawStruct, GR_DEFAULT_DRAWMODE );
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
SetaParent( NewDrawStruct, screen );
|
2008-11-24 06:53:43 +00:00
|
|
|
NewDrawStruct->SetNext( screen->EEDrawList );
|
2008-12-08 15:27:13 +00:00
|
|
|
screen->EEDrawList = NewDrawStruct;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Free the original DrawPickedStruct chain: */
|
2007-09-01 12:00:30 +00:00
|
|
|
if( DrawStruct->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
PickedList = (DrawPickedStruct*) DrawStruct;
|
|
|
|
PickedList->DeleteWrapperList();
|
|
|
|
}
|
|
|
|
|
|
|
|
return NewDrawStruct;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*********************************************************************************/
|
2008-12-08 15:27:13 +00:00
|
|
|
void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM* DrawStruct )
|
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 delete an object from global drawing object list.
|
2007-08-20 01:20:48 +00:00
|
|
|
* Object is put in Undo list
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
SCH_SCREEN* screen = (SCH_SCREEN*) panel->GetScreen();
|
|
|
|
WinEDA_SchematicFrame* frame = (WinEDA_SchematicFrame*) panel->m_Parent;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( !DrawStruct )
|
|
|
|
return;
|
|
|
|
|
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
|
|
|
{
|
|
|
|
/* Cette stucture est rattachee a une feuille, et n'est pas
|
2007-08-20 01:20:48 +00:00
|
|
|
* accessible par la liste globale directement */
|
2009-02-12 08:12:41 +00:00
|
|
|
frame->SaveCopyInUndoList( (SCH_ITEM*) ( (Hierarchical_PIN_Sheet_Struct
|
|
|
|
*) DrawStruct )->GetParent(),
|
2008-12-08 15:27:13 +00:00
|
|
|
IS_CHANGED );
|
|
|
|
frame->DeleteSheetLabel( DC ? true : false,
|
|
|
|
(Hierarchical_PIN_Sheet_Struct*) DrawStruct );
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
if( DrawStruct->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
// Unlink all picked structs from current EEDrawList
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
for( DrawPickedStruct* cur = (DrawPickedStruct*) DrawStruct;
|
|
|
|
cur;
|
|
|
|
cur = cur->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
SCH_ITEM* item = (SCH_ITEM*)cur->m_PickedStruct;
|
2008-03-20 01:50:21 +00:00
|
|
|
screen->RemoveFromDrawList( item );
|
|
|
|
panel->PostDirtyRect( item->GetBoundingBox() );
|
2008-11-24 06:53:43 +00:00
|
|
|
item->SetNext( 0 );
|
|
|
|
item->SetBack( 0 );
|
2008-12-08 15:27:13 +00:00
|
|
|
item->m_Flags = IS_DELETED;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
// Removed items are put onto the Undo list
|
2007-08-20 01:20:48 +00:00
|
|
|
frame->SaveCopyInUndoList( DrawStruct, IS_DELETED );
|
|
|
|
}
|
|
|
|
else /* structure classique */
|
|
|
|
{
|
|
|
|
screen->RemoveFromDrawList( DrawStruct );
|
|
|
|
|
2008-03-30 11:57:40 +00:00
|
|
|
panel->PostDirtyRect( DrawStruct->GetBoundingBox() );
|
2008-03-13 05:04:59 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
/* Unlink the structure */
|
2008-11-24 06:53:43 +00:00
|
|
|
DrawStruct->SetNext( 0 );
|
|
|
|
DrawStruct->SetBack( 0 ); // Only one struct -> no link
|
|
|
|
|
2008-02-28 19:27:25 +00:00
|
|
|
if( DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE )
|
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
frame->SaveCopyInUndoList( DrawStruct, IS_DELETED ); // Currently In TEST
|
2008-02-28 19:27:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
frame->SaveCopyInUndoList( DrawStruct, IS_DELETED );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*****************************************************************/
|
2008-12-08 15:27:13 +00:00
|
|
|
SCH_ITEM* SaveStructListForPaste( SCH_ITEM* DrawStruct )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*****************************************************************/
|
|
|
|
|
|
|
|
/* Routine to Save an object from global drawing object list.
|
2007-08-20 01:20:48 +00:00
|
|
|
* This routine is the same as delete but:
|
|
|
|
* - the original list is NOT removed.
|
|
|
|
* - List is saved in g_BlockSaveDataList
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPickedStruct* PickedList;
|
2008-12-08 15:27:13 +00:00
|
|
|
SCH_ITEM* DrawStructCopy;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( !DrawStruct )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* Make a copy of the original picked item. */
|
|
|
|
DrawStructCopy = DuplicateStruct( DrawStruct );
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
if( DrawStruct->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
/* Delete the picked wrapper if this is a picked list. */
|
|
|
|
PickedList = (DrawPickedStruct*) DrawStruct;
|
|
|
|
PickedList->DeleteWrapperList();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* And delete old list and save the new list: */
|
|
|
|
if( g_BlockSaveDataList ) /* Delete last deleted item or item list */
|
|
|
|
{
|
|
|
|
EDA_BaseStruct* item = g_BlockSaveDataList, * next_item;
|
|
|
|
while( item )
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
next_item = item->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
delete item;
|
|
|
|
item = next_item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
g_BlockSaveDataList = DrawStructCopy;
|
|
|
|
DrawStructCopy->SetParent( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
return DrawStructCopy;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Routine to paste a structure from the g_BlockSaveDataList stack. *
|
|
|
|
* This routine is the same as undelete but original list is NOT removed. *
|
|
|
|
*****************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_SchematicFrame::PasteStruct( wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
SCH_ITEM* DrawStruct;
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPickedStruct* PickedList = NULL;
|
|
|
|
|
|
|
|
if( g_BlockSaveDataList == NULL )
|
|
|
|
{
|
|
|
|
DisplayError( this, wxT( "No struct to paste" ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawStruct = DuplicateStruct( g_BlockSaveDataList );
|
|
|
|
|
|
|
|
PlaceStruct( GetScreen(), DrawStruct );
|
|
|
|
|
|
|
|
RedrawStructList( DrawPanel, DC, DrawStruct, GR_DEFAULT_DRAWMODE );
|
|
|
|
|
|
|
|
// Clear annotation and init new time stamp for the new components:
|
2007-09-01 12:00:30 +00:00
|
|
|
if( DrawStruct->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
for( PickedList = (DrawPickedStruct*) DrawStruct; PickedList != NULL; ) // Clear annotation for new components
|
|
|
|
{
|
|
|
|
EDA_BaseStruct* Struct = PickedList->m_PickedStruct;
|
2008-03-20 01:50:21 +00:00
|
|
|
if( Struct->Type() == TYPE_SCH_COMPONENT )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
( (SCH_COMPONENT*) Struct )->m_TimeStamp = GetTimeStamp();
|
2008-12-08 15:27:13 +00:00
|
|
|
( (SCH_COMPONENT*) Struct )->ClearAnnotation( NULL );
|
2008-12-04 04:28:11 +00:00
|
|
|
SetaParent( Struct, GetScreen() );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2008-11-24 06:53:43 +00:00
|
|
|
PickedList = (DrawPickedStruct*) PickedList->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RedrawStructList( DrawPanel, DC, DrawStruct, GR_DEFAULT_DRAWMODE );
|
|
|
|
for( PickedList = (DrawPickedStruct*) DrawStruct; PickedList != NULL; )
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
SCH_ITEM* Struct = (SCH_ITEM*) PickedList->m_PickedStruct;
|
2008-11-24 06:53:43 +00:00
|
|
|
Struct->SetNext( GetScreen()->EEDrawList );
|
2008-12-04 04:28:11 +00:00
|
|
|
SetaParent( Struct, GetScreen() );
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->EEDrawList = Struct;
|
2008-04-14 19:22:48 +00:00
|
|
|
PickedList = PickedList->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Save wrapper list in undo stack */
|
|
|
|
SaveCopyInUndoList( DrawStruct, IS_NEW );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
if( DrawStruct->Type() == TYPE_SCH_COMPONENT )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
( (SCH_COMPONENT*) DrawStruct )->m_TimeStamp = GetTimeStamp();
|
2008-12-08 15:27:13 +00:00
|
|
|
( (SCH_COMPONENT*) DrawStruct )->ClearAnnotation( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2008-12-04 04:28:11 +00:00
|
|
|
SetaParent( DrawStruct, GetScreen() );
|
2007-08-20 01:20:48 +00:00
|
|
|
RedrawOneStruct( DrawPanel, DC, DrawStruct, GR_DEFAULT_DRAWMODE );
|
2008-11-24 06:53:43 +00:00
|
|
|
DrawStruct->SetNext( GetScreen()->EEDrawList );
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->EEDrawList = DrawStruct;
|
|
|
|
SaveCopyInUndoList( DrawStruct, IS_NEW );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* clear .m_Flags member for all items */
|
2008-12-08 15:27:13 +00:00
|
|
|
SCH_ITEM* Struct;
|
|
|
|
for( Struct = GetScreen()->EEDrawList;
|
|
|
|
Struct != NULL;
|
|
|
|
Struct = Struct->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
Struct->m_Flags = 0;
|
|
|
|
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
|
|
|
|
return;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Routine to place a given object. *
|
|
|
|
*****************************************************************************/
|
2008-12-08 15:27:13 +00:00
|
|
|
bool PlaceStruct( BASE_SCREEN* screen, SCH_ITEM* DrawStruct )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPickedStruct* DrawStructs;
|
|
|
|
wxPoint move_vector;
|
|
|
|
|
|
|
|
if( !DrawStruct )
|
|
|
|
return FALSE;
|
|
|
|
|
2009-01-02 13:19:34 +00:00
|
|
|
move_vector = screen->m_Curseur - screen->BlockLocate.m_BlockLastCursorPosition;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( DrawStruct->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
default:
|
|
|
|
case TYPE_NOT_INIT:
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
case DRAW_POLYLINE_STRUCT_TYPE:
|
|
|
|
case DRAW_JUNCTION_STRUCT_TYPE:
|
|
|
|
case DRAW_SEGMENT_STRUCT_TYPE:
|
|
|
|
case DRAW_BUSENTRY_STRUCT_TYPE:
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_TEXT:
|
|
|
|
case TYPE_SCH_LABEL:
|
|
|
|
case TYPE_SCH_GLOBALLABEL:
|
|
|
|
case TYPE_SCH_HIERLABEL:
|
|
|
|
case TYPE_SCH_COMPONENT:
|
2007-08-20 01:20:48 +00:00
|
|
|
case DRAW_SHEET_STRUCT_TYPE:
|
2008-04-15 19:38:19 +00:00
|
|
|
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
|
2007-08-20 01:20:48 +00:00
|
|
|
case DRAW_MARKER_STRUCT_TYPE:
|
|
|
|
case DRAW_NOCONNECT_STRUCT_TYPE:
|
|
|
|
MoveOneStruct( DrawStruct, move_vector );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_PICK_ITEM_STRUCT_TYPE:
|
|
|
|
DrawStructs = (DrawPickedStruct*) DrawStruct;
|
|
|
|
while( DrawStructs )
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
MoveOneStruct( (SCH_ITEM*) DrawStructs->m_PickedStruct,
|
|
|
|
move_vector );
|
2008-04-14 19:22:48 +00:00
|
|
|
DrawStructs = DrawStructs->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/**************************************************************************/
|
2008-12-08 15:27:13 +00:00
|
|
|
void MoveOneStruct( SCH_ITEM* DrawStruct, const wxPoint& move_vector )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/* Given a structure move it by Dx, Dy.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
DrawPolylineStruct* DrawPoly;
|
|
|
|
DrawJunctionStruct* DrawConnect;
|
|
|
|
EDA_DrawLineStruct* DrawSegment;
|
|
|
|
DrawBusEntryStruct* DrawRaccord;
|
|
|
|
SCH_COMPONENT* DrawLibItem;
|
|
|
|
DrawSheetStruct* DrawSheet;
|
|
|
|
Hierarchical_PIN_Sheet_Struct* DrawSheetLabel;
|
|
|
|
DrawMarkerStruct* DrawMarker;
|
|
|
|
DrawNoConnectStruct* DrawNoConnect;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( !DrawStruct )
|
|
|
|
return;
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( DrawStruct->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
case TYPE_NOT_INIT:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_POLYLINE_STRUCT_TYPE:
|
|
|
|
DrawPoly = (DrawPolylineStruct*) DrawStruct;
|
2009-01-02 17:07:50 +00:00
|
|
|
for( unsigned ii = 0; ii < DrawPoly->GetCornerCount(); ii++ )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-01-02 17:07:50 +00:00
|
|
|
DrawPoly->m_PolyPoints[ii] += move_vector;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_SEGMENT_STRUCT_TYPE:
|
|
|
|
DrawSegment = (EDA_DrawLineStruct*) DrawStruct;
|
|
|
|
if( (DrawSegment->m_Flags & STARTPOINT) == 0 )
|
|
|
|
{
|
|
|
|
DrawSegment->m_Start += move_vector;
|
|
|
|
}
|
|
|
|
if( (DrawSegment->m_Flags & ENDPOINT) == 0 )
|
|
|
|
{
|
|
|
|
DrawSegment->m_End += move_vector;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_BUSENTRY_STRUCT_TYPE:
|
|
|
|
DrawRaccord = (DrawBusEntryStruct*) DrawStruct;
|
|
|
|
DrawRaccord->m_Pos += move_vector;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_JUNCTION_STRUCT_TYPE:
|
|
|
|
DrawConnect = (DrawJunctionStruct*) DrawStruct;
|
|
|
|
DrawConnect->m_Pos += move_vector;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_MARKER_STRUCT_TYPE:
|
|
|
|
DrawMarker = (DrawMarkerStruct*) DrawStruct;
|
|
|
|
DrawMarker->m_Pos += move_vector;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_NOCONNECT_STRUCT_TYPE:
|
|
|
|
DrawNoConnect = (DrawNoConnectStruct*) DrawStruct;
|
|
|
|
DrawNoConnect->m_Pos += move_vector;
|
|
|
|
break;
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_TEXT:
|
|
|
|
#define DrawText ( (SCH_TEXT*) DrawStruct )
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawText->m_Pos += move_vector;
|
|
|
|
break;
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_LABEL:
|
|
|
|
#define DrawLabel ( (SCH_LABEL*) DrawStruct )
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawLabel->m_Pos += move_vector;
|
|
|
|
break;
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_HIERLABEL:
|
|
|
|
case TYPE_SCH_GLOBALLABEL:
|
|
|
|
#define DrawGHLabel ( (SCH_LABEL*) DrawStruct )
|
2008-02-12 21:12:46 +00:00
|
|
|
DrawGHLabel->m_Pos += move_vector;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_COMPONENT:
|
|
|
|
DrawLibItem = (SCH_COMPONENT*) DrawStruct;
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawLibItem->m_Pos += move_vector;
|
2009-01-02 17:07:50 +00:00
|
|
|
for( int ii = 0; ii < DrawLibItem->GetFieldCount(); ii++ )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
DrawLibItem->GetField( ii )->m_Pos += move_vector;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_SHEET_STRUCT_TYPE:
|
|
|
|
DrawSheet = (DrawSheetStruct*) DrawStruct;
|
|
|
|
DrawSheet->m_Pos += move_vector;
|
|
|
|
DrawSheetLabel = DrawSheet->m_Label;
|
|
|
|
while( DrawSheetLabel != NULL )
|
|
|
|
{
|
|
|
|
DrawSheetLabel->m_Pos += move_vector;
|
|
|
|
DrawSheetLabel = DrawSheetLabel->Next();
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
|
|
|
|
DrawSheetLabel = (Hierarchical_PIN_Sheet_Struct*) DrawStruct;
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawSheetLabel->m_Pos += move_vector;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_PICK_ITEM_STRUCT_TYPE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************/
|
2008-12-08 15:27:13 +00:00
|
|
|
SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct )
|
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 a new copy of given struct.
|
2007-08-20 01:20:48 +00:00
|
|
|
* The new object is not put in draw list (not linked)
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
SCH_ITEM* NewDrawStruct = NULL;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( DrawStruct == NULL )
|
|
|
|
{
|
|
|
|
DisplayError( NULL, wxT( "DuplicateStruct error: NULL struct" ) );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( DrawStruct->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
case DRAW_POLYLINE_STRUCT_TYPE:
|
|
|
|
NewDrawStruct = ( (DrawPolylineStruct*) DrawStruct )->GenCopy();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_SEGMENT_STRUCT_TYPE:
|
|
|
|
NewDrawStruct = ( (EDA_DrawLineStruct*) DrawStruct )->GenCopy();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_BUSENTRY_STRUCT_TYPE:
|
|
|
|
NewDrawStruct = ( (DrawBusEntryStruct*) DrawStruct )->GenCopy();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_JUNCTION_STRUCT_TYPE:
|
|
|
|
NewDrawStruct = ( (DrawJunctionStruct*) DrawStruct )->GenCopy();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_MARKER_STRUCT_TYPE:
|
|
|
|
NewDrawStruct = ( (DrawMarkerStruct*) DrawStruct )->GenCopy();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_NOCONNECT_STRUCT_TYPE:
|
|
|
|
NewDrawStruct = ( (DrawNoConnectStruct*) DrawStruct )->GenCopy();
|
|
|
|
break;
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_TEXT:
|
|
|
|
NewDrawStruct = ( (SCH_TEXT*) DrawStruct )->GenCopy();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_LABEL:
|
|
|
|
NewDrawStruct = ( (SCH_LABEL*) DrawStruct )->GenCopy();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_HIERLABEL:
|
|
|
|
NewDrawStruct = ( (SCH_HIERLABEL*) DrawStruct )->GenCopy();
|
2008-02-12 21:12:46 +00:00
|
|
|
break;
|
2008-02-28 19:27:25 +00:00
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_GLOBALLABEL:
|
|
|
|
NewDrawStruct = ( (SCH_GLOBALLABEL*) DrawStruct )->GenCopy();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_COMPONENT:
|
|
|
|
NewDrawStruct = ( (SCH_COMPONENT*) DrawStruct )->GenCopy();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_SHEET_STRUCT_TYPE:
|
|
|
|
NewDrawStruct = ( (DrawSheetStruct*) DrawStruct )->GenCopy();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_PICK_ITEM_STRUCT_TYPE:
|
|
|
|
{
|
|
|
|
DrawPickedStruct* NewPickedItem, * PickedList = NULL,
|
|
|
|
* LastPickedItem = NULL;
|
|
|
|
PickedList = (DrawPickedStruct*) DrawStruct;
|
|
|
|
while( PickedList )
|
|
|
|
{
|
|
|
|
NewPickedItem = new DrawPickedStruct();
|
|
|
|
if( NewDrawStruct == NULL )
|
2009-04-05 20:49:15 +00:00
|
|
|
NewDrawStruct = (SCH_ITEM*) NewPickedItem;
|
2007-08-20 01:20:48 +00:00
|
|
|
if( LastPickedItem )
|
2008-11-24 06:53:43 +00:00
|
|
|
LastPickedItem->SetNext( NewPickedItem );
|
2007-08-20 01:20:48 +00:00
|
|
|
LastPickedItem = NewPickedItem;
|
|
|
|
NewPickedItem->m_PickedStruct =
|
2009-04-05 20:49:15 +00:00
|
|
|
DuplicateStruct( (SCH_ITEM*) PickedList->m_PickedStruct );
|
2008-04-14 19:22:48 +00:00
|
|
|
PickedList = PickedList->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
|
2007-08-20 01:20:48 +00:00
|
|
|
case DRAW_PART_TEXT_STRUCT_TYPE:
|
|
|
|
case SCREEN_STRUCT_TYPE:
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
msg << wxT( "DuplicateStruct error: unexpected StructType " ) <<
|
2007-09-13 11:28:58 +00:00
|
|
|
DrawStruct->Type() << wxT( " " ) << DrawStruct->GetClass();
|
2007-08-20 01:20:48 +00:00
|
|
|
DisplayError( NULL, msg );
|
|
|
|
}
|
2009-02-12 08:12:41 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NewDrawStruct->m_Image = DrawStruct;
|
|
|
|
return NewDrawStruct;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
static void CollectStructsToDrag( SCH_SCREEN* screen )
|
2007-05-06 16:03:28 +00:00
|
|
|
/****************************************************/
|
2009-02-12 08:12:41 +00:00
|
|
|
|
|
|
|
/* creates the list of items found when a drag block is initiated.
|
|
|
|
* items are those slected in window block an some items outside this area but connected
|
|
|
|
* to a selected item (connected wires to a component or an entry )
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPickedStruct* DrawStructs, * FirstPicked;
|
2008-12-08 15:27:13 +00:00
|
|
|
SCH_ITEM* Struct;
|
2007-08-20 01:20:48 +00:00
|
|
|
EDA_DrawLineStruct* SegmStruct;
|
|
|
|
int ox, oy, fx, fy;
|
|
|
|
|
2009-02-12 08:12:41 +00:00
|
|
|
/* .m_Flags member is used to handle how a wire is exactly slected
|
|
|
|
* (fully selected, or partially selected by an end point )
|
|
|
|
*/
|
2008-04-14 19:22:48 +00:00
|
|
|
for( Struct = screen->EEDrawList; Struct != NULL; Struct = Struct->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
Struct->m_Flags = 0;
|
|
|
|
|
2009-02-12 08:12:41 +00:00
|
|
|
// Sel .m_Flags to selected for a wire or buss in selected area if there is only one item:
|
|
|
|
if( screen->BlockLocate.m_BlockDrawStruct->Type() == DRAW_SEGMENT_STRUCT_TYPE )
|
2007-08-20 01:20:48 +00:00
|
|
|
screen->BlockLocate.m_BlockDrawStruct->m_Flags = SELECTED;
|
|
|
|
|
2009-02-12 08:12:41 +00:00
|
|
|
// Sel .m_Flags to selected for a wire or buss in selected area for a list of items:
|
2008-12-08 15:27:13 +00:00
|
|
|
else if( screen->BlockLocate.m_BlockDrawStruct->Type() ==
|
|
|
|
DRAW_PICK_ITEM_STRUCT_TYPE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
DrawStructs =
|
|
|
|
(DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct;
|
2007-08-20 01:20:48 +00:00
|
|
|
while( DrawStructs )
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
Struct = (SCH_ITEM*) DrawStructs->m_PickedStruct;
|
2008-04-14 19:22:48 +00:00
|
|
|
DrawStructs = DrawStructs->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
Struct->m_Flags = SELECTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( screen->BlockLocate.m_Command != BLOCK_DRAG )
|
|
|
|
return;
|
|
|
|
|
|
|
|
ox = screen->BlockLocate.GetX();
|
|
|
|
oy = screen->BlockLocate.GetY();
|
|
|
|
fx = screen->BlockLocate.GetRight();
|
|
|
|
fy = screen->BlockLocate.GetBottom();
|
|
|
|
|
|
|
|
if( fx < ox )
|
|
|
|
EXCHG( fx, ox );
|
|
|
|
if( fy < oy )
|
|
|
|
EXCHG( fy, oy );
|
|
|
|
|
2009-02-12 08:12:41 +00:00
|
|
|
/* For drag block only:
|
|
|
|
* If only one item, change for a list of one item
|
|
|
|
* in order to have always a list to handle.
|
|
|
|
*/
|
2008-12-08 15:27:13 +00:00
|
|
|
if( screen->BlockLocate.m_BlockDrawStruct->Type() !=
|
|
|
|
DRAW_PICK_ITEM_STRUCT_TYPE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
DrawStructs = new DrawPickedStruct(
|
2009-02-12 08:12:41 +00:00
|
|
|
(SCH_ITEM*) screen->BlockLocate.m_BlockDrawStruct );
|
2007-08-20 01:20:48 +00:00
|
|
|
screen->BlockLocate.m_BlockDrawStruct = DrawStructs;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Suppression du deplacement des extremites de segments hors cadre
|
|
|
|
* de selection */
|
|
|
|
DrawStructs = (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct;
|
|
|
|
while( DrawStructs )
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
Struct = (SCH_ITEM*) DrawStructs->m_PickedStruct;
|
2008-04-14 19:22:48 +00:00
|
|
|
DrawStructs = DrawStructs->Next();
|
2007-09-01 12:00:30 +00:00
|
|
|
if( Struct->Type() == DRAW_SEGMENT_STRUCT_TYPE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
SegmStruct = (EDA_DrawLineStruct*) Struct;
|
|
|
|
if( (SegmStruct->m_Start.x < ox) || (SegmStruct->m_Start.x > fx)
|
|
|
|
|| (SegmStruct->m_Start.y < oy) || (SegmStruct->m_Start.y > fy) )
|
|
|
|
SegmStruct->m_Flags |= STARTPOINT;
|
|
|
|
|
|
|
|
if( (SegmStruct->m_End.x < ox) || (SegmStruct->m_End.x > fx)
|
|
|
|
|| (SegmStruct->m_End.y < oy) || (SegmStruct->m_End.y > fy) )
|
|
|
|
SegmStruct->m_Flags |= ENDPOINT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-12 08:12:41 +00:00
|
|
|
/* Search for other items to drag. They are end wires connected to selected items
|
|
|
|
*/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
FirstPicked = DrawStructs =
|
2009-04-05 20:49:15 +00:00
|
|
|
(DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct;
|
2007-08-20 01:20:48 +00:00
|
|
|
while( DrawStructs )
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
Struct = (SCH_ITEM*) DrawStructs->m_PickedStruct;
|
2008-04-14 19:22:48 +00:00
|
|
|
DrawStructs = DrawStructs->Next();
|
2008-03-20 01:50:21 +00:00
|
|
|
if( Struct->Type() == TYPE_SCH_COMPONENT )
|
2009-02-12 08:12:41 +00:00
|
|
|
{ // Add all pins of the selected component to list
|
2007-08-20 01:20:48 +00:00
|
|
|
LibEDA_BaseStruct* DrawItem;
|
2008-02-28 19:27:25 +00:00
|
|
|
wxPoint pos;
|
2008-03-20 01:50:21 +00:00
|
|
|
DrawItem = GetNextPinPosition( (SCH_COMPONENT*) Struct, pos );
|
2007-08-20 01:20:48 +00:00
|
|
|
while( DrawItem )
|
|
|
|
{
|
2009-02-12 08:12:41 +00:00
|
|
|
if( (pos.x < ox) || (pos.x > fx) || (pos.y < oy) || (pos.y > fy) )
|
|
|
|
{ // This pin is outside area,
|
|
|
|
// but because it it the pin of a selected component
|
|
|
|
// we must also select connected items to this pin
|
2007-09-04 14:28:20 +00:00
|
|
|
AddPickedItem( screen, pos );
|
2009-02-12 08:12:41 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-09-04 14:28:20 +00:00
|
|
|
DrawItem = GetNextPinPosition( NULL, pos );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
if( Struct->Type() == DRAW_SHEET_STRUCT_TYPE )
|
2009-02-12 08:12:41 +00:00
|
|
|
{ // Add all pins sheets of a selected hierarchical sheet to the list
|
2008-12-08 15:27:13 +00:00
|
|
|
Hierarchical_PIN_Sheet_Struct* SLabel =
|
|
|
|
( (DrawSheetStruct*) Struct )->m_Label;
|
2007-08-20 01:20:48 +00:00
|
|
|
while( SLabel )
|
|
|
|
{
|
2008-04-15 19:38:19 +00:00
|
|
|
if( SLabel->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
|
2007-09-04 14:28:20 +00:00
|
|
|
AddPickedItem( screen, SLabel->m_Pos );
|
2008-11-24 06:53:43 +00:00
|
|
|
SLabel = (Hierarchical_PIN_Sheet_Struct*) SLabel->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
if( Struct->Type() == DRAW_BUSENTRY_STRUCT_TYPE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
DrawBusEntryStruct* item = (DrawBusEntryStruct*) Struct;
|
2007-09-04 14:28:20 +00:00
|
|
|
AddPickedItem( screen, item->m_Pos );
|
|
|
|
AddPickedItem( screen, item->m_End() );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************/
|
2007-09-04 14:28:20 +00:00
|
|
|
static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
|
2007-05-06 16:03:28 +00:00
|
|
|
/******************************************************************/
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPickedStruct* DrawStructs;
|
2008-12-08 15:27:13 +00:00
|
|
|
SCH_ITEM* Struct;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
/* Examen de la liste des elements deja selectionnes */
|
|
|
|
DrawStructs = (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct;
|
|
|
|
while( DrawStructs )
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
Struct = (SCH_ITEM*) DrawStructs->m_PickedStruct;
|
2008-11-24 06:53:43 +00:00
|
|
|
DrawStructs = (DrawPickedStruct*) DrawStructs->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( Struct->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
case DRAW_SEGMENT_STRUCT_TYPE:
|
|
|
|
#undef STRUCT
|
|
|
|
#define STRUCT ( (EDA_DrawLineStruct*) Struct )
|
2007-09-04 14:28:20 +00:00
|
|
|
if( STRUCT->m_Start == position )
|
2007-08-20 01:20:48 +00:00
|
|
|
STRUCT->m_Flags &= ~STARTPOINT;
|
|
|
|
|
2007-09-04 14:28:20 +00:00
|
|
|
if( STRUCT->m_End == position )
|
2007-08-20 01:20:48 +00:00
|
|
|
STRUCT->m_Flags &= ~ENDPOINT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Examen de la liste des elements non selectionnes */
|
|
|
|
|
|
|
|
Struct = screen->EEDrawList;
|
|
|
|
while( Struct )
|
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( Struct->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
case TYPE_NOT_INIT:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_POLYLINE_STRUCT_TYPE:
|
|
|
|
if( Struct->m_Flags & SELECTED )
|
2008-02-28 19:27:25 +00:00
|
|
|
break; /* Deja en liste */
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_JUNCTION_STRUCT_TYPE:
|
|
|
|
#undef STRUCT
|
|
|
|
#define STRUCT ( (DrawJunctionStruct*) Struct )
|
|
|
|
if( Struct->m_Flags & SELECTED )
|
2008-02-28 19:27:25 +00:00
|
|
|
break; /* Deja en liste */
|
2007-09-04 14:28:20 +00:00
|
|
|
if( STRUCT->m_Pos != position )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
DrawStructs = new DrawPickedStruct( Struct );
|
2008-11-24 06:53:43 +00:00
|
|
|
DrawStructs->SetNext( screen->BlockLocate.m_BlockDrawStruct );
|
2008-12-08 15:27:13 +00:00
|
|
|
screen->BlockLocate.m_BlockDrawStruct =
|
|
|
|
(EDA_BaseStruct*) DrawStructs;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_SEGMENT_STRUCT_TYPE:
|
|
|
|
#undef STRUCT
|
|
|
|
#define STRUCT ( (EDA_DrawLineStruct*) Struct )
|
|
|
|
if( Struct->m_Flags & SELECTED )
|
2008-02-28 19:27:25 +00:00
|
|
|
break; /* Deja en liste */
|
2007-09-04 14:28:20 +00:00
|
|
|
if( STRUCT->m_Start == position )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
DrawStructs = new DrawPickedStruct( Struct );
|
2008-11-24 06:53:43 +00:00
|
|
|
DrawStructs->SetNext( screen->BlockLocate.m_BlockDrawStruct );
|
2008-12-08 15:27:13 +00:00
|
|
|
screen->BlockLocate.m_BlockDrawStruct =
|
|
|
|
(EDA_BaseStruct*) DrawStructs;
|
2007-08-20 01:20:48 +00:00
|
|
|
Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT;
|
|
|
|
Struct->m_Flags &= ~STARTPOINT;
|
|
|
|
}
|
2007-09-04 14:28:20 +00:00
|
|
|
else if( STRUCT->m_End == position )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
DrawStructs = new DrawPickedStruct( Struct );
|
2008-11-24 06:53:43 +00:00
|
|
|
DrawStructs->SetNext( screen->BlockLocate.m_BlockDrawStruct );
|
2008-12-08 15:27:13 +00:00
|
|
|
screen->BlockLocate.m_BlockDrawStruct =
|
|
|
|
(EDA_BaseStruct*) DrawStructs;
|
2007-08-20 01:20:48 +00:00
|
|
|
Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT;
|
|
|
|
Struct->m_Flags &= ~ENDPOINT;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_BUSENTRY_STRUCT_TYPE:
|
|
|
|
break;
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_TEXT:
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_LABEL:
|
2007-08-20 01:20:48 +00:00
|
|
|
#undef STRUCT
|
2008-03-20 01:50:21 +00:00
|
|
|
#define STRUCT ( (SCH_LABEL*) Struct )
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Struct->m_Flags & SELECTED )
|
2008-02-28 19:27:25 +00:00
|
|
|
break; /* Already in list */
|
2007-09-04 14:28:20 +00:00
|
|
|
if( STRUCT->m_Pos != position )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
DrawStructs = new DrawPickedStruct( Struct );
|
2008-11-24 06:53:43 +00:00
|
|
|
DrawStructs->SetNext( screen->BlockLocate.m_BlockDrawStruct );
|
2008-12-08 15:27:13 +00:00
|
|
|
screen->BlockLocate.m_BlockDrawStruct =
|
|
|
|
(EDA_BaseStruct*) DrawStructs;
|
2007-08-20 01:20:48 +00:00
|
|
|
Struct->m_Flags |= SELECTED;
|
|
|
|
break;
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_HIERLABEL:
|
|
|
|
case TYPE_SCH_GLOBALLABEL:
|
2007-08-20 01:20:48 +00:00
|
|
|
#undef STRUCT
|
2008-03-20 01:50:21 +00:00
|
|
|
#define STRUCT ( (SCH_LABEL*) Struct )
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Struct->m_Flags & SELECTED )
|
2008-02-28 19:27:25 +00:00
|
|
|
break; /* Already in list */
|
2007-09-04 14:28:20 +00:00
|
|
|
if( STRUCT->m_Pos != position )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
DrawStructs = new DrawPickedStruct( Struct );
|
2008-11-24 06:53:43 +00:00
|
|
|
DrawStructs->SetNext( screen->BlockLocate.m_BlockDrawStruct );
|
2008-12-08 15:27:13 +00:00
|
|
|
screen->BlockLocate.m_BlockDrawStruct =
|
|
|
|
(EDA_BaseStruct*) DrawStructs;
|
2007-08-20 01:20:48 +00:00
|
|
|
Struct->m_Flags |= SELECTED;
|
|
|
|
break;
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
case TYPE_SCH_COMPONENT:
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_SHEET_STRUCT_TYPE:
|
|
|
|
break;
|
|
|
|
|
2008-04-15 19:38:19 +00:00
|
|
|
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_PICK_ITEM_STRUCT_TYPE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_MARKER_STRUCT_TYPE:
|
|
|
|
#undef STRUCT
|
|
|
|
#define STRUCT ( (DrawMarkerStruct*) Struct )
|
|
|
|
if( Struct->m_Flags & SELECTED )
|
2008-02-28 19:27:25 +00:00
|
|
|
break; /* Already in list */
|
2007-09-04 14:28:20 +00:00
|
|
|
if( STRUCT->m_Pos != position )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
DrawStructs = new DrawPickedStruct( Struct );
|
2008-11-24 06:53:43 +00:00
|
|
|
DrawStructs->SetNext( screen->BlockLocate.m_BlockDrawStruct );
|
2008-12-08 15:27:13 +00:00
|
|
|
screen->BlockLocate.m_BlockDrawStruct =
|
|
|
|
(EDA_BaseStruct*) DrawStructs;
|
2007-08-20 01:20:48 +00:00
|
|
|
Struct->m_Flags |= SELECTED;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_NOCONNECT_STRUCT_TYPE:
|
|
|
|
#undef STRUCT
|
|
|
|
#define STRUCT ( (DrawNoConnectStruct*) Struct )
|
|
|
|
if( Struct->m_Flags & SELECTED )
|
2008-02-28 19:27:25 +00:00
|
|
|
break; /* Already in list */
|
2007-09-04 14:28:20 +00:00
|
|
|
if( STRUCT->m_Pos != position )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
DrawStructs = new DrawPickedStruct( Struct );
|
2008-11-24 06:53:43 +00:00
|
|
|
DrawStructs->SetNext( screen->BlockLocate.m_BlockDrawStruct );
|
2008-12-08 15:27:13 +00:00
|
|
|
screen->BlockLocate.m_BlockDrawStruct =
|
|
|
|
(EDA_BaseStruct*) DrawStructs;
|
2007-08-20 01:20:48 +00:00
|
|
|
Struct->m_Flags |= SELECTED;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-04-14 19:22:48 +00:00
|
|
|
Struct = Struct->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
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
/*********************************************************************************/
|
2009-01-02 13:19:34 +00:00
|
|
|
static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
|
|
|
|
wxPoint& aPosition )
|
2007-05-06 16:03:28 +00:00
|
|
|
/*********************************************************************************/
|
2009-02-12 08:12:41 +00:00
|
|
|
|
|
|
|
/** GetNextPinPosition()
|
|
|
|
* calculate position of the "next" pin of the aDrawLibItem component
|
|
|
|
* if aDrawLibItem is non null : search for the first pin
|
|
|
|
* if aDrawLibItem == NULL, search the next pin
|
|
|
|
* returns its position
|
|
|
|
* @param aDrawLibItem = component test. search for the first pin
|
|
|
|
* if NULL, serach for the next pin for each call
|
|
|
|
* @param aPosition = the calculated pin position, according to the component orientation and position
|
|
|
|
* @return a pointer to the pin
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
EDA_LibComponentStruct* Entry;
|
|
|
|
static LibEDA_BaseStruct* NextItem;
|
2009-02-12 08:12:41 +00:00
|
|
|
static int Multi, convert, TransMat[2][2];
|
2007-08-20 01:20:48 +00:00
|
|
|
LibEDA_BaseStruct* DEntry;
|
2007-09-04 14:28:20 +00:00
|
|
|
int orient;
|
2007-08-20 01:20:48 +00:00
|
|
|
LibDrawPin* Pin;
|
2009-02-12 08:12:41 +00:00
|
|
|
static wxPoint CmpPosition;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-01-02 13:19:34 +00:00
|
|
|
if( aDrawLibItem )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
NextItem = NULL;
|
2008-12-08 15:27:13 +00:00
|
|
|
if( ( Entry =
|
2009-01-02 13:19:34 +00:00
|
|
|
FindLibPart( aDrawLibItem->m_ChipName.GetData(), wxEmptyString,
|
2008-12-08 15:27:13 +00:00
|
|
|
FIND_ROOT ) ) == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
return NULL;
|
2009-02-12 08:12:41 +00:00
|
|
|
DEntry = Entry->m_Drawings;
|
|
|
|
Multi = aDrawLibItem->m_Multi;
|
|
|
|
convert = aDrawLibItem->m_Convert;
|
|
|
|
CmpPosition = aDrawLibItem->m_Pos;
|
2009-01-02 13:19:34 +00:00
|
|
|
memcpy( TransMat, aDrawLibItem->m_Transform, sizeof(TransMat) );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
DEntry = NextItem;
|
|
|
|
|
|
|
|
for( ; DEntry != NULL; DEntry = DEntry->Next() )
|
|
|
|
{
|
|
|
|
/* Elimination des elements non relatifs a l'unite */
|
|
|
|
if( Multi && DEntry->m_Unit && (DEntry->m_Unit != Multi) )
|
|
|
|
continue;
|
|
|
|
if( convert && DEntry->m_Convert && (DEntry->m_Convert != convert) )
|
|
|
|
continue;
|
2007-09-01 12:00:30 +00:00
|
|
|
if( DEntry->Type() != COMPONENT_PIN_DRAW_TYPE )
|
2007-08-20 01:20:48 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
Pin = (LibDrawPin*) DEntry;
|
|
|
|
|
|
|
|
/* Calcul de l'orientation reelle de la Pin */
|
|
|
|
orient = Pin->ReturnPinDrawOrient( TransMat );
|
|
|
|
|
|
|
|
/* Calcul de la position du point de reference */
|
2009-02-12 08:12:41 +00:00
|
|
|
aPosition = TransformCoordinate( TransMat, Pin->m_Pos ) + CmpPosition;
|
|
|
|
NextItem = DEntry->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
return DEntry;
|
|
|
|
}
|
|
|
|
|
|
|
|
NextItem = NULL;
|
|
|
|
return NULL;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|