#ifndef PERSPECTIVE_TRANSFORMER_H
#define PERSPECTIVE_TRANSFORMER_H
#include <Rect.h>
#include <Point.h>
#include <agg_conv_transform.h>
#include <agg_trans_perspective.h>
#include "IconBuild.h"
#include "Transformer.h"
#ifdef ICON_O_MATIC
#include "Observer.h"
#endif
#include "PathTransformer.h"
#include "StyleTransformer.h"
#include "VertexSource.h"
_BEGIN_ICON_NAMESPACE
class Shape;
typedef agg::conv_transform<VertexSource, agg::trans_perspective> Perspective;
class PerspectiveTransformer : public Transformer,
public PathTransformer,
public StyleTransformer,
#ifdef ICON_O_MATIC
public Observer,
#endif
public Perspective,
public agg::trans_perspective {
public:
enum {
archive_code = 'prsp',
};
PerspectiveTransformer(
VertexSource& source,
Shape* shape);
PerspectiveTransformer(
VertexSource& source,
Shape* shape,
BMessage* archive);
PerspectiveTransformer(
const PerspectiveTransformer& other);
virtual ~PerspectiveTransformer();
virtual Transformer* Clone() const;
virtual void rewind(unsigned path_id);
virtual unsigned vertex(double* x, double* y);
virtual void SetSource(VertexSource& source);
virtual double ApproximationScale() const;
virtual void transform(double* x, double* y) const
#ifdef ICON_O_MATIC
{ if (fValid) agg::trans_perspective::transform(x, y); }
#else
{ agg::trans_perspective::transform(x, y); }
#endif
virtual void Invert();
#ifdef ICON_O_MATIC
virtual status_t Archive(BMessage* into,
bool deep = true) const;
virtual void ObjectChanged(const Observable* object);
void TransformTo(BPoint leftTop, BPoint rightTop,
BPoint leftBottom, BPoint rightBottom);
BPoint LeftTop()
{ return fToLeftTop; }
BPoint RightTop()
{ return fToRightTop; }
BPoint LeftBottom()
{ return fToLeftBottom; }
BPoint RightBottom()
{ return fToRightBottom; }
private:
void _CheckValidity();
#endif
private:
Shape* fShape;
#ifdef ICON_O_MATIC
bool fInverted;
BRect fFromBox;
BPoint fToLeftTop;
BPoint fToRightTop;
BPoint fToLeftBottom;
BPoint fToRightBottom;
bool fValid;
#endif
};
_END_ICON_NAMESPACE
#endif