1/*
2 * Copyright 2006-2007, Haiku.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Stephan Aßmus <superstippi@gmx.de>
7 */
8
9
10#include "PerspectiveTransformer.h"
11
12#ifdef ICON_O_MATIC
13#	include <Message.h>
14#endif
15
16#include <new>
17
18
19_USING_ICON_NAMESPACE
20using std::nothrow;
21
22
23// constructor
24PerspectiveTransformer::PerspectiveTransformer(VertexSource& source)
25	: Transformer(source, "Perspective"),
26	  Perspective(source, *this)
27{
28}
29
30// constructor
31PerspectiveTransformer::PerspectiveTransformer(VertexSource& source,
32											   BMessage* archive)
33	: Transformer(source, archive),
34	  Perspective(source, *this)
35{
36	// TODO: upgrade AGG to be able to use load_from() etc
37}
38
39// destructor
40PerspectiveTransformer::~PerspectiveTransformer()
41{
42}
43
44// Clone
45Transformer*
46PerspectiveTransformer::Clone(VertexSource& source) const
47{
48	PerspectiveTransformer* clone
49		= new (nothrow) PerspectiveTransformer(source);
50	if (clone) {
51// TODO: upgrade AGG
52//		clone->multiply(*this);
53	}
54	return clone;
55}
56
57// rewind
58void
59PerspectiveTransformer::rewind(unsigned path_id)
60{
61	Perspective::rewind(path_id);
62}
63
64// vertex
65unsigned
66PerspectiveTransformer::vertex(double* x, double* y)
67{
68	return Perspective::vertex(x, y);
69}
70
71// SetSource
72void
73PerspectiveTransformer::SetSource(VertexSource& source)
74{
75	Transformer::SetSource(source);
76	Perspective::attach(source);
77}
78
79// ApproximationScale
80double
81PerspectiveTransformer::ApproximationScale() const
82{
83	// TODO: upgrade AGG
84	return fSource.ApproximationScale();// * scale();
85}
86
87// #pragma mark -
88
89#ifdef ICON_O_MATIC
90
91// Archive
92status_t
93PerspectiveTransformer::Archive(BMessage* into, bool deep) const
94{
95	status_t ret = Transformer::Archive(into, deep);
96
97	if (ret == B_OK)
98		into->what = archive_code;
99
100	// TODO: upgrade AGG to be able to use store_to()
101
102	return ret;
103}
104
105#endif // ICON_O_MATIC
106
107
108
109