crossplatform.ru

Здравствуйте, гость ( Вход | Регистрация )

История благодарностей участнику Red Devil ::: Спасибо сказали: 1 раз(а)
Дата поста: В теме: За сообщение: Спасибо сказали:
12.8.2008, 10:12 Упрощение кода
Код
class ScrTrack: public TImageClass
{
private:
    std::string m_sIniFileaame;
    int         nReadTime;          
    int         nReadDist;          
    bool         m_IsEventPicture;      
    bool         m_IsEventNamePress;    

protected:
    typedef std::vector <GEOPOINT>    GeoPointArray;
    GeoPointArray * m_pGeo;

public:
    enum GAPTYPE { GT_NONE = 0, GT_TIMEGAP, GT_DISTGAP, GT_TMDSTGAP };
    
    SubSahara * m_pSahara;
    bool         m_IsInitGaps;

public:
    ScrTrack(SubSahara* pSah): m_nReadTime(0), m_nReadDist(0), m_pGeo(0), m_pSahara(pSah), m_IsInitGaps(false),
                    bmpSymbol(NULL), m_IsEventNamePress(false), m_IsEventPicture(false) {}
    virtual ~ScrTrack() {}
    virtual void DrawClass(GRAPHIC_DEVICE& device, const CHART_SCOPE& scope, const DRAW_MODE& mode);
    virtual void LoadSymbols();
    virtual void UnloadSymbols();
    
    bool enumPossible(GeoPointArray::iterator cur, GeoPointArray::iterator next);
    bool GapNone();
    bool GapTime(GeoPointArray::iterator cur, GeoPointArray::iterator next);
    bool GapDist(GeoPointArray::iterator cur, GeoPointArray::iterator next);
    bool GapTDM(GeoPointArray::iterator cur, GeoPointArray::iterator next);
    
    bool checkStatusDist(GeoPointArray::iterator cur, GeoPointArray::iterator next);
    bool checkStatusBreak(GeoPointArray::iterator cur, GeoPointArray::iterator next);
};

bool ScrTrack::enumPossible(GeoPointArray::iterator cur, GeoPointArray::iterator next)
{
    switch(checkGaps())
    {
        case ScrTrack::GT_NONE:
            return GapNone();
            
        case ScrTrack::GT_TIMEGAP:
            return GapTime(cur, next);
            
        case ScrTrack::GT_DISTGAP:
            return GapDist(cur, next);
            
        case ScrTrack::GT_TMDSTGAP:
            return GapTDM(cur, next);
    }

    return true;
}

bool ScrTrack::GapNone()
{
    m_nReadTime = 10;
    return true;
}

bool ScrTrack::checkStatusBreak(GeoPointArray::iterator cur, GeoPointArray::iterator next)
{
    return next -> status_lat == PS_NONE || next -> status_lon == PS_NONE || cur -> status_lat == PS_NONE || cur -> status_lon == PS_NONE;
}

bool ScrTrack::checkStatusDist(GeoPointArray::iterator cur, GeoPointArray::iterator next)
{
    return next -> status_lat != PS_FAIL && next -> status_lon != PS_FAIL && cur -> status_lat != PS_FAIL
            && cur -> status_lon != PS_FAIL && next -> status_lat != PS_NODATA && next -> status_lon != PS_NODATA
            && cur -> status_lat != PS_NODATA && cur -> status_lon != PS_NODATA;
}

bool ScrTrack::GapTime(GeoPointArray::iterator cur, GeoPointArray::iterator next)
{
    if(checkStatusBreak(cur, next))
        return true;

    time_t time_diff = static_cast<time_t>(fabs(double(next -> time_marker - cur -> time_marker)));
    if(time_diff > m_nReadTime)
        return false;
    
    if(!m_IsInitGaps)
        return true;
        
    if(checkStatusDist(cur, next)
        q_calc.maxTime += time_diff;
        
    PARAMVALUE val;
    val.value     = (double)time_diff;                
    val.status     = next -> status_lat;
    x_data.time_x.push_back(val);
    
    return true;    
}

bool ScrTrack::GapDist(GeoPointArray::iterator cur, GeoPointArray::iterator next)
{
    if(checkStatusBreak(cur, next))
        return true;
    
    double pos_diff = diffDist(cur, next);
    if(pos_diff > m_nReadDist)
        return false;
    
    if(!m_IsInitGaps)
        return true;
        
    if(checkStatusDist(cur, next))
        q_calc.maxDist += pos_diff;

    PARAMVALUE val;
    val.value     = pos_diff;
    val.status     = next -> status_lat;
    x_data.dist_x.push_back(val);
    return true;
}

bool ScrTrack::GapTDM(GeoPointArray::iterator cur, GeoPointArray::iterator next)
{
    if(checkStatusBreak(cur, next))
        return true;
    
    time_t time_diff = (time_t)fabs(double(next -> time_marker - cur -> time_marker));
    double pos_diff = diffDist(cur, next);
    if(time_diff > m_nReadTime || pos_diff > m_nReadDist)
        return false;
        
    if (!m_IsInitGaps)
        return true;
        
    if(checkStatusDist(cur, next))
    {
                q_calc.maxDist += pos_diff;
                q_calc.maxTime += time_diff;
    }
    
    PARAMVALUE val;
    val.value = pos_diff;
    val.status = next -> status_lat;
    x_data.dist_x.push_back(val);
    val.value = (double)time_diff;
    x_data.time_x.push_back(val);
    
    return true;
}
AD,

RSS Текстовая версия Сейчас: 20.6.2019, 10:57