public void insert_point_child(int at_pos) { GuiIntermPoint ip = insert_point(at_pos); add_child(ip, null); ip.Invalidate(); }
public virtual object Clone() { GuiIntermPoint pt = new GuiIntermPoint(); pt.x = this.x; pt.y = this.y; pt.number_in_conn = this.number_in_conn; pt.root = this.root; pt.parent = this.parent; return(pt); }
// user moves conn_point private void fixup_quadric_endpoint_movement(GuiConnectionPoint conn_point) { GuiPoint neighbour; int x, y; if (conn.ipoints.Count == 2) { int dx = conn.first.x - conn.second.x, dy = conn.first.y - conn.second.y; GuiIntermPoint pt = null; if (dx != 0 && dy != 0) { pt = conn.insert_point(0); conn.add_child(pt, null); GuiPathFinder.select_pos_for_middle_point(conn.first, conn.second, out x, out y); pt.x = x; pt.y = y; } } else if (conn.ipoints.Count == 3) { GuiIntermPoint pt = conn.ipoints[1] as GuiIntermPoint; GuiPathFinder.select_pos_for_middle_point(conn.first, conn.second, out x, out y); pt.x = x; pt.y = y; } else if (conn.ipoints.Count >= 3) { bool vertical; if (conn_point == conn.first) { neighbour = conn.ipoints[1] as GuiPoint; vertical = neighbour.x - (conn.ipoints[2] as GuiPoint).x == 0; } else { neighbour = conn.ipoints[conn.ipoints.Count - 2] as GuiPoint; vertical = neighbour.x - (conn.ipoints[conn.ipoints.Count - 3] as GuiPoint).x == 0; } vertical = !vertical; // we have to invert the value to obtain the direction of the segment being moved if (vertical) { neighbour.x = conn_point.x; } else { neighbour.y = conn_point.y; } } }
public override void Moving(int x, int y, ref int ux, ref float uy) { int x2, y2; if (ux >= 0 && ux < conn.ipoints.Count - 1) { Geometry.nearest_point_from_segment(x, y, new Point(((GuiPoint)conn.ipoints[ux]).x, ((GuiPoint)conn.ipoints[ux]).y), new Point(((GuiPoint)conn.ipoints[ux + 1]).x, ((GuiPoint)conn.ipoints[ux + 1]).y), out x2, out y2); if (((x - x2) * (x - x2) + (y - y2) * (y - y2)) > 9) { conn.Invalidate(); GuiIntermPoint gp = conn.insert_point(ux); gp.x = x; gp.y = y; conn.add_child(gp, null); ux = -ux - 2; conn.Invalidate(); } } else if (ux < 0) { int n = -ux - 1; if (n > 0 && n < conn.ipoints.Count - 1) { conn.Invalidate(); Geometry.nearest_point_from_segment(x, y, new Point(((GuiPoint)conn.ipoints[n - 1]).x, ((GuiPoint)conn.ipoints[n - 1]).y), new Point(((GuiPoint)conn.ipoints[n + 1]).x, ((GuiPoint)conn.ipoints[n + 1]).y), out x2, out y2); if (((x - x2) * (x - x2) + (y - y2) * (y - y2)) <= 9) { ux = n - 1; uy = Geometry.point_to_uy(x2, y2, new Point(((GuiPoint)conn.ipoints[n - 1]).x, ((GuiPoint)conn.ipoints[n - 1]).y), new Point(((GuiPoint)conn.ipoints[n + 1]).x, ((GuiPoint)conn.ipoints[n + 1]).y)); conn.remove_child((GuiBound)conn.ipoints[n]); conn.remove_point(n); } else { ((GuiPoint)conn.ipoints[n]).x = x; ((GuiPoint)conn.ipoints[n]).y = y; } conn.Invalidate(); } } }
public GuiIntermPoint insert_point(int after_num) { if (after_num < 0 || after_num >= ipoints.Count - 1) { return(null); } GuiIntermPoint p = new GuiIntermPoint(); p.root = this; p.parent = parent; p.number_in_conn = after_num + 1; ipoints.Insert(after_num + 1, p); for (int i = after_num + 2; i < ipoints.Count; i++) { ((GuiPoint)ipoints[i]).number_in_conn = i; } // perform UC translation transl_action = Translation.AddPoint; transl_action_param = after_num + 1; ModifyUniversalCoords(); return(p); }
public virtual object Clone() { GuiIntermPoint pt = new GuiIntermPoint(); pt.x = this.x; pt.y = this.y; pt.number_in_conn = this.number_in_conn; pt.root = this.root; pt.parent = this.parent; return pt; }
// Params: // segnum - segment number (0..), vertical_sement, delta (offset in points) // affected_segment (if check is set), check - call collapse_quadric_segments // Returns: // 0 - the transformation affects the first connection point (new segment has been inserted ), // 1 - the transformation affects only intermediate points // 2 - the transformation affects the second connection point private int move_quadric_segment(ref int segnum, bool vertical_segment, int delta, out int affected_segment, bool check) { GuiIntermPoint pt = null; GuiPoint orig_pt; int ret = -1; affected_segment = -1; if (delta == 0) { return(ret); } conn.Invalidate(); if (conn.ipoints.Count == 2) { GuiIntermPoint pt2; pt = conn.insert_point(0); pt2 = conn.insert_point(1); pt.x = conn.first.x; pt.y = conn.first.y; pt2.x = conn.second.x; pt2.y = conn.second.y; if (vertical_segment) { pt.x += delta; pt2.x += delta; } else { pt.y += delta; pt2.y += delta; } conn.add_child(pt, null); conn.add_child(pt2, null); segnum = 1; ret = 0; } else { if (segnum != 0) { orig_pt = conn.ipoints[segnum] as GuiPoint; } else { orig_pt = conn.ipoints[1] as GuiPoint; } if (vertical_segment) { orig_pt.x += delta; } else { orig_pt.y += delta; } // the last segment if (segnum == conn.ipoints.Count - 2) { pt = conn.insert_point(segnum); if (vertical_segment) { pt.x = orig_pt.x; pt.y = conn.second.y; } else { pt.y = orig_pt.y; pt.x = conn.second.x; } ret = 2; // the first segment } else if (segnum == 0) { pt = conn.insert_point(0); if (vertical_segment) { pt.x = orig_pt.x; pt.y = conn.first.y; } else { pt.y = orig_pt.y; pt.x = conn.first.x; } segnum = 1; ret = 0; // some segment in the middle } else { GuiPoint sec = conn.ipoints[segnum + 1] as GuiPoint; if (vertical_segment) { sec.x += delta; } else if (!vertical_segment) { sec.y += delta; } ret = 1; } if (pt != null) { conn.add_child(pt, null); } } if (check) { collapse_quadric_segments(ref segnum, out affected_segment); } conn.Invalidate(); return(ret); }