All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions
SciFigs::XMLSciFigs Class Reference

Brief description of class still missing. More...

#include <XMLSciFigs.h>

Inheritance diagram for SciFigs::XMLSciFigs:
QGpCoreTools::XMLClass QGpCoreTools::XMLContext

List of all members.

Public Types

enum  FileType {
  None = 0, MakeUp = 1, Data = 2, PageHeader = 4,
  Layer = 3, Page = 7, Selection = 8
}

Public Member Functions

QString currentFileVersion ()
bool data ()
bool makeUp ()
XMLClass::Error restoreByteArray (QByteArray data, XMLClass *object, FileTypes type)
XMLClass::Error restoreFile (QString fileName, XMLClass *object, FileTypes type)
XMLClass::Error restoreString (QString s, XMLClass *object, FileTypes type)
bool restoring ()
QByteArray saveByteArray (const XMLClass *object, FileTypes type)
XMLClass::Error saveFile (QString fileName, const XMLClass *object, FileTypes type)
QString saveString (const XMLClass *object, FileTypes type)
bool selection ()
virtual const QString & xml_tagName () const
 XMLSciFigs ()

Static Public Attributes

static const QString xmlSciFigsTag = "SciFigs"

Protected Member Functions

virtual XMLMember xml_member (XML_MEMBER_ARGS)
virtual bool xml_setProperty (XML_SETPROPERTY_ARGS)
virtual void xml_writeChildren (XML_WRITECHILDREN_ARGS) const
virtual void xml_writeProperties (XML_WRITEPROPERTIES_ARGS) const

Detailed Description

Brief description of class still missing.

Full description of class still missing


Member Enumeration Documentation

Enumerator:
None 
MakeUp 
Data 
PageHeader 
Layer 
Page 
Selection 

Reimplemented from QGpCoreTools::XMLClass.

{None=0, MakeUp=1, Data=2, PageHeader=4, Layer=3, Page=7, Selection=8};

Constructor & Destructor Documentation

References None, and TRACE.

{
  TRACE;
  _currentObject=0;
  _currentFile=None;
}

Member Function Documentation

bool SciFigs::XMLSciFigs::data ( ) [inline]

Referenced by GeopsyGui::TimeWindowLayer::xml_layerPolish(), SciFigs::GridViewer::xml_member(), GeopsyGui::TimeWindowLayer::xml_member(), SciFigs::AbstractNameLine::xml_member(), SciFigs::XYValuePlot::xml_member(), SciFigs::XYValueLines::xml_member(), GeopsyGui::ChronogramLayer::xml_member(), SciFigs::ParallelBands::xml_member(), SciFigs::AbstractLine::xml_member(), SciFigs::CircleViewer::xml_member(), SciFigs::GridPlot::xml_member(), SciFigs::LegendWidget::xml_member(), SciFigs::ColorPaletteWidget::xml_member(), SciFigs::LineLayer::xml_member(), SciFigs::ImageLayer::xml_member(), GeopsyGui::SignalLayer::xml_member(), SciFigs::GraphicSheet::xml_member(), SciFigs::GraphContent::xml_member(), SciFigs::GraphContent::xml_polishChild(), SciFigs::TextEdit::xml_setProperty(), SciFigs::GridViewer::xml_writeChildren(), GeopsyGui::TimeWindowLayer::xml_writeChildren(), SciFigs::XYValuePlot::xml_writeChildren(), GeopsyGui::ChronogramLayer::xml_writeChildren(), SciFigs::XYValueLines::xml_writeChildren(), SciFigs::ParallelBands::xml_writeChildren(), NAModelsPlot::xml_writeChildren(), SciFigs::LiveGridLayer::xml_writeChildren(), SciFigs::GridPlot::xml_writeChildren(), SciFigs::LegendWidget::xml_writeChildren(), SciFigs::ColorPaletteWidget::xml_writeChildren(), SciFigs::ImageLayer::xml_writeChildren(), GeopsyGui::SignalLayer::xml_writeChildren(), GeopsyGui::TimeWindowLayer::xml_writeProperties(), NAModelsPlot::xml_writeProperties(), SciFigs::AbstractLine::xml_writeProperties(), SciFigs::CircleViewer::xml_writeProperties(), SciFigs::XYPlot::xml_writeProperties(), SciFigs::XUniqueYColorLines::xml_writeProperties(), SciFigs::XYColorLines::xml_writeProperties(), and SciFigs::ImageLayer::xml_writeProperties().

{return _currentFile & Data;}
bool SciFigs::XMLSciFigs::makeUp ( ) [inline]
XMLClass::Error SciFigs::XMLSciFigs::restoreByteArray ( QByteArray  data,
XMLClass object,
FileTypes  type 
)

Description still missing

References QGpCoreTools::XMLHeader::addAlternateTag(), QGpCoreTools::XMLClass::NoError, None, TRACE, and QGpCoreTools::XMLHeader::xml_restoreByteArray().

Referenced by SciFigs::GraphicSheet::paste(), SciFigs::GraphContent::pasteLayers(), SciFigs::GraphicObject::pasteMakeUp(), and SciFigs::GraphicSheet::pasteMakeUp().

{
  TRACE;
  if(type==None || !object) return XMLClass::NoError;
  _currentFile=type;
  _currentObject=object;
  XMLHeader hdr(this);
  hdr.addAlternateTag("Scifigs"); // compatibility
  XMLClass::Error err=hdr.xml_restoreByteArray(data, this);
  _currentObject=0;
  _currentFile=None;
  return err;
}
XMLClass::Error SciFigs::XMLSciFigs::restoreFile ( QString  fileName,
XMLClass object,
FileTypes  type 
)
XMLClass::Error SciFigs::XMLSciFigs::restoreString ( QString  s,
XMLClass object,
FileTypes  type 
)

Description still missing

References QGpCoreTools::XMLHeader::addAlternateTag(), QGpCoreTools::XMLClass::NoError, None, TRACE, and QGpCoreTools::XMLHeader::xml_restoreString().

Referenced by ChronogramWindow::ChronogramWindow(), and GraphicWindow::GraphicWindow().

{
  TRACE;
  if(type==None || !object) return XMLClass::NoError;
  _currentFile=type;
  _currentObject=object;
  XMLHeader hdr(this);
  hdr.addAlternateTag("Scifigs"); // compatibility
  XMLClass::Error err=hdr.xml_restoreString(s, this);
  _currentObject=0;
  _currentFile=None;
  return err;
}
bool SciFigs::XMLSciFigs::restoring ( ) [inline]

Referenced by SciFigs::TextEdit::xml_setProperty().

{return _currentFile!=None;}
QByteArray SciFigs::XMLSciFigs::saveByteArray ( const XMLClass object,
FileTypes  type 
)

Description still missing

References None, TRACE, and QGpCoreTools::XMLHeader::xml_saveByteArray().

Referenced by SciFigs::GraphicObject::copy(), SciFigs::GraphicSheet::copy(), and SciFigs::GraphContent::copyLayers().

{
  TRACE;
  if(type==None || !object) return QByteArray();
  _currentFile=type;
  _currentObject=object;
  XMLHeader hdr(this);
  QByteArray res=hdr.xml_saveByteArray(this);
  _currentObject=0;
  _currentFile=None;
  return res;
}
XMLClass::Error SciFigs::XMLSciFigs::saveFile ( QString  fileName,
const XMLClass object,
FileTypes  type 
)

Description still missing

References QGpCoreTools::XMLClass::NoError, None, TRACE, and QGpCoreTools::XMLHeader::xml_saveFile().

Referenced by SciFigs::GraphicSheet::fileSave(), SciFigs::LegendWidget::save(), SciFigs::ColorPaletteWidget::save(), SciFigs::GraphContent::saveLayers(), and SciFigs::GraphicObject::savePage().

{
  TRACE;
  if(type==None || !object) return XMLClass::NoError;
  _currentFile=type;
  _currentObject=object;
  XMLHeader hdr(this);
  XMLClass::Error err=hdr.xml_saveFile(fileName, this);
  _currentObject=0;
  _currentFile=None;
  return err;
}
QString SciFigs::XMLSciFigs::saveString ( const XMLClass object,
FileTypes  type 
)

Description still missing

References None, TRACE, and QGpCoreTools::XMLHeader::xml_saveString().

Referenced by SciFigs::GraphicObject::copyMakeUp(), SciFigs::GraphicSheet::copyMakeUp(), SciFigs::GraphicObject::saveMakeUp(), SciFigs::GraphicSheet::saveMakeUp(), ChronogramWindow::~ChronogramWindow(), and GraphicWindow::~GraphicWindow().

{
  TRACE;
  if(type==None || !object) return QString::null;
  _currentFile=type;
  _currentObject=object;
  XMLHeader hdr(this);
  QString res=hdr.xml_saveString(true, this);
  _currentObject=0;
  _currentFile=None;
  return res;
}
bool SciFigs::XMLSciFigs::selection ( ) [inline]

Referenced by SciFigs::GraphicSheet::xml_writeChildren().

{return _currentFile & Selection;}

Re-implement this function to offer XML restore (children and properties) support to your class.

From tag and map (with contains the attibute value) return a unique identifier under the format of a XMLMember. XMLMember is initialized with 3 types of contructors:

  • An integer: id number of a property
  • A XMLClass * : a child of this object identified by tag
  • Default constructor: error, unknow child or property

Map of attributes can be inspected in this way (can be achived also in xml_setProperty()):

    static const QString tmp("childrenName");
    XMLRestoreAttributeIterator it=map.find(tmp);
    if(it!=map.end()) {
      // found attribute "childrenName"
    }

If the map of attributes is not used:

    Q_UNUSED(attributes);
    if(tag=="x1") return XMLMember(0);
    else if(tag=="y1") return XMLMember(1);
    else if(tag=="x2") return XMLMember(2);
    else if(tag=="y2") return XMLMember(3);
    else return XMLMember(XMLMember::Unknown);

Arithmetic operations + and - apply to XMLMember to avoid confusion of property id numbers between inherited objects. Offset 3 corresponds to the number of properties defined in this object.

    if(tag=="anInteger") return XMLMember(0);
    else if(tag=="aString") return XMLMember(1);
    else if(tag=="aDouble") return XMLMember(2);
    return AbstractLine::xml_member(tag, attributes, context)+3;

For the arguments of this function use Macro XML_MEMBER_ARGS.

Reimplemented from QGpCoreTools::XMLClass.

References MSG_ID, QGpCoreTools::tr(), TRACE, and QGpCoreTools::XMLClass::xml_tagName().

{
  TRACE;
  Q_UNUSED(attributes);
  Q_UNUSED(context);
  if(tag=="xmlVersion") return XMLMember(0);
  else if(tag=="libVersion") return XMLMember(1);
  else if(tag=="type") return XMLMember(2);
  else if(_currentObject) {
    if(tag==_currentObject->xml_tagName()) {
      return XMLMember(const_cast<XMLClass *>(_currentObject));
    } else {
      Message::warning(MSG_ID, tr("Parsing Scifig XML"), tr("The XML information is for object of type %1. "
                           "The expected type is %2.").arg(tag.toString()). arg(_currentObject->xml_tagName()),
                           true);
      return XMLMember(XMLMember::Unknown);
    }
  } else {
    return XMLMember(XMLMember::Unknown);
  }
}

Re-implement this function to offer XML restore properties support to your class.

From memberID set the corresponding property with value content. The map of attributes is given as a supplementary information (not useful in all cases).

For a general case:

  Q_UNUSED(attributes);
  double val=content.toDouble();
  switch (memberID) {
  case 0:
    _x1=val;
    return true;
  case 1:
    _y1=val;
    return true;
  case 2:
    _x2=val;
    return true;
  case 3:
    _y2=val;
    return true;
  default:
    return false;
  }

For classes inheriting other classes (see also xml_member())

  switch (memberID) {
  case 0:
    _anInteger=content.toString();
    return true;
  case 1:
    _aString=content.toInt();
    return true;
  case 2:
    _aDouble=content.toDouble();
    return true;
  default:
    return AbstractLine::xml_setProperty(memberID-3, map, content);

For the arguments of this function use Macro XML_SETPROPERTY_ARGS.

Reimplemented from QGpCoreTools::XMLClass.

References Data, QGpCoreTools::endl(), Layer, MakeUp, None, Page, QGpCoreTools::tr(), and TRACE.

{
  TRACE;
  Q_UNUSED(tag);
  Q_UNUSED(attributes);
  Q_UNUSED(context);
  switch (memberID) {
  case 0:
    // left here to avoid error when reading old SciFigs files
    return true;
  case 1: {
      Version v(content.toString());
      static const Version vRef(SCIFIGS_VERSION);
      if(v>vRef) {
        App::stream() << tr("This file was generated by SciFigs %1, which is more recent\n"
                      "than your current version %2.\n"
                      "Upgrading might be necessary.").arg(content.toString()).arg(SCIFIGS_VERSION) << endl;
      }
      _currentFileVersion=content.toString();
      return true;
    }
  case 2: {
      FileType fileType=None;
      if(content=="MakeUp") fileType=MakeUp;
      else if(content=="Data") fileType=Data;
      else if(content=="Layer") fileType=Layer;
      else if(content=="Page") fileType=Page;
      if(fileType!=_currentFile) {
        if(fileType==Data && _currentFile==Layer) { // Compatibility: before 20110106, layer is saved as data
          return true;
        }
        App::stream() << tr("No information to restore from file type %1").arg(content.toString()) << endl;
        return false;
      }
    }
    return true;
  default:
    return false;
  }
}
virtual const QString& SciFigs::XMLSciFigs::xml_tagName ( ) const [inline, virtual]

Implements QGpCoreTools::XMLClass.

{return xmlSciFigsTag;}
void SciFigs::XMLSciFigs::xml_writeChildren ( XML_WRITECHILDREN_ARGS  ) const [protected, virtual]

Description still missing

Reimplemented from QGpCoreTools::XMLClass.

References QGpCoreTools::XMLSaveAttributes::add(), QGpCoreTools::endl(), PageHeader, TRACE, QGpCoreTools::XMLClass::xml_save(), and QGpCoreTools::XMLClass::xml_tagName().

{
  TRACE;
  /* The name is not put in the attribute as there is always only one
     child in this context */
  if(_currentObject) {
    if((_currentFile & PageHeader) && _currentObject->xml_tagName()!="GraphicSheet") {
      s << s.indent() << "<GraphicSheet>\n";
      s.incrementIndent();
      static const QString key("objectName");
      XMLSaveAttributes att;
      att.add(key);
      _currentObject->xml_save(s, context, att);
      s.decrementIndent();
      s << s.indent() << "</GraphicSheet>" << endl;
    } else {
      _currentObject->xml_save(s, context);
    }
  }
}

Description still missing

Reimplemented from QGpCoreTools::XMLClass.

References Data, Layer, MakeUp, None, Page, TRACE, and QGpCoreTools::XMLClass::writeProperty().

{
  TRACE;
  Q_UNUSED(context);
  writeProperty(s, "libVersion", QString(SCIFIGS_VERSION));
  switch (_currentFile & Page) {
  case None:
    writeProperty(s, "type", QString("None"));
    break;
  case MakeUp:
    writeProperty(s, "type", QString("MakeUp"));
    break;
  case Data:
    writeProperty(s, "type", QString("Data"));
    break;
  case Layer:
    writeProperty(s, "type", QString("Layer"));
    break;
  case Page:
    writeProperty(s, "type", QString("Page"));
    break;
  }
}

Member Data Documentation

const QString SciFigs::XMLSciFigs::xmlSciFigsTag = "SciFigs" [static]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines