| 58 | } |
| 59 | |
| 60 | void Path::writeLabel(ostream& s, double threshold) |
| 61 | { |
| 62 | if (m_label.size() == 0) { |
| 63 | return; |
| 64 | } |
| 65 | double v; |
| 66 | for (const auto& [species, value] : m_label) { |
| 67 | v = value / m_total; |
| 68 | if (m_label.size() == 1) { |
| 69 | s << species << "\\l"; |
| 70 | } else if (v > threshold) { |
| 71 | s << species; |
| 72 | int percent = int(100*v + 0.5); |
| 73 | if (percent < 100) { |
| 74 | s << " (" << percent << "%)\\l"; |
| 75 | } else { |
| 76 | s << "\\l"; |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | ReactionPathDiagram::ReactionPathDiagram( |
| 83 | shared_ptr<Kinetics> kin, const string& element_) : element(element_), m_kin(kin) |