Changeset fe493f for src/UIElements
- Timestamp:
- Feb 12, 2016, 11:15:40 PM (9 years ago)
- 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:
- 5a9e34
- Parents:
- deb5ee
- git-author:
- Frederik Heber <heber@…> (01/20/16 20:04:06)
- git-committer:
- Frederik Heber <heber@…> (02/12/16 23:15:40)
- Location:
- src/UIElements/Qt4/InstanceBoard
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Qt4/InstanceBoard/QtObservedAtom.cpp
rdeb5ee rfe493f 64 64 channels += 65 65 AtomObservable::IndexChanged, 66 AtomObservable::PositionChanged, 66 AtomObservable::BondsAdded, 67 AtomObservable::BondsRemoved, 68 AtomObservable::MoleculeChanged, 69 AtomObservable::NameChanged, 67 70 AtomObservable::ElementChanged, 68 AtomObservable::BondsAdded, 69 AtomObservable::BondsRemoved; 71 AtomObservable::PositionChanged; 70 72 return channels; 71 73 } … … 75 77 QtObservedAtom::AtomIndexChannels(1, AtomObservable::IndexChanged); 76 78 const Observable::channels_t 79 QtObservedAtom::AtomBondsChannels(getAtomBondsChannels()); 80 const Observable::channels_t 81 QtObservedAtom::AtomElementChannels(1, AtomObservable::ElementChanged); 82 const Observable::channels_t 83 QtObservedAtom::AtomMoleculeIndexChannels(1, AtomObservable::MoleculeChanged); 84 const Observable::channels_t 85 QtObservedAtom::AtomNameChannels(1, AtomObservable::NameChanged); 86 const Observable::channels_t 77 87 QtObservedAtom::AtomPositionChannels(1, AtomObservable::PositionChanged); 78 const Observable::channels_t79 QtObservedAtom::AtomElementChannels(1, AtomObservable::ElementChanged);80 const Observable::channels_t81 QtObservedAtom::AtomBondsChannels(getAtomBondsChannels());82 88 83 89 QtObservedAtom::QtObservedAtom( … … 120 126 } 121 127 122 Vector QtObservedAtom::updatePosition(123 const boost::function<const atomId_t ()> &_getAtomIndex)124 {125 const atom * const _atom = getAtomConst(_getAtomIndex());126 if (_atom != NULL) {127 return _atom->getPosition();128 } else {129 return zeroVec;130 }131 }132 133 atomicNumber_t QtObservedAtom::updateElement(134 const boost::function<const atomId_t ()> &_getAtomIndex)135 {136 const atom * const _atom = getAtomConst(_getAtomIndex());137 if (_atom != NULL) {138 return _atom->getElementNo();139 } else {140 return (atomicNumber_t)-1;141 }142 }143 144 128 QtObservedAtom::ListOfBonds_t QtObservedAtom::updateBonds( 145 129 const boost::function<const atomId_t ()> &_getAtomIndex) … … 160 144 } 161 145 146 atomicNumber_t QtObservedAtom::updateElement( 147 const boost::function<const atomId_t ()> &_getAtomIndex) 148 { 149 const atom * const _atom = getAtomConst(_getAtomIndex()); 150 if (_atom != NULL) { 151 return _atom->getElementNo(); 152 } else { 153 return (atomicNumber_t)-1; 154 } 155 } 156 157 moleculeId_t QtObservedAtom::updateMoleculeIndex( 158 const boost::function<const atomId_t ()> &_getAtomIndex) 159 { 160 const atom * const _atom = getAtomConst(_getAtomIndex()); 161 if ((_atom != NULL) && (_atom->getMolecule() != NULL)) { 162 return _atom->getMolecule()->getId(); 163 } else { 164 return (moleculeId_t)0; 165 } 166 } 167 168 std::string QtObservedAtom::updateName( 169 const boost::function<const atomId_t ()> &_getAtomIndex) 170 { 171 const atom * const _atom = getAtomConst(_getAtomIndex()); 172 if (_atom != NULL) { 173 return _atom->getName(); 174 } else { 175 return std::string(""); 176 } 177 } 178 179 Vector QtObservedAtom::updatePosition( 180 const boost::function<const atomId_t ()> &_getAtomIndex) 181 { 182 const atom * const _atom = getAtomConst(_getAtomIndex()); 183 if (_atom != NULL) { 184 return _atom->getPosition(); 185 } else { 186 return zeroVec; 187 } 188 } 189 162 190 void QtObservedAtom::update(Observable *publisher) 163 191 { … … 174 202 175 203 board.markObservedAtomAsDisconnected(getAtomIndex()); 204 205 emit atomRemoved(); 176 206 } 177 207 } … … 184 214 emit indexChanged(); 185 215 break; 186 case AtomObservable::PositionChanged:187 emit positionChanged();188 break;189 case AtomObservable::ElementChanged:190 emit elementChanged();191 break;192 216 case AtomObservable::BondsAdded: 193 217 case AtomObservable::BondsRemoved: 194 218 emit bondsChanged(); 219 break; 220 case AtomObservable::ElementChanged: 221 emit elementChanged(); 222 break; 223 case AtomObservable::MoleculeChanged: 224 emit moleculeindexChanged(); 225 break; 226 case AtomObservable::NameChanged: 227 emit nameChanged(); 228 break; 229 case AtomObservable::PositionChanged: 230 emit positionChanged(); 195 231 break; 196 232 default: … … 264 300 265 301 // fill ObservedValues: then all the other that need index 302 const boost::function<ListOfBonds_t ()> AtomBondsUpdater( 303 boost::bind(&QtObservedAtom::updateBonds, AtomIndexGetter)); 304 const boost::function<atomicNumber_t ()> AtomElementUpdater( 305 boost::bind(&QtObservedAtom::updateElement, AtomIndexGetter)); 306 const boost::function<moleculeId_t ()> AtomMoleculeIndexUpdater( 307 boost::bind(&QtObservedAtom::updateMoleculeIndex, AtomIndexGetter)); 308 const boost::function<std::string ()> AtomNameUpdater( 309 boost::bind(&QtObservedAtom::updateName, AtomIndexGetter)); 266 310 const boost::function<Vector ()> AtomPositionUpdater( 267 311 boost::bind(&QtObservedAtom::updatePosition, AtomIndexGetter)); 268 const boost::function<atomicNumber_t ()> AtomElementUpdater( 269 boost::bind(&QtObservedAtom::updateElement, AtomIndexGetter)); 270 const boost::function<ListOfBonds_t ()> AtomBondsUpdater( 271 boost::bind(&QtObservedAtom::updateBonds, AtomIndexGetter)); 272 312 313 _ObservedValues[AtomBonds] = new ObservedValue_wCallback<ListOfBonds_t, atomId_t>( 314 _atomref, 315 AtomBondsUpdater, 316 "AtomBonds_"+toString(_id), 317 AtomBondsUpdater(), 318 AtomBondsChannels, 319 _subjectKilled, 320 AtomIndexGetter); 321 _ObservedValues[AtomElement] = new ObservedValue_wCallback<atomicNumber_t, atomId_t>( 322 _atomref, 323 AtomElementUpdater, 324 "AtomElement"+toString(_id), 325 AtomElementUpdater(), 326 AtomElementChannels, 327 _subjectKilled, 328 AtomIndexGetter); 329 _ObservedValues[AtomMoleculeIndex] = new ObservedValue_wCallback<moleculeId_t, atomId_t>( 330 _atomref, 331 AtomMoleculeIndexUpdater, 332 "AtomMoleculeIndex"+toString(_id), 333 AtomMoleculeIndexUpdater(), 334 AtomMoleculeIndexChannels, 335 _subjectKilled, 336 AtomIndexGetter); 337 _ObservedValues[AtomName] = new ObservedValue_wCallback<std::string, atomId_t>( 338 _atomref, 339 AtomNameUpdater, 340 "AtomName"+toString(_id), 341 AtomNameUpdater(), 342 AtomNameChannels, 343 _subjectKilled, 344 AtomIndexGetter); 273 345 _ObservedValues[AtomPosition] = new ObservedValue_wCallback<Vector, atomId_t>( 274 346 _atomref, … … 279 351 _subjectKilled, 280 352 AtomIndexGetter); 281 _ObservedValues[AtomElement] = new ObservedValue_wCallback<atomicNumber_t, atomId_t>(282 _atomref,283 AtomElementUpdater,284 "AtomElement"+toString(_id),285 AtomElementUpdater(),286 AtomElementChannels,287 _subjectKilled,288 AtomIndexGetter);289 _ObservedValues[AtomBonds] = new ObservedValue_wCallback<ListOfBonds_t, atomId_t>(290 _atomref,291 AtomBondsUpdater,292 "AtomBonds_"+toString(_id),293 AtomBondsUpdater(),294 AtomBondsChannels,295 _subjectKilled,296 AtomIndexGetter);297 353 } 298 354 … … 301 357 { 302 358 delete boost::any_cast<ObservedValue_wCallback<atomId_t> *>(_ObservedValues[AtomIndex]); 359 delete boost::any_cast<ObservedValue_wCallback<ListOfBonds_t, atomId_t> *>(_ObservedValues[AtomBonds]); 360 delete boost::any_cast<ObservedValue_wCallback<atomicNumber_t, atomId_t> *>(_ObservedValues[AtomElement]); 361 delete boost::any_cast<ObservedValue_wCallback<moleculeId_t, atomId_t> *>(_ObservedValues[AtomMoleculeIndex]); 362 delete boost::any_cast<ObservedValue_wCallback<std::string, atomId_t> *>(_ObservedValues[AtomName]); 303 363 delete boost::any_cast<ObservedValue_wCallback<Vector, atomId_t> *>(_ObservedValues[AtomPosition]); 304 delete boost::any_cast<ObservedValue_wCallback<atomicNumber_t, atomId_t> *>(_ObservedValues[AtomElement]);305 delete boost::any_cast<ObservedValue_wCallback<ListOfBonds_t, atomId_t> *>(_ObservedValues[AtomBonds]);306 364 _ObservedValues.clear(); 307 365 } … … 312 370 } 313 371 372 QtObservedAtom::ListOfBonds_t QtObservedAtom::getAtomBonds() const 373 { 374 return boost::any_cast<ObservedValue_wCallback<ListOfBonds_t, atomId_t> *>(ObservedValues[AtomBonds])->get(); 375 } 376 377 atomicNumber_t QtObservedAtom::getAtomElement() const 378 { 379 return boost::any_cast<ObservedValue_wCallback<atomicNumber_t, atomId_t> *>(ObservedValues[AtomElement])->get(); 380 } 381 382 moleculeId_t QtObservedAtom::getAtomMoleculeIndex() const 383 { 384 return boost::any_cast<ObservedValue_wCallback<moleculeId_t, atomId_t> *>(ObservedValues[AtomMoleculeIndex])->get(); 385 } 386 387 std::string QtObservedAtom::getAtomName() const 388 { 389 return boost::any_cast<ObservedValue_wCallback<std::string, atomId_t> *>(ObservedValues[AtomName])->get(); 390 } 391 314 392 Vector QtObservedAtom::getAtomPosition() const 315 393 { 316 394 return boost::any_cast<ObservedValue_wCallback<Vector, atomId_t> *>(ObservedValues[AtomPosition])->get(); 317 395 } 318 319 atomicNumber_t QtObservedAtom::getAtomElement() const320 {321 return boost::any_cast<ObservedValue_wCallback<atomicNumber_t, atomId_t> *>(ObservedValues[AtomElement])->get();322 }323 324 QtObservedAtom::ListOfBonds_t QtObservedAtom::getAtomBonds() const325 {326 return boost::any_cast<ObservedValue_wCallback<ListOfBonds_t, atomId_t> *>(ObservedValues[AtomBonds])->get();327 } -
src/UIElements/Qt4/InstanceBoard/QtObservedAtom.hpp
rdeb5ee rfe493f 89 89 atomId_t getAtomIndex() const; 90 90 91 /** Getter to atom position contained in \a ObservedValues.92 *93 * \return atom's position94 */95 Vector getAtomPosition() const;96 97 /** Getter to atom element contained in \a ObservedValues.98 *99 * \return atom's elemnt100 */101 atomicNumber_t getAtomElement() const;102 103 91 //!> typedef for list of bonds, defined by pairs of atom ids 104 92 typedef std::vector< std::pair<atomId_t, atomId_t> > ListOfBonds_t; … … 110 98 ListOfBonds_t getAtomBonds() const; 111 99 100 /** Getter to atom element contained in \a ObservedValues. 101 * 102 * \return atom's element 103 */ 104 atomicNumber_t getAtomElement() const; 105 106 /** Getter to atom name contained in \a ObservedValues. 107 * 108 * \return atom's name 109 */ 110 std::string getAtomName() const; 111 112 /** Getter to atom position contained in \a ObservedValues. 113 * 114 * \return atom's position 115 */ 116 Vector getAtomPosition() const; 117 118 /** Getter to atom's molecule index contained in \a ObservedValues. 119 * 120 * \return atom's molecule index 121 */ 122 moleculeId_t getAtomMoleculeIndex() const; 123 112 124 signals: 113 125 void indexChanged(); 126 void bondsChanged(); 127 void elementChanged(); 128 void moleculeindexChanged(); 129 void nameChanged(); 114 130 void positionChanged(); 115 void elementChanged(); 116 void bondsChanged(); 131 void atomRemoved(); 117 132 118 133 //private slots: … … 127 142 private: 128 143 static atomId_t updateIndex(); 144 static ListOfBonds_t updateBonds( 145 const boost::function<const atomId_t ()> &_getAtomIndex); 146 static atomicNumber_t updateElement( 147 const boost::function<const atomId_t ()> &_getAtomIndex); 148 static moleculeId_t updateMoleculeIndex( 149 const boost::function<const atomId_t ()> &_getAtomIndex); 150 static std::string updateName( 151 const boost::function<const atomId_t ()> &_getAtomIndex); 129 152 static Vector updatePosition( 130 const boost::function<const atomId_t ()> &_getAtomIndex);131 static atomicNumber_t updateElement(132 const boost::function<const atomId_t ()> &_getAtomIndex);133 static ListOfBonds_t updateBonds(134 153 const boost::function<const atomId_t ()> &_getAtomIndex); 135 154 … … 138 157 //!> contains the current atom index 139 158 AtomIndex, 159 //!> contains the current set of bonds atoms for the atom 160 AtomBonds, 161 //!> contains the current atom element 162 AtomElement, 163 //!> contains the current atom's molecule index 164 AtomMoleculeIndex, 165 //!> contains the current atom position 166 AtomName, 140 167 //!> contains the current atom position 141 168 AtomPosition, 142 //!> contains the current atom element143 AtomElement,144 //!> contains the current set of bonds atoms fort the atom145 AtomBonds,146 169 //!> gives the size of the enumeration 147 170 MAX_ObservedTypes … … 175 198 //!> list of channels when index needs to update 176 199 static const Observable::channels_t AtomIndexChannels; 200 //!> list of channels when bonds needs to update 201 static const Observable::channels_t AtomBondsChannels; 202 //!> list of channels when element needs to update 203 static const Observable::channels_t AtomElementChannels; 204 //!> list of channels when molecule index needs to update 205 static const Observable::channels_t AtomMoleculeIndexChannels; 206 //!> list of channels when name needs to update 207 static const Observable::channels_t AtomNameChannels; 177 208 //!> list of channels when position needs to update 178 209 static const Observable::channels_t AtomPositionChannels; 179 //!> list of channels when element needs to update180 static const Observable::channels_t AtomElementChannels;181 //!> list of channels when bonds needs to update182 static const Observable::channels_t AtomBondsChannels;183 210 184 211 //!> we get multiple subjectKilled(), count and call callback() only on last
Note:
See TracChangeset
for help on using the changeset viewer.