source: src/UIElements/Views/Qt4/MoleculeList/QtMoleculeList.hpp@ 015f8c

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 015f8c was 015f8c, checked in by Frederik Heber <heber@…>, 10 years ago

QtMainWindow uses QtSelectionChangedAgent.

  • QtMoleculeListView and GLWorldView receive its signals. The latter passes it on to GLWorldScene.
  • QtMoleculeList has new MoleculeIdToIndex to allow QtMoleculeListView to (un)select specific rows on a given index.
  • GLWorldScene passes atom and molecule selection to GLMoleculeObject_molecule.
  • GLMoleculeObject_molecule passes atom selection to respective GLMoleculeObject_atom.
  • Property mode set to 100644
File size: 5.5 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 "CodePatterns/Observer/Observer.hpp"
28
29#include "UIElements/Views/Qt4/MoleculeList/QtMoleculeItem.hpp"
30
31#include "types.hpp"
32
33class molecule;
34class MoleculeListClass;
35class QtMoleculeItem;
36class QtMoleculeListView;
37
38class QtMoleculeList : public QStandardItemModel, public Observer
39{
40 Q_OBJECT
41
42public:
43 QtMoleculeList();
44 virtual ~QtMoleculeList();
45
46protected:
47 virtual void update(Observable *publisher);
48 virtual void recieveNotification(Observable *publisher, Notification_ptr notification);
49 virtual void subjectKilled(Observable *publisher);
50
51 void refill();
52
53 QVariant headerData(int section, Qt::Orientation orientation, int role) const;
54
55private slots:
56 void moleculeChanged();
57// void visibilityChanged(QStandardItem*, int);
58 void checkForVisibilityChange(QStandardItem*);
59 void checkState();
60
61 friend class QtMoleculeItem;
62
63 std::string readdItem(QtMoleculeItem *_molitem);
64
65signals:
66 void moleculeSelected(molecule*);
67 void moleculeUnSelected(molecule*);
68 void moleculesVisibilityChanged(const moleculeId_t, bool);
69
70private:
71
72 bool ChangingChildrensVisibility;
73
74 mutable boost::recursive_mutex listAccessing_mutex;
75 mutable boost::recursive_mutex refill_mutex;
76 mutable boost::recursive_mutex map_mutex;
77
78 //!> informs the view in regular intervals about updates
79 QTimer *update_timer;
80
81 //!> how often per second update is signalled to view
82 static const unsigned int update_times_per_second;
83
84 friend class QtMoleculeListView;
85
86 bool isMoleculeItemPresent(const moleculeId_t _molid) const;
87 QtMoleculeItem * MoleculeIdToItem(const moleculeId_t _molid) const;
88 const moleculeId_t ItemToMoleculeId(const QtMoleculeItem * const _item) const;
89 const QModelIndex MoleculeIdToIndex(const moleculeId_t _id) const;
90 const moleculeId_t IndexToMoleculeId(const QModelIndex &_index) const;
91 QtMoleculeItem * getSpecificMoleculeItem(
92 const QtMoleculeItem * const _item,
93 const enum QtMoleculeItem::COLUMNTYPES _type) const;
94 bool isGroupItemPresent(const std::string &_formula) const;
95 const std::string& GroupItemToFormula(const QStandardItem * const _item) const;
96 QStandardItem * FormulaToGroupItem(const std::string &_formula) const;
97 QStandardItem * getSpecificGroupItem(
98 const QStandardItem * const _item,
99 const enum QtMoleculeItem::COLUMNTYPES _type) const;
100
101 std::string addMolecule(const molecule * const _mol);
102 void addGroupItem(QStandardItem *&mainitem, const std::string &_molecule_formula);
103 void addMoleculeItem(QStandardItem *_groupitem, const moleculeId_t _molid, const std::string &molecule_formula);
104 void removeMoleculeItem(QtMoleculeItem * const _item);
105 int setOccurrence(QStandardItem * const _groupitem);
106 bool areAnyItemsDirty();
107 void setVisibilityForMoleculeItem(QtMoleculeItem* _item);
108 void setVisibilityForGroupItem(QStandardItem* _item);
109
110 void informDirtyState(
111 const moleculeId_t _id,
112 const QtMoleculeItem::COLUMNTYPES _type,
113 const QtMoleculeItem::MoveTypes _movetype);
114
115 void receiveSubjectKilled(const moleculeId_t _id);
116
117 void updateItemStates();
118
119 typedef std::map<std::string, unsigned int> FormulaVisibilityCountMap_t;
120 FormulaVisibilityCountMap_t FormulaVisibilityCountMap;
121
122 typedef boost::bimap<std::string, QStandardItem*> FormulaTreeItemBiMap_t;
123 //!> map of (unique) formulas in the world
124 FormulaTreeItemBiMap_t FormulaItemBiMap;
125
126 typedef std::map<moleculeId_t, std::string> MoleculeFormulaMap_t;
127 //!> map of (unique) formulas in the world
128 MoleculeFormulaMap_t MoleculeFormulaMap;
129
130 typedef boost::bimap<moleculeId_t, QtMoleculeItem*> MoleculeItemBiMap_t;
131 MoleculeItemBiMap_t MoleculeItemBiMap;
132
133 //!> callback function to hand over to items that inform about requiring update
134 const QtMoleculeItem::emitDirtyState_t callback_DirtyItems;
135
136 //!> callback function to hand over to items that inform about called subjectKilled()
137 const QtMoleculeItem::emitSubjectKilledState_t callback_subjectKilledItems;
138
139 typedef std::map<moleculeId_t, unsigned int> KilledItemsPerMolecule_t;
140 //!> takes note of how many items have already been killed for a specific row/molecule
141 KilledItemsPerMolecule_t KilledItemsPerMolecule;
142
143 typedef std::set< moleculeId_t > list_of_molecules_t;
144 typedef std::set< std::pair<moleculeId_t, QtMoleculeItem::COLUMNTYPES> > list_of_molecule_items_t;
145 typedef std::set< std::pair<std::string, QtMoleculeItem::COLUMNTYPES> > list_of_group_items_t;
146 //!> list of molecule items that need an update
147 list_of_molecule_items_t dirtyMolItems;
148 //!> list of molecule items that need an update of visibility
149 list_of_molecules_t visibilityMolItems;
150 //!> list of group items that need an update
151 list_of_group_items_t dirtyGroupItems;
152 //!> list of group items that need an update of visibility
153 list_of_group_items_t visibilityGroupItems;
154 //!> list of new molecules which need to be added
155 std::vector<moleculeId_t> newMolecules;
156 //!> list of molecules that have been removed
157 std::vector<moleculeId_t> removedMolecules;
158 //!> list of molecule items to molecule's whose formulas has changed and need to be moved
159 list_of_molecules_t toBeMovedItems;
160};
161
162#endif /* QTMOLECULELIST_HPP_ */
Note: See TracBrowser for help on using the repository browser.