public StaticAnalysisGraphGUI(EditorSimManager simManager, GUIDropDown<int> flapSettingDropDown, GUIDropDown<CelestialBody> bodySettingDropdown) { this.simManager = simManager; this.flapSettingDropdown = flapSettingDropDown; this.bodySettingDropdown = bodySettingDropdown; //Set up defaults for AoA Sweep aoASweepInputs = new GraphInputs(); aoASweepInputs.lowerBound = "0"; aoASweepInputs.upperBound = "25"; aoASweepInputs.numPts = "100"; aoASweepInputs.flapSetting = 0; aoASweepInputs.pitchSetting = "0"; aoASweepInputs.otherInput = "0.2"; //Set up defaults for Mach Sweep machSweepInputs = new GraphInputs(); machSweepInputs.lowerBound = "0"; machSweepInputs.upperBound = "3"; machSweepInputs.numPts = "100"; machSweepInputs.flapSetting = 0; machSweepInputs.pitchSetting = "0"; machSweepInputs.otherInput = "2"; _graph.SetBoundaries(0, 25, 0, 2); _graph.SetGridScaleUsingValues(5, 0.5); _graph.horizontalLabel = "Angle of Attack, degrees"; _graph.verticalLabel = "Cl\nCd\nCm\nL/D / 10"; _graph.Update(); }
private void RightGraphInputsGUI(GraphInputs input) { GUILayout.BeginVertical(); GUILayout.Label("Celestial Body:"); bodySettingDropdown.GUIDropDownDisplay(); GUILayout.Label("Flap Setting:"); flapSettingDropdown.GUIDropDownDisplay(); input.flapSetting = flapSettingDropdown.ActiveSelection; GUILayout.Label("Pitch Setting:"); input.pitchSetting = GUILayout.TextField(input.pitchSetting, GUILayout.ExpandWidth(true)); input.pitchSetting = Regex.Replace(input.pitchSetting, @"[^-?[0-9]*(\.[0-9]*)?]", ""); GUILayout.Label("Spoilers:"); input.spoilers = GUILayout.Toggle(input.spoilers, input.spoilers ? "Deployed" : "Retracted"); GUILayout.EndVertical(); }
private void RightGraphInputsGUI(GraphInputs input) { GUILayout.BeginVertical(); GUILayout.Label(Localizer.Format("FAREditorStabDerivPlanet")); bodySettingDropdown.GUIDropDownDisplay(); GUILayout.Label(Localizer.Format("FAREditorStabDerivFlap")); flapSettingDropdown.GUIDropDownDisplay(); input.flapSetting = flapSettingDropdown.ActiveSelection; GUILayout.Label(Localizer.Format("FAREditorStaticPitchSetting")); input.pitchSetting = GUILayout.TextField(input.pitchSetting, GUILayout.ExpandWidth(true)); input.pitchSetting = Regex.Replace(input.pitchSetting, @"[^-?[0-9]*(\.[0-9]*)?]", ""); GUILayout.Label(Localizer.Format("FAREditorStabDerivSpoiler")); input.spoilers = GUILayout.Toggle(input.spoilers, input.spoilers ? Localizer.Format("FAREditorStabDerivSDeploy") : Localizer.Format("FAREditorStabDerivSRetract")); GUILayout.EndVertical(); }
public void Display() { GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Label(isMachMode ? Localizer.Format("FAREditorStaticMachSweep") : Localizer.Format("FAREditorStaticAoASweep"), GUILayout.Width(250)); if (GUILayout.Button(Localizer.Format("FAREditorStaticLoopButton"), GUILayout.Width(175.0F))) { GraphInputs input = (isMachMode ? machSweepInputs : aoASweepInputs); int n = simManager.SweepSim.ExportSweep(bodySettingDropdown.ActiveSelection, input.PitchSetting, input.flapSetting, input.spoilers); if (n > 0) { PopupDialog.SpawnPopupDialog(new Vector2(0, 0), new Vector2(0, 0), "FARStaticLoopCount", Localizer.Format("FAREditorStaticLoopDone"), Localizer.Format("FAREditorStaticLoopDoneExp", n), Localizer.Format("FARGUIOKButton"), true, HighLogic.UISkin); } else { PopupDialog.SpawnPopupDialog(new Vector2(0, 0), new Vector2(0, 0), "FARStaticSaveError", Localizer.Format("FAREditorStaticSaveError"), Localizer.Format("FAREditorStaticSaveErrorExp"), Localizer.Format("FARGUIOKButton"), true, HighLogic.UISkin); } } if (GUILayout.Button(isMachMode ? Localizer.Format("FAREditorStaticSwitchAoA") : Localizer.Format("FAREditorStaticSwitchMach"))) { isMachMode = !isMachMode; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GraphDisplay(); RightGraphInputsGUI(isMachMode ? machSweepInputs : aoASweepInputs); GUILayout.EndHorizontal(); BelowGraphInputsGUI(isMachMode ? machSweepInputs : aoASweepInputs); GUILayout.EndVertical(); }
public StaticAnalysisGraphGUI( EditorSimManager simManager, GUIDropDown <int> flapSettingDropDown, GUIDropDown <CelestialBody> bodySettingDropdown ) { this.simManager = simManager; flapSettingDropdown = flapSettingDropDown; this.bodySettingDropdown = bodySettingDropdown; //Set up defaults for AoA Sweep aoASweepInputs = new GraphInputs { lowerBound = "0", upperBound = "25", numPts = "100", flapSetting = 0, pitchSetting = "0", otherInput = "0.2" }; //Set up defaults for Mach Sweep machSweepInputs = new GraphInputs { lowerBound = "0", upperBound = "3", numPts = "100", flapSetting = 0, pitchSetting = "0", otherInput = "2" }; _graph.SetBoundaries(0, 25, 0, 2); _graph.SetGridScaleUsingValues(5, 0.5); _graph.horizontalLabel = Localizer.Format("FAREditorStaticGraphAoA"); _graph.verticalLabel = Localizer.Format("FAREditorStaticGraphCoeff"); _graph.Update(); }
private void BelowGraphInputsGUI(GraphInputs input) { GUILayout.BeginHorizontal(); GUILayout.Label(Localizer.Format("FAREditorStaticGraphLowLim"), GUILayout.Width(50.0F), GUILayout.Height(25.0F)); input.lowerBound = GUILayout.TextField(input.lowerBound, GUILayout.ExpandWidth(true)); GUILayout.Label(Localizer.Format("FAREditorStaticGraphUpLim"), GUILayout.Width(50.0F), GUILayout.Height(25.0F)); input.upperBound = GUILayout.TextField(input.upperBound, GUILayout.ExpandWidth(true)); GUILayout.Label(Localizer.Format("FAREditorStaticGraphPtCount"), GUILayout.Width(70.0F), GUILayout.Height(25.0F)); input.numPts = GUILayout.TextField(input.numPts, GUILayout.ExpandWidth(true)); GUILayout.Label(isMachMode ? Localizer.Format("FARAbbrevAoA") : Localizer.Format("FARAbbrevMach"), GUILayout.Width(50.0F), GUILayout.Height(25.0F)); input.otherInput = GUILayout.TextField(input.otherInput, GUILayout.ExpandWidth(true)); if (GUILayout.Button(isMachMode ? Localizer.Format("FAREditorStaticSweepMach") : Localizer.Format("FAREditorStaticSweepAoA"), GUILayout.Width(100.0F), GUILayout.Height(25.0F))) { input.lowerBound = Regex.Replace(input.lowerBound, @"[^-?[0-9]*(\.[0-9]*)?]", ""); input.upperBound = Regex.Replace(input.upperBound, @"[^-?[0-9]*(\.[0-9]*)?]", ""); input.numPts = Regex.Replace(input.numPts, @"[^-?[0-9]*(\.[0-9]*)?]", ""); input.pitchSetting = Regex.Replace(input.pitchSetting, @"[^-?[0-9]*(\.[0-9]*)?]", ""); input.otherInput = Regex.Replace(input.otherInput, @"[^-?[0-9]*(\.[0-9]*)?]", ""); double lowerBound = double.Parse(input.lowerBound); lowerBound = lowerBound.Clamp(-90, 90); input.lowerBound = lowerBound.ToString(CultureInfo.InvariantCulture); double upperBound = double.Parse(input.upperBound); upperBound = upperBound.Clamp(lowerBound, 90); input.upperBound = upperBound.ToString(CultureInfo.InvariantCulture); double numPts = double.Parse(input.numPts); numPts = Math.Ceiling(numPts); input.numPts = numPts.ToString(CultureInfo.InvariantCulture); double pitchSetting = double.Parse(input.pitchSetting); pitchSetting = pitchSetting.Clamp(-1, 1); input.pitchSetting = pitchSetting.ToString(CultureInfo.InvariantCulture); double otherInput = double.Parse(input.otherInput); SweepSim sim = simManager.SweepSim; if (sim.IsReady()) { GraphData data; if (isMachMode) { data = sim.MachNumberSweep(otherInput, pitchSetting, lowerBound, upperBound, (int)numPts, input.flapSetting, input.spoilers, bodySettingDropdown.ActiveSelection); SetAngleVectors(pitchSetting, pitchSetting); } else { data = sim.AngleOfAttackSweep(otherInput, pitchSetting, lowerBound, upperBound, (int)numPts, input.flapSetting, input.spoilers, bodySettingDropdown.ActiveSelection); SetAngleVectors(lowerBound, upperBound); } UpdateGraph(data, isMachMode ? Localizer.Format("FAREditorStaticGraphMach") : Localizer.Format("FAREditorStaticGraphAoA"), Localizer.Format("FAREditorStaticGraphCoeff"), lowerBound, upperBound); } } GUILayout.EndHorizontal(); }
private void BelowGraphInputsGUI(GraphInputs input) { GUILayout.BeginHorizontal(); GUILayout.Label("Lower: ", GUILayout.Width(50.0F), GUILayout.Height(25.0F)); input.lowerBound = GUILayout.TextField(input.lowerBound, GUILayout.ExpandWidth(true)); GUILayout.Label("Upper: ", GUILayout.Width(50.0F), GUILayout.Height(25.0F)); input.upperBound = GUILayout.TextField(input.upperBound, GUILayout.ExpandWidth(true)); GUILayout.Label("Num Pts: ", GUILayout.Width(70.0F), GUILayout.Height(25.0F)); input.numPts = GUILayout.TextField(input.numPts, GUILayout.ExpandWidth(true)); GUILayout.Label(isMachMode ? "AoA" : "Mach", GUILayout.Width(50.0F), GUILayout.Height(25.0F)); input.otherInput = GUILayout.TextField(input.otherInput, GUILayout.ExpandWidth(true)); if (GUILayout.Button(isMachMode ? "Sweep Mach" : "Sweep AoA", GUILayout.Width(100.0F), GUILayout.Height(25.0F))) { input.lowerBound = Regex.Replace(input.lowerBound, @"[^-?[0-9]*(\.[0-9]*)?]", ""); input.upperBound = Regex.Replace(input.upperBound, @"[^-?[0-9]*(\.[0-9]*)?]", ""); input.numPts = Regex.Replace(input.numPts, @"[^-?[0-9]*(\.[0-9]*)?]", ""); input.pitchSetting = Regex.Replace(input.pitchSetting, @"[^-?[0-9]*(\.[0-9]*)?]", ""); input.otherInput = Regex.Replace(input.otherInput, @"[^-?[0-9]*(\.[0-9]*)?]", ""); double lowerBound, upperBound, numPts, pitchSetting, otherInput; lowerBound = double.Parse(input.lowerBound); lowerBound = FARMathUtil.Clamp(lowerBound, -90, 90); input.lowerBound = lowerBound.ToString(); upperBound = double.Parse(input.upperBound); upperBound = FARMathUtil.Clamp(upperBound, lowerBound, 90); input.upperBound = upperBound.ToString(); numPts = double.Parse(input.numPts); numPts = Math.Ceiling(numPts); input.numPts = numPts.ToString(); pitchSetting = double.Parse(input.pitchSetting); pitchSetting = FARMathUtil.Clamp(pitchSetting, -1, 1); input.pitchSetting = pitchSetting.ToString(); otherInput = double.Parse(input.otherInput); GraphData data; if (isMachMode) { data = simManager.SweepSim.MachNumberSweep(otherInput, pitchSetting, lowerBound, upperBound, (int)numPts, input.flapSetting, input.spoilers, bodySettingDropdown.ActiveSelection); SetAngleVectors(pitchSetting, pitchSetting); } else { data = simManager.SweepSim.AngleOfAttackSweep(otherInput, pitchSetting, lowerBound, upperBound, (int)numPts, input.flapSetting, input.spoilers, bodySettingDropdown.ActiveSelection); SetAngleVectors(lowerBound, upperBound); } UpdateGraph(data, isMachMode ? "Mach Number" : "Angle of Attack, degrees", "Cl\nCd\nCm\nL/D / 10", lowerBound, upperBound); } GUILayout.EndHorizontal(); }
public void Dispose() { aoASweepInputs = machSweepInputs = null; flapSettingDropdown = null; bodySettingDropdown = null; simManager = null; _graph = null; }
private void BelowGraphInputsGUI(GraphInputs input) { GUILayout.BeginHorizontal(); GUILayout.Label("Lower: ", GUILayout.Width(50.0F), GUILayout.Height(25.0F)); input.lowerBound = GUILayout.TextField(input.lowerBound, GUILayout.ExpandWidth(true)); GUILayout.Label("Upper: ", GUILayout.Width(50.0F), GUILayout.Height(25.0F)); input.upperBound = GUILayout.TextField(input.upperBound, GUILayout.ExpandWidth(true)); GUILayout.Label("Num Pts: ", GUILayout.Width(70.0F), GUILayout.Height(25.0F)); input.numPts = GUILayout.TextField(input.numPts, GUILayout.ExpandWidth(true)); GUILayout.Label(isMachMode ? "AoA" : "Mach", GUILayout.Width(50.0F), GUILayout.Height(25.0F)); input.otherInput = GUILayout.TextField(input.otherInput, GUILayout.ExpandWidth(true)); if (GUILayout.Button(isMachMode ? "Sweep Mach" : "Sweep AoA", GUILayout.Width(100.0F), GUILayout.Height(25.0F))) { input.lowerBound = Regex.Replace(input.lowerBound, @"[^-?[0-9]*(\.[0-9]*)?]", ""); input.upperBound = Regex.Replace(input.upperBound, @"[^-?[0-9]*(\.[0-9]*)?]", ""); input.numPts = Regex.Replace(input.numPts, @"[^-?[0-9]*(\.[0-9]*)?]", ""); input.pitchSetting = Regex.Replace(input.pitchSetting, @"[^-?[0-9]*(\.[0-9]*)?]", ""); input.otherInput = Regex.Replace(input.otherInput, @"[^-?[0-9]*(\.[0-9]*)?]", ""); double lowerBound, upperBound, numPts, pitchSetting, otherInput; lowerBound = double.Parse(input.lowerBound); lowerBound = FARMathUtil.Clamp(lowerBound, -90, 90); input.lowerBound = lowerBound.ToString(); upperBound = double.Parse(input.upperBound); upperBound = FARMathUtil.Clamp(upperBound, lowerBound, 90); input.upperBound = upperBound.ToString(); numPts = double.Parse(input.numPts); numPts = Math.Ceiling(numPts); input.numPts = numPts.ToString(); pitchSetting = double.Parse(input.pitchSetting); pitchSetting = FARMathUtil.Clamp(pitchSetting, -1, 1); input.pitchSetting = pitchSetting.ToString(); otherInput = double.Parse(input.otherInput); GraphData data; var sim = simManager.SweepSim; if (sim.IsReady()) { if (isMachMode) { data = sim.MachNumberSweep(otherInput, pitchSetting, lowerBound, upperBound, (int)numPts, input.flapSetting, input.spoilers, bodySettingDropdown.ActiveSelection); SetAngleVectors(pitchSetting, pitchSetting); } else { data = sim.AngleOfAttackSweep(otherInput, pitchSetting, lowerBound, upperBound, (int)numPts, input.flapSetting, input.spoilers, bodySettingDropdown.ActiveSelection); SetAngleVectors(lowerBound, upperBound); } UpdateGraph(data, isMachMode ? "Mach Number" : "Angle of Attack, degrees", "Cl\nCd\nCm\nL/D / 10", lowerBound, upperBound); } } GUILayout.EndHorizontal(); }