RDKit: MolDraw2DJS.h Source File

| 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
24#include <GraphMol/MolDraw2D/MolDraw2D.h>
25
26// ****************************************************************************
27
28namespace RDKit {
29
30 class RDKIT_MOLDRAW2D_EXPORT MolDraw2DJS : public MolDraw2D {
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;
44 MolDraw2DJS(MolDraw2DJS &&) = delete;
45 MolDraw2DJS &operator=(const MolDraw2DJS &) = delete;
46 MolDraw2DJS &operator=(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
PRECONDITION
#define PRECONDITION(expr, mess)
Definition Invariant.h:108
MolDraw2D.h
RDGeom::Point2D
Definition point.h:284
RDKit::MolDraw2DJS::drawPolygon
void drawPolygon(const std::vector< Point2D > &cds, bool rawCoords=false) override
RDKit::MolDraw2DJS::drawWavyLine
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
RDKit::MolDraw2DJS::MolDraw2DJS
MolDraw2DJS(int width, int height, emscripten::val &context, int panelWidth=-1, int panelHeight=-1, bool noFreetype=false)
Definition MolDraw2DJS.h:33
RDKit::MolDraw2DJS::drawEllipse
void drawEllipse(const Point2D &cds1, const Point2D &cds2, bool rawCoords=false) override
draw an ellipse
RDKit::MolDraw2DJS::drawLine
void drawLine(const Point2D &cds1, const Point2D &cds2, bool rawCoords=false) override
RDKit::MolDraw2DJS::MolDraw2DJS
MolDraw2DJS(const MolDraw2DJS &)=delete
RDKit::MolDraw2DJS::operator=
MolDraw2DJS & operator=(const MolDraw2DJS &)=delete
RDKit::MolDraw2DJS::operator=
MolDraw2DJS & operator=(MolDraw2DJS &&)=delete
RDKit::MolDraw2DJS::MolDraw2DJS
MolDraw2DJS(MolDraw2DJS &&)=delete
RDKit::MolDraw2DJS::clearDrawing
void clearDrawing() override
clears the contents of the drawing
RDKit::MolDraw2D::panelHeight
int panelHeight() const
return the height of the drawing panels.
Definition MolDraw2D.h:338
RDKit::MolDraw2D::needs_init_
bool needs_init_
Definition MolDraw2D.h:448
RDKit::MolDraw2D::MolDraw2D
MolDraw2D(int width, int height, int panelWidth, int panelHeight)
constructor for a particular size
RDKit::MolDraw2D::height
int height() const
return the height of the drawing area.
Definition MolDraw2D.h:334
RDKit::MolDraw2D::panelWidth
int panelWidth() const
return the width of the drawing panels.
Definition MolDraw2D.h:336
RDKit::MolDraw2D::width
int width() const
return the width of the drawing area.
Definition MolDraw2D.h:332
export.h
RDKIT_MOLDRAW2D_EXPORT
#define RDKIT_MOLDRAW2D_EXPORT
Definition export.h:313
RDKit
Std stuff.
Definition Abbreviations.h:19
RDKit::DrawColour
Definition MolDraw2DHelpers.h:40