2007-08-20 01:20:48 +00:00
|
|
|
|
/*****************************************************************/
|
|
|
|
|
/* Operations sur Blocks : deplacement, rotation, effacement ... */
|
|
|
|
|
/*****************************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
|
#include "gr_basic.h"
|
|
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
#include "gerbview.h"
|
|
|
|
|
#include "trigo.h"
|
|
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define BLOCK_COLOR BROWN
|
|
|
|
|
|
|
|
|
|
/* Routines Locales */
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
static TRACK* IsSegmentInBox( DrawBlockStruct& blocklocate, TRACK* PtSegm );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
/* Variables locales :*/
|
|
|
|
|
|
|
|
|
|
/*************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
int WinEDA_GerberFrame::ReturnBlockCommand( int key )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +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-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
int cmd = 0;
|
|
|
|
|
|
|
|
|
|
switch( key )
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
cmd = key & 0x255;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
|
cmd = BLOCK_MOVE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GR_KB_SHIFT:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GR_KB_CTRL:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GR_KB_SHIFTCTRL:
|
|
|
|
|
cmd = BLOCK_DELETE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GR_KB_ALT:
|
|
|
|
|
cmd = BLOCK_COPY;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case MOUSE_MIDDLE:
|
|
|
|
|
cmd = BLOCK_ZOOM;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return cmd;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void WinEDA_GerberFrame::HandleBlockPlace( wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*****************************************************/
|
|
|
|
|
/* Routine to handle the BLOCK PLACE commande */
|
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
bool err = FALSE;
|
|
|
|
|
|
|
|
|
|
if( DrawPanel->ManageCurseur == NULL )
|
|
|
|
|
{
|
|
|
|
|
err = TRUE;
|
|
|
|
|
DisplayError( this, wxT( "Error in HandleBlockPLace : ManageCurseur = NULL" ) );
|
|
|
|
|
}
|
|
|
|
|
GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP;
|
|
|
|
|
|
|
|
|
|
switch( GetScreen()->BlockLocate.m_Command )
|
|
|
|
|
{
|
|
|
|
|
case BLOCK_IDLE:
|
|
|
|
|
err = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BLOCK_DRAG: /* Drag */
|
|
|
|
|
case BLOCK_MOVE: /* Move */
|
|
|
|
|
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
|
|
|
|
|
if( DrawPanel->ManageCurseur )
|
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
|
Block_Move( DC );
|
|
|
|
|
GetScreen()->BlockLocate.m_BlockDrawStruct = NULL;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BLOCK_COPY: /* Copy */
|
|
|
|
|
if( DrawPanel->ManageCurseur )
|
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
|
Block_Duplicate( DC );
|
|
|
|
|
GetScreen()->BlockLocate.m_BlockDrawStruct = NULL;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BLOCK_PASTE:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BLOCK_ZOOM: // Handle by HandleBlockEnd()
|
|
|
|
|
case BLOCK_ROTATE:
|
|
|
|
|
case BLOCK_INVERT:
|
|
|
|
|
case BLOCK_DELETE:
|
|
|
|
|
case BLOCK_SAVE:
|
|
|
|
|
case BLOCK_ABORT:
|
|
|
|
|
case BLOCK_SELECT_ITEMS_ONLY:
|
|
|
|
|
case BLOCK_MIRROR_X:
|
|
|
|
|
case BLOCK_MIRROR_Y:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
|
|
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
|
|
|
|
GetScreen()->BlockLocate.m_Flags = 0;
|
|
|
|
|
GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK;
|
|
|
|
|
GetScreen()->BlockLocate.m_Command = BLOCK_IDLE;
|
|
|
|
|
if( GetScreen()->BlockLocate.m_BlockDrawStruct )
|
|
|
|
|
{
|
|
|
|
|
DisplayError( this, wxT( "Error in HandleBlockPLace DrawStruct != NULL" ) );
|
|
|
|
|
GetScreen()->BlockLocate.m_BlockDrawStruct = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DisplayToolMsg( wxEmptyString );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/**********************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/**********************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Routine de gestion de la commande BLOCK END
|
2007-08-20 01:20:48 +00:00
|
|
|
|
* returne :
|
|
|
|
|
* 0 si aucun compos ant selectionne
|
|
|
|
|
* 1 sinon
|
|
|
|
|
* -1 si commande termin<EFBFBD>e et composants trouv<EFBFBD>s (block delete, block save)
|
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
int endcommande = TRUE;
|
|
|
|
|
bool zoom_command = FALSE;
|
|
|
|
|
|
|
|
|
|
if( DrawPanel->ManageCurseur )
|
|
|
|
|
|
|
|
|
|
switch( GetScreen()->BlockLocate.m_Command )
|
|
|
|
|
{
|
|
|
|
|
case BLOCK_IDLE:
|
|
|
|
|
DisplayError( this, wxT( "Error in HandleBlockPLace" ) );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BLOCK_DRAG: /* Drag (not used, for future enhancements)*/
|
|
|
|
|
case BLOCK_MOVE: /* Move */
|
|
|
|
|
case BLOCK_COPY: /* Copy */
|
|
|
|
|
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
|
|
|
|
|
GetScreen()->BlockLocate.m_State = STATE_BLOCK_MOVE;
|
|
|
|
|
endcommande = FALSE;
|
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
|
DrawPanel->ManageCurseur = DrawMovingBlockOutlines;
|
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BLOCK_DELETE: /* Delete */
|
|
|
|
|
GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP;
|
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
|
Block_Delete( DC );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BLOCK_ROTATE: /* Unused */
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BLOCK_INVERT: /* Fip */
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BLOCK_SAVE: /* Save (not used)*/
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BLOCK_PASTE:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BLOCK_ZOOM: /* Window Zoom */
|
|
|
|
|
zoom_command = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BLOCK_ABORT:
|
|
|
|
|
case BLOCK_SELECT_ITEMS_ONLY:
|
|
|
|
|
case BLOCK_MIRROR_X:
|
|
|
|
|
case BLOCK_MIRROR_Y:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( endcommande == TRUE )
|
|
|
|
|
{
|
|
|
|
|
GetScreen()->BlockLocate.m_Flags = 0;
|
|
|
|
|
GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK;
|
|
|
|
|
GetScreen()->BlockLocate.m_Command = BLOCK_IDLE;
|
|
|
|
|
GetScreen()->BlockLocate.m_BlockDrawStruct = NULL;
|
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
|
|
|
|
DisplayToolMsg( wxEmptyString );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( zoom_command )
|
|
|
|
|
Window_Zoom( GetScreen()->BlockLocate );
|
|
|
|
|
|
|
|
|
|
return endcommande;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/**************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Retrace le contour du block de repositionnement des structures a d<>placer
|
|
|
|
|
*/
|
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
int Color;
|
|
|
|
|
BASE_SCREEN* screen = panel->GetScreen();
|
|
|
|
|
|
|
|
|
|
Color = YELLOW; GRSetDrawMode( DC, g_XorMode );
|
|
|
|
|
|
|
|
|
|
/* Effacement ancien cadre */
|
|
|
|
|
if( erase )
|
|
|
|
|
{
|
|
|
|
|
screen->BlockLocate.Draw( panel, DC );
|
|
|
|
|
if( screen->BlockLocate.m_MoveVector.x || screen->BlockLocate.m_MoveVector.y )
|
|
|
|
|
{
|
|
|
|
|
screen->BlockLocate.Offset( screen->BlockLocate.m_MoveVector );
|
|
|
|
|
screen->BlockLocate.Draw( panel, DC );
|
|
|
|
|
screen->BlockLocate.Offset( -screen->BlockLocate.m_MoveVector.x,
|
|
|
|
|
-screen->BlockLocate.m_MoveVector.y );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
if( panel->GetScreen()->BlockLocate.m_State != STATE_BLOCK_STOP )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
{
|
|
|
|
|
screen->BlockLocate.m_MoveVector.x = screen->m_Curseur.x - screen->BlockLocate.GetRight();
|
|
|
|
|
screen->BlockLocate.m_MoveVector.y = screen->m_Curseur.y - screen->BlockLocate.GetBottom();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
screen->BlockLocate.Draw( panel, DC );
|
|
|
|
|
if( screen->BlockLocate.m_MoveVector.x || screen->BlockLocate.m_MoveVector.y )
|
|
|
|
|
{
|
|
|
|
|
screen->BlockLocate.Offset( screen->BlockLocate.m_MoveVector );
|
|
|
|
|
screen->BlockLocate.Draw( panel, DC );
|
|
|
|
|
screen->BlockLocate.Offset( -screen->BlockLocate.m_MoveVector.x,
|
|
|
|
|
-screen->BlockLocate.m_MoveVector.y );
|
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*
|
2007-08-20 01:20:48 +00:00
|
|
|
|
* routine d'effacement du block deja selectionne
|
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
if( !IsOK( this, _( "Ok to delete block ?" ) ) )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
|
GetScreen()->BlockLocate.Normalize();
|
|
|
|
|
GetScreen()->SetCurItem( NULL );
|
|
|
|
|
|
|
|
|
|
/* Effacement des Pistes */
|
|
|
|
|
TRACK* pt_segm, * NextS;
|
|
|
|
|
for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = NextS )
|
|
|
|
|
{
|
|
|
|
|
NextS = pt_segm->Next();
|
|
|
|
|
if( IsSegmentInBox( GetScreen()->BlockLocate, pt_segm ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
2007-10-03 15:21:13 +00:00
|
|
|
|
/* la piste est ici bonne a etre efface */
|
2007-08-20 01:20:48 +00:00
|
|
|
|
pt_segm->Draw( DrawPanel, DC, GR_XOR );
|
2007-10-03 15:21:13 +00:00
|
|
|
|
pt_segm->DeleteStructure();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Effacement des Zones */
|
|
|
|
|
for( pt_segm = m_Pcb->m_Zone; pt_segm != NULL; pt_segm = NextS )
|
|
|
|
|
{
|
|
|
|
|
NextS = pt_segm->Next();
|
|
|
|
|
if( IsSegmentInBox( GetScreen()->BlockLocate, pt_segm ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
2007-10-03 15:21:13 +00:00
|
|
|
|
/* la piste est ici bonne a etre efface */
|
2007-08-20 01:20:48 +00:00
|
|
|
|
pt_segm->Draw( DrawPanel, DC, GR_XOR );
|
2007-10-03 15:21:13 +00:00
|
|
|
|
pt_segm->DeleteStructure();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Rafraichissement de l'ecran : */
|
|
|
|
|
RedrawActiveWindow( DC, TRUE );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void WinEDA_BasePcbFrame::Block_Move( wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*
|
2007-09-13 11:28:58 +00:00
|
|
|
|
* Function to move items in the current selected block
|
2007-08-20 01:20:48 +00:00
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2008-06-29 18:51:38 +00:00
|
|
|
|
wxPoint delta;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
wxPoint oldpos;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
oldpos = GetScreen()->m_Curseur;
|
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
GetScreen()->m_Curseur = oldpos;
|
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
|
GetScreen()->BlockLocate.Normalize();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
/* calcul du vecteur de deplacement pour les deplacements suivants */
|
2008-06-29 18:51:38 +00:00
|
|
|
|
delta = GetScreen()->BlockLocate.m_MoveVector;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
|
/* Move the Track segments in block */
|
2007-09-13 11:28:58 +00:00
|
|
|
|
TRACK* track = m_Pcb->m_Track;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
while( track )
|
|
|
|
|
{
|
|
|
|
|
if( IsSegmentInBox( GetScreen()->BlockLocate, track ) )
|
2007-09-13 11:28:58 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
m_Pcb->m_Status_Pcb = 0;
|
2007-09-13 11:28:58 +00:00
|
|
|
|
track->Draw( DrawPanel, DC, GR_XOR ); // erase the display
|
2008-06-29 18:51:38 +00:00
|
|
|
|
track->m_Start += delta;
|
|
|
|
|
track->m_End += delta;
|
|
|
|
|
// the two parameters are used in gerbview to store centre coordinates for arcs.
|
|
|
|
|
// move this centre
|
|
|
|
|
track->m_Param += delta.x;
|
|
|
|
|
track->SetSubNet( track->GetSubNet() + delta.y );
|
|
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
|
track->Draw( DrawPanel, DC, GR_OR ); // redraw the moved track
|
2007-08-20 01:20:48 +00:00
|
|
|
|
}
|
2007-09-13 11:28:58 +00:00
|
|
|
|
track = track->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
|
/* Move the Zone segments in block */
|
|
|
|
|
SEGZONE * zsegment= m_Pcb->m_Zone;
|
|
|
|
|
while( zsegment )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
{
|
2008-06-29 18:51:38 +00:00
|
|
|
|
if( IsSegmentInBox( GetScreen()->BlockLocate, zsegment ) )
|
2007-09-13 11:28:58 +00:00
|
|
|
|
{
|
|
|
|
|
zsegment->Draw( DrawPanel, DC, GR_XOR ); // erase the display
|
2008-06-29 18:51:38 +00:00
|
|
|
|
zsegment->m_Start += delta;
|
|
|
|
|
zsegment->m_End += delta;
|
|
|
|
|
// the two parameters are used in gerbview to store centre coordinates for arcs.
|
|
|
|
|
// move this centre
|
|
|
|
|
zsegment->m_Param += delta.x;
|
|
|
|
|
zsegment->SetSubNet( zsegment->GetSubNet() + delta.y );
|
2007-09-13 11:28:58 +00:00
|
|
|
|
zsegment->Draw( DrawPanel, DC, GR_OR ); // redraw the moved zone zegment
|
2007-08-20 01:20:48 +00:00
|
|
|
|
}
|
2007-09-13 11:28:58 +00:00
|
|
|
|
zsegment = zsegment->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DrawPanel->Refresh( TRUE );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/**************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*
|
2007-09-13 11:28:58 +00:00
|
|
|
|
* Function to duplicate items in the current selected block
|
2007-08-20 01:20:48 +00:00
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-09-13 11:28:58 +00:00
|
|
|
|
wxPoint delta;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
wxPoint oldpos;
|
|
|
|
|
|
|
|
|
|
oldpos = GetScreen()->m_Curseur;
|
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
|
|
|
|
|
|
GetScreen()->m_Curseur = oldpos;
|
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
|
GetScreen()->SetModify();
|
|
|
|
|
GetScreen()->BlockLocate.Normalize();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* calcul du vecteur de deplacement pour les deplacements suivants */
|
2007-09-13 11:28:58 +00:00
|
|
|
|
delta = GetScreen()->BlockLocate.m_MoveVector;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
|
/* Copy selected track segments and move the new track its new location */
|
|
|
|
|
TRACK* track = m_Pcb->m_Track;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
while( track )
|
|
|
|
|
{
|
2007-09-13 11:28:58 +00:00
|
|
|
|
TRACK* next_track = track->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
if( IsSegmentInBox( GetScreen()->BlockLocate, track ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
2007-09-13 11:28:58 +00:00
|
|
|
|
/* this track segment must be duplicated */
|
2007-08-20 01:20:48 +00:00
|
|
|
|
m_Pcb->m_Status_Pcb = 0;
|
2007-09-13 11:28:58 +00:00
|
|
|
|
TRACK* new_track = track->Copy();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
new_track->Insert( m_Pcb, NULL );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
|
|
new_track->m_Start += delta;
|
|
|
|
|
new_track->m_End += delta;
|
|
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
|
new_track->Draw( DrawPanel, DC, GR_OR ); // draw the new created segment
|
2007-08-20 01:20:48 +00:00
|
|
|
|
}
|
|
|
|
|
track = next_track;
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
|
/* Copy the Zone segments and move the new segment to its new location */
|
|
|
|
|
SEGZONE * zsegment= m_Pcb->m_Zone;
|
|
|
|
|
while( zsegment )
|
2007-08-20 01:20:48 +00:00
|
|
|
|
{
|
2007-09-13 11:28:58 +00:00
|
|
|
|
SEGZONE * next_zsegment = zsegment->Next();
|
2008-06-29 18:51:38 +00:00
|
|
|
|
if( IsSegmentInBox( GetScreen()->BlockLocate, zsegment ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
|
{
|
2007-09-13 11:28:58 +00:00
|
|
|
|
/* this zone segment must be duplicated */
|
|
|
|
|
SEGZONE * new_zsegment = (SEGZONE*) zsegment->Copy();
|
|
|
|
|
new_zsegment->Insert( m_Pcb, NULL );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
|
|
new_zsegment->m_Start += delta;
|
|
|
|
|
new_zsegment->m_End += delta;
|
|
|
|
|
|
2007-09-13 11:28:58 +00:00
|
|
|
|
new_zsegment->Draw( DrawPanel, DC, GR_OR ); // draw the new created segment
|
2007-08-20 01:20:48 +00:00
|
|
|
|
}
|
2007-09-13 11:28:58 +00:00
|
|
|
|
zsegment = next_zsegment;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
static TRACK* IsSegmentInBox( DrawBlockStruct& blocklocate, TRACK* PtSegm )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/**************************************************************************/
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/* Teste si la structure PtStruct est inscrite dans le block selectionne
|
2007-08-20 01:20:48 +00:00
|
|
|
|
* Retourne PtSegm si oui
|
|
|
|
|
* NULL si non
|
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
|
if( blocklocate.Inside( PtSegm->m_Start.x, PtSegm->m_Start.y ) )
|
|
|
|
|
return PtSegm;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
if( blocklocate.Inside( PtSegm->m_End.x, PtSegm->m_End.y ) )
|
|
|
|
|
return PtSegm;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
return NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|