Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef PARAMETER_H
00029 #define PARAMETER_H
00030
00031 #include <QGpCoreTools.h>
00032
00033 #include "DinverCoreDLLExport.h"
00034 #include "ParamCondition.h"
00035 #include "ParameterGrid.h"
00036
00037 namespace DinverCore {
00038
00039 class DINVERCORE_EXPORT Parameter : public XMLClass
00040 {
00041 TRANSLATIONS( "Param" )
00042 public:
00043 Parameter();
00044 virtual ~Parameter();
00045
00046 uint checksum() const;
00047
00048 void setFussy(bool f) {_fussy=f;}
00049 bool isFussy() const {return _fussy;}
00050
00051 inline void getRectangularLimits(double& min, double& max) const;
00052 inline void getLimits(double& min, double& max) const;
00053 inline void getGridLimits(int& min, int& max) const;
00054 inline void getGridLimits(double& min, double& max) const;
00055 inline bool isOk() const;
00056 inline bool isOkDebug() const;
00057 bool isOkDebugVerbose() const;
00058 void conditionDiagnostic() const;
00059 void humanInfo() const;
00060
00061 void setScale(ParameterGrid::Scale s) {_grid.setScale(s);}
00062 void setPrecision(double p) {_grid.setPrecision(p);}
00063 void setMinimum(double m) {_grid.setMinimum(m);}
00064 double minimum() const {return _grid.minimum();}
00065 void setMaximum(double m) {_grid.setMaximum(m);}
00066 double maximum() const {return _grid.maximum();}
00067 bool initGrid() {return _grid.init();}
00068 bool isFixed() const {return _grid.minimum() >= _grid.maximum();}
00069
00070 void setRealValue(double val) {_value=val;}
00071 bool setRealValue(QDataStream& s);
00072 double realValue() const {return _value;}
00073 int gridCount() const {return _grid.count();}
00074 int gridValue() const {return _grid.gridValue(_value);}
00075 void setGridValue(int val) {_value=realValue(val);}
00076 void setGridValue(double val) {_value=realValue(val);}
00077 double realValue(int val) const {return _grid.realValue(val);}
00078 double realValue(double val) const {return _grid.realValue(val);}
00079 int gridValue(double val) const {return _grid.gridValue(val);}
00080
00081 void setName(QString name) {_name=name;}
00082 const QString& name() const {return _name;}
00083
00084 void setUnit(QString unit) {_unit=unit;}
00085 const QString& unit() const {return _unit;}
00086
00087 void addCondition(AbstractCondition * c);
00088 private:
00089 QString _name;
00090 QString _unit;
00091 bool _fussy;
00092 QVector<ParamCondition> _conditions;
00093 ParameterGrid _grid;
00094 double _value;
00095 protected:
00096 virtual const QString& xml_tagName() const {return xmlParamTag;}
00097 static const QString xmlParamTag;
00098 virtual void xml_writeProperties(XML_WRITEPROPERTIES_ARGS) const;
00099 virtual bool xml_setProperty(XML_SETPROPERTY_ARGS);
00100 virtual XMLMember xml_member(XML_MEMBER_ARGS);
00101 };
00102
00103 inline void Parameter::getRectangularLimits(double& min, double& max) const
00104 {
00105 min=minimum();
00106 max=maximum();
00107 }
00108
00109 inline void Parameter::getLimits(double& min, double& max) const
00110 {
00111 for(QVector<ParamCondition>::const_iterator it=_conditions.begin(); it!=_conditions.end(); ++it) {
00112 it->getLimits(min, max);
00113 }
00114 }
00115
00116 inline void Parameter::getGridLimits(int& min, int& max) const
00117 {
00118 double dmin, dmax;
00119 getRectangularLimits(dmin, dmax);
00120 getLimits(dmin, dmax);
00121 _grid.getLimits(min, max, dmin, dmax);
00122 }
00123
00124 inline void Parameter::getGridLimits(double& min, double& max) const
00125 {
00126 double dmin, dmax;
00127 getRectangularLimits(dmin, dmax);
00128 getLimits(dmin, dmax);
00129 _grid.getLimits(min, max, dmin, dmax);
00130 }
00131
00132 inline bool Parameter::isOk() const
00133 {
00134 double min, max;
00135 getRectangularLimits(min, max);
00136 getLimits(min, max);
00137 if(isFixed()) {
00138 return (_value>=min && _value<=max);
00139 } else {
00140 return (_value>min && _value<max);
00141 }
00142 }
00143
00144 inline bool Parameter::isOkDebug() const
00145 {
00146 double min, max;
00147 getRectangularLimits(min, max);
00148 getLimits(min, max);
00149 if(isFixed()) {
00150 if(_value>=min && _value<=max) return true;
00151 printf(" %lg <= %lg <= %lg ? oh nooo!\n",min,_value,max);
00152 } else {
00153 if(_value>min && _value<max) return true;
00154 printf(" %lg < %lg < %lg ? oh nooo!\n",min,_value,max);
00155 }
00156 return false;
00157 }
00158
00159 }
00160
00161 #endif // PARAMETER_H