libPaceventsMetaInfo 2.0(r200)
Metainfo Object for .pacevents Files

PaceventsMetaInfo.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2008 by Matthias Nagl   *
00003  *   mnagl@uni-goettingen.de   *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 #ifndef PACEVENTSMETAINFO_H
00021 #define PACEVENTSMETAINFO_H
00022 
00033 #include <QtCore/QtGlobal>
00034 #include <QObject>
00035 #include <QFile>
00036 #include <QHash>
00037 #include <QMap>
00038 #include <QList>
00039 #include <QDateTime>
00040 #include <QPointer>
00041 #include <QLabel>
00042 #include <QPushButton>
00043 #include "pacDataTypes.h"
00044 
00045 #if defined(PACEVENTSMETAINFO_LIBRARY)
00046 #  define PACEVENTSMETAINFO_EXPORT Q_DECL_EXPORT
00047 #else
00048 #  define PACEVENTSMETAINFO_EXPORT Q_DECL_IMPORT
00049 #endif
00050 
00062 class PACEVENTSMETAINFO_EXPORT PaceventsMetaInfo : public QObject
00063 {
00064     Q_OBJECT
00065   public:
00066 
00068 
00072     PaceventsMetaInfo(QObject *parent = 0);
00073     PaceventsMetaInfo(QFile *paceventsfile, QObject *parent = 0);
00074     PaceventsMetaInfo(QFile *paceventsfile, bool allowChanges=false, QObject *parent = 0);
00075     ~PaceventsMetaInfo();
00076 
00083     bool processFile(QFile *paceventsfile);
00085 
00087 
00091     void setAllowChanges(bool allow);
00093 
00095 
00099     bool isValidFile() const;
00100     QString errorMessage() const;
00101     quint32 fileFormatVersion() const;
00102     quint64 fileSize() const;
00103     quint64 dataPointer() const;
00107     quint64 footerPointer() const;
00108     void setFooterPointer(quint64 pos);
00109     quint8  compressionLevel() const;
00110     quint64 eventsPerChunk() const;
00111     QDateTime startOfMeasurement() const;
00112     void setStartOfMeasurement(const QDateTime &starttime);
00113     QDateTime stopOfMeasurement() const;
00114     void setStopOfMeasurement(const QDateTime &stoptime);
00115     quint64 numOfRecords() const;
00116     void setNumOfRecords(quint64 num);
00117     quint16 numOfColumns() const;
00118     QList<Pac::DataFileColumns> columnContents() const;
00119     QList<Pac::DataFileColumType> columnTypes() const;
00123     Pac::DataFileColumType columnTypeOfContent(Pac::DataFileColumns content) const;
00128     int byteOffsetOfColumnContent(Pac::DataFileColumns content) const;
00129     quint8 numNodes() const;
00130     QList<quint8> nodeIds() const;
00134     QHash<quint8, float> nodeIdsToPhi() const;
00139     void setPhi(quint8 nid, float phi);
00143     QHash<quint8, float> nodeIdsToTheta() const;
00148     void setTheta(quint8 nid, float theta);
00149     QMap<QString, QString> setupTree() const;
00150     QString setupTreeItem(const QString &key) const;
00151     Pac::DataFileFlags flags() const;
00152     QStringList flagsStringList() const;
00153     bool stillRecording() const;
00154     void setStillRecording(bool flagstate);
00155     bool finalized() const;
00156     void setFinalized(bool flagstate);
00157     bool manuallyFinalized() const;
00158     void setManuallyFinalized(bool flagstate);
00159     bool manuallyMerged() const;
00160     void setManuallyMerged(bool flagstate);
00161     bool parametersManuallyModified() const;
00162     void setParametersManuallyModified(bool flagstate);
00163     QString finalComment() const;
00164     void setFinalComment(const QString &comment);
00165     qint32 sizeOfRecord() const;
00167 
00169 
00173     static quint8 sizeOfCol(Pac::DataFileColumType type);
00175 
00177 
00181     static QString createByteString(quint64 bytes);
00183 
00185 
00189     QWidget * metaInfoWidget();
00191 
00192   private slots:
00193     void fileIsClosed();
00194     void fileSizeChanged();
00195     void updateWidgets();
00196     void showComment();
00197     void showSetuptree();
00198 
00199   private:
00200     quint32 mainHeaderLength() const;
00201     void resetContents();
00202     bool checkIfWriteable() const;
00203     void saveOrigPos();
00204     void recoverOrigPos();
00205     void setFlags(quint8 flags);
00206 
00207     QPointer<QFile> file;
00208     bool valid;
00209     QString msg;
00210     quint64 filesize;
00211     quint32 fileformat;
00212     quint64 datapointer;
00213     quint64 footerpointer; 
00214     quint8 compressionlevel;
00215     quint64 eventsperchunk;
00216     QDateTime start, stop;
00217     quint64 numrecords;
00218     quint16 numcols;
00219     QList<Pac::DataFileColumns> colcontents;
00220     QList<Pac::DataFileColumType> coltypes;
00221     quint8 numnodes;
00222     QList<quint8> nodeids;
00223     QHash<quint8, float> nodeidstophi, nodeidstotheta;
00224     QMap<QString, QString> setuptree;
00225     Pac::DataFileFlags fileflags;
00226     quint64 fileflagpointer; 
00227     quint64 anglespointer; 
00228     QString comment;
00229     QPointer<QWidget> widget;
00230     QPointer<QLabel> fileSizeValueLabel, fileVersionValueLabel, numColumnsValueLabel, sizePerRecordValueLabel,
00231                      numRecordsValueLabel, eventsPerChunkValueLabel, startTimeValueLabel, stopTimeValueLabel,
00232                      compressionLevelValueLabel, numNodesValueLabel, flagsValueLabel;
00233     QPointer<QPushButton> commentValueButton, setuptreeValueButton;
00234     mutable qint32 recsize;
00235 
00236     bool allowchanges;
00237     quint64 origpos;
00238     mutable QHash<Pac::DataFileColumns, Pac::DataFileColumType> contentToType;
00239     mutable QHash<Pac::DataFileColumns, int> contentToOffset;
00240 };
00241 
00242 #endif
 All Classes Namespaces Files Functions Variables Enumerations Properties Friends Defines