Ejemplo n.º 1
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;
 }
 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);
 }
Ejemplo n.º 3
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 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));
             }
     }
 }
 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);
 }
 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);
 }
 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);
 }
Ejemplo n.º 8
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;
 }