Changeset 08a7ecc for src/UIElements


Ignore:
Timestamp:
Apr 25, 2016, 7:02:56 AM (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:
6c4b69
Parents:
375bc3f
git-author:
Frederik Heber <heber@…> (04/13/16 13:43:20)
git-committer:
Frederik Heber <heber@…> (04/25/16 07:02:56)
Message:

FIX: ObservedValue_Index_t is now the memory address of the Observer instance.

  • the atom, bond, or molecule may be removed before and reinstantiated at the same address. Hence, it is not a good unique index. The only sensible index is the memory address of the QtObserved... instance itself.
Location:
src/UIElements/Qt4/InstanceBoard
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Qt4/InstanceBoard/ObservedValue_types.hpp

    r375bc3f r08a7ecc  
    1919#include <boost/any.hpp>
    2020
    21 class Observable;
     21class Observer;
    2222
    2323/** typedef for a vector of ObservedValue's (each is due to templating its
     
    3232 * index if one is destroyed and another one instantiated at the same address.
    3333 */
    34 typedef const Observable * ObservedValue_Index_t;
     34typedef const Observer * ObservedValue_Index_t;
    3535
    3636
  • src/UIElements/Qt4/InstanceBoard/QtObservedAtom.cpp

    r375bc3f r08a7ecc  
    102102  owner(NULL),
    103103  oldId(_id),
    104   index(static_cast<const ObservedValue_Index_t>(_atom)),
     104  index(static_cast<const ObservedValue_Index_t>(const_cast<const QtObservedAtom * const>(this))),
    105105  board(_board),
    106106  BoardIsGone(false),
  • src/UIElements/Qt4/InstanceBoard/QtObservedBond.cpp

    r375bc3f r08a7ecc  
    8686  leftatom(_leftatom),
    8787  rightatom(_rightatom),
    88   index(static_cast<const ObservedValue_Index_t>(_bond.get())),
     88  index(static_cast<const ObservedValue_Index_t>(const_cast<const QtObservedBond * const>(this))),
    8989  board(_board),
    9090  BoardIsGone(false),
  • src/UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.cpp

    r375bc3f r08a7ecc  
    148148                  *this));
    149149          observedmolecule->setSelfRef(observedmolecule);
    150           const ObservedValue_Index_t index = static_cast<const Observable *>(_molecule);
     150          const ObservedValue_Index_t index = observedmolecule->getIndex();
    151151          moleculeObservedValues.insert(index, observedmolecule);
    152152          moleculeids_lookup.left.insert( std::make_pair(_id, index) );
     
    176176              new QtObservedAtom(_id, _atom, *this));
    177177          observedatom->setSelfRef(observedatom);
    178           const ObservedValue_Index_t index = static_cast<const Observable *>(_atom);
     178          const ObservedValue_Index_t index = observedatom->getIndex();
    179179          atomObservedValues.insert(index, observedatom);
    180180          atomids_lookup.left.insert( std::make_pair(_id, index) );
     
    254254
    255255          // check whether bond is already present, cause we get BondsAdded from both atoms
    256           const ObservedValue_Index_t index = static_cast<const Observable *>(bondref.get());
    257           if (!bondObservedValues.isPresent(index)) {
    258             const QtObservedAtom::ptr leftatom = getObservedAtom(
    259                 static_cast<const Observable *>(bondref->leftatom));
     256          const bondId_t bondid =
     257              std::make_pair( bondref->leftatom->getId(), bondref->rightatom->getId());
     258          if (!bondids_lookup.left.count(bondid)) {
     259            const QtObservedAtom::ptr leftatom = getObservedAtom(bondref->leftatom->getId());
    260260            ASSERT( leftatom,
    261261                "QtObservedInstanceBoard::recieveNotification() - QtObservedAtom leftatom to bond must exist.");
    262             const QtObservedAtom::ptr rightatom = getObservedAtom(
    263                 static_cast<const Observable *>(bondref->rightatom));
     262            const QtObservedAtom::ptr rightatom = getObservedAtom(bondref->rightatom->getId());
    264263            ASSERT( rightatom,
    265264                "QtObservedInstanceBoard::recieveNotification() - QtObservedAtom leftatom to bond must exist.");
    266             const bondId_t bondid =
    267                 std::make_pair( bondref->leftatom->getId(), bondref->rightatom->getId());
    268265            LOG(3, "DEBUG: InformationBoard initializes QtObservedBond for " << bondid);
    269266            QtObservedBond::ptr observedbond(
    270267                new QtObservedBond(bondid, bondref, leftatom, rightatom, *this));
     268            const ObservedValue_Index_t index = observedbond->getIndex();
    271269            bondObservedValues.insert(index, observedbond);
    272270            bondids_lookup.left.insert( std::make_pair(bondid, index) );
  • src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.cpp

    r375bc3f r08a7ecc  
    110110  owner(NULL),
    111111  oldId(_id),
    112   index(static_cast<const ObservedValue_Index_t>(_mol)),
     112  index(static_cast<const ObservedValue_Index_t>(const_cast<const QtObservedMolecule * const>(this))),
    113113  board(_board),
    114114  BoardIsGone(false),
Note: See TracChangeset for help on using the changeset viewer.