Eeschema: added Copy option in labels and component in pop up menu (and 'C' hotkey)
This commit is contained in:
parent
c4b37d77bd
commit
34728bec70
|
@ -79,6 +79,7 @@ set(EESCHEMA_SRCS
|
|||
eeschema.cpp
|
||||
eeschema_config.cpp
|
||||
erc.cpp
|
||||
events_called_functions_for_edit.cpp
|
||||
files-io.cpp
|
||||
find.cpp
|
||||
getpart.cpp
|
||||
|
|
|
@ -45,6 +45,8 @@ enum id_eeschema_frm
|
|||
ID_SCHEMATIC_VERTICAL_TOOLBAR_END,
|
||||
|
||||
/* Schematic editor context menu IDs. */
|
||||
ID_POPUP_SCH_COPY_ITEM,
|
||||
|
||||
ID_POPUP_START_RANGE,
|
||||
ID_POPUP_SCH_DELETE,
|
||||
ID_POPUP_SCH_BREAK_WIRE,
|
||||
|
@ -84,7 +86,6 @@ enum id_eeschema_frm
|
|||
ID_POPUP_SCH_EDIT_REF_CMP,
|
||||
ID_POPUP_SCH_EDIT_FOOTPRINT_CMP,
|
||||
ID_POPUP_SCH_EDIT_CONVERT_CMP,
|
||||
ID_POPUP_SCH_COPY_COMPONENT_CMP,
|
||||
ID_POPUP_SCH_SELECT_UNIT_CMP,
|
||||
ID_POPUP_SCH_SELECT_UNIT1,
|
||||
ID_POPUP_SCH_SELECT_UNIT2,
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* events_called_functions.cpp
|
||||
* some events functions
|
||||
*/
|
||||
#include "fctsys.h"
|
||||
#include "gr_basic.h"
|
||||
#include "common.h"
|
||||
#include "class_drawpanel.h"
|
||||
#include "program.h"
|
||||
#include "general.h"
|
||||
#include "kicad_device_context.h"
|
||||
|
||||
#include "protos.h"
|
||||
|
||||
/** Event function WinEDA_SchematicFrame::OnCopySchematicItemRequest
|
||||
* duplicate the current located item
|
||||
*/
|
||||
void WinEDA_SchematicFrame::OnCopySchematicItemRequest( wxCommandEvent& event )
|
||||
{
|
||||
SCH_ITEM * curr_item = GetScreen()->GetCurItem();
|
||||
|
||||
if( !curr_item || curr_item->m_Flags )
|
||||
return;
|
||||
|
||||
INSTALL_DC( dc, DrawPanel );
|
||||
|
||||
switch( curr_item->Type() )
|
||||
{
|
||||
case TYPE_SCH_COMPONENT:
|
||||
{
|
||||
SCH_COMPONENT* newitem;
|
||||
newitem = ((SCH_COMPONENT*) curr_item)->GenCopy();
|
||||
newitem->m_TimeStamp = GetTimeStamp();
|
||||
newitem->ClearAnnotation( NULL );
|
||||
newitem->m_Flags = IS_NEW;
|
||||
StartMovePart( newitem, &dc );
|
||||
|
||||
/* Redraw the original part, because StartMovePart() erased
|
||||
* it from screen */
|
||||
RedrawOneStruct( DrawPanel, &dc, curr_item, GR_DEFAULT_DRAWMODE );
|
||||
}
|
||||
break;
|
||||
|
||||
case TYPE_SCH_TEXT:
|
||||
case TYPE_SCH_LABEL:
|
||||
case TYPE_SCH_GLOBALLABEL:
|
||||
case TYPE_SCH_HIERLABEL:
|
||||
{
|
||||
SCH_TEXT* newitem = ((SCH_TEXT*) curr_item)->GenCopy();
|
||||
newitem->m_Flags = IS_NEW;
|
||||
StartMoveTexte( newitem, &dc );
|
||||
/* Redraw the original part in XOR mode */
|
||||
RedrawOneStruct( DrawPanel, &dc, curr_item, g_XorMode );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -83,9 +83,14 @@ static Ki_HotkeyInfo HkEditComponentValue( wxT( "Edit Component Value" ),
|
|||
static Ki_HotkeyInfo HkEditComponentFootprint( wxT( "Edit Component Footprint" ),
|
||||
HK_EDIT_COMPONENT_FOOTPRINT,
|
||||
'F' );
|
||||
static Ki_HotkeyInfo HkMoveComponent( wxT( "Move Component or Label" ),
|
||||
static Ki_HotkeyInfo HkMoveComponentOrText( wxT( "Move Component or Label" ),
|
||||
HK_MOVE_COMPONENT_OR_LABEL, 'M',
|
||||
ID_POPUP_SCH_MOVE_CMP_REQUEST );
|
||||
|
||||
static Ki_HotkeyInfo HkCopyComponentOrText( wxT( "Copy Component or Label" ),
|
||||
HK_COPY_COMPONENT_OR_LABEL, 'C',
|
||||
ID_POPUP_SCH_COPY_ITEM );
|
||||
|
||||
static Ki_HotkeyInfo HkDragComponent( wxT( "Drag Component" ),
|
||||
HK_DRAG_COMPONENT, 'G',
|
||||
ID_POPUP_SCH_DRAG_CMP_REQUEST );
|
||||
|
@ -122,7 +127,8 @@ Ki_HotkeyInfo* s_Schematic_Hotkey_List[] =
|
|||
{
|
||||
&HkNextSearch,
|
||||
&HkDelete, &HkInsert, &HkMove2Drag,
|
||||
&HkMoveComponent, &HkDragComponent, &HkAddComponent,
|
||||
&HkMoveComponentOrText, &HkCopyComponentOrText,
|
||||
&HkDragComponent, &HkAddComponent,
|
||||
&HkRotateComponent, &HkMirrorXComponent, &HkMirrorYComponent,
|
||||
&HkOrientNormalComponent,
|
||||
&HkEditComponent,&HkEditComponentValue,&HkEditComponentFootprint,
|
||||
|
@ -415,8 +421,9 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
|
|||
}
|
||||
break;
|
||||
|
||||
case HK_DRAG_COMPONENT: // Start drag Component
|
||||
case HK_MOVE_COMPONENT_OR_LABEL: // Start move Component
|
||||
case HK_DRAG_COMPONENT: // Start drag component
|
||||
case HK_MOVE_COMPONENT_OR_LABEL: // Start move component or text/label
|
||||
case HK_COPY_COMPONENT_OR_LABEL: // Duplicate component or text/label
|
||||
if( ItemInEdit )
|
||||
break;
|
||||
|
||||
|
@ -433,6 +440,14 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
|
|||
break;
|
||||
}
|
||||
|
||||
if( HK_Descr->m_Idcommand == HK_COPY_COMPONENT_OR_LABEL )
|
||||
{
|
||||
GetScreen()->SetCurItem( (SCH_ITEM*) DrawStruct );
|
||||
wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED,
|
||||
HK_Descr->m_IdMenuEvent );
|
||||
wxPostEvent( this, event );
|
||||
break;
|
||||
}
|
||||
|
||||
switch( DrawStruct->Type() )
|
||||
{
|
||||
|
|
|
@ -32,6 +32,7 @@ enum hotkey_id_commnand {
|
|||
HK_MIRROR_Y_COMPONENT,
|
||||
HK_ORIENT_NORMAL_COMPONENT,
|
||||
HK_MOVE_COMPONENT_OR_LABEL,
|
||||
HK_COPY_COMPONENT_OR_LABEL,
|
||||
HK_DRAG_COMPONENT,
|
||||
HK_ADD_NEW_COMPONENT,
|
||||
HK_BEGIN_WIRE
|
||||
|
|
|
@ -342,10 +342,15 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
|
|||
|
||||
if( !Component->m_Flags )
|
||||
{
|
||||
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_COPY_COMPONENT_CMP,
|
||||
_( "Copy Component" ), import_xpm );
|
||||
msg = AddHotkeyName( _( "Copy Component" ),
|
||||
s_Schematic_Hokeys_Descr,
|
||||
HK_COPY_COMPONENT_OR_LABEL );
|
||||
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_COPY_ITEM,
|
||||
msg, copy_button );
|
||||
msg = AddHotkeyName( _( "Delete Component" ), s_Schematic_Hokeys_Descr,
|
||||
HK_DELETE );
|
||||
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CMP,
|
||||
_( "Delete Component" ), delete_xpm );
|
||||
msg, delete_xpm );
|
||||
}
|
||||
|
||||
if( libEntry && !libEntry->GetDocFileName().IsEmpty() )
|
||||
|
@ -365,6 +370,11 @@ void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel )
|
|||
s_Schematic_Hokeys_Descr, HK_MOVE_COMPONENT_OR_LABEL );
|
||||
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST,
|
||||
msg, move_text_xpm );
|
||||
msg = AddHotkeyName( _( "Copy Global Label" ),
|
||||
s_Schematic_Hokeys_Descr,
|
||||
HK_COPY_COMPONENT_OR_LABEL );
|
||||
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_COPY_ITEM,
|
||||
msg, copy_button );
|
||||
}
|
||||
msg = AddHotkeyName( _( "Rotate Global Label" ), s_Schematic_Hokeys_Descr,
|
||||
HK_ROTATE_COMPONENT_OR_LABEL );
|
||||
|
@ -374,8 +384,10 @@ void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel )
|
|||
HK_EDIT_COMPONENT_OR_LABEL );
|
||||
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT,
|
||||
msg, edit_text_xpm );
|
||||
msg = AddHotkeyName( _( "Delete Global Label" ), s_Schematic_Hokeys_Descr,
|
||||
HK_DELETE );
|
||||
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE,
|
||||
_( "Delete Global Label" ), delete_text_xpm );
|
||||
msg, delete_text_xpm );
|
||||
|
||||
// add menu change type text (to label, glabel, text):
|
||||
ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL,
|
||||
|
@ -402,6 +414,11 @@ void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* HLabel )
|
|||
HK_MOVE_COMPONENT_OR_LABEL );
|
||||
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST,
|
||||
msg, move_text_xpm );
|
||||
msg = AddHotkeyName( _( "Copy Hierarchical Label" ),
|
||||
s_Schematic_Hokeys_Descr,
|
||||
HK_COPY_COMPONENT_OR_LABEL );
|
||||
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_COPY_ITEM,
|
||||
msg, copy_button );
|
||||
}
|
||||
msg = AddHotkeyName( _( "Rotate Hierarchical Label" ), s_Schematic_Hokeys_Descr,
|
||||
HK_ROTATE_COMPONENT_OR_LABEL );
|
||||
|
@ -411,8 +428,10 @@ void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* HLabel )
|
|||
HK_EDIT_COMPONENT_OR_LABEL );
|
||||
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT,
|
||||
_( "Edit Hierarchical Label" ), edit_text_xpm );
|
||||
msg = AddHotkeyName( _( "Delete Hierarchical Label" ), s_Schematic_Hokeys_Descr,
|
||||
HK_DELETE );
|
||||
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE,
|
||||
_( "Delete Hierarchical label" ), delete_text_xpm );
|
||||
msg, delete_text_xpm );
|
||||
|
||||
// add menu change type text (to label, glabel, text):
|
||||
ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL,
|
||||
|
@ -438,6 +457,11 @@ void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label )
|
|||
HK_MOVE_COMPONENT_OR_LABEL );
|
||||
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST,
|
||||
msg, move_text_xpm );
|
||||
msg = AddHotkeyName( _( "Copy Label" ),
|
||||
s_Schematic_Hokeys_Descr,
|
||||
HK_COPY_COMPONENT_OR_LABEL );
|
||||
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_COPY_ITEM,
|
||||
msg, copy_button );
|
||||
}
|
||||
msg = AddHotkeyName( _( "Rotate Label" ), s_Schematic_Hokeys_Descr,
|
||||
HK_ROTATE_COMPONENT_OR_LABEL );
|
||||
|
@ -447,8 +471,10 @@ void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label )
|
|||
HK_EDIT_COMPONENT_OR_LABEL );
|
||||
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT,
|
||||
msg, edit_text_xpm );
|
||||
msg = AddHotkeyName( _( "Delete Label" ), s_Schematic_Hokeys_Descr,
|
||||
HK_DELETE );
|
||||
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE,
|
||||
_( "Delete Label" ), delete_text_xpm );
|
||||
msg, delete_text_xpm );
|
||||
|
||||
// add menu change type text (to label, glabel, text):
|
||||
ADD_MENUITEM( menu_change_type, ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_HLABEL,
|
||||
|
@ -475,6 +501,11 @@ void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text )
|
|||
HK_MOVE_COMPONENT_OR_LABEL );
|
||||
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_MOVE_ITEM_REQUEST,
|
||||
msg, move_text_xpm );
|
||||
msg = AddHotkeyName( _( "Copy Text" ),
|
||||
s_Schematic_Hokeys_Descr,
|
||||
HK_COPY_COMPONENT_OR_LABEL );
|
||||
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_COPY_ITEM,
|
||||
msg, copy_button );
|
||||
}
|
||||
msg = AddHotkeyName( _( "Rotate Text" ), s_Schematic_Hokeys_Descr,
|
||||
HK_ROTATE_COMPONENT_OR_LABEL );
|
||||
|
@ -484,7 +515,9 @@ void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text )
|
|||
HK_EDIT_COMPONENT_OR_LABEL );
|
||||
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_TEXT, msg,
|
||||
edit_text_xpm );
|
||||
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Text" ),
|
||||
msg = AddHotkeyName( _( "Delete Text" ), s_Schematic_Hokeys_Descr,
|
||||
HK_DELETE );
|
||||
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, msg,
|
||||
delete_text_xpm );
|
||||
|
||||
/* add menu change type text (to label, glabel, text),
|
||||
|
@ -512,6 +545,7 @@ void AddMenusForJunction( wxMenu* PopMenu, SCH_JUNCTION* Junction,
|
|||
WinEDA_SchematicFrame* frame )
|
||||
{
|
||||
bool is_new = (Junction->m_Flags & IS_NEW) ? TRUE : FALSE;
|
||||
wxString msg;
|
||||
|
||||
if( !is_new )
|
||||
{
|
||||
|
@ -521,7 +555,9 @@ void AddMenusForJunction( wxMenu* PopMenu, SCH_JUNCTION* Junction,
|
|||
_( "Break Wire" ), break_line_xpm );
|
||||
}
|
||||
|
||||
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Junction" ),
|
||||
msg = AddHotkeyName( _( "Delete Junction" ), s_Schematic_Hokeys_Descr,
|
||||
HK_DELETE );
|
||||
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, msg,
|
||||
delete_xpm );
|
||||
|
||||
if( PickStruct( frame->GetScreen()->m_Curseur, frame->GetScreen(),
|
||||
|
@ -540,6 +576,7 @@ void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire,
|
|||
{
|
||||
bool is_new = (Wire->m_Flags & IS_NEW) ? TRUE : FALSE;
|
||||
wxPoint pos = frame->GetScreen()->m_Curseur;
|
||||
wxString msg;
|
||||
|
||||
if( is_new )
|
||||
{
|
||||
|
@ -550,7 +587,9 @@ void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire,
|
|||
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DRAG_WIRE_REQUEST, _( "Drag Wire" ),
|
||||
move_track_xpm );
|
||||
PopMenu->AppendSeparator();
|
||||
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Wire" ), delete_xpm );
|
||||
msg = AddHotkeyName( _( "Delete Wire" ), s_Schematic_Hokeys_Descr,
|
||||
HK_DELETE );
|
||||
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, msg, delete_xpm );
|
||||
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_NODE, _( "Delete Node" ),
|
||||
delete_node_xpm );
|
||||
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION,
|
||||
|
|
|
@ -564,27 +564,6 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
|
|||
&dc );
|
||||
break;
|
||||
|
||||
case ID_POPUP_SCH_COPY_COMPONENT_CMP:
|
||||
DrawPanel->MouseToCursorSchema();
|
||||
{
|
||||
SCH_COMPONENT* olditem, * newitem;
|
||||
if( screen->GetCurItem()->Type() != TYPE_SCH_COMPONENT )
|
||||
screen->SetCurItem( LocateSmallestComponent( screen ) );
|
||||
olditem = (SCH_COMPONENT*) screen->GetCurItem();
|
||||
if( olditem == NULL )
|
||||
break;
|
||||
newitem = olditem->GenCopy();
|
||||
newitem->m_TimeStamp = GetTimeStamp();
|
||||
newitem->ClearAnnotation(NULL);
|
||||
newitem->m_Flags = IS_NEW;
|
||||
StartMovePart( newitem, &dc );
|
||||
|
||||
/* Redraw the original part, because StartMovePart() has erase
|
||||
* it from screen */
|
||||
RedrawOneStruct( DrawPanel, &dc, olditem, GR_DEFAULT_DRAWMODE );
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_POPUP_SCH_SELECT_UNIT1:
|
||||
case ID_POPUP_SCH_SELECT_UNIT2:
|
||||
case ID_POPUP_SCH_SELECT_UNIT3:
|
||||
|
|
|
@ -58,6 +58,8 @@ BEGIN_EVENT_TABLE( WinEDA_SchematicFrame, WinEDA_DrawFrame )
|
|||
EVT_MENU( ID_GEN_COPY_BLOCK_TO_CLIPBOARD, WinEDA_DrawFrame::CopyToClipboard )
|
||||
EVT_MENU( ID_EXIT, WinEDA_SchematicFrame::OnExit )
|
||||
|
||||
EVT_MENU( ID_POPUP_SCH_COPY_ITEM, WinEDA_SchematicFrame::OnCopySchematicItemRequest )
|
||||
|
||||
EVT_MENU_RANGE( ID_CONFIG_AND_PREFERENCES_START,
|
||||
ID_CONFIG_AND_PREFERENCES_END,
|
||||
WinEDA_SchematicFrame::Process_Config )
|
||||
|
|
|
@ -271,6 +271,9 @@ private:
|
|||
void OnOpenLibraryEditor( wxCommandEvent& event );
|
||||
void OnSetOptions( wxCommandEvent& event );
|
||||
|
||||
/* edition events functions */
|
||||
void OnCopySchematicItemRequest( wxCommandEvent& event );
|
||||
|
||||
/* User interface update event handlers. */
|
||||
void OnUpdateBlockSelected( wxUpdateUIEvent& event );
|
||||
void OnUpdatePaste( wxUpdateUIEvent& event );
|
||||
|
|
Loading…
Reference in New Issue