Changeset 98c35c for src/UIElements


Ignore:
Timestamp:
Feb 12, 2016, 11:15:23 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:
41e287
Parents:
0070aa
git-author:
Frederik Heber <heber@…> (10/28/15 13:57:10)
git-committer:
Frederik Heber <heber@…> (02/12/16 23:15:23)
Message:

Added rudimentary getter and returner for ObservedAtom/..Molecule() to InstanceBoard.

Location:
src/UIElements
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Makefile.am

    r0070aa r98c35c  
    144144  UIElements/GlobalListOfParameterQueries.hpp \
    145145  UIElements/MainWindow.hpp \
     146  UIElements/Qt4/InstanceBoard/ObservedValue_types.hpp \
    146147  UIElements/Views/Qt4/Qt3D/ObservedValue_UpdateAtoms.hpp \
    147148  UIElements/Views/Qt4/Qt3D/ObservedValue_wCallback.hpp
  • src/UIElements/Qt4/InstanceBoard/QtObservedAtom.cpp

    r0070aa r98c35c  
    3838#include "CodePatterns/MemDebug.hpp"
    3939
    40 QtObservedAtom::QtObservedAtom(QWidget * _parent) :
     40QtObservedAtom::QtObservedAtom(
     41    const ObservedValues_t &_obsvalues,
     42    QWidget * _parent) :
    4143  QWidget(_parent),
    42   Observer("QtObservedAtom")
     44  Observer("QtObservedAtom"),
     45  obsvalues(_obsvalues)
    4346{}
    4447
    4548QtObservedAtom::~QtObservedAtom()
    4649{}
     50
     51void QtObservedAtom::update(Observable *publisher)
     52{}
     53
     54void QtObservedAtom::subjectKilled(Observable *publisher)
     55{}
     56
     57void QtObservedAtom::recieveNotification(Observable *publisher, Notification_ptr notification)
     58{}
  • src/UIElements/Qt4/InstanceBoard/QtObservedAtom.hpp

    r0070aa r98c35c  
    1717#include <QtGui/QWidget>
    1818
    19 #include <vector>
    2019
    21 #include <boost/any.hpp>
     20#include <boost/shared_ptr.hpp>
    2221
    2322#include "CodePatterns/Observer/Observer.hpp"
    24 #include "CodePatterns/ObservedValue.hpp"
    2523
     24#include "UIElements/Qt4/InstanceBoard/ObservedValue_types.hpp"
    2625#include "types.hpp"
     26
     27class QtObservedInstanceBoard;
    2728
    2829/** This instance is the ObservedValue representation of a World's atom.
     
    4041  Q_OBJECT
    4142
     43  //!> QtObservedInstanceBoard needs to access private cstor and dstor
     44  friend class QtObservedInstanceBoard;
     45
     46  //!> typedef for instance wrapped in shared ptr
     47  typedef boost::shared_ptr<QtObservedAtom> ptr;
     48
    4249  /** Cstor of QtObservedAtom.
    4350   *
     51   * \param _obsvalues ref to set of observed values for this instance
    4452   * \param _parent Qt parent to automatically destroy when parent is destroyed
    4553   */
    46   QtObservedAtom(QWidget * _parent=0);
     54  QtObservedAtom(
     55      const ObservedValues_t &_obsvalues,
     56      QWidget * _parent=0);
     57
     58public:
    4759
    4860  /** Dstor of QtObservedAtom.
     
    5062   */
    5163  ~QtObservedAtom();
     64
     65  // Observer functions
     66  void update(Observable *publisher);
     67  void subjectKilled(Observable *publisher);
     68  void recieveNotification(Observable *publisher, Notification_ptr notification);
    5269
    5370signals:
     
    5774
    5875private:
    59 
     76  //!> internal reference to ObservedValues held by QtObservedInstanceBoard
     77  const ObservedValues_t &obsvalues;
    6078};
    6179
  • src/UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.cpp

    r0070aa r98c35c  
    142142#endif
    143143              moleculeObservedValues.insert(
    144                   std::make_pair( _id, ObservedValues));
     144                  std::make_pair( _id, std::make_pair(ObservedValues,0) ));
    145145          ASSERT( inserter.second,
    146146              "QtObservedInstanceBoard::recieveNotification() - could not insert ObservedValues for"
     
    190190#endif
    191191              atomObservedValues.insert(
    192                   std::make_pair( _id, ObservedValues));
     192                  std::make_pair( _id, std::make_pair(ObservedValues,0) ));
    193193          ASSERT( inserter.second,
    194194              "QtObservedInstanceBoard::recieveNotification() - could not insert ObservedValues for"
     
    259259          // change id here only if still present
    260260          if (iter != moleculeObservedValues.end()) {
    261             ObservedValues_t obsvalues = iter->second;
     261            RefCountedObservedValues_t obsvalues = iter->second;
    262262            moleculeObservedValues.erase(iter);
    263263            ASSERT( moleculeObservedValues.find(newmoleculeId) == moleculeObservedValues.end(),
     
    290290          // change id here only if still present
    291291          if (iter != atomObservedValues.end()) {
    292             ObservedValues_t obsvalues = iter->second;
     292            RefCountedObservedValues_t obsvalues = iter->second;
    293293            atomObservedValues.erase(iter);
    294294            ASSERT( atomObservedValues.find(newatomId) == atomObservedValues.end(),
     
    326326
    327327  if (iter->second > GLMoleculeObject_atom::MAX_ObservedTypes) {
     328    ASSERT( atomObservedValues[_atomid].second == 0,
     329        "QtObservedInstanceBoard::atomcountsubjectKilled() - observed Values for atom "
     330        +toString(_atomid)+" are still being held somewhere.");
    328331    if (_atomid == lastremovedatomsmolecule.second)
    329332      emit atomRemoved(lastremovedatomsmolecule.first, lastremovedatomsmolecule.second);
     
    347350
    348351  if (iter->second > GLMoleculeObject_molecule::MAX_ObservedTypes) {
     352    ASSERT( moleculeObservedValues[_molid].second == 0,
     353        "QtObservedInstanceBoard::moleculecountsubjectKilled() - observed Values for molecule "
     354        +toString(_molid)+" are still being held somewhere.");
    349355    // then free the instance
    350356    emit moleculeRemoved(_molid);
     
    353359}
    354360
    355 QtObservedInstanceBoard::ObservedValues_t
     361ObservedValues_t
    356362QtObservedInstanceBoard::getAtomObservedValues(const atomId_t _id)
    357363{
     
    362368      +toString(_id));
    363369  if (iter->first == _id) {
    364     returnvalues = iter->second;
     370    returnvalues = iter->second.first;
    365371    atomObservedValues.erase(iter);
    366372  }
     
    368374}
    369375
    370 QtObservedInstanceBoard::ObservedValues_t
     376ObservedValues_t
    371377QtObservedInstanceBoard::getMoleculeObservedValues(const moleculeId_t _id)
    372378{
     
    377383      +toString(_id));
    378384  if (iter->first == _id) {
    379     returnvalues = iter->second;
     385    returnvalues = iter->second.first;
    380386    moleculeObservedValues.erase(iter);
    381387  }
     
    392398#endif
    393399        atomObservedValues.insert(
    394             std::make_pair( _id, _observedvalues) );
     400            std::make_pair( _id, std::make_pair(_observedvalues,0) ) );
    395401    ASSERT( inserter.second,
    396402        "QtObservedInstanceBoard::returnAtomObservedValues() - could not insert ObservedValues for"
     
    409415#endif
    410416          moleculeObservedValues.insert(
    411               std::make_pair( _id, _observedvalues) );
     417              std::make_pair( _id, std::make_pair(_observedvalues,0) ) );
    412418      ASSERT( inserter.second,
    413419          "QtObservedInstanceBoard::returnMoleculeObservedValues() - could not insert ObservedValues for"
     
    416422    lastremovedmolecule = (moleculeId_t)-1;
    417423}
     424
     425QtObservedAtom::ptr QtObservedInstanceBoard::getObservedAtom(const atomId_t _id)
     426{
     427  atomObservedValues_t::iterator iter = atomObservedValues.find(_id);
     428  ASSERT( iter != atomObservedValues.end(),
     429      "QtObservedInstanceBoard::getObservedAtom() - no observed values present for atom "
     430      +toString(_id));
     431  const ObservedValues_t &obsvalues = iter->second.first;
     432  // increase refcount
     433  ++(iter->second.second);
     434  QtObservedAtom::ptr _atom(new QtObservedAtom(obsvalues));
     435
     436  return _atom;
     437}
     438
     439QtObservedMolecule::ptr QtObservedInstanceBoard::getObservedMolecule(const moleculeId_t _id)
     440{
     441  moleculeObservedValues_t::iterator iter = moleculeObservedValues.find(_id);
     442  ASSERT( iter != moleculeObservedValues.end(),
     443      "QtObservedInstanceBoard::getObservedMolecule() - no observed values present for molecule "
     444      +toString(_id));
     445  const ObservedValues_t &obsvalues = iter->second.first;
     446  // increase refcount
     447  ++(iter->second.second);
     448  QtObservedMolecule::ptr _molecule(new QtObservedMolecule(obsvalues));
     449
     450  return _molecule;
     451}
     452
     453void QtObservedInstanceBoard::returnObservedAtom(const atomId_t _id)
     454{
     455  atomObservedValues_t::iterator iter = atomObservedValues.find(_id);
     456  ASSERT( iter != atomObservedValues.end(),
     457      "QtObservedInstanceBoard::returnObservedAtom() - no observed values present for atom "
     458      +toString(_id));
     459  ASSERT( iter->second.second != 0,
     460      "QtObservedInstanceBoard::returnObservedAtom() - all ObservedAtoms for atom "
     461      +toString(_id)+" have already been returned.");
     462  // decrease refcount
     463  --(iter->second.second);
     464  if (iter->second.second == 0) {
     465    // free instance
     466  }
     467}
     468
     469void QtObservedInstanceBoard::returnObservedMolecule(const moleculeId_t _id)
     470{
     471  moleculeObservedValues_t::iterator iter = moleculeObservedValues.find(_id);
     472  ASSERT( iter != moleculeObservedValues.end(),
     473      "QtObservedInstanceBoard::returnObservedMolecule() - no observed values present for molecule "
     474      +toString(_id));
     475  ASSERT( iter->second.second != 0,
     476      "QtObservedInstanceBoard::returnObservedMolecule() - all ObservedMolecules for molecule "
     477      +toString(_id)+" have already been returned.");
     478  // decrease refcount
     479  --(iter->second.second);
     480  if (iter->second.second == 0) {
     481    // free instance
     482  }
     483}
     484
  • src/UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.hpp

    r0070aa r98c35c  
    1717#include <QtGui/QWidget>
    1818
     19#include "UIElements/Qt4/InstanceBoard/QtObservedAtom.hpp"
     20#include "UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp"
     21
    1922#include <map>
    20 #include <vector>
    21 
    22 #include <boost/any.hpp>
     23#include <boost/function.hpp>
    2324
    2425#include "CodePatterns/Observer/Observer.hpp"
    25 #include "CodePatterns/ObservedValue.hpp"
    2626
     27#include "UIElements/Qt4/InstanceBoard/ObservedValue_types.hpp"
    2728#include "types.hpp"
    2829
     
    6263
    6364public:
    64   /** typedef for a vector of ObservedValue's (each is due to templating its
    65    * own type. Therefore, we need to use boost::any).
    66    */
    67   typedef std::vector<boost::any> ObservedValues_t;
    68 
    6965  /** Cstor of QtObservedInstanceBoard.
    7066   *
     
    8379  void recieveNotification(Observable *publisher, Notification_ptr notification);
    8480
     81  QtObservedAtom::ptr getObservedAtom(const atomId_t _id);
     82  QtObservedMolecule::ptr getObservedMolecule(const moleculeId_t _id);
     83
    8584  ObservedValues_t getAtomObservedValues(const atomId_t _id);
    8685  ObservedValues_t getMoleculeObservedValues(const moleculeId_t _id);
     86
     87  void returnObservedAtom(const atomId_t _id);
     88  void returnObservedMolecule(const moleculeId_t _id);
    8789
    8890  void returnAtomObservedValues(const atomId_t _id, ObservedValues_t &_observedvalues);
     
    144146  moleculesubjectKilledCount_t moleculesubjectKilledCount;
    145147
     148  typedef std::pair<ObservedValues_t, size_t> RefCountedObservedValues_t;
     149
    146150  //!> typedef for the map of id to each one's ObservedValues
    147   typedef typename std::map<atomId_t, ObservedValues_t> atomObservedValues_t;
     151  typedef typename std::map<atomId_t, RefCountedObservedValues_t> atomObservedValues_t;
    148152  //!> map containing all ObservedValues for each atom, associated by id
    149153  atomObservedValues_t atomObservedValues;
    150154
    151155  //!> typedef for the map of id to each one's ObservedValues
    152   typedef typename std::map<moleculeId_t, ObservedValues_t> moleculeObservedValues_t;
     156  typedef typename std::map<moleculeId_t, RefCountedObservedValues_t> moleculeObservedValues_t;
    153157  //!> map containing all ObservedValues for each molecule, associated by id
    154158  moleculeObservedValues_t moleculeObservedValues;
  • src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.cpp

    r0070aa r98c35c  
    3838#include "CodePatterns/MemDebug.hpp"
    3939
    40 QtObservedMolecule::QtObservedMolecule(QWidget * _parent) :
     40QtObservedMolecule::QtObservedMolecule(
     41    const ObservedValues_t &_obsvalues,
     42    QWidget * _parent) :
    4143  QWidget(_parent),
    42   Observer("QtObservedMolecule")
     44  Observer("QtObservedMolecule"),
     45  obsvalues(_obsvalues)
    4346{}
    4447
    4548QtObservedMolecule::~QtObservedMolecule()
    4649{}
     50
     51void QtObservedMolecule::update(Observable *publisher)
     52{}
     53
     54void QtObservedMolecule::subjectKilled(Observable *publisher)
     55{}
     56
     57void QtObservedMolecule::recieveNotification(Observable *publisher, Notification_ptr notification)
     58{}
  • src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp

    r0070aa r98c35c  
    1717#include <QtGui/QWidget>
    1818
    19 #include <vector>
    20 
    21 #include <boost/any.hpp>
     19#include <boost/shared_ptr.hpp>
    2220
    2321#include "CodePatterns/Observer/Observer.hpp"
    24 #include "CodePatterns/ObservedValue.hpp"
    2522
     23#include "UIElements/Qt4/InstanceBoard/ObservedValue_types.hpp"
    2624#include "types.hpp"
     25
     26class QtObservedInstanceBoard;
    2727
    2828/** This instance is the ObservedValue representation of a World's molecule.
     
    4040  Q_OBJECT
    4141
     42  //!> QtObservedInstanceBoard needs to access private cstor and dstor
     43  friend class QtObservedInstanceBoard;
     44
     45  //!> typedef for instance wrapped in shared ptr
     46  typedef boost::shared_ptr<QtObservedMolecule> ptr;
     47
    4248  /** Cstor of QtObservedMolecule.
    4349   *
     50   * \param _obsvalues ref to set of observed values for this instance
    4451   * \param _parent Qt parent to automatically destroy when parent is destroyed
    4552   */
    46   QtObservedMolecule(QWidget * _parent=0);
     53  QtObservedMolecule(
     54      const ObservedValues_t &_obsvalues,
     55      QWidget * _parent=0);
     56
     57public:
    4758
    4859  /** Dstor of QtObservedMolecule.
     
    5061   */
    5162  ~QtObservedMolecule();
     63
     64  // Observer functions
     65  void update(Observable *publisher);
     66  void subjectKilled(Observable *publisher);
     67  void recieveNotification(Observable *publisher, Notification_ptr notification);
    5268
    5369signals:
     
    5773
    5874private:
    59 
     75  //!> internal reference to ObservedValues held by QtObservedInstanceBoard
     76  const ObservedValues_t &obsvalues;
    6077};
    6178
Note: See TracChangeset for help on using the changeset viewer.