// ----------------------------------------------------------------------------- // Static Method // ----------------------------------------------------------------------------- void FilterWidgetManager::RegisterFilterWidgetFactory(const std::string &name, IFilterWidgetFactory::Pointer factory) { if (NULL != factory.get() ) { // Instantiate the Instance Manager for IFilterWidgetFactory FilterWidgetManager::Pointer idManager = FilterWidgetManager::Instance(); idManager->addFilterWidgetFactory( name, factory ); } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- QWidget* FilterWidgetManager::createWidget(FilterParameter* parameter, AbstractFilter* filter) { IFilterWidgetFactory::Pointer factory = m_Factories.value(parameter->getWidgetType()); if(NULL != factory.get()) { return factory->createWidget(parameter, filter, NULL); } UnknownWidget* unknownWidget = new UnknownWidget(parameter, filter, NULL); return unknownWidget; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- FilterWidgetManager::Collection FilterWidgetManager::getFactories(const std::string &groupName) { FilterWidgetManager::Collection groupFactories; for (FilterWidgetManager::Collection::iterator factory = m_Factories.begin(); factory != m_Factories.end(); ++factory) { IFilterWidgetFactory::Pointer filterFactory = (*factory).second; if ( NULL != filterFactory.get() && (*factory).second->getFilterGroup().compare(groupName) == 0) { groupFactories[(*factory).first] = (*factory).second; } } return groupFactories; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- IFilterWidgetFactory::Pointer FilterWidgetManager::getFactoryForFilterHumanName(const std::string &humanName) { IFilterWidgetFactory::Pointer widgetFactory; for (FilterWidgetManager::Collection::iterator factory = m_Factories.begin(); factory != m_Factories.end(); ++factory) { IFilterWidgetFactory::Pointer filterFactory = (*factory).second; if ( NULL != filterFactory.get() && filterFactory->getFilterHumanLabel().compare(humanName) == 0) { widgetFactory = filterFactory; break; } } return widgetFactory; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- std::set<std::string> FilterWidgetManager::getSubGroupNames(const std::string &groupName) { // std::cout << "FilterWidgetManager::getGroupNames" << std::endl; // Get all the Widget Factories and loop over each one we know about and instantiate a new one FilterWidgetManager::Pointer fm = FilterWidgetManager::Instance(); FilterWidgetManager::Collection factories = fm->getFactories(); std::set<std::string> subGroupNames; for (FilterWidgetManager::Collection::iterator factory = factories.begin(); factory != factories.end(); ++factory) { IFilterWidgetFactory::Pointer filterFactory = (*factory).second; if ( NULL != filterFactory.get() && (*factory).second->getFilterGroup().compare(groupName) == 0) { subGroupNames.insert((*factory).second->getFilterSubGroup()); } } return subGroupNames; }