QGpCoreWave/Resistivity1DModel.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of QGpCoreWave.
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: 2010-05-27
00022 **  Authors:
00023 **    Marc Wathelet (LGIT, Grenoble, France)
00024 **
00025 ***************************************************************************/
00026 
00027 #ifndef RESISTIVITY1DMODEL_H
00028 #define RESISTIVITY1DMODEL_H
00029 
00030 #include "QGpCoreWaveDLLExport.h"
00031 #include "GeophysicalModel.h"
00032 #include "Profile.h"
00033 
00034 namespace QGpCoreWave {
00035 
00036   class QGPCOREWAVE_EXPORT Resistivity1DModel : public GeophysicalModel, private Profile
00037   {
00038   public:
00039     Resistivity1DModel() {}
00040     Resistivity1DModel(int layerCount) : Profile() {resize(layerCount);}
00041     Resistivity1DModel(const Resistivity1DModel& o) : GeophysicalModel(), Profile() {operator=(o);}
00042     Resistivity1DModel(const Profile& o) : GeophysicalModel(), Profile() {Profile::operator=(o);}
00043 
00044     void operator=(const Resistivity1DModel& o) {Profile::operator=(o);}
00045 
00046     virtual GeophysicalModel * clone() const {return new Resistivity1DModel(*this);}
00047 
00048     int layerCount() const {return Profile::count();}
00049     virtual bool isEmpty() const {return layerCount()==0;}
00050 
00051     inline void setDepth(int i, double d) {Profile::setDepth(i, d);}
00052     inline void setResistivity(int i, double v) {Profile::setValue(i, v);}
00053 
00054     Profile profile() const;
00055     const QVector<double>& resistivities() const {return values();}
00056     QVector<double>& resistivities() {return values();}
00057     const QVector<double>& depths() const {return Profile::depths();}
00058 
00059     static QString formatHelp();
00060     virtual QString toString() const;
00061     virtual bool fromStream(QTextStream& s, QString * comments=0);
00062     virtual void toStream(QTextStream& s) const;
00063 
00064     class ResistivityContext : public GeophysicalContext
00065     {
00066     public:
00067       ResistivityContext();
00068       Resistivity1DModel * model() const {return static_cast<Resistivity1DModel *>(_model);}
00069       virtual QString helpCode() const;
00070     };
00071 
00072     virtual GeophysicalContext * expressionContext() const {return new ResistivityContext;}
00073 
00074     class ResistivityStorage : public ExpressionStorage
00075     {
00076     public:
00077       ResistivityStorage(ResistivityContext * context) {_context=context;}
00078       virtual bool isReadOnly() const {return false;}
00079     protected:
00080       ResistivityContext * _context;
00081     };
00082 
00083     class VariableN : public ResistivityStorage
00084     {
00085     public:
00086       VariableN(ResistivityContext * context) : ResistivityStorage(context) {}
00087       virtual bool isReadOnly() const {return true;}
00088       virtual QVariant value(const QString&) const;
00089       virtual void setValue(const QString&, const QVariant& ) {}
00090     };
00091 
00092     class VariableD : public ResistivityStorage
00093     {
00094     public:
00095       VariableD(ResistivityContext * context) : ResistivityStorage(context) {}
00096       virtual QVariant value(const QString& index) const;
00097       virtual void setValue(const QString&, const QVariant& );
00098     };
00099 
00100     class VariableRes : public ResistivityStorage
00101     {
00102     public:
00103       VariableRes(ResistivityContext * context) : ResistivityStorage(context) {}
00104       virtual QVariant value(const QString& index) const;
00105       virtual void setValue(const QString&, const QVariant& );
00106     };
00107   private:
00108     bool setValue(double& var, const StringSection& field, int iLayer, const QString& varName, bool optional);
00109   };
00110 
00111 } // namespace QGpCoreWave
00112 
00113 #endif // RESISTIVITY1DMODEL_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines