Beispiel #1
0
 public AGSBoundingBoxes GetBoundingBoxes(IViewport viewport)
 {
     return(_boundingBoxComponent.GetBoundingBoxes(viewport));
 }
Beispiel #2
0
        private AGSBoundingBox getBoundingBox(IInObjectTreeComponent tree, IBoundingBoxComponent box,
                                              Func <AGSBoundingBoxes, AGSBoundingBox> getBox, string printoutId)
        {
            float minX = float.MaxValue;
            float maxX = float.MinValue;
            float minY = float.MaxValue;
            float maxY = float.MinValue;

            var boxes = box?.GetBoundingBoxes(_state.Viewport);

            if (boxes != null)
            {
                var boundingBox = getBox(boxes);

                if (boundingBox.IsValid)
                {
                    minX = boundingBox.MinX;
                    maxX = boundingBox.MaxX;
                    minY = boundingBox.MinY;
                    maxY = boundingBox.MaxY;
                }

                if (printoutId != null)
                {
                    Debug.WriteLine($"{printoutId}: {minX}-{maxX}, {minY}-{maxY}");
                }
            }

            if (tree?.TreeNode != null)
            {
                foreach (var child in tree.TreeNode.Children)
                {
                    if (child == null || !child.UnderlyingVisible || EntitiesToSkip.Contains(child.ID))
                    {
                        continue;
                    }

                    //note: the text component check is needed for textboxes. We have a "with caret" version of the textbox flashing in and out
                    //but we don't want to set it to visible and not visible because it hurts performance to keep changing the display list (which triggers sorting)
                    //so we hide the the text and text background with label renderer properties. Because it's hidden the textbox may not be updated which correct bounding boxes.
                    var textComponent = child.GetComponent <ITextComponent>();
                    if (textComponent != null && !textComponent.TextVisible && !child.IsImageVisible)
                    {
                        continue;
                    }

                    var childBox = getBoundingBox(child, child, getBox, printoutId == null ? null : child.ID);
                    if (!childBox.IsValid)
                    {
                        continue;
                    }
                    if (minX > childBox.MinX)
                    {
                        minX = childBox.MinX;
                    }
                    if (maxX < childBox.MaxX)
                    {
                        maxX = childBox.MaxX;
                    }
                    if (minY > childBox.MinY)
                    {
                        minY = childBox.MinY;
                    }
                    if (maxY < childBox.MaxY)
                    {
                        maxY = childBox.MaxY;
                    }
                }
            }
            if (MathUtils.FloatEquals(minX, float.MaxValue))
            {
                return(default);