Changes in / [0ac85c3:27e464]


Ignore:
Location:
src
Files:
13 added
2 deleted
15 edited

Legend:

Unmodified
Added
Removed
  • src/Atom/AtomicInfo.cpp

    r0ac85c3 r27e464  
    8888  bool status = true;
    8989  if (_atom.getId() != Id)
    90     status = _atom.changeId(Id);
     90    status &= _atom.changeId(Id);
    9191
    9292  // set its father
    93   atom * const _father = World::getInstance().getAtom(AtomById(FatherId));
    94   if (_father == NULL)
    95     _atom.father = &_atom;
    96   else
    97     _atom.father = _father;
     93  if (status) {
     94    atom * const _father = World::getInstance().getAtom(AtomById(FatherId));
     95    if ((_father == NULL) || (Id == FatherId)) {
     96      _atom.father = &_atom;
     97      // don't sign on
     98    } else {
     99      _atom.father = _father;
     100      _father->signOn(&_atom);
     101    }
    98102
    99   // setting molecule
    100   molecule * const _mol = World::getInstance().getMolecule(MoleculeById(MolId));
    101   if (_mol != NULL)
    102     _atom.setMolecule(_mol); // this is ok, mol is const within AtomicInfo, but not outside (atoms need to register)
    103   _atom.changeNr(Nr);
     103    // setting molecule
     104    molecule * const _mol = World::getInstance().getMolecule(MoleculeById(MolId));
     105    if (_mol != NULL)
     106      _atom.setMolecule(_mol); // this is ok, mol is const within AtomicInfo, but not outside (atoms need to register)
     107    _atom.changeNr(Nr);
     108  }
    104109
    105110  return status;
  • src/Atom/atom.cpp

    r0ac85c3 r27e464  
    5858  mol(0)
    5959{
    60   // sign on to global atom change tracker
     60  // note AtomObserver about inserted atom
    6161  AtomObserver::getInstance().AtomInserted(this);
    6262}
     
    6969    mol(0)
    7070{
    71   // sign on to global atom change tracker
     71  // sign on to father atom to be notified when it is removed
     72  father->signOn(this);
     73
     74  // note AtomObserver about inserted atom
    7275  AtomObserver::getInstance().AtomInserted(this);
    7376};
     
    8487atom::~atom()
    8588{
     89  // sign off from possible father
     90  if ((father != this) && (father != NULL))
     91    father->signOff(this);
     92
    8693  removeFromMolecule();
    87   // sign off from global atom change tracker
     94  // note AtomObserver about removed atom
    8895  AtomObserver::getInstance().AtomRemoved(this);
    8996}
     
    125132    return father->GetTrueFather();
    126133  }
    127 };
     134}
     135
     136void atom::setFather(atom * const _father)
     137{
     138  // sign off from old father
     139  if ((father != this) && (father != NULL))
     140    father->signOff(this);
     141
     142  father = _father;
     143  father->signOn(this);
     144}
    128145
    129146/** Sets father to itself or its father in case of copying a molecule.
     
    325342  return atom1->getType()->getAtomicNumber() < atom2->getType()->getAtomicNumber();
    326343}
     344/*
     345void atom::update(Observable *publisher)
     346{}
     347
     348void atom::recieveNotification(Observable *publisher, Notification_ptr notification)
     349{
     350  ASSERT(0, "atom::recieveNotification() - we are not signed on to any notifications.");
     351}
     352*/
     353void atom::subjectKilled(Observable *publisher)
     354{
     355  // as publisher has been half-deallocated (Observable is one of the base classes, hence
     356  // becomes destroyed latest), we cannot senibly cast it anymore.
     357  // Hence, we simply have to check here whether it is NOT one of the other instances
     358  // we are signed on to.
     359  father = this;
     360  // no need to sign off
     361}
  • src/Atom/atom.hpp

    r0ac85c3 r27e464  
    2525#include "atom_bondedparticle.hpp"
    2626#include "atom_graphnode.hpp"
     27#include "atom_observable.hpp"
    2728#include "atom_particleinfo.hpp"
    2829#include "Atom/TesselPoint.hpp"
    2930#include "types.hpp"
    3031
     32#include "CodePatterns/Observer/Observer.hpp"
    3133#include "CodePatterns/enumeration.hpp"
    3234
     
    4446 * Class incorporates position, type
    4547 */
    46 class atom : public GraphNode, public BondedParticle, public TesselPoint {
     48class atom :
     49            public GraphNode,
     50            public BondedParticle,
     51            public TesselPoint
     52{
    4753  friend atom* NewAtom(atomId_t);
    4854  friend void  DeleteAtom(atom*);
     55
     56  atom *father;   //!< In many-body bond order fragmentations points to originating atom
     57  int *sort;      //!< sort criteria
     58
    4959public:
    50     atom *father;   //!< In many-body bond order fragmentations points to originating atom
    51     int *sort;      //!< sort criteria
    5260
    5361  /** Clones this atom.
     
    130138   */
    131139  const atom *GetTrueFather() const;
     140
     141  /** Const getter for the atoms father.
     142   *
     143   * \return father of this atom
     144   */
     145  atom * const getFather() const
     146  { return father; }
     147
     148  /** Sets the father for this atom.
     149   *
     150   * \param _father ptr to father atom
     151   */
     152  void setFather(atom * const _father);
    132153
    133154  /** Compares the indices of \a this atom with a given \a ptr.
     
    228249    void unsetMolecule();
    229250
     251//    virtual void update(Observable *publisher);
     252//    virtual void recieveNotification(Observable *publisher, Notification_ptr notification);
     253    virtual void subjectKilled(Observable *publisher);
    230254
    231255  private:
  • src/Atom/atom_observable.cpp

    r0ac85c3 r27e464  
    5555AtomObservable::~AtomObservable()
    5656{}
     57
     58void AtomObservable::subjectKilled(Observable *publisher)
     59{}
  • src/Atom/atom_observable.hpp

    r0ac85c3 r27e464  
    4141  AtomObservable();
    4242  virtual ~AtomObservable();
     43
     44protected:
     45
     46  virtual void subjectKilled(Observable *publisher);
    4347};
    4448
  • src/Fragmentation/Exporters/HydrogenPool.cpp

    r0ac85c3 r27e464  
    6868  ++HydrogenCount;
    6969
    70   // give warning if pool has more than thereshold
     70  // give warning if pool has more than threshold
    7171  if (HydrogenCount >= WARNINGTHRESHOLD) {
    7272    ELOG(2, "HydrogenPool contains more hydrogen atoms than limit.");
  • src/Fragmentation/Exporters/SaturatedFragment.cpp

    r0ac85c3 r27e464  
    311311  _atom->setFixedIon(true);
    312312  // if we replace hydrogen, we mark it as our father, otherwise we are just an added hydrogen with no father
    313   _atom->father = _father;
     313  _atom->setFather(_father);
    314314  SaturationHydrogens.insert(_atom->getId());
    315315
     
    387387  _atom->setFixedIon(replacement->getFixedIon());
    388388  // if we replace hydrogen, we mark it as our father, otherwise we are just an added hydrogen with no father
    389   _atom->father = replacement;
     389  _atom->setFather(replacement);
    390390  SaturationHydrogens.insert(_atom->getId());
    391391  return _atom;
  • src/Graph/BuildInducedSubgraph.cpp

    r0ac85c3 r27e464  
    6363  LOG(3, "Filling Parent List.");
    6464  for (molecule::iterator iter = Son->begin(); iter != Son->end(); ++iter) {
    65     ParentList[(*iter)->father] = (*iter);
     65    ParentList[(*iter)->getFather()] = (*iter);
    6666    // Outputting List for debugging
    67     LOG(4, "INFO: ParentList[] of " << (*iter)->father << " is " << *ParentList[(*iter)->father] << ".");
     67    LOG(4, "INFO: ParentList[] of " << (*iter)->getFather() << " is " << *ParentList[(*iter)->getFather()] << ".");
    6868  }
    6969}
     
    7777  for (molecule::iterator iter = Father->begin(); iter != Father->end(); ++iter) {
    7878    if (ParentList.count(*iter)) {
    79       if (ParentList[(*iter)]->father != (*iter)) {
     79      if (ParentList[(*iter)]->getFather() != (*iter)) {
    8080        status = false;
    8181      } else {
  • src/Parser/PdbParser.cpp

    r0ac85c3 r27e464  
    360360{
    361361  if (additionalAtomData.find(_atom->getId()) != additionalAtomData.end()) {
    362   } else if (additionalAtomData.find(_atom->father->getId()) != additionalAtomData.end()) {
     362  } else if (additionalAtomData.find(_atom->getFather()->getId()) != additionalAtomData.end()) {
    363363    // use info from direct father
    364     additionalAtomData[_atom->getId()] = additionalAtomData[_atom->father->getId()];
     364    additionalAtomData[_atom->getId()] = additionalAtomData[_atom->getFather()->getId()];
    365365  } else if (additionalAtomData.find(_atom->GetTrueFather()->getId()) != additionalAtomData.end()) {
    366366    // use info from topmost father
  • src/UIElements/Makefile.am

    r0ac85c3 r27e464  
    167167  UIElements/Qt4/QtDialog.cpp \
    168168  UIElements/Qt4/QtUIFactory.cpp \
     169  UIElements/Views/Qt4/MoleculeList/QtMoleculeItem.cpp \
     170  UIElements/Views/Qt4/MoleculeList/QtMoleculeItemFactory.cpp \
     171  UIElements/Views/Qt4/MoleculeList/QtMoleculeList.cpp \
     172  UIElements/Views/Qt4/MoleculeList/QtMoleculeListView.cpp \
    169173  UIElements/Menu/Qt4/QtMenuPipe.cpp \
    170174  UIElements/Views/Qt4/QtElementList.cpp \
     
    173177  UIElements/Views/Qt4/QtInfoBox.cpp \
    174178  UIElements/Views/Qt4/QtLogBox.cpp \
    175   UIElements/Views/Qt4/QtMoleculeList.cpp \
    176179  UIElements/Views/Qt4/QtShapeController.cpp \
    177180  UIElements/Views/Qt4/QtShapeList.cpp \
     
    195198  UIElements/Menu/Qt4/QMenu_tooltip.hpp \
    196199  UIElements/Menu/Qt4/QtMenuPipe.hpp \
    197   UIElements/Views/Qt4/QDebugStream.hpp \
     200  UIElements/Views/Qt4/MoleculeList/QtMoleculeList.hpp \
     201  UIElements/Views/Qt4/MoleculeList/QtMoleculeListView.hpp \
    198202  UIElements/Views/Qt4/QtElementList.hpp \
    199203  UIElements/Views/Qt4/QtFragmentList.hpp \
     
    201205  UIElements/Views/Qt4/QtInfoBox.hpp \
    202206  UIElements/Views/Qt4/QtLogBox.hpp \
    203   UIElements/Views/Qt4/QtMoleculeList.hpp \
    204207  UIElements/Views/Qt4/QtShapeController.hpp \
    205208  UIElements/Views/Qt4/QtShapeList.hpp \
     
    224227  UIElements/Menu/Qt4/QtMenu.hpp \
    225228  UIElements/Qt4/Query/QtQueryList.hpp \
    226   UIElements/Qt4/QtUIFactory.hpp
     229  UIElements/Qt4/QtUIFactory.hpp \
     230  UIElements/Views/Qt4/MoleculeList/QtMoleculeItem.hpp \
     231  UIElements/Views/Qt4/MoleculeList/QtMoleculeItemFactory.hpp \
     232  UIElements/Views/Qt4/MoleculeList/SpecificItems/QtMoleculeItem_atomcount.hpp \
     233  UIElements/Views/Qt4/MoleculeList/SpecificItems/QtMoleculeItem_formula.hpp \
     234  UIElements/Views/Qt4/MoleculeList/SpecificItems/QtMoleculeItem_name.hpp \
     235  UIElements/Views/Qt4/MoleculeList/SpecificItems/QtMoleculeItem_occurrence.hpp \
     236  UIElements/Views/Qt4/MoleculeList/SpecificItems/QtMoleculeItem_visibility.hpp \
     237  UIElements/Views/Qt4/QDebugStream.hpp
    227238
    228239lib_LTLIBRARIES += libMolecuilderUI.la
  • src/UIElements/Qt4/QtMainWindow.cpp

    r0ac85c3 r27e464  
    5353
    5454#include "Menu/Qt4/QtMenu.hpp"
    55 #include "Views/Qt4/QtMoleculeList.hpp"
     55#include "Views/Qt4/MoleculeList/QtMoleculeList.hpp"
     56#include "Views/Qt4/MoleculeList/QtMoleculeListView.hpp"
    5657#include "Views/Qt4/QtElementList.hpp"
    5758#include "Views/Qt4/QtFragmentList.hpp"
     
    9596  QVBoxLayout *layout = new QVBoxLayout(layoutwidget);
    9697
    97   moleculeList = new QtMoleculeList(worldTab);
     98  QtMoleculeListView *moleculeListView = new QtMoleculeListView(worldTab);
     99  moleculeList = new QtMoleculeList;
     100  moleculeListView->setModel(moleculeList);
     101
    98102  elementList = new QtElementList(worldTab);
    99103  homologyList = new QtHomologyList(worldTab);
     
    129133  layout->addWidget(worldTab);
    130134  splitter2->addWidget(layoutwidget);
    131   worldTab->addTab(moleculeList, "Molecules");
     135  worldTab->addTab(moleculeListView, "Molecules");
    132136  worldTab->addTab(elementList, "All Elements");
    133137  worldTab->addTab(fragmentList, "All Fragments");
  • src/builder.cpp

    r0ac85c3 r27e464  
    3939#include "UIElements/UIFactory.hpp"
    4040
     41#ifdef LOG_OBSERVER
     42#include "CodePatterns/Observer/ObserverLog.hpp"
     43#endif
     44
    4145/********************************************** Main routine **************************************/
    4246
    4347int main(int argc, char **argv)
    4448{
     49#ifdef LOG_OBSERVER
     50  ObserverLog::getInstance().enableLogging();
     51#endif
     52
    4553  initGeneral();
    4654
  • src/molecule.cpp

    r0ac85c3 r27e464  
    3535#include "CodePatterns/MemDebug.hpp"
    3636
    37 #include <cstring>
     37#include <algorithm>
    3838#include <boost/bind.hpp>
    3939#include <boost/foreach.hpp>
     40#include <cstring>
    4041
    4142#include <gsl/gsl_inline.h>
     
    102103molecule::~molecule()
    103104{
     105  // inform all UI elements about imminent removal before anything is lost
     106  {
     107    OBSERVE;
     108    NOTIFY(AboutToBeRemoved);
     109  }
    104110  CleanupMolecule();
    105111};
     
    648654void removeAtomsinMolecule(molecule *&_mol)
    649655{
     656  // copy list of atoms from molecule as it will be changed
     657  std::vector<atom *> atoms;
     658  atoms.resize(_mol->getAtomCount(), NULL);
     659  std::copy(_mol->begin(), _mol->end(), atoms.begin());
    650660  // remove each atom from world
    651   for(molecule::iterator AtomRunner = _mol->begin(); !_mol->empty(); AtomRunner = _mol->begin())
     661  for(std::vector<atom *>::iterator AtomRunner = atoms.begin();
     662      AtomRunner != atoms.end(); ++AtomRunner)
    652663    World::getInstance().destroyAtom(*AtomRunner);
    653664  // make sure that pointer os not usable
     
    934945    output << "Map is ";
    935946    for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    936       if ((*iter)->father == NULL) {
     947      if ((*iter)->getFather() == NULL) {
    937948        AtomicMap[(*iter)->getNr()] = -2;
    938949      } else {
     
    940951      //for (int i=0;i<AtomCount;i++) { // search atom
    941952        //for (int j=0;j<OtherMolecule->getAtomCount();j++) {
    942           //LOG(4, "Comparing father " << (*iter)->father << " with the other one " << (*runner)->father << ".");
    943           if ((*iter)->father == (*runner))
     953          //LOG(4, "Comparing father " << (*iter)->getFather() << " with the other one " << (*runner)->getFather() << ".");
     954          if ((*iter)->getFather() == (*runner))
    944955            AtomicMap[(*iter)->getNr()] = (*runner)->getNr();
    945956        }
  • src/molecule.hpp

    r0ac85c3 r27e464  
    113113    AtomMoved,
    114114    MoleculeNameChanged,
     115    AboutToBeRemoved,
    115116    NotificationType_MAX
    116117  };
  • src/moleculelist.cpp

    r0ac85c3 r27e464  
    409409    for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) {
    410410      //LOG(1, "(*iter): " << *(*iter) << " with first bond " << *((*iter)->getListOfBonds().begin()) << ".");
    411       if (((*iter)->getType()->getAtomicNumber() == 1) && (((*iter)->father == NULL)
    412           || ((*iter)->father->getType()->getAtomicNumber() != 1))) { // if it's a hydrogen
     411      if (((*iter)->getType()->getAtomicNumber() == 1) && (((*iter)->getFather() == NULL)
     412          || ((*iter)->getFather()->getType()->getAtomicNumber() != 1))) { // if it's a hydrogen
    413413        for (molecule::const_iterator runner = (*ListRunner)->begin(); runner != (*ListRunner)->end(); ++runner) {
    414414          //LOG(2, "Runner: " << *(*runner) << " with first bond " << *((*iter)->getListOfBonds().begin()) << ".");
Note: See TracChangeset for help on using the changeset viewer.