本文整理汇总了C++中Topic::setup方法的典型用法代码示例。如果您正苦于以下问题:C++ Topic::setup方法的具体用法?C++ Topic::setup怎么用?C++ Topic::setup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Topic
的用法示例。
在下文中一共展示了Topic::setup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setup
//--------------------------------------------------------------
void ofApp::setup(){
ofSetWindowShape(800, 1000);
ofPoint chartPos = ofPoint(ofGetWidth() * 0.1, ofGetHeight() * 0.1);
ofPoint chartSize = ofPoint(ofGetWidth() * 0.8, ofGetHeight() * 0.8);
drawLabels = true;
chartType = 0;
// 0: Load tsv file
ofBuffer file = ofBufferFromFile("pomodoro.tsv");
// 1: Get all possible dates
vector<string> allDates;
string prevDate = "";
while (!file.isLastLine()){
string line = file.getNextLine();
vector <string> split = ofSplitString(line, "\t");
string thisDate = split[0];
if(thisDate != prevDate){
allDates.push_back(thisDate);
}
prevDate = thisDate;
}
// 2: Create topics with names and pass all possible dates
file.resetLineReader();
while (!file.isLastLine()){
string line = file.getNextLine();
vector <string> split = ofSplitString(line, "\t");
string thisName = split[1];
bool nameIsStored = false;
for (int i = 0; i < allTopics.size(); i++) {
if(allTopics[i].name == thisName){
nameIsStored = true;
}
}
if(!nameIsStored){
Topic thisTopic;
thisTopic.setup(thisName, allDates);
allTopics.push_back(thisTopic);
}
}
// 3: Fill out hours
file.resetLineReader();
while (!file.isLastLine()){
string line = file.getNextLine();
vector <string> split = ofSplitString(line, "\t");
string thisName = split[1];
string thisDate = split[0];
float theseHours = split[5].size() * 0.5;
for (int i = 0; i < allTopics.size(); i++) {
if(allTopics[i].name == thisName){
for (int j = 0; j < allTopics[i].dates.size(); j++){
if (allTopics[i].dates[j] == thisDate) {
allTopics[i].hours[j] += theseHours;
}
}
}
}
}
// 4: Calculate the total hours for each topic
for (int i = 0; i < allTopics.size(); i++) {
allTopics[i].calculateHours();
}
// 5: Sort by total hours
sort(allTopics.begin(), allTopics.end(), sortByCount);
// 6: Before setting the vertices, we need to know
// what is the highest value of hours for one day
vector<float> allHours;
for (int i = 0; i < allTopics[0].hours.size(); i++) {
float sumOfHours = 0.0;
for (int j = 0; j < allTopics.size(); j++) {
// cout << allTopics[j].hours[i] << endl;
sumOfHours += allTopics[j].hours[i];
}
// cout << "****************************" << endl;
// cout << sumOfHours << endl;
// cout << "****************************" << endl;
allHours.push_back(sumOfHours);
}
float maxHoursPerDay = 0.0;
for (int i = 0; i < allHours.size(); i++) {
// cout << allHours[i] << endl;
if (allHours[i] > maxHoursPerDay) {
//.........这里部分代码省略.........