Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13853


Ignore:
Timestamp:
05/19/16 15:31:30 (9 years ago)
Author:
pfleck
Message:

#2597

  • Added GradientChartConfigurationDialog to allow setup x/y axis and drawing steps.
  • Added "calculating pending"-icon only after 100ms to avoid flickering.
  • Fixed some small issues.
Location:
branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/DensityTrackbar.cs

    r13850 r13853  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Drawing;
    2425using System.Globalization;
    2526using System.Windows.Forms;
     
    9192      trackBar.Enabled = !Checked;
    9293      textBox.Text = Checked ? "Plotted" : Value.ToString(CultureInfo.InvariantCulture);
     94      radioButton.BackColor = Checked ? SystemColors.ActiveCaption : SystemColors.Control;
    9395      OnCheckedChanged();
    9496    }
  • branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/GradientChart.Designer.cs

    r13850 r13853  
    3030      System.Windows.Forms.DataVisualization.Charting.StripLine stripLine2 = new System.Windows.Forms.DataVisualization.Charting.StripLine();
    3131      System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
     32      this.calculationPendingLabel = new System.Windows.Forms.Label();
     33      this.calculationPendingTimer = new System.Windows.Forms.Timer(this.components);
    3234      this.chart = new HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart();
    33       this.statusLabel = new System.Windows.Forms.Label();
    3435      ((System.ComponentModel.ISupportInitialize)(this.chart)).BeginInit();
    3536      this.SuspendLayout();
     37      //
     38      // calculationPendingLabel
     39      //
     40      this.calculationPendingLabel.BackColor = System.Drawing.Color.White;
     41      this.calculationPendingLabel.Image = HeuristicLab.Common.Resources.VSImageLibrary.Timer;
     42      this.calculationPendingLabel.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
     43      this.calculationPendingLabel.Location = new System.Drawing.Point(3, 3);
     44      this.calculationPendingLabel.Margin = new System.Windows.Forms.Padding(0);
     45      this.calculationPendingLabel.Name = "calculationPendingLabel";
     46      this.calculationPendingLabel.Size = new System.Drawing.Size(17, 17);
     47      this.calculationPendingLabel.TabIndex = 1;
     48      this.calculationPendingLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
     49      this.calculationPendingLabel.Visible = false;
     50      //
     51      // calculationPendingTimer
     52      //
     53      this.calculationPendingTimer.Tick += new System.EventHandler(this.calculationPendingTimer_Tick);
    3654      //
    3755      // chart
     
    6886      this.chart.TabIndex = 0;
    6987      this.chart.AnnotationPositionChanging += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.AnnotationPositionChangingEventArgs>(this.chart_AnnotationPositionChanging);
    70       this.chart.FormatNumber += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.FormatNumberEventArgs>(this.chart_FormatNumber);
    7188      this.chart.DragDrop += new System.Windows.Forms.DragEventHandler(this.chart_DragDrop);
    7289      this.chart.DragEnter += new System.Windows.Forms.DragEventHandler(this.chart_DragEnter);
    7390      this.chart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove);
    74       //
    75       // statusLabel
    76       //
    77       this.statusLabel.BackColor = System.Drawing.Color.White;
    78       this.statusLabel.Image = HeuristicLab.Common.Resources.VSImageLibrary.Timer;
    79       this.statusLabel.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
    80       this.statusLabel.Location = new System.Drawing.Point(3, 3);
    81       this.statusLabel.Margin = new System.Windows.Forms.Padding(0);
    82       this.statusLabel.Name = "statusLabel";
    83       this.statusLabel.Size = new System.Drawing.Size(17, 17);
    84       this.statusLabel.TabIndex = 1;
    85       this.statusLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
    86       this.statusLabel.Visible = false;
    8791      //
    8892      // GradientChart
     
    9094      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    9195      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    92       this.Controls.Add(this.statusLabel);
     96      this.Controls.Add(this.calculationPendingLabel);
    9397      this.Controls.Add(this.chart);
    9498      this.Name = "GradientChart";
     
    102106
    103107    private HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart chart;
    104     private System.Windows.Forms.Label statusLabel;
     108    private System.Windows.Forms.Label calculationPendingLabel;
     109    private System.Windows.Forms.Timer calculationPendingTimer;
    105110  }
    106111}
  • branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/GradientChart.cs

    r13850 r13853  
    4444    private readonly Dictionary<IRegressionSolution, Series> ciSeriesCache;
    4545
     46    private readonly ToolStripMenuItem configToolStripMenuItem;
     47    private readonly GradientChartConfigurationDialog configurationDialog;
     48
    4649    #region Properties
    4750    public bool ShowLegend {
     
    4952      set { chart.Legends[0].Enabled = value; }
    5053    }
    51     public bool ShowXAxisLabel {
    52       get { return chart.ChartAreas[0].AxisX.Enabled == AxisEnabled.True; }
    53       set { chart.ChartAreas[0].AxisX.Enabled = value ? AxisEnabled.True : AxisEnabled.False; }
    54     }
    55     public bool ShowYAxisLabel {
    56       get { return chart.ChartAreas[0].AxisY.Enabled == AxisEnabled.True; }
    57       set { chart.ChartAreas[0].AxisY.Enabled = value ? AxisEnabled.True : AxisEnabled.False; }
    58     }
    5954    public bool ShowCursor {
    6055      get { return chart.Annotations[0].Visible; }
    61       set { chart.Annotations[0].Visible = value; }
     56      set {
     57        chart.Annotations[0].Visible = value;
     58        if (!value) chart.ChartAreas[0].AxisX.Title = string.Empty;
     59      }
    6260    }
    6361
     
    191189      chart.ChartAreas[0].CursorY.Interval = 0;
    192190
     191      configToolStripMenuItem = new ToolStripMenuItem("Configuration");
     192      configToolStripMenuItem.Click += configToolStripMenuItem_Click;
     193      chart.ContextMenuStrip.Items.Add(new ToolStripSeparator());
     194      chart.ContextMenuStrip.Items.Add(configToolStripMenuItem);
     195
     196      configurationDialog = new GradientChartConfigurationDialog(this);
     197
    193198      Disposed += GradientChart_Disposed;
    194199    }
     200
    195201    private void GradientChart_Disposed(object sender, EventArgs e) {
    196202      if (cancelCurrentRecalculateSource != null)
     
    237243        return;
    238244
    239       statusLabel.Visible = true;
     245      calculationPendingTimer.Start();
     246
    240247      Update(); // immediately show label
    241248
     
    248255      var defaultValue = sharedFixedVariables.GetDoubleValue(freeVariable, 0);
    249256      VerticalLineAnnotation.X = defaultValue;
    250       chart.ChartAreas[0].AxisX.Title = FreeVariable + " : " + defaultValue.ToString("N3", CultureInfo.CurrentCulture);
     257      if (ShowCursor)
     258        chart.ChartAreas[0].AxisX.Title = FreeVariable + " : " + defaultValue.ToString("N3", CultureInfo.CurrentCulture);
    251259
    252260      // Update series
     
    264272        UpdateOutOfTrainingRangeStripLines();
    265273
    266         statusLabel.Visible = false;
     274        calculationPendingTimer.Stop();
     275        calculationPendingLabel.Visible = false;
    267276        if (updateOnFinish)
    268277          Update();
     
    437446      var series = seriesCache[solution];
    438447      series.Points.SuspendUpdates();
     448      series.Points.Clear();
    439449      for (int i = 0; i < xvalues.Count; i++)
    440450        series.Points.Add(new DataPoint(xvalues[i], 0.0));
     
    444454      if (ciSeriesCache.TryGetValue(solution, out confidenceIntervalSeries)) {
    445455        confidenceIntervalSeries.Points.SuspendUpdates();
     456        confidenceIntervalSeries.Points.Clear();
    446457        for (int i = 0; i < xvalues.Count; i++)
    447458          confidenceIntervalSeries.Points.Add(new DataPoint(xvalues[i], new[] { -1.0, 1.0 }));
     
    538549        newLocation = axisX.Minimum;
    539550
     551      if (oldCurserPosition.IsAlmost(newLocation))
     552        return;
     553
    540554      e.NewLocationX = newLocation;
     555      oldCurserPosition = e.NewLocationX;
    541556
    542557      var annotation = VerticalLineAnnotation;
     
    544559      sharedFixedVariables.SetVariableValue(x, FreeVariable, 0);
    545560
    546       chart.ChartAreas[0].AxisX.Title = FreeVariable + " : " + x.ToString("N3", CultureInfo.CurrentCulture);
    547       chart.Update();
    548 
    549       if (!oldCurserPosition.IsAlmost(e.NewLocationX))
    550         OnVariableValueChanged(this, EventArgs.Empty);
    551       oldCurserPosition = e.NewLocationX;
     561      if (ShowCursor) {
     562        chart.ChartAreas[0].AxisX.Title = FreeVariable + " : " + x.ToString("N3", CultureInfo.CurrentCulture);
     563        chart.Update();
     564      }
     565
     566      OnVariableValueChanged(this, EventArgs.Empty);
    552567    }
    553568
     
    555570      bool hitCursor = chart.HitTest(e.X, e.Y).ChartElementType == ChartElementType.Annotation;
    556571      chart.Cursor = hitCursor ? Cursors.VSplit : Cursors.Default;
    557     }
    558 
    559     private void chart_FormatNumber(object sender, FormatNumberEventArgs e) {
    560       if (e.ElementType == ChartElementType.AxisLabels) {
    561         switch (e.Format) {
    562           case "CustomAxisXFormat":
    563             break;
    564           case "CustomAxisYFormat":
    565             var v = e.Value;
    566             e.LocalizedValue = string.Format("{0,5}", v);
    567             break;
    568           default:
    569             break;
    570         }
    571       }
    572572    }
    573573
     
    590590      }
    591591    }
     592
     593    private void calculationPendingTimer_Tick(object sender, EventArgs e) {
     594      calculationPendingLabel.Visible = true;
     595      Update();
     596    }
     597
     598    private void configToolStripMenuItem_Click(object sender, EventArgs e) {
     599      configurationDialog.ShowDialog(this);
     600    }
    592601    #endregion
    593602  }
  • branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj

    r13850 r13853  
    282282    <Compile Include="GradientChart.Designer.cs">
    283283      <DependentUpon>GradientChart.cs</DependentUpon>
     284    </Compile>
     285    <Compile Include="GradientChartConfigurationDialog.cs">
     286      <SubType>Form</SubType>
     287    </Compile>
     288    <Compile Include="GradientChartConfigurationDialog.Designer.cs">
     289      <DependentUpon>GradientChartConfigurationDialog.cs</DependentUpon>
    284290    </Compile>
    285291    <Compile Include="Regression\RegressionSolutionGradientView.cs">
  • branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionGradientView.Designer.cs

    r13850 r13853  
    8181      this.gradientChart.Name = "gradientChart";
    8282      this.gradientChart.ShowCursor = false;
    83       this.gradientChart.ShowLegend = true;
    84       this.gradientChart.ShowXAxisLabel = false;
    85       this.gradientChart.ShowYAxisLabel = true;
     83      this.gradientChart.ShowLegend = false;
    8684      this.gradientChart.Size = new System.Drawing.Size(715, 376);
    8785      this.gradientChart.TabIndex = 0;
  • branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionGradientView.cs

    r13850 r13853  
    110110      tableLayoutPanel.ResumeRepaint(true);
    111111
     112      // Init Y-axis range
     113      var problemData = Content.ProblemData;
     114      double min = double.MaxValue, max = double.MinValue;
     115      var trainingTarget = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, problemData.TrainingIndices);
     116      foreach (var t in trainingTarget) {
     117        if (t < min) min = t;
     118        if (t > max) max = t;
     119      }
     120      double range = max - min;
     121      const double scale = 1.0 / 3.0;
     122      double axisMin, axisMax, axisInterval;
     123      ChartUtil.CalculateAxisInterval(min - scale * range, max + scale * range, 5, out axisMin, out axisMax, out axisInterval);
     124      gradientChart.FixedYAxisMin = axisMin;
     125      gradientChart.FixedYAxisMax = axisMax;
     126
    112127      trackbars.First().Checked = true;
    113128    }
  • branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionTargetResponseGradientView.Designer.cs

    r13850 r13853  
    5050      this.variableListView.Location = new System.Drawing.Point(3, 16);
    5151      this.variableListView.Name = "variableListView";
    52       this.variableListView.Size = new System.Drawing.Size(163, 482);
     52      this.variableListView.Size = new System.Drawing.Size(163, 503);
    5353      this.variableListView.TabIndex = 0;
    5454      this.variableListView.UseCompatibleStateImageBehavior = false;
     
    7777      this.yAxisConfigGroupBox.Location = new System.Drawing.Point(0, 0);
    7878      this.yAxisConfigGroupBox.Name = "yAxisConfigGroupBox";
    79       this.yAxisConfigGroupBox.Size = new System.Drawing.Size(169, 98);
     79      this.yAxisConfigGroupBox.Size = new System.Drawing.Size(169, 77);
    8080      this.yAxisConfigGroupBox.TabIndex = 2;
    8181      this.yAxisConfigGroupBox.TabStop = false;
     
    9797      //
    9898      this.automaticYAxisCheckBox.AutoSize = true;
    99       this.automaticYAxisCheckBox.Location = new System.Drawing.Point(6, 72);
     99      this.automaticYAxisCheckBox.Location = new System.Drawing.Point(49, -1);
    100100      this.automaticYAxisCheckBox.Name = "automaticYAxisCheckBox";
    101101      this.automaticYAxisCheckBox.Size = new System.Drawing.Size(73, 17);
     
    108108      this.densityGroupBox.Controls.Add(this.densityComboBox);
    109109      this.densityGroupBox.Dock = System.Windows.Forms.DockStyle.Top;
    110       this.densityGroupBox.Location = new System.Drawing.Point(0, 98);
     110      this.densityGroupBox.Location = new System.Drawing.Point(0, 77);
    111111      this.densityGroupBox.Name = "densityGroupBox";
    112112      this.densityGroupBox.Size = new System.Drawing.Size(169, 49);
     
    156156      this.variableGroupBox.Controls.Add(this.variableListView);
    157157      this.variableGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
    158       this.variableGroupBox.Location = new System.Drawing.Point(0, 147);
     158      this.variableGroupBox.Location = new System.Drawing.Point(0, 126);
    159159      this.variableGroupBox.Name = "variableGroupBox";
    160       this.variableGroupBox.Size = new System.Drawing.Size(169, 501);
     160      this.variableGroupBox.Size = new System.Drawing.Size(169, 522);
    161161      this.variableGroupBox.TabIndex = 1;
    162162      this.variableGroupBox.TabStop = false;
  • branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionTargetResponseGradientView.cs

    r13850 r13853  
    160160        ShowLegend = false,
    161161        ShowCursor = true,
    162         ShowXAxisLabel = true,
    163         ShowYAxisLabel = true,
    164162        YAxisTicks = 5,
    165163      };
Note: See TracChangeset for help on using the changeset viewer.