//-------------------------------------------------------------------------------------------------- /// Calculates a set of humanly readable levels. Works very well for linear, and ok for logarithmic. /// The logarithmic needs a bit more tweaking, so should override this method for linear but not yet done. //-------------------------------------------------------------------------------------------------- void ScalarMapperContinuousLog::majorLevels( std::vector<double>* domainValues) const { CVF_ASSERT(domainValues != NULL); domainValues->push_back(m_rangeMin); if (m_majorLevelCount > 1) { double stepSizeNorm = 1.0/m_majorLevelCount; size_t i; if (m_adjustLevels) // adjust levels { double prevDomValue = domainValue(0); for (i = 1; i < m_majorLevelCount + 5; ++i) { double prevNormPos = normalizedLevelPosition(prevDomValue); double newNormPos = prevNormPos + stepSizeNorm; double domValue = domainValue(newNormPos); double domStep = domValue - prevDomValue; double newLevel; newLevel = prevDomValue + adjust(domStep, domStep, m_decadeLevelCount); // Must handle first level specially to get a good absolute staring point // For log domain this must be done all the time, and it does not hamper linear, so.. do it always newLevel = adjust(newLevel, domStep, m_decadeLevelCount); if (newLevel > m_rangeMax - domStep*0.4) break; domainValues->push_back(newLevel); prevDomValue = newLevel; } } else { for (i = 1; i < m_majorLevelCount; ++i) { domainValues->push_back(domainValue(stepSizeNorm*i)); } } } domainValues->push_back(m_rangeMax); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- bool ScalarMapperRangeBased::updateTexture(TextureImage* image) const { CVF_ASSERT(image); image->allocate(m_textureSize, 1); // For now fill with white so we can see any errors more easily image->fill(Color4ub(Color3::WHITE)); uint ic; for (ic = 0; ic < m_textureSize; ic++) { const Color4ub clr(mapToColor(domainValue(((double)ic)/(m_textureSize-1))), 255); image->setPixel(ic, 0, clr); } return true; }
//-------------------------------------------------------------------------------------------------- /// Calculates a set of humanly readable levels. Works very well for linear, and ok for logarithmic. /// The logarithmic needs a bit more tweaking, so should override this method for linear but not yet done. //-------------------------------------------------------------------------------------------------- void ScalarMapperRangeBased::majorTickValues( std::vector<double>* domainValues) const { CVF_ASSERT(domainValues != NULL); CVF_ASSERT(m_rangeMin != cvf::UNDEFINED_DOUBLE && m_rangeMax != cvf::UNDEFINED_DOUBLE); if (m_userDefinedLevelValues.empty()) { domainValues->push_back(domainValue(0)); if (m_levelCount > 1) { double stepSizeNorm = 1.0/m_levelCount; size_t i; if (m_adjustLevels) // adjust levels { double prevDomValue = domainValue(0); for (i = 1; i < m_levelCount + 5; ++i) { double prevNormPos = normalizedValue(prevDomValue); double newNormPos = prevNormPos + stepSizeNorm; double domValue = domainValue(newNormPos); double domStep = domValue - prevDomValue; double newLevel; //newLevel = prevDomValue + adjust(domStep, domStep, m_decadeLevelCount); newLevel = domValue; // Must handle first level specially to get a good absolute staring point // For log domain this must be done all the time, and it does not hamper linear, so.. do it always newLevel = adjust(newLevel, domStep, m_decadeLevelCount); if (normalizedValue(newLevel) > 1.0 - stepSizeNorm*0.4) break; domainValues->push_back(newLevel); prevDomValue = newLevel; } } else { for (i = 1; i < m_levelCount; ++i) { domainValues->push_back(domainValue(stepSizeNorm*i)); } } } domainValues->push_back(domainValue(1)); } else { // Use the user defined levels between max and min. // (max and min values are set from the user defined levels if not set explicitly) domainValues->push_back(m_rangeMin); std::set<double>::iterator it; for (it = m_userDefinedLevelValues.begin(); it != m_userDefinedLevelValues.end(); ++it) { if (*it <= m_rangeMin ) continue; if (*it >= m_rangeMax ) continue; domainValues->push_back(*it); } domainValues->push_back(m_rangeMax); } }
OsStatus CallerAliasDB::store() { UtlString fileName = DbName + ".xml"; UtlString pathName = SipXecsService::Path(SipXecsService::DatabaseDirType, fileName.data()); // Create an empty document TiXmlDocument document; // Create a hard coded standalone declaration section document.Parse ("<?xml version=\"1.0\" standalone=\"yes\"?>"); // Create the root node container TiXmlElement itemsElement ( "items" ); itemsElement.SetAttribute( "type", sType.data() ); itemsElement.SetAttribute( "xmlns", sXmlNamespace.data() ); // Critical Section while actually opening and using the database { OsLock lock( sLockMutex ); if ( mpFastDB != NULL ) { // Thread Local Storage mpFastDB->attach(); // Search our memory for rows dbCursor< CallerAliasRow > cursor; // Select everything in the IMDB and add as item elements if present int rowNumber; int rows; for (rowNumber = 0, rows = cursor.select(); rowNumber < rows; rowNumber++, cursor.next() ) { // Create an item container TiXmlElement itemElement ("item"); if ( *cursor->identity ) { // Add an identity element and put the value in it TiXmlElement identityElement(IdentityKey.data()); TiXmlText identityValue(cursor->identity); identityElement.InsertEndChild(identityValue); itemElement.InsertEndChild(identityElement); } // add the domain element and put the value in it TiXmlElement domainElement(DomainKey.data()); TiXmlText domainValue(cursor->domain); domainElement.InsertEndChild(domainValue); itemElement.InsertEndChild(domainElement); // add the alias element and put the value in it TiXmlElement aliasElement(AliasKey.data()); TiXmlText aliasValue(cursor->alias); aliasElement.InsertEndChild(aliasValue); itemElement.InsertEndChild(aliasElement); // add this item (row) to the parent items container itemsElement.InsertEndChild ( itemElement ); } // Commit rows to memory - multiprocess workaround mpFastDB->detach(0); mTableLoaded = true; } } // release mutex around database use // Attach the root node to the document document.InsertEndChild ( itemsElement ); document.SaveFile ( pathName ); return OS_SUCCESS; }