kicad-source/pcbnew/board_commit.h
Jeff Young 6f389fd320 Tighten parent/child undo/redo architecture.
Always look for pre-existing undo/redo record.  Checking for IsNew()
is less robust and should be avoided.  Also moves the checking to a
location where it will be easier to ensure that it's uniform.

Push get-undo-level-item processing down a level so it is uniformly
called.

Make sure tables & labels are uniformly handled.

Remove incorrect usage of Get/SetGroupId() for storing lastPin
(which we don't use anyway).

Lists of deleted and changed items MUST include the screen pointer.
An item could be changed on one screen but not on another.

Also tightens handling of PCB_NETINFO_T items, which are not in the
view.

Also fixes a bug where there is no increment parameter if you assign
the base increment command to a hotkey.
(This was discovered while testing the above changes.)

Also fixes a bug where delete during a move in PCB Editor did an
undo instead of a delete.
(Again, found while testing above.)

An experiment was also run to collapse shared parts of SCH_EDIT_FRAME
and SYMBOL_EDITOR_FRAME into SCH_BASE_EDIT_FRAME.  However, sharing the
undo code actually increased complexity, and there was very little else
of value in SCH_BASE_EDIT_FRAME (other than the Increment() routines).
2025-08-18 19:20:09 +01:00

86 lines
2.9 KiB
C++

/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 CERN
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#pragma once
#include <commit.h>
class BOARD_ITEM;
class PCB_SHAPE;
class ZONE;
class BOARD;
class PICKED_ITEMS_LIST;
class PCB_TOOL_BASE;
class TOOL_MANAGER;
class EDA_DRAW_FRAME;
class TOOL_BASE;
#define SKIP_UNDO 0x0001
#define APPEND_UNDO 0x0002
#define SKIP_SET_DIRTY 0x0004
#define SKIP_CONNECTIVITY 0x0008
#define ZONE_FILL_OP 0x0010
#define SKIP_TEARDROPS 0x0020
class BOARD_COMMIT : public COMMIT
{
public:
BOARD_COMMIT( EDA_DRAW_FRAME* aFrame );
BOARD_COMMIT( TOOL_BASE* aTool );
BOARD_COMMIT( TOOL_MANAGER* aMgr );
BOARD_COMMIT( TOOL_MANAGER* aMgr, bool aIsBoardEditor, bool aIsFootprintEditor );
virtual ~BOARD_COMMIT() {}
BOARD* GetBoard() const;
virtual void Push( const wxString& aMessage = wxEmptyString, int aCommitFlags = 0 ) override;
virtual void Revert() override;
COMMIT& Stage( EDA_ITEM* aItem, CHANGE_TYPE aChangeType,
BASE_SCREEN* aScreen = nullptr,
RECURSE_MODE aRecurse = RECURSE_MODE::NO_RECURSE ) override;
COMMIT& Stage( std::vector<EDA_ITEM*>& container, CHANGE_TYPE aChangeType,
BASE_SCREEN* aScreen = nullptr ) override;
COMMIT& Stage( const PICKED_ITEMS_LIST& aItems,
UNDO_REDO aModFlag = UNDO_REDO::UNSPECIFIED,
BASE_SCREEN* aScreen = nullptr ) override;
static EDA_ITEM* MakeImage( EDA_ITEM* aItem );
private:
EDA_ITEM* undoLevelItem( EDA_ITEM* aItem ) const override;
EDA_ITEM* makeImage( EDA_ITEM* aItem ) const override;
void propagateDamage( BOARD_ITEM* aItem, std::vector<ZONE*>* aStaleZones,
std::vector<BOX2I>& aStaleRuleAreas );
private:
TOOL_MANAGER* m_toolMgr;
bool m_isBoardEditor;
bool m_isFootprintEditor;
};