00001 #ifndef survinfo_h
00002 #define survinfo_h
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "namedobj.h"
00017 #include "ranges.h"
00018 #include "rcol2coord.h"
00019 #include "enums.h"
00020 class ascostream;
00021 class IOPar;
00022 class CubeSampling;
00023 class LatLong2Coord;
00024
00025
00042 mClass SurveyInfo : public NamedObject
00043 {
00044
00045 mGlobal friend const SurveyInfo& SI();
00046
00047 public:
00048
00049 ~SurveyInfo();
00050 bool isValid() const { return valid_; }
00051 bool has2D() const;
00052 bool has3D() const;
00053
00054 StepInterval<int> inlRange(bool work) const;
00055 StepInterval<int> crlRange(bool work) const;
00056 const StepInterval<float>& zRange( bool work ) const;
00057 int inlStep() const;
00058 int crlStep() const;
00059 float zStep() const;
00060 float inlDistance() const;
00061 float crlDistance() const;
00062 float computeArea(const Interval<int>& inl,
00063 const Interval<int>& crl) const;
00064 float computeArea(bool work) const ;
00065
00066 Coord3 oneStepTranslation(const Coord3& planenormal) const;
00067
00068 const CubeSampling& sampling( bool work ) const
00069 { return work ? wcs_ : cs_; }
00070
00071 Coord transform( const BinID& b ) const
00072 { return b2c_.transform(b); }
00073 BinID transform(const Coord&) const;
00076 enum Unit { Second, Meter, Feet };
00077 Unit xyUnit() const;
00078 Unit zUnit() const;
00079 inline bool xyInFeet() const { return xyinfeet_;}
00080 inline bool zIsTime() const { return zistime_; }
00081 inline bool zInMeter() const { return !zistime_ &&!zinfeet_;}
00082 inline bool zInFeet() const { return !zistime_ && zinfeet_;}
00083 const char* getXYUnitString(bool withparens=true) const;
00084 const char* getZUnitString(bool withparens=true) const;
00085 float zFactor() const;
00087 static float zFactor(bool time);
00089 bool depthsInFeetByDefault() const;
00090
00091 Coord minCoord(bool work) const;
00092 Coord maxCoord(bool work) const;
00093 bool isInside(const BinID&,bool work) const;
00094 bool isReasonable(const BinID&) const;
00096 bool isReasonable(const Coord&) const;
00098 int maxNrTraces(bool work) const;
00099
00100 void checkInlRange(Interval<int>&,bool work) const;
00102 void checkCrlRange(Interval<int>&,bool work) const;
00104 void checkZRange(Interval<float>&,bool work) const;
00106 bool includes(const BinID&,const float,bool work) const;
00108
00109 void snap(BinID&,BinID direction=BinID(0,0)) const;
00111 void snapStep(BinID&,BinID direction=BinID(0,0)) const;
00113 void snapZ(float&,int direction=0) const;
00115
00116 const IOPar& pars() const { return pars_; }
00117 void putZDomain(IOPar&) const;
00118
00119
00120
00121
00122 enum Pol2D { No2D=0, Both2DAnd3D=1, Only2D=2 };
00123
00124 protected:
00125
00126 SurveyInfo();
00127 bool valid_;
00128
00129 BufferString datadir;
00130 BufferString dirname;
00131
00132 bool zistime_;
00133 bool zinfeet_;
00134 bool xyinfeet_;
00135 BufferString comment_;
00136 BufferString wsprojnm_;
00137 BufferString wspwd_;
00138 CubeSampling& cs_;
00139 CubeSampling& wcs_;
00140 IOPar& pars_;
00141
00142 RCol2Coord b2c_;
00143 LatLong2Coord& ll2c_;
00144 BinID set3binids[3];
00145 Coord set3coords[3];
00146
00147 Pol2D survdatatype_;
00148 bool survdatatypeknown_;
00149
00150 static SurveyInfo* theinst_;
00151
00152 static void deleteInstance();
00153 void handleLineRead(const BufferString&,const char*);
00154 bool wrapUpRead();
00155 void writeSpecLines(ascostream&) const;
00156
00157 void setTr(RCol2Coord::RCTransform&,const char*);
00158 void putTr(const RCol2Coord::RCTransform&,
00159 ascostream&,const char*) const;
00160
00161 private:
00162
00163
00164 friend class IOMan;
00165 friend class uiSurvey;
00166 friend class uiSurveyInfoEditor;
00167
00168 RCol2Coord::RCTransform rdxtr;
00169 RCol2Coord::RCTransform rdytr;
00170
00171 public:
00172
00173
00174
00175 void setWorkRange(const CubeSampling&);
00176 Notifier<SurveyInfo> workRangeChg;
00177
00178 const RCol2Coord& binID2Coord() const { return b2c_; }
00179 void get3Pts(Coord c[3],BinID b[2],int& xline) const;
00180 const LatLong2Coord& latlong2Coord() const { return ll2c_; }
00181 bool isClockWise() const;
00184 float computeAngleXInl() const;
00187 void setXYInFeet( bool yn=true ) { xyinfeet_ = yn; }
00188 void setZUnit(bool istime,bool infeet=false);
00189 static float defaultXYtoZScale(Unit,Unit);
00192 float zScale() const;
00196 static const char* sKeyInlRange();
00197 static const char* sKeyCrlRange();
00198 static const char* sKeyXRange();
00199 static const char* sKeyYRange();
00200 static const char* sKeyZRange();
00201 static const char* sKeyWSProjName();
00202 static const char* sKeyXYInFt();
00203 static const char* sKeyDpthInFt();
00204 static const char* sKeySurvDataType();
00205
00206 BufferString getDirName() const { return dirname; }
00207
00208 DeclareEnumUtils(Pol2D);
00209 Pol2D survDataType() const { return survdatatype_; }
00210 void setSurvDataType( Pol2D typ ) { survdatatype_ = typ; }
00211
00212 const char* comment() const { return comment_.buf(); }
00213
00214 const char* getWSProjName() const { return wsprojnm_.buf(); }
00215
00216 const char* getWSPwd() const { return wspwd_.buf(); }
00217
00218
00219
00220 SurveyInfo(const SurveyInfo&);
00221 SurveyInfo& operator =(const SurveyInfo&);
00222
00223 RCol2Coord& getBinID2Coord() const
00224 { return const_cast<SurveyInfo*>(this)->b2c_; }
00225 LatLong2Coord& getLatlong2Coord() const
00226 { return const_cast<SurveyInfo*>(this)->ll2c_; }
00227 IOPar& getPars() const
00228 { return const_cast<SurveyInfo*>(this)->pars_; }
00229
00230 bool write(const char* basedir=0) const;
00232 void savePars(const char* basedir=0) const;
00234 static SurveyInfo* read(const char*);
00235 void setRange(const CubeSampling&,bool);
00236 const char* set3Pts(const Coord c[3],const BinID b[2],int xline);
00237 void gen3Pts();
00238 void setComment( const char* s ) { comment_ = s; }
00239 void setInvalid() const;
00240
00241 void setWSProjName( const char* nm ) const
00242 { const_cast<SurveyInfo*>(this)->wsprojnm_ = nm; }
00243 void setWSPwd( const char* nm ) const
00244 { const_cast<SurveyInfo*>(this)->wspwd_ = nm; }
00245
00246 };
00247
00248
00249 mGlobal const SurveyInfo& SI();
00250
00251
00252 #endif