Ignore:
Timestamp:
Feb 12, 2016, 11:15:06 PM (9 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:
0f7ffe
Parents:
47f0e4
git-author:
Frederik Heber <heber@…> (01/25/16 11:09:33)
git-committer:
Frederik Heber <heber@…> (02/12/16 23:15:06)
Message:

GLMoleculeObject_atom, _bond, _molecule all use QtInstanceInformationBoard passed via GLWorldScene.

File:
1 edited

Legend:

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

    r47f0e4 r8d5fbf1  
    5353#include "Element/periodentafel.hpp"
    5454#include "LinearAlgebra/Vector.hpp"
    55 #include "GLMoleculeObject_bond.hpp"
     55#include "UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.hpp"
     56#include "UIElements/Views/Qt4/QtInstanceInformationBoard.hpp"
    5657#include "World.hpp"
    5758#include "WorldTime.hpp"
     
    6566  Observable::channels_t channels;
    6667  channels += AtomObservable::BondsAdded, AtomObservable::BondsRemoved;
     68  return channels;
     69}
     70
     71static const Observable::channels_t getAllObservedChannels()
     72{
     73  Observable::channels_t channels;
     74  channels +=
     75      AtomObservable::IndexChanged,
     76      AtomObservable::PositionChanged,
     77      AtomObservable::ElementChanged,
     78      AtomObservable::BondsAdded,
     79      AtomObservable::BondsRemoved;
    6780  return channels;
    6881}
     
    8194    QGLSceneNode *mesh[],
    8295    QObject *parent,
    83     const atomId_t _id) :
    84   GLMoleculeObject(mesh, parent),
    85   Observer(std::string("GLMoleculeObject_atom")+toString(_id)),
    86   atomref(getAtom(_id)),
    87   ObservedValues(MAX_ObservedTypes),
    88   subjectKilledCount(0),
    89   owner(NULL)
    90 {
    91   boost::function<void(const atomId_t)> subjectKilled =
    92       boost::bind(&GLMoleculeObject_atom::countsubjectKilled, this, _id);
    93   initObservedValues(ObservedValues, _id, atomref, subjectKilled);
    94 
    95   init(_id);
    96 }
    97 
    98 GLMoleculeObject_atom::GLMoleculeObject_atom(
    99     QGLSceneNode *mesh[],
    100     QObject *parent,
    10196    const atomId_t _id,
     97    QtInstanceInformationBoard * _board,
    10298    std::vector<boost::any> _ObservedValues) :
    10399  GLMoleculeObject(mesh, parent),
     
    106102  ObservedValues(_ObservedValues),
    107103  subjectKilledCount(0),
    108   owner(NULL)
     104  owner(NULL),
     105  AllsignedOnChannels(getAllObservedChannels().size()),
     106  signedOnChannels(0),
     107  board(_board)
    109108{
    110109  init(_id);
     
    130129  connect( this, SIGNAL(positionChanged()), this, SLOT(resetPosition()), Qt::QueuedConnection);
    131130  connect( this, SIGNAL(bondsChanged()), this, SLOT(resetPosition()), Qt::QueuedConnection);
     131
     132  // use that ObservedValues::AtomBonds is always up-to-date
     133  resetBonds();
    132134}
    133135
     
    135137{
    136138  if (atomref != NULL) {
     139    Observable::channels_t channels = getAllObservedChannels();
    137140    owner = static_cast<const Observable *>(atomref);
    138     owner->signOn(this, AtomObservable::IndexChanged);
    139     owner->signOn(this, AtomObservable::PositionChanged);
    140     owner->signOn(this, AtomObservable::ElementChanged);
    141     owner->signOn(this, AtomObservable::BondsAdded);
    142     owner->signOn(this, AtomObservable::BondsRemoved);
     141    for (Observable::channels_t::const_iterator iter = channels.begin();
     142        iter != channels.end(); ++iter)
     143      owner->signOn(this, *iter);
    143144  }
    144145}
     
    149150  // sign Off
    150151  if (owner != NULL) {
    151     owner->signOff(this, AtomObservable::IndexChanged);
    152     owner->signOff(this, AtomObservable::PositionChanged);
    153     owner->signOff(this, AtomObservable::ElementChanged);
    154     owner->signOff(this, AtomObservable::BondsAdded);
    155     owner->signOff(this, AtomObservable::BondsRemoved);
     152    Observable::channels_t channels = getAllObservedChannels();
     153    for (Observable::channels_t::const_iterator iter = channels.begin();
     154        iter != channels.end(); ++iter)
     155      owner->signOff(this, *iter);
    156156    owner = NULL;
     157    signedOnChannels = 0;
    157158  }
    158159}
     
    161162{
    162163  deactivateObserver();
    163   destroyObservedValues(ObservedValues);
     164  board->returnAtomObservedValues(getAtomIndex(), ObservedValues);
    164165}
    165166
     
    338339void GLMoleculeObject_atom::subjectKilled(Observable *publisher)
    339340{
    340   deactivateObserver();
    341 
    342   countsubjectKilled(getAtomIndex());
     341  ++signedOnChannels;
     342
     343  if (signedOnChannels == AllsignedOnChannels) {
     344    // remove owner: no more signOff needed
     345    owner = NULL;
     346
     347    board->atomcountsubjectKilled(getAtomIndex());
     348  }
    343349}
    344350
     
    371377}
    372378
    373 void GLMoleculeObject_atom::countsubjectKilled(const atomId_t)
    374 {
    375   ++subjectKilledCount;
    376 
    377   if (subjectKilledCount > ObservedValues.size())
    378     emit InstanceRemoved(getAtomIndex());
    379 }
    380 
    381379void GLMoleculeObject_atom::initObservedValues(
    382380    std::vector<boost::any> &_ObservedValues,
Note: See TracChangeset for help on using the changeset viewer.