Loading...
Searching...
No Matches
MolDraw2DJS.h
Go to the documentation of this file.
//
// Copyright (C) 2020 Greg Landrum and T5 informatics GmbH
//
// @@ All Rights Reserved @@
// This file is part of the RDKit.
// The contents are covered by the terms of the BSD license
// which is included in the file license.txt, found at the root
// of the RDKit source tree.
//
// derived from Dave Cosgrove's MolDraw2D
//
// This is a concrete class derived from MolDraw2D that uses RDKit to draw using
// the JS canvas. This requires emscripten and is only intended for the RDKit
// Javascript builds
#include <RDGeneral/export.h>
#ifndef MOLDRAW2DJS_H
#define MOLDRAW2DJS_H
#include <iostream>
#include <sstream>
#include <emscripten.h>
#include <emscripten/val.h>
#include <GraphMol/MolDraw2D/MolDraw2D.h>
// ****************************************************************************
namespace RDKit {
class RDKIT_MOLDRAW2D_EXPORT MolDraw2DJS : public MolDraw2D {
public:
// initialize to use a particular ostream
MolDraw2DJS(int width, int height, emscripten::val &context,
int panelWidth = -1, int panelHeight = -1,
bool noFreetype = false)
: MolDraw2D(width, height, panelWidth, panelHeight), d_context(context) {
PRECONDITION(width > 0, "bad width");
PRECONDITION(height > 0, "bad height");
initDrawing();
needs_init_ = false;
initTextDrawer(noFreetype);
}
MolDraw2DJS(const MolDraw2DJS &) = delete;
MolDraw2DJS(MolDraw2DJS &&) = delete;
MolDraw2DJS &operator=(const MolDraw2DJS &) = delete;
MolDraw2DJS &operator=(MolDraw2DJS &&) = delete;
void drawLine(const Point2D &cds1, const Point2D &cds2,
bool rawCoords = false) override;
void drawPolygon(const std::vector<Point2D> &cds,
bool rawCoords = false) override;
void drawEllipse(const Point2D &cds1, const Point2D &cds2,
bool rawCoords = false) override;
void clearDrawing() 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;
private:
emscripten::val &d_context;
void initDrawing() override;
void initTextDrawer(bool noFreetype) override;
};
} // namespace RDKit
#endif // MOLDRAW2DSVG_H
PRECONDITION
#define PRECONDITION(expr, mess)
Definition Invariant.h:109
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:34
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:39