Esempio n. 1
0
File: GUIAxes.cpp Progetto: EQ4/Viza
// get Attr idx in Data world
int GUIAxes::getFullAttrIdx(const string & attr,const string &  aggr ){
    string attrN = attr+"."+aggr;
    bool found = false;
    for (vector<string> ::iterator it = Container::attributeNames.begin(); it!=Container::attributeNames.end(); ++it) {
        if(*it==attrN){
            found = true;
            break;
        }
        
    }
    if(!found){
        attrN = ofSplitString(attrN, ".")[0];
    }
    return ofFind(Container::attributeNames, attrN );;
}
void CloudsClip::revokeKeyword(string keyword){
	
//	cout << "revoking keyword " << keyword << endl;
//	cout << "	in original? " << (ofContains(originalKeywords, keyword) ? "YES" : "NO") << endl;
//	cout << "	in additional? " << (ofContains(additionalKeywords, keyword) ? "YES" : "NO") << endl;
//	cout << "	in revoked? " << (ofContains(revokedKeywords, keyword) ? "YES" : "NO") << endl;
//	
    if(!ofContains(revokedKeywords, keyword) &&
        ofContains(originalKeywords, keyword))
    {
        revokedKeywords.push_back(keyword);
        keywordsDirty = true;
    }
	else if(ofContains(additionalKeywords, keyword)){
		additionalKeywords.erase(additionalKeywords.begin() +
								 ofFind(additionalKeywords, keyword));
		keywordsDirty = true;
	}
}
Esempio n. 3
0
File: GUIAxes.cpp Progetto: EQ4/Viza
// Async GUI modifications
void GUIAxes::async(ofEventArgs & e,bool init){
    
    //update Aggregator list for Selected Attribute in given Axe
    if(shouldUpdateAggregator!=-1){
        int axe = shouldUpdateAggregator;
        string attrtmp =attr[axe]->getSelected()[0]->getName();
        string oldAggr ="";
        if(aggr[axe]->getSelected().size()>0) oldAggr =aggr[axe]->getSelected()[0]->getName();
        aggr[axe]->clearSelected();
        aggr[axe]->clearToggles();
        vector<string>  newAggr = Container::getAggregators(attrtmp);
        
        int idx = ofFind(newAggr, oldAggr);
        if(oldAggr == "" || idx == newAggr.size())idx = 0;
        aggr[axe]->addToggles(newAggr);
        aggr[axe]->getToggles()[idx]->setValue(true);
        if(!init)aggr[axe]->getToggles()[idx]->triggerSelf();
        aggr[axe]->setSingleSelected(idx);
        shouldUpdateAggregator = -1;
    }
}
void CloudsClip::collateKeywords(){
    
    keywords = originalKeywords;
    specialKeywords.clear();
    
    //go through and remove revoked keywords
    for (int k = 0; k<revokedKeywords.size(); k++) {
        if(ofContains(keywords, revokedKeywords[k])){
            keywords.erase(keywords.begin()+ofFind(keywords, revokedKeywords[k]));
//            cout<<"Removing keywords for clip "<<name<< " : "<< revokedKeywords[k]<<endl;
        }
    }
    
    //go through and add additional
    for (int l = 0; l < additionalKeywords.size(); l++) {
        
        if (!ofContains(keywords, additionalKeywords[l]) ){
            keywords.push_back(additionalKeywords[l]);
//            cout<<"Adding addition keywords for clip "<<name<< " : "<< additionalKeywords[l]<<endl;
        }
    }
    
    //remove special keywords from keywords -> specialKeywords
    for (int l = keywords.size() - 1 ; l >= 0; l--) {
        
        if(keywords[l].compare(0, 1, "#") == 0 && !ofContains(specialKeywords, keywords[l])){
//            cout<<"Special keywords for clip "<<name<< " : "<<keywords[l]<<". Erasing from keywords list"<<endl;
            specialKeywords.push_back(keywords[l]);
            keywords.erase(keywords.begin()+l);

        }
        else if(keywords[l][0] == '?' && !ofContains(specialKeywords, keywords[l])){
            
//           cout<<keywords[l] << " is a question in the new format. removing from keywords list and adding to questions"<< endl;
            
            //format of question topic pair is ?topic:question
            specialKeywords.push_back(keywords[l]);
            vector<string>questionTopicPair = ofSplitString(keywords[l], ":",true,true);
            ofStringReplace(questionTopicPair[0], "?", "");
            addQuestionTopicPair(questionTopicPair[0], questionTopicPair[1]);
            keywords.erase(keywords.begin() + l);
        }
    }
    
	hasProjectExample = false;
	projectExampleTitle = "";
	for(int i = 0; i < specialKeywords.size(); i++){
		if(specialKeywords[i].find("pe?") != string::npos){
			vector<string> exampleProject = ofSplitString(specialKeywords[i], "?");
			if(exampleProject.size() != 2){
				ofLogError("CloudsClip::collateKeywords") << "Clip " << getLinkName() << " doesn't have a specific example tagged";
			}
			else {
				projectExampleTitle = exampleProject[1];
				hasProjectExample = true;
//				cout << "Found project example " << projectExampleTitle << " for clip " << getLinkName() << endl;
			}
			break;
		}
	}
    keywordsDirty = false;
}