source: src/UIElements/Views/Qt4/QtInfoBox.cpp@ a8fc70

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 a8fc70 was 94d5ac6, checked in by Frederik Heber <heber@…>, 12 years ago

FIX: As we use GSL internally, we are as of now required to use GPL v2 license.

  • GNU Scientific Library is used at every place in the code, especially the sub-package LinearAlgebra is based on it which in turn is used really everywhere in the remainder of MoleCuilder. Hence, we have to use the GPL license for the whole of MoleCuilder. In effect, GPL's COPYING was present all along and stated the terms of the GPL v2 license.
  • Hence, I added the default GPL v2 disclaimer to every source file and removed the note about a (actually missing) LICENSE file.
  • also, I added a help-redistribute action which again gives the disclaimer of the GPL v2.
  • also, I changed in the disclaimer that is printed at every program start in builder_init.cpp.
  • TEST: Added check on GPL statement present in every module to test CodeChecks project-disclaimer.
  • Property mode set to 100644
File size: 4.7 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 *
6 *
7 * This file is part of MoleCuilder.
8 *
9 * MoleCuilder is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * MoleCuilder is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23/*
24 * QtInfoBox.cpp
25 *
26 * Created on: Mar 4, 2010
27 * Author: crueger
28 */
29
30// include config.h
31#ifdef HAVE_CONFIG_H
32#include <config.h>
33#endif
34
35#include "Views/Qt4/QtInfoBox.hpp"
36
37#include <iostream>
38#include <QAbstractItemView>
39
40#include "CodePatterns/MemDebug.hpp"
41
42#include "molecule.hpp"
43#include "Element/element.hpp"
44
45using namespace std;
46
47/***************** Basic structure for tab layout ***********/
48
49QtInfoBox::QtInfoBox() :
50 QTabWidget(),
51 curAtom(NULL), nextAtom(NULL),
52 page_mol(NULL), page_atom(NULL)
53{
54 timer = new QTimer(this);
55 timer->setSingleShot(true);
56
57 setMinimumWidth(200);
58 currentPage = 0;
59
60 connect(timer, SIGNAL(timeout()), this, SLOT(timerTimeout()));
61}
62
63QtInfoBox::~QtInfoBox()
64{
65 clearTabs();
66}
67
68void QtInfoBox::atomHover(const atom *_atom)
69{
70 nextAtom = _atom;
71 timer->start(500);
72}
73
74void QtInfoBox::timerTimeout()
75{
76 if (nextAtom)
77 showAtom(nextAtom);
78}
79
80void QtInfoBox::clearTabs()
81{
82 if (page_atom){
83 //removeTab(indexOf(page_atom));
84 delete(page_atom);
85 page_atom = NULL;
86 }
87 if (page_mol){
88 //removeTab(indexOf(page_mol));
89 delete(page_mol);
90 page_mol = NULL;
91 }
92}
93
94void QtInfoBox::showAtom(const atom *_atom)
95{
96 currentPage = currentIndex();
97
98 // Remove old tabs.
99 clearTabs();
100
101 curAtom = _atom;
102
103 // Show new tabs.
104 if (curAtom){
105 page_atom = new QtAtomInfoPage(curAtom, this);
106 addTab(page_atom, "Atom");
107 connect(page_atom, SIGNAL(atomKilled()), this, SLOT(clearTabs()));
108
109 if (curAtom->getMolecule()){
110 page_mol = new QtMoleculeInfoPage(curAtom->getMolecule(), this);
111 addTab(page_mol, "Molecule");
112 connect(page_mol, SIGNAL(moleculeKilled()), this, SLOT(clearTabs()));
113
114 if (currentPage > 0)
115 setCurrentIndex(currentPage);
116 }
117 }
118}
119
120/************************ Tab for single Atoms ********************/
121
122static void addInfo(QTreeWidget *info, const QString &key, const QString &value)
123{
124 QTreeWidgetItem *treeItem = new QTreeWidgetItem(info);
125 treeItem->setText(0, key);
126 treeItem->setText(1, value);
127}
128
129QtAtomInfoPage::QtAtomInfoPage(const atom *_atom, QWidget *parent) :
130 QTreeWidget(parent),
131 Observer("QTAtomPage"),
132 atomRef(_atom)
133{
134 atomRef->signOn(this);
135
136 setColumnCount(2);
137 QStringList header;
138 header << "data";
139 header << "value";
140 setHeaderLabels(header);
141
142 addInfo(this, "Element", QString(atomRef->getElement().getName().c_str()));
143 addInfo(this, "Mass", QString("%1").arg(atomRef->getMass()));
144 addInfo(this, "Charge", QString("%1").arg(atomRef->getCharge()));
145 addInfo(this, "Position", QString(toString(atomRef->getPosition()).c_str()));
146 addInfo(this, "Bonds", QString("%1").arg(atomRef->getListOfBonds().size()));
147}
148
149QtAtomInfoPage::~QtAtomInfoPage()
150{
151 if (atomRef)
152 atomRef->signOff(this);
153}
154
155void QtAtomInfoPage::update(Observable *subject){
156 /*if(name != atomRef->name){
157 name = atomRef->name;
158 emit nameChanged(this,name);
159 }*/
160}
161
162void QtAtomInfoPage::subjectKilled(Observable *subject){
163 atomRef = NULL;
164 emit atomKilled();
165}
166
167/************************ Tab for single Molecules *****************/
168
169QtMoleculeInfoPage::QtMoleculeInfoPage(const molecule *_mol, QWidget *parent) :
170 QTreeWidget(parent),
171 Observer("QTMoleculePage"),
172 mol(_mol)
173{
174 mol->signOn(this);
175
176 setColumnCount(2);
177 QStringList header;
178 header << "data";
179 header << "value";
180 setHeaderLabels(header);
181
182 addInfo(this, "Name", QString(mol->getName().c_str()));
183 addInfo(this, "Formula", QString(mol->getFormula().toString().c_str()));
184 addInfo(this, "Atoms", QString("%1").arg(mol->getAtomCount()));
185 addInfo(this, "Bonds", QString("%1").arg(mol->getBondCount()));
186}
187
188QtMoleculeInfoPage::~QtMoleculeInfoPage(){
189 if (mol)
190 mol->signOff(this);
191}
192
193void QtMoleculeInfoPage::update(Observable *subject){ std::cout << "tab mol update\n";
194}
195
196void QtMoleculeInfoPage::subjectKilled(Observable *subject){
197 mol = NULL;
198 emit moleculeKilled();
199}
Note: See TracBrowser for help on using the repository browser.