xref: /haiku/src/libs/icon/transformer/PerspectiveTransformer.cpp (revision 22440f4105cafc95cc1d49f9bc65bb395c527d86)
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
20 using std::nothrow;
21 
22 
23 // constructor
24 PerspectiveTransformer::PerspectiveTransformer(VertexSource& source)
25 	: Transformer(source, "Perspective"),
26 	  Perspective(source, *this)
27 {
28 }
29 
30 // constructor
31 PerspectiveTransformer::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
40 PerspectiveTransformer::~PerspectiveTransformer()
41 {
42 }
43 
44 // Clone
45 Transformer*
46 PerspectiveTransformer::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
58 void
59 PerspectiveTransformer::rewind(unsigned path_id)
60 {
61 	Perspective::rewind(path_id);
62 }
63 
64 // vertex
65 unsigned
66 PerspectiveTransformer::vertex(double* x, double* y)
67 {
68 	return Perspective::vertex(x, y);
69 }
70 
71 // SetSource
72 void
73 PerspectiveTransformer::SetSource(VertexSource& source)
74 {
75 	Transformer::SetSource(source);
76 	Perspective::attach(source);
77 }
78 
79 // ApproximationScale
80 double
81 PerspectiveTransformer::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
92 status_t
93 PerspectiveTransformer::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