Commit 34728bec authored by charras's avatar charras
Browse files

Eeschema: added Copy option in labels and component in pop up menu (and 'C' hotkey)

parent c4b37d77
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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
+2 −1
Original line number Diff line number Diff line
@@ -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,
+60 −0
Original line number Diff line number Diff line
/*
 *  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;
    }
}
+20 −5
Original line number Diff line number Diff line
@@ -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() )
        {
+1 −0
Original line number Diff line number Diff line
@@ -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
Loading