예제 #1
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
int main (int argc, char  *argv[])
{
  QApplication app(argc, argv);

  FilterWidgetsLib::RegisterKnownQFilterWidgets();




  FilterWidgetManager::Pointer wm = FilterWidgetManager::Instance();

  FilterWidgetManager::Collection allFactories = wm->getFactories();


  for(FilterWidgetManager::Collection::iterator iter = allFactories.begin(); iter != allFactories.end(); ++iter)
  {
    QString filterName = QString::fromStdString((*iter).first);
    std::cout << "Writing " << filterName.toStdString() << std::endl;
    IFilterWidgetFactory::Pointer wf = (*iter).second;
    if (NULL == wf) { return EXIT_FAILURE;}
    QFilterWidget* w = wf->createWidget();
    QString filePath = QString("/tmp/") + filterName + QString(".ini");
    QSettings prefs(filePath, QSettings::IniFormat, NULL);
    prefs.beginGroup(QString("FILTER_NUMBER"));
    w->writeOptions(prefs);
    prefs.endGroup();

  }


  return EXIT_SUCCESS;
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
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;
}
예제 #3
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
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;
}
예제 #4
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
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;
}
예제 #5
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
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;
}
예제 #6
0
// -----------------------------------------------------------------------------
//  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 );
    }
}