Vespucci  1.0.0
kmeansdialog.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright (C) 2014-2016 Wright State University - All Rights Reserved
3  Daniel P. Foose - Maintainer/Lead Developer
4 
5  This file is part of Vespucci.
6 
7  Vespucci 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  Vespucci 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 Vespucci. If not, see <http://www.gnu.org/licenses/>.
19 *******************************************************************************/
21 #include "ui_kmeansdialog.h"
23 
30 KMeansDialog::KMeansDialog(QWidget *parent, QSharedPointer<VespucciWorkspace> ws, QSharedPointer<AbstractDataAnalyzer> analyzer) :
31  QDialog(parent),
32  ui(new Ui::KMeansDialog),
33  workspace_(ws),
34  analyzer_(analyzer)
35 {
36  ui->setupUi(this);
37  workspace_ = ws;
38  analyzer_ = analyzer;
39  ui->clustersSpinBox->setRange(0, analyzer_->columns());
40 }
41 
43 {
44  delete ui;
45 }
46 
50 void KMeansDialog::on_buttonBox_accepted()
51 {
52  QString name = ui->nameLineEdit->text();
53  QString metric_text = ui->metricComboBox->currentText();
54  metric_text = metric_text.toLower().remove(" ");
55  QString partition_policy = ui->partitionComboBox->currentText();
56  partition_policy = partition_policy.toLower().remove(" ");
57  bool allow_empty = ui->emptyCheckBox->isChecked();
58  size_t clusters = ui->clustersSpinBox->value();
59  try{
60  analyzer_->KMeans(name, metric_text, partition_policy, allow_empty, clusters);
61  }catch(exception e){
62  workspace_->main_window()->DisplayExceptionWarning(e);
63  }
64  analyzer_.clear();
65  close();
66 }
67 
71 void KMeansDialog::on_buttonBox_rejected()
72 {
73  close();
74  analyzer_.clear();
75 }
76 
77 void KMeansDialog::on_predictionCheckBox_clicked(bool checked)
78 {
79  ui->clustersSpinBox->setEnabled(!checked);
80 }
Definition: ahcadialog.h:26
The KMeansDialog class Allows the user to create a k-means clustering map.
Definition: kmeansdialog.h:33
KMeansDialog(QWidget *parent, QSharedPointer< VespucciWorkspace > ws, QSharedPointer< AbstractDataAnalyzer > analyzer)
KMeansDialog::KMeansDialog.