-
Notifications
You must be signed in to change notification settings - Fork 0
/
GraphicObject.cpp
53 lines (50 loc) · 1.98 KB
/
GraphicObject.cpp
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
//---------------------------------------------------------------------------
#pragma hdrstop
#include "GraphicObject.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
//---------------------------------------------------------------------------
// Lifecycle
//---------------------------------------------------------------------------
GraphicObject::GraphicObject() : Object3D() { hidden = false; }
//---------------------------------------------------------------------------
GraphicObject::GraphicObject(const GraphicObject& src)
: Object3D(src)
{
edges.reserve(src.edges.size());
hidden = false;
for (cEdgeIt i = src.edges.begin(); i != src.edges.end(); ++i) {
Edge *newEdge = new Edge (**i);
edges.push_back (newEdge);
}
for(vertIt_const i = src.allVertices.begin(); i != src.allVertices.end(); ++i) {
Vertice *newPoint = new Vertice(*(*i).second);
allVertices[newPoint->tag] = newPoint;
}
}
//---------------------------------------------------------------------------
// Transformations
//---------------------------------------------------------------------------
void GraphicObject::applyTransform (Matrix *transform)
{
for(vertIt i = allVertices.begin(); i != allVertices.end(); ++i) {
(*i).second->applyTransform (transform);
}
}
//---------------------------------------------------------------------------
void GraphicObject::applyRotation(const double ax, const double ay)
{
for(vertIt i = allVertices.begin(); i != allVertices.end(); ++i) {
(*i).second->applyRotation (ax, ay);
}
}
//---------------------------------------------------------------------------
// Custom methods
//---------------------------------------------------------------------------
void GraphicObject::draw(Graphics::TBitmap *bmp)
{
for (EdgeIt i = edges.begin(); i != edges.end(); ++i) {
(*i)->draw (bmp->Canvas, allVertices[(*i)->tagA], allVertices[(*i)->tagB]);
}
}
//---------------------------------------------------------------------------