void KeyboardTranslatorManager::findTranslators() { QDir dir(get_kb_layout_dir()); QStringList filters; filters << "*.keytab"; dir.setNameFilters(filters); QStringList list = dir.entryList(filters); list = dir.entryList(filters); // QStringList list = KGlobal::dirs()->findAllResources("data", // "konsole/*.keytab", // KStandardDirs::NoDuplicates); // add the name of each translator to the list and associated // the name with a null pointer to indicate that the translator // has not yet been loaded from disk QStringListIterator listIter(list); while (listIter.hasNext()) { QString translatorPath = listIter.next(); QString name = QFileInfo(translatorPath).baseName(); if ( !_translators.contains(name) ) _translators.insert(name,0); } _haveLoadedAll = true; }
void KeyboardTranslatorManager::findTranslators() { QDir dir; #ifdef QTOPIA_PHONE dir.setPath(Qtopia::qtopiaDir()+"/etc/qterminal/"); #else dir.setPath("/opt/Qtopia/etc/qterminal/"); #endif dir.setNameFilters(QStringList()<<"*.keytab"); // TODO: add personal keytabs as preferred QStringList list = dir.entryList(QStringList()<<"*.keytab"); // add the name of each translator to the list and associated // the name with a null pointer to indicate that the translator // has not yet been loaded from disk QStringListIterator listIter(list); while (listIter.hasNext()) { QString translatorPath = listIter.next(); QString name = QFileInfo(translatorPath).baseName(); if ( !_translators.contains(name) ) _translators.insert(name,0); } _haveLoadedAll = true; }
void DNASequenceGenerator::evaluateBaseContent(const MultipleSequenceAlignment& ma, QMap<char, qreal>& result) { QList< QMap<char, qreal> > rowsContents; foreach(const MultipleSequenceAlignmentRow& row, ma->getMsaRows()) { QMap<char, qreal> rowContent; evaluate(row->getData(), rowContent); rowsContents.append(rowContent); } QListIterator< QMap<char, qreal> > listIter(rowsContents); while (listIter.hasNext()) { const QMap<char, qreal>& cm = listIter.next(); QMapIterator<char, qreal> mapIter(cm); while (mapIter.hasNext()) { mapIter.next(); char ch = mapIter.key(); qreal freq = mapIter.value(); if (!result.keys().contains(ch)) { result.insertMulti(ch, freq); } else { result[ch] += freq; } } } int rowsNum = ma->getNumRows(); QMutableMapIterator<char, qreal> i(result); while (i.hasNext()) { i.next(); i.value() /= rowsNum; } }
bool Account::updateStatus(QList<Status> &statusList, QMap<QString, Status> &retwMap, QList<Status> &sourceList, QMap<QString, Status> &sourceMap) { bool bChanged = false; if (sourceList.size() == 0) return false; QListIterator<Status> listIter(sourceList); QList<Status> tmpList; /* for (int i = 0; i != sourceList.size(); ++i) { Status status = sourceList.at(i); status.updatePlainCreatedTime(); bool fExist = statusList.contains(status); if (fExist) continue; else { statusList.append(status); tmpList.append(status); bChanged = true; } } */ while(listIter.hasNext()) { Status status = listIter.next(); status.updatePlainCreatedTime(); if (statusList.contains(status)) { // qDebug(status.getText().toLocal8Bit()); continue; } else { statusList.append(status); tmpList.append(status); bChanged = true; } } sourceList = tmpList; QMapIterator<QString,Status> mapIter(sourceMap); while(mapIter.hasNext()) { QString statusId = mapIter.next().key(); Status status = mapIter.value(); if (!retwMap.contains(statusId)) retwMap.insert(statusId,status); } return bChanged; }
// parse input string int Clause::parse(const List<String> &list) { // set defaults values clear(); // check if list is empty if (list.isEmpty()) { // nothing to parse type = Empty; return(OK); } // list is not empty, get options. ListIterator<String> listIter(list); String options = listIter(); // parse options StringMatcher conclusionopt(options, String("CONCLUSION")); if (!conclusionopt.done()) partOfConclusion = 1; StringMatcher setofsupportopt(options, String("SET-OF-SUPPORT")); if (!setofsupportopt.done()) setOfSupport = 1; // scan list of literal strings for (listIter++; !listIter.done(); listIter++) { // insert literal into clause; will set type. Literal literal(listIter()); if (insert(literal) != OK) return(NOTOK); } // convert to a string convertToString(inputstring); // all done return(OK); }
//________________________________________________________ void GFHistManager::Clear(Bool_t deleteHists) { // delete all canvases and clear the lists of hists stored in the manager // (hists and objects are deleted if deleteHists is true [by default it is false]) TIter iterCanArrays(fCanArrays); while(TObjArray* arr = static_cast<TObjArray*>(iterCanArrays.Next())){ // A simple 'arr->Delete();' causes a crash if the user has closed a canvas // via the GUI - so delete only those that are known to gROOT: TIter cans(arr); while (TObject *c = cans.Next()) delete gROOT->GetListOfCanvases()->FindObject(c); } fCanArrays->Delete(); // delete arrays of canvases delete fCanArrays; if(fLegendArrays){ // by default there are no legends... TIter iterLegArrays(fLegendArrays); while(TObjArray* arr = static_cast<TObjArray*>(iterLegArrays.Next())){ arr->Delete(); // delete legends } fLegendArrays->Delete(); // delete arrays of legends delete fLegendArrays; } if(fObjLists) { TIter listArrayIter(fObjLists); while(TObjArray* listArray = static_cast<TObjArray*>(listArrayIter.Next())){ if(deleteHists) { TIter listIter(listArray); while(TList* list = static_cast<TList*>(listIter.Next())){ list->Delete(); // delete objects if requested } } listArray->Delete(); // delete lists } fObjLists->Delete(); // delete arrays of lists delete fObjLists; // delete array of arrays of lists } TIter iterHistArrays(fHistArrays); while(TObjArray* arr = static_cast<TObjArray*>(iterHistArrays.Next())){ TIter iterHistArrays2(arr); while(TObjArray* arr2 = static_cast<TObjArray*>(iterHistArrays2.Next())){ if(deleteHists) arr2->Delete(); // delete histograms else arr2->Clear(); } arr->Delete(); } fHistArrays->Delete(); // delete arrays of arrays of histograms delete fHistArrays; this->Initialise(); // here the arrays are rebuild and fDepth etc. adjusted }
void depdagFreeDeeply(DepDag dag) { DepDagList dags = depdagDependsOn(dag); /* Free the children deeply */ listIter(DepDag, d, dags, depdagFreeDeeply(d)); /* Free this node */ depdagFree(dag); }
void SoundSourceProviderRegistry::insertRegistration( QList<SoundSourceProviderRegistration> *pRegistrations, SoundSourceProviderRegistration registration) { QList<SoundSourceProviderRegistration>::iterator listIter( pRegistrations->begin()); // Perform a linear search through the list & insert while (pRegistrations->end() != listIter) { // Priority comparison with <=: New registrations will be inserted // before existing registrations with equal priority, but after // existing registrations with higher priority. if (listIter->getProviderPriority() <= registration.getProviderPriority()) { listIter = pRegistrations->insert(listIter, std::move(registration)); DEBUG_ASSERT(pRegistrations->end() != listIter); return; // done } else { ++listIter; // continue loop } } if (pRegistrations->end() == listIter) { // List was empty or registration has the lowest priority pRegistrations->append(std::move(registration)); } }
// parse input string int Clause::parse(const List<String> &list) { // set defaults values clear(); // check if list is empty if (list.isEmpty()) { // nothing to parse type = Empty; return(OK); } // list is not empty, get options. ListIterator<String> listIter(list); String options = listIter(); // parse options StringMatcher conclusionopt(options, String("CONCLUSION")); if (!conclusionopt.done()) partOfConclusion = 1; StringMatcher queryopt(options, String("QUERY")); if (!queryopt.done()) partOfQuery = 1; StringMatcher setofsupportopt(options, String("SET-OF-SUPPORT")); if (!setofsupportopt.done()) setOfSupport = 1; // scan list of literal strings for (listIter++; !listIter.done(); listIter++) { // insert literal into clause; will set type. Literal literal(listIter()); if (insert(literal) != OK) { ERROR("insert failed.", errno); return(NOTOK); } } // convert to a string convertToString(inputstring); // add answer literal if (partOfQuery) { int ivar = 0; String answerstring("( ANSWER "); StringTokens st(inputstring, " \t"); for ( ; !st.done(); st++) { String token = st(); if (token(0,2) == String("_V")) { ivar++; answerstring += token + String(" "); } else if (token(0,3) == String("_RV")) { ivar++; answerstring += token + String(" "); } } if (ivar == 0) { // no variables were found answerstring = String("ANSWER"); } else { // finish answer literal answerstring += String(") "); } // insert answer literal into answer clause Literal answerliteral(answerstring); if (insertAnswer(answerliteral) != OK) { ERROR("insertAnswer failed.", errno); return(NOTOK); } } // update clause type updateType(); // all done return(OK); }
MStatus simulateBoids::doIt( const MArgList& args ) { // Description: implements the MEL boids command // Arguments: args - the argument list that was passes to the command from MEL MStatus status = MS::kSuccess; /**************************************** * building thread/dll data structure * ****************************************/ InfoCache infoCache; SimulationParameters simParams; RulesParameters *applyingRules; double progressBar=0; double aov=pi/3; int i,numberOfDesires=0; // params retrievement MSelectionList sel; MObject node; MFnDependencyNode nodeFn; MFnTransform locatorFn; MPlug plug; // simulation params int simulationLengthValue; // [int] in seconds int framesPerSecondValue; // [int] int startFrameValue; // [int] int boidsNumberValue; // [int] // export params MString logFilePathValue; // [char *] MString logFileNameValue; // [char *] int logFileTypeValue; // 0 = nCache; 1 = log file; 2 = XML; // locomotion params int locomotionModeValue; // [int] double maxSpeedValue; // [double] double maxForceValue; // [double] // double mass=1; // [double] MTime currentTime, maxTime; MPlug plugX, plugY, plugZ; double tx, ty, tz; int frameLength ; Vector * leader = NULL; MStatus leaderFound=MStatus::kFailure; MGlobal::getActiveSelectionList(sel); for ( MItSelectionList listIter(sel); !listIter.isDone(); listIter.next() ) { listIter.getDependNode(node); switch(node.apiType()) { case MFn::kTransform: // get locator transform to follow leaderFound=locatorFn.setObject(node); cout << locatorFn.name().asChar() << " is selected as locator" << endl; break; case MFn::kPluginDependNode: nodeFn.setObject(node); cout << nodeFn.name().asChar() << " is selected as brain" << endl; break; default: break; } cout<< node.apiTypeStr()<<endl; } // rules params setRuleVariables(alignment); setRuleVariables(cohesion); setRuleVariables(separation); setRuleVariables(follow); getPlugValue(simulationLength); getPlugValue(framesPerSecond); getPlugValue(startFrame); getPlugValue(boidsNumber); getPlugValue(logFileType); getRulePlugValue(alignment); getRulePlugValue(cohesion); getRulePlugValue(separation); getRulePlugValue(follow); getPlugValue(locomotionMode); getPlugValue(maxSpeed); getPlugValue(maxForce); getTypePlugValue(logFilePath); getTypePlugValue(logFileName); // counting active rules number if(alignmentActiveValue) numberOfDesires++; if(cohesionActiveValue) numberOfDesires++; if(separationActiveValue) numberOfDesires++; if(followActiveValue) numberOfDesires++; currentTime = MTime((double)startFrameValue); // MAnimControl::minTime(); maxTime = MTime((double)(startFrameValue + (simulationLengthValue * framesPerSecondValue))); // MAnimControl::maxTime(); cout << "time unit enum (6 is 24 fps): " << currentTime.unit() << endl; plugX = locatorFn.findPlug( MString( "translateX" ), &status ); plugY = locatorFn.findPlug( MString( "translateY" ), &status ); plugZ = locatorFn.findPlug( MString( "translateZ" ), &status ); frameLength = simulationLengthValue * framesPerSecondValue; if(leaderFound==MS::kSuccess) { leader = new Vector[frameLength]; while ( currentTime < maxTime ) { { int index = (int)currentTime.value() - startFrameValue; /* MGlobal::viewFrame(currentTime); pos = locatorFn.getTranslation(MSpace::kWorld); cout << "pos: " << pos.x << " " << pos.y << " " << pos.z << endl; */ status = plugX.getValue( tx, MDGContext(currentTime) ); status = plugY.getValue( ty, MDGContext(currentTime) ); status = plugZ.getValue( tz, MDGContext(currentTime) ); leader[index].x = tx; leader[index].y = ty; leader[index].z = tz; //cout << "pos at time " << currentTime.value() << " has x: " << tx << " y: " << ty << " z: " << tz << endl; currentTime++; } } } simParams.fps=framesPerSecondValue; simParams.lenght=simulationLengthValue; simParams.numberOfBoids=boidsNumberValue; simParams.maxAcceleration=maxForceValue; simParams.maxVelocity=maxSpeedValue; simParams.simplifiedLocomotion=TRUE; applyingRules=new RulesParameters[numberOfDesires]; // cache settings MString saveString; saveString = logFilePathValue+"/"+logFileNameValue; infoCache.fileName=new char[saveString.length()+1]; memcpy(infoCache.fileName,saveString.asChar(),sizeof(char)*(saveString.length()+1)); infoCache.cacheFormat=ONEFILE; infoCache.fps=framesPerSecondValue; infoCache.start=startFrameValue/framesPerSecondValue; infoCache.end=simulationLengthValue+infoCache.start; infoCache.loging=FALSE; infoCache.option=POSITIONVELOCITY; infoCache.particleSysName="BoidsNParticles"; infoCache.saveMethod=MAYANCACHE; for(i=0;i<numberOfDesires;i++) { applyingRules[i].enabled=TRUE; applyingRules[i].precedence=1; applyingRules[i].aov=aov; applyingRules[i].visibilityOption=FALSE; } if(cohesionActiveValue==0) applyingRules[COHESIONRULE].enabled=FALSE; else { applyingRules[COHESIONRULE].ruleName=COHESIONRULE; applyingRules[COHESIONRULE].ruleFactor=cohesionFactorValue; applyingRules[COHESIONRULE].ruleRadius=cohesionRadiusValue; applyingRules[COHESIONRULE].ruleWeight=cohesionWeightValue; } if(separationActiveValue==0) applyingRules[SEPARATIONRULE].enabled=FALSE; else { applyingRules[SEPARATIONRULE].ruleName=SEPARATIONRULE; applyingRules[SEPARATIONRULE].ruleFactor=separationFactorValue; applyingRules[SEPARATIONRULE].ruleRadius=separationRadiusValue; applyingRules[SEPARATIONRULE].ruleWeight=separationWeightValue; } if(alignmentActiveValue==0) applyingRules[ALIGNMENTRULE].enabled=FALSE; else { applyingRules[ALIGNMENTRULE].ruleName=ALIGNMENTRULE; applyingRules[ALIGNMENTRULE].ruleFactor=alignmentFactorValue; applyingRules[ALIGNMENTRULE].ruleRadius=alignmentRadiusValue; applyingRules[ALIGNMENTRULE].ruleWeight=alignmentWeightValue; } if(followActiveValue==0) applyingRules[FOLLOWRULE].enabled=FALSE; else { applyingRules[FOLLOWRULE].ruleName=FOLLOWRULE; applyingRules[FOLLOWRULE].ruleRadius=followRadiusValue; applyingRules[FOLLOWRULE].ruleFactor=followFactorValue; applyingRules[FOLLOWRULE].ruleWeight=followWeightValue; } // initializing simulation parameters boidInit(numberOfDesires, applyingRules, simParams , infoCache, leader); DLLData datadll; // preparing threads pool status = MThreadPool::init(); if (status==MStatus::kSuccess) { MThreadPool::newParallelRegion(ThreadsCreator, &datadll); setResult( "Command executed!\n" ); CHECK_MSTATUS(MProgressWindow::endProgress()); MThreadPool::release(); } switch(datadll.result) { case 0: status=MS::kSuccess; break; default: status=MS::kFailure; } MThreadPool::release(); return status; }
void SceneManager::Update() { RenderLayerManager & renderManager = RenderLayerManager::GetRenderLayerManager(); const PVRTVec3 center = renderManager.GetCenter(); float occlusionRadius = renderManager.GetOcclusionRadius(); PVRTVec4 vecA( mLookMtx->f[12], 0.0f, mLookMtx->f[14], 1); PVRTVec4 vecB( GLOBAL_SCALE * FRUSTUM_W, 0.0f, GLOBAL_SCALE * FRUSTUM_D, 1); PVRTVec4 vecC( GLOBAL_SCALE * -FRUSTUM_W, 0.0f, GLOBAL_SCALE * FRUSTUM_D, 1); vecB = *mLookMtx * vecB; vecC = *mLookMtx * vecC; PVRTVec2 A(vecA.x, vecA.z); PVRTVec2 B(vecB.x, vecB.z); PVRTVec2 C(vecC.x, vecC.z); mToApplyCount = 0; if (mQuadTree) { static QuadNode * quadNodes[256]={0}; int quadNodeCount = 0; //mQuadTree->GetQuads(center.x, center.z, occlusionRadius, quadNodes, quadNodeCount); mQuadTree->GetQuadsCameraFrustum(quadNodes, quadNodeCount, mLookMtx); quadNodeCount--; bool useFrustumCulling = true; //!!!!!!!!!!!!!!!!!!!!! for (int quad = quadNodeCount ; quad >=0 ; quad--) { QuadNode * pQuadNode = quadNodes[quad]; List & dataList = pQuadNode->GetDataList(); ListIterator listIter(dataList); while( Node * pRootNode = (Node*)listIter.GetPtr() ) { if (!pRootNode->IsVisible()) continue; //pRootNode->UpdateWithoutChildren(); bool useOcclusionRadius = pRootNode->GetUseOcclusionCulling(); PVRTVec3 worldPos = pRootNode->GetWorldTranslation(); if (!useFrustumCulling && useOcclusionRadius) { PVRTVec3 distVec = worldPos - center; if ( distVec.lenSqr() < MM(occlusionRadius) ) { pRootNode->SetInFrustum(true); pRootNode->Update(); mToApply[mToApplyCount] = pRootNode; mToApplyCount++; } else { pRootNode->SetInFrustum(false); } } else if (useFrustumCulling) { PVRTVec2 P(worldPos.x, worldPos.z); PVRTVec2 v0 = C - A; PVRTVec2 v1 = B - A; PVRTVec2 v2 = P - A; // Compute dot products float dot00 = v0.dot(v0); float dot01 = v0.dot(v1); float dot02 = v0.dot(v2); float dot11 = v1.dot(v1); float dot12 = v1.dot(v2); // Compute barycentric coordinates float invDenom = 1.0f / (dot00 * dot11 - dot01 * dot01); float u = (dot11 * dot02 - dot01 * dot12) * invDenom; float v = (dot00 * dot12 - dot01 * dot02) * invDenom; bool addToList = false; // Check if point is in triangle //PVRTVec3 distVec = worldPos - center; //if ( distVec.lenSqr() < MM(occlusionRadius) ) { if ( (u > 0) && (v > 0) && (u + v < 1)) { addToList = true; } else if ( Collision::CircleTriangleEdgeIntersection(A,B,P, pRootNode->GetRadius() ) ) { addToList = true; } else if ( Collision::CircleTriangleEdgeIntersection(A,C,P, pRootNode->GetRadius() )) { addToList = true; } if (addToList) { pRootNode->SetInFrustum(true); //pRootNode->Update(); mToApply[mToApplyCount] = pRootNode; mToApplyCount++; } else { pRootNode->SetInFrustum(false); } } //else //{ // pRootNode->SetInFrustum(false); //} } else { pRootNode->SetInFrustum(true); //pRootNode->Update(); mToApply[mToApplyCount] = pRootNode; mToApplyCount++; } } } } for (int n=0;n<mNodeCount;n++) { Node * pRootNode = mRootNodes[n]; if (!pRootNode->IsVisible()) continue; pRootNode->UpdateWithoutChildren(); bool useOcclusionRadius = pRootNode->GetUseOcclusionCulling(); PVRTVec3 worldPos = pRootNode->GetWorldTranslation(); PVRTVec3 distVec = worldPos - center; if (useOcclusionRadius) { if ( distVec.lenSqr() < MM(occlusionRadius) ) { PVRTVec2 P(worldPos.x, worldPos.z); PVRTVec2 v0 = C - A; PVRTVec2 v1 = B - A; PVRTVec2 v2 = P - A; // Compute dot products float dot00 = v0.dot(v0); float dot01 = v0.dot(v1); float dot02 = v0.dot(v2); float dot11 = v1.dot(v1); float dot12 = v1.dot(v2); // Compute barycentric coordinates float invDenom = 1.0f / (dot00 * dot11 - dot01 * dot01); float u = (dot11 * dot02 - dot01 * dot12) * invDenom; float v = (dot00 * dot12 - dot01 * dot02) * invDenom; bool addToList = false; // Check if point is in triangle //PVRTVec3 distVec = worldPos - center; //if ( distVec.lenSqr() < MM(occlusionRadius) ) { if ( (u > 0) && (v > 0) && (u + v < 1)) { addToList = true; } else if ( Collision::CircleTriangleEdgeIntersection(A,B,P, pRootNode->GetRadius() ) ) { addToList = true; } else if ( Collision::CircleTriangleEdgeIntersection(A,C,P, pRootNode->GetRadius() )) { addToList = true; } if (addToList) { pRootNode->SetInFrustum(true); pRootNode->Update(); mToApply[mToApplyCount] = pRootNode; mToApplyCount++; } else { pRootNode->SetInFrustum(false); } } /* pRootNode->SetInFrustum(true); pRootNode->Update(); mToApply[mToApplyCount] = pRootNode; mToApplyCount++; */ } else { pRootNode->SetInFrustum(false); } } else { pRootNode->SetInFrustum(true); pRootNode->Update(); mToApply[mToApplyCount] = pRootNode; mToApplyCount++; } /* PVRTVec3 worldPos = pRootNode->GetWorldTranslation(); PVRTVec3 distVec = worldPos - center; if (!pRootNode->GetUseOcclusionCulling()) { pRootNode->SetInFrustum(true); } else if ( distVec.lenSqr() < occlusionRadius ) { pRootNode->SetInFrustum(true); } else { pRootNode->SetInFrustum(false); } */ } }