// ************************************************************************** // Function: LoadParameterList // Purpose: Loads the current list of parameters from a parameter file // It does NOT load system critical dynamic parameters (e.g., ports, // IP addresses) // Parameters: char *filename - filename of the parameterlist // nonexisting - if true, load parameters, even if they currently do // not exist in the list // Returns: true - successful // false - error // ************************************************************************** bool ParamList::Load( const string& inFileName, bool inImportNonexisting ) { ifstream file( inFileName.c_str() ); ParamList paramsFromFile; file >> paramsFromFile; if( file.fail() ) return false; // If desired, exclude parameters missing from the main parameter list. typedef set<string> NameSet; NameSet unwantedParams; if( !inImportNonexisting ) for( int i = 0; i < paramsFromFile.Size(); ++i ) if( !Exists( paramsFromFile[i].Name() ) ) unwantedParams.insert( paramsFromFile[i].Name() ); for( NameSet::const_iterator i = unwantedParams.begin(); i != unwantedParams.end(); ++i ) paramsFromFile.Delete( *i ); for( int i = 0; i < paramsFromFile.Size(); ++i ) { Param &p = paramsFromFile[i], &q = ByName( p.Name() ); if( !q.Readonly() ) q.AssignValues( p, true ); } return true; }
// Called before any call to GenericFilter::Preflight(). void EnvironmentBase::EnterPreflightPhase( ParamList* inParamList, StateList* inStateList, StateVector* /*inStateVector*/ ) { bcierr__.SetAction( BCIStream::ConfigurationError ); phase_ = preflight; Accessor_<ParamList>::spGlobal = inParamList; Accessor_<StateList>::spGlobal = inStateList; Accessor_<StateVector>::spGlobal = NULL; BCIStream::Apply( *inParamList ); ParamsRangeChecked().clear(); if( inParamList ) { NameSet notAutoConfig; for( int i = 0; i < inParamList->Size(); ++i ) { const Param& p = inParamList->ByIndex( i ); if( !IsAutoConfigParam( p ) ) notAutoConfig.insert( p.Name() ); } RangeCheckParams( inParamList, notAutoConfig ); } ParamsAccessedDuringPreflight().clear(); StatesAccessedDuringPreflight().clear(); for( ExtensionsContainer::iterator i = Extensions().begin(); i != Extensions().end(); ++i ) ( *i )->CallPreflight(); }
/*! \todo */ NameSet Parameter::getDependentParameterNameSet() const throw() { NameSet lNameSet; for(NameSet::const_iterator lItr = mDependentParameterNameSet.begin(); lItr != mDependentParameterNameSet.end(); lItr++) lNameSet.insert(lItr->c_str()); return lNameSet; }
/*! TODO: */ TranslucencyModule::TranslucencyModule() :Module(MODULE_NAME, MODULE_DISPLAY_NAME, TRANSLUCENCYMODULE_VERSION), mParamMode(PARAMETER_NAME_MODE, Variable::eVariableTypeString, "Translucency mode", "The type of translucency to perform", false), mParamAlpha(PARAMETER_NAME_ALPHA, Variable::eVariableTypeDouble, "Translucency alpha", "Percentage of translucency (0=opaque, 1=invisible)", true), mParamInvert(PARAMETER_NAME_INVERT, Variable::eVariableTypeBool, "Invert mask", "Invert plain or alpha mask", true) { mShortDescription = "Module for embedding a color image in another one with translucency effect"; mLongDescription = "This module embeds an image into another one using an alpha mask (translucency)"; ValueSet lModeName; lModeName.insert(Value("image", "Whole Image", "Whole image is made translucent using the specified alpha value")); lModeName.insert(Value("plainmask", "Plain Mask", "Only the image pixels where the provided mask is non zero are made translucent using the specified alpha value")); lModeName.insert(Value("alphamask", "Alpha Mask", "Each pixel of the mask specify the alpha value to apply to the corresponding image pixel")); mParamMode.setPossibleValues(lModeName); NameSet lDependentParameterSet; lDependentParameterSet.insert(PARAMETER_NAME_ALPHA); lDependentParameterSet.insert(PARAMETER_NAME_INVERT); mParamMode.setDependentParameterNameSet(lDependentParameterSet); mParamMode.setValueStr("plainmask"); mParamAlpha.setValue(0.5); mParamAlpha.setMinValue("0"); mParamAlpha.setMaxValue("1"); mParamInvert.setValue(false); newParameter(mParamMode); newParameter(mParamAlpha); newParameter(mParamInvert); mInputSlotBackgroundColorImage = newSlot(new ModuleSlot(this, INPUT_SLOT_NAME_BGIMAGE, INPUT_SLOT_DISPLAYNAME_BGIMAGE, "Background image on which embedding with be performed")); mInputSlotTranslucencyColorImage = newSlot(new ModuleSlot(this, INPUT_SLOT_NAME_TRANSIMAGE, INPUT_SLOT_DISPLAYNAME_TRANSIMAGE, "Image that is going to be made translucent")); mInputSlotTranslucencyMaskImage = newSlot(new ModuleSlot(this, INPUT_SLOT_NAME_ALPHAMASK, INPUT_SLOT_DISPLAYNAME_ALPHAMASK, "Alpha mask used to make translucent image")); mOutputSlot = newSlot(new ModuleSlot(this, OUTPUT_SLOT_NAME_IMAGE, OUTPUT_SLOT_DISPLAYNAME_IMAGE, "Output image", &mOutputFrame)); mOutputFrameIpl = NULL; mOutputFrame = NULL; mTmpFrame1 = NULL; mTmpFrame2 = NULL; mTmpFrame3 = NULL; mTmpFrame4 = NULL; mTmpFrame5 = NULL; }
// ************************************************************************** // Function: LoadParameterList // Purpose: Loads the current list of parameters from a parameter file // It does NOT load system critical dynamic parameters (e.g., ports, // IP addresses) // Parameters: char *filename - filename of the parameterlist // nonexisting - if true, load parameters, even if they currently do // not exist in the list // Returns: true - successful // false - error // ************************************************************************** bool ParamList::Load( const string& inFileName, bool inImportNonexisting ) { ifstream file( inFileName.c_str() ); ParamList paramsFromFile; file >> paramsFromFile; if( file.fail() ) return false; typedef set<string> NameSet; NameSet unwantedParams; // Exclude parameters from unwanted sections. const char* unwantedSections[] = { "System", }; for( size_t j = 0; j < sizeof( unwantedSections ) / sizeof( *unwantedSections ); ++j ) for( ParamContainer::const_iterator i = paramsFromFile.mParams.begin(); i != paramsFromFile.mParams.end(); ++i ) if( Param::strciequal( i->Param.Section(), unwantedSections[ j ] ) ) unwantedParams.insert( i->Param.mName ); // If desired, exclude parameters missing from the main parameter list. if( !inImportNonexisting ) for( ParamContainer::const_iterator i = paramsFromFile.mParams.begin(); i != paramsFromFile.mParams.end(); ++i ) if( mNameIndex.find( i->Param.mName ) == mNameIndex.end() ) unwantedParams.insert( i->Param.mName ); for( NameSet::const_iterator i = unwantedParams.begin(); i != unwantedParams.end(); ++i ) paramsFromFile.Delete( *i ); for( ParamContainer::const_iterator i = paramsFromFile.mParams.begin(); i != paramsFromFile.mParams.end(); ++i ) ( *this )[ i->Param.mName ].AssignValues( i->Param ); return true; }
bool filterBlockWithQuery(ASTPtr query, Block & block, const Context & context) { query = query->clone(); const ASTSelectQuery & select = typeid_cast<ASTSelectQuery & >(*query); if (!select.where_expression && !select.prewhere_expression) return false; NameSet columns; for (const auto & it : block.getColumnsList()) columns.insert(it.name); /// Составим выражение, вычисляющее выражения в WHERE и PREWHERE, зависящие только от имеющихся столбцов. std::vector<ASTPtr> functions; if (select.where_expression) extractFunctions(select.where_expression, columns, functions); if (select.prewhere_expression) extractFunctions(select.prewhere_expression, columns, functions); ASTPtr expression_ast = buildWhereExpression(functions); if (!expression_ast) return false; /// Распарсим и вычислим выражение. ExpressionAnalyzer analyzer(expression_ast, context, {}, block.getColumnsList()); ExpressionActionsPtr actions = analyzer.getActions(false); actions->execute(block); /// Отфильтруем блок. String filter_column_name = expression_ast->getColumnName(); ColumnPtr filter_column = block.getByName(filter_column_name).column; if (auto converted = filter_column->convertToFullColumnIfConst()) filter_column = converted; const IColumn::Filter & filter = dynamic_cast<ColumnUInt8 &>(*filter_column).getData(); if (std::accumulate(filter.begin(), filter.end(), 0ul) == filter.size()) return false; for (size_t i = 0; i < block.columns(); ++i) { ColumnPtr & column = block.safeGetByPosition(i).column; column = column->filter(filter, -1); } return true; }
bool filterBlockWithQuery(const ASTPtr & query, Block & block, const Context & context) { const ASTSelectQuery & select = typeid_cast<const ASTSelectQuery & >(*query); if (!select.where_expression && !select.prewhere_expression) return false; NameSet columns; for (const auto & it : block.getColumnsList()) columns.insert(it.name); /// We will create an expression that evaluates the expressions in WHERE and PREWHERE, depending only on the existing columns. std::vector<ASTPtr> functions; if (select.where_expression) extractFunctions(select.where_expression, columns, functions); if (select.prewhere_expression) extractFunctions(select.prewhere_expression, columns, functions); ASTPtr expression_ast = buildWhereExpression(functions); if (!expression_ast) return false; /// Let's parse and calculate the expression. ExpressionAnalyzer analyzer(expression_ast, context, {}, block.getColumnsList()); ExpressionActionsPtr actions = analyzer.getActions(false); actions->execute(block); /// Filter the block. String filter_column_name = expression_ast->getColumnName(); ColumnPtr filter_column = block.getByName(filter_column_name).column; if (auto converted = filter_column->convertToFullColumnIfConst()) filter_column = converted; const IColumn::Filter & filter = dynamic_cast<ColumnUInt8 &>(*filter_column).getData(); if (countBytesInFilter(filter) == 0) return false; for (size_t i = 0; i < block.columns(); ++i) { ColumnPtr & column = block.safeGetByPosition(i).column; column = column->filter(filter, -1); } return true; }
void AnimationCleanerVisitor::cleanInvalidUpdateMorph() { // Removes unused UpdateMorph targets (i.e. name does not match any MorphGeometry target) for(AnimationUpdateCallBackMap::iterator update = _updates.begin() ; update != _updates.end() ; ++ update) { osgAnimation::UpdateMorph *updateMorph = dynamic_cast<osgAnimation::UpdateMorph*>(update->first.get()); if(!updateMorph) continue; NameSet toRemove; for(unsigned int i = 0, numTarget = updateMorph->getNumTarget(); i < numTarget; ++i) { const std::string& name = updateMorph->getTargetName(i); if(_morphTargets.count(name) == 0) { toRemove.insert(name); } } for(NameSet::iterator targetName = toRemove.begin(); targetName != toRemove.end(); ++targetName) { updateMorph->removeTarget(*targetName); } } // Removes empty UpdateMorphCallback for(AnimationUpdateCallBackMap::iterator update = _updates.begin() ; update != _updates.end() ; ) { osgAnimation::UpdateMorph *updateMorph = dynamic_cast<osgAnimation::UpdateMorph*>(update->first.get()); if(!updateMorph || updateMorph->getNumTarget() != 0) { ++ update; } else { osg::Callback *callBack = update->second.get()->getUpdateCallback(); if(callBack) { if(callBack == updateMorph) update->second.get()->setUpdateCallback(callBack->getNestedCallback()); else callBack->removeNestedCallback(updateMorph); } _updates.erase(update ++); } } }
void WidgetDataBase::loadPlugins() { typedef QMap<QString, int> NameIndexMap; typedef QList<QDesignerWidgetDataBaseItemInterface*> ItemList; typedef QMap<QString, QDesignerWidgetDataBaseItemInterface*> NameItemMap; typedef QSet<QString> NameSet; // 1) create a map of existing custom classes NameIndexMap existingCustomClasses; NameSet nonCustomClasses; const int count = m_items.size(); for (int i = 0; i < count; i++) { const QDesignerWidgetDataBaseItemInterface* item = m_items[i]; if (item->isCustom() && !item->isPromoted()) existingCustomClasses.insert(item->name(), i); else nonCustomClasses.insert(item->name()); } // 2) create a list plugins ItemList pluginList; const QDesignerPluginManager *pm = m_core->pluginManager(); foreach(QDesignerCustomWidgetInterface* c, pm->registeredCustomWidgets()) pluginList += createCustomWidgetItem(c, pm->customWidgetData(c)); // 3) replace custom classes or add new ones, remove them from existingCustomClasses, // leaving behind deleted items unsigned replacedPlugins = 0; unsigned addedPlugins = 0; unsigned removedPlugins = 0; if (!pluginList.empty()) { ItemList::const_iterator cend = pluginList.constEnd(); for (ItemList::const_iterator it = pluginList.constBegin();it != cend; ++it ) { QDesignerWidgetDataBaseItemInterface* pluginItem = *it; const QString pluginName = pluginItem->name(); NameIndexMap::iterator existingIt = existingCustomClasses.find(pluginName); if (existingIt == existingCustomClasses.end()) { // Add new class. if (nonCustomClasses.contains(pluginName)) { designerWarning(tr("A custom widget plugin whose class name (%1) matches that of an existing class has been found.").arg(pluginName)); } else { append(pluginItem); addedPlugins++; } } else { // replace existing info const int existingIndex = existingIt.value(); delete m_items[existingIndex]; m_items[existingIndex] = pluginItem; existingCustomClasses.erase(existingIt); replacedPlugins++; } } } // 4) remove classes that have not been matched. The stored indexes become invalid while deleting. if (!existingCustomClasses.empty()) { NameIndexMap::const_iterator cend = existingCustomClasses.constEnd(); for (NameIndexMap::const_iterator it = existingCustomClasses.constBegin();it != cend; ++it ) { const int index = indexOfClassName(it.key()); if (index != -1) { remove(index); removedPlugins++; } } } if (debugWidgetDataBase) qDebug() << "WidgetDataBase::loadPlugins(): " << addedPlugins << " added, " << replacedPlugins << " replaced, " << removedPlugins << "deleted."; }