- Timestamp:
- Feb 12, 2016, 11:15:04 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:
- 2831b3
- Parents:
- e25448
- git-author:
- Frederik Heber <heber@…> (10/16/15 11:51:16)
- git-committer:
- Frederik Heber <heber@…> (02/12/16 23:15:04)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.cpp
re25448 r7c7c4a 57 57 #include "WorldTime.hpp" 58 58 59 #include "ObservedValue_wCallback.hpp" 60 59 61 using namespace boost::assign; 60 62 … … 80 82 Observer(std::string("GLMoleculeObject_atom")+toString(_id)), 81 83 atomref(getAtom(_id)), 82 AtomIndex( 83 atomref, 84 boost::bind(&GLMoleculeObject_atom::updateIndex, this), 85 "AtomIndex_"+toString(_id), 86 _id, 87 AtomIndexChannels), 88 AtomPosition( 89 atomref, 90 boost::bind(&GLMoleculeObject_atom::updatePosition, this), 91 "AtomPosition_"+toString(_id), 92 updatePosition(), 93 AtomPositionChannels), 94 AtomElement( 95 atomref, 96 boost::bind(&GLMoleculeObject_atom::updateElement, this), 97 "AtomElement"+toString(_id), 98 updateElement(), 99 AtomElementChannels), 100 AtomBonds( 101 atomref, 102 boost::bind(&GLMoleculeObject_atom::updateBonds, this), 103 "AtomBonds_"+toString(_id), 104 updateBonds(), 105 AtomBondsChannels), 84 ObservedValues(MAX_ObservedTypes), 85 subjectKilledCount(0), 106 86 owner(NULL) 107 87 { 88 initObservedValues(_id); 89 108 90 setObjectId(_id); 109 91 resetPosition(); … … 154 136 { 155 137 deactivateObserver(); 138 destroyObservedValues(); 156 139 } 157 140 158 141 void GLMoleculeObject_atom::resetIndex() 159 142 { 160 const atomId_t newId = AtomIndex.get();143 const atomId_t newId = getAtomIndex(); 161 144 const size_t oldId = objectId(); 162 145 ASSERT( newId != oldId, … … 170 153 void GLMoleculeObject_atom::resetPosition() 171 154 { 172 const Vector Position = AtomPosition.get();155 const Vector Position = getAtomPosition(); 173 156 LOG(4, "INFO: GLMoleculeObject_atom::resetIndex() - new position is "+toString(Position)+"."); 174 157 setPosition(QVector3D(Position[0], Position[1], Position[2])); … … 179 162 size_t elementno = 0; 180 163 const element * const _type = World::getInstance(). 181 getPeriode()->FindElement( AtomElement.get());164 getPeriode()->FindElement(getAtomElement()); 182 165 if (_type != NULL) { 183 166 elementno = _type->getAtomicNumber(); … … 205 188 void GLMoleculeObject_atom::resetBonds() 206 189 { 207 ListOfBonds_t ListOfBonds_new = AtomBonds.get();190 ListOfBonds_t ListOfBonds_new = getAtomBonds(); 208 191 std::sort(ListOfBonds_new.begin(), ListOfBonds_new.end()); 209 192 ListOfBonds_t BondsToAdd; … … 220 203 iter != BondsToAdd.end(); 221 204 ++iter) { 222 const GLMoleculeObject_bond::SideOfBond side = (iter->first == AtomIndex.get()) ?205 const GLMoleculeObject_bond::SideOfBond side = (iter->first == getAtomIndex()) ? 223 206 GLMoleculeObject_bond::left : GLMoleculeObject_bond::right; 224 207 emit BondsAdded(iter->first, iter->second, side); … … 259 242 void GLMoleculeObject_atom::wasClicked() 260 243 { 261 LOG(4, "INFO: GLMoleculeObject_atom: atom " << AtomIndex.get() << " has been clicked");262 emit clicked( AtomIndex.get());244 LOG(4, "INFO: GLMoleculeObject_atom: atom " << getAtomIndex() << " has been clicked"); 245 emit clicked(getAtomIndex()); 263 246 } 264 247 … … 283 266 Vector GLMoleculeObject_atom::updatePosition() const 284 267 { 285 const atom * const _atom = getAtom( AtomIndex.get());268 const atom * const _atom = getAtom(getAtomIndex()); 286 269 if (_atom != NULL) { 287 270 return _atom->getPosition(); … … 293 276 atomicNumber_t GLMoleculeObject_atom::updateElement() const 294 277 { 295 const atom * const _atom = getAtom( AtomIndex.get());278 const atom * const _atom = getAtom(getAtomIndex()); 296 279 if (_atom != NULL) { 297 280 return _atom->getElementNo(); … … 304 287 { 305 288 ListOfBonds_t ListOfBonds; 306 const atom * const _atom = getAtom( AtomIndex.get());289 const atom * const _atom = getAtom(getAtomIndex()); 307 290 if (_atom != NULL) { 308 291 // make sure position is up-to-date … … 315 298 (*iter)->rightatom->getId()) ); 316 299 } else { 317 ELOG(2, "Atom with id "+toString( AtomIndex.get())+" is already gone.");300 ELOG(2, "Atom with id "+toString(getAtomIndex())+" is already gone."); 318 301 } 319 302 return ListOfBonds; … … 328 311 { 329 312 deactivateObserver(); 313 314 countsubjectKilled(); 330 315 } 331 316 … … 357 342 ASSERT(0, "GLMoleculeObject_atom::recieveNotification() - received notification from unexpected source."); 358 343 } 344 345 void GLMoleculeObject_atom::countsubjectKilled() 346 { 347 ++subjectKilledCount; 348 349 if (subjectKilledCount > ObservedValues.size()) 350 emit InstanceRemoved(getAtomIndex()); 351 } 352 353 void GLMoleculeObject_atom::initObservedValues(const atomId_t _id) 354 { 355 // fill ObservedValues 356 boost::function<void()> subjectKilled = 357 boost::bind(&GLMoleculeObject_atom::countsubjectKilled, this); 358 ObservedValues[AtomIndex] = new ObservedValue_wCallback<atomId_t>( 359 atomref, 360 boost::bind(&GLMoleculeObject_atom::updateIndex, this), 361 "AtomIndex_"+toString(_id), 362 _id, 363 AtomIndexChannels, 364 subjectKilled); 365 ObservedValues[AtomPosition] = new ObservedValue_wCallback<Vector>( 366 atomref, 367 boost::bind(&GLMoleculeObject_atom::updatePosition, this), 368 "AtomPosition_"+toString(_id), 369 updatePosition(), 370 AtomPositionChannels, 371 subjectKilled); 372 ObservedValues[AtomElement] = new ObservedValue_wCallback<atomicNumber_t>( 373 atomref, 374 boost::bind(&GLMoleculeObject_atom::updateElement, this), 375 "AtomElement"+toString(_id), 376 updateElement(), 377 AtomElementChannels, 378 subjectKilled); 379 ObservedValues[AtomBonds] = new ObservedValue_wCallback<ListOfBonds_t>( 380 atomref, 381 boost::bind(&GLMoleculeObject_atom::updateBonds, this), 382 "AtomBonds_"+toString(_id), 383 updateBonds(), 384 AtomBondsChannels, 385 subjectKilled); 386 } 387 388 void GLMoleculeObject_atom::destroyObservedValues() 389 { 390 delete boost::any_cast<ObservedValue_wCallback<atomId_t> *>(ObservedValues[AtomIndex]); 391 delete boost::any_cast<ObservedValue_wCallback<Vector> *>(ObservedValues[AtomPosition]); 392 delete boost::any_cast<ObservedValue_wCallback<atomicNumber_t> *>(ObservedValues[AtomElement]); 393 delete boost::any_cast<ObservedValue_wCallback<ListOfBonds_t> *>(ObservedValues[AtomBonds]); 394 ObservedValues.clear(); 395 } 396 397 atomId_t GLMoleculeObject_atom::getAtomIndex() const 398 { 399 return boost::any_cast<ObservedValue_wCallback<atomId_t> *>(ObservedValues[AtomIndex])->get(); 400 } 401 402 Vector GLMoleculeObject_atom::getAtomPosition() const 403 { 404 return boost::any_cast<ObservedValue_wCallback<Vector> *>(ObservedValues[AtomPosition])->get(); 405 } 406 407 atomicNumber_t GLMoleculeObject_atom::getAtomElement() const 408 { 409 return boost::any_cast<ObservedValue_wCallback<atomicNumber_t> *>(ObservedValues[AtomElement])->get(); 410 } 411 412 GLMoleculeObject_atom::ListOfBonds_t GLMoleculeObject_atom::getAtomBonds() const 413 { 414 return boost::any_cast<ObservedValue_wCallback<ListOfBonds_t> *>(ObservedValues[AtomBonds])->get(); 415 }
Note:
See TracChangeset
for help on using the changeset viewer.