Changeset ee3fb8 for src/UIElements
- Timestamp:
- Apr 20, 2016, 8:53:33 AM (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:
- bf6245
- Parents:
- 62a127
- git-author:
- Frederik Heber <heber@…> (03/22/16 11:58:35)
- git-committer:
- Frederik Heber <heber@…> (04/20/16 08:53:33)
- Location:
- src/UIElements/Qt4/InstanceBoard
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Qt4/InstanceBoard/QtObservedAtom.cpp
r62a127 ree3fb8 106 106 ObservedValues(QtObservedAtom::MAX_ObservedTypes) 107 107 { 108 boost::function<void ( const atomId_t)> atomSubjectKilled(108 boost::function<void (ObservedValue_Index_t)> atomSubjectKilled( 109 109 boost::bind(&QtObservedAtom::countValuesSubjectKilled, 110 110 boost::ref(*this), 111 _1));111 boost::bind(&QtObservedAtom::getIndex, boost::ref(*this)))); 112 112 initObservedValues( ObservedValues, _id, _atom, atomSubjectKilled); 113 113 … … 117 117 QtObservedAtom::~QtObservedAtom() 118 118 { 119 boost::any_cast<ObservedValue_wCallback<atomId_t > *>(ObservedValues[AtomIndex])->noteCallBackIsGone();120 boost::any_cast<ObservedValue_wCallback<ListOfBonds_t, atomId_t> *>(ObservedValues[AtomBonds])->noteCallBackIsGone();121 boost::any_cast<ObservedValue_wCallback<atomicNumber_t, atomId_t> *>(ObservedValues[AtomElement])->noteCallBackIsGone();122 boost::any_cast<ObservedValue_wCallback<QtObservedMolecule*, atomId_t> *>(ObservedValues[AtomMolecule])->noteCallBackIsGone();123 boost::any_cast<ObservedValue_wCallback<std::string, atomId_t> *>(ObservedValues[AtomName])->noteCallBackIsGone();124 boost::any_cast<ObservedValue_wCallback<Vector, atomId_t> *>(ObservedValues[AtomPosition])->noteCallBackIsGone();125 boost::any_cast<ObservedValue_wCallback<bool, atomId_t> *>(ObservedValues[AtomSelected])->noteCallBackIsGone();119 boost::any_cast<ObservedValue_wCallback<atomId_t, ObservedValue_Index_t> *>(ObservedValues[AtomIndex])->noteCallBackIsGone(); 120 boost::any_cast<ObservedValue_wCallback<ListOfBonds_t, ObservedValue_Index_t> *>(ObservedValues[AtomBonds])->noteCallBackIsGone(); 121 boost::any_cast<ObservedValue_wCallback<atomicNumber_t, ObservedValue_Index_t> *>(ObservedValues[AtomElement])->noteCallBackIsGone(); 122 boost::any_cast<ObservedValue_wCallback<QtObservedMolecule*, ObservedValue_Index_t> *>(ObservedValues[AtomMolecule])->noteCallBackIsGone(); 123 boost::any_cast<ObservedValue_wCallback<std::string, ObservedValue_Index_t> *>(ObservedValues[AtomName])->noteCallBackIsGone(); 124 boost::any_cast<ObservedValue_wCallback<Vector, ObservedValue_Index_t> *>(ObservedValues[AtomPosition])->noteCallBackIsGone(); 125 boost::any_cast<ObservedValue_wCallback<bool, ObservedValue_Index_t> *>(ObservedValues[AtomSelected])->noteCallBackIsGone(); 126 126 127 127 deactivateObserver(); … … 229 229 ++signedOffChannels; 230 230 231 checkForRemoval( );232 } 233 234 void QtObservedAtom::countValuesSubjectKilled( const atomId_t _id)235 { 236 ASSERT( _id == get AtomIndex(),237 "QtObservedAtom::countValuesSubjectKilled() - atom "+toString(get AtomIndex())231 checkForRemoval(getIndex()); 232 } 233 234 void QtObservedAtom::countValuesSubjectKilled(ObservedValue_Index_t _id) 235 { 236 ASSERT( _id == getIndex(), 237 "QtObservedAtom::countValuesSubjectKilled() - atom "+toString(getIndex()) 238 238 +" received countValuesSubjectKilled for atom id "+toString(_id)+"."); 239 239 240 240 ++subjectKilledCount; 241 241 242 checkForRemoval( );243 } 244 245 #ifdef HAVE_INLINE 246 inline 247 #endif 248 void QtObservedAtom::checkForRemoval( )242 checkForRemoval(_id); 243 } 244 245 #ifdef HAVE_INLINE 246 inline 247 #endif 248 void QtObservedAtom::checkForRemoval(ObservedValue_Index_t _id) 249 249 { 250 250 if ((signedOffChannels == AllsignedOnChannels) && (subjectKilledCount == MAX_ObservedTypes)) { … … 255 255 256 256 if (!BoardIsGone) { 257 board.markObservedAtomAsDisconnected( getIndex());258 board.markObservedAtomForErase( getIndex());257 board.markObservedAtomAsDisconnected(_id); 258 board.markObservedAtomForErase(_id); 259 259 } 260 260 } … … 332 332 const atomId_t _id, 333 333 const atom * const _atomref, 334 const boost::function<void(const atomId_t)> &_subjectKilled) 335 { 336 /* This is an old note from when the code was still part of cstor's initializer body. 337 * TODO: Probably does not apply anymore but has not yet been tested. 338 * 339 * We must not use boost::cref(this) as "this" has not been properly constructed and seemingly 340 * boost::cref tries to do some magic to grasp the inheritance hierarchy which fails because 341 * the class has not been fully constructed yet. "This" itself seems to be working fine. 342 */ 343 334 const boost::function<void(ObservedValue_Index_t)> &_subjectKilled) 335 { 344 336 ASSERT( _ObservedValues.size() == MAX_ObservedTypes, 345 337 "QtObservedAtom::initObservedValues() - given ObservedValues has not correct size."); 346 338 347 339 // fill ObservedValues: index first 340 const boost::function<ObservedValue_Index_t ()> IndexGetter = 341 boost::bind(&QtObservedAtom::getIndex, 342 boost::cref(*this)); 343 344 // fill ObservedValues: then all the other that need index 348 345 const boost::function<atomId_t ()> AtomIndexUpdater( 349 346 boost::bind(&QtObservedAtom::updateIndex, boost::cref(*_atomref))); 350 351 ObservedValue_wCallback<atomId_t> * const IndexObservable =352 new ObservedValue_wCallback<atomId_t>(353 _atomref,354 AtomIndexUpdater,355 "AtomIndex_"+toString(_id),356 _id,357 AtomIndexChannels,358 _subjectKilled);359 _ObservedValues[AtomIndex] = IndexObservable;360 361 const boost::function<const atomId_t ()> AtomIndexGetter =362 boost::bind(&ObservedValue_wCallback<atomId_t>::get,363 IndexObservable);364 365 // fill ObservedValues: then all the other that need index366 347 const boost::function<ListOfBonds_t ()> AtomBondsUpdater( 367 348 boost::bind(&QtObservedAtom::updateBonds, boost::cref(*_atomref))); … … 377 358 boost::bind(&QtObservedAtom::updateSelected, boost::cref(*_atomref))); 378 359 379 _ObservedValues[AtomBonds] = new ObservedValue_wCallback<ListOfBonds_t, atomId_t>( 360 _ObservedValues[AtomIndex] = new ObservedValue_wCallback<atomId_t, ObservedValue_Index_t>( 361 _atomref, 362 AtomIndexUpdater, 363 "AtomIndex_"+toString(_id), 364 _id, 365 AtomIndexChannels, 366 _subjectKilled, 367 IndexGetter); 368 _ObservedValues[AtomBonds] = new ObservedValue_wCallback<ListOfBonds_t, ObservedValue_Index_t>( 380 369 _atomref, 381 370 AtomBondsUpdater, … … 384 373 AtomBondsChannels, 385 374 _subjectKilled, 386 AtomIndexGetter);387 _ObservedValues[AtomElement] = new ObservedValue_wCallback<atomicNumber_t, atomId_t>(375 IndexGetter); 376 _ObservedValues[AtomElement] = new ObservedValue_wCallback<atomicNumber_t, ObservedValue_Index_t>( 388 377 _atomref, 389 378 AtomElementUpdater, … … 392 381 AtomElementChannels, 393 382 _subjectKilled, 394 AtomIndexGetter);395 _ObservedValues[AtomMolecule] = new ObservedValue_wCallback<QtObservedMolecule*, atomId_t>(383 IndexGetter); 384 _ObservedValues[AtomMolecule] = new ObservedValue_wCallback<QtObservedMolecule*, ObservedValue_Index_t>( 396 385 _atomref, 397 386 AtomMoleculeUpdater, … … 400 389 AtomMoleculeChannels, 401 390 _subjectKilled, 402 AtomIndexGetter);403 _ObservedValues[AtomName] = new ObservedValue_wCallback<std::string, atomId_t>(391 IndexGetter); 392 _ObservedValues[AtomName] = new ObservedValue_wCallback<std::string, ObservedValue_Index_t>( 404 393 _atomref, 405 394 AtomNameUpdater, … … 408 397 AtomNameChannels, 409 398 _subjectKilled, 410 AtomIndexGetter);411 _ObservedValues[AtomPosition] = new ObservedValue_wCallback<Vector, atomId_t>(399 IndexGetter); 400 _ObservedValues[AtomPosition] = new ObservedValue_wCallback<Vector, ObservedValue_Index_t>( 412 401 _atomref, 413 402 AtomPositionUpdater, … … 416 405 AtomPositionChannels, 417 406 _subjectKilled, 418 AtomIndexGetter);419 _ObservedValues[AtomSelected] = new ObservedValue_wCallback<bool, atomId_t>(407 IndexGetter); 408 _ObservedValues[AtomSelected] = new ObservedValue_wCallback<bool, ObservedValue_Index_t>( 420 409 _atomref, 421 410 AtomSelectedUpdater, … … 424 413 AtomSelectedChannels, 425 414 _subjectKilled, 426 AtomIndexGetter);415 IndexGetter); 427 416 } 428 417 … … 430 419 std::vector<boost::any> &_ObservedValues) 431 420 { 432 delete boost::any_cast<ObservedValue_wCallback<atomId_t > *>(_ObservedValues[AtomIndex]);433 delete boost::any_cast<ObservedValue_wCallback<ListOfBonds_t, atomId_t> *>(_ObservedValues[AtomBonds]);434 delete boost::any_cast<ObservedValue_wCallback<atomicNumber_t, atomId_t> *>(_ObservedValues[AtomElement]);435 delete boost::any_cast<ObservedValue_wCallback<QtObservedMolecule*, atomId_t> *>(_ObservedValues[AtomMolecule]);436 delete boost::any_cast<ObservedValue_wCallback<std::string, atomId_t> *>(_ObservedValues[AtomName]);437 delete boost::any_cast<ObservedValue_wCallback<Vector, atomId_t> *>(_ObservedValues[AtomPosition]);438 delete boost::any_cast<ObservedValue_wCallback<bool, atomId_t> *>(_ObservedValues[AtomSelected]);421 delete boost::any_cast<ObservedValue_wCallback<atomId_t, ObservedValue_Index_t> *>(_ObservedValues[AtomIndex]); 422 delete boost::any_cast<ObservedValue_wCallback<ListOfBonds_t, ObservedValue_Index_t> *>(_ObservedValues[AtomBonds]); 423 delete boost::any_cast<ObservedValue_wCallback<atomicNumber_t, ObservedValue_Index_t> *>(_ObservedValues[AtomElement]); 424 delete boost::any_cast<ObservedValue_wCallback<QtObservedMolecule*, ObservedValue_Index_t> *>(_ObservedValues[AtomMolecule]); 425 delete boost::any_cast<ObservedValue_wCallback<std::string, ObservedValue_Index_t> *>(_ObservedValues[AtomName]); 426 delete boost::any_cast<ObservedValue_wCallback<Vector, ObservedValue_Index_t> *>(_ObservedValues[AtomPosition]); 427 delete boost::any_cast<ObservedValue_wCallback<bool, ObservedValue_Index_t> *>(_ObservedValues[AtomSelected]); 439 428 _ObservedValues.clear(); 440 429 } … … 449 438 const atomId_t& QtObservedAtom::getAtomIndex() const 450 439 { 451 return boost::any_cast<ObservedValue_wCallback<atomId_t > *>(ObservedValues[AtomIndex])->get();440 return boost::any_cast<ObservedValue_wCallback<atomId_t, ObservedValue_Index_t> *>(ObservedValues[AtomIndex])->get(); 452 441 } 453 442 454 443 const QtObservedAtom::ListOfBonds_t& QtObservedAtom::getAtomBonds() const 455 444 { 456 return boost::any_cast<ObservedValue_wCallback<ListOfBonds_t, atomId_t> *>(ObservedValues[AtomBonds])->get();445 return boost::any_cast<ObservedValue_wCallback<ListOfBonds_t, ObservedValue_Index_t> *>(ObservedValues[AtomBonds])->get(); 457 446 } 458 447 459 448 const atomicNumber_t& QtObservedAtom::getAtomElement() const 460 449 { 461 return boost::any_cast<ObservedValue_wCallback<atomicNumber_t, atomId_t> *>(ObservedValues[AtomElement])->get();450 return boost::any_cast<ObservedValue_wCallback<atomicNumber_t, ObservedValue_Index_t> *>(ObservedValues[AtomElement])->get(); 462 451 } 463 452 464 453 QtObservedMolecule* const QtObservedAtom::getAtomMolecule() const 465 454 { 466 return boost::any_cast<ObservedValue_wCallback<QtObservedMolecule*, atomId_t> *>(ObservedValues[AtomMolecule])->get();455 return boost::any_cast<ObservedValue_wCallback<QtObservedMolecule*, ObservedValue_Index_t> *>(ObservedValues[AtomMolecule])->get(); 467 456 } 468 457 469 458 const std::string& QtObservedAtom::getAtomName() const 470 459 { 471 return boost::any_cast<ObservedValue_wCallback<std::string, atomId_t> *>(ObservedValues[AtomName])->get();460 return boost::any_cast<ObservedValue_wCallback<std::string, ObservedValue_Index_t> *>(ObservedValues[AtomName])->get(); 472 461 } 473 462 474 463 const Vector& QtObservedAtom::getAtomPosition() const 475 464 { 476 return boost::any_cast<ObservedValue_wCallback<Vector, atomId_t> *>(ObservedValues[AtomPosition])->get();465 return boost::any_cast<ObservedValue_wCallback<Vector, ObservedValue_Index_t> *>(ObservedValues[AtomPosition])->get(); 477 466 } 478 467 479 468 const bool QtObservedAtom::getAtomSelected() const 480 469 { 481 return boost::any_cast<ObservedValue_wCallback<bool, atomId_t> *>(ObservedValues[AtomSelected])->get();482 } 470 return boost::any_cast<ObservedValue_wCallback<bool, ObservedValue_Index_t> *>(ObservedValues[AtomSelected])->get(); 471 } -
src/UIElements/Qt4/InstanceBoard/QtObservedAtom.hpp
r62a127 ree3fb8 207 207 const atomId_t _id, 208 208 const atom * const _atomref, 209 const boost::function<void( const atomId_t)> &_subjectKilled);209 const boost::function<void(ObservedValue_Index_t)> &_subjectKilled); 210 210 211 211 /** Destroys all \a ObservedValues entries. … … 227 227 * \param _id id to check against ours 228 228 */ 229 void countValuesSubjectKilled( const atomId_t _id);229 void countValuesSubjectKilled(ObservedValue_Index_t _id); 230 230 231 231 //!> counts how many ObservedValues have already been subjectKilled() … … 235 235 * this instance and all its internal observed values. 236 236 * 237 */ 238 void checkForRemoval(); 237 * \param _id id to check against ours 238 */ 239 void checkForRemoval(ObservedValue_Index_t _id); 239 240 240 241 private:
Note:
See TracChangeset
for help on using the changeset viewer.