Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

KMolCalc Class Reference

#include </home/clem/local/src/opie/noncore/apps/oxygen/kmolcalc.h>

Collaboration diagram for KMolCalc:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 KMolCalc ()
 ~KMolCalc ()
QString readFormula (const QString &s)
double getWeight ()
QString getEA ()
QString getEmpFormula ()
void defineElement (const QString &name, double weight)
QString defineGroup (const QString &name, const QString &formula)
void undefineGroup (const QString &name)
void readElstable ()

Public Attributes

QDict< SubUnit > * elstable
QString mwfile

Private Member Functions

QString readGroup (const QString &s, ElementList *els)
void readMwfile (QFile &f)

Private Attributes

double weight
ElementListelements

Detailed Description

KMOLCALC is the calculation engine. It knows about a hashtable of user defined atomic weights and group definitions ELSTABLE, and the currently processed formula, stored as a list of elements and their coefficients, ELEMENTS.

Definition at line 31 of file kmolcalc.h.


Constructor & Destructor Documentation

KMolCalc::KMolCalc  ) 
 

Construct a new calculator object.

Definition at line 21 of file kmolcalc.cpp.

References elements, elstable, NULL, and readElstable().

KMolCalc::~KMolCalc  ) 
 

Definition at line 27 of file kmolcalc.cpp.

References elements.


Member Function Documentation

void KMolCalc::defineElement const QString name,
double  weight
 

Add a new element name - atomic weight record to the ELSTABLE hashtable. Assumes NAME has valid syntax.

Definition at line 180 of file kmolcalc.cpp.

References elstable, and QDict< type >::replace().

QString KMolCalc::defineGroup const QString name,
const QString formula
 

Add a new group definition to the ELSTABLE. Returns "OK" if OK, error message if parsing FORMULA fails. Assumes the syntax of NAME is correct.

Definition at line 189 of file kmolcalc.cpp.

References ElementList::contains(), elstable, error(), readGroup(), and QDict< type >::replace().

QString KMolCalc::getEA  ) 
 

Return the elemental composition of the current formula, as a string of tab-separated element - percentage pairs, separated by newlines.

Definition at line 142 of file kmolcalc.cpp.

References elements, elstable, ElementList::getEA(), ElementList::getWeight(), and weight.

Referenced by calcDlgUI::calc().

QString KMolCalc::getEmpFormula  ) 
 

Return the empirical formula of the current compound as a QString.

Definition at line 151 of file kmolcalc.cpp.

References elements, and ElementList::getEmpFormula().

Referenced by calcDlgUI::calc().

double KMolCalc::getWeight  ) 
 

Calculate and return the molecular weight of the current chemical formula.

Definition at line 133 of file kmolcalc.cpp.

References elements, elstable, ElementList::getWeight(), and weight.

Referenced by calcDlgUI::calc().

void KMolCalc::readElstable  ) 
 

Read the element definitions file and construct ELSTABLE.

Definition at line 31 of file kmolcalc.cpp.

References elstable, QFile::exists(), f, mwfile, QPEApplication::qpeDir(), readMwfile(), QPtrCollection::setAutoDelete(), TRUE, and weight.

Referenced by KMolCalc().

QString KMolCalc::readFormula const QString s  ) 
 

Parse a string S and construct the ElementList ELEMENTS, representing the composition of S. Returns "OK" if successful, or an error message if parsing failed. The elements is S must be valid element or group symbols, as stored in ELSTABLE. See help files for correct formula syntax.

Definition at line 49 of file kmolcalc.cpp.

References elements, readGroup(), and weight.

Referenced by calcDlgUI::calc().

QString KMolCalc::readGroup const QString s,
ElementList els
[private]
 

Definition at line 57 of file kmolcalc.cpp.

References SubUnit::addTo(), ElementList::addTo(), elstable, errors, QDict< type >::find(), i, ElementList::isEmpty(), QString::isEmpty(), QString::left(), QString::length(), QString::mid(), NULL, and TRUE.

Referenced by defineGroup(), and readFormula().

void KMolCalc::readMwfile QFile f  )  [private]
 

Definition at line 156 of file kmolcalc.cpp.

References elstable, QTextStream::eof(), SubUnit::getName(), IO_ReadOnly, SubUnit::makeSubUnit(), QFile::open(), QTextStream::readLine(), QDict< type >::replace(), and s.

Referenced by readElstable().

void KMolCalc::undefineGroup const QString name  ) 
 

Remove a group or element definition from ELSTABLE.

Definition at line 171 of file kmolcalc.cpp.

References elstable, and QDict< type >::remove().


Member Data Documentation

ElementList* KMolCalc::elements [private]
 

Definition at line 97 of file kmolcalc.h.

Referenced by getEA(), getEmpFormula(), getWeight(), KMolCalc(), readFormula(), and ~KMolCalc().

QDict<SubUnit>* KMolCalc::elstable
 

The element dictionary.

Definition at line 88 of file kmolcalc.h.

Referenced by defineElement(), defineGroup(), getEA(), getWeight(), KMolCalc(), readElstable(), readGroup(), readMwfile(), and undefineGroup().

QString KMolCalc::mwfile
 

Definition at line 90 of file kmolcalc.h.

Referenced by readElstable().

double KMolCalc::weight [private]
 

Definition at line 93 of file kmolcalc.h.

Referenced by getEA(), getWeight(), readElstable(), and readFormula().


The documentation for this class was generated from the following files:
Generated on Sat Nov 5 17:37:52 2005 for OPIE by  doxygen 1.4.2