Changeset 12599


Ignore:
Timestamp:
07/06/15 13:52:12 (4 years ago)
Author:
abeham
Message:

#2270: Fixed several of the runcollection views

  • Added InvokeRequired checks where missing
  • Added suppressUpdates check where missing
  • Fixed some bugs, added some null checks
Location:
trunk/sources
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Analysis.Statistics.Views/3.3/ChartAnalysisView.cs

    r12117 r12599  
    108108
    109109    void Content_RowsChanged(object sender, EventArgs e) {
    110       RebuildDataTableAsync();
     110      if (suppressUpdates) return;
     111      if (InvokeRequired) Invoke((Action<object, EventArgs>)Content_RowsChanged, sender, e);
     112      else {
     113        RebuildDataTableAsync();
     114      }
    111115    }
    112116
    113117    void Content_ColumnsChanged(object sender, EventArgs e) {
    114       if (!suppressUpdates) {
     118      if (suppressUpdates) return;
     119      if (InvokeRequired) Invoke((Action<object, EventArgs>)Content_ColumnsChanged, sender, e);
     120      else {
    115121        RebuildDataTableAsync();
    116122      }
     
    118124
    119125    private void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) {
    120       UpdateComboboxes();
    121       RebuildDataTableAsync();
     126      if (suppressUpdates) return;
     127      if (InvokeRequired) Invoke((Action<object, CollectionItemsChangedEventArgs<IRun>>)Content_CollectionReset, sender, e);
     128      else {
     129        UpdateComboboxes();
     130        RebuildDataTableAsync();
     131      }
    122132    }
    123133
    124134    private void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) {
    125       suppressUpdates = Content.UpdateOfRunsInProgress;
    126 
    127       if (!suppressUpdates && !valuesAdded) {
    128         RebuildDataTableAsync();
    129       }
    130       if (valuesAdded) {
    131         valuesAdded = false;
     135      if (InvokeRequired) Invoke((Action<object, EventArgs>)Content_UpdateOfRunsInProgressChanged, sender, e);
     136      else {
     137        suppressUpdates = Content.UpdateOfRunsInProgress;
     138
     139        if (!suppressUpdates && !valuesAdded) {
     140          RebuildDataTableAsync();
     141        }
     142        if (valuesAdded) {
     143          valuesAdded = false;
     144        }
    132145      }
    133146    }
     
    248261
    249262    private void RebuildDataTableAsync() {
     263      string resultName = (string)dataTableComboBox.SelectedItem;
     264      if (string.IsNullOrEmpty(resultName)) return;
     265
     266      string rowName = (string)dataRowComboBox.SelectedItem;
     267
    250268      progress = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Calculating values...");
    251 
    252       string resultName = (string)dataTableComboBox.SelectedItem;
    253       string rowName = (string)dataRowComboBox.SelectedItem;
    254 
    255269      var task = Task.Factory.StartNew(() => RebuildDataTable(resultName, rowName));
    256270
  • trunk/sources/HeuristicLab.Analysis.Statistics.Views/3.3/CorrelationView.cs

    r12152 r12599  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HeuristicLab.Collections;
    2526using HeuristicLab.Core.Views;
    2627using HeuristicLab.Data;
     
    8182      Content.ColumnsChanged += Content_ColumnsChanged;
    8283      Content.RowsChanged += Content_RowsChanged;
    83       Content.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
     84      Content.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
    8485      Content.UpdateOfRunsInProgressChanged += Content_UpdateOfRunsInProgressChanged;
    8586    }
     
    8990      Content.ColumnsChanged -= Content_ColumnsChanged;
    9091      Content.RowsChanged -= Content_RowsChanged;
    91       Content.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
     92      Content.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
    9293      Content.UpdateOfRunsInProgressChanged -= Content_UpdateOfRunsInProgressChanged;
    9394    }
    9495
    9596    void Content_RowsChanged(object sender, EventArgs e) {
    96       UpdateUI();
     97      if (suppressUpdates) return;
     98      if (InvokeRequired) Invoke((Action<object, EventArgs>)Content_RowsChanged, sender, e);
     99      else {
     100        UpdateUI();
     101      }
    97102    }
    98103
    99104    void Content_ColumnsChanged(object sender, EventArgs e) {
    100       if (!suppressUpdates) {
    101         UpdateUI();
    102       }
    103     }
    104 
    105     private void Content_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
    106       UpdateUI();
     105      if (suppressUpdates) return;
     106      if (InvokeRequired) Invoke((Action<object, EventArgs>)Content_ColumnsChanged, sender, e);
     107      else {
     108        UpdateUI();
     109      }
     110    }
     111
     112    private void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) {
     113      if (suppressUpdates) return;
     114      if (InvokeRequired) Invoke((Action<object, CollectionItemsChangedEventArgs<IRun>>)Content_CollectionReset, sender, e);
     115      else {
     116        UpdateUI();
     117      }
    107118    }
    108119
    109120    private void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) {
    110       suppressUpdates = Content.UpdateOfRunsInProgress;
    111       UpdateUI();
     121      if (InvokeRequired) Invoke((Action<object, EventArgs>)Content_UpdateOfRunsInProgressChanged, sender, e);
     122      else {
     123        suppressUpdates = Content.UpdateOfRunsInProgress;
     124        UpdateUI();
     125      }
    112126    }
    113127    #endregion
    114128
    115129    private void UpdateUI() {
    116       if (!suppressUpdates) {
    117         RebuildCorrelationTable();
    118       }
     130      RebuildCorrelationTable();
    119131    }
    120132
  • trunk/sources/HeuristicLab.Analysis.Statistics.Views/3.3/SampleSizeInfluenceView.cs

    r12116 r12599  
    4141    private const string BoxPlotSeriesName = "BoxPlotSeries";
    4242    private const string BoxPlotChartAreaName = "BoxPlotChartArea";
    43     private const string delimitor = ";";
     43    private const string delimiter = ";";
    4444
    4545    private bool suppressUpdates = false;
     
    7272    protected override void RegisterContentEvents() {
    7373      base.RegisterContentEvents();
    74       Content.Reset += new EventHandler(Content_Reset);
    7574      Content.ColumnNamesChanged += new EventHandler(Content_ColumnNamesChanged);
    7675      Content.ItemsAdded += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);
     
    8382    protected override void DeregisterContentEvents() {
    8483      base.DeregisterContentEvents();
    85       Content.Reset -= new EventHandler(Content_Reset);
    8684      Content.ColumnNamesChanged -= new EventHandler(Content_ColumnNamesChanged);
    8785      Content.ItemsAdded -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);
     
    142140      DeregisterRunEvents(e.OldItems);
    143141      RegisterRunEvents(e.Items);
    144       UpdateAll();
     142      if (!suppressUpdates) UpdateAll();
    145143    }
    146144    private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) {
    147145      DeregisterRunEvents(e.Items);
    148       UpdateComboBoxes();
     146      if (!suppressUpdates) UpdateComboBoxes();
    149147    }
    150148    private void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRun> e) {
    151149      RegisterRunEvents(e.Items);
    152       UpdateComboBoxes();
     150      if (!suppressUpdates) UpdateComboBoxes();
    153151    }
    154152    private void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) {
     
    157155      else {
    158156        suppressUpdates = Content.UpdateOfRunsInProgress;
    159         if (!suppressUpdates) UpdateDataPoints();
    160       }
    161     }
    162 
    163     private void Content_Reset(object sender, EventArgs e) {
    164       if (InvokeRequired)
    165         Invoke(new EventHandler(Content_Reset), sender, e);
    166       else {
    167         this.categoricalMapping.Clear();
    168         UpdateDataPoints();
    169         UpdateAxisLabels();
     157        if (!suppressUpdates) UpdateAll();
    170158      }
    171159    }
     
    174162        Invoke(new EventHandler(Content_ColumnNamesChanged), sender, e);
    175163      else {
    176         if (!suppressUpdates) {
    177           UpdateComboBoxes();
    178         }
     164        if (!suppressUpdates) UpdateComboBoxes();
    179165      }
    180166    }
     
    182168      if (InvokeRequired)
    183169        this.Invoke(new EventHandler(run_Changed), sender, e);
    184       else if (!suppressUpdates) {
    185         UpdateDataPoints();
    186       }
     170      else if (!suppressUpdates) UpdateDataPoints();
    187171    }
    188172
     
    190174      if (InvokeRequired)
    191175        Invoke(new EventHandler(Content_AlgorithmNameChanged), sender, e);
    192       else UpdateCaption();
     176      else if (!suppressUpdates) UpdateCaption();
    193177    }
    194178    #endregion
     
    226210        if (values.Any()) {
    227211          if (hypergeometricCheckBox.Checked) {
    228             xAxisTextBox.Text += ((int)(values.Count() / 16)) + delimitor + " ";
    229             xAxisTextBox.Text += ((int)(values.Count() / 8)) + delimitor + " ";
     212            xAxisTextBox.Text += ((int)(values.Count() / 16)) + delimiter + " ";
     213            xAxisTextBox.Text += ((int)(values.Count() / 8)) + delimiter + " ";
    230214            xAxisTextBox.Text += (int)(values.Count() / 4);
    231215          } else {
    232             xAxisTextBox.Text += ((int)(values.Count() / 4)) + delimitor + " ";
    233             xAxisTextBox.Text += ((int)(values.Count() / 2)) + delimitor + " ";
    234             xAxisTextBox.Text += ((int)(values.Count() / 4 * 3)) + delimitor + " ";
     216            xAxisTextBox.Text += ((int)(values.Count() / 4)) + delimiter + " ";
     217            xAxisTextBox.Text += ((int)(values.Count() / 2)) + delimiter + " ";
     218            xAxisTextBox.Text += ((int)(values.Count() / 4 * 3)) + delimiter + " ";
    235219            xAxisTextBox.Text += (int)(values.Count());
    236220          }
     
    340324
    341325    private List<int> ParseGroupSizesFromText(string groupsText, bool verbose = true) {
    342       string[] gs = groupsText.Split(delimitor.ToCharArray());
     326      string[] gs = groupsText.Split(delimiter.ToCharArray());
    343327      List<int> vals = new List<int>();
    344328
     
    351335            v = int.Parse(ns);
    352336            vals.Add(v);
    353           }
    354           catch (Exception ex) {
     337          } catch (Exception ex) {
    355338            if (verbose) {
    356               ErrorHandling.ShowErrorDialog("Can't parse group sizes. Please only use numbers seperated by a " + delimitor + ". ", ex);
     339              ErrorHandling.ShowErrorDialog("Can't parse group sizes. Please only use numbers seperated by a " + delimiter + ". ", ex);
    357340            }
    358341          }
     
    625608          string newVals = "";
    626609          foreach (int v in values) {
    627             newVals += v + delimitor + " ";
     610            newVals += v + delimiter + " ";
    628611          }
    629612          xAxisTextBox.Text = newVals;
  • trunk/sources/HeuristicLab.Analysis.Statistics.Views/3.3/StatisticalTestsView.cs

    r12131 r12599  
    4040    private const int requiredSampleSize = 5;
    4141    private double[][] data;
     42    private bool suppressUpdates = false;
    4243
    4344    public double SignificanceLevel {
     
    105106
    106107    void Content_RowsChanged(object sender, EventArgs e) {
    107       RebuildDataTable();
     108      if (suppressUpdates) return;
     109      if (InvokeRequired) Invoke((Action<object, EventArgs>)Content_RowsChanged, sender, e);
     110      else {
     111        RebuildDataTable();
     112      }
    108113    }
    109114
    110115    void Content_ColumnsChanged(object sender, EventArgs e) {
    111       if (!Content.UpdateOfRunsInProgress) {
     116      if (suppressUpdates) return;
     117      if (InvokeRequired) Invoke((Action<object, EventArgs>)Content_ColumnsChanged, sender, e);
     118      else {
    112119        RebuildDataTable();
    113120      }
     
    115122
    116123    private void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) {
    117       RebuildDataTable();
     124      if (suppressUpdates) return;
     125      if (InvokeRequired) Invoke((Action<object, CollectionItemsChangedEventArgs<IRun>>)Content_CollectionReset, sender, e);
     126      else {
     127        RebuildDataTable();
     128      }
    118129    }
    119130
    120131    void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) {
    121       if (!Content.UpdateOfRunsInProgress) {
    122         RebuildDataTable();
     132      if (InvokeRequired) Invoke((Action<object, EventArgs>)Content_UpdateOfRunsInProgressChanged, sender, e);
     133      else {
     134        suppressUpdates = Content.UpdateOfRunsInProgress;
     135        if (!suppressUpdates) RebuildDataTable();
    123136      }
    124137    }
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionChartAggregationView.cs

    r12012 r12599  
    168168
    169169    private void UpdateRuns(IEnumerable<IRun> runs) {
    170       if (suppressUpdates) return;
    171170      foreach (var run in runs) {
    172171        //update color
    173         foreach (var dataRow in runMapping[run]) {
    174           dataRow.VisualProperties.Color = run.Color;
     172        if (!runMapping.ContainsKey(run)) {
     173          runMapping[run] = ExtractDataRowsFromRun(run).ToList();
     174          RegisterRunEvents(run);
     175        } else {
     176          foreach (var dataRow in runMapping[run]) {
     177            dataRow.VisualProperties.Color = run.Color;
     178          }
    175179        }
    176         //update visibility - remove and add all rows to keep the same order as before
    177         combinedDataTable.Rows.Clear();
    178         combinedDataTable.Rows.AddRange(runMapping.Where(mapping => mapping.Key.Visible).SelectMany(mapping => mapping.Value));
    179       }
     180      }
     181      //update visibility - remove and add all rows to keep the same order as before
     182      combinedDataTable.Rows.Clear();
     183      combinedDataTable.Rows.AddRange(runMapping.Where(mapping => mapping.Key.Visible).SelectMany(mapping => mapping.Value));
    180184    }
    181185
    182186    private IEnumerable<DataRow> ExtractDataRowsFromRun(IRun run) {
    183187      var resultName = (string)dataTableComboBox.SelectedItem;
     188      if (string.IsNullOrEmpty(resultName)) yield break;
     189
    184190      var rowName = (string)dataRowComboBox.SelectedItem;
    185191      if (!run.Results.ContainsKey(resultName)) yield break;
Note: See TracChangeset for help on using the changeset viewer.