Ignore:
Timestamp:
Sep 15, 2014, 3:05:28 PM (11 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:
7e1a88
Parents:
b73545 (diff), 8859b5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'GUI_Fixes' into stable

File:
1 edited

Legend:

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

    rb73545 r7f1b51  
    9494  }
    9595
     96  connect(this, SIGNAL(updated()), this, SLOT(update()));
     97
    9698  setSelectionMode(SelectAtom);
    9799
     
    110112void GLWorldScene::init()
    111113{
    112   const std::vector<molecule*> &molecules = World::getInstance().getAllMolecules();
    113 
    114   if (molecules.size() > 0) {
    115     for (std::vector<molecule*>::const_iterator Runner = molecules.begin();
    116         Runner != molecules.end();
    117         Runner++) {
    118 
    119       for (molecule::const_iterator atomiter = (*Runner)->begin();
    120           atomiter != (*Runner)->end();
    121           ++atomiter) {
    122         // create atom objects in scene
     114  const std::vector<atom*> &atoms = World::getInstance().getAllAtoms();
     115
     116  if (atoms.size() > 0) {
     117    for (std::vector<atom*>::const_iterator atomiter = atoms.begin();
     118        atomiter != atoms.end();
     119        atomiter++) {
     120      // create atom objects in scene
     121      atomInserted((*atomiter)->getId());
     122
     123      // create bond objects in scene
     124      const BondList &bondlist = (*atomiter)->getListOfBonds();
     125      for (BondList::const_iterator bonditer = bondlist.begin();
     126          bonditer != bondlist.end();
     127          ++bonditer) {
     128        const bond::ptr _bond = *bonditer;
     129        const GLMoleculeObject_bond::SideOfBond side = (_bond->leftatom == *atomiter) ?
     130            GLMoleculeObject_bond::left : GLMoleculeObject_bond::right;
     131        bondInserted(_bond, side);
     132      }
     133    }
     134  }
     135}
     136
     137/** Update the WorldScene with molecules and atoms from World.
     138 *
     139 * This function should be called after e.g. WorldTime::TimeChanged was
     140 * received or after another molecule has been loaded.
     141 *
     142 */
     143void GLWorldScene::update()
     144{
     145  const std::vector<atom*> &atoms = World::getInstance().getAllAtoms();
     146
     147  if (atoms.size() > 0) {
     148    for (std::vector<atom*>::const_iterator atomiter = atoms.begin();
     149        atomiter != atoms.end();
     150        atomiter++) {
     151      // check whether atom already exists
     152      const atomId_t atomid = (*atomiter)->getId();
     153      const bool atom_present = AtomsinSceneMap.count(atomid);
     154      if (!atom_present)
    123155        atomInserted((*atomiter)->getId());
    124 
    125         // create bond objects in scene
    126         const BondList &bondlist = (*atomiter)->getListOfBonds();
    127         for (BondList::const_iterator bonditer = bondlist.begin();
    128             bonditer != bondlist.end();
    129             ++bonditer) {
    130           const bond::ptr _bond = *bonditer;
    131           const GLMoleculeObject_bond::SideOfBond side = (_bond->leftatom == *atomiter) ?
    132               GLMoleculeObject_bond::left : GLMoleculeObject_bond::right;
     156      else
     157        AtomsinSceneMap[atomid]->resetPosition();
     158
     159
     160      // create bond objects in scene
     161      const BondList &bondlist = (*atomiter)->getListOfBonds();
     162      for (BondList::const_iterator bonditer = bondlist.begin();
     163          bonditer != bondlist.end();
     164          ++bonditer) {
     165        const bond::ptr _bond = *bonditer;
     166        const GLMoleculeObject_bond::SideOfBond side = (_bond->leftatom == *atomiter) ?
     167            GLMoleculeObject_bond::left : GLMoleculeObject_bond::right;
     168        bool bond_present = false;
     169        const BondIds ids = getBondIds(_bond,side);
     170        if (atom_present) {
     171          // check whether bond is not present already
     172          bond_present = BondsinSceneMap.count(ids);
     173        }
     174        if (!bond_present)
    133175          bondInserted(_bond, side);
     176        else {
     177          BondsinSceneMap[ids]->resetPosition();
     178          BondsinSceneMap[ids]->resetWidth();
    134179        }
    135180      }
     
    246291}
    247292
    248 /** Adds a bond to the scene.
    249  *
    250  * @param _bond bond to add
    251  * @param side which side of the bond (left or right)
    252  */
    253 void GLWorldScene::bondInserted(const bond::ptr _bond, const enum GLMoleculeObject_bond::SideOfBond side)
    254 {
    255   LOG(3, "INFO: GLWorldScene::bondInserted() - Adding bond "+toString(*_bond)+".");
    256   //LOG(4, "INFO: Currently present bonds " << BondsinSceneMap << ".");
    257 
     293/** Helper function to get bond ids in the correct order for BondNodeMap.
     294 *
     295 * \return pair of ids in correct order.
     296 */
     297GLWorldScene::BondIds GLWorldScene::getBondIds(
     298    const bond::ptr _bond,
     299    const enum GLMoleculeObject_bond::SideOfBond _side) const
     300{
    258301  BondIds ids;
    259   switch (side) {
     302  switch (_side) {
    260303    case GLMoleculeObject_bond::left:
    261304      ids = std::make_pair(_bond->leftatom->getId(), _bond->rightatom->getId());
     
    265308      break;
    266309  }
    267 #ifndef NDEBUG
     310  return ids;
     311}
     312
     313/** Adds a bond to the scene.
     314 *
     315 * @param _bond bond to add
     316 * @param side which side of the bond (left or right)
     317 */
     318void GLWorldScene::bondInserted(const bond::ptr _bond, const enum GLMoleculeObject_bond::SideOfBond _side)
     319{
     320  LOG(3, "INFO: GLWorldScene::bondInserted() - Adding bond "+toString(*_bond)+".");
     321  //LOG(4, "INFO: Currently present bonds " << BondsinSceneMap << ".");
     322
     323  const BondIds ids = getBondIds(_bond, _side);
    268324  BondNodeMap::iterator iter = BondsinSceneMap.find(ids);
    269   ASSERT(iter == BondsinSceneMap.end(),
    270       "GLWorldScene::bondAdded() - same left-sided bond "+toString(*_bond)+" added again.");
    271 #endif
    272   GLMoleculeObject_bond * bondObject =
    273       new GLMoleculeObject_bond(meshCylinder, this, _bond, side);
    274   connect (
    275       bondObject, SIGNAL(BondRemoved(const atomId_t, const atomId_t)),
    276       this, SLOT(bondRemoved(const atomId_t, const atomId_t)));
    277   connect (bondObject, SIGNAL(changed()), this, SIGNAL(changed()));
    278   BondsinSceneMap.insert( make_pair(ids, bondObject) );
    279 //    BondIdsinSceneMap.insert( Leftids );
     325  if (iter == BondsinSceneMap.end()) {
     326    GLMoleculeObject_bond * bondObject =
     327        new GLMoleculeObject_bond(meshCylinder, this, _bond, _side);
     328    connect (
     329        bondObject, SIGNAL(BondRemoved(const atomId_t, const atomId_t)),
     330        this, SLOT(bondRemoved(const atomId_t, const atomId_t)));
     331    connect (bondObject, SIGNAL(changed()), this, SIGNAL(changed()));
     332    BondsinSceneMap.insert( make_pair(ids, bondObject) );
     333  //    BondIdsinSceneMap.insert( Leftids );
     334  } else {
     335    iter->second->resetPosition();
     336    iter->second->resetWidth();
     337  }
    280338  emit changeOccured();
    281339}
Note: See TracChangeset for help on using the changeset viewer.