Commit 6f009e8f authored by jean-pierre charras's avatar jean-pierre charras
Browse files

Pcbnew: Added move and rotate hot keys in board editor. hotkeys.cpp code...

Pcbnew: Added move and rotate hot keys in board editor. hotkeys.cpp code cleaned. Fixed a bug that can crash Pcbnew when switching track posture.
parents f839ba95 7774d684
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -257,7 +257,14 @@ public:
                                              wxDC*         DC );

    void          AddPad( MODULE* Module, bool draw );
    void          DeletePad( D_PAD* Pad );
    /** Function DeletePad
     * Delete the pad aPad.
     * Refresh the modified screen area
     * Refresh modified parameters of the parent module (bounding box, last date)
     * @param aPad = the pad to delete
     * @param aQuery = true to promt for confirmation, false to delete silently
     */
    void          DeletePad( D_PAD* aPad, bool aQuery = true );
    void          StartMovePad( D_PAD* Pad, wxDC* DC );
    void          RotatePad( D_PAD* Pad, wxDC* DC );
    void          PlacePad( D_PAD* Pad, wxDC* DC );
+38 −4
Original line number Diff line number Diff line
@@ -253,10 +253,44 @@ public:
     */
    void             SetLastNetListRead( const wxString& aNetListFile );

    void             OnHotKey( wxDC*           DC,
                               int             hotkey,
                               EDA_BaseStruct* DrawStruct );
    bool             OnHotkeyDeleteItem( wxDC* DC, EDA_BaseStruct* DrawStruct );
    /** Function OnHotKey.
     *  ** Commands are case insensitive **
     *  Some commands are relatives to the item under the mouse cursor
     *  @param aDC = current device context
     *  @param aHotkeyCode = hotkey code (ascii or wxWidget code for special keys)
     *  @param aItem = NULL or pointer on a EDA_BaseStruct under the mouse cursor
     */
    void             OnHotKey( wxDC*           aDC,
                               int             aHotkeyCode,
                               EDA_BaseStruct* aItem );

    /** Function OnHotkeyDeleteItem
     * Delete the item found under the mouse cursor
     *  Depending on the current active tool::
     *      Tool track
     *          if a track is in progress: Delete the last segment
     *			else delete the entire track
     *      Tool module (footprint):
     *          Delete the module.
     * @param aDC = current device context
     * @return true if an item was deleted
     */
    bool             OnHotkeyDeleteItem( wxDC* aDC );

    /** Function OnHotkeyMoveItem
     * Moves or drag the item (footprint, track, text .. ) found under the mouse cursor
     * Only a footprint or a track can be dragged
     * @param aIdCommand = the hotkey command id
     * @return true if an item was moved
     */
    bool             OnHotkeyMoveItem( int aIdCommand );

    /** Function OnHotkeyRotateItem
     * Rotate the item (text or footprint) found under the mouse cursor
     * @param aIdCommand = the hotkey command id
     * @return true if an item was moved
     */
    bool             OnHotkeyRotateItem( int aIdCommand );

    void             OnCloseWindow( wxCloseEvent& Event );
    void             Process_Special_Functions( wxCommandEvent& event );
+41 −50
Original line number Diff line number Diff line
@@ -36,79 +36,77 @@ wxString ModulesMaskSelection = wxT( "*" );
void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event )
{
    int        id = event.GetId();
    wxPoint    pos;
    INSTALL_DC( dc, DrawPanel );
    bool       on_state;

    if( m_HToolBar == NULL )
        return;

    wxGetMousePosition( &pos.x, &pos.y );

    switch( id )
    {
    case ID_TOOLBARH_PCB_AUTOPLACE:
    case ID_TOOLBARH_PCB_AUTOROUTE:
        break;

    case ID_POPUP_CANCEL_CURRENT_COMMAND:
        if( DrawPanel->ManageCurseur
            && DrawPanel->ForceCloseManageCurseur )
        {
            DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
        }
        break;

    default:   // Abort a current command (if any)
        DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW );
        break;
    }

    /* Erase ratsnest if needed */
    if( GetBoard()->IsElementVisible(RATSNEST_VISIBLE) )
        DrawGeneralRatsnest( &dc );
    GetBoard()->m_Status_Pcb |= DO_NOT_SHOW_GENERAL_RASTNEST;
    INSTALL_DC( dc, DrawPanel );

    switch( id )
    {
    case ID_TOOLBARH_PCB_AUTOPLACE:
        on_state = m_HToolBar->GetToolState( ID_TOOLBARH_PCB_AUTOPLACE );
    case ID_TOOLBARH_PCB_MODE_MODULE:
        on_state = m_HToolBar->GetToolState( ID_TOOLBARH_PCB_MODE_MODULE );
        if( on_state )
        {
            m_HToolBar->ToggleTool( ID_TOOLBARH_PCB_AUTOROUTE, FALSE );
            m_HTOOL_current_state = ID_TOOLBARH_PCB_AUTOPLACE;
            m_HToolBar->ToggleTool( ID_TOOLBARH_PCB_MODE_TRACKS, FALSE );
            m_HTOOL_current_state = ID_TOOLBARH_PCB_MODE_MODULE;
        }
        else
            m_HTOOL_current_state = 0;
        break;
        return;

    case ID_TOOLBARH_PCB_AUTOROUTE:
        on_state = m_HToolBar->GetToolState( ID_TOOLBARH_PCB_AUTOROUTE );
    case ID_TOOLBARH_PCB_MODE_TRACKS:
        on_state = m_HToolBar->GetToolState( ID_TOOLBARH_PCB_MODE_TRACKS );
        if( on_state )
        {
            m_HToolBar->ToggleTool( ID_TOOLBARH_PCB_AUTOPLACE, FALSE );
            m_HTOOL_current_state = ID_TOOLBARH_PCB_AUTOROUTE;
            m_HToolBar->ToggleTool( ID_TOOLBARH_PCB_MODE_MODULE, FALSE );
            m_HTOOL_current_state = ID_TOOLBARH_PCB_MODE_TRACKS;
        }
        else
            m_HTOOL_current_state = 0;
        break;
        return;


    case ID_POPUP_PCB_AUTOROUTE_SELECT_LAYERS:
        return;

    case ID_POPUP_PCB_AUTOPLACE_FIXE_MODULE:
        FixeModule( (MODULE*) GetScreen()->GetCurItem(), TRUE );
        break;
        return;

    case ID_POPUP_PCB_AUTOPLACE_FREE_MODULE:
        FixeModule( (MODULE*) GetScreen()->GetCurItem(), FALSE );
        break;
        return;

    case ID_POPUP_PCB_AUTOPLACE_FREE_ALL_MODULES:
        FixeModule( NULL, FALSE );
        break;
        return;

    case ID_POPUP_PCB_AUTOPLACE_FIXE_ALL_MODULES:
        FixeModule( NULL, TRUE );
        return;

    case ID_POPUP_CANCEL_CURRENT_COMMAND:
        if( DrawPanel->ManageCurseur
            && DrawPanel->ForceCloseManageCurseur )
        {
            DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
        }
        break;

    default:   // Abort a current command (if any)
        DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW );
        break;
    }

    /* Erase ratsnest if needed */
    if( GetBoard()->IsElementVisible(RATSNEST_VISIBLE) )
        DrawGeneralRatsnest( &dc );
    GetBoard()->m_Status_Pcb |= DO_NOT_SHOW_GENERAL_RASTNEST;

    switch( id )
    {
    case ID_POPUP_PCB_AUTOPLACE_CURRENT_MODULE:
        AutoPlaceModule( (MODULE*) GetScreen()->GetCurItem(),
                        PLACE_1_MODULE, &dc );
@@ -158,9 +156,6 @@ void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event )
        Reset_Noroutable( &dc );
        break;

    case ID_POPUP_PCB_AUTOROUTE_SELECT_LAYERS:
        break;

    default:
        DisplayError( this, wxT( "AutoPlace command error" ) );
        break;
@@ -168,16 +163,12 @@ void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event )

    GetBoard()->m_Status_Pcb &= ~DO_NOT_SHOW_GENERAL_RASTNEST;
    Compile_Ratsnest( &dc, true );
    SetToolbars();
}


/* Routine allocation of components in a rectangular format 4 / 3,
 * Starting from the mouse cursor
 * The components with the FIXED status are not normally dives
 * According to the flags:
 * All modules (not fixed) will be left
 * Only PCB modules are not left
/* Function to move components in a rectangular area format 4 / 3,
 * starting from the mouse cursor
 * The components with the FIXED status set are not moved
 */
void WinEDA_PcbFrame::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
{
+1 −1
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode )
    {
        switch( m_HTOOL_current_state )
        {
        case ID_TOOLBARH_PCB_AUTOPLACE:
        case ID_TOOLBARH_PCB_MODE_MODULE:
            scanList = GENERAL_COLLECTOR::ModuleItems;
            break;

+5 −2
Original line number Diff line number Diff line
@@ -348,9 +348,12 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
    case ID_POPUP_PCB_SWITCH_TRACK_POSTURE:
        /* change the position of initial segment when creating new tracks
         * switch from _/  to -\ .
         * If a track is in progress, it will be redrawn
        */
        if( DrawPanel->ManageCurseur == ShowNewTrackWhenMovingCursor )
            ShowNewTrackWhenMovingCursor( DrawPanel, &dc, false );
        g_Alternate_Track_Posture = !g_Alternate_Track_Posture;
        if( DrawPanel->ManageCurseur == ShowNewTrackWhenMovingCursor )
            ShowNewTrackWhenMovingCursor( DrawPanel, &dc, false );
        break;

Loading