Changeset 10847
- Timestamp:
- 05/14/14 13:37:28 (11 years ago)
- Location:
- branches/DataPreprocessing
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/PreprocessingChartView.cs
r10818 r10847 42 42 private List<PreprocessingDataTable> dataTablePerVariable; 43 43 private List<DataRow> dataRows; 44 private List<DataRow> selectedDataRows; 44 45 45 46 protected DataRowVisualProperties.DataRowChartType chartType; … … 58 59 foreach (IndexedItem<StringValue> item in checkedItems.Items) { 59 60 string variableName = item.Value.Value; 61 62 //variable is displayed -> remove 60 63 if (VariableIsDisplayed(variableName)) { 61 64 dataTable.Rows.Remove(variableName); 65 dataTable.SelectedRows.Remove(variableName); 62 66 dataTablePerVariable.Remove(dataTablePerVariable.Find(x => (x.Name == variableName))); 67 //variable isnt't displayed -> add 63 68 } else { 64 69 DataRow row = GetDataRow(variableName); 70 DataRow selectedRow = GetSelectedDataRow(variableName); 65 71 dataTable.Rows.Add(row); 66 72 PreprocessingDataTable d = new PreprocessingDataTable(variableName); 67 73 d.Rows.Add(row); 68 74 dataTablePerVariable.Add(d); 75 if (selectedRow != null) 76 { 77 dataTable.SelectedRows.Add(selectedRow); 78 d.SelectedRows.Add(selectedRow); 69 79 } 80 } 70 81 } 71 82 … … 88 99 base.RegisterContentEvents(); 89 100 Content.ChartLogic.Changed += PreprocessingData_Changed; 101 Content.ChartLogic.SelectionChanged += PreprocessingData_SelctionChanged; 90 102 91 103 } … … 94 106 base.DeregisterContentEvents(); 95 107 Content.ChartLogic.Changed -= PreprocessingData_Changed; 108 Content.ChartLogic.SelectionChanged -= PreprocessingData_SelctionChanged; 96 109 } 97 110 … … 109 122 dataRows = logic.CreateAllDataRows(chartType); 110 123 111 // init data table112 124 dataTable = new PreprocessingDataTable(chartTitle); 113 dataTable.Rows.AddRange(dataRows);114 115 116 // init data table per variable117 125 dataTablePerVariable = new List<PreprocessingDataTable>(); 126 127 //add data rows to data tables according to checked item list 118 128 foreach (var checkedItem in Content.VariableItemList.CheckedItems) 119 129 { … … 121 131 PreprocessingDataTable d = new PreprocessingDataTable(variableName); 122 132 DataRow row = GetDataRow(variableName); 123 //DataRow rowSelect = logic.CreateDataRowRange(variableName, 200, 400, chartType); 124 //rowSelect.Name = variableName + "(Selected)"; 125 //rowSelect.VisualProperties.Color = Color.Green; 126 133 134 //add row to data table 135 dataTable.Rows.Add(row); 136 137 //add row to data table per variable 127 138 d.Rows.Add(row); 128 //d.SelectedRows.Add(rowSelect);129 130 139 dataTablePerVariable.Add(d); 131 132 } 140 } 141 142 UpdateSelection(); 143 } 144 145 private void UpdateSelection() { 146 147 //update data table selection 148 selectedDataRows = logic.CreateAllSelectedDataRows(chartType); 149 dataTable.SelectedRows.Clear(); 150 dataTable.SelectedRows.AddRange(selectedDataRows); 151 152 //update data table per variable selection 153 foreach (PreprocessingDataTable d in dataTablePerVariable) { 154 d.SelectedRows.Clear(); 155 DataRow row = selectedDataRows.Find(x => x.Name == d.Name); 156 if (row != null) 157 d.SelectedRows.Add(row); 158 } 159 160 } 161 162 private DataRow GetSelectedDataRow(string variableName) { 163 foreach (DataRow row in selectedDataRows) { 164 if (row.Name == variableName) 165 return row; 166 } 167 return null; 133 168 } 134 169 … … 168 203 case DataPreprocessingChangedEventType.Any: 169 204 default: 205 //TODO: test with transform 170 206 InitData(); 171 207 GenerateChart(); 172 208 break; 173 209 } 210 } 211 212 private void PreprocessingData_SelctionChanged(object sender, EventArgs e) { 213 UpdateSelection(); 174 214 } 175 215 -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/PreprocessingDataTableView.cs
r10804 r10847 60 60 Content.Rows.ItemsReplaced -= new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsReplaced); 61 61 Content.Rows.CollectionReset -= new CollectionItemsChangedEventHandler<DataRow>(Rows_CollectionReset); 62 63 Content.SelectedRows.ItemsAdded -= new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsAdded); 64 Content.SelectedRows.ItemsRemoved -= new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsRemoved); 65 Content.SelectedRows.ItemsReplaced -= new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsReplaced); 66 Content.SelectedRows.CollectionReset -= new CollectionItemsChangedEventHandler<DataRow>(Rows_CollectionReset); 62 67 base.DeregisterContentEvents(); 63 68 } … … 69 74 Content.Rows.ItemsReplaced += new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsReplaced); 70 75 Content.Rows.CollectionReset += new CollectionItemsChangedEventHandler<DataRow>(Rows_CollectionReset); 71 } 76 77 Content.SelectedRows.ItemsAdded += new CollectionItemsChangedEventHandler<DataRow>(SelectedRows_ItemsAdded); 78 Content.SelectedRows.ItemsRemoved += new CollectionItemsChangedEventHandler<DataRow>(SelectedRows_ItemsRemoved); 79 Content.SelectedRows.ItemsReplaced += new CollectionItemsChangedEventHandler<DataRow>(SelectedRows_ItemsReplaced); 80 Content.SelectedRows.CollectionReset += new CollectionItemsChangedEventHandler<DataRow>(SelectedRows_CollectionReset); 81 } 82 72 83 73 84 protected virtual void RegisterDataRowEvents(DataRow row) { … … 141 152 foreach (var row in rows) { 142 153 if (row.VisualProperties.ChartType == DataRowVisualProperties.DataRowChartType.Line) { 143 //RegisterDataRowEvents(row);144 154 row.VisualProperties.IsVisibleInLegend = false; 145 var series = new Series(row.Name); 155 156 //add selected to name in order to avoid naming conflict 157 var series = new Series(row.Name+"(Selected)"); 146 158 ConfigureSeries(series, row); 147 159 FillSeriesWithRowValues(series, row); 148 160 chart.Series.Add(series); 149 161 } 162 } 163 } 164 165 protected virtual void RemoveSelectedDataRows(IEnumerable<DataRow> rows) { 166 foreach (var row in rows) { 167 Series series = chart.Series[row.Name + "(Selected)"]; 168 chart.Series.Remove(series); 150 169 } 151 170 } … … 307 326 #endregion 308 327 #region Rows Event Handlers 328 329 private void SelectedRows_CollectionReset(object sender, CollectionItemsChangedEventArgs<DataRow> e) { 330 if (InvokeRequired) 331 Invoke(new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsReplaced), sender, e); 332 else { 333 RemoveSelectedDataRows(e.OldItems); 334 AddSelectedDataRows(e.Items); 335 } 336 } 337 338 private void SelectedRows_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<DataRow> e) { 339 if (InvokeRequired) 340 Invoke(new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsReplaced), sender, e); 341 else { 342 RemoveSelectedDataRows(e.OldItems); 343 AddSelectedDataRows(e.Items); 344 } 345 } 346 347 private void SelectedRows_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<DataRow> e) { 348 if (InvokeRequired) 349 Invoke(new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsRemoved), sender, e); 350 else { 351 RemoveSelectedDataRows(e.Items); 352 } 353 } 354 355 private void SelectedRows_ItemsAdded(object sender, CollectionItemsChangedEventArgs<DataRow> e) { 356 if (InvokeRequired) 357 Invoke(new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsAdded), sender, e); 358 else { 359 AddSelectedDataRows(e.Items); 360 } 361 } 362 363 309 364 private void Rows_ItemsAdded(object sender, CollectionItemsChangedEventArgs<DataRow> e) { 310 365 if (InvokeRequired) … … 570 625 } 571 626 627 572 628 if (!row.VisualProperties.ExactBins) { 573 629 intervalWidth = HumanRoundRange(intervalWidth); -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/ChartLogic.cs
r10811 r10847 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Drawing; 24 25 using HeuristicLab.Analysis; 25 26 using HeuristicLab.Core; … … 35 36 this.preprocessingData = preprocessingData; 36 37 } 38 39 #region IChartLogic Members 37 40 38 41 public DataRow CreateDataRow(string variableName, DataRowVisualProperties.DataRowChartType chartType) { … … 92 95 } 93 96 97 public event EventHandler SelectionChanged { 98 add { preprocessingData.SelectionChanged += value; } 99 remove { preprocessingData.SelectionChanged -= value; } 100 } 101 94 102 public string GetVariableNameByIndex(int index) { 95 103 return preprocessingData.GetVariableName(index); … … 104 112 } 105 113 114 public List<DataRow> CreateAllSelectedDataRows(DataRowVisualProperties.DataRowChartType chartType) { 115 List<DataRow> dataRows = new List<DataRow>(); 116 foreach (var name in GetVariableNames()) { 117 DataRow row = CreateSelectedDataRow(name, chartType); 118 if(row != null) 119 dataRows.Add(row); 120 } 121 return dataRows; 122 } 123 124 public DataRow CreateSelectedDataRow(string variableName, DataRowVisualProperties.DataRowChartType chartType) { 125 126 IDictionary<int,IList<int>> selection = preprocessingData.GetSelection(); 127 int variableIndex = preprocessingData.GetColumnIndex(variableName); 128 129 if (selection.Keys.Contains(variableIndex)) 130 { 131 List<int> selectedIndices = new List<int>(selection[variableIndex]); 132 //need selection with more than 1 value 133 if(selectedIndices.Count < 2) 134 return null; 135 136 int end = selectedIndices[0]; // indices are provided in reverse order 137 int start = selectedIndices[selectedIndices.Count-1]; 138 139 DataRow rowSelect = CreateDataRowRange(variableName, start, end, chartType); 140 rowSelect.VisualProperties.Color = Color.Green; 141 return rowSelect; 142 } 143 else 144 return null; 145 } 146 147 #endregion 106 148 } 107 149 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/FilteredPreprocessingData.cs
r10810 r10847 186 186 } 187 187 188 public event EventHandler SelectionChanged; 188 public event EventHandler SelectionChanged { 189 add { originalData.SelectionChanged += value; } 190 remove { originalData.SelectionChanged -= value; } 191 } 189 192 190 193 #endregion -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/PreprocessingDataTable.cs
r10803 r10847 4 4 using System.Text; 5 5 using HeuristicLab.Analysis; 6 using HeuristicLab.Collections; 6 7 using HeuristicLab.Core; 7 8 … … 26 27 if (selectedRows != null) throw new InvalidOperationException("Rows already set"); 27 28 selectedRows = value; 28 //if (selectedRows != null) Register RowsEvents();29 //if (selectedRows != null) RegisterSelectedRowEvents(); 29 30 } 30 31 } 31 32 32 33 34 33 } 35 34 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IChartLogic.cs
r10803 r10847 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using HeuristicLab.Analysis; … … 32 33 event DataPreprocessingChangedEventHandler Changed; 33 34 35 event EventHandler SelectionChanged; 36 34 37 ICheckedItemList<StringValue> CreateVariableItemList(); 38 39 List<DataRow> CreateAllSelectedDataRows(DataRowVisualProperties.DataRowChartType chartType); 40 41 DataRow CreateSelectedDataRow(string variableName, DataRowVisualProperties.DataRowChartType chartType); 35 42 36 43 DataRow CreateDataRow(string variableName,DataRowVisualProperties.DataRowChartType chartType);
Note: See TracChangeset
for help on using the changeset viewer.