-
Notifications
You must be signed in to change notification settings - Fork 0
/
Edge.h
45 lines (41 loc) · 1.41 KB
/
Edge.h
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
//---------------------------------------------------------------------------
#ifndef EdgeH
#define EdgeH
#include <vcl.h>
#include "Vertice.h"
#include "Constants.h"
//---------------------------------------------------------------------------
class Edge
{
private :
TPen *pen;
public :
UnicodeString tagA;
UnicodeString tagB;
Edge (const UnicodeString&, const UnicodeString&);
Edge (const Edge&);
~Edge();
inline void setPen(TColor, int, TPenStyle);
inline void draw (TCanvas *, const Vertice *, const Vertice *);
};
//---------------------------------------------------------------------------
// Custom methods
//---------------------------------------------------------------------------
inline void Edge::setPen(TColor penColor, int penWidth, TPenStyle penStyle)
{
delete pen;
pen = new TPen;
pen->Color = penColor;
pen->Width = penWidth;
pen->Style = penStyle;
}
//---------------------------------------------------------------------------
inline void Edge::draw(TCanvas *canvas, const Vertice *a, const Vertice *b)
{
canvas->Pen = pen;
TPoint canvasCenter = TPoint(canvas->ClipRect.Width() / 2.0, canvas->ClipRect.Height() / 2.0);
canvas->PenPos = TPoint(canvasCenter.x + a->getX() * scale, canvasCenter.y - a->getY() * scale);
canvas->LineTo(canvasCenter.x + b->getX() * scale, canvasCenter.y - b->getY() * scale);
}
//---------------------------------------------------------------------------
#endif