public SnappingIndicators(IInteractionVolumeContext context, MeshSelectInfo currentSelectInfo) : base(context) { this.DrawOnTop = true; this.meshSelectInfo = currentSelectInfo; InteractionContext.GuiSurface.AfterDraw += InteractionLayer_AfterDraw; }
public PathControl(IInteractionVolumeContext context) { this.context = context; theme = MatterControl.AppContext.Theme; world = context.World; }
public IEnumerable <InteractionVolume> Create(IInteractionVolumeContext context) { // X, Y, Z RotateCornerControls return(new[] { new RotateCornerControl(context, 0), new RotateCornerControl(context, 1), new RotateCornerControl(context, 2) }); }
public IEnumerable <InteractionVolume> Create(IInteractionVolumeContext context) { return(new List <InteractionVolume> { new ScaleTopControl(context), new ScaleCornerControl(context, 0), new ScaleCornerControl(context, 1), new ScaleCornerControl(context, 2), new ScaleCornerControl(context, 3) }); }
public ScaleCornerControl(IInteractionVolumeContext context, int cornerIndex) : base(context) { theme = MatterControl.AppContext.Theme; xValueDisplayInfo = new InlineEditControl() { ForceHide = ForceHideScale, GetDisplayString = (value) => "{0:0.0}mm".FormatWith(value), }; xValueDisplayInfo.EditComplete += EditComplete; xValueDisplayInfo.VisibleChanged += (s, e) => { if (!xValueDisplayInfo.Visible) { HadClickOnControl = false; } }; yValueDisplayInfo = new InlineEditControl() { ForceHide = ForceHideScale, GetDisplayString = (value) => "{0:0.0}mm".FormatWith(value) }; yValueDisplayInfo.EditComplete += EditComplete; yValueDisplayInfo.VisibleChanged += (s, e) => { if (!yValueDisplayInfo.Visible) { HadClickOnControl = false; } }; InteractionContext.GuiSurface.AddChild(xValueDisplayInfo); InteractionContext.GuiSurface.AddChild(yValueDisplayInfo); this.quadrantIndex = cornerIndex; DrawOnTop = true; minXminYMesh = PlatonicSolids.CreateCube(selectCubeSize, selectCubeSize, selectCubeSize); CollisionVolume = minXminYMesh.CreateBVHData(); InteractionContext.GuiSurface.AfterDraw += InteractionLayer_AfterDraw; }
public MoveInZControl(IInteractionVolumeContext context) : base(context) { theme = AppContext.Theme; Name = "MoveInZControl"; zHeightDisplayInfo = new InlineEditControl() { ForceHide = () => { var selectedItem = RootSelection; // if the selection changes if (selectedItem != ActiveSelectedItem) { return(true); } // if another control gets a hover if (InteractionContext.HoveredInteractionVolume != this && InteractionContext.HoveredInteractionVolume != null) { return(true); } // if we clicked on the control if (HadClickOnControl) { return(false); } return(false); } , GetDisplayString = (value) => "{0:0.0#}mm".FormatWith(value) }; zHeightDisplayInfo.VisibleChanged += (s, e) => { if (!zHeightDisplayInfo.Visible) { HadClickOnControl = false; } }; zHeightDisplayInfo.EditComplete += (s, e) => { var selectedItem = RootSelection; Matrix4X4 startingTransform = selectedItem.Matrix; var newZPosition = zHeightDisplayInfo.Value; if (InteractionContext.SnapGridDistance > 0) { // snap this position to the grid double snapGridDistance = InteractionContext.SnapGridDistance; // snap this position to the grid newZPosition = ((int)((newZPosition / snapGridDistance) + .5)) * snapGridDistance; } AxisAlignedBoundingBox originalSelectedBounds = selectedItem.GetAxisAlignedBoundingBox(); var moveAmount = newZPosition - originalSelectedBounds.MinXYZ.Z; if (moveAmount != 0) { selectedItem.Matrix = selectedItem.Matrix * Matrix4X4.CreateTranslation(0, 0, moveAmount); Invalidate(); } context.Scene.AddTransformSnapshot(startingTransform); }; InteractionContext.GuiSurface.AddChild(zHeightDisplayInfo); DrawOnTop = true; using (Stream arrowStream = AggContext.StaticData.OpenStream(Path.Combine("Stls", "up_pointer.stl"))) { upArrowMesh = StlProcessing.Load(arrowStream, CancellationToken.None); } CollisionVolume = upArrowMesh.CreateBVHData(); InteractionContext.GuiSurface.AfterDraw += InteractionLayer_AfterDraw; }
public RotateCornerControl(IInteractionVolumeContext context, int axisIndex) : base(context) { angleTextControl = new InlineEditControl() { ForceHide = ForceHideAngle, GetDisplayString = (value) => "{0:0.0#}°".FormatWith(value) }; angleTextControl.VisibleChanged += (s, e) => { mouseDownInfo = null; Invalidate(); }; InteractionContext.GuiSurface.AddChild(angleTextControl); angleTextControl.Visible = false; angleTextControl.EditComplete += (s, e) => { var selectedItem = RootSelection; if (selectedItem != null && mouseDownInfo != null) { if (mouseMoveInfo != null) { SnappedRotationAngle = MathHelper.DegreesToRadians(angleTextControl.Value); mouseMoveInfo.AngleOfHit = mouseDownInfo.AngleOfHit + SnappedRotationAngle; rotatingCW = DeltaAngle(0, SnappedRotationAngle) < 0; // undo the last rotation RotateAroundAxis(selectedItem, -lastSnappedRotation); // rotate it RotateAroundAxis(selectedItem, SnappedRotationAngle); Invalidate(); lastSnappedRotation = SnappedRotationAngle; } InteractionContext.Scene.AddTransformSnapshot(mouseDownInfo.SelectedObjectTransform); } }; this.RotationAxis = axisIndex; DrawOnTop = true; rotationHandle = PlatonicSolids.CreateCube(selectCubeSize); RectangleDouble bounds = arrows.GetBounds(); if (rotationImageWhite == null) { rotationImageWhite = new ImageBuffer(64, 64, 32, new BlenderBGRA()); } VertexSourceApplyTransform arrows2 = new VertexSourceApplyTransform(arrows, Affine.NewTranslation(-bounds.Center) * Affine.NewScaling(rotationImageWhite.Width / bounds.Width, rotationImageWhite.Height / bounds.Height) * Affine.NewTranslation(rotationImageWhite.Width / 2, rotationImageWhite.Height / 2)); Graphics2D imageGraphics = rotationImageWhite.NewGraphics2D(); imageGraphics.Clear(new Color(Color.White, 0)); imageGraphics.Render(new FlattenCurves(arrows2), Color.White); ImageBuffer clearImage = new ImageBuffer(2, 2, 32, new BlenderBGRA()); for (int i = 0; i < rotationHandle.Faces.Count; i++) { if (i == 0 || i == 1) { rotationHandle.PlaceTextureOnFace(i, rotationImageWhite); } else { rotationHandle.PlaceTextureOnFace(i, clearImage); } } CollisionVolume = rotationHandle.CreateTraceData(); InteractionContext.GuiSurface.AfterDraw += InteractionLayer_AfterDraw; }
public ScaleTopControl(IInteractionVolumeContext context) : base(context) { zValueDisplayInfo = new InlineEditControl() { ForceHide = () => { // if the selection changes if (RootSelection != ActiveSelectedItem) { return(true); } // if another control gets a hover if (InteractionContext.HoveredInteractionVolume != this && InteractionContext.HoveredInteractionVolume != null) { return(true); } // if we clicked on the control if (HadClickOnControl) { return(false); } return(false); } , GetDisplayString = (value) => "{0:0.0}mm".FormatWith(value) }; zValueDisplayInfo.VisibleChanged += (s, e) => { if (!zValueDisplayInfo.Visible) { HadClickOnControl = false; } }; zValueDisplayInfo.EditComplete += (s, e) => { var selectedItem = ActiveSelectedItem; Matrix4X4 startingTransform = selectedItem.Matrix; var originalSelectedBounds = selectedItem.GetAxisAlignedBoundingBox(Matrix4X4.Identity); Vector3 topPosition = GetTopPosition(selectedItem); Vector3 lockedBottom = new Vector3(topPosition.X, topPosition.Y, originalSelectedBounds.MinXYZ.Z); Vector3 newSize = Vector3.Zero; newSize.Z = zValueDisplayInfo.Value; Vector3 scaleAmount = ScaleCornerControl.GetScalingConsideringShiftKey(originalSelectedBounds, mouseDownSelectedBounds, newSize, InteractionContext.GuiSurface.ModifierKeys); Matrix4X4 scale = Matrix4X4.CreateScale(scaleAmount); selectedItem.Matrix = selectedItem.ApplyAtBoundsCenter(scale); // and keep the locked edge in place AxisAlignedBoundingBox scaledSelectedBounds = selectedItem.GetAxisAlignedBoundingBox(Matrix4X4.Identity); Vector3 newLockedBottom = new Vector3(topPosition.X, topPosition.Y, scaledSelectedBounds.MinXYZ.Z); selectedItem.Matrix *= Matrix4X4.CreateTranslation(lockedBottom - newLockedBottom); Invalidate(); InteractionContext.Scene.AddTransformSnapshot(startingTransform); }; InteractionContext.GuiSurface.AddChild(zValueDisplayInfo); DrawOnTop = true; topScaleMesh = PlatonicSolids.CreateCube(selectCubeSize, selectCubeSize, selectCubeSize); CollisionVolume = topScaleMesh.CreateTraceData(); InteractionContext.GuiSurface.AfterDraw += InteractionLayer_AfterDraw; }
public InteractionVolume(IInteractionVolumeContext meshViewerToDrawWith) { this.InteractionContext = meshViewerToDrawWith; }
public virtual InteractionVolume CreateInteractionVolume(IInteractionVolumeContext context) { return(null); }
public SelectionShadow(IInteractionVolumeContext context) : base(context) { }
public SelectionShadow(IInteractionVolumeContext context) : base(context) { theme = AppContext.Theme; shadowColor = theme.ResolveColor(theme.BackgroundColor, Color.Black.WithAlpha(80)).WithAlpha(110); }