~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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
////////////////////////////////////////////////////////////////////////////////
/*! @file DataTableRecord.cpp A record with a data table (as a dependence).
- Part of RANet - Research Assistant Net Library.
- Copyright(C) 2010-2017, Viktor E. Bursian, St.Petersburg, Russia.
                          Viktor_dot_Bursian_at_mail_dot_ioffe_dot_ru
*///////////////////////////////////////////////////////////////////////////////
#include "DataTableRecord.h"
//#include "Log.h"
namespace RA {
//------------------------------------------------------------------------------
//--------------------------------------------------------- sDataTableRecord ---

sDataTableRecord::~sDataTableRecord ()
{
  if( XValues ){
    delete [] XValues;  XValues=NULL;
  };
  if( YValues ){
    delete [] YValues;  YValues=NULL;
  };
}


sDataTableRecord::sDataTableRecord (int number_of_points)
    :sTableDataFunction(number_of_points)
    ,sRecord()
{
}


sDataTableRecord::sDataTableRecord (rcsPhysPair  multiplier
                                   ,int          number_of_points)
    :sTableDataFunction(multiplier,number_of_points)
    ,sRecord()
{
}


sDataTableRecord::sDataTableRecord (std::istream &  a_stream
                                   ,rcsVersion      version)
    :sTableDataFunction(a_stream,version)
    ,sRecord(a_stream,version)
{
  if( version <= sVersion(0,9) ){
    sPhysPair                 M(a_stream,version);
    TheMultiplier = M;
    a_stream.READ_INTO(TheNumberOfPoints);
    ASSERT( TheNumberOfPoints > 0 );
    XValues= new real [TheNumberOfPoints];
    YValues= new real [TheNumberOfPoints];
    realIOv14 R;
    for( int PointNo=0 ; PointNo < TheNumberOfPoints ; PointNo++ ){
      a_stream.READ_INTO(R);  XValues[PointNo]=R;
      a_stream.READ_INTO(R);  YValues[PointNo]=R;
    }
  }
}


void  sDataTableRecord::Store (std::ostream & a_stream) const
{
  sTableDataFunction::Store(a_stream);
  sRecord::Store(a_stream);
}


void  sDataTableRecord::CopyFrom (psNode  other)
{
  sRecord::CopyFrom(other);
  psDataTableRecord      Other = dynamic_cast<psDataTableRecord>(other);
  if( Other ){
    if( TheNumberOfPoints != Other->TheNumberOfPoints ){
      if( XValues ){
        delete [] XValues;  XValues = NULL;
      }
      if( YValues ){
        delete [] YValues;  YValues = NULL;
      }
      TheNumberOfPoints = Other->TheNumberOfPoints;
      if( TheNumberOfPoints > 0 ){
        XValues = new real [TheNumberOfPoints];
        YValues = new real [TheNumberOfPoints];
      }
    }
    for( int PointNo=0 ; PointNo < TheNumberOfPoints ; PointNo++ ){
      XValues[PointNo] = Other->XValues[PointNo];
      YValues[PointNo] = Other->YValues[PointNo];
    };
    MarkAsEdited();
  }
}


//sCurve::psTracer  sDataTableRecord::GetCurveTracer (rcsScales  scales) const
//{
//  return new sDataTableRecord::sTracer(this,scales);
//}


sString  sDataTableRecord::Text (eTextFormat        format
                                ,eTextDetalization  detalization)
{
  sString                     T;
  T = sFunction::Text(format,detalization);
  T += sRecord::Text(format,detalization);
  if( detalization > Laconic ){
    T += sString(" [") + TheMultiplier.Y.Units().Text(format)
        +sString("(") + TheMultiplier.X.Units().Text(format) + sString(")]");
  }
  return T;
}


void  sDataTableRecord::SetAppearance (psAppearance  appearance)
{
  QMutexLocker                BodyLocker(&BodyMutex);
  sTableDataFunction::SetAppearance(appearance);
  MarkAsEdited();
}


psMathValue  sDataTableRecord::MathValue ()
{
  QMutexLocker                BodyLocker(&BodyMutex);
  return Replica();
}


void  sDataTableRecord::SetValue (int N ,rcsPoint P)
{
  QMutexLocker                BodyLocker(&BodyMutex);
  if( (N >= 0) && (N < TheNumberOfPoints) ){
    XValues[N]=P.X;
    YValues[N]=P.Y;
//    if( ! RecalculateBoundaries )
//      LastBoundaries |= sPhysPair( P.X*Multiplier().X , P.Y*Multiplier().Y );
    RecalculateBoundaries = true;
    MarkAsEdited();
  }
}


void  sDataTableRecord::SetXValue (int N ,real  X)
{
  QMutexLocker                BodyLocker(&BodyMutex);
  if( (N >= 0) && (N < TheNumberOfPoints) ){
    XValues[N]=X;
//    if( ! RecalculateBoundaries )
//      LastBoundaries.X |= X * Multiplier().X;
    RecalculateBoundaries = true;
    MarkAsEdited();
  }
}


void  sDataTableRecord::SetYValue (int N ,real  Y)
{
  QMutexLocker                BodyLocker(&BodyMutex);
  if( (N >= 0) && (N < TheNumberOfPoints) ){
    YValues[N]=Y;
//    if( ! RecalculateBoundaries )
//      LastBoundaries.Y |= Y * Multiplier().Y;
    RecalculateBoundaries = true;
    MarkAsEdited();
  }
}

//------------------------------------------------------------------------------
} //namespace RA