Пример #1
0
		internal void initArrowHead(ArrowHeadShape ah)
		{
			ah.elements = new int[elements.Count];
			ah.coords = new float[coords.Count];

			for (int i = 0; i < elements.Count; ++i)
				ah.elements[i] = (int)elements[i];
		}
Пример #2
0
        internal void initArrowHead(ArrowHeadShape ah)
        {
            ah.elements = new int[elements.Count];
            ah.coords   = new float[coords.Count];

            for (int i = 0; i < elements.Count; ++i)
            {
                ah.elements[i] = (int)elements[i];
            }
        }
Пример #3
0
        internal void recalcArrowHead(ArrowHeadShape ah, PointF pt1, PointF pt2)
        {
            float dx = pt2.X - pt1.X;
            float dy = pt2.Y - pt1.Y;
            float l  = (float)Math.Sqrt(dx * dx + dy * dy);

            if (l == 0)
            {
                ah.defined = false;
                return;
            }
            ah.defined = true;
            float sine = +dx / l;
            float cosine = -dy / l;
            int   pts, c = 0, ch = 0;
            float x, y, r;

            for (int i = 0; i < elements.Count; ++i)
            {
                EArrowHeadElement el = (EArrowHeadElement)elements[i];
                switch (el)
                {
                case EArrowHeadElement.heLine:
                    for (int j = 0; j < 2; ++j)
                    {
                        x = (float)coords[c++] * ah.size;
                        y = (float)coords[c++] * ah.size;
                        ah.coords[ch++] = x * cosine - y * sine + pt2.X;
                        ah.coords[ch++] = x * sine + y * cosine + pt2.Y;
                    }
                    break;

                case EArrowHeadElement.heShape:
                    pts = (int)elements[++i];
                    for (int j = 0; j < pts; ++j)
                    {
                        x = (float)coords[c++] * ah.size;
                        y = (float)coords[c++] * ah.size;
                        ah.coords[ch++] = x * cosine - y * sine + pt2.X;
                        ah.coords[ch++] = x * sine + y * cosine + pt2.Y;
                    }
                    break;

                case EArrowHeadElement.heCircle:
                    x = (float)coords[c++] * ah.size;
                    y = (float)coords[c++] * ah.size;
                    r = (float)coords[c++] * ah.size;
                    ah.coords[ch++] = x * cosine - y * sine + pt2.X;
                    ah.coords[ch++] = x * sine + y * cosine + pt2.Y;
                    ah.coords[ch++] = r;
                    break;
                }               // switch (el)
            }                   // for (
        }
Пример #4
0
		internal void recalcArrowHead(ArrowHeadShape ah, PointF pt1, PointF pt2)
		{
			float dx = pt2.X - pt1.X;
			float dy = pt2.Y - pt1.Y;
			float l = (float)Math.Sqrt(dx*dx + dy*dy);
			if (l == 0)
			{
				ah.defined = false;
				return;
			}
			ah.defined = true;
			float sine = +dx/l;
			float cosine = -dy/l;
			int pts, c = 0, ch = 0;
			float x, y, r;

			for (int i = 0; i < elements.Count; ++i)
			{
				EArrowHeadElement el = (EArrowHeadElement)elements[i];
				switch (el)
				{
				case EArrowHeadElement.heLine:
					for (int j = 0; j < 2; ++j)
					{
						x = (float)coords[c++] * ah.size;
						y = (float)coords[c++] * ah.size;
						ah.coords[ch++] = x * cosine - y * sine + pt2.X;
						ah.coords[ch++] = x * sine + y * cosine + pt2.Y;
					}
					break;
				case EArrowHeadElement.heShape:
					pts = (int)elements[++i];
					for (int j = 0; j < pts; ++j)
					{
						x = (float)coords[c++] * ah.size;
						y = (float)coords[c++] * ah.size;
						ah.coords[ch++] = x * cosine - y * sine + pt2.X;
						ah.coords[ch++] = x * sine + y * cosine + pt2.Y;
					}
					break;
				case EArrowHeadElement.heCircle:
					x = (float)coords[c++] * ah.size;
					y = (float)coords[c++] * ah.size;
					r = (float)coords[c++] * ah.size;
					ah.coords[ch++] = x * cosine - y * sine + pt2.X;
					ah.coords[ch++] = x * sine + y * cosine + pt2.Y;
					ah.coords[ch++] = r;
					break;

				}	// switch (el)

			}	// for (
		}
Пример #5
0
		/// <summary>
		/// Get DXF string output for arrow's head
		/// </summary>
		/// <param name="ahs">Arrow head type</param>
		/// <param name="crLine">Arrow head line color</param>
		/// <param name="dst">Arrow line dash style</param>
		/// <param name="crFill">Arrow head fill color</param>
		/// <param name="sFill">DXF output for arrow head's fill</param>
		/// <returns>DXF string for arrow head frame</returns>
		public string ArrowHead2Str (ArrowHeadShape ahs, Color crLine, DashStyle dst, Color crFill, ref string sFill)
		{
			string sResult = "";
			int c = 0;
			float xoff = 0, yoff =0;
			PointF[] shape = null;

			try
			{

				sFill = "";
				for (int i = 0; i < ahs.Elements.GetLength(0); ++i)
				{
					EArrowHeadElement el = (EArrowHeadElement)ahs.Elements[i];
					switch (el)
					{
						case EArrowHeadElement.heLine:
						{
							float x1 = ahs.Coordinates[c++] + xoff;
							float y1 = m_FlowChart.DocExtents.Height -  ahs.Coordinates[c++] + yoff;
							float x2 = ahs.Coordinates[c++] + xoff;
							float y2 = m_FlowChart.DocExtents.Height -  ahs.Coordinates[c++] + yoff;
							shape = new PointF[2] {new PointF(x1,y1), new PointF(x2,y2)};

							sResult+=Pt2String(shape, crLine, ARROW_LAYER, DxLineType.ltSingle, dst, 1);
							
						
						}
							break;
						case EArrowHeadElement.heShape:
						{
							int pts = ahs.Elements[++i];
							shape = new PointF[pts];	
						
							for (int j = 0; j < pts; ++j)
							{
								shape[j].X = ahs.Coordinates[c++] + xoff;
								shape[j].Y = m_FlowChart.DocExtents.Height - ahs.Coordinates[c++] + yoff;
							}
							
							
							
							sResult+=Pt2String(shape, crLine, ARROW_LAYER, DxLineType.ltClosedSingle, dst, 1);
							if (!IsTransparent(crFill, null))
							{
								shape = MakePtsUnique(shape);
								sFill+= String.Format(provider, "0\nHATCH\n  100\nAcDbEntity\n{0:HAN}  8\n{0}\n  62\n{10:ACI}\n  100\nAcDbHatch\n  10\n0\n  20\n0\n  30\n0\n    210\n0\n  220\n0\n  230\n1\n  2\n{1}\n  70\n{2}\n  71\n{3}\n  91\n{4}\n  92\n{5}\n  72\n{6}\n  73\n{7}\n  93\n{8}\n{9}  97\n0\n  75\n0\n  76\n1\n  47\n1\n 98\n0\n",
									HATCH_LAYER,"SOLID", "1", "1", "1","7", "0", "1", shape.Length , Pt2String(shape,crFill, HATCH_LAYER, DxLineType.ltHatch, DashStyle.Solid, 1), crFill);
							}
							

						
						}
							break;
						case EArrowHeadElement.heCircle:
						{
							float cx = ahs.Coordinates[c++] + xoff;
							float cy = ahs.Coordinates[c++] + yoff;
							float r = ahs.Coordinates[c++];

							sResult+= String.Format(provider, "  0\nARC\n  100\nAcDbEntity\n{0:HAN}  8\n{5}\n  62\n{6:ACI}\n 100\nAcDbCircle\n  10\n{0:U}\n  20\n{1:U}\n  40\n{2:U}\n  100\nAcDbArc\n  50\n{3}\n  51\n{4}\n",
										cx, m_FlowChart.DocExtents.Height - cy, r, 0 , 360, ARROW_LAYER, crLine);
						
							if (!IsTransparent(crFill, null))
								sFill+= String.Format(provider, "0\nHATCH\n  100\nAcDbEntity\n{0:HAN}  8\n{0}\n  62\n{7:ACI}\n  100\nAcDbHatch\n  10\n0\n  20\n0\n  30\n0\n  210\n0\n  220\n0\n  230\n1\n  2\n{1}\n  70\n{2}\n  71\n{3}\n  91\n1\n  92\n1\n  93\n1\n  72\n{6}\n  10\n{8}\n  20\n{9}\n  40\n{10}\n  50\n{11}\n  51\n{12}\n   73\n0\n  97\n0\n    75\n0\n  76\n1\n  98\n0\n",
									HATCH_LAYER,"SOLID", "1", "1", "1","5", "2",  crFill,cx, m_FlowChart.DocExtents.Height - cy, r, 0, 360);

							
						}			
							break;

					}	
				}

			
			}
			catch ( Exception ex )
			{
				Trace.WriteLine(String.Format("{0} error {1}\n","ArrowHead2Str",ex.Message));
				sResult = null;
			}
			
			return sResult;

		}
Пример #6
0
		/// <summary>
		/// Returns SVG path string for Arrow's head/base
		/// </summary>
		/// <param name="ahs">Arrow's head or base</param>
		/// <returns>string SVG path</returns>
		public string GetArrowHead (ArrowHeadShape ahs)
		{
			string sResult = "";
			int c = 0;
			float xoff = 0, yoff =0;

			try
			{

				for (int i = 0; i < ahs.Elements.GetLength(0); ++i)
				{
					EArrowHeadElement el = (EArrowHeadElement)ahs.Elements[i];
					switch (el)
					{
						case EArrowHeadElement.heLine:
						{
							float x1 = ahs.Coordinates[c++] + xoff;
							float y1 = ahs.Coordinates[c++] + yoff;
							float x2 = ahs.Coordinates[c++] + xoff;
							float y2 = ahs.Coordinates[c++] + yoff;

							sResult+=String.Format("M{0},{1} L{2},{3} ", Unit2Pix(x1), Unit2Pix(y1),Unit2Pix(x2), Unit2Pix(y2));
						
						}
							break;
						case EArrowHeadElement.heShape:
						{
							int pts = ahs.Elements[++i];
							PointF[] shape = new PointF[pts];	
						
							for (int j = 0; j < pts; ++j)
							{
								shape[j].X = ahs.Coordinates[c++] + xoff;
								shape[j].Y = ahs.Coordinates[c++] + yoff;
							}
							
							for (int j = 0; j < pts; ++j)
							{
								sResult+=String.Format("{0}{1},{2} ", j == 0 ? "M" : "L" , Unit2Pix(shape[j].X), Unit2Pix(shape[j].Y));
								
							}

						
						}
							break;
						case EArrowHeadElement.heCircle:
						{
							float cx = ahs.Coordinates[c++] + xoff;
							float cy = ahs.Coordinates[c++] + yoff;
							float r = ahs.Coordinates[c++];

							sResult+= String.Format("M{0},{1} A{2},{3} {4} {5},{6} {7},{8} " ,
								Unit2Pix(cx),
								Unit2Pix(cy),
								Unit2Pix(r), 
								Unit2Pix(r),
								0,
								1,
								1,
								Unit2Pix(cx),
								Unit2Pix(cy));
						
						}			
							break;

					}	
				}

				if ( sResult!="" )
					sResult+="z";
			}
			catch ( Exception ex )
			{
				Trace.WriteLine(String.Format("{0} error {1}\n","SvgManager.GetArrowHead",ex.Message));
				sResult = null;
			}
			
			return sResult;

		}
Пример #7
0
		public override void loadFrom(BinaryReader reader, PersistContext ctx)
		{
			base.loadFrom(reader, ctx);

			style = (ArrowStyle)reader.ReadInt32();
			penColor = ctx.loadColor();
			ctx.loadReference(this);
			ctx.loadReference(this);
			segmentCount = reader.ReadInt16();
			text = reader.ReadString();
			textColor = ctx.loadColor();
			arrowHead = (ArrowHead)reader.ReadInt32();
			arrowBase = (ArrowHead)reader.ReadInt32();
			arrowInterm = (ArrowHead)reader.ReadInt32();
			headSize = (float)reader.ReadDouble();
			baseSize = (float)reader.ReadDouble();
			intermSize = (float)reader.ReadDouble();
			fillColor = ctx.loadColor();
			dynamic = reader.ReadBoolean();
			cascadeOrientation = (Orientation)reader.ReadInt32();
			cascadeStartHorizontal = reader.ReadBoolean();
			reflexive = reader.ReadBoolean();
			ctx.loadReference(this);
			ctx.loadReference(this);

			ahHead = new ArrowHeadShape(headSize);
			ahBase = new ArrowHeadShape(baseSize);
			ahInterm = new ArrowHeadShape(intermSize);

			headTemplates[(int)arrowHead].initArrowHead(ahHead);
			headTemplates[(int)arrowBase].initArrowHead(ahBase);
			headTemplates[(int)arrowInterm].initArrowHead(ahInterm);

			pen.Width = PenWidth;
			pen.Color = frameColor;
			pen.DashStyle = PenDashStyle;
			brush.Release();
			brush = new SolidBrush(fillColor);
			brush.AddRef();
			headPen.Width = PenWidth;
			headPen.Color = frameColor;
			headPen.DashStyle = PenDashStyle;

			if (ctx.FileVersion > 3)
			{
				pen = (Pen)ctx.loadObject();
				ctx.loadReference(this);

				if (ctx.FileVersion > 4)
				{
					// new in file format 5
					allowMoveStart = reader.ReadBoolean();
					allowMoveEnd = reader.ReadBoolean();
					orgnAnchor = reader.ReadInt32();
					destAnchor = reader.ReadInt32();

					if (ctx.FileVersion > 7)
					{
						// new in file format 8
						autoRoute = reader.ReadBoolean();
						retainForm = reader.ReadBoolean();
						textStyle = (ArrowTextStyle)reader.ReadInt32();

						if (ctx.FileVersion > 9)
						{
							// new in file format 10
							headPen = (Pen)ctx.loadObject();

							if (ctx.FileVersion > 16)
							{
								// new in file format 17
								customDraw = (CustomDraw)reader.ReadInt32();

								if (ctx.FileVersion > 19)
								{
									// new in file format 20
									snapToNodeBorder = reader.ReadBoolean();
									selStyle = (HandlesStyle)ctx.reader.ReadInt32();

									if (ctx.FileVersion > 25)
									{
										// new in file format 26
										hyperLink = reader.ReadString();

										if (ctx.FileVersion > 28)
										{
											// new in file format 29
											drawCrossings = reader.ReadBoolean();
										}
									}
								}
							}
						}
					}
				}
			}

			updateText();
		}
Пример #8
0
		public Arrow(Arrow prototype, Node src, Node dest) : base(prototype)
		{
			penColor = prototype.penColor;
			headPen = (Pen)prototype.headPen.Clone();

			style = prototype.style;
			setSegments(prototype.segmentCount);
			selStyle = prototype.selStyle;

			text = prototype.text;
			textStyle = prototype.textStyle;
			textColor = prototype.textColor;
			updateText();

			reflexive = prototype.reflexive;

			dynamic = prototype.dynamic;
			snapToNodeBorder = prototype.snapToNodeBorder;
			retainForm = prototype.retainForm;
			cascadeOrientation = prototype.cascadeOrientation;
			cascadeStartHorizontal = prototype.cascadeStartHorizontal;

			orgnLink = null;
			destLink = null;
			objNewDest = null;

			headSize = 5;

			arrowHead = prototype.arrowHead;
			arrowBase = prototype.arrowBase;
			arrowInterm = prototype.arrowInterm;

			headSize = prototype.headSize;
			baseSize = prototype.baseSize;
			intermSize = prototype.intermSize;

			ahHead = new ArrowHeadShape(headSize);
			ahBase = new ArrowHeadShape(baseSize);
			ahInterm = new ArrowHeadShape(intermSize);

			headTemplates[(int)arrowHead].initArrowHead(ahHead);
			headTemplates[(int)arrowBase].initArrowHead(ahBase);
			headTemplates[(int)arrowInterm].initArrowHead(ahInterm);

			textSize = prototype.textSize;

			allowMoveStart = prototype.allowMoveStart;
			allowMoveEnd = prototype.allowMoveEnd;

			orgnAnchor = prototype.orgnAnchor;
			destAnchor = prototype.destAnchor;

			autoRoute = false;
			setOrgAndDest(
				src.createLink(this, src.getCenter(), false),
				dest.createLink(this, dest.getCenter(), true));

			for (int i = 0; i < points.Count; ++i)
				points[i] = prototype.points[i];

			OrgnIndex = prototype.OrgnIndex;
			DestIndex = prototype.DestIndex;
			OrgnAnchor = prototype.OrgnAnchor;
			DestAnchor = prototype.DestAnchor;

			int l = points.Count - 1;
			if (Origin is DummyNode)
				points[0] = prototype.points[0];
			if (Destination is DummyNode)
				points[l] = prototype.points[l];

			customDraw = prototype.customDraw;

			autoRoute = prototype.autoRoute;
			savedSegments = null;
		}
Пример #9
0
		public Arrow(FlowChart parent) : base(parent)
		{
			pen = (Pen)flowChart.ArrowPen.Clone();
			headPen = (Pen)pen.Clone();
			brush = flowChart.ArrowBrush;
			brush.AddRef();

			penColor = parent.ArrowColor;
			frameColor = parent.ArrowColor;
			fillColor = parent.ArrowFillColor;

			style = parent.ArrowStyle;
			setSegments(parent.ArrowSegments);
			selStyle = parent.ArrowHandlesStyle;

			text = parent.ArrowText;
			textStyle = parent.ArrowTextStyle;
			textColor = parent.TextColor;
			updateText();

			reflexive = false;

			dynamic = parent.DynamicArrows;
			snapToNodeBorder = parent.ArrowsSnapToBorders;
			retainForm = parent.ArrowsRetainForm;

			cascadeOrientation = parent.ArrowCascadeOrientation;
			cascadeStartHorizontal = true;

			orgnLink = null;
			destLink = null;
			objNewDest = null;

			headSize = 5;

			arrowHead = flowChart.ArrowHead;
			arrowBase = flowChart.ArrowBase;
			arrowInterm = flowChart.IntermArrowHead;

			ahHead = new ArrowHeadShape(flowChart.ArrowHeadSize);
			ahBase = new ArrowHeadShape(flowChart.ArrowBaseSize);
			ahInterm = new ArrowHeadShape(flowChart.ArrowIntermSize);

			headTemplates[(int)arrowHead].initArrowHead(ahHead);
			headTemplates[(int)arrowBase].initArrowHead(ahBase);
			headTemplates[(int)arrowInterm].initArrowHead(ahInterm);

			headSize = flowChart.ArrowHeadSize;
			baseSize = flowChart.ArrowBaseSize;
			intermSize = flowChart.ArrowIntermSize;

			textSize = new SizeF(0, 0);

			allowMoveStart = flowChart.ArrowEndsMovable;
			allowMoveEnd = flowChart.ArrowEndsMovable;

			orgnAnchor = -1;
			destAnchor = -1;

			autoRoute = flowChart.RouteArrows;

			customDraw = parent.ArrowCustomDraw;
			savedSegments = null;
			drawCrossings = true;
		}