using FeMM.Common.Models;
using FeMM.Grasshopper.DataTypes.FeMM;
using FeMM.Grasshopper.Helpers;
using Grasshopper.Kernel;
using System;
namespace FeMM.Grasshopper.Components.Definitions
{
public class StoryComponent : GH_Component
{
/// <summary>
/// Initializes a new instance of the SuperElementComponent class.
/// </summary>
public StoryComponent()
: base("Story", "St", "Defines story to be used in ETABS", CategoryNameConstants.CATEGORY_FEMM, CategoryNameConstants.SUBCATEGORY_DEFINITIONS)
{
}
/// <summary>
/// Registers all the input parameters for this component.
/// </summary>
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddTextParameter("Name", "N", "The name of the story", GH_ParamAccess.item);
pManager.AddNumberParameter("Height", "H", "The height of the story", GH_ParamAccess.item);
pManager.AddBooleanParameter("Master story", "M", "Is it a master story?", GH_ParamAccess.item, false);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddNumberParameter("Splice Height", "Sp", "The story splice height", GH_ParamAccess.item, 0);
pManager[pManager.ParamCount - 1].Optional = true;
}
/// <summary>
/// Registers all the output parameters for this component.
/// </summary>
protected override void RegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddGenericParameter("Story", "St", "The story", GH_ParamAccess.item);
}
/// <summary>
/// This is the method that actually does the work.
/// </summary>
/// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
protected override void SolveInstance(IGH_DataAccess DA)
{
string name = null;
double height = 0;
bool isMaster = false;
double spliceHeight = 0;
if (!DA.GetData(0, ref name))
return;
if (!DA.GetData(1, ref height))
return;
if (!DA.GetData(2, ref isMaster))
return;
if (!DA.GetData(3, ref spliceHeight))
return;
var sm = new StoryModel()
{
Name = name,
Height = height,
MasterStory = isMaster,
SpliceHeight = spliceHeight,
SpliceAbove = spliceHeight > 0 ? true : false,
};
var gH_Story = new GH_FunctionDefinition(sm);
DA.SetData(0, gH_Story);
}
public override GH_Exposure Exposure => GH_Exposure.tertiary;
/// <summary>
/// Provides an Icon for the component.
/// </summary>
protected override System.Drawing.Bitmap Icon => Properties.Resources.StoryIcon;
/// <summary>
/// Gets the unique ID for this component. Do not change this ID after release.
/// </summary>
public override Guid ComponentGuid => new("CEEE65B4-2E67-432B-9178-B486047FE0AF");
}
}