author | zecke <zecke> | 2004-09-10 11:11:23 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-10 11:11:23 (UTC) |
commit | 532d65f8a45850bfda3c3344a7b165af91e48440 (patch) (side-by-side diff) | |
tree | cbda2467001ed9a5be304fa52cabbb797b56ecfe /noncore/apps/oxygen/kmolelements.cpp | |
parent | e64d9e9682e0afefc4fbebe7ba9737e0f86e3ed7 (diff) | |
download | opie-532d65f8a45850bfda3c3344a7b165af91e48440.zip opie-532d65f8a45850bfda3c3344a7b165af91e48440.tar.gz opie-532d65f8a45850bfda3c3344a7b165af91e48440.tar.bz2 |
Add newlines, remove unused local variables, remove unused parameters,
add newlines at the end of file...
Diffstat (limited to 'noncore/apps/oxygen/kmolelements.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/oxygen/kmolelements.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/noncore/apps/oxygen/kmolelements.cpp b/noncore/apps/oxygen/kmolelements.cpp index ce8f9c1..e76461b 100644 --- a/noncore/apps/oxygen/kmolelements.cpp +++ b/noncore/apps/oxygen/kmolelements.cpp @@ -7,19 +7,19 @@ // classes that store and manipulate chemical formulas represented as // lists of elements #include <stdio.h> -#include "kmolelements.h" +#include "kmolelements.h" /** - * A generic chemical entity. Can be an element or a group. + * A generic chemical entity. Can be an element or a group. */ SubUnit::SubUnit () {} SubUnit::~SubUnit () {} /** - * Construct a subunit and return a pointer to it. The syntax of LINE is + * Construct a subunit and return a pointer to it. The syntax of LINE is * the one used in the element definition file. */ SubUnit* SubUnit::makeSubUnit(QString line) { QString name, grpname, weight, coef; @@ -27,9 +27,9 @@ SubUnit* SubUnit::makeSubUnit(QString line) { str >> name; if (name != "-group") { // not a group - must be represented as Element str >> weight >> ws; return new Element(name, weight.toDouble()); - } + } else { str >> grpname; ElementList* els = new ElementList(grpname); // group - make an ElementList while (!str.eof()) { @@ -47,14 +47,14 @@ QString SubUnit::getName() const { /** * Get the molecular weight of THIS, based on the data from ELSTABLE. */ -double SubUnit::getWeight(QDict<SubUnit>* elstable) const { +double SubUnit::getWeight(QDict<SubUnit>* ) const { return -1; } /** - * A group of elements. + * A group of elements. */ ElementList::ElementList () { elements = new QList<ElementCoef>; } @@ -64,9 +64,9 @@ ElementList::~ElementList () { } /** - * A group of elements. + * A group of elements. */ ElementList::ElementList (QString name) { this->name = name; elements = new QList<ElementCoef>; @@ -79,9 +79,9 @@ void ElementList::writeOut(QString& line) { QString coef; line = "-group " + name; ElementCoef* current = elements->first(); while (current != 0) { - line += " " + current->name + " " + coef.setNum(current->coef, 'g', 10); + line += " " + current->name + " " + coef.setNum(current->coef, 'g', 10); // precision set to 10 digits current = elements->next(); } } @@ -102,9 +102,9 @@ double ElementList::getWeight(QDict<SubUnit>* elstable) const { return weight; } /** - * Return a string representing the elemental composition of THIS, as + * Return a string representing the elemental composition of THIS, as * a tab-separated element - percentage pairs, separated by newlines. */ QString ElementList::getEA(QDict<SubUnit>* elstable, double mw) const { if (mw == 0) mw = getWeight(elstable); @@ -113,19 +113,19 @@ QString ElementList::getEA(QDict<SubUnit>* elstable, double mw) const { ElementCoef* current = elements->first(); while (current != 0) { SubUnit* e = elstable->find(current->name); if (e != 0) { - double current_percent = 100 * (current->coef) * - (e->getWeight(elstable)) + double current_percent = 100 * (current->coef) * + (e->getWeight(elstable)) / mw; - ea += current->name + "\t" + + ea += current->name + "\t" + temp.setNum(current_percent) + "\n"; } else return QString("ERROR!\n"); //ERROR current = elements->next(); } return ea; } - + /** * Return a string representing THIS as an empirical chemical formula. */ QString ElementList::getEmpFormula() const { @@ -161,9 +161,9 @@ void ElementList::addTo(ElementList& els, double coef) { } } /** - * Add an element to THIS, with a coefficient COEF. If THIS already contains + * Add an element to THIS, with a coefficient COEF. If THIS already contains * an element with the same name, adjust its coefficient only; if not, create * a new ElementCoef pair and add to THIS. */ void ElementList::addElement(const QString& name, double coef) { @@ -183,9 +183,9 @@ void ElementList::addElement(const QString& name, double coef) { */ bool ElementList::contains(const QString& name) { ElementCoef* current = elements->first(); while (current != 0) { - if (current->name == name) + if (current->name == name) return true; current = elements->next(); } return false; @@ -201,9 +201,9 @@ QString ElementList::getName() const { /** * A chemical element. */ -Element::Element(const QString& n, double w) +Element::Element(const QString& n, double w) : weight(w), name(n) { } Element::~Element() { @@ -217,9 +217,9 @@ void Element::writeOut(QString& line) { line.setNum(weight); line = name + " " + line; } -double Element::getWeight(QDict<SubUnit>* elstable) const { +double Element::getWeight(QDict<SubUnit>* ) const { return weight; } void Element::addTo(ElementList& els, double coef) { @@ -230,9 +230,9 @@ QString Element::getName() const { return name; } /** - * An element - coefficient pair. Used to represent elements within an + * An element - coefficient pair. Used to represent elements within an * element list. */ ElementCoef::ElementCoef(const QString& n, double c) : name(n), coef(c) {} |