1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- #ifndef STUDIO_UTIL_QT_PATH_H_3FCA40F9_C398_5905_B884_1EA23BEF81F4
- #define STUDIO_UTIL_QT_PATH_H_3FCA40F9_C398_5905_B884_1EA23BEF81F4
- #include <QPainterPath>
- #include <2geom/path-sink.h>
- #include <geom_helpers/knots.h>
- namespace rainynite::util {
- class QtPathSink : public Geom::PathSink {
- public:
- void moveTo(Geom::Point const& p) override {
- target.moveTo(p.x(), p.y());
- }
- void lineTo(Geom::Point const& p) override {
- target.lineTo(p.x(), p.y());
- }
- void curveTo(Geom::Point const& c0, Geom::Point const& c1, Geom::Point const& p) override {
- target.cubicTo(
- c0.x(), c0.y(),
- c1.x(), c1.y(),
- p.x(), p.y()
- );
- }
- void quadTo(Geom::Point const& c, Geom::Point const& p) override {
- target.quadTo(
- c.x(), c.y(),
- p.x(), p.y()
- );
- }
- void arcTo(Geom::Coord , Geom::Coord , Geom::Coord , bool , bool , Geom::Point const& ) override {
- throw std::runtime_error("QtPathSink: arcs not supported");
- }
- void closePath() override {
- target.closeSubpath();
- }
- void flush() override {
- }
- QPainterPath get() {
- return target;
- }
- private:
- QPainterPath target;
- };
- inline QPainterPath path_to_qt(Geom::BezierKnots const& path) {
- QtPathSink sink;
- sink.feed(Geom::knots_to_path(path));
- return sink.get();
- }
- }
- #endif
|