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.

Location:
src/UIElements/Views/Qt4
Files:
2 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{}
  • src/UIElements/Views/Qt4/QtInfoBox.hpp

    r5a9e34 r367489  
    2020#include <QTimer>
    2121
    22 #include "CodePatterns/Observer/Observer.hpp"
     22#include "UIElements/Qt4/InstanceBoard/QtObservedAtom.hpp"
     23#include "UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp"
    2324
    2425#include "types.hpp"
    2526
    26 class molecule;
    27 class atom;
     27class periodentafel;
    2828
    2929// Forwarding of the Tab-Pages
     
    3131class QtMoleculeInfoPage;
    3232
     33class QtObservedInstanceBoard;
     34
    3335class QtInfoBox : public QTabWidget
    3436{
    3537  Q_OBJECT
    3638public:
    37   QtInfoBox();
     39  QtInfoBox(QtObservedInstanceBoard *_board);
    3840  virtual ~QtInfoBox();
    3941
     
    5860  QTimer *timer;
    5961
     62  QtObservedInstanceBoard *board;
     63
    6064  int currentPage;
     65
     66  periodentafel *periode;
    6167};
    6268
     
    6470 * Widget to display the tab page for a single atom
    6571 */
    66 class QtAtomInfoPage : public QTreeWidget, public Observer {
     72class QtAtomInfoPage : public QTreeWidget
     73{
    6774  Q_OBJECT
    6875public:
    69   QtAtomInfoPage(const atom *_atom, QWidget *parent);
     76  QtAtomInfoPage(QtObservedAtom::ptr &_atom, periodentafel *_periode, QWidget *parent);
    7077  virtual ~QtAtomInfoPage();
    71   void update(Observable *subject);
    72   void subjectKilled(Observable *subject);
    7378
    74 signals:
    75   void atomKilled();
    76 
    77 private:
     79private slots:
    7880  void updatePage();
    7981
    8082private:
    81   const atom *atomRef;
     83  QtObservedAtom::ptr atomRef;
     84  periodentafel *periode;
    8285  QTreeWidget *info;
    8386};
     
    8689 * Widget to display the tab page for a single molecule
    8790 */
    88 class QtMoleculeInfoPage : public QTreeWidget,  public Observer {
     91class QtMoleculeInfoPage : public QTreeWidget
     92{
    8993  Q_OBJECT
    9094public:
    91   QtMoleculeInfoPage(const molecule *_mol, QWidget *parent);
     95  QtMoleculeInfoPage(QtObservedMolecule::ptr &_mol, QWidget *parent);
    9296  virtual ~QtMoleculeInfoPage();
    9397
    94   void update(Observable *subject);
    95   void subjectKilled(Observable *subject);
    96 
    97   signals:
    98     void moleculeKilled();
    99 
    100 private:
     98private slots:
    10199  void updatePage();
    102100
    103101private:
    104   const molecule *mol;
     102  QtObservedMolecule::ptr mol;
    105103  QTreeWidget *info;
    106104};
Note: See TracChangeset for help on using the changeset viewer.