-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathKMeansParametersDialog.cpp
More file actions
77 lines (59 loc) · 2.24 KB
/
KMeansParametersDialog.cpp
File metadata and controls
77 lines (59 loc) · 2.24 KB
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
#include "KMeansParametersDialog.hpp"
#include "ui_KMeansParametersDialog.h"
KMeansParametersDialog::KMeansParametersDialog(KMeansNode* cvor, QWidget *parent) :
QDialog(parent),
ui(new Ui::KMeansParametersDialog),
kmN(cvor)
{
ui->setupUi(this);
}
KMeansParametersDialog::~KMeansParametersDialog()
{
delete ui;
}
void KMeansParametersDialog::on_Odabir_clicked()
{
if(ui->UnosIteracija->text().isEmpty() || ui->UnosBrKlastera->text().isEmpty() ||
ui->Rastojanja->selectedItems().isEmpty())
{
QMessageBox::information(this, "Greska!", "Popunite sva polja i odaberite zeljeno rastojanje!");
return;
}
bool ok;
int brIter = ui->UnosIteracija->text().toInt(&ok);
if(ok == false){
QMessageBox::information(this, "Greska!", "Unesite odgovarajucu vrednost za broj iteracija!");
return;
}
if(brIter < 0){
QMessageBox::information(this, "Greska!", "Broj iteracija ne moze biti negativan!");
return;
}
size_t brIter_t = brIter;
int brKlastera = ui->UnosBrKlastera->text().toInt(&ok);
if(ok == false){
QMessageBox::information(this, "Greska!", "Unesite odgovarajucu vrednost za broj klastera (>= 2)!");
return;
}
if(brKlastera < 2 ){
QMessageBox::information(this, "Greska!", "Unesite broj klastera >= 2 !");
return;
}
size_t brKlastera_t = brKlastera;
kmN->SetNumberOfClusters(brKlastera_t);
kmN->SetMaxNumberOfIterations(brIter_t);
auto odabranoRastojanje = ui->Rastojanja->selectedItems();
if(odabranoRastojanje[0]->text() == "Euklidsko Rastojanje"){
kmN->SetDistance(KMeansNode::distances::EuclideanDistance);
}else if(odabranoRastojanje[0]->text() == "Kvadratno Euklidsko Rastojanje"){
kmN->SetDistance(KMeansNode::distances::SquaredEuclideanDistance);
}else if(odabranoRastojanje[0]->text() == "Menhetn Rastojanje"){
kmN->SetDistance(KMeansNode::distances::ManhattanDistance);
}else if(odabranoRastojanje[0]->text() == "Cebisevljevo Rastojanje"){
kmN->SetDistance(KMeansNode::distances::ChebyshevDistance);
}else{
QMessageBox::information(this, "Greska!", "Doslo je do nepoznate greske!");
return;
}
this->close();
}