~vbursian/research-assistant/intervers

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
////////////////////////////////////////////////////////////////////////////////
/*! @file ListDataFunction.h   Function given by a list of X-Y-pairs.
- Part of RANet - Research Assistant Net Library.
- Copyright(C) 2010-2015, Viktor E. Bursian, St.Petersburg, Russia.
                          Viktor.Bursian@mail.ioffe.ru
*///////////////////////////////////////////////////////////////////////////////
#ifndef ListDataFunction_H
#define ListDataFunction_H
#include "Functions.h"
#include <list>
namespace RA {
//------------------------------------------------------------------------------

ANNOUNCE_CLASS(sListDataFunction)

//------------------------------------------------------ sListDataFunction ---
/*! An implementation of sDataFunction with the data set stored as
    a list of X-Y-pairs.

В отличие от sArrayDataFunction и от sTableDataFunction в этом типе
представления зависимости число точек заранее не задаётся, их можно добавлять.
Абциссы произвольны. При добавлении точек список автоматически сортируется по
неубыванию абцисс. Как следствие, доступ по номеру и редактирование точки не
предусмотрены.
*/
class RANet_EXPORT  sListDataFunction : public sDataFunction
{
  STORABLE(sListDataFunction)

  protected: //classes
    ANNOUNCE_CLASS(sDataPoint)

  public: //classes
    ANNOUNCE_CLASS(sTracer)
    class RANet_EXPORT  sTracer : public sCurve::sTracer
    {
      public:
                                  sTracer (pcsListDataFunction  host_curve
                                          ,rcsScales              scales    );
        virtual                   ~sTracer ()
                                    {}
      public:
        virtual bool              NextPoint ();
        virtual bool              NextLineSegment ();
      protected:
        pcsListDataFunction       TheFunction;
      private:
        sPoint                    Scaling;
        sRange                    ArbRange;
        bool                      WrongUnits;
        bool                      SegmentFingerInitiated;
        bool                      PointFingerInitiated;
        std::list<sDataPoint>::const_iterator
                                  SegmentFinger;
        std::list<sDataPoint>::const_iterator
                                  PointFinger;
    };

  public:
    virtual                   ~sListDataFunction ();
                              sListDataFunction ();
      explicit                sListDataFunction (rcsPhysPair  multiplier);
//                              sListDataFunction (rcsListDataFunction);
//    virtual psMathValue       Replica () const
//                                { return new sListDataFunction(*this); }
    virtual sString           Hint ()
                                { return sString(); }
    virtual sCurve::psTracer  GetCurveTracer (rcsScales  scales) const;
    virtual void              AddNewPoint (sPoint);
    virtual void              AddNewPoint (real  x ,real  y)
                                { AddNewPoint(sPoint(x,y)); }

  protected: //classes
    class RANet_EXPORT  sDataPoint : public sPoint
    {
      public:
                                  sDataPoint ()
                                      :sPoint()
                                    {}
                                  sDataPoint (rcsDataPoint DP)
                                      :sPoint(DP.X,DP.Y)
                                    {}
                                  sDataPoint (rcsPoint P)
                                      :sPoint(P)
                                    {}
        rsPoint                   operator = (rcsDataPoint P)
                                    { X=P.X;  Y=P.Y; return *this; }
        bool                      operator < (rcsDataPoint DP)
                                    { return ( X < DP.X ); }
    };

  protected: //fields
    bool                      Sorted;
    std::list<sDataPoint>     ThePoints;
};

//------------------------------------------------------------------------------
} //namespace RA
#endif