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