Files
rdkit/Code/GraphMol/MolDraw2D/catch_qt.cpp
Greg Landrum 44fa9b9932 Get MolDraw2DQt working again (#3592)
* Qt drawing works with freetype.
needs polish and testing
non-freetype drawing doesn't work still

* make the Qt rendering anti-aliased

* non-freetype fonts work in Qt
With the giant caveat that you need a QGuiApplication to use fonts. We try to detect that

* cleanup

* changes in response to review

* add qt support to CI builds

* fix VS build problem

* try resolving a linux link error

* Update linux_build.yml

* Update linux_build.yml

* another attempt to get the linux CI builds working

* getting closer?

* Update linux_build.yml

* disable the qt CI builds on windows
2020-12-12 06:15:02 +01:00

57 lines
1.6 KiB
C++

//
// Copyright (C) 2019 Greg Landrum
//
// @@ 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.
//
#define CATCH_CONFIG_RUNNER
#include "catch.hpp"
#include <GraphMol/RDKitBase.h>
#include <GraphMol/SmilesParse/SmilesParse.h>
#include <GraphMol/MolDraw2D/MolDraw2D.h>
#include <GraphMol/MolDraw2D/MolDraw2DQt.h>
#include <GraphMol/MolDraw2D/MolDraw2DUtils.h>
#include <GraphMol/MolDraw2D/MolDraw2DDetails.h>
#include <GraphMol/FileParsers/FileParsers.h>
#include <GraphMol/Depictor/RDDepictor.h>
#include <QImage>
#include <QPainter>
#include <QGuiApplication>
using namespace RDKit;
TEST_CASE("basic generate PNGs", "[drawing][Qt]") {
SECTION("with freetype") {
auto m1 = "C1N[C@@H]2OCC12"_smiles;
REQUIRE(m1);
QImage qimg(250, 200, QImage::Format_RGB32);
QPainter qpt(&qimg);
MolDraw2DQt drawer(qimg.width(), qimg.height(), qpt);
MolDraw2DUtils::prepareAndDrawMolecule(drawer, *m1);
qimg.save("qttest-1a.png");
}
SECTION("no freetype") {
auto m1 = "C1N[C@@H]2OCC12"_smiles;
REQUIRE(m1);
QImage qimg(250, 200, QImage::Format_RGB32);
QPainter qpt(&qimg);
bool no_freetype = true;
MolDraw2DQt drawer(qimg.width(), qimg.height(), qpt, -1, -1, no_freetype);
MolDraw2DUtils::prepareAndDrawMolecule(drawer, *m1);
qimg.save("qttest-1b.png");
}
}
int main(int argc, char* argv[]) {
QGuiApplication app(argc, argv);
int result = Catch::Session().run(argc, argv);
return result;
}