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