public edge(PointD siteA, PointD siteB) { Start = null; End = null; SiteA = siteA; SiteB = siteB; }
public MeshVertexInfo(Pt pt, Pt normalOverride, PointD?texture = null, PointD?textureAfter = null) : this() { Location = pt; NormalOverride = normalOverride; Texture = texture; TextureAfter = textureAfter; }
/// <summary> /// загрузить настройки, относящиеся к графику /// </summary> public void LoadChartSettings(ChartWindowSettings sets) { chart.Symbol = sets.Symbol; chart.Timeframe = new BarSettings(sets.Timeframe); chart.chart.StockSeries.BarDrawMode = sets.GraphMode; try { var theme = (ChartControl.Themes)Enum.Parse(typeof(ChartControl.Themes), sets.Theme); chart.chart.visualSettings.Theme = theme; chart.chart.visualSettings.ApplyTheme(); } catch { } chart.chart.visualSettings.StockSeriesUpLineColor = sets.ColorShadowUp; chart.chart.visualSettings.StockSeriesDownLineColor = sets.ColorShadowDn; chart.chart.visualSettings.StockSeriesUpFillColor = sets.ColorBarUp; chart.chart.visualSettings.StockSeriesDownFillColor = sets.ColorBarDn; chart.chart.visualSettings.PaneBackColor = sets.ColorBackground; chart.chart.StockSeries.ShowLastQuote = sets.ShowLastQuote; chart.chart.StockSeries.AutoScroll = sets.AutoScroll; chart.CurrentTemplateName = sets.LastTemplateName; chart.chart.YAxisAlignment = sets.YAxisAlignment; chart.chart.RightBars = sets.BarOffset; chartTimeExtends = new PointD(sets.FirstCandleIndex, sets.LastCandleIndex); chart.UniqueId = sets.UniqueId; chart.SetupSeries(sets.SeriesSettings); }
/// <summary> /// Processes the XML that this <see cref="T:ORMSolutions.ORMArchitect.Views.RelationalView.RelationalDiagram"/> has /// written. /// </summary> /// <param name="reader">A <see cref="T:System.Xml.XmlReader"/> that will read the XML associated with the /// serialization of this object.</param> void IXmlSerializable.ReadXml(XmlReader reader) { string rvNamespace = RelationalShapeDomainModel.XmlNamespace; Dictionary <object, object> context = Store.TransactionManager.CurrentTransaction.TopLevelTransaction.Context.ContextInfo; ISerializationContext serializationContext = ((ISerializationContextHost)Store).SerializationContext; object tablePositionsObject; Dictionary <Guid, PointD> tablePositions; if (!context.TryGetValue(TablePositionDictionaryKey, out tablePositionsObject) || (tablePositions = tablePositionsObject as Dictionary <Guid, PointD>) == null) { context[TablePositionDictionaryKey] = tablePositions = new Dictionary <Guid, PointD>(); } while (reader.NodeType != XmlNodeType.Element && reader.Read()) { ; } if (Subject == null) { serializationContext.RealizeElementLink( null, this, serializationContext.RealizeElement(reader.GetAttribute(SubjectRefAttributeName), Catalog.DomainClassId, true), PresentationViewsSubject.SubjectDomainRoleId, null); } this.DisplayDataTypes = XmlConvert.ToBoolean(reader.GetAttribute(DisplayDataTypesAttributeName)); TypeConverter pointConverter = TypeDescriptor.GetConverter(typeof(PointD)); while (reader.Read()) { string objectType = null; PointD?location = null; if (reader.NodeType == XmlNodeType.Element) { if (reader.LocalName == TableShapeElementName) { while (reader.MoveToNextAttribute()) { if (reader.LocalName == ObjectTypeRefAttributeName) { objectType = reader.Value; } else if (reader.LocalName == LocationAttributeName) { location = (PointD)pointConverter.ConvertFromInvariantString(reader.Value); } } if (objectType == null || location == null) { throw new InvalidOperationException(); } tablePositions[serializationContext.ResolveElementIdentifier(objectType)] = location.Value; } } } }
/// <summary> /// Initializes a new instance of the <see cref="LineIntersection"/> structure with the /// specified shared coordinates, relative locations, and spatial relationship between the /// intersected lines.</summary> /// <param name="shared"> /// The <see cref="PointD"/> coordinates shared by the two line segments or their infinite /// extensions.</param> /// <param name="first"> /// The location of the <see cref="Shared"/> coordinates relative to the first line segment. /// </param> /// <param name="second"> /// The location of the <see cref="Shared"/> coordinates relative to the second line /// segment.</param> /// <param name="relation"> /// The spatial relationship between the two line segments.</param> public LineIntersection(PointD?shared, LineLocation first, LineLocation second, LineRelation relation) { Shared = shared; First = first; Second = second; Relation = relation; }
public MeshVertexInfo(Pt pt, Normal befX, Normal afX, Normal befY, Normal afY, PointD?texture = null, PointD?textureAfter = null) : this() { Location = pt; NormalBeforeX = befX; NormalAfterX = afX; NormalBeforeY = befY; NormalAfterY = afY; Texture = texture; TextureAfter = textureAfter; }
public void SetEndPoint(PointD end) { if (Start == null) { Start = end; } else if (End == null) { End = end; } }
/// <summary> /// оповестить другие графики /// </summary> private void RaiseCursorCrossChangedEvent(PointD?crossCoords) { DateTime?time = null; double? price = null; if (crossCoords.HasValue) { price = crossCoords.Value.Y; var x = (int)(crossCoords.Value.X + 0.5); if (x >= 0 && x < Chart.StockSeries.Data.Count) { time = Chart.StockSeries.Data.Candles[x].timeOpen; } } Chart.Owner.onCursorCrossUpdated(time, price, Chart.Owner); }
private bool _ProcessHorizontalRelation(int sideIndex, int vertexIndex, FreeVector[] vector, Func <int, int> next, Func <int, int> prev) { FreeVector sideVector = new FreeVector(_vertices[vertexIndex].Location, _vertices[prev(vertexIndex)].Location + vector[prev(vertexIndex)]); if (sideVector.IsHorizontal) { return(true); } switch (_relations[next(sideIndex)].ToString()) { case "EmptyRelation": vector[vertexIndex] = vector[prev(vertexIndex)]; return(true); case "VerticalRelation": double xw = _vertices[vertexIndex].Location.X; double yw = (_vertices[prev(vertexIndex)].Location + vector[prev(vertexIndex)]).Y; FreeVector v = new FreeVector(_vertices[vertexIndex].Location, new PointD(xw, yw)); vector[vertexIndex] = v; return(true); case "LengthRelation": Circle c = new Circle(_vertices[next(vertexIndex)].Location, (_relations[next(sideIndex)] as LengthRelation).Length); double y = (_vertices[prev(vertexIndex)].Location + vector[prev(vertexIndex)]).Y; PointD[] p = c.GetIntersectionPointsWithHorizontalLine(y); PointD?chosenPoint = _GetTheNearestPoint(p, _vertices[vertexIndex].Location); if (!chosenPoint.HasValue) { vector[vertexIndex] = vector[prev(vertexIndex)]; return(false); } vector[vertexIndex] = new FreeVector(_vertices[vertexIndex].Location, chosenPoint.Value); return(true); } return(true); //? }
/// <summary> /// загрузить настройки, относящиеся к графику /// </summary> public void LoadChartSettings(ChartWindowSettings sets) { chart.Symbol = sets.Symbol; chart.Timeframe = new BarSettings(sets.Timeframe); chart.chart.StockSeries.BarDrawMode = sets.GraphMode; try { var theme = (ChartControl.Themes) Enum.Parse(typeof (ChartControl.Themes), sets.Theme); chart.chart.visualSettings.Theme = theme; chart.chart.visualSettings.ApplyTheme(); } catch { } chart.chart.visualSettings.StockSeriesUpLineColor = sets.ColorShadowUp; chart.chart.visualSettings.StockSeriesDownLineColor = sets.ColorShadowDn; chart.chart.visualSettings.StockSeriesUpFillColor = sets.ColorBarUp; chart.chart.visualSettings.StockSeriesDownFillColor = sets.ColorBarDn; chart.chart.visualSettings.PaneBackColor = sets.ColorBackground; chart.chart.StockSeries.ShowLastQuote = sets.ShowLastQuote; chart.chart.StockSeries.AutoScroll = sets.AutoScroll; chart.CurrentTemplateName = sets.LastTemplateName; chart.chart.YAxisAlignment = sets.YAxisAlignment; chart.chart.RightBars = sets.BarOffset; chartTimeExtends = new PointD(sets.FirstCandleIndex, sets.LastCandleIndex); chart.UniqueId = sets.UniqueId; chart.SetupSeries(sets.SeriesSettings); }
public static void Plot( Graphics g, Rectangle plotRectangle, float fontSize, Color lineColor, Color textColor, RangeD xRange, RangeD yRange, Tuple <double, string>[] xTics, Tuple <double, string>[] yTics, bool enableDots, Tuple <Color, PointD[]>[] data, PointD?marker) { var font = new Font("Consolas", fontSize, GraphicsUnit.Pixel); var linePen = new Pen(lineColor); var lineBrush = new SolidBrush(lineColor); var textBrush = new SolidBrush(textColor); g.DrawRectangles(linePen, new[] { plotRectangle }); var ticLength = 3; var t = new Translator(plotRectangle, xRange, yRange); foreach (var tic in xTics) { var x = t.Translate(new PointD(tic.Item1, 0.0)).X; g.DrawString(tic.Item2, font, textBrush, new PointF(x, plotRectangle.Bottom + XLabelOffset), StringFormatTop); g.DrawLine(linePen, x, plotRectangle.Top, x, plotRectangle.Top + ticLength); g.DrawLine(linePen, x, plotRectangle.Bottom - ticLength, x, plotRectangle.Bottom); } foreach (var tic in yTics) { var y = t.Translate(new PointD(0, tic.Item1)).Y; g.DrawString(tic.Item2, font, textBrush, new PointF(plotRectangle.Left - YLabelOffset, y), StringFormatRight); g.DrawLine(linePen, plotRectangle.Left, y, plotRectangle.Left + ticLength, y); g.DrawLine(linePen, plotRectangle.Right - ticLength, y, plotRectangle.Right, y); } for (int i = 0; i < data.Length; i++) { var curve = Array.ConvertAll(data[i].Item2, t.Translate); Color color = data[i].Item1; using (var pen = new Pen(color)) using (var brush = new SolidBrush(color)) { for (int j = 0; j < curve.Length; j++) { if (j != 0 && Point_IsValid(curve[j - 1]) && Point_IsValid(curve[j])) { g.DrawLine(pen, curve[j - 1], curve[j]); } if (enableDots && Point_IsValid(curve[j])) { g.FillRectangle(brush, new Rectangle(curve[j].X - DotSize / 2, curve[j].Y - DotSize / 2, DotSize, DotSize)); } } } } if (marker.HasValue) { var p = t.Translate(marker.Value); if (Point_IsValid(p)) { g.DrawRectangles(Pens.White, new[] { new RectangleF(p.X - MarkerSize / 2, p.Y - MarkerSize / 2, MarkerSize - 1, MarkerSize - 1) }); } } font.Dispose(); linePen.Dispose(); lineBrush.Dispose(); textBrush.Dispose(); }
private PointD InsertMacro(string windowMacroPath, Project project, Page page, PointD?point) { SymbolMacro symbolMacro = new SymbolMacro(); symbolMacro.Open(windowMacroPath, project); WindowMacro.Enums.RepresentationType representationType = symbolMacro.RepresentationTypes.First(); int variant = 0; var offsetX = 40; var offsetY = 200; if (point == null) { point = new PointD(offsetX, offsetY); } else { point = new PointD(point.Value.X + offsetX, point.Value.Y); } var insert = new Insert(); insert.SymbolMacro(symbolMacro, representationType, variant, page, point.Value, Insert.MoveKind.Absolute, WindowMacro.Enums.NumerationMode.Number); return(page.GetBoundingBox().Last()); // todo: Check variant // todo: Check RepresentationType // todo: Locking }
private bool _ProcessLengthRelation(int sideIndex, int vertexIndex, FreeVector[] vector, Func <int, int> next, Func <int, int> prev) { FreeVector v = new FreeVector(_vertices[prev(vertexIndex)].Location + vector[prev(vertexIndex)], _vertices[vertexIndex].Location); double L1 = (_relations[sideIndex] as LengthRelation).Length; if (v.Length == L1) { return(true); } switch (_relations[next(sideIndex)].ToString()) { case "EmptyRelation": { v = new FreeVector(_vertices[prev(vertexIndex)].Location, _vertices[vertexIndex].Location); PointD newPoint = (_vertices[prev(vertexIndex)].Location + vector[prev(vertexIndex)]) + (v); vector[vertexIndex] = new FreeVector(_vertices[vertexIndex].Location, newPoint); return(true); } case "HorizontalRelation": { double y = _vertices[vertexIndex].Location.Y; Circle c = new Circle(_vertices[prev(vertexIndex)].Location + vector[prev(vertexIndex)], L1); PointD[] p = c.GetIntersectionPointsWithHorizontalLine(y); PointD? chosenPoint = _GetTheNearestPoint(p, _vertices[vertexIndex].Location); if (!chosenPoint.HasValue) { vector[vertexIndex] = vector[prev(vertexIndex)]; return(false); } vector[vertexIndex] = new FreeVector(_vertices[vertexIndex].Location, chosenPoint.Value); return(true); } case "VerticalRelation": { Circle c = new Circle(_vertices[prev(vertexIndex)].Location + vector[prev(vertexIndex)], L1); double x = _vertices[vertexIndex].Location.X; PointD[] p = c.GetIntersectionPointsWithVerticalLine(x); PointD? chosenPoint = _GetTheNearestPoint(p, _vertices[vertexIndex].Location); if (!chosenPoint.HasValue) { vector[vertexIndex] = vector[prev(vertexIndex)]; return(false); } vector[vertexIndex] = new FreeVector(_vertices[vertexIndex].Location, chosenPoint.Value); return(true); } case "LengthRelation": { Circle c1 = new Circle(_vertices[prev(vertexIndex)].Location + vector[prev(vertexIndex)], L1); double L2 = (_relations[next(sideIndex)] as LengthRelation).Length; Circle c2 = new Circle(_vertices[next(vertexIndex)].Location, L2); PointD[] p = c1.GetIntersectionPointsWithCircle(c2); PointD? chosenPoint = _GetTheNearestPoint(p, _vertices[vertexIndex].Location); if (!chosenPoint.HasValue) { vector[vertexIndex] = vector[prev(vertexIndex)]; return(false); } vector[vertexIndex] = new FreeVector(_vertices[vertexIndex].Location, chosenPoint.Value); return(true); } } return(true); }
/// <summary> /// Calculates and shows the minimum value of the specified line between the specified bounds. /// </summary> /// <param name="slotId">The slot ID that corresponds to the line.</param> /// <param name="lowerBound">The X-value that the search should start at (left bound).</param> /// <param name="upperBound">The X-value that the search should stop at (right bound).</param> public void ShowMinimum(int slotId, double lowerBound, double upperBound) { ExpressionInfo info; if (!_expressions.TryGetValue(slotId, out info)) { throw new ArgumentException("The specified slot ID is not present in this instance."); } if (info.Expression.Type != ExpressionType.Linear) { throw new NotSupportedException("Only linear expressions may be used with this method."); } PointD min = MinMaxCalculator.FindMinimum(Calculator, _expressions[slotId].GraphedLine, lowerBound, upperBound); _displayedPoint = min; Invalidate(); }
public void ActivateXRangeSelection() { _current.Enabled = false; _current = _xRange; _current.Enabled = true; _displayedPoint = null; Invalidate(); }
private void ClearPoints() { _displayedPoint = null; _valuePoint = null; _derivativePoint = null; _derivativePointSlope = null; ClearValueTrackedLine(); ClearDerivativeTrackedLine(); _integralDrawHelper.ClearValues(); Invalidate(); }
public VertexInfo(Pt location, PointD?texture, Pt?normal) { Location = location; Texture = texture; Normal = normal; }
public SegmentIntersectionInfo(PointD?point, IntersectionType type) { _point = point; _type = type; }
private static void DrawAssociationEnd( DiagramPaintEventArgs e, IGeometryHost geometryHost, NodeShape node, PointD pointOnBorder, PointD endPoint, bool many, bool optional, bool id, string predicateText, ref PointF?lineEnd, bool bothOptional) { Pen pen; ShapeElement shapeHost; IOffsetBorderPoint offsetPointProvider; Font font; Brush brush; Graphics g = e.Graphics; if (null != (shapeHost = node) && null != (offsetPointProvider = shapeHost.ShapeGeometry as IOffsetBorderPoint) && null != (pen = geometryHost.GeometryStyleSet.GetPen(DiagramPens.ConnectionLine)) && null != (font = geometryHost.GeometryStyleSet.GetFont(DiagramFonts.ConnectionLine)) && null != (brush = geometryHost.GeometryStyleSet.GetBrush(DiagramBrushes.ConnectionLineText))) { Color restoreColor = pen.Color; pen.Color = geometryHost.UpdateGeometryLuminosity(e.View, pen); double angle = GeometryUtility.CalculateRadiansRotationAngle(endPoint, pointOnBorder); PointD vertexPoint = pointOnBorder; vertexPoint.Offset(CrowsFootHeight * Math.Cos(angle), CrowsFootHeight * Math.Sin(angle)); #region draw the main line Pen mainLinePen = (Pen)pen.Clone(); if (optional) { mainLinePen.DashPattern = DashPattern; mainLinePen.DashOffset = DashPattern[0]; } if (many & optional) { if (!bothOptional) { g.DrawLine(mainLinePen, PointD.ToPointF(endPoint), PointD.ToPointF(vertexPoint)); } else { lineEnd = PointD.ToPointF(vertexPoint); } g.DrawLine(pen, PointD.ToPointF(vertexPoint), PointD.ToPointF(pointOnBorder)); } else { if (!bothOptional) { g.DrawLine(mainLinePen, PointD.ToPointF(endPoint), PointD.ToPointF(pointOnBorder)); } else { lineEnd = PointD.ToPointF(pointOnBorder); } } #endregion #region draw crow's foot if necessary if (many) { PointD?offsetBorderPoint = offsetPointProvider.OffsetBorderPoint(shapeHost, pointOnBorder, vertexPoint, CrowsFootHalfWidth, CrowsFootParallelMode); if (offsetBorderPoint.HasValue) { g.DrawLine(pen, PointD.ToPointF(vertexPoint), PointD.ToPointF(offsetBorderPoint.Value)); } offsetBorderPoint = offsetPointProvider.OffsetBorderPoint(shapeHost, pointOnBorder, vertexPoint, -CrowsFootHalfWidth, CrowsFootParallelMode); if (offsetBorderPoint.HasValue) { g.DrawLine(pen, PointD.ToPointF(vertexPoint), PointD.ToPointF(offsetBorderPoint.Value)); } } #endregion #region draw tick mark if necessary if (id) { PointD oneMarkLeft = vertexPoint; double cosAngle = Math.Cos(angle); double sinAngle = Math.Sin(angle); oneMarkLeft.Offset(InfEngInnerOneMarkOffset * cosAngle, InfEngInnerOneMarkOffset * sinAngle); PointD oneMarkRight = oneMarkLeft; oneMarkLeft.Offset(-InfEngMarkerHalfWidth * sinAngle, InfEngMarkerHalfWidth * cosAngle); oneMarkRight.Offset(InfEngMarkerHalfWidth * sinAngle, -InfEngMarkerHalfWidth * cosAngle); g.DrawLine(pen, PointD.ToPointF(oneMarkLeft), PointD.ToPointF(oneMarkRight)); } #endregion #region draw text //determine the line's properties double edgeX = pointOnBorder.X; double edgeY = pointOnBorder.Y; EntitySideType whichSideShapeIsOn = EntitySide.FindWhichSide(pointOnBorder, shapeHost.GeometryBoundingBox); double w = 0; //, y = 0; angle = Math.Atan2(Math.Abs(endPoint.Y - edgeY), Math.Abs(endPoint.X - edgeX)); double inDegrees = angle * 180 / Math.PI; if (inDegrees < 0) { inDegrees += 360; } SizeF textSize = g.MeasureString(predicateText, font); w = textSize.Width; //y = Math.Abs(w * Math.Tan(angle)); //determine what to offset double textX = edgeX; double textY = edgeY; double h = textSize.Height; bool lessThan45 = inDegrees < 45; switch (whichSideShapeIsOn) { case EntitySideType.OnBottom: textY -= TextPaddingY + h; if (lessThan45) { textX += TextPaddingX; } else { textX -= TextPaddingX + w; } break; case EntitySideType.OnTop: textY += TextPaddingY; if (lessThan45) { textX -= TextPaddingX + w; } else { textX += TextPaddingX; } break; case EntitySideType.OnLeft: textX += TextPaddingX; if (lessThan45) { textY -= TextPaddingY + h; } else { textY += TextPaddingY; } break; case EntitySideType.OnRight: textX -= TextPaddingX + w; if (lessThan45) { textY += TextPaddingY; } else { textY -= TextPaddingY + h; } break; } //perform the drawing g.DrawString(predicateText, font, brush, new PointF((float)textX, (float)textY)); #endregion pen.Color = restoreColor; } }
public VertexInfo(Pt loc, Pt?normal, double?textureU, double?textureV) : this() { Location = loc; Normal = normal; Texture = textureU == null || textureV == null ? (PointD?)null : new PointD(textureU.Value, textureV.Value); }
public VertexInfo(Pt loc, Pt?normal, PointD?texture = null) : this() { Location = loc; Normal = normal; Texture = texture; }