NAPISD
PAHdb website C++ backend
Loading...
Searching...
No Matches
Text.cpp
1#include "Text.h"
2
3Text::Text()
4 : _coordinates({0.0, 0.0, 0.0}), _text(""), _color("000000"), _size(1.0),
5 _angle(0.0), _justification(CenterJustification),
6 _system(CoordinateSystem::DATA) {
7 type = Type::I_Text;
8}
9
10Text::Text(std::string_view text)
11 : _coordinates({2.0, 0.0}), _text(text), _color("000000"), _size(1.0),
12 _angle(0.0), _justification(LeftJustification) {
13 type = Type::I_Text;
14}
15
16Text *Text::clone() const { return new Text(*this); }
17
18void Text::setCoordinates(double x, double y, double z,
19 CoordinateSystem system) {
20
21 _coordinates = {x, y, z};
22
23 _system = system;
24}
25
26std::string Text::formatChemicalFormula(std::string_view formula) {
27
28 std::ostringstream ostr;
29
30 bool subscript = false;
31
32 bool superscript = false;
33
34 bool charge = false;
35
36 for (const auto &c : formula) {
37
38 if (isdigit(c) && !charge) {
39
40 if (superscript) {
41
42 ostr << "#d";
43
44 superscript = false;
45 }
46
47 if (!subscript) {
48
49 ostr << "#d";
50
51 subscript = true;
52 }
53 } else if (isalpha(c)) {
54
55 if (superscript) {
56
57 ostr << "#d";
58
59 superscript = false;
60 }
61
62 if (subscript) {
63
64 ostr << "#u";
65
66 subscript = false;
67 }
68 } else if (!superscript) {
69
70 if (subscript) {
71
72 ostr << "#u";
73
74 subscript = false;
75 }
76
77 ostr << "#u";
78
79 superscript = charge = true;
80 }
81
82 ostr << c;
83 }
84
85 if (subscript) {
86
87 ostr << "#u";
88 }
89
90 if (superscript) {
91
92 ostr << "#d";
93 }
94
95 return (ostr.str());
96}
Definition Text.h:13

Since FY2019 the NASA Ames PAH IR Spectroscopic Database is being supported through a directed Work Package at NASA Ames titled: "Laboratory Astrophysics - The NASA Ames PAH IR Spectroscopic Database".
Since FY2023 the NASA Ames PAH IR Spectroscopic Database is being supported through the Laboratory Astrophysics Rd 2 directed Work Package at NASA Ames.
© Copyright 2021-2025, Christiaan Boersma