Changeset 367489 for src/UIElements/Views/Qt4/QtInfoBox.cpp
- Timestamp:
- Feb 12, 2016, 11:15:40 PM (9 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:
- 3b9aa1
- Parents:
- 5a9e34
- git-author:
- Frederik Heber <heber@…> (10/30/15 11:06:30)
- git-committer:
- Frederik Heber <heber@…> (02/12/16 23:15:40)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/QtInfoBox.cpp
r5a9e34 r367489 40 40 #include "CodePatterns/MemDebug.hpp" 41 41 42 #include "Descriptors/AtomIdDescriptor.hpp" 43 #include "Descriptors/MoleculeIdDescriptor.hpp" 44 45 #include "molecule.hpp" 42 #include "UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.hpp" 43 46 44 #include "Element/element.hpp" 45 #include "Element/periodentafel.hpp" 47 46 #include "World.hpp" 48 47 … … 51 50 /***************** Basic structure for tab layout ***********/ 52 51 53 QtInfoBox::QtInfoBox( ) :52 QtInfoBox::QtInfoBox(QtObservedInstanceBoard *_board) : 54 53 QTabWidget(), 55 54 curAtomId(-1), nextAtomId(-1), 56 55 curMoleculeId(-1), nextMoleculeId(-1), 57 page_mol(NULL), page_atom(NULL) 56 page_mol(NULL), page_atom(NULL), 57 board(_board), 58 currentPage(0), 59 periode(World::getInstance().getPeriode()) 58 60 { 59 61 timer = new QTimer(this); … … 62 64 setMinimumWidth(200); 63 65 setMinimumHeight(220); 64 currentPage = 0;65 66 66 67 connect(timer, SIGNAL(timeout()), this, SLOT(timerTimeout())); … … 113 114 clearTabs(); 114 115 115 const atom *curAtom = const_cast<const World &>(World::getInstance()). 116 getAtom(AtomById(_id)); 117 curAtomId = curAtom->getId(); 118 nextAtomId = -1; 119 nextMoleculeId = -1; 116 QtObservedAtom::ptr curAtom = board->getObservedAtom(_id); 120 117 121 118 // Show new tabs. 122 119 if (curAtom){ 123 page_atom = new QtAtomInfoPage(curAtom, this); 120 curAtomId = curAtom->getAtomIndex(); 121 nextAtomId = -1; 122 nextMoleculeId = -1; 123 124 page_atom = new QtAtomInfoPage(curAtom, periode, this); 124 125 addTab(page_atom, "Atom"); 125 connect(page_atom, SIGNAL(atomKilled()), this, SLOT(clearTabs())); 126 127 if (curAtom->getMolecule()){ 128 page_mol = new QtMoleculeInfoPage(curAtom->getMolecule(), this); 129 addTab(page_mol, "Molecule"); 130 connect(page_mol, SIGNAL(moleculeKilled()), this, SLOT(clearTabs())); 131 132 if (currentPage > 0) 133 setCurrentIndex(currentPage); 126 connect(curAtom.get(), SIGNAL(atomRemoved()), this, SLOT(clearTabs())); 127 128 const moleculeId_t molid = curAtom->getAtomMoleculeIndex(); 129 if (molid != (moleculeId_t)-1) { 130 QtObservedMolecule::ptr curMolecule = board->getObservedMolecule(molid); 131 if (curMolecule) { 132 page_mol = new QtMoleculeInfoPage(curMolecule, this); 133 addTab(page_mol, "Molecule"); 134 connect(curMolecule.get(), SIGNAL(moleculeRemoved()), this, SLOT(clearMoleculeTab())); 135 136 if (currentPage > 0) 137 setCurrentIndex(currentPage); 138 } 134 139 } 135 140 } … … 143 148 clearTabs(); 144 149 145 const molecule *curMolecule = const_cast<const World &>(World::getInstance()). 146 getMolecule(MoleculeById(_id)); 150 QtObservedMolecule::ptr curMolecule = board->getObservedMolecule(_id); 147 151 nextAtomId = -1; 148 152 nextMoleculeId = -1; … … 152 156 page_mol = new QtMoleculeInfoPage(curMolecule, this); 153 157 addTab(page_mol, "Molecule"); 154 connect( page_mol, SIGNAL(moleculeKilled()), this, SLOT(clearTabs()));158 connect(curMolecule.get(), SIGNAL(moleculeRemoved()), this, SLOT(clearTabs())); 155 159 156 160 if (currentPage > 0) … … 168 172 } 169 173 170 QtAtomInfoPage::QtAtomInfoPage(const atom *_atom, QWidget *parent) : 174 QtAtomInfoPage::QtAtomInfoPage( 175 QtObservedAtom::ptr &_atom, 176 periodentafel *_periode, 177 QWidget *parent) : 171 178 QTreeWidget(parent), 172 Observer("QTAtomPage"), 173 atomRef(_atom) 174 { 175 atomRef->signOn(this); 176 179 atomRef(_atom), 180 periode(_periode) 181 { 177 182 setColumnCount(2); 178 183 QStringList header; … … 190 195 if (atomRef == NULL) 191 196 return; 192 addInfo(this, "Name", QString(atomRef->getName().c_str())); 193 addInfo(this, "Element", QString(atomRef->getElement().getName().c_str())); 194 addInfo(this, "Mass", QString("%1").arg(atomRef->getMass())); 195 addInfo(this, "Charge", QString("%1").arg(atomRef->getCharge())); 196 addInfo(this, "Bonds", QString("%1").arg(atomRef->getListOfBonds().size())); 197 addInfo(this, "Position x", QString(toString(atomRef->getPosition()[0]).c_str())); 198 addInfo(this, "Position y", QString(toString(atomRef->getPosition()[1]).c_str())); 199 addInfo(this, "Position z", QString(toString(atomRef->getPosition()[2]).c_str())); 197 const element * const _element = periode->FindElement(atomRef->getAtomElement()); 198 addInfo(this, "Name", QString(atomRef->getAtomName().c_str())); 199 addInfo(this, "Element", QString(_element->getName().c_str())); 200 addInfo(this, "Mass", QString("%1").arg(_element->getMass())); 201 addInfo(this, "Charge", QString("%1").arg(_element->getCharge())); 202 addInfo(this, "Bonds", QString("%1").arg(atomRef->getAtomBonds().size())); 203 addInfo(this, "Position x", QString(toString(atomRef->getAtomPosition()[0]).c_str())); 204 addInfo(this, "Position y", QString(toString(atomRef->getAtomPosition()[1]).c_str())); 205 addInfo(this, "Position z", QString(toString(atomRef->getAtomPosition()[2]).c_str())); 200 206 } 201 207 202 208 QtAtomInfoPage::~QtAtomInfoPage() 203 { 204 if (atomRef) 205 atomRef->signOff(this); 206 } 207 208 void QtAtomInfoPage::update(Observable *subject) 209 { 210 if (dynamic_cast<atom *>(subject) == atomRef) 211 updatePage(); 212 } 213 214 void QtAtomInfoPage::subjectKilled(Observable *subject){ 215 atomRef = NULL; 216 emit atomKilled(); 217 } 209 {} 218 210 219 211 /************************ Tab for single Molecules *****************/ 220 212 221 QtMoleculeInfoPage::QtMoleculeInfoPage(const molecule *_mol, QWidget *parent) : 213 QtMoleculeInfoPage::QtMoleculeInfoPage( 214 QtObservedMolecule::ptr &_mol, 215 QWidget *parent) : 222 216 QTreeWidget(parent), 223 Observer("QTMoleculePage"),224 217 mol(_mol) 225 218 { 226 mol->signOn(this);227 228 219 setColumnCount(2); 229 220 QStringList header; … … 241 232 if (mol == NULL) 242 233 return; 243 addInfo(this, "Name", QString(mol->get Name().c_str()));244 addInfo(this, "Formula", QString(mol->get Formula().toString().c_str()));234 addInfo(this, "Name", QString(mol->getMolName().c_str())); 235 addInfo(this, "Formula", QString(mol->getMolFormula().c_str())); 245 236 addInfo(this, "Atoms", QString("%1").arg(mol->getAtomCount())); 246 addInfo(this, "NonHydrogens", QString("%1").arg(mol->getNo NonHydrogen()));237 addInfo(this, "NonHydrogens", QString("%1").arg(mol->getNonHydrogenCount())); 247 238 addInfo(this, "Bonds", QString("%1").arg(mol->getBondCount())); 248 const Vector molCenter = mol-> DetermineCenterOfAll();239 const Vector molCenter = mol->getMolCenter(); 249 240 addInfo(this, "Center x", QString("%1").arg(molCenter[0])); 250 241 addInfo(this, "Center y", QString("%1").arg(molCenter[1])); … … 252 243 } 253 244 254 QtMoleculeInfoPage::~QtMoleculeInfoPage(){ 255 if (mol) 256 mol->signOff(this); 257 } 258 259 void QtMoleculeInfoPage::update(Observable *subject){ 260 if (dynamic_cast<molecule *>(subject) == mol) 261 updatePage(); 262 } 263 264 void QtMoleculeInfoPage::subjectKilled(Observable *subject){ 265 mol = NULL; 266 emit moleculeKilled(); 267 } 245 QtMoleculeInfoPage::~QtMoleculeInfoPage() 246 {}
Note:
See TracChangeset
for help on using the changeset viewer.