Changeset 8281cc for src/UIElements
- Timestamp:
- Feb 14, 2016, 12:34:29 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:
- 03e69e
- Parents:
- 1c0961
- git-author:
- Frederik Heber <heber@…> (01/07/16 12:00:38)
- git-committer:
- Frederik Heber <heber@…> (02/14/16 12:34:29)
- Location:
- src/UIElements/Views/Qt4/Qt3D
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp
r1c0961 r8281cc 94 94 } 95 95 connect(board, SIGNAL(moleculeInserted(QtObservedMolecule::ptr)), 96 this, SLOT(molecule Inserted(QtObservedMolecule::ptr)));96 this, SLOT(moleculeSignOn(QtObservedMolecule::ptr))); 97 97 connect(board, SIGNAL(moleculeRemoved(const moleculeId_t)), 98 this, SLOT(molecule Removed(const moleculeId_t)));98 this, SLOT(moleculeSignOff(const moleculeId_t))); 99 99 connect(board, SIGNAL(moleculeIndexChanged(const moleculeId_t, const moleculeId_t)), 100 100 this, SLOT(moleculeIndexChanged(const moleculeId_t, const moleculeId_t))); 101 connect( board, SIGNAL(atomInserted(QtObservedAtom::ptr)),102 this, SLOT( atomInserted(QtObservedAtom::ptr)));103 connect( board, SIGNAL(atomRemoved(const moleculeId_t, const atomId_t)),104 this, SLOT( atomRemoved(const moleculeId_t, const atomId_t)));101 connect(this, SIGNAL(insertMolecule(QtObservedMolecule::ptr)), 102 this, SLOT(moleculeInserted(QtObservedMolecule::ptr)) ); 103 connect(this, SIGNAL(removeMolecule(const moleculeId_t)), 104 this, SLOT(moleculeRemoved(const moleculeId_t)) ); 105 105 106 106 // connect(this, SIGNAL(updated()), this, SLOT(update())); … … 174 174 MoleculeMissedStateMap[molid].insert( std::make_pair(atomid, atomInsertedState) ); 175 175 QtObservedAtomMap[atomid] = _atom; 176 connect(_atom.get(), SIGNAL(indexChanged(const atomId_t,const atomId_t)), 177 this, SLOT(atomIndexChanged(const atomId_t,const atomId_t)) ); 176 178 LOG(3, "INFO: GLWorldScene: Placing atomInserted for atom " << atomid 177 179 << " and molecule " << molid << " into missed state map."); … … 184 186 * @param _atomid atom to insert 185 187 */ 186 void GLWorldScene::atomRemoved(const moleculeId_t _molid, const atomId_t _atomid) 187 { 188 void GLWorldScene::atomRemoved(const atomId_t _atomid) 189 { 190 boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex); 191 188 192 LOG(3, "INFO: GLWorldScene: Received signal atomRemoved for atom "+toString(_atomid)+"."); 189 193 190 boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex); 191 192 // check of molecule is already present 193 MoleculeNodeMap::iterator moliter = MoleculesinSceneMap.find(_molid); 194 if (moliter != MoleculesinSceneMap.end()) { 195 // no action, is also caught via QtObservedMolecule by GLMoleculeObject_molecule 196 } else { 197 // store signal for when it is instantiated 198 if (MoleculeMissedStateMap.count(_molid) == 0) 199 MoleculeMissedStateMap.insert( std::make_pair(_molid ,StateChangeMap_t()) ); 200 MoleculeMissedStateMap[_molid].insert( std::make_pair(_atomid, atomRemovedState) ); 201 LOG(3, "INFO: GLWorldScene: Placing atomRemoved for atom " << _atomid 202 << " and molecule " << _molid << " into missed state map."); 203 } 194 // if atom is not in map, then GLMoleculeObject_molecule is already present anyway. 195 if (QtObservedAtomMap.count(_atomid)) { 196 const QtObservedAtom::ptr atom = QtObservedAtomMap[_atomid]; 197 const moleculeId_t molid = atom->getAtomMoleculeIndex(); 198 // check of molecule is already present 199 MoleculeNodeMap::iterator moliter = MoleculesinSceneMap.find(molid); 200 if (moliter != MoleculesinSceneMap.end()) { 201 // no action, is also caught via QtObservedMolecule by GLMoleculeObject_molecule 202 } else { 203 // store signal for when it is instantiated 204 if (MoleculeMissedStateMap.count(molid) == 0) 205 MoleculeMissedStateMap.insert( std::make_pair(molid ,StateChangeMap_t()) ); 206 MoleculeMissedStateMap[molid].insert( std::make_pair(_atomid, atomRemovedState) ); 207 LOG(3, "INFO: GLWorldScene: Placing atomRemoved for atom " << _atomid 208 << " and molecule " << molid << " into missed state map."); 209 } 210 } 211 } 212 213 void GLWorldScene::moleculeSignOn(QtObservedMolecule::ptr _mol) 214 { 215 // sign on to QtObservedMolecule to get atomInserted/..Removed signals from same 216 // source as GLMoleculeObject_molecule would 217 connect(_mol.get(), SIGNAL(atomInserted(QtObservedAtom::ptr)), 218 this, SLOT(atomInserted(QtObservedAtom::ptr)) ); 219 connect(_mol.get(), SIGNAL(atomRemoved(const atomId_t)), 220 this, SLOT(atomRemoved(const atomId_t)) ); 221 const moleculeId_t molid = _mol->getMolIndex(); 222 QtObservedMoleculeMap.insert( std::make_pair(molid, _mol) ); 223 224 LOG(3, "INFO: GLWorldScene: Received signal moleculeSignOn for molecule "+toString(molid)+"."); 225 226 emit insertMolecule(_mol); 227 } 228 229 void GLWorldScene::moleculeSignOff(const moleculeId_t _id) 230 { 231 ASSERT( QtObservedMoleculeMap.count(_id), 232 "GLWorldScene::moleculeSignOff() - cannot find id "+toString(_id)+" in map."); 233 const QtObservedMolecule::ptr mol = QtObservedMoleculeMap[_id]; 234 mol->disconnect(this); 235 QtObservedMoleculeMap.erase(_id); 236 237 LOG(3, "INFO: GLWorldScene: Received signal moleculeSignOff for molecule "+toString(_id)+"."); 238 239 emit removeMolecule(_id); 204 240 } 205 241 … … 289 325 { 290 326 LOG(1, "INFO: invoking atomInserted for atom " << iter->first); 327 const QtObservedAtom::ptr walker = QtObservedAtomMap[iter->first]; 291 328 QMetaObject::invokeMethod(molObject, // pointer to a QObject 292 329 "atomInserted", // member name (no parameters here) … … 357 394 } 358 395 396 void GLWorldScene::atomIndexChanged(const atomId_t _oldid, const atomId_t _newid) 397 { 398 if (QtObservedAtomMap.count(_oldid)) { 399 const QtObservedAtom::ptr atom = QtObservedAtomMap[_oldid]; 400 QtObservedAtomMap.erase(_oldid); 401 QtObservedAtomMap.insert( std::make_pair(_newid, atom) ); 402 } 403 } 404 359 405 void GLWorldScene::moleculeIndexChanged(const moleculeId_t _oldid, const moleculeId_t _newid) 360 406 { … … 367 413 RemovalMolecules.erase(removeiter); 368 414 RemovalMolecules.insert(_newid); 415 if (QtObservedMoleculeMap.count(_oldid)) { 416 const QtObservedMolecule::ptr mol = QtObservedMoleculeMap[_oldid]; 417 QtObservedMoleculeMap.erase(_oldid); 418 QtObservedMoleculeMap.insert( std::make_pair(_newid, mol) ); 419 } 369 420 } else { 370 421 LOG(1, "DEBUG: Changing GLMoleculeObject_molecule from " << _oldid << " to id " << _newid); … … 467 518 } 468 519 469 void GLWorldScene::changeMoleculeId(470 GLMoleculeObject_molecule *ob,471 const moleculeId_t oldId,472 const moleculeId_t newId)473 {474 LOG(3, "INFO: GLWorldScene - change molecule id " << oldId << " to " << newId << ".");475 476 {477 boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex);478 // Remove from map.479 MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(oldId);480 ASSERT(iter != MoleculesinSceneMap.end(),481 "GLWorldScene::changeMoleculeId() - molecule with old id "+toString(oldId)+" not on display.");482 ASSERT(iter->second == ob,483 "GLWorldScene::changeMoleculeId() - molecule with id "484 +toString(oldId)+" does not match with object in MoleculesinSceneMap.");485 MoleculesinSceneMap.erase(iter);486 487 // Reinsert with new id.488 {489 MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(newId);490 ASSERT(iter == MoleculesinSceneMap.end(),491 "GLWorldScene::changeMoleculeId() - moleculewith new id "+toString(newId)+" already known.");492 }493 MoleculesinSceneMap.insert( make_pair(newId, ob) );494 }495 496 {497 boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex);498 // Remove and re-insert from map if present.499 MoleculeMissedStateMap_t::iterator iter = MoleculeMissedStateMap.find(oldId);500 if (iter != MoleculeMissedStateMap.end()) {501 StateChangeMap_t changemap = iter->second;502 MoleculeMissedStateMap.erase(iter);503 MoleculeMissedStateMap.insert( std::make_pair(newId, changemap) );504 }505 }506 }507 -
src/UIElements/Views/Qt4/Qt3D/GLWorldScene.hpp
r1c0961 r8281cc 84 84 void hoverChanged(const atomId_t); 85 85 void hoverChanged(const moleculeId_t, int); 86 void insertMolecule(QtObservedMolecule::ptr); 87 void removeMolecule(const moleculeId_t); 86 88 87 89 private slots: … … 89 91 void moleculeClicked(moleculeId_t no); 90 92 void moleculeRemoved(const moleculeId_t _id); 93 void moleculeSignOff(const moleculeId_t _id); 91 94 void moleculeInserted(QtObservedMolecule::ptr); 95 void moleculeSignOn(QtObservedMolecule::ptr); 92 96 void moleculeIndexChanged(const moleculeId_t _oldid, const moleculeId_t _newid); 93 void atomRemoved(const moleculeId_t _molid, constatomId_t _atomid);97 void atomRemoved(const atomId_t _atomid); 94 98 void atomInserted(QtObservedAtom::ptr); 99 void atomIndexChanged(const atomId_t _oldid, const atomId_t _newid); 95 100 void setSelectionModeAtom(); 96 101 void setSelectionModeMolecule(); … … 99 104 // void update(); 100 105 void moleculesVisibilityChanged(const moleculeId_t _id, bool _visible); 101 void changeMoleculeId(GLMoleculeObject_molecule *, const moleculeId_t, const moleculeId_t);102 106 103 107 public: … … 124 128 }; 125 129 typedef std::map< atomId_t, QtObservedAtom::ptr> QtObservedAtomMap_t; 130 typedef std::map< moleculeId_t, QtObservedMolecule::ptr> QtObservedMoleculeMap_t; 126 131 typedef std::multimap< atomId_t, StateChangeType> StateChangeMap_t; 127 132 typedef std::map< moleculeId_t, StateChangeMap_t> MoleculeMissedStateMap_t; … … 130 135 //!> map to contain all QtObservedAtom that have not been instantiated so far 131 136 QtObservedAtomMap_t QtObservedAtomMap; 137 //!> map to contain all QtObservedMolecule that have not been instantiated so far 138 QtObservedMoleculeMap_t QtObservedMoleculeMap; 132 139 //!> flag to indicate whether state map is currently worked on 133 140 boost::recursive_mutex MoleculeMissedStateMap_mutex;
Note:
See TracChangeset
for help on using the changeset viewer.