Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align to changes required for Representation System #600

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions Grasshopper_UI/Goos/GH_BakeableObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
using GH_IO.Serialization;
using BH.Engine.Serialiser;
using BH.Engine.Reflection;
using System.Drawing;

namespace BH.UI.Grasshopper.Goos
{
Expand Down Expand Up @@ -154,7 +155,7 @@ public override bool Read(GH_IReader reader)
return false;
}
}


return true;
}
Expand All @@ -173,15 +174,15 @@ public override bool Write(GH_IWriter writer)
public virtual void DrawViewportMeshes(GH_PreviewMeshArgs args)
{
if (m_RhinoGeometry != null)
Render.IRenderRhinoMeshes(m_RhinoGeometry, args);
Render.IRenderRhinoMeshes(m_RhinoGeometry, args, m_Color);
}

/***************************************************/

public virtual void DrawViewportWires(GH_PreviewWireArgs args)
{
if (m_RhinoGeometry != null)
Render.IRenderRhinoWires(m_RhinoGeometry, args);
Render.IRenderRhinoWires(m_RhinoGeometry, args, m_Color);
}


Expand All @@ -195,6 +196,14 @@ private bool SetGeometry()
{
return true;
}
else if (Value is IRepresentation)
{
m_RhinoGeometry = (Value as IRepresentation).IToRhino();
m_Color = (Value as IRepresentation).Colour;
if(Value is GeometricalRepresentation)
m_Geometry = (Value as GeometricalRepresentation).Geometry;
return true;
}
else if (Value is BHoMObject)
{
m_Geometry = (Value as BHoMObject).IGeometry();
Expand All @@ -205,6 +214,7 @@ private bool SetGeometry()
{
m_Geometry = Value as IGeometry;
m_RhinoGeometry = m_Geometry.IToRhino();
m_Color = Color.FromArgb(80, 255, 41, 105);//BHoM pink!
return true;
}
else
Expand Down Expand Up @@ -266,8 +276,8 @@ public bool BakeGeometry(RhinoDoc doc, ObjectAttributes att, out Guid obj_guid)

protected object m_RhinoGeometry = null;

protected Color m_Color = new Color();

/***************************************************/
}
}


}
4 changes: 2 additions & 2 deletions Grasshopper_UI/Render/RenderColour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ public static partial class Render
/**** Public Methods ****/
/***************************************************/

public static Color RenderColour(Color ghColour)
public static Color RenderColour(Color ghColour, Color custom)
{
Color pColour = GH.Instances.ActiveCanvas.Document.PreviewColour;
if (ghColour.R == pColour.R & // If the color sent by PreviewArgs is the default object PreviewColour
ghColour.G == pColour.G &
ghColour.B == pColour.B) // Excluding Alpha channel from comparison
{
return Color.FromArgb(80, 255, 41, 105);
return custom;
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions Grasshopper_UI/Render/RenderMaterial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ public static partial class Render
/**** Public Methods ****/
/***************************************************/

public static DisplayMaterial RenderMaterial(DisplayMaterial material)
public static DisplayMaterial RenderMaterial(DisplayMaterial material, Color custom)
{
Color pColour = GH.Instances.ActiveCanvas.Document.PreviewColour;
Color ghColour = material.Diffuse;
if (ghColour.R == pColour.R & // If the color sent by PreviewArgs is the default object PreviewColour
ghColour.G == pColour.G &
ghColour.B == pColour.B) // Excluding Alpha channel from comparison
{
return new DisplayMaterial(Color.FromArgb(255, 255, 41, 105), 0.6);
return new DisplayMaterial(custom, 0.6);//transparency hard coded but eventually we should have full material props in represenatation
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Grasshopper_UI/Render/RenderMeshes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static void IRenderMeshes(this BHG.IGeometry geometry, GH_PreviewMeshArgs
{
return;
}
DisplayMaterial bhMaterial = RenderMaterial(args.Material);
DisplayMaterial bhMaterial = RenderMaterial(args.Material, Color.FromArgb(80, 255, 41, 105));//BHoM pink!
try
{
RenderMeshes(geometry as dynamic, args.Pipeline, bhMaterial);
Expand Down
13 changes: 7 additions & 6 deletions Grasshopper_UI/Render/RenderRhinoMeshes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
using System;
using BH.oM.Reflection.Attributes;
using System.Collections.Generic;
using BH.oM.Geometry;
using System.Drawing;
using BH.Engine.Rhinoceros;

namespace BH.UI.Grasshopper
{
Expand All @@ -35,17 +38,17 @@ public static partial class Render
/**** Public Methods - Interfaces ****/
/***************************************************/

public static void IRenderRhinoMeshes(this object geometry, GH_PreviewMeshArgs args)
public static void IRenderRhinoMeshes(this object obj, GH_PreviewMeshArgs args, Color custom)
{
if (geometry == null)
if (obj == null)
{
return;
}
DisplayMaterial bhMaterial = RenderMaterial(args.Material);
DisplayMaterial material = RenderMaterial(args.Material, custom);

try
{
RenderRhinoMeshes(geometry as dynamic, args.Pipeline, bhMaterial);
RenderRhinoMeshes(obj as dynamic, args.Pipeline, material);
}
catch (Exception) { }
}
Expand Down Expand Up @@ -155,8 +158,6 @@ public static void RenderRhinoMeshes(RHG.BoundingBox bbBox, Rhino.Display.Displa
{
pipeline.DrawBrepShaded(bbBox.ToBrep(), material);
}

/***************************************************/
}
}

Expand Down
19 changes: 16 additions & 3 deletions Grasshopper_UI/Render/RenderRhinoWires.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
using BH.oM.Reflection.Attributes;
using System.Collections.Generic;
using GH = Grasshopper;
using BH.oM.Base;
using BH.oM.Geometry;
using BH.Engine.Rhinoceros;

namespace BH.UI.Grasshopper
{
Expand All @@ -37,13 +40,13 @@ public static partial class Render
/**** Public Methods - Interfaces ****/
/***************************************************/

public static void IRenderRhinoWires(this object geometry, GH_PreviewWireArgs args)
public static void IRenderRhinoWires(this object geometry, GH_PreviewWireArgs args, Color custom)
{
if (geometry == null)
{
return;
}
Color bhColour = RenderColour(args.Color);
Color bhColour = RenderColour(args.Color, custom);
try
{
RenderRhinoWires(geometry as dynamic, args.Pipeline, bhColour);
Expand Down Expand Up @@ -171,7 +174,6 @@ public static void RenderRhinoWires(RHG.PolylineCurve polyline, Rhino.Display.Di
pipeline.DrawPolyline(poly, bhColour, 2);
}


/***************************************************/
/**** Public Methods - Surfaces ****/
/***************************************************/
Expand Down Expand Up @@ -249,6 +251,17 @@ public static void RenderRhinoWires(RHG.BoundingBox bbBox, Rhino.Display.Display
pipeline.DrawBox(bbBox, bhColour, 2);
}


/***************************************************/
/**** Public Methods - Representations ****/
/***************************************************/

public static void RenderRhinoWires(Text3d text3D, Rhino.Display.DisplayPipeline pipeline, Color bhColour)
{

pipeline.Draw3dText(text3D, bhColour, text3D.TextPlane);
}

/***************************************************/
}
}
Expand Down
2 changes: 1 addition & 1 deletion Grasshopper_UI/Render/RenderWires.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static void IRenderWires(this BHG.IGeometry geometry, GH_PreviewWireArgs
{
return;
}
Color bhColour = RenderColour(args.Color);
Color bhColour = RenderColour(args.Color, Color.FromArgb(80, 255, 41, 105));//BHoM pink!
try
{
RenderWires(geometry as dynamic, args.Pipeline, bhColour);
Expand Down