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
|
////////////////////////////////////////////////////////////////////////////////
/*! @file DataArrayRecord.cpp A record with a data array (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 "DataArrayRecord.h"
#include "Log.h"
namespace RA {
//------------------------------------------------------------------------------
//--------------------------------------------------------- sDataArrayRecord ---
sDataArrayRecord::~sDataArrayRecord ()
{
if( Values ){
delete [] Values; Values=NULL;
}
}
sDataArrayRecord::sDataArrayRecord (int number_of_points
,real x0
,real step)
:sArrayDataFunction(number_of_points,x0,step)
,sRecord()
{
}
sDataArrayRecord::sDataArrayRecord (rcsPhysPair multiplier
,int number_of_points
,real x0
,real step)
:sArrayDataFunction(multiplier,number_of_points,x0,step)
,sRecord()
{
}
sDataArrayRecord::sDataArrayRecord (int record_no
,rcsPhysPair multiplier
,int number_of_points
,real x0
,real step)
:sArrayDataFunction(multiplier,number_of_points,x0,step)
,sRecord(record_no)
{
}
sDataArrayRecord::sDataArrayRecord (std::istream & a_stream
,rcsVersion version)
:sArrayDataFunction(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 );
realIOv14 R;
a_stream.READ_INTO(R); TheX0=R;
a_stream.READ_INTO(R); TheStep=R;
Values= new real [TheNumberOfPoints];
for( int PointNo=0 ; PointNo < TheNumberOfPoints ; PointNo++ ){
a_stream.READ_INTO(R); Values[PointNo]=R;
}
}
}
void sDataArrayRecord::Store (std::ostream & a_stream) const
{
sArrayDataFunction::Store(a_stream);
sRecord::Store(a_stream);
}
void sDataArrayRecord::CopyFrom (psNode other)
{
sRecord::CopyFrom(other);
psDataArrayRecord Other = dynamic_cast<psDataArrayRecord>(other);
if( Other ){
if( TheNumberOfPoints != Other->TheNumberOfPoints ){
if( Values ){
delete [] Values; Values = NULL;
}
TheNumberOfPoints = Other->TheNumberOfPoints;
if( TheNumberOfPoints > 0 )
Values = new real [TheNumberOfPoints];
}
TheX0 = Other->TheX0;
TheStep = Other->TheStep;
for( int PointNo=0 ; PointNo < TheNumberOfPoints ; PointNo++ ){
Values[PointNo]=Other->Values[PointNo];
};
MarkAsEdited();
}
}
sString sDataArrayRecord::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 sDataArrayRecord::SetAppearance (psAppearance appearance)
{
QMutexLocker BodyLocker(&BodyMutex);
sArrayDataFunction::SetAppearance(appearance);
MarkAsEdited();
}
psMathValue sDataArrayRecord::MathValue ()
{
QMutexLocker BodyLocker(&BodyMutex);
return Replica();
}
void sDataArrayRecord::SetValue (int N ,real V)
{
QMutexLocker BodyLocker(&BodyMutex);
if( (N >= 0) && (N < TheNumberOfPoints) ){
Values[N]=V;
// if( ! RecalculateBoundaries )
// LastBoundaries.Y |= V * Multiplier().Y;
RecalculateBoundaries = true;
MarkAsEdited();
}
}
//------------------------------------------------------------------------------
} //namespace RA
|