2007-06-05 12:10:51 +00:00
|
|
|
/****************************************************/
|
2009-11-12 15:43:38 +00:00
|
|
|
/* block_module_editor.cpp */
|
|
|
|
/* Handle block commands for the footprint editor */
|
2007-06-05 12:10:51 +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-06-05 12:10:51 +00:00
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
|
|
|
#include "block_commande.h"
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "pcbnew.h"
|
2009-07-30 11:04:07 +00:00
|
|
|
#include "wxPcbStruct.h"
|
2010-08-10 18:34:26 +00:00
|
|
|
#include "module_editor_frame.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "pcbplot.h"
|
|
|
|
#include "trigo.h"
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
|
|
|
|
#define BLOCK_COLOR BROWN
|
|
|
|
#define IS_SELECTED 1
|
|
|
|
|
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
|
|
|
bool aErase );
|
2011-03-29 19:33:07 +00:00
|
|
|
static int MarkItemsInBloc( MODULE* module, EDA_RECT& Rect );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
static void ClearMarkItems( MODULE* module );
|
|
|
|
static void CopyMarkedItems( MODULE* module, wxPoint offset );
|
|
|
|
static void MoveMarkedItems( MODULE* module, wxPoint offset );
|
|
|
|
static void MirrorMarkedItems( MODULE* module, wxPoint offset );
|
|
|
|
static void RotateMarkedItems( MODULE* module, wxPoint offset );
|
|
|
|
static void DeleteMarkedItems( MODULE* module );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to
|
2009-11-12 15:43:38 +00:00
|
|
|
* the key (ALT, SHIFT ALT ..) pressed when dragging mouse and left or
|
|
|
|
* middle button pressed
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-11-12 15:43:38 +00:00
|
|
|
int WinEDA_ModuleEditFrame::ReturnBlockCommand( int key )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int cmd;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
switch( key )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
cmd = key & 0x255;
|
|
|
|
break;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case - 1:
|
|
|
|
cmd = BLOCK_PRESELECT_MOVE;
|
|
|
|
break;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case 0:
|
|
|
|
cmd = BLOCK_MOVE;
|
|
|
|
break;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case GR_KB_ALT:
|
|
|
|
cmd = BLOCK_MIRROR_Y;
|
|
|
|
break;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case GR_KB_SHIFTCTRL:
|
|
|
|
cmd = BLOCK_DELETE;
|
|
|
|
break;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case GR_KB_SHIFT:
|
|
|
|
cmd = BLOCK_COPY;
|
|
|
|
break;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case GR_KB_CTRL:
|
|
|
|
cmd = BLOCK_ROTATE;
|
|
|
|
break;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case MOUSE_MIDDLE:
|
|
|
|
cmd = BLOCK_ZOOM;
|
|
|
|
break;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
return cmd;
|
2007-06-05 12:10:51 +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_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-11-13 11:02:24 +00:00
|
|
|
int itemsCount = 0;
|
|
|
|
bool nextcmd = false;
|
|
|
|
MODULE* currentModule = GetBoard()->m_Modules;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
if( GetScreen()->m_BlockLocate.GetCount() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-07-25 04:53:39 +00:00
|
|
|
BlockState state = GetScreen()->m_BlockLocate.m_State;
|
|
|
|
CmdBlockType command = GetScreen()->m_BlockLocate.m_Command;
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->m_endMouseCaptureCallback( DrawPanel, DC );
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.m_State = state;
|
|
|
|
GetScreen()->m_BlockLocate.m_Command = command;
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->SetMouseCapture( DrawAndSizingBlockOutlines, AbortBlockCurrentCommand );
|
|
|
|
GetScreen()->SetCrossHairPosition( wxPoint( GetScreen()->m_BlockLocate.GetRight(),
|
|
|
|
GetScreen()->m_BlockLocate.GetBottom() ) );
|
|
|
|
DrawPanel->MoveCursorToCrossHair();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
switch( GetScreen()->m_BlockLocate.m_Command )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
case BLOCK_IDLE:
|
|
|
|
DisplayError( this, wxT( "Error in HandleBlockPLace" ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_DRAG: /* Drag */
|
|
|
|
case BLOCK_MOVE: /* Move */
|
|
|
|
case BLOCK_COPY: /* Copy */
|
2010-11-13 11:02:24 +00:00
|
|
|
itemsCount = MarkItemsInBloc( currentModule,
|
2009-11-12 15:43:38 +00:00
|
|
|
GetScreen()->m_BlockLocate );
|
2010-11-13 11:02:24 +00:00
|
|
|
if( itemsCount )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-11-13 11:02:24 +00:00
|
|
|
nextcmd = true;
|
2011-02-11 20:48:13 +00:00
|
|
|
|
|
|
|
if( DrawPanel->IsMouseCaptured() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE );
|
|
|
|
DrawPanel->m_mouseCaptureCallback = DrawMovingBlockOutlines;
|
|
|
|
DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE;
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->Refresh( TRUE );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
|
2010-11-13 11:02:24 +00:00
|
|
|
nextcmd = true;
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->m_mouseCaptureCallback = DrawMovingBlockOutlines;
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_DELETE: /* Delete */
|
2010-11-13 11:02:24 +00:00
|
|
|
itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
|
|
|
|
if( itemsCount )
|
|
|
|
SaveCopyInUndoList( currentModule, UR_MODEDIT );
|
|
|
|
DeleteMarkedItems( currentModule );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_SAVE: /* Save */
|
|
|
|
case BLOCK_PASTE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_ROTATE:
|
2010-11-13 11:02:24 +00:00
|
|
|
itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
|
|
|
|
if( itemsCount )
|
|
|
|
SaveCopyInUndoList( currentModule, UR_MODEDIT );
|
|
|
|
RotateMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case BLOCK_MIRROR_X:
|
|
|
|
case BLOCK_MIRROR_Y:
|
2009-08-12 10:40:01 +00:00
|
|
|
case BLOCK_FLIP: /* mirror */
|
2010-11-13 11:02:24 +00:00
|
|
|
itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
|
|
|
|
if( itemsCount )
|
|
|
|
SaveCopyInUndoList( currentModule, UR_MODEDIT );
|
|
|
|
MirrorMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_ZOOM: /* Window Zoom */
|
2009-07-25 04:53:39 +00:00
|
|
|
Window_Zoom( GetScreen()->m_BlockLocate );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_ABORT:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_SELECT_ITEMS_ONLY:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
if( !nextcmd )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-07-25 04:53:39 +00:00
|
|
|
if( GetScreen()->m_BlockLocate.m_Command != BLOCK_SELECT_ITEMS_ONLY )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-11-13 11:02:24 +00:00
|
|
|
ClearMarkItems( currentModule );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2011-02-11 20:48:13 +00:00
|
|
|
|
|
|
|
GetScreen()->ClearBlockCommand();
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->SetMouseCapture( NULL, NULL );
|
2011-03-10 08:31:07 +00:00
|
|
|
SetToolID( GetToolId(), DrawPanel->GetCurrentCursor(), wxEmptyString );
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->Refresh( true );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
return nextcmd;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
/******************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-12 15:43:38 +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-12 15:43:38 +00:00
|
|
|
* - block copy & paste
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-11-13 11:02:24 +00:00
|
|
|
MODULE* currentModule = GetBoard()->m_Modules;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
if( !DrawPanel->IsMouseCaptured() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-02-11 20:48:13 +00:00
|
|
|
DisplayError( this, wxT( "HandleBlockPLace : m_mouseCaptureCallback = NULL" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
switch( GetScreen()->m_BlockLocate.m_Command )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
case BLOCK_IDLE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_DRAG: /* Drag */
|
|
|
|
case BLOCK_MOVE: /* Move */
|
|
|
|
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.ClearItemsList();
|
2010-11-13 11:02:24 +00:00
|
|
|
SaveCopyInUndoList( currentModule, UR_MODEDIT );
|
|
|
|
MoveMarkedItems( currentModule, GetScreen()->m_BlockLocate.m_MoveVector );
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->Refresh( TRUE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_COPY: /* Copy */
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.ClearItemsList();
|
2010-11-13 11:02:24 +00:00
|
|
|
SaveCopyInUndoList( currentModule, UR_MODEDIT );
|
|
|
|
CopyMarkedItems( currentModule, GetScreen()->m_BlockLocate.m_MoveVector );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
case BLOCK_PASTE: /* Paste */
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.ClearItemsList();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_MIRROR_X:
|
|
|
|
case BLOCK_MIRROR_Y:
|
2009-08-12 10:40:01 +00:00
|
|
|
case BLOCK_FLIP: /* Mirror by popup menu, from block move */
|
2010-11-13 11:02:24 +00:00
|
|
|
SaveCopyInUndoList( currentModule, UR_MODEDIT );
|
|
|
|
MirrorMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_ROTATE:
|
2010-11-13 11:02:24 +00:00
|
|
|
SaveCopyInUndoList( currentModule, UR_MODEDIT );
|
|
|
|
RotateMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_ZOOM: // Handled by HandleBlockEnd
|
|
|
|
case BLOCK_DELETE:
|
|
|
|
case BLOCK_SAVE:
|
|
|
|
case BLOCK_ABORT:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.m_Flags = 0;
|
|
|
|
GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
|
|
|
|
GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->SetMouseCapture( NULL, NULL );
|
|
|
|
DrawPanel->Refresh( true );
|
2011-03-10 08:31:07 +00:00
|
|
|
SetToolID( GetToolId(), DrawPanel->GetCurrentCursor(), wxEmptyString );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
/* Traces the outline of the search block structures
|
|
|
|
* The entire block follows the cursor
|
|
|
|
*/
|
2011-02-03 19:27:28 +00:00
|
|
|
static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
|
|
|
bool aErase )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-12 15:43:38 +00:00
|
|
|
BLOCK_SELECTOR* PtBlock;
|
2011-02-03 19:27:28 +00:00
|
|
|
BASE_SCREEN* screen = aPanel->GetScreen();
|
2008-04-01 05:21:50 +00:00
|
|
|
BOARD_ITEM* item;
|
2007-08-20 01:20:48 +00:00
|
|
|
wxPoint move_offset;
|
2010-11-13 11:02:24 +00:00
|
|
|
MODULE* currentModule =
|
2011-03-01 19:26:17 +00:00
|
|
|
( (PCB_BASE_FRAME*) wxGetApp().GetTopWindow() )->m_ModuleEditFrame->GetBoard()->m_Modules;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
PtBlock = &screen->m_BlockLocate;
|
2011-02-03 19:27:28 +00:00
|
|
|
GRSetDrawMode( aDC, g_XorMode );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
if( aErase )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-02-03 19:27:28 +00:00
|
|
|
PtBlock->Draw( aPanel, aDC, PtBlock->m_MoveVector, g_XorMode, PtBlock->m_Color );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
if( currentModule )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
move_offset.x = -PtBlock->m_MoveVector.x;
|
|
|
|
move_offset.y = -PtBlock->m_MoveVector.y;
|
2010-11-13 11:02:24 +00:00
|
|
|
item = currentModule->m_Drawings;
|
2011-02-03 19:27:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
for( ; item != NULL; item = item->Next() )
|
|
|
|
{
|
|
|
|
if( item->m_Selected == 0 )
|
|
|
|
continue;
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_TEXTE_MODULE:
|
|
|
|
case TYPE_EDGE_MODULE:
|
2011-02-03 19:27:28 +00:00
|
|
|
item->Draw( aPanel, aDC, g_XorMode, move_offset );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
D_PAD* pad = currentModule->m_Pads;
|
2011-02-03 19:27:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
for( ; pad != NULL; pad = pad->Next() )
|
|
|
|
{
|
|
|
|
if( pad->m_Selected == 0 )
|
|
|
|
continue;
|
2011-02-03 19:27:28 +00:00
|
|
|
pad->Draw( aPanel, aDC, g_XorMode, move_offset );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
/* Repaint new view. */
|
2011-02-11 20:48:13 +00:00
|
|
|
PtBlock->m_MoveVector = screen->GetCrossHairPosition() - PtBlock->m_BlockLastCursorPosition;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
PtBlock->Draw( aPanel, aDC, PtBlock->m_MoveVector, g_XorMode, PtBlock->m_Color );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
if( currentModule )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-11-13 11:02:24 +00:00
|
|
|
item = currentModule->m_Drawings;
|
2009-08-12 10:40:01 +00:00
|
|
|
move_offset = - PtBlock->m_MoveVector;
|
2011-02-03 19:27:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
for( ; item != NULL; item = item->Next() )
|
|
|
|
{
|
|
|
|
if( item->m_Selected == 0 )
|
|
|
|
continue;
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_TEXTE_MODULE:
|
|
|
|
case TYPE_EDGE_MODULE:
|
2011-02-03 19:27:28 +00:00
|
|
|
item->Draw( aPanel, aDC, g_XorMode, move_offset );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
D_PAD* pad = currentModule->m_Pads;
|
2011-02-03 19:27:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
for( ; pad != NULL; pad = pad->Next() )
|
|
|
|
{
|
|
|
|
if( pad->m_Selected == 0 )
|
|
|
|
continue;
|
2011-02-03 19:27:28 +00:00
|
|
|
|
|
|
|
pad->Draw( aPanel, aDC, g_XorMode, move_offset );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
/* Copy marked items, at new position = old position + offset
|
|
|
|
*/
|
2009-11-12 15:43:38 +00:00
|
|
|
void CopyMarkedItems( MODULE* module, wxPoint offset )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( module == NULL )
|
|
|
|
return;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
for( D_PAD* pad = module->m_Pads; pad; pad = pad->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
if( pad->m_Selected == 0 )
|
|
|
|
continue;
|
|
|
|
pad->m_Selected = 0;
|
|
|
|
D_PAD* NewPad = new D_PAD( module );
|
|
|
|
NewPad->Copy( pad );
|
|
|
|
NewPad->m_Selected = IS_SELECTED;
|
2009-02-18 07:37:53 +00:00
|
|
|
module->m_Pads.PushFront( NewPad );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2009-02-18 07:37:53 +00:00
|
|
|
for( BOARD_ITEM* item = module->m_Drawings; item; item = item->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
if( item->m_Selected == 0 )
|
|
|
|
continue;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
item->m_Selected = 0;
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_TEXTE_MODULE:
|
2008-12-08 15:27:13 +00:00
|
|
|
TEXTE_MODULE * textm;
|
2008-12-04 04:28:11 +00:00
|
|
|
textm = new TEXTE_MODULE( module );
|
|
|
|
textm->Copy( (TEXTE_MODULE*) item );
|
|
|
|
textm->m_Selected = IS_SELECTED;
|
|
|
|
module->m_Drawings.PushFront( textm );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_EDGE_MODULE:
|
2008-12-08 15:27:13 +00:00
|
|
|
EDGE_MODULE * edge;
|
2008-12-04 04:28:11 +00:00
|
|
|
edge = new EDGE_MODULE( module );
|
|
|
|
edge->Copy( (EDGE_MODULE*) item );
|
|
|
|
edge->m_Selected = IS_SELECTED;
|
|
|
|
module->m_Drawings.PushFront( edge );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2009-11-12 15:43:38 +00:00
|
|
|
DisplayError( NULL, wxT( "CopyMarkedItems: type undefined" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MoveMarkedItems( module, offset );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
/* Move marked items, at new position = old position + offset
|
|
|
|
*/
|
2009-11-12 15:43:38 +00:00
|
|
|
void MoveMarkedItems( MODULE* module, wxPoint offset )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM* item;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( module == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
D_PAD* pad = module->m_Pads;
|
|
|
|
for( ; pad != NULL; pad = pad->Next() )
|
|
|
|
{
|
|
|
|
if( pad->m_Selected == 0 )
|
|
|
|
continue;
|
2009-02-18 07:37:53 +00:00
|
|
|
pad->SetPosition( pad->GetPosition() + offset );
|
|
|
|
pad->m_Pos0 += offset;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
item = module->m_Drawings;
|
|
|
|
for( ; item != NULL; item = item->Next() )
|
|
|
|
{
|
|
|
|
if( item->m_Selected == 0 )
|
|
|
|
continue;
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_TEXTE_MODULE:
|
2009-02-18 07:37:53 +00:00
|
|
|
( (TEXTE_MODULE*) item )->m_Pos += offset;
|
|
|
|
( (TEXTE_MODULE*) item )->m_Pos0 += offset;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_EDGE_MODULE:
|
2009-02-18 07:37:53 +00:00
|
|
|
( (EDGE_MODULE*) item )->m_Start += offset;
|
|
|
|
( (EDGE_MODULE*) item )->m_End += offset;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2009-02-18 07:37:53 +00:00
|
|
|
( (EDGE_MODULE*) item )->m_Start0 += offset;
|
|
|
|
( (EDGE_MODULE*) item )->m_End0 += offset;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2007-08-24 15:10:46 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
item->m_Flags = item->m_Selected = 0;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
/* Delete marked items
|
|
|
|
*/
|
2009-11-12 15:43:38 +00:00
|
|
|
void DeleteMarkedItems( MODULE* module )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
BOARD_ITEM* item;
|
|
|
|
BOARD_ITEM* next_item;
|
|
|
|
D_PAD* pad;
|
|
|
|
D_PAD* next_pad;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( module == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
pad = module->m_Pads;
|
|
|
|
for( ; pad != NULL; pad = next_pad )
|
|
|
|
{
|
|
|
|
next_pad = pad->Next();
|
|
|
|
if( pad->m_Selected == 0 )
|
|
|
|
continue;
|
2007-10-03 15:21:13 +00:00
|
|
|
pad->DeleteStructure();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
item = module->m_Drawings;
|
|
|
|
for( ; item != NULL; item = next_item )
|
|
|
|
{
|
|
|
|
next_item = item->Next();
|
|
|
|
if( item->m_Selected == 0 )
|
|
|
|
continue;
|
2007-10-03 15:21:13 +00:00
|
|
|
item->DeleteStructure();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Mirror marked items, refer to a Vertical axis at position offset
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-11-12 15:43:38 +00:00
|
|
|
void MirrorMarkedItems( MODULE* module, wxPoint offset )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
#define SETMIRROR( z ) (z) -= offset.x; (z) = -(z); (z) += offset.x;
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM* item;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( module == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
D_PAD* pad = module->m_Pads;
|
|
|
|
for( ; pad != NULL; pad = pad->Next() )
|
|
|
|
{
|
|
|
|
if( pad->m_Selected == 0 )
|
|
|
|
continue;
|
2007-12-01 03:42:52 +00:00
|
|
|
SETMIRROR( pad->GetPosition().x );
|
2008-12-08 15:27:13 +00:00
|
|
|
pad->m_Pos0.x = pad->GetPosition().x;
|
2009-08-12 10:40:01 +00:00
|
|
|
NEGATE( pad->m_Offset.x );
|
|
|
|
NEGATE( pad->m_DeltaSize.x );
|
2008-12-08 15:27:13 +00:00
|
|
|
pad->m_Orient = 1800 - pad->m_Orient;
|
2011-01-05 17:28:55 +00:00
|
|
|
NORMALIZE_ANGLE_POS( pad->m_Orient );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
item = module->m_Drawings;
|
|
|
|
for( ; item != NULL; item = item->Next() )
|
|
|
|
{
|
|
|
|
if( item->m_Selected == 0 )
|
|
|
|
continue;
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_EDGE_MODULE:
|
2009-08-12 10:40:01 +00:00
|
|
|
{ EDGE_MODULE * edge = (EDGE_MODULE*) item;
|
|
|
|
SETMIRROR( edge->m_Start.x );
|
|
|
|
edge->m_Start0.x = edge->m_Start.x;
|
|
|
|
SETMIRROR( edge->m_End.x );
|
|
|
|
edge->m_End0.x = edge->m_End.x;
|
|
|
|
NEGATE( edge->m_Angle );
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_TEXTE_MODULE:
|
2007-12-01 03:42:52 +00:00
|
|
|
SETMIRROR( ( (TEXTE_MODULE*) item )->GetPosition().x );
|
2008-12-08 15:27:13 +00:00
|
|
|
( (TEXTE_MODULE*) item )->m_Pos0.x =
|
|
|
|
( (TEXTE_MODULE*) item )->GetPosition().x;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
default:
|
2009-08-12 10:40:01 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2009-08-12 10:40:01 +00:00
|
|
|
item->m_Flags = 0;
|
|
|
|
item->m_Selected = 0;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Rotate marked items, refer to a Vertical axis at position offset
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-11-12 15:43:38 +00:00
|
|
|
void RotateMarkedItems( MODULE* module, wxPoint offset )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
#define ROTATE( z ) RotatePoint( (&z), offset, 900 )
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM* item;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( module == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
D_PAD* pad = module->m_Pads;
|
|
|
|
for( ; pad != NULL; pad = pad->Next() )
|
|
|
|
{
|
|
|
|
if( pad->m_Selected == 0 )
|
|
|
|
continue;
|
2007-12-01 03:42:52 +00:00
|
|
|
ROTATE( pad->GetPosition() );
|
|
|
|
pad->m_Pos0 = pad->GetPosition();
|
2007-08-20 01:20:48 +00:00
|
|
|
pad->m_Orient += 900;
|
2011-01-05 17:28:55 +00:00
|
|
|
NORMALIZE_ANGLE_POS( pad->m_Orient );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
item = module->m_Drawings;
|
|
|
|
for( ; item != NULL; item = item->Next() )
|
|
|
|
{
|
|
|
|
if( item->m_Selected == 0 )
|
|
|
|
continue;
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_EDGE_MODULE:
|
2007-08-20 01:20:48 +00:00
|
|
|
ROTATE( ( (EDGE_MODULE*) item )->m_Start );
|
2008-12-08 15:27:13 +00:00
|
|
|
( (EDGE_MODULE*) item )->m_Start0 =
|
|
|
|
( (EDGE_MODULE*) item )->m_Start;
|
2007-08-20 01:20:48 +00:00
|
|
|
ROTATE( ( (EDGE_MODULE*) item )->m_End );
|
|
|
|
( (EDGE_MODULE*) item )->m_End0 = ( (EDGE_MODULE*) item )->m_End;
|
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_TEXTE_MODULE:
|
2007-12-01 03:42:52 +00:00
|
|
|
ROTATE( ( (TEXTE_MODULE*) item )->GetPosition() );
|
2008-12-08 15:27:13 +00:00
|
|
|
( (TEXTE_MODULE*) item )->m_Pos0 =
|
|
|
|
( (TEXTE_MODULE*) item )->GetPosition();
|
2007-08-20 01:20:48 +00:00
|
|
|
( (TEXTE_MODULE*) item )->m_Orient += 900;
|
|
|
|
break;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2007-08-24 15:10:46 +00:00
|
|
|
default:
|
|
|
|
;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
item->m_Flags = item->m_Selected = 0;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
void ClearMarkItems( MODULE* module )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM* item;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( module == NULL )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
item = module->m_Drawings;
|
|
|
|
for( ; item != NULL; item = item->Next() )
|
|
|
|
item->m_Flags = item->m_Selected = 0;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
item = module->m_Pads;
|
|
|
|
for( ; item != NULL; item = item->Next() )
|
|
|
|
item->m_Flags = item->m_Selected = 0;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Mark items inside rect.
|
2007-08-20 01:20:48 +00:00
|
|
|
* Items are inside rect when an end point is inside rect
|
|
|
|
*/
|
2011-03-29 19:33:07 +00:00
|
|
|
int MarkItemsInBloc( MODULE* module, EDA_RECT& Rect )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM* item;
|
|
|
|
int ItemsCount = 0;
|
|
|
|
wxPoint pos;
|
|
|
|
D_PAD* pad;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( module == NULL )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
pad = module->m_Pads;
|
|
|
|
for( ; pad != NULL; pad = pad->Next() )
|
|
|
|
{
|
|
|
|
pad->m_Selected = 0;
|
2007-12-01 03:42:52 +00:00
|
|
|
pos = pad->GetPosition();
|
2010-12-20 17:44:25 +00:00
|
|
|
if( Rect.Contains( pos ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
pad->m_Selected = IS_SELECTED;
|
|
|
|
ItemsCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
item = module->m_Drawings;
|
|
|
|
for( ; item != NULL; item = item->Next() )
|
|
|
|
{
|
|
|
|
item->m_Selected = 0;
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_EDGE_MODULE:
|
2011-02-27 19:54:01 +00:00
|
|
|
if( ((EDGE_MODULE*)item )->HitTest( Rect ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
item->m_Selected = IS_SELECTED;
|
|
|
|
ItemsCount++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_TEXTE_MODULE:
|
2007-12-01 03:42:52 +00:00
|
|
|
pos = ( (TEXTE_MODULE*) item )->GetPosition();
|
2010-12-20 17:44:25 +00:00
|
|
|
if( Rect.Contains( pos ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
item->m_Selected = IS_SELECTED;
|
|
|
|
ItemsCount++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ItemsCount;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|