Skip to content

Commit

Permalink
Merge branch 'main' into task/GSAGH-386-fix-double.NaN
Browse files Browse the repository at this point in the history
  • Loading branch information
kpne authored Oct 6, 2023
2 parents c4fa90d + 9804fb7 commit 74bf906
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
4 changes: 3 additions & 1 deletion GsaGH/Components/6_Display/LoadDiagrams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Grasshopper.Kernel;
using Grasshopper.Kernel.Types;
using GsaAPI;
using GsaGH.Helpers;
using GsaGH.Helpers.GH;
using GsaGH.Helpers.GsaApi;
using GsaGH.Helpers.GsaApi.Grahics;
Expand All @@ -21,6 +22,7 @@
using OasysGH.Units;
using OasysGH.Units.Helpers;
using OasysUnits;
using Rhino.Commands;
using Rhino.Geometry;
using DiagramType = GsaAPI.DiagramType;
using ForceUnit = OasysUnits.Units.ForceUnit;
Expand Down Expand Up @@ -320,7 +322,7 @@ double computedScale
da.SetDataList(0, diagramLines);
da.SetDataList(1, diagramAnnotations);

//PostHog.Result(modelGoo.Value.Model.case, 1, "Diagram", type.ToString());
PostHog.Diagram("Load", _caseId, _selectedItems[1], types, Parameters.EntityType.Element);
}

private bool IsGhObjectValid(GsaModelGoo modelGoo) {
Expand Down
12 changes: 6 additions & 6 deletions GsaGH/Components/6_Display/ResultDiagrams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,11 @@ string warningText
$"Model came straight out of GSA and we couldn't read the units. The geometry has been scaled to be in {lengthUnit}. This can be changed by right-clicking the component -> 'Select Units'");
}

DiagramType type = _selectedItems[0] == "Force" ?
Mappings.diagramTypeMappingForce.Where(item => item.Description == _selectedItems[1])
.Select(item => item.GsaApiEnum).FirstOrDefault() : Mappings.diagramTypeMappingStress
.Where(item => item.Description == _selectedItems[1]).Select(item => item.GsaApiEnum)
.FirstOrDefault();
DiagramType type = _selectedItems[0] == "Force"
? Mappings.diagramTypeMappingForce.Where(item => item.Description == _selectedItems[1])
.Select(item => item.GsaApiEnum).FirstOrDefault()
: Mappings.diagramTypeMappingStress.Where(item => item.Description == _selectedItems[1])
.Select(item => item.GsaApiEnum).FirstOrDefault();

double unitScale = ComputeUnitScale(autoScale);
double computedScale
Expand Down Expand Up @@ -283,7 +283,7 @@ double computedScale
da.SetDataList(0, diagramLines);
da.SetDataList(1, diagramAnnotations);

PostHog.Result(result.Type, 1, "Diagram", type.ToString());
PostHog.Diagram("Result", result.Type, _selectedItems[0], type.ToString(), Parameters.EntityType.Element);
}

private List<GsaAnnotationGoo> GenerateAnnotations(
Expand Down
27 changes: 27 additions & 0 deletions GsaGH/Helpers/PostHog.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Data;
using GsaGH.Parameters;
using GsaGH.Parameters.Enums;

Expand All @@ -10,6 +11,32 @@ internal static void Debug(Dictionary<string, object> properties) {
_ = OasysGH.Helpers.PostHog.SendToPostHog(PluginInfo.Instance, eventName, properties);
}

internal static void Diagram(string diagramType, CaseType caseType, string type, string subTypes, EntityType entityType) {
const string eventName = "Diagram";
var properties = new Dictionary<string, object>() {
{
"diagramType", diagramType
}, {
"caseType", caseType.ToString()
}, {
"type", type
}, {
"subType", subTypes
}, {
"entityType", entityType.ToString()
},
};
_ = OasysGH.Helpers.PostHog.SendToPostHog(PluginInfo.Instance, eventName, properties);
}

internal static void Diagram(
string diagramType, string caseId, string type, List<GsaAPI.DiagramType> subTypes, EntityType entityType) {
CaseType caseType = caseId.StartsWith("L") ? CaseType.Load
: caseId.StartsWith("A") ? CaseType.AnalysisCase : CaseType.Combination;
List<string> subType = subTypes.ConvertAll(x => x.ToString());
Diagram(diagramType, caseType, type, string.Join(";", subTypes), entityType);
}

internal static void Gwa(string gwa, bool existingModel) {
string[] commands = gwa.Split('\n');
foreach (string command in commands) {
Expand Down
1 change: 1 addition & 0 deletions GsaGH/Parameters/Enums/CaseType.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace GsaGH.Parameters {
public enum CaseType {
Load,
AnalysisCase,
Combination
}
Expand Down

0 comments on commit 74bf906

Please sign in to comment.