-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnectionmatrixview.cpp
More file actions
47 lines (37 loc) · 1.14 KB
/
connectionmatrixview.cpp
File metadata and controls
47 lines (37 loc) · 1.14 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
#include "connectionmatrixview.h"
ConnectionMatrixView::ConnectionMatrixView(QWidget *parent) : QWidget(parent)
{
myLayout=new QVBoxLayout(this);
this->setLayout(myLayout);
}
void ConnectionMatrixView::update(QObject * sender){
Q_UNUSED(sender);
source=Engine::getInstance()->getGraph();
QLayoutItem *wItem;
while (true){
wItem=this->myLayout->takeAt(0);
if(!wItem){
break;
}
delete wItem->widget();
delete wItem;
}
delete myLayout;
myLayout=new QVBoxLayout(this);
this->setLayout(myLayout);
std::vector<std::vector<int> > connectionMatrix=source->getIncidenceMatrix();
for(unsigned i=0;i<connectionMatrix.size();i++){
QLabel * row=new QLabel(this);
QString result(QString::number(i+1)+":\t");
for(unsigned j=0;j<connectionMatrix[i].size();j++){
result+="|";
if(connectionMatrix[i][j]!=-1){
result+=" ";
}
result=result+QString::number(connectionMatrix[i][j]);
}
result+="|";
row->setText(result);
myLayout->addWidget(row);
}
}