Access the new paste behaviour via a new Paste Special... dialog
ADDED Paste Special... action in pcbnew CHANGED Additional options for Paste Special... in eeschema, including "Assign unique reference designators to pasted instance"
This commit is contained in:
parent
98c8f43320
commit
f2677340f2
|
@ -179,6 +179,8 @@ set( COMMON_DLG_SRCS
|
|||
dialogs/dialog_migrate_settings.cpp
|
||||
dialogs/dialog_migrate_settings_base.cpp
|
||||
dialogs/dialog_page_settings_base.cpp
|
||||
dialogs/dialog_paste_special.cpp
|
||||
dialogs/dialog_paste_special_base.cpp
|
||||
dialogs/dialog_text_entry_base.cpp
|
||||
dialogs/dialog_page_settings.cpp
|
||||
dialogs/dialog_print_generic.cpp
|
||||
|
|
|
@ -24,13 +24,27 @@
|
|||
#include <dialog_paste_special.h>
|
||||
|
||||
|
||||
static bool g_keepAnnotations = true;
|
||||
static PASTE_MODE g_paste_mode = PASTE_MODE::UNIQUE_ANNOTATIONS;
|
||||
|
||||
|
||||
DIALOG_PASTE_SPECIAL::DIALOG_PASTE_SPECIAL( wxWindow* parent, bool* aKeep ) :
|
||||
DIALOG_PASTE_SPECIAL_BASE( parent ),
|
||||
m_keep( aKeep )
|
||||
DIALOG_PASTE_SPECIAL::DIALOG_PASTE_SPECIAL( wxWindow* aParent,
|
||||
PASTE_MODE* aMode,
|
||||
wxString aReplacement ) :
|
||||
DIALOG_PASTE_SPECIAL_BASE( aParent ),
|
||||
m_mode( aMode )
|
||||
{
|
||||
m_pasteOptions->SetItemToolTip( static_cast<int>( PASTE_MODE::UNIQUE_ANNOTATIONS ),
|
||||
_( "Finds the next available reference designator for "
|
||||
"any designators that already exist in the design." ) );
|
||||
|
||||
m_pasteOptions->SetItemToolTip( static_cast<int>( PASTE_MODE::KEEP_ANNOTATIONS ),
|
||||
wxT( "" ) ); // Self explanatory
|
||||
|
||||
m_pasteOptions->SetItemToolTip( static_cast<int>( PASTE_MODE::REMOVE_ANNOTATIONS ),
|
||||
wxString::Format( _( "Replaces reference designators "
|
||||
"with '%s'." ),
|
||||
aReplacement ) );
|
||||
|
||||
// Now all widgets have the size fixed, call FinishDialogSettings
|
||||
finishDialogSettings();
|
||||
}
|
||||
|
@ -38,13 +52,13 @@ DIALOG_PASTE_SPECIAL::DIALOG_PASTE_SPECIAL( wxWindow* parent, bool* aKeep ) :
|
|||
|
||||
bool DIALOG_PASTE_SPECIAL::TransferDataToWindow()
|
||||
{
|
||||
m_keepAnnotations->SetValue( g_keepAnnotations );
|
||||
m_pasteOptions->SetSelection( static_cast<int>( g_paste_mode ) );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool DIALOG_PASTE_SPECIAL::TransferDataFromWindow()
|
||||
{
|
||||
g_keepAnnotations = *m_keep = m_keepAnnotations->GetValue();
|
||||
g_paste_mode = *m_mode = static_cast<PASTE_MODE>( m_pasteOptions->GetSelection() );
|
||||
return true;
|
||||
}
|
|
@ -31,18 +31,26 @@
|
|||
|
||||
class SCH_SHEET_PIN;
|
||||
|
||||
enum class PASTE_MODE
|
||||
{
|
||||
UNIQUE_ANNOTATIONS = 0,
|
||||
KEEP_ANNOTATIONS = 1,
|
||||
REMOVE_ANNOTATIONS = 2
|
||||
};
|
||||
|
||||
|
||||
class DIALOG_PASTE_SPECIAL : public DIALOG_PASTE_SPECIAL_BASE
|
||||
{
|
||||
|
||||
public:
|
||||
DIALOG_PASTE_SPECIAL( wxWindow* parent, bool* aKeepAnnotations );
|
||||
DIALOG_PASTE_SPECIAL( wxWindow* aParent, PASTE_MODE* aMode,
|
||||
wxString aReplacement = wxT( "?" ) );
|
||||
|
||||
bool TransferDataToWindow() override;
|
||||
bool TransferDataFromWindow() override;
|
||||
|
||||
private:
|
||||
bool* m_keep;
|
||||
PASTE_MODE* m_mode;
|
||||
};
|
||||
|
||||
#endif // DIALOG_PASTE_SPECIAL_H
|
|
@ -19,12 +19,11 @@ DIALOG_PASTE_SPECIAL_BASE::DIALOG_PASTE_SPECIAL_BASE( wxWindow* parent, wxWindow
|
|||
wxBoxSizer* optionsSizer;
|
||||
optionsSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_staticText7 = new wxStaticText( this, wxID_ANY, _("Paste Options"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText7->Wrap( -1 );
|
||||
optionsSizer->Add( m_staticText7, 0, wxALL, 5 );
|
||||
|
||||
m_keepAnnotations = new wxCheckBox( this, wxID_ANY, _("Keep existing annotations, even if they are duplicated"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
optionsSizer->Add( m_keepAnnotations, 0, wxALL, 5 );
|
||||
wxString m_pasteOptionsChoices[] = { _("Assign unique reference designators to pasted symbols"), _("Keep existing reference designators, even if they are duplicated"), _("Clear reference designators on all pasted symbols") };
|
||||
int m_pasteOptionsNChoices = sizeof( m_pasteOptionsChoices ) / sizeof( wxString );
|
||||
m_pasteOptions = new wxRadioBox( this, wxID_ANY, _("Paste Options"), wxDefaultPosition, wxDefaultSize, m_pasteOptionsNChoices, m_pasteOptionsChoices, 1, wxRA_SPECIFY_COLS );
|
||||
m_pasteOptions->SetSelection( 1 );
|
||||
optionsSizer->Add( m_pasteOptions, 0, wxALL, 5 );
|
||||
|
||||
|
||||
m_mainSizer->Add( optionsSizer, 1, wxALL|wxEXPAND, 10 );
|
|
@ -71,7 +71,7 @@
|
|||
<property name="border">5</property>
|
||||
<property name="flag">wxALL</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxStaticText" expanded="1">
|
||||
<object class="wxRadioBox" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
|
@ -85,6 +85,7 @@
|
|||
<property name="caption"></property>
|
||||
<property name="caption_visible">1</property>
|
||||
<property name="center_pane">0</property>
|
||||
<property name="choices">"Assign unique reference designators to pasted symbols" "Keep existing reference designators, even if they are duplicated" "Clear reference designators on all pasted symbols"</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
|
@ -100,7 +101,7 @@
|
|||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Paste Options</property>
|
||||
<property name="markup">0</property>
|
||||
<property name="majorDimension">1</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
|
@ -108,7 +109,7 @@
|
|||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_staticText7</property>
|
||||
<property name="name">m_pasteOptions</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
|
@ -116,70 +117,10 @@
|
|||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="selection">1</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style"></property>
|
||||
<property name="subclass">; ; forward_declare</property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<property name="wrap">-1</property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALL</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxCheckBox" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
<property name="caption_visible">1</property>
|
||||
<property name="center_pane">0</property>
|
||||
<property name="checked">0</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="default_pane">0</property>
|
||||
<property name="dock">Dock</property>
|
||||
<property name="dock_fixed">0</property>
|
||||
<property name="docking">Left</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="fg"></property>
|
||||
<property name="floatable">1</property>
|
||||
<property name="font"></property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Keep existing annotations, even if they are duplicated</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_keepAnnotations</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style"></property>
|
||||
<property name="style">wxRA_SPECIFY_COLS</property>
|
||||
<property name="subclass">; ; forward_declare</property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
|
@ -12,12 +12,11 @@
|
|||
#include <wx/intl.h>
|
||||
#include "dialog_shim.h"
|
||||
#include <wx/string.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/radiobox.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/font.h>
|
||||
#include <wx/colour.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/checkbox.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/statline.h>
|
||||
#include <wx/button.h>
|
||||
|
@ -34,8 +33,7 @@ class DIALOG_PASTE_SPECIAL_BASE : public DIALOG_SHIM
|
|||
private:
|
||||
|
||||
protected:
|
||||
wxStaticText* m_staticText7;
|
||||
wxCheckBox* m_keepAnnotations;
|
||||
wxRadioBox* m_pasteOptions;
|
||||
wxStaticLine* m_staticline1;
|
||||
wxStdDialogButtonSizer* m_sdbSizer;
|
||||
wxButton* m_sdbSizerOK;
|
|
@ -85,8 +85,6 @@ set( EESCHEMA_DLGS
|
|||
dialogs/dialog_migrate_buses_base.cpp
|
||||
dialogs/dialog_netlist.cpp
|
||||
dialogs/dialog_netlist_base.cpp
|
||||
dialogs/dialog_paste_special.cpp
|
||||
dialogs/dialog_paste_special_base.cpp
|
||||
dialogs/dialog_pin_properties.cpp
|
||||
dialogs/dialog_pin_properties_base.cpp
|
||||
dialogs/dialog_plot_schematic.cpp
|
||||
|
|
|
@ -1450,30 +1450,29 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
|
|||
paste_screen->Append( new SCH_TEXT( wxPoint( 0, 0 ), text ) );
|
||||
}
|
||||
|
||||
bool forceKeepAnnotations = false;
|
||||
|
||||
// Save loaded screen instances to m_clipboardSheetInstances
|
||||
setClipboardInstances( paste_screen );
|
||||
|
||||
PASTE_MODE pasteMode = PASTE_MODE::REMOVE_ANNOTATIONS;
|
||||
|
||||
if( aEvent.IsAction( &ACTIONS::pasteSpecial ) )
|
||||
{
|
||||
DIALOG_PASTE_SPECIAL dlg( m_frame, &forceKeepAnnotations );
|
||||
DIALOG_PASTE_SPECIAL dlg( m_frame, &pasteMode );
|
||||
|
||||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool reannotateOnPaste = !forceKeepAnnotations;
|
||||
forceKeepAnnotations = true; // Always keep annotations of pasted instances
|
||||
bool forceKeepAnnotations = pasteMode != PASTE_MODE::REMOVE_ANNOTATIONS;
|
||||
|
||||
// SCH_SEXP_PLUGIN added the items to the paste screen, but not to the view or anything
|
||||
// else. Pull them back out to start with.
|
||||
//
|
||||
EDA_ITEMS loadedItems;
|
||||
bool sheetsPasted = false;
|
||||
SCH_SHEET_LIST hierarchy = m_frame->Schematic().GetSheets();
|
||||
SCH_SHEET_PATH& pasteRoot = m_frame->GetCurrentSheet();
|
||||
wxFileName destFn = pasteRoot.Last()->GetFileName();
|
||||
SCH_SHEET_LIST hierarchy = m_frame->Schematic().GetSheets();
|
||||
SCH_SHEET_PATH& pasteRoot = m_frame->GetCurrentSheet();
|
||||
wxFileName destFn = pasteRoot.Last()->GetFileName();
|
||||
|
||||
if( destFn.IsRelative() )
|
||||
destFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
|
||||
|
@ -1688,7 +1687,7 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent )
|
|||
|
||||
pasteInstances.SortByPageNumbers();
|
||||
|
||||
if( reannotateOnPaste )
|
||||
if( pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS )
|
||||
{
|
||||
for( SCH_SHEET_PATH& instance : pasteInstances )
|
||||
{
|
||||
|
|
|
@ -193,6 +193,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
|
|||
editMenu->Add( ACTIONS::cut );
|
||||
editMenu->Add( ACTIONS::copy );
|
||||
editMenu->Add( ACTIONS::paste );
|
||||
editMenu->Add( ACTIONS::pasteSpecial );
|
||||
editMenu->Add( ACTIONS::doDelete );
|
||||
|
||||
editMenu->AppendSeparator();
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <board_commit.h>
|
||||
#include <board.h>
|
||||
#include <board_item.h>
|
||||
#include <dialogs/dialog_paste_special.h>
|
||||
#include <dimension.h>
|
||||
#include <footprint.h>
|
||||
#include <track.h>
|
||||
|
@ -632,6 +633,17 @@ int PCB_CONTROL::Paste( const TOOL_EVENT& aEvent )
|
|||
if( !frame()->IsType( FRAME_FOOTPRINT_EDITOR ) && !frame()->IsType( FRAME_PCB_EDITOR ) )
|
||||
return 0;
|
||||
|
||||
PASTE_MODE pasteMode = PASTE_MODE::KEEP_ANNOTATIONS;
|
||||
const wxString defaultRef = wxT( "REF**" );
|
||||
|
||||
if( aEvent.IsAction( &ACTIONS::pasteSpecial ) )
|
||||
{
|
||||
DIALOG_PASTE_SPECIAL dlg( m_frame, &pasteMode, defaultRef );
|
||||
|
||||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool isFootprintEditor = m_isFootprintEditor || frame()->IsType( FRAME_FOOTPRINT_EDITOR );
|
||||
|
||||
if( clipItem->Type() == PCB_T )
|
||||
|
@ -698,11 +710,18 @@ int PCB_CONTROL::Paste( const TOOL_EVENT& aEvent )
|
|||
|
||||
delete clipBoard;
|
||||
|
||||
placeBoardItems( pastedItems, true, true );
|
||||
placeBoardItems( pastedItems, true, true,
|
||||
pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS );
|
||||
}
|
||||
else
|
||||
{
|
||||
placeBoardItems( clipBoard, true );
|
||||
if( pasteMode == PASTE_MODE::REMOVE_ANNOTATIONS )
|
||||
{
|
||||
for( FOOTPRINT* clipFootprint : clipBoard->Footprints() )
|
||||
clipFootprint->SetReference( defaultRef );
|
||||
}
|
||||
|
||||
placeBoardItems( clipBoard, true, pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS );
|
||||
|
||||
m_frame->GetBoard()->BuildConnectivity();
|
||||
m_frame->Compile_Ratsnest( true );
|
||||
|
@ -723,11 +742,14 @@ int PCB_CONTROL::Paste( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else
|
||||
{
|
||||
if( pasteMode == PASTE_MODE::REMOVE_ANNOTATIONS )
|
||||
clipFootprint->SetReference( defaultRef );
|
||||
|
||||
clipFootprint->SetParent( board() );
|
||||
pastedItems.push_back( clipFootprint );
|
||||
}
|
||||
|
||||
placeBoardItems( pastedItems, true, true );
|
||||
placeBoardItems( pastedItems, true, true, pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -820,7 +842,7 @@ static void moveUnflaggedItems( ZONES& aList, std::vector<BOARD_ITEM*>& aTarget,
|
|||
|
||||
|
||||
|
||||
int PCB_CONTROL::placeBoardItems( BOARD* aBoard, bool aAnchorAtOrigin )
|
||||
int PCB_CONTROL::placeBoardItems( BOARD* aBoard, bool aAnchorAtOrigin, bool aReannotateDuplicates )
|
||||
{
|
||||
// items are new if the current board is not the board source
|
||||
bool isNew = board() != aBoard;
|
||||
|
@ -838,12 +860,12 @@ int PCB_CONTROL::placeBoardItems( BOARD* aBoard, bool aAnchorAtOrigin )
|
|||
// selection created aBoard that has the group and all descendents in it.
|
||||
moveUnflaggedItems( aBoard->Groups(), items, isNew );
|
||||
|
||||
return placeBoardItems( items, isNew, aAnchorAtOrigin );
|
||||
return placeBoardItems( items, isNew, aAnchorAtOrigin, aReannotateDuplicates );
|
||||
}
|
||||
|
||||
|
||||
int PCB_CONTROL::placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew,
|
||||
bool aAnchorAtOrigin )
|
||||
bool aAnchorAtOrigin, bool aReannotateDuplicates )
|
||||
{
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||
|
||||
|
@ -903,7 +925,8 @@ int PCB_CONTROL::placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew,
|
|||
m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &itemsToSel );
|
||||
|
||||
// Reannotate duplicate footprints
|
||||
m_toolMgr->GetTool<BOARD_REANNOTATE_TOOL>()->ReannotateDuplicatesInSelection();
|
||||
if( aReannotateDuplicates )
|
||||
m_toolMgr->GetTool<BOARD_REANNOTATE_TOOL>()->ReannotateDuplicatesInSelection();
|
||||
|
||||
for( BOARD_ITEM* item : aItems )
|
||||
{
|
||||
|
@ -1024,7 +1047,7 @@ int PCB_CONTROL::AppendBoard( PLUGIN& pi, wxString& fileName )
|
|||
brd->SetEnabledLayers( enabledLayers );
|
||||
brd->SetVisibleLayers( enabledLayers );
|
||||
|
||||
return placeBoardItems( brd, false );
|
||||
return placeBoardItems( brd, false, false ); // Do not reannotate duplicates on Append Board
|
||||
}
|
||||
|
||||
|
||||
|
@ -1201,6 +1224,7 @@ void PCB_CONTROL::setTransitions()
|
|||
Go( &PCB_CONTROL::AppendBoardFromFile, PCB_ACTIONS::appendBoard.MakeEvent() );
|
||||
|
||||
Go( &PCB_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
|
||||
Go( &PCB_CONTROL::Paste, ACTIONS::pasteSpecial.MakeEvent() );
|
||||
|
||||
Go( &PCB_CONTROL::UpdateMessagePanel, EVENTS::SelectedEvent );
|
||||
Go( &PCB_CONTROL::UpdateMessagePanel, EVENTS::UnselectedEvent );
|
||||
|
|
|
@ -107,10 +107,13 @@ private:
|
|||
* items are already managed by the current board
|
||||
* @param aAnchorAtOrigin = true if the items are translated so that the anchor is {0, 0}
|
||||
* (if false, the top-left item's origin will be used)
|
||||
* @param aReannotateDuplicates = true to reannotate any footprints with a designator
|
||||
that already exist in the board.
|
||||
*/
|
||||
int placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew, bool aAnchorAtOrigin );
|
||||
int placeBoardItems( std::vector<BOARD_ITEM*>& aItems, bool aIsNew, bool aAnchorAtOrigin,
|
||||
bool aReannotateDuplicates );
|
||||
|
||||
int placeBoardItems( BOARD* aBoard, bool aAnchorAtOrigin );
|
||||
int placeBoardItems( BOARD* aBoard, bool aAnchorAtOrigin, bool aReannotateDuplicates );
|
||||
|
||||
///< Pointer to the currently used edit frame.
|
||||
PCB_BASE_FRAME* m_frame;
|
||||
|
|
Loading…
Reference in New Issue