Ignore:
Timestamp:
Feb 12, 2016, 11:15:40 PM (9 years ago)
Author:
Frederik Heber <heber@…>
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)
Message:

QtInfoBox now obtains information completely from QtObservedInstanceBoard and ObservedValues.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Views/Qt4/QtInfoBox.cpp

    r5a9e34 r367489  
    4040#include "CodePatterns/MemDebug.hpp"
    4141
    42 #include "Descriptors/AtomIdDescriptor.hpp"
    43 #include "Descriptors/MoleculeIdDescriptor.hpp"
    44 
    45 #include "molecule.hpp"
     42#include "UIElements/Qt4/InstanceBoard/QtObservedInstanceBoard.hpp"
     43
    4644#include "Element/element.hpp"
     45#include "Element/periodentafel.hpp"
    4746#include "World.hpp"
    4847
     
    5150/***************** Basic structure for tab layout ***********/
    5251
    53 QtInfoBox::QtInfoBox() :
     52QtInfoBox::QtInfoBox(QtObservedInstanceBoard *_board) :
    5453    QTabWidget(),
    5554    curAtomId(-1), nextAtomId(-1),
    5655    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())
    5860{
    5961  timer = new QTimer(this);
     
    6264  setMinimumWidth(200);
    6365  setMinimumHeight(220);
    64   currentPage = 0;
    6566
    6667  connect(timer, SIGNAL(timeout()), this, SLOT(timerTimeout()));
     
    113114  clearTabs();
    114115
    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);
    120117
    121118  // Show new tabs.
    122119  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);
    124125    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      }
    134139    }
    135140  }
     
    143148  clearTabs();
    144149
    145   const molecule *curMolecule = const_cast<const World &>(World::getInstance()).
    146       getMolecule(MoleculeById(_id));
     150  QtObservedMolecule::ptr curMolecule = board->getObservedMolecule(_id);
    147151  nextAtomId = -1;
    148152  nextMoleculeId = -1;
     
    152156    page_mol = new QtMoleculeInfoPage(curMolecule, this);
    153157    addTab(page_mol, "Molecule");
    154     connect(page_mol, SIGNAL(moleculeKilled()), this, SLOT(clearTabs()));
     158    connect(curMolecule.get(), SIGNAL(moleculeRemoved()), this, SLOT(clearTabs()));
    155159
    156160    if (currentPage > 0)
     
    168172}
    169173
    170 QtAtomInfoPage::QtAtomInfoPage(const atom *_atom, QWidget *parent) :
     174QtAtomInfoPage::QtAtomInfoPage(
     175    QtObservedAtom::ptr &_atom,
     176    periodentafel *_periode,
     177    QWidget *parent) :
    171178  QTreeWidget(parent),
    172   Observer("QTAtomPage"),
    173   atomRef(_atom)
    174 {
    175   atomRef->signOn(this);
    176 
     179  atomRef(_atom),
     180  periode(_periode)
     181{
    177182  setColumnCount(2);
    178183  QStringList header;
     
    190195  if (atomRef == NULL)
    191196    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()));
    200206}
    201207
    202208QtAtomInfoPage::~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{}
    218210
    219211/************************ Tab for single Molecules *****************/
    220212
    221 QtMoleculeInfoPage::QtMoleculeInfoPage(const molecule *_mol, QWidget *parent) :
     213QtMoleculeInfoPage::QtMoleculeInfoPage(
     214    QtObservedMolecule::ptr &_mol,
     215    QWidget *parent) :
    222216    QTreeWidget(parent),
    223     Observer("QTMoleculePage"),
    224217    mol(_mol)
    225218{
    226   mol->signOn(this);
    227 
    228219  setColumnCount(2);
    229220  QStringList header;
     
    241232  if (mol == NULL)
    242233    return;
    243   addInfo(this, "Name", QString(mol->getName().c_str()));
    244   addInfo(this, "Formula", QString(mol->getFormula().toString().c_str()));
     234  addInfo(this, "Name", QString(mol->getMolName().c_str()));
     235  addInfo(this, "Formula", QString(mol->getMolFormula().c_str()));
    245236  addInfo(this, "Atoms", QString("%1").arg(mol->getAtomCount()));
    246   addInfo(this, "NonHydrogens", QString("%1").arg(mol->getNoNonHydrogen()));
     237  addInfo(this, "NonHydrogens", QString("%1").arg(mol->getNonHydrogenCount()));
    247238  addInfo(this, "Bonds", QString("%1").arg(mol->getBondCount()));
    248   const Vector molCenter = mol->DetermineCenterOfAll();
     239  const Vector molCenter = mol->getMolCenter();
    249240  addInfo(this, "Center x", QString("%1").arg(molCenter[0]));
    250241  addInfo(this, "Center y", QString("%1").arg(molCenter[1]));
     
    252243}
    253244
    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 }
     245QtMoleculeInfoPage::~QtMoleculeInfoPage()
     246{}
Note: See TracChangeset for help on using the changeset viewer.