Exemple #1
0
		private void setEndPoints(Link orgnLink, Link destLink, PointF end)
		{
			reflexive = destLink.sameNode(orgnLink);

			// align the end points of the arrow to the outlines of the connected nodes
			if (orgnLink.calcIntrs())
				ptOrg = points[0] = orgnLink.getInitialPt();
			if (destLink.calcIntrs())
				ptEnd = destLink.getInitialPt();
			else
				ptEnd = end;

			if (!orgnLink.objsIntersect(destLink) && !reflexive)
			{
				if (orgnLink.calcIntrs())
					ptOrg = points[0] = orgnLink.getIntersection(ptOrg, ptEnd);
				if (destLink.calcIntrs())
					ptEnd = destLink.getIntersection(ptEnd, ptOrg);
			}
			else
			{
				// if the arrow will be routed, choose the closest points on the
				// horizontal line intersections with the node outlines. These points
				// should not be contained within a node
				if (autoRoute && !dynamic && orgnAnchor == -1 && destAnchor == -1)
				{
					chooseRouteOutlinePoints(orgnLink, destLink, ref ptOrg, ref ptEnd);
					points[0] = ptOrg;
				}
			}
		}
Exemple #2
0
		private void chooseRouteOutlinePoints(Link orgnLink, Link destLink,
			ref PointF ptOrg, ref PointF ptDest)
		{
			RoutingOptions rop = flowChart.RoutingOptions;
			Node origin = orgnLink.getNode();
			Node destination = destLink.getNode();
			bool reflexive = orgnLink.sameNode(destLink);

			// how many points to consider ?
			int srcCount = rop.StartOrientation == Orientation.Auto ? 4 : 2;
			int dstCount = rop.EndOrientation == Orientation.Auto ? 4 : 2;
			PointF[] srcPoints = new PointF[srcCount];
			PointF[] dstPoints = new PointF[dstCount];

			// determine the coordinates of the points to be checked ...
			int srcIdx = 0, dstIdx = 0;

			// source points
			if (rop.StartOrientation != Orientation.Vertical)
			{
				srcPoints[srcIdx++] = orgnLink.getIntersection(ptOrg,
					new PointF(ptOrg.X - 2*origin.BoundingRect.Width, ptOrg.Y));
				srcPoints[srcIdx++] = orgnLink.getIntersection(ptOrg,
					new PointF(ptOrg.X + 2*origin.BoundingRect.Width, ptOrg.Y));
			}
			if (rop.StartOrientation != Orientation.Horizontal)
			{
				srcPoints[srcIdx++] = orgnLink.getIntersection(ptOrg,
					new PointF(ptOrg.X, ptOrg.Y - 2*origin.BoundingRect.Height));
				srcPoints[srcIdx++] = orgnLink.getIntersection(ptOrg,
					new PointF(ptOrg.X, ptOrg.Y + 2*origin.BoundingRect.Height));
			}

			// destination points
			if (rop.EndOrientation != Orientation.Vertical)
			{
				dstPoints[dstIdx++] = dstPoints[1] = destLink.getIntersection(ptDest,
					new PointF(ptDest.X - 2*destination.BoundingRect.Width, ptDest.Y));
				dstPoints[dstIdx++] = destLink.getIntersection(ptDest,
					new PointF(ptDest.X + 2*destination.BoundingRect.Width, ptDest.Y));
			}
			if (rop.EndOrientation != Orientation.Horizontal)
			{
				dstPoints[dstIdx++] = destLink.getIntersection(ptDest,
					new PointF(ptDest.X, ptDest.Y - 2*destination.BoundingRect.Height));
				dstPoints[dstIdx++] = destLink.getIntersection(ptDest,
					new PointF(ptDest.X, ptDest.Y + 2*destination.BoundingRect.Height));
			}

			// check which of these points are closest
			ptOrg = srcPoints[0];
			ptDest = dstPoints[0];
			float minDist = Single.MaxValue;
			for (int sidx = 0; sidx < srcCount; ++sidx)
			{
				if (!reflexive && destination.containsPoint(srcPoints[sidx]))
					continue;

				for (int didx = 0; didx < dstCount; ++didx)
				{
					if (!reflexive && origin.containsPoint(dstPoints[didx]))
						continue;

					float dist = Utilities.Distance(
						srcPoints[sidx], dstPoints[didx]);

					if (dist < 2 * rop.GridSize)
						continue;

					// we prefer these to be on the same side
					if (sidx != didx) dist *= 3;

					if (dist < minDist)
					{
						minDist = dist;
						ptOrg = srcPoints[sidx];
						ptDest = dstPoints[didx];
					}
				}
			}
		}
Exemple #3
0
		private void putEndPointsAtNodeBorders(bool routing, Link orgnLink, Link destLink)
		{
			PointF ptOrg = orgnLink.getInitialPt();
			PointF ptDest = destLink.getInitialPt();

			if (!orgnLink.objsIntersect(destLink))
			{
				// if destination and source do not intersect, use the points
				// where the line connecting their centers crosses their outlines
				if (style == ArrowStyle.Cascading)
					updateEndPtsPrp();
				ptOrg = orgnLink.getIntersection(ptOrg,
					routing ? ptDest : points[1]);
				ptDest = destLink.getIntersection(ptDest,
					routing ? ptOrg : points[points.Count - 2]);
			}
			else
			{
				// if the arrow will be rerouted, choose the closest points on the
				// horizontal line intersections with the node outlines. These points
				// should not be contained within a node
				if (routing)
					chooseRouteOutlinePoints(orgnLink, destLink, ref ptOrg, ref ptDest);
			}

			// snap to nearest anchors
			ptOrg = orgnLink.getNode().getAnchor(
				ptOrg, this, false, ref orgnAnchor);
			ptDest = destLink.getNode().getAnchor(
				ptDest, this, true, ref destAnchor);

			if (style != ArrowStyle.Cascading)
				retain(ptOrg.X - points[0].X, ptOrg.Y - points[0].Y, true);
			points[0] = ptOrg;
			if (style != ArrowStyle.Cascading)
				retain(ptDest.X - points[points.Count - 1].X, ptDest.Y - points[points.Count - 1].Y, false);
			points[points.Count - 1] = ptDest;

			if (style == ArrowStyle.Cascading)
				updateEndPtsPrp();
		}
Exemple #4
0
		internal void setOrgAndDest(Link orgLink, Link trgLink)
		{
			orgnLink = orgLink;
			destLink = trgLink;

			// place the end points of the arrow at their respective object edge
			points[0] = orgnLink.getInitialPt();
			points[points.Count-1] = destLink.getInitialPt();
			if (!orgnLink.objsIntersect(destLink))
			{
				points[0] = orgnLink.getIntersection(points[0], points[points.Count-1]);
				points[points.Count-1] = destLink.getIntersection(points[points.Count-1], points[0]);
			}

			points[0] = orgnLink.getAnchor(points[0], this, false, ref orgnAnchor);
			points[points.Count-1] = destLink.getAnchor(points[points.Count-1], this, true, ref destAnchor);

			// set reflexive arrow position & form
			reflexive = orgnLink.sameNode(destLink);
			if (reflexive)
			{
				setReflexive();
			}
			else
			{
				// compute the arrow points
				updatePoints(points[points.Count-1]);
				if (dynamic)
					updatePosFromOrgAndDest(true);
			}

			rectFromPoints();

			// relative position to nodes
			orgnLink.saveEndRelative();
			destLink.saveEndRelative();

			doRoute();
		}