Commit 32394e05 authored by jean-pierre charras's avatar jean-pierre charras
Browse files

Eeschema: Add hotkeys. Minor code cleaning

parents 76aa3f6e 42f403f3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -124,7 +124,7 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type )
        }

        newsegment->m_Flags = IS_NEW;
        if( g_HVLines ) // We need 2 segments to go from a given start pint to
        if( g_HVLines ) // We need 2 segments to go from a given start pin to
                        // an end point
        {
            nextsegment = newsegment->GenCopy();
+4 −13
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ static void ExitBusEntry( WinEDA_DrawPanel* Panel, wxDC* DC )

static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
{
    /*  Drawing of the bus entry segment" while moving the cursor. */
    // Draws the bus entry while moving the cursor
    BASE_SCREEN*   screen   = panel->GetScreen();
    SCH_BUS_ENTRY* BusEntry = (SCH_BUS_ENTRY*) screen->GetCurItem();

@@ -69,21 +69,12 @@ static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
SCH_BUS_ENTRY* WinEDA_SchematicFrame::CreateBusEntry( wxDC* DC,
                                                      int   entry_type )
{
    /* Create a new bus entry, and prepare moving function (for later place it)
     */
    // Create and place a new bus entry at cursor position
    SCH_BUS_ENTRY* BusEntry = new SCH_BUS_ENTRY( GetScreen()->m_Curseur,
                                                 s_LastShape,
                                                 entry_type );

                                                 s_LastShape, entry_type );
    BusEntry->m_Flags = IS_NEW;

    DrawPanel->CursorOff( DC );     // Erase schematic cursor
    RedrawOneStruct( DrawPanel, DC, BusEntry, g_XorMode );
    DrawPanel->CursorOn( DC );      // Display schematic cursor

    BusEntry->Place( this, DC );;
    OnModify( );

    StartMoveBusEntry( BusEntry, DC );
    return BusEntry;
}

+7 −22
Original line number Diff line number Diff line
@@ -443,13 +443,8 @@ void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aOffset,
    // Enable these line to draw the bounding box (debug tests purposes only)
#if 0
    {
        EDA_Rect BoundaryBox;
        BoundaryBox = GetBoundingBox();
        int      x1 = BoundaryBox.GetX();
        int      y1 = BoundaryBox.GetY();
        int      x2 = BoundaryBox.GetRight();
        int      y2 = BoundaryBox.GetBottom();
        GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN );
        EDA_Rect BoundaryBox = GetBoundingBox();
        GRRect( &panel->m_ClipBox, DC, BoundaryBox, 0, BROWN );
    }
#endif
}
@@ -1028,7 +1023,7 @@ void SCH_GLOBALLABEL::Mirror_Y( int aYaxis_position )
{
    /* The global label is NOT really mirrored.
     *  for an horizontal label, the schematic orientation is changed.
     *  for a vericalal label, the schematic orientation is not changed.
     *  for a vertical label, the schematic orientation is not changed.
     *  and the label is moved to a suitable position
     */
    switch( GetSchematicTextOrientation() )
@@ -1210,13 +1205,8 @@ void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel,
    // Enable these line to draw the bounding box (debug tests purposes only)
#if 0
    {
        EDA_Rect BoundaryBox;
        BoundaryBox = GetBoundingBox();
        int      x1 = BoundaryBox.GetX();
        int      y1 = BoundaryBox.GetY();
        int      x2 = BoundaryBox.GetRight();
        int      y2 = BoundaryBox.GetBottom();
        GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN );
        EDA_Rect BoundaryBox = GetBoundingBox();
        GRRect( &panel->m_ClipBox, DC, BoundaryBox, 0, BROWN );
    }
#endif
}
@@ -1555,13 +1545,8 @@ void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel,
    // Enable these line to draw the bounding box (debug tests purposes only)
#if 0
    {
        EDA_Rect BoundaryBox;
        BoundaryBox = GetBoundingBox();
        int      x1 = BoundaryBox.GetX();
        int      y1 = BoundaryBox.GetY();
        int      x2 = BoundaryBox.GetRight();
        int      y2 = BoundaryBox.GetBottom();
        GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN );
        EDA_Rect BoundaryBox = GetBoundingBox();
        GRRect( &panel->m_ClipBox, DC, BoundaryBox, 0, BROWN );
    }
#endif
}
+135 −18
Original line number Diff line number Diff line
@@ -103,16 +103,21 @@ static Ki_HotkeyInfo HkRedo( wxT( "Redo" ), HK_REDO, GR_KB_SHIFT + GR_KB_CTRL +

// Schematic editor
static Ki_HotkeyInfo HkAddLabel( wxT( "add Label" ), HK_ADD_LABEL, 'L' );
static Ki_HotkeyInfo HkAddHierarchicalLabel( wxT( "add Hierarchical Label" ), HK_ADD_HLABEL, 'H' );
static Ki_HotkeyInfo HkAddGlobalLabel( wxT( "add Global Label" ), HK_ADD_GLABEL, GR_KB_CTRL + 'L' );
static Ki_HotkeyInfo HkAddJunction( wxT( "add Junction" ), HK_ADD_JUNCTION, 'J' );
static Ki_HotkeyInfo HkBeginWire( wxT( "begin Wire" ), HK_BEGIN_WIRE, 'W' );
static Ki_HotkeyInfo HkAddComponent( wxT( "Add Component" ),
                                     HK_ADD_NEW_COMPONENT, 'A' );
static Ki_HotkeyInfo HkAddNoConn( wxT( "Add NoConnected Flag" ),
                                  HK_ADD_NOCONN_FLAG, 'Q' );
static Ki_HotkeyInfo HkMirrorYComponent( wxT( "Mirror Y Component" ),
                                         HK_MIRROR_Y_COMPONENT, 'Y' );
static Ki_HotkeyInfo HkMirrorXComponent( wxT( "Mirror X Component" ),
                                         HK_MIRROR_X_COMPONENT, 'X' );
static Ki_HotkeyInfo HkBeginBus( wxT( "begin Bus" ), HK_BEGIN_BUS, 'B' );
static Ki_HotkeyInfo HkAddComponent( wxT( "Add Component" ), HK_ADD_NEW_COMPONENT, 'A' );
static Ki_HotkeyInfo HkAddPower( wxT( "Add Power" ), HK_ADD_NEW_POWER, 'P' );
static Ki_HotkeyInfo HkAddNoConn( wxT( "Add NoConnected Flag" ), HK_ADD_NOCONN_FLAG, 'Q' );
static Ki_HotkeyInfo HkAddHierSheet( wxT( "Add Sheet" ), HK_ADD_HIER_SHEET, 'S' );
static Ki_HotkeyInfo HkAddBusEntry( wxT( "Add Bus Entry" ), HK_ADD_BUS_ENTRY, '/' );
static Ki_HotkeyInfo HkAddWireEntry( wxT( "Add Wire Entry" ), HK_ADD_WIRE_ENTRY, 'Z' );
static Ki_HotkeyInfo HkAddGraphicPolyLine( wxT( "Add Graphic PolyLine" ), HK_ADD_GRAPHIC_POLYLINE, 'I' );
static Ki_HotkeyInfo HkAddGraphicText( wxT( "Add Graphic Text" ), HK_ADD_GRAPHIC_TEXT, 'T' );
static Ki_HotkeyInfo HkMirrorYComponent( wxT( "Mirror Y Component" ), HK_MIRROR_Y_COMPONENT, 'Y' );
static Ki_HotkeyInfo HkMirrorXComponent( wxT( "Mirror X Component" ), HK_MIRROR_X_COMPONENT, 'X' );
static Ki_HotkeyInfo HkOrientNormalComponent( wxT( "Orient Normal Component" ),
                                              HK_ORIENT_NORMAL_COMPONENT, 'N' );
static Ki_HotkeyInfo HkRotate( wxT( "Rotate Item" ), HK_ROTATE, 'R' );
@@ -175,6 +180,7 @@ Ki_HotkeyInfo* s_Schematic_Hotkey_List[] =
    &HkCopyComponentOrText,
    &HkDrag,
    &HkAddComponent,
    &HkAddPower,
    &HkRotate,
    &HkMirrorXComponent,
    &HkMirrorYComponent,
@@ -183,9 +189,17 @@ Ki_HotkeyInfo* s_Schematic_Hotkey_List[] =
    &HkEditComponentValue,
    &HkEditComponentFootprint,
    &HkBeginWire,
    &HkBeginBus,
    &HkAddLabel,
    &HkAddHierarchicalLabel,
    &HkAddGlobalLabel,
    &HkAddJunction,
    &HkAddNoConn,
    &HkAddHierSheet,
    &HkAddWireEntry,
    &HkAddBusEntry,
    &HkAddGraphicPolyLine,
    &HkAddGraphicText,
    NULL
};

@@ -382,6 +396,16 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
        }
        break;

    case HK_ADD_NEW_POWER:      // Add power component
        if( !itemInEdit )
        {
            // switch to m_ID_current_state = ID_PLACE_POWER_BUTT;
            if( m_ID_current_state != ID_PLACE_POWER_BUTT )
                SetToolID( ID_PLACE_POWER_BUTT, wxCURSOR_PENCIL, _( "Add Power" ) );
            OnLeftClick( DC, MousePos );
        }
        break;

    case HK_ADD_LABEL:
        if( notBusy )
        {
@@ -392,6 +416,26 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
        }
        break;

    case HK_ADD_HLABEL:
        if( notBusy )
        {
            // switch to m_ID_current_state = ID_HIERLABEL_BUTT;
            if( m_ID_current_state != ID_HIERLABEL_BUTT )
                SetToolID( ID_HIERLABEL_BUTT, wxCURSOR_PENCIL, _( "Add Hierarchical Label" ) );
            OnLeftClick( DC, MousePos );
        }
        break;

    case HK_ADD_GLABEL:
        if( notBusy )
        {
            // switch to m_ID_current_state = ID_GLABEL_BUTT;
            if( m_ID_current_state != ID_GLABEL_BUTT )
                SetToolID( ID_GLABEL_BUTT, wxCURSOR_PENCIL, _( "Add Global Label" ) );
            OnLeftClick( DC, MousePos );
        }
        break;

    case HK_ADD_JUNCTION:
        if( notBusy )
        {
@@ -402,26 +446,99 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
        }
        break;

    case HK_BEGIN_WIRE:
        // An item is selected. If not a wire, a new command is not possible
    case HK_ADD_WIRE_ENTRY:
        if( notBusy )
        {
            // switch to m_ID_current_state = ID_WIRETOBUS_ENTRY_BUTT;
            if( m_ID_current_state != ID_WIRETOBUS_ENTRY_BUTT )
                SetToolID( ID_WIRETOBUS_ENTRY_BUTT, wxCURSOR_PENCIL, _( "Add Wire to Bus entry" ) );
            OnLeftClick( DC, MousePos );
        }
        break;

    case HK_ADD_BUS_ENTRY:
        if( notBusy )
        {
            // switch to m_ID_current_state = ID_BUSTOBUS_ENTRY_BUTT;
            if( m_ID_current_state != ID_BUSTOBUS_ENTRY_BUTT )
                SetToolID( ID_BUSTOBUS_ENTRY_BUTT, wxCURSOR_PENCIL, _( "Add Bus to Bus entry" ) );
            OnLeftClick( DC, MousePos );
        }
        break;

    case HK_ADD_HIER_SHEET:
        if( notBusy )
        {
            // switch to m_ID_current_state = ID_SHEET_SYMBOL_BUTT;
            if( m_ID_current_state != ID_SHEET_SYMBOL_BUTT )
                SetToolID( ID_SHEET_SYMBOL_BUTT, wxCURSOR_PENCIL, _( "Add Sheet" ) );
            OnLeftClick( DC, MousePos );
        }
        break;

    case HK_ADD_GRAPHIC_TEXT:
        if( notBusy )
        {
            // switch to m_ID_current_state = ID_TEXT_COMMENT_BUTT;
            if( m_ID_current_state != ID_TEXT_COMMENT_BUTT )
                SetToolID( ID_TEXT_COMMENT_BUTT, wxCURSOR_PENCIL, _( "Add Text" ) );
            OnLeftClick( DC, MousePos );
        }
        break;

    case HK_ADD_GRAPHIC_POLYLINE:
        if( notBusy )
        {
            // switch to m_ID_current_state = ID_LINE_COMMENT_BUTT;
            if( m_ID_current_state != ID_LINE_COMMENT_BUTT )
                SetToolID( ID_LINE_COMMENT_BUTT, wxCURSOR_PENCIL, _( "Add Lines" ) );
            OnLeftClick( DC, MousePos );
        }
        break;

    case HK_BEGIN_BUS:
        // An item can be selected. If not a Bus, a begin command is not possible
        if( notBusy )
        {
            if( DrawStruct && DrawStruct->m_Flags )
            // switch to m_ID_current_state = ID_WIRE_BUTT;
            if( m_ID_current_state != ID_BUS_BUTT )
                SetToolID( ID_BUS_BUTT, wxCURSOR_PENCIL, _( "Add Bus" ) );
            OnLeftClick( DC, MousePos );
            break;
        }
        if( DrawStruct && DrawStruct->IsNew() && ( m_ID_current_state == ID_BUS_BUTT ) )
        {
            if( DrawStruct->Type() == DRAW_SEGMENT_STRUCT_TYPE )
            {
                SCH_LINE* segment = (SCH_LINE*) DrawStruct;
                    if( segment->GetLayer() != LAYER_WIRE )
                if( segment->GetLayer() != LAYER_BUS )
                    break;
            // Bus in progress:
            OnLeftClick( DC, MousePos );
            }
                else
                    break;
        }
        break;

    case HK_BEGIN_WIRE:
        // An item can be selected. If not a wire, a begin command is not possible
        if( notBusy )
        {
            // switch to m_ID_current_state = ID_WIRE_BUTT;
            if( m_ID_current_state != ID_WIRE_BUTT )
                SetToolID( ID_WIRE_BUTT, wxCURSOR_PENCIL, _( "Add Wire" ) );
            OnLeftClick( DC, MousePos );
            break;
        }
        if( DrawStruct && DrawStruct->IsNew() && ( m_ID_current_state == ID_WIRE_BUTT ) )
        {
            if( DrawStruct->Type() == DRAW_SEGMENT_STRUCT_TYPE )
            {
                SCH_LINE* segment = (SCH_LINE*) DrawStruct;
                if( segment->GetLayer() != LAYER_WIRE )
                    break;
            // Wire in progress:
            OnLeftClick( DC, MousePos );
            }
        }
        break;

+9 −0
Original line number Diff line number Diff line
@@ -30,9 +30,18 @@ enum hotkey_id_commnand {
    HK_COPY_COMPONENT_OR_LABEL,
    HK_DRAG,
    HK_ADD_NEW_COMPONENT,
    HK_ADD_NEW_POWER,
    HK_BEGIN_WIRE,
    HK_BEGIN_BUS,
    HK_ADD_WIRE_ENTRY,
    HK_ADD_BUS_ENTRY,
    HK_ADD_LABEL,
    HK_ADD_HLABEL,
    HK_ADD_GLABEL,
    HK_ADD_JUNCTION,
    HK_ADD_HIER_SHEET,
    HK_ADD_GRAPHIC_TEXT,
    HK_ADD_GRAPHIC_POLYLINE,
    HK_ADD_NOCONN_FLAG
};

Loading