Changeset 13787 for branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Views/UnderstandingProblemInstanceView.cs
- Timestamp:
- 04/24/16 10:03:52 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Views/UnderstandingProblemInstanceView.cs
r13757 r13787 22 22 using HeuristicLab.Common.Resources; 23 23 using HeuristicLab.Core; 24 using HeuristicLab.Core.Views;25 24 using HeuristicLab.Data; 26 25 using HeuristicLab.MainForm; 26 using HeuristicLab.MainForm.WindowsForms; 27 27 using HeuristicLab.OptimizationExpertSystem.Common; 28 28 using System; … … 39 39 public sealed partial class UnderstandingProblemInstanceView : KnowledgeCenterViewBase { 40 40 private bool SuppressEvents { get; set; } 41 private readonly CheckedItemList View<StringValue> characteristicsView;41 private readonly CheckedItemList<StringValue> characteristics; 42 42 43 43 public UnderstandingProblemInstanceView() { … … 45 45 showCharacteristicsCheckBox.Text = string.Empty; 46 46 showCharacteristicsCheckBox.Image = VSImageLibrary.Properties; 47 characteristicsView = new CheckedItemListView<StringValue>() { 48 Dock = DockStyle.Fill 49 }; 50 mapSplitContainer.Panel2.Controls.Add(characteristicsView); 47 characteristics = new CheckedItemList<StringValue>(); 48 characteristics.CheckedItemsChanged += CharacteristicsOnCheckedItemsChanged; 49 mapSplitContainer.Panel2.Controls.Add(new ViewHost() { 50 Dock = DockStyle.Fill, 51 Content = characteristics 52 }); 51 53 } 52 54 53 55 protected override void OnContentChanged() { 54 56 base.OnContentChanged(); 57 characteristics.Clear(); 55 58 if (Content == null) { 56 59 problemInstancesView.Content = null; 57 characteristicsView.Content = null;58 60 instanceMapChart.Series["InstancesSeries"].Points.Clear(); 59 61 instanceMapChart.Series["CurrentInstanceSeries"].Points.Clear(); 60 62 } else { 61 63 problemInstancesView.Content = Content.ProblemInstances; 62 characteristicsView.Content = Content.ProblemCharacteristics;64 UpdateCharacteristics(); 63 65 UpdateProjectionComboBox(); 64 66 UpdateSizeComboBox(); … … 67 69 } 68 70 69 #region Content Event Handlers 70 protected override void OnProblemChanged() { 71 base.OnProblemChanged(); 72 SetEnabledStateOfControls(); 73 } 74 75 protected override void OnProblemInstancesChanged() { 76 base.OnProblemInstancesChanged(); 77 if (Content.ProblemInstances.UpdateOfRunsInProgress) return; 78 UpdateProjectionComboBox(); 79 UpdateSizeComboBox(); 80 UpdateColorComboBox(); 81 UpdateProjection(); 82 } 83 #endregion 71 protected override void SetEnabledStateOfControls() { 72 base.SetEnabledStateOfControls(); 73 } 74 75 #region Update Controls 76 private void UpdateCharacteristics() { 77 var @checked = new HashSet<string>(characteristics.CheckedItems.Select(x => x.Value.Value)); 78 characteristics.Clear(); 79 foreach (var c in Content.ProblemInstances.ResultNames) { 80 characteristics.Add(new StringValue(c), @checked.Contains(c)); 81 } 82 } 84 83 85 84 private void UpdateProjectionComboBox() { … … 126 125 } finally { SuppressEvents = false; } 127 126 } 128 129 private IEnumerable<string> GetProjections() {130 return Content.ProblemInstances131 .SelectMany(x => x.Results.Where(y => Regex.IsMatch(y.Key, "^Projection[.].*[.][XY]$")))132 .Select(x => Regex.Match(x.Key, "Projection[.](?<g>.*)[.][XY]").Groups["g"].Value)133 .Distinct();134 }135 127 136 128 private void UpdateProjection() { … … 153 145 size, color, invPropCheckBox.Checked, fromZeroCheckBox.Checked); 154 146 } 147 #endregion 148 149 #region Content Event Handlers 150 protected override void OnProblemChanged() { 151 base.OnProblemChanged(); 152 SetEnabledStateOfControls(); 153 } 154 155 protected override void OnProblemInstancesChanged() { 156 base.OnProblemInstancesChanged(); 157 if (Content.ProblemInstances.UpdateOfRunsInProgress) return; 158 try { 159 SuppressEvents = true; 160 UpdateCharacteristics(); 161 } finally { SuppressEvents = false; } 162 UpdateProjectionComboBox(); 163 UpdateSizeComboBox(); 164 UpdateColorComboBox(); 165 UpdateProjection(); 166 } 167 #endregion 168 169 #region Control Event Handlers 170 private void ProjectionComboBoxOnSelectedIndexChanged(object sender, EventArgs e) { 171 UpdateProjection(); 172 } 173 174 private void SizeComboBoxOnSelectedIndexChanged(object sender, EventArgs e) { 175 UpdateProjection(); 176 } 177 178 private void colorComboBox_SelectedIndexChanged(object sender, EventArgs e) { 179 UpdateProjection(); 180 } 181 182 private void InvPropCheckBoxOnCheckedChanged(object sender, EventArgs e) { 183 UpdateProjection(); 184 } 185 186 private void fromZeroCheckBox_CheckedChanged(object sender, EventArgs e) { 187 UpdateProjection(); 188 } 189 190 private void showCharacteristicsCheckBox_CheckedChanged(object sender, EventArgs e) { 191 mapSplitContainer.Panel2Collapsed = !showCharacteristicsCheckBox.Checked; 192 } 193 #endregion 194 195 #region Other Event Handlers 196 private void CharacteristicsOnCheckedItemsChanged(object sender, EventArgs e) { 197 if (SuppressEvents) return; 198 if (characteristics.CheckedItems.Any()) 199 Content.UpdateInstanceProjection(characteristics.CheckedItems.Select(x => x.Value.Value).ToArray()); 200 } 201 #endregion 202 203 #region Helper Classes and Methods 204 private IEnumerable<string> GetProjections() { 205 return Content.ProblemInstances.ResultNames 206 .Where(x => Regex.IsMatch(x, "^Projection[.].*[.][XY]$")) 207 .Select(x => Regex.Match(x, "Projection[.](?<g>.*)[.][XY]").Groups["g"].Value) 208 .Distinct(); 209 } 155 210 156 211 private void DoProjectProblemInstances(Series instancesSeries, Series currentInstanceSeries, string projection, string size, string color, bool invProp, bool fromZero) { … … 160 215 double maxSize = 0, minSize = 0; 161 216 if (!string.IsNullOrEmpty(size)) { 162 var sizes = Content.ProblemInstances.Where(x => x.Results.ContainsKey(size)).Select(x => x.Results[size]).OfType<D ata.DoubleValue>().Where(x => !double.IsNaN(x.Value)).ToList();217 var sizes = Content.ProblemInstances.Where(x => x.Results.ContainsKey(size)).Select(x => x.Results[size]).OfType<DoubleValue>().Where(x => !double.IsNaN(x.Value)).ToList(); 163 218 if (sizes.Count > 0) { 164 219 maxSize = sizes.Max(x => x.Value); … … 177 232 var yKey = "Projection." + projection + ".Y"; 178 233 if (!run.Results.ContainsKey(xKey) || !run.Results.ContainsKey(yKey) 179 || !(run.Results[xKey] is D ata.DoubleValue) || !(run.Results[yKey] is Data.DoubleValue)) continue;180 var x = ((D ata.DoubleValue)run.Results[xKey]).Value;181 var y = ((D ata.DoubleValue)run.Results[yKey]).Value;234 || !(run.Results[xKey] is DoubleValue) || !(run.Results[yKey] is DoubleValue)) continue; 235 var x = ((DoubleValue)run.Results[xKey]).Value; 236 var y = ((DoubleValue)run.Results[yKey]).Value; 182 237 var dataPoint = new DataPoint(x, y) { 183 238 Label = run.Name, … … 185 240 IItem item; 186 241 if (maxSize > minSize && run.Results.TryGetValue(size, out item)) { 187 var dItem = item as D ata.DoubleValue;242 var dItem = item as DoubleValue; 188 243 if (dItem == null && item is IntValue) dItem = new DoubleValue(((IntValue)item).Value); 189 244 if (dItem != null) { … … 216 271 } 217 272 } 218 219 #region Control Event Handlers220 private void ProjectionComboBoxOnSelectedIndexChanged(object sender, EventArgs e) {221 UpdateProjection();222 }223 224 private void SizeComboBoxOnSelectedIndexChanged(object sender, EventArgs e) {225 UpdateProjection();226 }227 228 private void colorComboBox_SelectedIndexChanged(object sender, EventArgs e) {229 UpdateProjection();230 }231 232 private void InvPropCheckBoxOnCheckedChanged(object sender, EventArgs e) {233 UpdateProjection();234 }235 236 private void fromZeroCheckBox_CheckedChanged(object sender, EventArgs e) {237 UpdateProjection();238 }239 240 private void showCharacteristicsCheckBox_CheckedChanged(object sender, EventArgs e) {241 mapSplitContainer.Panel2Collapsed = !showCharacteristicsCheckBox.Checked;242 }243 273 #endregion 244 274 }
Note: See TracChangeset
for help on using the changeset viewer.