diff --git a/src/apps/icon-o-matic/Jamfile b/src/apps/icon-o-matic/Jamfile index 0911991839..926c8d2ec1 100644 --- a/src/apps/icon-o-matic/Jamfile +++ b/src/apps/icon-o-matic/Jamfile @@ -75,7 +75,10 @@ Application Icon-O-Matic : Style.cpp StyleManager.cpp # transformer + AffineTransformer.cpp + ContourTransformer.cpp PathSource.cpp + PerspectiveTransformer.cpp StrokeTransformer.cpp Transformer.cpp # diff --git a/src/apps/icon-o-matic/MainWindow.cpp b/src/apps/icon-o-matic/MainWindow.cpp index ffa30889ae..6365b941bb 100644 --- a/src/apps/icon-o-matic/MainWindow.cpp +++ b/src/apps/icon-o-matic/MainWindow.cpp @@ -17,6 +17,7 @@ #include "IconEditorApp.h" // TODO: just for testing +#include "AffineTransformer.h" #include "Gradient.h" #include "Icon.h" #include "MultipleManipulatorState.h" @@ -120,6 +121,22 @@ MainWindow::_Init() fDocument->Icon()->Shapes()->AddShape(shape); + Style* style3 = new Style(); + style3->SetColor((rgb_color){ 255, 0, 169,200 }); + + StyleManager::Default()->AddStyle(style3); + + shape = new Shape(style3); + shape->Paths()->AddPath(path); + AffineTransformer* transformer2 + = new AffineTransformer(shape->VertexSource()); + *transformer2 *= agg::trans_affine_translation(10.0, 6.0); + *transformer2 *= agg::trans_affine_rotation(0.2); + *transformer2 *= agg::trans_affine_scaling(0.8, 0.6); + shape->AppendTransformer(transformer2); + + fDocument->Icon()->Shapes()->AddShape(shape); + PathManipulator* pathManipulator = new PathManipulator(path); state->AddManipulator(pathManipulator); // ---- diff --git a/src/apps/icon-o-matic/shape/Shape.cpp b/src/apps/icon-o-matic/shape/Shape.cpp index ce6e5f8c7c..dee99d857e 100644 --- a/src/apps/icon-o-matic/shape/Shape.cpp +++ b/src/apps/icon-o-matic/shape/Shape.cpp @@ -85,6 +85,7 @@ Shape::SetStyle(::Style* style) BRect Shape::Bounds() const { + // TODO: incorrect - use VertexSource instead!! BRect bounds(LONG_MAX, LONG_MAX, LONG_MIN, LONG_MIN); int32 count = fPaths->CountPaths(); diff --git a/src/apps/icon-o-matic/transformer/AffineTransformer.cpp b/src/apps/icon-o-matic/transformer/AffineTransformer.cpp new file mode 100644 index 0000000000..1dce4a0536 --- /dev/null +++ b/src/apps/icon-o-matic/transformer/AffineTransformer.cpp @@ -0,0 +1,44 @@ +/* + * Copyright 2006, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * Stephan Aßmus + */ + +#include "AffineTransformer.h" + +// constructor +AffineTransformer::AffineTransformer(VertexSource& source) + : Transformer(source), + Affine(source, *this) +{ +} + +// destructor +AffineTransformer::~AffineTransformer() +{ +} + +// rewind +void +AffineTransformer::rewind(unsigned path_id) +{ + Affine::rewind(path_id); +} + +// vertex +unsigned +AffineTransformer::vertex(double* x, double* y) +{ + return Affine::vertex(x, y); +} + +// SetSource +void +AffineTransformer::SetSource(VertexSource& source) +{ + Transformer::SetSource(source); + Affine::attach(source); +} + diff --git a/src/apps/icon-o-matic/transformer/AffineTransformer.h b/src/apps/icon-o-matic/transformer/AffineTransformer.h new file mode 100644 index 0000000000..a6f1dee87b --- /dev/null +++ b/src/apps/icon-o-matic/transformer/AffineTransformer.h @@ -0,0 +1,34 @@ +/* + * Copyright 2006, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * Stephan Aßmus + */ + +#ifndef AFFINE_TRANSFORMER_H +#define AFFINE_TRANSFORMER_H + +#include "agg_conv_transform.h" +#include "agg_trans_affine.h" + +#include "Transformer.h" + +typedef agg::conv_transform Affine; + +class AffineTransformer : public Transformer, + public Affine, + public agg::trans_affine { + public: + AffineTransformer( + VertexSource& source); + virtual ~AffineTransformer(); + + virtual void rewind(unsigned path_id); + virtual unsigned vertex(double* x, double* y); + + virtual void SetSource(VertexSource& source); +}; + +#endif // AFFINE_TRANSFORMER_H diff --git a/src/apps/icon-o-matic/transformer/ContourTransformer.cpp b/src/apps/icon-o-matic/transformer/ContourTransformer.cpp new file mode 100644 index 0000000000..b184b641a1 --- /dev/null +++ b/src/apps/icon-o-matic/transformer/ContourTransformer.cpp @@ -0,0 +1,44 @@ +/* + * Copyright 2006, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * Stephan Aßmus + */ + +#include "ContourTransformer.h" + +// constructor +ContourTransformer::ContourTransformer(VertexSource& source) + : Transformer(source), + Contour(source) +{ +} + +// destructor +ContourTransformer::~ContourTransformer() +{ +} + +// rewind +void +ContourTransformer::rewind(unsigned path_id) +{ + Contour::rewind(path_id); +} + +// vertex +unsigned +ContourTransformer::vertex(double* x, double* y) +{ + return Contour::vertex(x, y); +} + +// SetSource +void +ContourTransformer::SetSource(VertexSource& source) +{ + Transformer::SetSource(source); + Contour::attach(source); +} + diff --git a/src/apps/icon-o-matic/transformer/ContourTransformer.h b/src/apps/icon-o-matic/transformer/ContourTransformer.h new file mode 100644 index 0000000000..3f40ac7a4b --- /dev/null +++ b/src/apps/icon-o-matic/transformer/ContourTransformer.h @@ -0,0 +1,31 @@ +/* + * Copyright 2006, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * Stephan Aßmus + */ + +#ifndef CONTOUR_TRANSFORMER_H +#define CONTOUR_TRANSFORMER_H + +#include "agg_conv_contour.h" + +#include "Transformer.h" + +typedef agg::conv_contour Contour; + +class ContourTransformer : public Transformer, + public Contour { + public: + ContourTransformer( + VertexSource& source); + virtual ~ContourTransformer(); + + virtual void rewind(unsigned path_id); + virtual unsigned vertex(double* x, double* y); + + virtual void SetSource(VertexSource& source); +}; + +#endif // CONTOUR_TRANSFORMER_H diff --git a/src/apps/icon-o-matic/transformer/PerspectiveTransformer.cpp b/src/apps/icon-o-matic/transformer/PerspectiveTransformer.cpp new file mode 100644 index 0000000000..bcd5878059 --- /dev/null +++ b/src/apps/icon-o-matic/transformer/PerspectiveTransformer.cpp @@ -0,0 +1,44 @@ +/* + * Copyright 2006, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * Stephan Aßmus + */ + +#include "PerspectiveTransformer.h" + +// constructor +PerspectiveTransformer::PerspectiveTransformer(VertexSource& source) + : Transformer(source), + Perspective(source, *this) +{ +} + +// destructor +PerspectiveTransformer::~PerspectiveTransformer() +{ +} + +// rewind +void +PerspectiveTransformer::rewind(unsigned path_id) +{ + Perspective::rewind(path_id); +} + +// vertex +unsigned +PerspectiveTransformer::vertex(double* x, double* y) +{ + return Perspective::vertex(x, y); +} + +// SetSource +void +PerspectiveTransformer::SetSource(VertexSource& source) +{ + Transformer::SetSource(source); + Perspective::attach(source); +} + diff --git a/src/apps/icon-o-matic/transformer/PerspectiveTransformer.h b/src/apps/icon-o-matic/transformer/PerspectiveTransformer.h new file mode 100644 index 0000000000..1d19508990 --- /dev/null +++ b/src/apps/icon-o-matic/transformer/PerspectiveTransformer.h @@ -0,0 +1,34 @@ +/* + * Copyright 2006, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * Stephan Aßmus + */ + +#ifndef PERSPECTIVE_TRANSFORMER_H +#define PERSPECTIVE_TRANSFORMER_H + +#include "agg_conv_transform.h" +#include "agg_trans_perspective.h" + +#include "Transformer.h" + +typedef agg::conv_transform Perspective; + +class PerspectiveTransformer : public Transformer, + public Perspective, + public agg::trans_perspective { + public: + PerspectiveTransformer( + VertexSource& source); + virtual ~PerspectiveTransformer(); + + virtual void rewind(unsigned path_id); + virtual unsigned vertex(double* x, double* y); + + virtual void SetSource(VertexSource& source); +}; + +#endif // PERSPECTIVE_TRANSFORMER_H