- Timestamp:
- Aug 5, 2015, 5:32:08 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:
- 95f49f
- Parents:
- 20f9b5
- git-author:
- Frederik Heber <heber@…> (07/07/15 01:08:58)
- git-committer:
- Frederik Heber <heber@…> (08/05/15 17:32:08)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/QtElementList.cpp
r20f9b5 r88846b 66 66 setHeaderLabels(header); 67 67 68 { 69 periodentafel *&periode = World::getInstance().getPeriode(); 70 71 elementSelection.clear(); 72 73 int i; 74 75 clear(); 76 periodentafel::const_iterator iter; 77 for(iter = periode->begin(),i=0; 78 iter != periode->end(); 79 ++i,++iter) { 80 const element *e = iter->second; 81 int count = 0; 82 count = const_cast<const World &>(World::getInstance()). 83 getAllAtoms(AtomByType(e)).size(); 84 85 QTreeWidgetItem *treeItem = new QTreeWidgetItem(this); 86 treeItem->setText(NUMBER, QString::number(e->getAtomicNumber())); 87 treeItem->setText(NAME, QString(e->getName().c_str())); 88 treeItem->setText(SYMBOL, QString(e->getSymbol().c_str())); 89 treeItem->setText(MASS, QString::number(e->getMass())); 90 setOccurrence(*treeItem, count); 91 elementSelection.push_back(treeItem->isSelected()); 92 // insertTopLevelItem(e->getAtomicNumber()-1, treeItem); 93 } 94 } 68 95 dirty = true; 69 96 … … 74 101 // connect(this,SIGNAL(changed()),this,SLOT(update())); 75 102 76 // emit needsRefill();77 103 } 78 104 … … 91 117 { 92 118 if (notification->getChannelNo() == atom::ElementChanged) { 93 // updateElement(static_cast<atom &>(*publisher));94 119 dirty = true; 95 120 … … 101 126 void QtElementList::updateElement(const atom &_atom) 102 127 { 103 // this function has not been tested and is not used because it is 104 // incompatible with the current refill scheme 128 const atomicNumber_t newelement = _atom.getElementNo(); 129 atomicNumber_t oldelement = -1; 130 QTreeWidgetItem *newtreeItem = topLevelItem(newelement-1); 131 ASSERT( newtreeItem != NULL, 132 "QtElementList::updateElement() - new element item not present."); 133 // if (newtreeItem == NULL) { 134 // // add new item 135 // const element& e = _atom.getElement(); 136 // newtreeItem = new QTreeWidgetItem(); 137 // newtreeItem->setText(NUMBER, QString::number(e.getAtomicNumber())); 138 // newtreeItem->setText(NAME, QString(e.getName().c_str())); 139 // newtreeItem->setText(SYMBOL, QString(e.getSymbol().c_str())); 140 // newtreeItem->setText(MASS, QString::number(e.getMass())); 141 // setOccurrence(*newtreeItem, 0); 142 // elementSelection.push_back(newtreeItem->isSelected()); 143 // insertTopLevelItem(newelement-1, newtreeItem); 144 // } 105 145 AtomElementMap_t::iterator iter = AtomElementMap.find(_atom.getId()); 106 146 if (iter == AtomElementMap.end()) { 107 147 AtomElementMap.insert( std::make_pair(_atom.getId(), -1)); 108 148 iter = AtomElementMap.find(_atom.getId()); 109 } 110 const atomicNumber_t oldelement = iter->second; 111 const atomicNumber_t newelement = _atom.getElementNo(); 149 } else 150 oldelement = iter->second; 112 151 iter->second = newelement; 113 QTreeWidgetItem *oldtreeItem = NULL; 114 if (oldelement != (atomicNumber_t)-1) 115 oldtreeItem = topLevelItem(oldelement-1); 116 QTreeWidgetItem *newtreeItem = topLevelItem(newelement-1); 117 ASSERT( (newtreeItem != NULL), 118 "QtElementList::updateElement() - missing new element item."); 152 153 // reduce old occurence 119 154 if (oldelement != (atomicNumber_t)-1) { 155 QTreeWidgetItem *oldtreeItem = topLevelItem(oldelement-1); 156 ASSERT( oldtreeItem != NULL, 157 "QtElementList::updateElement() - old element item not present."); 120 158 const int count_old = oldtreeItem->text(OCCURRENCE).toInt(); 121 159 setOccurrence(*oldtreeItem, count_old-1); 122 160 } 161 // increase new occurence 123 162 const int count_new = newtreeItem->text(OCCURRENCE).toInt(); 124 163 setOccurrence(*newtreeItem, count_new+1); … … 130 169 "QtElementList::setOccurrence() - count for an elment < 0."); 131 170 132 // // something must be very wrong, rather refill 133 // dirty = true; 134 // refill(); 135 // } else { 136 if (count > 0) { 137 _item.setText(OCCURRENCE, QString::number(count)); 138 } else { 139 _item.setText(OCCURRENCE, "none"); 140 _item.setDisabled(true); 141 } 142 // } 171 if (count > 0) { 172 _item.setText(OCCURRENCE, QString::number(count)); 173 if (_item.isDisabled()) 174 _item.setDisabled(false); 175 } else { 176 _item.setText(OCCURRENCE, "none"); 177 _item.setDisabled(true); 178 } 143 179 } 144 180 … … 147 183 refill_mutex.lock(); 148 184 149 // periodentafel *&periode = World::getInstance().getPeriode();150 //151 // elementSelection.clear();152 //153 // int i;154 //155 // clear();156 // periodentafel::const_iterator iter;157 // for(iter = periode->begin(),i=0;158 // iter != periode->end();159 // ++i,++iter) {160 // const element *e = iter->second;161 // int count = 0;162 // count = const_cast<const World &>(World::getInstance()).163 // getAllAtoms(AtomByType(e)).size();164 //165 // QTreeWidgetItem *treeItem = new QTreeWidgetItem(this);166 // treeItem->setText(NUMBER, QString::number(e->getAtomicNumber()));167 // treeItem->setText(NAME, QString(e->getName().c_str()));168 // treeItem->setText(SYMBOL, QString(e->getSymbol().c_str()));169 // treeItem->setText(MASS, QString::number(e->getMass()));170 // setOccurrence(*treeItem, count);171 // elementSelection.push_back(treeItem->isSelected());172 // }173 // dirty = false174 185 const atom * const walker = const_cast<const World &>(World::getInstance()). 175 186 getAtom(AtomById(_atomid)); … … 178 189 else { 179 190 AtomElementMap_t::iterator iter = AtomElementMap.find(_atomid); 180 QTreeWidgetItem *oldtreeItem = topLevelItem(iter->second-1); 181 const int count_old = oldtreeItem->text(OCCURRENCE).toInt(); 182 setOccurrence(*oldtreeItem, count_old-1); 183 184 AtomElementMap.erase(iter); 191 if (iter != AtomElementMap.end()) { 192 QTreeWidgetItem *oldtreeItem = topLevelItem(iter->second-1); 193 const int count_old = oldtreeItem->text(OCCURRENCE).toInt(); 194 setOccurrence(*oldtreeItem, count_old-1); 195 196 AtomElementMap.erase(iter); 197 } 185 198 } 186 199
Note:
See TracChangeset
for help on using the changeset viewer.