internal static RulerData GetRulerData() { var overlay = new RulerData(); foreach (var l in Lines) { overlay.Lines.Add(l.ToRulerLine()); } return(overlay); }
private void DrawSegments(RulerData rulerData, float strokeLength) { var step = (float)Math.Truncate(CalculateEffectiveStep()); var delta = step * sv.Scene.Scale.X; DrawSegments(rulerData, delta, strokeLength, step); var reduceFactor = 1f / Tesselation; DrawSegments(rulerData, delta * reduceFactor, strokeLength * reduceFactor); }
private void DrawRuler(RulerData ruler, Vector2 size, Widget root) { var t = Document.Current.RootNode.AsWidget.CalcTransitionToSpaceOf(root); foreach (var line in ruler.Lines) { if (line.IsVertical) { var val = (new Vector2(line.Value + size.X, 0) * t).X; Renderer.DrawLine(new Vector2(val, 0), new Vector2(val, root.Size.Y), ColorTheme.Current.SceneView.Ruler); } else { var val = (new Vector2(0, line.Value + size.Y) * t).Y; Renderer.DrawLine(new Vector2(0, val), new Vector2(root.Size.X, val), ColorTheme.Current.SceneView.Ruler); } } }
public RulerRowView(RulerData overlay, IList <RulerData> overlays) : base() { Layout = new HBoxLayout(); Nodes.Add(Label = new ThemedSimpleText { Padding = new Thickness { Left = 10 }, }); this.AddChangeWatcher(() => overlay.Name, (name) => Label.Text = name); Nodes.Add(new Widget()); Nodes.Add(deleteButton = new ThemedDeleteButton { Anchors = Anchors.Right, LayoutCell = new LayoutCell(Alignment.LeftTop) }); CompoundPresenter.Add(StripePresenter); deleteButton.Clicked = () => overlays.Remove(overlay); MinMaxHeight = 20; }
private void DrawSegments(RulerData rulerData, float strokeDelta, float strokeLength, float?strokeValue = null) { var maskInverted = rulerData.RulerOrientation.GetDirection(); var mask = (Vector2.One - maskInverted); var delta = mask * strokeDelta; var j = -(int)Math.Round(((rulerData.Origin * mask).Length - rulerData.LeftStoper) / strokeDelta); var b = maskInverted * rulerData.Offset + rulerData.Origin * mask + j * strokeDelta * mask; var a = b - maskInverted * strokeLength; var fontHeight = 14f; var letterspacing = 1f; var textOffset = Vector2.Zero; do { if (GetVectorComponentForOrientation(a, rulerData.RulerOrientation) - rulerData.Offset >= 0) { Renderer.DrawLine(a, b, ColorTheme.Current.SceneView.RulerTextColor); if (strokeValue != null) { var lengthMarkerText = ((int)(j * strokeValue.Value)).ToString(); var textLength = FontPool.Instance.DefaultFont.MeasureTextLine(lengthMarkerText, fontHeight, letterspacing); var lengthMarkerPosition = a + textOffset; Renderer.PushState(RenderState.Transform1); Renderer.MultiplyTransform1(Matrix32.Translation(lengthMarkerPosition.X.Round(), lengthMarkerPosition.Y.Round())); if (rulerData.RulerOrientation == RulerOrientation.Vertical) { Renderer.MultiplyTransform1(Matrix32.Rotation(-Mathf.HalfPi)); textOffset = Vector2.Down * (5 + textLength.X); } else { textOffset = Vector2.Right * 5; } Renderer.DrawTextLine(Vector2.Zero, lengthMarkerText, fontHeight, ColorTheme.Current.SceneView.RulerTextColor, letterspacing); Renderer.PopState(); } } j++; a += delta; b += delta; } while (rulerData.RightStoper > GetVectorComponentForOrientation(a, rulerData.RulerOrientation)); }