Commit df8f7d1e authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

EESchema remove global variable and fix text object change type undo/redo.

* Move undo item copy global variable into schematic editor frame object
  member variable.
* Add helper methods for accessing the undo item copy member variable.
* Fix undetected bug when changing a text type.
* Added an exchange command to the undo/redo base class for handling undoing
  a changed item type which cannot be undone by swapping out the variables.
* Revert change to common/hotkeys_basic.cpp that broke hot key behavior.
* Lots of coding policy changes while making the changes above.
parent fb475361
Loading
Loading
Loading
Loading
+8 −11
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@
#include "class_undoredo_container.h"


ITEM_PICKER::ITEM_PICKER( EDA_ITEM* aItem, UndoRedoOpType aUndoRedoStatus )
ITEM_PICKER::ITEM_PICKER( EDA_ITEM* aItem, UNDO_REDO_T aUndoRedoStatus )
{
    m_UndoRedoStatus = aUndoRedoStatus;
    m_PickedItem     = aItem;
@@ -134,6 +134,7 @@ void PICKED_ITEMS_LIST::ClearListAndDeleteItems()
            break;

        case UR_CHANGED:
        case UR_EXCHANGE_T:
            delete wrapper.m_Link;   //  the picker is owner of this item
            break;

@@ -149,12 +150,8 @@ void PICKED_ITEMS_LIST::ClearListAndDeleteItems()
            break;

        default:
        {
            wxString msg;
            msg.Printf( wxT( "ClearUndoORRedoList() error: unknown command type %d" ),
                        wrapper.m_UndoRedoStatus );
            wxMessageBox( msg );
        }
            wxFAIL_MSG( wxString::Format( wxT( "Cannot clear unknown undo/redo command %d" ),
                                          wrapper.m_UndoRedoStatus ) );
            break;
        }
    }
@@ -190,7 +187,7 @@ EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItemLink( unsigned int aIdx )
}


UndoRedoOpType PICKED_ITEMS_LIST::GetPickedItemStatus( unsigned int aIdx )
UNDO_REDO_T PICKED_ITEMS_LIST::GetPickedItemStatus( unsigned int aIdx )
{
    if( aIdx < m_ItemsList.size() )
        return m_ItemsList[aIdx].m_UndoRedoStatus;
@@ -232,7 +229,7 @@ bool PICKED_ITEMS_LIST::SetPickedItemLink( EDA_ITEM* aLink, unsigned aIdx )
}


bool PICKED_ITEMS_LIST::SetPickedItem( EDA_ITEM* aItem, UndoRedoOpType aStatus, unsigned aIdx )
bool PICKED_ITEMS_LIST::SetPickedItem( EDA_ITEM* aItem, UNDO_REDO_T aStatus, unsigned aIdx )
{
    if( aIdx < m_ItemsList.size() )
    {
@@ -245,7 +242,7 @@ bool PICKED_ITEMS_LIST::SetPickedItem( EDA_ITEM* aItem, UndoRedoOpType aStatus,
}


bool PICKED_ITEMS_LIST::SetPickedItemStatus( UndoRedoOpType aStatus, unsigned aIdx )
bool PICKED_ITEMS_LIST::SetPickedItemStatus( UNDO_REDO_T aStatus, unsigned aIdx )
{
    if( aIdx < m_ItemsList.size() )
    {
+9 −3
Original line number Diff line number Diff line
@@ -189,8 +189,12 @@ wxString AddHotkeyName( const wxString& aText, Ki_HotkeyInfo** aList,
        keyname = ReturnKeyNameFromCommandId( aList, aCommandId );

    if( !keyname.IsEmpty() )
    {
        if( aIsShortCut )
            msg << wxT( "\t" ) << keyname;

        else
            msg << wxT( " <" ) << keyname << wxT( ">" );
    }
    return msg;
}

@@ -219,10 +223,12 @@ wxString AddHotkeyName( const wxString& aText,
        {
            List    = aDescList->m_HK_InfoList;
            keyname = ReturnKeyNameFromCommandId( List, aCommandId );

            if( !keyname.IsEmpty() )
            {
                if( aIsShortCut )
                    msg << wxT( "\t" ) << keyname;
                else
                    msg << wxT( " <" ) << keyname << wxT( ">" );
                break;
            }
        }
+6 −0
Original line number Diff line number Diff line
@@ -116,6 +116,12 @@ bool SCH_ITEM::IsConnected( const wxPoint& aPosition ) const
}


void SCH_ITEM::SwapData( SCH_ITEM* aItem )
{
    wxFAIL_MSG( wxT( "SwapData() method not implemented for class " ) + GetClass() );
}


bool SCH_ITEM::operator < ( const SCH_ITEM& aItem ) const
{
    wxCHECK_MSG( false, this->Type() < aItem.Type(),
+3 −3
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ public:
     * but but be defined because it is a pure virtual in PCB_BASE_FRAME
     */
    virtual void SaveCopyInUndoList( BOARD_ITEM* aItemToCopy,
                                     UndoRedoOpType aTypeCommand = UR_UNSPECIFIED,
                                     UNDO_REDO_T aTypeCommand = UR_UNSPECIFIED,
                                     const wxPoint& aTransformPoint = wxPoint( 0, 0 ) )
    {
    }
@@ -71,12 +71,12 @@ public:
     * Creates a new entry in undo list of commands.
     * add a list of pickers to handle a list of items
     * @param aItemsList = the list of items modified by the command to undo
     * @param aTypeCommand = command type (see enum UndoRedoOpType)
     * @param aTypeCommand = command type (see enum UNDO_REDO_T)
     * @param aTransformPoint = the reference point of the transformation,
     *                          for commands like move
     */
    virtual void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
                                     UndoRedoOpType aTypeCommand,
                                     UNDO_REDO_T aTypeCommand,
                                     const wxPoint& aTransformPoint = wxPoint( 0, 0 ) )
    {
        // currently: do nothing in cvpcb.
+2 −5
Original line number Diff line number Diff line
@@ -86,12 +86,9 @@ void SCH_EDIT_FRAME::StartMoveBusEntry( SCH_BUS_ENTRY* BusEntry, wxDC* DC )
        return;

    if( !BusEntry->IsNew() )    // not already in edit, save shape
    {
        delete g_ItemToUndoCopy;
        g_ItemToUndoCopy = BusEntry->Clone();
    }
        SetUndoItem( BusEntry );

    BusEntry->m_Flags |= IS_MOVED;
    BusEntry->SetFlags( IS_MOVED );

    ItemInitialPosition = BusEntry->m_Pos;

Loading