public InteractionLayer(ISceneContext sceneContext, ThemeConfig theme, EditorType editorType = EditorType.Part) { this.sceneContext = sceneContext; this.EditorMode = editorType; this.theme = theme; scene = sceneContext.Scene; gCodeMeshColor = new Color(theme.PrimaryAccentColor, 35); BuildVolumeColor = new ColorF(.2, .8, .3, .2).ToColor(); floorDrawable = new FloorDrawable(editorType, sceneContext, this.BuildVolumeColor, theme); if (ViewOnlyTexture == null) { // TODO: What is the ViewOnlyTexture??? UiThread.RunOnIdle(() => { ViewOnlyTexture = new ImageBuffer(32, 32, 32); var graphics2D = ViewOnlyTexture.NewGraphics2D(); graphics2D.Clear(Color.White); graphics2D.FillRectangle(0, 0, ViewOnlyTexture.Width / 2, ViewOnlyTexture.Height, Color.LightGray); // request the texture so we can set it to repeat var plugin = ImageGlPlugin.GetImageGlPlugin(ViewOnlyTexture, true, true, false); }); } iavMappings.Add(typeof(ImageObject3D), new List <InteractionVolume> { new MoveInZControl(this) }); // Register listeners sceneContext.Scene.SelectionChanged += this.Scene_SelectionChanged; }
public Object3DControlsLayer(ISceneContext sceneContext, ThemeConfig theme, EditorType editorType = EditorType.Part) { this.sceneContext = sceneContext; this.EditorMode = editorType; scene = sceneContext.Scene; gCodeMeshColor = new Color(theme.PrimaryAccentColor, 35); BuildVolumeColor = new ColorF(.2, .8, .3, .2).ToColor(); floorDrawable = new FloorDrawable(editorType, sceneContext, this.BuildVolumeColor, theme); if (viewOnlyTexture == null) { // TODO: What is the ViewOnlyTexture??? UiThread.RunOnIdle(() => { viewOnlyTexture = new ImageBuffer(32, 32, 32); var graphics2D = viewOnlyTexture.NewGraphics2D(); graphics2D.Clear(Color.White); graphics2D.FillRectangle(0, 0, viewOnlyTexture.Width / 2, viewOnlyTexture.Height, Color.LightGray); // request the texture so we can set it to repeat ImageGlPlugin.GetImageGlPlugin(viewOnlyTexture, true, true, false); }); } // Register listeners sceneContext.Scene.SelectionChanged += this.Scene_SelectionChanged; if (sceneContext.Printer != null) { sceneContext.Printer.Settings.SettingChanged += this.Settings_SettingChanged; } }
private void TextureFace(int face, string name, Matrix4X4?initialRotation = null) { var sourceTexture = new ImageBuffer(256, 256); var graphics = sourceTexture.NewGraphics2D(); graphics.Clear(theme.BedColor); graphics.DrawString(name, sourceTexture.Width / 2, sourceTexture.Height / 2, 60, justification: Agg.Font.Justification.Center, baseline: Agg.Font.Baseline.BoundsCenter, color: theme.TextColor); graphics.Render(new Stroke(new RoundedRect(.5, .5, 254.5, 254.4, 0), 6), theme.BedGridColors.Line); var activeTexture = new ImageBuffer(sourceTexture); ImageGlPlugin.GetImageGlPlugin(activeTexture, true); var faces = cube.GetCoplanerFaces(face); cube.PlaceTextureOnFaces(faces, activeTexture, cube.GetMaxPlaneProjection(faces, activeTexture, initialRotation)); textureDatas.Add(new TextureData() { source = sourceTexture, active = activeTexture }); }
public void DisplaySizeInfo(Graphics2D graphics2D, Vector2 widthDisplayCenter, double size) { string displayString = formatString.FormatWith(size); if (measureDisplayImage == null || measureDisplayedString != displayString) { measureDisplayedString = displayString; TypeFacePrinter printer = new TypeFacePrinter(measureDisplayedString, 16); TypeFacePrinter unitPrinter = new TypeFacePrinter(unitsString, 10); Double unitPrinterOffset = 1; BorderDouble margin = new BorderDouble(5); printer.Origin = new Vector2(margin.Left, margin.Bottom); RectangleDouble bounds = printer.LocalBounds; unitPrinter.Origin = new Vector2(bounds.Right + unitPrinterOffset, margin.Bottom); RectangleDouble unitPrinterBounds = unitPrinter.LocalBounds; measureDisplayImage = new ImageBuffer((int)(bounds.Width + margin.Width + unitPrinterBounds.Width + unitPrinterOffset), (int)(bounds.Height + margin.Height)); // make sure the texture has mipmaps (so it can reduce well) ImageGlPlugin glPlugin = ImageGlPlugin.GetImageGlPlugin(measureDisplayImage, true); Graphics2D widthGraphics = measureDisplayImage.NewGraphics2D(); widthGraphics.Clear(new RGBA_Bytes(RGBA_Bytes.White, 128)); printer.Render(widthGraphics, RGBA_Bytes.Black); unitPrinter.Render(widthGraphics, RGBA_Bytes.Black); } widthDisplayCenter -= new Vector2(measureDisplayImage.Width / 2, measureDisplayImage.Height / 2); graphics2D.Render(measureDisplayImage, widthDisplayCenter); }
public GCode2DWidget(PrinterConfig printer, ThemeConfig theme) { this.printer = printer; options = printer.Bed.RendererOptions; this.LocalBounds = new RectangleDouble(0, 0, 100, 100); this.AnchorAll(); // Register listeners printer.Bed.LoadedGCodeChanged += LoadedGCodeChanged; printer.Settings.SettingChanged += Printer_SettingChanged; Printer_SettingChanged(this, null); this.gridSizeMm = printer.Settings.GetValue <Vector2>(SettingsKey.bed_size); this.gridCenterMm = printer.Settings.GetValue <Vector2>(SettingsKey.print_center); // Acquire the bed image bedImage = BedMeshGenerator.CreatePrintBedImage(printer); // Create a semi-transparent overlay with the theme color var overlay = new ImageBuffer(bedImage.Width, bedImage.Height); overlay.NewGraphics2D().Clear(new Color(theme.BackgroundColor, 100)); // Render the overlay onto the bedImage to tint it and reduce its default overbearing light on dark contrast bedImage.NewGraphics2D().Render(overlay, 0, 0); // Preload GL texture for 2D bed image and use MipMaps UiThread.RunOnIdle(() => { ImageGlPlugin.GetImageGlPlugin(bedImage, createAndUseMipMaps: true); }); }
private static void TextureFace(Face face, string name, Matrix4X4?initialRotation = null) { ImageBuffer textureToUse = new ImageBuffer(256, 256); var frontGraphics = textureToUse.NewGraphics2D(); frontGraphics.Clear(Color.White); frontGraphics.DrawString(name, textureToUse.Width / 2, textureToUse.Height / 2, 60, justification: Agg.Font.Justification.Center, baseline: Agg.Font.Baseline.BoundsCenter); frontGraphics.Render(new Stroke(new RoundedRect(.5, .5, 254.5, 254.4, 0), 6), Color.DarkGray); ImageGlPlugin.GetImageGlPlugin(textureToUse, true); MeshHelper.PlaceTextureOnFace(face, textureToUse, MeshHelper.GetMaxFaceProjection(face, textureToUse, initialRotation)); }
public MeshViewerWidget(BedConfig sceneContext, InteractionLayer interactionLayer, string startingTextMessage = "", EditorType editorType = EditorType.Part) { this.EditorMode = editorType; this.scene = sceneContext.Scene; this.sceneContext = sceneContext; this.interactionLayer = interactionLayer; this.World = interactionLayer.World; var theme = ApplicationController.Instance.Theme; gridColors = new GridColors() { Gray = theme.ResolveColor(theme.ActiveTabColor, theme.GetBorderColor((theme.Colors.IsDarkTheme ? 35 : 55))), Red = theme.ResolveColor(theme.ActiveTabColor, new Color(Color.Red, (theme.Colors.IsDarkTheme ? 105 : 170))), Green = theme.ResolveColor(theme.ActiveTabColor, new Color(Color.Green, (theme.Colors.IsDarkTheme ? 105 : 170))), Blue = theme.ResolveColor(theme.ActiveTabColor, new Color(Color.Blue, 195)) }; gCodeMeshColor = new Color(theme.Colors.PrimaryAccentColor, 35); scene.SelectionChanged += (sender, e) => { Invalidate(); lastSelectionChangedMs = UiThread.CurrentTimerMs; }; BedColor = new ColorF(.8, .8, .8, .7).ToColor(); BuildVolumeColor = new ColorF(.2, .8, .3, .2).ToColor(); this.interactionLayer.DrawGlTransparentContent += Draw_GlTransparentContent; if (ViewOnlyTexture == null) { UiThread.RunOnIdle(() => { ViewOnlyTexture = new ImageBuffer(32, 32, 32); var graphics2D = ViewOnlyTexture.NewGraphics2D(); graphics2D.Clear(Color.White); graphics2D.FillRectangle(0, 0, ViewOnlyTexture.Width / 2, ViewOnlyTexture.Height, Color.LightGray); // request the texture so we can set it to repeat var plugin = ImageGlPlugin.GetImageGlPlugin(ViewOnlyTexture, true, true, false); }); } }
public MeshViewerWidget(BedConfig sceneContext, InteractionLayer interactionLayer, ThemeConfig theme, EditorType editorType = EditorType.Part) { this.EditorMode = editorType; this.scene = sceneContext.Scene; this.sceneContext = sceneContext; this.interactionLayer = interactionLayer; this.World = interactionLayer.World; this.theme = theme; gridColors = new GridColors() { Gray = theme.ResolveColor(theme.BackgroundColor, theme.GetBorderColor((theme.IsDarkTheme ? 35 : 55))), Red = theme.ResolveColor(theme.BackgroundColor, new Color(Color.Red, (theme.IsDarkTheme ? 105 : 170))), Green = theme.ResolveColor(theme.BackgroundColor, new Color(Color.Green, (theme.IsDarkTheme ? 105 : 170))), Blue = theme.ResolveColor(theme.BackgroundColor, new Color(Color.Blue, 195)) }; gCodeMeshColor = new Color(theme.PrimaryAccentColor, 35); // Register listeners scene.SelectionChanged += selection_Changed; BuildVolumeColor = new ColorF(.2, .8, .3, .2).ToColor(); this.interactionLayer.DrawGlTransparentContent += Draw_GlTransparentContent; if (ViewOnlyTexture == null) { // TODO: What is the ViewOnlyTexture??? UiThread.RunOnIdle(() => { ViewOnlyTexture = new ImageBuffer(32, 32, 32); var graphics2D = ViewOnlyTexture.NewGraphics2D(); graphics2D.Clear(Color.White); graphics2D.FillRectangle(0, 0, ViewOnlyTexture.Width / 2, ViewOnlyTexture.Height, Color.LightGray); // request the texture so we can set it to repeat var plugin = ImageGlPlugin.GetImageGlPlugin(ViewOnlyTexture, true, true, false); }); } }
public static ImageBuffer CreatePrintBedImage(PrinterConfig printer) { ImageBuffer bedImage; switch (printer.Bed.BedShape) { case BedShape.Rectangular: bedImage = CreateRectangularBedGridImage(printer); break; case BedShape.Circular: bedImage = CreateCircularBedGridImage(printer); break; default: throw new NotImplementedException(); } // Preload GL texture for 2D bed image and use MipMaps ImageGlPlugin.GetImageGlPlugin(bedImage, createAndUseMipMaps: true); return(bedImage); }
public new void MakeCurrent() { currentControl = this; base.MakeCurrent(); ImageGlPlugin.SetCurrentContextData(Id, releaseAllGlData); }