2009-11-12 15:43:38 +00:00
|
|
|
/*************/
|
|
|
|
/* block.cpp */
|
|
|
|
/*************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
|
|
|
#include "block_commande.h"
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "pcbnew.h"
|
2009-07-30 11:04:07 +00:00
|
|
|
#include "wxPcbStruct.h"
|
2007-05-06 16:03:28 +00:00
|
|
|
#include "autorout.h"
|
|
|
|
#include "pcbplot.h"
|
|
|
|
#include "trigo.h"
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
|
|
|
|
#define BLOCK_COLOR BROWN
|
|
|
|
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
|
|
|
|
bool erase );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
static bool Block_Include_Modules = TRUE;
|
|
|
|
static bool Block_Include_Tracks = TRUE;
|
|
|
|
static bool Block_Include_Zones = TRUE;
|
|
|
|
static bool Block_Include_Draw_Items = TRUE;
|
2007-05-06 16:03:28 +00:00
|
|
|
static bool Block_Include_Edges_Items = TRUE;
|
2007-08-20 01:20:48 +00:00
|
|
|
static bool Block_Include_PcbTextes = TRUE;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
/************************************/
|
|
|
|
/* class WinEDA_ExecBlockCmdFrame */
|
|
|
|
/************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
class WinEDA_ExecBlockCmdFrame : public wxDialog
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
WinEDA_BasePcbFrame* m_Parent;
|
|
|
|
wxCheckBox* m_Include_Modules;
|
|
|
|
wxCheckBox* m_Include_Tracks;
|
|
|
|
wxCheckBox* m_Include_Zones;
|
|
|
|
wxCheckBox* m_Include_Draw_Items;
|
|
|
|
wxCheckBox* m_Include_Edges_Items;
|
|
|
|
wxCheckBox* m_Include_PcbTextes;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
public:
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
WinEDA_ExecBlockCmdFrame( WinEDA_BasePcbFrame* parent,
|
|
|
|
const wxString& title );
|
2007-09-01 12:00:30 +00:00
|
|
|
~WinEDA_ExecBlockCmdFrame()
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
private:
|
2009-08-01 19:26:05 +00:00
|
|
|
void ExecuteCommand( wxCommandEvent& event );
|
|
|
|
void Cancel( wxCommandEvent& event );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
2007-05-06 16:03:28 +00:00
|
|
|
};
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
BEGIN_EVENT_TABLE( WinEDA_ExecBlockCmdFrame, wxDialog )
|
2009-11-12 15:43:38 +00:00
|
|
|
EVT_BUTTON( wxID_OK, WinEDA_ExecBlockCmdFrame::ExecuteCommand )
|
|
|
|
EVT_BUTTON( wxID_CANCEL, WinEDA_ExecBlockCmdFrame::Cancel )
|
2007-05-06 16:03:28 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
static bool InstallBlockCmdFrame( WinEDA_BasePcbFrame* parent,
|
|
|
|
const wxString& title )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int nocmd;
|
|
|
|
wxPoint oldpos = parent->GetScreen()->m_Curseur;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
parent->DrawPanel->m_IgnoreMouseEvents = TRUE;
|
2009-11-12 15:43:38 +00:00
|
|
|
WinEDA_ExecBlockCmdFrame* frame =
|
|
|
|
new WinEDA_ExecBlockCmdFrame( parent, title );
|
2008-04-01 05:21:50 +00:00
|
|
|
|
|
|
|
nocmd = frame->ShowModal();
|
2007-10-13 06:18:44 +00:00
|
|
|
frame->Destroy();
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2007-10-13 06:18:44 +00:00
|
|
|
parent->GetScreen()->m_Curseur = oldpos;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
parent->DrawPanel->MouseToCursorSchema();
|
|
|
|
parent->DrawPanel->m_IgnoreMouseEvents = FALSE;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
parent->DrawPanel->SetCursor( parent->DrawPanel->m_PanelCursor =
|
|
|
|
parent->DrawPanel->m_PanelDefaultCursor );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
return nocmd ? FALSE : TRUE;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
WinEDA_ExecBlockCmdFrame::WinEDA_ExecBlockCmdFrame( WinEDA_BasePcbFrame* parent,
|
|
|
|
const wxString& title ) :
|
2007-09-29 16:17:35 +00:00
|
|
|
wxDialog( parent, -1, title, wxPoint( -1, -1 ), wxDefaultSize,
|
2007-08-20 01:20:48 +00:00
|
|
|
DIALOG_STYLE )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
wxPoint pos;
|
2007-09-29 16:17:35 +00:00
|
|
|
wxButton* m_button1;
|
|
|
|
wxButton* m_button2;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
m_Parent = parent;
|
|
|
|
Centre();
|
2007-10-03 19:57:23 +00:00
|
|
|
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
|
2009-05-01 18:06:03 +00:00
|
|
|
this->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90,
|
|
|
|
false, wxEmptyString ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-09-29 16:17:35 +00:00
|
|
|
/* Sizer 1 creation */
|
|
|
|
wxFlexGridSizer* fgSizer1;
|
|
|
|
fgSizer1 = new wxFlexGridSizer( 1, 1, 0, 0 );
|
|
|
|
fgSizer1->SetFlexibleDirection( wxBOTH );
|
|
|
|
fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
m_Include_Modules = new wxCheckBox( this, -1, _( "Include Modules" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
2009-08-01 19:26:05 +00:00
|
|
|
0 );
|
2007-08-20 01:20:48 +00:00
|
|
|
m_Include_Modules->SetValue( Block_Include_Modules );
|
2007-09-29 16:17:35 +00:00
|
|
|
fgSizer1->Add( m_Include_Modules, 0, wxALL, 5 );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
m_Include_Tracks = new wxCheckBox( this, -1, _( "Include tracks" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize, 0 );
|
2007-08-20 01:20:48 +00:00
|
|
|
m_Include_Tracks->SetValue( Block_Include_Tracks );
|
2007-09-29 16:17:35 +00:00
|
|
|
fgSizer1->Add( m_Include_Tracks, 0, wxALL, 5 );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
m_Include_Zones = new wxCheckBox( this, -1, _( "Include zones" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize, 0 );
|
2007-08-20 01:20:48 +00:00
|
|
|
m_Include_Zones->SetValue( Block_Include_Zones );
|
2007-09-29 16:17:35 +00:00
|
|
|
fgSizer1->Add( m_Include_Zones, 0, wxALL, 5 );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
m_Include_PcbTextes = new wxCheckBox( this, -1,
|
2009-11-12 15:43:38 +00:00
|
|
|
_( "Include Text on copper layers" ),
|
|
|
|
wxDefaultPosition,
|
2009-08-01 19:26:05 +00:00
|
|
|
wxDefaultSize, 0 );
|
2007-08-20 01:20:48 +00:00
|
|
|
m_Include_PcbTextes->SetValue( Block_Include_PcbTextes );
|
2007-09-29 16:17:35 +00:00
|
|
|
fgSizer1->Add( m_Include_PcbTextes, 0, wxALL, 5 );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
m_Include_Draw_Items = new wxCheckBox( this, -1, _( "Include drawings" ),
|
|
|
|
wxDefaultPosition,
|
2009-08-01 19:26:05 +00:00
|
|
|
wxDefaultSize, 0 );
|
2007-08-20 01:20:48 +00:00
|
|
|
m_Include_Draw_Items->SetValue( Block_Include_Draw_Items );
|
2007-09-29 16:17:35 +00:00
|
|
|
fgSizer1->Add( m_Include_Draw_Items, 0, wxALL, 5 );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
m_Include_Edges_Items = new wxCheckBox( this, -1,
|
|
|
|
_( "Include board outline layer" ),
|
|
|
|
wxDefaultPosition,
|
2009-08-01 19:26:05 +00:00
|
|
|
wxDefaultSize, 0 );
|
2007-08-20 01:20:48 +00:00
|
|
|
m_Include_Edges_Items->SetValue( Block_Include_Edges_Items );
|
2007-09-29 16:17:35 +00:00
|
|
|
fgSizer1->Add( m_Include_Edges_Items, 0, wxALL, 5 );
|
|
|
|
|
|
|
|
/* Sizer 2 creation */
|
|
|
|
wxFlexGridSizer* fgSizer2;
|
|
|
|
fgSizer2 = new wxFlexGridSizer( 1, 2, 0, 0 );
|
|
|
|
fgSizer2->SetFlexibleDirection( wxBOTH );
|
|
|
|
fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
m_button2 = new wxButton( this, wxID_CANCEL, _( "Cancel" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize, 0 );
|
2007-09-29 16:17:35 +00:00
|
|
|
fgSizer2->Add( m_button2, 0, wxALL, 5 );
|
2009-11-12 15:43:38 +00:00
|
|
|
m_button1 = new wxButton( this, wxID_OK, _( "OK" ), wxDefaultPosition,
|
|
|
|
wxDefaultSize, 0 );
|
2007-09-29 16:17:35 +00:00
|
|
|
m_button1->SetDefault();
|
|
|
|
fgSizer2->Add( m_button1, 0, wxALL, 5 );
|
|
|
|
|
|
|
|
fgSizer1->Add( fgSizer2, 1, wxALIGN_RIGHT, 5 );
|
|
|
|
this->SetSizer( fgSizer1 );
|
|
|
|
this->Layout();
|
|
|
|
fgSizer1->Fit( this );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
void WinEDA_ExecBlockCmdFrame::Cancel( wxCommandEvent& WXUNUSED (event) )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-10-07 03:08:24 +00:00
|
|
|
EndModal( -1 );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
void WinEDA_ExecBlockCmdFrame::ExecuteCommand( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
Block_Include_Modules = m_Include_Modules->GetValue();
|
|
|
|
Block_Include_Tracks = m_Include_Tracks->GetValue();
|
|
|
|
Block_Include_Zones = m_Include_Zones->GetValue();
|
|
|
|
Block_Include_Draw_Items = m_Include_Draw_Items->GetValue();
|
|
|
|
Block_Include_Edges_Items = m_Include_Edges_Items->GetValue();
|
|
|
|
Block_Include_PcbTextes = m_Include_PcbTextes->GetValue();
|
|
|
|
|
|
|
|
EndModal( 0 );
|
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-11-12 15:43:38 +00:00
|
|
|
int WinEDA_PcbFrame::ReturnBlockCommand( int key )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int cmd = 0;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
switch( key )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
cmd = key & 0x255;
|
|
|
|
break;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case 0:
|
|
|
|
cmd = BLOCK_MOVE;
|
|
|
|
break;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case GR_KB_SHIFT:
|
|
|
|
cmd = BLOCK_COPY;
|
|
|
|
break;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case GR_KB_CTRL:
|
|
|
|
cmd = BLOCK_ROTATE;
|
|
|
|
break;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case GR_KB_SHIFTCTRL:
|
|
|
|
cmd = BLOCK_DELETE;
|
|
|
|
break;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case GR_KB_ALT:
|
2009-08-12 10:40:01 +00:00
|
|
|
cmd = BLOCK_FLIP;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
case MOUSE_MIDDLE:
|
|
|
|
cmd = BLOCK_ZOOM;
|
|
|
|
break;
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
return cmd;
|
2007-05-06 16:03:28 +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
|
|
|
void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
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" ) );
|
|
|
|
}
|
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-08-01 19:26:05 +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 );
|
2009-08-01 19:26:05 +00:00
|
|
|
Block_Move();
|
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 );
|
2009-08-01 19:26:05 +00:00
|
|
|
Block_Duplicate();
|
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: // Handled by HandleBlockEnd()
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
2009-08-01 19:26:05 +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( "Error in HandleBlockPLace some items left in list" ) );
|
|
|
|
GetScreen()->m_BlockLocate.ClearItemsList();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DisplayToolMsg( wxEmptyString );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
/* Handle END BLOCK command.
|
|
|
|
* Returns:
|
|
|
|
* 0 if no features selected
|
|
|
|
* 1 otherwise
|
|
|
|
* -1 If order is completed and components found (block delete, block save)
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-11-12 15:43:38 +00:00
|
|
|
int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int endcommande = TRUE;
|
|
|
|
|
|
|
|
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-08-01 19:26:05 +00:00
|
|
|
case BLOCK_IDLE:
|
2007-08-20 01:20:48 +00:00
|
|
|
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*/
|
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 */
|
|
|
|
|
|
|
|
// Turn off the block rectangle now so it is not redisplayed
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP;
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE );
|
2009-08-01 19:26:05 +00:00
|
|
|
Block_Delete();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_ROTATE: /* Rotation */
|
|
|
|
|
|
|
|
// Turn off the block rectangle now so it is not redisplayed
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP;
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE );
|
2009-08-01 19:26:05 +00:00
|
|
|
Block_Rotate();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2009-08-12 10:40:01 +00:00
|
|
|
case BLOCK_FLIP: /* Flip */
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
// Turn off the block rectangle now so it is not redisplayed
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP;
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE );
|
2009-08-01 19:26:05 +00:00
|
|
|
Block_Flip();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_SAVE: /* Save (not used, for future enhancements)*/
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP;
|
|
|
|
if( GetScreen()->m_BlockLocate.GetCount() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE );
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
// TODO (if useful) Save_Block( );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_PASTE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_ZOOM: /* Window Zoom */
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
// Turn off the redraw block routine now so it is not displayed
|
2007-08-20 01:20:48 +00:00
|
|
|
// with one corner at the new center of the screen
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
2009-07-25 04:53:39 +00:00
|
|
|
Window_Zoom( GetScreen()->m_BlockLocate );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
return endcommande;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
/* Block operations: */
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
/**
|
|
|
|
* Function Block_SelectItems
|
|
|
|
* Uses GetScreen()->m_BlockLocate
|
|
|
|
* select items within the selected block.
|
|
|
|
* selected items are put in the pick list
|
|
|
|
* @param none
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-08-01 19:26:05 +00:00
|
|
|
void WinEDA_PcbFrame::Block_SelectItems()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-08-01 19:26:05 +00:00
|
|
|
int masque_layer;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
GetScreen()->m_BlockLocate.Normalize();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.m_ItemsSelection;
|
|
|
|
ITEM_PICKER picker( NULL, UR_UNSPECIFIED );
|
2009-07-31 05:33:11 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Block_Include_Modules )
|
|
|
|
{
|
2009-11-12 15:43:38 +00:00
|
|
|
for( MODULE* module = m_Pcb->m_Modules; module != NULL;
|
|
|
|
module = module->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-07-25 04:53:39 +00:00
|
|
|
if( module->HitTest( GetScreen()->m_BlockLocate ) )
|
2008-04-01 05:21:50 +00:00
|
|
|
{
|
2009-08-01 19:26:05 +00:00
|
|
|
picker.m_PickedItem = module;
|
2009-07-31 05:33:11 +00:00
|
|
|
picker.m_PickedItemType = module->Type();
|
2009-08-01 19:26:05 +00:00
|
|
|
itemsList->PushItem( picker );
|
2008-04-01 05:21:50 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-31 05:33:11 +00:00
|
|
|
/* Remove tracks and vias */
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Block_Include_Tracks )
|
|
|
|
{
|
2009-11-12 15:43:38 +00:00
|
|
|
for( TRACK* pt_segm = m_Pcb->m_Track; pt_segm != NULL;
|
|
|
|
pt_segm = pt_segm->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-07-25 04:53:39 +00:00
|
|
|
if( pt_segm->HitTest( GetScreen()->m_BlockLocate ) )
|
2008-04-01 05:21:50 +00:00
|
|
|
{
|
2009-08-01 19:26:05 +00:00
|
|
|
/* This track is in bloc: select it */
|
|
|
|
picker.m_PickedItem = pt_segm;
|
2009-07-31 05:33:11 +00:00
|
|
|
picker.m_PickedItemType = pt_segm->Type();
|
2009-08-01 19:26:05 +00:00
|
|
|
itemsList->PushItem( picker );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
/* Select graphic items */
|
2007-08-20 01:20:48 +00:00
|
|
|
masque_layer = EDGE_LAYER;
|
|
|
|
if( Block_Include_Draw_Items )
|
|
|
|
masque_layer = ALL_LAYERS;
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( !Block_Include_Edges_Items )
|
|
|
|
masque_layer &= ~EDGE_LAYER;
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
for( BOARD_ITEM* PtStruct = m_Pcb->m_Drawings; PtStruct != NULL;
|
|
|
|
PtStruct = PtStruct->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-08-01 19:26:05 +00:00
|
|
|
bool select_me = false;
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( PtStruct->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_DRAWSEGMENT:
|
2008-04-01 06:07:00 +00:00
|
|
|
if( (g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer) == 0 )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2009-08-01 19:26:05 +00:00
|
|
|
if( !PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2009-08-01 19:26:05 +00:00
|
|
|
select_me = true; // This item is in bloc: select it
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_TEXTE:
|
2007-08-20 01:20:48 +00:00
|
|
|
if( !Block_Include_PcbTextes )
|
|
|
|
break;
|
2009-08-01 19:26:05 +00:00
|
|
|
if( !PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2009-08-01 19:26:05 +00:00
|
|
|
select_me = true; // This item is in bloc: select it
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_MIRE:
|
2009-11-12 15:43:38 +00:00
|
|
|
if( ( g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer ) == 0 )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2009-08-01 19:26:05 +00:00
|
|
|
if( !PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2009-08-01 19:26:05 +00:00
|
|
|
select_me = true; // This item is in bloc: select it
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
case TYPE_DIMENSION:
|
2009-11-12 15:43:38 +00:00
|
|
|
if( ( g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer ) == 0 )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2009-08-01 19:26:05 +00:00
|
|
|
if( !PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2009-08-01 19:26:05 +00:00
|
|
|
select_me = true; // This item is in bloc: select it
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2009-07-31 05:33:11 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
if( select_me )
|
2009-07-31 05:33:11 +00:00
|
|
|
{
|
2009-08-01 19:26:05 +00:00
|
|
|
picker.m_PickedItem = PtStruct;
|
2009-07-31 05:33:11 +00:00
|
|
|
picker.m_PickedItemType = PtStruct->Type();
|
2009-08-01 19:26:05 +00:00
|
|
|
itemsList->PushItem( picker );
|
2009-07-31 05:33:11 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2009-08-06 15:42:09 +00:00
|
|
|
/* Zone selection */
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Block_Include_Zones )
|
|
|
|
{
|
2009-08-08 06:07:08 +00:00
|
|
|
#if 0
|
2009-08-06 15:42:09 +00:00
|
|
|
/* This section can creates problems if selected:
|
|
|
|
* m_Pcb->m_Zone can have a *lot* of items (100 000 is easily possible)
|
|
|
|
* so it is not selected (and TODO: will be removed, one day)
|
|
|
|
*/
|
2009-11-12 15:43:38 +00:00
|
|
|
for( SEGZONE* pt_segm = m_Pcb->m_Zone; pt_segm != NULL;
|
|
|
|
pt_segm = pt_segm->Next() )
|
2009-08-06 15:42:09 +00:00
|
|
|
{ /* Segments used in Zone filling selection */
|
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
if( pt_segm->HitTest( GetScreen()->m_BlockLocate ) )
|
2008-04-01 05:21:50 +00:00
|
|
|
{
|
2009-08-06 15:42:09 +00:00
|
|
|
picker.m_PickedItem = pt_segm;
|
|
|
|
picker.m_PickedItemType = pt_segm->Type();
|
2009-08-01 19:26:05 +00:00
|
|
|
itemsList->PushItem( picker );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
2009-08-06 15:42:09 +00:00
|
|
|
#endif
|
2009-08-01 19:26:05 +00:00
|
|
|
for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
|
2008-04-01 05:21:50 +00:00
|
|
|
{
|
2009-08-01 19:26:05 +00:00
|
|
|
if( m_Pcb->GetArea( ii )->HitTest( GetScreen()->m_BlockLocate ) )
|
2008-04-01 05:21:50 +00:00
|
|
|
{
|
2009-08-01 19:26:05 +00:00
|
|
|
BOARD_ITEM* zone_c = m_Pcb->GetArea( ii );
|
|
|
|
picker.m_PickedItem = zone_c;
|
2009-07-31 05:33:11 +00:00
|
|
|
picker.m_PickedItemType = zone_c->Type();
|
2009-08-01 19:26:05 +00:00
|
|
|
itemsList->PushItem( picker );
|
2008-04-01 05:21:50 +00:00
|
|
|
}
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2009-08-06 15:42:09 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
/* Traces the outline of the block structures during move.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-11-12 15:43:38 +00:00
|
|
|
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
|
|
|
|
bool erase )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-08-01 19:26:05 +00:00
|
|
|
int Color;
|
|
|
|
BASE_SCREEN* screen = panel->GetScreen();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
Color = YELLOW;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
if( erase )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-11-12 15:43:38 +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-08-01 19:26:05 +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-08-01 19:26:05 +00:00
|
|
|
if( screen->m_BlockLocate.m_State != STATE_BLOCK_STOP )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-08-01 19:26:05 +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-08-01 19:26:05 +00:00
|
|
|
screen->m_BlockLocate.Draw( panel, DC, wxPoint( 0, 0 ), g_XorMode, Color );
|
2009-11-12 15:43:38 +00:00
|
|
|
if( screen->m_BlockLocate.m_MoveVector.x
|
|
|
|
|| screen->m_BlockLocate.m_MoveVector.y )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-08-01 19:26:05 +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-08-01 19:26:05 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
/*
|
2009-11-12 15:43:38 +00:00
|
|
|
* Erase selected block.
|
2009-08-01 19:26:05 +00:00
|
|
|
*/
|
2009-11-12 15:43:38 +00:00
|
|
|
void WinEDA_PcbFrame::Block_Delete()
|
2009-08-01 19:26:05 +00:00
|
|
|
{
|
|
|
|
if( !InstallBlockCmdFrame( this, _( "Delete Block" ) ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
Block_SelectItems();
|
|
|
|
if( GetScreen()->m_BlockLocate.GetCount() == 0 )
|
|
|
|
return;
|
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2009-08-01 19:26:05 +00:00
|
|
|
SetCurItem( NULL );
|
|
|
|
|
|
|
|
PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.m_ItemsSelection;
|
|
|
|
itemsList->m_Status = UR_DELETED;
|
|
|
|
|
|
|
|
/* unlink items and clear flags */
|
|
|
|
for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-08-01 19:26:05 +00:00
|
|
|
BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
|
|
|
|
itemsList->SetPickedItemStatus( UR_DELETED, ii );
|
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-08-01 19:26:05 +00:00
|
|
|
case TYPE_MODULE:
|
|
|
|
{
|
|
|
|
MODULE* module = (MODULE*) item;
|
|
|
|
module->m_Flags = 0;
|
|
|
|
module->UnLink();
|
|
|
|
m_Pcb->m_Status_Pcb = 0;
|
|
|
|
}
|
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
case TYPE_ZONE_CONTAINER: // a zone area
|
2009-08-01 19:26:05 +00:00
|
|
|
m_Pcb->Remove( item );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
case TYPE_DRAWSEGMENT: // a segment not on copper layers
|
|
|
|
case TYPE_TEXTE: // a text on a layer
|
|
|
|
case TYPE_TRACK: // a track segment (segment on a copper layer)
|
|
|
|
case TYPE_VIA: // a via (like atrack segment on a copper layer)
|
2010-04-23 09:54:40 +00:00
|
|
|
case TYPE_DIMENSION: // a dimension (graphic item)
|
2009-11-12 15:43:38 +00:00
|
|
|
case TYPE_MIRE: // a target (graphic item)
|
2009-08-01 19:26:05 +00:00
|
|
|
item->UnLink();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2009-08-06 15:42:09 +00:00
|
|
|
// These items are deleted, but not put in undo list
|
2009-11-12 15:43:38 +00:00
|
|
|
case TYPE_MARKER_PCB: // a marker used to show something
|
|
|
|
case TYPE_ZONE: // SEG_ZONE items are now deprecated
|
2009-08-06 15:42:09 +00:00
|
|
|
item->UnLink();
|
|
|
|
itemsList->RemovePicker( ii );
|
|
|
|
ii--;
|
|
|
|
item->DeleteStructure();
|
|
|
|
break;
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
default:
|
2009-08-01 19:26:05 +00:00
|
|
|
wxMessageBox( wxT( "WinEDA_PcbFrame::Block_Delete( ) error: unexpected type" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
SaveCopyInUndoList( *itemsList, UR_DELETED );
|
|
|
|
|
|
|
|
Compile_Ratsnest( NULL, TRUE );
|
2008-01-06 12:43:57 +00:00
|
|
|
DrawPanel->Refresh( TRUE );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
/**
|
|
|
|
* Function Block_Rotate
|
|
|
|
* Rotate all items within the selected block.
|
2009-11-12 15:43:38 +00:00
|
|
|
* The rotation center is the center of the block
|
2009-08-01 19:26:05 +00:00
|
|
|
* @param none
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-08-01 19:26:05 +00:00
|
|
|
void WinEDA_PcbFrame::Block_Rotate()
|
2008-01-06 12:43:57 +00:00
|
|
|
{
|
2009-08-01 19:26:05 +00:00
|
|
|
wxPoint oldpos;
|
2009-11-12 15:43:38 +00:00
|
|
|
wxPoint centre; // rotation cent-re for the rotation transform
|
|
|
|
int rotAngle = 900; // rotation angle in 0.1 deg.
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
if( !InstallBlockCmdFrame( this, _( "Rotate Block" ) ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
Block_SelectItems();
|
|
|
|
if( GetScreen()->m_BlockLocate.GetCount() == 0 )
|
|
|
|
return;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
oldpos = GetScreen()->m_Curseur;
|
2009-11-12 15:43:38 +00:00
|
|
|
centre = GetScreen()->m_BlockLocate.Centre();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.m_ItemsSelection;
|
|
|
|
itemsList->m_Status = UR_ROTATED;
|
|
|
|
|
|
|
|
for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-08-01 19:26:05 +00:00
|
|
|
BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
|
|
|
|
wxASSERT(item);
|
|
|
|
itemsList->SetPickedItemStatus( UR_ROTATED, ii );
|
|
|
|
item->Rotate(centre, rotAngle);
|
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-08-01 19:26:05 +00:00
|
|
|
case TYPE_MODULE:
|
|
|
|
((MODULE*) item)->m_Flags = 0;
|
2007-08-20 01:20:48 +00:00
|
|
|
m_Pcb->m_Status_Pcb = 0;
|
2009-08-01 19:26:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* Move and rotate the track segments */
|
2009-11-12 15:43:38 +00:00
|
|
|
case TYPE_TRACK: // a track segment (segment on a copper layer)
|
|
|
|
case TYPE_VIA: // a via (like atrack segment on a copper layer)
|
2009-08-01 19:26:05 +00:00
|
|
|
m_Pcb->m_Status_Pcb = 0;
|
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
case TYPE_ZONE_CONTAINER:
|
|
|
|
case TYPE_DRAWSEGMENT:
|
|
|
|
case TYPE_TEXTE:
|
|
|
|
case TYPE_MIRE:
|
2010-04-23 09:54:40 +00:00
|
|
|
case TYPE_DIMENSION:
|
2009-08-01 19:26:05 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-06 15:42:09 +00:00
|
|
|
// This item is not put in undo list
|
2009-11-12 15:43:38 +00:00
|
|
|
case TYPE_ZONE: // SEG_ZONE items are now deprecated
|
2009-08-06 15:42:09 +00:00
|
|
|
itemsList->RemovePicker( ii );
|
|
|
|
ii--;
|
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
default:
|
|
|
|
wxMessageBox( wxT( "WinEDA_PcbFrame::Block_Rotate( ) error: unexpected type" ) );
|
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
SaveCopyInUndoList( *itemsList, UR_ROTATED, centre );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
Compile_Ratsnest( NULL, TRUE );
|
|
|
|
DrawPanel->Refresh( TRUE );
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
/**
|
|
|
|
* Function Block_Flip
|
|
|
|
* Flip items within the selected block.
|
2009-11-12 15:43:38 +00:00
|
|
|
* The flip center is the center of the block
|
2009-08-01 19:26:05 +00:00
|
|
|
* @param none
|
|
|
|
*/
|
|
|
|
void WinEDA_PcbFrame::Block_Flip()
|
|
|
|
{
|
|
|
|
#define INVERT( pos ) (pos) = center.y - ( (pos) - center.y )
|
|
|
|
wxPoint memo;
|
2009-11-12 15:43:38 +00:00
|
|
|
wxPoint center; /* Position of the axis for inversion of all elements */
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
Block_SelectItems();
|
|
|
|
if( GetScreen()->m_BlockLocate.GetCount() == 0 )
|
|
|
|
return;
|
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2009-08-01 19:26:05 +00:00
|
|
|
|
|
|
|
PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.m_ItemsSelection;
|
|
|
|
itemsList->m_Status = UR_FLIPPED;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
memo = GetScreen()->m_Curseur;
|
|
|
|
|
|
|
|
center = GetScreen()->m_BlockLocate.Centre();
|
|
|
|
|
|
|
|
for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-08-01 19:26:05 +00:00
|
|
|
BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
|
|
|
|
wxASSERT(item);
|
|
|
|
itemsList->SetPickedItemStatus( UR_FLIPPED, ii );
|
|
|
|
item->Flip(center);
|
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-08-01 19:26:05 +00:00
|
|
|
case TYPE_MODULE:
|
|
|
|
((MODULE*) item)->m_Flags = 0;
|
|
|
|
m_Pcb->m_Status_Pcb = 0;
|
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
/* Move and rotate the track segments */
|
2009-11-12 15:43:38 +00:00
|
|
|
case TYPE_TRACK: // a track segment (segment on a copper layer)
|
|
|
|
case TYPE_VIA: // a via (like atrack segment on a copper layer)
|
2009-08-01 19:26:05 +00:00
|
|
|
m_Pcb->m_Status_Pcb = 0;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
case TYPE_ZONE_CONTAINER:
|
|
|
|
case TYPE_DRAWSEGMENT:
|
|
|
|
case TYPE_TEXTE:
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_MIRE:
|
2010-04-23 09:54:40 +00:00
|
|
|
case TYPE_DIMENSION:
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2009-08-06 15:42:09 +00:00
|
|
|
// This item is not put in undo list
|
2009-11-12 15:43:38 +00:00
|
|
|
case TYPE_ZONE: // SEG_ZONE items are now deprecated
|
2009-08-06 15:42:09 +00:00
|
|
|
itemsList->RemovePicker( ii );
|
|
|
|
ii--;
|
|
|
|
break;
|
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
default:
|
2009-08-01 19:26:05 +00:00
|
|
|
wxMessageBox( wxT( "WinEDA_PcbFrame::Block_Flip( ) error: unexpected type" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
SaveCopyInUndoList( *itemsList, UR_FLIPPED, center );
|
|
|
|
Compile_Ratsnest( NULL, TRUE );
|
2008-01-06 12:43:57 +00:00
|
|
|
DrawPanel->Refresh( TRUE );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
/**
|
|
|
|
* Function Block_Move
|
|
|
|
* moves all tracks and segments within the selected block.
|
2009-11-12 15:43:38 +00:00
|
|
|
* New location is determined by the current offset from the selected block's
|
|
|
|
* original location.
|
2009-08-01 19:26:05 +00:00
|
|
|
* @param none
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-08-01 19:26:05 +00:00
|
|
|
void WinEDA_PcbFrame::Block_Move()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( !InstallBlockCmdFrame( this, _( "Move Block" ) ) )
|
|
|
|
return;
|
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
Block_SelectItems();
|
|
|
|
if( GetScreen()->m_BlockLocate.GetCount() == 0 )
|
|
|
|
return;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
wxPoint MoveVector = GetScreen()->m_BlockLocate.m_MoveVector;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.m_ItemsSelection;
|
|
|
|
itemsList->m_Status = UR_MOVED;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-08-01 19:26:05 +00:00
|
|
|
BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
|
|
|
|
itemsList->SetPickedItemStatus( UR_MOVED, ii );
|
|
|
|
item->Move( MoveVector );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
switch( item->Type() )
|
2008-04-01 05:21:50 +00:00
|
|
|
{
|
2009-08-01 19:26:05 +00:00
|
|
|
case TYPE_MODULE:
|
|
|
|
m_Pcb->m_Status_Pcb = 0;
|
|
|
|
((MODULE*) item)->m_Flags = 0;
|
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
/* Move track segments */
|
2009-11-12 15:43:38 +00:00
|
|
|
case TYPE_TRACK: // a track segment (segment on a copper layer)
|
|
|
|
case TYPE_VIA: // a via (like a track segment on a copper layer)
|
2009-08-01 19:26:05 +00:00
|
|
|
m_Pcb->m_Status_Pcb = 0;
|
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
case TYPE_ZONE_CONTAINER:
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_DRAWSEGMENT:
|
|
|
|
case TYPE_TEXTE:
|
|
|
|
case TYPE_MIRE:
|
2010-04-23 09:54:40 +00:00
|
|
|
case TYPE_DIMENSION:
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2009-08-06 15:42:09 +00:00
|
|
|
// This item is not put in undo list
|
2009-11-12 15:43:38 +00:00
|
|
|
case TYPE_ZONE: // SEG_ZONE items are now deprecated
|
2009-08-06 15:42:09 +00:00
|
|
|
itemsList->RemovePicker( ii );
|
|
|
|
ii--;
|
|
|
|
break;
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
default:
|
2009-08-01 19:26:05 +00:00
|
|
|
wxMessageBox( wxT( "WinEDA_PcbFrame::Block_Move( ) error: unexpected type" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
SaveCopyInUndoList( *itemsList, UR_MOVED, MoveVector );
|
|
|
|
|
|
|
|
Compile_Ratsnest( NULL, TRUE );
|
2008-01-06 12:43:57 +00:00
|
|
|
DrawPanel->Refresh( TRUE );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
/**
|
|
|
|
* Function Block_Duplicate
|
|
|
|
* Duplicate all items within the selected block.
|
2009-11-12 15:43:38 +00:00
|
|
|
* New location is determined by the current offset from the selected block's
|
|
|
|
* original location.
|
2009-08-01 19:26:05 +00:00
|
|
|
* @param none
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-08-01 19:26:05 +00:00
|
|
|
void WinEDA_PcbFrame::Block_Duplicate()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-07-25 04:53:39 +00:00
|
|
|
wxPoint MoveVector = GetScreen()->m_BlockLocate.m_MoveVector;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( !InstallBlockCmdFrame( this, _( "Copy Block" ) ) )
|
|
|
|
return;
|
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
Block_SelectItems();
|
|
|
|
if( GetScreen()->m_BlockLocate.GetCount() == 0 )
|
|
|
|
return;
|
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.m_ItemsSelection;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
PICKED_ITEMS_LIST newList;
|
|
|
|
newList.m_Status = UR_NEW;
|
|
|
|
|
|
|
|
ITEM_PICKER picker(NULL, UR_NEW);
|
|
|
|
BOARD_ITEM * newitem;
|
|
|
|
|
|
|
|
for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
|
|
|
|
{
|
|
|
|
BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
|
|
|
|
newitem = NULL;
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case TYPE_MODULE:
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-08-01 19:26:05 +00:00
|
|
|
MODULE* module = (MODULE*) item;
|
2007-08-20 01:20:48 +00:00
|
|
|
MODULE* new_module;
|
|
|
|
m_Pcb->m_Status_Pcb = 0;
|
2009-08-01 19:26:05 +00:00
|
|
|
module->m_Flags = 0;
|
|
|
|
newitem = new_module = new MODULE( m_Pcb );
|
2007-08-20 01:20:48 +00:00
|
|
|
new_module->Copy( module );
|
|
|
|
new_module->m_TimeStamp = GetTimeStamp();
|
2008-12-04 04:28:11 +00:00
|
|
|
m_Pcb->m_Modules.PushFront( new_module );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2009-08-01 19:26:05 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
case TYPE_TRACK:
|
|
|
|
case TYPE_VIA:
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-08-01 19:26:05 +00:00
|
|
|
TRACK* track = (TRACK*) item;
|
|
|
|
m_Pcb->m_Status_Pcb = 0;
|
|
|
|
TRACK* new_track = track->Copy();
|
|
|
|
newitem = new_track;
|
|
|
|
m_Pcb->m_Track.PushFront( new_track );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2009-08-01 19:26:05 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-08 06:07:08 +00:00
|
|
|
case TYPE_ZONE: // SEG_ZONE items are now deprecated
|
|
|
|
break;
|
2008-01-06 12:43:57 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
case TYPE_ZONE_CONTAINER:
|
2008-04-01 05:21:50 +00:00
|
|
|
{
|
2009-11-12 15:43:38 +00:00
|
|
|
ZONE_CONTAINER* new_zone =
|
|
|
|
new ZONE_CONTAINER( (BOARD*) item->GetParent() );
|
2009-08-01 19:26:05 +00:00
|
|
|
new_zone->Copy( (ZONE_CONTAINER*) item );
|
|
|
|
new_zone->m_TimeStamp = GetTimeStamp();
|
|
|
|
newitem = new_zone;
|
|
|
|
m_Pcb->Add( new_zone );
|
2008-04-01 05:21:50 +00:00
|
|
|
}
|
2009-08-01 19:26:05 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_DRAWSEGMENT:
|
2009-08-01 19:26:05 +00:00
|
|
|
{
|
|
|
|
DRAWSEGMENT* new_drawsegment = new DRAWSEGMENT( m_Pcb );
|
|
|
|
new_drawsegment->Copy( (DRAWSEGMENT*) item );
|
|
|
|
m_Pcb->Add( new_drawsegment );
|
|
|
|
newitem = new_drawsegment;
|
|
|
|
}
|
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_TEXTE:
|
2009-08-01 19:26:05 +00:00
|
|
|
{
|
|
|
|
TEXTE_PCB* new_pcbtext = new TEXTE_PCB( m_Pcb );
|
|
|
|
new_pcbtext->Copy( (TEXTE_PCB*) item );
|
|
|
|
m_Pcb->Add( new_pcbtext );
|
|
|
|
newitem = new_pcbtext;
|
|
|
|
}
|
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_MIRE:
|
2009-08-01 19:26:05 +00:00
|
|
|
{
|
|
|
|
MIREPCB* new_mire = new MIREPCB( m_Pcb );
|
|
|
|
new_mire->Copy( (MIREPCB*) item );
|
|
|
|
m_Pcb->Add( new_mire );
|
|
|
|
newitem = new_mire;
|
|
|
|
}
|
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-04-23 09:54:40 +00:00
|
|
|
case TYPE_DIMENSION:
|
2009-08-01 19:26:05 +00:00
|
|
|
{
|
2010-04-23 09:54:40 +00:00
|
|
|
DIMENSION* new_cotation = new DIMENSION( m_Pcb );
|
|
|
|
new_cotation->Copy( (DIMENSION*) item );
|
2009-08-01 19:26:05 +00:00
|
|
|
m_Pcb->Add( new_cotation );
|
|
|
|
newitem = new_cotation;
|
|
|
|
}
|
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
default:
|
2009-08-01 19:26:05 +00:00
|
|
|
wxMessageBox( wxT( "WinEDA_PcbFrame::Block_Duplicate( ) error: unexpected type" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-08-01 19:26:05 +00:00
|
|
|
|
|
|
|
if ( newitem )
|
|
|
|
{
|
|
|
|
newitem->Move( MoveVector );
|
|
|
|
picker.m_PickedItem = newitem;
|
|
|
|
picker.m_PickedItemType = newitem->Type();
|
|
|
|
newList.PushItem(picker);
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2009-06-05 15:57:41 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
if( newList.GetCount() )
|
|
|
|
SaveCopyInUndoList( newList, UR_NEW );
|
2009-06-05 15:57:41 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
Compile_Ratsnest( NULL, TRUE );
|
|
|
|
DrawPanel->Refresh( TRUE );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|