2011-11-10 15:55:05 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2012-06-08 09:56:42 +00:00
|
|
|
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2011-11-10 15:55:05 +00:00
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
/**
|
2011-12-01 16:49:28 +00:00
|
|
|
* @file pcbnew/block.cpp
|
2011-09-23 13:57:12 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <block_commande.h>
|
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <trigo.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_track.h>
|
|
|
|
#include <class_drawsegment.h>
|
|
|
|
#include <class_pcb_text.h>
|
|
|
|
#include <class_mire.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
#include <class_dimension.h>
|
|
|
|
#include <class_zone.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialog_block_options_base.h>
|
2010-11-12 18:38:48 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <protos.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-11-11 21:46:55 +00:00
|
|
|
#define BLOCK_OUTLINE_COLOR YELLOW
|
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function drawPickedItems
|
2010-11-11 21:46:55 +00:00
|
|
|
* draws items currently selected in a block
|
|
|
|
* @param aPanel = Current draw panel
|
|
|
|
* @param aDC = Current device context
|
|
|
|
* @param aOffset = Drawing offset
|
|
|
|
**/
|
2011-01-21 19:30:59 +00:00
|
|
|
static void drawPickedItems( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPoint aOffset );
|
2010-11-12 18:38:48 +00:00
|
|
|
|
2010-11-12 16:36:43 +00:00
|
|
|
/**
|
|
|
|
* Function drawMovingBlock
|
2010-11-11 21:46:55 +00:00
|
|
|
* handles drawing of a moving block
|
|
|
|
* @param aPanel = Current draw panel
|
|
|
|
* @param aDC = Current device context
|
2011-02-03 19:27:28 +00:00
|
|
|
* @param aPosition The cursor position in logical (drawing) units.
|
2010-11-11 21:46:55 +00:00
|
|
|
* @param aErase = Erase block at current position
|
|
|
|
**/
|
2011-02-03 19:27:28 +00:00
|
|
|
static void drawMovingBlock( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
|
|
|
bool aErase );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
static bool blockIncludeModules = true;
|
|
|
|
static bool blockIncludeLockedModules = true;
|
|
|
|
static bool blockIncludeTracks = true;
|
|
|
|
static bool blockIncludeZones = true;
|
|
|
|
static bool blockIncludeItemsOnTechLayers = true;
|
|
|
|
static bool blockIncludeBoardOutlineLayer = true;
|
|
|
|
static bool blockIncludePcbTexts = true;
|
|
|
|
static bool blockDrawItems = true;
|
2011-03-07 12:28:14 +00:00
|
|
|
static bool blockIncludeItemsOnInvisibleLayers = false;
|
2009-11-12 15:43:38 +00:00
|
|
|
|
2011-11-10 15:55:05 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
/************************************/
|
2010-11-12 18:38:48 +00:00
|
|
|
/* class DIALOG_BLOCK_OPTIONS */
|
2007-08-20 01:20:48 +00:00
|
|
|
/************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-11-12 18:38:48 +00:00
|
|
|
class DIALOG_BLOCK_OPTIONS : public DIALOG_BLOCK_OPTIONS_BASE
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
private:
|
2011-03-01 19:26:17 +00:00
|
|
|
PCB_BASE_FRAME* m_Parent;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
public:
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
DIALOG_BLOCK_OPTIONS( PCB_BASE_FRAME* parent, const wxString& title );
|
2010-11-12 18:38:48 +00:00
|
|
|
~DIALOG_BLOCK_OPTIONS()
|
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 );
|
2011-11-26 20:02:59 +00:00
|
|
|
void OnCancel( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
EndModal( wxID_CANCEL );
|
|
|
|
}
|
2010-11-13 11:02:24 +00:00
|
|
|
void checkBoxClicked( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( m_Include_Modules->GetValue() )
|
|
|
|
m_IncludeLockedModules->Enable();
|
|
|
|
else
|
|
|
|
m_IncludeLockedModules->Disable();
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
};
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
static bool InstallBlockCmdFrame( PCB_BASE_FRAME* parent, const wxString& title )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
wxPoint oldpos = parent->GetCrossHairPosition();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
parent->GetCanvas()->SetIgnoreMouseEvents( true );
|
2011-11-26 20:02:59 +00:00
|
|
|
DIALOG_BLOCK_OPTIONS * dlg = new DIALOG_BLOCK_OPTIONS( parent, title );
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2011-11-26 20:02:59 +00:00
|
|
|
int cmd = dlg->ShowModal();
|
|
|
|
dlg->Destroy();
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
parent->SetCrossHairPosition( oldpos );
|
2011-12-22 13:28:11 +00:00
|
|
|
parent->GetCanvas()->MoveCursorToCrossHair();
|
2011-12-29 20:11:42 +00:00
|
|
|
parent->GetCanvas()->SetIgnoreMouseEvents( false );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-11-26 20:02:59 +00:00
|
|
|
return cmd == wxID_OK;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
DIALOG_BLOCK_OPTIONS::DIALOG_BLOCK_OPTIONS( PCB_BASE_FRAME* aParent, const wxString& aTitle ) :
|
2010-11-13 11:02:24 +00:00
|
|
|
DIALOG_BLOCK_OPTIONS_BASE( aParent, -1, aTitle )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2010-11-13 11:02:24 +00:00
|
|
|
m_Parent = aParent;
|
|
|
|
|
|
|
|
m_Include_Modules->SetValue( blockIncludeModules );
|
|
|
|
m_IncludeLockedModules->SetValue( blockIncludeLockedModules );
|
2011-01-20 20:36:17 +00:00
|
|
|
|
|
|
|
if( m_Include_Modules->GetValue() )
|
|
|
|
m_IncludeLockedModules->Enable();
|
|
|
|
else
|
|
|
|
m_IncludeLockedModules->Disable();
|
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
m_Include_Tracks->SetValue( blockIncludeTracks );
|
|
|
|
m_Include_Zones->SetValue( blockIncludeZones );
|
|
|
|
m_Include_Draw_Items->SetValue( blockIncludeItemsOnTechLayers );
|
|
|
|
m_Include_Edges_Items->SetValue( blockIncludeBoardOutlineLayer );
|
|
|
|
m_Include_PcbTextes->SetValue( blockIncludePcbTexts );
|
|
|
|
m_DrawBlockItems->SetValue( blockDrawItems );
|
2011-03-07 12:28:14 +00:00
|
|
|
m_checkBoxIncludeInvisible->SetValue( blockIncludeItemsOnInvisibleLayers );
|
2011-01-06 16:55:18 +00:00
|
|
|
m_sdbSizer1OK->SetDefault();
|
2010-11-12 18:38:48 +00:00
|
|
|
SetFocus();
|
|
|
|
GetSizer()->SetSizeHints( this );
|
|
|
|
Centre();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-11-12 18:38:48 +00:00
|
|
|
void DIALOG_BLOCK_OPTIONS::ExecuteCommand( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2010-11-13 11:02:24 +00:00
|
|
|
blockIncludeModules = m_Include_Modules->GetValue();
|
|
|
|
blockIncludeLockedModules = m_IncludeLockedModules->GetValue();
|
|
|
|
blockIncludeTracks = m_Include_Tracks->GetValue();
|
|
|
|
blockIncludeZones = m_Include_Zones->GetValue();
|
|
|
|
blockIncludeItemsOnTechLayers = m_Include_Draw_Items->GetValue();
|
|
|
|
blockIncludeBoardOutlineLayer = m_Include_Edges_Items->GetValue();
|
|
|
|
blockIncludePcbTexts = m_Include_PcbTextes->GetValue();
|
|
|
|
blockDrawItems = m_DrawBlockItems->GetValue();
|
2011-03-07 12:28:14 +00:00
|
|
|
blockIncludeItemsOnInvisibleLayers = m_checkBoxIncludeInvisible->GetValue();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-11-26 20:02:59 +00:00
|
|
|
EndModal( wxID_OK );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-20 12:11:17 +00:00
|
|
|
int PCB_EDIT_FRAME::BlockCommand( EDA_KEY aKey )
|
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
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
switch( aKey )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
default:
|
2014-09-24 16:42:56 +00:00
|
|
|
cmd = aKey & 0xFF;
|
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 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
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2014-09-24 16:42:56 +00:00
|
|
|
GetBoard()->m_Status_Pcb &= ~DO_NOT_SHOW_GENERAL_RASTNEST;
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
if( !m_canvas->IsMouseCaptured() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-02-11 20:48:13 +00:00
|
|
|
DisplayError( this, wxT( "Error in HandleBlockPLace : m_mouseCaptureCallback = NULL" ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_STOP );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2015-03-22 09:42:41 +00:00
|
|
|
const BLOCK_COMMAND_T command = GetScreen()->m_BlockLocate.GetCommand();
|
|
|
|
|
|
|
|
switch( 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
|
|
|
break;
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
case BLOCK_DRAG: // Drag
|
|
|
|
case BLOCK_MOVE: // Move
|
|
|
|
case BLOCK_PRESELECT_MOVE: // Move with preselection list
|
2011-12-22 13:28:11 +00:00
|
|
|
if( m_canvas->IsMouseCaptured() )
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
2011-02-11 20:48:13 +00:00
|
|
|
|
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;
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
case BLOCK_COPY: // Copy
|
2015-03-22 09:42:41 +00:00
|
|
|
case BLOCK_COPY_AND_INCREMENT:
|
2011-12-22 13:28:11 +00:00
|
|
|
if( m_canvas->IsMouseCaptured() )
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2015-03-22 09:42:41 +00:00
|
|
|
Block_Duplicate( command == BLOCK_COPY_AND_INCREMENT );
|
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
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString, false );
|
2011-02-11 20:48:13 +00:00
|
|
|
GetScreen()->ClearBlockCommand();
|
|
|
|
|
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
|
|
|
DisplayError( this, wxT( "Error in HandleBlockPLace some items left in list" ) );
|
|
|
|
GetScreen()->m_BlockLocate.ClearItemsList();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
bool PCB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2011-01-05 17:28:55 +00:00
|
|
|
bool nextcmd = false; // Will be set to true if a block place is needed
|
2010-11-13 11:02:24 +00:00
|
|
|
bool cancelCmd = false;
|
2010-11-11 21:46:55 +00:00
|
|
|
// If coming here after cancel block, clean up and exit
|
2012-03-26 23:47:08 +00:00
|
|
|
if( GetScreen()->m_BlockLocate.GetState() == STATE_NO_BLOCK )
|
2010-11-11 21:46:55 +00:00
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString,
|
|
|
|
false );
|
2011-02-11 20:48:13 +00:00
|
|
|
GetScreen()->ClearBlockCommand();
|
2010-11-13 11:02:24 +00:00
|
|
|
return false;
|
2010-11-11 21:46:55 +00:00
|
|
|
}
|
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
// Show dialog if there are no selected items and we're not zooming
|
2010-11-12 18:38:48 +00:00
|
|
|
if( !GetScreen()->m_BlockLocate.GetCount()
|
2012-03-26 23:47:08 +00:00
|
|
|
&& GetScreen()->m_BlockLocate.GetCommand() != BLOCK_ZOOM )
|
2010-11-11 21:46:55 +00:00
|
|
|
{
|
2011-11-26 20:02:59 +00:00
|
|
|
if( InstallBlockCmdFrame( this, _( "Block Operation" ) ) == false )
|
2010-11-11 21:46:55 +00:00
|
|
|
{
|
2010-11-13 11:02:24 +00:00
|
|
|
cancelCmd = true;
|
2011-02-03 19:27:28 +00:00
|
|
|
|
|
|
|
// undraw block outline
|
2015-07-19 09:18:07 +00:00
|
|
|
if( DC )
|
|
|
|
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
2010-11-11 21:46:55 +00:00
|
|
|
}
|
2010-11-13 11:02:24 +00:00
|
|
|
else
|
2010-11-12 18:38:48 +00:00
|
|
|
{
|
2011-12-22 13:28:11 +00:00
|
|
|
DrawAndSizingBlockOutlines( m_canvas, DC, wxDefaultPosition, false );
|
2010-11-13 11:02:24 +00:00
|
|
|
Block_SelectItems();
|
2010-11-12 17:33:20 +00:00
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
// Exit if no items found
|
|
|
|
if( !GetScreen()->m_BlockLocate.GetCount() )
|
|
|
|
cancelCmd = true;
|
2010-11-11 21:46:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
if( !cancelCmd && m_canvas->IsMouseCaptured() )
|
2010-11-13 11:02:24 +00:00
|
|
|
{
|
2012-03-26 23:47:08 +00:00
|
|
|
switch( GetScreen()->m_BlockLocate.GetCommand() )
|
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;
|
|
|
|
|
2015-03-22 09:42:41 +00:00
|
|
|
case BLOCK_DRAG: // Drag (not used, for future enhancements)
|
|
|
|
case BLOCK_MOVE: // Move
|
|
|
|
case BLOCK_COPY: // Copy
|
|
|
|
case BLOCK_COPY_AND_INCREMENT: // Copy and increment relevant references
|
|
|
|
case BLOCK_PRESELECT_MOVE: // Move with preselection list
|
2012-03-26 23:47:08 +00:00
|
|
|
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_MOVE );
|
2010-11-13 11:02:24 +00:00
|
|
|
nextcmd = true;
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetMouseCaptureCallback( drawMovingBlock );
|
2015-07-19 09:18:07 +00:00
|
|
|
if( DC )
|
|
|
|
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
case BLOCK_DELETE: // Delete
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetMouseCaptureCallback( NULL );
|
2012-03-26 23:47:08 +00:00
|
|
|
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_STOP );
|
2009-08-01 19:26:05 +00:00
|
|
|
Block_Delete();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
case BLOCK_ROTATE: // Rotation
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetMouseCaptureCallback( NULL );
|
2012-03-26 23:47:08 +00:00
|
|
|
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_STOP );
|
2009-08-01 19:26:05 +00:00
|
|
|
Block_Rotate();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
case BLOCK_FLIP: // Flip
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetMouseCaptureCallback( NULL );
|
2012-03-26 23:47:08 +00:00
|
|
|
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_STOP );
|
2009-08-01 19:26:05 +00:00
|
|
|
Block_Flip();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
case BLOCK_SAVE: // Save (not used, for future enhancements)
|
2012-03-26 23:47:08 +00:00
|
|
|
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_STOP );
|
|
|
|
|
2009-07-25 04:53:39 +00:00
|
|
|
if( GetScreen()->m_BlockLocate.GetCount() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2010-11-12 17:33:20 +00:00
|
|
|
// @todo (if useful) Save_Block( );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_PASTE:
|
|
|
|
break;
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
case BLOCK_ZOOM: // Window Zoom
|
2007-08-20 01:20:48 +00:00
|
|
|
|
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
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetMouseCaptureCallback( 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;
|
|
|
|
}
|
2010-11-13 11:02:24 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
if( ! nextcmd )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2014-09-24 16:42:56 +00:00
|
|
|
GetBoard()->m_Status_Pcb |= DO_NOT_SHOW_GENERAL_RASTNEST;
|
2011-02-11 20:48:13 +00:00
|
|
|
GetScreen()->ClearBlockCommand();
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString,
|
|
|
|
false );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
return nextcmd;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::Block_SelectItems()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET layerMask;
|
2013-09-21 18:09:41 +00:00
|
|
|
bool selectOnlyComplete = GetScreen()->m_BlockLocate.GetWidth() > 0 ;
|
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
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.GetItems();
|
2009-08-01 19:26:05 +00:00
|
|
|
ITEM_PICKER picker( NULL, UR_UNSPECIFIED );
|
2009-07-31 05:33:11 +00:00
|
|
|
|
2011-03-05 22:12:32 +00:00
|
|
|
// Add modules
|
2010-11-13 11:02:24 +00:00
|
|
|
if( blockIncludeModules )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
for( MODULE* module = m_Pcb->m_Modules; module; module = module->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
LAYER_ID layer = module->GetLayer();
|
2011-03-05 22:12:32 +00:00
|
|
|
|
2013-09-21 18:09:41 +00:00
|
|
|
if( module->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete )
|
2011-03-07 12:28:14 +00:00
|
|
|
&& ( !module->IsLocked() || blockIncludeLockedModules ) )
|
2008-04-01 05:21:50 +00:00
|
|
|
{
|
2011-03-07 12:28:14 +00:00
|
|
|
if( blockIncludeItemsOnInvisibleLayers || m_Pcb->IsModuleLayerVisible( layer ) )
|
|
|
|
{
|
2012-02-05 13:02:46 +00:00
|
|
|
picker.SetItem ( module );
|
2011-03-07 12:28:14 +00:00
|
|
|
itemsList->PushItem( picker );
|
|
|
|
}
|
2008-04-01 05:21:50 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-05 22:12:32 +00:00
|
|
|
// Add tracks and vias
|
2010-11-13 11:02:24 +00:00
|
|
|
if( blockIncludeTracks )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2013-09-21 18:09:41 +00:00
|
|
|
for( TRACK* track = m_Pcb->m_Track; track != NULL; track = track->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2013-09-21 18:09:41 +00:00
|
|
|
if( track->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete ) )
|
2008-04-01 05:21:50 +00:00
|
|
|
{
|
2011-09-23 13:57:12 +00:00
|
|
|
if( blockIncludeItemsOnInvisibleLayers
|
2013-09-21 18:09:41 +00:00
|
|
|
|| m_Pcb->IsLayerVisible( track->GetLayer() ) )
|
2011-03-07 12:28:14 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
picker.SetItem( track );
|
2011-03-07 12:28:14 +00:00
|
|
|
itemsList->PushItem( picker );
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-05 22:12:32 +00:00
|
|
|
// Add graphic items
|
2014-06-24 16:17:18 +00:00
|
|
|
layerMask = LSET( Edge_Cuts );
|
2011-03-05 22:12:32 +00:00
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
if( blockIncludeItemsOnTechLayers )
|
2014-06-24 16:17:18 +00:00
|
|
|
layerMask.set();
|
2008-04-01 05:21:50 +00:00
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
if( !blockIncludeBoardOutlineLayer )
|
2014-06-24 16:17:18 +00:00
|
|
|
layerMask.set( Edge_Cuts, false );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
for( BOARD_ITEM* PtStruct = m_Pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-03-07 12:28:14 +00:00
|
|
|
if( !m_Pcb->IsLayerVisible( PtStruct->GetLayer() ) && ! blockIncludeItemsOnInvisibleLayers)
|
2011-03-05 22:12:32 +00:00
|
|
|
continue;
|
2012-03-26 23:47:08 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
bool select_me = false;
|
2012-03-26 23:47:08 +00:00
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( PtStruct->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_LINE_T:
|
2014-06-24 16:17:18 +00:00
|
|
|
if( !layerMask[PtStruct->GetLayer()] )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2011-03-05 22:12:32 +00:00
|
|
|
|
2013-09-21 18:09:41 +00:00
|
|
|
if( !PtStruct->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2011-09-23 13:57:12 +00:00
|
|
|
|
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;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TEXT_T:
|
2010-11-13 11:02:24 +00:00
|
|
|
if( !blockIncludePcbTexts )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2011-03-05 22:12:32 +00:00
|
|
|
|
2013-09-21 18:09:41 +00:00
|
|
|
if( !PtStruct->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2011-09-23 13:57:12 +00:00
|
|
|
|
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;
|
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
case PCB_TARGET_T:
|
2014-06-24 16:17:18 +00:00
|
|
|
if( !layerMask[PtStruct->GetLayer()] )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2011-03-05 22:12:32 +00:00
|
|
|
|
2013-09-21 18:09:41 +00:00
|
|
|
if( !PtStruct->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
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;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_DIMENSION_T:
|
2014-06-24 16:17:18 +00:00
|
|
|
if( !layerMask[PtStruct->GetLayer()] )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2011-03-05 22:12:32 +00:00
|
|
|
|
2013-09-21 18:09:41 +00:00
|
|
|
if( !PtStruct->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
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
|
|
|
{
|
2012-02-05 13:02:46 +00:00
|
|
|
picker.SetItem ( PtStruct );
|
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
|
|
|
}
|
|
|
|
|
2011-03-05 22:12:32 +00:00
|
|
|
// Add zones
|
2010-11-13 11:02:24 +00:00
|
|
|
if( blockIncludeZones )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
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
|
|
|
{
|
2011-03-05 22:12:32 +00:00
|
|
|
ZONE_CONTAINER* area = m_Pcb->GetArea( ii );
|
|
|
|
|
2013-09-21 18:09:41 +00:00
|
|
|
if( area->HitTest( GetScreen()->m_BlockLocate, selectOnlyComplete ) )
|
2008-04-01 05:21:50 +00:00
|
|
|
{
|
2011-09-23 13:57:12 +00:00
|
|
|
if( blockIncludeItemsOnInvisibleLayers
|
|
|
|
|| m_Pcb->IsLayerVisible( area->GetLayer() ) )
|
2011-03-07 12:28:14 +00:00
|
|
|
{
|
|
|
|
BOARD_ITEM* zone_c = (BOARD_ITEM*) area;
|
2012-02-05 13:02:46 +00:00
|
|
|
picker.SetItem ( zone_c );
|
2011-03-07 12:28:14 +00:00
|
|
|
itemsList->PushItem( picker );
|
|
|
|
}
|
2008-04-01 05:21:50 +00:00
|
|
|
}
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2010-11-12 17:33:20 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-11-12 18:38:48 +00:00
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
static void drawPickedItems( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPoint aOffset )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2012-03-26 23:47:08 +00:00
|
|
|
PICKED_ITEMS_LIST* itemsList = &aPanel->GetScreen()->m_BlockLocate.GetItems();
|
2011-03-01 19:26:17 +00:00
|
|
|
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) aPanel->GetParent();
|
2010-11-12 17:33:20 +00:00
|
|
|
|
2010-11-12 18:38:48 +00:00
|
|
|
g_Offset_Module = -aOffset;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-11-11 21:46:55 +00:00
|
|
|
for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
|
|
|
|
{
|
|
|
|
BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-11-11 21:46:55 +00:00
|
|
|
switch( item->Type() )
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_T:
|
2010-11-11 21:46:55 +00:00
|
|
|
frame->GetBoard()->m_Status_Pcb &= ~RATSNEST_ITEM_LOCAL_OK;
|
2015-01-19 08:23:10 +00:00
|
|
|
((MODULE*) item)->DrawOutlinesWhenMoving( aPanel, aDC, g_Offset_Module );
|
2010-11-11 21:46:55 +00:00
|
|
|
break;
|
2010-11-12 18:38:48 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_LINE_T:
|
|
|
|
case PCB_TEXT_T:
|
|
|
|
case PCB_TRACE_T:
|
|
|
|
case PCB_VIA_T:
|
2011-09-07 19:41:04 +00:00
|
|
|
case PCB_TARGET_T:
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_DIMENSION_T: // Currently markers are not affected by block commands
|
|
|
|
case PCB_MARKER_T:
|
2010-11-13 11:02:24 +00:00
|
|
|
item->Draw( aPanel, aDC, GR_XOR, aOffset );
|
2010-11-11 21:46:55 +00:00
|
|
|
break;
|
2010-11-12 18:38:48 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_ZONE_AREA_T:
|
2010-11-13 11:02:24 +00:00
|
|
|
item->Draw( aPanel, aDC, GR_XOR, aOffset );
|
|
|
|
((ZONE_CONTAINER*) item)->DrawFilledArea( aPanel, aDC, GR_XOR, aOffset );
|
2010-11-11 21:46:55 +00:00
|
|
|
break;
|
2010-11-12 15:43:26 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2010-11-11 21:46:55 +00:00
|
|
|
}
|
|
|
|
}
|
2010-11-12 18:38:48 +00:00
|
|
|
|
2010-11-11 21:46:55 +00:00
|
|
|
g_Offset_Module = wxPoint( 0, 0 );
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-11-12 18:38:48 +00:00
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
static void drawMovingBlock( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
|
|
|
bool aErase )
|
2010-11-11 21:46:55 +00:00
|
|
|
{
|
|
|
|
BASE_SCREEN* screen = aPanel->GetScreen();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2014-09-24 16:42:56 +00:00
|
|
|
// do not show local module rastnest in block move, it is not usable.
|
2015-01-10 10:27:49 +00:00
|
|
|
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)aPanel->GetDisplayOptions();
|
|
|
|
bool showRats = displ_opts->m_Show_Module_Ratsnest;
|
|
|
|
displ_opts->m_Show_Module_Ratsnest = false;
|
2014-09-24 16:42:56 +00:00
|
|
|
|
2010-11-11 21:46:55 +00:00
|
|
|
if( aErase )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-03-26 23:47:08 +00:00
|
|
|
if( screen->m_BlockLocate.GetMoveVector().x || screen->m_BlockLocate.GetMoveVector().y )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-03-26 23:47:08 +00:00
|
|
|
screen->m_BlockLocate.Draw( aPanel, aDC, screen->m_BlockLocate.GetMoveVector(),
|
2010-11-12 18:38:48 +00:00
|
|
|
GR_XOR, BLOCK_OUTLINE_COLOR );
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
if( blockDrawItems )
|
2012-03-26 23:47:08 +00:00
|
|
|
drawPickedItems( aPanel, aDC, screen->m_BlockLocate.GetMoveVector() );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
|
|
|
|
if( screen->m_BlockLocate.GetState() != STATE_BLOCK_STOP )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
screen->m_BlockLocate.SetMoveVector( aPanel->GetParent()->GetCrossHairPosition() -
|
2012-03-26 23:47:08 +00:00
|
|
|
screen->m_BlockLocate.GetLastCursorPosition() );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
if( screen->m_BlockLocate.GetMoveVector().x || screen->m_BlockLocate.GetMoveVector().y )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-03-26 23:47:08 +00:00
|
|
|
screen->m_BlockLocate.Draw( aPanel, aDC, screen->m_BlockLocate.GetMoveVector(),
|
2010-11-12 18:38:48 +00:00
|
|
|
GR_XOR, BLOCK_OUTLINE_COLOR );
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2010-11-13 11:02:24 +00:00
|
|
|
if( blockDrawItems )
|
2012-03-26 23:47:08 +00:00
|
|
|
drawPickedItems( aPanel, aDC, screen->m_BlockLocate.GetMoveVector() );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2014-09-24 16:42:56 +00:00
|
|
|
|
2015-01-10 10:27:49 +00:00
|
|
|
displ_opts->m_Show_Module_Ratsnest = showRats;
|
2009-08-01 19:26:05 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::Block_Delete()
|
2009-08-01 19:26:05 +00:00
|
|
|
{
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2009-08-01 19:26:05 +00:00
|
|
|
SetCurItem( NULL );
|
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.GetItems();
|
2009-08-01 19:26:05 +00:00
|
|
|
itemsList->m_Status = UR_DELETED;
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
// unlink items and clear flags
|
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_DELETED, ii );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_T:
|
2009-08-01 19:26:05 +00:00
|
|
|
{
|
|
|
|
MODULE* module = (MODULE*) item;
|
2011-12-21 13:42:02 +00:00
|
|
|
module->ClearFlags();
|
2009-08-01 19:26:05 +00:00
|
|
|
module->UnLink();
|
|
|
|
m_Pcb->m_Status_Pcb = 0;
|
|
|
|
}
|
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_ZONE_AREA_T: // a zone area
|
2009-08-01 19:26:05 +00:00
|
|
|
m_Pcb->Remove( item );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_LINE_T: // a segment not on copper layers
|
|
|
|
case PCB_TEXT_T: // a text on a layer
|
|
|
|
case PCB_TRACE_T: // a track segment (segment on a copper layer)
|
2011-11-10 15:55:05 +00:00
|
|
|
case PCB_VIA_T: // a via (like track segment on a copper layer)
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_DIMENSION_T: // a dimension (graphic item)
|
|
|
|
case PCB_TARGET_T: // 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
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MARKER_T: // a marker used to show something
|
|
|
|
case PCB_ZONE_T: // 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:
|
2011-03-01 19:26:17 +00:00
|
|
|
wxMessageBox( wxT( "PCB_EDIT_FRAME::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 );
|
|
|
|
|
2010-11-12 18:38:48 +00:00
|
|
|
Compile_Ratsnest( NULL, true );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh( true );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::Block_Rotate()
|
2008-01-06 12:43:57 +00:00
|
|
|
{
|
2014-03-07 22:34:54 +00:00
|
|
|
wxPoint centre; // rotation cent-re for the rotation transform
|
|
|
|
int rotAngle = m_rotationAngle; // rotation angle in 0.1 deg.
|
2007-08-20 01:20:48 +00:00
|
|
|
|
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
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.GetItems();
|
2014-03-07 22:34:54 +00:00
|
|
|
itemsList->m_Status = UR_CHANGED;
|
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 );
|
2010-11-12 18:38:48 +00:00
|
|
|
wxASSERT( item );
|
2014-03-07 22:34:54 +00:00
|
|
|
itemsList->SetPickedItemStatus( UR_CHANGED, ii );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_T:
|
2011-12-21 13:42:02 +00:00
|
|
|
( (MODULE*) item )->ClearFlags();
|
2007-08-20 01:20:48 +00:00
|
|
|
m_Pcb->m_Status_Pcb = 0;
|
2010-11-12 18:38:48 +00:00
|
|
|
break;
|
2009-08-01 19:26:05 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
// Move and rotate the track segments
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TRACE_T: // a track segment (segment on a copper layer)
|
2011-11-10 15:55:05 +00:00
|
|
|
case PCB_VIA_T: // a via (like track segment on a copper layer)
|
2009-08-01 19:26:05 +00:00
|
|
|
m_Pcb->m_Status_Pcb = 0;
|
2010-11-12 18:38:48 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_ZONE_AREA_T:
|
|
|
|
case PCB_LINE_T:
|
|
|
|
case PCB_TEXT_T:
|
2011-09-07 19:41:04 +00:00
|
|
|
case PCB_TARGET_T:
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_DIMENSION_T:
|
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
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_ZONE_T: // 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:
|
2011-03-01 19:26:17 +00:00
|
|
|
wxMessageBox( wxT( "PCB_EDIT_FRAME::Block_Rotate( ) error: unexpected type" ) );
|
2009-08-01 19:26:05 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-07 22:34:54 +00:00
|
|
|
// Save all the block items in there current state before applying the rotation.
|
|
|
|
SaveCopyInUndoList( *itemsList, UR_CHANGED, centre );
|
|
|
|
|
|
|
|
// Now perform the rotation.
|
|
|
|
for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
|
|
|
|
{
|
|
|
|
BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
|
|
|
|
wxASSERT( item );
|
|
|
|
item->Rotate( centre, rotAngle );
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-11-12 18:38:48 +00:00
|
|
|
Compile_Ratsnest( NULL, true );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh( true );
|
2009-08-01 19:26:05 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::Block_Flip()
|
2009-08-01 19:26:05 +00:00
|
|
|
{
|
|
|
|
#define INVERT( pos ) (pos) = center.y - ( (pos) - center.y )
|
2013-08-03 05:15:23 +00:00
|
|
|
wxPoint center; // Position of the axis for inversion of all elements
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2009-08-01 19:26:05 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.GetItems();
|
2009-08-01 19:26:05 +00:00
|
|
|
itemsList->m_Status = UR_FLIPPED;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
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 );
|
2010-11-12 18:38:48 +00:00
|
|
|
wxASSERT( item );
|
2009-08-01 19:26:05 +00:00
|
|
|
itemsList->SetPickedItemStatus( UR_FLIPPED, ii );
|
2010-11-12 18:38:48 +00:00
|
|
|
item->Flip( center );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2015-12-27 15:51:13 +00:00
|
|
|
// If a connected item is flipped, the ratsnest is no more OK
|
2009-08-01 19:26:05 +00:00
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_T:
|
2011-12-21 13:42:02 +00:00
|
|
|
item->ClearFlags();
|
2009-08-01 19:26:05 +00:00
|
|
|
m_Pcb->m_Status_Pcb = 0;
|
2010-11-12 18:38:48 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2015-12-27 15:51:13 +00:00
|
|
|
case PCB_TRACE_T:
|
|
|
|
case PCB_VIA_T:
|
2009-08-01 19:26:05 +00:00
|
|
|
m_Pcb->m_Status_Pcb = 0;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_ZONE_AREA_T:
|
|
|
|
case PCB_LINE_T:
|
|
|
|
case PCB_TEXT_T:
|
2011-09-07 19:41:04 +00:00
|
|
|
case PCB_TARGET_T:
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_DIMENSION_T:
|
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
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_ZONE_T: // 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:
|
2011-03-01 19:26:17 +00:00
|
|
|
wxMessageBox( wxT( "PCB_EDIT_FRAME::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 );
|
2010-11-12 18:38:48 +00:00
|
|
|
Compile_Ratsnest( NULL, true );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh( true );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::Block_Move()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
wxPoint MoveVector = GetScreen()->m_BlockLocate.GetMoveVector();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.GetItems();
|
2009-08-01 19:26:05 +00:00
|
|
|
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 );
|
2014-09-24 16:42:56 +00:00
|
|
|
item->ClearFlags( IS_MOVED );
|
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
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_T:
|
2010-11-12 18:38:48 +00:00
|
|
|
m_Pcb->m_Status_Pcb = 0;
|
2011-12-21 13:42:02 +00:00
|
|
|
item->ClearFlags();
|
2010-11-12 18:38:48 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
// Move track segments
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TRACE_T: // a track segment (segment on a copper layer)
|
|
|
|
case PCB_VIA_T: // a via (like a track segment on a copper layer)
|
2009-08-01 19:26:05 +00:00
|
|
|
m_Pcb->m_Status_Pcb = 0;
|
2010-11-12 18:38:48 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_ZONE_AREA_T:
|
|
|
|
case PCB_LINE_T:
|
|
|
|
case PCB_TEXT_T:
|
2011-09-07 19:41:04 +00:00
|
|
|
case PCB_TARGET_T:
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_DIMENSION_T:
|
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
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_ZONE_T: // 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:
|
2011-03-01 19:26:17 +00:00
|
|
|
wxMessageBox( wxT( "PCB_EDIT_FRAME::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 );
|
|
|
|
|
2010-11-12 18:38:48 +00:00
|
|
|
Compile_Ratsnest( NULL, true );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh( true );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-22 09:42:41 +00:00
|
|
|
void PCB_EDIT_FRAME::Block_Duplicate( bool aIncrement )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2012-03-26 23:47:08 +00:00
|
|
|
wxPoint MoveVector = GetScreen()->m_BlockLocate.GetMoveVector();
|
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
|
|
|
|
2012-03-26 23:47:08 +00:00
|
|
|
PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.GetItems();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-01-14 19:50:32 +00:00
|
|
|
PICKED_ITEMS_LIST newList;
|
2009-08-01 19:26:05 +00:00
|
|
|
newList.m_Status = UR_NEW;
|
|
|
|
|
2012-01-14 19:50:32 +00:00
|
|
|
ITEM_PICKER picker( NULL, UR_NEW );
|
|
|
|
BOARD_ITEM* newitem;
|
2009-08-01 19:26:05 +00:00
|
|
|
|
|
|
|
for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
|
|
|
|
{
|
|
|
|
BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-01-14 19:50:32 +00:00
|
|
|
newitem = (BOARD_ITEM*)item->Clone();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2015-03-22 09:42:41 +00:00
|
|
|
if( aIncrement )
|
|
|
|
newitem->IncrementItemReference();
|
|
|
|
|
2012-01-14 19:50:32 +00:00
|
|
|
if( item->Type() == PCB_MODULE_T )
|
|
|
|
m_Pcb->m_Status_Pcb = 0;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-01-14 19:50:32 +00:00
|
|
|
m_Pcb->Add( newitem );
|
2009-08-01 19:26:05 +00:00
|
|
|
|
2010-11-12 17:33:20 +00:00
|
|
|
if( newitem )
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
|
|
|
newitem->Move( MoveVector );
|
2012-02-05 13:02:46 +00:00
|
|
|
picker.SetItem ( newitem );
|
2011-09-07 19:41:04 +00:00
|
|
|
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
|
|
|
|
2010-11-12 18:38:48 +00:00
|
|
|
Compile_Ratsnest( NULL, true );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh( true );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|