-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
136 lines (106 loc) · 3.22 KB
/
mainwindow.cpp
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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <iostream>
MainWindow::MainWindow(QWidget *parent):
QMainWindow(parent)
, ui(new Ui::MainWindow)
,tableLoaded(false)
{
ui->setupUi(this);
ui->tableWidget->init();
ui->toolButton->init(ui->tableWidget->getMatriceAddr());
ui->graphicsView->setTab(ui->tableWidget);
ui->graphicsView->updateDisplay();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::updateInfoContent()
{
//Ordre Label
Matrice matrice=ui->tableWidget->getMatrice();
QString qs;
cout<<"label to "+to_string(matrice.ordre)<<endl;
qs=qs.fromStdString(to_string(matrice.ordre));
ui->label_Ordre->setText(qs);
/*
QString symetrie;
if(matrice.type==Matrice::Type::NonOrientee)
symetrie=symetrie.fromStdString("oui");
ui->label_Symetrie->setText(symetrie);
*/
QString connexe;
if(matrice.isConnex())
connexe=connexe.fromStdString("oui");
else
connexe=connexe.fromStdString("non");
ui->label_Connexe->setText(connexe);
QString fortementConnexe;
if(matrice.isFortementConnex())
fortementConnexe=fortementConnexe.fromStdString("oui");
else
fortementConnexe=fortementConnexe.fromStdString("non");
ui->label_FortementConnexe->setText(fortementConnexe);
}
void MainWindow::on_pushButton_2_clicked()
{
Matrice matrice=ui->tableWidget->getMatrice();
vector<float> tab (matrice.ordre*matrice.ordre);
matrice.calculTransposee(tab);
Dialog dial(nullptr,tab);
dial.setModal(true);
dial.setWindowTitle("Transposée");
dial.exec();
}
void MainWindow::on_pushButton_clicked()
{
Matrice matrice=ui->tableWidget->getMatrice();
vector<float> tab (matrice.ordre*matrice.ordre);
int n=ui->factorNSpinBox->value();
matrice.calculPowN(n,tab);
Dialog dial(nullptr,tab);
dial.setModal(true);
dial.setWindowTitle("M^n");
dial.exec();
}
void MainWindow::on_typeChangeButton_clicked()
{
Matrice* matrice =ui->tableWidget->getMatriceAddr();
matrice->setNextType();
char ch[30];
strcpy(ch,matrice->getTypeToString().c_str());
QString qs(ch);
//ui->typeChangeButton->setText(qs);
ui->tableWidget->displayRefresh();
}
void MainWindow::on_pushButton_Ponderation_clicked()
{
Matrice* matrice =ui->tableWidget->getMatriceAddr();
matrice->setNextPonderation();
char ch[30];
strcpy(ch,matrice->getPondereToString().c_str());
QString qs(ch);
ui->pushButton_Ponderation->setText(qs);
// ui->tableWidget->setNextMatrice();
ui->tableWidget->displayRefresh();
}
void MainWindow::on_pushButton_Dijkstra_clicked()
{
Matrice matrice=ui->tableWidget->getMatrice();
vector<float> tab (matrice.ordre*matrice.ordre);
//int n=ui->factorNSpinBox->value();
Sommet* s =matrice.getSommetNum(0);
cout<<s->getName()+" pos = "+to_string(matrice.getPosSommet(s))<<endl;
matrice.calculateDijkstra(*s,tab);
cout<<"still ok"<<endl;
Dialog dial(this,tab);
dial.setModal(true);
dial.setWindowTitle("Dijkstra");
dial.exec();
}
void MainWindow::on_tableWidget_cellChanged(int row, int column)
{
ui->tableWidget-> resizeColumnsToContents();
ui->tableWidget-> resizeRowsToContents();
}