GeopsyCore/SignalHeaderObject.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of GeopsyCore.
00004 **
00005 **  This library is free software; you can redistribute it and/or
00006 **  modify it under the terms of the GNU Lesser General Public
00007 **  License as published by the Free Software Foundation; either
00008 **  version 2.1 of the License, or (at your option) any later version.
00009 **
00010 **  This file is distributed in the hope that it will be useful, but WITHOUT
00011 **  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 **  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00013 **  License for more details.
00014 **
00015 **  You should have received a copy of the GNU Lesser General Public
00016 **  License along with this library; if not, write to the Free Software
00017 **  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018 **
00019 **  See http://www.geopsy.org for more information.
00020 **
00021 **  Created: 2011-10-24
00022 **  Authors:
00023 **    Marc Wathelet (ISTerre, Grenoble, France)
00024 **
00025 ***************************************************************************/
00026 
00027 #ifndef SIGNALHEADEROBJECT_H
00028 #define SIGNALHEADEROBJECT_H
00029 
00030 #include <QtScript>
00031 
00032 #include "Signal.h"
00033 
00034 namespace GeopsyCore {
00035 
00036   class SignalHeaderObject: public QObject, public QScriptable
00037   {
00038     Q_OBJECT
00039     Q_PROPERTY(QString amplitudeUnit READ amplitudeUnit WRITE setAmplitudeUnit)
00040     Q_PROPERTY(double averageAmplitude READ averageAmplitude)
00041     Q_PROPERTY(double countPerUnit READ countPerUnit)
00042     Q_PROPERTY(double countPerVolt READ countPerVolt WRITE setCountPerVolt)
00043     Q_PROPERTY(QString component READ component WRITE setComponent)
00044     Q_PROPERTY(double deltaT READ deltaT WRITE setDeltaT)
00045     Q_PROPERTY(QString duration READ duration WRITE setDuration)
00046     Q_PROPERTY(QString endTime READ endTime WRITE setEndTime)
00047     Q_PROPERTY(QString fileFormat READ fileFormat)
00048     Q_PROPERTY(QString fileName READ fileName)
00049     Q_PROPERTY(bool headerModified READ headerModified)
00050     Q_PROPERTY(int id READ id)
00051     Q_PROPERTY(bool isOriginalFile READ isOriginalFile)
00052     Q_PROPERTY(double maximumAmplitude READ maximumAmplitude)
00053     Q_PROPERTY(QString name READ name WRITE setName)
00054     Q_PROPERTY(int nSamples READ nSamples)
00055     Q_PROPERTY(int numberInFile READ numberInFile)
00056     Q_PROPERTY(QString pointer READ pointer)
00057     Q_PROPERTY(double receiverX READ receiverX WRITE setReceiverX)
00058     Q_PROPERTY(double receiverY READ receiverY WRITE setReceiverY)
00059     Q_PROPERTY(double receiverZ READ receiverZ WRITE setReceiverZ)
00060     Q_PROPERTY(double samplingFrequency READ samplingFrequency WRITE setSamplingFrequency)
00061     Q_PROPERTY(int sampleSize READ sampleSize)
00062     Q_PROPERTY(QString shortFileName READ shortFileName)
00063     Q_PROPERTY(double sourceAzimuth READ sourceAzimuth)
00064     Q_PROPERTY(double sourceDistance READ sourceDistance)
00065     Q_PROPERTY(double sourceX READ sourceX WRITE setSourceX)
00066     Q_PROPERTY(double sourceY READ sourceY WRITE setSourceY)
00067     Q_PROPERTY(double sourceZ READ sourceZ WRITE setSourceZ)
00068     Q_PROPERTY(QString t0 READ t0 WRITE setT0)
00069     Q_PROPERTY(QString timeReference READ timeReference WRITE setTimeReference)
00070     Q_PROPERTY(QString type READ type)
00071     Q_PROPERTY(double unitPerCount READ unitPerCount)
00072     Q_PROPERTY(double unitPerVolt READ unitPerVolt WRITE setUnitPerVolt)
00073     Q_PROPERTY(double voltPerCount READ voltPerCount WRITE setVoltPerCount)
00074     Q_PROPERTY(double voltPerUnit READ voltPerUnit WRITE setVoltPerUnit)
00075   public:
00076     SignalHeaderObject(QObject * parent=0);
00077 
00078     void setAmplitudeUnit(const QString& v);
00079     void setComponent(const QString& v);
00080     void setCountPerVolt(double v);
00081     void setDeltaT(double v);
00082     void setDuration(const QString& v);
00083     void setEndTime(const QString& v);
00084     void setName(const QString& v);
00085     void setReceiverX(double v);
00086     void setReceiverY(double v);
00087     void setReceiverZ(double v);
00088     void setSamplingFrequency(double v);
00089     void setSourceX(double v);
00090     void setSourceY(double v);
00091     void setSourceZ(double v);
00092     void setT0(const QString& v);
00093     void setTimeReference(const QString& v);
00094     void setUnitPerVolt(double v);
00095     void setVoltPerCount(double v);
00096     void setVoltPerUnit(double v);
00097 
00098     QString amplitudeUnit() const {return thisSignal()->amplitudeUnitStandardName();}
00099     double averageAmplitude() const {return thisSignal()->averageAmplitude();}
00100     QString component() const {return thisSignal()->componentStandardName();}
00101     double countPerUnit() const {return thisSignal()->countPerUnit();}
00102     double countPerVolt() const {return thisSignal()->countPerVolt();}
00103     double deltaT() const {return thisSignal()->deltaT();}
00104     QString duration() const {return QString::number(thisSignal()->duration(), 'g', 20);}
00105     QString endTime() const {return QString::number(thisSignal()->endTime(), 'g', 20);}
00106     QString fileFormat() const;
00107     QString fileName() const;
00108     bool headerModified() const {return thisSignal()->isHeaderModified();}
00109     int id() const {return thisSignal()->id();}
00110     bool isOriginalFile() const {return thisSignal()->isOriginalFile();}
00111     double maximumAmplitude() const {return thisSignal()->maximumAmplitude();}
00112     QString name() const {return thisSignal()->name();}
00113     int nSamples() const {return thisSignal()->nSamples();}
00114     int numberInFile() const {return thisSignal()->numberInFile();}
00115     QString pointer() const {return QString::number((long)thisSignal(), 16);}
00116     double receiverX() const {return thisSignal()->receiver().x();}
00117     double receiverY() const {return thisSignal()->receiver().y();}
00118     double receiverZ() const {return thisSignal()->receiver().z();}
00119     double samplingFrequency() const {return thisSignal()->samplingFrequency();}
00120     int sampleSize() const {return thisSignal()->dataSizeMb();}
00121     QString shortFileName() const;
00122     double sourceAzimuth() const {return Angle::mathToGeographic(thisSignal()->sourceReceiverAzimuth());}
00123     double sourceDistance() const {return thisSignal()->sourceReceiverDistance();}
00124     double sourceX() const {return thisSignal()->source().x();}
00125     double sourceY() const {return thisSignal()->source().y();}
00126     double sourceZ() const {return thisSignal()->source().z();}
00127     QString t0() const {return QString::number(thisSignal()->t0(), 'g', 20);}
00128     QString timeReference() const {return thisSignal()->timeReferenceString();}
00129     QString type() const {return Signal::typeString(thisSignal()->type());}
00130     double unitPerCount() const {return thisSignal()->unitPerCount();}
00131     double unitPerVolt() const {return thisSignal()->unitPerVolt();}
00132     double voltPerCount() const {return thisSignal()->voltPerCount();}
00133     double voltPerUnit() const {return thisSignal()->voltPerUnit();}
00134   signals:
00135     void dataChanged(Signal * sig);
00136   private:
00137     inline Signal * thisSignal() const;
00138   };
00139 
00140   inline Signal * SignalHeaderObject::thisSignal() const
00141   {
00142     return qscriptvalue_cast<Signal *>(thisObject().data());
00143   }
00144 
00145 } // namespace GeopsyCore
00146 
00147 Q_DECLARE_METATYPE(GeopsyCore::Signal *)
00148 
00149 #endif // SIGNALHEADEROBJECT_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines