2009-11-09 14:00:22 +00:00
|
|
|
/**********************************************************/
|
|
|
|
/* Block operations: displacement, rotation, deletion ... */
|
|
|
|
/**********************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "trigo.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "confirm.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "gerbview.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
|
|
|
|
#define BLOCK_COLOR BROWN
|
|
|
|
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel,
|
|
|
|
wxDC* DC,
|
|
|
|
bool erase );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
static TRACK* IsSegmentInBox( BLOCK_SELECTOR& 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
|
|
|
/* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to
|
2007-08-20 01:20:48 +00:00
|
|
|
* the key (ALT, SHIFT ALT ..)
|
|
|
|
*/
|
2009-11-09 14:00:22 +00:00
|
|
|
int WinEDA_GerberFrame::ReturnBlockCommand( int key )
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
/* Routine to handle the BLOCK PLACE command */
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_GerberFrame::HandleBlockPlace( wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
bool err = FALSE;
|
|
|
|
|
|
|
|
if( DrawPanel->ManageCurseur == NULL )
|
|
|
|
{
|
|
|
|
err = TRUE;
|
2009-11-09 14:00:22 +00:00
|
|
|
DisplayError( this,
|
|
|
|
wxT( "Error in HandleBlockPLace : ManageCurseur = 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
|
|
|
{
|
2009-11-09 14:00:22 +00:00
|
|
|
case BLOCK_IDLE:
|
2007-08-20 01:20:48 +00:00
|
|
|
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 );
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.ClearItemsList();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_COPY: /* Copy */
|
|
|
|
if( DrawPanel->ManageCurseur )
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
Block_Duplicate( DC );
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.ClearItemsList();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_PASTE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_ZOOM: // Handle by HandleBlockEnd()
|
|
|
|
case BLOCK_ROTATE:
|
2009-08-12 10:40:01 +00:00
|
|
|
case BLOCK_FLIP:
|
2007-08-20 01:20:48 +00:00
|
|
|
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;
|
2009-11-09 14:00:22 +00:00
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
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;
|
|
|
|
if( GetScreen()->m_BlockLocate.GetCount() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-07-25 04:53:39 +00:00
|
|
|
DisplayError( this, wxT( "HandleBlockPLace error: some items left" ) );
|
|
|
|
GetScreen()->m_BlockLocate.ClearItemsList();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DisplayToolMsg( wxEmptyString );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
/* Routine management command END BLOCK
|
|
|
|
* Returns:
|
|
|
|
* 0 if no and selects compounds
|
|
|
|
* 1 otherwise
|
|
|
|
* -1 If order is completed and components found (block delete, block save)
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-11-09 14:00:22 +00:00
|
|
|
int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC )
|
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 )
|
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
switch( GetScreen()->m_BlockLocate.m_Command )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-11-09 14:00:22 +00:00
|
|
|
case BLOCK_IDLE:
|
2007-08-20 01:20:48 +00:00
|
|
|
DisplayError( this, wxT( "Error in HandleBlockPLace" ) );
|
|
|
|
break;
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
case BLOCK_DRAG: /* Drag (not used, for future
|
|
|
|
* enhancements) */
|
2007-08-20 01:20:48 +00:00
|
|
|
case BLOCK_MOVE: /* Move */
|
|
|
|
case BLOCK_COPY: /* Copy */
|
2009-11-09 14:00:22 +00:00
|
|
|
case BLOCK_PRESELECT_MOVE: /* Move with preselection list */
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE;
|
2007-08-20 01:20:48 +00:00
|
|
|
endcommande = FALSE;
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
DrawPanel->ManageCurseur = DrawMovingBlockOutlines;
|
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_DELETE: /* Delete */
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP;
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
Block_Delete( DC );
|
|
|
|
break;
|
|
|
|
|
2009-05-02 18:53:04 +00:00
|
|
|
case BLOCK_MIRROR_X: /* Mirror*/
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP;
|
2009-05-02 18:53:04 +00:00
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
|
|
|
|
Block_Mirror_X( DC );
|
|
|
|
break;
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case BLOCK_ROTATE: /* Unused */
|
|
|
|
break;
|
|
|
|
|
2009-08-12 10:40:01 +00:00
|
|
|
case BLOCK_FLIP: /* Flip, unused */
|
2007-08-20 01:20:48 +00:00
|
|
|
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_Y:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( endcommande == TRUE )
|
|
|
|
{
|
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;
|
|
|
|
GetScreen()->m_BlockLocate.ClearItemsList();
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
|
|
|
DisplayToolMsg( wxEmptyString );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( zoom_command )
|
2009-07-25 04:53:39 +00:00
|
|
|
Window_Zoom( GetScreen()->m_BlockLocate );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
return endcommande;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
/* Traces the outline of the block structures of a repositioning move
|
2007-06-05 12:10:51 +00:00
|
|
|
*/
|
2009-11-09 14:00:22 +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
|
|
|
int Color;
|
|
|
|
BASE_SCREEN* screen = panel->GetScreen();
|
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
Color = YELLOW;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( erase )
|
|
|
|
{
|
2009-11-09 14:00:22 +00:00
|
|
|
screen->m_BlockLocate.Draw( panel, DC, wxPoint( 0, 0 ), g_XorMode,
|
|
|
|
Color );
|
|
|
|
if( screen->m_BlockLocate.m_MoveVector.x
|
|
|
|
|| screen->m_BlockLocate.m_MoveVector.y )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-11-09 14:00:22 +00:00
|
|
|
screen->m_BlockLocate.Draw( panel,
|
|
|
|
DC,
|
|
|
|
screen->m_BlockLocate.m_MoveVector,
|
|
|
|
g_XorMode,
|
|
|
|
Color );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
if( panel->GetScreen()->m_BlockLocate.m_State != STATE_BLOCK_STOP )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-11-09 14:00:22 +00:00
|
|
|
screen->m_BlockLocate.m_MoveVector.x = screen->m_Curseur.x -
|
|
|
|
screen->m_BlockLocate.GetRight();
|
|
|
|
screen->m_BlockLocate.m_MoveVector.y = screen->m_Curseur.y -
|
|
|
|
screen->m_BlockLocate.GetBottom();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
screen->m_BlockLocate.Draw( panel, DC, wxPoint( 0, 0 ), g_XorMode, Color );
|
|
|
|
if( screen->m_BlockLocate.m_MoveVector.x
|
|
|
|
|| screen->m_BlockLocate.m_MoveVector.y )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-11-09 14:00:22 +00:00
|
|
|
screen->m_BlockLocate.Draw( panel,
|
|
|
|
DC,
|
|
|
|
screen->m_BlockLocate.m_MoveVector,
|
|
|
|
g_XorMode,
|
|
|
|
Color );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2009-11-09 14:00:22 +00:00
|
|
|
* Erase the selected block.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-11-09 14:00:22 +00:00
|
|
|
void WinEDA_GerberFrame::Block_Delete( wxDC* DC )
|
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();
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.Normalize();
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->SetCurItem( NULL );
|
|
|
|
|
|
|
|
TRACK* pt_segm, * NextS;
|
|
|
|
for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = NextS )
|
|
|
|
{
|
|
|
|
NextS = pt_segm->Next();
|
2009-07-25 04:53:39 +00:00
|
|
|
if( IsSegmentInBox( GetScreen()->m_BlockLocate, pt_segm ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2009-11-09 14:00:22 +00:00
|
|
|
/* the track here is good to be cleared */
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
/* Erasing areas. */
|
2007-08-20 01:20:48 +00:00
|
|
|
for( pt_segm = m_Pcb->m_Zone; pt_segm != NULL; pt_segm = NextS )
|
|
|
|
{
|
|
|
|
NextS = pt_segm->Next();
|
2009-07-25 04:53:39 +00:00
|
|
|
if( IsSegmentInBox( GetScreen()->m_BlockLocate, pt_segm ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2009-11-09 14:00:22 +00:00
|
|
|
/* The track here is good to be cleared. */
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-22 18:13:43 +00:00
|
|
|
Refresh();
|
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
|
|
|
*/
|
2009-11-09 14:00:22 +00:00
|
|
|
void WinEDA_GerberFrame::Block_Move( wxDC* DC )
|
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();
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.Normalize();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
/* Calculate displacement vectors. */
|
2009-07-25 04:53:39 +00:00
|
|
|
delta = GetScreen()->m_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 )
|
|
|
|
{
|
2009-07-25 04:53:39 +00:00
|
|
|
if( IsSegmentInBox( GetScreen()->m_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;
|
2009-11-09 14:00:22 +00:00
|
|
|
|
|
|
|
// the two parameters are used in gerbview to store center
|
|
|
|
// coordinates for arcs. Move this center.
|
|
|
|
track->m_Param += delta.x;
|
2008-06-29 18:51:38 +00:00
|
|
|
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 */
|
2009-11-09 14:00:22 +00:00
|
|
|
SEGZONE* zsegment = m_Pcb->m_Zone;
|
2007-09-13 11:28:58 +00:00
|
|
|
while( zsegment )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-07-25 04:53:39 +00:00
|
|
|
if( IsSegmentInBox( GetScreen()->m_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;
|
2009-11-09 14:00:22 +00:00
|
|
|
|
|
|
|
// the two parameters are used in gerbview to store center
|
|
|
|
// coordinates for arcs. Move this center
|
|
|
|
zsegment->m_Param += delta.x;
|
2008-06-29 18:51:38 +00:00
|
|
|
zsegment->SetSubNet( zsegment->GetSubNet() + delta.y );
|
2009-11-09 14:00:22 +00:00
|
|
|
zsegment->Draw( DrawPanel, DC, GR_OR ); // redraw the moved zone
|
|
|
|
// segment
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-02 18:53:04 +00:00
|
|
|
/*
|
|
|
|
* Function to mirror items in the current selected block
|
|
|
|
*/
|
2009-11-09 14:00:22 +00:00
|
|
|
void WinEDA_GerberFrame::Block_Mirror_X( wxDC* DC )
|
2009-05-02 18:53:04 +00:00
|
|
|
{
|
|
|
|
int xoffset = 0;
|
|
|
|
wxPoint oldpos;
|
|
|
|
|
|
|
|
oldpos = GetScreen()->m_Curseur;
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
|
|
|
|
GetScreen()->m_Curseur = oldpos;
|
|
|
|
DrawPanel->MouseToCursorSchema();
|
|
|
|
GetScreen()->SetModify();
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.Normalize();
|
2009-05-02 18:53:04 +00:00
|
|
|
|
|
|
|
/* Calculate offset to mirror track points from block edges */
|
2009-11-09 14:00:22 +00:00
|
|
|
xoffset = GetScreen()->m_BlockLocate.m_Pos.x
|
|
|
|
+ GetScreen()->m_BlockLocate.m_Pos.x
|
2009-07-25 04:53:39 +00:00
|
|
|
+ GetScreen()->m_BlockLocate.m_Size.x;
|
2009-05-02 18:53:04 +00:00
|
|
|
|
|
|
|
/* Move the Track segments in block */
|
2009-11-09 14:00:22 +00:00
|
|
|
for( TRACK* track = m_Pcb->m_Track; track; track = track->Next() )
|
2009-05-02 18:53:04 +00:00
|
|
|
{
|
2009-07-25 04:53:39 +00:00
|
|
|
if( IsSegmentInBox( GetScreen()->m_BlockLocate, track ) )
|
2009-05-02 18:53:04 +00:00
|
|
|
{
|
|
|
|
m_Pcb->m_Status_Pcb = 0;
|
|
|
|
track->Draw( DrawPanel, DC, GR_XOR ); // erase the display
|
|
|
|
track->m_Start.x = xoffset - track->m_Start.x;
|
|
|
|
track->m_End.x = xoffset - track->m_End.x;
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
// the two parameters are used in gerbview to store center
|
|
|
|
// coordinates for arcs. Move this center
|
2009-05-02 18:53:04 +00:00
|
|
|
track->m_Param = xoffset - track->m_Param;
|
|
|
|
track->Draw( DrawPanel, DC, GR_OR ); // redraw the moved track
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Move the Zone segments in block */
|
2009-11-09 14:00:22 +00:00
|
|
|
for( SEGZONE* zsegment = m_Pcb->m_Zone;
|
|
|
|
zsegment;
|
|
|
|
zsegment = zsegment->Next() )
|
2009-05-02 18:53:04 +00:00
|
|
|
{
|
2009-07-25 04:53:39 +00:00
|
|
|
if( IsSegmentInBox( GetScreen()->m_BlockLocate, zsegment ) )
|
2009-05-02 18:53:04 +00:00
|
|
|
{
|
|
|
|
zsegment->Draw( DrawPanel, DC, GR_XOR ); // erase the display
|
|
|
|
zsegment->m_Start.x = xoffset - zsegment->m_Start.x;
|
|
|
|
zsegment->m_End.x = xoffset - zsegment->m_End.x;
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
// the two parameters are used in gerbview to store center
|
|
|
|
// coordinates for arcs. Move this center
|
2009-05-02 18:53:04 +00:00
|
|
|
zsegment->m_Param = xoffset - zsegment->m_Param;
|
2009-11-09 14:00:22 +00:00
|
|
|
zsegment->Draw( DrawPanel, DC, GR_OR ); // redraw the moved zone
|
|
|
|
// segment
|
2009-05-02 18:53:04 +00:00
|
|
|
}
|
|
|
|
}
|
2009-07-25 04:53:39 +00:00
|
|
|
|
2009-05-02 18:53:04 +00:00
|
|
|
DrawPanel->Refresh( TRUE );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
*/
|
2009-11-09 14:00:22 +00:00
|
|
|
void WinEDA_GerberFrame::Block_Duplicate( wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-09 14:00:22 +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();
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.Normalize();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
delta = GetScreen()->m_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();
|
2009-07-25 04:53:39 +00:00
|
|
|
if( IsSegmentInBox( GetScreen()->m_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();
|
2008-12-04 04:28:11 +00:00
|
|
|
|
|
|
|
m_Pcb->Add( new_track );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
new_track->m_Start += delta;
|
|
|
|
new_track->m_End += delta;
|
|
|
|
|
2009-11-09 14:00:22 +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 */
|
2009-11-09 14:00:22 +00:00
|
|
|
SEGZONE* zsegment = m_Pcb->m_Zone;
|
2007-09-13 11:28:58 +00:00
|
|
|
while( zsegment )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-11-09 14:00:22 +00:00
|
|
|
SEGZONE* next_zsegment = zsegment->Next();
|
2009-07-25 04:53:39 +00:00
|
|
|
if( IsSegmentInBox( GetScreen()->m_BlockLocate, zsegment ) )
|
2008-04-17 16:25:29 +00:00
|
|
|
{
|
2007-09-13 11:28:58 +00:00
|
|
|
/* this zone segment must be duplicated */
|
2009-11-09 14:00:22 +00:00
|
|
|
SEGZONE* new_zsegment = (SEGZONE*) zsegment->Copy();
|
2008-12-04 04:28:11 +00:00
|
|
|
|
|
|
|
m_Pcb->Add( new_zsegment );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
new_zsegment->m_Start += delta;
|
|
|
|
new_zsegment->m_End += delta;
|
|
|
|
|
2009-11-09 14:00:22 +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
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
/* Test if the structure PtStruct is listed in the block selects
|
|
|
|
* Returns whether PtSegm
|
|
|
|
* NULL if not
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-11-09 14:00:22 +00:00
|
|
|
static TRACK* IsSegmentInBox( BLOCK_SELECTOR& blocklocate, TRACK* PtSegm )
|
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
|
|
|
}
|