creaContours_lib
CommandsHandler Class Reference

#include <CommandsHandler.h>

Collaboration diagram for CommandsHandler:

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 ()
 
CommandObjectgetActual_UNDO ()
 
CommandObjectgetActual_REDO ()
 
CommandObjectget_DO_CommandAt (int position)
 
CommandObjectget_UNDO_CommandAt (int position)
 
void validateOperationsAvaliability ()
 
void setModelBoss (ICommandsUser *theModelParent)
 

Private Attributes

CommandsRegisterStructureredo_actions
 
CommandsRegisterStructureunDo_actions
 
bool posibleUNDO
 
bool posibleREDO
 
ICommandsUsertheWorksSpaceBoss
 
bool isLastREDO_executed
 
bool isLastUNDO_executed
 
std::deque< CommandObject * > executionQueue
 

Detailed Description

Definition at line 40 of file CommandsHandler.h.

Constructor & Destructor Documentation

CommandsHandler::CommandsHandler ( )

Definition at line 44 of file CommandsHandler.cxx.

References isLastREDO_executed, isLastUNDO_executed, posibleREDO, posibleUNDO, redo_actions, and unDo_actions.

45  {
48 
49  posibleREDO = false;
50  posibleUNDO = false;
51 
52  isLastREDO_executed = true;
53  isLastUNDO_executed = false;
54  }
CommandsHandler::~CommandsHandler ( )

Definition at line 59 of file CommandsHandler.cxx.

References clearActions(), redo_actions, and unDo_actions.

60  {
61  clearActions();
62  delete redo_actions;
63  delete unDo_actions;
64  }

Here is the call graph for this function:

Member Function Documentation

void CommandsHandler::clearActions ( )

Definition at line 223 of file CommandsHandler.cxx.

References CommandsRegisterStructure::clearActions(), redo_actions, and unDo_actions.

Referenced by ~CommandsHandler().

224  {
227  }

Here is the call graph for this function:

Here is the caller graph for this function:

CommandObject * CommandsHandler::get_DO_CommandAt ( int  position)

Definition at line 262 of file CommandsHandler.cxx.

References CommandsRegisterStructure::getCommandAt(), and redo_actions.

263  {
264  return redo_actions->getCommandAt(position);
265  }

Here is the call graph for this function:

CommandObject * CommandsHandler::get_UNDO_CommandAt ( int  position)

Definition at line 271 of file CommandsHandler.cxx.

References CommandsRegisterStructure::getCommandAt(), and unDo_actions.

272  {
273  return unDo_actions->getCommandAt(position);
274  }

Here is the call graph for this function:

CommandObject * CommandsHandler::getActual_REDO ( )

Definition at line 253 of file CommandsHandler.cxx.

References CommandsRegisterStructure::getActual_Pointer(), and redo_actions.

Referenced by redo().

254  {
256  }

Here is the call graph for this function:

Here is the caller graph for this function:

CommandObject * CommandsHandler::getActual_UNDO ( )

Definition at line 244 of file CommandsHandler.cxx.

References CommandsRegisterStructure::getActual_Pointer(), and unDo_actions.

Referenced by undo().

245  {
247  }

Here is the call graph for this function:

Here is the caller graph for this function:

int CommandsHandler::getTotalCommands ( )

Definition at line 233 of file CommandsHandler.cxx.

References CommandsRegisterStructure::getTotalCommandsCount(), redo_actions, and unDo_actions.

234  {
235  int value = redo_actions->getTotalCommandsCount();
236  return value == (unDo_actions->getTotalCommandsCount()) ? value : -1;
237  }

Here is the call graph for this function:

bool CommandsHandler::isPosibleREDO ( )

Definition at line 197 of file CommandsHandler.cxx.

References posibleREDO.

198  {
199  return posibleREDO;
200  }
bool CommandsHandler::isPosibleUNDO ( )

Definition at line 188 of file CommandsHandler.cxx.

References posibleUNDO.

189  {
190  return posibleUNDO;
191  }
bool CommandsHandler::redo ( )

Definition at line 137 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().

138  {
139  bool executed = posibleREDO;
140  if( posibleREDO )
141  {
142  validateOperationsAvaliability();//para borrar!!!!!!!!-----------------------------*********************---------------------
143  isLastREDO_executed = true;
144  //isLastUNDO_executed = false; // Posible needed
145  executed = theWorksSpaceBoss->executeCommand(getActual_REDO(), true);
147  {
148  executed = redo_actions->moveForward_Actual();
149  executed = executed && redo_actions->moveBack_Last();
150  isLastUNDO_executed = false;
151  }
153  {
154  executed = redo_actions->moveForward_Actual();
156  executed = executed && unDo_actions->moveForward_Last();
157  executed = executed && unDo_actions->moveForward_Actual();
159  executed = executed && redo_actions->moveForward_Last();
160  }
161  else
162  {
163  executed = unDo_actions->moveForward_Actual();
164  executed = executed && unDo_actions->moveForward_Last();
165  executed = executed && redo_actions->moveForward_Actual();
166  if( redo_actions->hasLastNext() )
167  executed = executed && redo_actions->moveForward_Last();
168  else
169  executed = executed && redo_actions->moveBack_Last();
170  }
172  {
173  isLastUNDO_executed = false;
174  }
176  {
177  isLastUNDO_executed = false;
178  }
180  }
181  return executed;
182  }

Here is the call graph for this function:

Here is the caller graph for this function:

void CommandsHandler::registerCommand ( CommandObject doneAction,
CommandObject unDoAction 
)

Definition at line 76 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().

77  {
78  int actToUNDO = unDo_actions->getActualIndex();
79  redo_actions->setActualIndex( actToUNDO );
80 
81  redo_actions->registerCommand(doneAction);
82  unDo_actions->registerCommand(unDoAction);
83 
84  posibleREDO = false;
85  posibleUNDO = true;
86 
87  isLastREDO_executed = true;
88  isLastUNDO_executed = false;
89 
90  }

Here is the call graph for this function:

Here is the caller graph for this function:

void CommandsHandler::setModelBoss ( ICommandsUser theModelParent)

Definition at line 280 of file CommandsHandler.cxx.

References theWorksSpaceBoss.

Referenced by ContourWorkspace::ContourWorkspace().

281  {
282  theWorksSpaceBoss = theModelParent;
283  }

Here is the caller graph for this function:

void CommandsHandler::setPosibleREDO ( bool  REDOstate)

Definition at line 215 of file CommandsHandler.cxx.

References posibleREDO.

216  {
217  posibleREDO = REDOstate;
218  }
void CommandsHandler::setPosibleUNDO ( bool  UNDOstate)

Definition at line 206 of file CommandsHandler.cxx.

References posibleUNDO.

207  {
208  posibleUNDO = UNDOstate;
209  }
bool CommandsHandler::undo ( )

Definition at line 96 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().

97  {
98  bool executed = posibleUNDO;
99  if( posibleUNDO )
100  {
101  validateOperationsAvaliability();//para borrar!!!!!!!!-----------------------------*********************---------------------
102  executed = theWorksSpaceBoss->executeCommand(getActual_UNDO(), true);
103  isLastUNDO_executed = true;
105  {
107  executed = unDo_actions->moveBack_Actual() ;
108  else
109  executed = true;
110  if( unDo_actions->hasLastNext() )
111  executed = executed && unDo_actions->moveBack_Last();
112  isLastREDO_executed = false;
113  }
115  {
116  executed = redo_actions->moveBack_Actual();
117  executed = executed && redo_actions->moveBack_Last();
118  executed = executed && unDo_actions->moveBack_Last();
119  }
120  else
121  {
122  executed = unDo_actions->moveBack_Last();
123  executed = executed && unDo_actions->moveBack_Actual();
124  executed = executed && redo_actions->moveBack_Actual();
125  if( redo_actions->hasLastNext() )
126  executed = executed && redo_actions->moveBack_Last();
127  }
129  }
130  return executed;
131  }

Here is the call graph for this function:

Here is the caller graph for this function:

void CommandsHandler::validateOperationsAvaliability ( )

Definition at line 288 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().

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

std::deque<CommandObject *> CommandsHandler::executionQueue
private

Definition at line 175 of file CommandsHandler.h.

bool CommandsHandler::isLastREDO_executed
private
bool CommandsHandler::isLastUNDO_executed
private
bool CommandsHandler::posibleREDO
private
bool CommandsHandler::posibleUNDO
private
ICommandsUser* CommandsHandler::theWorksSpaceBoss
private

Definition at line 169 of file CommandsHandler.h.

Referenced by redo(), setModelBoss(), and undo().


The documentation for this class was generated from the following files: