RDKit
Open-source cheminformatics and machine learning.
MolDraw2DJS.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2020 Greg Landrum and T5 informatics GmbH
3 //
4 // @@ All Rights Reserved @@
5 // This file is part of the RDKit.
6 // The contents are covered by the terms of the BSD license
7 // which is included in the file license.txt, found at the root
8 // of the RDKit source tree.
9 //
10 // derived from Dave Cosgrove's MolDraw2D
11 //
12 // This is a concrete class derived from MolDraw2D that uses RDKit to draw using
13 // the JS canvas. This requires emscripten and is only intended for the RDKit
14 // Javascript builds
15 
16 #include <RDGeneral/export.h>
17 #ifndef MOLDRAW2DJS_H
18 #define MOLDRAW2DJS_H
19 
20 #include <iostream>
21 #include <sstream>
22 #include <emscripten.h>
23 #include <emscripten/val.h>
24 
26 
27 // ****************************************************************************
28 
29 namespace RDKit {
30 
32  public:
33  // initialize to use a particular ostream
34  MolDraw2DJS(int width, int height, emscripten::val &context,
35  int panelWidth = -1, int panelHeight = -1,
36  bool noFreetype = false)
37  : MolDraw2D(width, height, panelWidth, panelHeight), d_context(context) {
38  initDrawing();
39  initTextDrawer(noFreetype);
40  };
41 
42  void drawLine(const Point2D &cds1, const Point2D &cds2) override;
43  void drawPolygon(const std::vector<Point2D> &cds) override;
44  void drawEllipse(const Point2D &cds1, const Point2D &cds2) override;
45  void clearDrawing() override;
46 
47  private:
48  emscripten::val &d_context;
49  void initDrawing() override;
50  void initTextDrawer(bool noFreetype) override;
51 };
52 
53 } // namespace RDKit
54 #endif // MOLDRAW2DSVG_H
void drawLine(const Point2D &cds1, const Point2D &cds2) override
draws a line from cds1 to cds2 using the current drawing style
void drawPolygon(const std::vector< Point2D > &cds) override
void drawEllipse(const Point2D &cds1, const Point2D &cds2) override
draw an ellipse
MolDraw2DJS(int width, int height, emscripten::val &context, int panelWidth=-1, int panelHeight=-1, bool noFreetype=false)
Definition: MolDraw2DJS.h:34
void clearDrawing() override
clears the contents of the drawing
MolDraw2D is the base class for doing 2D renderings of molecules.
Definition: MolDraw2D.h:281
#define RDKIT_MOLDRAW2D_EXPORT
Definition: export.h:437
Std stuff.
Definition: Abbreviations.h:17