// Write the current Ranges portion of controls to an XML stream
bool US_RunProtocol::RunProtoRanges::toXml( QXmlStreamWriter& xmlo )
{
   nranges              = chrngs.count();
   xmlo.writeStartElement( "ranges" );
   for ( int ii = 0; ii < nranges; ii++ )
   {
      xmlo.writeStartElement( "range" );
      xmlo.writeAttribute   ( "channel",      chrngs[ ii ].channel );
      xmlo.writeAttribute   ( "start_radius",
                              QString::number( chrngs[ ii ].lo_rad ) );
      xmlo.writeAttribute   ( "end_radius",
                              QString::number( chrngs[ ii ].hi_rad ) );
      for ( int jj = 0; jj < chrngs[ ii ].wvlens.count(); jj++ )
      {
         xmlo.writeStartElement( "wavelength" );
         xmlo.writeAttribute   ( "lambda",
                                 QString::number( chrngs[ ii ].wvlens[ jj ] ) );
         xmlo.writeEndElement(); // wavelength
      }
      xmlo.writeEndElement(); // range
   }
   xmlo.writeEndElement(); // ranges

   return ( ! xmlo.hasError() );
}
// Write all current controls to an XML stream
bool US_RunProtocol::toXml( QXmlStreamWriter& xmlo )
{
   xmlo.writeStartDocument();
   xmlo.writeDTD          ( "<!DOCTYPE US_RunProtocol>" );
   xmlo.writeStartElement ( "ProtocolData" );
   xmlo.writeAttribute    ( "version", "1.0" );

   xmlo.writeStartElement ( "protocol" );
   xmlo.writeAttribute    ( "description",  protname );
   xmlo.writeAttribute    ( "guid",         pGUID );
   xmlo.writeAttribute    ( "optima_host",  optimahost );
   xmlo.writeAttribute    ( "investigator", investigator );
   xmlo.writeAttribute    ( "temperature",  QString::number( temperature ) );
   xmlo.writeAttribute    ( "temeq_delay",  QString::number( temeq_delay ) );

   rpRotor.toXml( xmlo );
   rpSpeed.toXml( xmlo );
   rpCells.toXml( xmlo );
   rpSolut.toXml( xmlo );
   rpOptic.toXml( xmlo );
   rpRange.toXml( xmlo );

   xmlo.writeEndElement();    // protocol

   xmlo.writeEndElement();    // ProtocolData
   xmlo.writeEndDocument();

   return ( ! xmlo.hasError() );
}
// Write the current Cells portion of controls to an XML stream
bool US_RunProtocol::RunProtoCells::toXml( QXmlStreamWriter& xmlo )
{
   xmlo.writeStartElement( "cells" );
   xmlo.writeAttribute   ( "total_holes", QString::number( ncell ) );
   xmlo.writeAttribute   ( "used_holes",  QString::number( nused ) );

  
   for ( int ii = 0; ii < nused; ii++ )
   {
      xmlo.writeStartElement( "cell" );
      xmlo.writeAttribute   ( "id", QString::number( used[ ii ].cell ) );
      // if ( ( ii + 1 ) < nused )                                         //ALEXEY bug
      // {
      //    xmlo.writeAttribute( "centerpiece",    used[ ii ].centerpiece );
      //    xmlo.writeAttribute( "windows",        used[ ii ].windows     );
      // }
      if ( used[ ii ].cell != ncell )
       {
          xmlo.writeAttribute( "centerpiece",    used[ ii ].centerpiece );
          xmlo.writeAttribute( "windows",        used[ ii ].windows     );
       }           
      else
      {
	xmlo.writeAttribute( "counterbalance", used[ ii ].cbalance    );   // ALEXEY: Potential BUG: WHY last cell is always counterbalance ?? 
      }
      xmlo.writeEndElement(); // cell
   }

   xmlo.writeEndElement(); // cells

   return ( ! xmlo.hasError() );
}
// Write the current Speed portion of controls to an XML stream
bool US_RunProtocol::RunProtoSpeed::toXml( QXmlStreamWriter& xmlo )
{
   xmlo.writeStartElement( "speed" );
   xmlo.writeAttribute( "spin_down",          spin_down    ? "1" : "0" );
   xmlo.writeAttribute( "radial_calibration", radial_calib ? "1" : "0" );

   for ( int ii = 0; ii < ssteps.count(); ii++ )
   {
      QString s_durat;
      QString s_delay;
      QString s_sintv;
      US_RunProtocol::timeToString( ssteps[ ii ].duration, s_durat );
      US_RunProtocol::timeToString( ssteps[ ii ].delay,    s_delay );
      US_RunProtocol::timeToString( ssteps[ ii ].scanintv, s_sintv );

      xmlo.writeStartElement( "speedstep" );
      xmlo.writeAttribute   ( "rotorspeed",
                              QString::number( ssteps[ ii ].speed ) );
      xmlo.writeAttribute   ( "acceleration",
                              QString::number( ssteps[ ii ].accel ) );
      xmlo.writeAttribute   ( "duration",      s_durat );
      xmlo.writeAttribute   ( "delay",         s_delay );
      xmlo.writeAttribute   ( "scan_interval", s_sintv );
      xmlo.writeEndElement  (); // speedstep
   }
   xmlo.writeEndElement();    // speed

   return ( ! xmlo.hasError() );
}
// Write the current Solutions portion of controls to an XML stream
bool US_RunProtocol::RunProtoSolutions::toXml( QXmlStreamWriter& xmlo )
{
   nschan               = chsols.count();
   xmlo.writeStartElement( "solutions" );
   for ( int ii = 0; ii < nschan; ii++ )
   {
      xmlo.writeStartElement( "solution" );
      xmlo.writeAttribute   ( "channel",      chsols[ ii ].channel    );
      xmlo.writeAttribute   ( "name",         chsols[ ii ].solution   );
      xmlo.writeAttribute   ( "id",           chsols[ ii ].sol_id     );
      xmlo.writeAttribute   ( "chan_comment", chsols[ ii ].ch_comment );
      xmlo.writeEndElement(); // solution
   }
   xmlo.writeEndElement();    // solutions

   return ( ! xmlo.hasError() );
}
// Write the current Optical Systems portion of controls to an XML stream
bool US_RunProtocol::RunProtoOptics::toXml( QXmlStreamWriter& xmlo )
{
   nochan               = chopts.count();
   xmlo.writeStartElement( "optics" );
   for ( int ii = 0; ii < nochan; ii++ )
   {
      xmlo.writeStartElement( "optical_system" );
      xmlo.writeAttribute   ( "channel", chopts[ ii ].channel );
      if ( ! chopts[ ii ].scan1.isEmpty() )
         xmlo.writeAttribute   ( "scan1",   chopts[ ii ].scan1 );
      if ( ! chopts[ ii ].scan2.isEmpty() )
         xmlo.writeAttribute   ( "scan2",   chopts[ ii ].scan2 );
      if ( ! chopts[ ii ].scan3.isEmpty() )
         xmlo.writeAttribute   ( "scan3",   chopts[ ii ].scan3 );
      xmlo.writeEndElement(); // optical_system
   }
   xmlo.writeEndElement(); // optics

   return ( ! xmlo.hasError() );
}
// Write the current Rotor portion of controls to an XML stream
bool US_RunProtocol::RunProtoRotor::toXml( QXmlStreamWriter& xmlo )
{
   xmlo.writeStartElement( "rotor" );

   xmlo.writeAttribute( "laboratory",  laboratory );
   xmlo.writeAttribute( "rotor",       rotor );
   xmlo.writeAttribute( "calibration", calibration );
   xmlo.writeAttribute( "labid",       QString::number( labID ) );
   xmlo.writeAttribute( "rotid",       QString::number( rotID ) );
   xmlo.writeAttribute( "calid",       QString::number( calID ) );
   xmlo.writeAttribute( "absid",       QString::number( absID ) );
   xmlo.writeAttribute( "labguid",     labGUID );
   xmlo.writeAttribute( "rotguid",     rotGUID );
   xmlo.writeAttribute( "calguid",     calGUID );
   xmlo.writeAttribute( "absguid",     absGUID );

   xmlo.writeEndElement();    // rotor

   return ( ! xmlo.hasError() );
}
Beispiel #8
0
void Table::setXML(QXmlStreamWriter& w) const{
    int s=datalist.size();
    for(int i=0;i<s && !w.hasError();i++)
    {
        QString xname=datalist[i]->getName()->text();
        QString xtype=datalist[i]->getType()->text();
        QString xlv=datalist[i]->getLV()->text();
        QString xstrength=datalist[i]->getStrength()->text();
        QString xconstitution=datalist[i]->getConstitution()->text();
        w.writeStartElement(xtype);
        w.writeTextElement("Name",xname);
        w.writeTextElement("LV",xlv);
        w.writeTextElement("Strength",xstrength);
        w.writeTextElement("Constitution",xconstitution);
        if(xtype!="Golem")
        {
            QString xmp=datalist[i]->getMP()->text();
            QString xwisdom=datalist[i]->getWisdom()->text();
            w.writeTextElement("MP",xmp);
            w.writeTextElement("Wisdom",xwisdom);
        }
        w.writeEndElement();
    }
}
Beispiel #9
0
bool Document::saveMOJ(QString fileName)
{
  QFile file(fileName);
  if (!file.open(QIODevice::WriteOnly))
  {
    return false;
  }

  QXmlStreamWriter writer;

  writer.setAutoFormatting(true);

  writer.setDevice(&file);

  writer.writeStartDocument("1.0", false);
  writer.writeStartElement("MrWriter");
  QString version;
  version.append(QString::number(MAJOR_VERSION)).append(".").append(QString::number(MINOR_VERSION)).append(QString::number(PATCH_VERSION));
  writer.writeAttribute(QXmlStreamAttribute("version", version));
  QString docVersion = QString::number(DOC_VERSION);
  writer.writeAttribute(QXmlStreamAttribute("docversion", docVersion));

  writer.writeStartElement("title");
  writer.writeCharacters("MrWriter document - see http://unruhschuh.com/mrwriter/");
  writer.writeEndElement();

  for (int i = 0; i < pages.size(); ++i)
  {
    writer.writeStartElement("page");
    writer.writeAttribute(QXmlStreamAttribute("width", QString::number(pages[i].width())));
    writer.writeAttribute(QXmlStreamAttribute("height", QString::number(pages[i].height())));
    writer.writeEmptyElement("background");
    writer.writeAttribute(QXmlStreamAttribute("type", "solid"));
    writer.writeAttribute(QXmlStreamAttribute("color", toRGBA(pages[i].backgroundColor().name(QColor::HexArgb))));
    writer.writeAttribute(QXmlStreamAttribute("style", "plain"));
    writer.writeStartElement("layer");

    //    for (int j = 0; j < pages[i].m_strokes.size(); ++j)
    for (auto strokes : pages[i].strokes())
    {
      writer.writeStartElement("stroke");
      writer.writeAttribute(QXmlStreamAttribute("tool", "pen"));
      writer.writeAttribute(QXmlStreamAttribute("color", toRGBA(strokes.color.name(QColor::HexArgb))));
      QString patternString;
      if (strokes.pattern == MrDoc::solidLinePattern)
      {
        patternString = "solid";
      }
      else if (strokes.pattern == MrDoc::dashLinePattern)
      {
        patternString = "dash";
      }
      else if (strokes.pattern == MrDoc::dashDotLinePattern)
      {
        patternString = "dashdot";
      }
      else if (strokes.pattern == MrDoc::dotLinePattern)
      {
        patternString = "dot";
      }
      else
      {
        patternString = "solid";
      }
      writer.writeAttribute(QXmlStreamAttribute("style", patternString));
      qreal width = strokes.penWidth;
      writer.writeAttribute(QXmlStreamAttribute("width", QString::number(width)));
      QString pressures;
      for (int k = 0; k < strokes.pressures.length(); ++k)
      {
        pressures.append(QString::number(strokes.pressures[k])).append(" ");
      }
      writer.writeAttribute((QXmlStreamAttribute("pressures", pressures.trimmed())));
      QString points;
      for (int k = 0; k < strokes.points.size(); ++k)
      {
        points.append(QString::number(strokes.points[k].x()));
        points.append(" ");
        points.append(QString::number(strokes.points[k].y()));
        points.append(" ");
      }
      writer.writeCharacters(points.trimmed());
      writer.writeEndElement(); // closing "stroke"
    }

    writer.writeEndElement(); // closing "layer"
    writer.writeEndElement(); // closing "page"
  }

  writer.writeEndDocument();

  QFileInfo fileInfo(file);

  file.close();

  if (writer.hasError())
  {
    return false;
  }
  else
  {
    setDocumentChanged(false);

    m_path = fileInfo.absolutePath();
    m_docName = fileInfo.completeBaseName();
    return true;
  }
}
Beispiel #10
0
bool Document::saveXOJ(QString fileName)
{
  QFile file(fileName);
  if (!file.open(QIODevice::WriteOnly))
  {
    return false;
  }

  QXmlStreamWriter writer;

  writer.setAutoFormatting(true);

  writer.setDevice(&file);

  writer.writeStartDocument("1.0", false);
  writer.writeStartElement("xournal");
  writer.writeAttribute(QXmlStreamAttribute("version", "0.4.8"));

  writer.writeStartElement("title");
  writer.writeCharacters("Xournal document - see http://math.mit.edu/~auroux/software/xournal/");
  writer.writeEndElement();

  for (int i = 0; i < pages.size(); ++i)
  {
    writer.writeStartElement("page");
    writer.writeAttribute(QXmlStreamAttribute("width", QString::number(pages[i].width())));
    writer.writeAttribute(QXmlStreamAttribute("height", QString::number(pages[i].height())));
    writer.writeEmptyElement("background");
    writer.writeAttribute(QXmlStreamAttribute("type", "solid"));
    writer.writeAttribute(QXmlStreamAttribute("color", toRGBA(pages[i].backgroundColor().name(QColor::HexArgb))));
    writer.writeAttribute(QXmlStreamAttribute("style", "plain"));
    writer.writeStartElement("layer");

    //    for (int j = 0; j < pages[i].m_strokes.size(); ++j)
    for (auto strokes : pages[i].strokes())
    {
      writer.writeStartElement("stroke");
      writer.writeAttribute(QXmlStreamAttribute("tool", "pen"));
      writer.writeAttribute(QXmlStreamAttribute("color", toRGBA(strokes.color.name(QColor::HexArgb))));
      qreal width = strokes.penWidth;
      QString widthString;
      widthString.append(QString::number(width));
      for (int k = 0; k < strokes.pressures.size() - 1; ++k)
      {
        qreal p0 = strokes.pressures[k];
        qreal p1 = strokes.pressures[k + 1];
        widthString.append(' ');
        widthString.append(QString::number(0.5 * (p0 + p1) * width));
      }
      writer.writeAttribute(QXmlStreamAttribute("width", widthString));
      for (int k = 0; k < strokes.points.size(); ++k)
      {
        writer.writeCharacters(QString::number(strokes.points[k].x()));
        writer.writeCharacters(" ");
        writer.writeCharacters(QString::number(strokes.points[k].y()));
        writer.writeCharacters(" ");
      }
      writer.writeEndElement(); // closing "stroke"
    }

    writer.writeEndElement(); // closing "layer"
    writer.writeEndElement(); // closing "page"
  }

  writer.writeEndDocument();

  QFileInfo fileInfo(file);

  file.close();

  if (writer.hasError())
  {
    return false;
  }
  else
  {
    return true;
  }
}