Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/12/17 16:32:35 (6 years ago)
Author:
pfleck
Message:

#2809: merged branch to trunk

Location:
trunk/sources/HeuristicLab.DataPreprocessing
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.DataPreprocessing

  • trunk/sources/HeuristicLab.DataPreprocessing/3.4

  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Content/FilterContent.cs

    r15110 r15518  
    2020#endregion
    2121
     22using System.Collections.Generic;
    2223using System.Drawing;
     24using System.Linq;
    2325using HeuristicLab.Common;
    2426using HeuristicLab.Core;
    2527using HeuristicLab.DataPreprocessing.Filter;
     28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2629
    2730namespace HeuristicLab.DataPreprocessing {
    2831  [Item("Filter", "Represents the filter grid.")]
    29   public class FilterContent : Item, IViewShortcut {
     32  [StorableClass]
     33  public class FilterContent : PreprocessingContent, IViewShortcut {
    3034    public static new Image StaticItemImage {
    3135      get { return HeuristicLab.Common.Resources.VSImageLibrary.Filter; }
    3236    }
    33 
    34     public FilterLogic FilterLogic { get; private set; }
    35 
     37    [Storable]
    3638    public ICheckedItemCollection<IFilter> Filters { get; private set; }
    3739
     40    [Storable]
    3841    public bool IsAndCombination { get; set; }
    3942
    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) {
    4171      Filters = new CheckedItemCollection<IFilter>();
    4272      IsAndCombination = true;
    43       FilterLogic = filterLogic;
    4473    }
    4574
    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;
    4879    }
    49 
    5080    public override IDeepCloneable Clone(Cloner cloner) {
    5181      return new FilterContent(this, cloner);
    5282    }
     83
     84    [StorableConstructor]
     85    protected FilterContent(bool deserializing)
     86      : base(deserializing) { }
     87    #endregion
    5388  }
    5489}
Note: See TracChangeset for help on using the changeset viewer.