Loading common/CMakeLists.txt +1 −0 Original line number Original line Diff line number Diff line Loading @@ -14,6 +14,7 @@ set(COMMON_SRCS block_commande.cpp block_commande.cpp class_drawpickedstruct.cpp class_drawpickedstruct.cpp class_marker_base.cpp class_marker_base.cpp class_undoredo_container.cpp common.cpp common.cpp common_plot_functions.cpp common_plot_functions.cpp common_plotHPGL_functions.cpp common_plotHPGL_functions.cpp Loading common/about_kicad.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -8,7 +8,7 @@ #include "appl_wxstruct.h" #include "appl_wxstruct.h" #define BUILD_VERSION "(20090712-unstable)" #define BUILD_VERSION "(20090723-unstable)" #ifdef HAVE_SVN_VERSION #ifdef HAVE_SVN_VERSION Loading common/base_screen.cpp +20 −86 Original line number Original line Diff line number Diff line Loading @@ -28,9 +28,7 @@ BASE_SCREEN* ActiveScreen = NULL; BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) : EDA_BaseStruct( aType ) BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) : EDA_BaseStruct( aType ) { { EEDrawList = NULL; /* Schematic items list */ EEDrawList = NULL; /* Schematic items list */ m_UndoList = NULL; m_UndoRedoCountMax = 1; /* undo/Redo command Max depth */ m_RedoList = NULL; m_UndoRedoCountMax = 1; m_FirstRedraw = TRUE; m_FirstRedraw = TRUE; m_ScreenNumber = 1; m_ScreenNumber = 1; m_NumberOfScreen = 1; /* Hierarchy: Root: ScreenNumber = 1 */ m_NumberOfScreen = 1; /* Hierarchy: Root: ScreenNumber = 1 */ Loading Loading @@ -486,121 +484,57 @@ void BASE_SCREEN::ClearUndoRedoList() /* free the undo and the redo lists /* free the undo and the redo lists */ */ { { EDA_BaseStruct* nextitem; m_UndoList.ClearCommandList(); m_RedoList.ClearCommandList(); while( m_UndoList ) { nextitem = m_UndoList->Next(); delete m_UndoList; m_UndoList = nextitem; } while( m_RedoList ) { nextitem = m_RedoList->Next(); delete m_RedoList; m_RedoList = nextitem; } } } /***********************************************************/ /***********************************************************/ void BASE_SCREEN::AddItemToUndoList( EDA_BaseStruct* newitem ) void BASE_SCREEN::PushCommandToUndoList( PICKED_ITEMS_LIST* aNewitem ) /************************************************************/ /************************************************************/ /* Put newitem in head of undo list /* Put aNewitem in top of undo list * Deletes olds items if > count max. * Deletes olds items if > count max. */ */ { { int ii; m_UndoList.PushCommand(aNewitem); EDA_BaseStruct* item; while( m_UndoList.m_CommandsList.size() > 0 && EDA_BaseStruct* nextitem; m_UndoList.m_CommandsList.size() >= m_UndoRedoCountMax ) if( newitem == NULL ) return; newitem->SetNext( m_UndoList ); m_UndoList = newitem; /* Free first items, if count max reached */ for( ii = 0, item = m_UndoList; ii < m_UndoRedoCountMax; ii++ ) { { if( item->Next() == NULL ) delete m_UndoList.m_CommandsList[0]; return; m_UndoList.m_CommandsList.erase( m_UndoList.m_CommandsList.begin() ); item = item->Next(); } } if( item == NULL ) return; nextitem = item->Next(); item->SetNext( NULL ); // Set end of chain // Delete the extra items for( item = nextitem; item != NULL; item = nextitem ) { nextitem = item->Next(); delete item; } } } /***********************************************************/ /***********************************************************/ void BASE_SCREEN::AddItemToRedoList( EDA_BaseStruct* newitem ) void BASE_SCREEN::PushCommandToRedoList( PICKED_ITEMS_LIST* aNewitem ) /***********************************************************/ /***********************************************************/ { { int ii; m_RedoList.PushCommand(aNewitem); EDA_BaseStruct* item, * nextitem; while( m_RedoList.m_CommandsList.size() > 0 && m_RedoList.m_CommandsList.size() >= m_UndoRedoCountMax ) if( newitem == NULL ) return; newitem->SetNext( m_RedoList ); m_RedoList = newitem; /* Free first items, if count max reached */ for( ii = 0, item = m_RedoList; ii < m_UndoRedoCountMax; ii++ ) { { if( item->Next() == NULL ) delete m_RedoList.m_CommandsList[0]; break; m_RedoList.m_CommandsList.erase( m_RedoList.m_CommandsList.begin() ); item = item->Next(); } if( item == NULL ) return; nextitem = item->Next(); item->SetNext( NULL ); // Set end of chain // Delete the extra items for( item = nextitem; item != NULL; item = nextitem ) { nextitem = item->Next(); delete item; } } } } /*****************************************************/ /*****************************************************/ EDA_BaseStruct* BASE_SCREEN::GetItemFromUndoList() PICKED_ITEMS_LIST* BASE_SCREEN::PopCommandFromUndoList( ) /*****************************************************/ /*****************************************************/ { { EDA_BaseStruct* item = m_UndoList; return m_UndoList.PopCommand( ); if( item ) m_UndoList = item->Next(); return item; } } /******************************************************/ /******************************************************/ EDA_BaseStruct* BASE_SCREEN::GetItemFromRedoList() PICKED_ITEMS_LIST* BASE_SCREEN::PopCommandFromRedoList( ) /******************************************************/ /******************************************************/ { { EDA_BaseStruct* item = m_RedoList; return m_RedoList.PopCommand( ); if( item ) m_RedoList = item->Next(); return item; } } Loading eeschema/libedit_undo_redo.cpp +41 −19 Original line number Original line Diff line number Diff line Loading @@ -21,19 +21,29 @@ void WinEDA_LibeditFrame::SaveCopyInUndoList( EDA_BaseStruct* ItemToCopy, { { EDA_BaseStruct* item; EDA_BaseStruct* item; EDA_LibComponentStruct* CopyItem; EDA_LibComponentStruct* CopyItem; PICKED_ITEMS_LIST* lastcmd; CopyItem = CopyLibEntryStruct( this, (EDA_LibComponentStruct*) ItemToCopy ); CopyItem = CopyLibEntryStruct( this, (EDA_LibComponentStruct*) ItemToCopy ); GetScreen()->AddItemToUndoList( (EDA_BaseStruct*) CopyItem ); lastcmd = new PICKED_ITEMS_LIST(); ITEM_PICKER wrapper(CopyItem); lastcmd->PushItem(wrapper); GetScreen()->PushCommandToUndoList( lastcmd ); /* Clear current flags (which can be temporary set by a current edit command) */ /* Clear current flags (which can be temporary set by a current edit command) */ for( item = CopyItem->m_Drawings; item != NULL; item = item->Next() ) for( item = CopyItem->m_Drawings; item != NULL; item = item->Next() ) item->m_Flags = 0; item->m_Flags = 0; /* Clear redo list, because after new save there is no redo to do */ /* Clear redo list, because after new save there is no redo to do */ while( GetScreen()->m_RedoList ) while( (lastcmd = GetScreen()->PopCommandFromRedoList( ) ) != NULL ) { while ( 1 ) { { item = GetScreen()->m_RedoList->Next(); wrapper = lastcmd->PopItem(); delete( GetScreen()->m_RedoList ); if ( wrapper.m_Item == NULL ) GetScreen()->m_RedoList = item; break; // All items are removed delete wrapper.m_Item; } delete lastcmd; } } } } Loading @@ -45,15 +55,21 @@ bool WinEDA_LibeditFrame::GetComponentFromRedoList() /* Redo the last edition: /* Redo the last edition: * - Place the current edited library component in undo list * - Place the current edited library component in undo list * - Get old version of the current edited library component * - Get old version of the current edited library component * @return FALSE if nothing done, else TRUE * @return FALSE if nothing done, else true */ */ { { if( GetScreen()->m_RedoList == NULL ) if ( GetScreen()->GetRedoCommandCount() <= 0 ) return FALSE; return false; PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST(); ITEM_PICKER wrapper(CurrentLibEntry); lastcmd->PushItem(wrapper); GetScreen()->PushCommandToUndoList( lastcmd ); GetScreen()->AddItemToUndoList( (EDA_BaseStruct*) CurrentLibEntry ); lastcmd = GetScreen()->PopCommandFromRedoList( ); CurrentLibEntry = (EDA_LibComponentStruct*) GetScreen()->GetItemFromRedoList(); wrapper = lastcmd->PopItem(); CurrentLibEntry = (EDA_LibComponentStruct*) wrapper.m_Item; if( CurrentLibEntry ) if( CurrentLibEntry ) CurrentLibEntry->SetNext( NULL ); CurrentLibEntry->SetNext( NULL ); CurrentDrawItem = NULL; CurrentDrawItem = NULL; Loading @@ -61,7 +77,7 @@ bool WinEDA_LibeditFrame::GetComponentFromRedoList() ReCreateHToolbar(); ReCreateHToolbar(); SetToolbars(); SetToolbars(); return TRUE; return true; } } Loading @@ -72,15 +88,21 @@ bool WinEDA_LibeditFrame::GetComponentFromUndoList() /* Undo the last edition: /* Undo the last edition: * - Place the current edited library component in Redo list * - Place the current edited library component in Redo list * - Get old version of the current edited library component * - Get old version of the current edited library component * @return FALSE if nothing done, else TRUE * @return FALSE if nothing done, else true */ */ { { if( GetScreen()->m_UndoList == NULL ) if ( GetScreen()->GetUndoCommandCount() <= 0 ) return FALSE; return false; PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST(); ITEM_PICKER wrapper(CurrentLibEntry); lastcmd->PushItem(wrapper); GetScreen()->PushCommandToRedoList( lastcmd ); lastcmd = GetScreen()->PopCommandFromUndoList( ); GetScreen()->AddItemToRedoList( (EDA_BaseStruct*) CurrentLibEntry ); wrapper = lastcmd->PopItem(); CurrentLibEntry = CurrentLibEntry = (EDA_LibComponentStruct*) wrapper.m_Item; (EDA_LibComponentStruct*) GetScreen()->GetItemFromUndoList(); if( CurrentLibEntry ) if( CurrentLibEntry ) CurrentLibEntry->SetNext( NULL ); CurrentLibEntry->SetNext( NULL ); Loading @@ -89,5 +111,5 @@ bool WinEDA_LibeditFrame::GetComponentFromUndoList() ReCreateHToolbar(); ReCreateHToolbar(); SetToolbars(); SetToolbars(); return TRUE; return true; } } eeschema/libframe.cpp +2 −2 Original line number Original line Diff line number Diff line Loading @@ -279,8 +279,8 @@ void WinEDA_LibeditFrame::SetToolbars() if( GetScreen() ) if( GetScreen() ) { { m_HToolBar->EnableTool( ID_LIBEDIT_UNDO, GetScreen()->m_UndoList ); m_HToolBar->EnableTool( ID_LIBEDIT_UNDO, GetScreen()->GetUndoCommandCount() ); m_HToolBar->EnableTool( ID_LIBEDIT_REDO, GetScreen()->m_RedoList ); m_HToolBar->EnableTool( ID_LIBEDIT_REDO, GetScreen()->GetRedoCommandCount() ); } } } } Loading Loading
common/CMakeLists.txt +1 −0 Original line number Original line Diff line number Diff line Loading @@ -14,6 +14,7 @@ set(COMMON_SRCS block_commande.cpp block_commande.cpp class_drawpickedstruct.cpp class_drawpickedstruct.cpp class_marker_base.cpp class_marker_base.cpp class_undoredo_container.cpp common.cpp common.cpp common_plot_functions.cpp common_plot_functions.cpp common_plotHPGL_functions.cpp common_plotHPGL_functions.cpp Loading
common/about_kicad.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -8,7 +8,7 @@ #include "appl_wxstruct.h" #include "appl_wxstruct.h" #define BUILD_VERSION "(20090712-unstable)" #define BUILD_VERSION "(20090723-unstable)" #ifdef HAVE_SVN_VERSION #ifdef HAVE_SVN_VERSION Loading
common/base_screen.cpp +20 −86 Original line number Original line Diff line number Diff line Loading @@ -28,9 +28,7 @@ BASE_SCREEN* ActiveScreen = NULL; BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) : EDA_BaseStruct( aType ) BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) : EDA_BaseStruct( aType ) { { EEDrawList = NULL; /* Schematic items list */ EEDrawList = NULL; /* Schematic items list */ m_UndoList = NULL; m_UndoRedoCountMax = 1; /* undo/Redo command Max depth */ m_RedoList = NULL; m_UndoRedoCountMax = 1; m_FirstRedraw = TRUE; m_FirstRedraw = TRUE; m_ScreenNumber = 1; m_ScreenNumber = 1; m_NumberOfScreen = 1; /* Hierarchy: Root: ScreenNumber = 1 */ m_NumberOfScreen = 1; /* Hierarchy: Root: ScreenNumber = 1 */ Loading Loading @@ -486,121 +484,57 @@ void BASE_SCREEN::ClearUndoRedoList() /* free the undo and the redo lists /* free the undo and the redo lists */ */ { { EDA_BaseStruct* nextitem; m_UndoList.ClearCommandList(); m_RedoList.ClearCommandList(); while( m_UndoList ) { nextitem = m_UndoList->Next(); delete m_UndoList; m_UndoList = nextitem; } while( m_RedoList ) { nextitem = m_RedoList->Next(); delete m_RedoList; m_RedoList = nextitem; } } } /***********************************************************/ /***********************************************************/ void BASE_SCREEN::AddItemToUndoList( EDA_BaseStruct* newitem ) void BASE_SCREEN::PushCommandToUndoList( PICKED_ITEMS_LIST* aNewitem ) /************************************************************/ /************************************************************/ /* Put newitem in head of undo list /* Put aNewitem in top of undo list * Deletes olds items if > count max. * Deletes olds items if > count max. */ */ { { int ii; m_UndoList.PushCommand(aNewitem); EDA_BaseStruct* item; while( m_UndoList.m_CommandsList.size() > 0 && EDA_BaseStruct* nextitem; m_UndoList.m_CommandsList.size() >= m_UndoRedoCountMax ) if( newitem == NULL ) return; newitem->SetNext( m_UndoList ); m_UndoList = newitem; /* Free first items, if count max reached */ for( ii = 0, item = m_UndoList; ii < m_UndoRedoCountMax; ii++ ) { { if( item->Next() == NULL ) delete m_UndoList.m_CommandsList[0]; return; m_UndoList.m_CommandsList.erase( m_UndoList.m_CommandsList.begin() ); item = item->Next(); } } if( item == NULL ) return; nextitem = item->Next(); item->SetNext( NULL ); // Set end of chain // Delete the extra items for( item = nextitem; item != NULL; item = nextitem ) { nextitem = item->Next(); delete item; } } } /***********************************************************/ /***********************************************************/ void BASE_SCREEN::AddItemToRedoList( EDA_BaseStruct* newitem ) void BASE_SCREEN::PushCommandToRedoList( PICKED_ITEMS_LIST* aNewitem ) /***********************************************************/ /***********************************************************/ { { int ii; m_RedoList.PushCommand(aNewitem); EDA_BaseStruct* item, * nextitem; while( m_RedoList.m_CommandsList.size() > 0 && m_RedoList.m_CommandsList.size() >= m_UndoRedoCountMax ) if( newitem == NULL ) return; newitem->SetNext( m_RedoList ); m_RedoList = newitem; /* Free first items, if count max reached */ for( ii = 0, item = m_RedoList; ii < m_UndoRedoCountMax; ii++ ) { { if( item->Next() == NULL ) delete m_RedoList.m_CommandsList[0]; break; m_RedoList.m_CommandsList.erase( m_RedoList.m_CommandsList.begin() ); item = item->Next(); } if( item == NULL ) return; nextitem = item->Next(); item->SetNext( NULL ); // Set end of chain // Delete the extra items for( item = nextitem; item != NULL; item = nextitem ) { nextitem = item->Next(); delete item; } } } } /*****************************************************/ /*****************************************************/ EDA_BaseStruct* BASE_SCREEN::GetItemFromUndoList() PICKED_ITEMS_LIST* BASE_SCREEN::PopCommandFromUndoList( ) /*****************************************************/ /*****************************************************/ { { EDA_BaseStruct* item = m_UndoList; return m_UndoList.PopCommand( ); if( item ) m_UndoList = item->Next(); return item; } } /******************************************************/ /******************************************************/ EDA_BaseStruct* BASE_SCREEN::GetItemFromRedoList() PICKED_ITEMS_LIST* BASE_SCREEN::PopCommandFromRedoList( ) /******************************************************/ /******************************************************/ { { EDA_BaseStruct* item = m_RedoList; return m_RedoList.PopCommand( ); if( item ) m_RedoList = item->Next(); return item; } } Loading
eeschema/libedit_undo_redo.cpp +41 −19 Original line number Original line Diff line number Diff line Loading @@ -21,19 +21,29 @@ void WinEDA_LibeditFrame::SaveCopyInUndoList( EDA_BaseStruct* ItemToCopy, { { EDA_BaseStruct* item; EDA_BaseStruct* item; EDA_LibComponentStruct* CopyItem; EDA_LibComponentStruct* CopyItem; PICKED_ITEMS_LIST* lastcmd; CopyItem = CopyLibEntryStruct( this, (EDA_LibComponentStruct*) ItemToCopy ); CopyItem = CopyLibEntryStruct( this, (EDA_LibComponentStruct*) ItemToCopy ); GetScreen()->AddItemToUndoList( (EDA_BaseStruct*) CopyItem ); lastcmd = new PICKED_ITEMS_LIST(); ITEM_PICKER wrapper(CopyItem); lastcmd->PushItem(wrapper); GetScreen()->PushCommandToUndoList( lastcmd ); /* Clear current flags (which can be temporary set by a current edit command) */ /* Clear current flags (which can be temporary set by a current edit command) */ for( item = CopyItem->m_Drawings; item != NULL; item = item->Next() ) for( item = CopyItem->m_Drawings; item != NULL; item = item->Next() ) item->m_Flags = 0; item->m_Flags = 0; /* Clear redo list, because after new save there is no redo to do */ /* Clear redo list, because after new save there is no redo to do */ while( GetScreen()->m_RedoList ) while( (lastcmd = GetScreen()->PopCommandFromRedoList( ) ) != NULL ) { while ( 1 ) { { item = GetScreen()->m_RedoList->Next(); wrapper = lastcmd->PopItem(); delete( GetScreen()->m_RedoList ); if ( wrapper.m_Item == NULL ) GetScreen()->m_RedoList = item; break; // All items are removed delete wrapper.m_Item; } delete lastcmd; } } } } Loading @@ -45,15 +55,21 @@ bool WinEDA_LibeditFrame::GetComponentFromRedoList() /* Redo the last edition: /* Redo the last edition: * - Place the current edited library component in undo list * - Place the current edited library component in undo list * - Get old version of the current edited library component * - Get old version of the current edited library component * @return FALSE if nothing done, else TRUE * @return FALSE if nothing done, else true */ */ { { if( GetScreen()->m_RedoList == NULL ) if ( GetScreen()->GetRedoCommandCount() <= 0 ) return FALSE; return false; PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST(); ITEM_PICKER wrapper(CurrentLibEntry); lastcmd->PushItem(wrapper); GetScreen()->PushCommandToUndoList( lastcmd ); GetScreen()->AddItemToUndoList( (EDA_BaseStruct*) CurrentLibEntry ); lastcmd = GetScreen()->PopCommandFromRedoList( ); CurrentLibEntry = (EDA_LibComponentStruct*) GetScreen()->GetItemFromRedoList(); wrapper = lastcmd->PopItem(); CurrentLibEntry = (EDA_LibComponentStruct*) wrapper.m_Item; if( CurrentLibEntry ) if( CurrentLibEntry ) CurrentLibEntry->SetNext( NULL ); CurrentLibEntry->SetNext( NULL ); CurrentDrawItem = NULL; CurrentDrawItem = NULL; Loading @@ -61,7 +77,7 @@ bool WinEDA_LibeditFrame::GetComponentFromRedoList() ReCreateHToolbar(); ReCreateHToolbar(); SetToolbars(); SetToolbars(); return TRUE; return true; } } Loading @@ -72,15 +88,21 @@ bool WinEDA_LibeditFrame::GetComponentFromUndoList() /* Undo the last edition: /* Undo the last edition: * - Place the current edited library component in Redo list * - Place the current edited library component in Redo list * - Get old version of the current edited library component * - Get old version of the current edited library component * @return FALSE if nothing done, else TRUE * @return FALSE if nothing done, else true */ */ { { if( GetScreen()->m_UndoList == NULL ) if ( GetScreen()->GetUndoCommandCount() <= 0 ) return FALSE; return false; PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST(); ITEM_PICKER wrapper(CurrentLibEntry); lastcmd->PushItem(wrapper); GetScreen()->PushCommandToRedoList( lastcmd ); lastcmd = GetScreen()->PopCommandFromUndoList( ); GetScreen()->AddItemToRedoList( (EDA_BaseStruct*) CurrentLibEntry ); wrapper = lastcmd->PopItem(); CurrentLibEntry = CurrentLibEntry = (EDA_LibComponentStruct*) wrapper.m_Item; (EDA_LibComponentStruct*) GetScreen()->GetItemFromUndoList(); if( CurrentLibEntry ) if( CurrentLibEntry ) CurrentLibEntry->SetNext( NULL ); CurrentLibEntry->SetNext( NULL ); Loading @@ -89,5 +111,5 @@ bool WinEDA_LibeditFrame::GetComponentFromUndoList() ReCreateHToolbar(); ReCreateHToolbar(); SetToolbars(); SetToolbars(); return TRUE; return true; } }
eeschema/libframe.cpp +2 −2 Original line number Original line Diff line number Diff line Loading @@ -279,8 +279,8 @@ void WinEDA_LibeditFrame::SetToolbars() if( GetScreen() ) if( GetScreen() ) { { m_HToolBar->EnableTool( ID_LIBEDIT_UNDO, GetScreen()->m_UndoList ); m_HToolBar->EnableTool( ID_LIBEDIT_UNDO, GetScreen()->GetUndoCommandCount() ); m_HToolBar->EnableTool( ID_LIBEDIT_REDO, GetScreen()->m_RedoList ); m_HToolBar->EnableTool( ID_LIBEDIT_REDO, GetScreen()->GetRedoCommandCount() ); } } } } Loading