Ignore:
Timestamp:
Jun 16, 2010, 12:24:21 PM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
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:
492279
Parents:
f8e486 (diff), 980dd6 (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.
Message:

Broken: Merge commit 'Gitosis/stable' into stable

Conflicts:

molecuilder/src/Actions/AnalysisAction/PairCorrelationToPointAction.cpp
molecuilder/src/Actions/AnalysisAction/PairCorrelationToSurfaceAction.cpp
molecuilder/src/Makefile.am

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/CommandLineUI/CommandLineDialog.cpp

    rf8e486 re6317b  
    88#include "Helpers/MemDebug.hpp"
    99
    10 #include <cassert>
    1110#include <iostream>
     11#include <vector>
    1212
    1313#include <Descriptors/AtomDescriptor.hpp>
     
    1616#include <Descriptors/MoleculeIdDescriptor.hpp>
    1717#include "CommandLineUI/CommandLineDialog.hpp"
     18
     19#include "Actions/Values.hpp"
    1820
    1921#include "element.hpp"
     
    7981}
    8082
    81 void CommandLineDialog::queryElement(const char* title, const element **target, string _description){
     83void CommandLineDialog::queryElement(const char* title, std::vector<element *> *target, string _description){
    8284  registerQuery(new ElementCommandLineQuery(title,target, _description));
    8385}
     
    106108    tmp = CommandLineParser::getInstance().vm[getTitle()].as<int>();
    107109    return true;
    108   } else
    109     return false;
     110  } else {
     111    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing integer for " << getTitle() << "." << endl);
     112    return false;
     113  }
    110114}
    111115
     
    117121
    118122bool CommandLineDialog::BooleanCommandLineQuery::handle() {
    119   bool badInput = false;
    120   char input = ' ';
    121   do{
    122     badInput = false;
    123     Log() << Verbose(0) << getTitle();
    124     cin >> input;
    125     if ((input == 'y' ) || (input == 'Y')) {
    126       tmp = true;
    127     } else if ((input == 'n' ) || (input == 'N')) {
    128       tmp = false;
    129     } else {
    130       badInput=true;
    131       cin.clear();
    132       cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
    133       Log() << Verbose(0) << "Input was not of [yYnN]!" << endl;
    134     }
    135   } while(badInput);
    136   // clear the input buffer of anything still in the line
    137   cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
    138   return true;
     123  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     124    tmp = CommandLineParser::getInstance().vm[getTitle()].as<bool>();
     125    return true;
     126  } else {
     127    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing boolean for " << getTitle() << "." << endl);
     128    return false;
     129  }
    139130}
    140131
     
    149140    tmp = CommandLineParser::getInstance().vm[getTitle()].as<string>();
    150141    return true;
    151   } else
    152     return false;
     142  } else {
     143    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing string for " << getTitle() << "." << endl);
     144    return false;
     145  }
    153146}
    154147
     
    163156    tmp = CommandLineParser::getInstance().vm[getTitle()].as<double>();
    164157    return true;
    165   } else
    166     return false;
     158  } else {
     159    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing double for " << getTitle() << "." << endl);
     160    return false;
     161  }
    167162}
    168163
     
    179174    tmp = World::getInstance().getAtom(AtomById(IdxOfAtom));
    180175    return true;
    181   } else
    182     return false;
     176  } else {
     177    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing atom for " << getTitle() << "." << endl);
     178    return false;
     179  }
    183180}
    184181
     
    199196      tmp = NULL;
    200197    return true;
    201   } else
    202     return false;
     198  } else {
     199    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing molecule for " << getTitle() << "." << endl);
     200    return false;
     201  }
    203202}
    204203
     
    211210
    212211bool CommandLineDialog::VectorCommandLineQuery::handle() {
    213   vector<double> temp;
    214   if (CommandLineParser::getInstance().vm.count(getTitle())) {
    215     temp = CommandLineParser::getInstance().vm[getTitle()].as<vector<double> >();
    216     assert((temp.size() == 3) && "Vector from command line does not have three components.");
    217     for (int i=0;i<NDIM;i++)
    218       tmp->at(i) = temp[i];
    219     return true;
    220   } else
    221     return false;
     212  VectorValue temp;
     213  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     214    temp = CommandLineParser::getInstance().vm[getTitle()].as< VectorValue >();
     215    tmp->at(0) = temp.x;
     216    tmp->at(1) = temp.y;
     217    tmp->at(2) = temp.z;
     218    return true;
     219  } else {
     220    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing vector for " << getTitle() << "." << endl);
     221    return false;
     222  }
    222223}
    223224
     
    231232
    232233bool CommandLineDialog::BoxCommandLineQuery::handle() {
    233   vector<double> temp;
    234   if (CommandLineParser::getInstance().vm.count(getTitle())) {
    235     temp = CommandLineParser::getInstance().vm[getTitle()].as<vector<double> >();
    236     assert((temp.size() == 6) && "Symmetric box matrix from command line does not have six components.");
    237     for (int i=0;i<6;i++) {
    238       tmp[i] = temp[i];
    239     }
    240     return true;
    241   } else
    242     return false;
    243 }
    244 
    245 CommandLineDialog::ElementCommandLineQuery::ElementCommandLineQuery(string title, const element **target, string _description) :
     234  BoxValue temp;
     235  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     236    temp = CommandLineParser::getInstance().vm[getTitle()].as< BoxValue >();
     237    tmp[0] = temp.xx;
     238    tmp[1] = temp.xy;
     239    tmp[2] = temp.xz;
     240    tmp[3] = temp.yy;
     241    tmp[4] = temp.yz;
     242    tmp[5] = temp.zz;
     243    return true;
     244  } else {
     245    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing symmetric box matrix for " << getTitle() << "." << endl);
     246    return false;
     247  }
     248}
     249
     250CommandLineDialog::ElementCommandLineQuery::ElementCommandLineQuery(string title, std::vector<element *> *target, string _description) :
    246251    Dialog::ElementQuery(title,target, _description)
    247252{}
     
    252257bool CommandLineDialog::ElementCommandLineQuery::handle() {
    253258  // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector?
    254   int Z;
     259  periodentafel *periode = World::getInstance().getPeriode();
     260  element *elemental = NULL;
    255261  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    256262    vector<int> AllElements = CommandLineParser::getInstance().vm[getTitle()].as< vector<int> >();
    257     vector<int>::iterator ElementRunner = AllElements.begin();
    258     Z = *ElementRunner;
    259     // TODO: So far, this does not really erase the element in the parsed list.
    260     AllElements.erase(ElementRunner);
    261     tmp = World::getInstance().getPeriode()->FindElement(Z);
    262     return true;
    263   } else
    264     return false;
    265 }
     263    for (vector<int>::iterator ZRunner = AllElements.begin(); ZRunner != AllElements.end(); ++ZRunner) {
     264      elemental = periode->FindElement(*ZRunner);
     265      ASSERT(elemental != NULL, "Invalid element specified in ElementCommandLineQuery");
     266      elements.push_back(elemental);
     267    }
     268    return true;
     269  } else {
     270    DoeLog(1) && (eLog() << Verbose(1) << "CommandLineUI parsing error: Missing element for " << getTitle() << "." << endl);
     271    return false;
     272  }
     273}
Note: See TracChangeset for help on using the changeset viewer.