Pcbnew: when update PCB from schematic, spread footprints also in legacy mode. Remove also one useless undo command level after update.
This commit is contained in:
parent
4ee344e150
commit
89f9b7df5c
|
@ -1562,11 +1562,15 @@ public:
|
||||||
* board edges, if aSpreadAreaPosition is incorrectly chosen.
|
* board edges, if aSpreadAreaPosition is incorrectly chosen.
|
||||||
* @param aSpreadAreaPosition the position of the upper left corner of the
|
* @param aSpreadAreaPosition the position of the upper left corner of the
|
||||||
* area used to spread footprints
|
* area used to spread footprints
|
||||||
|
* @param aPrepareUndoCommand = true (defualt) to commit a undo command for the
|
||||||
|
* spread footprints, false to do just the spread command
|
||||||
|
* (no undo specific to this move command)
|
||||||
*/
|
*/
|
||||||
void SpreadFootprints( std::vector<MODULE*>* aFootprints,
|
void SpreadFootprints( std::vector<MODULE*>* aFootprints,
|
||||||
bool aMoveFootprintsOutsideBoardOnly,
|
bool aMoveFootprintsOutsideBoardOnly,
|
||||||
bool aCheckForBoardEdges,
|
bool aCheckForBoardEdges,
|
||||||
wxPoint aSpreadAreaPosition );
|
wxPoint aSpreadAreaPosition,
|
||||||
|
bool aPrepareUndoCommand = true );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function AutoPlaceModule
|
* Function AutoPlaceModule
|
||||||
|
|
|
@ -167,13 +167,15 @@ void moveFootprintsInArea( CRectPlacement& aPlacementArea,
|
||||||
static bool sortFootprintsbySheetPath( MODULE* ref, MODULE* compare );
|
static bool sortFootprintsbySheetPath( MODULE* ref, MODULE* compare );
|
||||||
|
|
||||||
/* Function to move components in a rectangular area format 4 / 3,
|
/* Function to move components in a rectangular area format 4 / 3,
|
||||||
* starting from the mouse cursor
|
* starting from the mouse cursor.
|
||||||
* The components with the FIXED status set are not moved
|
* Footprints are grouped by sheet.
|
||||||
|
* Components with the LOCKED status set are not moved
|
||||||
*/
|
*/
|
||||||
void PCB_EDIT_FRAME::SpreadFootprints( std::vector<MODULE*>* aFootprints,
|
void PCB_EDIT_FRAME::SpreadFootprints( std::vector<MODULE*>* aFootprints,
|
||||||
bool aMoveFootprintsOutsideBoardOnly,
|
bool aMoveFootprintsOutsideBoardOnly,
|
||||||
bool aCheckForBoardEdges,
|
bool aCheckForBoardEdges,
|
||||||
wxPoint aSpreadAreaPosition )
|
wxPoint aSpreadAreaPosition,
|
||||||
|
bool aPrepareUndoCommand )
|
||||||
{
|
{
|
||||||
EDA_RECT bbox = GetBoard()->ComputeBoundingBox( true );
|
EDA_RECT bbox = GetBoard()->ComputeBoundingBox( true );
|
||||||
bool edgesExist = bbox.GetWidth() || bbox.GetHeight();
|
bool edgesExist = bbox.GetWidth() || bbox.GetHeight();
|
||||||
|
@ -216,17 +218,23 @@ void PCB_EDIT_FRAME::SpreadFootprints( std::vector<MODULE*>* aFootprints,
|
||||||
// sort footprints by sheet path. we group them later by sheet
|
// sort footprints by sheet path. we group them later by sheet
|
||||||
sort( footprintList.begin(), footprintList.end(), sortFootprintsbySheetPath );
|
sort( footprintList.begin(), footprintList.end(), sortFootprintsbySheetPath );
|
||||||
|
|
||||||
// Undo command: init undo list
|
// Undo command: init undo list. If aPrepareUndoCommand == false
|
||||||
|
// no undo command will be initialized.
|
||||||
|
// Useful when a undo command is already initialized by the caller
|
||||||
PICKED_ITEMS_LIST undoList;
|
PICKED_ITEMS_LIST undoList;
|
||||||
undoList.m_Status = UR_CHANGED;
|
|
||||||
ITEM_PICKER picker( NULL, UR_CHANGED );
|
|
||||||
|
|
||||||
for( MODULE* footprint : footprintList )
|
if( aPrepareUndoCommand )
|
||||||
{
|
{
|
||||||
// Undo: add copy of the footprint to undo list
|
undoList.m_Status = UR_CHANGED;
|
||||||
picker.SetItem( footprint );
|
ITEM_PICKER picker( NULL, UR_CHANGED );
|
||||||
picker.SetLink( footprint->Clone() );
|
|
||||||
undoList.PushItem( picker );
|
for( MODULE* footprint : footprintList )
|
||||||
|
{
|
||||||
|
// Undo: add copy of the footprint to undo list
|
||||||
|
picker.SetItem( footprint );
|
||||||
|
picker.SetLink( footprint->Clone() );
|
||||||
|
undoList.PushItem( picker );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract and place footprints by sheet
|
// Extract and place footprints by sheet
|
||||||
|
@ -348,7 +356,9 @@ void PCB_EDIT_FRAME::SpreadFootprints( std::vector<MODULE*>* aFootprints,
|
||||||
} // End pass
|
} // End pass
|
||||||
|
|
||||||
// Undo: commit list
|
// Undo: commit list
|
||||||
SaveCopyInUndoList( undoList, UR_CHANGED );
|
if( aPrepareUndoCommand )
|
||||||
|
SaveCopyInUndoList( undoList, UR_CHANGED );
|
||||||
|
|
||||||
OnModify();
|
OnModify();
|
||||||
|
|
||||||
m_canvas->Refresh();
|
m_canvas->Refresh();
|
||||||
|
|
|
@ -250,7 +250,8 @@ void PCB_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
|
||||||
{
|
{
|
||||||
NETLIST netlist;
|
NETLIST netlist;
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
STRING_LINE_READER* lineReader = new STRING_LINE_READER( payload, _( "EEschema netlist" ) );
|
STRING_LINE_READER* lineReader = new STRING_LINE_READER( payload, _( "EEschema netlist" ) );
|
||||||
KICAD_NETLIST_READER netlistReader( lineReader, &netlist );
|
KICAD_NETLIST_READER netlistReader( lineReader, &netlist );
|
||||||
netlistReader.LoadNetlist();
|
netlistReader.LoadNetlist();
|
||||||
|
|
|
@ -1,3 +1,30 @@
|
||||||
|
/**
|
||||||
|
* @file pcbnew/dialogs/dialog_update_pcb.cpp
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 1992-2016 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
|
||||||
|
*/
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <wxPcbStruct.h>
|
#include <wxPcbStruct.h>
|
||||||
#include <pcb_netlist.h>
|
#include <pcb_netlist.h>
|
||||||
|
@ -7,6 +34,7 @@
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
#include <tools/common_actions.h>
|
#include <tools/common_actions.h>
|
||||||
#include <class_draw_panel_gal.h>
|
#include <class_draw_panel_gal.h>
|
||||||
|
#include <class_drawpanel.h>
|
||||||
#include <class_board.h>
|
#include <class_board.h>
|
||||||
#include <ratsnest_data.h>
|
#include <ratsnest_data.h>
|
||||||
|
|
||||||
|
@ -40,6 +68,10 @@ void DIALOG_UPDATE_PCB::PerformUpdate( bool aDryRun )
|
||||||
TOOL_MANAGER* toolManager = m_frame->GetToolManager();
|
TOOL_MANAGER* toolManager = m_frame->GetToolManager();
|
||||||
BOARD* board = m_frame->GetBoard();
|
BOARD* board = m_frame->GetBoard();
|
||||||
|
|
||||||
|
// keep trace of the initial baord area, if we want to place new footprints
|
||||||
|
// outside the existinag board
|
||||||
|
EDA_RECT bbox = board->ComputeBoundingBox( false );
|
||||||
|
|
||||||
if( !aDryRun )
|
if( !aDryRun )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -81,13 +113,24 @@ void DIALOG_UPDATE_PCB::PerformUpdate( bool aDryRun )
|
||||||
m_frame->SetCurItem( NULL );
|
m_frame->SetCurItem( NULL );
|
||||||
m_frame->SetMsgPanel( board );
|
m_frame->SetMsgPanel( board );
|
||||||
|
|
||||||
|
std::vector<MODULE*> newFootprints = updater.GetAddedComponents();
|
||||||
|
|
||||||
|
// Spread new footprints.
|
||||||
|
wxPoint areaPosition = m_frame->GetCrossHairPosition();
|
||||||
|
|
||||||
|
if( !m_frame->IsGalCanvasActive() )
|
||||||
|
{
|
||||||
|
// In legacy mode place area to the left side of the board.
|
||||||
|
// if the board is empty, the bbox position is (0,0)
|
||||||
|
areaPosition.x = bbox.GetEnd().x + Millimeter2iu( 10 );
|
||||||
|
areaPosition.y = bbox.GetOrigin().y;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_frame->SpreadFootprints( &newFootprints, false, false, areaPosition, false );
|
||||||
|
|
||||||
if( m_frame->IsGalCanvasActive() )
|
if( m_frame->IsGalCanvasActive() )
|
||||||
{
|
{
|
||||||
std::vector<MODULE*> newFootprints = updater.GetAddedComponents();
|
// Start move and place the new modules command
|
||||||
|
|
||||||
// Place the new modules
|
|
||||||
m_frame->SpreadFootprints( &newFootprints, false, false, m_frame->GetCrossHairPosition() );
|
|
||||||
|
|
||||||
if( !newFootprints.empty() )
|
if( !newFootprints.empty() )
|
||||||
{
|
{
|
||||||
for( MODULE* footprint : newFootprints )
|
for( MODULE* footprint : newFootprints )
|
||||||
|
@ -98,6 +141,8 @@ void DIALOG_UPDATE_PCB::PerformUpdate( bool aDryRun )
|
||||||
toolManager->InvokeTool( "pcbnew.InteractiveEdit" );
|
toolManager->InvokeTool( "pcbnew.InteractiveEdit" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else // Legacy canvas
|
||||||
|
m_frame->GetCanvas()->Refresh();
|
||||||
|
|
||||||
m_btnPerformUpdate->Enable( false );
|
m_btnPerformUpdate->Enable( false );
|
||||||
m_btnPerformUpdate->SetLabel( _( "Update complete" ) );
|
m_btnPerformUpdate->SetLabel( _( "Update complete" ) );
|
||||||
|
@ -112,12 +157,6 @@ void DIALOG_UPDATE_PCB::OnMatchChange( wxCommandEvent& event )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DIALOG_UPDATE_PCB::OnCancelClick( wxCommandEvent& event )
|
|
||||||
{
|
|
||||||
EndModal( wxID_CANCEL );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void DIALOG_UPDATE_PCB::OnUpdateClick( wxCommandEvent& event )
|
void DIALOG_UPDATE_PCB::OnUpdateClick( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
m_messagePanel->SetLabel( _( "Changes applied to the PCB:" ) );
|
m_messagePanel->SetLabel( _( "Changes applied to the PCB:" ) );
|
||||||
|
|
|
@ -539,7 +539,7 @@
|
||||||
<property name="window_extra_style"></property>
|
<property name="window_extra_style"></property>
|
||||||
<property name="window_name"></property>
|
<property name="window_name"></property>
|
||||||
<property name="window_style"></property>
|
<property name="window_style"></property>
|
||||||
<event name="OnButtonClick">OnCancelClick</event>
|
<event name="OnButtonClick"></event>
|
||||||
<event name="OnChar"></event>
|
<event name="OnChar"></event>
|
||||||
<event name="OnEnterWindow"></event>
|
<event name="OnEnterWindow"></event>
|
||||||
<event name="OnEraseBackground"></event>
|
<event name="OnEraseBackground"></event>
|
||||||
|
|
|
@ -5,7 +5,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) 1992-2012 KiCad Developers, see change_log.txt for contributors.
|
* Copyright (C) 1992-2016 KiCad Developers, see change_log.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
|
||||||
|
@ -48,7 +48,6 @@ public:
|
||||||
private:
|
private:
|
||||||
|
|
||||||
virtual void OnMatchChange( wxCommandEvent& event ) override;
|
virtual void OnMatchChange( wxCommandEvent& event ) override;
|
||||||
virtual void OnCancelClick( wxCommandEvent& event ) override;
|
|
||||||
virtual void OnUpdateClick( wxCommandEvent& event ) override;
|
virtual void OnUpdateClick( wxCommandEvent& event ) override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// C++ code generated with wxFormBuilder (version Jun 6 2014)
|
// C++ code generated with wxFormBuilder (version Sep 8 2016)
|
||||||
// http://www.wxformbuilder.org/
|
// http://www.wxformbuilder.org/
|
||||||
//
|
//
|
||||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||||
|
@ -70,7 +70,6 @@ DIALOG_UPDATE_PCB_BASE::DIALOG_UPDATE_PCB_BASE( wxWindow* parent, wxWindowID id,
|
||||||
// Connect Events
|
// Connect Events
|
||||||
m_matchByReference->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_UPDATE_PCB_BASE::OnMatchChange ), NULL, this );
|
m_matchByReference->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_UPDATE_PCB_BASE::OnMatchChange ), NULL, this );
|
||||||
m_matchByTimestamp->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_UPDATE_PCB_BASE::OnMatchChange ), NULL, this );
|
m_matchByTimestamp->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_UPDATE_PCB_BASE::OnMatchChange ), NULL, this );
|
||||||
m_btnCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_UPDATE_PCB_BASE::OnCancelClick ), NULL, this );
|
|
||||||
m_btnPerformUpdate->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_UPDATE_PCB_BASE::OnUpdateClick ), NULL, this );
|
m_btnPerformUpdate->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_UPDATE_PCB_BASE::OnUpdateClick ), NULL, this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +78,6 @@ DIALOG_UPDATE_PCB_BASE::~DIALOG_UPDATE_PCB_BASE()
|
||||||
// Disconnect Events
|
// Disconnect Events
|
||||||
m_matchByReference->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_UPDATE_PCB_BASE::OnMatchChange ), NULL, this );
|
m_matchByReference->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_UPDATE_PCB_BASE::OnMatchChange ), NULL, this );
|
||||||
m_matchByTimestamp->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_UPDATE_PCB_BASE::OnMatchChange ), NULL, this );
|
m_matchByTimestamp->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_UPDATE_PCB_BASE::OnMatchChange ), NULL, this );
|
||||||
m_btnCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_UPDATE_PCB_BASE::OnCancelClick ), NULL, this );
|
|
||||||
m_btnPerformUpdate->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_UPDATE_PCB_BASE::OnUpdateClick ), NULL, this );
|
m_btnPerformUpdate->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_UPDATE_PCB_BASE::OnUpdateClick ), NULL, this );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// C++ code generated with wxFormBuilder (version Jun 6 2014)
|
// C++ code generated with wxFormBuilder (version Sep 8 2016)
|
||||||
// http://www.wxformbuilder.org/
|
// http://www.wxformbuilder.org/
|
||||||
//
|
//
|
||||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||||
|
@ -46,7 +46,6 @@ class DIALOG_UPDATE_PCB_BASE : public DIALOG_SHIM
|
||||||
|
|
||||||
// Virtual event handlers, overide them in your derived class
|
// Virtual event handlers, overide them in your derived class
|
||||||
virtual void OnMatchChange( wxCommandEvent& event ) { event.Skip(); }
|
virtual void OnMatchChange( wxCommandEvent& event ) { event.Skip(); }
|
||||||
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
|
|
||||||
virtual void OnUpdateClick( wxCommandEvent& event ) { event.Skip(); }
|
virtual void OnUpdateClick( wxCommandEvent& event ) { event.Skip(); }
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ void PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFileName,
|
||||||
std::vector<MODULE*> newFootprints;
|
std::vector<MODULE*> newFootprints;
|
||||||
// keep trace of the initial baord area, if we want to place new footprints
|
// keep trace of the initial baord area, if we want to place new footprints
|
||||||
// outside the existinag board
|
// outside the existinag board
|
||||||
EDA_RECT bbox = GetBoard()->ComputeBoundingBox( false );
|
EDA_RECT bbox = board->ComputeBoundingBox( false );
|
||||||
|
|
||||||
netlist.SetIsDryRun( aIsDryRun );
|
netlist.SetIsDryRun( aIsDryRun );
|
||||||
netlist.SetFindByTimeStamp( aSelectByTimeStamp );
|
netlist.SetFindByTimeStamp( aSelectByTimeStamp );
|
||||||
|
|
Loading…
Reference in New Issue