- Timestamp:
- Feb 12, 2016, 11:15:06 PM (9 years ago)
- 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.cpp
r47f0e4 r8d5fbf1 53 53 #include "Element/periodentafel.hpp" 54 54 #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" 56 57 #include "World.hpp" 57 58 #include "WorldTime.hpp" … … 65 66 Observable::channels_t channels; 66 67 channels += AtomObservable::BondsAdded, AtomObservable::BondsRemoved; 68 return channels; 69 } 70 71 static 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; 67 80 return channels; 68 81 } … … 81 94 QGLSceneNode *mesh[], 82 95 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,101 96 const atomId_t _id, 97 QtInstanceInformationBoard * _board, 102 98 std::vector<boost::any> _ObservedValues) : 103 99 GLMoleculeObject(mesh, parent), … … 106 102 ObservedValues(_ObservedValues), 107 103 subjectKilledCount(0), 108 owner(NULL) 104 owner(NULL), 105 AllsignedOnChannels(getAllObservedChannels().size()), 106 signedOnChannels(0), 107 board(_board) 109 108 { 110 109 init(_id); … … 130 129 connect( this, SIGNAL(positionChanged()), this, SLOT(resetPosition()), Qt::QueuedConnection); 131 130 connect( this, SIGNAL(bondsChanged()), this, SLOT(resetPosition()), Qt::QueuedConnection); 131 132 // use that ObservedValues::AtomBonds is always up-to-date 133 resetBonds(); 132 134 } 133 135 … … 135 137 { 136 138 if (atomref != NULL) { 139 Observable::channels_t channels = getAllObservedChannels(); 137 140 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); 143 144 } 144 145 } … … 149 150 // sign Off 150 151 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); 156 156 owner = NULL; 157 signedOnChannels = 0; 157 158 } 158 159 } … … 161 162 { 162 163 deactivateObserver(); 163 destroyObservedValues(ObservedValues);164 board->returnAtomObservedValues(getAtomIndex(), ObservedValues); 164 165 } 165 166 … … 338 339 void GLMoleculeObject_atom::subjectKilled(Observable *publisher) 339 340 { 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 } 343 349 } 344 350 … … 371 377 } 372 378 373 void GLMoleculeObject_atom::countsubjectKilled(const atomId_t)374 {375 ++subjectKilledCount;376 377 if (subjectKilledCount > ObservedValues.size())378 emit InstanceRemoved(getAtomIndex());379 }380 381 379 void GLMoleculeObject_atom::initObservedValues( 382 380 std::vector<boost::any> &_ObservedValues,
Note:
See TracChangeset
for help on using the changeset viewer.