Ignore:
Timestamp:
Jul 24, 2015, 4:44:35 PM (9 years ago)
Author:
Frederik Heber <heber@…>
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:
28864c
Parents:
8d3ee6
git-author:
Frederik Heber <heber@…> (06/02/15 17:11:15)
git-committer:
Frederik Heber <heber@…> (07/24/15 16:44:35)
Message:

Removed lots of code in GLWorldScene that now resides in GLMoleculeObject_molecule.

  • atoms and their bonds are now controlled by the latter.
Location:
src/UIElements/Views/Qt4/Qt3D
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp

    r8d3ee6 rd619338  
    176176}
    177177
    178 
    179 /** Adds an atom to the scene.
    180  *
    181  * @param _atom atom to add
    182  */
    183 void GLWorldScene::atomInserted(const atomId_t _id)
    184 {
    185   LOG(3, "INFO: GLWorldScene: Received signal atomInserted for atom "+toString(_id)+".");
    186   // find associated molecule
    187   const atom * const _atom = const_cast<const World &>(World::getInstance()).
    188       getAtom(AtomById(_id));
    189   if (_atom != NULL) {
    190     const moleculeId_t molid = _atom->getMolecule()->getId();
    191     MoleculeNodeMap::const_iterator moliter = MoleculesinSceneMap.find(molid );
    192     ASSERT(moliter != MoleculesinSceneMap.end(),
    193         "GLWorldScene::atomAdded() - molecule with id of "+toString(molid)
    194         +" atom with id "+toString(_id)+" is unknown.");
    195     GLMoleculeObject_molecule *molObject = moliter->second;
    196 
    197     // add atom to internal list
    198 #ifndef NDEBUG
    199     AtomMoleculeMap::const_iterator atomiter = AtomsinSceneMap.find(_id);
    200       ASSERT(atomiter == AtomsinSceneMap.end(),
    201           "GLWorldScene::atomRemoved() - atom "+toString(_id)+" already known.");
    202 #endif
    203     AtomsinSceneMap.insert( std::make_pair( _id, molObject ));
    204 
    205     // inform its GlMoleculeObject_molecule.
    206     molObject->atomInserted(_id);
    207 
    208     // emit change
    209     emit changeOccured();
    210   } else {
    211     ELOG(1, "GLWorldScene::atomInserted() - added NULL molobject to AtomsinSceneMap for id " << _id);
    212     GLMoleculeObject_molecule *molObject = NULL;
    213     AtomsinSceneMap.insert( std::make_pair( _id, molObject ));
    214   }
    215 }
    216 
    217 /** Removes an atom from the scene.
    218  *
    219  * We just the id as the atom might have already been destroyed.
    220  *
    221  * @param _id id of atom to remove
    222  */
    223 void GLWorldScene::atomRemoved(const atomId_t _id)
    224 {
    225   LOG(3, "INFO: GLWorldScene: Received signal atomRemoved for atom "+toString(_id)+".");
    226   // find associated molecule
    227   AtomMoleculeMap::iterator iter = AtomsinSceneMap.find(_id);
    228   ASSERT(iter != AtomsinSceneMap.end(),
    229       "GLWorldScene::atomRemoved() - atom "+toString(_id)+" not on display.");
    230   GLMoleculeObject_molecule *molObject = iter->second;
    231 
    232   // remove from internal list
    233   AtomsinSceneMap.erase(iter);
    234 
    235   // inform its GlMoleculeObject_molecule.
    236   molObject->atomRemoved(_id);
    237 
    238   // emit change
    239   emit changeOccured();
    240 }
    241 
    242178/** ....
    243179 *
     
    331267}
    332268
    333 /** Adds a bond to the scene.
    334  *
    335  * @param _bond bond to add
    336  * @param side which side of the bond (left or right)
    337  */
    338 void GLWorldScene::bondInserted(const bond::ptr _bond, const enum GLMoleculeObject_bond::SideOfBond _side)
    339 {
    340   LOG(3, "INFO: GLWorldScene::bondInserted() - Adding bond "+toString(*_bond)+".");
    341   //LOG(4, "INFO: Currently present bonds " << BondsinSceneMap << ".");
    342   // bond partners must both belong to same atom
    343   ASSERT( _bond->leftatom->getMolecule() == _bond->rightatom->getMolecule(),
    344       "GLWorldScene::bondInserted() - bond partners do not belong to same molecule.");
    345 
    346   // find associated molecule object
    347   const moleculeId_t molid = _bond->leftatom->getMolecule()->getId();
    348   MoleculeNodeMap::const_iterator moliter = MoleculesinSceneMap.find(molid );
    349   ASSERT(moliter != MoleculesinSceneMap.end(),
    350       "GLWorldScene::bondInserted() - molecule with id of "+toString(molid)
    351       +" atom with id "+toString(_bond->leftatom->getId())+" is unknown.");
    352   GLMoleculeObject_molecule *molObject = moliter->second;
    353 
    354   // add to internal list
    355   const GLMoleculeObject_molecule::BondIds ids =
    356       GLMoleculeObject_molecule::getBondIds(_bond, _side);
    357   BondMoleculeMap::const_iterator iter = BondsinSceneMap.find(ids);
    358   ASSERT(iter == BondsinSceneMap.end(),
    359       "GLWorldScene::bondInserted() - bond with ids "+toString(ids.first)
    360       +","+toString(ids.second)+" already present.");
    361   BondsinSceneMap.insert( std::make_pair( ids, molObject ));
    362 
    363   // inform its GlMoleculeObject_molecule.
    364   molObject->bondInserted(_bond, _side);
    365 
    366   // emit change
    367   emit changeOccured();
    368 }
    369 
    370 /** Removes a bond from the scene.
    371  *
    372  * @param _bond bond to remove
    373  */
    374 void GLWorldScene::bondRemoved(const atomId_t leftnr, const atomId_t rightnr)
    375 {
    376   LOG(3, "INFO: GLWorldScene::bondRemoved() - Removing bond between "+toString(leftnr)+" and "+toString(rightnr)+".");
    377   {
    378     // left bond
    379     const GLMoleculeObject_molecule::BondIds Leftids( make_pair(leftnr, rightnr) );
    380     BondMoleculeMap::iterator leftiter = BondsinSceneMap.find( Leftids );
    381     ASSERT(leftiter != BondsinSceneMap.end(),
    382         "GLWorldScene::bondRemoved() - bond "+toString(leftnr)+"-"
    383         +toString(rightnr)+" not on display.");
    384     GLMoleculeObject_molecule *molObject = leftiter->second;
    385 
    386     // remove from internal list
    387     BondsinSceneMap.erase(leftiter);
    388 
    389     // inform its GlMoleculeObject_molecule.
    390     molObject->bondRemoved( leftnr, rightnr );
    391   }
    392 
    393   // emit change
    394   emit changeOccured();
    395 }
    396 
    397269/** Adds a shape to the scene.
    398270 *
     
    465337  setSelectionMode(SelectMolecule);
    466338}
    467 
    468 void GLWorldScene::changeAtomId(GLMoleculeObject_atom *ob, int oldId, int newId)
    469 {
    470   LOG(3, "INFO: GLWorldScene - change atom id " << oldId << " to " << newId << ".");
    471   // Remove from map.
    472   AtomMoleculeMap::iterator iter = AtomsinSceneMap.find(oldId);
    473   ASSERT(iter != AtomsinSceneMap.end(),
    474         "GLWorldScene::changeAtomId() - atom with old id "+toString(oldId)+" not on display.");
    475   GLMoleculeObject_molecule *molObject = iter->second;
    476 
    477   // erase by signalling removal
    478   molObject->atomRemoved(oldId);
    479 
    480   // remove from internal list
    481   AtomsinSceneMap.erase(iter);
    482 
    483   // Reinsert with new id.
    484   {
    485     AtomMoleculeMap::iterator iter = AtomsinSceneMap.find(newId);
    486     ASSERT(iter == AtomsinSceneMap.end(),
    487           "GLWorldScene::changeAtomId() - atom with new id "+toString(newId)+" already known.");
    488   }
    489   AtomsinSceneMap.insert( make_pair(newId, molObject) );
    490 
    491   // inform molecule object
    492   molObject->atomInserted(newId);
    493 }
  • src/UIElements/Views/Qt4/Qt3D/GLWorldScene.hpp

    r8d3ee6 rd619338  
    8080private slots:
    8181  void atomClicked(atomId_t no);
    82   void atomInserted(const atomId_t _id);
    83   void atomRemoved(const atomId_t _id);
    8482  void moleculeClicked(moleculeId_t no);
    8583  void moleculeRemoved(const moleculeId_t _id);
    8684  void moleculeInserted(const moleculeId_t _id);
    8785  void worldSelectionChanged();
    88   void bondInserted(const bond::ptr _bond, const GLMoleculeObject_bond::SideOfBond side);
    89   void bondRemoved(const atomId_t leftnr, const atomId_t rightnr);
    9086  void setSelectionModeAtom();
    9187  void setSelectionModeMolecule();
    92   void changeAtomId(GLMoleculeObject_atom *ob, int oldId, int newOd);
    9388  void addShape();
    9489  void removeShape();
     
    10499private:
    105100
    106   typedef std::map< atomId_t, GLMoleculeObject_molecule* > AtomMoleculeMap;
    107   typedef std::map< GLMoleculeObject_molecule::BondIds , GLMoleculeObject_molecule* > BondMoleculeMap;
    108101  typedef std::map< moleculeId_t , GLMoleculeObject_molecule* > MoleculeNodeMap;
    109102  typedef std::map< std::string , GLMoleculeObject_shape* > ShapeNodeMap;
    110   AtomMoleculeMap AtomsinSceneMap;
    111   BondMoleculeMap BondsinSceneMap;
    112103  MoleculeNodeMap MoleculesinSceneMap;
    113104  ShapeNodeMap ShapesinSceneMap;
Note: See TracChangeset for help on using the changeset viewer.