private void Mode5Clicked() { if (_mode == FoldMode.CurvedShell) { return; } RecordUndoEvent("Curved Shell Parameters"); if (_mode == FoldMode.LoadPanel || _mode == FoldMode.Fabric) { //remove input parameters while (Params.Input.Count > 3) { Params.UnregisterInputParameter(Params.Input[3], true); } //register input parameter Params.RegisterInputParam(new Param_Integer()); Params.RegisterInputParam(new Param_String()); Params.RegisterInputParam(new Param_Integer()); Params.RegisterInputParam(new Param_Integer()); Params.RegisterInputParam(new Param_Number()); } _mode = FoldMode.CurvedShell; (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); Params.OnParametersChanged(); ExpireSolution(true); }
private void Mode7Clicked() { FoldMode myMode = FoldMode.Angle; //if (_mode == myMode) // return; RecordUndoEvent(myMode.ToString() + " Parameter"); // set number of input parameters int param = 4; //remove input parameters while (Params.Input.Count > param) { Params.UnregisterInputParameter(Params.Input[param], true); } //register input parameter while (Params.Input.Count < param) { Params.RegisterInputParam(new Param_Number()); } _mode = myMode; (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); Params.OnParametersChanged(); ExpireSolution(true); }
public override bool Read(GH_IO.Serialization.GH_IReader reader) { _mode = (FoldMode)reader.GetInt32("Mode"); _disp = (DisplayValue)reader.GetInt32("Display"); slider = reader.GetBoolean("slider"); noDigits = reader.GetInt32("noDec"); MaxValue = reader.GetDouble("valMax"); MinValue = reader.GetDouble("valMin"); Value = reader.GetDouble("val"); dropdowncontents = new List <List <string> >(); dropdowncontents.Add(dropdownitems); if (_mode == FoldMode.Displacement) { dropdowncontents.Add(dropdowndisplacement); } if (_mode == FoldMode.Stress) { dropdowncontents.Add(dropdownstress); } selections = new List <string>(); selections.Add(dropdowncontents[0][(int)_mode]); selections.Add(dropdowncontents[1][(int)_disp]); first = false; this.CreateAttributes(); return(base.Read(reader)); }
private void Mode5Clicked() { if (_mode == FoldMode.Trilinear) { return; } RecordUndoEvent("Trilinear Parameters"); if (_mode != FoldMode.Patch) { //remove input parameters while (Params.Input.Count > 7) { Params.UnregisterInputParameter(Params.Input[7], true); } //add input parameters Params.RegisterInputParam(new Param_Number()); Params.RegisterInputParam(new Param_Number()); Params.RegisterInputParam(new Param_Number()); } _mode = FoldMode.Trilinear; (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); Params.OnParametersChanged(); ExpireSolution(true); }
private void Mode8Clicked() { FoldMode myMode = FoldMode.Geometric; if (_mode == myMode) { return; } RecordUndoEvent(myMode.ToString() + " Parameter"); //remove input parameters while (Params.Input.Count > 0) { Params.UnregisterInputParameter(Params.Input[0], true); } //register input parameter Params.RegisterInputParam(new Param_Brep()); _mode = myMode; (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); Params.OnParametersChanged(); ExpireSolution(true); }
public override bool Read(GH_IO.Serialization.GH_IReader reader) { _mode = (FoldMode)reader.GetInt32("Mode"); selecteditem = reader.GetString("select"); this.CreateAttributes(); return(base.Read(reader)); }
private void Mode4Clicked() { if (_mode == FoldMode.Edge) { return; } RecordUndoEvent("Edge Parameters"); //remove input parameters while (Params.Input.Count > 5) { Params.UnregisterInputParameter(Params.Input[5], true); } //add input parameters Params.RegisterInputParam(new Param_Number()); Params.RegisterInputParam(new Param_Number()); Params.RegisterInputParam(new Param_Number()); _mode = FoldMode.Edge; (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); Params.OnParametersChanged(); ExpireSolution(true); }
private void Mode2Clicked() { if (_mode == FoldMode.Fabric) { return; } RecordUndoEvent("Fabric Parameters"); _mode = FoldMode.Fabric; //remove input parameters while (Params.Input.Count > 3) { Params.UnregisterInputParameter(Params.Input[3], true); } //register input parameter Params.RegisterInputParam(new Param_Integer()); Params.RegisterInputParam(new Param_Integer()); Params.RegisterInputParam(new Param_Integer()); (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); Params.OnParametersChanged(); ExpireSolution(true); }
private void Mode2Clicked() { FoldMode myMode = FoldMode.Rectangle; //if (_mode == myMode) // return; RecordUndoEvent(myMode.ToString() + " Parameter"); // set number of input parameters int param; if (isTapered) { param = 3; } else { if (isHollow) { param = 4; } else { param = 2; } } //handle exception when we come from Geometric mode where //first input paraemter is of curve type and must be deleted int par2; if (_mode == FoldMode.Geometric) { par2 = 0; } else { par2 = param; } //remove input parameters while (Params.Input.Count > par2) { Params.UnregisterInputParameter(Params.Input[par2], true); } //register input parameter while (Params.Input.Count < param) { Params.RegisterInputParam(new Param_Number()); } _mode = myMode; (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); Params.OnParametersChanged(); ExpireSolution(true); }
public override bool Read(GH_IO.Serialization.GH_IReader reader) { // when a GH file is opened we need to read in the data that was previously set by user _mode = (FoldMode)reader.GetInt32("Mode"); // dropdown content list int dropdownCount = reader.GetInt32("dropdownCount"); dropdowncontents = new List <List <string> >(); for (int i = 0; i < dropdownCount; i++) { int dropdowncontentsCount = reader.GetInt32("dropdowncontentsCount" + i); List <string> tempcontent = new List <string>(); for (int j = 0; j < dropdowncontentsCount; j++) { tempcontent.Add(reader.GetString("dropdowncontents" + i + j)); } dropdowncontents.Add(tempcontent); } // spacer list int dropdownspacerCount = reader.GetInt32("spacerCount"); dropdownspacer = new List <string>(); for (int i = 0; i < dropdownspacerCount; i++) { dropdownspacer.Add(reader.GetString("spacercontents" + i)); } // selection list int selectionsCount = reader.GetInt32("selectionCount"); selections = new List <string>(); for (int i = 0; i < selectionsCount; i++) { selections.Add(reader.GetString("selectioncontents" + i)); } loadlistid = reader.GetInt32("loadlistid"); loadselectid = reader.GetInt32("loadselectid"); catalogueIndex = reader.GetInt32("catalogueIndex"); catalogueTypeIndex = reader.GetInt32("catalogueTypeIndex"); catalogueProfileIndex = reader.GetInt32("catalogueProfileIndex"); isTapered = reader.GetBoolean("isTapered"); isHollow = reader.GetBoolean("isHollow"); isElliptical = reader.GetBoolean("isElliptical"); isGeneral = reader.GetBoolean("isGeneral"); isB2B = reader.GetBoolean("isB2B"); // we need to recreate the custom UI again as this is created before this read IO is called // otherwise the component will not display the selected items on the canvas this.CreateAttributes(); return(base.Read(reader)); }
private void GraftModeClicked(object sender, EventArgs e) { if (_mode == FoldMode.Graft) { return; } RecordUndoEvent("Graft by Property"); _mode = FoldMode.Graft; (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); Params.OnParametersChanged(); Message = "Graft by Property"; ExpireSolution(true); }
private void ListModeClicked(object sender, EventArgs e) { if (_mode == FoldMode.List) { return; } RecordUndoEvent("List"); _mode = FoldMode.List; (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); Params.OnParametersChanged(); Message = "Import as List"; ExpireSolution(true); }
private void Mode8Clicked() { if (_mode == FoldMode.Fabric) { return; } RecordUndoEvent(_mode.ToString() + "Parameters"); _mode = FoldMode.Fabric; (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); Params.OnParametersChanged(); ExpireSolution(true); }
private void Mode2Clicked() { if (_mode == FoldMode.Storey) { return; } RecordUndoEvent("Storey Parameters"); _mode = FoldMode.Storey; //add input parameters Params.RegisterInputParam(new Param_Number()); Params.RegisterInputParam(new Param_Number()); (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); Params.OnParametersChanged(); ExpireSolution(true); }
private void Mode4Clicked() { if (_mode == FoldMode.Constraint) { return; } RecordUndoEvent(_mode.ToString() + " Parameters"); _mode = FoldMode.Constraint; slider = false; Value = 0; ReDrawComponent(); (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); Params.OnParametersChanged(); ExpireSolution(true); }
private void Mode3Clicked() { if (_mode == FoldMode.Two_Dimensional) { return; } RecordUndoEvent("2D Parameters"); _mode = FoldMode.Two_Dimensional; //remove input parameters while (Params.Input.Count > 5) { Params.UnregisterInputParameter(Params.Input[5], true); } (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); Params.OnParametersChanged(); ExpireSolution(true); }
private void SimpleSubClicked(object sender, EventArgs e) { if (_mode == FoldMode.SimpleSubdivision) { return; } RecordUndoEvent("Simple Parameters"); _mode = FoldMode.SimpleSubdivision; Message = "Simple Mode"; while (Params.Input.Count > 2) { Params.UnregisterInputParameter(Params.Input[2], true); } (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); Params.OnParametersChanged(); ExpireSolution(true); }
private void Mode2Clicked() { if (_mode == FoldMode.Uniform) { return; } RecordUndoEvent("Uniform Parameters"); _mode = FoldMode.Uniform; //remove input parameters while (Params.Input.Count > 7) { Params.UnregisterInputParameter(Params.Input[7], true); } (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); Params.OnParametersChanged(); ExpireSolution(true); }
private void Mode2Clicked() { if (_mode == FoldMode.Force) { return; } RecordUndoEvent(_mode.ToString() + " Parameters"); _mode = FoldMode.Force; slider = false; Value = 0; spacertext[2] = "Deform Shape"; ReDrawComponent(); (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); Params.OnParametersChanged(); ExpireSolution(true); }
private void Mode2Clicked() { if (_mode == FoldMode.Stress) { return; } RecordUndoEvent(_mode.ToString() + " Parameters"); _mode = FoldMode.Stress; Params.RegisterOutputParam(new Param_Vector(), 1); slider = false; Value = 0; ReDrawComponent(); (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); Params.OnParametersChanged(); ExpireSolution(true); }
private void Mode1Clicked() { if (_mode == FoldMode.Displacement) { return; } RecordUndoEvent(_mode.ToString() + " Parameters"); _mode = FoldMode.Displacement; Params.UnregisterOutputParameter(Params.Output[1], true); slider = true; Value = 50; ReDrawComponent(); (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); Params.OnParametersChanged(); ExpireSolution(true); }
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { pManager.AddGenericParameter("GSA Model", "GSA", "GSA model containing geometry", GH_ParamAccess.item); pManager.AddTextParameter("Node filter list", "No", "Filter import by list." + System.Environment.NewLine + "Node list should take the form:" + System.Environment.NewLine + " 1 11 to 72 step 2 not (XY3 31 to 45)" + System.Environment.NewLine + "Refer to GSA help file for definition of lists and full vocabulary.", GH_ParamAccess.item, "All"); pManager.AddTextParameter("Element filter list", "El", "Filter import by list." + System.Environment.NewLine + "Element list should take the form:" + System.Environment.NewLine + " 1 11 to 20 step 2 P1 not (G1 to G6 step 3) P11 not (PA PB1 PS2 PM3 PA4 M1)" + System.Environment.NewLine + "Refer to GSA help file for definition of lists and full vocabulary.", GH_ParamAccess.item, "All"); pManager.AddTextParameter("Member filter list", "Me", "Filter import by list." + System.Environment.NewLine + "Member list should take the form:" + System.Environment.NewLine + " 1 11 to 20 step 2 P1 not (G1 to G6 step 3) P11 not (Z4 XY55)" + System.Environment.NewLine + "Refer to GSA help file for definition of lists and full vocabulary.", GH_ParamAccess.item, "All"); pManager[1].Optional = true; pManager[2].Optional = true; pManager[3].Optional = true; _mode = FoldMode.Graft; Message = "Graft by Property" + System.Environment.NewLine + "Right-click to change"; }
private void Mode2Clicked() { if (_mode == FoldMode.One_Dimensional_Two_Way) { return; } RecordUndoEvent("1D, two-way Parameters"); _mode = FoldMode.One_Dimensional_Two_Way; //remove input parameters while (Params.Input.Count > 5) { Params.UnregisterInputParameter(Params.Input[5], true); } //add input parameters Params.RegisterInputParam(new Param_Integer()); Params.RegisterInputParam(new Param_Boolean()); (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); Params.OnParametersChanged(); ExpireSolution(true); }
/// <summary> /// Creates a string representation of a JsonObj, list, string, or double that conforms to the JSON or JSON5 standards. /// </summary> /// <param name="object">The object to stringify.</param> /// <param name="space">How many spaces to indent each level.</param> /// <returns>A string representation of the input object.</returns> public static string Stringify(this object @object, int space = 2) { var previousCulture = System.Threading.Thread.CurrentThread.CurrentCulture; System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; Func <char, bool> isWordChar = (c) => { return((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_' || c == '$'); }; Func <char, bool> isWordStart = (c) => { return((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || c == '$'); }; Func <object, bool> isWord = (key) => { if (!AllowBareKeys) { return(false); } if (!(key is string)) { return(false); } var k = key as string; if (!isWordStart(k[0])) { return(false); } var i = 1; while (i < k.Length) { if (!isWordChar(k[i])) { return(false); } i++; } return(true); }; var objStack = new Stack <object>(); Action <object> checkForCircular = (obj) => { if (objStack.Contains(obj)) { throw new JsonException("Converting circular structure to JSON"); } }; Func <string, int, bool, string> makeIndent = (str, num, noNewLine) => { if (string.IsNullOrEmpty(str)) { return(string.Empty); } // indentation no more than 10 chars if (str.Length > 10) { str = str.Substring(0, 10); } var indent = new StringBuilder(noNewLine ? "" : "\n"); for (var i = 0; i < num; i++) { indent.Append(str); } return(indent.ToString()); }; var indentStr = space == 0 ? string.Empty : makeIndent(" ", space, true); Func <string, string> escapeString = (str) => { return('\"' + str.Replace("\"", "\\\"") + '\"'); }; Func <object, string> internalStringify = null; internalStringify = (obj_part) => { var buffer = new StringBuilder(); var singleBuffer = new StringBuilder(); var res = string.Empty; if (obj_part == null) { return("null"); } if (obj_part is bool) { return(obj_part.ToString().ToLowerInvariant()); } if (obj_part is double || obj_part is float) { if (!AllowNaN && (double.IsNaN((double)obj_part) || double.IsInfinity((double)obj_part))) { throw new JsonException("Found an unallowed NaN or Infinity value."); } else { return(obj_part.ToString()); } } if (obj_part is int || obj_part is long || obj_part is byte || obj_part is sbyte) { return(obj_part.ToString()); } if (obj_part is int[]) { return(internalStringify(((int[])obj_part).Cast <object>().ToList())); } if (obj_part is long[]) { return(internalStringify(((long[])obj_part).Cast <object>().ToList())); } if (obj_part is byte[]) { return(internalStringify(((byte[])obj_part).Cast <object>().ToList())); } if (obj_part is sbyte[]) { return(internalStringify(((sbyte[])obj_part).Cast <object>().ToList())); } if (obj_part is double[]) { return(internalStringify(((double[])obj_part).Cast <object>().ToList())); } if (obj_part is float[]) { return(internalStringify(((float[])obj_part).Cast <object>().ToList())); } if (obj_part is string[]) { return(internalStringify(((string[])obj_part).Cast <object>().ToList())); } if (obj_part is List <int> ) { return(internalStringify(((List <int>)obj_part).Cast <object>().ToList())); } if (obj_part is List <long> ) { return(internalStringify(((List <long>)obj_part).Cast <object>().ToList())); } if (obj_part is List <byte> ) { return(internalStringify(((List <byte>)obj_part).Cast <object>().ToList())); } if (obj_part is List <sbyte> ) { return(internalStringify(((List <sbyte>)obj_part).Cast <object>().ToList())); } if (obj_part is List <double> ) { return(internalStringify(((List <double>)obj_part).Cast <object>().ToList())); } if (obj_part is List <float> ) { return(internalStringify(((List <float>)obj_part).Cast <object>().ToList())); } if (obj_part is List <string> ) { return(internalStringify(((List <string>)obj_part).Cast <object>().ToList())); } if (obj_part is string) { return(escapeString(obj_part.ToString())); } if (obj_part is object) { if (obj_part is object[]) { obj_part = ((object[])obj_part).ToList(); } if (obj_part == null) { return("null"); } else if (obj_part is List <object> ) { checkForCircular(obj_part); var objPartAsArray = obj_part as List <object>; if (objPartAsArray.Count == 0) { return("[]"); } buffer.Append('['); singleBuffer.Append('['); objStack.Push(obj_part); for (var i = 0; i < objPartAsArray.Count; i++) { res = internalStringify(objPartAsArray[i]); buffer.Append(makeIndent(indentStr, objStack.Count, false)); singleBuffer.Append(' '); if (res == null) { buffer.Append("null"); singleBuffer.Append("null"); } else { buffer.Append(res); singleBuffer.Append(res); } if (i < objPartAsArray.Count - 1) { buffer.Append(','); singleBuffer.Append(','); } else if (string.IsNullOrEmpty(indentStr)) { buffer.Append('\n'); } } objStack.Pop(); buffer.Append(makeIndent(indentStr, objStack.Count, false)); buffer.Append(']'); singleBuffer.Append(" ]"); if (FoldMode.HasFlag(FoldMode.Arrays) && singleBuffer.Length < FoldLength) { return(singleBuffer.ToString()); } } else if (obj_part is JsonObj) { checkForCircular(obj_part); buffer.Append('{'); singleBuffer.Append('{'); objStack.Push(obj_part); var nonEmpty = false; var objPartAsDict = obj_part as JsonObj; foreach (var pair in objPartAsDict) { var val = internalStringify(pair.Value); if (val != null) { buffer.Append(makeIndent(indentStr, objStack.Count, false)); singleBuffer.Append(' '); nonEmpty = true; var key = isWord(pair.Key) ? pair.Key : escapeString(pair.Key); buffer.AppendFormat("{0} : {1},", key, val); singleBuffer.AppendFormat("{0} : {1},", key, val); } } objStack.Pop(); if (nonEmpty) { if (FoldMode.HasFlag(FoldMode.Objects) && singleBuffer.Length < FoldLength) { return(singleBuffer.ToString().Substring(0, singleBuffer.Length - 1) + " }"); } return(buffer.ToString().Substring(0, buffer.Length - 1) + makeIndent(indentStr, objStack.Count, false) + '}'); } return("{}"); } return(buffer.ToString()); } else { return(null); } }; var ret = internalStringify(@object); System.Threading.Thread.CurrentThread.CurrentCulture = previousCulture; return(ret); }
private void VerticeClicked(object sender, EventArgs e) { switch (_mode) { case FoldMode.Vertices: RecordUndoEvent("Simple Parameters"); _mode = FoldMode.SimpleSubdivision; while (Params.Input.Count > 2) { Params.UnregisterInputParameter(Params.Input[2], true); } break; case FoldMode.SimpleSubdivision: case FoldMode.VerticesAndEdges: case FoldMode.VerticesAndFaces: RecordUndoEvent("Vertices Parameters"); if (_mode == FoldMode.SimpleSubdivision) { _mode = FoldMode.Vertices; } if (_mode == FoldMode.VerticesAndEdges) { _mode = FoldMode.Edges; } if (_mode == FoldMode.VerticesAndFaces) { _mode = FoldMode.Faces; } while (Params.Input.Count < 3) { Params.RegisterInputParam(new Param_Integer()); } while (Params.Input.Count > 3) { Params.UnregisterInputParameter(Params.Input[3], true); } break; case FoldMode.Edges: case FoldMode.Faces: case FoldMode.AllSelect: RecordUndoEvent("Vertices Parameters"); // should add this to each mode if (_mode == FoldMode.Edges) { _mode = FoldMode.VerticesAndEdges; } if (_mode == FoldMode.Faces) { _mode = FoldMode.VerticesAndFaces; } if (_mode == FoldMode.AllSelect) { _mode = FoldMode.EdgesAndFace; } while (Params.Input.Count < 4) { Params.RegisterInputParam(new Param_Integer()); } while (Params.Input.Count > 4) { Params.UnregisterInputParameter(Params.Input[4], true); } break; case FoldMode.EdgesAndFace: // all selection parameters RecordUndoEvent("All Parameters"); _mode = FoldMode.AllSelect; while (Params.Input.Count < 5) { Params.RegisterInputParam(new Param_Integer()); } while (Params.Input.Count > 5) { Params.UnregisterInputParameter(Params.Input[5], true); } break; } (this as IGH_VariableParameterComponent).VariableParameterMaintenance(); Params.OnParametersChanged(); ExpireSolution(true); }
public override bool Read(GH_IO.Serialization.GH_IReader reader) { _mode = (FoldMode)reader.GetInt32("Mode"); return(base.Read(reader)); }