1
////////////////////////////////////////////////////////////////////////////////
2
/*! @file Graphicals.h Графические примитивы.
3
- Part of RANet - Research Assistant Net Library (based on ANSI C++).
4
- Copyright(C) 2000-2010, Viktor E. Bursian, St.Petersburg, Russia.
5
Viktor.Bursian@mail.ioffe.ru
6
*///////////////////////////////////////////////////////////////////////////////
11
#include "PhysValue.h"
14
//------------------------------------------------------------------------------
16
ANNOUNCE_CLASS(sPoint)
17
ANNOUNCE_CLASS(sLineSegment)
18
ANNOUNCE_CLASS(sRectangle)
20
ANNOUNCE_CLASS(sPhysPair)
21
ANNOUNCE_CLASS(sBoundaries)
23
ANNOUNCE_CLASS(sIntPoint)
24
ANNOUNCE_CLASS(sScale)
25
ANNOUNCE_CLASS(sScales)
27
ANNOUNCE_CLASS(sAppearance)
28
ANNOUNCE_CLASS(sPointAppearance)
29
ANNOUNCE_CLASS(sLineAppearance)
31
ANNOUNCE_ABSTRACT_CLASS(sGraphObject)
33
//------------------------------------------------------------------- sPoint ---
35
class RANet_EXPORT sPoint
41
sPoint (real x ,real y)
47
rsPoint operator = (rcsPoint P)
48
{ X=P.X; Y=P.Y; return *this; };
49
rsPoint operator = (rcsIntPoint P);
50
// bool operator == (rcsPoint P) const
51
// { return (X==P.X)&&(Y==P.Y); };
52
// bool operator < (rcsPoint P) const
53
// { return (X<P.X)&&(Y<P.Y); };
54
rsPoint operator += (rcsPoint P)
55
{ X+=P.X; Y+=P.Y; return *this; };
56
rsPoint operator -= (rcsPoint P)
57
{ X-=P.X; Y-=P.Y; return *this; };
58
sPoint operator + (rcsPoint P) const
59
{ return sPoint( X+P.X , Y+P.Y ); };
60
sPoint operator - (rcsPoint P) const
61
{ return sPoint( X-P.X , Y-P.Y ); };
68
//------------------------------------------------------------- sLineSegment ---
70
class RANet_EXPORT sLineSegment
77
//--------------------------------------------------------------- sRectangle ---
79
class RANet_EXPORT sRectangle
84
sRectangle (sRange x ,sRange y)
87
sRectangle (rcsRectangle B)
90
rsRectangle operator = (rcsRectangle B)
91
{ X=B.X; Y=B.Y; return *this; };
92
bool operator == (rcsRectangle B) const
93
{ return (X==B.X) && (Y==B.Y); };
94
// rsRectangle operator |= (rcsRectangle);
95
// rsRectangle operator |= (rcsPoint);
102
//---------------------------------------------------------------- sPhysPair ---
104
class RANet_EXPORT sPhysPair : public virtual sStorable
111
sPhysPair (sPhysValue x ,sPhysValue y)
114
sPhysPair (rcsPhysPair P)
115
:sStorable(),X(P.X),Y(P.Y)
117
rsPhysPair operator = (rcsPhysPair P)
118
{ X=P.X; Y=P.Y; return *this; };
119
rsPhysPair operator += (rcsPhysPair P)
120
{ X+=P.X; Y+=P.Y; return *this; };
121
rsPhysPair operator -= (rcsPhysPair P)
122
{ X-=P.X; Y-=P.Y; return *this; };
123
sPhysPair operator + (rcsPhysPair P) const
124
{ return sPhysPair( X+P.X , Y+P.Y ); };
125
sPhysPair operator - (rcsPhysPair P) const
126
{ return sPhysPair( X-P.X , Y-P.Y ); };
133
//-------------------------------------------------------------- sBoundaries ---
135
class RANet_EXPORT sBoundaries : public virtual sStorable
137
STORABLE(sBoundaries)
141
sBoundaries (sPhysRange x ,sPhysRange y)
144
sBoundaries (rcsBoundaries B)
145
:sStorable(),X(B.X),Y(B.Y)
147
rsBoundaries operator = (rcsBoundaries B)
148
{ X=B.X; Y=B.Y; return *this; };
149
bool operator == (rcsBoundaries B) const
150
{ return (X==B.X) && (Y==B.Y); };
151
// rsBoundaries operator |= (rcsBoundaries);
152
// rsBoundaries operator |= (rcsPhysPair);
159
//---------------------------------------------------------------- sIntPoint ---
161
class RANet_EXPORT sIntPoint
167
sIntPoint (int x ,int y)
170
sIntPoint (rcsIntPoint P)
173
rsIntPoint operator = (rcsIntPoint P)
174
{ X=P.X; Y=P.Y; return *this; };
175
rsIntPoint operator = (rcsPoint P)
176
{ X=Round(P.X); Y=Round(P.Y); return *this; };
177
bool operator == (rcsIntPoint P) const
178
{ return (X==P.X)&&(Y==P.Y); };
179
// bool operator < (rcsIntPoint P) const
180
// { return (X<P.X)&&(Y<P.Y); };
181
rsIntPoint operator += (rcsIntPoint P)
182
{ X+=P.X; Y+=P.Y; return *this; };
183
rsIntPoint operator -= (rcsIntPoint P)
184
{ X-=P.X; Y-=P.Y; return *this; };
185
sIntPoint operator + (rcsIntPoint P) const
186
{ return sIntPoint( X+P.X , Y+P.Y ); };
187
sIntPoint operator - (rcsIntPoint P) const
188
{ return sIntPoint( X-P.X , Y-P.Y ); };
189
int ManhattanLength () const
190
{ return abs(X)+abs(Y); };
199
inline rsPoint sPoint::operator = (rcsIntPoint P)
201
X=P.X; Y=P.Y; return *this;
205
//------------------------------------------------------------------- sScale ---
207
class RANet_EXPORT sScale
210
sScale (bool upside_down);
211
sScale (rcsPhysValue unit);
212
sScale (rcsScale scale);
213
rsScale operator = (rcsScale scale);
214
sPhysRange PhysRange () const
217
(TheRange.From * TheUnit.ArbValue()
218
,TheRange.To * TheUnit.ArbValue()
221
sPhysValue Unit () const
223
sRange Range () const
224
{ return TheRange; };
225
virtual void SetRange (sPhysRange);
226
void SetRange (rcsRange);
227
void SetRange (int from ,int to);
228
void ShiftRange (int shift);
229
real PixelValue () const
230
{ return (TheRange.To-TheRange.From)/TheSize; };
233
virtual void SetSize (int);
235
int Tr (sPhysValue) const;
236
sPhysValue Tr (int) const;
239
virtual void SetOffset (int offset)
240
{ Offset = offset; };
245
int Offset; //!< shifts discrete coordinate system
246
//!< (by halfwidth of the axis line)
251
//------------------------------------------------------------------ sScales ---
253
class RANet_EXPORT sScales
259
sScales (rcsScale x ,rcsScale y)
262
sScales (rcsScales S)
265
rsScales operator = (rcsScales S)
266
{ X=S.X; Y=S.Y; return *this; };
267
sIntPoint Tr (rcsPoint P) const
268
{ return sIntPoint(X.Tr(P.X),Y.Tr(P.Y)); };
269
sIntPoint Tr (rcsPhysPair P) const
270
{ return sIntPoint(X.Tr(P.X),Y.Tr(P.Y)); };
271
sPhysPair Tr (rcsIntPoint P) const
272
{ return sPhysPair(X.Tr(P.X),Y.Tr(P.Y)); };
279
//-------------------------------------------------------------- sAppearance ---
280
/*! Базовый класс для атрибутов внешнего вида узлов сети (цвета кривых и т.п.).
284
class RANet_EXPORT sAppearance : virtual public sStorable
286
STORABLE(sAppearance)
294
//--------------------------------------------------------- sPointAppearance ---
296
class RANet_EXPORT sPointAppearance : public sAppearance
298
STORABLE(sPointAppearance)
301
{PointSolidCircle,PointOpenCircle};
302
static const eStyle DefaultStyle;
303
static const int DefaultSize;
311
//---------------------------------------------------------- sLineAppearance ---
313
class RANet_EXPORT sLineAppearance : public sAppearance
315
STORABLE(sLineAppearance)
318
{LineSolid,LineDotted,LineDashed};
319
static const eStyle DefaultStyle;
320
static const int DefaultThickness;
329
//------------------------------------------------------------- sGraphObject ---
331
class RANet_EXPORT sGraphObject : virtual public sStorable
333
ABSTRACT_STORABLE(sGraphObject)
335
virtual sBoundaries Boundaries ();
336
virtual int Distance (rcsIntPoint position
338
virtual sString Hint () const =0;
339
virtual void SetColor (rcsColor);
342
explicit sGraphObject ()
343
:sAdam(),sStorable(),Appearance(NULL)
347
psAppearance Appearance;
350
//------------------------------------------------------------------------------