Ignore:
Timestamp:
Apr 11, 2012, 4:52:37 PM (14 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:
3e93332
Parents:
c0ed1e (diff), 3927ef (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.
git-author:
Frederik Heber <heber@…> (04/06/12 11:59:28)
git-committer:
Frederik Heber <heber@…> (04/11/12 16:52:37)
Message:

Merge branch 'michi-track-molecules' into stable

Conflicts:

src/World.hpp

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.cpp

    rc0ed1e r53059e  
    3939#include "LinearAlgebra/Vector.hpp"
    4040
    41 static QGLSceneNode *createBond(QObject *parent, double distance)
     41static QGLSceneNode *createBond(QObject *parent)
    4242{
    4343   QGLBuilder builder;
    44    QGLCylinder cylinder(.25,.25,.25);
    45    cylinder.setHeight(distance);
     44   QGLCylinder cylinder(.25,.25,1.0,16);
    4645   builder << cylinder;
    4746   QGLSceneNode *n = builder.finalizedSceneNode();
     
    5049}
    5150
    52 GLMoleculeObject_bond::GLMoleculeObject_bond(QObject *parent, const bond *bondref, const double distance, const enum SideOfBond side) :
    53   GLMoleculeObject(createBond(parent, distance), parent),
     51GLMoleculeObject_bond::GLMoleculeObject_bond(QObject *parent, const bond *bondref, const enum SideOfBond side) :
     52  GLMoleculeObject(createBond(parent), parent),
    5453  Observer(std::string("GLMoleculeObject_bond")
    5554      +toString(bondref->leftatom->getId())
     
    6160  // sign on as observer (obtain non-const instance before)
    6261  _bond->signOn(this, BondObservable::BondRemoved);
    63 
    64   Vector Position;
    65   Vector OtherPosition;
     62  _bond->leftatom->signOn(this, AtomObservable::PositionChanged);
     63  _bond->rightatom->signOn(this, AtomObservable::PositionChanged);
     64
    6665  size_t elementno = 0;
    6766  switch (BondSide) {
    6867    case left:
    69       Position = _bond->leftatom->getPosition();
    70       OtherPosition = _bond->rightatom->getPosition();
    7168      if (_bond->leftatom->getType() != NULL) {
    7269        elementno = _bond->leftatom->getType()->getAtomicNumber();
     
    7673      break;
    7774    case right:
    78       Position = _bond->rightatom->getPosition();
    79       OtherPosition = _bond->leftatom->getPosition();
    8075      if (_bond->rightatom->getType() != NULL) {
    8176        elementno = _bond->rightatom->getType()->getAtomicNumber();
     
    9388  QGLMaterial *elementmaterial = getMaterial(elementno);
    9489  setMaterial(elementmaterial);
     90
     91  resetPosition();
     92}
     93
     94GLMoleculeObject_bond::~GLMoleculeObject_bond()
     95{
     96  // sign on as observer (obtain non-const instance before)
     97  _bond->signOff(this, BondObservable::BondRemoved);
     98  _bond->leftatom->signOff(this, AtomObservable::PositionChanged);
     99  _bond->rightatom->signOff(this, AtomObservable::PositionChanged);
     100
     101  LOG(2, "INFO: Destroying  GLMoleculeObject_bond to bond " << *_bond << " and side " << BondSide << ".");
     102}
     103
     104void GLMoleculeObject_bond::update(Observable *publisher)
     105{
     106#ifdef LOG_OBSERVER
     107  observerLog().addMessage() << "++ Update of Observer " << observerLog().getName(this) << " from bond " << *_bond << ".";
     108#endif
     109}
     110
     111void GLMoleculeObject_bond::subjectKilled(Observable *publisher)
     112{
     113  LOG(2, "INFO: Received subjectKilled from " << *_bond << ".");
     114  switch (BondSide) {
     115    case left:
     116      emit BondRemoved(_bond->leftatom->getId(), _bond->rightatom->getId());
     117      break;
     118    case right:
     119      emit BondRemoved(_bond->rightatom->getId(), _bond->leftatom->getId());
     120      break;
     121    default:
     122      ASSERT(0,
     123          "GLMoleculeObject_bond::subjectKilled() - side is not a valid argument: "+toString(BondSide)+".");
     124      break;
     125  }
     126  delete this;
     127}
     128
     129void GLMoleculeObject_bond::recieveNotification(Observable *publisher, Notification_ptr notification)
     130{
     131#ifdef LOG_OBSERVER
     132  observerLog().addMessage() << "++ Update of Observer "<< observerLog().getName(this)
     133      << " received notification from bond " << *_bond << " for channel "
     134      << notification->getChannelNo() << ".";
     135#endif
     136  if (publisher == dynamic_cast<const Observable*>(_bond)){
     137    // from the bond
     138    switch (notification->getChannelNo()) {
     139      case BondObservable::BondRemoved:
     140        LOG(2, "INFO: Received notification of BondRemoved from " << *_bond << ".");
     141        switch (BondSide) {
     142          case left:
     143            emit BondRemoved(_bond->leftatom->getId(), _bond->rightatom->getId());
     144            break;
     145          case right:
     146            emit BondRemoved(_bond->rightatom->getId(), _bond->leftatom->getId());
     147            break;
     148          default:
     149            ASSERT(0,
     150                "GLMoleculeObject_bond::recieveNotification() - side is not a valid argument: "+toString(BondSide)+".");
     151            break;
     152        }
     153        delete this;
     154        break;
     155          default:
     156            break;
     157    }
     158  }else{
     159    // from an atom
     160    switch (notification->getChannelNo()) {
     161      case AtomObservable::PositionChanged:
     162        LOG(2, "INFO: Received notification of PositionChanged.");
     163        resetPosition();
     164        emit changed();
     165    }
     166  }
     167}
     168
     169void GLMoleculeObject_bond::resetPosition()
     170{
     171  Vector Position;
     172  Vector OtherPosition;
     173  switch (BondSide) {
     174    case left:
     175      Position = _bond->leftatom->getPosition();
     176      OtherPosition = _bond->rightatom->getPosition();
     177      break;
     178    case right:
     179      Position = _bond->rightatom->getPosition();
     180      OtherPosition = _bond->leftatom->getPosition();
     181      break;
     182    default:
     183      ASSERT(0,
     184          "GLMoleculeObject_bond::resetPosition() - side is not a valid argument: "+toString(BondSide)+".");
     185      break;
     186  }
     187  const double distance =
     188      Position.distance(OtherPosition)/2.;
     189  setScaleZ(distance);
    95190
    96191  // calculate position
     
    123218  setRotationAngle(alpha/M_PI*180.);
    124219}
    125 
    126 GLMoleculeObject_bond::~GLMoleculeObject_bond()
    127 {
    128   // sign on as observer (obtain non-const instance before)
    129   _bond->signOff(this, BondObservable::BondRemoved);
    130 
    131   LOG(2, "INFO: Destroying  GLMoleculeObject_bond to bond " << *_bond << " and side " << BondSide << ".");
    132 }
    133 
    134 void GLMoleculeObject_bond::update(Observable *publisher)
    135 {
    136 #ifdef LOG_OBSERVER
    137   observerLog().addMessage() << "++ Update of Observer " << observerLog().getName(this) << " from bond " << *_bond << ".";
    138 #endif
    139 }
    140 
    141 void GLMoleculeObject_bond::subjectKilled(Observable *publisher)
    142 {
    143   LOG(2, "INFO: Received subjectKilled from " << *_bond << ".");
    144   switch (BondSide) {
    145     case left:
    146       emit BondRemoved(_bond->leftatom->getId(), _bond->rightatom->getId());
    147       break;
    148     case right:
    149       emit BondRemoved(_bond->rightatom->getId(), _bond->leftatom->getId());
    150       break;
    151     default:
    152       ASSERT(0,
    153           "GLMoleculeObject_bond::subjectKilled() - side is not a valid argument: "+toString(BondSide)+".");
    154       break;
    155   }
    156   delete this;
    157 }
    158 
    159 void GLMoleculeObject_bond::recieveNotification(Observable *publisher, Notification_ptr notification)
    160 {
    161 #ifdef LOG_OBSERVER
    162   observerLog().addMessage() << "++ Update of Observer "<< observerLog().getName(this)
    163       << " received notification from bond " << *_bond << " for channel "
    164       << notification->getChannelNo() << ".";
    165 #endif
    166   switch (notification->getChannelNo()) {
    167     case BondObservable::BondRemoved:
    168       LOG(2, "INFO: Received notification of BondRemoved from " << *_bond << ".");
    169       switch (BondSide) {
    170         case left:
    171           emit BondRemoved(_bond->leftatom->getId(), _bond->rightatom->getId());
    172           break;
    173         case right:
    174           emit BondRemoved(_bond->rightatom->getId(), _bond->leftatom->getId());
    175           break;
    176         default:
    177           ASSERT(0,
    178               "GLMoleculeObject_bond::recieveNotification() - side is not a valid argument: "+toString(BondSide)+".");
    179           break;
    180       }
    181       delete this;
    182       break;
    183     default:
    184       break;
    185   }
    186 }
Note: See TracChangeset for help on using the changeset viewer.