private void View3DWidget_AfterDraw(object sender, DrawEventArgs e) { if (view3DWidget?.HasBeenClosed == false && this.TrackingObject != null) { // Account for loading items in InsertionGroups - inherit parent transform var offset = TrackingObject.Parent?.Matrix ?? Matrix4X4.Identity; AxisAlignedBoundingBox bounds = TrackingObject.GetAxisAlignedBoundingBox(offset); Vector3 renderPosition = bounds.GetBottomCorner(2); Vector2 cornerScreenSpace = view3DWidget.Object3DControlLayer.World.GetScreenPosition(renderPosition) - new Vector2(20, 0); e.Graphics2D.PushTransform(); Affine currentGraphics2DTransform = e.Graphics2D.GetTransform(); Affine accumulatedTransform = currentGraphics2DTransform * Affine.NewTranslation(cornerScreenSpace.X, cornerScreenSpace.Y); e.Graphics2D.SetTransform(accumulatedTransform); progressBar.OnDraw(e.Graphics2D); if (!string.IsNullOrEmpty(this.State)) { e.Graphics2D.DrawString(this.State, 0, -20, 11); } e.Graphics2D.PopTransform(); } }
private void View3DWidget_AfterDraw(object sender, DrawEventArgs e) { if (view3DWidget?.HasBeenClosed == false && this.TrackingObject != null) { // Account for loading items in InsertionGroups - inherit parent transform var offset = TrackingObject.Parent?.Matrix ?? Matrix4X4.Identity; AxisAlignedBoundingBox bounds = TrackingObject.GetAxisAlignedBoundingBox(offset); Vector3 renderPosition = bounds.GetBottomCorner(2); Vector2 cornerScreenSpace = view3DWidget.Object3DControlLayer.World.GetScreenPosition(renderPosition) - new Vector2(20, 10) * GuiWidget.DeviceScale; e.Graphics2D.PushTransform(); Affine currentGraphics2DTransform = e.Graphics2D.GetTransform(); Affine accumulatedTransform = currentGraphics2DTransform * Affine.NewTranslation(cornerScreenSpace.X, cornerScreenSpace.Y); e.Graphics2D.SetTransform(accumulatedTransform); progressBar.OnDraw(e.Graphics2D); if (!string.IsNullOrEmpty(this.State)) { var stringPrinter = new TypeFacePrinter(this.State, 9, new Vector2(0, -20)); var textBounds = stringPrinter.LocalBounds; textBounds.Inflate(textBounds.Height / 4); e.Graphics2D.Render(new RoundedRect(textBounds, textBounds.Height / 4), theme.BackgroundColor); stringPrinter.Render(e.Graphics2D, theme.TextColor); } e.Graphics2D.PopTransform(); } }