File: HistoStatsConfigWidget.cpp

package info (click to toggle)
tulip 4.8.0dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 179,264 kB
  • ctags: 64,517
  • sloc: cpp: 600,444; ansic: 36,311; makefile: 22,136; python: 1,304; sh: 946; yacc: 522; xml: 337; pascal: 157; php: 66; lex: 55
file content (169 lines) | stat: -rw-r--r-- 4,512 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/**
 *
 * This file is part of Tulip (www.tulip-software.org)
 *
 * Authors: David Auber and the Tulip development Team
 * from LaBRI, University of Bordeaux
 *
 * Tulip is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation, either version 3
 * of the License, or (at your option) any later version.
 *
 * Tulip is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 */

#include "HistoStatsConfigWidget.h"
#include "ui_HistoStatsConfigWidget.h"

using namespace std;

namespace tlp {

HistoStatsConfigWidget::HistoStatsConfigWidget(QWidget *parent) : QWidget(parent),_ui(new Ui::HistoStatsConfigWidget) {
  _ui->setupUi(this);
  connect(_ui->applyButton, SIGNAL(clicked()), this, SIGNAL(computeAndDrawInteractor()));

}

HistoStatsConfigWidget::~HistoStatsConfigWidget() {
  delete _ui;
}

double HistoStatsConfigWidget::getSampleStep() const {
  return _ui->sampleStepSB->value();
}

double HistoStatsConfigWidget::getBandwidth() const {
  return _ui->windowWidthSP->value();
}

QString HistoStatsConfigWidget::getKernelFunctionName() const {
  return _ui->kernelFunctionsList->currentText();
}

bool HistoStatsConfigWidget::densityEstimation() const {
  return _ui->densityEstimationGB->isChecked();
}

bool HistoStatsConfigWidget::displayMeanAndStandardDeviation() const {
  return _ui->displayMeanAndSdGB->isChecked();
}

bool HistoStatsConfigWidget::nodesSelection() const {
  return _ui->nodesSelectionGB->isChecked();
}

double HistoStatsConfigWidget::getSelectionLowerBound() const {
  return getBoundFromString(_ui->lowerBoundCB->currentText());
}

double HistoStatsConfigWidget::getSelectionUpperBound() const {
  return getBoundFromString(_ui->upperBoundCB->currentText());
}

void HistoStatsConfigWidget::setMinMaxMeanAndSd(double min, double max, double mean, double standardDeviation) {
  bool changed=false;

  if(this->min!=min) {
    this->min = min;
    changed=true;
  }

  if(this->max!=max) {
    this->max = max;
    changed=true;
  }

  if(this->mean!=mean) {
    this->mean = mean;
    changed=true;
  }

  if(this->standardDeviation!=standardDeviation) {
    this->standardDeviation = standardDeviation;
    changed=true;
  }

  if(changed) {
    _ui->meanValue->setText(QString::number(mean));
    _ui->standardDeviationValue->setText(QString::number(standardDeviation));
    _ui->lowerBoundCB->clear();
    _ui->upperBoundCB->clear();
    _ui->lowerBoundCB->addItem("min");
    _ui->upperBoundCB->addItem("min");
    bool m3sdOk = false;
    bool m2sdOk = false;

    if ((mean - (3 * standardDeviation)) > min) {
      _ui->lowerBoundCB->addItem("m - 3sd");
      _ui->upperBoundCB->addItem("m - 3sd");
      m3sdOk = true;
    }

    if ((mean - (2 * standardDeviation)) > min) {
      _ui->lowerBoundCB->addItem("m - 2sd");
      _ui->upperBoundCB->addItem("m - 2sd");
      m2sdOk = true;
    }

    _ui->lowerBoundCB->addItem("m - sd");
    _ui->upperBoundCB->addItem("m - sd");
    _ui->lowerBoundCB->addItem("m");
    _ui->upperBoundCB->addItem("m");
    _ui->lowerBoundCB->addItem("m + sd");
    _ui->upperBoundCB->addItem("m + sd");

    if (m2sdOk) {
      _ui->lowerBoundCB->addItem("m + 2sd");
      _ui->upperBoundCB->addItem("m + 2sd");
    }

    if (m3sdOk) {
      _ui->lowerBoundCB->addItem("m + 3sd");
      _ui->upperBoundCB->addItem("m + 3sd");
    }

    _ui->lowerBoundCB->addItem("max");
    _ui->upperBoundCB->addItem("max");

    _ui->lowerBoundCB->setCurrentIndex(_ui->lowerBoundCB->findText("m - sd"));
    _ui->upperBoundCB->setCurrentIndex(_ui->upperBoundCB->findText("m + sd"));
  }
}

double HistoStatsConfigWidget::getBoundFromString(const QString &bound) const {
  if (bound == "min") {
    return min;
  }
  else if (bound == "m - 3sd") {
    return (mean - 3 * standardDeviation);
  }
  else if (bound == "m - 2sd") {
    return (mean - 2 * standardDeviation);
  }
  else if (bound == "m - sd") {
    return (mean - standardDeviation);
  }
  else if (bound == "m") {
    return mean;
  }
  else if (bound == "m + sd") {
    return (mean + standardDeviation);
  }
  else if (bound == "m + 2sd") {
    return (mean + 2 * standardDeviation);
  }
  else if (bound == "m + 3sd") {
    return (mean + 3 * standardDeviation);
  }
  else {
    return max;
  }
}

}