// user moves the end of connection public override void EndPointPositionChanging(GuiConnectionPoint movepoint) { int s = 0, a; fixup_quadric_endpoint_movement(movepoint); collapse_quadric_segments(ref s, out a); check_current_connection(); }
static public bool select_pos_for_middle_point(GuiConnectionPoint p1, GuiConnectionPoint p2, out int x, out int y) { int x1 = p1.x, y1 = p1.y, x2 = p2.x, y2 = p2.y; Geometry.Direction d1 = Geometry.Direction.Null; Rectangle r1 = Rectangle.Empty, r2 = Rectangle.Empty; if (p1.item is GuiItem) { d1 = (p1.item as GuiItem).direction(p1.ux); r1 = (p1.item as GuiItem).AroundRect; } if (p2.item is GuiItem) { r2 = (p2.item as GuiItem).AroundRect; } // try two solutions (x1, y2) and (x2, y1) bool sol1 = !Geometry.rect_inters_with_quadric_segment(r1, x1, y1, x1, y2) && !Geometry.rect_inters_with_quadric_segment(r2, x1, y1, x1, y2) && !Geometry.rect_inters_with_quadric_segment(r1, x2, y2, x1, y2) && !Geometry.rect_inters_with_quadric_segment(r2, x2, y2, x1, y2); bool sol2 = !Geometry.rect_inters_with_quadric_segment(r1, x1, y1, x2, y1) && !Geometry.rect_inters_with_quadric_segment(r2, x1, y1, x2, y1) && !Geometry.rect_inters_with_quadric_segment(r1, x2, y2, x2, y1) && !Geometry.rect_inters_with_quadric_segment(r2, x2, y2, x2, y1); if (p2.item == null && r1.Contains(x2, y2)) { sol1 = true; } if (sol1 && sol2) { if (d1 == Geometry.Direction.South || d1 == Geometry.Direction.North) { sol2 = false; // select sol1 } else { sol1 = false; } } if (sol1 || !sol2 && (d1 == Geometry.Direction.South && y2 - y1 > 0 || d1 == Geometry.Direction.North && y2 - y1 < 0 || d1 == Geometry.Direction.West && x2 - x1 > 0 || d1 == Geometry.Direction.East && x2 - x1 < 0)) { x = x1; y = y2; } else { x = x2; y = y1; } return(sol1 || sol2); }
public GuiConnection(GuiConnectionPoint p1, GuiConnectionPoint p2, UmlRelationType t, StaticView par, GuiConnectionStyle style) { first = p1; second = p2; type = t; parent = par; this.style = style; nav = GuiConnectionNavigation.None; p1.parent = p2.parent = par; p1.root = p2.root = this; ipoints.Add(p1); ipoints.Add(p2); }
// 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 void EndPointPositionChanging(GuiConnectionPoint movepoint) { if (!created) { return; } Style.EndPointPositionChanging(movepoint); foreach (GuiConnectionPoint p in cpoints) { p.UpdatePosition(true); } notify_children(); }
public override void PostLoad() { base.PostLoad(); first = find_child("LeftPoint") as GuiConnectionPoint; second = find_child("RightPoint") as GuiConnectionPoint; first.UpdatePosition(true); second.UpdatePosition(true); first.role = find_child("Role 1") as GuiBoundString; second.role = find_child("Role 2") as GuiBoundString; conn_name = find_child("Name") as GuiBoundString; conn_stereo = find_child("Stereotype") as GuiBoundStereotype; ipoints.Add(first); for (int i = 1; i < loadtime_iterm_count - 1; i++) { ipoints.Add(find_child("Point #" + i)); } ipoints.Add(second); created = true; notify_children(); }
public override void EndPointPositionChanging(GuiConnectionPoint movepoint) { SetupEndPointsPositions(); }
public void remove_connection_point(GuiConnectionPoint p) { cpoints.Remove(p); }
public void add_connection_point(GuiConnectionPoint p) { cpoints.Add(p); }
public override void EndPointPositionChanging(GuiConnectionPoint movepoint) { }
// object to which the movepoint was assigned has changed its location abstract public void EndPointPositionChanging(GuiConnectionPoint movepoint);
// user moves the end of connection public override void EndPointPositionChanging(GuiConnectionPoint movepoint) { int s = 0, a; fixup_quadric_endpoint_movement( movepoint ); collapse_quadric_segments( ref s, out a ); check_current_connection(); }
public static Point[] polyline_quadric_DummyWay(GuiConnectionPoint p1, GuiConnectionPoint p2, ArrayList active) { int x1 = p1.x, y1 = p1.y, x2 = p2.x, y2 = p2.y; Geometry.Direction d1 = Geometry.Direction.Null, d2 = Geometry.Direction.Null; Rectangle r1 = Rectangle.Empty, r2 = Rectangle.Empty; if (p1.item is GuiItem) { d1 = (p1.item as GuiItem).direction(p1.ux); r1 = (p1.item as GuiItem).AroundRect; } if (p2.item is GuiItem) { d2 = (p2.item as GuiItem).direction(p2.ux); r2 = (p2.item as GuiItem).AroundRect; } if ((x1 == x2 || y1 == y2) && !Geometry.rect_inters_with_quadric_segment(r1, x1, y1, x2, y2) && !Geometry.rect_inters_with_quadric_segment(r2, x1, y1, x2, y2)) { return new Point[] {} } ; // try two solutions (x1, y2) and (x2, y1) int xm, ym; if (select_pos_for_middle_point(p1, p2, out xm, out ym)) { return new Point[] { new Point(xm, ym) } } ; // try solutions of 3 segments bool sol1, sol2; Point[] ans1 = new Point[] { new Point(x1, y1), new Point(x2, y2) }, ans2 = new Point[] { new Point(x1, y1), new Point(x2, y2) }; sol2 = sol1 = false; if ((d1 == Geometry.Direction.East && x2 < x1) || (d1 == Geometry.Direction.West && x2 > x1) || (d1 == Geometry.Direction.South && y2 < y1) || (d1 == Geometry.Direction.North && y2 > y1)) { if (d1 == Geometry.Direction.North || d1 == Geometry.Direction.South) { if (d2 == Geometry.Direction.North || d2 == Geometry.Direction.South) { if (x2 > x1) { ans1[0].X = ans1[1].X = (r2.Left > r1.Right) ? (r2.Left + r1.Right) / 2 : Math.Max(r1.Right, r2.Right); } else { ans1[0].X = ans1[1].X = (r2.Right < r1.Left) ? (r1.Left + r2.Right) / 2 : Math.Min(r1.Left, r2.Left); } } else if (d2 == Geometry.Direction.West) { ans1[0].X = ans1[1].X = r1.Left; } else { ans1[0].X = ans1[1].X = r1.Right; } } else { if (d2 == Geometry.Direction.West || d2 == Geometry.Direction.East) { if (y2 > y1) { ans1[0].Y = ans1[1].Y = Math.Max(r1.Bottom, r2.Bottom); } else { ans1[0].Y = ans1[1].Y = Math.Min(r1.Top, r2.Top); } } else if (d2 == Geometry.Direction.North) { ans1[0].Y = ans1[1].Y = r1.Top; } else { ans1[0].Y = ans1[1].Y = r1.Bottom; } } sol1 = true; } if ((d2 == Geometry.Direction.East && x1 < x2) || (d2 == Geometry.Direction.West && x1 > x2) || (d2 == Geometry.Direction.South && y1 < y2) || (d2 == Geometry.Direction.North && y1 > y2)) { if (d2 == Geometry.Direction.North || d2 == Geometry.Direction.South) { if (d1 == Geometry.Direction.North || d1 == Geometry.Direction.South) { if (x1 > x2) { ans2[0].X = ans2[1].X = (r1.Left > r2.Right) ? (r1.Left + r2.Right) / 2 : Math.Max(r1.Right, r2.Right); } else { ans2[0].X = ans2[1].X = (r1.Right < r2.Left) ? (r2.Left + r1.Right) / 2 : Math.Min(r1.Left, r2.Left); } } else if (d1 == Geometry.Direction.West) { ans2[0].X = ans2[1].X = r2.Left; } else { ans2[0].X = ans2[1].X = r2.Right; } } else { if (d1 == Geometry.Direction.West || d1 == Geometry.Direction.East) { if (y1 > y2) { ans2[0].Y = ans2[1].Y = Math.Max(r1.Bottom, r2.Bottom); } else { ans2[0].Y = ans2[1].Y = Math.Min(r1.Top, r2.Top); } } else if (d1 == Geometry.Direction.North) { ans2[0].Y = ans2[1].Y = r2.Top; } else { ans2[0].Y = ans2[1].Y = r2.Bottom; } } sol2 = true; } // try to select best one if (sol1 && sol2) { if (!Geometry.rect_inters_with_quadric_segment(r1, x1, y1, ans1[0].X, ans1[0].Y) && !Geometry.rect_inters_with_quadric_segment(r2, x1, y1, ans1[0].X, ans1[0].Y) && !Geometry.rect_inters_with_quadric_segment(r1, x2, y2, ans1[1].X, ans1[1].Y) && !Geometry.rect_inters_with_quadric_segment(r2, x2, y2, ans1[1].X, ans1[1].Y) && !Geometry.rect_inters_with_quadric_segment(r1, ans1[0].X, ans1[0].Y, ans1[1].X, ans1[1].Y) && !Geometry.rect_inters_with_quadric_segment(r2, ans1[0].X, ans1[0].Y, ans1[1].X, ans1[1].Y)) { sol2 = false; } else { sol1 = false; } } return(sol1 ? ans1 : ans2); }
// 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 static bool select_pos_for_middle_point( GuiConnectionPoint p1, GuiConnectionPoint p2, out int x, out int y ) { int x1 = p1.x, y1 = p1.y, x2 = p2.x, y2 = p2.y; Geometry.Direction d1 = Geometry.Direction.Null; Rectangle r1 = Rectangle.Empty, r2 = Rectangle.Empty; if( p1.item is GuiItem ) { d1 = (p1.item as GuiItem).direction(p1.ux); r1 = (p1.item as GuiItem).AroundRect; } if( p2.item is GuiItem ) { r2 = (p2.item as GuiItem).AroundRect; } // try two solutions (x1, y2) and (x2, y1) bool sol1 = !Geometry.rect_inters_with_quadric_segment( r1, x1, y1, x1, y2 ) && !Geometry.rect_inters_with_quadric_segment( r2, x1, y1, x1, y2 ) && !Geometry.rect_inters_with_quadric_segment( r1, x2, y2, x1, y2 ) && !Geometry.rect_inters_with_quadric_segment( r2, x2, y2, x1, y2 ); bool sol2 = !Geometry.rect_inters_with_quadric_segment( r1, x1, y1, x2, y1 ) && !Geometry.rect_inters_with_quadric_segment( r2, x1, y1, x2, y1 ) && !Geometry.rect_inters_with_quadric_segment( r1, x2, y2, x2, y1 ) && !Geometry.rect_inters_with_quadric_segment( r2, x2, y2, x2, y1 ); if( p2.item == null && r1.Contains( x2, y2 ) ) sol1 = true; if( sol1 && sol2 ) { if( d1 == Geometry.Direction.South || d1 == Geometry.Direction.North ) sol2 = false; // select sol1 else sol1 = false; } if( sol1 || !sol2 && ( d1 == Geometry.Direction.South && y2-y1 > 0 || d1 == Geometry.Direction.North && y2-y1 < 0 || d1 == Geometry.Direction.West && x2-x1 > 0 || d1 == Geometry.Direction.East && x2-x1 < 0 ) ) { x = x1; y = y2; } else { x = x2; y = y1; } return sol1 || sol2; }
public static Point[] polyline_quadric_DummyWay( GuiConnectionPoint p1, GuiConnectionPoint p2, ArrayList active ) { int x1 = p1.x, y1 = p1.y, x2 = p2.x, y2 = p2.y; Geometry.Direction d1 = Geometry.Direction.Null, d2 = Geometry.Direction.Null; Rectangle r1 = Rectangle.Empty, r2 = Rectangle.Empty; if( p1.item is GuiItem ) { d1 = (p1.item as GuiItem).direction(p1.ux); r1 = (p1.item as GuiItem).AroundRect; } if( p2.item is GuiItem ) { d2 = (p2.item as GuiItem).direction(p2.ux); r2 = (p2.item as GuiItem).AroundRect; } if( (x1 == x2 || y1 == y2) && !Geometry.rect_inters_with_quadric_segment( r1, x1, y1, x2, y2 ) && !Geometry.rect_inters_with_quadric_segment( r2, x1, y1, x2, y2 ) ) return new Point[] {}; // try two solutions (x1, y2) and (x2, y1) int xm, ym; if( select_pos_for_middle_point( p1, p2, out xm, out ym ) ) return new Point[] { new Point(xm, ym) }; // try solutions of 3 segments bool sol1, sol2; Point[] ans1 = new Point[] { new Point(x1,y1), new Point(x2,y2) }, ans2 = new Point[] { new Point(x1,y1), new Point(x2,y2) }; sol2 = sol1 = false; if( (d1 == Geometry.Direction.East && x2 < x1 ) || (d1 == Geometry.Direction.West && x2 > x1 ) || (d1 == Geometry.Direction.South && y2 < y1 ) || (d1 == Geometry.Direction.North && y2 > y1 ) ) { if( d1 == Geometry.Direction.North || d1 == Geometry.Direction.South ) { if( d2 == Geometry.Direction.North || d2 == Geometry.Direction.South ) { if( x2 > x1 ) { ans1[0].X = ans1[1].X = (r2.Left > r1.Right) ? (r2.Left+r1.Right)/2 : Math.Max( r1.Right, r2.Right ); } else { ans1[0].X = ans1[1].X = (r2.Right < r1.Left) ? (r1.Left+r2.Right)/2 : Math.Min( r1.Left, r2.Left ); } } else if( d2 == Geometry.Direction.West ) { ans1[0].X = ans1[1].X = r1.Left; } else { ans1[0].X = ans1[1].X = r1.Right; } } else { if( d2 == Geometry.Direction.West || d2 == Geometry.Direction.East ) { if( y2 > y1 ) { ans1[0].Y = ans1[1].Y = Math.Max( r1.Bottom, r2.Bottom ); } else { ans1[0].Y = ans1[1].Y = Math.Min( r1.Top, r2.Top ); } } else if( d2 == Geometry.Direction.North ) { ans1[0].Y = ans1[1].Y = r1.Top; } else { ans1[0].Y = ans1[1].Y = r1.Bottom; } } sol1 = true; } if((d2 == Geometry.Direction.East && x1 < x2 ) || (d2 == Geometry.Direction.West && x1 > x2 ) || (d2 == Geometry.Direction.South && y1 < y2 ) || (d2 == Geometry.Direction.North && y1 > y2 ) ) { if( d2 == Geometry.Direction.North || d2 == Geometry.Direction.South ) { if( d1 == Geometry.Direction.North || d1 == Geometry.Direction.South ) { if( x1 > x2 ) { ans2[0].X = ans2[1].X = (r1.Left > r2.Right) ? (r1.Left+r2.Right)/2 : Math.Max( r1.Right, r2.Right ); } else { ans2[0].X = ans2[1].X = (r1.Right < r2.Left) ? (r2.Left+r1.Right)/2 : Math.Min( r1.Left, r2.Left ); } } else if( d1 == Geometry.Direction.West ) { ans2[0].X = ans2[1].X = r2.Left; } else { ans2[0].X = ans2[1].X = r2.Right; } } else { if( d1 == Geometry.Direction.West || d1 == Geometry.Direction.East ) { if( y1 > y2 ) { ans2[0].Y = ans2[1].Y = Math.Max( r1.Bottom, r2.Bottom ); } else { ans2[0].Y = ans2[1].Y = Math.Min( r1.Top, r2.Top ); } } else if( d1 == Geometry.Direction.North ) { ans2[0].Y = ans2[1].Y = r2.Top; } else { ans2[0].Y = ans2[1].Y = r2.Bottom; } } sol2 = true; } // try to select best one if( sol1 && sol2 ) { if( !Geometry.rect_inters_with_quadric_segment( r1, x1, y1, ans1[0].X, ans1[0].Y ) && !Geometry.rect_inters_with_quadric_segment( r2, x1, y1, ans1[0].X, ans1[0].Y ) && !Geometry.rect_inters_with_quadric_segment( r1, x2, y2, ans1[1].X, ans1[1].Y ) && !Geometry.rect_inters_with_quadric_segment( r2, x2, y2, ans1[1].X, ans1[1].Y ) && !Geometry.rect_inters_with_quadric_segment( r1, ans1[0].X, ans1[0].Y, ans1[1].X, ans1[1].Y ) && !Geometry.rect_inters_with_quadric_segment( r2, ans1[0].X, ans1[0].Y, ans1[1].X, ans1[1].Y ) ) sol2 = false; else sol1 = false; } return sol1 ? ans1 : ans2; }
public void add_connection_point( GuiConnectionPoint p ) { cpoints.Add( p ); }
public void remove_connection_point( GuiConnectionPoint p ) { cpoints.Remove( p ); }