00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef _SV_FILE_READER_H_
00017 #define _SV_FILE_READER_H_
00018
00019 #include "layer/LayerFactory.h"
00020 #include "plugin/transform/Transform.h"
00021
00022 #include <QXmlDefaultHandler>
00023
00024 #include <map>
00025
00026 class Pane;
00027 class Model;
00028 class Document;
00029 class PlayParameters;
00030
00031 class SVFileReaderPaneCallback
00032 {
00033 public:
00034 virtual ~SVFileReaderPaneCallback();
00035 virtual Pane *addPane() = 0;
00036 virtual void setWindowSize(int width, int height) = 0;
00037 virtual void addSelection(int start, int end) = 0;
00038 };
00039
00164 class SVFileReader : public QObject, QXmlDefaultHandler
00165 {
00166 Q_OBJECT
00167
00168 public:
00169 SVFileReader(Document *document,
00170 SVFileReaderPaneCallback &callback,
00171 QString location = "");
00172 virtual ~SVFileReader();
00173
00174 void parse(const QString &xmlData);
00175 void parse(QXmlInputSource &source);
00176
00177 bool isOK();
00178 QString getErrorString() const { return m_errorString; }
00179
00180
00181 void setCurrentPane(Pane *pane) { m_currentPane = pane; }
00182
00183 virtual bool startElement(const QString &namespaceURI,
00184 const QString &localName,
00185 const QString &qName,
00186 const QXmlAttributes& atts);
00187
00188 virtual bool characters(const QString &);
00189
00190 virtual bool endElement(const QString &namespaceURI,
00191 const QString &localName,
00192 const QString &qName);
00193
00194 bool error(const QXmlParseException &exception);
00195 bool fatalError(const QXmlParseException &exception);
00196
00197 signals:
00198 void modelRegenerationFailed(QString layerName, QString transformName,
00199 QString message);
00200 void modelRegenerationWarning(QString layerName, QString transformName,
00201 QString message);
00202
00203 protected:
00204 bool readWindow(const QXmlAttributes &);
00205 bool readModel(const QXmlAttributes &);
00206 bool readView(const QXmlAttributes &);
00207 bool readLayer(const QXmlAttributes &);
00208 bool readDatasetStart(const QXmlAttributes &);
00209 bool addBinToDataset(const QXmlAttributes &);
00210 bool addPointToDataset(const QXmlAttributes &);
00211 bool addRowToDataset(const QXmlAttributes &);
00212 bool readRowData(const QString &);
00213 bool readDerivation(const QXmlAttributes &);
00214 bool readPlayParameters(const QXmlAttributes &);
00215 bool readPlugin(const QXmlAttributes &);
00216 bool readTransform(const QXmlAttributes &);
00217 bool readParameter(const QXmlAttributes &);
00218 bool readSelection(const QXmlAttributes &);
00219 bool readMeasurement(const QXmlAttributes &);
00220 void addUnaddedModels();
00221
00222 bool haveModel(int id) {
00223 return (m_models.find(id) != m_models.end()) && m_models[id];
00224 }
00225
00226 Document *m_document;
00227 SVFileReaderPaneCallback &m_paneCallback;
00228 QString m_location;
00229 Pane *m_currentPane;
00230 std::map<int, Layer *> m_layers;
00231 std::map<int, Model *> m_models;
00232 std::set<Model *> m_addedModels;
00233 std::map<int, int> m_awaitingDatasets;
00234 Layer *m_currentLayer;
00235 Model *m_currentDataset;
00236 Model *m_currentDerivedModel;
00237 int m_currentDerivedModelId;
00238 PlayParameters *m_currentPlayParameters;
00239 Transform m_currentTransform;
00240 Model *m_currentTransformSource;
00241 int m_currentTransformChannel;
00242 bool m_currentTransformIsNewStyle;
00243 QString m_datasetSeparator;
00244 bool m_inRow;
00245 bool m_inLayer;
00246 bool m_inView;
00247 bool m_inData;
00248 bool m_inSelections;
00249 int m_rowNumber;
00250 QString m_errorString;
00251 bool m_ok;
00252 };
00253
00254 #endif