private List<int> PlaceVertically(Sheet sheet, Graphic graphic, E3Text text, Point placePosition, E3Font smallFont, E3Font bigFont) { List<int> groupIds = new List<int>(5); int sheetId = sheet.Id; double radius = diameter / 2; double x, y2; double y = sheet.MoveUp(placePosition.Y, Size.Height / 2 - radius); if (isCircle) { groupIds.Add(graphic.CreateCircle(sheetId, placePosition.X, y, radius)); } else { x = sheet.MoveLeft(placePosition.X, ovalLength / 2); groupIds.Add(graphic.CreateArc(sheetId, x, y, radius, 90, 270)); double x2 = sheet.MoveRight(x, ovalLength); groupIds.Add(graphic.CreateArc(sheetId, x2, y, radius, 270, 90)); y = sheet.MoveDown(y, radius); y2 = sheet.MoveUp(y, 2 * radius); groupIds.Add(graphic.CreateLine(sheetId, x, y, x2, y)); groupIds.Add(graphic.CreateLine(sheetId, x, y2, x2, y2)); y = sheet.MoveUp(y, radius); } x = sheet.MoveLeft(placePosition.X, nameTextWidth / 2); y = sheet.MoveDown(y, bigFontHeight / 2); groupIds.Add(text.CreateText(sheetId, cableInfo.Name, x,y, bigFont)); y = sheet.MoveDown(y, radius - bigFontHeight/2); y2 = sheet.MoveDown(y, smallOffset + Math.Max(typeTextWidth, lengthTextWidth)); groupIds.Add(graphic.CreateLine(sheetId, placePosition.X, y, placePosition.X, y2, lineHeight,connectionColorIndex)); y = sheet.MoveDown(y, smallOffset+typeTextWidth); x = sheet.MoveLeft(placePosition.X, bigOffset); groupIds.Add(text.CreateVerticalText(sheetId, cableInfo.Type, x, y, smallFont)); x = sheet.MoveRight(placePosition. X, bigOffset + smallFontHeight); y = sheet.MoveUp(y, typeTextWidth - lengthTextWidth); groupIds.Add(text.CreateVerticalText(sheetId, cableInfo.Length, x, y, smallFont)); PlacedPosition = placePosition; return groupIds; }
private List<int> DrawPins(Sheet sheet, Graphic graphic, E3Text text, List<SymbolPin> pins, double pinsHeight, double pinsWidth, int sheetId, double xLeft, double pinBottom, double pinTop, Level position) { List<int> graphicIds = new List<int>(pins.Count * 2 + 1); double pinLeft = sheet.MoveRight(xLeft, (Size.Width - pinsWidth) / 2); foreach (SymbolPin pin in pins) { double pinRight = sheet.MoveRight(pinLeft, gridStep); int pinOutlineId = graphic.CreateRectangle(sheetId, pinLeft, pinBottom, pinRight, pinTop); graphicIds.Add(pinOutlineId); double textWidth = text.GetTextLength(pin.Name, smallFont); double xPinText = sheet.MoveRight(sheet.MoveRight(pinLeft, halfGridStep), smallFont.height / 2 - 0.2); double yPinText = sheet.MoveUp(pinBottom, (pinsHeight - textWidth) / 2); graphicIds.Add(text.CreateVerticalText(sheetId, pin.Name, xPinText, yPinText, smallFont)); int signalTextId = DrawSignalAndSetConnectionPoint(pin, position, sheet, text, sheetId, pinBottom, pinTop, pinLeft); graphicIds.Add(signalTextId); pinLeft = pinRight; } return graphicIds; }
private int DrawSignalAndSetConnectionPoint(SymbolPin pin, Level position, Sheet sheet, E3Text text, int sheetId, double pinBottom, double pinTop, double pinLeft) { double xSignalText = sheet.MoveRight(pinLeft, 1); double ySignalText; E3Font font = new E3Font(height: smallFont.height); if (position == Level.Top) { ySignalText = sheet.MoveUp(pinTop, skewLineOffset); font.alignment = Alignment.Left; } else { ySignalText = sheet.MoveDown(pinBottom, skewLineOffset); font.alignment = Alignment.Right; } return text.CreateVerticalText(sheetId, pin.Signal, xSignalText, ySignalText, font); }
private List<int> CreateTerminalSymbol(Sheet sheet, E3Text text, Graphic graphic, int sheetId, Point position) { List<int> groupIds; E3Font smallFont = new E3Font(height:2.5, alignment: Alignment.Left); int outlineId = CreateOutline(sheet, graphic, sheetId, position); double offset = 0.5; double xText = sheet.MoveRight(sheet.MoveRight(position.X, halfGridStep), smallFont.height / 2 - 0.2); if (!String.IsNullOrEmpty(Assignment)) { double yAssignmentText = sheet.MoveUp(position.Y, offset); groupIds = new List<int>(3); groupIds.Add(text.CreateVerticalText(sheetId, Assignment, xText, yAssignmentText, smallFont)); } else groupIds = new List<int>(2); groupIds.Add(outlineId); nameWidth = text.GetTextLength(Name, smallFont); double top = sheet.MoveUp(position.Y, Size.Height); double yText = sheet.MoveDown(top, offset + nameWidth); groupIds.Add(text.CreateVerticalText(sheetId, Name, xText, yText, smallFont)); foreach (SymbolPin topPin in topPins) { int signalTextId = DrawSignalAndSetConnectionPoint(topPin, Level.Top, sheet, text, sheetId, position.Y, top, position.X); groupIds.Add(signalTextId); } foreach (SymbolPin bottomPin in bottomPins) { int signalTextId = DrawSignalAndSetConnectionPoint(bottomPin, Level.Bottom, sheet, text, sheetId, position.Y, top, position.X); groupIds.Add(signalTextId); } return groupIds; }