- 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_molecule.cpp
re25448 r7c7c4a 63 63 #include "Atom/TesselPoint.hpp" 64 64 #include "World.hpp" 65 66 #include "ObservedValue_wCallback.hpp" 65 67 66 68 using namespace boost::assign; … … 122 124 boost::bind(&GLMoleculeObject_molecule::updateAtoms, this) 123 125 ), 124 MolIndex( 125 molref, 126 MolIndexUpdater, 127 "MoleculeIndex_"+toString(_molid), 128 _molid, 129 IndexChannels), 130 MolName( 131 molref, 132 MolNameUpdater, 133 "MoleculeName_"+toString(_molid), 134 updateName(), 135 NameChannels), 126 ObservedValues(MAX_ObservedTypes), 127 subjectKilledCount(0), 136 128 TesselationHull( 137 129 molref, … … 139 131 "MoleculeTesselationHull_"+toString(_molid), 140 132 HullChannels), 141 BoundingBox(142 molref,143 BoundingBoxUpdater,144 "MoleculeBoundingBox_"+toString(_molid),145 initBoundingBox(),146 BoundingBoxChannels),147 PresentAtoms(148 molref,149 PresentAtomsUpdater,150 "MoleculeAtoms_"+toString(_molid),151 updateAtoms(),152 AtomsChannels),153 133 hoverAtomId(-1) 154 134 { 135 initObservedValues(_molid); 136 155 137 setObjectId(_molid); 156 138 setMaterial(getMaterial(1)); … … 199 181 boost::bind(&GLMoleculeObject_molecule::updateAtoms, this) 200 182 ), 201 MolIndex( 202 molref, 203 MolIndexUpdater, 204 "MoleculeIndex_"+toString(_molid), 205 _molid, 206 IndexChannels), 207 MolName( 208 molref, 209 MolNameUpdater, 210 "MoleculeName_"+toString(_molid), 211 updateName(), 212 NameChannels), 183 ObservedValues(MAX_ObservedTypes), 184 subjectKilledCount(0), 213 185 TesselationHull( 214 186 molref, … … 216 188 "MoleculeTesselationHull_"+toString(_molid), 217 189 HullChannels), 218 BoundingBox(219 molref,220 BoundingBoxUpdater,221 "MoleculeBoundingBox_"+toString(_molid),222 initBoundingBox(),223 BoundingBoxChannels),224 PresentAtoms(225 molref,226 PresentAtomsUpdater,227 "MoleculeAtoms_"+toString(_molid),228 atoms_t(),229 AtomsChannels),230 190 hoverAtomId(-1) 231 191 { 192 initObservedValues(_molid); 193 232 194 setObjectId(_molid); 233 195 setMaterial(getMaterial(1)); … … 254 216 { 255 217 deactivateObserver(); 218 destroyObservedValues(); 256 219 } 257 220 … … 270 233 { 271 234 // sign on as observer (obtain non-const instance before) 272 const molecule * const _molecule = getMolecule( MolIndex.get());235 const molecule * const _molecule = getMolecule(getMolIndex()); 273 236 if (_molecule != NULL) { 274 237 owner = static_cast<const Observable *>(_molecule); … … 278 241 owner->signOn(this, molecule::IndexChanged); 279 242 } else { 280 ELOG(1, "GLMoleculeObject_molecule() - added null object for not present mol id " << MolIndex.get());243 ELOG(1, "GLMoleculeObject_molecule() - added null object for not present mol id " << getMolIndex()); 281 244 } 282 245 … … 332 295 QGeometryData geo; 333 296 334 const molecule * const molref = getMolecule( MolIndex.get());297 const molecule * const molref = getMolecule(getMolIndex()); 335 298 if (molref == NULL) { 336 ELOG(1, "Could not createMoleculeMesh, molecule with id " << MolIndex.get() << " already gone.");299 ELOG(1, "Could not createMoleculeMesh, molecule with id " << getMolIndex() << " already gone."); 337 300 return geo; 338 301 } … … 353 316 354 317 // we need at least three points for tesselation 355 if ( PresentAtoms.get().size() >= 3) {318 if (getPresentAtoms().size() >= 3) { 356 319 // Tesselate the points. 357 320 Tesselation T; 358 PointCloudAdaptor<molecule> cloud(const_cast<molecule *>(molref), MolName.get());321 PointCloudAdaptor<molecule> cloud(const_cast<molecule *>(molref), getMolName()); 359 322 T(cloud, minradius); 360 323 … … 413 376 molecule::BoundingBoxInfo GLMoleculeObject_molecule::updateBoundingBox() const 414 377 { 415 return BoundingBox.get();378 return getBoundingBox(); 416 379 } 417 380 418 381 GLMoleculeObject_molecule::atoms_t GLMoleculeObject_molecule::updateAtoms() 419 382 { 420 const molecule * const mol = getMolecule( MolIndex.get());383 const molecule * const mol = getMolecule(getMolIndex()); 421 384 if (mol != NULL) { 422 385 const atomId_t id = mol->lastChangedAtomId(); … … 436 399 std::string GLMoleculeObject_molecule::updateName() const 437 400 { 438 const molecule * const mol = getMolecule( MolIndex.get());401 const molecule * const mol = getMolecule(getMolIndex()); 439 402 return mol->getName(); 440 403 } … … 448 411 void GLMoleculeObject_molecule::resetBoundingBox() 449 412 { 450 molecule::BoundingBoxInfo info = BoundingBox.get();413 molecule::BoundingBoxInfo info = getBoundingBox(); 451 414 setPosition(QVector3D(info.position[0], info.position[1], info.position[2])); 452 415 setScale(info.radius + 0.3); // getBoundingSphere() only sees atoms as points, so make the box a bit bigger … … 455 418 void GLMoleculeObject_molecule::resetAtoms() 456 419 { 457 const atoms_t atoms = PresentAtoms.get();420 const atoms_t atoms = getPresentAtoms(); 458 421 std::vector<atomId_t> InsertedAtoms; 459 422 std::vector<atomId_t> RemovedAtoms; … … 479 442 void GLMoleculeObject_molecule::resetIndex() 480 443 { 481 const atomId_t newId = MolIndex.get();444 const atomId_t newId = getMolIndex(); 482 445 const size_t oldId = objectId(); 483 446 ASSERT( newId != oldId, … … 544 507 // remove owner: no more signOff needed 545 508 owner = NULL; 509 510 countsubjectKilled(); 546 511 } 547 512 548 513 void GLMoleculeObject_molecule::recieveNotification(Observable *publisher, Notification_ptr notification) 549 514 { 550 const molecule * const _molecule = getMolecule( MolIndex.get());515 const molecule * const _molecule = getMolecule(getMolIndex()); 551 516 // when molecule is NULL we will soon get destroyed anyway 552 517 if (_molecule == NULL) … … 556 521 #ifdef LOG_OBSERVER 557 522 observerLog().addMessage() << "++ Update of Observer "<< observerLog().getName(static_cast<Observer *>(this)) 558 << " received notification from molecule " << MolIndex.get() << " for channel "523 << " received notification from molecule " << getMolIndex() << " for channel " 559 524 << notification->getChannelNo() << "."; 560 525 #endif … … 577 542 observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+" has been removed."; 578 543 #endif 579 emit AtomRemoved(_id);580 544 emit TesselationHullChanged(); 581 545 emit BoundingBoxChanged(); … … 719 683 connect (atomObject, SIGNAL(BondsRemoved(const atomId_t, const atomId_t)), this, SLOT(bondRemoved(const atomId_t, const atomId_t))); 720 684 connect (atomObject, SIGNAL(indexChanged(GLMoleculeObject_atom*, const atomId_t, const atomId_t)), this, SLOT(changeAtomId(GLMoleculeObject_atom*, const atomId_t, const atomId_t))); 685 connect (atomObject, SIGNAL(InstanceRemoved(const atomId_t)), this, SIGNAL(AtomRemoved(const atomId_t))); 721 686 722 687 if (m_objectId == -1) … … 773 738 if (moleculeObject == this){ 774 739 // Propagate signal. 775 emit hoverChanged( MolIndex.get(), 0);740 emit hoverChanged(getMolIndex(), 0); 776 741 } 777 742 } … … 871 836 void GLMoleculeObject_molecule::wasClicked() 872 837 { 873 LOG(4, "INFO: GLMoleculeObject_molecule: atom " << MolIndex.get() << " has been clicked");874 emit moleculeClicked( MolIndex.get());838 LOG(4, "INFO: GLMoleculeObject_molecule: atom " << getMolIndex() << " has been clicked"); 839 emit moleculeClicked(getMolIndex()); 875 840 } 876 841 … … 906 871 return mol; 907 872 } 873 874 void GLMoleculeObject_molecule::countsubjectKilled() 875 { 876 ++subjectKilledCount; 877 878 if (subjectKilledCount > ObservedValues.size()) 879 emit InstanceRemoved(getMolIndex()); 880 } 881 882 void GLMoleculeObject_molecule::initObservedValues(const moleculeId_t _molid) 883 { 884 // fill ObservedValues 885 boost::function<void()> subjectKilled = 886 boost::bind(&GLMoleculeObject_molecule::countsubjectKilled, this); 887 ObservedValues[MolIndex] = new ObservedValue_wCallback<moleculeId_t>( 888 molref, 889 MolIndexUpdater, 890 "MoleculeIndex_"+toString(_molid), 891 _molid, 892 IndexChannels, 893 subjectKilled); 894 ObservedValues[MolName] = new ObservedValue_wCallback<std::string>( 895 molref, 896 MolNameUpdater, 897 "MoleculeName_"+toString(_molid), 898 updateName(), 899 NameChannels, 900 subjectKilled); 901 ObservedValues[BoundingBox] = new ObservedValue_wCallback<molecule::BoundingBoxInfo>( 902 molref, 903 BoundingBoxUpdater, 904 "MoleculeBoundingBox_"+toString(_molid), 905 initBoundingBox(), 906 BoundingBoxChannels, 907 subjectKilled); 908 ObservedValues[PresentAtoms] = new ObservedValue_wCallback<atoms_t>( 909 molref, 910 PresentAtomsUpdater, 911 "MoleculeAtoms_"+toString(_molid), 912 updateAtoms(), 913 AtomsChannels, 914 subjectKilled); 915 } 916 917 void GLMoleculeObject_molecule::destroyObservedValues() 918 { 919 delete boost::any_cast<ObservedValue_wCallback<moleculeId_t> *>(ObservedValues[MolIndex]); 920 delete boost::any_cast<ObservedValue_wCallback<std::string> *>(ObservedValues[MolName]); 921 delete boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo> *>(ObservedValues[BoundingBox]); 922 delete boost::any_cast<ObservedValue_wCallback<atoms_t> *>(ObservedValues[PresentAtoms]); 923 ObservedValues.clear(); 924 } 925 926 moleculeId_t GLMoleculeObject_molecule::getMolIndex() const 927 { 928 return boost::any_cast<ObservedValue_wCallback<moleculeId_t> *>(ObservedValues[MolIndex])->get(); 929 } 930 931 std::string GLMoleculeObject_molecule::getMolName() const 932 { 933 return boost::any_cast<ObservedValue_wCallback<std::string> *>(ObservedValues[MolName])->get(); 934 } 935 936 molecule::BoundingBoxInfo GLMoleculeObject_molecule::getBoundingBox() const 937 { 938 return boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo> *>(ObservedValues[BoundingBox])->get(); 939 } 940 941 GLMoleculeObject_molecule::atoms_t GLMoleculeObject_molecule::getPresentAtoms() const 942 { 943 return boost::any_cast<ObservedValue_wCallback<atoms_t> *>(ObservedValues[PresentAtoms])->get(); 944 }
Note:
See TracChangeset
for help on using the changeset viewer.