gtk / cairo-chart

SSH Git

To clone this repository:

git clone git@git.backbone.ws:gtk/cairo-chart.git

To push to this repository:

# Add a new remote
git remote add origin git@git.backbone.ws:gtk/cairo-chart.git

# Push the master branch to the newly added origin, and configure
# this remote and branch as the default:
git push -u origin master

# From now on you can push master to the "origin" remote with:
git push

Commit: #892527d

Parent: #4b17336

In progress...

avatar Kolan Sh 12 days ago

Summary

  • src/Chart.vala (63) ----------+++++++++++++++++++++++++++++++++++++++++++++++++++++
944 944 * (s.axis_y.zoom_max - s.axis_y.zoom_min) / (s.zoom_place.y_high - s.zoom_place.y_low);
945 945 }
946 946
947 protected virtual bool point_in_square (Point p, double x0, double x1, double y0, double y1) {
947 protected virtual bool point_in_rect (Point p, double x0, double x1, double y0, double y1) {
948 948 if ( (x0 <= p.x <= x1 || x1 <= p.x <= x0)
949 949 && (y0 <= p.y <= y1 || y1 <= p.y <= y0))
950 950 return true;
951 951 return false;
952 952 }
953 953
954 protected virtual bool point_in_plot_area (Point p) {
955 if (point_in_rect (p, plot_area_x_min, plot_area_x_max, plot_area_y_min, plot_area_y_max))
956 return true;
957 return false;
958 }
959
954 960 protected virtual bool hcross (Point a1, Point a2, Float128 h_x1, Float128 h_x2, Float128 h_y, out Float128 x) {
955 961 x = 0;
956 962 if (a1.y == a2.y) return false;
957 963 if (a1.y >= h_y && a2.y >= h_y || a1.y <= h_y && a2.y <= h_y) return false;
958 964 x = a1.x + (a2.x - a1.x) * (h_y - a1.y) / (a2.y - a1.y);
959 return true;
965 if (h_x1 <= x <= h_x2 || h_x2 <= x <= h_x1)
966 return true;
967 return false;
960 968 }
961 969
962 970 protected virtual bool vcross (Point a1, Point a2, Float128 v_x, Float128 v_y1, Float128 v_y2, out Float128 y) {
972 972 if (a1.x == a2.x) return false;
973 973 if (a1.x >= v_x && a2.x >= v_x || a1.x <= v_x && a2.x <= v_x) return false;
974 974 y = a1.y + (a2.y - a1.y) * (v_x - a1.x) / (a2.x - a1.x);
975 return true;
975 if (v_y1 <= y <= v_y2 || v_y2 <= y <= v_y1)
976 return true;
977 return false;
976 978 }
977 979
978 980 delegate int PointComparator(Point a, Point b);
990 990 }
991 991 }
992 992
993 protected virtual void cut_line (Point a, Point b, out Point c, out Point d) {
993 protected virtual bool cut_line (Point a, Point b, out Point c, out Point d) {
994 int ncross = 0;
995 Float128 x = 0, y = 0;
996 Point pc[4];
997 if (hcross(a, b, plot_area_x_min, plot_area_x_max, plot_area_y_min, out x))
998 pc[ncross++] = Point(x, plot_area_y_min);
999 if (hcross(a, b, plot_area_x_min, plot_area_x_max, plot_area_y_max, out x))
1000 pc[ncross++] = Point(x, plot_area_y_max);
1001 if (vcross(a, b, plot_area_x_min, plot_area_y_min, plot_area_y_max, out y))
1002 pc[ncross++] = Point(plot_area_x_min, y);
1003 if (vcross(a, b, plot_area_x_max, plot_area_y_min, plot_area_y_max, out y))
1004 pc[ncross++] = Point(plot_area_x_max, y);
994 1005 c = a;
995 1006 d = b;
1007 if (ncross == 0) {
1008 if (point_in_plot_area (a) && point_in_plot_area (b))
1009 return true;
1010 return false;
1011 }
1012 if (ncross >= 2) {
1013 c = pc[0]; d = pc[1];
1014 return true;
1015 }
1016 if (ncross == 1) {
1017 if (point_in_plot_area (a)) {
1018 c = a;
1019 d = pc[0];
1020 return true;
1021 } else if (point_in_plot_area (b)) {
1022 c = b;
1023 d = pc[0];
1024 return true;
1025 }
1026 }
1027 return false;
996 1028 }
997 1029
998 1030 protected virtual void draw_series () {
1052 1052 // draw series line
1053 1053 for (int i = 1; i < points.length; ++i) {
1054 1054 Point c, d;
1055 cut_line (Point(get_scr_x(s, points[i - 1].x), get_scr_y(s, points[i - 1].y)),
1056 Point(get_scr_x(s, points[i].x), get_scr_y(s, points[i].y)),
1057 out c, out d);
1058 context.move_to (c.x, c.y);
1059 context.line_to (d.x, d.y);
1055 if (cut_line (Point(get_scr_x(s, points[i - 1].x), get_scr_y(s, points[i - 1].y)),
1056 Point(get_scr_x(s, points[i].x), get_scr_y(s, points[i].y)),
1057 out c, out d)) {
1058 context.move_to (c.x, c.y);
1059 context.line_to (d.x, d.y);
1060 }
1060 1061 }
1061 1062 context.stroke();
1062 1063 for (int i = 0; i < points.length; ++i) {
1063 1064 var x = get_scr_x(s, points[i].x);
1064 1065 var y = get_scr_y(s, points[i].y);
1065 if (point_in_square (Point (x, y), plot_area_x_min, plot_area_x_max, plot_area_y_min, plot_area_y_max))
1066 if (point_in_plot_area (Point (x, y)))
1066 1067 draw_marker_at_pos(s.marker_type, x, y);
1067 1068 }
1068 1069 }

Comments