Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e4a7ef3

Browse files
authored
Merge pull request #25728 from oscargus/srccleanup
Remove and deprecate unused methods in src
2 parents 04586cd + 4657204 commit e4a7ef3

File tree

8 files changed

+38
-145
lines changed

8 files changed

+38
-145
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
``ft2font.FT2Image.draw_rect`` and ``ft2font.FT2Font.get_xys``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
... are deprecated as they are unused. If you rely on these, please let us know.

src/_path.h

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -282,35 +282,15 @@ inline bool point_in_path(
282282
return result[0] != 0;
283283
}
284284

285-
template <class PathIterator, class PointArray, class ResultArray>
286-
void points_on_path(PointArray &points,
287-
const double r,
288-
PathIterator &path,
289-
agg::trans_affine &trans,
290-
ResultArray result)
285+
template <class PathIterator>
286+
inline bool point_on_path(
287+
double x, double y, const double r, PathIterator &path, agg::trans_affine &trans)
291288
{
292289
typedef agg::conv_transform<PathIterator> transformed_path_t;
293290
typedef PathNanRemover<transformed_path_t> no_nans_t;
294291
typedef agg::conv_curve<no_nans_t> curve_t;
295292
typedef agg::conv_stroke<curve_t> stroke_t;
296293

297-
size_t i;
298-
for (i = 0; i < points.size(); ++i) {
299-
result[i] = false;
300-
}
301-
302-
transformed_path_t trans_path(path, trans);
303-
no_nans_t nan_removed_path(trans_path, true, path.has_codes());
304-
curve_t curved_path(nan_removed_path);
305-
stroke_t stroked_path(curved_path);
306-
stroked_path.width(r * 2.0);
307-
point_in_path_impl(points, stroked_path, result);
308-
}
309-
310-
template <class PathIterator>
311-
inline bool point_on_path(
312-
double x, double y, const double r, PathIterator &path, agg::trans_affine &trans)
313-
{
314294
npy_intp shape[] = {1, 2};
315295
numpy::array_view<double, 2> points(shape);
316296
points(0, 0) = x;
@@ -319,8 +299,12 @@ inline bool point_on_path(
319299
int result[1];
320300
result[0] = 0;
321301

322-
points_on_path(points, r, path, trans, result);
323-
302+
transformed_path_t trans_path(path, trans);
303+
no_nans_t nan_removed_path(trans_path, true, path.has_codes());
304+
curve_t curved_path(nan_removed_path);
305+
stroke_t stroked_path(curved_path);
306+
stroked_path.width(r * 2.0);
307+
point_in_path_impl(points, stroked_path, result);
324308
return result[0] != 0;
325309
}
326310

src/_path_wrapper.cpp

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -91,98 +91,6 @@ static PyObject *Py_points_in_path(PyObject *self, PyObject *args)
9191
return results.pyobj();
9292
}
9393

94-
const char *Py_point_on_path__doc__ =
95-
"point_on_path(x, y, radius, path, trans)\n"
96-
"--\n\n";
97-
98-
static PyObject *Py_point_on_path(PyObject *self, PyObject *args)
99-
{
100-
double x, y, r;
101-
py::PathIterator path;
102-
agg::trans_affine trans;
103-
bool result;
104-
105-
if (!PyArg_ParseTuple(args,
106-
"dddO&O&:point_on_path",
107-
&x,
108-
&y,
109-
&r,
110-
&convert_path,
111-
&path,
112-
&convert_trans_affine,
113-
&trans)) {
114-
return NULL;
115-
}
116-
117-
CALL_CPP("point_on_path", (result = point_on_path(x, y, r, path, trans)));
118-
119-
if (result) {
120-
Py_RETURN_TRUE;
121-
} else {
122-
Py_RETURN_FALSE;
123-
}
124-
}
125-
126-
const char *Py_points_on_path__doc__ =
127-
"points_on_path(points, radius, path, trans)\n"
128-
"--\n\n";
129-
130-
static PyObject *Py_points_on_path(PyObject *self, PyObject *args)
131-
{
132-
numpy::array_view<const double, 2> points;
133-
double r;
134-
py::PathIterator path;
135-
agg::trans_affine trans;
136-
137-
if (!PyArg_ParseTuple(args,
138-
"O&dO&O&:points_on_path",
139-
&convert_points,
140-
&points,
141-
&r,
142-
&convert_path,
143-
&path,
144-
&convert_trans_affine,
145-
&trans)) {
146-
return NULL;
147-
}
148-
149-
npy_intp dims[] = { (npy_intp)points.size() };
150-
numpy::array_view<uint8_t, 1> results(dims);
151-
152-
CALL_CPP("points_on_path", (points_on_path(points, r, path, trans, results)));
153-
154-
return results.pyobj();
155-
}
156-
157-
const char *Py_get_path_extents__doc__ =
158-
"get_path_extents(path, trans)\n"
159-
"--\n\n";
160-
161-
static PyObject *Py_get_path_extents(PyObject *self, PyObject *args)
162-
{
163-
py::PathIterator path;
164-
agg::trans_affine trans;
165-
166-
if (!PyArg_ParseTuple(
167-
args, "O&O&:get_path_extents", &convert_path, &path, &convert_trans_affine, &trans)) {
168-
return NULL;
169-
}
170-
171-
extent_limits e;
172-
173-
CALL_CPP("get_path_extents", (reset_limits(e)));
174-
CALL_CPP("get_path_extents", (update_path_extents(path, trans, e)));
175-
176-
npy_intp dims[] = { 2, 2 };
177-
numpy::array_view<double, 2> extents(dims);
178-
extents(0, 0) = e.x0;
179-
extents(0, 1) = e.y0;
180-
extents(1, 0) = e.x1;
181-
extents(1, 1) = e.y1;
182-
183-
return extents.pyobj();
184-
}
185-
18694
const char *Py_update_path_extents__doc__ =
18795
"update_path_extents(path, trans, rect, minpos, ignore)\n"
18896
"--\n\n";
@@ -845,9 +753,6 @@ static PyObject *Py_is_sorted(PyObject *self, PyObject *obj)
845753
static PyMethodDef module_functions[] = {
846754
{"point_in_path", (PyCFunction)Py_point_in_path, METH_VARARGS, Py_point_in_path__doc__},
847755
{"points_in_path", (PyCFunction)Py_points_in_path, METH_VARARGS, Py_points_in_path__doc__},
848-
{"point_on_path", (PyCFunction)Py_point_on_path, METH_VARARGS, Py_point_on_path__doc__},
849-
{"points_on_path", (PyCFunction)Py_points_on_path, METH_VARARGS, Py_points_on_path__doc__},
850-
{"get_path_extents", (PyCFunction)Py_get_path_extents, METH_VARARGS, Py_get_path_extents__doc__},
851756
{"update_path_extents", (PyCFunction)Py_update_path_extents, METH_VARARGS, Py_update_path_extents__doc__},
852757
{"get_path_collection_extents", (PyCFunction)Py_get_path_collection_extents, METH_VARARGS, Py_get_path_collection_extents__doc__},
853758
{"point_in_path_collection", (PyCFunction)Py_point_in_path_collection, METH_VARARGS, Py_point_in_path_collection__doc__},

src/ft2font.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -725,11 +725,6 @@ FT_UInt FT2Font::get_char_index(FT_ULong charcode, bool fallback = false)
725725
return ft_get_char_index_or_warn(ft_object->get_face(), charcode, false);
726726
}
727727

728-
void FT2Font::get_cbox(FT_BBox &bbox)
729-
{
730-
FT_Glyph_Get_CBox(glyphs.back(), ft_glyph_bbox_subpixels, &bbox);
731-
}
732-
733728
void FT2Font::get_width_height(long *width, long *height)
734729
{
735730
*width = advance;

src/ft2font.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class FT2Image
3737

3838
void resize(long width, long height);
3939
void draw_bitmap(FT_Bitmap *bitmap, FT_Int x, FT_Int y);
40-
void write_bitmap(FILE *fp) const;
4140
void draw_rect(unsigned long x0, unsigned long y0, unsigned long x1, unsigned long y1);
4241
void draw_rect_filled(unsigned long x0, unsigned long y0, unsigned long x1, unsigned long y1);
4342

@@ -106,7 +105,6 @@ class FT2Font
106105
void get_glyph_name(unsigned int glyph_number, char *buffer, bool fallback);
107106
long get_name_index(char *name);
108107
FT_UInt get_char_index(FT_ULong charcode, bool fallback);
109-
void get_cbox(FT_BBox &bbox);
110108
PyObject* get_path();
111109
bool get_char_fallback_index(FT_ULong charcode, int& index) const;
112110

src/ft2font_wrapper.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,21 @@ static void PyFT2Image_dealloc(PyFT2Image *self)
6969
const char *PyFT2Image_draw_rect__doc__ =
7070
"draw_rect(self, x0, y0, x1, y1)\n"
7171
"--\n\n"
72-
"Draw an empty rectangle to the image.\n";
72+
"Draw an empty rectangle to the image.\n"
73+
"\n"
74+
".. deprecated:: 3.8\n";
75+
;
7376

7477
static PyObject *PyFT2Image_draw_rect(PyFT2Image *self, PyObject *args)
7578
{
79+
char const* msg =
80+
"FT2Image.draw_rect is deprecated since Matplotlib 3.8 and will be removed "
81+
"two minor releases later as it is not used in the library. If you rely on "
82+
"it, please let us know.";
83+
if (PyErr_WarnEx(PyExc_DeprecationWarning, msg, 1)) {
84+
return NULL;
85+
}
86+
7687
double x0, y0, x1, y1;
7788

7889
if (!PyArg_ParseTuple(args, "dddd:draw_rect", &x0, &y0, &x1, &y1)) {
@@ -820,10 +831,20 @@ static PyObject *PyFT2Font_draw_glyphs_to_bitmap(PyFT2Font *self, PyObject *args
820831
const char *PyFT2Font_get_xys__doc__ =
821832
"get_xys(self, antialiased=True)\n"
822833
"--\n\n"
823-
"Get the xy locations of the current glyphs.\n";
834+
"Get the xy locations of the current glyphs.\n"
835+
"\n"
836+
".. deprecated:: 3.8\n";
824837

825838
static PyObject *PyFT2Font_get_xys(PyFT2Font *self, PyObject *args, PyObject *kwds)
826839
{
840+
char const* msg =
841+
"FT2Font.get_xys is deprecated since Matplotlib 3.8 and will be removed two "
842+
"minor releases later as it is not used in the library. If you rely on it, "
843+
"please let us know.";
844+
if (PyErr_WarnEx(PyExc_DeprecationWarning, msg, 1)) {
845+
return NULL;
846+
}
847+
827848
bool antialiased = true;
828849
std::vector<double> xys;
829850
const char *names[] = { "antialiased", NULL };

src/tri/_tri.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,6 @@ double XYZ::dot(const XYZ& other) const
133133
return x*other.x + y*other.y + z*other.z;
134134
}
135135

136-
double XYZ::length_squared() const
137-
{
138-
return x*x + y*y + z*z;
139-
}
140-
141136
XYZ XYZ::operator-(const XYZ& other) const
142137
{
143138
return XYZ(x - other.x, y - other.y, z - other.z);
@@ -182,12 +177,6 @@ ContourLine::ContourLine()
182177
: std::vector<XY>()
183178
{}
184179

185-
void ContourLine::insert_unique(iterator pos, const XY& point)
186-
{
187-
if (empty() || pos == end() || point != *pos)
188-
std::vector<XY>::insert(pos, point);
189-
}
190-
191180
void ContourLine::push_back(const XY& point)
192181
{
193182
if (empty() || point != back())

src/tri/_tri.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ struct XYZ
116116
XYZ(const double& x_, const double& y_, const double& z_);
117117
XYZ cross(const XYZ& other) const;
118118
double dot(const XYZ& other) const;
119-
double length_squared() const;
120119
XYZ operator-(const XYZ& other) const;
121120
friend std::ostream& operator<<(std::ostream& os, const XYZ& xyz);
122121

@@ -137,14 +136,12 @@ class BoundingBox
137136
};
138137

139138
/* A single line of a contour, which may be a closed line loop or an open line
140-
* strip. Identical adjacent points are avoided using insert_unique() and
141-
* push_back(), and a closed line loop should also not have identical first and
142-
* last points. */
139+
* strip. Identical adjacent points are avoided using push_back(), and a closed
140+
* line loop should also not have identical first and last points. */
143141
class ContourLine : public std::vector<XY>
144142
{
145143
public:
146144
ContourLine();
147-
void insert_unique(iterator pos, const XY& point);
148145
void push_back(const XY& point);
149146
void write() const;
150147
};

0 commit comments

Comments
 (0)