Changeset f0a3ec for src


Ignore:
Timestamp:
Jun 11, 2010, 12:19:50 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:
54b953
Parents:
6c7352
git-author:
Frederik Heber <heber@…> (06/11/10 10:22:45)
git-committer:
Frederik Heber <heber@…> (06/11/10 12:19:50)
Message:

Case 'a' is now handled by CommandLineUI.

  • NOTE: atom has still to be added to a molecule to get saved in the end, this is fixed with new parser and should be corrected then (TODO is in the code)
  • TESTFIX: Scanning for "Not enough or invalid" for invalid commands test cases has been replaced by just "Not enough"
Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/AtomAction/AddAction.cpp

    r6c7352 rf0a3ec  
    1010#include "element.hpp"
    1111#include "log.hpp"
    12 #include "periodentafel.hpp"
     12#include "molecule.hpp"
    1313#include "vector.hpp"
    1414#include "verbose.hpp"
     
    3535Action::state_ptr AtomAddAction::performCall() {
    3636  Dialog *dialog = UIFactory::getInstance().makeDialog();
    37   int Z = -1;
     37  std::vector<element *> elements;
    3838  Vector position;
    3939
    40   dialog->queryInt(NAME, &Z, MapOfActions::getInstance().getDescription(NAME));
     40  dialog->queryElement(NAME, &elements, MapOfActions::getInstance().getDescription(NAME));
    4141  dialog->queryVector("position", &position, World::getInstance().getDomain(), true, MapOfActions::getInstance().getDescription("position"));
     42  cout << "pre-dialog" << endl;
    4243
    4344  if(dialog->display()) {
     45    cout << "post-dialog" << endl;
    4446    delete dialog;
    45     atom * first = World::getInstance().createAtom();
    46     first->type = World::getInstance().getPeriode()->FindElement(Z);
    47     first->x = position;
    48     if (first->type != NULL) {
     47    if (elements.size() == 1) {
     48      atom * first = World::getInstance().createAtom();
     49      first->type = *(elements.begin());
     50      first->x = position;
    4951      DoLog(1) && (Log() << Verbose(1) << "Adding new atom with element " << first->type->name << " at " << (first->x) << "." << endl);
     52      // TODO: remove when all of World's atoms are stored.
     53      std::vector<molecule *> molecules = World::getInstance().getAllMolecules();
     54      if (!molecules.empty()) {
     55        std::vector<molecule *>::iterator iter = molecules.begin();
     56        (*iter)->AddAtom(first);
     57      }
    5058      return Action::success;
    5159    } else {
    5260      DoeLog(1) && (eLog()<< Verbose(1) << "Could not find the specified element." << endl);
    53       World::getInstance().destroyAtom(first);
    5461      return Action::failure;
    5562    }
  • src/Actions/MapOfActions.cpp

    r6c7352 rf0a3ec  
    164164
    165165  // value types for the actions
    166   TypeMap["add-atom"] = Atom;
     166  TypeMap["add-atom"] = Element;
    167167  TypeMap["bond-file"] = String;
    168168  TypeMap["bond-table"] = String;
     
    210210  TypeMap["distances"] = Vector;
    211211  TypeMap["DoRotate"] = Boolean;
    212   TypeMap["elements"] = Element;
     212  TypeMap["element"] = Element;
    213213  TypeMap["elements"] = ListOfElements;
    214214  TypeMap["length"] = Double;
     
    230230
    231231  // list of generic actions
    232 //      generic.insert("add-atom");
     232        generic.insert("add-atom");
    233233//  generic.insert("bond-file");
    234234        generic.insert("bond-table");
     
    434434            ListRunner->second->add_options()
    435435              (getKeyAndShortForm(*OptionRunner).c_str(),
    436                   DefaultValue.find(*OptionRunner) != DefaultValue.end() ?
    437                         po::value< int >()->default_value(atoi(DefaultValue[*OptionRunner].c_str())) :
    438                         po::value< int >(),
     436                  po::value< vector<int> >(),
    439437                  getDescription(*OptionRunner).c_str())
    440438              ;
  • src/builder.cpp

    r6c7352 rf0a3ec  
    16811681            case 'a':
    16821682              if (ExitFlag == 0) ExitFlag = 1;
    1683               if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3]))) {
     1683              if ((argptr+4 >= argc) || (argv[argptr][0] == '-')) {
    16841684                ExitFlag = 255;
    1685                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for adding atom: -a <element> <x> <y> <z>" << endl);
     1685                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough arguments for adding atom: -a <Z> --position <x> <y> <z>" << endl);
    16861686                performCriticalExit();
    16871687              } else {
    1688                 SaveFlag = true;
    1689                 Log() << Verbose(1) << "Adding new atom with element " << argv[argptr] << " at (" << argv[argptr+1] << "," << argv[argptr+2] << "," << argv[argptr+3] << "), ";
    1690                 first = World::getInstance().createAtom();
    1691                 first->type = periode->FindElement(atoi(argv[argptr]));
    1692                 if (first->type != NULL)
    1693                   DoLog(2) && (Log() << Verbose(2) << "found element " << first->type->name << endl);
    1694                 for (int i=NDIM;i--;)
    1695                   first->x[i] = atof(argv[argptr+1+i]);
    1696                 if (first->type != NULL) {
    1697                   mol->AddAtom(first);  // add to molecule
    1698                   if ((configPresent == empty) && (mol->getAtomCount() != 0))
    1699                     configPresent = present;
    1700                 } else
    1701                   DoeLog(1) && (eLog()<< Verbose(1) << "Could not find the specified element." << endl);
    1702                 argptr+=4;
     1688                ArgcList.insert(argptr-1);
     1689                ArgcList.insert(argptr);
     1690                ArgcList.insert(argptr+1);
     1691                ArgcList.insert(argptr+2);
     1692                ArgcList.insert(argptr+3);
     1693                ArgcList.insert(argptr+4);
     1694                argptr+=5;
    17031695              }
    17041696              break;
     
    17381730                bool periodic = (argv[argptr-1][2] =='p');
    17391731                if (ExitFlag == 0) ExitFlag = 1;
    1740                 if ((argptr >= argc)) {
     1732                if ((argptr+11 >= argc)) {
    17411733                  ExitFlag = 255;
    17421734                  DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C[p] <type: E/P/S> [more params] <output> <bin output> <BinStart> <BinEnd>" << endl);
Note: See TracChangeset for help on using the changeset viewer.