data.h

00001 
00002 /***************************************************************************
00003  *   This file is part of Aspect, a simple PEC tool.                       *
00004  *                                                                         *
00005  *   Copyright (C) 2007 by Wolfgang Hoffmann <woho@woho.de>                *
00006  *                                                                         *
00007  *   This program is free software, licensed under the GPL v2.             *
00008  *   See the file COPYING for more details.                                *
00009  ***************************************************************************/
00010 
00011 
00012 #ifndef ASPECT_DATA_H
00013 #define ASPECT_DATA_H
00014 
00015 
00016 #include <QList>
00017 #include <QString>
00018 #include <QVector>
00019 
00020 
00021 class IProgress
00022     {
00023 public:
00024     virtual ~IProgress() {};
00025     virtual void setText(const QString &qsText) = 0;
00026     virtual bool setValue(double dfValue) = 0;
00027     };
00028 
00029 
00030 class PecSample
00031     {
00032 public:
00033     enum Val { keep = 0, faster = 1, slower = 2, reset = 3 };
00034 
00035     static int val2Int(Val eVal);
00036     static Val int2Val(int nVal);
00037     static int val2Acc(Val eVal);
00038     static Val acc2Val(int nAcc);
00039 
00040     PecSample();
00041     PecSample(Val eVal);
00042     PecSample(Val eVal, int nAcc, int nSpd, int nPos);
00043 
00044     Val m_eVal;
00045     int m_nAcc;
00046     int m_nSpd;
00047     int m_nPos;
00048     };
00049 
00050 class PecData
00051     {
00052 public:
00053     static const int c_nRowNum = 256;
00054     static const int c_nRowGen = 4;
00055     static const int c_nAggressNum = 15;
00056     static const int c_nFactorNum = 15;
00057     enum Traversal { forward = 1, backward = -1 };
00058 
00059     PecData();
00060     void clear();
00061 
00062     Traversal traversal() const;
00063     void setTraversal(Traversal eDirection);
00064 
00065     int factor() const;
00066     int aggress() const;
00067     int fileFactorAggress() const;
00068     const PecSample &operator[](int nRow) const;
00069     PecSample::Val value(int nRow) const;
00070     int valueInt(int nRow) const;
00071     bool set(int nFactor, int nAggress, const QVector<PecSample::Val> &aTable);
00072     bool setFactor(int nFactor);
00073     bool setAggress(int nAggress);
00074     bool setFileFactorAggress(int nFactorAggress);
00075     bool setValue(int nRow, PecSample::Val eVal);
00076     void setFinish();
00077 
00078     bool calc(const QVector<double> &aProfile, double dfPecPosScale,
00079         int nAggressMin, int nAggressMax, int nFactorMax, IProgress *pProgress);
00080     bool fit(const QVector<double> &aProfile, double dfPecPosScale,
00081         IProgress *pProgress);
00082 
00083 private:
00084     void recalcGeo();
00085 
00086 private:
00087     int m_nFactor;
00088     int m_nAggress;
00089     QVector<PecSample> m_aTable;
00090     Traversal m_eTraversal;
00091     int m_nOffset;
00092     };
00093 
00094 
00095 #endif // ASPECT_DATA_H
00096 

Generated on Sun Jun 3 16:45:46 2007 for Aspect by  doxygen 1.5.1