Changeset 3d078d for src


Ignore:
Timestamp:
Jul 21, 2010, 7:49:33 AM (14 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:
6d858c
Parents:
c538d1 (diff), be97a8 (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:

Merge branch 'stable' into Shapes

Location:
src
Files:
6 added
21 edited

Legend:

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

    rc538d1 r3d078d  
    3838  std::vector<element *> elements;
    3939
    40   dialog->queryAtom(NAME, &first, MapOfActions::getInstance().getDescription(NAME));
    41   dialog->queryElement("element", &elements, MapOfActions::getInstance().getDescription("element"));
     40  dialog->queryElement(NAME, &elements, MapOfActions::getInstance().getDescription(NAME));
     41  dialog->queryAtom("atom-by-id", &first, MapOfActions::getInstance().getDescription("atom-by-id"));
    4242
    4343  if(dialog->display()) {
  • src/Actions/MapOfActions.cpp

    rc538d1 r3d078d  
    272272  TypeMap["center-in-box"] = Box;
    273273  TypeMap["change-box"] = Box;
    274   TypeMap["change-element"] = Atom;
     274  TypeMap["change-element"] = Element;
    275275  TypeMap["change-molname"] = String;
    276276  TypeMap["convex-envelope"] = Molecule;
     
    323323  TypeMap["MaxDistance"] = Double;
    324324  TypeMap["molecule-by-id"] = Molecule;
    325   TypeMap["molecule-by-name"] = Molecule;
     325  TypeMap["molecule-by-name"] = String;
    326326  TypeMap["nonconvex-file"] = String;
    327327  TypeMap["order"] = Integer;
  • src/Actions/ParserAction/LoadXyzAction.cpp

    rc538d1 r3d078d  
    7878        if (UniqueList.size() != ListAfter.size()) { // only create if new atoms have been parsed
    7979          MoleculeListClass *molecules = World::getInstance().getMolecules();
    80           molecule *mol= NULL;
    81           if (molecules->ListOfMolecules.empty()) {
    82             mol = World::getInstance().createMolecule();
    83             molecules->insert(mol);
    84           } else {
    85             mol = *(molecules->ListOfMolecules.begin());
    86           }
     80          molecule *mol = World::getInstance().createMolecule();
     81          molecules->insert(mol);
    8782          for (vector<atom *>::iterator runner = ListAfter.begin(); runner != ListAfter.end(); ++runner) {
    8883            Inserter = UniqueList.insert(*runner);
  • src/Actions/WorldAction/ChangeBoxAction.cpp

    rc538d1 r3d078d  
    4141  if(dialog->display()) {
    4242    DoLog(0) && (Log() << Verbose(0) << "Setting box domain to " << cell_size.getM() << endl);
     43    World::getInstance().setDomain(cell_size.getM());
    4344    delete dialog;
    4445    return Action::success;
  • src/Actions/WorldAction/InputAction.cpp

    rc538d1 r3d078d  
    3838  MoleculeListClass *molecules = World::getInstance().getMolecules();
    3939  molecule *mol = NULL;
    40   string filename;
     40  std::string filename;
    4141  std::ifstream test;
    4242
     
    4545  if(dialog->display()) {
    4646    DoLog(0) && (Log() << Verbose(0) << "Config file given." << endl);
    47     std::string FilenamePrefix = filename.substr(0,filename.find('.'));
    48     FormatParserStorage::getInstance().SetOutputPrefixForAll(FilenamePrefix);
    49     DoLog(1) && (Log() << Verbose(1) << "Setting config file name prefix to " << FilenamePrefix << "." << endl);
    50     test.open(filename.c_str());
    51     if (test == NULL) {
    52       DoLog(1) && (Log() << Verbose(1) << "Specified config file " << filename << " not found." << endl);
     47    if (filename.find('.') != string::npos) {
     48      std::string FilenamePrefix = filename.substr(0,filename.find_last_of('.'));
     49      std::string FilenameSuffix = filename.substr(filename.find_last_of('.')+1, filename.length());
     50      DoLog(1) && (Log() << Verbose(1) << "Setting config file name prefix to " << FilenamePrefix << "." << endl);
     51      test.open(filename.c_str());
     52      if (test == NULL) {
     53        DoLog(1) && (Log() << Verbose(1) << "Specified config file " << filename << " not found." << endl);
     54      } else {
     55        DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... ");
     56        FormatParserStorage::getInstance().get((std::istream &)test, FilenameSuffix);
     57        test.close();
     58      }
     59      FormatParserStorage::getInstance().SetOutputPrefixForAll(FilenamePrefix);
     60      // set mol to first active molecule
     61      if (molecules->ListOfMolecules.size() != 0) {
     62        for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
     63          if ((*ListRunner)->ActiveFlag) {
     64            mol = *ListRunner;
     65            break;
     66          }
     67      }
     68      if (mol == NULL) {
     69        mol = World::getInstance().createMolecule();
     70        mol->ActiveFlag = true;
     71        molecules->insert(mol);
     72      }
     73      mol->SetNameFromFilename(filename.substr(0,filename.find('.')).c_str());
    5374    } else {
    54       DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... ");
    55       FormatParserStorage::getInstance().getPcp().load(&test);
    56       test.close();
     75      DoeLog(1) && (eLog() << Verbose(1) << "Input file does not have a suffix, cannot recognize format." << endl);
    5776    }
    58     // set mol to first active molecule
    59     if (molecules->ListOfMolecules.size() != 0) {
    60       for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    61         if ((*ListRunner)->ActiveFlag) {
    62           mol = *ListRunner;
    63           break;
    64         }
    65     }
    66     if (mol == NULL) {
    67       mol = World::getInstance().createMolecule();
    68       mol->ActiveFlag = true;
    69       molecules->insert(mol);
    70     }
    71     mol->SetNameFromFilename(filename.c_str());
    7277    delete dialog;
    7378    return Action::success;
  • src/Box.cpp

    rc538d1 r3d078d  
    4646
    4747void Box::setM(Matrix _M){
    48   ASSERT(_M.at(1,0)==_M.at(0,1),"Matrix used as cell_size was not symmetric");
    49   ASSERT(_M.at(2,0)==_M.at(0,2),"Matrix used as cell_size was not symmetric");
    50   ASSERT(_M.at(1,2)==_M.at(2,1),"Matrix used as cell_size was not symmetric");
     48  ASSERT(_M.determinant()!=0,"Matrix in Box construction was not invertible");
    5149  *M    =_M;
    5250  *Minv = M->invert();
  • src/Descriptors/AtomDescriptor.cpp

    rc538d1 r3d078d  
    8282  vector<atom*> res;
    8383  World::AtomSet atoms = getAtoms();
    84   atoms_iter_t iter;
    85   for(iter=atoms.begin_internal();iter!=atoms.end_internal();++iter) {
    86     if(predicate(*iter)){
    87       res.push_back((*iter).second);
    88     }
     84  for_each(atoms.begin_internal(),
     85           atoms.end_internal(),
     86           boost::bind(&AtomDescriptor_impl::checkAndAdd,
     87                       this,&res,_1));
     88  return res;
     89}
     90
     91void AtomDescriptor_impl::checkAndAdd(std::vector<atom*> *v,std::pair<atomId_t,atom*> p){
     92  if(predicate(p)){
     93    v->push_back(p.second);
    8994  }
    90   return res;
    9195}
    9296
  • src/Descriptors/AtomDescriptor_impl.hpp

    rc538d1 r3d078d  
    5050   */
    5151  World::AtomSet& getAtoms();
     52
     53  void checkAndAdd(std::vector<atom*>*,std::pair<atomId_t,atom*>);
    5254};
    5355
  • src/Descriptors/AtomIdDescriptor.cpp

    rc538d1 r3d078d  
    3333
    3434atom *AtomIdDescriptor_impl::find(){
    35   World::AtomSet atoms = getAtoms();
     35  World::AtomSet &atoms = getAtoms();
    3636  World::AtomSet::iterator res = atoms.find(id);
    3737  return (res!=atoms.end())?((*res).second):0;
  • src/Descriptors/MoleculeDescriptor.cpp

    rc538d1 r3d078d  
    7474
    7575molecule* MoleculeDescriptor_impl::find() {
    76   World::MoleculeSet molecules = getMolecules();
     76  World::MoleculeSet &molecules = getMolecules();
    7777  molecules_iter_t res = find_if(molecules.begin_internal(),molecules.end_internal(),boost::bind(&MoleculeDescriptor_impl::predicate,this,_1));
    7878  return (res!=molecules.end_internal())?((*res).second):0;
     
    8181vector<molecule*> MoleculeDescriptor_impl::findAll() {
    8282  vector<molecule*> res;
    83   World::MoleculeSet molecules = getMolecules();
    84   molecules_iter_t iter;
    85   for(iter=molecules.begin_internal();iter!=molecules.end_internal();++iter) {
    86     if(predicate(*iter)){
    87       res.push_back((*iter).second);
    88     }
     83  World::MoleculeSet &molecules = getMolecules();
     84  for_each(molecules.begin_internal(),
     85           molecules.end_internal(),
     86           boost::bind(&MoleculeDescriptor_impl::checkAndAdd,
     87                       this,&res,_1));
     88  return res;
     89}
     90
     91void MoleculeDescriptor_impl::checkAndAdd(std::vector<molecule*> *v,std::pair<moleculeId_t,molecule*> p){
     92  if(predicate(p)){
     93    v->push_back(p.second);
    8994  }
    90   return res;
    9195}
    9296
  • src/Descriptors/MoleculeDescriptor_impl.hpp

    rc538d1 r3d078d  
    5050   */
    5151  World::MoleculeSet& getMolecules();
     52
     53  void checkAndAdd(std::vector<molecule*>*,std::pair<moleculeId_t,molecule*>);
    5254};
    5355
  • src/Descriptors/MoleculeIdDescriptor.cpp

    rc538d1 r3d078d  
    3434
    3535molecule *MoleculeIdDescriptor_impl::find(){
    36   World::MoleculeSet molecules = getMolecules();
     36  World::MoleculeSet &molecules = getMolecules();
    3737  World::MoleculeSet::iterator res = molecules.find(id);
    3838  return (res!=molecules.end())?((*res).second):0;
  • src/Makefile.am

    rc538d1 r3d078d  
    150150DESCRIPTORSOURCE = Descriptors/AtomDescriptor.cpp \
    151151  Descriptors/AtomIdDescriptor.cpp \
     152  Descriptors/AtomSelectionDescriptor.cpp \
    152153  Descriptors/AtomTypeDescriptor.cpp \
    153154  Descriptors/MoleculeDescriptor.cpp \
    154155  Descriptors/MoleculeIdDescriptor.cpp \
    155156  Descriptors/MoleculeNameDescriptor.cpp \
    156   Descriptors/MoleculePtrDescriptor.cpp
     157  Descriptors/MoleculePtrDescriptor.cpp \
     158  Descriptors/MoleculeSelectionDescriptor.cpp
    157159                                   
    158160
    159161DESCRIPTORHEADER = Descriptors/AtomDescriptor.hpp \
    160162  Descriptors/AtomIdDescriptor.hpp \
     163  Descriptors/AtomSelectionDescriptor.hpp \
    161164  Descriptors/AtomTypeDescriptor.hpp \
    162165  Descriptors/MoleculeDescriptor.hpp \
    163166  Descriptors/MoleculeIdDescriptor.hpp \
    164167  Descriptors/MoleculeNameDescriptor.hpp \
    165   Descriptors/MoleculePtrDescriptor.hpp
     168  Descriptors/MoleculePtrDescriptor.hpp \
     169  Descriptors/MoleculeSelectionDescriptor.cpp
    166170                                 
    167171QTUISOURCE = ${QTUIMOC_TARGETS} \
  • src/Parser/FormatParserStorage.cpp

    rc538d1 r3d078d  
    4242  ParserSuffix.resize(ParserTypes_end, "");
    4343
    44   ParserSuffix[mpqc] = "conf.in";
     44  ParserSuffix[mpqc] = "in";
    4545  ParserSuffix[pcp] = "conf";
    46   ParserSuffix[tremolo] = "conf.data";
    47   ParserSuffix[xyz] = "conf.xyz";
     46  ParserSuffix[tremolo] = "data";
     47  ParserSuffix[xyz] = "xyz";
    4848}
    4949
     
    133133}
    134134
     135/** Parses an istream depending on its suffix
     136 * \param &input input stream
     137 * \param suffix
     138 * \return true - parsing ok, false - suffix unknown
     139 */
     140bool FormatParserStorage::get(std::istream &input, std::string suffix)
     141{
     142  if (suffix == ParserSuffix[mpqc]) {
     143    getMpqc().load(&input);
     144  } else if (suffix == ParserSuffix[pcp]) {
     145    getPcp().load(&input);
     146  } else if (suffix == ParserSuffix[tremolo]) {
     147    getTremolo().load(&input);
     148  } else if (suffix == ParserSuffix[xyz]) {
     149    getXyz().load(&input);
     150  } else {
     151    DoeLog(1) && (eLog() << Verbose(1) << "Unknown suffix to for FormatParserStorage::get()." << endl);
     152    return false;
     153  }
     154  return true;
     155}
     156
    135157/** Returns reference to the output MpqcParser, adds if not present.
    136158 * \return reference to the output MpqcParser
  • src/Parser/FormatParserStorage.hpp

    rc538d1 r3d078d  
    4141  void addXyz();
    4242
     43  bool get(std::istream &input, std::string suffix);
    4344  MpqcParser &getMpqc();
    4445  PcpParser &getPcp();
  • src/Parser/XyzParser.cpp

    rc538d1 r3d078d  
    5959  if (comment == "") {
    6060    time_t now = time((time_t *)NULL);   // Get the system time and put it into 'now' as 'calender time'
    61     comment = "\tCreated by molecuilder on ";
     61    comment = "Created by molecuilder on ";
    6262    // ctime ends in \n\0, we have to cut away the newline
    6363    std::string time(ctime(&now));
     
    6868      comment += time;
    6969  }
    70   *file << World::getInstance().numAtoms() << endl << comment << endl;
     70  *file << World::getInstance().numAtoms() << endl << "\t" << comment << endl;
    7171
    7272  vector<atom*> atoms = World::getInstance().getAllAtoms();
  • src/World.cpp

    rc538d1 r3d078d  
    99
    1010#include "World.hpp"
    11 #include "Patterns/ObservedContainer_impl.hpp"
     11
     12#include <functional>
    1213
    1314#include "atom.hpp"
     
    2829
    2930#include "Patterns/Singleton_impl.hpp"
     31#include "Patterns/ObservedContainer_impl.hpp"
    3032
    3133using namespace std;
     
    8385
    8486void World::setDomain(const Matrix &mat){
     87  OBSERVE;
    8588  *cell_size = mat;
    8689}
     
    8891void World::setDomain(double * matrix)
    8992{
     93  OBSERVE;
    9094  Matrix M = ReturnFullMatrixforSymmetric(matrix);
    9195  cell_size->setM(M);
     
    98102void World::setDefaultName(std::string name)
    99103{
     104  OBSERVE;
    100105  defaultName = name;
    101106};
     
    485490}
    486491
     492/************************** Selection of Atoms and molecules ******************/
     493
     494// Atoms
     495
     496void World::clearAtomSelection(){
     497  selectedAtoms.clear();
     498}
     499
     500void World::selectAtom(atom *atom){
     501  ASSERT(atom,"Invalid pointer in selection of atom");
     502  selectedAtoms[atom->getId()]=atom;
     503}
     504
     505void World::selectAtom(atomId_t id){
     506  ASSERT(atoms.count(id),"Atom Id selected that was not in the world");
     507  selectedAtoms[id]=atoms[id];
     508}
     509
     510void World::selectAllAtoms(AtomDescriptor descr){
     511  internal_AtomIterator begin = getAtomIter_internal(descr);
     512  internal_AtomIterator end = atomEnd_internal();
     513  void (World::*func)(atom*) = &World::selectAtom; // needed for type resolution of overloaded function
     514  for_each(begin,end,bind1st(mem_fun(func),this)); // func is select... see above
     515}
     516
     517void World::selectAtomsOfMolecule(molecule *_mol){
     518  ASSERT(_mol,"Invalid pointer to molecule in selection of Atoms of Molecule");
     519  // need to make it const to get the fast iterators
     520  const molecule *mol = _mol;
     521  void (World::*func)(atom*) = &World::selectAtom; // needed for type resolution of overloaded function
     522  for_each(mol->begin(),mol->end(),bind1st(mem_fun(func),this)); // func is select... see above
     523}
     524
     525void World::selectAtomsOfMolecule(moleculeId_t id){
     526  ASSERT(molecules.count(id),"No molecule with the given id upon Selection of atoms from molecule");
     527  selectAtomsOfMolecule(molecules[id]);
     528}
     529
     530void World::unselectAtom(atom *atom){
     531  ASSERT(atom,"Invalid pointer in unselection of atom");
     532  unselectAtom(atom->getId());
     533}
     534
     535void World::unselectAtom(atomId_t id){
     536  ASSERT(atoms.count(id),"Atom Id unselected that was not in the world");
     537  selectedAtoms.erase(id);
     538}
     539
     540void World::unselectAllAtoms(AtomDescriptor descr){
     541  internal_AtomIterator begin = getAtomIter_internal(descr);
     542  internal_AtomIterator end = atomEnd_internal();
     543  void (World::*func)(atom*) = &World::unselectAtom; // needed for type resolution of overloaded function
     544  for_each(begin,end,bind1st(mem_fun(func),this)); // func is unselect... see above
     545}
     546
     547void World::unselectAtomsOfMolecule(molecule *_mol){
     548  ASSERT(_mol,"Invalid pointer to molecule in selection of Atoms of Molecule");
     549  // need to make it const to get the fast iterators
     550  const molecule *mol = _mol;
     551  void (World::*func)(atom*) = &World::unselectAtom; // needed for type resolution of overloaded function
     552  for_each(mol->begin(),mol->end(),bind1st(mem_fun(func),this)); // func is unsselect... see above
     553}
     554
     555void World::unselectAtomsOfMolecule(moleculeId_t id){
     556  ASSERT(molecules.count(id),"No molecule with the given id upon Selection of atoms from molecule");
     557  unselectAtomsOfMolecule(molecules[id]);
     558}
     559
     560// Molecules
     561
     562void World::clearMoleculeSelection(){
     563  selectedMolecules.clear();
     564}
     565
     566void World::selectMolecule(molecule *mol){
     567  ASSERT(mol,"Invalid pointer to molecule in selection");
     568  selectedMolecules[mol->getId()]=mol;
     569}
     570
     571void World::selectMolecule(moleculeId_t id){
     572  ASSERT(molecules.count(id),"Molecule Id selected that was not in the world");
     573  selectedMolecules[id]=molecules[id];
     574}
     575
     576void World::selectAllMoleculess(MoleculeDescriptor descr){
     577  internal_MoleculeIterator begin = getMoleculeIter_internal(descr);
     578  internal_MoleculeIterator end = moleculeEnd_internal();
     579  void (World::*func)(molecule*) = &World::selectMolecule; // needed for type resolution of overloaded function
     580  for_each(begin,end,bind1st(mem_fun(func),this)); // func is select... see above
     581}
     582
     583void World::selectMoleculeOfAtom(atom *atom){
     584  ASSERT(atom,"Invalid atom pointer in selection of MoleculeOfAtom");
     585  molecule *mol=atom->getMolecule();
     586  // the atom might not be part of a molecule
     587  if(mol){
     588    selectMolecule(mol);
     589  }
     590}
     591
     592void World::selectMoleculeOfAtom(atomId_t id){
     593  ASSERT(atoms.count(id),"No such atom with given ID in selection of Molecules of Atom");\
     594  selectMoleculeOfAtom(atoms[id]);
     595}
     596
     597void World::unselectMolecule(molecule *mol){
     598  ASSERT(mol,"invalid pointer in unselection of molecule");
     599  unselectMolecule(mol->getId());
     600}
     601
     602void World::unselectMolecule(moleculeId_t id){
     603  ASSERT(molecules.count(id),"No such molecule with ID in unselection");
     604  selectedMolecules.erase(id);
     605}
     606
     607void World::unselectAllMoleculess(MoleculeDescriptor descr){
     608  internal_MoleculeIterator begin = getMoleculeIter_internal(descr);
     609  internal_MoleculeIterator end = moleculeEnd_internal();
     610  void (World::*func)(molecule*) = &World::unselectMolecule; // needed for type resolution of overloaded function
     611  for_each(begin,end,bind1st(mem_fun(func),this)); // func is unselect... see above
     612}
     613
     614void World::unselectMoleculeOfAtom(atom *atom){
     615  ASSERT(atom,"Invalid atom pointer in selection of MoleculeOfAtom");
     616  molecule *mol=atom->getMolecule();
     617  // the atom might not be part of a molecule
     618  if(mol){
     619    unselectMolecule(mol);
     620  }
     621}
     622
     623void World::unselectMoleculeOfAtom(atomId_t id){
     624  ASSERT(atoms.count(id),"No such atom with given ID in selection of Molecules of Atom");\
     625  unselectMoleculeOfAtom(atoms[id]);
     626}
     627
     628/******************* Iterators over Selection *****************************/
     629World::AtomSelectionIterator World::beginAtomSelection(){
     630  return selectedAtoms.begin();
     631}
     632
     633World::AtomSelectionIterator World::endAtomSelection(){
     634  return selectedAtoms.end();
     635}
     636
     637
     638World::MoleculeSelectionIterator World::beginMoleculeSelection(){
     639  return selectedMolecules.begin();
     640}
     641
     642World::MoleculeSelectionIterator World::endMoleculeSelection(){
     643  return selectedMolecules.end();
     644}
     645
    487646/******************************* Singleton Stuff **************************/
    488647
     
    494653    ExitFlag(0),
    495654    atoms(this),
     655    selectedAtoms(this),
    496656    currAtomId(0),
    497657    lastAtomPoolSize(0),
    498658    numAtomDefragSkips(0),
    499659    molecules(this),
     660    selectedMolecules(this),
    500661    currMoleculeId(0),
    501662    molecules_deprecated(new MoleculeListClass(this))
  • src/World.hpp

    rc538d1 r3d078d  
    6262friend class MoleculeDescriptor_impl;
    6363friend class MoleculeDescriptor;
     64// coupling with descriptors over selection
     65friend class AtomSelectionDescriptor_impl;
     66friend class MoleculeSelectionDescriptor_impl;
    6467
    6568// Actions, calculations etc associated with the World
     
    222225   * All these iterators are observed to track changes.
    223226   * There is a corresponding protected section with unobserved iterators,
    224    * which ca be used internally when the extra speed is needed
     227   * which can be used internally when the extra speed is needed
    225228   */
    226229
     
    239242  typedef SelectiveIterator<molecule*,MoleculeSet,MoleculeDescriptor>   MoleculeIterator;
    240243
     244  /**
     245   * returns an iterator over all Molecules matching a given descriptor.
     246   * This iterator is observed, so don't keep it around unnecessary to
     247   * avoid unintended blocking.
     248   */
    241249  MoleculeIterator getMoleculeIter(MoleculeDescriptor descr);
    242250  MoleculeIterator getMoleculeIter();
    243251
    244252  MoleculeIterator moleculeEnd();
     253
     254  /******** Selections of molecules and Atoms *************/
     255  void clearAtomSelection();
     256  void selectAtom(atom*);
     257  void selectAtom(atomId_t);
     258  void selectAllAtoms(AtomDescriptor);
     259  void selectAtomsOfMolecule(molecule*);
     260  void selectAtomsOfMolecule(moleculeId_t);
     261  void unselectAtom(atom*);
     262  void unselectAtom(atomId_t);
     263  void unselectAllAtoms(AtomDescriptor);
     264  void unselectAtomsOfMolecule(molecule*);
     265  void unselectAtomsOfMolecule(moleculeId_t);
     266
     267  void clearMoleculeSelection();
     268  void selectMolecule(molecule*);
     269  void selectMolecule(moleculeId_t);
     270  void selectAllMoleculess(MoleculeDescriptor);
     271  void selectMoleculeOfAtom(atom*);
     272  void selectMoleculeOfAtom(atomId_t);
     273  void unselectMolecule(molecule*);
     274  void unselectMolecule(moleculeId_t);
     275  void unselectAllMoleculess(MoleculeDescriptor);
     276  void unselectMoleculeOfAtom(atom*);
     277  void unselectMoleculeOfAtom(atomId_t);
     278
     279  /******************** Iterators to selections *****************/
     280  typedef AtomSet::iterator AtomSelectionIterator;
     281  AtomSelectionIterator beginAtomSelection();
     282  AtomSelectionIterator endAtomSelection();
     283
     284  typedef MoleculeSet::iterator MoleculeSelectionIterator;
     285  MoleculeSelectionIterator beginMoleculeSelection();
     286  MoleculeSelectionIterator endMoleculeSelection();
    245287
    246288protected:
     
    308350  class ThermoStatContainer *Thermostats;
    309351  int ExitFlag;
    310 public:
     352private:
     353
    311354  AtomSet atoms;
    312 private:
     355  AtomSet selectedAtoms;
    313356  typedef std::set<std::pair<atomId_t, atomId_t> > atomIdPool_t;
    314 
    315357  /**
    316358   * stores the pool for all available AtomIds below currAtomId
     
    324366
    325367  MoleculeSet molecules;
     368  MoleculeSet selectedMolecules;
    326369  typedef std::set<std::pair<moleculeId_t, moleculeId_t> > moleculeIdPool_t;
     370  /**
     371   * stores the pool for all available AtomIds below currAtomId
     372   *
     373   * The pool contains ranges of free ids in the form [bottom,top).
     374   */
    327375  moleculeIdPool_t moleculeIdPool;
    328376  moleculeId_t currMoleculeId;
  • src/atom.cpp

    rc538d1 r3d078d  
    330330}
    331331
     332molecule* atom::getMolecule(){
     333  return mol;
     334}
     335
    332336void atom::removeFromMolecule(){
    333337  if(mol){
  • src/atom.hpp

    rc538d1 r3d078d  
    9090
    9191   void setMolecule(molecule*);
     92   molecule* getMolecule();
    9293   void removeFromMolecule();
    9394
  • src/unittests/ParserUnitTest.cpp

    rc538d1 r3d078d  
    131131\tmolecule = $:molecule\n\
    132132)\n";
    133 static string waterXyz = "3\nH2O: water molecule\nO\t0\t0\t0\nH\t0.758602\t0\t0.504284\nH\t0.758602\t0\t-0.504284\n";
     133static string waterXyz = "3\n\tH2O: water molecule\nO\t0\t0\t0\nH\t0.758602\t0\t0.504284\nH\t0.758602\t0\t-0.504284\n";
    134134static string Tremolo_Atomdata1 = "# ATOMDATA\tId\tname\tType\tx=3\n";
    135135static string Tremolo_Atomdata2 = "#\n#ATOMDATA Id name Type x=3\n1 hydrogen H 3.0 4.5 0.1\n\n";
Note: See TracChangeset for help on using the changeset viewer.