Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6115


Ignore:
Timestamp:
05/03/11 19:52:35 (13 years ago)
Author:
abeham
Message:

#1465

  • Added new interface IConfigureableView to HeuristicLab.MainForm
  • Adapted ViewHost to show a configuration button when its ActiveView is of type IConfigureableView
  • Changed DataTableHistoryView to be an IConfigureableView
  • When changing the configuration of a history view the configuration will be applied to every frame
  • Fixed a bug in calculating the histogram (when all values were the same)
  • Added preceeding and trailing 0-bar in the histogram to prevent cutting the first and last column in the view
  • Added a method Replace(IEnumerable<T>) to the ObservableList to do Clear() and AddRange() with just a single event notification
    • Calling that method from the QualityDistributionAnalyzer (otherwise the result view is flickering)
  • Fixing a bug regarding axis labels in the QualityDistributionAnalyzer
  • Removed double AfterDeserializationHook in QAP
Location:
branches/histogram
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • branches/histogram/HeuristicLab.Analysis.Views/3.3/DataTableHistoryView.cs

    r5445 r6115  
    2727  [View("DataTableHistory View")]
    2828  [Content(typeof(DataTableHistory), true)]
    29   public partial class DataTableHistoryView : MovieView<DataTable> {
     29  public partial class DataTableHistoryView : MovieView<DataTable>, IConfigureableView {
    3030    public DataTableHistoryView() {
    3131      InitializeComponent();
    3232      itemsGroupBox.Text = "Data Table";
    3333    }
     34
     35    public void ShowConfiguration() {
     36      DataTable current = viewHost.Content as DataTable;
     37      if (current == null) return;
     38      using (DataTableVisualPropertiesDialog dialog = new DataTableVisualPropertiesDialog(current)) {
     39        if (dialog.ShowDialog() != DialogResult.OK) return;
     40        foreach (DataTable dt in Content) {
     41          if (current != dt) {
     42            dt.VisualProperties = (DataTableVisualProperties)current.VisualProperties.Clone();
     43            foreach (DataRow row in current.Rows)
     44              dt.Rows[row.Name].VisualProperties = (DataRowVisualProperties)row.VisualProperties.Clone();
     45          }
     46        }
     47      }
     48    }
     49
    3450  }
    3551}
  • branches/histogram/HeuristicLab.Analysis.Views/3.3/DataTableView.cs

    r6032 r6115  
    236236      }
    237237      area.RecalculateAxesScale();
     238      area.AxisX.IsMarginVisible = false;
     239      area.AxisX2.IsMarginVisible = false;
    238240
    239241      if (!Content.VisualProperties.XAxisMinimumAuto && !double.IsNaN(Content.VisualProperties.XAxisMinimumFixedValue)) area.AxisX.Minimum = Content.VisualProperties.XAxisMinimumFixedValue;
    240       #region Workaround for bug in RecalculateAxesScale() that would assign -1
    241       else {
    242         if (area.AxisX.IsStartedFromZero
    243         && chart.Series.Where(x => x.XAxisType == AxisType.Primary).Any()
    244         && chart.Series.Where(x => x.XAxisType == AxisType.Primary).SelectMany(x => x.Points).Any()) {
    245           double minX = chart.Series.Where(x => x.XAxisType == AxisType.Primary).SelectMany(x => x.Points).Select(x => x.XValue).Min();
    246           if (minX >= 0 && area.AxisX.Minimum < 0) area.AxisX.Minimum = 0;
    247         }
    248       }
    249       #endregion
    250242      if (!Content.VisualProperties.XAxisMaximumAuto && !double.IsNaN(Content.VisualProperties.XAxisMaximumFixedValue)) area.AxisX.Maximum = Content.VisualProperties.XAxisMaximumFixedValue;
    251243      if (!Content.VisualProperties.SecondXAxisMinimumAuto && !double.IsNaN(Content.VisualProperties.SecondXAxisMinimumFixedValue)) area.AxisX2.Minimum = Content.VisualProperties.SecondXAxisMinimumFixedValue;
    252       #region Workaround for bug in RecalculateAxesScale() that would assign -1
    253       else {
    254         if (area.AxisX2.IsStartedFromZero
    255          && chart.Series.Where(x => x.XAxisType == AxisType.Secondary).Any()
    256          && chart.Series.Where(x => x.XAxisType == AxisType.Secondary).SelectMany(x => x.Points).Any()) {
    257           double minX2 = chart.Series.Where(x => x.XAxisType == AxisType.Secondary).SelectMany(x => x.Points).Select(x => x.XValue).Min();
    258           if (minX2 >= 0 && area.AxisX2.Minimum < 0) area.AxisX2.Minimum = 0;
    259         }
    260       }
    261       #endregion
    262244      if (!Content.VisualProperties.SecondXAxisMaximumAuto && !double.IsNaN(Content.VisualProperties.SecondXAxisMaximumFixedValue)) area.AxisX2.Maximum = Content.VisualProperties.SecondXAxisMaximumFixedValue;
    263245      if (!Content.VisualProperties.YAxisMinimumAuto && !double.IsNaN(Content.VisualProperties.YAxisMinimumFixedValue)) area.AxisY.Minimum = Content.VisualProperties.YAxisMinimumFixedValue;
     
    575557      double maxValue = row.Values.Max();
    576558      double intervalWidth = (maxValue - minValue) / bins;
    577       if (intervalWidth <= 0) return;
     559      if (intervalWidth < 0) return;
     560      if (intervalWidth == 0) {
     561        series.Points.AddXY(minValue, row.Values.Count);
     562        return;
     563      }
    578564
    579565      if (!row.VisualProperties.ExactBins) {
     
    585571      double current = minValue, intervalCenter = intervalWidth / 2.0;
    586572      int frequency = 0;
     573      series.Points.AddXY(current - intervalCenter, 0); // so that the first column is not visually truncated
    587574      foreach (double v in row.Values.Where(x => !IsInvalidValue(x)).OrderBy(x => x)) {
    588575        while (v > current + intervalWidth) {
     
    594581      }
    595582      series.Points.AddXY(current + intervalCenter, frequency);
     583      series.Points.AddXY(current + 3 * intervalCenter, 0); // so that the last column is not visually truncated
    596584    }
    597585
  • branches/histogram/HeuristicLab.Analysis/3.3/QualityAnalysis/QualityDistributionAnalyzer.cs

    r6013 r6115  
    9797      } else {
    9898        qualityDistribution = new DataTable("Population Quality Distribution", description);
    99         qualityDistribution.VisualProperties.XAxisTitle = IterationsParameter.ActualName;
    100         qualityDistribution.VisualProperties.YAxisTitle = QualityParameter.ActualName;
     99        qualityDistribution.VisualProperties.XAxisTitle = QualityParameter.ActualName;
     100        qualityDistribution.VisualProperties.YAxisTitle = "Frequency";
    101101        results.Add(new Result(HistogramName, description, qualityDistribution));
    102102      }
     
    108108      }
    109109      var qualities = QualityParameter.ActualValue;
    110       row.Values.Clear();
    111       row.Values.AddRange(qualities.Select(x => x.Value));
     110      row.Values.Replace(qualities.Select(x => x.Value));
    112111
    113112      if (StoreHistory) {
  • branches/histogram/HeuristicLab.Collections/3.3/ObservableList.cs

    r5445 r6115  
    2424using System.Collections.Generic;
    2525using System.ComponentModel;
     26using System.Linq;
    2627using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2728
     
    211212    }
    212213
     214    /// <summary>
     215    /// Performs a Clear and an AddRange, but does not fire separate events for those operations
     216    /// </summary>
     217    /// <param name="collection"></param>
     218    public void Replace(IEnumerable<T> collection) {
     219      List<IndexedItem<T>> oldItems = null;
     220      if (list.Any()) oldItems = list.Select((x, i) => new IndexedItem<T>(i, x)).ToList();
     221      else oldItems = new List<IndexedItem<T>>();
     222
     223      int oldCapacity = list.Capacity;
     224      list.Clear();
     225      list.AddRange(collection);
     226
     227      List<IndexedItem<T>> items = null;
     228      if (list.Any()) items = list.Select((x, i) => new IndexedItem<T>(i, x)).ToList();
     229      else items = new List<IndexedItem<T>>();
     230
     231      if (oldCapacity != list.Capacity) OnPropertyChanged("Capacity");
     232      OnPropertyChanged("Item[]");
     233      if (oldItems.Count != items.Count) OnPropertyChanged("Count");
     234      OnItemsReplaced(items, oldItems);
     235    }
     236
    213237    public bool Remove(T item) {
    214238      int index = list.IndexOf(item);
  • branches/histogram/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ViewHost.Designer.cs

    r5956 r6115  
    5151      this.viewContextMenuStrip = new HeuristicLab.MainForm.WindowsForms.ViewContextMenuStrip();
    5252      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
     53      this.configurationLabel = new System.Windows.Forms.Label();
    5354      this.SuspendLayout();
    5455      //
     
    8687      this.viewContextMenuStrip.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.viewContextMenuStrip_ItemClicked);
    8788      //
     89      // configurationLabel
     90      //
     91      this.configurationLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
     92      this.configurationLabel.Image = HeuristicLab.Common.Resources.VSImageLibrary.EditInformation;
     93      this.configurationLabel.Location = new System.Drawing.Point(211, 22);
     94      this.configurationLabel.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);
     95      this.configurationLabel.Name = "configurationLabel";
     96      this.configurationLabel.Size = new System.Drawing.Size(16, 16);
     97      this.configurationLabel.TabIndex = 0;
     98      this.configurationLabel.Visible = false;
     99      this.configurationLabel.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.configurationLabel_MouseDoubleClick);
     100      //
    88101      // ViewHost
    89102      //
     
    91104      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    92105      this.Controls.Add(this.viewsLabel);
     106      this.Controls.Add(this.configurationLabel);
    93107      this.Controls.Add(this.messageLabel);
    94108      this.Name = "ViewHost";
     
    103117    private System.Windows.Forms.ToolTip toolTip;
    104118    private HeuristicLab.MainForm.WindowsForms.ViewContextMenuStrip viewContextMenuStrip;
     119    private System.Windows.Forms.Label configurationLabel;
    105120
    106121  }
  • branches/histogram/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ViewHost.cs

    r5956 r6115  
    101101            }
    102102          } else viewType = null;
     103          configurationLabel.Visible = activeView is IConfigureableView;
     104          configurationLabel.Enabled = activeView != null && !activeView.Locked;
    103105        }
    104106      }
     
    189191    private void activeView_LockedChanged(object sender, EventArgs e) {
    190192      Locked = activeView.Locked;
     193      configurationLabel.Enabled = !activeView.Locked;
    191194    }
    192195
     
    200203      base.OnSizeChanged(e);
    201204      viewsLabel.Location = new Point(Width - viewsLabel.Margin.Right - viewsLabel.Width, viewsLabel.Margin.Top);
     205      configurationLabel.Location = new Point(Width - configurationLabel.Margin.Right - configurationLabel.Width, viewsLabel.Bottom + viewsLabel.Margin.Bottom + configurationLabel.Margin.Top);
    202206    }
    203207
     
    287291        startDragAndDrop = false;
    288292    }
     293
     294    private void configurationLabel_MouseDoubleClick(object sender, MouseEventArgs e) {
     295      ((IConfigureableView)ActiveView).ShowConfiguration();
     296    }
    289297    #endregion
    290298  }
  • branches/histogram/HeuristicLab.MainForm/3.3/HeuristicLab.MainForm-3.3.csproj

    r5163 r6115  
    1212    <AssemblyName>HeuristicLab.MainForm-3.3</AssemblyName>
    1313    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    14     <TargetFrameworkProfile></TargetFrameworkProfile>
     14    <TargetFrameworkProfile>
     15    </TargetFrameworkProfile>
    1516    <FileAlignment>512</FileAlignment>
    1617    <SignAssembly>true</SignAssembly>
     
    111112  <ItemGroup>
    112113    <None Include="HeuristicLabMainFormPlugin.cs.frame" />
     114    <Compile Include="Interfaces\IConfigureableView.cs" />
    113115    <Compile Include="ViewAttribute.cs" />
    114116    <Compile Include="Interfaces\IContentView.cs" />
  • branches/histogram/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs

    r6089 r6115  
    164164        Parameters.Add(new OptionalValueParameter<ItemList<Permutation>>("BestKnownSolutions", "The list of best known solutions which is updated whenever a new better solution is found or may be the optimal solution if it is known beforehand.", null));
    165165      }
     166      if (Parameters.ContainsKey("DistanceMatrix")) {
     167        DoubleMatrix bla = ((ValueParameter<DoubleMatrix>)Parameters["DistanceMatrix"]).Value;
     168        Parameters.Remove("DistanceMatrix");
     169        Parameters.Add(new ValueParameter<DoubleMatrix>("Distances", "bla", bla));
     170      }
     171      AttachEventHandlers();
    166172      #endregion
    167173    }
     
    252258
    253259    #region Helpers
    254     [StorableHook(HookType.AfterDeserialization)]
    255     private void AfterDeserializationHook() {
    256       AttachEventHandlers();
    257     }
    258 
    259260    private void AttachEventHandlers() {
    260261      SolutionCreator.PermutationParameter.ActualNameChanged += new EventHandler(SolutionCreator_PermutationParameter_ActualNameChanged);
Note: See TracChangeset for help on using the changeset viewer.