Retire legacy block architecture.

This commit is contained in:
Jeff Young 2019-05-27 10:06:34 +01:00
parent 927d2a645c
commit e9e28b9aac
36 changed files with 27 additions and 2689 deletions

View File

@ -71,13 +71,11 @@ set( GAL_SRCS
) )
set( LEGACY_GAL_SRCS set( LEGACY_GAL_SRCS
legacy_gal/block.cpp
legacy_gal/eda_draw_frame.cpp legacy_gal/eda_draw_frame.cpp
legacy_gal/other.cpp legacy_gal/other.cpp
) )
set( LEGACY_WX_SRCS set( LEGACY_WX_SRCS
legacy_wx/block.cpp
legacy_wx/eda_draw_frame.cpp legacy_wx/eda_draw_frame.cpp
legacy_wx/eda_draw_panel.cpp legacy_wx/eda_draw_panel.cpp
legacy_wx/other.cpp legacy_wx/other.cpp

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -23,7 +23,6 @@
*/ */
/** /**
* @file base_struct.cpp
* @brief Implementation of EDA_ITEM base class for KiCad. * @brief Implementation of EDA_ITEM base class for KiCad.
*/ */
@ -36,6 +35,7 @@
#include <base_screen.h> #include <base_screen.h>
#include <bitmaps.h> #include <bitmaps.h>
#include <trace_helpers.h> #include <trace_helpers.h>
#include <eda_rect.h>
#include "../eeschema/dialogs/dialog_schematic_find.h" #include "../eeschema/dialogs/dialog_schematic_find.h"

View File

@ -305,22 +305,6 @@ void GRLine( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, int aW
} }
void GRDashedLine( EDA_RECT* ClipBox, wxDC* DC,
int x1, int y1, int x2, int y2,
int width, COLOR4D Color )
{
GRLine( ClipBox, DC, x1, y1, x2, y2, width, Color, wxPENSTYLE_SHORT_DASH );
}
void GRDottedLine( EDA_RECT* ClipBox, wxDC* DC,
int x1, int y1, int x2, int y2,
int width, COLOR4D Color )
{
GRLine( ClipBox, DC, x1, y1, x2, y2, width, Color, wxPENSTYLE_DOT );
}
/* /*
* Move to a new position, in object space. * Move to a new position, in object space.
*/ */
@ -340,12 +324,6 @@ void GRLineTo( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int width, COLOR4D Col
} }
void GRMixedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, COLOR4D Color )
{
GRLine( ClipBox, DC, x1, y1, x2, y2, width, Color, wxPENSTYLE_DOT_DASH );
}
/** /**

View File

@ -1,60 +0,0 @@
/**
* OBSOLETE
*/
#include <fctsys.h>
#include <gr_basic.h>
#include <draw_frame.h>
#include <common.h>
#include <macros.h>
#include <block_commande.h>
BLOCK_SELECTOR::BLOCK_SELECTOR() :
EDA_RECT()
{
m_state = STATE_NO_BLOCK; // State (enum BLOCK_STATE_T) of block.
m_command = BLOCK_IDLE; // Type (enum BLOCK_COMMAND_T) of operation.
}
BLOCK_SELECTOR::~BLOCK_SELECTOR()
{
}
void BLOCK_SELECTOR::SetMessageBlock( EDA_DRAW_FRAME* frame )
{
}
void BLOCK_SELECTOR::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
}
void BLOCK_SELECTOR::InitData( EDA_DRAW_PANEL* aPanel, const wxPoint& startpos )
{
}
void BLOCK_SELECTOR::ClearItemsList()
{
}
void BLOCK_SELECTOR::ClearListAndDeleteItems()
{
}
void BLOCK_SELECTOR::PushItem( ITEM_PICKER& aItem )
{
}
void BLOCK_SELECTOR::Clear()
{
}

View File

@ -500,39 +500,6 @@ void EDA_DRAW_FRAME::SetPresetGrid( int aIndex )
} }
int EDA_DRAW_FRAME::BlockCommand( EDA_KEY key )
{
wxFAIL_MSG( "Obsolete; how'd we get here?" );
return 0;
}
void EDA_DRAW_FRAME::InitBlockPasteInfos()
{
wxFAIL_MSG( "Obsolete; how'd we get here?" );
}
bool EDA_DRAW_FRAME::HandleBlockBegin( wxDC* , EDA_KEY , const wxPoint& , int )
{
wxFAIL_MSG( "Obsolete; how'd we get here?" );
return false;
}
void EDA_DRAW_FRAME::HandleBlockPlace( wxDC* DC )
{
wxFAIL_MSG( "Obsolete; how'd we get here?" );
}
bool EDA_DRAW_FRAME::HandleBlockEnd( wxDC* DC )
{
wxFAIL_MSG( "Obsolete; how'd we get here?" );
return false;
}
void EDA_DRAW_FRAME::UpdateStatusBar() void EDA_DRAW_FRAME::UpdateStatusBar()
{ {
SetStatusText( GetZoomLevelIndicator(), 1 ); SetStatusText( GetZoomLevelIndicator(), 1 );
@ -1065,16 +1032,7 @@ bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame )
wxRect DrawArea; wxRect DrawArea;
BASE_SCREEN* screen = aFrame->GetCanvas()->GetScreen(); BASE_SCREEN* screen = aFrame->GetCanvas()->GetScreen();
if( screen->IsBlockActive() ) DrawArea.SetSize( aFrame->GetPageSizeIU() );
{
DrawBlock = true;
DrawArea.SetX( screen->m_BlockLocate.GetX() );
DrawArea.SetY( screen->m_BlockLocate.GetY() );
DrawArea.SetWidth( screen->m_BlockLocate.GetWidth() );
DrawArea.SetHeight( screen->m_BlockLocate.GetHeight() );
}
else
DrawArea.SetSize( aFrame->GetPageSizeIU() );
// Calculate a reasonable dc size, in pixels, and the dc scale to fit // Calculate a reasonable dc size, in pixels, and the dc scale to fit
// the drawings into the dc size // the drawings into the dc size

View File

@ -1,223 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2004-2011 KiCad Developers, see change_log.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
*/
/**
* @file block_commande.cpp
* @brief Common routines for managing on block commands.
*/
#include <fctsys.h>
#include <gr_basic.h>
#include <draw_frame.h>
#include <common.h>
#include <macros.h>
#include <base_struct.h>
#include <base_screen.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <block_commande.h>
BLOCK_SELECTOR::BLOCK_SELECTOR() :
EDA_RECT()
{
m_state = STATE_NO_BLOCK; // State (enum BLOCK_STATE_T) of block.
m_command = BLOCK_IDLE; // Type (enum BLOCK_COMMAND_T) of operation.
m_color = BROWN;
m_appendUndo = false;
}
BLOCK_SELECTOR::~BLOCK_SELECTOR()
{
ClearListAndDeleteItems();
}
void BLOCK_SELECTOR::SetMessageBlock( EDA_DRAW_FRAME* frame )
{
wxString msg;
switch( m_command )
{
case BLOCK_IDLE:
break;
case BLOCK_MOVE: // Move
case BLOCK_PRESELECT_MOVE: // Move with preselection list
case BLOCK_MOVE_EXACT:
msg = _( "Block Move" );
break;
case BLOCK_DRAG: // Drag
msg = _( "Block Drag" );
break;
case BLOCK_DRAG_ITEM: // Drag
msg = _( "Drag item" );
break;
case BLOCK_DUPLICATE: // Duplicate
msg = _( "Block Duplicate" );
break;
case BLOCK_DELETE: // Delete
msg = _( "Block Delete" );
break;
case BLOCK_COPY: // Copy
msg = _( "Block Copy" );
break;
case BLOCK_PASTE:
msg = _( "Block Paste" );
break;
case BLOCK_ZOOM: // Window Zoom
msg = _( "Zoom to selection" );
break;
case BLOCK_FLIP: // Flip
msg = _( "Block Flip" );
break;
case BLOCK_ABORT:
break;
default:
msg = wxT( "???" );
break;
}
frame->DisplayToolMsg( msg );
}
void BLOCK_SELECTOR::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, COLOR4D aColor )
{
if( !aDC )
return;
int w = GetWidth();
int h = GetHeight();
GRSetDrawMode( aDC, aDrawMode );
if( w == 0 || h == 0 )
GRLine( aPanel->GetClipBox(), aDC, GetX() + aOffset.x, GetY() + aOffset.y,
GetRight() + aOffset.x, GetBottom() + aOffset.y, 0, aColor );
else
GRRect( aPanel->GetClipBox(), aDC, GetX() + aOffset.x, GetY() + aOffset.y,
GetRight() + aOffset.x, GetBottom() + aOffset.y, 0, aColor );
}
void BLOCK_SELECTOR::InitData( EDA_DRAW_PANEL* aPanel, const wxPoint& startpos )
{
m_state = STATE_BLOCK_INIT;
SetOrigin( startpos );
SetSize( wxSize( 0, 0 ) );
m_items.ClearItemsList();
aPanel->SetMouseCapture( DrawAndSizingBlockOutlines, AbortBlockCurrentCommand );
}
void BLOCK_SELECTOR::ClearItemsList()
{
m_items.ClearItemsList();
}
void BLOCK_SELECTOR::ClearListAndDeleteItems()
{
m_items.ClearListAndDeleteItems();
}
void BLOCK_SELECTOR::PushItem( ITEM_PICKER& aItem )
{
m_items.PushItem( aItem );
}
void BLOCK_SELECTOR::Clear()
{
if( m_command != BLOCK_IDLE )
{
m_command = BLOCK_IDLE;
m_state = STATE_NO_BLOCK;
ClearItemsList();
}
}
void DrawAndSizingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase )
{
BLOCK_SELECTOR* block = &aPanel->GetScreen()->m_BlockLocate;
block->SetMoveVector( wxPoint( 0, 0 ) );
if( aErase && aDC ) // Erase current outline
block->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, block->GetColor() );
block->SetLastCursorPosition( aPanel->GetParent()->GetCrossHairPosition() );
block->SetEnd( aPanel->GetParent()->GetCrossHairPosition() );
if( aDC ) // Draw new outline
block->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, block->GetColor() );
if( block->GetState() == STATE_BLOCK_INIT )
{
if( block->GetWidth() || block->GetHeight() )
// 2nd point exists: the rectangle is not surface anywhere
block->SetState( STATE_BLOCK_END );
}
}
void AbortBlockCurrentCommand( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
{
BASE_SCREEN* screen = aPanel->GetScreen();
if( aPanel->IsMouseCaptured() ) // Erase current drawing on screen
{
// Clear block outline.
aPanel->CallMouseCapture( aDC, wxDefaultPosition, false );
aPanel->SetMouseCapture( NULL, NULL );
screen->SetCurItem( NULL );
// Delete the picked wrapper if this is a picked list.
screen->m_BlockLocate.ClearItemsList();
}
screen->m_BlockLocate.SetState( STATE_NO_BLOCK );
screen->m_BlockLocate.SetCommand( BLOCK_ABORT );
aPanel->GetParent()->HandleBlockEnd( aDC );
screen->m_BlockLocate.SetCommand( BLOCK_IDLE );
aPanel->GetParent()->DisplayToolMsg( wxEmptyString );
aPanel->SetCursor( (wxStockCursor) aPanel->GetCurrentCursor() );
}

View File

@ -652,30 +652,6 @@ void EDA_DRAW_FRAME::SetPresetGrid( int aIndex )
} }
int EDA_DRAW_FRAME::BlockCommand( EDA_KEY key )
{
return 0;
}
void EDA_DRAW_FRAME::InitBlockPasteInfos()
{
GetScreen()->m_BlockLocate.ClearItemsList();
m_canvas->SetMouseCaptureCallback( NULL );
}
void EDA_DRAW_FRAME::HandleBlockPlace( wxDC* DC )
{
}
bool EDA_DRAW_FRAME::HandleBlockEnd( wxDC* DC )
{
return false;
}
void EDA_DRAW_FRAME::UpdateStatusBar() void EDA_DRAW_FRAME::UpdateStatusBar()
{ {
SetStatusText( GetZoomLevelIndicator(), 1 ); SetStatusText( GetZoomLevelIndicator(), 1 );
@ -832,84 +808,6 @@ void EDA_DRAW_FRAME::PushPreferences( const EDA_DRAW_PANEL* aParentCanvas )
} }
bool EDA_DRAW_FRAME::HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& aPosition,
int aExplicitCommand )
{
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
if( ( block->GetCommand() != BLOCK_IDLE ) || ( block->GetState() != STATE_NO_BLOCK ) )
return false;
if( aExplicitCommand == 0 )
block->SetCommand( (BLOCK_COMMAND_T) BlockCommand( aKey ) );
else
block->SetCommand( (BLOCK_COMMAND_T) aExplicitCommand );
if( block->GetCommand() == 0 )
return false;
switch( block->GetCommand() )
{
case BLOCK_IDLE:
break;
case BLOCK_MOVE: // Move
case BLOCK_DRAG: // Drag (block defined)
case BLOCK_DRAG_ITEM: // Drag from a drag item command
case BLOCK_DUPLICATE: // Duplicate
case BLOCK_DUPLICATE_AND_INCREMENT: // Duplicate and increment relevant references
case BLOCK_DELETE: // Delete
case BLOCK_COPY: // Copy
case BLOCK_FLIP: // Flip
case BLOCK_ZOOM: // Window Zoom
case BLOCK_PRESELECT_MOVE: // Move with preselection list
block->InitData( m_canvas, aPosition );
break;
case BLOCK_PASTE:
block->InitData( m_canvas, aPosition );
block->SetLastCursorPosition( wxPoint( 0, 0 ) );
InitBlockPasteInfos();
if( block->GetCount() == 0 ) // No data to paste
{
DisplayError( this, wxT( "No block to paste" ), 20 );
GetScreen()->m_BlockLocate.SetCommand( BLOCK_IDLE );
m_canvas->SetMouseCaptureCallback( NULL );
block->SetState( STATE_NO_BLOCK );
block->SetMessageBlock( this );
return true;
}
if( !m_canvas->IsMouseCaptured() )
{
block->ClearItemsList();
DisplayError( this,
wxT( "EDA_DRAW_FRAME::HandleBlockBegin() Err: m_mouseCaptureCallback NULL" ) );
block->SetState( STATE_NO_BLOCK );
block->SetMessageBlock( this );
return true;
}
block->SetState( STATE_BLOCK_MOVE );
m_canvas->CallMouseCapture( aDC, aPosition, false );
break;
default:
{
wxString msg;
msg << wxT( "EDA_DRAW_FRAME::HandleBlockBegin() error: Unknown command " ) <<
block->GetCommand();
DisplayError( this, msg );
}
break;
}
block->SetMessageBlock( this );
return true;
}
// I am not seeing a problem with this size yet: // I am not seeing a problem with this size yet:
static const double MAX_AXIS = INT_MAX - 100; static const double MAX_AXIS = INT_MAX - 100;
@ -1851,14 +1749,6 @@ static bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame );
void EDA_DRAW_FRAME::CopyToClipboard( wxCommandEvent& event ) void EDA_DRAW_FRAME::CopyToClipboard( wxCommandEvent& event )
{ {
DrawPageOnClipboard( this ); DrawPageOnClipboard( this );
if( event.GetId() == ID_GEN_COPY_BLOCK_TO_CLIPBOARD )
{
if( GetScreen()->IsBlockActive() )
m_canvas->SetCursor( wxCursor( (wxStockCursor) m_canvas->GetDefaultCursor() ) );
m_canvas->EndMouseCapture();
}
} }
@ -1868,20 +1758,10 @@ void EDA_DRAW_FRAME::CopyToClipboard( wxCommandEvent& event )
*/ */
bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame ) bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame )
{ {
bool DrawBlock = false;
wxRect DrawArea; wxRect DrawArea;
BASE_SCREEN* screen = aFrame->GetCanvas()->GetScreen(); BASE_SCREEN* screen = aFrame->GetCanvas()->GetScreen();
if( screen->IsBlockActive() ) DrawArea.SetSize( aFrame->GetPageSizeIU() );
{
DrawBlock = true;
DrawArea.SetX( screen->m_BlockLocate.GetX() );
DrawArea.SetY( screen->m_BlockLocate.GetY() );
DrawArea.SetWidth( screen->m_BlockLocate.GetWidth() );
DrawArea.SetHeight( screen->m_BlockLocate.GetHeight() );
}
else
DrawArea.SetSize( aFrame->GetPageSizeIU() );
// Calculate a reasonable dc size, in pixels, and the dc scale to fit // Calculate a reasonable dc size, in pixels, and the dc scale to fit
// the drawings into the dc size // the drawings into the dc size
@ -1926,13 +1806,7 @@ bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame )
screen->m_IsPrinting = true; screen->m_IsPrinting = true;
dc.SetUserScale( scale, scale ); dc.SetUserScale( scale, scale );
aFrame->GetCanvas()->SetClipBox( EDA_RECT( wxPoint( 0, 0 ), aFrame->GetCanvas()->SetClipBox( EDA_RECT( wxPoint( 0, 0 ), wxSize( 0x7FFFFF0, 0x7FFFFF0 ) ) );
wxSize( 0x7FFFFF0, 0x7FFFFF0 ) ) );
if( DrawBlock )
{
dc.SetClippingRegion( DrawArea );
}
dc.Clear(); dc.Clear();
aFrame->GetCanvas()->EraseScreen( &dc ); aFrame->GetCanvas()->EraseScreen( &dc );

View File

@ -1162,24 +1162,6 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
// the call to OnLeftClick(), so do not change it after calling OnLeftClick // the call to OnLeftClick(), so do not change it after calling OnLeftClick
bool ignoreEvt = m_ignoreNextLeftButtonRelease; bool ignoreEvt = m_ignoreNextLeftButtonRelease;
m_ignoreNextLeftButtonRelease = false; m_ignoreNextLeftButtonRelease = false;
if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK && !ignoreEvt )
{
EDA_ITEM* item = screen->GetCurItem();
m_CursorClickPos = GetParent()->RefPos( true );
// If we have an item already selected, or we are using a tool,
// we won't use the disambiguation menu so process the click immediately
if( ( item && item->GetEditFlags() ) || GetParent()->GetToolId() != ID_NO_TOOL_SELECTED )
GetParent()->OnLeftClick( &DC, m_CursorClickPos );
else
{
wxDELETE( m_ClickTimer );
m_ClickTimer = new wxTimer(this, ID_MOUSE_DOUBLECLICK);
m_ClickTimer->StartOnce( m_doubleClickInterval );
}
}
} }
else if( !event.LeftIsDown() ) else if( !event.LeftIsDown() )
{ {
@ -1257,102 +1239,6 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
m_CursorStartPos = GetParent()->GetCrossHairPosition(); m_CursorStartPos = GetParent()->GetCrossHairPosition();
} }
if( m_enableBlockCommands && !(localbutt & GR_M_DCLICK) )
{
if( !screen->IsBlockActive() )
{
screen->m_BlockLocate.SetOrigin( m_CursorStartPos );
}
if( event.LeftDown() )
{
if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE )
{
SetAutoPanRequest( false );
GetParent()->HandleBlockPlace( &DC );
m_ignoreNextLeftButtonRelease = true;
}
}
else if( ( m_canStartBlock >= 0 ) && event.LeftIsDown() && !IsMouseCaptured() )
{
// Mouse is dragging: if no block in progress, start a block command.
if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK )
{
// Start a block command
int cmd_type = kbstat;
// A block command is started if the drag is enough. A small
// drag is ignored (it is certainly a little mouse move when
// clicking) not really a drag mouse
if( m_minDragEventCount < MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND )
m_minDragEventCount++;
else
{
auto cmd = (GetParent()->GetToolId() == ID_ZOOM_SELECTION) ? BLOCK_ZOOM : 0;
if( !GetParent()->HandleBlockBegin( &DC, cmd_type, m_CursorStartPos, cmd ) )
{
// should not occur: error
GetParent()->DisplayToolMsg(
wxT( "EDA_DRAW_PANEL::OnMouseEvent() Block Error" ) );
}
else
{
SetAutoPanRequest( true );
SetCursor( wxCURSOR_SIZING );
}
}
}
}
if( event.ButtonUp( wxMOUSE_BTN_LEFT ) )
{
/* Release the mouse button: end of block.
* The command can finish (DELETE) or have a next command (MOVE,
* COPY). However the block command is canceled if the block
* size is small because a block command filtering is already
* made, this case happens, but only when the on grid cursor has
* not moved.
*/
#define BLOCK_MINSIZE_LIMIT 1
bool BlockIsSmall =
( std::abs( screen->m_BlockLocate.GetWidth() ) < BLOCK_MINSIZE_LIMIT )
&& ( std::abs( screen->m_BlockLocate.GetHeight() ) < BLOCK_MINSIZE_LIMIT );
if( (screen->m_BlockLocate.GetState() != STATE_NO_BLOCK) && BlockIsSmall )
{
if( m_endMouseCaptureCallback )
{
m_endMouseCaptureCallback( this, &DC );
SetAutoPanRequest( false );
}
SetCursor( (wxStockCursor) m_currentCursor );
}
else if( screen->m_BlockLocate.GetState() == STATE_BLOCK_END )
{
SetAutoPanRequest( false );
GetParent()->HandleBlockEnd( &DC );
SetCursor( (wxStockCursor) m_currentCursor );
if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE )
{
SetAutoPanRequest( true );
SetCursor( wxCURSOR_HAND );
}
}
}
}
// End of block command on a double click
// To avoid an unwanted block move command if the mouse is moved while double clicking
if( localbutt == (int) ( GR_M_LEFT_DOWN | GR_M_DCLICK ) )
{
if( !screen->IsBlockActive() && IsMouseCaptured() )
{
m_endMouseCaptureCallback( this, &DC );
}
}
lastPanel = this; lastPanel = this;
#ifdef __WXGTK3__ #ifdef __WXGTK3__

View File

@ -30,7 +30,6 @@
#include <config_params.h> #include <config_params.h>
#include <undo_redo_container.h> #include <undo_redo_container.h>
#include <template_fieldnames.h> #include <template_fieldnames.h>
#include <block_commande.h>
#include <ee_collectors.h> #include <ee_collectors.h>
#include <tool/selection.h> #include <tool/selection.h>
#include <erc_settings.h> #include <erc_settings.h>

View File

@ -151,8 +151,6 @@ public:
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) override; void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset ) override;
// Geometric transforms (used in block operations):
void Move( const wxPoint& aMoveVector ) override void Move( const wxPoint& aMoveVector ) override
{ {
Offset( aMoveVector ); Offset( aMoveVector );

View File

@ -50,7 +50,7 @@ int LIB_CONTROL::Save( const TOOL_EVENT& aEvent )
int LIB_CONTROL::SaveAs( const TOOL_EVENT& aEvent ) int LIB_CONTROL::SaveAs( const TOOL_EVENT& aEvent )
{ {
m_frame->OnSaveAs( true ); m_frame->OnSaveAs();
return 0; return 0;
} }

View File

@ -27,7 +27,6 @@ set( DIALOGS_SRCS
) )
set( GERBVIEW_SRCS set( GERBVIEW_SRCS
block.cpp
am_param.cpp am_param.cpp
am_primitive.cpp am_primitive.cpp
DCodeSelectionbox.cpp DCodeSelectionbox.cpp

View File

@ -1,219 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2010 <Jean-Pierre Charras>
* Copyright (C) 1992-2010 KiCad Developers, see change_log.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
*/
/**
* @file gerbview/block.cpp
* @brief Block operations: displacement.
*/
#include <fctsys.h>
#include <common.h>
#include <class_drawpanel.h>
#include <gerbview_frame.h>
#include <gerber_draw_item.h>
#include <gerber_file_image.h>
#include <gerber_file_image_list.h>
// Call back function used in block command
static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aPosition, bool erase );
int GERBVIEW_FRAME::BlockCommand( EDA_KEY key )
{
int cmd = 0;
switch( key )
{
default:
cmd = key & 0x255;
break;
case 0:
cmd = BLOCK_MOVE;
break;
case GR_KB_SHIFT:
case GR_KB_CTRL:
case GR_KB_SHIFTCTRL:
case GR_KB_ALT:
break;
case MOUSE_MIDDLE:
cmd = BLOCK_ZOOM;
break;
}
return cmd;
}
void GERBVIEW_FRAME::HandleBlockPlace( wxDC* DC )
{
wxASSERT( m_canvas->IsMouseCaptured() );
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_STOP );
switch( GetScreen()->m_BlockLocate.GetCommand() )
{
case BLOCK_MOVE: /* Move */
if( m_canvas->IsMouseCaptured() )
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
Block_Move();
GetScreen()->m_BlockLocate.ClearItemsList();
break;
default:
wxFAIL_MSG( wxT("HandleBlockPlace: Unexpected block command") );
break;
}
m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString, false );
GetScreen()->SetModify();
GetScreen()->ClearBlockCommand();
wxASSERT( GetScreen()->m_BlockLocate.GetCount() == 0 );
DisplayToolMsg( wxEmptyString );
}
bool GERBVIEW_FRAME::HandleBlockEnd( wxDC* DC )
{
bool nextcmd = false;
bool zoom_command = false;
if( m_canvas->IsMouseCaptured() )
switch( GetScreen()->m_BlockLocate.GetCommand() )
{
case BLOCK_MOVE: /* Move */
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_MOVE );
nextcmd = true;
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines );
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
break;
case BLOCK_ZOOM: /* Window Zoom */
zoom_command = true;
break;
default:
wxFAIL_MSG( wxT("HandleBlockEnd: Unexpected block command") );
break;
}
if( ! nextcmd )
{
GetScreen()->ClearBlockCommand();
m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString,
false );
}
return nextcmd ;
}
/* Traces the outline of the block structures of a repositioning move
*/
static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPositon,
bool aErase )
{
BASE_SCREEN* screen = aPanel->GetScreen();
COLOR4D Color = COLOR4D( YELLOW );
if( aErase )
{
screen->m_BlockLocate.Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, Color );
if( screen->m_BlockLocate.GetMoveVector().x|| screen->m_BlockLocate.GetMoveVector().y )
{
screen->m_BlockLocate.Draw( aPanel,
aDC,
screen->m_BlockLocate.GetMoveVector(),
g_XorMode,
Color );
}
}
if( screen->m_BlockLocate.GetState() != STATE_BLOCK_STOP )
{
const wxPoint& cross_hair = aPanel->GetParent()->GetCrossHairPosition();
screen->m_BlockLocate.SetMoveVector(
wxPoint( cross_hair.x - screen->m_BlockLocate.GetRight(),
cross_hair.y - screen->m_BlockLocate.GetBottom() ) );
}
screen->m_BlockLocate.Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, Color );
if( screen->m_BlockLocate.GetMoveVector().x || screen->m_BlockLocate.GetMoveVector().y )
{
screen->m_BlockLocate.Draw( aPanel, aDC,
screen->m_BlockLocate.GetMoveVector(),
g_XorMode, Color );
}
}
void GERBVIEW_FRAME::Block_Move()
{
wxPoint delta;
wxPoint oldpos;
oldpos = GetCrossHairPosition();
m_canvas->SetMouseCaptureCallback( NULL );
SetCrossHairPosition( oldpos );
m_canvas->MoveCursorToCrossHair();
GetScreen()->SetModify();
GetScreen()->m_BlockLocate.Normalize();
/* Calculate displacement vectors. */
delta = GetScreen()->m_BlockLocate.GetMoveVector();
GERBER_FILE_IMAGE_LIST* images = GetGerberLayout()->GetImagesList();
for( unsigned layer = 0; layer < images->ImagesMaxCount(); ++layer )
{
GERBER_FILE_IMAGE* gerber = images->GetGbrImage( layer );
if( gerber == NULL ) // Graphic layer not yet used
continue;
/* Move items in block */
for( GERBER_DRAW_ITEM* item = gerber->GetItemsList(); item; item = item->Next() )
{
GERBER_DRAW_ITEM* gerb_item = item;
if( gerb_item->HitTest( GetScreen()->m_BlockLocate, true ) )
gerb_item->MoveAB( delta );
}
}
m_canvas->Refresh( true );
}

View File

@ -151,14 +151,6 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_CANCEL_CURRENT_COMMAND: case ID_POPUP_CANCEL_CURRENT_COMMAND:
m_canvas->EndMouseCapture(); m_canvas->EndMouseCapture();
if( GetScreen()->m_BlockLocate.GetCommand() != BLOCK_IDLE )
{
/* Should not be executed, except bug */
GetScreen()->m_BlockLocate.SetCommand( BLOCK_IDLE );
GetScreen()->m_BlockLocate.SetState( STATE_NO_BLOCK );
GetScreen()->m_BlockLocate.ClearItemsList();
}
if( GetToolId() == ID_NO_TOOL_SELECTED ) if( GetToolId() == ID_NO_TOOL_SELECTED )
SetNoToolSelected(); SetNoToolSelected();
else else

View File

@ -482,40 +482,6 @@ public:
void OnUpdateSelectDCode( wxUpdateUIEvent& aEvent ); void OnUpdateSelectDCode( wxUpdateUIEvent& aEvent );
void OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent ); void OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent );
/**
* Function BlockCommand
* returns the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to
* the \a aKey (ALT, SHIFT ALT ..)
*/
virtual int BlockCommand( EDA_KEY key ) override;
/**
* Function HandleBlockPlace
* handles the block place command.
*/
virtual void HandleBlockPlace( wxDC* DC ) override;
/**
* Function HandleBlockEnd
* handles the end of a block command,
* It is called at the end of the definition of the area of a block.
* Depending on the current block command, this command is executed
* or parameters are initialized to prepare a call to HandleBlockPlace
* in GetScreen()->m_BlockLocate
*
* @return false if no item selected, or command finished,
* true if some items found and HandleBlockPlace must be called later.
*/
virtual bool HandleBlockEnd( wxDC* DC ) override;
/**
* Function Block_Move
* moves all tracks and segments within the selected block.
* New location is determined by the current offset from the selected
* block's original location.
*/
void Block_Move();
/** /**
* Function ToPrinter * Function ToPrinter
* Open a dialog frame to print layers * Open a dialog frame to print layers

View File

@ -34,7 +34,6 @@
#include <draw_frame.h> #include <draw_frame.h>
#include <base_struct.h> #include <base_struct.h>
#include <undo_redo_container.h> #include <undo_redo_container.h>
#include <block_commande.h>
#include <common.h> #include <common.h>
/** /**
@ -209,9 +208,6 @@ public:
UNDO_REDO_CONTAINER m_UndoList; ///< Objects list for the undo command (old data) UNDO_REDO_CONTAINER m_UndoList; ///< Objects list for the undo command (old data)
UNDO_REDO_CONTAINER m_RedoList; ///< Objects list for the redo command (old data) UNDO_REDO_CONTAINER m_RedoList; ///< Objects list for the redo command (old data)
// block control
BLOCK_SELECTOR m_BlockLocate; ///< Block description for block commands
int m_ScreenNumber; int m_ScreenNumber;
int m_NumberOfScreens; int m_NumberOfScreens;
@ -495,10 +491,6 @@ public:
return wxT( "BASE_SCREEN" ); return wxT( "BASE_SCREEN" );
} }
inline bool IsBlockActive() const { return !m_BlockLocate.IsIdle(); }
void ClearBlockCommand() { m_BlockLocate.Clear(); }
#if defined(DEBUG) #if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const override; void Show( int nestLevel, std::ostream& os ) const override;
#endif #endif

View File

@ -1,230 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2004-2011 KiCad Developers, see change_log.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
*/
/**
* This file is part of the common library.
* @file block_commande.h
* @see common.h
*/
#ifndef __INCLUDE__BLOCK_COMMANDE_H__
#define __INCLUDE__BLOCK_COMMANDE_H__
#include <base_struct.h>
#include <undo_redo_container.h>
#include <gr_basic.h>
#include <eda_rect.h>
/* Block state codes. */
typedef enum {
STATE_NO_BLOCK,
STATE_BLOCK_INIT,
STATE_BLOCK_END,
STATE_BLOCK_MOVE,
STATE_BLOCK_STOP
} BLOCK_STATE_T;
/* Block command codes. */
typedef enum {
BLOCK_IDLE,
BLOCK_MOVE,
BLOCK_DUPLICATE,
BLOCK_DUPLICATE_AND_INCREMENT,
BLOCK_COPY,
BLOCK_DELETE,
BLOCK_PASTE,
BLOCK_CUT,
BLOCK_DRAG,
BLOCK_DRAG_ITEM, // like BLOCK_DRAG, when used to drag a selected component
// and not using an area defined by a mouse drag
BLOCK_ROTATE,
BLOCK_FLIP,
BLOCK_ZOOM,
BLOCK_ABORT,
BLOCK_PRESELECT_MOVE,
BLOCK_MOVE_EXACT,
BLOCK_SELECT_ITEMS_ONLY,
BLOCK_MIRROR_X,
BLOCK_MIRROR_Y
} BLOCK_COMMAND_T;
class BLOCK_SELECTOR : public EDA_RECT
{
BLOCK_STATE_T m_state; //< State (enum BLOCK_STATE_T) of the block.
BLOCK_COMMAND_T m_command; //< Command (enum BLOCK_COMMAND_T) operation.
PICKED_ITEMS_LIST m_items; //< List of items selected in this block.
COLOR4D m_color; //< Block Color (for drawings).
wxPoint m_moveVector; //< Move distance to move the block.
wxPoint m_lastCursorPosition; //< Last Mouse position in block command
//< last cursor position in move commands
//< 0,0 in paste command.
bool m_appendUndo; //< indicates that at least one undo record
//< has been saved and further undo records
//< should be appended
public:
BLOCK_SELECTOR();
~BLOCK_SELECTOR();
void SetState( BLOCK_STATE_T aState ) { m_state = aState; }
BLOCK_STATE_T GetState() const { return m_state; }
void SetCommand( BLOCK_COMMAND_T aCommand ) { m_command = aCommand; }
BLOCK_COMMAND_T GetCommand() const { return m_command; }
void SetColor( COLOR4D aColor ) { m_color = aColor; }
COLOR4D GetColor() const { return m_color; }
bool AppendUndo() const { return m_appendUndo; }
void SetAppendUndo() { m_appendUndo = true; }
/**
* Function SetLastCursorPosition
* sets the last cursor position to \a aPosition.
*
* @param aPosition The current cursor position.
*/
void SetLastCursorPosition( const wxPoint& aPosition ) { m_lastCursorPosition = aPosition; }
wxPoint GetLastCursorPosition() const { return m_lastCursorPosition; }
void SetMoveVector( const wxPoint& aMoveVector ) { m_moveVector = aMoveVector; }
wxPoint GetMoveVector() const { return m_moveVector; }
/**
* Function InitData
* sets the initial values of a BLOCK_SELECTOR, before starting a block
* command
*/
void InitData( EDA_DRAW_PANEL* Panel, const wxPoint& startpos );
/**
* Function SetMessageBlock
* Displays the type of block command in the status bar of the window
*/
void SetMessageBlock( EDA_DRAW_FRAME* frame );
void Draw( EDA_DRAW_PANEL* aPanel,
wxDC* aDC,
const wxPoint& aOffset,
GR_DRAWMODE aDrawMode,
COLOR4D aColor );
/**
* Function PushItem
* adds \a aItem to the list of items.
* @param aItem = an ITEM_PICKER to add to the list
*/
void PushItem( ITEM_PICKER& aItem );
/**
* Function ClearListAndDeleteItems
* deletes only the list of EDA_ITEM * pointers, AND the data printed
* by m_Item
*/
void ClearListAndDeleteItems();
/**
* Function ClearItemsList
* clear only the list of #EDA_ITEM pointers, it does _NOT_ delete the #EDA_ITEM object
* itself
*/
void ClearItemsList();
unsigned GetCount() const
{
return m_items.GetCount();
}
PICKED_ITEMS_LIST& GetItems() { return m_items; }
EDA_ITEM* GetItem( unsigned aIndex )
{
if( aIndex < m_items.GetCount() )
return m_items.GetPickedItem( aIndex );
return NULL;
}
/**
* Function SetFlags
* sets a status flag on each item in a block selector.
*/
void SetFlags( const STATUS_FLAGS aFlag )
{
for( unsigned i = 0; i < m_items.GetCount(); i++ )
m_items.GetPickedItem( i )->SetFlags( aFlag );
}
/**
* Function IsDragging
* returns true if the current block command is a drag operation.
*/
bool IsDragging() const
{
return m_command == BLOCK_DRAG || m_command == BLOCK_DRAG_ITEM;
}
/**
* Function IsIdle
* returns true if there is currently no block operation in progress.
*/
inline bool IsIdle() const { return m_command == BLOCK_IDLE; }
/**
* Function Clear
* clears the block selector by setting the command to idle, the state to no block,
* and clears the selected item list.
*/
void Clear();
};
/**
* Function AbortBlockCurrentCommand
* cancels the current block operation.
*/
void AbortBlockCurrentCommand( EDA_DRAW_PANEL* aPanel, wxDC* aDC );
/**
* Function DrawAndSizingBlockOutlines
* redraws the outlines of the block which shows the search area for block commands.
*
* The first point of the rectangle showing the area is initialized by InitBlockLocateDatas().
* The other point of the rectangle is the mouse cursor position.
*/
void DrawAndSizingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase );
#endif /* __INCLUDE__BLOCK_COMMANDE_H__ */

View File

@ -763,50 +763,6 @@ public:
*/ */
void DisplayUnitsMsg(); void DisplayUnitsMsg();
/* Handlers for block commands */
virtual void InitBlockPasteInfos();
/**
* Initialize a block command.
*
* @param aDC is the device context to perform the block command.
* @param aKey is the block command key press.
* @param aPosition is the logical position of the start of the block command.
* @param aExplicitCommand - if this is given, begin with this command, rather
* than looking up the command from \a aKey.
*/
virtual bool HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& aPosition,
int aExplicitCommand = 0 );
/**
* Return the block command code (BLOCK_MOVE, BLOCK_COPY...) corresponding to the
* keys pressed (ALT, SHIFT, SHIFT ALT ..) when block command is started by dragging
* the mouse.
*
* @param aKey = the key modifiers (Alt, Shift ...)
* @return the block command id (BLOCK_MOVE, BLOCK_COPY...)
*/
virtual int BlockCommand( EDA_KEY aKey );
/**
* Called after HandleBlockEnd, when a block command needs to be
* executed after the block is moved to its new place
* (bloc move, drag, copy .. )
* Parameters must be initialized in GetScreen()->m_BlockLocate
*/
virtual void HandleBlockPlace( wxDC* DC );
/**
* Handle the "end" of a block command,
* i.e. is called at the end of the definition of the area of a block.
* depending on the current block command, this command is executed
* or parameters are initialized to prepare a call to HandleBlockPlace
* in GetScreen()->m_BlockLocate
* @return false if no item selected, or command finished,
* true if some items found and HandleBlockPlace must be called later
*/
virtual bool HandleBlockEnd( wxDC* DC );
/** /**
* Copy the current page or the current block to the clipboard. * Copy the current page or the current block to the clipboard.
*/ */

View File

@ -28,7 +28,7 @@
#include <gal/color4d.h> #include <gal/color4d.h>
#include <vector> #include <vector>
class EDA_RECT; #include <eda_rect.h>
using KIGFX::COLOR4D; using KIGFX::COLOR4D;
@ -111,12 +111,6 @@ void GRLine( EDA_RECT* aClipBox, wxDC* aDC,
wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID ); wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID );
void GRLine( EDA_RECT* ClipBox, wxDC* DC, void GRLine( EDA_RECT* ClipBox, wxDC* DC,
int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle = wxPENSTYLE_SOLID ); int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle = wxPENSTYLE_SOLID );
void GRMixedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, COLOR4D Color );
void GRDashedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, COLOR4D Color );
void GRDottedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, COLOR4D Color );
void GRMoveTo( int x, int y ); void GRMoveTo( int x, int y );
void GRLineTo( EDA_RECT* ClipBox, wxDC* DC, void GRLineTo( EDA_RECT* ClipBox, wxDC* DC,
int x, int y, int width, COLOR4D Color ); int x, int y, int width, COLOR4D Color );

View File

@ -43,13 +43,6 @@ class PICKED_ITEMS_LIST;
* If an item is modified, a copy of the "old" item parameters value is held. * If an item is modified, a copy of the "old" item parameters value is held.
* When an item is deleted or added (new item) the pointer points the item, and there is * When an item is deleted or added (new item) the pointer points the item, and there is
* no other copy. * no other copy.
* However, because there are some commands that concern a lot of items
* and modify them, but modifications are easy to undo/redo,
* so a copy of old items is not necessary. They are block command
* Move block
* Rotate block
* Mirror or Flip block
* and they are undo/redo by the same command
*/ */

View File

@ -230,11 +230,9 @@ set( PCBNEW_CLASS_SRCS
autorouter/autoplacer_tool.cpp autorouter/autoplacer_tool.cpp
action_plugin.cpp action_plugin.cpp
append_board_to_current.cpp
array_creator.cpp array_creator.cpp
array_pad_name_provider.cpp array_pad_name_provider.cpp
attribut.cpp attribut.cpp
block_footprint_editor.cpp
board_netlist_updater.cpp board_netlist_updater.cpp
build_BOM_from_board.cpp build_BOM_from_board.cpp
connect.cpp connect.cpp

View File

@ -1,217 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2014 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
*/
/**
* @file append_board_to_current.cpp
* @brief append a board to the currently edited board.
*/
#include <fctsys.h>
#include <confirm.h>
#include <properties.h>
#include <pcb_edit_frame.h>
#include <pcbnew.h>
#include <io_mgr.h>
#include <class_module.h>
#include <class_zone.h>
#include <class_board.h>
#include <pcb_draw_panel_gal.h>
// Defined in files.cpp:
extern IO_MGR::PCB_FILE_T plugin_type( const wxString& aFileName, int aCtl );
bool PCB_EDIT_FRAME::AppendBoardFile( const wxString& aFullFileName, int aCtl )
{
IO_MGR::PCB_FILE_T pluginType = plugin_type( aFullFileName, aCtl );
PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) );
// keep trace of existing items, in order to know what are the new items
// (for undo command for instance)
// Tracks are inserted, not append, so mark existing tracks to know what are
// the new tracks
for( TRACK* track = GetBoard()->m_Track; track; track = track->Next() )
track->SetFlags( FLAG0 );
// Other items are append to the item list, so keep trace to the
// last existing item is enough
MODULE* module = GetBoard()->m_Modules.GetLast();
BOARD_ITEM* drawing = GetBoard()->DrawingsList().GetLast();
int zonescount = GetBoard()->GetAreaCount();
// Keep also the count of copper layers, because we can happen boards
// with different copper layers counts,
// and the enabled layers
int initialCopperLayerCount = GetBoard()->GetCopperLayerCount();
LSET initialEnabledLayers = GetBoard()->GetEnabledLayers();
try
{
PROPERTIES props;
char xbuf[30];
char ybuf[30];
// EAGLE_PLUGIN can use this info to center the BOARD, but it does not yet.
sprintf( xbuf, "%d", GetPageSizeIU().x );
sprintf( ybuf, "%d", GetPageSizeIU().y );
props["page_width"] = xbuf;
props["page_height"] = ybuf;
GetDesignSettings().m_NetClasses.Clear();
pi->Load( aFullFileName, GetBoard(), &props );
}
catch( const IO_ERROR& ioe )
{
for( TRACK* track = GetBoard()->m_Track; track; track = track->Next() )
{
track->ClearFlags( FLAG0 );
}
DisplayErrorMessage( this, _( "Error loading board in AppendBoardFile" ), ioe.What() );
return false;
}
// Now prepare a block move command to place the new items, and
// prepare the undo command.
BLOCK_SELECTOR& blockmove = GetScreen()->m_BlockLocate;
HandleBlockBegin( NULL, BLOCK_PRESELECT_MOVE, wxPoint( 0, 0) );
PICKED_ITEMS_LIST& blockitemsList = blockmove.GetItems();
PICKED_ITEMS_LIST undoListPicker;
ITEM_PICKER picker( NULL, UR_NEW );
EDA_RECT bbox; // the new items bounding box, for block move
bool bboxInit = true; // true until the bounding box is initialized
for( TRACK* track = GetBoard()->m_Track; track; track = track->Next() )
{
if( track->GetFlags() & FLAG0 )
{
track->ClearFlags( FLAG0 );
continue;
}
track->SetFlags( IS_MOVED );
picker.SetItem( track );
undoListPicker.PushItem( picker );
blockitemsList.PushItem( picker );
if( bboxInit )
bbox = track->GetBoundingBox();
else
bbox.Merge( track->GetBoundingBox() );
bboxInit = false;
}
if( module )
module = module->Next();
else
module = GetBoard()->m_Modules;
for( ; module; module = module->Next() )
{
module->SetFlags( IS_MOVED );
picker.SetItem( module );
undoListPicker.PushItem( picker );
blockitemsList.PushItem( picker );
if( bboxInit )
bbox = module->GetBoundingBox();
else
bbox.Merge( module->GetBoundingBox() );
bboxInit = false;
}
if( drawing )
drawing = drawing->Next();
else
drawing = GetBoard()->DrawingsList();
for( ; drawing; drawing = drawing->Next() )
{
drawing->SetFlags( IS_MOVED );
picker.SetItem( drawing );
undoListPicker.PushItem( picker );
blockitemsList.PushItem( picker );
if( bboxInit )
bbox = drawing->GetBoundingBox();
else
bbox.Merge( drawing->GetBoundingBox() );
bboxInit = false;
}
for( ZONE_CONTAINER* zone = GetBoard()->GetArea( zonescount ); zone;
zone = GetBoard()->GetArea( zonescount ) )
{
zone->SetFlags( IS_MOVED );
picker.SetItem( zone );
undoListPicker.PushItem( picker );
blockitemsList.PushItem( picker );
zonescount++;
if( bboxInit )
bbox = zone->GetBoundingBox();
else
bbox.Merge( zone->GetBoundingBox() );
bboxInit = false;
}
SaveCopyInUndoList( undoListPicker, UR_NEW );
// we should not ask PLUGINs to do these items:
int copperLayerCount = GetBoard()->GetCopperLayerCount();
if( copperLayerCount > initialCopperLayerCount )
GetBoard()->SetCopperLayerCount( copperLayerCount );
// Enable all used layers, and make them visible:
LSET enabledLayers = GetBoard()->GetEnabledLayers();
enabledLayers |= initialEnabledLayers;
GetBoard()->SetEnabledLayers( enabledLayers );
GetBoard()->SetVisibleLayers( enabledLayers );
onBoardLoaded();
if( IsGalCanvasActive() )
static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() )->SyncLayersVisibility( GetBoard() );
GetBoard()->BuildListOfNets();
GetBoard()->SynchronizeNetsAndNetClasses();
// Finish block move command:
wxPoint cpos = GetNearestGridPosition( bbox.Centre() );
blockmove.SetOrigin( bbox.GetOrigin() );
blockmove.SetSize( bbox.GetSize() );
blockmove.SetLastCursorPosition( cpos );
HandleBlockEnd( NULL );
return true;
}

View File

@ -1,890 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2017 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
*/
/**
* @file block_module_editor.cpp
* @brief Footprint editor block handling implementation.
*/
#include <fctsys.h>
#include <pgm_base.h>
#include <gr_basic.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <block_commande.h>
#include <macros.h>
#include <footprint_edit_frame.h>
#include <pcbplot.h>
#include <trigo.h>
#include <pcbnew.h>
#include <class_board.h>
#include <class_track.h>
#include <class_drawsegment.h>
#include <class_pcb_text.h>
#include <class_pcb_target.h>
#include <class_module.h>
#include <class_dimension.h>
#include <class_edge_mod.h>
#include <dialogs/dialog_move_exact.h>
#define BLOCK_COLOR BROWN
// Functions defined here, but used also in other files
// These 3 functions are used in modedit to rotate, mirror or move the
// whole footprint so they are called with force_all = true
void MirrorMarkedItems( MODULE* module, wxPoint offset, bool force_all = false );
void RotateMarkedItems( MODULE* module, wxPoint offset, bool force_all = false );
void MoveMarkedItemsExactly( MODULE* module, const wxPoint& centre,
const wxPoint& translation, double rotation,
bool force_all = false );
// Local functions:
static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase );
static int MarkItemsInBloc( MODULE* module, EDA_RECT& Rect );
static void ClearMarkItems( MODULE* module );
static void CopyMarkedItems( MODULE* module, wxPoint offset, bool aIncrement );
static void MoveMarkedItems( MODULE* module, wxPoint offset );
static void DeleteMarkedItems( MODULE* module );
int FOOTPRINT_EDIT_FRAME::BlockCommand( EDA_KEY key )
{
int cmd;
switch( key )
{
default:
cmd = key & 0xFF;
break;
case EDA_KEY_C( 0xffffffff ): // -1
// Historically, -1 has been used as a key, which can cause bit flag
// clashes with unaware code. On debug builds, catch any old code that
// might still be doing this. TODO: remove if sure all this old code is gone.
wxFAIL_MSG( "negative EDA_KEY value should be converted to GR_KEY_INVALID" );
// fall through on release builds
case GR_KEY_INVALID:
cmd = BLOCK_PRESELECT_MOVE;
break;
case 0:
cmd = BLOCK_MOVE;
break;
case GR_KB_ALT:
cmd = BLOCK_MIRROR_Y;
break;
case GR_KB_SHIFTCTRL:
cmd = BLOCK_DELETE;
break;
case GR_KB_SHIFT:
cmd = BLOCK_DUPLICATE;
break;
case GR_KB_CTRL:
cmd = BLOCK_ROTATE;
break;
case MOUSE_MIDDLE:
cmd = BLOCK_ZOOM;
break;
}
return cmd;
}
bool FOOTPRINT_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
{
int itemsCount = 0;
bool nextcmd = false;
MODULE* currentModule = GetBoard()->m_Modules;
if( GetScreen()->m_BlockLocate.GetCount() )
{
// Set the SELECTED flag of all preselected items, and clear preselect list
ClearMarkItems( currentModule );
PICKED_ITEMS_LIST* list = &GetScreen()->m_BlockLocate.GetItems();
for( unsigned ii = 0, e = list->GetCount(); ii < e; ++ii )
{
BOARD_ITEM* item = (BOARD_ITEM*) list->GetPickedItem( ii );
item->SetFlags( SELECTED );
++itemsCount;
}
GetScreen()->m_BlockLocate.ClearItemsList();
}
switch( GetScreen()->m_BlockLocate.GetCommand() )
{
case BLOCK_IDLE:
DisplayError( this, wxT( "Error in HandleBlockPLace" ) );
break;
case BLOCK_DRAG: // Drag
case BLOCK_DRAG_ITEM: // Drag a given item (not used here)
case BLOCK_MOVE: // Move
case BLOCK_DUPLICATE: // Duplicate
case BLOCK_DUPLICATE_AND_INCREMENT: // Specific to duplicate with increment command
// Find selected items if we didn't already set them manually
if( itemsCount == 0 )
itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
if( itemsCount )
{
nextcmd = true;
if( m_canvas->IsMouseCaptured() )
{
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines );
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
}
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_MOVE );
m_canvas->Refresh( true );
}
break;
case BLOCK_MOVE_EXACT:
itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
if( itemsCount )
{
wxPoint translation;
double rotation;
ROTATION_ANCHOR rotationAnchor = ROTATE_AROUND_SEL_CENTER;
DIALOG_MOVE_EXACT dialog( this, translation, rotation, rotationAnchor );
if( dialog.ShowModal() == wxID_OK )
{
SaveCopyInUndoList( currentModule, UR_CHANGED );
wxPoint blockCentre = GetScreen()->m_BlockLocate.Centre();
blockCentre += translation;
switch( rotationAnchor )
{
case ROTATE_AROUND_SEL_CENTER:
MoveMarkedItemsExactly( currentModule, blockCentre, translation, rotation );
break;
case ROTATE_AROUND_USER_ORIGIN:
MoveMarkedItemsExactly( currentModule, GetScreen()->m_O_Curseur, translation, rotation );
break;
default:
wxFAIL_MSG( "Rotation choice shouldn't have been available in this context." );
}
OnModify();
}
}
break;
case BLOCK_PRESELECT_MOVE: // Move with preselection list
nextcmd = true;
m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines );
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_MOVE );
break;
case BLOCK_DELETE: // Delete
itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
if( itemsCount )
SaveCopyInUndoList( currentModule, UR_CHANGED );
DeleteMarkedItems( currentModule );
OnModify();
break;
case BLOCK_COPY: // Copy
case BLOCK_PASTE:
case BLOCK_CUT:
break;
case BLOCK_ROTATE:
itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
if( itemsCount )
SaveCopyInUndoList( currentModule, UR_CHANGED );
RotateMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
OnModify();
break;
case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y:
case BLOCK_FLIP: // mirror
itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
if( itemsCount )
SaveCopyInUndoList( currentModule, UR_CHANGED );
MirrorMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
OnModify();
break;
case BLOCK_ABORT:
break;
case BLOCK_SELECT_ITEMS_ONLY:
break;
}
if( !nextcmd )
{
if( GetScreen()->m_BlockLocate.GetCommand() != BLOCK_SELECT_ITEMS_ONLY )
{
ClearMarkItems( currentModule );
}
GetScreen()->ClearBlockCommand();
SetCurItem( NULL );
m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString,
false );
m_canvas->Refresh( true );
}
return nextcmd;
}
void FOOTPRINT_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
{
MODULE* currentModule = GetBoard()->m_Modules;
if( !m_canvas->IsMouseCaptured() )
{
DisplayError( this, wxT( "HandleBlockPLace : m_mouseCaptureCallback = NULL" ) );
}
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_STOP );
const BLOCK_COMMAND_T command = GetScreen()->m_BlockLocate.GetCommand();
switch( command )
{
case BLOCK_IDLE:
break;
case BLOCK_DRAG: // Drag
case BLOCK_MOVE: // Move
case BLOCK_PRESELECT_MOVE: // Move with preselection list
GetScreen()->m_BlockLocate.ClearItemsList();
SaveCopyInUndoList( currentModule, UR_CHANGED );
MoveMarkedItems( currentModule, GetScreen()->m_BlockLocate.GetMoveVector() );
m_canvas->Refresh( true );
break;
case BLOCK_DUPLICATE: // Duplicate
case BLOCK_DUPLICATE_AND_INCREMENT: // Duplicate and increment pad names
GetScreen()->m_BlockLocate.ClearItemsList();
SaveCopyInUndoList( currentModule, UR_CHANGED );
CopyMarkedItems( currentModule, GetScreen()->m_BlockLocate.GetMoveVector(),
command == BLOCK_DUPLICATE_AND_INCREMENT );
break;
case BLOCK_PASTE: // Paste
GetScreen()->m_BlockLocate.ClearItemsList();
break;
case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y:
case BLOCK_FLIP: // Mirror by popup menu, from block move
SaveCopyInUndoList( currentModule, UR_CHANGED );
MirrorMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
break;
case BLOCK_ROTATE:
SaveCopyInUndoList( currentModule, UR_CHANGED );
RotateMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
break;
case BLOCK_ZOOM: // Handled by HandleBlockEnd
case BLOCK_DELETE:
case BLOCK_COPY:
case BLOCK_ABORT:
default:
break;
}
OnModify();
GetScreen()->m_BlockLocate.SetState( STATE_NO_BLOCK );
GetScreen()->m_BlockLocate.SetCommand( BLOCK_IDLE );
SetCurItem( NULL );
m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString, false );
m_canvas->Refresh( true );
}
/* Traces the outline of the search block structures
* The entire block follows the cursor
*/
static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase )
{
BASE_SCREEN* screen = aPanel->GetScreen();
FOOTPRINT_EDIT_FRAME* moduleEditFrame = static_cast<FOOTPRINT_EDIT_FRAME*>( aPanel->GetParent() );
wxASSERT( moduleEditFrame );
MODULE* currentModule = moduleEditFrame->GetBoard()->m_Modules;
BLOCK_SELECTOR* block = &screen->m_BlockLocate;
GRSetDrawMode( aDC, g_XorMode );
if( aErase )
{
block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
if( currentModule )
{
wxPoint move_offset = -block->GetMoveVector();
BOARD_ITEM* item = currentModule->GraphicalItemsList();
for( ; item != NULL; item = item->Next() )
{
if( !item->IsSelected() )
continue;
switch( item->Type() )
{
case PCB_MODULE_TEXT_T:
case PCB_MODULE_EDGE_T:
item->Draw( aPanel, aDC, g_XorMode, move_offset );
break;
default:
break;
}
}
D_PAD* pad = currentModule->PadsList();
for( ; pad != NULL; pad = pad->Next() )
{
if( !pad->IsSelected() )
continue;
pad->Draw( aPanel, aDC, g_XorMode, move_offset );
}
}
}
// Repaint new view.
block->SetMoveVector( moduleEditFrame->GetCrossHairPosition() - block->GetLastCursorPosition() );
block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
if( currentModule )
{
BOARD_ITEM* item = currentModule->GraphicalItemsList();
wxPoint move_offset = - block->GetMoveVector();
for( ; item != NULL; item = item->Next() )
{
if( !item->IsSelected() )
continue;
switch( item->Type() )
{
case PCB_MODULE_TEXT_T:
case PCB_MODULE_EDGE_T:
item->Draw( aPanel, aDC, g_XorMode, move_offset );
break;
default:
break;
}
}
D_PAD* pad = currentModule->PadsList();
for( ; pad != NULL; pad = pad->Next() )
{
if( !pad->IsSelected() )
continue;
pad->Draw( aPanel, aDC, g_XorMode, move_offset );
}
}
}
/* Copy marked items, at new position = old position + offset
*/
void CopyMarkedItems( MODULE* module, wxPoint offset, bool aIncrement )
{
if( module == NULL )
return;
// Reference and value cannot be copied, they are unique.
// Ensure they are not selected
module->Reference().ClearFlags();
module->Value().ClearFlags();
for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
{
if( !pad->IsSelected() )
continue;
pad->ClearFlags( SELECTED );
D_PAD* NewPad = new D_PAD( *pad );
NewPad->SetParent( module );
NewPad->SetFlags( SELECTED );
module->PadsList().PushFront( NewPad );
if( aIncrement )
NewPad->IncrementPadName( true, true );
}
BOARD_ITEM* newItem;
for( BOARD_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() )
{
if( !item->IsSelected() )
continue;
item->ClearFlags( SELECTED );
newItem = (BOARD_ITEM*)item->Clone();
newItem->SetParent( module );
newItem->SetFlags( SELECTED );
module->GraphicalItemsList().PushFront( newItem );
}
MoveMarkedItems( module, offset );
}
/* Move marked items, at new position = old position + offset
*/
void MoveMarkedItems( MODULE* module, wxPoint offset )
{
EDA_ITEM* item;
if( module == NULL )
return;
if( module->Reference().IsSelected() )
module->Reference().Move( offset );
if( module->Value().IsSelected() )
module->Value().Move( offset );
D_PAD* pad = module->PadsList();
for( ; pad != NULL; pad = pad->Next() )
{
if( !pad->IsSelected() )
continue;
pad->SetPosition( pad->GetPosition() + offset );
pad->SetPos0( pad->GetPos0() + offset );
}
item = module->GraphicalItemsList();
for( ; item != NULL; item = item->Next() )
{
if( !item->IsSelected() )
continue;
switch( item->Type() )
{
case PCB_MODULE_TEXT_T:
static_cast<TEXTE_MODULE*>( item )->Move( offset );
break;
case PCB_MODULE_EDGE_T:
{
EDGE_MODULE* em = (EDGE_MODULE*) item;
em->Move( offset );
em->SetStart0( em->GetStart0() + offset );
em->SetEnd0( em->GetEnd0() + offset );
em->SetBezier0_C1( em->GetBezier0_C1() + offset );
em->SetBezier0_C2( em->GetBezier0_C2() + offset );
}
break;
default:
;
}
}
ClearMarkItems( module );
}
/* Delete marked items
*/
void DeleteMarkedItems( MODULE* module )
{
if( module == NULL )
return;
D_PAD* next_pad;
BOARD* board = module->GetBoard();
for( D_PAD* pad = module->PadsList(); pad; pad = next_pad )
{
next_pad = pad->Next();
if( !pad->IsSelected() )
continue;
if( board )
board->PadDelete( pad );
else
pad->DeleteStructure();
}
BOARD_ITEM* next_item;
for( BOARD_ITEM* item = module->GraphicalItemsList(); item; item = next_item )
{
next_item = item->Next();
if( !item->IsSelected() )
continue;
item->DeleteStructure();
}
// Ref and value can be flagged, but cannot be deleted
ClearMarkItems( module );
}
/** Mirror marked items, refer to a Vertical axis at position offset
* Note: because this function is used in global transform,
* if force_all is true, all items will be mirrored
*/
void MirrorMarkedItems( MODULE* module, wxPoint offset, bool force_all )
{
#define SETMIRROR( z ) (z) -= offset.x; (z) = -(z); (z) += offset.x;
wxPoint tmp;
wxSize tmpz;
if( module == NULL )
return;
if( module->Reference().IsSelected() || force_all )
module->Reference().Mirror( offset, false );
if( module->Value().IsSelected() || force_all )
module->Value().Mirror( offset, false );
for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
{
// Skip pads not selected, i.e. not inside the block to mirror:
if( !pad->IsSelected() && !force_all )
continue;
tmp = pad->GetPosition();
SETMIRROR( tmp.x );
pad->SetPosition( tmp );
pad->SetX0( pad->GetPosition().x );
tmp = pad->GetOffset();
tmp.x = -tmp.x;
pad->SetOffset( tmp );
tmpz = pad->GetDelta();
tmpz.x = -tmpz.x;
pad->SetDelta( tmpz );
pad->SetOrientation( - pad->GetOrientation() );
}
for( EDA_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() )
{
// Skip items not selected, i.e. not inside the block to mirror:
if( !item->IsSelected() && !force_all )
continue;
switch( item->Type() )
{
case PCB_MODULE_EDGE_T:
((EDGE_MODULE*) item)->Mirror( offset, false );
break;
case PCB_MODULE_TEXT_T:
static_cast<TEXTE_MODULE*>( item )->Mirror( offset, false );
break;
default:
break;
}
}
ClearMarkItems( module );
}
/** Rotate marked items, refer to a rotation point at position offset
* Note: because this function is used in global transform,
* if force_all is true, all items will be rotated
*/
void RotateMarkedItems( MODULE* module, wxPoint offset, bool force_all )
{
#define ROTATE( z ) RotatePoint( (&z), offset, 900 )
if( module == NULL )
return;
if( module->Reference().IsSelected() || force_all )
module->Reference().Rotate( offset, 900 );
if( module->Value().IsSelected() || force_all )
module->Value().Rotate( offset, 900 );
for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() )
{
if( !pad->IsSelected() && !force_all )
continue;
wxPoint pos = pad->GetPos0();
ROTATE( pos );
pad->SetPos0( pos );
pad->SetOrientation( pad->GetOrientation() + 900 );
pad->SetDrawCoord();
}
for( EDA_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() )
{
if( !item->IsSelected() && !force_all )
continue;
switch( item->Type() )
{
case PCB_MODULE_EDGE_T:
((EDGE_MODULE*) item)->Rotate( offset, 900 );
break;
case PCB_MODULE_TEXT_T:
static_cast<TEXTE_MODULE*>( item )->Rotate( offset, 900 );
break;
default:
break;
}
}
ClearMarkItems( module );
}
void ClearMarkItems( MODULE* module )
{
if( module == NULL )
return;
module->Reference().ClearFlags();
module->Value().ClearFlags();
EDA_ITEM* item = module->GraphicalItemsList();
for( ; item != NULL; item = item->Next() )
{
item->ClearFlags();
}
item = module->PadsList();
for( ; item != NULL; item = item->Next() )
{
item->ClearFlags();
}
}
void MoveMarkedItemsExactly( MODULE* module, const wxPoint& centre,
const wxPoint& translation,
double rotation, bool force_all )
{
if( module == NULL )
return;
if( module->Reference().IsSelected() || force_all )
{
module->Reference().Rotate( centre, rotation );
module->Reference().Move( translation );
}
if( module->Value().IsSelected() || force_all )
{
module->Value().Rotate( centre, rotation );
module->Value().Move( translation );
}
D_PAD* pad = module->PadsList();
for( ; pad != NULL; pad = pad->Next() )
{
if( !pad->IsSelected() && !force_all )
continue;
// rotate about centre point,
wxPoint newPos = pad->GetPosition();
RotatePoint( &newPos, centre, rotation );
// shift and update
newPos += translation;
pad->SetPosition( newPos );
pad->SetPos0( newPos );
// finally apply rotation to the pad itself
pad->Rotate( newPos, rotation );
}
EDA_ITEM* item = module->GraphicalItemsList();
for( ; item != NULL; item = item->Next() )
{
if( !item->IsSelected() && !force_all )
continue;
switch( item->Type() )
{
case PCB_MODULE_TEXT_T:
{
TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
text->Rotate( centre, rotation );
text->Move( translation );
break;
}
case PCB_MODULE_EDGE_T:
{
EDGE_MODULE* em = static_cast<EDGE_MODULE*>( item );
em->Rotate( centre, rotation );
em->Move( translation );
break;
}
default:
;
}
}
ClearMarkItems( module );
}
/* Mark items inside rect.
* Items are inside rect when an end point is inside rect
*/
int MarkItemsInBloc( MODULE* module, EDA_RECT& Rect )
{
EDA_ITEM* item;
int ItemsCount = 0;
wxPoint pos;
D_PAD* pad;
if( module == NULL )
return 0;
ClearMarkItems( module ); // Just in case ...
pos = module->Reference().GetTextPos();
if( Rect.Contains( pos ) )
{
module->Reference().SetFlags( SELECTED );
ItemsCount++;
}
pos = module->Value().GetTextPos();
if( Rect.Contains( pos ) )
{
module->Value().SetFlags( SELECTED );
ItemsCount++;
}
pad = module->PadsList();
for( ; pad != NULL; pad = pad->Next() )
{
pad->ClearFlags( SELECTED );
pos = pad->GetPosition();
if( Rect.Contains( pos ) )
{
pad->SetFlags( SELECTED );
ItemsCount++;
}
}
item = module->GraphicalItemsList();
for( ; item != NULL; item = item->Next() )
{
item->ClearFlags( SELECTED );
switch( item->Type() )
{
case PCB_MODULE_EDGE_T:
if( ((EDGE_MODULE*)item )->HitTest( Rect, false ) )
{
item->SetFlags( SELECTED );
ItemsCount++;
}
break;
case PCB_MODULE_TEXT_T:
pos = static_cast<TEXTE_MODULE*>( item )->GetTextPos();
if( Rect.Contains( pos ) )
{
item->SetFlags( SELECTED );
ItemsCount++;
}
break;
default:
break;
}
}
return ItemsCount;
}

View File

@ -276,10 +276,6 @@ bool PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KE
if( GetToolId() == ID_PCB_DELETE_ITEM_BUTT ) if( GetToolId() == ID_PCB_DELETE_ITEM_BUTT )
snapToGrid = false; snapToGrid = false;
// Cursor is left off grid if no block in progress
if( GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK )
snapToGrid = true;
wxPoint curs_pos = pos; wxPoint curs_pos = pos;
wxRealPoint gridSize = GetScreen()->GetGridSize(); wxRealPoint gridSize = GetScreen()->GetGridSize();

View File

@ -142,14 +142,6 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
m_canvas->EndMouseCapture(); m_canvas->EndMouseCapture();
} }
// Should not be executed, just in case
if( GetScreen()->m_BlockLocate.GetCommand() != BLOCK_IDLE )
{
GetScreen()->m_BlockLocate.SetCommand( BLOCK_IDLE );
GetScreen()->m_BlockLocate.SetState( STATE_NO_BLOCK );
GetScreen()->m_BlockLocate.ClearItemsList();
}
if( GetToolId() == ID_NO_TOOL_SELECTED ) if( GetToolId() == ID_NO_TOOL_SELECTED )
SetNoToolSelected(); SetNoToolSelected();
else else
@ -905,11 +897,6 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
moveExact(); moveExact();
break; break;
case ID_POPUP_PCB_DUPLICATE_ITEM:
case ID_POPUP_PCB_DUPLICATE_ITEM_AND_INCREMENT:
duplicateItems( id == ID_POPUP_PCB_DUPLICATE_ITEM_AND_INCREMENT );
break;
case ID_POPUP_PCB_CREATE_ARRAY: case ID_POPUP_PCB_CREATE_ARRAY:
createArray(); createArray();
break; break;
@ -1263,60 +1250,6 @@ void PCB_EDIT_FRAME::moveExact()
} }
void PCB_EDIT_FRAME::duplicateItems( bool aIncrement )
{
BOARD_ITEM* item = GetScreen()->GetCurItem();
if( !item )
return;
// In the board editor, the pads or fp texts can be edited
// but cannot be duplicated (only the fp editor can do that).
// only the footprint can be duplicated
if( item->Type() == PCB_PAD_T || item->Type() == PCB_MODULE_TEXT_T )
item = static_cast<MODULE*>( item )->GetParent();
PCB_BASE_EDIT_FRAME::duplicateItem( item, aIncrement );
}
void PCB_BASE_EDIT_FRAME::duplicateItem( BOARD_ITEM* aItem, bool aIncrement )
{
if( !aItem )
return;
// The easiest way to handle a duplicate item command
// is to simulate a block copy command, which gives us the undo management
// for free
if( GetScreen()->m_BlockLocate.GetState() == STATE_NO_BLOCK )
{
m_canvas->MoveCursorToCrossHair();
INSTALL_UNBUFFERED_DC( dc, m_canvas );
wxPoint crossHairPos = GetCrossHairPosition();
const BLOCK_COMMAND_T blockType = aIncrement ? BLOCK_DUPLICATE_AND_INCREMENT : BLOCK_DUPLICATE;
if( !HandleBlockBegin( &dc, blockType, crossHairPos ) )
return;
// Add the item to the block copy pick list:
PICKED_ITEMS_LIST& itemsList = GetScreen()->m_BlockLocate.GetItems();
ITEM_PICKER picker( NULL, UR_UNSPECIFIED );
picker.SetItem ( aItem );
itemsList.PushItem( picker );
// Set 2 coordinates updated by the mouse, because our simulation
// does not use the mouse to call HandleBlockEnd()
GetScreen()->m_BlockLocate.SetLastCursorPosition( crossHairPos );
GetScreen()->m_BlockLocate.SetEnd( crossHairPos );
HandleBlockEnd( &dc );
}
}
class LEGACY_ARRAY_CREATOR: public ARRAY_CREATOR class LEGACY_ARRAY_CREATOR: public ARRAY_CREATOR
{ {
public: public:

View File

@ -289,20 +289,7 @@ bool PCB_EDIT_FRAME::Files_io_from_id( int id )
} }
case ID_APPEND_FILE: case ID_APPEND_FILE:
{ wxFAIL_MSG( "OBSOLETE! Should have gone though modern toolset." );
int open_ctl;
wxString fileName;
if( !AskLoadBoardFileName( this, &open_ctl, &fileName, true ) )
return false;
if( AppendBoardFile( fileName, open_ctl ) )
{
m_canvas->Refresh();
return true;
}
return false;
}
case ID_NEW_BOARD: case ID_NEW_BOARD:
{ {

View File

@ -147,11 +147,6 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
EVT_MENU( ID_POPUP_MODEDIT_EDIT_LAYER_ALL_EDGE, EVT_MENU( ID_POPUP_MODEDIT_EDIT_LAYER_ALL_EDGE,
FOOTPRINT_EDIT_FRAME::Process_Special_Functions ) FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
// Module transformations
EVT_MENU( ID_MODEDIT_MODULE_ROTATE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_MENU( ID_MODEDIT_MODULE_MIRROR, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_MENU( ID_MODEDIT_MODULE_MOVE_EXACT, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_MENU( ID_PCB_USER_GRID_SETUP, FOOTPRINT_EDIT_FRAME::OnGridSettings ) EVT_MENU( ID_PCB_USER_GRID_SETUP, FOOTPRINT_EDIT_FRAME::OnGridSettings )
// Menu 3D Frame // Menu 3D Frame

View File

@ -95,7 +95,7 @@ public:
* switches currently used canvas (default / Cairo / OpenGL). * switches currently used canvas (default / Cairo / OpenGL).
* It also reinit the layers manager that slightly changes with canvases * It also reinit the layers manager that slightly changes with canvases
*/ */
virtual void OnSwitchCanvas( wxCommandEvent& aEvent ) override; void OnSwitchCanvas( wxCommandEvent& aEvent ) override;
/** /**
* Update the layer manager and other widgets from the board setup * Update the layer manager and other widgets from the board setup
@ -143,7 +143,6 @@ public:
void setupTools(); void setupTools();
void ToolOnRightClick( wxCommandEvent& event ) override; void ToolOnRightClick( wxCommandEvent& event ) override;
void OnSelectOptionToolbar( wxCommandEvent& event );
void OnConfigurePaths( wxCommandEvent& aEvent ); void OnConfigurePaths( wxCommandEvent& aEvent );
void OnToggleSearchTree( wxCommandEvent& event ); void OnToggleSearchTree( wxCommandEvent& event );
@ -225,7 +224,7 @@ public:
* and prepare, if needed the refresh of the 3D frame showing the footprint * and prepare, if needed the refresh of the 3D frame showing the footprint
* do not forget to call the basic OnModify function to update auxiliary info * do not forget to call the basic OnModify function to update auxiliary info
*/ */
virtual void OnModify() override; void OnModify() override;
/** /**
* Install the print dialog * Install the print dialog
@ -241,29 +240,6 @@ public:
*/ */
bool Clear_Pcb( bool aQuery ); bool Clear_Pcb( bool aQuery );
/* handlers for block commands */
virtual int BlockCommand( EDA_KEY key ) override;
/**
* Handle the BLOCK PLACE command.
*
* Last routine for block operation for:
* - block move & drag
* - block copy & paste
*/
virtual void HandleBlockPlace( wxDC* DC ) override;
/**
* Handle the "end" of a block command,
* i.e. is called at the end of the definition of the area of a block.
* depending on the current block command, this command is executed
* or parameters are initialized to prepare a call to HandleBlockPlace
* in GetScreen()->m_BlockLocate
* @return false if no item selected, or command finished,
* true if some items found and HandleBlockPlace must be called later
*/
virtual bool HandleBlockEnd( wxDC* DC ) override;
BOARD_ITEM* ModeditLocateAndDisplay( int aHotKeyCode = 0 ); BOARD_ITEM* ModeditLocateAndDisplay( int aHotKeyCode = 0 );
/// Return the LIB_ID of the part selected in the footprint or the part being edited. /// Return the LIB_ID of the part selected in the footprint or the part being edited.
@ -400,19 +376,19 @@ public:
/** /**
* @return true if the grid must be shown * @return true if the grid must be shown
*/ */
virtual bool IsGridVisible() const override; bool IsGridVisible() const override;
/** /**
* It may be overloaded by derived classes * It may be overloaded by derived classes
* if you want to store/retrieve the grid visibility in configuration. * if you want to store/retrieve the grid visibility in configuration.
* @param aVisible = true if the grid must be shown * @param aVisible = true if the grid must be shown
*/ */
virtual void SetGridVisibility( bool aVisible ) override; void SetGridVisibility( bool aVisible ) override;
/** /**
* @return the color of the grid * @return the color of the grid
*/ */
virtual COLOR4D GetGridColor() override; COLOR4D GetGridColor() override;
///> @copydoc PCB_BASE_FRAME::SetActiveLayer() ///> @copydoc PCB_BASE_FRAME::SetActiveLayer()
void SetActiveLayer( PCB_LAYER_ID aLayer ) override; void SetActiveLayer( PCB_LAYER_ID aLayer ) override;
@ -421,7 +397,7 @@ public:
void OnUpdateLayerAlpha( wxUpdateUIEvent& aEvent ) override; void OnUpdateLayerAlpha( wxUpdateUIEvent& aEvent ) override;
///> @copydoc EDA_DRAW_FRAME::UseGalCanvas() ///> @copydoc EDA_DRAW_FRAME::UseGalCanvas()
virtual void UseGalCanvas( bool aEnable ) override; void UseGalCanvas( bool aEnable ) override;
/** /**
* Load a KiCad board (.kicad_pcb) from \a aFileName. * Load a KiCad board (.kicad_pcb) from \a aFileName.
@ -528,14 +504,6 @@ private:
* user the enter the move delta * user the enter the move delta
*/ */
void moveExact(); void moveExact();
/**
* Duplicate the item under the cursor
*
* @param aIncrement increment the number of pad (if that is what is selected)
*/
void duplicateItems( bool aIncrement ) override;
}; };
#endif // FOOTPRINT_EDIT_FRAME_H #endif // FOOTPRINT_EDIT_FRAME_H

View File

@ -254,14 +254,12 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case wxID_COPY: case wxID_COPY:
case ID_TOOLBARH_PCB_SELECT_LAYER: case ID_TOOLBARH_PCB_SELECT_LAYER:
case ID_MODEDIT_PAD_SETTINGS: case ID_MODEDIT_PAD_SETTINGS:
case ID_POPUP_PCB_APPLY_PAD_SETTINGS:
case ID_POPUP_PCB_COPY_PAD_SETTINGS: case ID_POPUP_PCB_COPY_PAD_SETTINGS:
case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS: case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS:
case ID_POPUP_PCB_STOP_CURRENT_DRAWING: case ID_POPUP_PCB_STOP_CURRENT_DRAWING:
case ID_POPUP_MODEDIT_EDIT_BODY_ITEM: case ID_POPUP_MODEDIT_EDIT_BODY_ITEM:
case ID_POPUP_MODEDIT_EDIT_WIDTH_ALL_EDGE: case ID_POPUP_MODEDIT_EDIT_WIDTH_ALL_EDGE:
case ID_POPUP_MODEDIT_EDIT_LAYER_ALL_EDGE: case ID_POPUP_MODEDIT_EDIT_LAYER_ALL_EDGE:
case ID_POPUP_PCB_DELETE_EDGE:
break; break;
case ID_POPUP_CANCEL_CURRENT_COMMAND: case ID_POPUP_CANCEL_CURRENT_COMMAND:
@ -618,14 +616,6 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
break; break;
case ID_POPUP_PCB_DUPLICATE_ITEM:
duplicateItems( false );
break;
case ID_POPUP_PCB_DUPLICATE_ITEM_AND_INCREMENT:
duplicateItems( true );
break;
case ID_POPUP_PCB_MOVE_EXACT: case ID_POPUP_PCB_MOVE_EXACT:
moveExact(); moveExact();
break; break;
@ -634,11 +624,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
createArray(); createArray();
break; break;
case ID_POPUP_PCB_APPLY_PAD_SETTINGS: // JEY TODO: many (most? all?) of these are legacy-only and can be removed.
SaveCopyInUndoList( GetBoard()->m_Modules, UR_CHANGED );
m_canvas->MoveCursorToCrossHair();
Import_Pad_Settings( (D_PAD*) GetScreen()->GetCurItem(), true );
break;
case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS: case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS:
SaveCopyInUndoList( GetBoard()->m_Modules, UR_CHANGED ); SaveCopyInUndoList( GetBoard()->m_Modules, UR_CHANGED );
@ -678,21 +664,6 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
m_canvas->Refresh(); m_canvas->Refresh();
break; break;
case ID_POPUP_PCB_DELETE_EDGE:
SaveCopyInUndoList( GetBoard()->m_Modules, UR_CHANGED );
m_canvas->MoveCursorToCrossHair();
RemoveStruct( GetScreen()->GetCurItem() );
SetCurItem( NULL );
break;
case ID_MODEDIT_MODULE_ROTATE:
case ID_MODEDIT_MODULE_MIRROR:
case ID_MODEDIT_MODULE_MOVE_EXACT:
SaveCopyInUndoList( GetBoard()->m_Modules, UR_CHANGED );
Transform( (MODULE*) GetScreen()->GetCurItem(), id );
m_canvas->Refresh();
break;
case ID_GEN_IMPORT_GRAPHICS_FILE: case ID_GEN_IMPORT_GRAPHICS_FILE:
if( GetBoard()->m_Modules ) if( GetBoard()->m_Modules )
{ {
@ -759,62 +730,6 @@ void FOOTPRINT_EDIT_FRAME::moveExact()
} }
void FOOTPRINT_EDIT_FRAME::duplicateItems( bool aIncrement )
{
BOARD_ITEM* item = GetScreen()->GetCurItem();
PCB_BASE_EDIT_FRAME::duplicateItem( item, aIncrement );
}
void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform )
{
switch( transform )
{
case ID_MODEDIT_MODULE_ROTATE:
RotateMarkedItems( module, wxPoint(0,0), true );
break;
case ID_MODEDIT_MODULE_MIRROR:
MirrorMarkedItems( module, wxPoint(0,0), true );
break;
case ID_MODEDIT_MODULE_MOVE_EXACT:
{
wxPoint translation;
double rotation;
ROTATION_ANCHOR rotationAnchor = ROTATE_AROUND_ITEM_ANCHOR;
DIALOG_MOVE_EXACT dialog( this, translation, rotation, rotationAnchor );
if( dialog.ShowModal() == wxID_OK )
{
switch( rotationAnchor )
{
case ROTATE_AROUND_ITEM_ANCHOR:
MoveMarkedItemsExactly( module, module->GetPosition() + translation, translation, rotation, true );
break;
case ROTATE_AROUND_USER_ORIGIN:
MoveMarkedItemsExactly( module, GetScreen()->m_O_Curseur, translation, rotation, true );
break;
default:
wxFAIL_MSG( "Rotation choice shouldn't have been available in this context." );
}
}
break;
}
default:
DisplayInfoMessage( this, wxT( "Not available" ) );
break;
}
module->CalculateBoundingBox();
OnModify();
}
void FOOTPRINT_EDIT_FRAME::OnVerticalToolbar( wxCommandEvent& aEvent ) void FOOTPRINT_EDIT_FRAME::OnVerticalToolbar( wxCommandEvent& aEvent )
{ {
int id = aEvent.GetId(); int id = aEvent.GetId();

View File

@ -125,33 +125,3 @@ bool FOOTPRINT_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPos
} }
BOARD_ITEM* FOOTPRINT_EDIT_FRAME::PrepareItemForHotkey( bool aFailIfCurrentlyEdited )
{
BOARD_ITEM* item = GetCurItem();
bool itemCurrentlyEdited = item && item->GetEditFlags();
bool blockActive = GetScreen()->m_BlockLocate.GetCommand() != BLOCK_IDLE;
if( aFailIfCurrentlyEdited )
{
if( itemCurrentlyEdited || blockActive )
return NULL;
item = ModeditLocateAndDisplay();
}
else
{
if( blockActive )
return NULL;
if( !itemCurrentlyEdited )
item = ModeditLocateAndDisplay();
}
// set item if we can, but don't clear if not
if( item )
SetCurItem( item );
return item;
}

View File

@ -382,73 +382,7 @@ void DIALOG_IMPORT_GFX::updatePcbImportOffsets_mm()
// Used only in legacy canvas by the board editor. // Used only in legacy canvas by the board editor.
bool InvokeDialogImportGfxBoard( PCB_BASE_FRAME* aCaller ) bool InvokeDialogImportGfxBoard( PCB_BASE_FRAME* aCaller )
{ {
DIALOG_IMPORT_GFX dlg( aCaller ); // Legacy R.I.P.
if( dlg.ShowModal() != wxID_OK )
return false;
auto& list = dlg.GetImportedItems();
// Ensure the list is not empty:
if( list.empty() )
{
wxMessageBox( _( "No graphic items found in file to import." ) );
return false;
}
PICKED_ITEMS_LIST picklist; // the pick list for undo command
ITEM_PICKER item_picker( nullptr, UR_NEW );
BOARD* board = aCaller->GetBoard();
// Now prepare a block move command to place the new items, if interactive placement,
// and prepare the undo command.
EDA_RECT bbox; // the new items bounding box, for block move if interactive placement.
bool bboxInit = true; // true until the bounding box is initialized
BLOCK_SELECTOR& blockmove = aCaller->GetScreen()->m_BlockLocate;
if( dlg.IsPlacementInteractive() )
aCaller->HandleBlockBegin( NULL, BLOCK_PRESELECT_MOVE, wxPoint( 0, 0 ) );
PICKED_ITEMS_LIST& blockitemsList = blockmove.GetItems();
for( auto it = list.begin(); it != list.end(); ++it )
{
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it->release() );
if( dlg.IsPlacementInteractive() )
item->SetFlags( IS_MOVED );
board->Add( item );
item_picker.SetItem( item );
picklist.PushItem( item_picker );
if( dlg.IsPlacementInteractive() )
{
blockitemsList.PushItem( item_picker );
if( bboxInit )
bbox = item->GetBoundingBox();
else
bbox.Merge( item->GetBoundingBox() );
bboxInit = false;
}
}
aCaller->SaveCopyInUndoList( picklist, UR_NEW, wxPoint( 0, 0 ) );
aCaller->OnModify();
if( dlg.IsPlacementInteractive() )
{
// Finish block move command:
wxPoint cpos = aCaller->GetNearestGridPosition( bbox.Centre() );
blockmove.SetOrigin( bbox.GetOrigin() );
blockmove.SetSize( bbox.GetSize() );
blockmove.SetLastCursorPosition( cpos );
aCaller->HandleBlockEnd( NULL );
}
return true; return true;
} }
@ -456,70 +390,6 @@ bool InvokeDialogImportGfxBoard( PCB_BASE_FRAME* aCaller )
// Used only in legacy canvas by the footprint editor. // Used only in legacy canvas by the footprint editor.
bool InvokeDialogImportGfxModule( PCB_BASE_FRAME* aCaller, MODULE* aModule ) bool InvokeDialogImportGfxModule( PCB_BASE_FRAME* aCaller, MODULE* aModule )
{ {
if( !aModule ) // Legacy R.I.P.
return false;
DIALOG_IMPORT_GFX dlg( aCaller, true );
if( dlg.ShowModal() != wxID_OK )
return false;
auto& list = dlg.GetImportedItems();
// Ensure the list is not empty:
if( list.empty() )
{
wxMessageBox( _( "No graphic items found in file to import" ) );
return false;
}
aCaller->SaveCopyInUndoList( aModule, UR_CHANGED );
PICKED_ITEMS_LIST picklist; // the pick list for undo command
ITEM_PICKER item_picker( nullptr, UR_NEW );
// Now prepare a block move command to place the new items, if interactive placement,
// and prepare the undo command.
EDA_RECT bbox; // the new items bounding box, for block move if interactive placement.
bool bboxInit = true; // true until the bounding box is initialized
BLOCK_SELECTOR& blockmove = aCaller->GetScreen()->m_BlockLocate;
if( dlg.IsPlacementInteractive() )
aCaller->HandleBlockBegin( nullptr, BLOCK_PRESELECT_MOVE, wxPoint( 0, 0 ) );
PICKED_ITEMS_LIST& blockitemsList = blockmove.GetItems();
for( auto it = list.begin(); it != list.end(); ++it )
{
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it->release() );
aModule->Add( item );
if( dlg.IsPlacementInteractive() )
{
item->SetFlags( IS_MOVED );
item_picker.SetItem( item );
blockitemsList.PushItem( item_picker );
if( bboxInit )
bbox = item->GetBoundingBox();
else
bbox.Merge( item->GetBoundingBox() );
bboxInit = false;
}
}
aCaller->OnModify();
if( dlg.IsPlacementInteractive() )
{
// Finish block move command:
wxPoint cpos = aCaller->GetNearestGridPosition( bbox.Centre() );
blockmove.SetOrigin( bbox.GetOrigin() );
blockmove.SetSize( bbox.GetSize() );
blockmove.SetLastCursorPosition( cpos );
aCaller->HandleBlockEnd( NULL );
}
return true; return true;
} }

View File

@ -108,32 +108,29 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
// to keep consistency with the project mgr which expects files names same as prj name // to keep consistency with the project mgr which expects files names same as prj name
// for main files // for main files
if( Kiface().IsSingle() ) if( Kiface().IsSingle() )
fileMenu->AddItem( ACTIONS::saveAs, SELECTION_CONDITIONS::ShowAlways ); fileMenu->AddItem( ACTIONS::saveAs, SELECTION_CONDITIONS::ShowAlways );
else else
fileMenu->AddItem( ACTIONS::saveCopyAs, SELECTION_CONDITIONS::ShowAlways ); fileMenu->AddItem( ACTIONS::saveCopyAs, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddSeparator(); fileMenu->AddSeparator();
fileMenu->AddItem( ID_MENU_RECOVER_BOARD_AUTOSAVE, fileMenu->AddItem( ID_MENU_RECOVER_BOARD_AUTOSAVE,
_( "Resc&ue" ), _( "Resc&ue" ),
_( "Clear board and get last rescue file automatically saved by Pcbnew" ), _( "Clear board and get last rescue file automatically saved by Pcbnew" ),
rescue_xpm, SELECTION_CONDITIONS::ShowAlways ); rescue_xpm, SELECTION_CONDITIONS::ShowAlways );
if( Kiface().IsSingle() ) // not when under a project mgr if( Kiface().IsSingle() ) // not when under a project mgr
{ {
fileMenu->AddItem( ID_APPEND_FILE, fileMenu->AddItem( PCB_ACTIONS::appendBoard, SELECTION_CONDITIONS::ShowAlways );
_( "&Append Board..." ),
_( "Append another board to currently loaded board" ),
add_board_xpm, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddItem( ID_IMPORT_NON_KICAD_BOARD, fileMenu->AddItem( ID_IMPORT_NON_KICAD_BOARD,
_( "Import Non-KiCad Board File..." ), _( "Import Non-KiCad Board File..." ),
_( "Import board file from other applications" ), _( "Import board file from other applications" ),
import_brd_file_xpm, SELECTION_CONDITIONS::ShowAlways ); import_brd_file_xpm, SELECTION_CONDITIONS::ShowAlways );
} }
fileMenu->AddItem( ID_MENU_READ_BOARD_BACKUP_FILE, fileMenu->AddItem( ID_MENU_READ_BOARD_BACKUP_FILE,
_( "Revert to Last Backup" ), _( "Revert to Last Backup" ),
_( "Clear board and get previous backup version of board" ), _( "Clear board and get previous backup version of board" ),
undo_xpm, SELECTION_CONDITIONS::ShowAlways ); undo_xpm, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddSeparator(); fileMenu->AddSeparator();
@ -150,7 +147,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
submenuImport->Add( _( "Graphics..." ), _( "Import 2D drawing file" ), submenuImport->Add( _( "Graphics..." ), _( "Import 2D drawing file" ),
ID_GEN_IMPORT_GRAPHICS_FILE, import_vector_xpm ); ID_GEN_IMPORT_GRAPHICS_FILE, import_vector_xpm );
fileMenu->AddMenu( submenuImport, SELECTION_CONDITIONS::ShowAlways ); fileMenu->AddMenu( submenuImport, SELECTION_CONDITIONS::ShowAlways );
//----- Export submenu ------------------------------------------------------ //----- Export submenu ------------------------------------------------------
ACTION_MENU* submenuExport = new ACTION_MENU(); ACTION_MENU* submenuExport = new ACTION_MENU();
@ -176,7 +173,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
submenuExport->Add( _( "Hyperlynx..." ), "", submenuExport->Add( _( "Hyperlynx..." ), "",
ID_GEN_EXPORT_FILE_HYPERLYNX, export_step_xpm ); ID_GEN_EXPORT_FILE_HYPERLYNX, export_step_xpm );
fileMenu->AddMenu( submenuExport, SELECTION_CONDITIONS::ShowAlways ); fileMenu->AddMenu( submenuExport, SELECTION_CONDITIONS::ShowAlways );
//----- Fabrication Outputs submenu ----------------------------------------- //----- Fabrication Outputs submenu -----------------------------------------
ACTION_MENU* submenuFabOutputs = new ACTION_MENU(); ACTION_MENU* submenuFabOutputs = new ACTION_MENU();
@ -203,13 +200,13 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
_( "Create bill of materials from current schematic" ), _( "Create bill of materials from current schematic" ),
ID_PCB_GEN_BOM_FILE_FROM_BOARD, bom_xpm ); ID_PCB_GEN_BOM_FILE_FROM_BOARD, bom_xpm );
fileMenu->AddMenu( submenuFabOutputs, SELECTION_CONDITIONS::ShowAlways ); fileMenu->AddMenu( submenuFabOutputs, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddSeparator(); fileMenu->AddSeparator();
fileMenu->AddItem( ID_BOARD_SETUP_DIALOG, fileMenu->AddItem( ID_BOARD_SETUP_DIALOG,
_( "&Board Setup..." ), _( "&Board Setup..." ),
_( "Edit board setup including layers, design rules and various defaults" ), _( "Edit board setup including layers, design rules and various defaults" ),
options_board_xpm, SELECTION_CONDITIONS::ShowAlways ); options_board_xpm, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddSeparator(); fileMenu->AddSeparator();
fileMenu->AddItem( ACTIONS::pageSettings, SELECTION_CONDITIONS::ShowAlways ); fileMenu->AddItem( ACTIONS::pageSettings, SELECTION_CONDITIONS::ShowAlways );

View File

@ -10,7 +10,6 @@
#include <common.h> #include <common.h>
#include <class_drawpanel.h> #include <class_drawpanel.h>
#include <trigo.h> #include <trigo.h>
#include <block_commande.h>
#include <pcb_base_frame.h> #include <pcb_base_frame.h>
#include <class_board.h> #include <class_board.h>

View File

@ -196,29 +196,6 @@ protected:
*/ */
void createArray(); void createArray();
/**
* Function duplicateItem
* Duplicate the specified item
* This function is shared between pcbnew and modedit, as it is virtually
* the same
* @param aItem the item to duplicate
* @param aIncrement (has meaning only for pads in footprint editor):
* increment pad name if appropriate
*/
void duplicateItem( BOARD_ITEM* aItem, bool aIncrement );
/**
* Function duplicateItems
* Find and duplicate the currently selected items
* @param aIncrement (has meaning only for pads in footprint editor):
* increment pad name if appropriate
*
* @note The implementer should find the selected item (and do processing
* like finding parents when relevant, and then call
* duplicateItem(BOARD_ITEM*, bool) above
*/
virtual void duplicateItems( bool aIncrement ) = 0;
void unitsChangeRefresh() override; void unitsChangeRefresh() override;
}; };

View File

@ -247,13 +247,6 @@ protected:
*/ */
void moveExact(); void moveExact();
/**
* Function duplicateItems
* Duplicate selected item if possible and start a move
* @param aIncrement increment the item number if appropriate
*/
void duplicateItems( bool aIncrement ) override;
/** /**
* Load the given filename but sets the path to the current project path. * Load the given filename but sets the path to the current project path.
* @param full filepath of file to be imported. * @param full filepath of file to be imported.

View File

@ -70,10 +70,6 @@ using namespace std::placeholders;
* - delete item(s) command * - delete item(s) command
* - change item(s) command * - change item(s) command
* - add item(s) command * - add item(s) command
* and 3 cases for block:
* - move list of items
* - mirror (Y) list of items
* - Flip list of items
* *
* Undo command * Undo command
* - delete item(s) command: * - delete item(s) command: