~vbursian/research-assistant/intervers

1 by Viktor Bursian
first usable version 0.2.0
1
////////////////////////////////////////////////////////////////////////////////
2
/*! @file Marks.cpp   Базовые классы разметки.
3
- Part of RANet - Research Assistant Net Library (based on ANSI C++).
4.40.9 by Viktor Bursian at blin-ubuntu
appearances: tidying up
4
- Copyright(C) 2000-2015, Viktor E. Bursian, St.Petersburg, Russia.
5
                          Viktor_dot_Bursian_at_mail_dot_ioffe_dot_ru
1 by Viktor Bursian
first usable version 0.2.0
6
*///////////////////////////////////////////////////////////////////////////////
7
#include "Marks.h"
2 by Viktor Bursian
version 0.3.0
8
#include "Symbols.h"
9
#include "Log.h"
1 by Viktor Bursian
first usable version 0.2.0
10
//#include "Excepts.h"
11
//#include <math.h>
12
//#include <limits>
13
namespace RA {
14
//------------------------------------------------------------------------------
15
2 by Viktor Bursian
version 0.3.0
16
//-------------------------------------------------------------------- sMark ---
17
4.40.7 by Viktor Bursian
incomplete2
18
sMark::sMark  (std::istream & a_stream ,rcsVersion  version)
4.40.9 by Viktor Bursian at blin-ubuntu
appearances: tidying up
19
    :sStorable(a_stream,version)
20
    ,sGraphObject(a_stream,version)
2 by Viktor Bursian
version 0.3.0
21
{
4.4.29 by Viktor Bursian at blin-Ubuntu
Исправлен недавно привнесённый баг в спасении атрибутов (на самом деле, это была просто недоделанная переделка). Развитие sAdminWindow. Подключены почти все модули RANet.
22
}
23
24
4.40.7 by Viktor Bursian
incomplete2
25
void  sMark::Store (std::ostream & a_stream) const
2 by Viktor Bursian
version 0.3.0
26
{
4.40.7 by Viktor Bursian
incomplete2
27
  sGraphObject::Store(a_stream);
4.3.3 by Viktor Bursian at blin-Ubuntu
Pro-files simplified. Tried to make them more appropriate for QtLinguist -- without success. Also had to rename some methods named Tr() because of lupdate, which thinks, it is a misspelled tr(), and generates annoying warnings.
28
}
2 by Viktor Bursian
version 0.3.0
29
30
//------------------------------------------------------------ sPositionMark ---
1 by Viktor Bursian
first usable version 0.2.0
31
4.40.7 by Viktor Bursian
incomplete2
32
sPositionMark::sPositionMark  (std::istream & a_stream ,rcsVersion  version)
4.40.9 by Viktor Bursian at blin-ubuntu
appearances: tidying up
33
    :sStorable(a_stream,version)
34
    ,sPhysValueNode(a_stream,version)
4.40.7 by Viktor Bursian
incomplete2
35
    ,sMark(a_stream,version)
1 by Viktor Bursian
first usable version 0.2.0
36
{
4.40.20 by Viktor Bursian at blin-ubuntu
Nightmare: programming seems to be done.
37
  if( version < sVersion(1,1) ){
38
    int Mode;
39
    a_stream.READ_INTO(Mode);
40
  }
4.3.3 by Viktor Bursian at blin-Ubuntu
Pro-files simplified. Tried to make them more appropriate for QtLinguist -- without success. Also had to rename some methods named Tr() because of lupdate, which thinks, it is a misspelled tr(), and generates annoying warnings.
41
}
1 by Viktor Bursian
first usable version 0.2.0
42
43
4.40.7 by Viktor Bursian
incomplete2
44
void  sPositionMark::Store (std::ostream & a_stream) const
1 by Viktor Bursian
first usable version 0.2.0
45
{
4.40.7 by Viktor Bursian
incomplete2
46
  sPhysValueNode::Store(a_stream);
47
  sMark::Store(a_stream);
4.3.3 by Viktor Bursian at blin-Ubuntu
Pro-files simplified. Tried to make them more appropriate for QtLinguist -- without success. Also had to rename some methods named Tr() because of lupdate, which thinks, it is a misspelled tr(), and generates annoying warnings.
48
}
1 by Viktor Bursian
first usable version 0.2.0
49
50
4.40.6 by Viktor Bursian at blin-ubuntu
incomplete
51
void  sPositionMark::SetAppearance (psAppearance  appearance)
52
{
53
  QMutexLocker                BodyLocker(&BodyMutex);
4.40.7 by Viktor Bursian
incomplete2
54
  sMark::SetAppearance(appearance);
4.40.6 by Viktor Bursian at blin-ubuntu
incomplete
55
  MarkAsEdited();
56
}
4.4.43 by Viktor Bursian at blin-Ubuntu
Приведены в порядок BasicNodes, понаставлены мьютексы. По всей иерархии изменены Text, Docket, Hint (теперь не const, берут мьютекс). Исправлен баг в AscribeAttribute. Изменён template get_from и это хорошо.
57
58
2 by Viktor Bursian
version 0.3.0
59
sString  sPositionMark::Text (eTextFormat        F
4.4.43 by Viktor Bursian at blin-Ubuntu
Приведены в порядок BasicNodes, понаставлены мьютексы. По всей иерархии изменены Text, Docket, Hint (теперь не const, берут мьютекс). Исправлен баг в AscribeAttribute. Изменён template get_from и это хорошо.
60
                             ,eTextDetalization  D)
2 by Viktor Bursian
version 0.3.0
61
{
62
  sString                     T;
63
  if( F == HTML ){
64
    T = Symbol::MarkIcon;
4.40.6 by Viktor Bursian at blin-ubuntu
incomplete
65
    if( psLineAppearance  A = dynamic_cast<psLineAppearance>(TheAppearance) ){
66
      T = sString("<font color=") + A->LineColor.HexARGB() + ">"
67
          + T
68
          + "</font>";
69
    };
2 by Viktor Bursian
version 0.3.0
70
  };
71
  return T + sPhysValueNode::Text(F,D);
4.3.3 by Viktor Bursian at blin-Ubuntu
Pro-files simplified. Tried to make them more appropriate for QtLinguist -- without success. Also had to rename some methods named Tr() because of lupdate, which thinks, it is a misspelled tr(), and generates annoying warnings.
72
}
2 by Viktor Bursian
version 0.3.0
73
4.4.29 by Viktor Bursian at blin-Ubuntu
Исправлен недавно привнесённый баг в спасении атрибутов (на самом деле, это была просто недоделанная переделка). Развитие sAdminWindow. Подключены почти все модули RANet.
74
75
void  sPositionMark::CopyFrom (psNode  other)
76
{
77
  sPhysValueNode::CopyFrom(other);
78
  psPositionMark              Other = dynamic_cast<psPositionMark>(other);
79
  if( Other ){
4.4.43 by Viktor Bursian at blin-Ubuntu
Приведены в порядок BasicNodes, понаставлены мьютексы. По всей иерархии изменены Text, Docket, Hint (теперь не const, берут мьютекс). Исправлен баг в AscribeAttribute. Изменён template get_from и это хорошо.
80
    //!@todo{Net} Копирование Appearance
81
//    if( Appearance ){
82
//      delete Appearance;  Appearance = NULL;
83
//    }
84
//    if( Other->Appearance )
85
//      Appearance = Other->Appearance->Replica();
4.4.29 by Viktor Bursian at blin-Ubuntu
Исправлен недавно привнесённый баг в спасении атрибутов (на самом деле, это была просто недоделанная переделка). Развитие sAdminWindow. Подключены почти все модули RANet.
86
    MarkAsEdited();
87
  }
88
}
89
4.40.7 by Viktor Bursian
incomplete2
90
//-------------------------------------------------- sPositionMarkAppearance ---
91
92
sPositionMarkAppearance::~sPositionMarkAppearance ()
93
{
94
}
95
96
4.40.20 by Viktor Bursian at blin-ubuntu
Nightmare: programming seems to be done.
97
sPositionMarkAppearance::sPositionMarkAppearance ()
4.40.7 by Viktor Bursian
incomplete2
98
    :sAppearance()
99
    ,sLineAppearance()
4.40.20 by Viktor Bursian at blin-ubuntu
Nightmare: programming seems to be done.
100
    ,Mode(cInfiniteLine)
4.40.7 by Viktor Bursian
incomplete2
101
    ,MarkLength(10)
102
{
103
}
104
105
106
sPositionMarkAppearance::sPositionMarkAppearance (std::istream &  a_stream
107
                                                 ,rcsVersion      version)
4.40.9 by Viktor Bursian at blin-ubuntu
appearances: tidying up
108
    :sAppearance(a_stream,version)
109
    ,sLineAppearance(a_stream,version)
4.40.7 by Viktor Bursian
incomplete2
110
{
4.40.20 by Viktor Bursian at blin-ubuntu
Nightmare: programming seems to be done.
111
  a_stream.READ_INTO(Mode);
4.40.7 by Viktor Bursian
incomplete2
112
  a_stream.READ_INTO(MarkLength);
113
}
114
115
116
void  sPositionMarkAppearance::Store (std::ostream &  a_stream) const
117
{
118
  sLineAppearance::Store(a_stream);
4.40.20 by Viktor Bursian at blin-ubuntu
Nightmare: programming seems to be done.
119
  a_stream.WRITE_FROM(Mode);
4.40.7 by Viktor Bursian
incomplete2
120
  a_stream.WRITE_FROM(MarkLength);
121
}
122
2 by Viktor Bursian
version 0.3.0
123
//------------------------------------------------------------------- sXMark ---
124
4.40.7 by Viktor Bursian
incomplete2
125
sXMark::sXMark  (std::istream & a_stream ,rcsVersion  version)
126
    :sPositionMark(a_stream,version)
2 by Viktor Bursian
version 0.3.0
127
{
4.3.3 by Viktor Bursian at blin-Ubuntu
Pro-files simplified. Tried to make them more appropriate for QtLinguist -- without success. Also had to rename some methods named Tr() because of lupdate, which thinks, it is a misspelled tr(), and generates annoying warnings.
128
}
2 by Viktor Bursian
version 0.3.0
129
130
4.40.7 by Viktor Bursian
incomplete2
131
void  sXMark::Store (std::ostream &  a_stream) const
2 by Viktor Bursian
version 0.3.0
132
{
4.40.7 by Viktor Bursian
incomplete2
133
  sPositionMark::Store(a_stream);
4.3.3 by Viktor Bursian at blin-Ubuntu
Pro-files simplified. Tried to make them more appropriate for QtLinguist -- without success. Also had to rename some methods named Tr() because of lupdate, which thinks, it is a misspelled tr(), and generates annoying warnings.
134
}
1 by Viktor Bursian
first usable version 0.2.0
135
136
137
sBoundaries  sXMark::Boundaries ()
138
{
2 by Viktor Bursian
version 0.3.0
139
  sBoundaries                 B (sPhysRange((sPhysValue)(*this)
140
                                           ,(sPhysValue)(*this))
141
                                ,sPhysRange(real_nan,real_nan,_Unitsless_)
142
                                );
143
//  RANet::Log.Put(sLog::Debug,"Graph"
144
//      ,sString("sXMark::Boundaries: ")+B.X.From().Text()+" "+B.X.To().Text());
1 by Viktor Bursian
first usable version 0.2.0
145
  return B;
4.3.3 by Viktor Bursian at blin-Ubuntu
Pro-files simplified. Tried to make them more appropriate for QtLinguist -- without success. Also had to rename some methods named Tr() because of lupdate, which thinks, it is a misspelled tr(), and generates annoying warnings.
146
}
1 by Viktor Bursian
first usable version 0.2.0
147
148
2 by Viktor Bursian
version 0.3.0
149
int  sXMark::Distance (rcsIntPoint  position
150
                      ,rcsScales    scales  )
151
{
152
  try{
9.19.1 by Viktor Bursian
fabs, abs -> std::abs
153
    return std::abs( position.X - scales.X.T((sPhysValue)(*this)) );
2 by Viktor Bursian
version 0.3.0
154
  }catch(rxRAlgebra){
155
    return std::numeric_limits<int>::max();
4.40.20 by Viktor Bursian at blin-ubuntu
Nightmare: programming seems to be done.
156
  }
4.3.3 by Viktor Bursian at blin-Ubuntu
Pro-files simplified. Tried to make them more appropriate for QtLinguist -- without success. Also had to rename some methods named Tr() because of lupdate, which thinks, it is a misspelled tr(), and generates annoying warnings.
157
}
2 by Viktor Bursian
version 0.3.0
158
159
//------------------------------------------------------------------- sYMark ---
160
4.40.7 by Viktor Bursian
incomplete2
161
sYMark::sYMark  (std::istream & a_stream ,rcsVersion  version)
162
    :sPositionMark(a_stream,version)
2 by Viktor Bursian
version 0.3.0
163
{
4.3.3 by Viktor Bursian at blin-Ubuntu
Pro-files simplified. Tried to make them more appropriate for QtLinguist -- without success. Also had to rename some methods named Tr() because of lupdate, which thinks, it is a misspelled tr(), and generates annoying warnings.
164
}
2 by Viktor Bursian
version 0.3.0
165
166
4.40.7 by Viktor Bursian
incomplete2
167
void  sYMark::Store (std::ostream & a_stream) const
2 by Viktor Bursian
version 0.3.0
168
{
4.40.7 by Viktor Bursian
incomplete2
169
  sPositionMark::Store(a_stream);
4.3.3 by Viktor Bursian at blin-Ubuntu
Pro-files simplified. Tried to make them more appropriate for QtLinguist -- without success. Also had to rename some methods named Tr() because of lupdate, which thinks, it is a misspelled tr(), and generates annoying warnings.
170
}
1 by Viktor Bursian
first usable version 0.2.0
171
172
173
sBoundaries  sYMark::Boundaries ()
174
{
2 by Viktor Bursian
version 0.3.0
175
  sBoundaries                 B (sPhysRange(real_nan,real_nan,_Unitsless_)
176
                                ,sPhysRange((sPhysValue)(*this)
177
                                           ,(sPhysValue)(*this))
178
                                );
179
//  RANet::Log.Put(sLog::Debug,"Graph"
180
//      ,sString("sYMark::Boundaries: ")+B.Y.From().Text()+" "+B.Y.To().Text());
1 by Viktor Bursian
first usable version 0.2.0
181
  return B;
4.3.3 by Viktor Bursian at blin-Ubuntu
Pro-files simplified. Tried to make them more appropriate for QtLinguist -- without success. Also had to rename some methods named Tr() because of lupdate, which thinks, it is a misspelled tr(), and generates annoying warnings.
182
}
1 by Viktor Bursian
first usable version 0.2.0
183
184
2 by Viktor Bursian
version 0.3.0
185
int  sYMark::Distance (rcsIntPoint  position
186
                      ,rcsScales    scales  )
1 by Viktor Bursian
first usable version 0.2.0
187
{
2 by Viktor Bursian
version 0.3.0
188
  try{
9.19.1 by Viktor Bursian
fabs, abs -> std::abs
189
    return std::abs( position.Y - scales.Y.T((sPhysValue)(*this)) );
2 by Viktor Bursian
version 0.3.0
190
  }catch(rxRAlgebra){
191
    return std::numeric_limits<int>::max();
4.40.20 by Viktor Bursian at blin-ubuntu
Nightmare: programming seems to be done.
192
  }
4.3.3 by Viktor Bursian at blin-Ubuntu
Pro-files simplified. Tried to make them more appropriate for QtLinguist -- without success. Also had to rename some methods named Tr() because of lupdate, which thinks, it is a misspelled tr(), and generates annoying warnings.
193
}
1 by Viktor Bursian
first usable version 0.2.0
194
2 by Viktor Bursian
version 0.3.0
195
/*
1 by Viktor Bursian
first usable version 0.2.0
196
//------------------------------------------------------------------------------
197
198
sIntervalMark::sIntervalMark (real AFrom ,real ATo)
199
    :FFrom(AFrom),FTo(ATo)
200
{
201
};
202
203
4.4.19 by Viktor Bursian at blin-Ubuntu
Переносим часть надстройки, минимально необходимую для sAdminWindow. Работает на пустой базе :-)
204
sIntervalMark::sIntervalMark  (std::istream & S)
1 by Viktor Bursian
first usable version 0.2.0
205
    :sMark(S)
206
{
207
  S.READ_INTO(FFrom);
208
  S.READ_INTO(FTo);
209
};
210
211
4.4.29 by Viktor Bursian at blin-Ubuntu
Исправлен недавно привнесённый баг в спасении атрибутов (на самом деле, это была просто недоделанная переделка). Развитие sAdminWindow. Подключены почти все модули RANet.
212
void  sIntervalMark::Store (std::ostream & S) const
1 by Viktor Bursian
first usable version 0.2.0
213
{
214
  sMark::Store(S);
215
  S.WRITE_FROM(FFrom);
216
  S.WRITE_FROM(FTo);
217
};
218
219
220
void  sIntervalMark::AssignIntrinsicContent (sNode::sPtr   NP)
221
{
222
  sMark::AssignIntrinsicContent(NP);
223
  if( NP->OwnType() <= sIntervalMark::Type ){
224
    //! @todo{Undo} sNetUndoAssignValue2nInt(sPtr(this),Value)
225
    FFrom=rsIntervalMark(*NP).FFrom;
226
    FTo=rsIntervalMark(*NP).FTo;
227
  };
228
};
229
230
4.4.43 by Viktor Bursian at blin-Ubuntu
Приведены в порядок BasicNodes, понаставлены мьютексы. По всей иерархии изменены Text, Docket, Hint (теперь не const, берут мьютекс). Исправлен баг в AscribeAttribute. Изменён template get_from и это хорошо.
231
sString  sIntervalMark::Text ()
1 by Viktor Bursian
first usable version 0.2.0
232
{
233
  sLongString                 T;
234
  T=sLongString(AnsiString(FFrom).c_str());
235
  T+=" .. ";
236
  T+=sLongString(AnsiString(FTo).c_str());
237
  return T;
238
};
239
240
//------------------------------------------------------------------------------
241
242
sNode::sPtr  sXIntervalMark::Copy () const
243
{
244
  psXIntervalMark           NewNode = new sXIntervalMark(From(),To());
245
  return sPtr(NewNode);
246
};
247
248
249
sBoundaries  sXIntervalMark::Boundaries ()
250
{
251
  sBoundaries                 B ( sPhysRange(From(),To()) ,sPhysRange() );
252
  return B;
253
};
254
255
256
int  sXIntervalMark::Distance (sPoint P
257
                              ,real XPixelValue
258
                              ,real //YPixelValue
259
                              )
260
{
261
  if( P.X < From() ){
262
    return floor((From()-P.X)/XPixelValue+0.5);
263
  }else if( P.X > To() ){
264
    return floor((P.X-To())/XPixelValue+0.5);
265
  }else{
266
    return 0;
267
  };
268
};
269
270
//------------------------------------------------------------------------------
271
272
sNode::sPtr  sYIntervalMark::Copy () const
273
{
274
  psYIntervalMark           NewNode = new sYIntervalMark(From(),To());
275
  return sPtr(NewNode);
276
};
277
278
sBoundaries  sYIntervalMark::Boundaries ()
279
{
280
  sBoundaries                 B ( sPhysRange() ,sPhysRange(From(),To()) );
281
  return B;
282
};
283
284
285
int  sYIntervalMark::Distance (sPoint P
286
                              ,real //XPixelValue
287
                              ,real YPixelValue
288
                              )
289
{
290
  if( P.Y < From() ){
291
    return floor((From()-P.Y)/YPixelValue+0.5);
292
  }else if( P.Y > To() ){
293
    return floor((P.Y-To())/YPixelValue+0.5);
294
  }else{
295
    return 0;
296
  };
297
};
298
299
//------------------------------------------------------------------------------
300
301
sNode::sPtr  sBaselineMark::Copy () const
302
{
303
  psBaselineMark              NewNode = new sBaselineMark(From(),To());
304
  return sPtr(NewNode);
305
};
306
2 by Viktor Bursian
version 0.3.0
307
*/
1 by Viktor Bursian
first usable version 0.2.0
308
//------------------------------------------------------------------------------
4.3.3 by Viktor Bursian at blin-Ubuntu
Pro-files simplified. Tried to make them more appropriate for QtLinguist -- without success. Also had to rename some methods named Tr() because of lupdate, which thinks, it is a misspelled tr(), and generates annoying warnings.
309
} //namespace RA
1 by Viktor Bursian
first usable version 0.2.0
310
311
312
313