source: src/UIElements/Views/Qt4/QtMoleculeView.cpp@ 4f7473

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 4f7473 was 4f7473, checked in by Michael Ankele <ankele@…>, 13 years ago

QtMoleculeView: show some data

  • Property mode set to 100644
File size: 4.2 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8/*
9 * QtMoleculeView.cpp
10 *
11 * Created on: Mar 4, 2010
12 * Author: crueger
13 */
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
20#include "Views/Qt4/QtMoleculeView.hpp"
21
22#include <iostream>
23#include <QAbstractItemView>
24
25#include "CodePatterns/MemDebug.hpp"
26
27#include "molecule.hpp"
28#include "Element/element.hpp"
29
30using namespace std;
31
32/***************** Basic structure for tab layout ***********/
33
34QtMoleculeView::QtMoleculeView() :
35 QTabWidget(),
36 page_mol(NULL), page_atom(NULL)
37{
38 /*allPage = new QTAllMoleculePage();
39 addTab(allPage,QString("All Molecules"));
40
41 connect(this,SIGNAL(addMolecule(molecule*)),allPage,SLOT(addMolecule(molecule*)));
42 connect(this,SIGNAL(removeMolecule(molecule*)),allPage,SLOT(removeMolecule(molecule*)));*/
43}
44
45QtMoleculeView::~QtMoleculeView()
46{}
47
48/*void QtMoleculeView::moleculeSelected(molecule *mol){
49 if(!pages.count(mol)){
50 string molName = mol->name;
51 QTMoleculePage *molPage = new QTMoleculePage(mol,molName);
52 addTab(molPage,QString(molName.c_str()));
53 pages[mol] = molPage;
54
55 connect(molPage,SIGNAL(nameChanged(QTMoleculePage*,std::string)),this,SLOT(nameChanged(QTMoleculePage*,std::string)));
56
57 emit addMolecule(mol);
58 }
59}
60
61void QtMoleculeView::moleculeUnSelected(molecule *mol){
62 if(pages.count(mol)){
63 QTMoleculePage *molPage = pages[mol];
64 removeTab(indexOf(molPage));
65 pages.erase(mol);
66 delete molPage;
67 emit removeMolecule(mol);
68 }
69}
70
71void QtMoleculeView::nameChanged(QTMoleculePage *page, std::string name){
72 setTabText(indexOf(page),QString(name.c_str()));
73}*/
74
75void QtMoleculeView::nameChanged(QTMoleculePage *page, std::string name){}
76
77void QtMoleculeView::atomHover(const atom *_atom)
78{
79 // Remove old tabs.
80 if (page_atom){
81 removeTab(indexOf(page_atom));
82 delete(page_atom);
83 page_atom = NULL;
84 }
85 if (page_mol){
86 removeTab(indexOf(page_mol));
87 delete(page_mol);
88 page_mol = NULL;
89 }
90
91
92 // Show new tabs.
93 if (_atom){
94 page_atom = new QTAtomPage(_atom);
95 addTab(page_atom, "Atom");
96
97 page_mol = new QTMoleculePage(_atom->getMolecule());
98 addTab(page_mol, "Molecule");
99 }
100}
101
102/************************ Tab for single Atoms ********************/
103
104static void addInfo(QTreeWidget *info, const QString &key, const QString &value)
105{
106 QTreeWidgetItem *treeItem = new QTreeWidgetItem(info);
107 treeItem->setText(0, key);
108 treeItem->setText(1, value);
109}
110
111QTAtomPage::QTAtomPage(const atom *_atom) :
112 Observer("QTAtomPage"),
113 atomRef(_atom)
114{
115 atomRef->signOn(this);
116
117 info = new QTreeWidget(this);
118 info->setColumnCount(2);
119 QStringList header;
120 header << "data";
121 header << "value";
122 info->setHeaderLabels(header);
123
124 addInfo(info, "Element", QString(atomRef->getElement().getName().c_str()));
125 addInfo(info, "Mass", QString("%1").arg(atomRef->getMass()));
126 addInfo(info, "Charge", QString("%1").arg(atomRef->getCharge()));
127 addInfo(info, "Position", QString(toString(atomRef->getPosition()).c_str()));
128 addInfo(info, "Bonds", QString("%1").arg(atomRef->getListOfBonds().size()));
129}
130
131QTAtomPage::~QTAtomPage()
132{
133 atomRef->signOff(this);
134}
135
136void QTAtomPage::update(Observable *subject){
137 /*if(name != atomRef->name){
138 name = atomRef->name;
139 emit nameChanged(this,name);
140 }*/
141}
142
143void QTAtomPage::subjectKilled(Observable *subject){}
144
145/************************ Tab for single Molecules *****************/
146
147QTMoleculePage::QTMoleculePage(const molecule *_mol) :
148 Observer("QTMoleculePage"),
149 mol(_mol)
150{
151 mol->signOn(this);
152
153 info = new QTreeWidget(this);
154 info->setColumnCount(2);
155 QStringList header;
156 header << "data";
157 header << "value";
158 info->setHeaderLabels(header);
159
160 addInfo(info, "Name", QString(mol->getName().c_str()));
161 addInfo(info, "Formula", QString(mol->getFormula().toString().c_str()));
162 addInfo(info, "Atoms", QString("%1").arg(mol->getAtomCount()));
163 addInfo(info, "Bonds", QString("%1").arg(mol->getBondCount()));
164}
165
166QTMoleculePage::~QTMoleculePage(){
167 mol->signOff(this);
168}
169
170void QTMoleculePage::update(Observable *subject){
171}
172
173void QTMoleculePage::subjectKilled(Observable *subject){}
Note: See TracBrowser for help on using the repository browser.