Commit 32c54e49 authored by charras's avatar charras
Browse files

More about undo/redo in pcbnew

parent a6fc1329
Loading
Loading
Loading
Loading
+18 −14
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@

/* Routines Locales */
static void Show_MoveTexte_Module( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void ExitTextModule( WinEDA_DrawPanel* Panel, wxDC* DC );
static void AbortMoveTextModule( WinEDA_DrawPanel* Panel, wxDC* DC );

/* local variables */
wxPoint MoveVector;                     // Move vector for move edge, exported to dialog_edit mod_text.cpp
@@ -129,9 +129,8 @@ void WinEDA_BasePcbFrame::DeleteTextModule( TEXTE_MODULE* Text )


/*************************************************************/
static void ExitTextModule( WinEDA_DrawPanel* Panel, wxDC* DC )
static void AbortMoveTextModule( WinEDA_DrawPanel* Panel, wxDC* DC )
/*************************************************************/

/*
 *  Routine de sortie du menu edit texte module
 *  Si un texte est selectionne, ses coord initiales sont regenerees
@@ -151,8 +150,12 @@ static void ExitTextModule( WinEDA_DrawPanel* Panel, wxDC* DC )

    Text->Draw( Panel, DC, GR_XOR, MoveVector );

    /* Redessin du Texte */
    // Text->Draw( Panel, DC, GR_OR );
    // If the text was moved (the move does not change internal data)
    // it could be rotated while moving. So set old value for orientation
    if ( (Text->m_Flags & IS_MOVED) )
        Text->m_Orient = TextInitialOrientation;

    /* Redraw the text */
    Panel->PostDirtyRect( Text->GetBoundingBox() );

    // leave it at (0,0) so we can use it Rotate when not moving.
@@ -191,7 +194,7 @@ void WinEDA_BasePcbFrame::StartMoveTexteModule( TEXTE_MODULE* Text, wxDC* DC )

    SetCurItem( Text );
    DrawPanel->ManageCurseur = Show_MoveTexte_Module;
    DrawPanel->ForceCloseManageCurseur = ExitTextModule;
    DrawPanel->ForceCloseManageCurseur = AbortMoveTextModule;

    DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
}
@@ -209,20 +212,19 @@ void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC )
    {
        DrawPanel->PostDirtyRect( Text->GetBoundingBox() );

        Text->m_Pos = GetScreen()->m_Curseur;
        /* mise a jour des coordonnes relatives a l'ancre */
        MODULE* Module = (MODULE*) Text->GetParent();
        if( Module )
        {
            // Prepare undo command for Board Editor:
            if( m_Ident == PCB_FRAME )
            {
                EXCHG(Text->m_Pos, TextInitialPosition);
            // Prepare undo command (a rotation can be made while moving)
            EXCHG(Text->m_Orient, TextInitialOrientation);
            if( m_Ident == PCB_FRAME )
                SaveCopyInUndoList(Module, UR_CHANGED);
                EXCHG(Text->m_Pos, TextInitialPosition);
            else
                SaveCopyInUndoList(Module, UR_MODEDIT);
            EXCHG(Text->m_Orient, TextInitialOrientation);
            }

            Text->m_Pos = GetScreen()->m_Curseur;   // Set the new position for text
            wxPoint textRelPos = Text->m_Pos - Module->m_Pos;
            RotatePoint( &textRelPos, -Module->m_Orient );
            Text->m_Pos0  = textRelPos;
@@ -234,6 +236,8 @@ void WinEDA_BasePcbFrame::PlaceTexteModule( TEXTE_MODULE* Text, wxDC* DC )
            /* Redessin du Texte */
            DrawPanel->PostDirtyRect( Text->GetBoundingBox() );
        }
        else
            Text->m_Pos = GetScreen()->m_Curseur;
    }

    // leave it at (0,0) so we can use it Rotate when not moving.
+27 −24
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
            switch( DrawStruct->Type() )
            {
            case TYPE_TEXTE_MODULE:
                SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
                PlaceTexteModule( (TEXTE_MODULE*) DrawStruct, DC );
                break;

@@ -64,8 +63,8 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
    DrawStruct = GetCurItem();
    if( !DrawStruct || (DrawStruct->m_Flags == 0) )
    {
        if( !wxGetKeyState(WXK_SHIFT) && !wxGetKeyState(WXK_ALT) &&
                !wxGetKeyState(WXK_CONTROL) )
        if( !wxGetKeyState( WXK_SHIFT ) && !wxGetKeyState( WXK_ALT )
           && !wxGetKeyState( WXK_CONTROL ) )
            DrawStruct = ModeditLocateAndDisplay();
        SetCurItem( DrawStruct );
    }
@@ -137,6 +136,7 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
        Place_Ancre( module );      // set the new relatives internal coordinates of items
        GetScreen()->m_Curseur = wxPoint( 0, 0 );
        Recadre_Trace( TRUE );

        // Replace the module in position 0, to recalculate absolutes coordinates of items
        module->SetPosition( wxPoint( 0, 0 ) );
        SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
@@ -290,11 +290,14 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos,
        }
        ADD_MENUITEM( PopMenu, ID_POPUP_PCB_ROTATE_TEXTMODULE,
                      _( "Rotate Text Mod." ), rotate_field_xpm );
        if( !flags )
        {
            ADD_MENUITEM( PopMenu, ID_POPUP_PCB_EDIT_TEXTMODULE,
                          _( "Edit Text Mod." ), edit_text_xpm );
            if( ( (TEXTE_MODULE*) DrawStruct )->m_Type == TEXT_is_DIVERS )
                ADD_MENUITEM( PopMenu, ID_POPUP_PCB_DELETE_TEXTMODULE,
                              _( "Delete Text Mod." ), delete_text_xpm );
        }
        break;

    case TYPE_EDGE_MODULE:
+7 −6
Original line number Diff line number Diff line
@@ -176,7 +176,8 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
                ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_MOVE_DRAWING_REQUEST,
                              _( "Move Drawing" ), move_xpm );
                ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_EDIT_DRAWING, _( "Edit Drawing" ), edit_xpm );
                ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_DRAWING, _( "Delete Drawing" ), delete_xpm );
                ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_DRAWING, _(
                                  "Delete Drawing" ), delete_xpm );
                if( item->GetLayer() > LAST_COPPER_LAYER )
                    ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_DRAWING_LAYER,
                                  _( "Delete All Drawing on Layer" ), delete_body_xpm );
@@ -707,6 +708,7 @@ void WinEDA_PcbFrame::createPopUpMenuForFpTexts( TEXTE_MODULE* FpText, wxMenu* m

    ADD_MENUITEM( sub_menu_Fp_text, ID_POPUP_PCB_ROTATE_TEXTMODULE,
                  _( "Rotate" ), rotate_field_xpm );
    if( !flags )
        ADD_MENUITEM( sub_menu_Fp_text, ID_POPUP_PCB_EDIT_TEXTMODULE,
                      _( "Edit" ), edit_text_xpm );

@@ -891,4 +893,3 @@ static wxMenu* Append_Track_Width_List()

    return trackwidth_menu;
}