1fb07ece0SStephan Aßmus /* 2325a6253SAxel Dörfler * Copyright 2006-2007, Haiku. 3fb07ece0SStephan Aßmus * Distributed under the terms of the MIT License. 4fb07ece0SStephan Aßmus * 5fb07ece0SStephan Aßmus * Authors: 6fb07ece0SStephan Aßmus * Stephan Aßmus <superstippi@gmx.de> 7fb07ece0SStephan Aßmus */ 8fb07ece0SStephan Aßmus 9fb07ece0SStephan Aßmus #include "TransformerFactory.h" 10fb07ece0SStephan Aßmus 11fb07ece0SStephan Aßmus #include "AffineTransformer.h" 12fb07ece0SStephan Aßmus #include "ContourTransformer.h" 13fb07ece0SStephan Aßmus #include "PerspectiveTransformer.h" 14fb07ece0SStephan Aßmus #include "StrokeTransformer.h" 15fb07ece0SStephan Aßmus 16325a6253SAxel Dörfler #ifdef ICON_O_MATIC 17325a6253SAxel Dörfler # include <Message.h> 18325a6253SAxel Dörfler #endif 19325a6253SAxel Dörfler 20*25dc253dSIngo Weinhold 21*25dc253dSIngo Weinhold _USING_ICON_NAMESPACE 22325a6253SAxel Dörfler 23325a6253SAxel Dörfler 24fb07ece0SStephan Aßmus // TransformerFor 25fb07ece0SStephan Aßmus Transformer* 26fb07ece0SStephan Aßmus TransformerFactory::TransformerFor(uint32 type, VertexSource& source) 27fb07ece0SStephan Aßmus { 28fb07ece0SStephan Aßmus switch (type) { 29fb07ece0SStephan Aßmus case 0: 30fb07ece0SStephan Aßmus return new AffineTransformer(source); 31fb07ece0SStephan Aßmus case 1: 32fb07ece0SStephan Aßmus return new PerspectiveTransformer(source); 33fb07ece0SStephan Aßmus case 2: 34fb07ece0SStephan Aßmus return new ContourTransformer(source); 35fb07ece0SStephan Aßmus case 3: 36fb07ece0SStephan Aßmus return new StrokeTransformer(source); 37fb07ece0SStephan Aßmus } 38fb07ece0SStephan Aßmus 39fb07ece0SStephan Aßmus return NULL; 40fb07ece0SStephan Aßmus } 41fb07ece0SStephan Aßmus 42fb07ece0SStephan Aßmus // TransformerFor 43fb07ece0SStephan Aßmus Transformer* 44fb07ece0SStephan Aßmus TransformerFactory::TransformerFor(BMessage* message, 45fb07ece0SStephan Aßmus VertexSource& source) 46fb07ece0SStephan Aßmus { 47fb07ece0SStephan Aßmus switch (message->what) { 48fb07ece0SStephan Aßmus case AffineTransformer::archive_code: 49fb07ece0SStephan Aßmus return new AffineTransformer(source, message); 50fb07ece0SStephan Aßmus case PerspectiveTransformer::archive_code: 51fb07ece0SStephan Aßmus return new PerspectiveTransformer(source, message); 52fb07ece0SStephan Aßmus case ContourTransformer::archive_code: 53fb07ece0SStephan Aßmus return new ContourTransformer(source, message); 54fb07ece0SStephan Aßmus case StrokeTransformer::archive_code: 55fb07ece0SStephan Aßmus return new StrokeTransformer(source, message); 56fb07ece0SStephan Aßmus } 57fb07ece0SStephan Aßmus 58fb07ece0SStephan Aßmus return NULL; 59fb07ece0SStephan Aßmus } 60fb07ece0SStephan Aßmus 618b8d44bfSMichael Lotz #ifdef ICON_O_MATIC 628b8d44bfSMichael Lotz 63fb07ece0SStephan Aßmus // NextType 64fb07ece0SStephan Aßmus bool 65fb07ece0SStephan Aßmus TransformerFactory::NextType(int32* cookie, uint32* type, BString* name) 66fb07ece0SStephan Aßmus { 67fb07ece0SStephan Aßmus *type = *cookie; 68fb07ece0SStephan Aßmus *cookie = *cookie + 1; 69fb07ece0SStephan Aßmus 70fb07ece0SStephan Aßmus switch (*type) { 71fb07ece0SStephan Aßmus case 0: 72fb07ece0SStephan Aßmus *name = "Transformation"; 73fb07ece0SStephan Aßmus return true; 74fb07ece0SStephan Aßmus case 1: 75fb07ece0SStephan Aßmus *name = "Perspective"; 76fb07ece0SStephan Aßmus return true; 77fb07ece0SStephan Aßmus case 2: 78fb07ece0SStephan Aßmus *name = "Contour"; 79fb07ece0SStephan Aßmus return true; 80fb07ece0SStephan Aßmus case 3: 81fb07ece0SStephan Aßmus *name = "Stroke"; 82fb07ece0SStephan Aßmus return true; 83fb07ece0SStephan Aßmus } 84fb07ece0SStephan Aßmus 85fb07ece0SStephan Aßmus return false; 86fb07ece0SStephan Aßmus } 87fb07ece0SStephan Aßmus #endif // ICON_O_MATIC 88