-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGraphicNode.cpp
62 lines (53 loc) · 1.41 KB
/
GraphicNode.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
54
55
56
57
58
59
60
61
#include "GraphicManager.h"
using namespace graph_man;
GraphicNode::GraphicNode(std::weak_ptr<GraphicData>wk, coordinate siz)
{
ptr = wk;
if (!check())return;
if (siz.first != -1)
{
size = siz;
}
else
{
GetGraphSize(ptr.lock()->getdata(), &size.first, &size.second);
}
}
//#error 果たしてrot=1.0の場合は処理が軽減化されるのだろうか?
int GraphicNode::draw(coordinate position, std::pair<double, double> anchor, std::pair<double, double> ext, double rot, int trans, int flip)
{
if (!check())return -2;
return DrawRotaGraph3(position.first, position.second, size.first * anchor.first, size.second*anchor.second, ext.first, ext.second, rot, ptr.lock()->getdata(), trans, flip);
}
int GraphicNode::derivate(coordinate position, coordinate size)
{
if (!check())return -2;
int handle = DerivationGraph(position.first, position.second, size.first, size.second, ptr.lock()->getdata());
if (handle < 0)return -1;
ptr.lock()->pushch(handle);
return 0;
}
int GraphicNode::divend(coordinate divgrid, int divnum, coordinate size)
{
if (!check())return -2;
int r = 0;
for (int x = 0; x < divnum; ++x)
{
r &= derivate({ size.first * (x % divgrid.first),size.second * (x / divgrid.second) }, size);
}
return r;
}
void GraphicNode::free()
{
if (!check())return;
ptr.lock()->crush();
}
bool GraphicNode::check()
{
if (ptr.expired() || ptr.lock()->getdata() < 0)
{
size = { -1,-1 };
return false;
}
return true;
}