Code

Extensions. Fix Color Markers extension (crashed when a fill or stroke attribute...
[inkscape.git] / src / display / nr-filter-units.h
1 #ifndef __NR_FILTER_UNITS_H__
2 #define __NR_FILTER_UNITS_H__
4 /*
5  * Utilities for handling coordinate system transformations in filters
6  *
7  * Author:
8  *   Niko Kiirala <niko@kiirala.com>
9  *
10  * Copyright (C) 2007 Niko Kiirala
11  *
12  * Released under GNU GPL, read the file 'COPYING' for more information
13  */
15 #include "sp-filter-units.h"
16 #include "libnr/nr-matrix.h"
17 #include "libnr/nr-rect.h"
18 #include "libnr/nr-rect-l.h"
19 #include <2geom/matrix.h>
20 #include <2geom/rect.h>
22 namespace Inkscape {
23 namespace Filters {
25 class FilterUnits {
26 public:
27     FilterUnits();
28     FilterUnits(SPFilterUnits const filterUnits, SPFilterUnits const primitiveUnits);
30     /**
31      * Sets the current transformation matrix, i.e. transformation matrix
32      * from object's user coordinates to screen coordinates
33      */
34     void set_ctm(Geom::Matrix const &ctm);
36     /**
37      * Sets the resolution, the filter should be rendered with.
38      */
39     void set_resolution(double const x_res, double const y_res);
41     /**
42      * Sets the item bounding box in user coordinates
43      */
44     void set_item_bbox(Geom::OptRect const &bbox);
46     /**
47      * Sets the filter effects area in user coordinates
48      */
49     void set_filter_area(Geom::OptRect const &area);
51     /**
52      * Sets, if x and y axis in pixblock coordinates should be paraller
53      * to x and y of user coordinates.
54      */
55     void set_paraller(bool const paraller);
57     /**
58      * Sets, if filter resolution is automatic.
59      * NOTE: even if resolution is automatic, it must be set with
60      * set_resolution. This only tells, if the set value is automatic.
61      */
62     void set_automatic_resolution(bool const automatic);
64     /**
65      * Gets the user coordinates to pixblock coordinates transformation matrix.
66      */
67     Geom::Matrix get_matrix_user2pb() const;
69     /**
70      * Gets the filterUnits to pixblock coordinates transformation matrix.
71      */
72     Geom::Matrix get_matrix_filterunits2pb() const;
74     /**
75      * Gets the primitiveUnits to pixblock coordinates transformation matrix.
76      */
77     Geom::Matrix get_matrix_primitiveunits2pb() const;
79     /**
80      * Gets the display coordinates to pixblock coordinates transformation
81      * matrix.
82      */
83     Geom::Matrix get_matrix_display2pb() const;
85     /**
86      * Gets the pixblock coordinates to display coordinates transformation
87      * matrix
88      */
89     Geom::Matrix get_matrix_pb2display() const;
91     /**
92      * Gets the user coordinates to filterUnits transformation matrix.
93      */
94     Geom::Matrix get_matrix_user2filterunits() const;
96     /**
97      * Gets the user coordinates to primitiveUnits transformation matrix.
98      */
99     Geom::Matrix get_matrix_user2primitiveunits() const;
101     /**
102      * Returns the filter area in pixblock coordinates.
103      * NOTE: use only in filters, that define TRAIT_PARALLER in
104      * get_input_traits. The filter effects area may not be representable
105      * by simple rectangle otherwise. */
106     NR::IRect get_pixblock_filterarea_paraller() const;
108     FilterUnits& operator=(FilterUnits const &other);
110 private:
111     Geom::Matrix get_matrix_units2pb(SPFilterUnits units) const;
112     Geom::Matrix get_matrix_user2units(SPFilterUnits units) const;
114     SPFilterUnits filterUnits, primitiveUnits;
115     double resolution_x, resolution_y;
116     bool paraller_axis;
117     bool automatic_resolution;
118     Geom::Matrix ctm;
119     Geom::OptRect item_bbox;
120     Geom::OptRect filter_area;
122 };
125 } /* namespace Filters */
126 } /* namespace Inkscape */
129 #endif /* __NR_FILTER_UNITS_H__ */
130 /*
131   Local Variables:
132   mode:c++
133   c-file-style:"stroustrup"
134   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
135   indent-tabs-mode:nil
136   fill-column:99
137   End:
138 */
139 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :