author | cniehaus <cniehaus> | 2002-09-15 17:09:54 (UTC) |
---|---|---|
committer | cniehaus <cniehaus> | 2002-09-15 17:09:54 (UTC) |
commit | 33ec9ead7ce30bf9450b9048506f0bda49ba4791 (patch) (unidiff) | |
tree | 1683b16a3cb06d7773427193fc4ea5284bf3bdaa /noncore/apps/oxygen/kmolcalc.h | |
parent | 7a8dc6b0a16db160a1e50fde8f298eb9e3cb0099 (diff) | |
download | opie-33ec9ead7ce30bf9450b9048506f0bda49ba4791.zip opie-33ec9ead7ce30bf9450b9048506f0bda49ba4791.tar.gz opie-33ec9ead7ce30bf9450b9048506f0bda49ba4791.tar.bz2 |
Fell free to shoot me if I messed up CVS again... *fingercrossed*
Diffstat (limited to 'noncore/apps/oxygen/kmolcalc.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/oxygen/kmolcalc.h | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/noncore/apps/oxygen/kmolcalc.h b/noncore/apps/oxygen/kmolcalc.h new file mode 100644 index 0000000..c3e02f3 --- a/dev/null +++ b/noncore/apps/oxygen/kmolcalc.h | |||
@@ -0,0 +1,110 @@ | |||
1 | /* | ||
2 | * kmolcalc.h | ||
3 | * | ||
4 | * Copyright (C) 2000 Tomislav Gountchev <tomi@idiom.com> | ||
5 | */ | ||
6 | |||
7 | |||
8 | #ifndef KMOLCALC_H | ||
9 | #define KMOLCALC_H | ||
10 | |||
11 | #ifdef HAVE_CONFIG_H | ||
12 | #include <config.h> | ||
13 | #endif | ||
14 | |||
15 | |||
16 | #include "kmolelements.h" | ||
17 | #include <qdict.h> | ||
18 | #include <qlist.h> | ||
19 | #include <qstring.h> | ||
20 | #include <qfile.h> | ||
21 | #include <qfileinfo.h> | ||
22 | #include <qmessagebox.h> | ||
23 | #include <qtextstream.h> | ||
24 | |||
25 | |||
26 | /** | ||
27 | * KMOLCALC is the calculation engine. It knows about a hashtable of user defined atomic | ||
28 | * weights and group definitions ELSTABLE, and the currently processed formula, stored | ||
29 | * as a list of elements and their coefficients, ELEMENTS. | ||
30 | */ | ||
31 | class KMolCalc { | ||
32 | |||
33 | public: | ||
34 | |||
35 | KMolCalc(); | ||
36 | ~KMolCalc(); | ||
37 | |||
38 | /** | ||
39 | * Parse a string S and construct the ElementList ELEMENTS, representing the composition | ||
40 | * of S. Returns "OK" if successful, or an error message if parsing failed. | ||
41 | * The elements is S must be valid element or group symbols, as stored in ELSTABLE. | ||
42 | * See help files for correct formula syntax. | ||
43 | */ | ||
44 | QString readFormula(const QString& s); | ||
45 | |||
46 | /** | ||
47 | * Calculate and return the molecular weight of the current chemical formula. | ||
48 | */ | ||
49 | double getWeight(); | ||
50 | |||
51 | /** | ||
52 | * Return the elemental composition of the current formula, as a string of tab-separated | ||
53 | * element - percentage pairs, separated by newlines. | ||
54 | */ | ||
55 | QString getEA(); | ||
56 | |||
57 | |||
58 | /** | ||
59 | * Return the empirical formula of the current compound as a QString. | ||
60 | */ | ||
61 | QString getEmpFormula(); | ||
62 | |||
63 | /** | ||
64 | * Add a new element name - atomic weight record to the ELSTABLE hashtable. | ||
65 | * Assumes NAME has valid syntax. | ||
66 | */ | ||
67 | void defineElement(const QString& name, double weight); | ||
68 | |||
69 | /** | ||
70 | * Add a new group definition to the ELSTABLE. Returns "OK" if OK, error message | ||
71 | * if parsing FORMULA fails. Assumes the syntax of NAME is correct. | ||
72 | */ | ||
73 | QString defineGroup(const QString& name, const QString& formula); | ||
74 | |||
75 | /** | ||
76 | * Remove a group or element definition from ELSTABLE. | ||
77 | */ | ||
78 | void undefineGroup(const QString& name); | ||
79 | |||
80 | /** | ||
81 | * Save the element definitions file. | ||
82 | */ | ||
83 | void writeElstable(); | ||
84 | |||
85 | /** | ||
86 | * Read the element definitions file and construct ELSTABLE. | ||
87 | */ | ||
88 | void readElstable(); | ||
89 | |||
90 | /** | ||
91 | * The element dictionary. | ||
92 | */ | ||
93 | QDict<SubUnit>* elstable; | ||
94 | |||
95 | QString mwfile; | ||
96 | |||
97 | private: | ||
98 | double weight; | ||
99 | |||
100 | QString readGroup(const QString& s, ElementList* els); | ||
101 | void readMwfile(QFile& f); | ||
102 | ElementList* elements; | ||
103 | }; | ||
104 | |||
105 | #endif | ||
106 | |||
107 | |||
108 | |||
109 | |||
110 | |||