From 12877fd12404aa469ea06bbe80d2c4c9844fc896 Mon Sep 17 00:00:00 2001 From: Poruri Sai Rahul Date: Tue, 20 Apr 2021 15:35:26 +0530 Subject: [PATCH 1/2] CLN : Remove dead code - remove support for older versions of wx - remove unnecessary files - remove unnecessary readmes or update readmes - remove commented out code and code paths - remove KIVA_WISHLIST handling in kiva init deleted: docs/kiva/agg/interface.txt modified: enable/savage/svg/backends/wx/renderer.py modified: enable/wx/base_window.py modified: enable/wx/constants.py modified: kiva/__init__.py deleted: kiva/agg/src/dummy.cpp modified: kiva/agg/src/kiva_gradient.h modified: kiva/agg/src/kiva_graphics_context.h modified: kiva/agg/src/numeric_ext.i modified: kiva/agg/src/readme.txt deleted: kiva/agg/src/tst_convert.py deleted: kiva/fonttools/README.rst modified: kiva/gl/src/kiva_gl_graphics_context.cpp deleted: kiva/readme.txt deleted: kiva/tests/agg/README.txt --- docs/kiva/agg/interface.txt | 305 ------------ enable/savage/svg/backends/wx/renderer.py | 72 +-- enable/wx/base_window.py | 6 - enable/wx/constants.py | 5 +- kiva/__init__.py | 13 +- kiva/agg/src/dummy.cpp | 547 ---------------------- kiva/agg/src/kiva_gradient.h | 7 - kiva/agg/src/kiva_graphics_context.h | 10 - kiva/agg/src/numeric_ext.i | 4 - kiva/agg/src/readme.txt | 12 +- kiva/agg/src/tst_convert.py | 14 - kiva/fonttools/README.rst | 16 - kiva/gl/src/kiva_gl_graphics_context.cpp | 6 - kiva/readme.txt | 41 -- kiva/tests/agg/README.txt | 4 - 15 files changed, 20 insertions(+), 1042 deletions(-) delete mode 100755 docs/kiva/agg/interface.txt delete mode 100644 kiva/agg/src/dummy.cpp delete mode 100644 kiva/agg/src/tst_convert.py delete mode 100644 kiva/fonttools/README.rst delete mode 100644 kiva/readme.txt delete mode 100644 kiva/tests/agg/README.txt diff --git a/docs/kiva/agg/interface.txt b/docs/kiva/agg/interface.txt deleted file mode 100755 index 243cf425c..000000000 --- a/docs/kiva/agg/interface.txt +++ /dev/null @@ -1,305 +0,0 @@ -Kiva Interface Quick Reference (AGG backend) -========================================================================== - -This document is a summary of the classes and functions available in -Kiva. More specifically, it describes some of the details of the -kiva.agg backend, including enumerated types and helper classes. - -------------------------------------------- -Primitive types -------------------------------------------- -The following conventions are used to describe input and output types: - - color: either a 3-tuple or 4-tuple; the represented color depends - on the graphics context's pixel format - rect: (origin_x, origin_y, width, height) - bool: an int that is 1 or 0 - affine_matrix: an AffineMatrix instance representing some type of - coordinate transform. See /kiva/agg/src/kiva_affine_matrix.h - point_array: an array/sequence of length-2 arrays, e.g. ((x,y), (x2,y2),...) - rect_array: an array/sequence of rects: ((x,y,w,h), (x2,y2,w2,h2), ...) - -------------------------------------------- -Supporting types -------------------------------------------- - - AffineMatrix - ------------ - (kiva_affine_matrix.h and affine_matrix.i) - All of the following member functions modify the instance on which they - are called: - - __init__(v0, v1, v2, v3, v4, v5) or __init__() - reset() # sets this matrix to the identity - multiply(AffineMatrix) # multiples this matrix by another - invert() # sets this matrix to the inverse of itself - flip_x() # mirrors around X - flip_y() # mirrors around Y - scale() -> float # returns the average scale of this matrix - determinant() -> float # returns the determinant - - The following factory methods are available in the top-level "agg" namespace - to create specific kinds of AffineMatrix instances: - - translation_matrix(float X, float Y) - rotation_matrix(float angle_in_radians) - scaling_matrix(float x_scale, float y_scale) - skewing_matrix(float x_shear, float y_shear) - - FontType - ------------ - (kiva_font_type.h and font_type.i) - __init__(name, size=12) - - CompiledPath - ------------ - see kiva_compiled_path.h in /kiva/agg/src/; - interface is very similar to "Path drawing" interface of Graphics Context - - -------------------------------------------- -Enumerations - see also /kiva/agg/src/kiva_constants.h -------------------------------------------- -The following enumerations are represented by top-level constants in the "agg" -namespace. They are fundamentally integers. Some of them also have dicts that -map between their names and integer values - - line_cap: CAP_BUTT, CAP_ROUND, CAP_SQUARE - line_join: JOIN_ROUND, JOIN_BEVEL, JOIN_MITER - - draw_mode: FILL, EOF_FILL, STROKE, FILL_STROKE, EOF_FILL_STROKE - - text_style: NORMAL, BOLD, ITALIC - text_draw_mode: TEXT_FILL, TEXT_INVISIBLE [this is currently unused] - - pix_format: - dicts: pix_format_string_map, pix_format_enum_map - values: pix_format_gray8, pix_format_rgb555, pix_format_rgb565, - pix_format_rgb24, pix_format_bgr24, pix_format_rgba32, - pix_format_argb32, pix_format_abgr32, pix_format_bgra32 - (NOTE: the strings in the dicts omit the "pix_format_" prefix) - - interpolation: - dicts: interp_enum_map, interp_string_map - values: nearest, bilinear, bicubic, spline16, spline36, sinc64, sinc144, - sinc256, blackman64, blackman100, blackman256 - - marker: - dicts: marker_string_map, marker_enum_map - values: marker_circle, marker_cross, marker_crossed_circle, marker_dash, - marker_diamond, marker_dot, marker_four_rays, marker_pixel, - marker_semiellipse_down, marker_semiellipse_left, marker_x, - marker_semiellipse_right, marker_semiellipse_up, marker_square, - marker_triangle_down, marker_triangle_left, marker_triangle_right, - marker_triangle_up - (NOTE: the strings in the dicts omit the "marker_" prefix) - -Path_cmd and path_flags are low-level Agg path attributes. See the Agg -documentation for more information about them. We just pass them through in Kiva. - - path_cmd: path_cmd_curve3, path_cmd_curve4, path_cmd_end_poly, path_cmd_line_to - path_cmd_mask, path_cmd_move_to, path_cmd_stop - path_flags: path_flags, path_flags_ccw, path_flags_close, path_flags_cw, - path_flags_mask, path_flags_none - - - - -************************************************* -*** Graphics Context Reference *** -************************************************* - -------------------------------------------- -Construction -------------------------------------------- - GraphicsContextArray(size, pix_format="rgba32") - # size is a tuple (width, height) - Image(filename) - - -------------------------------------------- -Graphics state -------------------------------------------- - save_state() - restore_state() - set_stroke_color(color) - get_stroke_color() -> color - set_line_width(float) - set_line_join(line_join) - set_line_cap(line_cap) - set_line_dash(array) - # array is an even-lengthed tuple of floats that represents - # the width of each dash and gap in the dash pattern. - set_fill_color(color) - get_fill_color() -> color - linear_gradient(x1, y1, x2, y2, stops, spread_method, units) - radial_gradient(cx, cy, r, fx, fy, stops, spread_method, units) - # The gradient methods modify the current fill color - set_alpha(float) - get_alpha() -> float - set_antialias(bool) - get_antialias() -> bool - set_miter_limit(float) - set_flatness(float) - get_image_interpolation() -> interpolation - set_image_interpolation(interpolation) - - translate_ctm(float x, float y) - rotate_ctm(float angle_in_radians) - concat_ctm(AffineMatrix) - scale_ctm(float x_scale, float y_scale) - set_ctm(AffineMatrix) - get_ctm() -> AffineMatrix - - -------------------------------------------- -Clipping functions -------------------------------------------- - clip_to_rect(rect) - clip_to_rects(rect_array) - clip() - # clips using the current path - even_odd_clip() - # modifies the current clipping path using the even-odd rule to - # calculate the intersection of the current path and the current - # clipping path. - -------------------------------------------- -Path construction functions -------------------------------------------- - # All coordinates below are floating-point - begin_path() - close_path() - get_empty_path() -> CompiledPath - # returns a blank CompiledPath instance - add_path(CompiledPath) - - move_to(x, y) - line_to(x, y) - lines(point_array) - rect(x, y, w, h) - rects(rect_array) - - curve_to(x1, y1, x2, y2, end_x, end_y) - # draws a cubic bezier curve with control points (x1,y1) and (x2,y2) - # that ends at point (end_x, end_y) - - quad_curve_to(cp_x, cp_y, end_x, end_y) - # draws a quadratic bezier curve from the current point using - # control point (cp_x, cp_y) and ending at (end_x, end_y) - - arc(x, y, radius, start_angle, end_angle, bool cw=false) - # draws a circular arc of the given radius, centered at (x,y) - # with angular span as indicated. Angles are measured counter- - # clockwise from the positive X axis. If "cw" is true, then - # the arc is swept from the end_angle back to the start_angle - # (it does not change the sense in which the angles are measured). - - arc_to(x1, y1, x2, y2, radius) - # from the comments in kiva_graphics_context_base.h: - # Sweeps a circular arc from the pen position to a point on the - # line from (x1,y1) to (x2,y2). - # - # The arc is tangent to the line from the current pen position - # to (x1,y1), and it is also tangent to the line from (x1,y1) - # to (x2,y2). (x1,y1) is the imaginary intersection point of - # the two lines tangent to the arc at the current point and - # at (x2,y2). - # - # If the tangent point on the line from the current pen position - # to (x1,y1) is not equal to the current pen position, a line is - # drawn to it. Depending on the supplied radius, the tangent - # point on the line fron (x1,y1) to (x2,y2) may or may not be - # (x2,y2). In either case, the arc is drawn to the point of - # tangency, which is also the new pen position. - # - # Consider the common case of rounding a rectangle's upper left - # corner. Let "r" be the radius of rounding. Let the current - # pen position be (x_left + r, y_top). Then (x2,y2) would be - # (x_left, y_top - radius), and (x1,y1) would be (x_left, y_top). - -------------------------------------------- -Drawing functions -------------------------------------------- - stroke_path() - fill_path() - eof_fill_path() - draw_path(draw_mode=FILL_STROKE) - draw_rect(rect, draw_mode=FILL_STROKE) - draw_marker_at_points(point_array, int size, marker=marker_square) - draw_path_at_points(point_array, CompiledPath, draw_mode) - draw_image(graphics_context img, rect=None) - # if rect is defined, then img is scaled and drawn into it; - # otherwise, img is overlayed exactly on top of this graphics context - -------------------------------------------- -Text functions -------------------------------------------- - set_text_drawing_mode(text_draw_mode) - set_text_matrix(AffineMatrix) - get_text_matrix() -> AffineMatrix - set_text_position(float X, float Y) - get_text_position() -> (X, Y) - show_text(string) - show_text_translate(string, float X, float Y) - get_text_extent(string) -> (x,y,w,h) - get_full_text_extent(string) -> (w,h,x,y) - # deprecated; order has been changed for backwards-compatibility - # with existing Enable - select_font(name, size, style) - set_font(FontType) - get_font() -> FontType - set_font_size(int) - set_character_spacing() - get_character_spacing() - set_text_drawing_mode() - show_text_at_point() - -------------------------------------------- -Misc functions -------------------------------------------- - width() -> int - height() -> int - stride() -> int - bottom_up() -> bool - format() -> pix_format - - flush() - # Force all pending drawing operations to be rendered immediately. - # This only makes sense in window contexts, ie- the Mac Quartz backend. - synchronize() - # A deferred version of flush(). Also only relevant in window contexts. - begin_page() - end_page() - - clear_rect(rect) - # Clears a rect. Not available in PDF context. - - convert_pixel_format(pix_format, bool inplace=0) - - save(filename, file_format=None, pil_options=None) - # From the comments in graphics_context.i: - # Save the GraphicsContext to a file. Output files are always - # saved in RGB or RGBA format; if this GC is not in one of - # these formats, it is automatically converted. - # - # If filename includes an extension, the image format is - # inferred from it. file_format is only required if the - # format can't be inferred from the filename (e.g. if you - # wanted to save a PNG file as a .dat or .bin). - # - # pil_options is a dict of format-specific options that - # are passed down to the PIL image file writer. If a writer - # doesn't recognize an option, it is silently ignored. - # - # If the image has an alpha channel and the specified output - # file format does not support alpha, the image is saved in - # rgb24 format. - - - -------------------------------------------- -Functions that are currently stubbed -out or not implemented -------------------------------------------- - show_glyphs_at_point() diff --git a/enable/savage/svg/backends/wx/renderer.py b/enable/savage/svg/backends/wx/renderer.py index 452d0d46e..f1dcfad0c 100644 --- a/enable/savage/svg/backends/wx/renderer.py +++ b/enable/savage/svg/backends/wx/renderer.py @@ -96,31 +96,15 @@ def convert_stop(stop): ) return offset, color - if wx.VERSION[:2] > (2, 9): - # wxPython 2.9+ supports a collection of stops - wx_stops = wx.GraphicsGradientStops() - for stop in stops: - offset, color = convert_stop(stop) - wx_stops.Add(color, offset) - - wx_renderer = wx.GraphicsRenderer.GetDefaultRenderer() - return wx_renderer.CreateLinearGradientBrush( - x1, y1, x2, y2, wx_stops - ) - - else: - if len(stops) > 2: - msg = ("wxPython 2.8 only supports 2 gradient stops, but %d " - "were specified") - warnings.warn(msg % len(stops)) - - start_offset, start_color = convert_stop(stops[0]) - end_offset, end_color = convert_stop(stops[1]) - - wx_renderer = wx.GraphicsRenderer.GetDefaultRenderer() - return wx_renderer.CreateLinearGradientBrush( - x1, y1, x2, y2, start_color, end_color - ) + wx_stops = wx.GraphicsGradientStops() + for stop in stops: + offset, color = convert_stop(stop) + wx_stops.Add(color, offset) + + wx_renderer = wx.GraphicsRenderer.GetDefaultRenderer() + return wx_renderer.CreateLinearGradientBrush( + x1, y1, x2, y2, wx_stops + ) @staticmethod def createRadialGradientBrush(cx, cy, r, stops, fx=None, fy=None, @@ -136,37 +120,15 @@ def convert_stop(stop): ) return offset, color - if wx.VERSION[:2] > (2, 9): - # wxPython 2.9+ supports a collection of stops - wx_stops = wx.GraphicsGradientStops() - for stop in stops: - offset, color = convert_stop(stop) - wx_stops.Add(color, offset) - - wx_renderer = wx.GraphicsRenderer.GetDefaultRenderer() - return wx_renderer.CreateRadialGradientBrush( - fx, fy, cx, cy, r, wx_stops - ) - - else: - - if len(stops) > 2: - msg = ("wxPython 2.8 only supports 2 gradient stops, but %d " - "were specified") - warnings.warn(msg % len(stops)) + wx_stops = wx.GraphicsGradientStops() + for stop in stops: + offset, color = convert_stop(stop) + wx_stops.Add(color, offset) - start_offset, start_color = convert_stop(stops[0]) - end_offset, end_color = convert_stop(stops[-1]) - - if fx is None: - fx = cx - if fy is None: - fy = cy - - wx_renderer = wx.GraphicsRenderer.GetDefaultRenderer() - return wx_renderer.CreateRadialGradientBrush( - fx, fy, cx, cy, r, start_color, end_color - ) + wx_renderer = wx.GraphicsRenderer.GetDefaultRenderer() + return wx_renderer.CreateRadialGradientBrush( + fx, fy, cx, cy, r, wx_stops + ) @staticmethod def fillPath(*args): diff --git a/enable/wx/base_window.py b/enable/wx/base_window.py index 0fe74adf6..0cb2a6f0d 100644 --- a/enable/wx/base_window.py +++ b/enable/wx/base_window.py @@ -381,12 +381,6 @@ def _create_mouse_event(self, event): else: mouse_wheel_delta = (0, mouse_wheel * 120 / 200.0) - # Note: The following code fixes a bug in wxPython that returns - # 'mouse_wheel' events in screen coordinates, rather than window - # coordinates: - if wx.VERSION[:2] < (2, 8): - if mouse_wheel != 0 and sys.platform == "win32": - x, y = self.control.ScreenToClientXY(x, y) return MouseEvent( x=x, y=self._flip_y(y), diff --git a/enable/wx/constants.py b/enable/wx/constants.py index a0465d8fc..2c2068598 100644 --- a/enable/wx/constants.py +++ b/enable/wx/constants.py @@ -145,10 +145,7 @@ KEY_MAP = dict(zip(key_symbols, key_names)) -if wx.VERSION[:3] < (2, 9, 4): - mouse_wheel_axes = [0, 1] -else: - mouse_wheel_axes = [wx.MOUSE_WHEEL_VERTICAL, wx.MOUSE_WHEEL_HORIZONTAL] +mouse_wheel_axes = [wx.MOUSE_WHEEL_VERTICAL, wx.MOUSE_WHEEL_HORIZONTAL] if len(mouse_wheel_axes) != len(mouse_wheel_axes_names): warnings.warn("The WX toolkit backend mouse wheel axes are out of sync!") diff --git a/kiva/__init__.py b/kiva/__init__.py index c8bfb247c..8e84a2f0f 100644 --- a/kiva/__init__.py +++ b/kiva/__init__.py @@ -8,21 +8,10 @@ # # Thanks for using Enthought open source! """ -A multi-platform DisplayPDF vector drawing engine. +A multi-platform raster and vector drawing engine. Part of the Enable project of the Enthought Tool Suite. """ -import os - from kiva._version import full_version as __version__ from .constants import * from .fonttools import Font - -if "KIVA_WISHLIST" in os.environ: - from warnings import warn - - warn( - "Use of the KIVA_WISHLIST environment variable to select Kiva backends" - "is no longer supported." - ) -del os diff --git a/kiva/agg/src/dummy.cpp b/kiva/agg/src/dummy.cpp deleted file mode 100644 index 2a2a12e6b..000000000 --- a/kiva/agg/src/dummy.cpp +++ /dev/null @@ -1,547 +0,0 @@ -// (C) Copyright 2005-2021 Enthought, Inc., Austin, TX -// All rights reserved. -// -// This software is provided without warranty under the terms of the BSD -// license included in LICENSE.txt and may be redistributed only under -// the conditions described in the aforementioned license. The license -// is also available online at http://www.enthought.com/licenses/BSD.txt -// -// Thanks for using Enthought open source! -#include "agg_trans_affine.h" -#include "kiva_graphics_context.h" -#include "kiva_compiled_path.h" -#include "kiva_font_type.h" -#include "kiva_rect.h" - -#include - -// ripped from Agg -bool write_ppm(const unsigned char* buf, - unsigned width, - unsigned height, - const char* file_name) -{ - FILE* fd = fopen(file_name, "wb"); - if(fd) - { - fprintf(fd, "P6 %d %d 255 ", width, height); - fwrite(buf, 1, width * height * 3, fd); - fclose(fd); - return true; - } - return false; -} - -agg24::rgba black(0.0, 0.0, 0.0); -agg24::rgba white(1.0, 1.0, 1.0); -agg24::rgba lightgray(0.2, 0.2, 0.2); -agg24::rgba red(1.0, 0.0, 0.0); -agg24::rgba green(0.0, 1.0, 0.0); -agg24::rgba blue(0.0, 0.0, 1.0); -agg24::rgba niceblue(0.411, 0.584, 0.843); - - -typedef agg24::pixfmt_rgb24 AGG_PIX_TYPE; -typedef kiva::graphics_context GC_TYPE; -typedef std::vector rect_list_type; - - - - -void draw_sub_image(GC_TYPE &gc_img, unsigned int width, unsigned int height) -{ - gc_img.clear(white); - gc_img.set_alpha(0.4); - gc_img.set_fill_color(green); - gc_img.rect(0, 0, width, height); - gc_img.fill_path(); - - gc_img.set_alpha(1.0); - gc_img.set_stroke_color(red); - gc_img.move_to(0.0,0.0); - gc_img.line_to(width,height); - gc_img.stroke_path(); - gc_img.set_stroke_color(blue); - gc_img.move_to(0.0, height); - gc_img.line_to(width, 0.0); - gc_img.stroke_path(); - - //show_clip_rects(gc_img); - -} - - -void test_arc_to2(GC_TYPE &gc, double x2, double y2, double radiusstep=25.0) -{ - gc.set_stroke_color(lightgray); - //gc.move_to(100, 0); - //gc.line_to(0, 0); - gc.move_to(0, 0); - gc.line_to(100, 0); - gc.line_to(x2, y2); - gc.stroke_path(); - gc.set_stroke_color(black); - - int numradii = 7; - for (int i=0; ix << " " << it->y << " " << it->w << " " << it->h << std::endl; -// } - //gc.clip_to_rects(mclip_rects); - //kiva::test_disjoint_union(); - //draw_sub_image(gc, 200, 200); - - double color_delta = 0.0; - for (kiva::rect_iterator it=actual_rects.begin(); it != actual_rects.end(); it++) - { - agg24::rgba tmpcolor(0.0, 0.4+color_delta, 0.0); - gc.set_fill_color(tmpcolor); - gc.rect(*it); - gc.fill_path(); - color_delta += 0.5/actual_rects.size(); - } - gc.set_alpha(1.0); - gc.set_stroke_color(black); - gc.set_line_width(1); - //gc.clear_clip_path(); - gc.rects(mclip_rects); - gc.rect(0, 0, 200, 200); - gc.stroke_path(); - gc.restore_state(); -} - -void test_disjoint_intersect(GC_TYPE &gc) -{ - kiva::rect_list_type output_rects; - kiva::rect_list_type input_rects; - //kiva::rect_type rect1(atof(argv[0]),atof(argv[1]),atof(argv[2]),atof(argv[3])); - //kiva::rect_type rect2(atof(argv[4]),atof(argv[5]),atof(argv[6]),atof(argv[7])); - input_rects.push_back(kiva::rect_type(20.5,20.5,60,50)); - //input_rects.push_back(kiva::rect_type(40.5,40.5,60,10)); - input_rects.push_back(kiva::rect_type(60.5,80.5,35,60)); -// input_rects.push_back(kiva::rect_type(40.5,60.5,60,60)); - kiva::rect_type new_rect(40.5,60.5,60,60); - output_rects = kiva::disjoint_intersect(input_rects, new_rect); - - gc.save_state(); - gc.set_alpha(1.0); - gc.set_stroke_color(blue); - gc.rects(input_rects); - gc.rect(new_rect); - gc.stroke_path(); - gc.set_alpha(0.4); - gc.set_fill_color(red); - gc.rects(output_rects); - gc.fill_path(); - gc.restore_state(); -} - -void test_compiled_path(GC_TYPE &gc) -{ - // Compiled path test - kiva::compiled_path mypath; - mypath.begin_path(); - mypath.move_to(0.0, 0.0); - mypath.line_to(20.0, 0.0); - mypath.line_to(20.0,20.0); - mypath.line_to(0.0, 20.0); - mypath.line_to(0.0, 10.0); - mypath.close_path(); - agg24::rgba tmpcolor(0.0, 0.0, 1.0); - gc.set_stroke_color(tmpcolor); - gc.add_path(mypath); - gc.stroke_path(); - double points[] = {25, 25, 75, 25, 25, 75, 75, 75, 50, 50}; - gc.draw_path_at_points(points, 5, mypath, kiva::STROKE); - -} - -void test_handling_text(GC_TYPE &gc) -{ - char unicodeString[] = {230, 234, 223, 220, 0}; - - // Text handling test. Make sure timesi.ttf is in the current directory! - kiva::font_type timesFont("times", 12, "regular"); - kiva::font_type copperFont("coprgtl", 12, "regular"); - kiva::font_type curlzFont("arial", 12, "regular"); - //kiva::font_type unicodeFont("uni_font", 12, "regular"); - - gc.set_alpha(1.0); - gc.set_text_drawing_mode(kiva::TEXT_FILL); - - gc.set_font(timesFont); - //gc.set_font(unicodeFont); - gc.translate_ctm(100.0, 100.0); - gc.move_to(-5,0); - gc.line_to(5,0); - gc.move_to(0,5); - gc.line_to(0,-5); - gc.move_to(0,0); - gc.stroke_path(); - //agg24::trans_affine_translation txtTrans(200.0,150.0); - agg24::trans_affine_rotation txtRot(agg24::deg2rad(30)); - //txtTrans.premultiply(txtRot); - //txtTrans *= txtRot; - gc.set_text_matrix(txtRot); - //gc.set_text_position(150.5, 350.5); - //kiva::rect_type bbox(gc.get_text_extent("Hello")); - //gc.get_text_matrix().transform(&bbox.x, &bbox.y); - gc.show_text("Hello"); - gc.show_text("foobar"); - gc.show_text(unicodeString); - //txtRot.invert(); - //gc.set_text_matrix(txtRot); - //gc.show_text("inverted"); -// gc.rect(bbox); -// gc.stroke_path(); -/* - gc.set_font(copperFont); - gc.set_text_position(150.5, 250.5); - kiva::rect_type bbox2(gc.get_text_extent("Hello")); - gc.get_text_matrix().transform(&bbox2.x, &bbox2.y); - gc.show_text("Hello"); -// gc.rect(bbox2); -// gc.stroke_path(); - - gc.set_font(curlzFont); - gc.set_text_position(150.5, 150.5); - kiva::rect_type bbox3(gc.get_text_extent("Hello")); - gc.get_text_matrix().transform(&bbox3.x, &bbox3.y); - gc.show_text("Hello"); -// gc.rect(bbox3); -// gc.stroke_path(); -*/ - //gc.set_stroke_color(red); - //gc.show_text("blah"); - - //gc.set_text_position(200.0, 100.0); - //gc.show_text("Hello"); - //gc.show_text_translate("Hello", 10.0, 360.0); - //gc.set_font_size(36); - //gc.show_text_translate("Hello", 10.0, 190.0); -} - - -void gc_stress_test() -{ - int width = 100; - int height = 100; - int pixelsize = 3; - unsigned char *buf = new unsigned char[width * height * pixelsize]; - - bool tmp = true; - for (int i=0; i<100000; i++) - { - if (i%1000 == 0) - { - printf("%d\n", i); - } - GC_TYPE gc(buf, width, height, -width*pixelsize); - kiva::font_type f("arial"); - gc.set_font(f); -// tmp = gc.show_text("hello"); - if (f.filename == "") - { - int q = 5; - } - - } - - delete[] buf; -} - -void brandon_draw_test(GC_TYPE &gc) -{ - gc.set_stroke_color(red); - gc.set_line_width(1.0); - gc.begin_path(); - gc.move_to(30.0, 10.0); - gc.line_to(20.0, 10.0); - gc.line_to(20.0, 90.0); - gc.line_to(10.0, 10.0); - gc.close_path(); - gc.stroke_path(); -} - -int main(int argc, char **argv) -{ - - unsigned int width = 640; - unsigned int height = 480; - unsigned char pixelsize = 0; - AGG_PIX_TYPE *msvc6_dummy = NULL; - switch (kiva::agg_pix_to_kiva(msvc6_dummy)) - { - case (kiva::pix_format_gray8) : pixelsize = 1; break; - case (kiva::pix_format_rgb24) : - case (kiva::pix_format_bgr24) : pixelsize = 3; break; - case (kiva::pix_format_bgra32): - case (kiva::pix_format_rgba32): - case (kiva::pix_format_argb32): - case (kiva::pix_format_abgr32): pixelsize = 4; break; - } - unsigned char *buf = new unsigned char[width * height * pixelsize]; - - GC_TYPE gc((unsigned char*)buf, width, height, -width * pixelsize); - gc.clear(); - - //brandon_draw_test(gc); - //gc_stress_test(); - //test_handling_text(gc); - test_clip_stack(gc); - //test_arc_curve(gc); - //test_arc_to(gc); - //test_clip_stack(gc); - - if (!write_ppm(buf, width, height, "dummy.ppm")) - { - printf("\nError writing file.\n"); - } - - delete[] buf; - - return 0; -} diff --git a/kiva/agg/src/kiva_gradient.h b/kiva/agg/src/kiva_gradient.h index 4ffb2e786..07bceddfa 100644 --- a/kiva/agg/src/kiva_gradient.h +++ b/kiva/agg/src/kiva_gradient.h @@ -229,13 +229,6 @@ namespace kiva } gradient_mtx.invert(); - //std::cout << "drawing with affine matrix " << gradient_mtx.m0 - // << ", " << gradient_mtx.m1 - // << ", " << gradient_mtx.m2 - // << ", " << gradient_mtx.m3 - // << ", " << gradient_mtx.m4 - // << ", " << gradient_mtx.m5 << std::endl; - span_gradient_type span_gradient(span_interpolator, gradient_func, color_array, diff --git a/kiva/agg/src/kiva_graphics_context.h b/kiva/agg/src/kiva_graphics_context.h index cd58ece18..28b273c61 100644 --- a/kiva/agg/src/kiva_graphics_context.h +++ b/kiva/agg/src/kiva_graphics_context.h @@ -1083,10 +1083,6 @@ namespace kiva this->close_path(); this->draw_path(mode); } - else - { - //printf("simple worked!\n"); - } this->path.remove_all(); } @@ -1098,7 +1094,6 @@ namespace kiva /* function requires that antialiasing is false and ctm doesn't have any rotation. */ - //printf("trying _simple\n"); int success = 0; agg24::trans_affine ctm = this->get_ctm(); @@ -1125,8 +1120,6 @@ namespace kiva double tx = temp[4]; double ty = temp[5]; - //printf("rect: %d, %d %d, %d\n", rect[0], rect[1], rect[2], rect[3]); - //printf("trans, scale: %d, %d %d, %d\n", tx, ty, scale_x, scale_y); // fix me: need to handle rounding here... int x1 = int(rect[0]*scale_x + tx); int y1 = int(rect[1]*scale_y + ty); @@ -1137,7 +1130,6 @@ namespace kiva if (mode == FILL_STROKE || mode == EOF_FILL_STROKE) { - //printf("fill stroke: %d, %d %d, %d\n", x1, y1, x2, y2); renderer.outlined_rectangle(x1, y1, x2, y2); // This isn't right, but it should be faster. Interestingly, // it didn't seem to be. @@ -1146,14 +1138,12 @@ namespace kiva } else if (mode == STROKE ) { - //printf("stroke: %d, %d %d, %d\n", x1, y1, x2, y2); renderer.rectangle(x1, y1, x2, y2); success = 1; } else if (mode == FILL || mode == EOF_FILL ) { - //printf("fill: %d, %d %d, %d\n", x1, y1, x2, y2); renderer.solid_rectangle(x1, y1, x2, y2); success = 1; } diff --git a/kiva/agg/src/numeric_ext.i b/kiva/agg/src/numeric_ext.i index 29191aaf7..97566a0e1 100644 --- a/kiva/agg/src/numeric_ext.i +++ b/kiva/agg/src/numeric_ext.i @@ -23,10 +23,6 @@ PyObject *PyArray_FromDimsAndStridesAndDataAndDescr(int nd, int *d, int* st, int *dimensions, *strides; int flags= CONTIGUOUS | OWN_DIMENSIONS | OWN_STRIDES; - //static int calls = 0; - //calls++; - //printf("allocs: %d\n;", calls); - dimensions = strides = NULL; if (nd < 0) diff --git a/kiva/agg/src/readme.txt b/kiva/agg/src/readme.txt index 96356fcf0..b898a7958 100644 --- a/kiva/agg/src/readme.txt +++ b/kiva/agg/src/readme.txt @@ -47,22 +47,12 @@ kiva_pix_format.h defines agg_pix_to_kiva() kiva_rect.h/.cpp Kiva rectangle class (with converters to/from double*, Agg rects, etc.) -Visual Studio 6 files -------------------------------- -kiva.dsp Project file for the agg wrapper -kiva.dsw workspace file for kiva.dsp - -The following files are generated by Visual Studio during compilation -kiva.ncd -kiva.opt -kiva.plg - Directories ------------------------------- gtk1 support files for grabbing a graphics context in GTK win32 " " " " " " " " win32 x11 " " " " " " " " xwindows -gl " " " " " " " " openGL +osx " " " " " " " " OSX diff --git a/kiva/agg/src/tst_convert.py b/kiva/agg/src/tst_convert.py deleted file mode 100644 index ac09c93cd..000000000 --- a/kiva/agg/src/tst_convert.py +++ /dev/null @@ -1,14 +0,0 @@ -# (C) Copyright 2005-2021 Enthought, Inc., Austin, TX -# All rights reserved. -# -# This software is provided without warranty under the terms of the BSD -# license included in LICENSE.txt and may be redistributed only under -# the conditions described in the aforementioned license. The license -# is also available online at http://www.enthought.com/licenses/BSD.txt -# -# Thanks for using Enthought open source! -import agg - -q = agg.Image((10, 10), pix_format="rgb24") -q.convert_pixel_format("rgba32") -print(q.format()) diff --git a/kiva/fonttools/README.rst b/kiva/fonttools/README.rst deleted file mode 100644 index 6602aa2ca..000000000 --- a/kiva/fonttools/README.rst +++ /dev/null @@ -1,16 +0,0 @@ -fonttools -========= - -The ``fonttools`` package provides a platform independent API for describing -fonts as well as locating and loading font information from the local system. - -Only components exposed from ``kiva.font`` are public API. Other modules should -be considered as private implementation details. - -Third-party libraries ---------------------- - -The ``afm`` and ``font_manager`` modules are based heavily on matplotlib's -``afm`` and ``font_manager`` modules. The latter has been modified to remove -dependencies on matplotlib. The original code is subject to matplotlib license. -Copies of licenses can be found in the LICENSES folder. diff --git a/kiva/gl/src/kiva_gl_graphics_context.cpp b/kiva/gl/src/kiva_gl_graphics_context.cpp index df821a6bf..fb3dcc9f2 100644 --- a/kiva/gl/src/kiva_gl_graphics_context.cpp +++ b/kiva/gl/src/kiva_gl_graphics_context.cpp @@ -213,7 +213,6 @@ gl_graphics_context::clip_to_rect(kiva_gl::rect_type &rect) // new clip rectangle doesn't intersect anything, so we push on // an empty rect as the new clipping region. glScissor(0, 0, 0, 0); - //printf("NULL intersection area in clip_to_rect\n"); this->state.device_space_clip_rects.push_back(kiva_gl::rect_type(0, 0, -1, -1)); } else @@ -234,7 +233,6 @@ gl_graphics_context::clip_to_rect(kiva_gl::rect_type &rect) if (this->state.device_space_clip_rects.size() == 0) { glScissor(0, 0, 0, 0); - //printf("NULL intersection area in clip_to_rect\n"); this->state.device_space_clip_rects.push_back(kiva_gl::rect_type(0, 0, -1, -1)); } else @@ -245,10 +243,6 @@ gl_graphics_context::clip_to_rect(kiva_gl::rect_type &rect) // (same problem as in restore_state()) kiva_gl::rect_iterator it = rects.begin(); glScissor(int(it->x), int(it->y), int(it->w), int(it->h)); - if (rects.size() > 1) - { - //printf("Warning: more than 1 clip rect in clip_to_rect()\n"); - } } } } diff --git a/kiva/readme.txt b/kiva/readme.txt deleted file mode 100644 index 102ca00c3..000000000 --- a/kiva/readme.txt +++ /dev/null @@ -1,41 +0,0 @@ -[Importing Kiva] - -To import kiva, you need to get the constants (which includes pen styles, -cap styles, lines styles, etc.), the font stuff, and a backend. You can -import these all together with a wildcard: - - from kiva import * - -If you prefer to get the constants by themselves, you can also do a: - - import kiva - -and this will allow you to refer to them as kiva.JOIN_MITER, kiva.CAP_ROUND, -etc. - -If you don't wish to do a wildcard import, you can also just grab the -following by themselves: - - from kiva import Font, CompiledPath, GraphicsContext, - Canvas, CanvasWindow - -This will auto-detect what backend is appropriate based on the OS platform, -available libraries, and the order of backends listed in the KIVA_WISHLIST -environment variable. If this environment variable is not defined, then the -default ordering of backends is in __init__.py. - -If you want to choose what backend gets used, you can do the following: - - from kiva.backend_ import GraphicsContext, Canvas, CanvasWindow - - is one of: - image - in-memory GraphicsContext, uses Agg to raster, can save out to any PIL format - wx - uses Agg to raster to a platform-dependent wx window - wx_gl - uses Agg to raster into a platform-dependent wx.glcanvas - gl - uses OpenGL module to draw into a GL window - mac - calls Quartz drawing routines into an OS X window/GraphicsContext - ps - PostScript file output - svg - SVG file output - pdf - PDF file output (uses ReportLab) - - diff --git a/kiva/tests/agg/README.txt b/kiva/tests/agg/README.txt deleted file mode 100644 index 185593955..000000000 --- a/kiva/tests/agg/README.txt +++ /dev/null @@ -1,4 +0,0 @@ - -NOTE: - The tests in this folder write image files into this - directory for visual inspection. From 124b24b14fdfc36522c88fd66070845a207e52e5 Mon Sep 17 00:00:00 2001 From: Poruri Sai Rahul Date: Tue, 20 Apr 2021 16:19:48 +0530 Subject: [PATCH 2/2] CLN : Remove conditionals checking for swig version 1 modified: kiva/agg/agg.i modified: kiva/gl/gl.i --- kiva/agg/agg.i | 2 -- kiva/gl/gl.i | 2 -- 2 files changed, 4 deletions(-) diff --git a/kiva/agg/agg.i b/kiva/agg/agg.i index 90c0c07bc..6d2b39d9f 100644 --- a/kiva/agg/agg.i +++ b/kiva/agg/agg.i @@ -11,9 +11,7 @@ %module agg -#if (SWIG_VERSION > 0x010322) %feature("compactdefaultargs"); -#endif // (SWIG_VERSION > 0x010322) %include "constants.i" %include "rgba.i" diff --git a/kiva/gl/gl.i b/kiva/gl/gl.i index 676f30972..a7c5687db 100644 --- a/kiva/gl/gl.i +++ b/kiva/gl/gl.i @@ -11,9 +11,7 @@ %module gl -#if (SWIG_VERSION > 0x010322) %feature("compactdefaultargs"); -#endif // (SWIG_VERSION > 0x010322) %include "constants.i" %include "rgba.i"