Changeset 9e9100 for src/UIElements


Ignore:
Timestamp:
Feb 14, 2016, 12:33:42 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:
5cd3a33
Parents:
6d4925
git-author:
Frederik Heber <heber@…> (12/28/15 11:43:34)
git-committer:
Frederik Heber <heber@…> (02/14/16 12:33:42)
Message:

Added ObservedValue for selection status of atoms and molecules to QtObserved...

Location:
src/UIElements/Qt4/InstanceBoard
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Qt4/InstanceBoard/QtObservedAtom.cpp

    r6d4925 r9e9100  
    6969      AtomObservable::NameChanged,
    7070      AtomObservable::ElementChanged,
    71       AtomObservable::PositionChanged;
     71      AtomObservable::PositionChanged,
     72      AtomObservable::SelectionChanged;
    7273  return channels;
    7374}
     
    8687const Observable::channels_t
    8788QtObservedAtom::AtomPositionChannels(1, AtomObservable::PositionChanged);
     89const Observable::channels_t
     90QtObservedAtom::AtomSelectedChannels(1, AtomObservable::SelectionChanged);
    8891
    8992QtObservedAtom::QtObservedAtom(
     
    112115  boost::any_cast<ObservedValue_wCallback<std::string, atomId_t> *>(ObservedValues[AtomName])->noteCallBackIsGone();
    113116  boost::any_cast<ObservedValue_wCallback<Vector, atomId_t> *>(ObservedValues[AtomPosition])->noteCallBackIsGone();
     117  boost::any_cast<ObservedValue_wCallback<bool, atomId_t> *>(ObservedValues[AtomSelected])->noteCallBackIsGone();
    114118
    115119  deactivateObserver();
     
    196200}
    197201
     202bool QtObservedAtom::updateSelected(
     203    const boost::function<const atomId_t ()> &_getAtomIndex)
     204{
     205  const atom * const _atom = getAtomConst(_getAtomIndex());
     206  if (_atom != NULL) {
     207    return _atom->getSelected();
     208  } else {
     209    return false;
     210  }
     211}
     212
    198213void QtObservedAtom::update(Observable *publisher)
    199214{
     
    240255    case AtomObservable::PositionChanged:
    241256      emit positionChanged();
     257      break;
     258    case AtomObservable::SelectionChanged:
     259      emit selectedChanged();
    242260      break;
    243261    default:
     
    324342  const boost::function<Vector ()> AtomPositionUpdater(
    325343      boost::bind(&QtObservedAtom::updatePosition, AtomIndexGetter));
     344  const boost::function<bool ()> AtomSelectedUpdater(
     345      boost::bind(&QtObservedAtom::updateSelected, AtomIndexGetter));
    326346
    327347  _ObservedValues[AtomBonds] = new ObservedValue_wCallback<ListOfBonds_t, atomId_t>(
     
    363383      AtomPositionUpdater(),
    364384      AtomPositionChannels,
     385      _subjectKilled,
     386      AtomIndexGetter);
     387  _ObservedValues[AtomSelected] = new ObservedValue_wCallback<bool, atomId_t>(
     388      _atomref,
     389      AtomSelectedUpdater,
     390      "AtomSelected_"+toString(_id),
     391      AtomSelectedUpdater(),
     392      AtomSelectedChannels,
    365393      _subjectKilled,
    366394      AtomIndexGetter);
     
    376404  delete boost::any_cast<ObservedValue_wCallback<std::string, atomId_t> *>(_ObservedValues[AtomName]);
    377405  delete boost::any_cast<ObservedValue_wCallback<Vector, atomId_t> *>(_ObservedValues[AtomPosition]);
     406  delete boost::any_cast<ObservedValue_wCallback<bool, atomId_t> *>(_ObservedValues[AtomSelected]);
    378407  _ObservedValues.clear();
    379408}
     
    408437  return boost::any_cast<ObservedValue_wCallback<Vector, atomId_t> *>(ObservedValues[AtomPosition])->get();
    409438}
     439
     440const bool QtObservedAtom::getAtomSelected() const
     441{
     442  return boost::any_cast<ObservedValue_wCallback<bool, atomId_t> *>(ObservedValues[AtomSelected])->get();
     443}
  • src/UIElements/Qt4/InstanceBoard/QtObservedAtom.hpp

    r6d4925 r9e9100  
    121121   */
    122122  const moleculeId_t& getAtomMoleculeIndex() const;
     123
     124  /** Getter to atom's selected status.
     125   *
     126   * \return true - atom selected, false - else
     127   */
     128  const bool getAtomSelected() const;
    123129
    124130signals:
     
    130136  void positionChanged();
    131137  void atomRemoved();
     138  void selectedChanged();
    132139
    133140//private slots:
     
    151158      const boost::function<const atomId_t ()> &_getAtomIndex);
    152159  static Vector updatePosition(
     160      const boost::function<const atomId_t ()> &_getAtomIndex);
     161  static bool updateSelected(
    153162      const boost::function<const atomId_t ()> &_getAtomIndex);
    154163
     
    167176    //!> contains the current atom position
    168177    AtomPosition,
     178    //!> contains the current atom's selection status
     179    AtomSelected,
    169180    //!> gives the size of the enumeration
    170181    MAX_ObservedTypes
     
    215226  //!> list of channels when position needs to update
    216227  static const Observable::channels_t AtomPositionChannels;
     228  //!> list of channels when selection needs to update
     229  static const Observable::channels_t AtomSelectedChannels;
    217230
    218231  //!> we get multiple subjectKilled(), count and call callback() only on last
  • src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.cpp

    r6d4925 r9e9100  
    6464      molecule::IndexChanged,
    6565      molecule::MoleculeNameChanged,
    66       molecule::BoundingBoxChanged;
     66      molecule::BoundingBoxChanged,
     67      molecule::SelectionChanged;
    6768  return channels;
    6869}
     
    9697const Observable::channels_t QtObservedMolecule::NameChannels(1, molecule::MoleculeNameChanged);
    9798const Observable::channels_t QtObservedMolecule::NonHydrogenCountChannels(1, molecule::FormulaChanged);
     99const Observable::channels_t QtObservedMolecule::SelectedChannels(1, molecule::SelectionChanged);
    98100
    99101QtObservedMolecule::QtObservedMolecule(
     
    124126  boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(ObservedValues[MolName])->noteCallBackIsGone();
    125127  boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(ObservedValues[NonHydrogenCount])->noteCallBackIsGone();
     128  boost::any_cast<ObservedValue_wCallback<bool, moleculeId_t> *>(ObservedValues[MolSelected])->noteCallBackIsGone();
    126129
    127130  deactivateObserver();
     
    254257  #endif
    255258        emit nameChanged();
     259        break;
     260      }
     261      case molecule::SelectionChanged:
     262      {
     263  #ifdef LOG_OBSERVER
     264        observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that selected has changed.";
     265  #endif
     266        emit selectedChanged();
    256267        break;
    257268      }
     
    327338  const boost::function<molecule::BoundingBoxInfo ()> BoundingBoxUpdater(
    328339      boost::bind(&QtObservedMolecule::updateBoundingBox, MolIndexGetter));
     340  const boost::function<bool ()> SelectedUpdater(
     341      boost::bind(&QtObservedMolecule::updateSelected, MolIndexGetter));
    329342
    330343  _ObservedValues[AtomCount] = new ObservedValue_wCallback<int, moleculeId_t>(
     
    382395      NonHydrogenCountUpdater(),
    383396      NonHydrogenCountChannels,
     397      _subjectKilled,
     398      MolIndexGetter);
     399  _ObservedValues[MolSelected] = new ObservedValue_wCallback<bool, moleculeId_t>(
     400      _molref,
     401      SelectedUpdater,
     402      "MoleculeSelected_"+toString(_molid),
     403      SelectedUpdater(),
     404      SelectedChannels,
    384405      _subjectKilled,
    385406      MolIndexGetter);
     
    397418  delete boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(_ObservedValues[MolName]);
    398419  delete boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(_ObservedValues[NonHydrogenCount]);
     420  delete boost::any_cast<ObservedValue_wCallback<bool, moleculeId_t> *>(_ObservedValues[MolSelected]);
    399421  _ObservedValues.clear();
    400422}
     
    475497}
    476498
     499bool QtObservedMolecule::updateSelected(
     500    const boost::function<const moleculeId_t ()> &_getMolIndex)
     501{
     502  const molecule * const mol = getMolecule(_getMolIndex());
     503  if (mol != NULL)
     504    return mol->getSelected();
     505  else
     506    return false;
     507}
     508
    477509const int& QtObservedMolecule::getAtomCount() const
    478510{
     
    514546  return boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t> *>(ObservedValues[BoundingBox])->get();
    515547}
     548
     549const bool& QtObservedMolecule::getMolSelected() const
     550{
     551  return boost::any_cast<ObservedValue_wCallback<bool, moleculeId_t> *>(ObservedValues[MolSelected])->get();
     552}
  • src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp

    r6d4925 r9e9100  
    128128  const molecule::BoundingBoxInfo& getBoundingBox() const;
    129129
     130  /** Getter to molecule's selected status.
     131   *
     132   * \return true - molecule selected, false - else
     133   */
     134  const bool& getMolSelected() const;
     135
    130136  static const molecule * const getMolecule(const moleculeId_t _id);
    131137
     
    143149  void atomRemoved(const atomId_t);
    144150  void moleculeRemoved();
     151  void selectedChanged();
    145152
    146153private:
     
    164171      const boost::function<const moleculeId_t ()> &_getMolIndex);
    165172  static int updateNonHydrogenCount(
     173      const boost::function<const moleculeId_t ()> &_getMolIndex);
     174  static bool updateSelected(
    166175      const boost::function<const moleculeId_t ()> &_getMolIndex);
    167176
     
    182191  //!> list of channels when the name needs to update
    183192  static const Observable::channels_t NonHydrogenCountChannels;
     193  //!> list of channels when the name needs to update
     194  static const Observable::channels_t SelectedChannels;
    184195
    185196private:
     
    204215    //!> contains the current molecule's non-hydrogen atom count
    205216    NonHydrogenCount,
     217    //!> contains the current molecule's selection status
     218    MolSelected,
    206219    //!> gives the size of the enumeration
    207220    MAX_ObservedTypes
Note: See TracChangeset for help on using the changeset viewer.