-
Notifications
You must be signed in to change notification settings - Fork 0
/
matrixbuttons.cpp
105 lines (81 loc) · 2.12 KB
/
matrixbuttons.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
#include "matrixbuttons.h"
#include "ui_matrixbuttons.h"
MatrixButtons::MatrixButtons(MatrixWidget &matrix, Matrix &lastMatrix, QWidget *parent) :
QWidget(parent),
ui(new Ui::MatrixButtons)
{
ui->setupUi(this);
this->matrix = &matrix;
this->lastMatrix = &lastMatrix;
}
MatrixButtons::~MatrixButtons()
{
delete ui;
}
void MatrixButtons::on_calcDetBtn_clicked()
{
ui->detLbl->setText("Determinant = " + QString::number(matrix->matrix.determinant()));
}
void MatrixButtons::on_calcAlgAddBtn_clicked()
{
int i = ui->iEdit->text().toInt();
int j = ui->jEdit->text().toInt();
ui->algAddLbl->setText("AlgAdd = " + QString::number(matrix->matrix.algAddition(i, j)));
}
void MatrixButtons::on_transposeBtn_clicked()
{
*lastMatrix = matrix->matrix;
matrix->matrix.transpose();
matrix->update();
}
void MatrixButtons::on_reverseBtn_clicked()
{
*lastMatrix = matrix->matrix;
matrix->matrix.reverse();
matrix->update();
}
void MatrixButtons::on_delRowBtn_clicked()
{
*lastMatrix = matrix->matrix;
matrix->matrix.delRow(ui->iDelEdit->text().toInt());//DADA TODO
matrix->update();
}
void MatrixButtons::on_delColBtn_clicked()
{
*lastMatrix = matrix->matrix;
matrix->matrix.delColumn(ui->jDelEdit->text().toInt());//DADA TODO
matrix->update();
}
void MatrixButtons::on_backBtn_clicked()
{
std::swap(matrix->matrix, *lastMatrix);
matrix->update();
}
void MatrixButtons::on_swapColsBtn_clicked()
{
int j1 = ui->j1Edit->text().toInt();
int j2 = ui->j2Edit->text().toInt();
*lastMatrix = matrix->matrix;
matrix->matrix.swapColumns(j1, j2);
matrix->update();
}
void MatrixButtons::on_swapRowsBtn_clicked()
{
int i1 = ui->i1Edit->text().toInt();
int i2 = ui->i2Edit->text().toInt();
*lastMatrix = matrix->matrix;
matrix->matrix.swapRows(i1, i2);
matrix->update();
}
void MatrixButtons::on_addRowBtn_clicked()
{
*lastMatrix = matrix->matrix;
matrix->matrix.addRow();
matrix->update();
}
void MatrixButtons::on_addColBtn_clicked()
{
*lastMatrix = matrix->matrix;
matrix->matrix.addColumn();
matrix->update();
}