Exemplo n.º 1
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
bool CorrectInitializerList( AbstractFilter::Pointer filter, const QString& hFile, const QString& cppFile)
{
  QString contents;
  {
    // Read the Source File
    QFileInfo fi(cppFile);
    //
    if (fi.baseName().compare("RegisterPointSets") != 0)
    {
      return false;
    }
    QFile source(cppFile);
    source.open(QFile::ReadOnly);
    contents = source.readAll();
    source.close();
  }


  QStringList names;
  bool didReplace = false;

  QString searchString = filter->getNameOfClass() + "::" + filter->getNameOfClass();
  QStringList outLines;
  QStringList list = contents.split(QRegExp("\\n"));
  QStringListIterator sourceLines(list);

  int index = 0;
  while (sourceLines.hasNext())
  {
    QString line = sourceLines.next();
    if(line.contains(searchString) )
    {
      outLines.push_back(line);
      line = sourceLines.next();
      outLines.push_back(line); // get the call to the superclass

      fixInitializerList(sourceLines, outLines, hFile, cppFile);
      didReplace = true;
    }
    else
    {
      outLines.push_back(line);
    }
  }


  writeOutput(didReplace, outLines, cppFile);
  index++;

  return didReplace;
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void LoopOnFilters()
{
  FilterManager::Pointer fm = FilterManager::Instance();
  FilterManager::Collection factories = fm->getFactories();

  FilterManager::CollectionIterator i(factories);
  int count = 0;
  while (i.hasNext())
  {
    i.next();
    std::cout << ++count << ": " << i.key().toStdString() << ": " << std::endl;

    //std::cout << "  public:" << std::endl;
    IFilterFactory::Pointer factory = i.value();
    AbstractFilter::Pointer filter = factory->create();
    //if (filter->getGroupName().compare(DREAM3D::FilterGroups::StatisticsFilters) == 0)
    // if(filter->getNameOfClass().compare("FindSchmids") == 0)
    {
      //   std::cout << "" << filter->getGroupName().toStdString() << "Filters/" << filter->getNameOfClass().toStdString() << ".cpp" << std::endl;
      QString cpp = findPath(filter->getGroupName(), filter->getNameOfClass(), ".cpp");
      std::cout << filter << " " << cpp.toStdString() << std::endl;
    }

  }

}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void GenerateFilterParametersCode()
{

  FilterManager::Pointer fm = FilterManager::Instance();
  FilterManager::Collection factories = fm->getFactories();
  QMapIterator<QString, IFilterFactory::Pointer> iter(factories);
  // Loop on each filter
  while(iter.hasNext())
  {
    iter.next();
    IFilterFactory::Pointer factory = iter.value();
    AbstractFilter::Pointer filter = factory->create();

    QString cpp = findPath(filter->getGroupName(), filter->getNameOfClass(), ".cpp");
    QString h = findPath(filter->getGroupName(), filter->getNameOfClass(), ".h");

    fixFile(filter, h, cpp);
  }

}
Exemplo n.º 4
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void GenerateCodeForFilter(const QString& outDir, AbstractFilter::Pointer filter)
{
  QString filterClassName = filter->getNameOfClass();

  // Generate our Output File Name for this filter. If we are going to generate a single file for everything then,
  // We need to think abit more about how this is setup. There is a potential for 2 plugins to clash with a filter's
  // C++ Class name, which would be interesting to say the least.

  QFile f(outDir + QDir::separator() + filterClassName + ".m");
  f.open(QFile::WriteOnly);
  QTextStream out(&f);


  QVector<FilterParameter::Pointer> options = filter->getFilterParameters();

  out << "function [ Filter_Parts ] = " << filterClassName << '\n';

  int i = 1;
  for (QVector<FilterParameter::Pointer>::iterator iter = options.begin(); iter != options.end(); ++iter )
  {
    SeparatorFilterParameter::Pointer sepFiltParam = SeparatorFilterParameter::New();
    FilterParameter* option = (*iter).get();
    if (option->getHumanLabel().compare("Required Information") == 0
        || option->getHumanLabel().compare("Created Information") == 0
        || option->getHumanLabel().compare("Optional Information") == 0
        || option->getWidgetType().compare(sepFiltParam->getWidgetType()) == 0)
    { continue; }

    // creates a working MATLAB m-file function per file per filter
    out << "Filter_Parts{1}{" << i << "} = '" << option->getPropertyName() << "';\n"
        << "Filter_Parts{2}{" << i << "} = '" << option->getWidgetType() << "';\n";
    ++i;
  }

  out << "end";

  f.close();
}