Ignore:
Timestamp:
Jul 17, 2012, 12:17:27 PM (13 years ago)
Author:
Michael Ankele <ankele@…>
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:
4a2f3e
Parents:
7b6bcfe
git-author:
Michael Ankele <ankele@…> (06/18/12 15:01:14)
git-committer:
Michael Ankele <ankele@…> (07/17/12 12:17:27)
Message:

QtMoleculeView: show some data

Location:
src/UIElements/Views/Qt4
Files:
2 edited

Legend:

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

    r7b6bcfe r4f7473  
    2121
    2222#include <iostream>
     23#include <QAbstractItemView>
    2324
    2425#include "CodePatterns/MemDebug.hpp"
    2526
    2627#include "molecule.hpp"
     28#include "Element/element.hpp"
    2729
    2830using namespace std;
     
    9092  // Show new tabs.
    9193  if (_atom){
    92     page_atom = new QTAtomPage(_atom, "test");
    93     addTab(page_atom, "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");
    9499  }
    95100}
     
    97102/************************ Tab for single Atoms ********************/
    98103
    99 QTAtomPage::QTAtomPage(const atom *_atom,std::string _name) :
     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) :
    100112  Observer("QTAtomPage"),
    101   atomRef(_atom), name(_name)
     113  atomRef(_atom)
    102114{
    103115  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()));
    104129}
    105130
     
    120145/************************ Tab for single Molecules *****************/
    121146
    122 QTMoleculePage::QTMoleculePage(const molecule *_mol, std::string _name) :
     147QTMoleculePage::QTMoleculePage(const molecule *_mol) :
    123148    Observer("QTMoleculePage"),
    124     mol(_mol), name(_name)
     149    mol(_mol)
    125150{
    126151  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()));
    127164}
    128165
     
    132169
    133170void QTMoleculePage::update(Observable *subject){
    134   if(name != mol->name){
    135     name = mol->name;
    136     emit nameChanged(this,name);
    137   }
    138171}
    139172
  • src/UIElements/Views/Qt4/QtMoleculeView.hpp

    r7b6bcfe r4f7473  
    1717#include <string>
    1818#include <QtGui/QTabWidget>
     19#include <QtGui/QTreeWidget>
    1920#include "CodePatterns/Observer/Observer.hpp"
    2021
     
    4950  Q_OBJECT
    5051public:
    51   QTAtomPage(const atom *_atom,std::string _name);
     52  QTAtomPage(const atom *_atom);
    5253  virtual ~QTAtomPage();
    5354  void update(Observable *subject);
    5455  void subjectKilled(Observable *subject);
    5556
    56 //public slots:
    57 //  void nameChanged(QTAtomPage*,std::string);
    58 
    5957private:
    6058  const atom *atomRef;
    61   std::string name;
     59  QTreeWidget *info;
    6260};
    6361
     
    6866  Q_OBJECT
    6967public:
    70   QTMoleculePage(const molecule *_mol,std::string _name);
     68  QTMoleculePage(const molecule *_mol);
    7169  virtual ~QTMoleculePage();
    7270
     
    7472  void subjectKilled(Observable *subject);
    7573
    76 signals:
    77   void nameChanged(QTMoleculePage*,std::string);
    78 
    7974private:
    8075  const molecule *mol;
    81   std::string name;
     76  QTreeWidget *info;
    8277};
    8378#endif /* MOLECULEVIEW_HPP_ */
Note: See TracChangeset for help on using the changeset viewer.