Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/RegressionSolutionView.cs @ 14095

Last change on this file since 14095 was 14095, checked in by mkommend, 8 years ago

#2597: Merged all changesets from HeuristiLab.RegressionSolutionGradientView into the trunk.

File size: 3.2 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Linq;
24using System.Threading.Tasks;
25using System.Windows.Forms;
26using HeuristicLab.Core;
27using HeuristicLab.Data;
28using HeuristicLab.Data.Views;
29using HeuristicLab.MainForm;
30using HeuristicLab.MainForm.WindowsForms;
31
32namespace HeuristicLab.Problems.DataAnalysis.Views {
33  [View("Solution View")]
34  [Content(typeof(RegressionSolutionBase), false)]
35  public partial class RegressionSolutionView : DataAnalysisSolutionView {
36    public RegressionSolutionView() {
37      InitializeComponent();
38    }
39
40    public new RegressionSolutionBase Content {
41      get { return (RegressionSolutionBase)base.Content; }
42      set { base.Content = value; }
43    }
44
45    protected override void SetEnabledStateOfControls() {
46      base.SetEnabledStateOfControls();
47      btnImpactCalculation.Enabled = Content != null && !Locked;
48    }
49
50    protected virtual void btnImpactCalculation_Click(object sender, EventArgs e) {
51      var mainForm = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm;
52      var view = new StringConvertibleArrayView();
53      view.Caption = Content.Name + " Variable Impacts";
54      view.Show();
55
56      Task.Factory.StartNew(() => {
57        try {
58          mainForm.AddOperationProgressToView(view, "Calculating variable impacts for " + Content.Name);
59
60          var impacts = RegressionSolutionVariableImpactsCalculator.CalculateImpacts(Content);
61          var impactArray = new DoubleArray(impacts.Select(i => i.Item2).ToArray());
62          impactArray.ElementNames = impacts.Select(i => i.Item1);
63          view.Content = (DoubleArray)impactArray.AsReadOnly();
64        }
65        finally {
66          mainForm.RemoveOperationProgressFromView(view);
67        }
68      });
69    }
70
71    #region drag and drop
72    protected override void itemsListView_DragEnter(object sender, DragEventArgs e) {
73      validDragOperation = false;
74      if (ReadOnly) return;
75
76      var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
77      if (dropData is IRegressionProblemData) validDragOperation = true;
78      else if (dropData is IRegressionProblem) validDragOperation = true;
79      else if (dropData is IValueParameter) {
80        var param = (IValueParameter)dropData;
81        if (param.Value is RegressionProblemData) validDragOperation = true;
82      }
83    }
84    #endregion
85  }
86}
Note: See TracBrowser for help on using the repository browser.