source: src/UIElements/Views/Qt4/MoleculeList/QtMoleculeList.hpp@ 50d49d

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
Last change on this file since 50d49d was 1b07b1, checked in by Frederik Heber <heber@…>, 9 years ago

QtObservedInstanceBoard now sends QtObserved..::ptr around in signals.

  • this should get rid of the problem that we need to keep the QtObservedAtom until it was requested at least once. And we don't know for how long. Now, we simply place the shared_ptr into the signal (to which it seems to be copied) and hence a representation of the atoms remains valid.
  • cstor of GLMoleculeObject_.. take Observed.. as ref.
  • Property mode set to 100644
File size: 5.4 KB
Line 
1/*
2 * QtMoleculeList.hpp
3 *
4 * Created on: Jan 21, 2010
5 * Author: crueger
6 */
7
8#ifndef QTMOLECULELIST_HPP_
9#define QTMOLECULELIST_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include <QtGui/QItemSelection>
17#include <QtGui/QStandardItem>
18#include <QtGui/QStandardItemModel>
19#include <QTimer>
20
21#include <boost/bimap.hpp>
22#include <boost/thread/recursive_mutex.hpp>
23#include <map>
24#include <set>
25#include <string>
26
27#include "UIElements/Views/Qt4/MoleculeList/QtMoleculeItem.hpp"
28#include "UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp"
29
30#include "types.hpp"
31
32class QtMoleculeItem;
33class QtMoleculeListView;
34class QtObservedInstanceBoard;
35
36class QtMoleculeList : public QStandardItemModel
37{
38 Q_OBJECT
39
40public:
41 QtMoleculeList(QtObservedInstanceBoard *_board, QObject *_parent = NULL);
42 virtual ~QtMoleculeList();
43
44 void resetUpdateTimer();
45
46 QVariant headerData(int section, Qt::Orientation orientation, int role) const;
47
48private slots:
49 void moleculeNameChanged(QStandardItem*);
50 void checkForVisibilityChange(QStandardItem*);
51 void checkState();
52
53 friend class QtMoleculeItem;
54
55 std::string readdItem(QtMoleculeItem *_molitem);
56
57signals:
58 void moleculeSelected(molecule*);
59 void moleculeUnSelected(molecule*);
60 void moleculesVisibilityChanged(const moleculeId_t, bool);
61
62private:
63
64 bool ChangingChildrensVisibility;
65
66private slots:
67 void moleculeInserted(QtObservedMolecule::ptr _mol);
68 void moleculeRemoved(const moleculeId_t _id);
69 void moleculeIndexChanged(const moleculeId_t _oldid, const moleculeId_t _newid);
70
71private:
72 mutable boost::recursive_mutex listAccessing_mutex;
73 mutable boost::recursive_mutex refill_mutex;
74 mutable boost::recursive_mutex map_mutex;
75
76 //!> informs the view in regular intervals about updates
77 QTimer *update_timer;
78
79 //!> how often per second update is signalled to view
80 static const unsigned int update_times_per_second;
81
82 friend class QtMoleculeListView;
83
84 bool isMoleculeItemPresent(const moleculeId_t _molid) const;
85 QtMoleculeItem * MoleculeIdToItem(const moleculeId_t _molid) const;
86 const moleculeId_t ItemToMoleculeId(const QtMoleculeItem * const _item) const;
87 const QModelIndex MoleculeIdToIndex(const moleculeId_t _id) const;
88 const moleculeId_t IndexToMoleculeId(const QModelIndex &_index) const;
89 QtMoleculeItem * getSpecificMoleculeItem(
90 const QtMoleculeItem * const _item,
91 const enum QtMoleculeItem::COLUMNTYPES _type) const;
92 bool isGroupItemPresent(const std::string &_formula) const;
93 const std::string& GroupItemToFormula(const QStandardItem * const _item) const;
94 QStandardItem * FormulaToGroupItem(const std::string &_formula) const;
95 QStandardItem * getSpecificGroupItem(
96 const QStandardItem * const _item,
97 const enum QtMoleculeItem::COLUMNTYPES _type) const;
98
99 std::string addMolecule(
100 QtObservedMolecule::ptr &_ObservedMolecule);
101 void addGroupItem(
102 QStandardItem *&mainitem,
103 const std::string &_molecule_formula);
104 QList<QStandardItem *> createMoleculeItems(
105 QtObservedMolecule::ptr &_ObservedMolecule,
106 std::string &molecule_formula);
107 void removeMoleculeItem(QtMoleculeItem * const _item);
108 int setOccurrence(QStandardItem * const _groupitem);
109 bool areAnyItemsDirty();
110 void setVisibilityForMoleculeItem(QtMoleculeItem* _item);
111 void setVisibilityForGroupItem(QStandardItem* _item);
112
113 void informDirtyState(
114 const moleculeId_t _id,
115 const QtMoleculeItem::COLUMNTYPES _type,
116 const QtMoleculeItem::MoveTypes _movetype);
117
118 void updateItemStates();
119
120 //!> reference to InstanceBoard
121 QtObservedInstanceBoard *board;
122
123 typedef std::map<std::string, unsigned int> FormulaVisibilityCountMap_t;
124 FormulaVisibilityCountMap_t FormulaVisibilityCountMap;
125
126 typedef boost::bimap<std::string, QStandardItem*> FormulaTreeItemBiMap_t;
127 //!> map of (unique) formulas in the world
128 FormulaTreeItemBiMap_t FormulaItemBiMap;
129
130 typedef std::map<moleculeId_t, std::string> MoleculeFormulaMap_t;
131 //!> map of (unique) formulas in the world
132 MoleculeFormulaMap_t MoleculeFormulaMap;
133
134 typedef boost::bimap<moleculeId_t, QtMoleculeItem*> MoleculeItemBiMap_t;
135 MoleculeItemBiMap_t MoleculeItemBiMap;
136
137 //!> callback function to hand over to items that inform about requiring update
138 const QtMoleculeItem::emitDirtyState_t callback_DirtyItems;
139
140 typedef std::map<moleculeId_t, unsigned int> KilledItemsPerMolecule_t;
141 //!> takes note of how many items have already been killed for a specific row/molecule
142 KilledItemsPerMolecule_t KilledItemsPerMolecule;
143
144 typedef std::set< moleculeId_t > list_of_molecules_t;
145 typedef std::set< std::pair<moleculeId_t, QtMoleculeItem::COLUMNTYPES> > list_of_molecule_items_t;
146 typedef std::set< std::pair<std::string, QtMoleculeItem::COLUMNTYPES> > list_of_group_items_t;
147
148 //!> list of molecule items that need an update
149 list_of_molecule_items_t dirtyMolItems;
150 //!> list of molecule items that need an update of visibility
151 list_of_molecules_t visibilityMolItems;
152 //!> list of group items that need an update
153 list_of_group_items_t dirtyGroupItems;
154 //!> list of group items that need an update of visibility
155 list_of_group_items_t visibilityGroupItems;
156 //!> list of new molecules which need to be added
157 std::vector<QtObservedMolecule::ptr> newMolecules;
158 //!> list of molecules that have been removed
159 std::vector<moleculeId_t> removedMolecules;
160 //!> list of molecule items to molecule's whose formulas has changed and need to be moved
161 list_of_molecules_t toBeMovedItems;
162};
163
164#endif /* QTMOLECULELIST_HPP_ */
Note: See TracBrowser for help on using the repository browser.