#include <CommandsHandler.h>
Public Member Functions | |
CommandsHandler () | |
~CommandsHandler () | |
void | registerCommand (CommandObject *doneAction, CommandObject *unDoAction) |
bool | undo () |
bool | redo () |
bool | isPosibleUNDO () |
bool | isPosibleREDO () |
void | setPosibleUNDO (bool UNDOstate) |
void | setPosibleREDO (bool REDOstate) |
void | clearActions () |
int | getTotalCommands () |
CommandObject * | getActual_UNDO () |
CommandObject * | getActual_REDO () |
CommandObject * | get_DO_CommandAt (int position) |
CommandObject * | get_UNDO_CommandAt (int position) |
void | validateOperationsAvaliability () |
void | setModelBoss (ICommandsUser *theModelParent) |
Private Attributes | |
CommandsRegisterStructure * | redo_actions |
CommandsRegisterStructure * | unDo_actions |
bool | posibleUNDO |
bool | posibleREDO |
ICommandsUser * | theWorksSpaceBoss |
bool | isLastREDO_executed |
bool | isLastUNDO_executed |
std::deque< CommandObject * > | executionQueue |
Definition at line 15 of file CommandsHandler.h.
CommandsHandler::CommandsHandler | ( | ) |
Definition at line 19 of file CommandsHandler.cxx.
References isLastREDO_executed, isLastUNDO_executed, posibleREDO, posibleUNDO, redo_actions, and unDo_actions.
00020 { 00021 redo_actions = new CommandsRegisterStructure(); 00022 unDo_actions = new CommandsRegisterStructure(); 00023 00024 posibleREDO = false; 00025 posibleUNDO = false; 00026 00027 isLastREDO_executed = true; 00028 isLastUNDO_executed = false; 00029 }
CommandsHandler::~CommandsHandler | ( | ) |
Definition at line 34 of file CommandsHandler.cxx.
References clearActions(), redo_actions, and unDo_actions.
00035 { 00036 clearActions(); 00037 delete redo_actions; 00038 delete unDo_actions; 00039 }
void CommandsHandler::clearActions | ( | ) |
Definition at line 198 of file CommandsHandler.cxx.
References CommandsRegisterStructure::clearActions(), redo_actions, and unDo_actions.
Referenced by ~CommandsHandler().
00199 { 00200 redo_actions->clearActions(); 00201 unDo_actions->clearActions(); 00202 }
CommandObject * CommandsHandler::get_DO_CommandAt | ( | int | position | ) |
Definition at line 237 of file CommandsHandler.cxx.
References CommandsRegisterStructure::getCommandAt(), and redo_actions.
00238 { 00239 return redo_actions->getCommandAt(position); 00240 }
CommandObject * CommandsHandler::get_UNDO_CommandAt | ( | int | position | ) |
Definition at line 246 of file CommandsHandler.cxx.
References CommandsRegisterStructure::getCommandAt(), and unDo_actions.
00247 { 00248 return unDo_actions->getCommandAt(position); 00249 }
CommandObject * CommandsHandler::getActual_REDO | ( | ) |
Definition at line 228 of file CommandsHandler.cxx.
References CommandsRegisterStructure::getActual_Pointer(), and redo_actions.
Referenced by redo().
00229 { 00230 return redo_actions->getActual_Pointer(); 00231 }
CommandObject * CommandsHandler::getActual_UNDO | ( | ) |
Definition at line 219 of file CommandsHandler.cxx.
References CommandsRegisterStructure::getActual_Pointer(), and unDo_actions.
Referenced by undo().
00220 { 00221 return unDo_actions->getActual_Pointer(); 00222 }
int CommandsHandler::getTotalCommands | ( | ) |
Definition at line 208 of file CommandsHandler.cxx.
References CommandsRegisterStructure::getTotalCommandsCount(), redo_actions, and unDo_actions.
00209 { 00210 int value = redo_actions->getTotalCommandsCount(); 00211 return value == (unDo_actions->getTotalCommandsCount()) ? value : -1; 00212 }
bool CommandsHandler::isPosibleREDO | ( | ) |
Definition at line 172 of file CommandsHandler.cxx.
References posibleREDO.
00173 { 00174 return posibleREDO; 00175 }
bool CommandsHandler::isPosibleUNDO | ( | ) |
Definition at line 163 of file CommandsHandler.cxx.
References posibleUNDO.
00164 { 00165 return posibleUNDO; 00166 }
bool CommandsHandler::redo | ( | ) |
Definition at line 112 of file CommandsHandler.cxx.
References ICommandsUser::executeCommand(), getActual_REDO(), CommandsRegisterStructure::hasActualNext(), CommandsRegisterStructure::hasActualPrevious(), CommandsRegisterStructure::hasLastNext(), isLastREDO_executed, isLastUNDO_executed, CommandsRegisterStructure::moveBack_Last(), CommandsRegisterStructure::moveForward_Actual(), CommandsRegisterStructure::moveForward_Last(), posibleREDO, redo_actions, theWorksSpaceBoss, unDo_actions, and validateOperationsAvaliability().
Referenced by ContourWorkspace::callREDO().
00113 { 00114 bool executed = posibleREDO; 00115 if( posibleREDO ) 00116 { 00117 validateOperationsAvaliability();//para borrar!!!!!!!!-----------------------------*********************--------------------- 00118 isLastREDO_executed = true; 00119 //isLastUNDO_executed = false; // Posible needed 00120 executed = theWorksSpaceBoss->executeCommand(getActual_REDO(), true); 00121 if (!unDo_actions->hasActualPrevious() && !redo_actions->hasActualPrevious()) 00122 { 00123 executed = redo_actions->moveForward_Actual(); 00124 executed = executed && redo_actions->moveBack_Last(); 00125 isLastUNDO_executed = false; 00126 } 00127 else if (!unDo_actions->hasActualPrevious() && redo_actions->hasActualPrevious()) 00128 { 00129 executed = redo_actions->moveForward_Actual(); 00130 if(unDo_actions->hasLastNext()) 00131 executed = executed && unDo_actions->moveForward_Last(); 00132 executed = executed && unDo_actions->moveForward_Actual(); 00133 if(redo_actions->hasLastNext()) 00134 executed = executed && redo_actions->moveForward_Last(); 00135 } 00136 else 00137 { 00138 executed = unDo_actions->moveForward_Actual(); 00139 executed = executed && unDo_actions->moveForward_Last(); 00140 executed = executed && redo_actions->moveForward_Actual(); 00141 if( redo_actions->hasLastNext() ) 00142 executed = executed && redo_actions->moveForward_Last(); 00143 else 00144 executed = executed && redo_actions->moveBack_Last(); 00145 } 00146 if (!unDo_actions->hasActualPrevious() && redo_actions->hasActualPrevious()) 00147 { 00148 isLastUNDO_executed = false; 00149 } 00150 if (!unDo_actions->hasActualNext() && !redo_actions->hasActualNext()) 00151 { 00152 isLastUNDO_executed = false; 00153 } 00154 validateOperationsAvaliability(); 00155 } 00156 return executed; 00157 }
void CommandsHandler::registerCommand | ( | CommandObject * | doneAction, | |
CommandObject * | unDoAction | |||
) |
Definition at line 51 of file CommandsHandler.cxx.
References CommandsRegisterStructure::getActualIndex(), isLastREDO_executed, isLastUNDO_executed, posibleREDO, posibleUNDO, redo_actions, CommandsRegisterStructure::registerCommand(), CommandsRegisterStructure::setActualIndex(), and unDo_actions.
Referenced by ContourWorkspace::callRegisterCommand().
00052 { 00053 int actToUNDO = unDo_actions->getActualIndex(); 00054 redo_actions->setActualIndex( actToUNDO ); 00055 00056 redo_actions->registerCommand(doneAction); 00057 unDo_actions->registerCommand(unDoAction); 00058 00059 posibleREDO = false; 00060 posibleUNDO = true; 00061 00062 isLastREDO_executed = true; 00063 isLastUNDO_executed = false; 00064 00065 }
void CommandsHandler::setModelBoss | ( | ICommandsUser * | theModelParent | ) |
Definition at line 255 of file CommandsHandler.cxx.
References theWorksSpaceBoss.
Referenced by ContourWorkspace::ContourWorkspace().
00256 { 00257 theWorksSpaceBoss = theModelParent; 00258 }
void CommandsHandler::setPosibleREDO | ( | bool | REDOstate | ) |
Definition at line 190 of file CommandsHandler.cxx.
References posibleREDO.
00191 { 00192 posibleREDO = REDOstate; 00193 }
void CommandsHandler::setPosibleUNDO | ( | bool | UNDOstate | ) |
Definition at line 181 of file CommandsHandler.cxx.
References posibleUNDO.
00182 { 00183 posibleUNDO = UNDOstate; 00184 }
bool CommandsHandler::undo | ( | ) |
Definition at line 71 of file CommandsHandler.cxx.
References ICommandsUser::executeCommand(), getActual_UNDO(), CommandsRegisterStructure::hasActualNext(), CommandsRegisterStructure::hasActualPrevious(), CommandsRegisterStructure::hasLastNext(), isLastREDO_executed, isLastUNDO_executed, CommandsRegisterStructure::moveBack_Actual(), CommandsRegisterStructure::moveBack_Last(), posibleUNDO, redo_actions, theWorksSpaceBoss, unDo_actions, and validateOperationsAvaliability().
Referenced by ContourWorkspace::callUNDO().
00072 { 00073 bool executed = posibleUNDO; 00074 if( posibleUNDO ) 00075 { 00076 validateOperationsAvaliability();//para borrar!!!!!!!!-----------------------------*********************--------------------- 00077 executed = theWorksSpaceBoss->executeCommand(getActual_UNDO(), true); 00078 isLastUNDO_executed = true; 00079 if (!unDo_actions->hasActualNext() && !redo_actions->hasActualNext()) 00080 { 00081 if(unDo_actions->hasActualPrevious()) 00082 executed = unDo_actions->moveBack_Actual() ; 00083 else 00084 executed = true; 00085 if( unDo_actions->hasLastNext() ) 00086 executed = executed && unDo_actions->moveBack_Last(); 00087 isLastREDO_executed = false; 00088 } 00089 else if (!unDo_actions->hasActualPrevious() && redo_actions->hasActualPrevious()) 00090 { 00091 executed = redo_actions->moveBack_Actual(); 00092 executed = executed && redo_actions->moveBack_Last(); 00093 executed = executed && unDo_actions->moveBack_Last(); 00094 } 00095 else 00096 { 00097 executed = unDo_actions->moveBack_Last(); 00098 executed = executed && unDo_actions->moveBack_Actual(); 00099 executed = executed && redo_actions->moveBack_Actual(); 00100 if( redo_actions->hasLastNext() ) 00101 executed = executed && redo_actions->moveBack_Last(); 00102 } 00103 validateOperationsAvaliability(); 00104 } 00105 return executed; 00106 }
void CommandsHandler::validateOperationsAvaliability | ( | ) |
Definition at line 263 of file CommandsHandler.cxx.
References CommandsRegisterStructure::hasActualNext(), CommandsRegisterStructure::hasActualPrevious(), isLastREDO_executed, isLastUNDO_executed, posibleREDO, posibleUNDO, redo_actions, and unDo_actions.
Referenced by redo(), and undo().
00264 { 00265 posibleREDO = (redo_actions->hasActualNext() && unDo_actions->hasActualNext() )? true : 00266 ( (!redo_actions->hasActualNext()&& unDo_actions->hasActualNext() ) ? true : 00267 ( !unDo_actions->hasActualNext() && !redo_actions->hasActualNext() )? false : true && !isLastREDO_executed ); 00268 00269 posibleUNDO = (redo_actions->hasActualPrevious() && unDo_actions->hasActualPrevious() )? true : 00270 ( (!unDo_actions->hasActualPrevious()&& redo_actions->hasActualPrevious() ) ? true : 00271 ( !unDo_actions->hasActualPrevious() && !redo_actions->hasActualPrevious() )? false : true && !isLastUNDO_executed ); 00272 00273 }
std::deque<CommandObject *> CommandsHandler::executionQueue [private] |
Definition at line 150 of file CommandsHandler.h.
bool CommandsHandler::isLastREDO_executed [private] |
Definition at line 146 of file CommandsHandler.h.
Referenced by CommandsHandler(), redo(), registerCommand(), undo(), and validateOperationsAvaliability().
bool CommandsHandler::isLastUNDO_executed [private] |
Definition at line 148 of file CommandsHandler.h.
Referenced by CommandsHandler(), redo(), registerCommand(), undo(), and validateOperationsAvaliability().
bool CommandsHandler::posibleREDO [private] |
Definition at line 142 of file CommandsHandler.h.
Referenced by CommandsHandler(), isPosibleREDO(), redo(), registerCommand(), setPosibleREDO(), and validateOperationsAvaliability().
bool CommandsHandler::posibleUNDO [private] |
Definition at line 140 of file CommandsHandler.h.
Referenced by CommandsHandler(), isPosibleUNDO(), registerCommand(), setPosibleUNDO(), undo(), and validateOperationsAvaliability().
Definition at line 136 of file CommandsHandler.h.
Referenced by clearActions(), CommandsHandler(), get_DO_CommandAt(), getActual_REDO(), getTotalCommands(), redo(), registerCommand(), undo(), validateOperationsAvaliability(), and ~CommandsHandler().
ICommandsUser* CommandsHandler::theWorksSpaceBoss [private] |
Definition at line 138 of file CommandsHandler.h.
Referenced by clearActions(), CommandsHandler(), get_UNDO_CommandAt(), getActual_UNDO(), getTotalCommands(), redo(), registerCommand(), undo(), validateOperationsAvaliability(), and ~CommandsHandler().