-
Notifications
You must be signed in to change notification settings - Fork 0
/
MatCollection.cpp
121 lines (101 loc) · 2.86 KB
/
MatCollection.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
/*
Copyright 2014 Wouter Spekkink
Authors : Wouter Spekkink <[email protected]>
Website : http://www.wouterspekkink.org
This file is part of Dynamic Networks.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2014 Wouter Spekkink. All rights reserved.
Dynamic Networks is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Dynamic Networks is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
#include "MatCollection.h"
MatCollection::MatCollection(InputTable *table, int frame, bool userSlide)
: mainTable(table), frameSize(frame), slide(userSlide)
{
begin = 1;
total = mainTable->GetCols() - frame + 1;
collection = FillCollection();
}
MatCollection::MatCollection(InputTable *table, int userBeg, int userEnd, bool userSlide)
: mainTable(table), begin(userBeg), slide(userSlide)
{
total = (userEnd - userBeg + 1);
frameSize = 1;
collection = FillCollection();
}
std::vector<MatrixMulti> MatCollection::FillCollection()
{
int beg = begin;
int end = beg + frameSize - 1;
std::vector<MatrixMulti> tempcol;
int finish = 0;
if(slide) {
finish = total;
} else {
int temp = mainTable->GetCols();
if((temp % frameSize) > 0) {
finish = temp / frameSize + 1;
} else {
finish = temp / frameSize;
}
}
loadProgress = new ProgressBar(0, 1, finish);
loadProgress->setAttribute(Qt::WA_DeleteOnClose);
loadProgress->setModal(true);
loadProgress->show();
for(int i = 0; i != finish; ++i) {
MatrixMulti temp(mainTable, beg, end);
tempcol.push_back(temp);
if(slide) {
beg++;
end++;
} else {
beg = beg + frameSize;
if(!((end + frameSize) > (total + frameSize - 1))) {
end = end + frameSize;
} else {
end = total + frameSize - 1;
}
}
loadProgress->setProgress(i + 1);
}
loadProgress->close();
delete loadProgress;
return tempcol;
}
const std::vector<MatrixMulti> MatCollection::GetCollection()
{
return collection;
}
const std::vector<std::string> MatCollection::GetCollRows()
{
return mainTable->GetRowNames();
}
const std::vector<std::string> MatCollection::GetColNames()
{
return mainTable->GetHeader();
}
bool MatCollection::IsSlide()
{
return slide;
}
int MatCollection::GetFrameSize()
{
return frameSize;
}
int MatCollection::GetTotal()
{
return total;
}
int MatCollection::GetBegin()
{
return begin;
}