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/rect.h>
21 namespace NR {
23 class FilterUnits {
24 public:
25 FilterUnits();
26 FilterUnits(SPFilterUnits const filterUnits, SPFilterUnits const primitiveUnits);
28 /**
29 * Sets the current transformation matrix, i.e. transformation matrix
30 * from object's user coordinates to screen coordinates
31 */
32 void set_ctm(Matrix const &ctm);
34 /**
35 * Sets the resolution, the filter should be rendered with.
36 */
37 void set_resolution(double const x_res, double const y_res);
39 /**
40 * Sets the item bounding box in user coordinates
41 */
42 void set_item_bbox(Rect const &bbox);
44 /**
45 * Sets the filter effects area in user coordinates
46 */
47 void set_filter_area(Rect const &area);
49 /**
50 * Sets, if x and y axis in pixblock coordinates should be paraller
51 * to x and y of user coordinates.
52 */
53 void set_paraller(bool const paraller);
55 /**
56 * Sets, if filter resolution is automatic.
57 * NOTE: even if resolution is automatic, it must be set with
58 * set_resolution. This only tells, if the set value is automatic.
59 */
60 void set_automatic_resolution(bool const automatic);
62 /**
63 * Gets the user coordinates to pixblock coordinates transformation matrix.
64 */
65 Matrix get_matrix_user2pb() const;
67 /**
68 * Gets the filterUnits to pixblock coordinates transformation matrix.
69 */
70 Matrix get_matrix_filterunits2pb() const;
72 /**
73 * Gets the primitiveUnits to pixblock coordinates transformation matrix.
74 */
75 Matrix get_matrix_primitiveunits2pb() const;
77 /**
78 * Gets the display coordinates to pixblock coordinates transformation
79 * matrix.
80 */
81 Matrix get_matrix_display2pb() const;
83 /**
84 * Gets the pixblock coordinates to display coordinates transformation
85 * matrix
86 */
87 Matrix get_matrix_pb2display() const;
89 /**
90 * Gets the user coordinates to filterUnits transformation matrix.
91 */
92 Matrix get_matrix_user2filterunits() const;
94 /**
95 * Gets the user coordinates to primitiveUnits transformation matrix.
96 */
97 Matrix get_matrix_user2primitiveunits() const;
99 /**
100 * Returns the filter area in pixblock coordinates.
101 * NOTE: use only in filters, that define TRAIT_PARALLER in
102 * get_input_traits. The filter effects area may not be representable
103 * by simple rectangle otherwise. */
104 IRect get_pixblock_filterarea_paraller() const;
106 FilterUnits& operator=(FilterUnits const &other);
108 private:
109 Matrix get_matrix_units2pb(SPFilterUnits units) const;
110 Matrix get_matrix_user2units(SPFilterUnits units) const;
112 SPFilterUnits filterUnits, primitiveUnits;
113 double resolution_x, resolution_y;
114 bool paraller_axis;
115 bool automatic_resolution;
116 Matrix ctm;
117 Rect item_bbox;
118 Rect filter_area;
120 };
123 } // namespace NR
126 #endif /* __NR_FILTER_UNITS_H__ */
127 /*
128 Local Variables:
129 mode:c++
130 c-file-style:"stroustrup"
131 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
132 indent-tabs-mode:nil
133 fill-column:99
134 End:
135 */
136 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :