Changeset e69c87 for src


Ignore:
Timestamp:
Sep 21, 2011, 8:04:30 PM (13 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
520f93
Parents:
caeeb8
git-author:
Frederik Heber <heber@…> (04/27/11 12:06:33)
git-committer:
Frederik Heber <heber@…> (09/21/11 20:04:30)
Message:

Splitted off Undo and Redo parts into own tests (3-step rule).

  • this way tests are cleaner as there are no old files left.
  • added lots of Undos/Redos.

Corrected all failing regression tests (of these new Undos/Redos):

Location:
src
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/Action.cpp

    rcaeeb8 re69c87  
    2525
    2626#include "Actions/Action.hpp"
     27#include "Actions/ActionExceptions.hpp"
    2728#include "Actions/ActionRegistry.hpp"
    2829#include "Actions/ActionHistory.hpp"
     
    171172    }
    172173  }
     174
     175  // throw an exception that can be caught in case of failure
     176  if (state == Action::failure)
     177    throw ActionFailureException() << ActionNameString(getName());
    173178}
    174179Action::state_ptr Action::undo(state_ptr _state) {
  • src/Actions/ActionHistory.cpp

    rcaeeb8 re69c87  
    2222#include "Actions/ActionHistory.hpp"
    2323
     24#include "Actions/ActionExceptions.hpp"
     25
    2426#include <iostream>
    2527
     
    3840  history.pop_back();
    3941  Action::state_ptr newState = elem.action->undo(elem.state);
     42  if (newState == Action::failure)
     43    throw ActionFailureException() << ActionNameString(elem.action->getName());
    4044  yrotsih.push_back(HistoryElement(elem.action,newState));
    4145}
     
    4549  yrotsih.pop_back();
    4650  Action::state_ptr oldState = elem.action->redo(elem.state);
     51  if (oldState == Action::failure)
     52    throw ActionFailureException() << ActionNameString(elem.action->getName());
    4753  history.push_back(HistoryElement(elem.action,oldState));
    4854}
  • src/Actions/CommandAction/VerboseAction.cpp

    rcaeeb8 re69c87  
    4040  getParametersfromValueStorage();
    4141
     42
    4243  if (oldverbosity != params.verbosity) {
     44    // prepare undo state
    4345    CommandVerboseState *UndoState = new CommandVerboseState(oldverbosity, params);
     46    // set new verbosity
    4447    setVerbosity(params.verbosity);
    4548    DoLog(0) && (Log() << Verbose(0) << "Setting verbosity from " << oldverbosity << " to " << params.verbosity << "." << endl);
     
    4750  } else {
    4851    DoLog(0) && (Log() << Verbose(0) << "Verbosity remains unchanged at " << oldverbosity << "." << endl);
    49     return Action::failure;
     52    return Action::success;
    5053  }
    5154}
  • src/Actions/Makefile.am

    rcaeeb8 re69c87  
    2020ACTIONSHEADER = \
    2121  Actions/Action.hpp \
     22  Actions/ActionExceptions.hpp \
    2223  Actions/Action_impl_header.hpp \
    2324  Actions/Action_impl_pre.hpp \
  • src/Actions/MoleculeAction/BondFileAction.cpp

    rcaeeb8 re69c87  
    6969
    7070Action::state_ptr MoleculeBondFileAction::performRedo(Action::state_ptr _state){
    71   // Undo and redo have to do the same for this action
    72   return performUndo(_state);
     71  return Action::failure;
    7372}
    7473
    7574bool MoleculeBondFileAction::canUndo() {
    76   return false;
     75  return true;
    7776}
    7877
    7978bool MoleculeBondFileAction::shouldUndo() {
    80   return false;
     79  return true;
    8180}
    8281/** =========== end of function ====================== */
  • src/Actions/MoleculeAction/LoadAction.cpp

    rcaeeb8 re69c87  
    9090
    9191bool MoleculeLoadAction::canUndo() {
    92   return false;
     92  return true;
    9393}
    9494
    9595bool MoleculeLoadAction::shouldUndo() {
    96   return false;
     96  return true;
    9797}
    9898/** =========== end of function ====================== */
  • src/Actions/MoleculeAction/RotateAroundSelfByAngleAction.cpp

    rcaeeb8 re69c87  
    6060    // Creation Line that is the rotation axis
    6161    Vector *CenterOfGravity = mol->DetermineCenterOfGravity();
     62    DoLog(0) && (Log() << Verbose(0) <<  "Center of gravity is " << *CenterOfGravity << "." << std::endl);
    6263    Line RotationAxis(*CenterOfGravity, params.Axis);
    6364    delete(CenterOfGravity);
     
    7879  BOOST_FOREACH(molecule *mol, state->selectedMolecules) {
    7980    Vector *CenterOfGravity = mol->DetermineCenterOfGravity();
     81    DoLog(0) && (Log() << Verbose(0) <<  "Center of gravity is " << *CenterOfGravity << "." << std::endl);
    8082    Line RotationAxis(*CenterOfGravity, state->params.Axis);
    8183    delete(CenterOfGravity);
     84    DoLog(0) && (Log() << Verbose(0) << "Rotate " << mol->getName() << " around self by " << -state->params.angle << " radian around axis " << RotationAxis << "." << endl);
    8285
    8386    for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     
    9497  BOOST_FOREACH(molecule *mol, state->selectedMolecules) {
    9598    Vector *CenterOfGravity = mol->DetermineCenterOfGravity();
     99    DoLog(0) && (Log() << Verbose(0) <<  "Center of gravity is " << *CenterOfGravity << "." << std::endl);
    96100    Line RotationAxis(*CenterOfGravity, state->params.Axis);
    97101    delete(CenterOfGravity);
     102    DoLog(0) && (Log() << Verbose(0) << "Rotate " << mol->getName() << " around self by " << state->params.angle << " radian around axis " << RotationAxis << "." << endl);
    98103
    99104    for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) {
  • src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.cpp

    rcaeeb8 re69c87  
    7171
    7272Action::state_ptr MoleculeRotateToPrincipalAxisSystemAction::performRedo(Action::state_ptr _state){
    73   // Undo and redo have to do the same for this action
    74   return performUndo(_state);
     73  return Action::failure;
    7574}
    7675
    7776bool MoleculeRotateToPrincipalAxisSystemAction::canUndo() {
    78   return false;
     77  return true;
    7978}
    8079
    8180bool MoleculeRotateToPrincipalAxisSystemAction::shouldUndo() {
    82   return false;
     81  return true;
    8382}
    8483/** =========== end of function ====================== */
  • src/Actions/MoleculeAction/VerletIntegrationAction.cpp

    rcaeeb8 re69c87  
    7272
    7373Action::state_ptr MoleculeVerletIntegrationAction::performRedo(Action::state_ptr _state){
    74   // Undo and redo have to do the same for this action
    75   return performUndo(_state);
     74  return Action::failure;
    7675}
    7776
    7877bool MoleculeVerletIntegrationAction::canUndo() {
    79   return false;
     78  return true;
    8079}
    8180
    8281bool MoleculeVerletIntegrationAction::shouldUndo() {
    83   return false;
     82  return true;
    8483}
    8584/** =========== end of function ====================== */
  • src/boundary.cpp

    rcaeeb8 re69c87  
    13451345//  TesselStruct->CorrectAllDegeneratedPolygons();
    13461346//
    1347 //  // check envelope for consistency
    1348 //  status = CheckListOfBaselines(TesselStruct);
     1347  // check envelope for consistency
     1348  status = CheckListOfBaselines(TesselStruct);
    13491349
    13501350  // write final envelope
  • src/builder_init.cpp

    rcaeeb8 re69c87  
    4242#include "World.hpp"
    4343
     44#include "Actions/ActionExceptions.hpp"
     45#include "Actions/ActionHistory.hpp"
    4446#include "Actions/ActionRegistry.hpp"
    45 #include "Actions/ActionHistory.hpp"
    4647
    4748#include "RandomNumbers/RandomNumberDistributionFactory.hpp"
     
    144145{
    145146  MainWindow *mainWindow = UIFactory::getInstance().makeMainWindow();
    146   mainWindow->display();
     147  try {
     148    mainWindow->display();
     149  } catch(ActionFailureException &e) {
     150    std::cerr << "Action " << *boost::get_error_info<ActionNameString>(e) << " has failed." << std::endl;
     151    World::getInstance().setExitFlag(5);
     152  }
    147153  delete mainWindow;
    148154}
Note: See TracChangeset for help on using the changeset viewer.