Changeset 400170 for src/Actions/CmdAction
- Timestamp:
- Jul 28, 2010, 9:35:44 AM (16 years ago)
- 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, Candidate_v1.7.0, Candidate_v1.7.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:
- f12805
- Parents:
- c6f395 (diff), 677e13 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- src/Actions/CmdAction
- Files:
-
- 12 edited
-
BondLengthTableAction.cpp (modified) (3 diffs)
-
BondLengthTableAction.hpp (modified) (2 diffs)
-
ElementDbAction.cpp (modified) (3 diffs)
-
ElementDbAction.hpp (modified) (2 diffs)
-
FastParsingAction.cpp (modified) (3 diffs)
-
FastParsingAction.hpp (modified) (2 diffs)
-
HelpAction.cpp (modified) (2 diffs)
-
HelpAction.hpp (modified) (2 diffs)
-
VerboseAction.cpp (modified) (3 diffs)
-
VerboseAction.hpp (modified) (2 diffs)
-
VersionAction.cpp (modified) (3 diffs)
-
VersionAction.hpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/CmdAction/BondLengthTableAction.cpp
rc6f395 r400170 9 9 10 10 #include "Actions/CmdAction/BondLengthTableAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "bondgraph.hpp" 12 13 #include "config.hpp" … … 22 23 #include "UIElements/UIFactory.hpp" 23 24 #include "UIElements/Dialog.hpp" 24 #include " Actions/MapOfActions.hpp"25 #include "UIElements/ValueStorage.hpp" 25 26 26 27 const char CommandLineBondLengthTableAction::NAME[] = "bond-table"; … … 33 34 {} 34 35 36 void CommandBondLengthTable(std::string &BondGraphFileName) { 37 ValueStorage::getInstance().setCurrentValue(CommandLineBondLengthTableAction::NAME, BondGraphFileName); 38 ActionRegistry::getInstance().getActionByName(CommandLineBondLengthTableAction::NAME)->call(Action::NonInteractive); 39 }; 40 41 Dialog* CommandLineBondLengthTableAction::createDialog() { 42 Dialog *dialog = UIFactory::getInstance().makeDialog(); 43 44 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 45 46 return dialog; 47 } 48 35 49 Action::state_ptr CommandLineBondLengthTableAction::performCall() { 36 50 ostringstream usage; 37 51 string BondGraphFileName; 38 Dialog *dialog = UIFactory::getInstance().makeDialog();39 52 53 ValueStorage::getInstance().queryCurrentValue(NAME, BondGraphFileName); 54 DoLog(0) && (Log() << Verbose(0) << "Using " << BondGraphFileName << " as bond length table." << endl); 40 55 config *configuration = World::getInstance().getConfig(); 41 dialog->queryString(NAME, &BondGraphFileName, MapOfActions::getInstance().getDescription(NAME));42 43 if(dialog->display()) {44 DoLog(0) && (Log() << Verbose(0) << "Using " << BondGraphFileName << " as bond length table." << endl);45 delete dialog;46 } else {47 delete dialog;48 return Action::failure;49 }50 51 56 if (configuration->BG == NULL) { 52 57 configuration->BG = new BondGraph(configuration->GetIsAngstroem()); -
src/Actions/CmdAction/BondLengthTableAction.hpp
rc6f395 r400170 11 11 #include "Actions/Action.hpp" 12 12 13 void CommandBondLengthTable(std::string &BondGraphFileName); 14 13 15 class CommandLineBondLengthTableAction : public Action { 16 friend void CommandBondLengthTable(std::string &BondGraphFileName); 17 14 18 public: 15 19 CommandLineBondLengthTableAction(); … … 21 25 virtual const std::string getName(); 22 26 private: 27 virtual Dialog * createDialog(); 23 28 virtual Action::state_ptr performCall(); 24 29 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/CmdAction/ElementDbAction.cpp
rc6f395 r400170 9 9 10 10 #include "Actions/CmdAction/ElementDbAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "config.hpp" 12 13 #include "log.hpp" … … 22 23 #include "UIElements/UIFactory.hpp" 23 24 #include "UIElements/Dialog.hpp" 24 #include " Actions/MapOfActions.hpp"25 #include "UIElements/ValueStorage.hpp" 25 26 26 27 const char CommandLineElementDbAction::NAME[] = "element-db"; … … 33 34 {} 34 35 36 void CommandElementDb(std::string &databasepath) { 37 ValueStorage::getInstance().setCurrentValue(CommandLineElementDbAction::NAME, databasepath); 38 ActionRegistry::getInstance().getActionByName(CommandLineElementDbAction::NAME)->call(Action::NonInteractive); 39 }; 40 41 Dialog* CommandLineElementDbAction::createDialog() { 42 Dialog *dialog = UIFactory::getInstance().makeDialog(); 43 44 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); 45 46 return dialog; 47 } 48 35 49 Action::state_ptr CommandLineElementDbAction::performCall() { 36 50 ostringstream usage; 37 51 string databasepath; 38 Dialog *dialog = UIFactory::getInstance().makeDialog();39 52 40 53 // get the path 41 54 // TODO: Make databasepath a std::string 42 55 config *configuration = World::getInstance().getConfig(); 43 dialog->queryString(NAME, &databasepath, MapOfActions::getInstance().getDescription(NAME)); 44 45 if(dialog->display()) { 46 strcpy(configuration->databasepath, databasepath.c_str()); 47 delete dialog; 48 } else { 49 delete dialog; 50 return Action::failure; 51 } 56 ValueStorage::getInstance().queryCurrentValue(NAME, databasepath); 57 strcpy(configuration->databasepath, databasepath.c_str()); 52 58 53 59 // load table -
src/Actions/CmdAction/ElementDbAction.hpp
rc6f395 r400170 11 11 #include "Actions/Action.hpp" 12 12 13 void CommandElementDb(std::string &databasepath); 14 13 15 class CommandLineElementDbAction : public Action { 16 friend void CommandElementDb(std::string &databasepath); 17 14 18 public: 15 19 CommandLineElementDbAction(); … … 21 25 virtual const std::string getName(); 22 26 private: 27 virtual Dialog * createDialog(); 23 28 virtual Action::state_ptr performCall(); 24 29 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/CmdAction/FastParsingAction.cpp
rc6f395 r400170 9 9 10 10 #include "Actions/CmdAction/FastParsingAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "config.hpp" 12 13 #include "log.hpp" … … 21 22 #include "UIElements/UIFactory.hpp" 22 23 #include "UIElements/Dialog.hpp" 23 #include "Actions/MapOfActions.hpp" 24 #include "UIElements/ValueStorage.hpp" 25 26 // memento to remember the state when undoing 27 28 class CommandLineFastParsingState : public ActionState { 29 public: 30 CommandLineFastParsingState(bool _bool) : 31 boolean(_bool) 32 {} 33 bool boolean; 34 }; 35 24 36 25 37 const char CommandLineFastParsingAction::NAME[] = "fastparsing"; … … 32 44 {} 33 45 34 Action::state_ptr CommandLineFastParsingAction::performCall() { 46 void CommandFastParsing(bool fastparsing) { 47 ValueStorage::getInstance().setCurrentValue(CommandLineFastParsingAction::NAME, fastparsing); 48 ActionRegistry::getInstance().getActionByName(CommandLineFastParsingAction::NAME)->call(Action::NonInteractive); 49 }; 50 51 Dialog* CommandLineFastParsingAction::createDialog() { 35 52 Dialog *dialog = UIFactory::getInstance().makeDialog(); 36 53 54 dialog->queryBoolean(NAME, MapOfActions::getInstance().getDescription(NAME)); 55 56 return dialog; 57 } 58 59 Action::state_ptr CommandLineFastParsingAction::performCall() { 60 37 61 config *configuration = World::getInstance().getConfig(); 38 dialog->queryBoolean(NAME, &configuration->FastParsing, MapOfActions::getInstance().getDescription(NAME)); 39 40 if(dialog->display()) { 41 if (configuration->FastParsing) 42 DoLog(0) && (Log() << Verbose(0) << "I won't parse trajectories." << endl); 43 else 44 DoLog(0) && (Log() << Verbose(0) << "I will parse trajectories." << endl); 45 delete dialog; 46 return Action::success; 47 } else { 48 delete dialog; 49 return Action::failure; 50 } 62 ValueStorage::getInstance().queryCurrentValue(NAME, configuration->FastParsing); 63 if (configuration->FastParsing) 64 DoLog(0) && (Log() << Verbose(0) << "I won't parse trajectories." << endl); 65 else 66 DoLog(0) && (Log() << Verbose(0) << "I will parse trajectories." << endl); 67 return Action::success; 51 68 } 52 69 53 70 Action::state_ptr CommandLineFastParsingAction::performUndo(Action::state_ptr _state) { 54 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());71 CommandLineFastParsingState *state = assert_cast<CommandLineFastParsingState*>(_state.get()); 55 72 56 return Action::failure; 57 // string newName = state->mol->getName(); 58 // state->mol->setName(state->lastName); 59 // 60 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); 73 config *configuration = World::getInstance().getConfig(); 74 configuration->FastParsing = state->boolean; 75 76 return Action::state_ptr(new CommandLineFastParsingState(!state->boolean)); 61 77 } 62 78 63 79 Action::state_ptr CommandLineFastParsingAction::performRedo(Action::state_ptr _state){ 64 return Action::failure;80 performUndo(_state); 65 81 } 66 82 67 83 bool CommandLineFastParsingAction::canUndo() { 68 return false;84 return true; 69 85 } 70 86 71 87 bool CommandLineFastParsingAction::shouldUndo() { 72 return false;88 return true; 73 89 } 74 90 -
src/Actions/CmdAction/FastParsingAction.hpp
rc6f395 r400170 11 11 #include "Actions/Action.hpp" 12 12 13 void CommandFastParsing(bool fastparsing); 14 13 15 class CommandLineFastParsingAction : public Action { 16 friend void CommandFastParsing(bool fastparsing); 17 14 18 public: 15 19 CommandLineFastParsingAction(); … … 21 25 virtual const std::string getName(); 22 26 private: 27 virtual Dialog * createDialog(); 23 28 virtual Action::state_ptr performCall(); 24 29 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/CmdAction/HelpAction.cpp
rc6f395 r400170 9 9 10 10 #include "Actions/CmdAction/HelpAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "CommandLineParser.hpp" 12 13 … … 29 30 {} 30 31 31 Action::state_ptr CommandLineHelpAction::performCall() { 32 ostringstream usage; 32 void CommandHelp() { 33 ActionRegistry::getInstance().getActionByName(CommandLineHelpAction::NAME)->call(Action::NonInteractive); 34 }; 35 36 Dialog* CommandLineHelpAction::createDialog() { 33 37 Dialog *dialog = UIFactory::getInstance().makeDialog(); 34 38 39 ostringstream usage; 35 40 usage << CommandLineParser::getInstance().visible << endl; 36 41 dialog->queryEmpty(NAME, usage.str()); 37 42 38 if(dialog->display()) { 39 delete dialog; 40 return Action::success; 41 } else { 42 delete dialog; 43 return Action::failure; 44 } 43 return dialog; 44 } 45 46 Action::state_ptr CommandLineHelpAction::performCall() { 47 return Action::success; 45 48 } 46 49 47 50 Action::state_ptr CommandLineHelpAction::performUndo(Action::state_ptr _state) { 48 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get()); 49 50 return Action::failure; 51 // string newName = state->mol->getName(); 52 // state->mol->setName(state->lastName); 53 // 54 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); 51 return Action::success; 55 52 } 56 53 57 54 Action::state_ptr CommandLineHelpAction::performRedo(Action::state_ptr _state){ 58 return Action:: failure;55 return Action::success; 59 56 } 60 57 61 58 bool CommandLineHelpAction::canUndo() { 62 return false;59 return true; 63 60 } 64 61 65 62 bool CommandLineHelpAction::shouldUndo() { 66 return false;63 return true; 67 64 } 68 65 -
src/Actions/CmdAction/HelpAction.hpp
rc6f395 r400170 11 11 #include "Actions/Action.hpp" 12 12 13 void CommandHelp(); 14 13 15 class CommandLineHelpAction : public Action { 16 friend void CommandHelp(); 17 14 18 public: 15 19 CommandLineHelpAction(); … … 21 25 virtual const std::string getName(); 22 26 private: 27 virtual Dialog * createDialog(); 23 28 virtual Action::state_ptr performCall(); 24 29 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/CmdAction/VerboseAction.cpp
rc6f395 r400170 9 9 10 10 #include "Actions/CmdAction/VerboseAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 #include "log.hpp" 12 13 #include "verbose.hpp" … … 19 20 #include "UIElements/UIFactory.hpp" 20 21 #include "UIElements/Dialog.hpp" 21 #include "Actions/MapOfActions.hpp" 22 #include "UIElements/ValueStorage.hpp" 23 24 // memento to remember the state when undoing 25 26 class CommandLineVerboseState : public ActionState { 27 public: 28 CommandLineVerboseState(int _verbosity) : 29 verbosity(_verbosity) 30 {} 31 int verbosity; 32 }; 33 22 34 23 35 const char CommandLineVerboseAction::NAME[] = "verbose"; … … 30 42 {} 31 43 44 void CommandVerbose(int verbosity) { 45 ValueStorage::getInstance().setCurrentValue(CommandLineVerboseAction::NAME, verbosity); 46 ActionRegistry::getInstance().getActionByName(CommandLineVerboseAction::NAME)->call(Action::NonInteractive); 47 }; 48 49 Dialog* CommandLineVerboseAction::createDialog() { 50 Dialog *dialog = UIFactory::getInstance().makeDialog(); 51 52 dialog->queryInt(NAME, ValueStorage::getInstance().getDescription(NAME)); 53 54 return dialog; 55 } 56 32 57 Action::state_ptr CommandLineVerboseAction::performCall() { 33 Dialog *dialog = UIFactory::getInstance().makeDialog();34 58 int verbosity = 2; 35 59 36 dialog->queryInt(NAME, &verbosity, MapOfActions::getInstance().getDescription(NAME));60 ValueStorage::getInstance().queryCurrentValue(NAME, verbosity); 37 61 38 if(dialog->display()) { 39 setVerbosity(verbosity); 40 DoLog(0) && (Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl); 41 delete dialog; 42 return Action::success; 43 } else { 44 delete dialog; 45 return Action::failure; 46 } 62 setVerbosity(verbosity); 63 DoLog(0) && (Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl); 64 return Action::success; 47 65 } 48 66 49 67 Action::state_ptr CommandLineVerboseAction::performUndo(Action::state_ptr _state) { 50 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());68 CommandLineVerboseState *state = assert_cast<CommandLineVerboseState*>(_state.get()); 51 69 52 return Action::failure;53 // string newName = state->mol->getName();54 // state->mol->setName(state->lastName); 55 // 56 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));70 int verbosity = 2; 71 ValueStorage::getInstance().queryCurrentValue(NAME, verbosity); 72 73 setVerbosity(state->verbosity); 74 return Action::state_ptr(new CommandLineVerboseState(verbosity)); 57 75 } 58 76 59 77 Action::state_ptr CommandLineVerboseAction::performRedo(Action::state_ptr _state){ 60 return Action::failure;78 performUndo(_state); 61 79 } 62 80 63 81 bool CommandLineVerboseAction::canUndo() { 64 return false;82 return true; 65 83 } 66 84 67 85 bool CommandLineVerboseAction::shouldUndo() { 68 return false;86 return true; 69 87 } 70 88 -
src/Actions/CmdAction/VerboseAction.hpp
rc6f395 r400170 11 11 #include "Actions/Action.hpp" 12 12 13 void CommandVerbose(int verbosity); 14 13 15 class CommandLineVerboseAction : public Action { 16 friend void CommandVerbose(int verbosity); 17 14 18 public: 15 19 CommandLineVerboseAction(); … … 21 25 virtual const std::string getName(); 22 26 private: 27 virtual Dialog * createDialog(); 23 28 virtual Action::state_ptr performCall(); 24 29 virtual Action::state_ptr performUndo(Action::state_ptr); -
src/Actions/CmdAction/VersionAction.cpp
rc6f395 r400170 9 9 10 10 #include "Actions/CmdAction/VersionAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 11 12 12 13 #include <iostream> … … 17 18 #include "UIElements/UIFactory.hpp" 18 19 #include "UIElements/Dialog.hpp" 19 #include " Actions/MapOfActions.hpp"20 #include "UIElements/ValueStorage.hpp" 20 21 21 22 const char CommandLineVersionAction::NAME[] = "version"; … … 28 29 {} 29 30 30 Action::state_ptr CommandLineVersionAction::performCall() { 31 void CommandVersion() { 32 ActionRegistry::getInstance().getActionByName(CommandLineVersionAction::NAME)->call(Action::NonInteractive); 33 }; 34 35 Dialog* CommandLineVersionAction::createDialog() { 31 36 Dialog *dialog = UIFactory::getInstance().makeDialog(); 32 37 33 38 dialog->queryEmpty(NAME, ESPACKVersion); 34 39 35 if(dialog->display()) { 36 delete dialog; 37 return Action::success; 38 } else { 39 delete dialog; 40 return Action::failure; 41 } 40 return dialog; 41 } 42 43 Action::state_ptr CommandLineVersionAction::performCall() { 44 return Action::success; 42 45 } 43 46 44 47 Action::state_ptr CommandLineVersionAction::performUndo(Action::state_ptr _state) { 45 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get()); 46 47 return Action::failure; 48 // string newName = state->mol->getName(); 49 // state->mol->setName(state->lastName); 50 // 51 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); 48 return Action::success; 52 49 } 53 50 54 51 Action::state_ptr CommandLineVersionAction::performRedo(Action::state_ptr _state){ 55 return Action:: failure;52 return Action::success; 56 53 } 57 54 58 55 bool CommandLineVersionAction::canUndo() { 59 return false;56 return true; 60 57 } 61 58 62 59 bool CommandLineVersionAction::shouldUndo() { 63 return false;60 return true; 64 61 } 65 62 -
src/Actions/CmdAction/VersionAction.hpp
rc6f395 r400170 12 12 #include "version.h" 13 13 14 void CommandVersion(); 15 14 16 class CommandLineVersionAction : public Action { 17 friend void CommandVersion(); 18 15 19 public: 16 20 CommandLineVersionAction(); … … 22 26 virtual const std::string getName(); 23 27 private: 28 virtual Dialog * createDialog(); 24 29 virtual Action::state_ptr performCall(); 25 30 virtual Action::state_ptr performUndo(Action::state_ptr);
Note:
See TracChangeset
for help on using the changeset viewer.
