Changeset 1b6415a for src/UIElements/Qt4/InstanceBoard
- Timestamp:
- Feb 12, 2016, 11:15:39 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:
- ca1535
- Parents:
- ab628c
- git-author:
- Frederik Heber <heber@…> (10/29/15 21:55:51)
- git-committer:
- Frederik Heber <heber@…> (02/12/16 23:15:39)
- Location:
- src/UIElements/Qt4/InstanceBoard
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.cpp
rab628c r1b6415a 60 60 molecule::AtomInserted, 61 61 molecule::AtomRemoved, 62 molecule::FormulaChanged, 62 63 molecule::IndexChanged, 63 64 molecule::MoleculeNameChanged, … … 66 67 } 67 68 69 static const Observable::channels_t getAllAtomCountChannels() 70 { 71 Observable::channels_t channels; 72 channels += 73 molecule::AtomInserted, 74 molecule::AtomRemoved; 75 return channels; 76 } 77 68 78 // static instances 79 const Observable::channels_t QtObservedMolecule::AtomCountChannels(getAllAtomCountChannels()); 69 80 const Observable::channels_t QtObservedMolecule::BoundingBoxChannels(1, molecule::BoundingBoxChanged); 81 const Observable::channels_t QtObservedMolecule::FormulaStringChannels(1, molecule::FormulaChanged); 70 82 const Observable::channels_t QtObservedMolecule::IndexChannels(1, molecule::IndexChanged); 71 83 const Observable::channels_t QtObservedMolecule::NameChannels(1, molecule::MoleculeNameChanged); … … 154 166 { 155 167 const atomId_t _id = _molecule->lastChangedAtomId(); 168 emit atomcountChanged(); 156 169 emit atomInserted(_id); 157 170 break; … … 160 173 { 161 174 const atomId_t _id = _molecule->lastChangedAtomId(); 175 emit atomcountChanged(); 162 176 emit atomRemoved(_id); 163 177 break; … … 170 184 emit tesselationhullChanged(); 171 185 emit boundingboxChanged(); 186 break; 187 } 188 case molecule::FormulaChanged: 189 { 190 emit formulaChanged(); 172 191 break; 173 192 } … … 246 265 247 266 // fill ObservedValues: then all the other that need index 267 const boost::function<int ()> AtomCountUpdater( 268 boost::bind(&QtObservedMolecule::updateAtomCount, MolIndexGetter)); 269 const boost::function<std::string ()> MolFormulaUpdater( 270 boost::bind(&QtObservedMolecule::updateFormulaString, MolIndexGetter)); 248 271 const boost::function<std::string ()> MolNameUpdater( 249 272 boost::bind(&QtObservedMolecule::updateName, MolIndexGetter)); … … 251 274 boost::bind(&QtObservedMolecule::updateBoundingBox, MolIndexGetter)); 252 275 253 _ObservedValues[ MolName] = new ObservedValue_wCallback<std::string, moleculeId_t>(276 _ObservedValues[AtomCount] = new ObservedValue_wCallback<int, moleculeId_t>( 254 277 _molref, 255 MolNameUpdater,256 "Molecule Name_"+toString(_molid),257 MolNameUpdater(),258 NameChannels,278 AtomCountUpdater, 279 "MoleculeAtomCount_"+toString(_molid), 280 AtomCountUpdater(), 281 AtomCountChannels, 259 282 _subjectKilled, 260 283 MolIndexGetter); … … 267 290 _subjectKilled, 268 291 MolIndexGetter); 292 _ObservedValues[FormulaString] = new ObservedValue_wCallback<std::string, moleculeId_t>( 293 _molref, 294 MolFormulaUpdater, 295 "MoleculeFormula_"+toString(_molid), 296 MolFormulaUpdater(), 297 FormulaStringChannels, 298 _subjectKilled, 299 MolIndexGetter); 300 _ObservedValues[MolName] = new ObservedValue_wCallback<std::string, moleculeId_t>( 301 _molref, 302 MolNameUpdater, 303 "MoleculeName_"+toString(_molid), 304 MolNameUpdater(), 305 NameChannels, 306 _subjectKilled, 307 MolIndexGetter); 269 308 } 270 309 … … 273 312 { 274 313 delete boost::any_cast<ObservedValue_wCallback<moleculeId_t> *>(_ObservedValues[MolIndex]); 314 delete boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(_ObservedValues[AtomCount]); 315 delete boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(_ObservedValues[FormulaString]); 316 delete boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t> *>(_ObservedValues[BoundingBox]); 275 317 delete boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(_ObservedValues[MolName]); 276 delete boost::any_cast<ObservedValue_wCallback<molecule::BoundingBoxInfo, moleculeId_t> *>(_ObservedValues[BoundingBox]);277 318 _ObservedValues.clear(); 319 } 320 321 int QtObservedMolecule::updateAtomCount( 322 const boost::function<const moleculeId_t ()> &_getMolIndex) 323 { 324 const molecule * const mol = getMolecule(_getMolIndex()); 325 if (mol != NULL) 326 return mol->getAtomCount(); 327 else 328 return (int)0; 278 329 } 279 330 … … 288 339 } 289 340 341 std::string QtObservedMolecule::updateFormulaString( 342 const boost::function<const moleculeId_t ()> &_getMolIndex) 343 { 344 const molecule * const mol = getMolecule(_getMolIndex()); 345 if (mol != NULL) 346 return mol->getFormula().toString(); 347 else 348 return std::string(""); 349 } 350 290 351 moleculeId_t QtObservedMolecule::updateIndex() 291 352 { … … 303 364 } 304 365 366 int QtObservedMolecule::getAtomCount() const 367 { 368 return boost::any_cast<ObservedValue_wCallback<int, moleculeId_t> *>(ObservedValues[AtomCount])->get(); 369 } 370 371 std::string QtObservedMolecule::getMolFormula() const 372 { 373 return boost::any_cast<ObservedValue_wCallback<std::string, moleculeId_t> *>(ObservedValues[FormulaString])->get(); 374 } 375 305 376 moleculeId_t QtObservedMolecule::getMolIndex() const 306 377 { -
src/UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp
rab628c r1b6415a 78 78 void recieveNotification(Observable *publisher, Notification_ptr notification); 79 79 80 /** Getter to molecule atom count contained in \a ObservedValues. 81 * 82 * \return molecule's atom count 83 */ 84 int getAtomCount() const; 85 80 86 /** Getter to molecule index contained in \a ObservedValues. 81 87 * … … 90 96 std::string getMolName() const; 91 97 98 /** Getter to molecule formula contained in \a ObservedValues. 99 * 100 * \return molecule's formula 101 */ 102 std::string getMolFormula() const; 103 92 104 /** Getter to molecule's bounding box contained in \a ObservedValues. 93 105 * … … 99 111 100 112 signals: 113 void atomcountChanged(); 114 void formulaChanged(); 101 115 void indexChanged(); 102 116 void nameChanged(); … … 112 126 113 127 private: 128 static int updateAtomCount( 129 const boost::function<const moleculeId_t ()> &_getMolIndex); 114 130 static molecule::BoundingBoxInfo updateBoundingBox( 131 const boost::function<const moleculeId_t ()> &_getMolIndex); 132 static std::string updateFormulaString( 115 133 const boost::function<const moleculeId_t ()> &_getMolIndex); 116 134 static moleculeId_t updateIndex(); … … 118 136 const boost::function<const moleculeId_t ()> &_getMolIndex); 119 137 138 //!> list of channels when atom count needs to update 139 static const Observable::channels_t AtomCountChannels; 120 140 //!> list of channels when bounding box needs to update 121 141 static const Observable::channels_t BoundingBoxChannels; 142 //!> list of channels when formula needs to update 143 static const Observable::channels_t FormulaStringChannels; 122 144 //!> list of channels when the index needs to update 123 145 static const Observable::channels_t IndexChannels; … … 130 152 //!> enumeration of observed values to match with entries in ObservedValues 131 153 enum ObservedTypes { 154 //!> contains the current molecule's atom count 155 AtomCount, 156 //!> contains the current molecule's formula 157 FormulaString, 132 158 //!> contains the current molecule index 133 159 MolIndex,
Note:
See TracChangeset
for help on using the changeset viewer.