summaryrefslogtreecommitdiff
path: root/noncore/apps/checkbook/kmolcalc.h
Unidiff
Diffstat (limited to 'noncore/apps/checkbook/kmolcalc.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/kmolcalc.h110
1 files changed, 0 insertions, 110 deletions
diff --git a/noncore/apps/checkbook/kmolcalc.h b/noncore/apps/checkbook/kmolcalc.h
deleted file mode 100644
index c3e02f3..0000000
--- a/noncore/apps/checkbook/kmolcalc.h
+++ b/dev/null
@@ -1,110 +0,0 @@
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 */
31class KMolCalc {
32
33public:
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