2007-05-06 16:03:28 +00:00
|
|
|
/****************************************************/
|
2009-12-02 21:44:03 +00:00
|
|
|
/* BLOCK.CPP */
|
2007-05-06 16:03:28 +00:00
|
|
|
/****************************************************/
|
|
|
|
|
|
|
|
#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"
|
2010-11-10 15:30:12 +00:00
|
|
|
#include "wxEeschemaStruct.h"
|
|
|
|
#include "class_sch_screen.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "general.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
#include "class_library.h"
|
2010-10-22 12:11:52 +00:00
|
|
|
#include "lib_pin.h"
|
2009-07-26 17:16:42 +00:00
|
|
|
#include "protos.h"
|
2010-11-11 21:10:27 +00:00
|
|
|
#include "sch_marker.h"
|
|
|
|
#include "sch_items.h"
|
|
|
|
#include "sch_text.h"
|
|
|
|
#include "sch_component.h"
|
|
|
|
#include "sch_sheet.h"
|
2010-11-10 15:30:12 +00:00
|
|
|
|
|
|
|
#include <boost/foreach.hpp>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-02-27 19:38:16 +00:00
|
|
|
|
2009-07-26 17:16:42 +00:00
|
|
|
// Imported functions:
|
2010-11-03 14:13:15 +00:00
|
|
|
void MoveItemsInList( PICKED_ITEMS_LIST& aItemsList, const wxPoint aMoveVector );
|
|
|
|
void RotateListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& Center );
|
|
|
|
void Mirror_X_ListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& aMirrorPoint );
|
|
|
|
void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& Center );
|
|
|
|
void DeleteItemsInList( WinEDA_DrawPanel* panel, PICKED_ITEMS_LIST& aItemsList );
|
2009-11-03 13:26:31 +00:00
|
|
|
void DuplicateItemsInList( SCH_SCREEN* screen,
|
|
|
|
PICKED_ITEMS_LIST& aItemsList,
|
|
|
|
const wxPoint aMoveVector );
|
|
|
|
|
|
|
|
static void CollectStructsToDrag( SCH_SCREEN* screen );
|
|
|
|
static void AddPickedItem( SCH_SCREEN* screen, wxPoint aPosition );
|
|
|
|
static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
|
|
|
|
wxPoint& aPosition,
|
|
|
|
bool aSearchFirst );
|
2010-11-03 14:13:15 +00:00
|
|
|
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
|
2009-11-03 13:26:31 +00:00
|
|
|
static void SaveStructListForPaste( PICKED_ITEMS_LIST& aItemsList );
|
2009-07-25 04:53:39 +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 ..)
|
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
int WinEDA_SchematicFrame::ReturnBlockCommand( int key )
|
|
|
|
{
|
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
|
|
|
/* Init the parameters used by the block paste command
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
void WinEDA_SchematicFrame::InitBlockPasteInfos()
|
|
|
|
{
|
2009-07-25 04:53:39 +00:00
|
|
|
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
block->m_ItemsSelection.CopyList( g_BlockSaveDataList.m_ItemsSelection );
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->ManageCurseur = DrawMovingBlockOutlines;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Routine to handle the BLOCK PLACE command
|
2007-08-20 01:20:48 +00:00
|
|
|
* Last routine for block operation for:
|
|
|
|
* - block move & drag
|
2009-11-03 13:26:31 +00:00
|
|
|
* - block copy & paste
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
|
|
|
|
{
|
2010-11-13 11:02:24 +00:00
|
|
|
bool err = false;
|
2009-07-25 04:53:39 +00:00
|
|
|
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( DrawPanel->ManageCurseur == NULL )
|
|
|
|
{
|
2010-11-13 11:02:24 +00:00
|
|
|
err = true;
|
2007-08-20 01:20:48 +00:00
|
|
|
DisplayError( this, wxT( "HandleBlockPLace() : ManageCurseur = NULL" ) );
|
|
|
|
}
|
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
if( block->GetCount() == 0 )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
2010-11-13 11:02:24 +00:00
|
|
|
err = true;
|
2010-11-03 14:13:15 +00:00
|
|
|
msg.Printf( wxT( "HandleBlockPLace() error : no items to place (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 )
|
|
|
|
{
|
2009-07-25 04:53:39 +00:00
|
|
|
case BLOCK_IDLE:
|
2010-11-13 11:02:24 +00:00
|
|
|
err = true;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
case BLOCK_ROTATE:
|
|
|
|
case BLOCK_MIRROR_X:
|
|
|
|
case BLOCK_MIRROR_Y:
|
2007-08-20 01:20:48 +00:00
|
|
|
case BLOCK_DRAG: /* Drag */
|
|
|
|
case BLOCK_MOVE: /* Move */
|
|
|
|
if( DrawPanel->ManageCurseur )
|
2010-11-13 11:02:24 +00:00
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, false );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
SaveCopyInUndoList( block->m_ItemsSelection, UR_MOVED, block->m_MoveVector );
|
2009-07-27 14:32:40 +00:00
|
|
|
MoveItemsInList( block->m_ItemsSelection, block->m_MoveVector );
|
2009-07-25 04:53:39 +00:00
|
|
|
block->ClearItemsList();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_COPY: /* Copy */
|
|
|
|
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
|
|
|
|
if( DrawPanel->ManageCurseur )
|
2010-11-13 11:02:24 +00:00
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, false );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
DuplicateItemsInList( GetScreen(), block->m_ItemsSelection, block->m_MoveVector );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
SaveCopyInUndoList( block->m_ItemsSelection,
|
|
|
|
( block->m_Command == BLOCK_PRESELECT_MOVE ) ? UR_CHANGED : UR_NEW );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
block->ClearItemsList();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
case BLOCK_PASTE:
|
2007-08-20 01:20:48 +00:00
|
|
|
if( DrawPanel->ManageCurseur )
|
2010-11-13 11:02:24 +00:00
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, false );
|
2009-07-25 04:53:39 +00:00
|
|
|
PasteListOfItems( DC );
|
|
|
|
block->ClearItemsList();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_ZOOM: // Handled by HandleBlockEnd()
|
|
|
|
case BLOCK_DELETE:
|
|
|
|
case BLOCK_SAVE:
|
2009-08-12 10:40:01 +00:00
|
|
|
case BLOCK_FLIP:
|
2007-08-20 01:20:48 +00:00
|
|
|
case BLOCK_ABORT:
|
|
|
|
case BLOCK_SELECT_ITEMS_ONLY:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
OnModify();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
// clear struct.m_Flags.
|
|
|
|
GetScreen()->ClearDrawingState();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
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 );
|
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
if( block->GetCount() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-11-03 14:13:15 +00:00
|
|
|
DisplayError( this, wxT( "HandleBlockPLace() error: some items left in buffer" ) );
|
2009-07-25 04:53:39 +00:00
|
|
|
block->ClearItemsList();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString );
|
2009-11-03 13:26:31 +00:00
|
|
|
DrawPanel->Refresh();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
/**
|
|
|
|
* Function HandleBlockEnd( )
|
|
|
|
* Handle the "end" of a block command,
|
|
|
|
* i.e. is called at the end of the definition of the area of a block.
|
|
|
|
* depending on the current block command, this command is executed
|
|
|
|
* or parameters are initialized to prepare a call to HandleBlockPlace
|
|
|
|
* in GetScreen()->m_BlockLocate
|
|
|
|
* @return false if no item selected, or command finished,
|
|
|
|
* true if some items found and HandleBlockPlace must be called later
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2010-11-13 11:02:24 +00:00
|
|
|
bool WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2010-11-13 11:02:24 +00:00
|
|
|
bool nextcmd = false;
|
|
|
|
bool zoom_command = false;
|
2009-07-25 04:53:39 +00:00
|
|
|
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
if( block->GetCount() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
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;
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_Curseur = block->GetEnd();
|
2007-08-20 01:20:48 +00:00
|
|
|
if( block->m_Command != BLOCK_ABORT )
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( DrawPanel->ManageCurseur != NULL )
|
|
|
|
switch( block->m_Command )
|
|
|
|
{
|
2009-07-25 04:53:39 +00:00
|
|
|
case BLOCK_IDLE:
|
2007-08-20 01:20:48 +00:00
|
|
|
DisplayError( this, wxT( "Error in HandleBlockPLace()" ) );
|
|
|
|
break;
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
case BLOCK_DRAG: /* Drag */
|
2008-02-28 19:27:25 +00:00
|
|
|
BreakSegmentOnJunction( (SCH_SCREEN*) GetScreen() );
|
2009-11-03 13:26:31 +00:00
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
case BLOCK_ROTATE:
|
|
|
|
case BLOCK_MIRROR_X:
|
|
|
|
case BLOCK_MIRROR_Y:
|
2007-08-20 01:20:48 +00:00
|
|
|
case BLOCK_MOVE: /* Move */
|
|
|
|
case BLOCK_COPY: /* Copy */
|
2009-07-25 07:31:07 +00:00
|
|
|
PickItemsInBlock( GetScreen()->m_BlockLocate, GetScreen() );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
|
2009-07-25 04:53:39 +00:00
|
|
|
if( block->GetCount() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-11-13 11:02:24 +00:00
|
|
|
nextcmd = true;
|
2009-07-25 04:53:39 +00:00
|
|
|
CollectStructsToDrag( GetScreen() );
|
2010-11-13 11:02:24 +00:00
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, false );
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->ManageCurseur = DrawMovingBlockOutlines;
|
2010-11-13 11:02:24 +00:00
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, false );
|
2007-08-20 01:20:48 +00:00
|
|
|
block->m_State = STATE_BLOCK_MOVE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-11-13 11:02:24 +00:00
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, false );
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_DELETE: /* Delete */
|
2009-07-25 07:31:07 +00:00
|
|
|
PickItemsInBlock( GetScreen()->m_BlockLocate, GetScreen() );
|
2010-11-13 11:02:24 +00:00
|
|
|
DrawAndSizingBlockOutlines( DrawPanel, DC, false );
|
2009-07-25 04:53:39 +00:00
|
|
|
if( block->GetCount() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-07-25 04:53:39 +00:00
|
|
|
DeleteItemsInList( DrawPanel, block->m_ItemsSelection );
|
2010-09-05 17:01:48 +00:00
|
|
|
OnModify();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2009-07-25 04:53:39 +00:00
|
|
|
block->ClearItemsList();
|
2007-08-20 01:20:48 +00:00
|
|
|
TestDanglingEnds( GetScreen()->EEDrawList, DC );
|
2009-07-25 04:53:39 +00:00
|
|
|
DrawPanel->Refresh();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
case BLOCK_SAVE: /* Save */
|
2009-07-25 07:31:07 +00:00
|
|
|
PickItemsInBlock( GetScreen()->m_BlockLocate, GetScreen() );
|
2010-11-13 11:02:24 +00:00
|
|
|
DrawAndSizingBlockOutlines( DrawPanel, DC, false );
|
2009-07-25 04:53:39 +00:00
|
|
|
if( block->GetCount() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-11-03 14:13:15 +00:00
|
|
|
wxPoint move_vector = -GetScreen()->m_BlockLocate.m_BlockLastCursorPosition;
|
2009-07-25 04:53:39 +00:00
|
|
|
SaveStructListForPaste( block->m_ItemsSelection );
|
2010-11-03 14:13:15 +00:00
|
|
|
MoveItemsInList( g_BlockSaveDataList.m_ItemsSelection, move_vector );
|
2010-11-13 11:02:24 +00:00
|
|
|
}
|
2009-07-25 04:53:39 +00:00
|
|
|
block->ClearItemsList();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_PASTE:
|
|
|
|
block->m_State = STATE_BLOCK_MOVE;
|
|
|
|
break;
|
|
|
|
|
2009-08-12 10:40:01 +00:00
|
|
|
case BLOCK_FLIP: /* pcbnew only! */
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case BLOCK_ZOOM: /* Window Zoom */
|
2010-11-13 11:02:24 +00:00
|
|
|
zoom_command = true;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_SELECT_ITEMS_ONLY: /* Not used */
|
|
|
|
case BLOCK_ABORT: /* not executed here */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( block->m_Command == BLOCK_ABORT )
|
2009-07-25 04:53:39 +00:00
|
|
|
{
|
2010-11-03 14:13:15 +00:00
|
|
|
GetScreen()->ClearDrawingState();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
if( ! nextcmd )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
block->m_Flags = 0;
|
|
|
|
block->m_State = STATE_NO_BLOCK;
|
|
|
|
block->m_Command = BLOCK_IDLE;
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
|
|
|
GetScreen()->SetCurItem( NULL );
|
2010-11-03 14:13:15 +00:00
|
|
|
SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( zoom_command )
|
2009-07-25 04:53:39 +00:00
|
|
|
Window_Zoom( GetScreen()->m_BlockLocate );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
return nextcmd ;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Manage end block command from context menu.
|
2010-09-06 09:10:12 +00:00
|
|
|
* Can be called only :
|
|
|
|
* after HandleBlockEnd
|
|
|
|
* and if the current command is block move.
|
|
|
|
* Execute a command other than block move from the current block move selected items list.
|
|
|
|
* Due to (minor) problems in undo/redo or/and display block,
|
|
|
|
* a mirror/rotate command is immediatly executed and multible block commands
|
|
|
|
* are not allowed (multiple commands are tricky to undo/redo in one time)
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
|
|
|
|
{
|
2010-09-06 09:10:12 +00:00
|
|
|
bool blockCmdFinished = true; /* set to false for block command which
|
|
|
|
* have a next step
|
|
|
|
* and true if the block command is finished here
|
|
|
|
*/
|
2009-07-25 04:53:39 +00:00
|
|
|
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-09-06 09:10:12 +00:00
|
|
|
// can convert only a block move command to an other command
|
2007-08-20 01:20:48 +00:00
|
|
|
if( block->m_Command != BLOCK_MOVE )
|
|
|
|
return;
|
2010-09-06 09:10:12 +00:00
|
|
|
// Useless if the new command is block move because we are already in block move.
|
2007-08-20 01:20:48 +00:00
|
|
|
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;
|
2010-09-06 09:10:12 +00:00
|
|
|
blockCmdFinished = false;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_DRAG: /* move to Drag */
|
|
|
|
if( DrawPanel->ManageCurseur )
|
2010-11-13 11:02:24 +00:00
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, false );
|
2010-09-06 09:10:12 +00:00
|
|
|
// Clear list of items to move, and rebuild it with items to drag:
|
2009-07-25 04:53:39 +00:00
|
|
|
block->ClearItemsList();
|
|
|
|
|
|
|
|
BreakSegmentOnJunction( GetScreen() );
|
|
|
|
|
2009-07-25 07:31:07 +00:00
|
|
|
PickItemsInBlock( GetScreen()->m_BlockLocate, GetScreen() );
|
2009-07-25 04:53:39 +00:00
|
|
|
if( block->GetCount() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-09-06 09:10:12 +00:00
|
|
|
blockCmdFinished = false;
|
2008-02-28 19:27:25 +00:00
|
|
|
CollectStructsToDrag( (SCH_SCREEN*) GetScreen() );
|
2007-08-20 01:20:48 +00:00
|
|
|
if( DrawPanel->ManageCurseur )
|
2010-11-13 11:02:24 +00:00
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, false );
|
2007-08-20 01:20:48 +00:00
|
|
|
block->m_State = STATE_BLOCK_MOVE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_DELETE: /* move to Delete */
|
|
|
|
if( DrawPanel->ManageCurseur )
|
2010-11-13 11:02:24 +00:00
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, false );
|
2009-07-25 04:53:39 +00:00
|
|
|
if( block->GetCount() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-07-25 04:53:39 +00:00
|
|
|
DeleteItemsInList( DrawPanel, block->m_ItemsSelection );
|
2010-09-05 17:01:48 +00:00
|
|
|
OnModify();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
TestDanglingEnds( GetScreen()->EEDrawList, DC );
|
2009-07-25 04:53:39 +00:00
|
|
|
DrawPanel->Refresh();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2010-09-06 09:10:12 +00:00
|
|
|
case BLOCK_SAVE: /* Save list in paste buffer*/
|
2007-08-20 01:20:48 +00:00
|
|
|
if( DrawPanel->ManageCurseur )
|
2010-11-13 11:02:24 +00:00
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, false );
|
2009-07-25 04:53:39 +00:00
|
|
|
if( block->GetCount() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-11-03 14:13:15 +00:00
|
|
|
wxPoint move_vector = -GetScreen()->m_BlockLocate.m_BlockLastCursorPosition;
|
2009-07-25 04:53:39 +00:00
|
|
|
SaveStructListForPaste( block->m_ItemsSelection );
|
2009-07-27 14:32:40 +00:00
|
|
|
MoveItemsInList( g_BlockSaveDataList.m_ItemsSelection, move_vector );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_ZOOM: /* Window Zoom */
|
|
|
|
DrawPanel->ForceCloseManageCurseur( DrawPanel, DC );
|
2010-11-03 14:13:15 +00:00
|
|
|
DrawPanel->SetCursor( DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor );
|
2009-07-25 04:53:39 +00:00
|
|
|
Window_Zoom( GetScreen()->m_BlockLocate );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case BLOCK_ROTATE:
|
2010-09-05 17:01:48 +00:00
|
|
|
if( DrawPanel->ManageCurseur )
|
2010-11-13 11:02:24 +00:00
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, false );
|
2010-09-05 17:01:48 +00:00
|
|
|
if( block->GetCount() )
|
|
|
|
{
|
2010-09-06 09:10:12 +00:00
|
|
|
// blockCmdFinished = true;
|
2010-09-05 17:01:48 +00:00
|
|
|
/* Compute the rotation center and put it on grid */
|
|
|
|
wxPoint rotationPoint = block->Centre();
|
|
|
|
PutOnGrid( &rotationPoint );
|
2010-11-03 14:13:15 +00:00
|
|
|
SaveCopyInUndoList( block->m_ItemsSelection, UR_ROTATED, rotationPoint );
|
2010-09-05 17:01:48 +00:00
|
|
|
RotateListOfItems( block->m_ItemsSelection, rotationPoint );
|
|
|
|
OnModify();
|
|
|
|
}
|
|
|
|
TestDanglingEnds( GetScreen()->EEDrawList, DC );
|
|
|
|
DrawPanel->Refresh();
|
2010-09-06 09:10:12 +00:00
|
|
|
// block->m_State = STATE_BLOCK_MOVE;
|
|
|
|
// block->m_Command = BLOCK_MOVE; //allows multiple rotate
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_MIRROR_X:
|
2010-09-05 17:01:48 +00:00
|
|
|
if( DrawPanel->ManageCurseur )
|
2010-11-13 11:02:24 +00:00
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, false );
|
2010-09-05 17:01:48 +00:00
|
|
|
if( block->GetCount() )
|
|
|
|
{
|
2010-09-06 09:10:12 +00:00
|
|
|
// blockCmdFinished = true;
|
2010-09-05 17:01:48 +00:00
|
|
|
/* Compute the mirror center and put it on grid */
|
|
|
|
wxPoint mirrorPoint = block->Centre();
|
|
|
|
PutOnGrid( &mirrorPoint );
|
2010-11-03 14:13:15 +00:00
|
|
|
SaveCopyInUndoList( block->m_ItemsSelection, UR_MIRRORED_X, mirrorPoint );
|
2010-09-05 17:01:48 +00:00
|
|
|
Mirror_X_ListOfItems( block->m_ItemsSelection, mirrorPoint );
|
|
|
|
OnModify();
|
2010-09-06 09:10:12 +00:00
|
|
|
// block->m_State = STATE_BLOCK_MOVE;
|
|
|
|
// block->m_Command = BLOCK_MOVE; //allows multiple mirrors
|
2010-09-05 17:01:48 +00:00
|
|
|
}
|
|
|
|
TestDanglingEnds( GetScreen()->EEDrawList, DC );
|
|
|
|
DrawPanel->Refresh();
|
|
|
|
break;
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case BLOCK_MIRROR_Y:
|
|
|
|
if( DrawPanel->ManageCurseur )
|
2010-11-13 11:02:24 +00:00
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, false );
|
2009-07-25 04:53:39 +00:00
|
|
|
if( block->GetCount() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-09-06 09:10:12 +00:00
|
|
|
// blockCmdFinished = true;
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Compute the mirror center and put it on grid */
|
2009-07-26 17:16:42 +00:00
|
|
|
wxPoint mirrorPoint = block->Centre();
|
|
|
|
PutOnGrid( &mirrorPoint );
|
2010-11-03 14:13:15 +00:00
|
|
|
SaveCopyInUndoList( block->m_ItemsSelection, UR_MIRRORED_Y, mirrorPoint );
|
2009-07-26 17:16:42 +00:00
|
|
|
MirrorListOfItems( block->m_ItemsSelection, mirrorPoint );
|
2010-09-05 17:01:48 +00:00
|
|
|
OnModify();
|
2010-09-06 09:10:12 +00:00
|
|
|
// block->m_State = STATE_BLOCK_MOVE;
|
|
|
|
// block->m_Command = BLOCK_MOVE; //allows multiple mirrors
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
TestDanglingEnds( GetScreen()->EEDrawList, DC );
|
2009-07-25 04:53:39 +00:00
|
|
|
DrawPanel->Refresh();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-09-06 09:10:12 +00:00
|
|
|
if( blockCmdFinished )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-07-25 04:53:39 +00:00
|
|
|
block->ClearItemsList();
|
2007-08-20 01:20:48 +00:00
|
|
|
block->m_Flags = 0;
|
|
|
|
block->m_State = STATE_NO_BLOCK;
|
|
|
|
block->m_Command = BLOCK_IDLE;
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
|
|
|
GetScreen()->SetCurItem( NULL );
|
2010-11-03 14:13:15 +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
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Traces the outline of the search block structures
|
|
|
|
* The entire block follows the cursor
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2010-11-03 14:13:15 +00:00
|
|
|
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
|
2009-12-02 21:44:03 +00:00
|
|
|
{
|
2009-07-25 04:53:39 +00:00
|
|
|
BLOCK_SELECTOR* block = &panel->GetScreen()->m_BlockLocate;;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
BASE_SCREEN* screen = panel->GetScreen();
|
|
|
|
SCH_ITEM* schitem;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Erase old block contents. */
|
2009-07-25 04:53:39 +00:00
|
|
|
if( erase )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-07-25 04:53:39 +00:00
|
|
|
block->Draw( panel, DC, block->m_MoveVector, g_XorMode, block->m_Color );
|
|
|
|
for( unsigned ii = 0; ii < block->GetCount(); ii++ )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-07-31 05:33:11 +00:00
|
|
|
schitem = (SCH_ITEM*) block->m_ItemsSelection.GetPickedItem( ii );
|
2009-07-26 17:16:42 +00:00
|
|
|
DrawStructsInGhost( panel, DC, schitem, block->m_MoveVector );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Repaint new view. */
|
2009-07-25 04:53:39 +00:00
|
|
|
block->m_MoveVector = screen->m_Curseur - block->m_BlockLastCursorPosition;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
block->Draw( panel, DC, block->m_MoveVector, g_XorMode, block->m_Color );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
for( unsigned ii = 0; ii < block->GetCount(); ii++ )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-07-31 05:33:11 +00:00
|
|
|
schitem = (SCH_ITEM*) block->m_ItemsSelection.GetPickedItem( ii );
|
2009-07-26 17:16:42 +00:00
|
|
|
DrawStructsInGhost( panel, DC, schitem, block->m_MoveVector );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
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
|
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
void SaveStructListForPaste( PICKED_ITEMS_LIST& aItemsList )
|
|
|
|
{
|
2010-11-03 14:13:15 +00:00
|
|
|
g_BlockSaveDataList.ClearListAndDeleteItems(); // delete previous saved list, if exists
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
/* save the new list: */
|
|
|
|
ITEM_PICKER item;
|
2010-09-05 17:01:48 +00:00
|
|
|
|
2010-02-04 17:46:12 +00:00
|
|
|
// In list the wrapper is owner of the shematic item, we can use the UR_DELETED
|
|
|
|
// status for the picker because pickers with this status are owner of the picked item
|
|
|
|
// (or TODO ?: create a new status like UR_DUPLICATE)
|
|
|
|
item.m_UndoRedoStatus = UR_DELETED;
|
2009-07-25 04:53:39 +00:00
|
|
|
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-07-25 04:53:39 +00:00
|
|
|
/* Make a copy of the original picked item. */
|
2010-11-03 14:13:15 +00:00
|
|
|
SCH_ITEM* DrawStructCopy = DuplicateStruct( (SCH_ITEM*) aItemsList.GetPickedItem( ii ) );
|
2009-07-25 04:53:39 +00:00
|
|
|
DrawStructCopy->SetParent( NULL );
|
2009-07-31 05:33:11 +00:00
|
|
|
item.m_PickedItem = DrawStructCopy;
|
2009-07-25 04:53:39 +00:00
|
|
|
g_BlockSaveDataList.PushItem( item );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2009-07-25 04:53:39 +00:00
|
|
|
* Routine to paste a structure from the g_BlockSaveDataList stack.
|
2009-12-02 21:44:03 +00:00
|
|
|
* This routine is the same as undelete but original list is NOT removed.
|
2007-05-06 16:03:28 +00:00
|
|
|
*****************************************************************************/
|
2009-07-25 04:53:39 +00:00
|
|
|
void WinEDA_SchematicFrame::PasteListOfItems( wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-07-25 04:53:39 +00:00
|
|
|
SCH_ITEM* Struct;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
if( g_BlockSaveDataList.GetCount() == 0 )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
DisplayError( this, wxT( "No struct to paste" ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
PICKED_ITEMS_LIST picklist;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
// Creates data, and push it as new data in undo item list buffer
|
2009-11-03 13:26:31 +00:00
|
|
|
ITEM_PICKER picker( NULL, UR_NEW );
|
2009-07-25 04:53:39 +00:00
|
|
|
for( unsigned ii = 0; ii < g_BlockSaveDataList.GetCount(); ii++ )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
Struct = DuplicateStruct(
|
2010-11-03 14:13:15 +00:00
|
|
|
(SCH_ITEM*) g_BlockSaveDataList.m_ItemsSelection.GetPickedItem( ii ) );
|
2009-07-31 05:33:11 +00:00
|
|
|
picker.m_PickedItem = Struct;
|
2009-07-25 04:53:39 +00:00
|
|
|
picklist.PushItem( picker );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
// Clear annotation and init new time stamp for the new components:
|
|
|
|
if( Struct->Type() == TYPE_SCH_COMPONENT )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-07-25 04:53:39 +00:00
|
|
|
( (SCH_COMPONENT*) Struct )->m_TimeStamp = GetTimeStamp();
|
|
|
|
( (SCH_COMPONENT*) Struct )->ClearAnnotation( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2009-07-25 04:53:39 +00:00
|
|
|
SetaParent( Struct, GetScreen() );
|
|
|
|
RedrawOneStruct( DrawPanel, DC, Struct, GR_DEFAULT_DRAWMODE );
|
|
|
|
Struct->SetNext( GetScreen()->EEDrawList );
|
|
|
|
GetScreen()->EEDrawList = Struct;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2009-07-26 17:16:42 +00:00
|
|
|
SaveCopyInUndoList( picklist, UR_NEW );
|
2009-07-25 04:53:39 +00:00
|
|
|
|
2009-07-27 14:32:40 +00:00
|
|
|
MoveItemsInList( picklist, GetScreen()->m_BlockLocate.m_MoveVector );
|
2009-07-25 04:53:39 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
/* clear .m_Flags member for all items */
|
2010-11-03 14:13:15 +00:00
|
|
|
GetScreen()->ClearDrawingState();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
OnModify();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
return;
|
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.
|
2009-11-03 13:26:31 +00:00
|
|
|
* items are those selected in window block an some items outside this area but
|
|
|
|
* connected to a selected item (connected wires to a component or an entry )
|
2009-02-12 08:12:41 +00:00
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
static void CollectStructsToDrag( SCH_SCREEN* screen )
|
|
|
|
{
|
2010-09-05 17:01:48 +00:00
|
|
|
SCH_ITEM* Struct;
|
|
|
|
SCH_LINE* SegmStruct;
|
2009-08-28 07:11:56 +00:00
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
PICKED_ITEMS_LIST* pickedlist = &screen->m_BlockLocate.m_ItemsSelection;
|
2009-07-25 04:53:39 +00:00
|
|
|
|
|
|
|
if( pickedlist->GetCount() == 0 )
|
|
|
|
return;
|
|
|
|
|
2010-11-03 14:13:15 +00:00
|
|
|
screen->ClearDrawingState();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-07-17 11:14:57 +00:00
|
|
|
for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-07-17 11:14:57 +00:00
|
|
|
Struct = (SCH_ITEM*) pickedlist->GetPickedItem( ii );
|
|
|
|
Struct->m_Flags = SELECTED;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
if( screen->m_BlockLocate.m_Command != BLOCK_DRAG )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Remove the displacement of segment and undo the selection. */
|
2009-07-25 04:53:39 +00:00
|
|
|
for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-09-05 17:01:48 +00:00
|
|
|
Struct = (SCH_ITEM*)(SCH_ITEM*) pickedlist->GetPickedItem( ii );
|
2007-09-01 12:00:30 +00:00
|
|
|
if( Struct->Type() == DRAW_SEGMENT_STRUCT_TYPE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
SegmStruct = (SCH_LINE*) Struct;
|
2009-11-03 13:26:31 +00:00
|
|
|
if( !screen->m_BlockLocate.Inside( SegmStruct->m_Start ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
SegmStruct->m_Flags |= STARTPOINT;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
if( !screen->m_BlockLocate.Inside( SegmStruct->m_End ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
SegmStruct->m_Flags |= ENDPOINT;
|
2009-08-27 13:51:02 +00:00
|
|
|
|
|
|
|
// Save m_Flags for Undo/redo drag operations:
|
2009-11-03 13:26:31 +00:00
|
|
|
pickedlist->SetPickerFlags( SegmStruct->m_Flags, ii );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Search for other items to drag. They are end wires connected to selected
|
|
|
|
* items
|
2009-02-12 08:12:41 +00:00
|
|
|
*/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-09-05 17:01:48 +00:00
|
|
|
Struct = (SCH_ITEM*)(SCH_ITEM*) pickedlist->GetPickedItem( ii );
|
|
|
|
if( ( Struct->Type() == TYPE_SCH_LABEL )
|
|
|
|
|| ( Struct->Type() == TYPE_SCH_GLOBALLABEL )
|
|
|
|
|| ( Struct->Type() == TYPE_SCH_HIERLABEL ) )
|
|
|
|
{
|
2010-07-17 11:14:57 +00:00
|
|
|
#undef STRUCT
|
|
|
|
#define STRUCT ( (SCH_TEXT*) Struct )
|
2010-09-05 17:01:48 +00:00
|
|
|
if( !screen->m_BlockLocate.Inside( STRUCT->m_Pos ) )
|
|
|
|
{
|
|
|
|
AddPickedItem( screen, STRUCT->m_Pos );
|
|
|
|
}
|
2010-07-17 11:14:57 +00:00
|
|
|
}
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
if( Struct->Type() == TYPE_SCH_COMPONENT )
|
2009-07-25 04:53:39 +00:00
|
|
|
{
|
|
|
|
// Add all pins of the selected component to list
|
2009-10-08 16:45:59 +00:00
|
|
|
LIB_PIN* pin;
|
2009-11-03 13:26:31 +00:00
|
|
|
wxPoint pos;
|
2009-10-08 16:45:59 +00:00
|
|
|
pin = GetNextPinPosition( (SCH_COMPONENT*) Struct, pos, true );
|
|
|
|
while( pin )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
if( !screen->m_BlockLocate.Inside( pos ) )
|
2009-07-25 04:53:39 +00:00
|
|
|
{
|
|
|
|
// This pin is outside area,
|
2009-02-12 08:12:41 +00:00
|
|
|
// 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
|
|
|
|
2009-10-08 16:45:59 +00:00
|
|
|
pin = GetNextPinPosition( (SCH_COMPONENT*) Struct, pos, false );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
if( Struct->Type() == DRAW_SHEET_STRUCT_TYPE )
|
2009-07-25 04:53:39 +00:00
|
|
|
{
|
2010-06-24 18:31:43 +00:00
|
|
|
SCH_SHEET* sheet = (SCH_SHEET*) Struct;
|
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
// Add all pins sheets of a selected hierarchical sheet to the list
|
2010-11-03 14:13:15 +00:00
|
|
|
BOOST_FOREACH( SCH_SHEET_PIN label, sheet->GetSheetPins() )
|
|
|
|
{
|
2010-06-24 18:31:43 +00:00
|
|
|
AddPickedItem( screen, label.m_Pos );
|
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
|
|
|
{
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_BUS_ENTRY* item = (SCH_BUS_ENTRY*) 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
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
/** AddPickedItem
|
2009-11-03 13:26:31 +00:00
|
|
|
* add to the picked list in screen->m_BlockLocate items found at location
|
|
|
|
* position
|
2009-07-25 04:53:39 +00:00
|
|
|
* @param screen = the screen to consider
|
|
|
|
* @param position = the wxPoint where items must be located to be select
|
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
|
|
|
|
{
|
2010-09-05 17:01:48 +00:00
|
|
|
SCH_ITEM* Struct;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Review the list of already selected elements. */
|
2009-07-25 04:53:39 +00:00
|
|
|
PICKED_ITEMS_LIST* pickedlist = &screen->m_BlockLocate.m_ItemsSelection;
|
|
|
|
|
|
|
|
for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-07-31 05:33:11 +00:00
|
|
|
Struct = (SCH_ITEM*) pickedlist->GetPickedItem( ii );
|
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
|
2009-12-02 21:44:03 +00:00
|
|
|
#define STRUCT ( (SCH_LINE*) 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;
|
2009-08-27 13:51:02 +00:00
|
|
|
|
|
|
|
// Save m_Flags for Undo/redo drag operations:
|
2009-11-03 13:26:31 +00:00
|
|
|
pickedlist->SetPickerFlags( STRUCT->m_Flags, ii );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Review the list of elements not selected. */
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
ITEM_PICKER picker;
|
2007-08-20 01:20:48 +00:00
|
|
|
Struct = screen->EEDrawList;
|
|
|
|
while( Struct )
|
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
picker.m_PickedItem = Struct;
|
2009-07-31 05:33:11 +00:00
|
|
|
picker.m_PickedItemType = Struct->Type();
|
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 )
|
2009-11-03 13:26:31 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_JUNCTION_STRUCT_TYPE:
|
|
|
|
#undef STRUCT
|
2009-12-02 21:44:03 +00:00
|
|
|
#define STRUCT ( (SCH_JUNCTION*) Struct )
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Struct->m_Flags & SELECTED )
|
2009-11-03 13:26:31 +00:00
|
|
|
break;
|
2007-09-04 14:28:20 +00:00
|
|
|
if( STRUCT->m_Pos != position )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2009-07-25 04:53:39 +00:00
|
|
|
pickedlist->PushItem( picker );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_SEGMENT_STRUCT_TYPE:
|
|
|
|
#undef STRUCT
|
2009-12-02 21:44:03 +00:00
|
|
|
#define STRUCT ( (SCH_LINE*) Struct )
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Struct->m_Flags & SELECTED )
|
2009-11-03 13:26:31 +00:00
|
|
|
break;
|
2007-09-04 14:28:20 +00:00
|
|
|
if( STRUCT->m_Start == position )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT;
|
|
|
|
Struct->m_Flags &= ~STARTPOINT;
|
2009-11-03 13:26:31 +00:00
|
|
|
|
2009-08-27 13:51:02 +00:00
|
|
|
// Save m_Flags for Undo/redo drag operations:
|
2009-11-03 13:26:31 +00:00
|
|
|
picker.m_PickerFlags = Struct->m_Flags;
|
2009-07-25 04:53:39 +00:00
|
|
|
pickedlist->PushItem( picker );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-09-04 14:28:20 +00:00
|
|
|
else if( STRUCT->m_End == position )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT;
|
|
|
|
Struct->m_Flags &= ~ENDPOINT;
|
2009-11-03 13:26:31 +00:00
|
|
|
|
2009-08-27 13:51:02 +00:00
|
|
|
// Save m_Flags for Undo/redo drag operations:
|
2009-11-03 13:26:31 +00:00
|
|
|
picker.m_PickerFlags = Struct->m_Flags;
|
2009-07-25 04:53:39 +00:00
|
|
|
pickedlist->PushItem( picker );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
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 )
|
2009-11-03 13:26:31 +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;
|
|
|
|
Struct->m_Flags |= SELECTED;
|
2009-07-25 04:53:39 +00:00
|
|
|
pickedlist->PushItem( picker );
|
2007-08-20 01:20:48 +00:00
|
|
|
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 )
|
2009-11-03 13:26:31 +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;
|
|
|
|
Struct->m_Flags |= SELECTED;
|
2009-07-25 04:53:39 +00:00
|
|
|
pickedlist->PushItem( picker );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
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
|
|
|
break;
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
case TYPE_SCH_MARKER:
|
2007-08-20 01:20:48 +00:00
|
|
|
#undef STRUCT
|
2009-12-02 21:44:03 +00:00
|
|
|
#define STRUCT ( (SCH_MARKER*) Struct )
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Struct->m_Flags & SELECTED )
|
2009-11-03 13:26:31 +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;
|
|
|
|
Struct->m_Flags |= SELECTED;
|
2009-07-25 04:53:39 +00:00
|
|
|
pickedlist->PushItem( picker );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_NOCONNECT_STRUCT_TYPE:
|
|
|
|
#undef STRUCT
|
2009-12-02 21:44:03 +00:00
|
|
|
#define STRUCT ( (SCH_NO_CONNECT*) Struct )
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Struct->m_Flags & SELECTED )
|
2009-11-03 13:26:31 +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;
|
|
|
|
Struct->m_Flags |= SELECTED;
|
2009-07-25 04:53:39 +00:00
|
|
|
pickedlist->PushItem( picker );
|
2007-08-20 01:20:48 +00:00
|
|
|
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
|
|
|
|
2009-02-12 08:12:41 +00:00
|
|
|
/** GetNextPinPosition()
|
|
|
|
* calculate position of the "next" pin of the aDrawLibItem component
|
2009-10-08 16:45:59 +00:00
|
|
|
* @param aDrawLibItem = component to test.
|
2009-11-03 13:26:31 +00:00
|
|
|
* @param aPosition = the calculated pin position, according to the component
|
|
|
|
* orientation and position
|
2009-10-08 16:45:59 +00:00
|
|
|
* @param aSearchFirst = if true, search for the first pin
|
2009-02-12 08:12:41 +00:00
|
|
|
* @return a pointer to the pin
|
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
|
|
|
|
wxPoint& aPosition,
|
|
|
|
bool aSearchFirst )
|
|
|
|
{
|
2009-10-01 18:48:25 +00:00
|
|
|
static LIB_COMPONENT* Entry;
|
2010-10-20 20:24:26 +00:00
|
|
|
static int Multi, convert;
|
|
|
|
TRANSFORM transform;
|
2009-02-12 08:12:41 +00:00
|
|
|
static wxPoint CmpPosition;
|
2009-10-08 16:45:59 +00:00
|
|
|
static LIB_PIN* Pin;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-10-08 16:45:59 +00:00
|
|
|
if( aSearchFirst )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-09-18 14:56:05 +00:00
|
|
|
Entry = CMP_LIBRARY::FindLibraryComponent( aDrawLibItem->m_ChipName );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
|
|
|
if( Entry == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
return NULL;
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2010-09-05 17:01:48 +00:00
|
|
|
Pin = Entry->GetNextPin();
|
|
|
|
Multi = aDrawLibItem->m_Multi;
|
2009-02-12 08:12:41 +00:00
|
|
|
convert = aDrawLibItem->m_Convert;
|
|
|
|
CmpPosition = aDrawLibItem->m_Pos;
|
2010-10-20 20:24:26 +00:00
|
|
|
transform = aDrawLibItem->m_Transform;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
else
|
2009-10-08 16:45:59 +00:00
|
|
|
Pin = Entry->GetNextPin( Pin );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-10-08 16:45:59 +00:00
|
|
|
for( ; Pin != NULL; Pin = Entry->GetNextPin( Pin ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-09-29 18:38:21 +00:00
|
|
|
wxASSERT( Pin->Type() == COMPONENT_PIN_DRAW_TYPE );
|
|
|
|
|
2009-10-01 18:48:25 +00:00
|
|
|
/* Skip items not used for this part */
|
2010-10-25 15:43:42 +00:00
|
|
|
if( Multi && Pin->GetUnit() && ( Pin->GetUnit() != Multi ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
continue;
|
2010-10-25 15:43:42 +00:00
|
|
|
if( convert && Pin->GetConvert() && ( Pin->GetConvert() != convert ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
continue;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Calculate the pin position (according to the component orientation)
|
2009-12-02 21:44:03 +00:00
|
|
|
*/
|
2010-10-20 20:24:26 +00:00
|
|
|
aPosition = DefaultTransform.TransformCoordinate( Pin->m_Pos ) + CmpPosition;
|
2009-09-29 18:38:21 +00:00
|
|
|
return Pin;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2009-11-03 13:26:31 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
return NULL;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|