1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
/*******************************************************************************
* *
* Author : Angus Johnson *
* Version : 1.1 *
* Date : 4 April 2011 *
* Copyright : Angus Johnson 2010-2011 *
* *
* License: *
* Use, modification & distribution is subject to Boost Software License Ver 1. *
* http://www.boost.org/LICENSE_1_0.txt *
* *
* Modified by Mike Owens to support coordinate transformation *
*******************************************************************************/
#ifndef CLIPPER_CAIRO_CLIPPER_HPP
#define CLIPPER_CAIRO_CLIPPER_HPP
#include "clipper.hpp"
typedef struct _cairo cairo_t;
namespace ClipperLib {
namespace cairo {
enum Transform {
tNone,
tUserToDevice,
tDeviceToUser
};
//nb: Since Clipper only accepts integer coordinates, fractional values have to
//be scaled up and down when being passed to and from Clipper. This is easily
//accomplished by setting the scaling factor (10^x) in the following functions.
//When scaling, remember that on most platforms, integer is only a 32bit value.
void cairo_to_clipper(cairo_t* cr,
ClipperLib::Paths &pg,
int scaling_factor = 0,
Transform transform = tNone);
void clipper_to_cairo(const ClipperLib::Paths &pg,
cairo_t* cr,
int scaling_factor = 0,
Transform transform = tNone);
}
class clipperCairoException : public std::exception
{
public:
clipperCairoException(const char* description)
throw(): std::exception(), m_description (description) {}
virtual ~clipperCairoException() throw() {}
virtual const char* what() const throw() {return m_description.c_str();}
private:
std::string m_description;
};
}
#endif
|