Ignore:
Timestamp:
May 15, 2010, 5:56:57 PM (15 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:
99fcaf, f941b1
Parents:
498c519
git-author:
Frederik Heber <heber@…> (05/14/10 20:14:27)
git-committer:
Frederik Heber <heber@…> (05/15/10 17:56:57)
Message:

Added all commands defined in ParseCommandLineOptions() as Actions.

  • Actions are not yet used, except verbose, version and help.
  • Files are present and included in Makefile.am
  • not unit tests written so far
  • no action has been tested so far (except for MapOfActions)
  • structure introduced to to transition from ParseCommandLineOptions to actions.
  • program name and config file are fixed arguments.

Signed-off-by: Frederik Heber <heber@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/CommandLineDialog.cpp

    r498c519 r97ebf8  
    1010#include <iostream>
    1111
     12#include <Descriptors/AtomDescriptor.hpp>
     13#include <Descriptors/AtomIdDescriptor.hpp>
    1214#include <Descriptors/MoleculeDescriptor.hpp>
    1315#include <Descriptors/MoleculeIdDescriptor.hpp>
    1416#include "UIElements/CommandLineDialog.hpp"
    1517
     18#include "element.hpp"
    1619#include "periodentafel.hpp"
    17 #include "atom.hpp"
    1820#include "CommandLineParser.hpp"
    1921#include "defs.hpp"
    20 #include "molecule.hpp"
    2122#include "log.hpp"
     23#include "periodentafel.hpp"
    2224#include "verbose.hpp"
    2325#include "World.hpp"
    2426
     27#include "atom.hpp"
     28#include "element.hpp"
     29#include "molecule.hpp"
     30#include "vector.hpp"
     31
    2532using namespace std;
    2633
     
    4350}
    4451
     52void CommandLineDialog::queryBoolean(const char* title, bool* target, string _description){
     53  registerQuery(new BooleanCommandLineQuery(title,target, _description));
     54}
     55
    4556void CommandLineDialog::queryDouble(const char* title, double* target, string _description){
    4657  registerQuery(new DoubleCommandLineQuery(title,target, _description));
     
    5162}
    5263
    53 void CommandLineDialog::queryMolecule(const char* title, molecule **target, MoleculeListClass *molecules, string _description) {
    54   registerQuery(new MoleculeCommandLineQuery(title,target,molecules, _description));
     64void CommandLineDialog::queryAtom(const char* title, atom **target, string _description) {
     65  registerQuery(new AtomCommandLineQuery(title,target, _description));
     66}
     67
     68void CommandLineDialog::queryMolecule(const char* title, molecule **target, string _description) {
     69  registerQuery(new MoleculeCommandLineQuery(title,target, _description));
    5570}
    5671
    5772void CommandLineDialog::queryVector(const char* title, Vector *target,const double *const cellSize, bool check, string _description) {
    5873  registerQuery(new VectorCommandLineQuery(title,target,cellSize,check, _description));
     74}
     75
     76void CommandLineDialog::queryBox(const char* title, double ** const cellSize, string _description) {
     77  registerQuery(new BoxCommandLineQuery(title,cellSize,_description));
    5978}
    6079
     
    90109}
    91110
     111CommandLineDialog::BooleanCommandLineQuery::BooleanCommandLineQuery(string title,bool *_target, string _description) :
     112    Dialog::BooleanQuery(title,_target, _description)
     113{}
     114
     115CommandLineDialog::BooleanCommandLineQuery::~BooleanCommandLineQuery() {}
     116
     117bool CommandLineDialog::BooleanCommandLineQuery::handle() {
     118  bool badInput = false;
     119  char input = ' ';
     120  do{
     121    badInput = false;
     122    Log() << Verbose(0) << getTitle();
     123    cin >> input;
     124    if ((input == 'y' ) || (input == 'Y')) {
     125      tmp = true;
     126    } else if ((input == 'n' ) || (input == 'N')) {
     127      tmp = false;
     128    } else {
     129      badInput=true;
     130      cin.clear();
     131      cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
     132      Log() << Verbose(0) << "Input was not of [yYnN]!" << endl;
     133    }
     134  } while(badInput);
     135  // clear the input buffer of anything still in the line
     136  cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
     137  return true;
     138}
     139
    92140CommandLineDialog::StringCommandLineQuery::StringCommandLineQuery(string title,string *_target, string _description) :
    93141    Dialog::StringQuery(title,_target, _description)
     
    118166}
    119167
    120 CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, molecule **_target, MoleculeListClass *_molecules, string _description) :
    121     Dialog::MoleculeQuery(title,_target,_molecules, _description)
     168CommandLineDialog::AtomCommandLineQuery::AtomCommandLineQuery(string title, atom **_target, string _description) :
     169    Dialog::AtomQuery(title,_target, _description)
     170{}
     171
     172CommandLineDialog::AtomCommandLineQuery::~AtomCommandLineQuery() {}
     173
     174bool CommandLineDialog::AtomCommandLineQuery::handle() {
     175  int IdxOfAtom = -1;
     176  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     177    IdxOfAtom = CommandLineParser::getInstance().vm[getTitle()].as<int>();
     178    tmp = World::getInstance().getAtom(AtomById(IdxOfAtom));
     179    return true;
     180  } else
     181    return false;
     182}
     183
     184CommandLineDialog::MoleculeCommandLineQuery::MoleculeCommandLineQuery(string title, molecule **_target, string _description) :
     185    Dialog::MoleculeQuery(title,_target, _description)
    122186{}
    123187
     
    146210    temp = CommandLineParser::getInstance().vm[getTitle()].as<vector<double> >();
    147211    assert((temp.size() == 3) && "Vector from command line does not have three components.");
    148     tmp = new Vector;
    149212    for (int i=0;i<NDIM;i++)
    150213      tmp->at(i) = temp[i];
     
    155218
    156219
     220CommandLineDialog::BoxCommandLineQuery::BoxCommandLineQuery(string title, double ** const _cellSize, string _description) :
     221    Dialog::BoxQuery(title,_cellSize, _description)
     222{}
     223
     224CommandLineDialog::BoxCommandLineQuery::~BoxCommandLineQuery()
     225{}
     226
     227bool CommandLineDialog::BoxCommandLineQuery::handle() {
     228  vector<double> temp;
     229  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     230    temp = CommandLineParser::getInstance().vm[getTitle()].as<vector<double> >();
     231    assert((temp.size() == 6) && "Symmetric box matrix from command line does not have six components.");
     232    for (int i=0;i<6;i++)
     233      tmp[i] = temp[i];
     234    return true;
     235  } else
     236    return false;
     237}
     238
    157239CommandLineDialog::ElementCommandLineQuery::ElementCommandLineQuery(string title, const element **target, string _description) :
    158240    Dialog::ElementQuery(title,target, _description)
     
    163245
    164246bool CommandLineDialog::ElementCommandLineQuery::handle() {
    165   int Z = -1;
    166   if (CommandLineParser::getInstance().vm.count(getTitle())) {
    167     Z = CommandLineParser::getInstance().vm[getTitle()].as<int>();
     247  // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector?
     248  int Z;
     249  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     250    vector<int> AllElements = CommandLineParser::getInstance().vm[getTitle()].as< vector<int> >();
     251    vector<int>::iterator ElementRunner = AllElements.begin();
     252    Z = *ElementRunner;
     253    // TODO: So far, this does not really erase the element in the parsed list.
     254    AllElements.erase(ElementRunner);
    168255    tmp = World::getInstance().getPeriode()->FindElement(Z);
    169256    return true;
Note: See TracChangeset for help on using the changeset viewer.