RDKit
Open-source cheminformatics and machine learning.
DrawTextJS.h
Go to the documentation of this file.
1 //
2 // @@ All Rights Reserved @@
3 // This file is part of the RDKit.
4 // The contents are covered by the terms of the BSD license
5 // which is included in the file license.txt, found at the root
6 // of the RDKit source tree.
7 //
8 // Original author: Greg Landrum
9 //
10 // A concrete class derived from DrawText that uses the JS Canvas
11 // to draw text onto a picture.
12 // Requires emscripten
13 
14 #ifndef RDKIT_DRAWTEXTJS_H
15 #define RDKIT_DRAWTEXTJS_H
16 
17 #include <iosfwd>
18 
19 #include <emscripten.h>
20 #include <emscripten/val.h>
22 
23 namespace RDKit {
24 
25 // ****************************************************************************
26 
27 class DrawTextJS : public DrawText {
28  public:
29  DrawTextJS(double max_fnt_sz, double min_fnt_sz, emscripten::val &context);
30 
31  void drawChar(char c, const Point2D &cds) override;
32 
33  private:
34  emscripten::val &context_;
35 
36  // fills a vector of StringRects, one for each char in text, with
37  // super- and subscripts taken into account. Sizes in pixel coords,
38  // i.e. scaled by fontScale().
39  void getStringRects(const std::string &text,
40  std::vector<std::shared_ptr<StringRect>> &rects,
41  std::vector<TextDrawType> &draw_modes,
42  std::vector<char> &draw_chars) const override;
43 };
44 
45 } // namespace RDKit
46 
47 #endif // RDKIT_DRAWTEXTSVG_H
DrawTextJS(double max_fnt_sz, double min_fnt_sz, emscripten::val &context)
void drawChar(char c, const Point2D &cds) override
Std stuff.
Definition: Abbreviations.h:18