1
#ifndef INKSCAPE_LIBNR_CONVERT2GEOM_H
2
#define INKSCAPE_LIBNR_CONVERT2GEOM_H
5
* Converts between NR and 2Geom types.
7
* Copyright (C) Johan Engelen 2008 <j.b.c.engelen@utwente.nl>
9
* Released under GNU GPL, read the file 'COPYING' for more information
12
#include <libnr/nr-matrix.h>
13
#include <libnr/nr-rect.h>
14
#include <libnr/nr-point.h>
15
#include <2geom/matrix.h>
17
#include <2geom/transforms.h>
18
#include <2geom/point.h>
20
inline Geom::Point to_2geom(NR::Point const & _pt) {
21
return Geom::Point(_pt[0], _pt[1]);
23
inline NR::Point from_2geom(Geom::Point const & _pt) {
24
return NR::Point(_pt[0], _pt[1]);
27
inline Geom::Matrix to_2geom(NR::Matrix const & mat) {
28
Geom::Matrix mat2geom(mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]);
31
inline NR::Matrix from_2geom(Geom::Matrix const & mat) {
32
NR::Matrix mat2geom(mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]);
36
inline Geom::Translate to_2geom(NR::translate const & mat) {
37
return Geom::Translate( mat.offset[0], mat.offset[1] );
40
inline Geom::Rect to_2geom(NR::Rect const & rect) {
41
Geom::Rect rect2geom(to_2geom(rect.min()), to_2geom(rect.max()));
44
inline NR::Rect from_2geom(Geom::Rect const & rect2geom) {
45
NR::Rect rect(rect2geom.min(), rect2geom.max());
48
inline Geom::OptRect to_2geom(boost::optional<NR::Rect> const & rect) {
49
Geom::OptRect rect2geom;
53
rect2geom = to_2geom(*rect);
57
inline NR::scale from_2geom(Geom::Scale const & in) {
58
return NR::scale(in[Geom::X], in[Geom::Y]);
60
inline Geom::Scale to_2geom(NR::scale const & in) {
61
return Geom::Scale(in[NR::X], in[NR::Y]);
69
c-file-style:"stroustrup"
70
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
75
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :