Changeset 1b07b1 for src/UIElements
- Timestamp:
- Feb 14, 2016, 12:34:28 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:
- 62a0ee
- Parents:
- e7ed12
- git-author:
- Frederik Heber <heber@…> (01/06/16 17:34:22)
- git-committer:
- Frederik Heber <heber@…> (02/14/16 12:34:28)
- Location:
- src/UIElements
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.cpp
re7ed12 r1b07b1 75 75 _1)), 76 76 lastremovedatom((atomId_t)-1), 77 lastremovedatomsmolecule( std::make_pair((moleculeId_t)-1,(atomId_t)-1) ),78 77 lastremovedmolecule((moleculeId_t)-1) 79 78 { … … 169 168 MoleculeSignedOn.insert( static_cast<Observable *>(const_cast<molecule *>(_molecule)) ); 170 169 171 emit moleculeInserted( _id);170 emit moleculeInserted(observedmolecule); 172 171 } else { 173 172 ELOG(1, "QtObservedInstanceBoard got MoleculeInserted for unknown molecule id " << _id); … … 206 205 _atom->signOn(this, atom::IndexChanged); 207 206 AtomSignedOn.insert( static_cast<Observable *>(const_cast<atom *>(_atom)) ); 208 emit atomInserted(observedatom ->getAtomMoleculeIndex(), observedatom->getAtomIndex());207 emit atomInserted(observedatom); 209 208 } else { 210 209 ELOG(1, "QtObservedInstanceBoard got AtomInserted for unknown atom id " << _id); … … 227 226 const moleculeId_t molid = const_cast<const World &>(World::getInstance()).lastChangedMolId(); 228 227 switch (notification->getChannelNo()) { 229 case molecule::AtomInserted:230 {231 const molecule * const _molecule = const_cast<const World &>(World::getInstance()).232 getMolecule(MoleculeById(molid));233 if (_molecule != NULL) {234 const atomId_t atomid = const_cast<const molecule *>(_molecule)->lastChangedAtomId();235 LOG(3, "DEBUG: InformationBoard got AtomInserted signal for atom "236 << atomid << " from molecule " << molid);237 // check whether atom's observedvalues are present238 ASSERT( atomObservedValues.isPresent(atomid),239 "QtObservedInstanceBoard::recieveNotification() - ObservedValues for atom "240 +toString(atomid)+" are not present yet.");241 // and emit242 emit atomInserted(molid, atomid);243 } else {244 ELOG(2, "QtObservedInstanceBoard::recieveNotification() - molecule "245 << molid << " has disappeared.");246 }247 break;248 }249 case molecule::AtomRemoved:250 {251 const molecule * const _molecule = const_cast<const World &>(World::getInstance()).252 getMolecule(MoleculeById(molid));253 if (_molecule != NULL) {254 const atomId_t atomid = const_cast<const molecule *>(_molecule)->lastChangedAtomId();255 LOG(3, "DEBUG: InformationBoard got AtomRemoved signal for atom "256 << atomid << " from molecule " << molid);257 lastremovedatomsmolecule = std::make_pair(molid, atomid);258 }259 break;260 }261 228 case molecule::IndexChanged: 262 229 { … … 293 260 "QtObservedInstanceBoard::recieveNotification() - cannot change atom's id " 294 261 +toString(oldatomId)+" "+toString(newatomId)+" in atomObservedValues."); 295 // changed insertion delayed296 atomInsertionDelayed_t::iterator iter = atomInsertionDelayed.find(oldatomId);297 if (iter != atomInsertionDelayed.end()) {298 const moleculeId_t molid = iter->second;299 atomInsertionDelayed.erase(iter);300 #ifndef NDEBUG301 std::pair<atomInsertionDelayed_t::iterator, bool> inserter =302 #endif303 atomInsertionDelayed.insert( std::make_pair(newatomId, molid) );304 ASSERT( inserter.second,305 "QtObservedInstanceBoard::recieveNotification() - id "306 +toString(newatomId)+" already present in atomInsertionDelayed.");307 }308 262 // no need update SignedOn, ref does not change 309 263 emit atomIndexChanged(oldatomId, newatomId); … … 321 275 void QtObservedInstanceBoard::atomcountsubjectKilled(const atomId_t _atomid) 322 276 { 323 if ((_atomid == lastremovedatom smolecule.second) && (_atomid == lastremovedatom)) {277 if ((_atomid == lastremovedatom)) { 324 278 LOG(3, "DEBUG: InstanceBoard emits atomRemoved for " << _atomid); 325 emit atomRemoved(lastremovedatom smolecule.first, lastremovedatomsmolecule.second);279 emit atomRemoved(lastremovedatom); 326 280 } else 327 281 ELOG(2, "QtObservedInstanceBoard::atomcountsubjectKilled() - id " << _atomid 328 << " not fitting with " << lastremovedatom smolecule << " or " << lastremovedatom);282 << " not fitting with " << lastremovedatom); 329 283 } 330 284 -
src/UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.hpp
re7ed12 r1b07b1 89 89 90 90 signals: 91 void atomInserted( const moleculeId_t _molid, const atomId_t _atomid);92 void atomRemoved(const moleculeId_t _molid, constatomId_t _atomid);91 void atomInserted(QtObservedAtom::ptr _atom); 92 void atomRemoved(const atomId_t _atomid); 93 93 void atomIndexChanged(const atomId_t _oldid, const atomId_t _newid); 94 void moleculeInserted( const moleculeId_t _molid);94 void moleculeInserted(QtObservedMolecule::ptr _mol); 95 95 void moleculeRemoved(const moleculeId_t _molid); 96 96 void moleculeIndexChanged(const moleculeId_t _oldid, const moleculeId_t _newid); … … 143 143 atomId_t lastremovedatom; 144 144 145 //!> note down atom id of last removed atom to drop its ObservedValues146 std::pair<moleculeId_t, atomId_t> lastremovedatomsmolecule;147 148 145 //!> note down molecule id of last removed molecule to drop its ObservedValues 149 146 moleculeId_t lastremovedmolecule; -
src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.cpp
re7ed12 r1b07b1 201 201 { 202 202 const atomId_t _id = _molecule->lastChangedAtomId(); 203 QtObservedAtom::ptr _atom = board.getObservedAtom(_id); 203 204 emit atomcountChanged(); 204 emit atomInserted(_ id);205 emit atomInserted(_atom); 205 206 emit bondcountChanged(); 206 207 emit boundingboxChanged(); -
src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp
re7ed12 r1b07b1 28 28 #include "UIElements/Qt4/InstanceBoard/ObservedValue_types.hpp" 29 29 #include "UIElements/Qt4/InstanceBoard/ObservedValuesContainer.hpp" 30 #include "UIElements/Qt4/InstanceBoard/QtObservedAtom.hpp" 30 31 #include "types.hpp" 31 32 … … 146 147 void tesselationhullChanged(); 147 148 void boundingboxChanged(); 148 void atomInserted( const atomId_t);149 void atomInserted(QtObservedAtom::ptr); 149 150 void atomRemoved(const atomId_t); 150 151 void moleculeRemoved(); -
src/UIElements/Views/Qt4/MoleculeList/QtMoleculeList.cpp
re7ed12 r1b07b1 82 82 connect(this,SIGNAL(itemChanged(QStandardItem*)),this,SLOT(moleculeNameChanged(QStandardItem*))); 83 83 connect(this, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(checkForVisibilityChange(QStandardItem*))); 84 connect(board, SIGNAL(moleculeInserted( const moleculeId_t)), this, SLOT(moleculeInserted(const moleculeId_t)));84 connect(board, SIGNAL(moleculeInserted(QtObservedMolecule::ptr)), this, SLOT(moleculeInserted(QtObservedMolecule::ptr))); 85 85 connect(board, SIGNAL(moleculeRemoved(const moleculeId_t)), this, SLOT(moleculeRemoved(const moleculeId_t))); 86 86 connect(board, SIGNAL(moleculeIndexChanged(const moleculeId_t,const moleculeId_t)), … … 102 102 } 103 103 104 void QtMoleculeList::moleculeInserted( const moleculeId_t _id)104 void QtMoleculeList::moleculeInserted(QtObservedMolecule::ptr _mol) 105 105 { 106 106 // get ObservedMolecule from board 107 107 boost::recursive_mutex::scoped_lock lock(listAccessing_mutex); 108 newMolecules.push_back( _ id);108 newMolecules.push_back( _mol ); 109 109 } 110 110 … … 678 678 list_of_group_items_t visibilityGroupItems_copy = visibilityGroupItems; 679 679 visibilityGroupItems.clear(); 680 std::vector< moleculeId_t> newMolecules_copy = newMolecules;680 std::vector<QtObservedMolecule::ptr> newMolecules_copy = newMolecules; 681 681 newMolecules.clear(); 682 682 std::vector<moleculeId_t> removedMolecules_copy = removedMolecules; … … 784 784 785 785 /// 4. instantiate all new items 786 for (std::vector< moleculeId_t>::iterator moliter = newMolecules_copy.begin();786 for (std::vector<QtObservedMolecule::ptr>::iterator moliter = newMolecules_copy.begin(); 787 787 moliter != newMolecules_copy.end(); ++moliter) { 788 QtObservedMolecule::ptr ObservedMolecule = board->getObservedMolecule(*moliter); 789 if (ObservedMolecule) { 790 // LOG(1, "Adding molecule " << ObservedMolecule->getMoleculeName()); 791 // check that World knows the molecule still 792 const std::string formula = addMolecule(ObservedMolecule); 793 // LOG(1, "Adding " << formula << " to toBeSetOccurrence."); 794 toBeSetOccurrence.insert( formula ); 795 } 788 // LOG(1, "Adding molecule " << ObservedMolecule->getMoleculeName()); 789 // check that World knows the molecule still 790 const std::string formula = addMolecule(*moliter); 791 // LOG(1, "Adding " << formula << " to toBeSetOccurrence."); 792 toBeSetOccurrence.insert( formula ); 796 793 } 797 794 -
src/UIElements/Views/Qt4/MoleculeList/QtMoleculeList.hpp
re7ed12 r1b07b1 65 65 66 66 private slots: 67 void moleculeInserted( const moleculeId_t _id);67 void moleculeInserted(QtObservedMolecule::ptr _mol); 68 68 void moleculeRemoved(const moleculeId_t _id); 69 69 void moleculeIndexChanged(const moleculeId_t _oldid, const moleculeId_t _newid); … … 155 155 list_of_group_items_t visibilityGroupItems; 156 156 //!> list of new molecules which need to be added 157 std::vector< moleculeId_t> newMolecules;157 std::vector<QtObservedMolecule::ptr> newMolecules; 158 158 //!> list of molecules that have been removed 159 159 std::vector<moleculeId_t> removedMolecules; -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.cpp
re7ed12 r1b07b1 58 58 QGLSceneNode *mesh[], 59 59 QObject *parent, 60 QtObservedAtom::ptr _ObservedAtom) :60 QtObservedAtom::ptr &_ObservedAtom) : 61 61 GLMoleculeObject(mesh, parent), 62 62 ObservedAtom(_ObservedAtom) -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.hpp
re7ed12 r1b07b1 35 35 QGLSceneNode *mesh[], 36 36 QObject *parent, 37 QtObservedAtom::ptr _ObservedAtom37 QtObservedAtom::ptr &_ObservedAtom 38 38 ); 39 39 virtual ~GLMoleculeObject_atom(); -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.cpp
re7ed12 r1b07b1 84 84 QObject *parent, 85 85 QtObservedInstanceBoard &_board, 86 QtObservedMolecule::ptr _ObservedMolecule) :86 QtObservedMolecule::ptr &_ObservedMolecule) : 87 87 GLMoleculeObject((QGLSceneNode *)NULL, parent), 88 88 owner(NULL), … … 99 99 QObject *parent, 100 100 QtObservedInstanceBoard &_board, 101 QtObservedMolecule::ptr _ObservedMolecule) :101 QtObservedMolecule::ptr &_ObservedMolecule) : 102 102 GLMoleculeObject(mesh, parent), 103 103 owner(NULL), … … 125 125 connect (ObservedMolecule.get(), SIGNAL(boundingboxChanged()), this, SLOT(resetBoundingBox())); 126 126 connect (ObservedMolecule.get(), SIGNAL(indexChanged()), this, SLOT(resetIndex())); 127 connect (ObservedMolecule.get(), SIGNAL(atomInserted( const atomId_t)), this, SLOT(atomInserted(const atomId_t)));127 connect (ObservedMolecule.get(), SIGNAL(atomInserted(QtObservedAtom::ptr)), this, SLOT(atomInserted(QtObservedAtom::ptr))); 128 128 connect (ObservedMolecule.get(), SIGNAL(atomRemoved(const atomId_t)), this, SLOT(atomRemoved(const atomId_t))); 129 129 connect (ObservedMolecule.get(), SIGNAL(selectedChanged()), this, SLOT(resetSelected())); … … 357 357 * @param _atom atom to add 358 358 */ 359 void GLMoleculeObject_molecule::atomInserted( const atomId_t _id)360 { 361 LOG(3, "INFO: GLMoleculeObject_molecule: Received signal atomInserted for atom "+toString(_id)+".");362 363 const QtObservedAtom::ptr _atom = board.getObservedAtom(_id); 359 void GLMoleculeObject_molecule::atomInserted(QtObservedAtom::ptr _atom) 360 { 361 const atomId_t atomid = _atom->getAtomIndex(); 362 LOG(3, "INFO: GLMoleculeObject_molecule: Received signal atomInserted for atom "+toString(atomid)+"."); 363 364 364 if (_atom) { 365 365 GLMoleculeObject_atom *atomObject = … … 369 369 _atom); 370 370 ASSERT( atomObject != NULL, 371 "GLMoleculeObject_molecule::atomInserted - could not create atom object for "+toString( _id));372 AtomNodeMap::iterator iter = AtomsinSceneMap.find( _id);371 "GLMoleculeObject_molecule::atomInserted - could not create atom object for "+toString(atomid)); 372 AtomNodeMap::iterator iter = AtomsinSceneMap.find(atomid); 373 373 ASSERT(iter == AtomsinSceneMap.end(), 374 "GLMoleculeObject_molecule::atomInserted - same atom with id "+toString( _id)+" added again.");375 AtomsinSceneMap.insert( make_pair( _id, atomObject) );374 "GLMoleculeObject_molecule::atomInserted - same atom with id "+toString(atomid)+" added again."); 375 AtomsinSceneMap.insert( make_pair(atomid, atomObject) ); 376 376 377 377 qRegisterMetaType<atomId_t>("atomId_t"); … … 387 387 388 388 if (m_objectId == -1) 389 setObjectId( _id);389 setObjectId(atomid); 390 390 391 391 emit changed(); -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.hpp
re7ed12 r1b07b1 45 45 QObject *parent, 46 46 QtObservedInstanceBoard &_board, 47 QtObservedMolecule::ptr _ObservedMolecule);47 QtObservedMolecule::ptr &_ObservedMolecule); 48 48 GLMoleculeObject_molecule( 49 49 QGLSceneNode *mesh[], 50 50 QObject *parent, 51 51 QtObservedInstanceBoard &_board, 52 QtObservedMolecule::ptr _ObservedMolecule);52 QtObservedMolecule::ptr &_ObservedMolecule); 53 53 virtual ~GLMoleculeObject_molecule(); 54 54 … … 78 78 79 79 void wasClicked(); 80 void atomInserted( const atomId_t _id);80 void atomInserted(QtObservedAtom::ptr _atom); 81 81 void atomRemoved(const atomId_t _id); 82 82 void bondInserted(const atomId_t, const atomId_t, const GLMoleculeObject_bond::SideOfBond side); -
src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp
re7ed12 r1b07b1 93 93 GLMoleculeObject::meshCylinder[i]->setOption(QGLSceneNode::CullBoundingBox, true); 94 94 } 95 connect(board, SIGNAL(moleculeInserted( const moleculeId_t)),96 this, SLOT(moleculeInserted( const moleculeId_t)));95 connect(board, SIGNAL(moleculeInserted(QtObservedMolecule::ptr)), 96 this, SLOT(moleculeInserted(QtObservedMolecule::ptr))); 97 97 connect(board, SIGNAL(moleculeRemoved(const moleculeId_t)), 98 98 this, SLOT(moleculeRemoved(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( const moleculeId_t, const atomId_t)),102 this, SLOT(atomInserted( const moleculeId_t, const atomId_t)), Qt::DirectConnection);101 connect(board, SIGNAL(atomInserted(QtObservedAtom::ptr)), 102 this, SLOT(atomInserted(QtObservedAtom::ptr))); 103 103 connect(board, SIGNAL(atomRemoved(const moleculeId_t, const atomId_t)), 104 this, SLOT(atomRemoved(const moleculeId_t, const atomId_t)) , Qt::DirectConnection);104 this, SLOT(atomRemoved(const moleculeId_t, const atomId_t))); 105 105 106 106 // connect(this, SIGNAL(updated()), this, SLOT(update())); … … 156 156 * @param _atomid atom to insert 157 157 */ 158 void GLWorldScene::atomInserted(const moleculeId_t _molid, const atomId_t _atomid) 159 { 160 boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex); 161 162 LOG(3, "INFO: GLWorldScene: Received signal atomInserted for atom "+toString(_atomid)+"."); 158 void GLWorldScene::atomInserted(QtObservedAtom::ptr _atom) 159 { 160 ASSERT (_atom, 161 "GLWorldScene::moleculeInserted() - received shared_ptr for atom is empty?"); 162 const atomId_t atomid = _atom->getAtomIndex(); 163 const atomId_t molid = _atom->getAtomMoleculeIndex(); 164 LOG(3, "INFO: GLWorldScene: Received signal atomInserted for atom "+toString(atomid)+"."); 163 165 164 166 // check of molecule is already present 165 MoleculeNodeMap::iterator moliter = MoleculesinSceneMap.find( _molid);167 MoleculeNodeMap::iterator moliter = MoleculesinSceneMap.find(molid); 166 168 if (moliter != MoleculesinSceneMap.end()) { 167 169 // no action, is also caught via QtObservedMolecule by GLMoleculeObject_molecule 168 170 } else { 169 171 // store signal for when it is instantiated 170 if (MoleculeMissedStateMap.count(_molid) == 0) 171 MoleculeMissedStateMap.insert( std::make_pair(_molid ,StateChangeMap_t()) ); 172 MoleculeMissedStateMap[_molid].insert( std::make_pair(_atomid, atomInsertedState) ); 172 if (MoleculeMissedStateMap.count(molid) == 0) 173 MoleculeMissedStateMap.insert( std::make_pair(molid ,StateChangeMap_t()) ); 174 MoleculeMissedStateMap[molid].insert( std::make_pair(atomid, atomInsertedState) ); 175 QtObservedAtomMap[atomid] = _atom; 176 LOG(3, "INFO: GLWorldScene: Placing atomInserted for atom " << atomid 177 << " and molecule " << molid << " into missed state map."); 173 178 } 174 179 } … … 194 199 MoleculeMissedStateMap.insert( std::make_pair(_molid ,StateChangeMap_t()) ); 195 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."); 196 203 } 197 204 } … … 201 208 * @param _mol molecule to insert 202 209 */ 203 void GLWorldScene::moleculeInserted(const moleculeId_t _id) 204 { 205 LOG(3, "INFO: GLWorldScene: Received signal moleculeInserted for molecule "+toString(_id)+"."); 210 void GLWorldScene::moleculeInserted(QtObservedMolecule::ptr _mol) 211 { 212 ASSERT (_mol, 213 "GLWorldScene::moleculeInserted() - received shared_ptr for molecule is empty?"); 214 const moleculeId_t molid = _mol->getMolIndex(); 215 LOG(3, "INFO: GLWorldScene: Received signal moleculeInserted for molecule "+toString(molid)+"."); 206 216 207 217 boost::recursive_mutex::scoped_lock lock(MoleculeinSceneMap_mutex); 208 218 209 MoleculeNodeMap::const_iterator iter = MoleculesinSceneMap.find( _id);219 MoleculeNodeMap::const_iterator iter = MoleculesinSceneMap.find(molid); 210 220 ASSERT( iter == MoleculesinSceneMap.end(), 211 "GLWorldScene::moleculeInserted() - molecule's id "+toString( _id)+" already present.");221 "GLWorldScene::moleculeInserted() - molecule's id "+toString(molid)+" already present."); 212 222 213 223 // check whether molecule is still present 214 if (RemovalMolecules.count( _id) != 0) {215 RemovalMolecules.erase( _id);224 if (RemovalMolecules.count(molid) != 0) { 225 RemovalMolecules.erase(molid); 216 226 return; 217 227 } 218 if (const_cast<const World &>(World::getInstance()).getMolecule(MoleculeById(_id)) == NULL) {219 ELOG(2, "Molecule with id " << _id << " has disappeared.");220 return;221 }222 228 223 229 // add new object 224 LOG(1, "DEBUG: Adding GLMoleculeObject_molecule to id " << _id); 225 const QtObservedMolecule::ptr mol = board->getObservedMolecule(_id); 226 if (mol) { 227 GLMoleculeObject_molecule *molObject = 228 new GLMoleculeObject_molecule( 229 GLMoleculeObject::meshEmpty, 230 this, 231 *board, 232 mol); 233 ASSERT( molObject != NULL, 234 "GLWorldScene::moleculeInserted - could not create molecule object for "+toString(_id)); 235 MoleculesinSceneMap.insert( make_pair(_id, molObject) ); 236 237 // now handle all state changes that came up before the instantiation 238 while (MoleculeMissedStateMap.count(_id) != 0) { 239 // ASSERT( !MoleculeMissedStateMap[_id].empty(), 230 LOG(1, "DEBUG: Adding GLMoleculeObject_molecule to id " << molid); 231 GLMoleculeObject_molecule *molObject = 232 new GLMoleculeObject_molecule( 233 GLMoleculeObject::meshEmpty, 234 this, 235 *board, 236 _mol); 237 ASSERT( molObject != NULL, 238 "GLWorldScene::moleculeInserted - could not create molecule object for "+toString(molid)); 239 #ifndef NDEBUG 240 std::pair<MoleculeNodeMap::iterator, bool> inserter = 241 #endif 242 MoleculesinSceneMap.insert( make_pair(molid, molObject) ); 243 ASSERT(inserter.second, 244 "GLWorldScene::moleculeInserted() - molecule "+toString(molid)+" already present in scene."); 245 246 // now handle all state changes that came up before the instantiation 247 if (MoleculeMissedStateMap.count(molid) != 0) { 248 // ASSERT( !MoleculeMissedStateMap[molid].empty(), 240 249 // "GLWorldScene::moleculeInserted() - we have an empty state change map for molecule with id " 241 // +toString(_id)); 242 boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex); 243 for (StateChangeMap_t::iterator iter = MoleculeMissedStateMap[_id].begin(); 244 !MoleculeMissedStateMap[_id].empty(); 245 iter = MoleculeMissedStateMap[_id].begin()) { 246 std::pair<StateChangeMap_t::iterator, StateChangeMap_t::iterator> rangeiter = 247 MoleculeMissedStateMap[_id].equal_range(iter->first); 248 const size_t StateCounts = std::distance(rangeiter.first, rangeiter.second); 249 if (StateCounts > 1) { 250 // more than one state change, have to combine 251 typedef std::map<StateChangeType, size_t> StateChangeAmounts_t; 252 StateChangeAmounts_t StateChangeAmounts; 253 for (StateChangeMap_t::const_iterator stateiter = rangeiter.first; 254 stateiter != rangeiter.second; ++stateiter) 255 ++StateChangeAmounts[stateiter->second]; 256 ASSERT( StateChangeAmounts[atomInsertedState] >= StateChangeAmounts[atomRemovedState], 257 "GLWorldScene::moleculeInserted() - more atomRemoved states than atomInserted for atom " 258 +toString(iter->first)); 259 if (StateChangeAmounts[atomInsertedState] > StateChangeAmounts[atomRemovedState]) { 250 // +toString(molid)); 251 boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex); 252 for (StateChangeMap_t::iterator iter = MoleculeMissedStateMap[molid].begin(); 253 !MoleculeMissedStateMap[molid].empty(); 254 iter = MoleculeMissedStateMap[molid].begin()) { 255 std::pair<StateChangeMap_t::iterator, StateChangeMap_t::iterator> rangeiter = 256 MoleculeMissedStateMap[molid].equal_range(iter->first); 257 const size_t StateCounts = std::distance(rangeiter.first, rangeiter.second); 258 if (StateCounts > 1) { 259 // more than one state change, have to combine 260 typedef std::map<StateChangeType, size_t> StateChangeAmounts_t; 261 StateChangeAmounts_t StateChangeAmounts; 262 for (StateChangeMap_t::const_iterator stateiter = rangeiter.first; 263 stateiter != rangeiter.second; ++stateiter) 264 ++StateChangeAmounts[stateiter->second]; 265 ASSERT( StateChangeAmounts[atomInsertedState] >= StateChangeAmounts[atomRemovedState], 266 "GLWorldScene::moleculeInserted() - more atomRemoved states " 267 +toString(StateChangeAmounts[atomRemovedState])+" than atomInserted " 268 +toString(StateChangeAmounts[atomInsertedState])+" for atom "+toString(iter->first)); 269 if (StateChangeAmounts[atomInsertedState] > StateChangeAmounts[atomRemovedState]) { 270 LOG(1, "INFO: invoking atomInserted for atom " << iter->first); 271 QMetaObject::invokeMethod(molObject, // pointer to a QObject 272 "atomInserted", // member name (no parameters here) 273 Qt::QueuedConnection, // connection type 274 Q_ARG(QtObservedAtom::ptr, QtObservedAtomMap[iter->first])); // parameters 275 } else { 276 LOG(1, "INFO: Atom " << iter->first << " has been inserted and removed already."); 277 } 278 // removed all state changes for this atom 279 MoleculeMissedStateMap[molid].erase(rangeiter.first, rangeiter.second); 280 } else { 281 // can only be an insertion 282 switch (rangeiter.first->second) { 283 case atomRemovedState: 284 ASSERT( 0, 285 "GLWorldScene::moleculeInserted() - atomRemoved state without atomInserted for atom " 286 +toString(iter->first)); 287 break; 288 case atomInsertedState: 289 { 260 290 LOG(1, "INFO: invoking atomInserted for atom " << iter->first); 261 291 QMetaObject::invokeMethod(molObject, // pointer to a QObject 262 292 "atomInserted", // member name (no parameters here) 263 293 Qt::QueuedConnection, // connection type 264 Q_ARG(const atomId_t, iter->first)); // parameters 265 } else { 266 LOG(1, "INFO: Atom " << iter->first << " has been inserted and removed already."); 294 Q_ARG(QtObservedAtom::ptr, QtObservedAtomMap[iter->first])); // parameters 295 break; 267 296 } 268 } else { 269 // can only be an insertion 270 switch (rangeiter.first->second) { 271 case atomRemovedState: 272 ASSERT( 0, 273 "GLWorldScene::moleculeInserted() - atomRemoved state without atomInserted for atom " 274 +toString(iter->first)); 275 break; 276 case atomInsertedState: 277 LOG(1, "INFO: invoking atomInserted for atom " << iter->first); 278 QMetaObject::invokeMethod(molObject, // pointer to a QObject 279 "atomInserted", // member name (no parameters here) 280 Qt::QueuedConnection, // connection type 281 Q_ARG(const atomId_t, iter->first)); // parameters 282 break; 283 default: 284 ASSERT( 0, 285 "GLWorldScene::moleculeInserted() - there are unknown change states."); 286 break; 287 } 297 default: 298 ASSERT( 0, 299 "GLWorldScene::moleculeInserted() - there are unknown change states."); 300 break; 288 301 } 289 302 // removed state changes for this atom 290 MoleculeMissedStateMap[ _id].erase(iter);303 MoleculeMissedStateMap[molid].erase(iter); 291 304 } 292 305 } 293 294 connect (molObject, SIGNAL(changed()), this, SIGNAL(changed())); 295 connect (molObject, SIGNAL(changeOccured()), this, SIGNAL(changeOccured()));296 connect (molObject, SIGNAL(atomClicked(atomId_t)), this, SLOT(atomClicked(atomId_t)));297 connect (molObject, SIGNAL(moleculeClicked(moleculeId_t)), this, SLOT(moleculeClicked(moleculeId_t)));298 connect (molObject, SIGNAL(selectionChanged()), this, SIGNAL(changed()));299 300 connect (molObject, SIGNAL(hoverChanged(const atomId_t)), this, SIGNAL(hoverChanged(const atomId_t)));301 connect (molObject, SIGNAL(hoverChanged(const moleculeId_t, int)), this, SIGNAL(hoverChanged(const moleculeId_t, int)));302 303 304 emit changed(); 305 emit changeOccured();306 }306 } 307 308 connect (molObject, SIGNAL(changed()), this, SIGNAL(changed())); 309 connect (molObject, SIGNAL(changeOccured()), this, SIGNAL(changeOccured())); 310 connect (molObject, SIGNAL(atomClicked(atomId_t)), this, SLOT(atomClicked(atomId_t))); 311 connect (molObject, SIGNAL(moleculeClicked(moleculeId_t)), this, SLOT(moleculeClicked(moleculeId_t))); 312 connect (molObject, SIGNAL(selectionChanged()), this, SIGNAL(changed())); 313 connect (molObject, SIGNAL(selectionChanged()), this, SIGNAL(changed())); 314 connect (molObject, SIGNAL(hoverChanged(const atomId_t)), this, SIGNAL(hoverChanged(const atomId_t))); 315 connect (molObject, SIGNAL(hoverChanged(const moleculeId_t, int)), this, SIGNAL(hoverChanged(const moleculeId_t, int))); 316 connect (molObject, SIGNAL(hoverChanged(const moleculeId_t, int)), this, SIGNAL(hoverChanged(const moleculeId_t, int))); 317 318 emit changed(); 319 emit changeOccured(); 307 320 308 321 // remove state change map for the molecule 309 322 { 310 323 boost::recursive_mutex::scoped_lock lock(MoleculeMissedStateMap_mutex); 311 MoleculeMissedStateMap.erase( _id);324 MoleculeMissedStateMap.erase(molid); 312 325 } 313 326 } -
src/UIElements/Views/Qt4/Qt3D/GLWorldScene.hpp
re7ed12 r1b07b1 27 27 #include "types.hpp" 28 28 29 class atom; 30 class molecule; 29 #include "UIElements/Qt4/InstanceBoard/QtObservedAtom.hpp" 30 #include "UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp" 31 31 32 class Shape; 32 33 … … 88 89 void moleculeClicked(moleculeId_t no); 89 90 void moleculeRemoved(const moleculeId_t _id); 90 void moleculeInserted( const moleculeId_t _id);91 void moleculeInserted(QtObservedMolecule::ptr); 91 92 void moleculeIndexChanged(const moleculeId_t _oldid, const moleculeId_t _newid); 92 93 void atomRemoved(const moleculeId_t _molid, const atomId_t _atomid); 93 void atomInserted( const moleculeId_t _molid, const atomId_t _atomid);94 void atomInserted(QtObservedAtom::ptr); 94 95 void setSelectionModeAtom(); 95 96 void setSelectionModeMolecule(); … … 122 123 MAX_StateChangeType 123 124 }; 125 typedef std::map< atomId_t, QtObservedAtom::ptr> QtObservedAtomMap_t; 124 126 typedef std::multimap< atomId_t, StateChangeType> StateChangeMap_t; 125 127 typedef std::map< moleculeId_t, StateChangeMap_t> MoleculeMissedStateMap_t; 126 128 //!> map of all missed state changes 127 129 MoleculeMissedStateMap_t MoleculeMissedStateMap; 130 //!> map to contain all QtObservedAtom that have not been instantiated so far 131 QtObservedAtomMap_t QtObservedAtomMap; 128 132 //!> flag to indicate whether state map is currently worked on 129 133 boost::recursive_mutex MoleculeMissedStateMap_mutex;
Note:
See TracChangeset
for help on using the changeset viewer.