Pass graphics 2D to 3D render calls so we can draw to the screen
This commit is contained in:
parent
e393163848
commit
ab41b7c1a7
8 changed files with 24 additions and 37 deletions
|
|
@ -145,7 +145,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
InteractionContext.GuiSurface.AfterDraw += InteractionLayer_AfterDraw;
|
||||
}
|
||||
|
||||
public override void DrawGlContent(EventArgs e)
|
||||
public override void DrawGlContent(DrawGlContentEventArgs e)
|
||||
{
|
||||
bool shouldDrawScaleControls = true;
|
||||
if (InteractionContext.SelectedInteractionVolume != null
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
return demoShadowMesh;
|
||||
}
|
||||
|
||||
public override void DrawGlContent(EventArgs e)
|
||||
public override void DrawGlContent(DrawGlContentEventArgs e)
|
||||
{
|
||||
if (InteractionContext.Scene.HasSelection
|
||||
&& InteractionContext.Scene.ShowSelectionShadow)
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
public InteractiveScene Scene { get; }
|
||||
|
||||
public event EventHandler DrawGlContent;
|
||||
public event EventHandler<DrawEventArgs> DrawGlContent;
|
||||
|
||||
public bool DoOpenGlDrawing { get; set; } = true;
|
||||
|
||||
|
|
@ -134,7 +134,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
if (DoOpenGlDrawing)
|
||||
{
|
||||
SetGlContext();
|
||||
OnDrawGlContent();
|
||||
OnDrawGlContent(e);
|
||||
UnsetGlContext();
|
||||
}
|
||||
}
|
||||
|
|
@ -304,9 +304,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
public GuiWidget GuiSurface => this;
|
||||
|
||||
private void OnDrawGlContent()
|
||||
private void OnDrawGlContent(DrawEventArgs e)
|
||||
{
|
||||
DrawGlContent?.Invoke(this, null);
|
||||
DrawGlContent?.Invoke(this, e);
|
||||
}
|
||||
|
||||
private void SetGlContext()
|
||||
|
|
|
|||
|
|
@ -126,11 +126,7 @@ namespace MatterHackers.MeshVisualizer
|
|||
return cornerPosition;
|
||||
}
|
||||
|
||||
public virtual void Draw2DContent(Agg.Graphics2D graphics2D)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void DrawGlContent(EventArgs e)
|
||||
public virtual void DrawGlContent(DrawGlContentEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,11 +50,12 @@ namespace MatterHackers.MeshVisualizer
|
|||
{
|
||||
public enum BedShape { Rectangular, Circular };
|
||||
|
||||
public class DrawGlContentEventArgs : EventArgs
|
||||
public class DrawGlContentEventArgs : DrawEventArgs
|
||||
{
|
||||
public bool ZBuffered { get; }
|
||||
|
||||
public DrawGlContentEventArgs(bool zBuffered)
|
||||
public DrawGlContentEventArgs(bool zBuffered, DrawEventArgs e)
|
||||
: base(e.graphics2D)
|
||||
{
|
||||
ZBuffered = zBuffered;
|
||||
}
|
||||
|
|
@ -356,22 +357,9 @@ namespace MatterHackers.MeshVisualizer
|
|||
base.OnClosed(e);
|
||||
}
|
||||
|
||||
public override void OnDraw(Graphics2D graphics2D)
|
||||
{
|
||||
base.OnDraw(graphics2D);
|
||||
|
||||
//if (!SuppressUiVolumes)
|
||||
{
|
||||
foreach (InteractionVolume interactionVolume in interactionLayer.InteractionVolumes)
|
||||
{
|
||||
interactionVolume.Draw2DContent(graphics2D);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsActive { get; set; } = true;
|
||||
|
||||
private void DrawObject(IObject3D object3D, Matrix4X4 transform, bool parentSelected)
|
||||
private void DrawObject(IObject3D object3D, Matrix4X4 transform, bool parentSelected, DrawEventArgs e)
|
||||
{
|
||||
foreach(MeshRenderData renderData in object3D.VisibleMeshes(transform))
|
||||
{
|
||||
|
|
@ -430,6 +418,8 @@ namespace MatterHackers.MeshVisualizer
|
|||
var transformed2 = Vector3.Transform(meshEdge.VertexOnEnd[1].Position, renderData.Matrix);
|
||||
|
||||
GLHelper.Render3DLineNoPrep(frustum, World, transformed1, transformed2, RGBA_Bytes.White, selectionHighlightWidth);
|
||||
|
||||
e.graphics2D.Circle(transformed1.x, transformed1.y, 5, RGBA_Bytes.Red);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -488,11 +478,11 @@ namespace MatterHackers.MeshVisualizer
|
|||
|
||||
public EditorType EditorMode { get; set; } = EditorType.Part;
|
||||
|
||||
private void trackballTumbleWidget_DrawGlContent(object sender, EventArgs e)
|
||||
private void trackballTumbleWidget_DrawGlContent(object sender, DrawEventArgs e)
|
||||
{
|
||||
foreach(var object3D in scene.Children)
|
||||
{
|
||||
DrawObject(object3D, Matrix4X4.Identity, false);
|
||||
DrawObject(object3D, Matrix4X4.Identity, false, e);
|
||||
}
|
||||
|
||||
if (this.EditorMode == EditorType.Printer)
|
||||
|
|
@ -565,7 +555,7 @@ namespace MatterHackers.MeshVisualizer
|
|||
DrawInteractionVolumes(e);
|
||||
}
|
||||
|
||||
private void DrawInteractionVolumes(EventArgs e)
|
||||
private void DrawInteractionVolumes(DrawEventArgs e)
|
||||
{
|
||||
if(SuppressUiVolumes)
|
||||
{
|
||||
|
|
@ -578,7 +568,7 @@ namespace MatterHackers.MeshVisualizer
|
|||
if (interactionVolume.DrawOnTop)
|
||||
{
|
||||
GL.Disable(EnableCap.DepthTest);
|
||||
interactionVolume.DrawGlContent(new DrawGlContentEventArgs(false));
|
||||
interactionVolume.DrawGlContent(new DrawGlContentEventArgs(false, e));
|
||||
GL.Enable(EnableCap.DepthTest);
|
||||
}
|
||||
}
|
||||
|
|
@ -586,7 +576,7 @@ namespace MatterHackers.MeshVisualizer
|
|||
// Draw again setting the depth buffer and ensuring that all the interaction objects are sorted as well as we can
|
||||
foreach (InteractionVolume interactionVolume in interactionLayer.InteractionVolumes)
|
||||
{
|
||||
interactionVolume.DrawGlContent(new DrawGlContentEventArgs(true));
|
||||
interactionVolume.DrawGlContent(new DrawGlContentEventArgs(true, e));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -572,7 +572,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
}
|
||||
}
|
||||
|
||||
private void TrackballTumbleWidget_DrawGlContent(object sender, EventArgs e)
|
||||
private void TrackballTumbleWidget_DrawGlContent(object sender, DrawEventArgs e)
|
||||
{
|
||||
// This shows the BVH as rects around the scene items
|
||||
//Scene?.TraceData().RenderBvhRecursive(0, 3);
|
||||
|
|
@ -582,7 +582,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
return;
|
||||
}
|
||||
|
||||
printer.Bed.Render3DLayerFeatures();
|
||||
printer.Bed.Render3DLayerFeatures(e);
|
||||
}
|
||||
|
||||
public override void OnKeyDown(KeyEventArgs keyEvent)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue