1 /****************************************************************************
2 ** $Id: rs_undoable.cpp 1648 2003-06-11 06:56:01Z andrew $
4 ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
6 ** This file is part of the qcadlib Library project.
8 ** This file may be distributed and/or modified under the terms of the
9 ** GNU General Public License version 2 as published by the Free Software
10 ** Foundation and appearing in the file LICENSE.GPL included in the
11 ** packaging of this file.
13 ** Licensees holding valid qcadlib Professional Edition licenses may use
14 ** this file in accordance with the qcadlib Commercial License
15 ** Agreement provided with the Software.
17 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 ** See http://www.ribbonsoft.com for further details.
22 ** Contact info@ribbonsoft.com if any conditions of this licensing are
25 **********************************************************************/
27 #include "rs_undoable.h"
29 #include "rs_undocycle.h"
32 * Default constructor.
34 RS_Undoable::RS_Undoable()
40 * Destructor. Makes sure that this undoable is removed from
41 * its undo cycle before it is deleted.
43 RS_Undoable::~RS_Undoable()
46 cycle->removeUndoable(this);
50 * Runtime type identification for undoables.
51 * Note that this is voluntarily. The default implementation
52 * returns RS2::UndoableUnknown.
54 /*virtual*/ RS2::UndoableType RS_Undoable::undoRtti()
56 return RS2::UndoableUnknown;
60 * Sets the undo cycle this entity is in. This is necessary to
61 * make sure the entity can remove itself from the cycle before
64 void RS_Undoable::setUndoCycle(RS_UndoCycle * cycle)
70 * The undoable thing gets activated if it was undone and
71 * deactivated otherwise.
73 void RS_Undoable::changeUndoState()
75 toggleFlag(RS2::FlagUndone);
76 undoStateChanged(isUndone());
80 * Undoes or redoes an undoable.
82 void RS_Undoable::setUndoState(bool undone)
85 setFlag(RS2::FlagUndone);
87 delFlag(RS2::FlagUndone);
89 undoStateChanged(isUndone());
93 * Is this entity in the Undo memory and not active?
95 bool RS_Undoable::isUndone() const
97 return getFlag(RS2::FlagUndone);
101 * Can be overwriten by the implementing class to be notified
102 * when the undo state changes (the undoable becomes visible / invisible).
104 /*virtual*/ void RS_Undoable::undoStateChanged(bool /*undone*/)