Ignore:
Timestamp:
Oct 6, 2011, 4:06:10 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:
db7e6d
Parents:
e638f9
git-author:
Frederik Heber <heber@…> (09/01/11 13:49:14)
git-committer:
Frederik Heber <heber@…> (10/06/11 16:06:10)
Message:

Introduced atom_observables and GLWorldView observes World, GLMoleculeObject_atom observes its atom.

Observer changes:

  • new Channels pattern required from CodePatterns 1.1.5 and that Observable signing on and off is now with const instance possible.
  • class atom is now observable, encapsulated in class AtomObservable:
    • enums have notification types
    • we use NotificationChannels of Observable to emit these distinct types.
  • atominfo, particleinfo, bondedparticleinfo all have OBSERVE and NOTIFY(..) in their setter functions (thx encapsulation).
  • class GLMoleculeObject_atom signs on to atom to changes to position, element, and index.
  • World equally has notifications for atom (new,remove) and molecules (new, remove).
  • GLWorldView now observes World for these changes.

Other changes:

  • removed additional hierarchy level for GLWidget of molecules (i.e. GLMoleculeScene removed and incorporated into GLWorldScene).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/atom_atominfo.cpp

    re638f9 r7188b1  
    121121void AtomInfo::set(size_t i, const double value)
    122122{
     123  OBSERVE;
     124  NOTIFY(AtomObservable::PositionChanged);
    123125  ASSERT(AtomicPosition.size() > WorldTime::getTime(),
    124126      "AtomInfo::set() - Access out of range: "
     
    146148}
    147149
    148 void AtomInfo::setType(const element* _type) {
     150void AtomInfo::setType(const element* _type)
     151{
     152  OBSERVE;
     153  NOTIFY(AtomObservable::ElementChanged);
    149154  AtomicElement = _type;
    150155}
    151156
    152 void AtomInfo::setType(const int Z) {
     157void AtomInfo::setType(const int Z)
     158{
     159  OBSERVE;
     160  NOTIFY(AtomObservable::ElementChanged);
    153161  const element *elem = World::getInstance().getPeriode()->FindElement(Z);
    154162  setType(elem);
     
    187195void AtomInfo::setAtomicVelocity(const Vector &_newvelocity)
    188196{
     197  OBSERVE;
     198  NOTIFY(AtomObservable::VelocityChanged);
    189199  ASSERT(WorldTime::getTime() < AtomicVelocity.size(),
    190200      "AtomInfo::setAtomicVelocity() - Access out of range: "
     
    196206void AtomInfo::setAtomicVelocityAtStep(const unsigned int _step, const Vector &_newvelocity)
    197207{
     208  OBSERVE;
     209  if (WorldTime::getTime() == _step)
     210    NOTIFY(AtomObservable::VelocityChanged);
    198211  const unsigned int size = AtomicVelocity.size();
    199212  ASSERT(_step <= size,
     
    229242void AtomInfo::setAtomicForce(const Vector &_newforce)
    230243{
     244  OBSERVE;
     245  NOTIFY(AtomObservable::VelocityChanged);
    231246  ASSERT(WorldTime::getTime() < AtomicForce.size(),
    232247      "AtomInfo::setAtomicForce() - Access out of range: "
     
    238253void AtomInfo::setAtomicForceAtStep(const unsigned int _step, const Vector &_newforce)
    239254{
     255  OBSERVE;
     256  if (WorldTime::getTime() == _step)
     257    NOTIFY(AtomObservable::VelocityChanged);
    240258  const unsigned int size = AtomicForce.size();
    241259  ASSERT(_step <= size,
     
    258276void AtomInfo::setFixedIon(const bool _fixedion)
    259277{
     278  OBSERVE;
     279  NOTIFY(AtomObservable::PropertyChanged);
    260280  FixedIon = _fixedion;
    261281}
     
    263283void AtomInfo::setPosition(const Vector& _vector)
    264284{
     285  OBSERVE;
     286  NOTIFY(AtomObservable::PositionChanged);
    265287  ASSERT(WorldTime::getTime() < AtomicPosition.size(),
    266288      "AtomInfo::setPosition() - Access out of range: "
     
    273295void AtomInfo::setPositionAtStep(unsigned int _step, const Vector& _vector)
    274296{
     297  OBSERVE;
     298  if (WorldTime::getTime() == _step)
     299    NOTIFY(AtomObservable::PositionChanged);
    275300  const unsigned int size = AtomicPosition.size();
    276301  ASSERT(_step <= size,
     
    289314const VectorInterface& AtomInfo::operator+=(const Vector& b)
    290315{
     316  OBSERVE;
     317  NOTIFY(AtomObservable::PositionChanged);
    291318  ASSERT(WorldTime::getTime() < AtomicPosition.size(),
    292319      "AtomInfo::operator+=() - Access out of range: "
     
    299326const VectorInterface& AtomInfo::operator-=(const Vector& b)
    300327{
     328  OBSERVE;
     329  NOTIFY(AtomObservable::PositionChanged);
    301330  ASSERT(WorldTime::getTime() < AtomicPosition.size(),
    302331      "AtomInfo::operator-=() - Access out of range: "
     
    367396VectorInterface &AtomInfo::operator=(const Vector& _vector)
    368397{
     398  OBSERVE;
     399  NOTIFY(AtomObservable::PositionChanged);
    369400  ASSERT(WorldTime::getTime() < AtomicPosition.size(),
    370401      "AtomInfo::operator=() - Access out of range: "
     
    377408void AtomInfo::ScaleAll(const double *factor)
    378409{
     410  OBSERVE;
     411  NOTIFY(AtomObservable::PositionChanged);
    379412  ASSERT(WorldTime::getTime() < AtomicPosition.size(),
    380413      "AtomInfo::ScaleAll() - Access out of range: "
     
    386419void AtomInfo::ScaleAll(const Vector &factor)
    387420{
     421  OBSERVE;
     422  NOTIFY(AtomObservable::PositionChanged);
    388423  ASSERT(WorldTime::getTime() < AtomicPosition.size(),
    389424      "AtomInfo::ScaleAll() - Access out of range: "
     
    395430void AtomInfo::Scale(const double factor)
    396431{
     432  OBSERVE;
     433  NOTIFY(AtomObservable::PositionChanged);
    397434  ASSERT(WorldTime::getTime() < AtomicPosition.size(),
    398435      "AtomInfo::Scale() - Access out of range: "
     
    404441void AtomInfo::Zero()
    405442{
     443  OBSERVE;
     444  NOTIFY(AtomObservable::PositionChanged);
    406445  ASSERT(WorldTime::getTime() < AtomicPosition.size(),
    407446      "AtomInfo::Zero() - Access out of range: "
     
    413452void AtomInfo::One(const double one)
    414453{
     454  OBSERVE;
     455  NOTIFY(AtomObservable::PositionChanged);
    415456  ASSERT(WorldTime::getTime() < AtomicPosition.size(),
    416457      "AtomInfo::One() - Access out of range: "
     
    422463void AtomInfo::LinearCombinationOfVectors(const Vector &x1, const Vector &x2, const Vector &x3, const double * const factors)
    423464{
     465  OBSERVE;
     466  NOTIFY(AtomObservable::PositionChanged);
    424467  ASSERT(WorldTime::getTime() < AtomicPosition.size(),
    425468      "AtomInfo::LinearCombinationOfVectors() - Access out of range: "
     
    432475 *  returns the kinetic energy of this atom at a given time step
    433476 */
    434 double AtomInfo::getKineticEnergy(const unsigned int _step) const{
     477double AtomInfo::getKineticEnergy(const unsigned int _step) const
     478{
    435479  ASSERT(_step < AtomicPosition.size(),
    436480      "AtomInfo::getKineticEnergy() - Access out of range: "
     
    440484}
    441485
    442 Vector AtomInfo::getMomentum(const unsigned int _step) const{
     486Vector AtomInfo::getMomentum(const unsigned int _step) const
     487{
    443488  ASSERT(_step < AtomicPosition.size(),
    444489      "AtomInfo::getMomentum() - Access out of range: "
     
    475520  if (dest == src)  // self assignment check
    476521    return;
     522
     523  if (WorldTime::getTime() == dest){
     524    NOTIFY(AtomObservable::PositionChanged);
     525    NOTIFY(AtomObservable::VelocityChanged);
     526    NOTIFY(AtomObservable::ForceChanged);
     527  }
    477528
    478529  ASSERT(dest < AtomicPosition.size(),
Note: See TracChangeset for help on using the changeset viewer.