- Timestamp:
- 12/18/17 16:17:39 (7 years ago)
- Location:
- stable
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 15518,15534
- Property svn:mergeinfo changed
-
stable/HeuristicLab.DataPreprocessing
- Property svn:mergeinfo changed
-
stable/HeuristicLab.DataPreprocessing/3.4
- Property svn:mergeinfo changed
-
stable/HeuristicLab.DataPreprocessing/3.4/Content/FilterContent.cs
r15242 r15535 20 20 #endregion 21 21 22 using System.Collections.Generic; 22 23 using System.Drawing; 24 using System.Linq; 23 25 using HeuristicLab.Common; 24 26 using HeuristicLab.Core; 25 27 using HeuristicLab.DataPreprocessing.Filter; 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 29 27 30 namespace HeuristicLab.DataPreprocessing { 28 31 [Item("Filter", "Represents the filter grid.")] 29 public class FilterContent : Item, IViewShortcut { 32 [StorableClass] 33 public class FilterContent : PreprocessingContent, IViewShortcut { 30 34 public static new Image StaticItemImage { 31 35 get { return HeuristicLab.Common.Resources.VSImageLibrary.Filter; } 32 36 } 33 34 public FilterLogic FilterLogic { get; private set; } 35 37 [Storable] 36 38 public ICheckedItemCollection<IFilter> Filters { get; private set; } 37 39 40 [Storable] 38 41 public bool IsAndCombination { get; set; } 39 42 40 public FilterContent(FilterLogic filterLogic) { 43 public IEnumerable<IFilter> ActiveFilters { 44 get { return Filters.Where(f => f.Active && f.ConstraintData != null); } 45 } 46 47 public bool[] GetRemainingRows() { 48 var remainingRows = new bool[PreprocessingData.Rows]; 49 if (ActiveFilters.Any()) { 50 var filterResults = ActiveFilters.Select(f => f.Check()).ToList(); 51 var rowFilterResults = new bool[filterResults.Count]; 52 for (int row = 0; row < remainingRows.Length; row++) { 53 for (int i = 0; i < filterResults.Count; i++) 54 rowFilterResults[i] = filterResults[i][row]; 55 56 remainingRows[row] = IsAndCombination 57 ? rowFilterResults.All(x => x) 58 : rowFilterResults.Any(x => x); 59 } 60 } else { 61 // if not filters active => all rows are remaining 62 for (int i = 0; i < remainingRows.Length; i++) 63 remainingRows[i] = true; 64 } 65 return remainingRows; 66 } 67 68 #region Constructor, Cloning & Persistence 69 public FilterContent(IFilteredPreprocessingData preprocessingData) 70 : base(preprocessingData) { 41 71 Filters = new CheckedItemCollection<IFilter>(); 42 72 IsAndCombination = true; 43 FilterLogic = filterLogic;44 73 } 45 74 46 protected FilterContent(FilterContent content, Cloner cloner) 47 : base(content, cloner) { 75 protected FilterContent(FilterContent original, Cloner cloner) 76 : base(original, cloner) { 77 Filters = cloner.Clone(original.Filters); 78 IsAndCombination = original.IsAndCombination; 48 79 } 49 50 80 public override IDeepCloneable Clone(Cloner cloner) { 51 81 return new FilterContent(this, cloner); 52 82 } 83 84 [StorableConstructor] 85 protected FilterContent(bool deserializing) 86 : base(deserializing) { } 87 #endregion 53 88 } 54 89 }
Note: See TracChangeset
for help on using the changeset viewer.