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 using namespace BPrivate::Icon; 19 using std::nothrow; 20 21 22 // constructor 23 PerspectiveTransformer::PerspectiveTransformer(VertexSource& source) 24 : Transformer(source, "Perspective"), 25 Perspective(source, *this) 26 { 27 } 28 29 #ifdef ICON_O_MATIC 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 #endif 39 40 // destructor 41 PerspectiveTransformer::~PerspectiveTransformer() 42 { 43 } 44 45 // Clone 46 Transformer* 47 PerspectiveTransformer::Clone(VertexSource& source) const 48 { 49 PerspectiveTransformer* clone 50 = new (nothrow) PerspectiveTransformer(source); 51 if (clone) { 52 // TODO: upgrade AGG 53 // clone->multiply(*this); 54 } 55 return clone; 56 } 57 58 // rewind 59 void 60 PerspectiveTransformer::rewind(unsigned path_id) 61 { 62 Perspective::rewind(path_id); 63 } 64 65 // vertex 66 unsigned 67 PerspectiveTransformer::vertex(double* x, double* y) 68 { 69 return Perspective::vertex(x, y); 70 } 71 72 // SetSource 73 void 74 PerspectiveTransformer::SetSource(VertexSource& source) 75 { 76 Transformer::SetSource(source); 77 Perspective::attach(source); 78 } 79 80 // ApproximationScale 81 double 82 PerspectiveTransformer::ApproximationScale() const 83 { 84 // TODO: upgrade AGG 85 return fSource.ApproximationScale();// * scale(); 86 } 87 88 // #pragma mark - 89 90 #ifdef ICON_O_MATIC 91 92 // Archive 93 status_t 94 PerspectiveTransformer::Archive(BMessage* into, bool deep) const 95 { 96 status_t ret = Transformer::Archive(into, deep); 97 98 if (ret == B_OK) 99 into->what = archive_code; 100 101 // TODO: upgrade AGG to be able to use store_to() 102 103 return ret; 104 } 105 106 #endif // ICON_O_MATIC 107 108 109 110