44 #include "GroupData.hh" 46 #include "GroupBackup.hh" 71 if ( undoStates_.empty() )
79 IdList ids = current->objectIDs();
81 for (
unsigned int i=0; i < ids.size(); i++ ){
94 backupData =
dynamic_cast< BackupData*
>(
object->objectData(OBJECT_BACKUPS));
104 undoStates_.pop_back();
105 redoStates_.push_back( currentState_ );
106 currentState_ = backup;
120 if ( redoStates_.empty() )
125 if ( redoState == 0 )
128 IdList ids = redoState->objectIDs();
130 for (
unsigned int i=0; i < ids.size(); i++ ){
143 backupData =
dynamic_cast< BackupData*
>(
object->objectData(OBJECT_BACKUPS));
153 redoStates_.pop_back();
154 undoStates_.push_back( currentState_ );
155 currentState_ = backup;
178 if ( current->contains(_objectid) ){
183 undoStates_.pop_back();
184 redoStates_.push_back( currentState_ );
185 currentState_ = backup;
191 int backupIndex = -1;
193 for(
int i=undoStates_.size()-1; i >= 0; --i){
195 if ( back->contains(_objectid) ){
206 undoStates_.erase( undoStates_.begin() + backupIndex );
207 redoStates_.push_back( backup );
209 std::cerr <<
"Error: Cannot updateBackupData. Backup is blocked!" << std::endl;
216 int backupIndex = -1;
218 for(
int i=redoStates_.size()-1; i >= 0; --i){
220 if ( back->contains(_objectid) ){
231 redoStates_.erase( redoStates_.begin() + backupIndex );
232 undoStates_.push_back( currentState_ );
233 currentState_ = backup;
235 std::cerr <<
"Error: Cannot updateBackupData. Backup is blocked!" << std::endl;
259 std::cerr <<
"Cannot undo operation. This backup involves multiple objects!" << std::endl;
285 std::cerr <<
"Cannot redo operation. This backup involves multiple objects!" << std::endl;
298 if (dynamic_cast<const GroupBackup* >(_b) && dynamic_cast<const GroupBackup* >(_b)->contains(id_))
312 undoStates_.erase(std::remove_if(undoStates_.begin(),undoStates_.end(),
ContainsId_deleter(_objectid)), undoStates_.end());
313 redoStates_.erase(std::remove_if(redoStates_.begin(),redoStates_.end(),
ContainsId_deleter(_objectid)), redoStates_.end());
319 if (!undoStates_.empty())
321 currentState_ = undoStates_.back();
322 undoStates_.pop_back();
323 }
else if (!redoStates_.empty())
325 currentState_ = redoStates_.back();
326 redoStates_.pop_back();
bool redoBlocked()
return if a redo backup is blocked
void undo()
perform an undo if possible
void redo()
perform an redo if possible
Class that encapsulates simultaneous backups on multiple objects.
void undo()
perform an undo if possible
bool blocked()
Returns if this backup is blocked.
Class that encapsulates a backup.
void updateBackupData(int _objectid, bool _isUndo)
remove object from data
void eraseBackups(int _objectid)
erase all backups containing given id
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
std::vector< int > IdList
Standard Type for id Lists used for scripting.
Abstract class that is used to store backups.
bool hasObjectData(QString _dataName)
Checks if object data with given name is available.
void redo()
perform a redo if possible
bool undoBlocked()
return if an undo backup is blocked