RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
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 <sstream>
21#include <emscripten.h>
22#include <emscripten/val.h>
23
25
26// ****************************************************************************
27
28namespace RDKit {
29
31 public:
32 // initialize to use a particular ostream
33 MolDraw2DJS(int width, int height, emscripten::val &context,
34 int panelWidth = -1, int panelHeight = -1,
35 bool noFreetype = false)
36 : MolDraw2D(width, height, panelWidth, panelHeight), d_context(context) {
37 PRECONDITION(width > 0, "bad width");
38 PRECONDITION(height > 0, "bad height");
39 initDrawing();
40 needs_init_ = false;
41 initTextDrawer(noFreetype);
42 }
43 MolDraw2DJS(const MolDraw2DJS &) = delete;
45 MolDraw2DJS &operator=(const MolDraw2DJS &) = delete;
47
48 void drawLine(const Point2D &cds1, const Point2D &cds2,
49 bool rawCoords = false) override;
50 void drawPolygon(const std::vector<Point2D> &cds,
51 bool rawCoords = false) override;
52 void drawEllipse(const Point2D &cds1, const Point2D &cds2,
53 bool rawCoords = false) override;
54 void clearDrawing() override;
55 void drawWavyLine(const Point2D &cds1, const Point2D &cds2,
56 const DrawColour &col1, const DrawColour &col2,
57 unsigned int nSegments = 16, double vertOffset = 0.05,
58 bool rawCoords = false) override;
59
60 private:
61 emscripten::val &d_context;
62 void initDrawing() override;
63 void initTextDrawer(bool noFreetype) override;
64};
65
66} // namespace RDKit
67#endif // MOLDRAW2DSVG_H
#define PRECONDITION(expr, mess)
Definition Invariant.h:108
void drawPolygon(const std::vector< Point2D > &cds, bool rawCoords=false) override
void drawWavyLine(const Point2D &cds1, const Point2D &cds2, const DrawColour &col1, const DrawColour &col2, unsigned int nSegments=16, double vertOffset=0.05, bool rawCoords=false) override
draw a wavy line like that used to indicate unknown stereochemistry
MolDraw2DJS(int width, int height, emscripten::val &context, int panelWidth=-1, int panelHeight=-1, bool noFreetype=false)
Definition MolDraw2DJS.h:33
void drawEllipse(const Point2D &cds1, const Point2D &cds2, bool rawCoords=false) override
draw an ellipse
void drawLine(const Point2D &cds1, const Point2D &cds2, bool rawCoords=false) override
MolDraw2DJS(const MolDraw2DJS &)=delete
MolDraw2DJS & operator=(const MolDraw2DJS &)=delete
MolDraw2DJS & operator=(MolDraw2DJS &&)=delete
MolDraw2DJS(MolDraw2DJS &&)=delete
void clearDrawing() override
clears the contents of the drawing
int panelHeight() const
return the height of the drawing panels.
Definition MolDraw2D.h:338
MolDraw2D(int width, int height, int panelWidth, int panelHeight)
constructor for a particular size
int height() const
return the height of the drawing area.
Definition MolDraw2D.h:334
int panelWidth() const
return the width of the drawing panels.
Definition MolDraw2D.h:336
int width() const
return the width of the drawing area.
Definition MolDraw2D.h:332
#define RDKIT_MOLDRAW2D_EXPORT
Definition export.h:313
Std stuff.