Changeset 7d0ddb for src/UIElements/Views
- Timestamp:
- Jul 25, 2015, 1:02:11 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:
- ea73ce
- Parents:
- 9d4f964
- git-author:
- Frederik Heber <heber@…> (06/17/15 22:06:29)
- git-committer:
- Frederik Heber <heber@…> (07/25/15 13:02:11)
- Location:
- src/UIElements/Views/Qt4/MoleculeList
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/MoleculeList/QtMoleculeItem.cpp
r9d4f964 r7d0ddb 143 143 { 144 144 const molecule * const mol = const_cast<const World &>(World::getInstance()).getMolecule(MoleculeById(molid)); 145 ASSERT (mol != NULL,146 "QtMoleculeItem::getMolecule() - mol with "+toString(molid)+" is gone.");145 // ASSERT (mol != NULL, 146 // "QtMoleculeItem::getMolecule() - mol with "+toString(molid)+" is gone."); 147 147 return mol; 148 148 } -
src/UIElements/Views/Qt4/MoleculeList/QtMoleculeItem.hpp
r9d4f964 r7d0ddb 69 69 const molecule * const getMolecule() const; 70 70 71 /** Getter for the id of the molecule this item is associated to 72 * 73 * \return id of molecule 74 */ 75 moleculeId_t getMoleculeId() const 76 { return molid; } 77 71 78 private: 72 79 void update(Observable *publisher); -
src/UIElements/Views/Qt4/MoleculeList/QtMoleculeItemFactory.cpp
r9d4f964 r7d0ddb 72 72 // fill all the static channels lists 73 73 const_cast<QtMoleculeItem::channellist_t &>( 74 QtMoleculeItem_name::channellist_name) +=75 molecule::MoleculeNameChanged;76 const_cast<QtMoleculeItem::channellist_t &>(77 74 QtMoleculeItem_atomcount::channellist_atomcount) += 75 molecule::AboutToBeRemoved, 78 76 molecule::AtomInserted, 79 77 molecule::AtomRemoved; 80 78 const_cast<QtMoleculeItem::channellist_t &>( 81 79 QtMoleculeItem_formula::channellist_formula) += 80 molecule::AboutToBeRemoved, 82 81 molecule::FormulaChanged; 82 const_cast<QtMoleculeItem::channellist_t &>( 83 QtMoleculeItem_name::channellist_name) += 84 molecule::AboutToBeRemoved, 85 molecule::MoleculeNameChanged; 86 const_cast<QtMoleculeItem::channellist_t &>( 87 QtMoleculeItem_occurrence::channellist_occurrence) += 88 molecule::AboutToBeRemoved; 89 const_cast<QtMoleculeItem::channellist_t &>( 90 QtMoleculeItem_visibility::channellist_visibility) += 91 molecule::AboutToBeRemoved; 83 92 } 84 93 -
src/UIElements/Views/Qt4/MoleculeList/QtMoleculeList.cpp
r9d4f964 r7d0ddb 61 61 QtMoleculeList::QtMoleculeList() : 62 62 Observer("QtMoleculeList"), 63 changing(false),64 63 ChangingChildrensVisibility(false), 65 list_accessing(false),66 64 update_timer(NULL), 67 65 callback_DirtyItems(boost::bind(&QtMoleculeList::informDirtyState, this, _1, _2)) … … 138 136 { 139 137 const molecule * const mol = World::getInstance().lastChanged<molecule>(); 140 while(list_accessing); 141 list_accessing = true; 138 listAccessing_mutex.lock(); 142 139 newItems.push_back( mol ); 143 list _accessing = false;140 listAccessing_mutex.unlock(); 144 141 break; 145 142 } … … 148 145 const molecule * const mol = World::getInstance().lastChanged<molecule>(); 149 146 150 while(list_accessing); 151 list_accessing = true; 147 listAccessing_mutex.lock(); 152 148 toBeRemovedItems.push_back( mol ); // remove in any case, as we also got insert 153 list _accessing = false;149 listAccessing_mutex.unlock(); 154 150 155 151 const QtMoleculeItem *mol_item = MoleculeIdToItem(mol->getId()); … … 186 182 QStandardItem *_groupitem) 187 183 { 188 while (list_accessing); 189 list_accessing = true; 184 listAccessing_mutex.lock(); 190 185 toBeSetOccurrenceItems.insert( _groupitem ); 191 list _accessing = false;186 listAccessing_mutex.unlock(); 192 187 } 193 188 … … 271 266 update_timer->stop(); 272 267 273 changing = true;268 refill_mutex.lock(); 274 269 275 270 const std::vector<const molecule*> &molecules = … … 294 289 addMolecule(*iter); 295 290 296 changing = false;291 refill_mutex.unlock(); 297 292 298 293 // activate timer … … 303 298 { 304 299 // get whether any items are dirty 305 while (list_accessing); 306 list_accessing = true; 300 listAccessing_mutex.lock(); 307 301 bool dirty = false; 308 302 dirty |= !dirtyItems.empty(); … … 312 306 dirty |= !toBeSetOccurrenceItems.empty(); 313 307 dirty |= !toBeSetVisibilityItems.empty(); 314 list _accessing = false;308 listAccessing_mutex.unlock(); 315 309 return dirty; 316 310 } … … 333 327 if (_item->index().column() == QtMoleculeItemFactory::VISIBILITY) { 334 328 // qDebug() << "visibilityItem changed: " << (_item->checkState() ? "checked" : "unchecked"); 335 while(list_accessing); 336 list_accessing = true; 329 listAccessing_mutex.lock(); 337 330 if ((_item->parent() == NULL) || (_item->parent() == invisibleRootItem())) 338 331 toBeSetVisibilityItems.insert( _item ); 339 332 else 340 333 visibilityItems.insert( dynamic_cast<QtMoleculeItem *>(_item) ); 341 list _accessing = false;334 listAccessing_mutex.unlock(); 342 335 } 343 336 } … … 349 342 350 343 const bool visible = _item->checkState(); 351 const std::string &molecule_formula = _item->getMolecule()->getFormula().toString(); 352 ASSERT( FormulaVisibilityCountMap.count(molecule_formula) != 0, 353 "QtMoleculeList::setVisibilityForMoleculeItem() - molecule with formula " +molecule_formula 354 +" is not present in FormulaVisibilityCountMap."); 344 const molecule * const mol = _item->getMolecule(); 345 std::string molecule_formula; 346 if (mol != NULL) { 347 molecule_formula = mol->getFormula().toString(); 348 ASSERT( FormulaVisibilityCountMap.count(molecule_formula) != 0, 349 "QtMoleculeList::setVisibilityForMoleculeItem() - molecule with formula " +molecule_formula 350 +" is not present in FormulaVisibilityCountMap."); 351 } 355 352 356 353 // get parent … … 360 357 ASSERT( groupItem != NULL, 361 358 "QtMoleculeList::setVisibilityForMoleculeItem() - item with id " 362 +toString(_item->getMolecule ()->getId())+" has not parent?");359 +toString(_item->getMoleculeId())+" has not parent?"); 363 360 // check whether we have to set the group item 364 361 … … 469 466 addToBeSetOccurrence(groupitem); 470 467 // .. and re-add where new formula fits 471 const std::string molecule_formula = _molitem->getMolecule()->getFormula().toString(); 472 FormulaTreeItemMap_t::iterator iter = formula.find(molecule_formula); 473 if (iter == formula.end()) { 474 // add new group item and formula entry 475 addGroupItem(groupitem, molecule_formula); 476 } else { 477 groupitem = iter->second; 478 } 479 ASSERT( groupitem != NULL, 480 "QtMoleculeList::readdItem() - failed to create a sensible new groupitem"); 481 // finally add again 482 groupitem->appendRow(mol_row); 468 const molecule * const mol = _molitem->getMolecule(); 469 std::string molecule_formula; 470 if (mol != NULL) { 471 molecule_formula = mol->getFormula().toString(); 472 FormulaTreeItemMap_t::iterator iter = formula.find(molecule_formula); 473 if (iter == formula.end()) { 474 // add new group item and formula entry 475 addGroupItem(groupitem, molecule_formula); 476 } else { 477 groupitem = iter->second; 478 } 479 ASSERT( groupitem != NULL, 480 "QtMoleculeList::readdItem() - failed to create a sensible new groupitem"); 481 // finally add again 482 groupitem->appendRow(mol_row); 483 } 483 484 // call setOccurrence on the new group later 484 485 addToBeSetOccurrence(groupitem); … … 489 490 const QtMoleculeItem::MoveTypes _type) 490 491 { 491 while (list_accessing);492 list_accessing = true; 493 492 refill_mutex.lock(); 493 494 listAccessing_mutex.lock(); 494 495 dirtyItems.insert(_item); 496 listAccessing_mutex.unlock(); 495 497 if (_type == QtMoleculeItem::NeedsMove) { 496 498 // we have to convert whatever item raised the dirty signal to the first … … 500 502 QtMoleculeItem *mol_item = 501 503 dynamic_cast<QtMoleculeItem *>(group_item->child(_item->row(), 0)); 504 listAccessing_mutex.lock(); 502 505 toBeMovedItems.insert(mol_item); 506 listAccessing_mutex.unlock(); 503 507 // // add group item, too 504 508 // toBeSetOccurrenceItems.insert(group_item); 505 509 } 506 510 507 list_accessing = false;511 refill_mutex.unlock(); 508 512 } 509 513 … … 511 515 { 512 516 // wait till initial refill has been executed 513 if (changing) 514 return; 515 516 changing = true; 517 refill_mutex.lock(); 517 518 518 519 /// copy lists such that new signals for dirty/.. may come in right away 519 520 // TODO: if we had move semantics ... 520 while (list_accessing); 521 list_accessing = true; 521 listAccessing_mutex.lock(); 522 522 list_of_items_t dirtyItems_copy = dirtyItems; 523 523 dirtyItems.clear(); … … 534 534 std::set<QStandardItem*> toBeSetVisibilityItems_copy = toBeSetVisibilityItems; 535 535 toBeSetVisibilityItems.clear(); 536 list _accessing = false;536 listAccessing_mutex.unlock(); 537 537 538 538 /// first check consistency among the sets: … … 667 667 668 668 // and done 669 changing = false;670 } 669 refill_mutex.unlock(); 670 } -
src/UIElements/Views/Qt4/MoleculeList/QtMoleculeList.hpp
r9d4f964 r7d0ddb 17 17 #include <QtGui/QStandardItem> 18 18 #include <QtGui/QStandardItemModel> 19 #include <QMutex> 19 20 #include <QTimer> 20 21 … … 69 70 private: 70 71 71 bool changing;72 72 bool ChangingChildrensVisibility; 73 bool list_accessing; 73 74 QMutex listAccessing_mutex; 75 QMutex refill_mutex; 74 76 75 77 //!> informs the view in regular intervals about updates
Note:
See TracChangeset
for help on using the changeset viewer.