Пример #1
0
 public SymbolPin(string name, string signal, E3Text text, E3Font font)
 {
     Name = name;
     Signal = signal;
     CableIds = new List<int>();
     SignalTextWidth = text.GetTextLength(signal, font);
     SignalTextWidth = (SignalTextWidth % 1 > 0) ? (int)(SignalTextWidth + 1) : SignalTextWidth;
 }
Пример #2
0
 public LineTemplate(List<double> columnWidths, E3Font font, double lineHeight, double verticalLineWidth, double horizontalLineWidth)
 {
     ColumnWidths = columnWidths;
     Height = lineHeight;
     Width = columnWidths.Sum();
     Font = font;
     VerticalLineWidth = verticalLineWidth;
     HorizontalLineWidth = horizontalLineWidth;
     TextHorizontalOffsets = GetTextHorizontalOffsets(columnWidths);
     TextVerticalOffset = (lineHeight + font.height) / 2;
 }
 public CableSymbol(CableInfo cableInfo, E3Text text, Orientation orientation)
 {
     this.cableInfo = cableInfo;
     this.orientation = orientation;
     CableId = cableInfo.Id;
     ovalLength = 0;
     smallFontHeight = 2;
     bigFontHeight = 3;
     isCircle = true;
     E3Font smallFont = new E3Font(height: smallFontHeight);
     E3Font bigFont = new E3Font(height: 3);
     nameTextWidth = text.GetTextLength(cableInfo.Name, bigFont);
     typeTextWidth = text.GetTextLength(cableInfo.Type, smallFont);
     lengthTextWidth = text.GetTextLength(cableInfo.Length, smallFont);
     Size = GetSize();
 }
 public AssignmentReferenceSymbol(string assignment, int id, int cableId, E3Text text)
 {
     this.id = id;
     triangleHeight = 4;
     triangleBaseLength = 2;
     descriptionVerticalMargin = 2;
     description ="В "+ assignment;
     font = new E3Font();
     double descriptionLength = text.GetTextLength(description, font);
     height = triangleHeight + descriptionVerticalMargin + font.height;
     margin = Math.Max(triangleBaseLength, descriptionLength) / 2;
     cableIds = new List<int>() { cableId };
     CableLayout cableLayout = new CableLayout(cableId, Level.Bottom);
     cableLayout.AddOffset(new Point(0,0));
     CableLayoutById = new Dictionary<int, CableLayout>() { {cableId, cableLayout} };
 }
 public DeviceSymbol(NormalDevice device, DevicePin pin )
 {
     id = device.Id;
     Assignment = String.Intern(device.Assignment);
     if (String.IsNullOrEmpty(Assignment) && device.GetAttributeValue("IncludeInOWS").Equals("1"))
         Assignment = String.Intern("AssignmentForConnectingBox");
     Name = device.Name;
     isTerminal = device.IsTerminal();
     if (isTerminal)
     {
        pin.Id = device.PinIds.First();
        Name += ":" + pin.Name;
     }
     ConnectionIds = new List<int>();
     bigFont = new E3Font(alignment: Alignment.Left);
     smallFont = new E3Font(height: 2.5, alignment: Alignment.Left);
     gridStep = 4;
     halfGridStep = gridStep / 2;
     skewLineOffset = gridStep;
 }
Пример #6
0
 public double GetTextLength(string value, E3Font font)
 {
     if (String.IsNullOrEmpty(value))
         return 0;
     dynamic xArray = default(dynamic);
     dynamic yArray = default(dynamic);
     text.CalculateBoxAt(0, value, 0, 0, 0, font.height, (int)font.mode, (int)font.style, font.name, 0, 0, ref xArray, ref yArray); // в качестве начальных координат для простоты устанавливаем 0, 0
     return (double)xArray[2];    // координата X второго угла textBox
 }
Пример #7
0
 public Size GetTextBoxSize(string value, E3Font font, double rotation)
 {
     if (String.IsNullOrEmpty(value))
         return new Size(0, 0);
     dynamic xArray = default(dynamic);
     dynamic yArray = default(dynamic);
     text.CalculateBoxAt(0, value, 0, 0, rotation, font.height, (int)font.mode, (int)font.style, font.name, 0, 0, ref xArray, ref yArray); // в качестве начальных координат для простоты устанавливаем 0, 0
     double xMax = double.MinValue;
     double yMax = double.MinValue;
     double xMin = double.MaxValue;
     double yMin = double.MaxValue;
     for (int i = 1; i < 5; i++)
     {
         double x = xArray[i];
         double y = yArray[i];
         xMax = Math.Max(xMax, x);
         yMax = Math.Max(yMax, y);
         xMin = Math.Min(xMin, x);
         yMin = Math.Min(yMin, y);
     }
     return new Size(xMax-xMin, yMax-yMin);
 }
Пример #8
0
 public double GetTextAbsciss(double textCenterX, double textWidth, E3Font font, Sheet sheet)
 {
     double textOffset = font.height - textWidth / 2;
     return sheet.MoveRight(textCenterX, textOffset);
 }
 public void Place(Sheet sheet, Graphic graphic, E3Text text, Group group, Point placePosition)
 {
     E3Font smallFont = new E3Font(height: smallFontHeight, alignment: Alignment.Left);
     E3Font bigFont = new E3Font(height: bigFontHeight, alignment: Alignment.Left);
     List<int> groupIds;
     if (orientation == Orientation.Horizontal)
         groupIds = PlaceHorizontally(sheet, graphic, text, placePosition, smallFont, bigFont);
     else
         groupIds = PlaceVertically(sheet, graphic, text, placePosition, smallFont, bigFont);
     group.CreateGroup(groupIds);
 }
 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;
 }
Пример #11
0
 public int CreateText(int sheetId, string value, double x, double y, E3Font font)
 {
     Id = graph.CreateText(sheetId, value, x, y);
     SetFont(font);
     return Id;
 }
Пример #12
0
 public StringSeparator(char[] separators, E3Font font, E3Text text)
 {
     this.separators = separators;
     this.font = font;
     determineStringLength = new Func<string, E3Font, double>(text.GetTextLength);
 }
 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);
 }
Пример #14
0
 public double GetTextOrdinate(double textCenterY, double textHeight, E3Font font, Sheet sheet)
 {
     double textOffset = font.height - textHeight / 2;
     return sheet.MoveDown(textCenterY, textOffset);
 }
Пример #15
0
 private List<int> PlaceHorizontally(Sheet sheet, Graphic graphic, E3Text text, Point placePosition, E3Font smallFont, E3Font bigFont)
 {
     List<int> groupIds = new List<int>(6);
     int sheetId = sheet.Id;
     double x = sheet.MoveLeft(placePosition.X, Size.Width / 2);
     double y = sheet.MoveDown(placePosition.Y, bigOffset + smallFontHeight);
     groupIds.Add(text.CreateText(sheetId, cableInfo.Type, x, y, smallFont));
     double x2 = sheet.MoveRight(x, typeTextWidth + smallOffset);
     groupIds.Add(graphic.CreateLine(sheetId, x, placePosition.Y, x2, placePosition.Y, lineHeight,connectionColorIndex));
     double radius = diameter / 2;
     double halfNameTextWidth = nameTextWidth / 2;
     x = sheet.MoveRight(x2, radius - halfNameTextWidth + ovalLength / 2);
     y = sheet.MoveDown(placePosition.Y, bigFontHeight / 2);
     groupIds.Add(text.CreateText(sheetId, cableInfo.Name, x, y, bigFont));
     x = sheet.MoveRight(x2, radius);
     if (isCircle)
     {
         groupIds.Add(graphic.CreateCircle(sheetId, x, placePosition.Y, radius));
         x = sheet.MoveRight(x, radius);
     }
     else
     {
         groupIds.Add(graphic.CreateArc(sheetId, x, placePosition.Y, radius, 90, 270));
         double y1 = sheet.MoveUp(placePosition.Y, radius);
         double y2 = sheet.MoveDown(placePosition.Y, radius);
         x2 = sheet.MoveRight(x, ovalLength);
         groupIds.Add(graphic.CreateLine(sheetId, x, y1, x2, y1));
         groupIds.Add(graphic.CreateLine(sheetId, x, y2, x2, y2));
         groupIds.Add(graphic.CreateArc(sheetId, x2, placePosition.Y, radius, 270, 90));
         x = sheet.MoveRight(x2, radius);
     }
     x2 = sheet.MoveRight(x, smallOffset + lengthTextWidth);
     groupIds.Add(graphic.CreateLine(sheetId, x, placePosition.Y, x2, placePosition.Y, lineHeight,connectionColorIndex));
     x = sheet.MoveRight(x, smallOffset);
     y = sheet.MoveUp(placePosition.Y, bigOffset);
     groupIds.Add(text.CreateText(sheetId, cableInfo.Length, x, y, smallFont));
     PlacedPosition = placePosition;
     return groupIds;
 }
Пример #16
0
 public void SetFont(E3Font font)
 {
     if (font != null)
     {
         text.SetFontName(font.name);
         text.SetHeight(font.height);
         text.SetAlignment((int)font.alignment);
         text.SetMode((int)font.mode);
         text.SetStyle((int)font.style);
         text.SetColour(font.ColorIndex);
     }
 }
Пример #17
0
 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;
 }
Пример #18
0
 public int CreateVerticalText(int sheetId, string value, double x, double y, E3Font font)
 {
     Id = graph.CreateRotatedText(sheetId, value, x, y, 90);
     SetFont(font);
     return Id;
 }
 private List<int> CreateDeviceSymbol(Sheet sheet, E3Text text, Graphic graphic, int sheetId, Point position )
 {
     List<int> groupIds = new List<int>((topPins.Count + bottomPins.Count) * 2 + 2);
     E3Font bigFont = new E3Font(alignment: Alignment.Left);
     groupIds.Add(CreateOutline(sheet, graphic, sheetId, position));
     double xText = sheet.MoveRight(position.X, (Size.Width - nameWidth) / 2);
     double spaceForName = Size.Height - bottomPinsHeight - topPinsHeight;
     double offsetForName = (spaceForName - bigFont.height) / 2;
     double yText = sheet.MoveUp(position.Y, bottomPinsHeight + offsetForName);
     groupIds.Add(text.CreateText(sheetId, Name, xText, yText, bigFont));
     double top = sheet.MoveUp(position.Y, Size.Height);
     double pinBottom = sheet.MoveDown(top, topPinsHeight);
     List<int> topPinIds = DrawPins(sheet, graphic, text, topPins, topPinsHeight, topPinsWidth, sheetId, position.X, pinBottom, top, Level.Top);
     double pinTop = sheet.MoveUp(position.Y, bottomPinsHeight);
     List<int> bottomPinIds = DrawPins(sheet, graphic, text, bottomPins, bottomPinsHeight, bottomPinsWidth, sheetId, position.X, position.Y, pinTop, Level.Bottom);
     groupIds.AddRange(topPinIds);
     groupIds.AddRange(bottomPinIds);
     return groupIds;
 }