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 : 2003-12-24 00022 ** Authors : 00023 ** Marc Wathelet 00024 ** Marc Wathelet (ULg, Liège, Belgium) 00025 ** Marc Wathelet (LGIT, Grenoble, France) 00026 ** 00027 ***************************************************************************/ 00028 00029 #ifndef STATIONSIGNALS_H 00030 #define STATIONSIGNALS_H 00031 00032 #include <QGpCoreTools.h> 00033 00034 #include "GeopsyCoreDLLExport.h" 00035 #include "SubSignalPool.h" 00036 00037 namespace GeopsyCore { 00038 00039 class SparseKeepSignal; 00040 00041 class GEOPSYCORE_EXPORT StationSignals 00042 { 00043 TRANSLATIONS("StationSignals") 00044 public: 00045 enum Component {UndefinedComponent=0, VerticalComponent=1, HorizontalComponent=2, AllComponent=3, 00046 AnySingleComponent=7}; 00047 Q_DECLARE_FLAGS(Components, Component) 00048 00049 StationSignals(Components c=UndefinedComponent); 00050 virtual ~StationSignals(); 00051 00052 void setComponents(Components c); 00053 00054 Components components() const {return _components;} 00055 int nComponents() const {return nComponents(_components);} 00056 static int nComponents(Components c); 00057 static Signal::Components component(int index, Components c); 00058 00059 bool addSignal(Signal * sig, QString * log=0); 00060 bool hasAllComponents(QString * log=0) const; 00061 bool contains(Signal * sig) const; 00062 static void organizeSubPool(SubSignalPool * subPool); 00063 00064 const SubSignalPool& originals(int iComp) const {return _signals[iComp];} 00065 00066 double minTime() const; 00067 double maxTime() const; 00068 00069 // General information on station deduced from first valid station 00070 Signal * firstValidSignal() const; 00071 Signal * lastValidSignal() const; 00072 inline double deltaT() const; 00073 inline double t0() const; 00074 inline QDateTime timeReference() const; 00075 inline QString name() const; 00076 inline QString nameComponent() const; 00077 inline Signal::Components component() const; 00078 inline const Point& coordinates() const; 00079 inline const Point& source() const; 00080 inline double sourceReceiverDistance() const; 00081 inline double sourceReceiverAzimuth() const; 00082 00083 SparseTimeRange timeRange(const TimeRange& r) const; 00084 void setSampling(SparseKeepSignal * keep) const; 00085 void setKeep(SparseKeepSignal * keep, const WindowingParameters& param, int stationIndex) const; 00086 protected: 00087 SubSignalPool * _signals; 00088 private: 00089 Components _components; 00090 }; 00091 00092 inline double StationSignals::deltaT() const 00093 { 00094 TRACE; 00095 Signal * sig=firstValidSignal(); 00096 return sig ? sig->deltaT() : 0.0; 00097 } 00098 00099 inline double StationSignals::t0() const 00100 { 00101 TRACE; 00102 Signal * sig=firstValidSignal(); 00103 return sig ? sig->t0() : 0.0; 00104 } 00105 00106 inline QDateTime StationSignals::timeReference() const 00107 { 00108 TRACE; 00109 Signal * sig=firstValidSignal(); 00110 return sig ? sig->timeReference() : QDateTime(); 00111 } 00112 00113 inline QString StationSignals::name() const 00114 { 00115 TRACE; 00116 Signal * sig=firstValidSignal(); 00117 return sig ? sig->name() : QString::null; 00118 } 00119 00120 inline QString StationSignals::nameComponent() const 00121 { 00122 TRACE; 00123 Signal * sig=firstValidSignal(); 00124 return sig ? sig->nameComponent() : QString::null; 00125 } 00126 00127 inline Signal::Components StationSignals::component() const 00128 { 00129 TRACE; 00130 Signal * sig=firstValidSignal(); 00131 return sig ? sig->component() : Signal::UndefinedComponent; 00132 } 00133 00134 inline const Point& StationSignals::coordinates() const 00135 { 00136 static Point dummy; 00137 Signal * sig=firstValidSignal(); 00138 return sig ? sig->receiver() : dummy; 00139 } 00140 00141 inline const Point& StationSignals::source() const 00142 { 00143 static Point dummy; 00144 Signal * sig=firstValidSignal(); 00145 return sig ? sig->source() : dummy; 00146 } 00147 00148 inline double StationSignals::sourceReceiverDistance() const 00149 { 00150 TRACE; 00151 Signal * sig=firstValidSignal(); 00152 return sig ? sig->sourceReceiverDistance() : 0.0; 00153 } 00154 00155 inline double StationSignals::sourceReceiverAzimuth() const 00156 { 00157 TRACE; 00158 Signal * sig=firstValidSignal(); 00159 return sig ? sig->sourceReceiverAzimuth() : 0.0; 00160 } 00161 00162 } // namespace GeopsyCore 00163 00164 Q_DECLARE_OPERATORS_FOR_FLAGS(GeopsyCore::StationSignals::Components) 00165 00166 #endif // STATIONSIGNALS_H