|
|
@ -56,6 +56,8 @@ using namespace std::placeholders; |
|
|
|
#include <dialogs/dialog_move_exact.h>
|
|
|
|
#include <dialogs/dialog_track_via_properties.h>
|
|
|
|
|
|
|
|
#include <board_commit.h>
|
|
|
|
|
|
|
|
EDIT_TOOL::EDIT_TOOL() : |
|
|
|
PCB_TOOL( "pcbnew.InteractiveEdit" ), m_selectionTool( NULL ), |
|
|
|
m_dragging( false ), m_undoInhibit( 0 ), m_updateFlag( KIGFX::VIEW_ITEM::NONE ) |
|
|
@ -67,6 +69,9 @@ void EDIT_TOOL::Reset( RESET_REASON aReason ) |
|
|
|
{ |
|
|
|
m_dragging = false; |
|
|
|
m_updateFlag = KIGFX::VIEW_ITEM::NONE; |
|
|
|
|
|
|
|
if( aReason != RUN ) |
|
|
|
m_commit.reset( new BOARD_COMMIT( this ) ); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -214,11 +219,10 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) |
|
|
|
lockOverride = true; |
|
|
|
|
|
|
|
// Save items, so changes can be undone
|
|
|
|
if( !isUndoInhibited() ) |
|
|
|
selection.ForAll<BOARD_ITEM>( [&](BOARD_ITEM* item) |
|
|
|
{ |
|
|
|
editFrame->OnModify(); |
|
|
|
editFrame->SaveCopyInUndoList( selection.items, UR_CHANGED ); |
|
|
|
} |
|
|
|
m_commit->Modify( item ); |
|
|
|
} ); |
|
|
|
|
|
|
|
m_cursor = controls->GetCursorPosition(); |
|
|
|
|
|
|
@ -243,6 +247,8 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) |
|
|
|
|
|
|
|
controls->SetAutoPan( true ); |
|
|
|
m_dragging = true; |
|
|
|
|
|
|
|
// Do not save intermediate modifications when an item is dragged
|
|
|
|
incUndoInhibit(); |
|
|
|
} |
|
|
|
} |
|
|
@ -254,6 +260,8 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) |
|
|
|
// Dispatch TOOL_ACTIONs
|
|
|
|
else if( evt->Category() == TC_COMMAND ) |
|
|
|
{ |
|
|
|
wxPoint modPoint = getModificationPoint( selection ); |
|
|
|
|
|
|
|
if( evt->IsAction( &COMMON_ACTIONS::rotate ) ) |
|
|
|
{ |
|
|
|
Rotate( aEvent ); |
|
|
@ -301,6 +309,14 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) |
|
|
|
//MoveExact( aEvent );
|
|
|
|
break; // exit the loop - we move exactly, so we have finished moving
|
|
|
|
} |
|
|
|
|
|
|
|
if( m_dragging ) |
|
|
|
{ |
|
|
|
// Update dragging offset (distance between cursor and the first dragged item)
|
|
|
|
m_offset = selection.Item<BOARD_ITEM>( 0 )->GetPosition() - modPoint; |
|
|
|
selection.group->ViewUpdate( KIGFX::VIEW_ITEM::ALL ); |
|
|
|
updateRatsnest( true ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) ) |
|
|
@ -319,24 +335,13 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) |
|
|
|
m_offset.x = 0; |
|
|
|
m_offset.y = 0; |
|
|
|
|
|
|
|
if( restore ) |
|
|
|
{ |
|
|
|
// Modifications have to be rollbacked, so restore the previous state of items
|
|
|
|
wxCommandEvent dummy; |
|
|
|
editFrame->RestoreCopyFromUndoList( dummy ); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
// Changes are applied, so update the items
|
|
|
|
selection.group->ItemsViewUpdate( m_updateFlag ); |
|
|
|
} |
|
|
|
|
|
|
|
if( unselect ) |
|
|
|
if( unselect || restore ) |
|
|
|
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true ); |
|
|
|
|
|
|
|
RN_DATA* ratsnest = getModel<BOARD>()->GetRatsnest(); |
|
|
|
ratsnest->ClearSimple(); |
|
|
|
ratsnest->Recalculate(); |
|
|
|
if( restore ) |
|
|
|
m_commit->Revert(); |
|
|
|
else |
|
|
|
m_commit->Push( _( "Drag" ) ); |
|
|
|
|
|
|
|
controls->ShowCursor( false ); |
|
|
|
controls->SetAutoPan( false ); |
|
|
@ -363,17 +368,8 @@ int EDIT_TOOL::Properties( const TOOL_EVENT& aEvent ) |
|
|
|
|
|
|
|
if( dlg.ShowModal() ) |
|
|
|
{ |
|
|
|
RN_DATA* ratsnest = getModel<BOARD>()->GetRatsnest(); |
|
|
|
|
|
|
|
editFrame->OnModify(); |
|
|
|
editFrame->SaveCopyInUndoList( selection.items, UR_CHANGED ); |
|
|
|
dlg.Apply(); |
|
|
|
|
|
|
|
selection.ForAll<KIGFX::VIEW_ITEM>( std::bind( &KIGFX::VIEW_ITEM::ViewUpdate, |
|
|
|
std::placeholders::_1, KIGFX::VIEW_ITEM::ALL ) ); |
|
|
|
selection.ForAll<BOARD_ITEM>( std::bind( &RN_DATA::Update, ratsnest, |
|
|
|
std::placeholders::_1 ) ); |
|
|
|
ratsnest->Recalculate(); |
|
|
|
dlg.Apply( *m_commit ); |
|
|
|
m_commit->Push( _( "Edit track/via properties" ) ); |
|
|
|
} |
|
|
|
} |
|
|
|
else if( selection.Size() == 1 ) // Properties are displayed when there is only one item selected
|
|
|
@ -381,34 +377,18 @@ int EDIT_TOOL::Properties( const TOOL_EVENT& aEvent ) |
|
|
|
// Display properties dialog
|
|
|
|
BOARD_ITEM* item = selection.Item<BOARD_ITEM>( 0 ); |
|
|
|
|
|
|
|
// Store the head of the undo list to compare if anything has changed
|
|
|
|
std::vector<PICKED_ITEMS_LIST*>& undoList = editFrame->GetScreen()->m_UndoList.m_CommandsList; |
|
|
|
|
|
|
|
// Some of properties dialogs alter pointers, so we should deselect them
|
|
|
|
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true ); |
|
|
|
|
|
|
|
// Store flags, so they can be restored later
|
|
|
|
STATUS_FLAGS flags = item->GetFlags(); |
|
|
|
item->ClearFlags(); |
|
|
|
|
|
|
|
// It is necessary to determine if anything has changed, so store the current undo save point
|
|
|
|
PICKED_ITEMS_LIST* undoSavePoint = undoList.empty() ? NULL : undoList.back(); |
|
|
|
|
|
|
|
// Do not handle undo buffer, it is done by the properties dialogs
|
|
|
|
// Display properties dialog provided by the legacy canvas frame
|
|
|
|
editFrame->OnEditItemRequest( NULL, item ); |
|
|
|
|
|
|
|
if( !undoList.empty() && undoList.back() != undoSavePoint ) // Undo buffer has changed
|
|
|
|
{ |
|
|
|
// Process changes stored after undoSavePoint
|
|
|
|
processUndoBuffer( undoSavePoint ); |
|
|
|
|
|
|
|
// Update the modified item
|
|
|
|
item->ViewUpdate(); |
|
|
|
RN_DATA* ratsnest = getModel<BOARD>()->GetRatsnest(); |
|
|
|
ratsnest->Recalculate(); |
|
|
|
|
|
|
|
// TODO OBSERVER! I miss you so much..
|
|
|
|
m_toolMgr->RunAction( COMMON_ACTIONS::pointEditorUpdate, true ); |
|
|
|
} |
|
|
|
|
|
|
|
m_toolMgr->RunAction( COMMON_ACTIONS::pointEditorUpdate, true ); |
|
|
|
item->SetFlags( flags ); |
|
|
|
} |
|
|
|
|
|
|
@ -432,37 +412,20 @@ int EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent ) |
|
|
|
|
|
|
|
wxPoint rotatePoint = getModificationPoint( selection ); |
|
|
|
|
|
|
|
// If it is being dragged, then it is already saved with UR_CHANGED flag
|
|
|
|
if( !isUndoInhibited() ) |
|
|
|
{ |
|
|
|
editFrame->OnModify(); |
|
|
|
editFrame->SaveCopyInUndoList( selection.items, UR_ROTATED, rotatePoint ); |
|
|
|
} |
|
|
|
|
|
|
|
for( unsigned int i = 0; i < selection.items.GetCount(); ++i ) |
|
|
|
{ |
|
|
|
BOARD_ITEM* item = selection.Item<BOARD_ITEM>( i ); |
|
|
|
|
|
|
|
m_commit->Modify( item ); |
|
|
|
item->Rotate( rotatePoint, editFrame->GetRotationAngle() ); |
|
|
|
|
|
|
|
if( !m_dragging ) |
|
|
|
item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); |
|
|
|
} |
|
|
|
|
|
|
|
updateRatsnest( m_dragging ); |
|
|
|
|
|
|
|
// Update dragging offset (distance between cursor and the first dragged item)
|
|
|
|
m_offset = static_cast<BOARD_ITEM*>( selection.items.GetPickedItem( 0 ) )->GetPosition() - |
|
|
|
rotatePoint; |
|
|
|
|
|
|
|
if( m_dragging ) |
|
|
|
selection.group->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); |
|
|
|
else |
|
|
|
getModel<BOARD>()->GetRatsnest()->Recalculate(); |
|
|
|
if( !isUndoInhibited() ) |
|
|
|
m_commit->Push( _( "Rotate" ) ); |
|
|
|
|
|
|
|
if( unselect ) |
|
|
|
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true ); |
|
|
|
|
|
|
|
// TODO selectionModified
|
|
|
|
m_toolMgr->RunAction( COMMON_ACTIONS::pointEditorUpdate, true ); |
|
|
|
|
|
|
|
return 0; |
|
|
@ -472,7 +435,6 @@ int EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent ) |
|
|
|
int EDIT_TOOL::Flip( const TOOL_EVENT& aEvent ) |
|
|
|
{ |
|
|
|
const SELECTION& selection = m_selectionTool->GetSelection(); |
|
|
|
PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>(); |
|
|
|
|
|
|
|
// Shall the selection be cleared at the end?
|
|
|
|
bool unselect = selection.Empty(); |
|
|
@ -482,32 +444,15 @@ int EDIT_TOOL::Flip( const TOOL_EVENT& aEvent ) |
|
|
|
|
|
|
|
wxPoint flipPoint = getModificationPoint( selection ); |
|
|
|
|
|
|
|
if( !isUndoInhibited() ) // If it is being dragged, then it is already saved with UR_CHANGED flag
|
|
|
|
{ |
|
|
|
editFrame->OnModify(); |
|
|
|
editFrame->SaveCopyInUndoList( selection.items, UR_FLIPPED, flipPoint ); |
|
|
|
} |
|
|
|
|
|
|
|
for( unsigned int i = 0; i < selection.items.GetCount(); ++i ) |
|
|
|
{ |
|
|
|
BOARD_ITEM* item = selection.Item<BOARD_ITEM>( i ); |
|
|
|
|
|
|
|
m_commit->Modify( item ); |
|
|
|
item->Flip( flipPoint ); |
|
|
|
|
|
|
|
if( !m_dragging ) |
|
|
|
item->ViewUpdate( KIGFX::VIEW_ITEM::LAYERS ); |
|
|
|
} |
|
|
|
|
|
|
|
updateRatsnest( m_dragging ); |
|
|
|
|
|
|
|
// Update dragging offset (distance between cursor and the first dragged item)
|
|
|
|
m_offset = static_cast<BOARD_ITEM*>( selection.items.GetPickedItem( 0 ) )->GetPosition() - |
|
|
|
flipPoint; |
|
|
|
|
|
|
|
if( m_dragging ) |
|
|
|
selection.group->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); |
|
|
|
else |
|
|
|
getModel<BOARD>()->GetRatsnest()->Recalculate(); |
|
|
|
if( !isUndoInhibited() ) |
|
|
|
m_commit->Push( _( "Flip" ) ); |
|
|
|
|
|
|
|
if( unselect ) |
|
|
|
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true ); |
|
|
@ -520,91 +465,24 @@ int EDIT_TOOL::Flip( const TOOL_EVENT& aEvent ) |
|
|
|
|
|
|
|
int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent ) |
|
|
|
{ |
|
|
|
const SELECTION& selection = m_selectionTool->GetSelection(); |
|
|
|
|
|
|
|
if( !hoverSelection() || m_selectionTool->CheckLock() == SELECTION_LOCKED ) |
|
|
|
return 0; |
|
|
|
|
|
|
|
// Get a copy of the selected items set
|
|
|
|
PICKED_ITEMS_LIST selectedItems = selection.items; |
|
|
|
PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>(); |
|
|
|
// Get a copy instead of a reference, as we are going to clear current selection
|
|
|
|
SELECTION selection = m_selectionTool->GetSelection(); |
|
|
|
|
|
|
|
// As we are about to remove items, they have to be removed from the selection first
|
|
|
|
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true ); |
|
|
|
|
|
|
|
editFrame->OnModify(); |
|
|
|
editFrame->SaveCopyInUndoList( selectedItems, UR_DELETED ); |
|
|
|
|
|
|
|
// And now remove
|
|
|
|
for( unsigned int i = 0; i < selectedItems.GetCount(); ++i ) |
|
|
|
remove( static_cast<BOARD_ITEM*>( selectedItems.GetPickedItem( i ) ) ); |
|
|
|
|
|
|
|
getModel<BOARD>()->GetRatsnest()->Recalculate(); |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void EDIT_TOOL::remove( BOARD_ITEM* aItem ) |
|
|
|
{ |
|
|
|
BOARD* board = getModel<BOARD>(); |
|
|
|
|
|
|
|
switch( aItem->Type() ) |
|
|
|
{ |
|
|
|
case PCB_MODULE_T: |
|
|
|
{ |
|
|
|
MODULE* module = static_cast<MODULE*>( aItem ); |
|
|
|
module->ClearFlags(); |
|
|
|
module->RunOnChildren( std::bind( &KIGFX::VIEW::Remove, getView(), std::placeholders::_1 ) ); |
|
|
|
|
|
|
|
// Module itself is deleted after the switch scope is finished
|
|
|
|
// list of pads is rebuild by BOARD::BuildListOfNets()
|
|
|
|
|
|
|
|
// Clear flags to indicate, that the ratsnest, list of nets & pads are not valid anymore
|
|
|
|
board->m_Status_Pcb = 0; |
|
|
|
} |
|
|
|
break; |
|
|
|
|
|
|
|
// Default removal procedure
|
|
|
|
case PCB_MODULE_TEXT_T: |
|
|
|
for( unsigned int i = 0; i < selection.items.GetCount(); ++i ) |
|
|
|
{ |
|
|
|
TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( aItem ); |
|
|
|
|
|
|
|
switch( text->GetType() ) |
|
|
|
{ |
|
|
|
case TEXTE_MODULE::TEXT_is_REFERENCE: |
|
|
|
DisplayError( getEditFrame<PCB_BASE_FRAME>(), _( "Cannot delete component reference." ) ); |
|
|
|
return; |
|
|
|
|
|
|
|
case TEXTE_MODULE::TEXT_is_VALUE: |
|
|
|
DisplayError( getEditFrame<PCB_BASE_FRAME>(), _( "Cannot delete component value." ) ); |
|
|
|
return; |
|
|
|
|
|
|
|
case TEXTE_MODULE::TEXT_is_DIVERS: // suppress warnings
|
|
|
|
break; |
|
|
|
} |
|
|
|
BOARD_ITEM* item = selection.Item<BOARD_ITEM>( i ); |
|
|
|
m_commit->Remove( item ); |
|
|
|
} |
|
|
|
|
|
|
|
case PCB_PAD_T: |
|
|
|
case PCB_MODULE_EDGE_T: |
|
|
|
case PCB_LINE_T: // a segment not on copper layers
|
|
|
|
case PCB_TEXT_T: // a text on a layer
|
|
|
|
case PCB_TRACE_T: // a track segment (segment on a copper layer)
|
|
|
|
case PCB_VIA_T: // a via (like track segment on a copper layer)
|
|
|
|
case PCB_DIMENSION_T: // a dimension (graphic item)
|
|
|
|
case PCB_TARGET_T: // a target (graphic item)
|
|
|
|
case PCB_MARKER_T: // a marker used to show something
|
|
|
|
case PCB_ZONE_T: // SEG_ZONE items are now deprecated
|
|
|
|
case PCB_ZONE_AREA_T: |
|
|
|
break; |
|
|
|
|
|
|
|
default: // other types do not need to (or should not) be handled
|
|
|
|
assert( false ); |
|
|
|
return; |
|
|
|
} |
|
|
|
m_commit->Push( _( "Delete" ) ); |
|
|
|
|
|
|
|
getView()->Remove( aItem ); |
|
|
|
getEditFrame<PCB_EDIT_FRAME>()->GetModel()->Remove( aItem ); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -628,13 +506,6 @@ int EDIT_TOOL::MoveExact( const TOOL_EVENT& aEvent ) |
|
|
|
|
|
|
|
if( ret == wxID_OK ) |
|
|
|
{ |
|
|
|
if( !isUndoInhibited() ) |
|
|
|
{ |
|
|
|
editFrame->OnModify(); |
|
|
|
// Record an action of move and rotate
|
|
|
|
editFrame->SaveCopyInUndoList( selection.items, UR_CHANGED ); |
|
|
|
} |
|
|
|
|
|
|
|
VECTOR2I rp = selection.GetCenter(); |
|
|
|
wxPoint rotPoint( rp.x, rp.y ); |
|
|
|
|
|
|
@ -642,6 +513,7 @@ int EDIT_TOOL::MoveExact( const TOOL_EVENT& aEvent ) |
|
|
|
{ |
|
|
|
BOARD_ITEM* item = selection.Item<BOARD_ITEM>( i ); |
|
|
|
|
|
|
|
m_commit->Modify( item ); |
|
|
|
item->Move( translation ); |
|
|
|
item->Rotate( rotPoint, rotation ); |
|
|
|
|
|
|
@ -649,12 +521,8 @@ int EDIT_TOOL::MoveExact( const TOOL_EVENT& aEvent ) |
|
|
|
item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); |
|
|
|
} |
|
|
|
|
|
|
|
updateRatsnest( m_dragging ); |
|
|
|
|
|
|
|
if( m_dragging ) |
|
|
|
selection.group->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); |
|
|
|
else |
|
|
|
getModel<BOARD>()->GetRatsnest()->Recalculate(); |
|
|
|
if( !isUndoInhibited() ) |
|
|
|
m_commit->Push( _( "Move exact" ) ); |
|
|
|
|
|
|
|
if( unselect ) |
|
|
|
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true ); |
|
|
@ -681,9 +549,7 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent ) |
|
|
|
return 0; |
|
|
|
|
|
|
|
// we have a selection to work on now, so start the tool process
|
|
|
|
|
|
|
|
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>(); |
|
|
|
editFrame->OnModify(); |
|
|
|
|
|
|
|
// prevent other tools making undo points while the duplicate is going on
|
|
|
|
// so that if you cancel, you don't get a duplicate object hiding over
|
|
|
@ -711,9 +577,8 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent ) |
|
|
|
|
|
|
|
BOARD_ITEM* new_item = NULL; |
|
|
|
|
|
|
|
// TODO move DuplicateAndAddItem() to BOARD_ITEM_CONTAINER? dunno..
|
|
|
|
if( m_editModules ) |
|
|
|
new_item = editFrame->GetBoard()->m_Modules->Duplicate( item, increment, true ); |
|
|
|
new_item = editFrame->GetBoard()->m_Modules->Duplicate( item, increment ); |
|
|
|
else |
|
|
|
{ |
|
|
|
#if 0
|
|
|
@ -722,18 +587,12 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent ) |
|
|
|
// so zones are not duplicated
|
|
|
|
if( item->Type() != PCB_ZONE_AREA_T ) |
|
|
|
#endif
|
|
|
|
new_item = editFrame->GetBoard()->Duplicate( item, true ); |
|
|
|
new_item = editFrame->GetBoard()->Duplicate( item ); |
|
|
|
} |
|
|
|
|
|
|
|
if( new_item ) |
|
|
|
{ |
|
|
|
if( new_item->Type() == PCB_MODULE_T ) |
|
|
|
{ |
|
|
|
static_cast<MODULE*>( new_item )->RunOnChildren( std::bind( &KIGFX::VIEW::Add, |
|
|
|
getView(), std::placeholders::_1 ) ); |
|
|
|
} |
|
|
|
|
|
|
|
editFrame->GetGalCanvas()->GetView()->Add( new_item ); |
|
|
|
m_commit->Add( new_item ); |
|
|
|
|
|
|
|
// Select the new item, so we can pick it up
|
|
|
|
m_toolMgr->RunAction( COMMON_ACTIONS::selectItem, true, new_item ); |
|
|
@ -743,13 +602,11 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent ) |
|
|
|
// record the new items as added
|
|
|
|
if( !selection.Empty() ) |
|
|
|
{ |
|
|
|
editFrame->SaveCopyInUndoList( selection.items, UR_NEW ); |
|
|
|
|
|
|
|
editFrame->DisplayToolMsg( wxString::Format( _( "Duplicated %d item(s)" ), |
|
|
|
(int) old_items.size() ) ); |
|
|
|
|
|
|
|
// If items were duplicated, pick them up
|
|
|
|
// this works well for "dropping" copies around
|
|
|
|
// this works well for "dropping" copies around and pushes the commit
|
|
|
|
TOOL_EVENT evt = COMMON_ACTIONS::editActivate.MakeEvent(); |
|
|
|
Main( evt ); |
|
|
|
} |
|
|
@ -766,11 +623,9 @@ class GAL_ARRAY_CREATOR: public ARRAY_CREATOR |
|
|
|
public: |
|
|
|
|
|
|
|
GAL_ARRAY_CREATOR( PCB_BASE_FRAME& editFrame, bool editModules, |
|
|
|
RN_DATA* ratsnest, |
|
|
|
const SELECTION& selection ): |
|
|
|
ARRAY_CREATOR( editFrame ), |
|
|
|
m_editModules( editModules ), |
|
|
|
m_ratsnest( ratsnest ), |
|
|
|
m_selection( selection ) |
|
|
|
{} |
|
|
|
|
|
|
@ -813,24 +668,13 @@ private: |
|
|
|
|
|
|
|
void postPushAction( BOARD_ITEM* new_item ) //override
|
|
|
|
{ |
|
|
|
KIGFX::VIEW* view = m_parent.GetToolManager()->GetView(); |
|
|
|
if( new_item->Type() == PCB_MODULE_T) |
|
|
|
{ |
|
|
|
static_cast<MODULE*>(new_item)->RunOnChildren( |
|
|
|
std::bind(&KIGFX::VIEW::Add, view, std::placeholders::_1)); |
|
|
|
} |
|
|
|
|
|
|
|
m_parent.GetGalCanvas()->GetView()->Add( new_item ); |
|
|
|
m_ratsnest->Update( new_item ); |
|
|
|
} |
|
|
|
|
|
|
|
void finalise() // override
|
|
|
|
{ |
|
|
|
m_ratsnest->Recalculate(); |
|
|
|
} |
|
|
|
|
|
|
|
bool m_editModules; |
|
|
|
RN_DATA* m_ratsnest; |
|
|
|
const SELECTION& m_selection; |
|
|
|
}; |
|
|
|
|
|
|
@ -846,14 +690,8 @@ int EDIT_TOOL::CreateArray( const TOOL_EVENT& aEvent ) |
|
|
|
return 0; |
|
|
|
|
|
|
|
// we have a selection to work on now, so start the tool process
|
|
|
|
|
|
|
|
PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>(); |
|
|
|
editFrame->OnModify(); |
|
|
|
|
|
|
|
GAL_ARRAY_CREATOR array_creator( *editFrame, m_editModules, |
|
|
|
getModel<BOARD>()->GetRatsnest(), |
|
|
|
selection ); |
|
|
|
|
|
|
|
GAL_ARRAY_CREATOR array_creator( *editFrame, m_editModules, selection ); |
|
|
|
array_creator.Invoke(); |
|
|
|
|
|
|
|
return 0; |
|
|
@ -937,73 +775,6 @@ bool EDIT_TOOL::hoverSelection( bool aSanitize ) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void EDIT_TOOL::processUndoBuffer( const PICKED_ITEMS_LIST* aLastChange ) |
|
|
|
{ |
|
|
|
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>(); |
|
|
|
const std::vector<PICKED_ITEMS_LIST*>& undoList = editFrame->GetScreen()->m_UndoList.m_CommandsList; |
|
|
|
bool process = false; |
|
|
|
|
|
|
|
for( const PICKED_ITEMS_LIST* list : undoList ) |
|
|
|
{ |
|
|
|
if( process ) |
|
|
|
processPickedList( list ); |
|
|
|
else if( list == aLastChange ) |
|
|
|
process = true; // Start processing starting with the next undo save point
|
|
|
|
} |
|
|
|
|
|
|
|
// If we could not find the requested save point in the current undo list
|
|
|
|
// then the undo list must have been completely altered, so process everything
|
|
|
|
if( !process ) |
|
|
|
{ |
|
|
|
for( const PICKED_ITEMS_LIST* list : undoList ) |
|
|
|
processPickedList( list ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void EDIT_TOOL::processPickedList( const PICKED_ITEMS_LIST* aList ) |
|
|
|
{ |
|
|
|
KIGFX::VIEW* view = getView(); |
|
|
|
RN_DATA* ratsnest = getModel<BOARD>()->GetRatsnest(); |
|
|
|
|
|
|
|
for( unsigned int i = 0; i < aList->GetCount(); ++i ) |
|
|
|
{ |
|
|
|
UNDO_REDO_T operation = aList->GetPickedItemStatus( i ); |
|
|
|
BOARD_ITEM* updItem = static_cast<BOARD_ITEM*>( aList->GetPickedItem( i ) ); |
|
|
|
|
|
|
|
switch( operation ) |
|
|
|
{ |
|
|
|
case UR_CHANGED: |
|
|
|
ratsnest->Update( updItem ); |
|
|
|
updItem->ViewUpdate( KIGFX::VIEW_ITEM::ALL ); |
|
|
|
break; |
|
|
|
|
|
|
|
case UR_DELETED: |
|
|
|
if( updItem->Type() == PCB_MODULE_T ) |
|
|
|
static_cast<MODULE*>( updItem )->RunOnChildren( std::bind( &KIGFX::VIEW::Remove, |
|
|
|
view, std::placeholders::_1 ) ); |
|
|
|
|
|
|
|
view->Remove( updItem ); |
|
|
|
//ratsnest->Remove( updItem ); // this is done in BOARD::Remove
|
|
|
|
break; |
|
|
|
|
|
|
|
case UR_NEW: |
|
|
|
if( updItem->Type() == PCB_MODULE_T ) |
|
|
|
static_cast<MODULE*>( updItem )->RunOnChildren( std::bind( &KIGFX::VIEW::Add, |
|
|
|
view, std::placeholders::_1 ) ); |
|
|
|
|
|
|
|
view->Add( updItem ); |
|
|
|
//ratsnest->Add( updItem ); // this is done in BOARD::Add
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
assert( false ); // Not handled
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int EDIT_TOOL::editFootprintInFpEditor( const TOOL_EVENT& aEvent ) |
|
|
|
{ |
|
|
|
const SELECTION& selection = m_selectionTool->GetSelection(); |
|
|
@ -1019,7 +790,7 @@ int EDIT_TOOL::editFootprintInFpEditor( const TOOL_EVENT& aEvent ) |
|
|
|
|
|
|
|
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>(); |
|
|
|
|
|
|
|
editFrame-> SetCurItem( mod ); |
|
|
|
editFrame->SetCurItem( mod ); |
|
|
|
|
|
|
|
if( editFrame->GetCurItem()->GetTimeStamp() == 0 ) // Module Editor needs a non null timestamp
|
|
|
|
{ |
|
|
|