GeopsyCore/TimeRangeParameters.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 : 2004-04-19
00022 **  Authors :
00023 **    Marc Wathelet
00024 **    Marc Wathelet (ULg, Liège, Belgium)
00025 **    Marc Wathelet (LGIT, Grenoble, France)
00026 **
00027 ***************************************************************************/
00028 
00029 #ifndef TIMERANGEPARAMETERS_H
00030 #define TIMERANGEPARAMETERS_H
00031 
00032 #include <QGpCoreTools.h>
00033 
00034 #include "GeopsyCoreDLLExport.h"
00035 #include "TimeRange.h"
00036 
00037 namespace GeopsyCore {
00038 
00039 class Signal;
00040 class StationSignals;
00041 
00042 class GEOPSYCORE_EXPORT TimeRangeParameters : public TimeRange,
00043     public AbstractParameters, public XMLClass
00044 {
00045   TRANSLATIONS("TimeRangeParameters")
00046 public:
00047   TimeRangeParameters();
00048   TimeRangeParameters(const TimeRangeParameters& o)
00049     : TimeRange(o), AbstractParameters(), XMLClass() {operator=(o);}
00050 
00051   inline void operator=(const TimeRangeParameters& o);
00052 
00053   enum Type {Absolute, Delta, Signal, Pick};
00054 
00055   void setStartType(Type t) {_startType=t;}
00056   void setStartType(const QString& t) {_startType=string2Type(t);}
00057   Type startType() const {return _startType;}
00058   QString startTypeString() const {return type2String(_startType);}
00059 
00060   void setEndType(Type t) {_endType=t;}
00061   void setEndType(const QString& t) {_endType=string2Type(t);}
00062   Type endType() const {return _endType;}
00063   QString endTypeString() const {return type2String(_endType);}
00064 
00065   const QString& startPick() const {return _startPick;}
00066   void setStartPick(const QString& p) {_startPick=p;}
00067 
00068   const QString& endPick() const {return _endPick;}
00069   void setEndPick(const QString& p) {_endPick=p;}
00070 
00071   double deltaT() const {return _deltaT;}
00072   void setDeltaT(double dt) {_deltaT=dt; setEnd(start()+_deltaT);}
00073 
00074   bool useFirstSignal() const {return _useFirstSignal;}
00075   void setUseFirstSignal(bool f) {_useFirstSignal=f;}
00076 
00077   TimeRange absoluteRange() const;
00078   TimeRange absoluteRange(const GeopsyCore::Signal * sig) const;
00079   TimeRange absoluteRange(const StationSignals * sigs) const;
00080 
00081   virtual void xml_attributes(XML_ATTRIBUTES_ARGS) const;
00082   virtual bool xml_setAttributes(XML_SETATTRIBUTES_ARGS);
00083 
00084   virtual const QString& xml_tagName() const {return xmlTimeRangeParametersTag;}
00085   static const QString xmlTimeRangeParametersTag;
00086 
00087   virtual void collectKeywords(PARAMETERS_COLLECTKEYWORDS_ARGS);
00088   virtual int keywordCount(PARAMETERS_KEYWORDCOUNT_ARGS);
00089   virtual bool setValue(PARAMETERS_SETVALUE_ARGS);
00090   virtual QString toString(PARAMETERS_TOSTRING_ARGS_DECL) const;
00091 private:
00092   static QString type2String(Type t);
00093   static Type string2Type(QString t);
00094 
00095   double absoluteStart(const GeopsyCore::Signal * sig) const;
00096   double absoluteEnd(const GeopsyCore::Signal * sig) const;
00097 
00098   QString _startPick,_endPick;
00099   double _deltaT;
00100   Type _startType:2;
00101   Type _endType:2;
00102   bool _useFirstSignal:1;
00103 };
00104 
00105 inline void TimeRangeParameters::operator=(const TimeRangeParameters& o)
00106 {
00107   TRACE;
00108   _startPick=o._startPick;
00109   _endPick=o._endPick;
00110   _deltaT=o._deltaT;
00111   _startType=o._startType;
00112   _endType=o._endType;
00113   _useFirstSignal=o._useFirstSignal;
00114   TimeRange::operator=(o);
00115 }
00116 
00117 } // namespace GeopsyCore
00118 
00119 // Allow passing TimeRangeParameters as a QVariant
00120 Q_DECLARE_METATYPE(GeopsyCore::TimeRangeParameters);
00121 
00122 #endif // TIMERANGEPARAMETERS_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines