static BBNode BuildBBHierarchyUnderDObject(DObject dObject) { DNode dNode = dObject as DNode; if (dNode != null) { return(BuildBBHierarchyUnderDNode(dNode)); } DEdge dedge = dObject as DEdge; if (dedge != null) { return(BuildBBHierarchyUnderDEdge(dedge)); } DLabel dLabel = dObject as DLabel; if (dLabel != null) { return(BuildBBHierarchyUnderDLabel(dLabel)); } DGraph dGraph = dObject as DGraph; if (dGraph != null) { dGraph.BbNode.bBox = dGraph.DrawingGraph.BoundingBox; return(dGraph.BbNode); } throw new InvalidOperationException(); }
internal Line(DObject tag, P2 start, P2 end, double lw) : base(tag) { lineWidth = lw; P2 dir = end - start; if (lineWidth < 0) lineWidth = 1; double len = dir.Length; if (len > ApproximateComparer.IntersectionEpsilon) { dir /= (len / (lineWidth / 2)); dir = dir.Rotate(Math.PI / 2); } else { dir.X = 0; dir.Y = 0; } this.bBox = new BBox(start + dir); this.bBox.Add(start - dir); this.bBox.Add(end + dir); this.bBox.Add(end - dir); this.start = start; this.end = end; if (this.bBox.LeftTop.X == this.bBox.RightBottom.X) { bBox.LeftTop = bBox.LeftTop + new P2(-0.05f, 0); bBox.RightBottom = bBox.RightBottom + new P2(0.05f, 0); } if (this.bBox.LeftTop.Y == this.bBox.RightBottom.Y) { bBox.LeftTop = bBox.LeftTop + new P2(0, -0.05f); bBox.RightBottom = bBox.RightBottom + new P2(0, 0.05f); } }
/// <summary> /// constructor /// </summary> /// <param name="parentPar"></param> /// <param name="label"></param> public DLabel(DObject parentPar, Microsoft.Msagl.Drawing.Label label) { this.parent = parentPar; this.DrawingLabel = label; ((IHavingDLabel)parent).Label = this; Font = new Font(DrawingLabel.FontName, DrawingLabel.FontSize); }
static void InvalidateBBNodesAbove(DObject dObj) { for (BBNode node = dObj.BbNode; node != null; node = node.parent) { node.bBox.Width = -1; //this will make the box empty } }
/// <summary> /// constructor /// </summary> /// <param name="parentPar"></param> /// <param name="label"></param> /// <param name="viewer">the viewer containing the label</param> public DLabel(DObject parentPar, Label label, GViewer viewer) : base(viewer) { parent = parentPar; DrawingLabel = label; ((IHavingDLabel)parent).Label = this; Font = new Font(DrawingLabel.FontName, (int)DrawingLabel.FontSize); }
internal static void AddStyleForPen(DObject dObj, Pen myPen, Style style) { if (style == Style.Dashed) { myPen.DashStyle = DashStyle.Dash; if (dObj.DashPatternArray == null) { float f = dObj.DashSize(); dObj.DashPatternArray = new float[] { f, f }; } myPen.DashPattern = dObj.DashPatternArray; myPen.DashOffset = dObj.DashPatternArray[0]; } else if (style == Style.Dotted) { myPen.DashStyle = DashStyle.Dash; if (dObj.DashPatternArray == null) { float f = dObj.DashSize(); dObj.DashPatternArray = new float[] { 1, f }; } myPen.DashPattern = dObj.DashPatternArray; } }
internal static void CreateDLabel(DObject parent, Microsoft.Msagl.Drawing.Label label, out double width, out double height) { DLabel dLabel = new DLabel(parent, label); dLabel.Font = new Font(label.FontName, label.FontSize); StringMeasure.MeasureWithFont(label.Text, dLabel.Font, out width, out height); label.Width = width; label.Height = height; }
internal void SetSelectedObject(object o) { selectedDObject = (DObject)o; MousePositonWhenSetSelectedObject = MousePosition; if (SelectionChanged != null) { SelectionChanged(this, null); } }
static void RebuildBBHierarchyUnderObject(DObject dObj) { BBNode oldNode = dObj.BbNode; BBNode newNode = BuildBBHierarchyUnderDObject(dObj); //now copy all fields, except the parent oldNode.l = newNode.l; oldNode.r = newNode.r; oldNode.geometry = newNode.geometry; oldNode.bBox = newNode.bBox; }
internal Geometry(DObject dObject) { this.dObject = dObject; DNode dNode = dObject as DNode; if (dNode != null) bBox = dNode.DrawingNode.BoundingBox; else { DLabel dLabel = dObject as DLabel; if (dLabel != null) bBox = dLabel.DrawingLabel.BoundingBox; } }
static void RebuildBBHierarchyUnderObject(DObject dObj) { BBNode oldNode = dObj.BbNode; BBNode newNode = BuildBBHierarchyUnderDObject(dObj); if (newNode != null) { //now copy all fields, except the parent oldNode.left = newNode.left; oldNode.right = newNode.right; oldNode.geometry = newNode.geometry; oldNode.bBox = newNode.bBox; } else { oldNode.bBox = Rectangle.CreateAnEmptyBox(); } }
internal Geometry(DObject dObject) { this.dObject = dObject; DNode dNode = dObject as DNode; if (dNode != null) { bBox = dNode.DrawingNode.BoundingBox; } else { DLabel dLabel = dObject as DLabel; if (dLabel != null) { bBox = dLabel.DrawingLabel.BoundingBox; } } }
internal Geometry(DObject tag) { this.tag = tag; DNode dNode = tag as DNode; if (dNode != null) { bBox = dNode.DrawingNode.BoundingBox; } else { DLabel dLabel = tag as DLabel; if (dLabel != null) { bBox = dLabel.DrawingLabel.BoundingBox; } } }
internal static void CreateDLabel(DObject parent, Drawing.Label label, out double width, out double height, GViewer viewer) { var dLabel = new DLabel(parent, label, viewer) { Font = new Font(label.FontName, (int)label.FontSize, (System.Drawing.FontStyle)(int) label.FontStyle) }; StringMeasure.MeasureWithFont(label.Text, dLabel.Font, out width, out height); if (width <= 0) { //this is a temporary fix for win7 where Measure fonts return negative lenght for the string " " StringMeasure.MeasureWithFont("a", dLabel.Font, out width, out height); } label.Width = width; label.Height = height; }
internal Line(DObject tag, P2 start, P2 end, double lw) : base(tag) { lineWidth = lw; P2 dir = end - start; if (lineWidth < 0) { lineWidth = 1; } double len = dir.Length; if (len > Microsoft.Msagl.Splines.Curve.IntersectionEpsilon) { dir /= (len / (lineWidth / 2)); dir = dir.Rotate(Math.PI / 2); } else { dir.X = 0; dir.Y = 0; } this.bBox = new Microsoft.Msagl.Splines.Rectangle(start + dir); this.bBox.Add(start - dir); this.bBox.Add(end + dir); this.bBox.Add(end - dir); this.start = start; this.end = end; if (this.bBox.LeftTop.X == this.bBox.RightBottom.X) { bBox.LeftTop = bBox.LeftTop + new P2(-0.05f, 0); bBox.RightBottom = bBox.RightBottom + new P2(0.05f, 0); } if (this.bBox.LeftTop.Y == this.bBox.RightBottom.Y) { bBox.LeftTop = bBox.LeftTop + new P2(0, -0.05f); bBox.RightBottom = bBox.RightBottom + new P2(0, 0.05f); } }
/// <summary> /// first and count denine the segment needed to be split into two groups /// </summary> /// <param name="first"></param> /// <param name="count"></param> /// <returns></returns> BBNode ProcessGroup(int first, int count) { if (count > 1) { int seed0; BBox b0; int seed1; FindSeeds(first, count, out seed0, out b0, out seed1); BBox b1; int count0; int count1; SplitOnGroups(first, count, seed0, ref b0, seed1, out b1, out count0, out count1); BBNode node = new BBNode(); node.bBox = new BBox(b0, b1); node.left = ProcessGroup(first, count0); node.left.parent = node; node.right = ProcessGroup(first + count0, count1); node.right.parent = node; return(node); } if (count == 1) { Geometry geom = geometries[first] as Geometry; if (geom != null) { BBNode node = new BBNode(); node.geometry = geom; return(node); } DObject dObject = geometries[first] as DObject; if (dObject != null) { return(dObject.BbNode); } } return(null); }
IEnumerable <DObject> RelatedObjs(DObject dObj) { yield return(dObj); var dNode = dObj as DNode; if (dNode != null) { foreach (DEdge e in dNode.OutEdges) { yield return(e); } foreach (DEdge e in dNode.InEdges) { yield return(e); } foreach (DEdge e in dNode.SelfEdges) { yield return(e); } } else { var dEdge = dObj as DEdge; if (dEdge != null) { yield return(dEdge.Source); yield return(dEdge.Target); if (dEdge.Label != null) { yield return(dEdge.Label); } } } }
internal void SetSelectedObject(object o) { selectedDObject = (DObject)o; MousePositonWhenSetSelectedObject = MousePosition; }
internal Geometry(DObject dObject, BBox box) { this.dObject = dObject; this.bBox = box; }
/// <summary> /// constructor /// </summary> /// <param name="parentPar"></param> /// <param name="label"></param> /// <param name="viewer">the viewer containing the label</param> public DLabel(DObject parentPar, Label label, GViewer viewer) : base(viewer) { parent = parentPar; DrawingLabel = label; ((IHavingDLabel) parent).Label = this; Font = new Font(DrawingLabel.FontName, (int)DrawingLabel.FontSize, (System.Drawing.FontStyle)(int)label.FontStyle); }
static BBNode BuildBBHierarchyUnderDObject(DObject dObject){ var dNode = dObject as DNode; if (dNode != null) return BuildBBHierarchyUnderDNode(dNode); var dedge = dObject as DEdge; if (dedge != null){ return BuildBBHierarchyUnderDEdge(dedge); } var dLabel = dObject as DLabel; if (dLabel != null) if (DLabelIsValid(dLabel)) return BuildBBHierarchyUnderDLabel(dLabel); else return null; var dGraph = dObject as DGraph; if (dGraph != null){ dGraph.BbNode.bBox = dGraph.DrawingGraph.BoundingBox; return dGraph.BbNode; } throw new InvalidOperationException(); }
static void InvalidateBBNodesAbove(DObject dObj){ for (BBNode node = dObj.BbNode; node != null; node = node.parent) node.bBox.Width = -1; //this will make the box empty }
IEnumerable<DObject> RelatedObjs(DObject dObj){ yield return dObj; var dNode = dObj as DNode; if (dNode != null){ foreach (DEdge e in dNode.OutEdges) yield return e; foreach (DEdge e in dNode.InEdges) yield return e; foreach (DEdge e in dNode.SelfEdges) yield return e; } else{ var dEdge = dObj as DEdge; if (dEdge != null){ yield return dEdge.Source; yield return dEdge.Target; if (dEdge.Label != null) yield return dEdge.Label; } } }
static void RebuildBBHierarchyUnderObject(DObject dObj){ BBNode oldNode = dObj.BbNode; BBNode newNode = BuildBBHierarchyUnderDObject(dObj); if (newNode != null) { //now copy all fields, except the parent oldNode.left = newNode.left; oldNode.right = newNode.right; oldNode.geometry = newNode.geometry; oldNode.bBox = newNode.bBox; } else oldNode.bBox = Rectangle.CreateAnEmptyBox(); }
/// <summary> /// returns false on filtered entities and only on them /// </summary> /// <param name="dObject"></param> /// <returns></returns> static bool EdgeFilter(DObject dObject) { return !(dObject is DEdge); }
internal Geometry(DObject tag, BBox box) { this.tag = tag; this.bBox = box; }
internal static void CreateDLabel(DObject parent, Drawing.Label label, out double width, out double height, GViewer viewer){ var dLabel = new DLabel(parent, label, viewer){Font = new Font(label.FontName, (int)label.FontSize)}; StringMeasure.MeasureWithFont(label.Text, dLabel.Font, out width, out height); if (width <= 0) //this is a temporary fix for win7 where Measure fonts return negative lenght for the string " " StringMeasure.MeasureWithFont("a", dLabel.Font, out width, out height); label.Width = width; label.Height = height; }
internal static void AddStyleForPen(DObject dObj, Pen myPen, Style style){ if(style == Style.Dashed){ myPen.DashStyle = DashStyle.Dash; if(dObj.DashPatternArray == null){ float f = dObj.DashSize(); dObj.DashPatternArray = new[]{f, f}; } myPen.DashPattern = dObj.DashPatternArray; myPen.DashOffset = dObj.DashPatternArray[0]; } else if(style == Style.Dotted){ myPen.DashStyle = DashStyle.Dash; if(dObj.DashPatternArray == null){ float f = dObj.DashSize(); dObj.DashPatternArray = new[]{1, f}; } myPen.DashPattern = dObj.DashPatternArray; } }
internal void SetSelectedObject(object o){ selectedDObject = (DObject) o; MousePositonWhenSetSelectedObject = MousePosition; }