Skip to content

Commit

Permalink
Hide out -> out Rules from UI
Browse files Browse the repository at this point in the history
  • Loading branch information
janper committed Apr 24, 2021
1 parent 1095811 commit 1e17948
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
5 changes: 1 addition & 4 deletions Components/RulePreview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@ protected override void RegisterInputParams(GH_Component.GH_InputParamManager pM
"M",
"Monoceros Modules",
GH_ParamAccess.list);
// TODO: Change to tree access and process each branch individually
pManager.AddParameter(new RuleParameter(),
"Rules",
"R",
"All existing Monoceros Rules",
GH_ParamAccess.list);
pManager[0].Optional = true;
pManager[1].Optional = true;
}

/// <summary>
Expand Down Expand Up @@ -241,8 +240,6 @@ out Axis axis

}

public new bool Hidden => false;

public override bool IsPreviewCapable => !Hidden && !Locked;

public override void DrawViewportWires(IGH_PreviewArgs args) {
Expand Down
6 changes: 5 additions & 1 deletion Components/RuleUnwrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ protected override void SolveInstance(IGH_DataAccess DA) {
var rulesExplicit = rulesClean
.Where(rule => rule != null && rule.IsExplicit);

var rulesDeduplicated = rulesExplicit.Concat(rulesTypedUnwrapped).Distinct().ToList();
var rulesDeduplicated = rulesExplicit
.Concat(rulesTypedUnwrapped)
.Distinct()
.Where(rule => !(rule.IsExplicit && rule.Explicit.SourceModuleName == Config.OUTER_MODULE_NAME && rule.Explicit.TargetModuleName == Config.OUTER_MODULE_NAME))
.ToList();
rulesDeduplicated.Sort();

if (!rulesDeduplicated.Any()) {
Expand Down
27 changes: 16 additions & 11 deletions Components/RulesCollect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,25 +83,27 @@ protected override void SolveInstance(IGH_DataAccess DA) {
}



var allowedOriginalClean = allowed.Where(rule => rule.IsValidWithModules(modulesClean)).Distinct();

if (disallowed == null || !disallowed.Any()) {
var earlyRules = allowedOriginalClean.ToList();
earlyRules.Sort();
DA.SetDataList(0, earlyRules);
return;
}

Module.GenerateEmptySingleModule(Config.OUTER_MODULE_NAME,
Config.INDIFFERENT_TAG,
new Rhino.Geometry.Vector3d(1, 1, 1),
out var moduleOut,
out var rulesOut);
allowed.AddRange(

var allowedClean = allowedOriginalClean.Concat(
rulesOut.Select(ruleExplicit => new Rule(ruleExplicit))
);
modulesClean.Add(moduleOut);

var allowedClean = allowed.Where(rule => rule.IsValidWithModules(modulesClean)).Distinct();

if (disallowed == null || !disallowed.Any()) {
var earlyRules = allowedClean.ToList();
earlyRules.Sort();
DA.SetDataList(0, earlyRules);
return;
}

if (disallowed.Any(rule => rule == null)) {
AddRuntimeMessage(GH_RuntimeMessageLevel.Error,
"Some of the disallowed rules are null or invalid.");
Expand Down Expand Up @@ -142,7 +144,10 @@ protected override void SolveInstance(IGH_DataAccess DA) {
var outExplicit = allAllowed
.Distinct()
.Except(allDisallowed.Distinct());
var outRules = outExplicit.Select(explicitRule => new Rule(explicitRule)).ToList();
var outRules = outExplicit
.Where(rule => !(rule.SourceModuleName == Config.OUTER_MODULE_NAME && rule.TargetModuleName == Config.OUTER_MODULE_NAME))
.Select(explicitRule => new Rule(explicitRule))
.ToList();
outRules.Sort();

foreach (var rule in outRules) {
Expand Down
Binary file modified bin/Monoceros.pdb
Binary file not shown.

0 comments on commit 1e17948

Please sign in to comment.