Commit 71e86272859aa2794263cc59446a20a826d6d3aa
1 parent
de8929a4
Add const versions of QPDFMatrix::transform*
Showing
2 changed files
with
19 additions
and
0 deletions
include/qpdf/QPDFMatrix.hh
| @@ -74,6 +74,9 @@ class QPDFMatrix | @@ -74,6 +74,9 @@ class QPDFMatrix | ||
| 74 | // [x y 1] * this | 74 | // [x y 1] * this |
| 75 | // and take the first and second rows of the result as xp and yp. | 75 | // and take the first and second rows of the result as xp and yp. |
| 76 | QPDF_DLL | 76 | QPDF_DLL |
| 77 | + void transform(double x, double y, double& xp, double& yp) const; | ||
| 78 | + // ABI: delete non-const version | ||
| 79 | + QPDF_DLL | ||
| 77 | void transform(double x, double y, double& xp, double& yp); | 80 | void transform(double x, double y, double& xp, double& yp); |
| 78 | 81 | ||
| 79 | // Transform a rectangle by creating a new rectangle that tightly | 82 | // Transform a rectangle by creating a new rectangle that tightly |
| @@ -81,6 +84,10 @@ class QPDFMatrix | @@ -81,6 +84,10 @@ class QPDFMatrix | ||
| 81 | // corners. | 84 | // corners. |
| 82 | QPDF_DLL | 85 | QPDF_DLL |
| 83 | QPDFObjectHandle::Rectangle transformRectangle( | 86 | QPDFObjectHandle::Rectangle transformRectangle( |
| 87 | + QPDFObjectHandle::Rectangle r) const; | ||
| 88 | + // ABI: delete non-const version | ||
| 89 | + QPDF_DLL | ||
| 90 | + QPDFObjectHandle::Rectangle transformRectangle( | ||
| 84 | QPDFObjectHandle::Rectangle r); | 91 | QPDFObjectHandle::Rectangle r); |
| 85 | 92 | ||
| 86 | private: | 93 | private: |
libqpdf/QPDFMatrix.cc
| @@ -111,6 +111,12 @@ QPDFMatrix::rotatex90(int angle) | @@ -111,6 +111,12 @@ QPDFMatrix::rotatex90(int angle) | ||
| 111 | void | 111 | void |
| 112 | QPDFMatrix::transform(double x, double y, double& xp, double& yp) | 112 | QPDFMatrix::transform(double x, double y, double& xp, double& yp) |
| 113 | { | 113 | { |
| 114 | + const_cast<QPDFMatrix const*>(this)->transform(x, y, xp, yp); | ||
| 115 | +} | ||
| 116 | + | ||
| 117 | +void | ||
| 118 | +QPDFMatrix::transform(double x, double y, double& xp, double& yp) const | ||
| 119 | +{ | ||
| 114 | xp = (this->a * x) + (this->c * y) + this->e; | 120 | xp = (this->a * x) + (this->c * y) + this->e; |
| 115 | yp = (this->b * x) + (this->d * y) + this->f; | 121 | yp = (this->b * x) + (this->d * y) + this->f; |
| 116 | } | 122 | } |
| @@ -118,6 +124,12 @@ QPDFMatrix::transform(double x, double y, double& xp, double& yp) | @@ -118,6 +124,12 @@ QPDFMatrix::transform(double x, double y, double& xp, double& yp) | ||
| 118 | QPDFObjectHandle::Rectangle | 124 | QPDFObjectHandle::Rectangle |
| 119 | QPDFMatrix::transformRectangle(QPDFObjectHandle::Rectangle r) | 125 | QPDFMatrix::transformRectangle(QPDFObjectHandle::Rectangle r) |
| 120 | { | 126 | { |
| 127 | + return const_cast<QPDFMatrix const*>(this)->transformRectangle(r); | ||
| 128 | +} | ||
| 129 | + | ||
| 130 | +QPDFObjectHandle::Rectangle | ||
| 131 | +QPDFMatrix::transformRectangle(QPDFObjectHandle::Rectangle r) const | ||
| 132 | +{ | ||
| 121 | std::vector<double> tx(4); | 133 | std::vector<double> tx(4); |
| 122 | std::vector<double> ty(4); | 134 | std::vector<double> ty(4); |
| 123 | transform(r.llx, r.lly, tx.at(0), ty.at(0)); | 135 | transform(r.llx, r.lly, tx.at(0), ty.at(0)); |