Пример #1
0
 public Table(E3Project project, LineTemplate headerLineTemplate, List<string> headerLineTexts, LineTemplate lineTemplate, double bottomLineWidth, StringSeparator separator, TablePageTemplate firstPagetTemplate, TablePageTemplate subsequentPageTemplate = null )
 {
     this.project = project;
     this.firstPageTemplate = firstPagetTemplate;
     if (subsequentPageTemplate == null)
         this.subsequentPageTemplate = firstPagetTemplate;
     else
         this.subsequentPageTemplate = subsequentPageTemplate;
     this.headerLineTemplate = headerLineTemplate;
     this.bottomLineWidth = bottomLineWidth;
     this.headerLineTexts = headerLineTexts;
     this.lineTemplate = lineTemplate;
     this.separator = separator;
     this.graphic = project.GetGraphicById(0);
     this.group = project.GetGroupById(0);
     this.text = project.GetTextById(0);
     currentSheet = project.GetSheetById(0);
     sheetCount = 0;
     sheetIds = new List<int>();
 }
 public void Place(Point placePosition, Sheet sheet, Graphic graphic, Group group, E3Text text)
 {
     PlacedPosition = placePosition;
     double width = 0.2;
     List<int> ids = new List<int>(5);
     double halfBaseLength = triangleBaseLength / 2;
     Point leftBottom = new Point(sheet.MoveLeft(placePosition.X, halfBaseLength), placePosition.Y);
     Point rightBottom = new Point(sheet.MoveRight(placePosition.X, halfBaseLength), placePosition.Y);
     Point top = new Point(placePosition.X, sheet.MoveUp(placePosition.Y, triangleHeight));
     int sheetId = sheet.Id;
     ids.Add(graphic.CreateLine(sheetId, leftBottom.X, leftBottom.Y, rightBottom.X, rightBottom.Y, width));
     ids.Add(graphic.CreateLine(sheetId, leftBottom.X, leftBottom.Y, top.X, top.Y, width));
     ids.Add(graphic.CreateLine(sheetId, rightBottom.X, rightBottom.Y, top.X, top.Y, width));
     ids.Add(text.CreateText(sheetId, description, top.X, sheet.MoveUp(top.Y, descriptionVerticalMargin), font));
     ids.AddRange(CableLayoutById.Values.First().Place(sheet, graphic, placePosition));
     group.CreateGroup(ids);
 }
 private void PlaceSymbols(Sheet sheet, Graphic graphic, Group e3group, E3Text text, Dictionary<int, double> horizontalOffsetById, double startAbsciss, double groupOrdinate)
 {
     double offset = 0;
     foreach (int id in horizontalOffsetById.Keys)
     {
         ISchemeSymbol symbol = symbolById[id];
         offset += horizontalOffsetById[id];
         double absciss = sheet.MoveRight(startAbsciss, offset);
         symbol.Place(new Point(absciss, groupOrdinate), sheet, graphic, e3group, text);
     }
 }
 private void PlaceSideSymbolsConnectionLine(ISchemeSymbol symbol, Sheet sheet, Graphic graphic, double lineHeight, int sheetId, Dictionary<int, double> abscissesByCableId, double centerX, List<CableSymbol> cableSymbols, double turnY, Level level)
 {
     int symbolsCount = cableSymbols.Count;
     if (symbolsCount > 0)
     {
         cableSymbols.Sort((bs1, bs2) => Math.Abs(bs1.PlacedPosition.X - centerX).CompareTo(Math.Abs(bs2.PlacedPosition.X - centerX))); // сортировка по удаленности от центра
         foreach (CableSymbol cableSymbol in cableSymbols)
         {
             CableLayout cableLayout = symbol.CableLayoutById[cableSymbol.CableId];
             double layoutY = cableLayout.PlacedPoints.First().Y;
             if (cableLayout.StartOffsets.Count > 1)
                 layoutY = (level == Level.Top) ? sheet.MoveDown(layoutY, radius) : sheet.MoveUp(layoutY, radius);
             double absciss = abscissesByCableId[cableSymbol.CableId];
             double symbolX = cableSymbol.PlacedPosition.X;
             double symbolY = (level == Level.Top) ? sheet.MoveUp(cableSymbol.PlacedPosition.Y, cableSymbol.Size.Height / 2) : sheet.MoveDown(cableSymbol.PlacedPosition.Y, cableSymbol.Size.Height / 2);
             if (absciss == symbolX)
                 graphic.CreateLine(sheetId, absciss, layoutY, absciss, symbolY, lineHeight, connectionColorIndex);
             else
             {
                 graphic.CreateLine(sheetId, absciss, layoutY, absciss, turnY, lineHeight, connectionColorIndex);
                 graphic.CreateLine(sheetId, absciss, turnY, symbolX, turnY, lineHeight, connectionColorIndex);
                 graphic.CreateLine(sheetId, symbolX, turnY, symbolX, symbolY, lineHeight, connectionColorIndex);
             }
             turnY = sheet.MoveUp(turnY, gridStep);
         }
     }
 }
 private void PlaceConnectionLines(Sheet sheet, Graphic graphic, double topGroupOrdinate, double bottomGroupOrdinate)
 {
     double lineHeight = 0.2;
     int sheetId = sheet.Id;
     foreach (ISchemeSymbol symbol in symbolById.Values)
     {
         List<CableLayout> bottomLayouts = symbol.CableLayoutById.Values.Where(cl => cl.Level == Level.Bottom).ToList();
         int bottomLayoutsCount = bottomLayouts.Count();
         if (bottomLayoutsCount > 0)
         {
             double lastCableLayoutY = (symbol.Level == Level.Bottom) ? sheet.MoveDown(bottomGroupOrdinate, bottomGroupBottomMargin) : sheet.MoveDown(topGroupOrdinate, topGroupBottomMargin);
             List<CableSymbol> bottomSymbols = bottomLayouts.Select(bl => cableSymbolById[bl.Id]).ToList();
             bottomSymbols.Sort((bs1, bs2) => bs1.PlacedPosition.X.CompareTo(bs2.PlacedPosition.X));
             List<List<double>> connectionAbscisses = new List<List<double>>(bottomLayoutsCount);
             foreach (CableSymbol cableSymbol in bottomSymbols)
                 connectionAbscisses.Add(GetAbscisses(cableSymbol.PlacedPosition.X, symbol.CableLayoutById[cableSymbol.CableId]));
             List<int> maxPositions = new List<int>(bottomLayoutsCount);
             connectionAbscisses.ForEach(l => maxPositions.Add(l.Count));
             Dictionary<int, double> abscissesByCableId = GetAbscissesByCableId(maxPositions, connectionAbscisses, bottomSymbols, bottomLayouts, symbol);
             foreach (int cableId in abscissesByCableId.Keys)
             {
                 double absciss = abscissesByCableId[cableId];
                 CableLayout cableLayout = symbol.CableLayoutById[cableId];
                 double cableLayoutY = cableLayout.PlacedPoints.First().Y;
                 if (cableLayout.StartOffsets.Count > 1)
                     graphic.CreateArc(sheetId, absciss, cableLayoutY, radius, 180, 0, lineHeight, connectionColorIndex);
             }
             IEnumerable<CableSymbol> bottomHorizontalSymbols = bottomSymbols.Where(bs => bs.Orientation == Orientation.Horizontal);
             int horizontalCount = bottomHorizontalSymbols.Count();
             if (horizontalCount == 1)
             {
                 CableSymbol cableSymbol = bottomHorizontalSymbols.First();
                 int cableId = cableSymbol.CableId;
                 CableLayout cableLayout = symbol.CableLayoutById[cableId];
                 double firstLayoutPlacedY = cableLayout.PlacedPoints.First().Y;
                 if (cableLayout.StartOffsets.Count > 1)
                     firstLayoutPlacedY = sheet.MoveDown(firstLayoutPlacedY, radius);
                 CreateStraightConnectingLine(sheet, graphic, lineHeight, sheetId, abscissesByCableId, firstLayoutPlacedY, cableSymbol);
             }
             if (horizontalCount == 2)
             {
                 CableSymbol firstCableSymbol = bottomHorizontalSymbols.First();
                 int firstCableId = firstCableSymbol.CableId;
                 double firstAbsciss = abscissesByCableId[firstCableId];
                 CableLayout firstCableLayout = symbol.CableLayoutById[firstCableId];
                 double firstLayoutPlacedY = firstCableLayout.PlacedPoints.First().Y;
                 if (firstCableLayout.StartOffsets.Count > 1)
                     firstLayoutPlacedY = sheet.MoveDown(firstLayoutPlacedY, radius);
                 CableSymbol secondCableSymbol = bottomHorizontalSymbols.Last();
                 int secondCableId = secondCableSymbol.CableId;
                 double secondAbsciss = abscissesByCableId[secondCableId];
                 CableLayout secondCableLayout = symbol.CableLayoutById[secondCableId];
                 double secondLayoutPlacedY = secondCableLayout.PlacedPoints.First().Y;
                 if (secondCableLayout.StartOffsets.Count > 1)
                     secondLayoutPlacedY = sheet.MoveDown(secondLayoutPlacedY, radius);
                 if ((firstCableSymbol.PlacedPosition.X > secondCableSymbol.PlacedPosition.X && firstAbsciss > secondAbsciss) || (firstCableSymbol.PlacedPosition.X < secondCableSymbol.PlacedPosition.X && firstAbsciss < secondAbsciss))
                 {
                     CreateStraightConnectingLine(sheet, graphic, lineHeight, sheetId, abscissesByCableId, firstLayoutPlacedY, firstCableSymbol);
                     CreateStraightConnectingLine(sheet, graphic, lineHeight, sheetId, abscissesByCableId, secondLayoutPlacedY, secondCableSymbol);
                 }
                 else
                 {
                     CableSymbol straightSymbol, turningSymbol;
                     double straightLayouPlacedY, turningLayoutPlacedY;
                     if (firstCableSymbol.PlacedPosition.X < secondCableSymbol.PlacedPosition.X)
                     {
                         straightSymbol = firstCableSymbol;
                         turningSymbol = secondCableSymbol;
                         straightLayouPlacedY = firstLayoutPlacedY;
                         turningLayoutPlacedY = secondLayoutPlacedY;
                     }
                     else
                     {
                         straightSymbol = secondCableSymbol;
                         turningSymbol = firstCableSymbol;
                         straightLayouPlacedY = secondLayoutPlacedY;
                         turningLayoutPlacedY = firstLayoutPlacedY;
                     }
                     CreateStraightConnectingLine(sheet, graphic, lineHeight, sheetId, abscissesByCableId, straightLayouPlacedY, straightSymbol);
                     CreateTurningConnectingLine(sheet, graphic, lineHeight, sheetId, abscissesByCableId, turningLayoutPlacedY, turningSymbol, symbol);
                 }
             }
             IEnumerable<CableSymbol> bottomVerticalSymbols = bottomSymbols.Where(bs => bs.Orientation == Orientation.Vertical);
             if (bottomVerticalSymbols.Count() > 0)
             {
                 double centerX = (bottomVerticalSymbols.Min(bs => bs.PlacedPosition.X) + bottomVerticalSymbols.Max(bs => bs.PlacedPosition.X)) / 2;
                 List<CableSymbol> leftSymbols = bottomVerticalSymbols.Where(ls => ls.PlacedPosition.X < abscissesByCableId[ls.CableId]).ToList();
                 List<CableSymbol> rightSymbols = bottomVerticalSymbols.Where(rs => rs.PlacedPosition.X > abscissesByCableId[rs.CableId]).ToList();
                 CableSymbol cableSymbol = bottomVerticalSymbols.First();
                 double symbolY = sheet.MoveUp(cableSymbol.PlacedPosition.Y, cableSymbol.Size.Height / 2);
                 double centerY = (lastCableLayoutY + symbolY) / 2;
                 double leftTurnY = sheet.MoveDown(centerY, (leftSymbols.Count - 1) * gridStep / 2);
                 double rightTurnY = sheet.MoveDown(centerY, (rightSymbols.Count - 1) * gridStep / 2);
                 PlaceSideSymbolsConnectionLine(symbol, sheet, graphic, lineHeight, sheetId, abscissesByCableId, centerX, leftSymbols, leftTurnY, Level.Top);
                 PlaceSideSymbolsConnectionLine(symbol, sheet, graphic, lineHeight, sheetId, abscissesByCableId, centerX, rightSymbols, rightTurnY, Level.Top);
             }
         }
         List<CableLayout> topLayouts = symbol.CableLayoutById.Values.Where(cl => cl.Level == Level.Top).ToList();
         int topLayoutsCount = topLayouts.Count();
         if (topLayoutsCount > 0)
         {
             double lastCableLayoutY = topLayouts.Where(tl=>tl.verticalOffset == topLayouts.Max(t => t.verticalOffset)).First().PlacedPoints.First().Y;
             List<CableSymbol> topSymbols = topLayouts.Select(tl => cableSymbolById[tl.Id]).ToList();
             topSymbols.Sort((ts1, ts2) => ts1.PlacedPosition.X.CompareTo(ts2.PlacedPosition.X));
             List<List<double>> connectionAbscisses = new List<List<double>>(bottomLayoutsCount);
             foreach (CableSymbol cableSymbol in topSymbols)
                 connectionAbscisses.Add(GetAbscisses(cableSymbol.PlacedPosition.X, symbol.CableLayoutById[cableSymbol.CableId]));
             List<int> maxPositions = new List<int>(topLayoutsCount);
             connectionAbscisses.ForEach(l => maxPositions.Add(l.Count));
             Dictionary<int, double> abscissesByCableId = GetAbscissesByCableId(maxPositions, connectionAbscisses, topSymbols, topLayouts, symbol);
             foreach (int cableId in abscissesByCableId.Keys)
             {
                 double absciss = abscissesByCableId[cableId];
                 CableLayout cableLayout = symbol.CableLayoutById[cableId];
                 double cableLayoutY = cableLayout.PlacedPoints.First().Y;
                 if (cableLayout.StartOffsets.Count > 1)
                     graphic.CreateArc(sheetId, absciss, cableLayoutY, radius, 0, 180, lineHeight, connectionColorIndex);
             }
             double centerX = (topSymbols.Min(ts => ts.PlacedPosition.X) + topSymbols.Max(ts => ts.PlacedPosition.X)) / 2;
             List<CableSymbol> leftSymbols = topSymbols.Where(ts => ts.PlacedPosition.X <= abscissesByCableId[ts.CableId]).ToList();
             List<CableSymbol> rightSymbols = topSymbols.Where(ts => ts.PlacedPosition.X > abscissesByCableId[ts.CableId]).ToList();
             PlaceSideSymbolsConnectionLine(symbol, sheet, graphic, lineHeight, sheetId, abscissesByCableId, centerX, leftSymbols, lastCableLayoutY, Level.Bottom);
             PlaceSideSymbolsConnectionLine(symbol, sheet, graphic, lineHeight, sheetId, abscissesByCableId, centerX, rightSymbols, lastCableLayoutY, Level.Bottom);
         }
     }
 }
 private void PlaceCableSymbols(Sheet sheet, Graphic graphic, Group e3group, E3Text text, double startAbsciss, double topGroupOrdinate, double bottomGroupOrdinate)
 {
     foreach (int cableId in cableSymbolById.Keys)
     {
         CableSymbol cableSymbol = cableSymbolById[cableId];
         if (cableSymbol.Orientation == Orientation.Horizontal)
         {
             List<int> groupIds = symbolIdsByCableId[cableId];
             groupIds.Sort((id1,id2) => GetGroupPosition(id1).CompareTo(GetGroupPosition(id2)));
             ISchemeSymbol firstSymbol = symbolById[groupIds.First()];
             ISchemeSymbol secondSymbol = symbolById[groupIds.Last()];
             double firstPointX = sheet.MoveRight(firstSymbol.PlacedPosition.X, firstSymbol.RightMargin);
             double y = (firstSymbol.Level == Level.Bottom) ? sheet.MoveDown(bottomGroupOrdinate, bottomGroupBottomMargin) : sheet.MoveDown (topGroupOrdinate, topGroupBottomMargin);
             Point firstPoint = new Point (firstPointX, y);
             double secondPointX = sheet.MoveLeft(secondSymbol.PlacedPosition.X, secondSymbol.LeftMargin);
             Point secondPoint = new Point(secondPointX, y);
             double x = (firstPoint.X + secondPoint.X) / 2;
             double cableSymbolHalfHeight = cableSymbol.Size.Height / 2;
             y = sheet.MoveDown(y, cableSymbolHalfHeight + gridStep);
             cableSymbol.Place(sheet, graphic, text, e3group, new Point(x, y));
          }
     }
     if (topGroupHorizontalOffsetById.Count > 0)
     {
         double top = symbolById[topGroupHorizontalOffsetById.Keys.First()].PlacedPosition.Y;
         ISchemeSymbol bottomSymbol = symbolById[bottomGroupHorizontalOffsetById.Keys.First()];
         double bottom = sheet.MoveUp(bottomSymbol.PlacedPosition.Y, bottomSymbol.TopMargin);
         double center = (top + bottom) / 2;
         foreach (VerticalConnection verticalConnection in verticalConnections)
             foreach (CableSymbol cableSymbol in verticalConnection.VerticalCableSymbols)
             {
                 double y = sheet.MoveDown(center, (cableSymbol.Size.Height - cableSymbol.Diameter) / 2);
                 cableSymbol.Place(sheet, graphic, text, e3group, new Point(sheet.MoveRight(startAbsciss, verticalConnection.OffsetByCableId[cableSymbol.CableId]), y));
             }
     }
 }
 public void Place(Sheet sheet, Graphic graphic, Group e3group, E3Text text, Point placePositon)
 {
     //layout.Place(sheet, graphic, e3group, text, placePositon);
 }
 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;
 }
 public void Place(Sheet sheet, Graphic graphic, Group e3group, E3Text text, Point placePosition)
 {
     double startAbsciss = sheet.MoveLeft(placePosition.X, Size.Width / 2);
     double startOrdinate = sheet.MoveDown(placePosition.Y, Size.Height / 2);
     double bottomGroupOrdinate = sheet.MoveUp(startOrdinate, bottomGroupsOffset);
     double topGroupOrdinate = sheet.MoveUp(startOrdinate, topGroupsOffset);
     PlaceSymbols(sheet, graphic, e3group, text, topGroupHorizontalOffsetById, startAbsciss, topGroupOrdinate);
     PlaceSymbols(sheet, graphic, e3group, text, bottomGroupHorizontalOffsetById, startAbsciss, bottomGroupOrdinate);
     PlaceCableSymbols(sheet, graphic, e3group, text, startAbsciss, topGroupOrdinate, bottomGroupOrdinate);
     PlaceConnectionLines(sheet, graphic, topGroupOrdinate, bottomGroupOrdinate);
 }
 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 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;
 }
 private int CreateOutline(Sheet sheet, Graphic graphic, int sheetId, Point placePosition)
 {
     double x1 = placePosition.X;
     double y1 = placePosition.Y;
     double x2 = sheet.MoveRight(x1, Size.Width);
     double y2 = sheet.MoveUp(y1, Size.Height);
     return graphic.CreateRectangle(sheetId, x1, y1, x2, y2);
 }
 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;
 }
 public List<int> Place(Sheet sheet, Graphic graphic, E3Text text, Point position)
 {
     int sheetId = sheet.Id;
     if (isTerminal)
         return CreateTerminalSymbol(sheet, text, graphic, sheetId, position);
     else
         return CreateDeviceSymbol(sheet, text, graphic, sheetId, position);
 }
 private void CreateStraightConnectingLine(Sheet sheet, Graphic graphic, double lineHeight, int sheetId, Dictionary<int, double> abscissesByCableId, double layoutPlacedY, CableSymbol cableSymbol)
 {
     double absciss = abscissesByCableId[cableSymbol.CableId];
     double symbolX = (absciss > cableSymbol.PlacedPosition.X) ? sheet.MoveRight(cableSymbol.PlacedPosition.X, cableSymbol.Size.Width / 2) : sheet.MoveLeft(cableSymbol.PlacedPosition.X, cableSymbol.Size.Width / 2);
     double symbolY = cableSymbol.PlacedPosition.Y;
     graphic.CreateLine(sheetId, absciss, layoutPlacedY, absciss, symbolY, lineHeight, connectionColorIndex);
     graphic.CreateLine(sheetId, symbolX, symbolY, absciss, symbolY, lineHeight, connectionColorIndex);
 }
Пример #16
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;
 }
 private void CreateTurningConnectingLine(Sheet sheet, Graphic graphic, double lineHeight, int sheetId, Dictionary<int, double> abscissesByCableId, double lastCableLayoutY, CableSymbol cableSymbol, ISchemeSymbol symbol)
 {
     double absciss = abscissesByCableId[cableSymbol.CableId];
     double symbolX, turnX;
     if (absciss > cableSymbol.PlacedPosition.X)
     {
         symbolX = sheet.MoveRight(cableSymbol.PlacedPosition.X, cableSymbol.Size.Width / 2);
         turnX = sheet.MoveLeft(symbol.PlacedPosition.X, symbol.LeftMargin + gridStep);
     }
     else
     {
         symbolX = sheet.MoveLeft(cableSymbol.PlacedPosition.X, cableSymbol.Size.Width / 2);
         turnX = sheet.MoveRight(symbol.PlacedPosition.X, symbol.RightMargin + gridStep);
     }
     double symbolY = cableSymbol.PlacedPosition.Y;
     graphic.CreateLine(sheetId, absciss, lastCableLayoutY, turnX, lastCableLayoutY, lineHeight, connectionColorIndex);
     graphic.CreateLine(sheetId, turnX, lastCableLayoutY, turnX, symbolY, lineHeight, connectionColorIndex);
     graphic.CreateLine(sheetId, turnX, symbolY, symbolX, symbolY, lineHeight, connectionColorIndex);
 }
Пример #18
0
 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);
 }
Пример #19
0
 public List<int> Place(Sheet sheet, Graphic graphic, Point placePosition)
 {
     double lineHeight = 0.2;
     List<int> ids = new List<int>();
     int sheetId = sheet.Id;
     int colorIndex = 16;
     double endOrdinate = (level == Level.Top) ? sheet.MoveUp(placePosition.Y, verticalOffset) : sheet.MoveDown(placePosition.Y, verticalOffset);
     List<Point> placedPoints = new List<Point>(startOffsets.Count);
     if (skewDirection == Position.Center )
         foreach (Point startOffset in startOffsets)
         {
             double x = sheet.MoveRight(placePosition.X, startOffset.X);
             double y = (level == Level.Top) ? sheet.MoveUp(placePosition.Y, startOffset.Y) : sheet.MoveDown(placePosition.Y, startOffset.Y);
             ids.Add(graphic.CreateLine(sheetId, x, y, x, endOrdinate, lineHeight,colorIndex));
             placedPoints.Add(new Point(x, endOrdinate));
         }
     else
         for (int i = 0; i < startOffsets.Count; i++)
         {
             Point startOffset = startOffsets[i];
             double xStart = sheet.MoveRight(placePosition.X, startOffset.X);
             double yStart = (level == Level.Top) ? sheet.MoveUp(placePosition.Y, startOffset.Y) : sheet.MoveDown(placePosition.Y, startOffset.Y);
             double yIntermediate = (level == Level.Top) ? sheet.MoveUp(yStart, gridStep) :  sheet.MoveDown(yStart, gridStep);
             double xIntermediate = (skewDirection == Position.Left) ? sheet.MoveLeft(xStart, skewOffset) : sheet.MoveRight(xStart, skewOffset);
             ids.Add(graphic.CreateLine(sheetId, xStart, yStart, xIntermediate, yIntermediate, lineHeight, colorIndex));
             ids.Add(graphic.CreateLine(sheetId, xIntermediate, yIntermediate, xIntermediate, endOrdinate, lineHeight, colorIndex));
             placedPoints.Add(new Point(xIntermediate, endOrdinate));
         }
     PlacedPoints = placedPoints;
     if (minOffset!=maxOffset)
         ids.Add(graphic.CreateLine(sheetId, sheet.MoveRight(placePosition.X, minOffset),endOrdinate, sheet.MoveRight(placePosition.X, maxOffset), endOrdinate, 0.5 ,colorIndex));
     return ids;
 }