Changeset 69b434 for src/UIElements/Views
- Timestamp:
- Jun 23, 2015, 6:29:02 AM (10 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:
- 6b474e
- Parents:
- 704d59
- git-author:
- Frederik Heber <heber@…> (05/22/15 21:14:50)
- git-committer:
- Frederik Heber <heber@…> (06/23/15 06:29:02)
- Location:
- src/UIElements/Views/Qt4/MoleculeList
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/MoleculeList/QtMoleculeItem.cpp
r704d59 r69b434 41 41 #include "CodePatterns/MemDebug.hpp" 42 42 43 #include "CodePatterns/Assert.hpp" 44 #include "CodePatterns/toString.hpp" 45 43 46 #include "CodePatterns/Observer/Notification.hpp" 44 47 45 48 #include <algorithm> 46 49 50 #include "Descriptors/MoleculeIdDescriptor.hpp" 47 51 #include "molecule.hpp" 52 #include "World.hpp" 48 53 49 54 QtMoleculeItem::QtMoleculeItem( 50 const molecule * const _mol,55 const moleculeId_t _molid, 51 56 const channellist_t &_channellist, 52 57 const enum MoveTypes _movetype, 53 58 const emitDirtyState_t _emitDirtyState) : 54 59 Observer("QtMoleculeItem"), 55 mol (_mol),60 molid(_molid), 56 61 movetype(_movetype), 57 62 channellist(_channellist), … … 66 71 void QtMoleculeItem::signOnToMolecule() 67 72 { 68 if (!IsSignedOn) 69 for (channellist_t::const_iterator channeliter = channellist.begin(); 70 channeliter != channellist.end(); ++channeliter) 71 mol->signOn(this, *channeliter); 72 IsSignedOn = true; 73 const molecule *mol = World::getInstance().getMolecule(MoleculeById(molid)); 74 if (mol != NULL) { 75 if (!IsSignedOn) 76 for (channellist_t::const_iterator channeliter = channellist.begin(); 77 channeliter != channellist.end(); ++channeliter) 78 mol->signOn(this, *channeliter); 79 IsSignedOn = true; 80 } 73 81 } 74 82 75 83 void QtMoleculeItem::signOffFromMolecule() 76 84 { 77 if (IsSignedOn) 78 for (channellist_t::const_iterator channeliter = channellist.begin(); 79 channeliter != channellist.end(); ++channeliter) 80 mol->signOff(this, *channeliter); 85 const molecule *mol = World::getInstance().getMolecule(MoleculeById(molid)); 86 if (mol != NULL) { 87 if (IsSignedOn) 88 for (channellist_t::const_iterator channeliter = channellist.begin(); 89 channeliter != channellist.end(); ++channeliter) 90 mol->signOff(this, *channeliter); 91 } 81 92 IsSignedOn = false; 82 93 } … … 104 115 signOffFromMolecule(); 105 116 // prevent any remaining updates from accessing the molecule 106 //mol = NULL;117 //molid = -1; 107 118 dirty = false; 108 119 } else { … … 126 137 dirty = false; 127 138 } 139 140 const molecule * const QtMoleculeItem::getMolecule() const 141 { 142 const molecule * mol = World::getInstance().getMolecule(MoleculeById(molid)); 143 ASSERT (mol != NULL, 144 "QtMoleculeItem::getMolecule() - mol with "+toString(molid)+" is gone."); 145 return mol; 146 } -
src/UIElements/Views/Qt4/MoleculeList/QtMoleculeItem.hpp
r704d59 r69b434 52 52 53 53 QtMoleculeItem( 54 const molecule * const _mol,54 const moleculeId_t _molid, 55 55 const channellist_t &_channellist, 56 56 const enum MoveTypes _movetype, … … 67 67 * \return const ref to \a mol 68 68 */ 69 const molecule * const getMolecule() const 70 { return mol; } 69 const molecule * const getMolecule() const; 71 70 72 71 private: … … 85 84 86 85 //!> molecule we are signed on to 87 const molecule * const mol;86 const moleculeId_t molid; 88 87 89 88 private: -
src/UIElements/Views/Qt4/MoleculeList/QtMoleculeItemFactory.cpp
r704d59 r69b434 85 85 QList<QStandardItem *> 86 86 QtMoleculeItemFactory::createMoleculeItems( 87 const molecule * const _mol,87 const moleculeId_t _molid, 88 88 const QtMoleculeItem::emitDirtyState_t &_emitDirtyState) 89 89 { 90 90 QList<QStandardItem *> molItems; 91 molItems << new QtMoleculeItem_name(_mol , _emitDirtyState);92 molItems << new QtMoleculeItem_visibility(_mol , _emitDirtyState);93 molItems << new QtMoleculeItem_atomcount(_mol , _emitDirtyState);94 molItems << new QtMoleculeItem_formula(_mol , _emitDirtyState);95 molItems << new QtMoleculeItem_occurrence(_mol , _emitDirtyState);91 molItems << new QtMoleculeItem_name(_molid, _emitDirtyState); 92 molItems << new QtMoleculeItem_visibility(_molid, _emitDirtyState); 93 molItems << new QtMoleculeItem_atomcount(_molid, _emitDirtyState); 94 molItems << new QtMoleculeItem_formula(_molid, _emitDirtyState); 95 molItems << new QtMoleculeItem_occurrence(_molid, _emitDirtyState); 96 96 return molItems; 97 97 } -
src/UIElements/Views/Qt4/MoleculeList/QtMoleculeItemFactory.hpp
r704d59 r69b434 46 46 /** Creates all QtMoleculeItem's that make up the row for a single molecule. 47 47 * 48 * \param _mol ref to molecule which is stored internally48 * \param _molid id of molecule 49 49 * \param _emitDirtyState callback function to model to inform about required state update 50 50 * \return list of prepared items to be appended to a group item 51 51 */ 52 52 QList<QStandardItem *> createMoleculeItems( 53 const molecule * const _mol,53 const moleculeId_t _molid, 54 54 const QtMoleculeItem::emitDirtyState_t &_emitDirtyState); 55 55 -
src/UIElements/Views/Qt4/MoleculeList/QtMoleculeList.cpp
r704d59 r69b434 102 102 } 103 103 104 QtMoleculeItem * QtMoleculeList::Molecule ToItem(const molecule * const _mol) const104 QtMoleculeItem * QtMoleculeList::MoleculeIdToItem(const moleculeId_t _molid) const 105 105 { 106 106 MoleculeItemBiMap_t::left_const_iterator iter = 107 MoleculeItemBiMap.left.find(_mol );107 MoleculeItemBiMap.left.find(_molid); 108 108 if( iter != MoleculeItemBiMap.left.end()) 109 109 return iter->second; … … 112 112 } 113 113 114 const molecule * const QtMoleculeList::ItemToMolecule(const QtMoleculeItem * const _item) const114 const moleculeId_t QtMoleculeList::ItemToMoleculeId(const QtMoleculeItem * const _item) const 115 115 { 116 116 const MoleculeItemBiMap_t::right_const_iterator iter = … … 119 119 return iter->second; 120 120 else 121 return NULL;122 } 123 124 const molecule * const QtMoleculeList::IndexToMolecule(const QModelIndex &_index) const121 return -1; 122 } 123 124 const moleculeId_t QtMoleculeList::IndexToMoleculeId(const QModelIndex &_index) const 125 125 { 126 126 QtMoleculeItem * const item = dynamic_cast<QtMoleculeItem *>(itemFromIndex(_index)); 127 127 if (item == NULL) 128 return NULL;128 return -1; 129 129 else 130 return ItemToMolecule (item);130 return ItemToMoleculeId(item); 131 131 } 132 132 … … 153 153 list_accessing = false; 154 154 155 const QtMoleculeItem *mol_item = Molecule ToItem(mol);155 const QtMoleculeItem *mol_item = MoleculeIdToItem(mol->getId()); 156 156 if (mol_item != NULL) { 157 157 QStandardItem *parent_item = mol_item->parent(); … … 194 194 void QtMoleculeList::addMoleculeItem( 195 195 QStandardItem *_groupitem, 196 const molecule * const _mol,196 const moleculeId_t _molid, 197 197 const std::string &_molecule_formula) 198 198 { 199 199 QList<QStandardItem *> molItems = 200 QtMoleculeItemFactory::getInstance().createMoleculeItems(_mol , callback_DirtyItems);200 QtMoleculeItemFactory::getInstance().createMoleculeItems(_molid, callback_DirtyItems); 201 201 QtMoleculeItem *mol_item = dynamic_cast<QtMoleculeItem *>(molItems.front()); 202 202 ASSERT( mol_item != NULL, 203 203 "QtMoleculeList::addMoleculeItem() - item from factory was not a QtMoleculeItem?"); 204 MoleculeItemBiMap.left.insert( std::make_pair(_mol , mol_item) );204 MoleculeItemBiMap.left.insert( std::make_pair(_molid, mol_item) ); 205 205 // LOG(1, "Inserting molecule " << _mol->getId() << ": " << _mol); 206 206 _groupitem->appendRow(molItems); … … 242 242 243 243 // add molecule 244 addMoleculeItem(groupItem, _mol , molecule_formula);244 addMoleculeItem(groupItem, _mol->getId(), molecule_formula); 245 245 } 246 246 … … 567 567 for (std::vector<const molecule *>::iterator removeiter = toBeRemovedItems_copy.begin(); 568 568 removeiter != toBeRemovedItems_copy.end(); ++removeiter) { 569 QtMoleculeItem *item = Molecule ToItem(*removeiter);569 QtMoleculeItem *item = MoleculeIdToItem((*removeiter)->getId()); 570 570 dirtyItems_copy.erase(item); 571 571 toBeMovedItems_copy.erase(item); … … 577 577 (*visiter)->index().row(), 578 578 QtMoleculeItemFactory::NAME)); 579 const molecule *mol = ItemToMolecule(_item); 579 const moleculeId_t molid = ItemToMoleculeId(_item); 580 const molecule *mol = World::getInstance().getMolecule(MoleculeById(molid)); 580 581 if (std::binary_search( 581 582 toBeRemovedItems_copy.begin(), toBeRemovedItems_copy.end(), … … 613 614 removeiter != toBeRemovedItems_copy.end(); ++removeiter) { 614 615 // LOG(1, "Removing molecule " << *removeiter); // cannot access directly, molecule is gone 615 QtMoleculeItem *item = Molecule ToItem(*removeiter);616 QtMoleculeItem *item = MoleculeIdToItem((*removeiter)->getId()); 616 617 if (item != NULL) 617 618 removeItem(item); -
src/UIElements/Views/Qt4/MoleculeList/QtMoleculeList.hpp
r704d59 r69b434 81 81 friend class QtMoleculeListView; 82 82 83 QtMoleculeItem * Molecule ToItem(const molecule * const _mol) const;84 const molecule * const IndexToMolecule(const QModelIndex &_index) const;85 const molecule * const ItemToMolecule(const QtMoleculeItem * const _item) const;83 QtMoleculeItem * MoleculeIdToItem(const moleculeId_t _molid) const; 84 const moleculeId_t IndexToMoleculeId(const QModelIndex &_index) const; 85 const moleculeId_t ItemToMoleculeId(const QtMoleculeItem * const _item) const; 86 86 87 87 void addMolecule(const molecule * const _mol); 88 88 void addGroupItem(QStandardItem *&mainitem, const std::string &_molecule_formula); 89 void addMoleculeItem(QStandardItem *_groupitem, const molecule * const _mol, const std::string &molecule_formula);89 void addMoleculeItem(QStandardItem *_groupitem, const moleculeId_t _molid, const std::string &molecule_formula); 90 90 void removeItem(QtMoleculeItem * const _item); 91 91 int setOccurrence(QStandardItem * const _groupitem); … … 106 106 FormulaTreeItemMap_t formula; 107 107 108 typedef boost::bimap< const molecule *, QtMoleculeItem*> MoleculeItemBiMap_t;108 typedef boost::bimap<moleculeId_t, QtMoleculeItem*> MoleculeItemBiMap_t; 109 109 MoleculeItemBiMap_t MoleculeItemBiMap; 110 110 -
src/UIElements/Views/Qt4/MoleculeList/QtMoleculeListView.cpp
r704d59 r69b434 105 105 foreach (index, items) 106 106 if ((index.column() == 0) && (selectionModel()->isSelected(index))) { 107 const molecule *mol = moleculelist->IndexToMolecule(index); 108 if (mol == NULL) // means we are looking at deselection because of removal 109 continue; 110 int mol_id = mol->getId(); 107 const moleculeId_t mol_id = moleculelist->IndexToMoleculeId(index); 108 const molecule * const mol = World::getInstance().getMolecule(MoleculeById(mol_id)); 111 109 // check for invalid molecule 112 110 if (mol_id < 0) 113 111 continue; 114 112 // means we are looking at deselection because of removal (in World) 115 if ( World::getInstance().getMolecule(MoleculeById(mol_id)) != mol)113 if (mol == NULL) 116 114 continue; 117 115 if (!World::getInstance().isSelected(mol)) … … 129 127 ids.reserve(items.size()); 130 128 foreach (index, items) 131 if ((index.column() == 0) && (!selectionModel()->isSelected(index))) { 132 const molecule *mol = moleculelist->IndexToMolecule(index); 133 if (mol == NULL) // means we are looking at deselection because of removal 134 continue; 135 int mol_id = mol->getId(); 129 if ((index.column() == 0) && (!selectionModel()->isSelected(index))) { 130 const moleculeId_t mol_id = moleculelist->IndexToMoleculeId(index); 131 const molecule * const mol = World::getInstance().getMolecule(MoleculeById(mol_id)); 136 132 // check for invalid molecule 137 133 if (mol_id < 0) 138 134 continue; 139 135 // means we are looking at deselection because of removal (in World) 140 if ( World::getInstance().getMolecule(MoleculeById(mol_id)) != mol)136 if (mol == NULL) 141 137 continue; 142 138 if (World::getInstance().isSelected(mol)) … … 167 163 for (std::vector<molecule *>::const_iterator iter = selectedMolecules.begin(); 168 164 iter != selectedMolecules.end(); ++iter) { 169 QtMoleculeItem *item = moleculelist->Molecule ToItem(*iter);165 QtMoleculeItem *item = moleculelist->MoleculeIdToItem((*iter)->getId()); 170 166 if (item != NULL) { 171 167 QModelIndex mol_index = item->index(); -
src/UIElements/Views/Qt4/MoleculeList/SpecificItems/QtMoleculeItem_atomcount.hpp
r704d59 r69b434 16 16 #include "UIElements/Views/Qt4/MoleculeList/QtMoleculeItem.hpp" 17 17 18 #include "Descriptors/MoleculeIdDescriptor.hpp" 18 19 #include "molecule.hpp" 20 #include "World.hpp" 19 21 20 22 class QtMoleculeItemFactory; … … 29 31 30 32 QtMoleculeItem_atomcount( 31 const molecule * const _mol,33 const moleculeId_t _molid, 32 34 emitDirtyState_t _emitDirtyState) : 33 QtMoleculeItem(_mol , channellist_atomcount, QtMoleculeItem::NeedsMove, _emitDirtyState)35 QtMoleculeItem(_molid, channellist_atomcount, QtMoleculeItem::NeedsMove, _emitDirtyState) 34 36 { 35 37 // cannot call pure virtual function in QtMoleculeItem's cstor … … 42 44 void internal_updateState() 43 45 { 44 setText(QString::number(mol->getAtomCount())); 46 const molecule * mol = World::getInstance().getMolecule(MoleculeById(molid)); 47 if (mol != NULL) 48 setText(QString::number(mol->getAtomCount())); 49 else 50 setText(QString::number(-1)); 45 51 } 46 52 -
src/UIElements/Views/Qt4/MoleculeList/SpecificItems/QtMoleculeItem_formula.hpp
r704d59 r69b434 18 18 #include <string> 19 19 20 #include "Descriptors/MoleculeIdDescriptor.hpp" 20 21 #include "Formula.hpp" 21 22 #include "molecule.hpp" 23 #include "World.hpp" 22 24 23 25 class QtMoleculeItemFactory; … … 32 34 33 35 QtMoleculeItem_formula( 34 const molecule * const _mol,36 const moleculeId_t _molid, 35 37 emitDirtyState_t _emitDirtyState) : 36 QtMoleculeItem(_mol , channellist_formula, QtMoleculeItem::NeedsMove, _emitDirtyState)38 QtMoleculeItem(_molid, channellist_formula, QtMoleculeItem::NeedsMove, _emitDirtyState) 37 39 { 38 40 // cannot call pure virtual function in QtMoleculeItem's cstor … … 45 47 void internal_updateState() 46 48 { 47 setText(QString(mol->getFormula().toString().c_str())); 49 const molecule * mol = World::getInstance().getMolecule(MoleculeById(molid)); 50 if (mol != NULL) 51 setText(QString(mol->getFormula().toString().c_str())); 52 else 53 setText(QString("")); 48 54 } 49 55 -
src/UIElements/Views/Qt4/MoleculeList/SpecificItems/QtMoleculeItem_name.hpp
r704d59 r69b434 16 16 #include "UIElements/Views/Qt4/MoleculeList/QtMoleculeItem.hpp" 17 17 18 #include "Descriptors/MoleculeIdDescriptor.hpp" 18 19 #include "molecule.hpp" 20 #include "World.hpp" 19 21 20 22 class QtMoleculeItemFactory; … … 29 31 30 32 QtMoleculeItem_name( 31 const molecule * const _mol,33 const moleculeId_t _molid, 32 34 emitDirtyState_t _emitDirtyState) : 33 QtMoleculeItem(_mol , channellist_name, QtMoleculeItem::DoesNotMove, _emitDirtyState)35 QtMoleculeItem(_molid, channellist_name, QtMoleculeItem::DoesNotMove, _emitDirtyState) 34 36 { 35 37 // cannot call pure virtual function in QtMoleculeItem's cstor … … 42 44 void internal_updateState() 43 45 { 44 setText(QString(mol->getName().c_str())); 46 const molecule * mol = World::getInstance().getMolecule(MoleculeById(molid)); 47 if (mol != NULL) 48 setText(QString(mol->getName().c_str())); 49 else 50 setText(QString("to be removed")); 45 51 } 46 52 -
src/UIElements/Views/Qt4/MoleculeList/SpecificItems/QtMoleculeItem_occurrence.hpp
r704d59 r69b434 27 27 28 28 QtMoleculeItem_occurrence( 29 const molecule * const _mol,29 const moleculeId_t _molid, 30 30 emitDirtyState_t _emitDirtyState) : 31 QtMoleculeItem(_mol , channellist_occurrence, QtMoleculeItem::DoesNotMove, _emitDirtyState)31 QtMoleculeItem(_molid, channellist_occurrence, QtMoleculeItem::DoesNotMove, _emitDirtyState) 32 32 { 33 33 // cannot call pure virtual function in QtMoleculeItem's cstor -
src/UIElements/Views/Qt4/MoleculeList/SpecificItems/QtMoleculeItem_visibility.hpp
r704d59 r69b434 27 27 28 28 QtMoleculeItem_visibility( 29 const molecule * const _mol,29 const moleculeId_t _molid, 30 30 emitDirtyState_t _emitDirtyState) : 31 QtMoleculeItem(_mol , channellist_visibility, QtMoleculeItem::DoesNotMove, _emitDirtyState)31 QtMoleculeItem(_molid, channellist_visibility, QtMoleculeItem::DoesNotMove, _emitDirtyState) 32 32 { 33 33 setFlags(flags() | Qt::ItemIsUserCheckable);
Note:
See TracChangeset
for help on using the changeset viewer.