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 StoryBaseElevationComponent : GH_Component
    {
        /// <summary>
        /// Initializes a new instance of the SuperElementComponent class.
        /// </summary>
        public StoryBaseElevationComponent()
          : base("Base Elevation", "BE", "Defines stories base elevation 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.AddNumberParameter("Base Elevation", "BE", "Defines stories base elevation to be used in ETABS", GH_ParamAccess.item);
        }

        /// <summary>
        /// Registers all the output parameters for this component.
        /// </summary>
        protected override void RegisterOutputParams(GH_OutputParamManager pManager)
        {
            pManager.AddGenericParameter("Base Elevation", "BE", "The stories base elevation", 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)
        {
            double height = 0;

            if (!DA.GetData(0, ref height))
                return;

            var sm = new StoryBaseElevationModel()
            {
                BaseElevation = height,
            };

            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("296393a6-e992-4b9c-8983-d8482e0be6e4");
    }
}
303 files24 directories