Example #1
0
void PovRay::readNextDeclaration(TextStream& textStream, Data::PovRay* povray)
{
   // looks for '#declare TextureName = '
   const QRegExp declare("^#declare\\s+(\\S+)\\s?="); 

   QString line(textStream.nextLine());
   if (!line.contains(declare)) line = textStream.seek(declare);

   if (!textStream.atEnd() && declare.indexIn(line) > -1) {
      QString name(declare.cap(1));
      // remove the initial IQmol_Texture_
      name.remove(0,14);
      name.replace("_", " ");
      line = textStream.nextBlock();
      povray->addTexture(name,line);
   }
}
Example #2
0
QString EfpFragment::loadNextFragment(TextStream& textStream)
{
   QString line(textStream.previousLine()); 
   if (!line.contains("fragment", Qt::CaseInsensitive)) {
      line = textStream.seek("fragment", Qt::CaseInsensitive);
   }

   QStringList tokens(TextStream::tokenize(line));
   QString name;

   if (tokens.size() >= 2 && tokens[0].toLower() == "fragment") {
      name = tokens[1];
   }else {
      return QString();
   }

   CartesianCoordinates parser;
   Data::Geometry* geom(parser.parse(textStream)); 
   if ( !geom || !parser.error().isEmpty()) {
      m_errors.append("Invalid EFP file, no coordinates found");
      delete geom;
      return QString();
   }

   if (name.endsWith("_L", Qt::CaseInsensitive)) {
      Data::EfpFragmentLibrary::instance().add(name, geom);
   }else {
	  // We assume the fragment is not in the library and so we need to collect
	  // the additional guff so we can add it to the input file if required.
      QString line;
      QStringList guff;
      while ( !textStream.atEnd() && 
         !line.contains("fragment", Qt::CaseInsensitive) &&
         !line.contains("$end", Qt::CaseInsensitive) ) {
         guff << line;
      }
      Data::EfpFragmentLibrary::instance().add(name, geom, guff.join("\n"));
   }

   return name;
}